]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-2.9.1-3.10.0-201307092224.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-2.9.1-3.10.0-201307092224.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..3dd8184 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,18 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
247 the specified number of seconds. This is to be used if
248 your oopses keep scrolling off the screen.
249
250 + pax_nouderef [X86] disables UDEREF. Most likely needed under certain
251 + virtualization environments that don't cope well with the
252 + expand down segment used by UDEREF on X86-32 or the frequent
253 + page table updates on X86-64.
254 +
255 + pax_softmode= 0/1 to disable/enable PaX softmode on boot already.
256 +
257 + pax_extra_latent_entropy
258 + Enable a very simple form of latent entropy extraction
259 + from the first 4GB of memory as the bootmem allocator
260 + passes the memory pages to the buddy allocator.
261 +
262 pcbit= [HW,ISDN]
263
264 pcd. [PARIDE]
265 diff --git a/Makefile b/Makefile
266 index e5e3ba0..02c9b98 100644
267 --- a/Makefile
268 +++ b/Makefile
269 @@ -241,8 +241,9 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
270
271 HOSTCC = gcc
272 HOSTCXX = g++
273 -HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
274 -HOSTCXXFLAGS = -O2
275 +HOSTCFLAGS = -Wall -W -Wmissing-prototypes -Wstrict-prototypes -Wno-unused-parameter -Wno-missing-field-initializers -O2 -fomit-frame-pointer -fno-delete-null-pointer-checks
276 +HOSTCFLAGS += $(call cc-option, -Wno-empty-body)
277 +HOSTCXXFLAGS = -O2 -Wall -W -fno-delete-null-pointer-checks
278
279 # Decide whether to build built-in, modular, or both.
280 # Normally, just do built-in.
281 @@ -414,8 +415,8 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
282 # Rules shared between *config targets and build targets
283
284 # Basic helpers built in scripts/
285 -PHONY += scripts_basic
286 -scripts_basic:
287 +PHONY += scripts_basic gcc-plugins
288 +scripts_basic: gcc-plugins
289 $(Q)$(MAKE) $(build)=scripts/basic
290 $(Q)rm -f .tmp_quiet_recordmcount
291
292 @@ -576,6 +577,65 @@ else
293 KBUILD_CFLAGS += -O2
294 endif
295
296 +ifndef DISABLE_PAX_PLUGINS
297 +ifeq ($(call cc-ifversion, -ge, 0408, y), y)
298 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCXX)" "$(HOSTCXX)" "$(CC)")
299 +else
300 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCC)" "$(HOSTCXX)" "$(CC)")
301 +endif
302 +ifneq ($(PLUGINCC),)
303 +ifdef CONFIG_PAX_CONSTIFY_PLUGIN
304 +CONSTIFY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/constify_plugin.so -DCONSTIFY_PLUGIN
305 +endif
306 +ifdef CONFIG_PAX_MEMORY_STACKLEAK
307 +STACKLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/stackleak_plugin.so -DSTACKLEAK_PLUGIN
308 +STACKLEAK_PLUGIN_CFLAGS += -fplugin-arg-stackleak_plugin-track-lowest-sp=100
309 +endif
310 +ifdef CONFIG_KALLOCSTAT_PLUGIN
311 +KALLOCSTAT_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kallocstat_plugin.so
312 +endif
313 +ifdef CONFIG_PAX_KERNEXEC_PLUGIN
314 +KERNEXEC_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kernexec_plugin.so
315 +KERNEXEC_PLUGIN_CFLAGS += -fplugin-arg-kernexec_plugin-method=$(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD) -DKERNEXEC_PLUGIN
316 +KERNEXEC_PLUGIN_AFLAGS := -DKERNEXEC_PLUGIN
317 +endif
318 +ifdef CONFIG_CHECKER_PLUGIN
319 +ifeq ($(call cc-ifversion, -ge, 0406, y), y)
320 +CHECKER_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/checker_plugin.so -DCHECKER_PLUGIN
321 +endif
322 +endif
323 +COLORIZE_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/colorize_plugin.so
324 +ifdef CONFIG_PAX_SIZE_OVERFLOW
325 +SIZE_OVERFLOW_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/size_overflow_plugin.so -DSIZE_OVERFLOW_PLUGIN
326 +endif
327 +ifdef CONFIG_PAX_LATENT_ENTROPY
328 +LATENT_ENTROPY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/latent_entropy_plugin.so -DLATENT_ENTROPY_PLUGIN
329 +endif
330 +ifdef CONFIG_PAX_MEMORY_STRUCTLEAK
331 +STRUCTLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/structleak_plugin.so -DSTRUCTLEAK_PLUGIN
332 +endif
333 +GCC_PLUGINS_CFLAGS := $(CONSTIFY_PLUGIN_CFLAGS) $(STACKLEAK_PLUGIN_CFLAGS) $(KALLOCSTAT_PLUGIN_CFLAGS)
334 +GCC_PLUGINS_CFLAGS += $(KERNEXEC_PLUGIN_CFLAGS) $(CHECKER_PLUGIN_CFLAGS) $(COLORIZE_PLUGIN_CFLAGS)
335 +GCC_PLUGINS_CFLAGS += $(SIZE_OVERFLOW_PLUGIN_CFLAGS) $(LATENT_ENTROPY_PLUGIN_CFLAGS) $(STRUCTLEAK_PLUGIN_CFLAGS)
336 +GCC_PLUGINS_AFLAGS := $(KERNEXEC_PLUGIN_AFLAGS)
337 +export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGINS_AFLAGS CONSTIFY_PLUGIN
338 +ifeq ($(KBUILD_EXTMOD),)
339 +gcc-plugins:
340 + $(Q)$(MAKE) $(build)=tools/gcc
341 +else
342 +gcc-plugins: ;
343 +endif
344 +else
345 +gcc-plugins:
346 +ifeq ($(call cc-ifversion, -ge, 0405, y), y)
347 + $(error Your gcc installation does not support plugins. If the necessary headers for plugin support are missing, they should be installed. On Debian, apt-get install gcc-<ver>-plugin-dev. If you choose to ignore this error and lessen the improvements provided by this patch, re-run make with the DISABLE_PAX_PLUGINS=y argument.))
348 +else
349 + $(Q)echo "warning, your gcc version does not support plugins, you should upgrade it to gcc 4.5 at least"
350 +endif
351 + $(Q)echo "PAX_MEMORY_STACKLEAK, constification, PAX_LATENT_ENTROPY and other features will be less secure. PAX_SIZE_OVERFLOW will not be active."
352 +endif
353 +endif
354 +
355 include $(srctree)/arch/$(SRCARCH)/Makefile
356
357 ifdef CONFIG_READABLE_ASM
358 @@ -733,7 +793,7 @@ export mod_sign_cmd
359
360
361 ifeq ($(KBUILD_EXTMOD),)
362 -core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
363 +core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ grsecurity/
364
365 vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
366 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
367 @@ -782,6 +842,8 @@ endif
368
369 # The actual objects are generated when descending,
370 # make sure no implicit rule kicks in
371 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
372 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
373 $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
374
375 # Handle descending into subdirectories listed in $(vmlinux-dirs)
376 @@ -791,7 +853,7 @@ $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
377 # Error messages still appears in the original language
378
379 PHONY += $(vmlinux-dirs)
380 -$(vmlinux-dirs): prepare scripts
381 +$(vmlinux-dirs): gcc-plugins prepare scripts
382 $(Q)$(MAKE) $(build)=$@
383
384 # Store (new) KERNELRELASE string in include/config/kernel.release
385 @@ -835,6 +897,7 @@ prepare0: archprepare FORCE
386 $(Q)$(MAKE) $(build)=.
387
388 # All the preparing..
389 +prepare: KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
390 prepare: prepare0
391
392 # Generate some files
393 @@ -942,6 +1005,8 @@ all: modules
394 # using awk while concatenating to the final file.
395
396 PHONY += modules
397 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
398 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
399 modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
400 $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
401 @$(kecho) ' Building modules, stage 2.';
402 @@ -957,7 +1022,7 @@ modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
403
404 # Target to prepare building external modules
405 PHONY += modules_prepare
406 -modules_prepare: prepare scripts
407 +modules_prepare: gcc-plugins prepare scripts
408
409 # Target to install modules
410 PHONY += modules_install
411 @@ -1023,7 +1088,7 @@ MRPROPER_FILES += .config .config.old .version .old_version $(version_h) \
412 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
413 signing_key.priv signing_key.x509 x509.genkey \
414 extra_certificates signing_key.x509.keyid \
415 - signing_key.x509.signer
416 + signing_key.x509.signer tools/gcc/size_overflow_hash.h
417
418 # clean - Delete most, but leave enough to build external modules
419 #
420 @@ -1063,6 +1128,7 @@ distclean: mrproper
421 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
422 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
423 -o -name '.*.rej' \
424 + -o -name '.*.rej' -o -name '*.so' \
425 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
426 -type f -print | xargs rm -f
427
428 @@ -1223,6 +1289,8 @@ PHONY += $(module-dirs) modules
429 $(module-dirs): crmodverdir $(objtree)/Module.symvers
430 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
431
432 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
433 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
434 modules: $(module-dirs)
435 @$(kecho) ' Building modules, stage 2.';
436 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
437 @@ -1359,17 +1427,21 @@ else
438 target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
439 endif
440
441 -%.s: %.c prepare scripts FORCE
442 +%.s: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
443 +%.s: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
444 +%.s: %.c gcc-plugins prepare scripts FORCE
445 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
446 %.i: %.c prepare scripts FORCE
447 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
448 -%.o: %.c prepare scripts FORCE
449 +%.o: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
450 +%.o: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
451 +%.o: %.c gcc-plugins prepare scripts FORCE
452 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
453 %.lst: %.c prepare scripts FORCE
454 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
455 -%.s: %.S prepare scripts FORCE
456 +%.s: %.S gcc-plugins prepare scripts FORCE
457 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
458 -%.o: %.S prepare scripts FORCE
459 +%.o: %.S gcc-plugins prepare scripts FORCE
460 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
461 %.symtypes: %.c prepare scripts FORCE
462 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
463 @@ -1379,11 +1451,15 @@ endif
464 $(cmd_crmodverdir)
465 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
466 $(build)=$(build-dir)
467 -%/: prepare scripts FORCE
468 +%/: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
469 +%/: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
470 +%/: gcc-plugins prepare scripts FORCE
471 $(cmd_crmodverdir)
472 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
473 $(build)=$(build-dir)
474 -%.ko: prepare scripts FORCE
475 +%.ko: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
476 +%.ko: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
477 +%.ko: gcc-plugins prepare scripts FORCE
478 $(cmd_crmodverdir)
479 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
480 $(build)=$(build-dir) $(@:.ko=.o)
481 diff --git a/arch/alpha/include/asm/atomic.h b/arch/alpha/include/asm/atomic.h
482 index c2cbe4f..f7264b4 100644
483 --- a/arch/alpha/include/asm/atomic.h
484 +++ b/arch/alpha/include/asm/atomic.h
485 @@ -250,6 +250,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
486 #define atomic_dec(v) atomic_sub(1,(v))
487 #define atomic64_dec(v) atomic64_sub(1,(v))
488
489 +#define atomic64_read_unchecked(v) atomic64_read(v)
490 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
491 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
492 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
493 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
494 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
495 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
496 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
497 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
498 +
499 #define smp_mb__before_atomic_dec() smp_mb()
500 #define smp_mb__after_atomic_dec() smp_mb()
501 #define smp_mb__before_atomic_inc() smp_mb()
502 diff --git a/arch/alpha/include/asm/cache.h b/arch/alpha/include/asm/cache.h
503 index ad368a9..fbe0f25 100644
504 --- a/arch/alpha/include/asm/cache.h
505 +++ b/arch/alpha/include/asm/cache.h
506 @@ -4,19 +4,19 @@
507 #ifndef __ARCH_ALPHA_CACHE_H
508 #define __ARCH_ALPHA_CACHE_H
509
510 +#include <linux/const.h>
511
512 /* Bytes per L1 (data) cache line. */
513 #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_EV6)
514 -# define L1_CACHE_BYTES 64
515 # define L1_CACHE_SHIFT 6
516 #else
517 /* Both EV4 and EV5 are write-through, read-allocate,
518 direct-mapped, physical.
519 */
520 -# define L1_CACHE_BYTES 32
521 # define L1_CACHE_SHIFT 5
522 #endif
523
524 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
525 #define SMP_CACHE_BYTES L1_CACHE_BYTES
526
527 #endif
528 diff --git a/arch/alpha/include/asm/elf.h b/arch/alpha/include/asm/elf.h
529 index 968d999..d36b2df 100644
530 --- a/arch/alpha/include/asm/elf.h
531 +++ b/arch/alpha/include/asm/elf.h
532 @@ -91,6 +91,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
533
534 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x1000000)
535
536 +#ifdef CONFIG_PAX_ASLR
537 +#define PAX_ELF_ET_DYN_BASE (current->personality & ADDR_LIMIT_32BIT ? 0x10000 : 0x120000000UL)
538 +
539 +#define PAX_DELTA_MMAP_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 28)
540 +#define PAX_DELTA_STACK_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 19)
541 +#endif
542 +
543 /* $0 is set by ld.so to a pointer to a function which might be
544 registered using atexit. This provides a mean for the dynamic
545 linker to call DT_FINI functions for shared libraries that have
546 diff --git a/arch/alpha/include/asm/pgalloc.h b/arch/alpha/include/asm/pgalloc.h
547 index bc2a0da..8ad11ee 100644
548 --- a/arch/alpha/include/asm/pgalloc.h
549 +++ b/arch/alpha/include/asm/pgalloc.h
550 @@ -29,6 +29,12 @@ pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
551 pgd_set(pgd, pmd);
552 }
553
554 +static inline void
555 +pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
556 +{
557 + pgd_populate(mm, pgd, pmd);
558 +}
559 +
560 extern pgd_t *pgd_alloc(struct mm_struct *mm);
561
562 static inline void
563 diff --git a/arch/alpha/include/asm/pgtable.h b/arch/alpha/include/asm/pgtable.h
564 index 81a4342..348b927 100644
565 --- a/arch/alpha/include/asm/pgtable.h
566 +++ b/arch/alpha/include/asm/pgtable.h
567 @@ -102,6 +102,17 @@ struct vm_area_struct;
568 #define PAGE_SHARED __pgprot(_PAGE_VALID | __ACCESS_BITS)
569 #define PAGE_COPY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
570 #define PAGE_READONLY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
571 +
572 +#ifdef CONFIG_PAX_PAGEEXEC
573 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOE)
574 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
575 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
576 +#else
577 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
578 +# define PAGE_COPY_NOEXEC PAGE_COPY
579 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
580 +#endif
581 +
582 #define PAGE_KERNEL __pgprot(_PAGE_VALID | _PAGE_ASM | _PAGE_KRE | _PAGE_KWE)
583
584 #define _PAGE_NORMAL(x) __pgprot(_PAGE_VALID | __ACCESS_BITS | (x))
585 diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c
586 index 2fd00b7..cfd5069 100644
587 --- a/arch/alpha/kernel/module.c
588 +++ b/arch/alpha/kernel/module.c
589 @@ -160,7 +160,7 @@ apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab,
590
591 /* The small sections were sorted to the end of the segment.
592 The following should definitely cover them. */
593 - gp = (u64)me->module_core + me->core_size - 0x8000;
594 + gp = (u64)me->module_core_rw + me->core_size_rw - 0x8000;
595 got = sechdrs[me->arch.gotsecindex].sh_addr;
596
597 for (i = 0; i < n; i++) {
598 diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
599 index b9e37ad..44c24e7 100644
600 --- a/arch/alpha/kernel/osf_sys.c
601 +++ b/arch/alpha/kernel/osf_sys.c
602 @@ -1297,10 +1297,11 @@ SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
603 generic version except that we know how to honor ADDR_LIMIT_32BIT. */
604
605 static unsigned long
606 -arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
607 - unsigned long limit)
608 +arch_get_unmapped_area_1(struct file *filp, unsigned long addr, unsigned long len,
609 + unsigned long limit, unsigned long flags)
610 {
611 struct vm_unmapped_area_info info;
612 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
613
614 info.flags = 0;
615 info.length = len;
616 @@ -1308,6 +1309,7 @@ arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
617 info.high_limit = limit;
618 info.align_mask = 0;
619 info.align_offset = 0;
620 + info.threadstack_offset = offset;
621 return vm_unmapped_area(&info);
622 }
623
624 @@ -1340,20 +1342,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
625 merely specific addresses, but regions of memory -- perhaps
626 this feature should be incorporated into all ports? */
627
628 +#ifdef CONFIG_PAX_RANDMMAP
629 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
630 +#endif
631 +
632 if (addr) {
633 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit);
634 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(addr), len, limit, flags);
635 if (addr != (unsigned long) -ENOMEM)
636 return addr;
637 }
638
639 /* Next, try allocating at TASK_UNMAPPED_BASE. */
640 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),
641 - len, limit);
642 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(current->mm->mmap_base), len, limit, flags);
643 +
644 if (addr != (unsigned long) -ENOMEM)
645 return addr;
646
647 /* Finally, try allocating in low memory. */
648 - addr = arch_get_unmapped_area_1 (PAGE_SIZE, len, limit);
649 + addr = arch_get_unmapped_area_1 (filp, PAGE_SIZE, len, limit, flags);
650
651 return addr;
652 }
653 diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
654 index 0c4132d..88f0d53 100644
655 --- a/arch/alpha/mm/fault.c
656 +++ b/arch/alpha/mm/fault.c
657 @@ -53,6 +53,124 @@ __load_new_mm_context(struct mm_struct *next_mm)
658 __reload_thread(pcb);
659 }
660
661 +#ifdef CONFIG_PAX_PAGEEXEC
662 +/*
663 + * PaX: decide what to do with offenders (regs->pc = fault address)
664 + *
665 + * returns 1 when task should be killed
666 + * 2 when patched PLT trampoline was detected
667 + * 3 when unpatched PLT trampoline was detected
668 + */
669 +static int pax_handle_fetch_fault(struct pt_regs *regs)
670 +{
671 +
672 +#ifdef CONFIG_PAX_EMUPLT
673 + int err;
674 +
675 + do { /* PaX: patched PLT emulation #1 */
676 + unsigned int ldah, ldq, jmp;
677 +
678 + err = get_user(ldah, (unsigned int *)regs->pc);
679 + err |= get_user(ldq, (unsigned int *)(regs->pc+4));
680 + err |= get_user(jmp, (unsigned int *)(regs->pc+8));
681 +
682 + if (err)
683 + break;
684 +
685 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
686 + (ldq & 0xFFFF0000U) == 0xA77B0000U &&
687 + jmp == 0x6BFB0000U)
688 + {
689 + unsigned long r27, addr;
690 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
691 + unsigned long addrl = ldq | 0xFFFFFFFFFFFF0000UL;
692 +
693 + addr = regs->r27 + ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
694 + err = get_user(r27, (unsigned long *)addr);
695 + if (err)
696 + break;
697 +
698 + regs->r27 = r27;
699 + regs->pc = r27;
700 + return 2;
701 + }
702 + } while (0);
703 +
704 + do { /* PaX: patched PLT emulation #2 */
705 + unsigned int ldah, lda, br;
706 +
707 + err = get_user(ldah, (unsigned int *)regs->pc);
708 + err |= get_user(lda, (unsigned int *)(regs->pc+4));
709 + err |= get_user(br, (unsigned int *)(regs->pc+8));
710 +
711 + if (err)
712 + break;
713 +
714 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
715 + (lda & 0xFFFF0000U) == 0xA77B0000U &&
716 + (br & 0xFFE00000U) == 0xC3E00000U)
717 + {
718 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL;
719 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
720 + unsigned long addrl = lda | 0xFFFFFFFFFFFF0000UL;
721 +
722 + regs->r27 += ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
723 + regs->pc += 12 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
724 + return 2;
725 + }
726 + } while (0);
727 +
728 + do { /* PaX: unpatched PLT emulation */
729 + unsigned int br;
730 +
731 + err = get_user(br, (unsigned int *)regs->pc);
732 +
733 + if (!err && (br & 0xFFE00000U) == 0xC3800000U) {
734 + unsigned int br2, ldq, nop, jmp;
735 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL, resolver;
736 +
737 + addr = regs->pc + 4 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
738 + err = get_user(br2, (unsigned int *)addr);
739 + err |= get_user(ldq, (unsigned int *)(addr+4));
740 + err |= get_user(nop, (unsigned int *)(addr+8));
741 + err |= get_user(jmp, (unsigned int *)(addr+12));
742 + err |= get_user(resolver, (unsigned long *)(addr+16));
743 +
744 + if (err)
745 + break;
746 +
747 + if (br2 == 0xC3600000U &&
748 + ldq == 0xA77B000CU &&
749 + nop == 0x47FF041FU &&
750 + jmp == 0x6B7B0000U)
751 + {
752 + regs->r28 = regs->pc+4;
753 + regs->r27 = addr+16;
754 + regs->pc = resolver;
755 + return 3;
756 + }
757 + }
758 + } while (0);
759 +#endif
760 +
761 + return 1;
762 +}
763 +
764 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
765 +{
766 + unsigned long i;
767 +
768 + printk(KERN_ERR "PAX: bytes at PC: ");
769 + for (i = 0; i < 5; i++) {
770 + unsigned int c;
771 + if (get_user(c, (unsigned int *)pc+i))
772 + printk(KERN_CONT "???????? ");
773 + else
774 + printk(KERN_CONT "%08x ", c);
775 + }
776 + printk("\n");
777 +}
778 +#endif
779
780 /*
781 * This routine handles page faults. It determines the address,
782 @@ -133,8 +251,29 @@ retry:
783 good_area:
784 si_code = SEGV_ACCERR;
785 if (cause < 0) {
786 - if (!(vma->vm_flags & VM_EXEC))
787 + if (!(vma->vm_flags & VM_EXEC)) {
788 +
789 +#ifdef CONFIG_PAX_PAGEEXEC
790 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->pc)
791 + goto bad_area;
792 +
793 + up_read(&mm->mmap_sem);
794 + switch (pax_handle_fetch_fault(regs)) {
795 +
796 +#ifdef CONFIG_PAX_EMUPLT
797 + case 2:
798 + case 3:
799 + return;
800 +#endif
801 +
802 + }
803 + pax_report_fault(regs, (void *)regs->pc, (void *)rdusp());
804 + do_group_exit(SIGKILL);
805 +#else
806 goto bad_area;
807 +#endif
808 +
809 + }
810 } else if (!cause) {
811 /* Allow reads even for write-only mappings */
812 if (!(vma->vm_flags & (VM_READ | VM_WRITE)))
813 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
814 index 136f263..f471277 100644
815 --- a/arch/arm/Kconfig
816 +++ b/arch/arm/Kconfig
817 @@ -1766,7 +1766,7 @@ config ALIGNMENT_TRAP
818
819 config UACCESS_WITH_MEMCPY
820 bool "Use kernel mem{cpy,set}() for {copy_to,clear}_user()"
821 - depends on MMU
822 + depends on MMU && !PAX_MEMORY_UDEREF
823 default y if CPU_FEROCEON
824 help
825 Implement faster copy_to_user and clear_user methods for CPU
826 diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
827 index da1c77d..2ee6056 100644
828 --- a/arch/arm/include/asm/atomic.h
829 +++ b/arch/arm/include/asm/atomic.h
830 @@ -17,17 +17,35 @@
831 #include <asm/barrier.h>
832 #include <asm/cmpxchg.h>
833
834 +#ifdef CONFIG_GENERIC_ATOMIC64
835 +#include <asm-generic/atomic64.h>
836 +#endif
837 +
838 #define ATOMIC_INIT(i) { (i) }
839
840 #ifdef __KERNEL__
841
842 +#define _ASM_EXTABLE(from, to) \
843 +" .pushsection __ex_table,\"a\"\n"\
844 +" .align 3\n" \
845 +" .long " #from ", " #to"\n" \
846 +" .popsection"
847 +
848 /*
849 * On ARM, ordinary assignment (str instruction) doesn't clear the local
850 * strex/ldrex monitor on some implementations. The reason we can use it for
851 * atomic_set() is the clrex or dummy strex done on every exception return.
852 */
853 #define atomic_read(v) (*(volatile int *)&(v)->counter)
854 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
855 +{
856 + return v->counter;
857 +}
858 #define atomic_set(v,i) (((v)->counter) = (i))
859 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
860 +{
861 + v->counter = i;
862 +}
863
864 #if __LINUX_ARM_ARCH__ >= 6
865
866 @@ -42,6 +60,35 @@ static inline void atomic_add(int i, atomic_t *v)
867 int result;
868
869 __asm__ __volatile__("@ atomic_add\n"
870 +"1: ldrex %1, [%3]\n"
871 +" adds %0, %1, %4\n"
872 +
873 +#ifdef CONFIG_PAX_REFCOUNT
874 +" bvc 3f\n"
875 +"2: bkpt 0xf103\n"
876 +"3:\n"
877 +#endif
878 +
879 +" strex %1, %0, [%3]\n"
880 +" teq %1, #0\n"
881 +" bne 1b"
882 +
883 +#ifdef CONFIG_PAX_REFCOUNT
884 +"\n4:\n"
885 + _ASM_EXTABLE(2b, 4b)
886 +#endif
887 +
888 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
889 + : "r" (&v->counter), "Ir" (i)
890 + : "cc");
891 +}
892 +
893 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
894 +{
895 + unsigned long tmp;
896 + int result;
897 +
898 + __asm__ __volatile__("@ atomic_add_unchecked\n"
899 "1: ldrex %0, [%3]\n"
900 " add %0, %0, %4\n"
901 " strex %1, %0, [%3]\n"
902 @@ -60,6 +107,42 @@ static inline int atomic_add_return(int i, atomic_t *v)
903 smp_mb();
904
905 __asm__ __volatile__("@ atomic_add_return\n"
906 +"1: ldrex %1, [%3]\n"
907 +" adds %0, %1, %4\n"
908 +
909 +#ifdef CONFIG_PAX_REFCOUNT
910 +" bvc 3f\n"
911 +" mov %0, %1\n"
912 +"2: bkpt 0xf103\n"
913 +"3:\n"
914 +#endif
915 +
916 +" strex %1, %0, [%3]\n"
917 +" teq %1, #0\n"
918 +" bne 1b"
919 +
920 +#ifdef CONFIG_PAX_REFCOUNT
921 +"\n4:\n"
922 + _ASM_EXTABLE(2b, 4b)
923 +#endif
924 +
925 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
926 + : "r" (&v->counter), "Ir" (i)
927 + : "cc");
928 +
929 + smp_mb();
930 +
931 + return result;
932 +}
933 +
934 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
935 +{
936 + unsigned long tmp;
937 + int result;
938 +
939 + smp_mb();
940 +
941 + __asm__ __volatile__("@ atomic_add_return_unchecked\n"
942 "1: ldrex %0, [%3]\n"
943 " add %0, %0, %4\n"
944 " strex %1, %0, [%3]\n"
945 @@ -80,6 +163,35 @@ static inline void atomic_sub(int i, atomic_t *v)
946 int result;
947
948 __asm__ __volatile__("@ atomic_sub\n"
949 +"1: ldrex %1, [%3]\n"
950 +" subs %0, %1, %4\n"
951 +
952 +#ifdef CONFIG_PAX_REFCOUNT
953 +" bvc 3f\n"
954 +"2: bkpt 0xf103\n"
955 +"3:\n"
956 +#endif
957 +
958 +" strex %1, %0, [%3]\n"
959 +" teq %1, #0\n"
960 +" bne 1b"
961 +
962 +#ifdef CONFIG_PAX_REFCOUNT
963 +"\n4:\n"
964 + _ASM_EXTABLE(2b, 4b)
965 +#endif
966 +
967 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
968 + : "r" (&v->counter), "Ir" (i)
969 + : "cc");
970 +}
971 +
972 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
973 +{
974 + unsigned long tmp;
975 + int result;
976 +
977 + __asm__ __volatile__("@ atomic_sub_unchecked\n"
978 "1: ldrex %0, [%3]\n"
979 " sub %0, %0, %4\n"
980 " strex %1, %0, [%3]\n"
981 @@ -98,11 +210,25 @@ static inline int atomic_sub_return(int i, atomic_t *v)
982 smp_mb();
983
984 __asm__ __volatile__("@ atomic_sub_return\n"
985 -"1: ldrex %0, [%3]\n"
986 -" sub %0, %0, %4\n"
987 +"1: ldrex %1, [%3]\n"
988 +" subs %0, %1, %4\n"
989 +
990 +#ifdef CONFIG_PAX_REFCOUNT
991 +" bvc 3f\n"
992 +" mov %0, %1\n"
993 +"2: bkpt 0xf103\n"
994 +"3:\n"
995 +#endif
996 +
997 " strex %1, %0, [%3]\n"
998 " teq %1, #0\n"
999 " bne 1b"
1000 +
1001 +#ifdef CONFIG_PAX_REFCOUNT
1002 +"\n4:\n"
1003 + _ASM_EXTABLE(2b, 4b)
1004 +#endif
1005 +
1006 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1007 : "r" (&v->counter), "Ir" (i)
1008 : "cc");
1009 @@ -134,6 +260,28 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)
1010 return oldval;
1011 }
1012
1013 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *ptr, int old, int new)
1014 +{
1015 + unsigned long oldval, res;
1016 +
1017 + smp_mb();
1018 +
1019 + do {
1020 + __asm__ __volatile__("@ atomic_cmpxchg_unchecked\n"
1021 + "ldrex %1, [%3]\n"
1022 + "mov %0, #0\n"
1023 + "teq %1, %4\n"
1024 + "strexeq %0, %5, [%3]\n"
1025 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1026 + : "r" (&ptr->counter), "Ir" (old), "r" (new)
1027 + : "cc");
1028 + } while (res);
1029 +
1030 + smp_mb();
1031 +
1032 + return oldval;
1033 +}
1034 +
1035 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1036 {
1037 unsigned long tmp, tmp2;
1038 @@ -167,7 +315,17 @@ static inline int atomic_add_return(int i, atomic_t *v)
1039
1040 return val;
1041 }
1042 +
1043 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
1044 +{
1045 + return atomic_add_return(i, v);
1046 +}
1047 +
1048 #define atomic_add(i, v) (void) atomic_add_return(i, v)
1049 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
1050 +{
1051 + (void) atomic_add_return(i, v);
1052 +}
1053
1054 static inline int atomic_sub_return(int i, atomic_t *v)
1055 {
1056 @@ -182,6 +340,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1057 return val;
1058 }
1059 #define atomic_sub(i, v) (void) atomic_sub_return(i, v)
1060 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
1061 +{
1062 + (void) atomic_sub_return(i, v);
1063 +}
1064
1065 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1066 {
1067 @@ -197,6 +359,11 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1068 return ret;
1069 }
1070
1071 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
1072 +{
1073 + return atomic_cmpxchg(v, old, new);
1074 +}
1075 +
1076 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1077 {
1078 unsigned long flags;
1079 @@ -209,6 +376,10 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1080 #endif /* __LINUX_ARM_ARCH__ */
1081
1082 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
1083 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
1084 +{
1085 + return xchg(&v->counter, new);
1086 +}
1087
1088 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1089 {
1090 @@ -221,11 +392,27 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1091 }
1092
1093 #define atomic_inc(v) atomic_add(1, v)
1094 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
1095 +{
1096 + atomic_add_unchecked(1, v);
1097 +}
1098 #define atomic_dec(v) atomic_sub(1, v)
1099 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
1100 +{
1101 + atomic_sub_unchecked(1, v);
1102 +}
1103
1104 #define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0)
1105 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
1106 +{
1107 + return atomic_add_return_unchecked(1, v) == 0;
1108 +}
1109 #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0)
1110 #define atomic_inc_return(v) (atomic_add_return(1, v))
1111 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
1112 +{
1113 + return atomic_add_return_unchecked(1, v);
1114 +}
1115 #define atomic_dec_return(v) (atomic_sub_return(1, v))
1116 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
1117
1118 @@ -241,6 +428,14 @@ typedef struct {
1119 u64 __aligned(8) counter;
1120 } atomic64_t;
1121
1122 +#ifdef CONFIG_PAX_REFCOUNT
1123 +typedef struct {
1124 + u64 __aligned(8) counter;
1125 +} atomic64_unchecked_t;
1126 +#else
1127 +typedef atomic64_t atomic64_unchecked_t;
1128 +#endif
1129 +
1130 #define ATOMIC64_INIT(i) { (i) }
1131
1132 #ifdef CONFIG_ARM_LPAE
1133 @@ -257,6 +452,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1134 return result;
1135 }
1136
1137 +static inline u64 atomic64_read_unchecked(const atomic64_unchecked_t *v)
1138 +{
1139 + u64 result;
1140 +
1141 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1142 +" ldrd %0, %H0, [%1]"
1143 + : "=&r" (result)
1144 + : "r" (&v->counter), "Qo" (v->counter)
1145 + );
1146 +
1147 + return result;
1148 +}
1149 +
1150 static inline void atomic64_set(atomic64_t *v, u64 i)
1151 {
1152 __asm__ __volatile__("@ atomic64_set\n"
1153 @@ -265,6 +473,15 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1154 : "r" (&v->counter), "r" (i)
1155 );
1156 }
1157 +
1158 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1159 +{
1160 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1161 +" strd %2, %H2, [%1]"
1162 + : "=Qo" (v->counter)
1163 + : "r" (&v->counter), "r" (i)
1164 + );
1165 +}
1166 #else
1167 static inline u64 atomic64_read(const atomic64_t *v)
1168 {
1169 @@ -279,6 +496,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1170 return result;
1171 }
1172
1173 +static inline u64 atomic64_read_unchecked(atomic64_unchecked_t *v)
1174 +{
1175 + u64 result;
1176 +
1177 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1178 +" ldrexd %0, %H0, [%1]"
1179 + : "=&r" (result)
1180 + : "r" (&v->counter), "Qo" (v->counter)
1181 + );
1182 +
1183 + return result;
1184 +}
1185 +
1186 static inline void atomic64_set(atomic64_t *v, u64 i)
1187 {
1188 u64 tmp;
1189 @@ -292,6 +522,21 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1190 : "r" (&v->counter), "r" (i)
1191 : "cc");
1192 }
1193 +
1194 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1195 +{
1196 + u64 tmp;
1197 +
1198 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1199 +"1: ldrexd %0, %H0, [%2]\n"
1200 +" strexd %0, %3, %H3, [%2]\n"
1201 +" teq %0, #0\n"
1202 +" bne 1b"
1203 + : "=&r" (tmp), "=Qo" (v->counter)
1204 + : "r" (&v->counter), "r" (i)
1205 + : "cc");
1206 +}
1207 +
1208 #endif
1209
1210 static inline void atomic64_add(u64 i, atomic64_t *v)
1211 @@ -302,6 +547,36 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1212 __asm__ __volatile__("@ atomic64_add\n"
1213 "1: ldrexd %0, %H0, [%3]\n"
1214 " adds %0, %0, %4\n"
1215 +" adcs %H0, %H0, %H4\n"
1216 +
1217 +#ifdef CONFIG_PAX_REFCOUNT
1218 +" bvc 3f\n"
1219 +"2: bkpt 0xf103\n"
1220 +"3:\n"
1221 +#endif
1222 +
1223 +" strexd %1, %0, %H0, [%3]\n"
1224 +" teq %1, #0\n"
1225 +" bne 1b"
1226 +
1227 +#ifdef CONFIG_PAX_REFCOUNT
1228 +"\n4:\n"
1229 + _ASM_EXTABLE(2b, 4b)
1230 +#endif
1231 +
1232 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1233 + : "r" (&v->counter), "r" (i)
1234 + : "cc");
1235 +}
1236 +
1237 +static inline void atomic64_add_unchecked(u64 i, atomic64_unchecked_t *v)
1238 +{
1239 + u64 result;
1240 + unsigned long tmp;
1241 +
1242 + __asm__ __volatile__("@ atomic64_add_unchecked\n"
1243 +"1: ldrexd %0, %H0, [%3]\n"
1244 +" adds %0, %0, %4\n"
1245 " adc %H0, %H0, %H4\n"
1246 " strexd %1, %0, %H0, [%3]\n"
1247 " teq %1, #0\n"
1248 @@ -313,12 +588,49 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1249
1250 static inline u64 atomic64_add_return(u64 i, atomic64_t *v)
1251 {
1252 - u64 result;
1253 - unsigned long tmp;
1254 + u64 result, tmp;
1255
1256 smp_mb();
1257
1258 __asm__ __volatile__("@ atomic64_add_return\n"
1259 +"1: ldrexd %1, %H1, [%3]\n"
1260 +" adds %0, %1, %4\n"
1261 +" adcs %H0, %H1, %H4\n"
1262 +
1263 +#ifdef CONFIG_PAX_REFCOUNT
1264 +" bvc 3f\n"
1265 +" mov %0, %1\n"
1266 +" mov %H0, %H1\n"
1267 +"2: bkpt 0xf103\n"
1268 +"3:\n"
1269 +#endif
1270 +
1271 +" strexd %1, %0, %H0, [%3]\n"
1272 +" teq %1, #0\n"
1273 +" bne 1b"
1274 +
1275 +#ifdef CONFIG_PAX_REFCOUNT
1276 +"\n4:\n"
1277 + _ASM_EXTABLE(2b, 4b)
1278 +#endif
1279 +
1280 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1281 + : "r" (&v->counter), "r" (i)
1282 + : "cc");
1283 +
1284 + smp_mb();
1285 +
1286 + return result;
1287 +}
1288 +
1289 +static inline u64 atomic64_add_return_unchecked(u64 i, atomic64_unchecked_t *v)
1290 +{
1291 + u64 result;
1292 + unsigned long tmp;
1293 +
1294 + smp_mb();
1295 +
1296 + __asm__ __volatile__("@ atomic64_add_return_unchecked\n"
1297 "1: ldrexd %0, %H0, [%3]\n"
1298 " adds %0, %0, %4\n"
1299 " adc %H0, %H0, %H4\n"
1300 @@ -342,6 +654,36 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1301 __asm__ __volatile__("@ atomic64_sub\n"
1302 "1: ldrexd %0, %H0, [%3]\n"
1303 " subs %0, %0, %4\n"
1304 +" sbcs %H0, %H0, %H4\n"
1305 +
1306 +#ifdef CONFIG_PAX_REFCOUNT
1307 +" bvc 3f\n"
1308 +"2: bkpt 0xf103\n"
1309 +"3:\n"
1310 +#endif
1311 +
1312 +" strexd %1, %0, %H0, [%3]\n"
1313 +" teq %1, #0\n"
1314 +" bne 1b"
1315 +
1316 +#ifdef CONFIG_PAX_REFCOUNT
1317 +"\n4:\n"
1318 + _ASM_EXTABLE(2b, 4b)
1319 +#endif
1320 +
1321 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1322 + : "r" (&v->counter), "r" (i)
1323 + : "cc");
1324 +}
1325 +
1326 +static inline void atomic64_sub_unchecked(u64 i, atomic64_unchecked_t *v)
1327 +{
1328 + u64 result;
1329 + unsigned long tmp;
1330 +
1331 + __asm__ __volatile__("@ atomic64_sub_unchecked\n"
1332 +"1: ldrexd %0, %H0, [%3]\n"
1333 +" subs %0, %0, %4\n"
1334 " sbc %H0, %H0, %H4\n"
1335 " strexd %1, %0, %H0, [%3]\n"
1336 " teq %1, #0\n"
1337 @@ -353,18 +695,32 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1338
1339 static inline u64 atomic64_sub_return(u64 i, atomic64_t *v)
1340 {
1341 - u64 result;
1342 - unsigned long tmp;
1343 + u64 result, tmp;
1344
1345 smp_mb();
1346
1347 __asm__ __volatile__("@ atomic64_sub_return\n"
1348 -"1: ldrexd %0, %H0, [%3]\n"
1349 -" subs %0, %0, %4\n"
1350 -" sbc %H0, %H0, %H4\n"
1351 +"1: ldrexd %1, %H1, [%3]\n"
1352 +" subs %0, %1, %4\n"
1353 +" sbcs %H0, %H1, %H4\n"
1354 +
1355 +#ifdef CONFIG_PAX_REFCOUNT
1356 +" bvc 3f\n"
1357 +" mov %0, %1\n"
1358 +" mov %H0, %H1\n"
1359 +"2: bkpt 0xf103\n"
1360 +"3:\n"
1361 +#endif
1362 +
1363 " strexd %1, %0, %H0, [%3]\n"
1364 " teq %1, #0\n"
1365 " bne 1b"
1366 +
1367 +#ifdef CONFIG_PAX_REFCOUNT
1368 +"\n4:\n"
1369 + _ASM_EXTABLE(2b, 4b)
1370 +#endif
1371 +
1372 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1373 : "r" (&v->counter), "r" (i)
1374 : "cc");
1375 @@ -398,6 +754,30 @@ static inline u64 atomic64_cmpxchg(atomic64_t *ptr, u64 old, u64 new)
1376 return oldval;
1377 }
1378
1379 +static inline u64 atomic64_cmpxchg_unchecked(atomic64_unchecked_t *ptr, u64 old, u64 new)
1380 +{
1381 + u64 oldval;
1382 + unsigned long res;
1383 +
1384 + smp_mb();
1385 +
1386 + do {
1387 + __asm__ __volatile__("@ atomic64_cmpxchg_unchecked\n"
1388 + "ldrexd %1, %H1, [%3]\n"
1389 + "mov %0, #0\n"
1390 + "teq %1, %4\n"
1391 + "teqeq %H1, %H4\n"
1392 + "strexdeq %0, %5, %H5, [%3]"
1393 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1394 + : "r" (&ptr->counter), "r" (old), "r" (new)
1395 + : "cc");
1396 + } while (res);
1397 +
1398 + smp_mb();
1399 +
1400 + return oldval;
1401 +}
1402 +
1403 static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1404 {
1405 u64 result;
1406 @@ -421,21 +801,34 @@ static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1407
1408 static inline u64 atomic64_dec_if_positive(atomic64_t *v)
1409 {
1410 - u64 result;
1411 - unsigned long tmp;
1412 + u64 result, tmp;
1413
1414 smp_mb();
1415
1416 __asm__ __volatile__("@ atomic64_dec_if_positive\n"
1417 -"1: ldrexd %0, %H0, [%3]\n"
1418 -" subs %0, %0, #1\n"
1419 -" sbc %H0, %H0, #0\n"
1420 +"1: ldrexd %1, %H1, [%3]\n"
1421 +" subs %0, %1, #1\n"
1422 +" sbcs %H0, %H1, #0\n"
1423 +
1424 +#ifdef CONFIG_PAX_REFCOUNT
1425 +" bvc 3f\n"
1426 +" mov %0, %1\n"
1427 +" mov %H0, %H1\n"
1428 +"2: bkpt 0xf103\n"
1429 +"3:\n"
1430 +#endif
1431 +
1432 " teq %H0, #0\n"
1433 -" bmi 2f\n"
1434 +" bmi 4f\n"
1435 " strexd %1, %0, %H0, [%3]\n"
1436 " teq %1, #0\n"
1437 " bne 1b\n"
1438 -"2:"
1439 +"4:\n"
1440 +
1441 +#ifdef CONFIG_PAX_REFCOUNT
1442 + _ASM_EXTABLE(2b, 4b)
1443 +#endif
1444 +
1445 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1446 : "r" (&v->counter)
1447 : "cc");
1448 @@ -458,13 +851,25 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1449 " teq %0, %5\n"
1450 " teqeq %H0, %H5\n"
1451 " moveq %1, #0\n"
1452 -" beq 2f\n"
1453 +" beq 4f\n"
1454 " adds %0, %0, %6\n"
1455 -" adc %H0, %H0, %H6\n"
1456 +" adcs %H0, %H0, %H6\n"
1457 +
1458 +#ifdef CONFIG_PAX_REFCOUNT
1459 +" bvc 3f\n"
1460 +"2: bkpt 0xf103\n"
1461 +"3:\n"
1462 +#endif
1463 +
1464 " strexd %2, %0, %H0, [%4]\n"
1465 " teq %2, #0\n"
1466 " bne 1b\n"
1467 -"2:"
1468 +"4:\n"
1469 +
1470 +#ifdef CONFIG_PAX_REFCOUNT
1471 + _ASM_EXTABLE(2b, 4b)
1472 +#endif
1473 +
1474 : "=&r" (val), "+r" (ret), "=&r" (tmp), "+Qo" (v->counter)
1475 : "r" (&v->counter), "r" (u), "r" (a)
1476 : "cc");
1477 @@ -477,10 +882,13 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1478
1479 #define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
1480 #define atomic64_inc(v) atomic64_add(1LL, (v))
1481 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1LL, (v))
1482 #define atomic64_inc_return(v) atomic64_add_return(1LL, (v))
1483 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1LL, (v))
1484 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
1485 #define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
1486 #define atomic64_dec(v) atomic64_sub(1LL, (v))
1487 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1LL, (v))
1488 #define atomic64_dec_return(v) atomic64_sub_return(1LL, (v))
1489 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
1490 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
1491 diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
1492 index 75fe66b..ba3dee4 100644
1493 --- a/arch/arm/include/asm/cache.h
1494 +++ b/arch/arm/include/asm/cache.h
1495 @@ -4,8 +4,10 @@
1496 #ifndef __ASMARM_CACHE_H
1497 #define __ASMARM_CACHE_H
1498
1499 +#include <linux/const.h>
1500 +
1501 #define L1_CACHE_SHIFT CONFIG_ARM_L1_CACHE_SHIFT
1502 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
1503 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
1504
1505 /*
1506 * Memory returned by kmalloc() may be used for DMA, so we must make
1507 @@ -24,5 +26,6 @@
1508 #endif
1509
1510 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
1511 +#define __read_only __attribute__ ((__section__(".data..read_only")))
1512
1513 #endif
1514 diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
1515 index 17d0ae8..014e350 100644
1516 --- a/arch/arm/include/asm/cacheflush.h
1517 +++ b/arch/arm/include/asm/cacheflush.h
1518 @@ -116,7 +116,7 @@ struct cpu_cache_fns {
1519 void (*dma_unmap_area)(const void *, size_t, int);
1520
1521 void (*dma_flush_range)(const void *, const void *);
1522 -};
1523 +} __no_const;
1524
1525 /*
1526 * Select the calling method
1527 diff --git a/arch/arm/include/asm/checksum.h b/arch/arm/include/asm/checksum.h
1528 index 6dcc164..b14d917 100644
1529 --- a/arch/arm/include/asm/checksum.h
1530 +++ b/arch/arm/include/asm/checksum.h
1531 @@ -37,7 +37,19 @@ __wsum
1532 csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
1533
1534 __wsum
1535 -csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1536 +__csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1537 +
1538 +static inline __wsum
1539 +csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr)
1540 +{
1541 + __wsum ret;
1542 + pax_open_userland();
1543 + ret = __csum_partial_copy_from_user(src, dst, len, sum, err_ptr);
1544 + pax_close_userland();
1545 + return ret;
1546 +}
1547 +
1548 +
1549
1550 /*
1551 * Fold a partial checksum without adding pseudo headers
1552 diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
1553 index 4f009c1..466c59b 100644
1554 --- a/arch/arm/include/asm/cmpxchg.h
1555 +++ b/arch/arm/include/asm/cmpxchg.h
1556 @@ -102,6 +102,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
1557
1558 #define xchg(ptr,x) \
1559 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1560 +#define xchg_unchecked(ptr,x) \
1561 + ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1562
1563 #include <asm-generic/cmpxchg-local.h>
1564
1565 diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h
1566 index 6ddbe44..b5e38b1 100644
1567 --- a/arch/arm/include/asm/domain.h
1568 +++ b/arch/arm/include/asm/domain.h
1569 @@ -48,18 +48,37 @@
1570 * Domain types
1571 */
1572 #define DOMAIN_NOACCESS 0
1573 -#define DOMAIN_CLIENT 1
1574 #ifdef CONFIG_CPU_USE_DOMAINS
1575 +#define DOMAIN_USERCLIENT 1
1576 +#define DOMAIN_KERNELCLIENT 1
1577 #define DOMAIN_MANAGER 3
1578 +#define DOMAIN_VECTORS DOMAIN_USER
1579 #else
1580 +
1581 +#ifdef CONFIG_PAX_KERNEXEC
1582 #define DOMAIN_MANAGER 1
1583 +#define DOMAIN_KERNEXEC 3
1584 +#else
1585 +#define DOMAIN_MANAGER 1
1586 +#endif
1587 +
1588 +#ifdef CONFIG_PAX_MEMORY_UDEREF
1589 +#define DOMAIN_USERCLIENT 0
1590 +#define DOMAIN_UDEREF 1
1591 +#define DOMAIN_VECTORS DOMAIN_KERNEL
1592 +#else
1593 +#define DOMAIN_USERCLIENT 1
1594 +#define DOMAIN_VECTORS DOMAIN_USER
1595 +#endif
1596 +#define DOMAIN_KERNELCLIENT 1
1597 +
1598 #endif
1599
1600 #define domain_val(dom,type) ((type) << (2*(dom)))
1601
1602 #ifndef __ASSEMBLY__
1603
1604 -#ifdef CONFIG_CPU_USE_DOMAINS
1605 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1606 static inline void set_domain(unsigned val)
1607 {
1608 asm volatile(
1609 @@ -68,15 +87,7 @@ static inline void set_domain(unsigned val)
1610 isb();
1611 }
1612
1613 -#define modify_domain(dom,type) \
1614 - do { \
1615 - struct thread_info *thread = current_thread_info(); \
1616 - unsigned int domain = thread->cpu_domain; \
1617 - domain &= ~domain_val(dom, DOMAIN_MANAGER); \
1618 - thread->cpu_domain = domain | domain_val(dom, type); \
1619 - set_domain(thread->cpu_domain); \
1620 - } while (0)
1621 -
1622 +extern void modify_domain(unsigned int dom, unsigned int type);
1623 #else
1624 static inline void set_domain(unsigned val) { }
1625 static inline void modify_domain(unsigned dom, unsigned type) { }
1626 diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
1627 index 38050b1..9d90e8b 100644
1628 --- a/arch/arm/include/asm/elf.h
1629 +++ b/arch/arm/include/asm/elf.h
1630 @@ -116,7 +116,14 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1631 the loader. We need to make sure that it is out of the way of the program
1632 that it will "exec", and that there is sufficient room for the brk. */
1633
1634 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
1635 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1636 +
1637 +#ifdef CONFIG_PAX_ASLR
1638 +#define PAX_ELF_ET_DYN_BASE 0x00008000UL
1639 +
1640 +#define PAX_DELTA_MMAP_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1641 +#define PAX_DELTA_STACK_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1642 +#endif
1643
1644 /* When the program starts, a1 contains a pointer to a function to be
1645 registered with atexit, as per the SVR4 ABI. A value of 0 means we
1646 @@ -126,8 +133,4 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1647 extern void elf_set_personality(const struct elf32_hdr *);
1648 #define SET_PERSONALITY(ex) elf_set_personality(&(ex))
1649
1650 -struct mm_struct;
1651 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
1652 -#define arch_randomize_brk arch_randomize_brk
1653 -
1654 #endif
1655 diff --git a/arch/arm/include/asm/fncpy.h b/arch/arm/include/asm/fncpy.h
1656 index de53547..52b9a28 100644
1657 --- a/arch/arm/include/asm/fncpy.h
1658 +++ b/arch/arm/include/asm/fncpy.h
1659 @@ -81,7 +81,9 @@
1660 BUG_ON((uintptr_t)(dest_buf) & (FNCPY_ALIGN - 1) || \
1661 (__funcp_address & ~(uintptr_t)1 & (FNCPY_ALIGN - 1))); \
1662 \
1663 + pax_open_kernel(); \
1664 memcpy(dest_buf, (void const *)(__funcp_address & ~1), size); \
1665 + pax_close_kernel(); \
1666 flush_icache_range((unsigned long)(dest_buf), \
1667 (unsigned long)(dest_buf) + (size)); \
1668 \
1669 diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
1670 index e42cf59..7b94b8f 100644
1671 --- a/arch/arm/include/asm/futex.h
1672 +++ b/arch/arm/include/asm/futex.h
1673 @@ -50,6 +50,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1674 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1675 return -EFAULT;
1676
1677 + pax_open_userland();
1678 +
1679 smp_mb();
1680 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1681 "1: ldrex %1, [%4]\n"
1682 @@ -65,6 +67,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1683 : "cc", "memory");
1684 smp_mb();
1685
1686 + pax_close_userland();
1687 +
1688 *uval = val;
1689 return ret;
1690 }
1691 @@ -95,6 +99,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1692 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1693 return -EFAULT;
1694
1695 + pax_open_userland();
1696 +
1697 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1698 "1: " TUSER(ldr) " %1, [%4]\n"
1699 " teq %1, %2\n"
1700 @@ -105,6 +111,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1701 : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
1702 : "cc", "memory");
1703
1704 + pax_close_userland();
1705 +
1706 *uval = val;
1707 return ret;
1708 }
1709 @@ -127,6 +135,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1710 return -EFAULT;
1711
1712 pagefault_disable(); /* implies preempt_disable() */
1713 + pax_open_userland();
1714
1715 switch (op) {
1716 case FUTEX_OP_SET:
1717 @@ -148,6 +157,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1718 ret = -ENOSYS;
1719 }
1720
1721 + pax_close_userland();
1722 pagefault_enable(); /* subsumes preempt_enable() */
1723
1724 if (!ret) {
1725 diff --git a/arch/arm/include/asm/kmap_types.h b/arch/arm/include/asm/kmap_types.h
1726 index 83eb2f7..ed77159 100644
1727 --- a/arch/arm/include/asm/kmap_types.h
1728 +++ b/arch/arm/include/asm/kmap_types.h
1729 @@ -4,6 +4,6 @@
1730 /*
1731 * This is the "bare minimum". AIO seems to require this.
1732 */
1733 -#define KM_TYPE_NR 16
1734 +#define KM_TYPE_NR 17
1735
1736 #endif
1737 diff --git a/arch/arm/include/asm/mach/dma.h b/arch/arm/include/asm/mach/dma.h
1738 index 9e614a1..3302cca 100644
1739 --- a/arch/arm/include/asm/mach/dma.h
1740 +++ b/arch/arm/include/asm/mach/dma.h
1741 @@ -22,7 +22,7 @@ struct dma_ops {
1742 int (*residue)(unsigned int, dma_t *); /* optional */
1743 int (*setspeed)(unsigned int, dma_t *, int); /* optional */
1744 const char *type;
1745 -};
1746 +} __do_const;
1747
1748 struct dma_struct {
1749 void *addr; /* single DMA address */
1750 diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h
1751 index 2fe141f..192dc01 100644
1752 --- a/arch/arm/include/asm/mach/map.h
1753 +++ b/arch/arm/include/asm/mach/map.h
1754 @@ -27,13 +27,16 @@ struct map_desc {
1755 #define MT_MINICLEAN 6
1756 #define MT_LOW_VECTORS 7
1757 #define MT_HIGH_VECTORS 8
1758 -#define MT_MEMORY 9
1759 +#define MT_MEMORY_RWX 9
1760 #define MT_ROM 10
1761 -#define MT_MEMORY_NONCACHED 11
1762 +#define MT_MEMORY_NONCACHED_RX 11
1763 #define MT_MEMORY_DTCM 12
1764 #define MT_MEMORY_ITCM 13
1765 #define MT_MEMORY_SO 14
1766 #define MT_MEMORY_DMA_READY 15
1767 +#define MT_MEMORY_RW 16
1768 +#define MT_MEMORY_RX 17
1769 +#define MT_MEMORY_NONCACHED_RW 18
1770
1771 #ifdef CONFIG_MMU
1772 extern void iotable_init(struct map_desc *, int);
1773 diff --git a/arch/arm/include/asm/outercache.h b/arch/arm/include/asm/outercache.h
1774 index 12f71a1..04e063c 100644
1775 --- a/arch/arm/include/asm/outercache.h
1776 +++ b/arch/arm/include/asm/outercache.h
1777 @@ -35,7 +35,7 @@ struct outer_cache_fns {
1778 #endif
1779 void (*set_debug)(unsigned long);
1780 void (*resume)(void);
1781 -};
1782 +} __no_const;
1783
1784 #ifdef CONFIG_OUTER_CACHE
1785
1786 diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
1787 index 812a494..71fc0b6 100644
1788 --- a/arch/arm/include/asm/page.h
1789 +++ b/arch/arm/include/asm/page.h
1790 @@ -114,7 +114,7 @@ struct cpu_user_fns {
1791 void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
1792 void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
1793 unsigned long vaddr, struct vm_area_struct *vma);
1794 -};
1795 +} __no_const;
1796
1797 #ifdef MULTI_USER
1798 extern struct cpu_user_fns cpu_user;
1799 diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
1800 index 943504f..c37a730 100644
1801 --- a/arch/arm/include/asm/pgalloc.h
1802 +++ b/arch/arm/include/asm/pgalloc.h
1803 @@ -17,6 +17,7 @@
1804 #include <asm/processor.h>
1805 #include <asm/cacheflush.h>
1806 #include <asm/tlbflush.h>
1807 +#include <asm/system_info.h>
1808
1809 #define check_pgt_cache() do { } while (0)
1810
1811 @@ -43,6 +44,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1812 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
1813 }
1814
1815 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1816 +{
1817 + pud_populate(mm, pud, pmd);
1818 +}
1819 +
1820 #else /* !CONFIG_ARM_LPAE */
1821
1822 /*
1823 @@ -51,6 +57,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1824 #define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
1825 #define pmd_free(mm, pmd) do { } while (0)
1826 #define pud_populate(mm,pmd,pte) BUG()
1827 +#define pud_populate_kernel(mm,pmd,pte) BUG()
1828
1829 #endif /* CONFIG_ARM_LPAE */
1830
1831 @@ -126,6 +133,19 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
1832 __free_page(pte);
1833 }
1834
1835 +static inline void __section_update(pmd_t *pmdp, unsigned long addr, pmdval_t prot)
1836 +{
1837 +#ifdef CONFIG_ARM_LPAE
1838 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1839 +#else
1840 + if (addr & SECTION_SIZE)
1841 + pmdp[1] = __pmd(pmd_val(pmdp[1]) | prot);
1842 + else
1843 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1844 +#endif
1845 + flush_pmd_entry(pmdp);
1846 +}
1847 +
1848 static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,
1849 pmdval_t prot)
1850 {
1851 @@ -155,7 +175,7 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
1852 static inline void
1853 pmd_populate(struct mm_struct *mm, pmd_t *pmdp, pgtable_t ptep)
1854 {
1855 - __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE);
1856 + __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE | __supported_pmd_mask);
1857 }
1858 #define pmd_pgtable(pmd) pmd_page(pmd)
1859
1860 diff --git a/arch/arm/include/asm/pgtable-2level-hwdef.h b/arch/arm/include/asm/pgtable-2level-hwdef.h
1861 index 5cfba15..f415e1a 100644
1862 --- a/arch/arm/include/asm/pgtable-2level-hwdef.h
1863 +++ b/arch/arm/include/asm/pgtable-2level-hwdef.h
1864 @@ -20,12 +20,15 @@
1865 #define PMD_TYPE_FAULT (_AT(pmdval_t, 0) << 0)
1866 #define PMD_TYPE_TABLE (_AT(pmdval_t, 1) << 0)
1867 #define PMD_TYPE_SECT (_AT(pmdval_t, 2) << 0)
1868 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 2) /* v7 */
1869 #define PMD_BIT4 (_AT(pmdval_t, 1) << 4)
1870 #define PMD_DOMAIN(x) (_AT(pmdval_t, (x)) << 5)
1871 #define PMD_PROTECTION (_AT(pmdval_t, 1) << 9) /* v5 */
1872 +
1873 /*
1874 * - section
1875 */
1876 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 0) /* v7 */
1877 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1878 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1879 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 4) /* v6 */
1880 @@ -37,6 +40,7 @@
1881 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17) /* v6 */
1882 #define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18) /* v6 */
1883 #define PMD_SECT_AF (_AT(pmdval_t, 0))
1884 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 0))
1885
1886 #define PMD_SECT_UNCACHED (_AT(pmdval_t, 0))
1887 #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE)
1888 @@ -66,6 +70,7 @@
1889 * - extended small page/tiny page
1890 */
1891 #define PTE_EXT_XN (_AT(pteval_t, 1) << 0) /* v6 */
1892 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 2) /* v7 */
1893 #define PTE_EXT_AP_MASK (_AT(pteval_t, 3) << 4)
1894 #define PTE_EXT_AP0 (_AT(pteval_t, 1) << 4)
1895 #define PTE_EXT_AP1 (_AT(pteval_t, 2) << 4)
1896 diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
1897 index f97ee02..07f1be5 100644
1898 --- a/arch/arm/include/asm/pgtable-2level.h
1899 +++ b/arch/arm/include/asm/pgtable-2level.h
1900 @@ -125,6 +125,7 @@
1901 #define L_PTE_XN (_AT(pteval_t, 1) << 9)
1902 #define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */
1903 #define L_PTE_NONE (_AT(pteval_t, 1) << 11)
1904 +#define L_PTE_PXN (_AT(pteval_t, 1) << 12) /* v7*/
1905
1906 /*
1907 * These are the memory types, defined to be compatible with
1908 diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h
1909 index 18f5cef..25b8f43 100644
1910 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h
1911 +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h
1912 @@ -41,6 +41,7 @@
1913 */
1914 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1915 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1916 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 1) << 7)
1917 #define PMD_SECT_S (_AT(pmdval_t, 3) << 8)
1918 #define PMD_SECT_AF (_AT(pmdval_t, 1) << 10)
1919 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 11)
1920 @@ -71,6 +72,7 @@
1921 #define PTE_EXT_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1922 #define PTE_EXT_AF (_AT(pteval_t, 1) << 10) /* Access Flag */
1923 #define PTE_EXT_NG (_AT(pteval_t, 1) << 11) /* nG */
1924 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1925 #define PTE_EXT_XN (_AT(pteval_t, 1) << 54) /* XN */
1926
1927 /*
1928 diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
1929 index 86b8fe3..e25f975 100644
1930 --- a/arch/arm/include/asm/pgtable-3level.h
1931 +++ b/arch/arm/include/asm/pgtable-3level.h
1932 @@ -74,6 +74,7 @@
1933 #define L_PTE_RDONLY (_AT(pteval_t, 1) << 7) /* AP[2] */
1934 #define L_PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1935 #define L_PTE_YOUNG (_AT(pteval_t, 1) << 10) /* AF */
1936 +#define L_PTE_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1937 #define L_PTE_XN (_AT(pteval_t, 1) << 54) /* XN */
1938 #define L_PTE_DIRTY (_AT(pteval_t, 1) << 55) /* unused */
1939 #define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56) /* unused */
1940 @@ -82,6 +83,7 @@
1941 /*
1942 * To be used in assembly code with the upper page attributes.
1943 */
1944 +#define L_PTE_PXN_HIGH (1 << (53 - 32))
1945 #define L_PTE_XN_HIGH (1 << (54 - 32))
1946 #define L_PTE_DIRTY_HIGH (1 << (55 - 32))
1947
1948 diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
1949 index 9bcd262..fba731c 100644
1950 --- a/arch/arm/include/asm/pgtable.h
1951 +++ b/arch/arm/include/asm/pgtable.h
1952 @@ -30,6 +30,9 @@
1953 #include <asm/pgtable-2level.h>
1954 #endif
1955
1956 +#define ktla_ktva(addr) (addr)
1957 +#define ktva_ktla(addr) (addr)
1958 +
1959 /*
1960 * Just any arbitrary offset to the start of the vmalloc VM area: the
1961 * current 8MB value just means that there will be a 8MB "hole" after the
1962 @@ -45,6 +48,9 @@
1963 #define LIBRARY_TEXT_START 0x0c000000
1964
1965 #ifndef __ASSEMBLY__
1966 +extern pteval_t __supported_pte_mask;
1967 +extern pmdval_t __supported_pmd_mask;
1968 +
1969 extern void __pte_error(const char *file, int line, pte_t);
1970 extern void __pmd_error(const char *file, int line, pmd_t);
1971 extern void __pgd_error(const char *file, int line, pgd_t);
1972 @@ -53,6 +59,50 @@ extern void __pgd_error(const char *file, int line, pgd_t);
1973 #define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd)
1974 #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd)
1975
1976 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
1977 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
1978 +
1979 +#ifdef CONFIG_PAX_KERNEXEC
1980 +#include <asm/domain.h>
1981 +#include <linux/thread_info.h>
1982 +#include <linux/preempt.h>
1983 +#endif
1984 +
1985 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1986 +static inline int test_domain(int domain, int domaintype)
1987 +{
1988 + return ((current_thread_info()->cpu_domain) & domain_val(domain, 3)) == domain_val(domain, domaintype);
1989 +}
1990 +#endif
1991 +
1992 +#ifdef CONFIG_PAX_KERNEXEC
1993 +static inline unsigned long pax_open_kernel(void) {
1994 +#ifdef CONFIG_ARM_LPAE
1995 + /* TODO */
1996 +#else
1997 + preempt_disable();
1998 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC));
1999 + modify_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC);
2000 +#endif
2001 + return 0;
2002 +}
2003 +
2004 +static inline unsigned long pax_close_kernel(void) {
2005 +#ifdef CONFIG_ARM_LPAE
2006 + /* TODO */
2007 +#else
2008 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_MANAGER));
2009 + /* DOMAIN_MANAGER = "client" under KERNEXEC */
2010 + modify_domain(DOMAIN_KERNEL, DOMAIN_MANAGER);
2011 + preempt_enable_no_resched();
2012 +#endif
2013 + return 0;
2014 +}
2015 +#else
2016 +static inline unsigned long pax_open_kernel(void) { return 0; }
2017 +static inline unsigned long pax_close_kernel(void) { return 0; }
2018 +#endif
2019 +
2020 /*
2021 * This is the lowest virtual address we can permit any user space
2022 * mapping to be mapped at. This is particularly important for
2023 @@ -72,8 +122,8 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2024 /*
2025 * The pgprot_* and protection_map entries will be fixed up in runtime
2026 * to include the cachable and bufferable bits based on memory policy,
2027 - * as well as any architecture dependent bits like global/ASID and SMP
2028 - * shared mapping bits.
2029 + * as well as any architecture dependent bits like global/ASID, PXN,
2030 + * and SMP shared mapping bits.
2031 */
2032 #define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
2033
2034 @@ -257,7 +307,7 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
2035 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
2036 {
2037 const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |
2038 - L_PTE_NONE | L_PTE_VALID;
2039 + L_PTE_NONE | L_PTE_VALID | __supported_pte_mask;
2040 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
2041 return pte;
2042 }
2043 diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h
2044 index f3628fb..a0672dd 100644
2045 --- a/arch/arm/include/asm/proc-fns.h
2046 +++ b/arch/arm/include/asm/proc-fns.h
2047 @@ -75,7 +75,7 @@ extern struct processor {
2048 unsigned int suspend_size;
2049 void (*do_suspend)(void *);
2050 void (*do_resume)(void *);
2051 -} processor;
2052 +} __do_const processor;
2053
2054 #ifndef MULTI_CPU
2055 extern void cpu_proc_init(void);
2056 diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h
2057 index 06e7d50..8a8e251 100644
2058 --- a/arch/arm/include/asm/processor.h
2059 +++ b/arch/arm/include/asm/processor.h
2060 @@ -65,9 +65,8 @@ struct thread_struct {
2061 regs->ARM_cpsr |= PSR_ENDSTATE; \
2062 regs->ARM_pc = pc & ~1; /* pc */ \
2063 regs->ARM_sp = sp; /* sp */ \
2064 - regs->ARM_r2 = stack[2]; /* r2 (envp) */ \
2065 - regs->ARM_r1 = stack[1]; /* r1 (argv) */ \
2066 - regs->ARM_r0 = stack[0]; /* r0 (argc) */ \
2067 + /* r2 (envp), r1 (argv), r0 (argc) */ \
2068 + (void)copy_from_user(&regs->ARM_r0, (const char __user *)stack, 3 * sizeof(unsigned long)); \
2069 nommu_start_thread(regs); \
2070 })
2071
2072 diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h
2073 index ce0dbe7..c085b6f 100644
2074 --- a/arch/arm/include/asm/psci.h
2075 +++ b/arch/arm/include/asm/psci.h
2076 @@ -29,7 +29,7 @@ struct psci_operations {
2077 int (*cpu_off)(struct psci_power_state state);
2078 int (*cpu_on)(unsigned long cpuid, unsigned long entry_point);
2079 int (*migrate)(unsigned long cpuid);
2080 -};
2081 +} __no_const;
2082
2083 extern struct psci_operations psci_ops;
2084
2085 diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
2086 index d3a22be..3a69ad5 100644
2087 --- a/arch/arm/include/asm/smp.h
2088 +++ b/arch/arm/include/asm/smp.h
2089 @@ -107,7 +107,7 @@ struct smp_operations {
2090 int (*cpu_disable)(unsigned int cpu);
2091 #endif
2092 #endif
2093 -};
2094 +} __no_const;
2095
2096 /*
2097 * set platform specific SMP operations
2098 diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
2099 index 1995d1a..76693a2 100644
2100 --- a/arch/arm/include/asm/thread_info.h
2101 +++ b/arch/arm/include/asm/thread_info.h
2102 @@ -77,9 +77,9 @@ struct thread_info {
2103 .flags = 0, \
2104 .preempt_count = INIT_PREEMPT_COUNT, \
2105 .addr_limit = KERNEL_DS, \
2106 - .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2107 - domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2108 - domain_val(DOMAIN_IO, DOMAIN_CLIENT), \
2109 + .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_USERCLIENT) | \
2110 + domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT) | \
2111 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT), \
2112 .restart_block = { \
2113 .fn = do_no_restart_syscall, \
2114 }, \
2115 @@ -152,7 +152,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2116 #define TIF_SYSCALL_AUDIT 9
2117 #define TIF_SYSCALL_TRACEPOINT 10
2118 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */
2119 -#define TIF_NOHZ 12 /* in adaptive nohz mode */
2120 +/* within 8 bits of TIF_SYSCALL_TRACE
2121 + * to meet flexible second operand requirements
2122 + */
2123 +#define TIF_GRSEC_SETXID 12
2124 +#define TIF_NOHZ 13 /* in adaptive nohz mode */
2125 #define TIF_USING_IWMMXT 17
2126 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
2127 #define TIF_RESTORE_SIGMASK 20
2128 @@ -166,10 +170,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2129 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
2130 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
2131 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
2132 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
2133
2134 /* Checks for any syscall work in entry-common.S */
2135 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
2136 - _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
2137 + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_GRSEC_SETXID)
2138
2139 /*
2140 * Change these and you break ASM code in entry-common.S
2141 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
2142 index 7e1f760..510061e 100644
2143 --- a/arch/arm/include/asm/uaccess.h
2144 +++ b/arch/arm/include/asm/uaccess.h
2145 @@ -18,6 +18,7 @@
2146 #include <asm/domain.h>
2147 #include <asm/unified.h>
2148 #include <asm/compiler.h>
2149 +#include <asm/pgtable.h>
2150
2151 #define VERIFY_READ 0
2152 #define VERIFY_WRITE 1
2153 @@ -63,11 +64,35 @@ extern int __put_user_bad(void);
2154 static inline void set_fs(mm_segment_t fs)
2155 {
2156 current_thread_info()->addr_limit = fs;
2157 - modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
2158 + modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_KERNELCLIENT : DOMAIN_MANAGER);
2159 }
2160
2161 #define segment_eq(a,b) ((a) == (b))
2162
2163 +static inline void pax_open_userland(void)
2164 +{
2165 +
2166 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2167 + if (segment_eq(get_fs(), USER_DS) {
2168 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_UDEREF));
2169 + modify_domain(DOMAIN_USER, DOMAIN_UDEREF);
2170 + }
2171 +#endif
2172 +
2173 +}
2174 +
2175 +static inline void pax_close_userland(void)
2176 +{
2177 +
2178 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2179 + if (segment_eq(get_fs(), USER_DS) {
2180 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_NOACCESS));
2181 + modify_domain(DOMAIN_USER, DOMAIN_NOACCESS);
2182 + }
2183 +#endif
2184 +
2185 +}
2186 +
2187 #define __addr_ok(addr) ({ \
2188 unsigned long flag; \
2189 __asm__("cmp %2, %0; movlo %0, #0" \
2190 @@ -143,8 +168,12 @@ extern int __get_user_4(void *);
2191
2192 #define get_user(x,p) \
2193 ({ \
2194 + int __e; \
2195 might_fault(); \
2196 - __get_user_check(x,p); \
2197 + pax_open_userland(); \
2198 + __e = __get_user_check(x,p); \
2199 + pax_close_userland(); \
2200 + __e; \
2201 })
2202
2203 extern int __put_user_1(void *, unsigned int);
2204 @@ -188,8 +217,12 @@ extern int __put_user_8(void *, unsigned long long);
2205
2206 #define put_user(x,p) \
2207 ({ \
2208 + int __e; \
2209 might_fault(); \
2210 - __put_user_check(x,p); \
2211 + pax_open_userland(); \
2212 + __e = __put_user_check(x,p); \
2213 + pax_close_userland(); \
2214 + __e; \
2215 })
2216
2217 #else /* CONFIG_MMU */
2218 @@ -230,13 +263,17 @@ static inline void set_fs(mm_segment_t fs)
2219 #define __get_user(x,ptr) \
2220 ({ \
2221 long __gu_err = 0; \
2222 + pax_open_userland(); \
2223 __get_user_err((x),(ptr),__gu_err); \
2224 + pax_close_userland(); \
2225 __gu_err; \
2226 })
2227
2228 #define __get_user_error(x,ptr,err) \
2229 ({ \
2230 + pax_open_userland(); \
2231 __get_user_err((x),(ptr),err); \
2232 + pax_close_userland(); \
2233 (void) 0; \
2234 })
2235
2236 @@ -312,13 +349,17 @@ do { \
2237 #define __put_user(x,ptr) \
2238 ({ \
2239 long __pu_err = 0; \
2240 + pax_open_userland(); \
2241 __put_user_err((x),(ptr),__pu_err); \
2242 + pax_close_userland(); \
2243 __pu_err; \
2244 })
2245
2246 #define __put_user_error(x,ptr,err) \
2247 ({ \
2248 + pax_open_userland(); \
2249 __put_user_err((x),(ptr),err); \
2250 + pax_close_userland(); \
2251 (void) 0; \
2252 })
2253
2254 @@ -418,11 +459,44 @@ do { \
2255
2256
2257 #ifdef CONFIG_MMU
2258 -extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
2259 -extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
2260 +extern unsigned long __must_check ___copy_from_user(void *to, const void __user *from, unsigned long n);
2261 +extern unsigned long __must_check ___copy_to_user(void __user *to, const void *from, unsigned long n);
2262 +
2263 +static inline unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n)
2264 +{
2265 + unsigned long ret;
2266 +
2267 + check_object_size(to, n, false);
2268 + pax_open_userland();
2269 + ret = ___copy_from_user(to, from, n);
2270 + pax_close_userland();
2271 + return ret;
2272 +}
2273 +
2274 +static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
2275 +{
2276 + unsigned long ret;
2277 +
2278 + check_object_size(from, n, true);
2279 + pax_open_userland();
2280 + ret = ___copy_to_user(to, from, n);
2281 + pax_close_userland();
2282 + return ret;
2283 +}
2284 +
2285 extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2286 -extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
2287 +extern unsigned long __must_check ___clear_user(void __user *addr, unsigned long n);
2288 extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
2289 +
2290 +static inline unsigned long __must_check __clear_user(void __user *addr, unsigned long n)
2291 +{
2292 + unsigned long ret;
2293 + pax_open_userland();
2294 + ret = ___clear_user(addr, n);
2295 + pax_close_userland();
2296 + return ret;
2297 +}
2298 +
2299 #else
2300 #define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0)
2301 #define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0)
2302 @@ -431,6 +505,9 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
2303
2304 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
2305 {
2306 + if ((long)n < 0)
2307 + return n;
2308 +
2309 if (access_ok(VERIFY_READ, from, n))
2310 n = __copy_from_user(to, from, n);
2311 else /* security hole - plug it */
2312 @@ -440,6 +517,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
2313
2314 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
2315 {
2316 + if ((long)n < 0)
2317 + return n;
2318 +
2319 if (access_ok(VERIFY_WRITE, to, n))
2320 n = __copy_to_user(to, from, n);
2321 return n;
2322 diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
2323 index 96ee092..37f1844 100644
2324 --- a/arch/arm/include/uapi/asm/ptrace.h
2325 +++ b/arch/arm/include/uapi/asm/ptrace.h
2326 @@ -73,7 +73,7 @@
2327 * ARMv7 groups of PSR bits
2328 */
2329 #define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */
2330 -#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */
2331 +#define PSR_ISET_MASK 0x01000020 /* ISA state (J, T) mask */
2332 #define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
2333 #define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */
2334
2335 diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
2336 index 60d3b73..e5a0f22 100644
2337 --- a/arch/arm/kernel/armksyms.c
2338 +++ b/arch/arm/kernel/armksyms.c
2339 @@ -53,7 +53,7 @@ EXPORT_SYMBOL(arm_delay_ops);
2340
2341 /* networking */
2342 EXPORT_SYMBOL(csum_partial);
2343 -EXPORT_SYMBOL(csum_partial_copy_from_user);
2344 +EXPORT_SYMBOL(__csum_partial_copy_from_user);
2345 EXPORT_SYMBOL(csum_partial_copy_nocheck);
2346 EXPORT_SYMBOL(__csum_ipv6_magic);
2347
2348 @@ -89,9 +89,9 @@ EXPORT_SYMBOL(__memzero);
2349 #ifdef CONFIG_MMU
2350 EXPORT_SYMBOL(copy_page);
2351
2352 -EXPORT_SYMBOL(__copy_from_user);
2353 -EXPORT_SYMBOL(__copy_to_user);
2354 -EXPORT_SYMBOL(__clear_user);
2355 +EXPORT_SYMBOL(___copy_from_user);
2356 +EXPORT_SYMBOL(___copy_to_user);
2357 +EXPORT_SYMBOL(___clear_user);
2358
2359 EXPORT_SYMBOL(__get_user_1);
2360 EXPORT_SYMBOL(__get_user_2);
2361 diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2362 index 582b405..50351b7 100644
2363 --- a/arch/arm/kernel/entry-armv.S
2364 +++ b/arch/arm/kernel/entry-armv.S
2365 @@ -47,6 +47,87 @@
2366 9997:
2367 .endm
2368
2369 + .macro pax_enter_kernel
2370 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2371 + @ make aligned space for saved DACR
2372 + sub sp, sp, #8
2373 + @ save regs
2374 + stmdb sp!, {r1, r2}
2375 + @ read DACR from cpu_domain into r1
2376 + mov r2, sp
2377 + @ assume 8K pages, since we have to split the immediate in two
2378 + bic r2, r2, #(0x1fc0)
2379 + bic r2, r2, #(0x3f)
2380 + ldr r1, [r2, #TI_CPU_DOMAIN]
2381 + @ store old DACR on stack
2382 + str r1, [sp, #8]
2383 +#ifdef CONFIG_PAX_KERNEXEC
2384 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2385 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2386 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2387 +#endif
2388 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2389 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2390 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2391 +#endif
2392 + @ write r1 to current_thread_info()->cpu_domain
2393 + str r1, [r2, #TI_CPU_DOMAIN]
2394 + @ write r1 to DACR
2395 + mcr p15, 0, r1, c3, c0, 0
2396 + @ instruction sync
2397 + instr_sync
2398 + @ restore regs
2399 + ldmia sp!, {r1, r2}
2400 +#endif
2401 + .endm
2402 +
2403 + .macro pax_open_userland
2404 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2405 + @ save regs
2406 + stmdb sp!, {r0, r1}
2407 + @ read DACR from cpu_domain into r1
2408 + mov r0, sp
2409 + @ assume 8K pages, since we have to split the immediate in two
2410 + bic r0, r0, #(0x1fc0)
2411 + bic r0, r0, #(0x3f)
2412 + ldr r1, [r0, #TI_CPU_DOMAIN]
2413 + @ set current DOMAIN_USER to DOMAIN_CLIENT
2414 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2415 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2416 + @ write r1 to current_thread_info()->cpu_domain
2417 + str r1, [r0, #TI_CPU_DOMAIN]
2418 + @ write r1 to DACR
2419 + mcr p15, 0, r1, c3, c0, 0
2420 + @ instruction sync
2421 + instr_sync
2422 + @ restore regs
2423 + ldmia sp!, {r0, r1}
2424 +#endif
2425 + .endm
2426 +
2427 + .macro pax_close_userland
2428 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2429 + @ save regs
2430 + stmdb sp!, {r0, r1}
2431 + @ read DACR from cpu_domain into r1
2432 + mov r0, sp
2433 + @ assume 8K pages, since we have to split the immediate in two
2434 + bic r0, r0, #(0x1fc0)
2435 + bic r0, r0, #(0x3f)
2436 + ldr r1, [r0, #TI_CPU_DOMAIN]
2437 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2438 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2439 + @ write r1 to current_thread_info()->cpu_domain
2440 + str r1, [r0, #TI_CPU_DOMAIN]
2441 + @ write r1 to DACR
2442 + mcr p15, 0, r1, c3, c0, 0
2443 + @ instruction sync
2444 + instr_sync
2445 + @ restore regs
2446 + ldmia sp!, {r0, r1}
2447 +#endif
2448 + .endm
2449 +
2450 .macro pabt_helper
2451 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
2452 #ifdef MULTI_PABORT
2453 @@ -89,11 +170,15 @@
2454 * Invalid mode handlers
2455 */
2456 .macro inv_entry, reason
2457 +
2458 + pax_enter_kernel
2459 +
2460 sub sp, sp, #S_FRAME_SIZE
2461 ARM( stmib sp, {r1 - lr} )
2462 THUMB( stmia sp, {r0 - r12} )
2463 THUMB( str sp, [sp, #S_SP] )
2464 THUMB( str lr, [sp, #S_LR] )
2465 +
2466 mov r1, #\reason
2467 .endm
2468
2469 @@ -149,7 +234,11 @@ ENDPROC(__und_invalid)
2470 .macro svc_entry, stack_hole=0
2471 UNWIND(.fnstart )
2472 UNWIND(.save {r0 - pc} )
2473 +
2474 + pax_enter_kernel
2475 +
2476 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2477 +
2478 #ifdef CONFIG_THUMB2_KERNEL
2479 SPFIX( str r0, [sp] ) @ temporarily saved
2480 SPFIX( mov r0, sp )
2481 @@ -164,7 +253,12 @@ ENDPROC(__und_invalid)
2482 ldmia r0, {r3 - r5}
2483 add r7, sp, #S_SP - 4 @ here for interlock avoidance
2484 mov r6, #-1 @ "" "" "" ""
2485 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2486 + @ offset sp by 8 as done in pax_enter_kernel
2487 + add r2, sp, #(S_FRAME_SIZE + \stack_hole + 4)
2488 +#else
2489 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2490 +#endif
2491 SPFIX( addeq r2, r2, #4 )
2492 str r3, [sp, #-4]! @ save the "real" r0 copied
2493 @ from the exception stack
2494 @@ -316,6 +410,9 @@ ENDPROC(__pabt_svc)
2495 .macro usr_entry
2496 UNWIND(.fnstart )
2497 UNWIND(.cantunwind ) @ don't unwind the user space
2498 +
2499 + pax_enter_kernel_user
2500 +
2501 sub sp, sp, #S_FRAME_SIZE
2502 ARM( stmib sp, {r1 - r12} )
2503 THUMB( stmia sp, {r0 - r12} )
2504 @@ -414,7 +511,9 @@ __und_usr:
2505 tst r3, #PSR_T_BIT @ Thumb mode?
2506 bne __und_usr_thumb
2507 sub r4, r2, #4 @ ARM instr at LR - 4
2508 + pax_open_userland
2509 1: ldrt r0, [r4]
2510 + pax_close_userland
2511 #ifdef CONFIG_CPU_ENDIAN_BE8
2512 rev r0, r0 @ little endian instruction
2513 #endif
2514 @@ -449,10 +548,14 @@ __und_usr_thumb:
2515 */
2516 .arch armv6t2
2517 #endif
2518 + pax_open_userland
2519 2: ldrht r5, [r4]
2520 + pax_close_userland
2521 cmp r5, #0xe800 @ 32bit instruction if xx != 0
2522 blo __und_usr_fault_16 @ 16bit undefined instruction
2523 + pax_open_userland
2524 3: ldrht r0, [r2]
2525 + pax_close_userland
2526 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
2527 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
2528 orr r0, r0, r5, lsl #16
2529 @@ -690,7 +793,7 @@ ENTRY(__switch_to)
2530 THUMB( stmia ip!, {r4 - sl, fp} ) @ Store most regs on stack
2531 THUMB( str sp, [ip], #4 )
2532 THUMB( str lr, [ip], #4 )
2533 -#ifdef CONFIG_CPU_USE_DOMAINS
2534 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2535 ldr r6, [r2, #TI_CPU_DOMAIN]
2536 #endif
2537 set_tls r3, r4, r5
2538 @@ -699,7 +802,7 @@ ENTRY(__switch_to)
2539 ldr r8, =__stack_chk_guard
2540 ldr r7, [r7, #TSK_STACK_CANARY]
2541 #endif
2542 -#ifdef CONFIG_CPU_USE_DOMAINS
2543 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2544 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
2545 #endif
2546 mov r5, r0
2547 diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2548 index bc5bc0a..d0998ca 100644
2549 --- a/arch/arm/kernel/entry-common.S
2550 +++ b/arch/arm/kernel/entry-common.S
2551 @@ -10,18 +10,46 @@
2552
2553 #include <asm/unistd.h>
2554 #include <asm/ftrace.h>
2555 +#include <asm/domain.h>
2556 #include <asm/unwind.h>
2557
2558 +#include "entry-header.S"
2559 +
2560 #ifdef CONFIG_NEED_RET_TO_USER
2561 #include <mach/entry-macro.S>
2562 #else
2563 .macro arch_ret_to_user, tmp1, tmp2
2564 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2565 + @ save regs
2566 + stmdb sp!, {r1, r2}
2567 + @ read DACR from cpu_domain into r1
2568 + mov r2, sp
2569 + @ assume 8K pages, since we have to split the immediate in two
2570 + bic r2, r2, #(0x1fc0)
2571 + bic r2, r2, #(0x3f)
2572 + ldr r1, [r2, #TI_CPU_DOMAIN]
2573 +#ifdef CONFIG_PAX_KERNEXEC
2574 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2575 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2576 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2577 +#endif
2578 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2579 + @ set current DOMAIN_USER to DOMAIN_UDEREF
2580 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2581 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2582 +#endif
2583 + @ write r1 to current_thread_info()->cpu_domain
2584 + str r1, [r2, #TI_CPU_DOMAIN]
2585 + @ write r1 to DACR
2586 + mcr p15, 0, r1, c3, c0, 0
2587 + @ instruction sync
2588 + instr_sync
2589 + @ restore regs
2590 + ldmia sp!, {r1, r2}
2591 +#endif
2592 .endm
2593 #endif
2594
2595 -#include "entry-header.S"
2596 -
2597 -
2598 .align 5
2599 /*
2600 * This is the fast syscall return path. We do as little as
2601 @@ -350,6 +378,7 @@ ENDPROC(ftrace_stub)
2602
2603 .align 5
2604 ENTRY(vector_swi)
2605 +
2606 sub sp, sp, #S_FRAME_SIZE
2607 stmia sp, {r0 - r12} @ Calling r0 - r12
2608 ARM( add r8, sp, #S_PC )
2609 @@ -399,6 +428,12 @@ ENTRY(vector_swi)
2610 ldr scno, [lr, #-4] @ get SWI instruction
2611 #endif
2612
2613 + /*
2614 + * do this here to avoid a performance hit of wrapping the code above
2615 + * that directly dereferences userland to parse the SWI instruction
2616 + */
2617 + pax_enter_kernel_user
2618 +
2619 #ifdef CONFIG_ALIGNMENT_TRAP
2620 ldr ip, __cr_alignment
2621 ldr ip, [ip]
2622 diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2623 index 160f337..db67ee4 100644
2624 --- a/arch/arm/kernel/entry-header.S
2625 +++ b/arch/arm/kernel/entry-header.S
2626 @@ -73,6 +73,60 @@
2627 msr cpsr_c, \rtemp @ switch back to the SVC mode
2628 .endm
2629
2630 + .macro pax_enter_kernel_user
2631 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2632 + @ save regs
2633 + stmdb sp!, {r0, r1}
2634 + @ read DACR from cpu_domain into r1
2635 + mov r0, sp
2636 + @ assume 8K pages, since we have to split the immediate in two
2637 + bic r0, r0, #(0x1fc0)
2638 + bic r0, r0, #(0x3f)
2639 + ldr r1, [r0, #TI_CPU_DOMAIN]
2640 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2641 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2642 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2643 +#endif
2644 +#ifdef CONFIG_PAX_KERNEXEC
2645 + @ set current DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2646 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2647 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2648 +#endif
2649 + @ write r1 to current_thread_info()->cpu_domain
2650 + str r1, [r0, #TI_CPU_DOMAIN]
2651 + @ write r1 to DACR
2652 + mcr p15, 0, r1, c3, c0, 0
2653 + @ instruction sync
2654 + instr_sync
2655 + @ restore regs
2656 + ldmia sp!, {r0, r1}
2657 +#endif
2658 + .endm
2659 +
2660 + .macro pax_exit_kernel
2661 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2662 + @ save regs
2663 + stmdb sp!, {r0, r1}
2664 + @ read old DACR from stack into r1
2665 + ldr r1, [sp, #(8 + S_SP)]
2666 + sub r1, r1, #8
2667 + ldr r1, [r1]
2668 +
2669 + @ write r1 to current_thread_info()->cpu_domain
2670 + mov r0, sp
2671 + @ assume 8K pages, since we have to split the immediate in two
2672 + bic r0, r0, #(0x1fc0)
2673 + bic r0, r0, #(0x3f)
2674 + str r1, [r0, #TI_CPU_DOMAIN]
2675 + @ write r1 to DACR
2676 + mcr p15, 0, r1, c3, c0, 0
2677 + @ instruction sync
2678 + instr_sync
2679 + @ restore regs
2680 + ldmia sp!, {r0, r1}
2681 +#endif
2682 + .endm
2683 +
2684 #ifndef CONFIG_THUMB2_KERNEL
2685 .macro svc_exit, rpsr, irq = 0
2686 .if \irq != 0
2687 @@ -92,6 +146,9 @@
2688 blne trace_hardirqs_off
2689 #endif
2690 .endif
2691 +
2692 + pax_exit_kernel
2693 +
2694 msr spsr_cxsf, \rpsr
2695 #if defined(CONFIG_CPU_V6)
2696 ldr r0, [sp]
2697 @@ -155,6 +212,9 @@
2698 blne trace_hardirqs_off
2699 #endif
2700 .endif
2701 +
2702 + pax_exit_kernel
2703 +
2704 ldr lr, [sp, #S_SP] @ top of the stack
2705 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
2706 clrex @ clear the exclusive monitor
2707 diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
2708 index 2adda11..7fbe958 100644
2709 --- a/arch/arm/kernel/fiq.c
2710 +++ b/arch/arm/kernel/fiq.c
2711 @@ -82,7 +82,9 @@ void set_fiq_handler(void *start, unsigned int length)
2712 #if defined(CONFIG_CPU_USE_DOMAINS)
2713 memcpy((void *)0xffff001c, start, length);
2714 #else
2715 + pax_open_kernel();
2716 memcpy(vectors_page + 0x1c, start, length);
2717 + pax_close_kernel();
2718 #endif
2719 flush_icache_range(0xffff001c, 0xffff001c + length);
2720 if (!vectors_high())
2721 diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2722 index 8bac553..caee108 100644
2723 --- a/arch/arm/kernel/head.S
2724 +++ b/arch/arm/kernel/head.S
2725 @@ -52,7 +52,9 @@
2726 .equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE
2727
2728 .macro pgtbl, rd, phys
2729 - add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE
2730 + mov \rd, #TEXT_OFFSET
2731 + sub \rd, #PG_DIR_SIZE
2732 + add \rd, \rd, \phys
2733 .endm
2734
2735 /*
2736 @@ -434,7 +436,7 @@ __enable_mmu:
2737 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2738 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2739 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
2740 - domain_val(DOMAIN_IO, DOMAIN_CLIENT))
2741 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT))
2742 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
2743 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
2744 #endif
2745 diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c
2746 index 1fd749e..47adb08 100644
2747 --- a/arch/arm/kernel/hw_breakpoint.c
2748 +++ b/arch/arm/kernel/hw_breakpoint.c
2749 @@ -1029,7 +1029,7 @@ static int __cpuinit dbg_reset_notify(struct notifier_block *self,
2750 return NOTIFY_OK;
2751 }
2752
2753 -static struct notifier_block __cpuinitdata dbg_reset_nb = {
2754 +static struct notifier_block dbg_reset_nb = {
2755 .notifier_call = dbg_reset_notify,
2756 };
2757
2758 diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
2759 index 1e9be5d..03edbc2 100644
2760 --- a/arch/arm/kernel/module.c
2761 +++ b/arch/arm/kernel/module.c
2762 @@ -37,12 +37,37 @@
2763 #endif
2764
2765 #ifdef CONFIG_MMU
2766 -void *module_alloc(unsigned long size)
2767 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2768 {
2769 + if (!size || PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR)
2770 + return NULL;
2771 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2772 - GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
2773 + GFP_KERNEL, prot, -1,
2774 __builtin_return_address(0));
2775 }
2776 +
2777 +void *module_alloc(unsigned long size)
2778 +{
2779 +
2780 +#ifdef CONFIG_PAX_KERNEXEC
2781 + return __module_alloc(size, PAGE_KERNEL);
2782 +#else
2783 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2784 +#endif
2785 +
2786 +}
2787 +
2788 +#ifdef CONFIG_PAX_KERNEXEC
2789 +void module_free_exec(struct module *mod, void *module_region)
2790 +{
2791 + module_free(mod, module_region);
2792 +}
2793 +
2794 +void *module_alloc_exec(unsigned long size)
2795 +{
2796 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2797 +}
2798 +#endif
2799 #endif
2800
2801 int
2802 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2803 index 07314af..c46655c 100644
2804 --- a/arch/arm/kernel/patch.c
2805 +++ b/arch/arm/kernel/patch.c
2806 @@ -18,6 +18,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2807 bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
2808 int size;
2809
2810 + pax_open_kernel();
2811 if (thumb2 && __opcode_is_thumb16(insn)) {
2812 *(u16 *)addr = __opcode_to_mem_thumb16(insn);
2813 size = sizeof(u16);
2814 @@ -39,6 +40,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2815 *(u32 *)addr = insn;
2816 size = sizeof(u32);
2817 }
2818 + pax_close_kernel();
2819
2820 flush_icache_range((uintptr_t)(addr),
2821 (uintptr_t)(addr) + size);
2822 diff --git a/arch/arm/kernel/perf_event_cpu.c b/arch/arm/kernel/perf_event_cpu.c
2823 index 1f2740e..b36e225 100644
2824 --- a/arch/arm/kernel/perf_event_cpu.c
2825 +++ b/arch/arm/kernel/perf_event_cpu.c
2826 @@ -171,7 +171,7 @@ static int __cpuinit cpu_pmu_notify(struct notifier_block *b,
2827 return NOTIFY_OK;
2828 }
2829
2830 -static struct notifier_block __cpuinitdata cpu_pmu_hotplug_notifier = {
2831 +static struct notifier_block cpu_pmu_hotplug_notifier = {
2832 .notifier_call = cpu_pmu_notify,
2833 };
2834
2835 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2836 index 6e8931c..82ec6a5 100644
2837 --- a/arch/arm/kernel/process.c
2838 +++ b/arch/arm/kernel/process.c
2839 @@ -28,7 +28,6 @@
2840 #include <linux/tick.h>
2841 #include <linux/utsname.h>
2842 #include <linux/uaccess.h>
2843 -#include <linux/random.h>
2844 #include <linux/hw_breakpoint.h>
2845 #include <linux/cpuidle.h>
2846 #include <linux/leds.h>
2847 @@ -223,6 +222,7 @@ void machine_power_off(void)
2848
2849 if (pm_power_off)
2850 pm_power_off();
2851 + BUG();
2852 }
2853
2854 /*
2855 @@ -236,7 +236,7 @@ void machine_power_off(void)
2856 * executing pre-reset code, and using RAM that the primary CPU's code wishes
2857 * to use. Implementing such co-ordination would be essentially impossible.
2858 */
2859 -void machine_restart(char *cmd)
2860 +__noreturn void machine_restart(char *cmd)
2861 {
2862 smp_send_stop();
2863
2864 @@ -258,8 +258,8 @@ void __show_regs(struct pt_regs *regs)
2865
2866 show_regs_print_info(KERN_DEFAULT);
2867
2868 - print_symbol("PC is at %s\n", instruction_pointer(regs));
2869 - print_symbol("LR is at %s\n", regs->ARM_lr);
2870 + printk("PC is at %pA\n", instruction_pointer(regs));
2871 + printk("LR is at %pA\n", regs->ARM_lr);
2872 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2873 "sp : %08lx ip : %08lx fp : %08lx\n",
2874 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2875 @@ -426,12 +426,6 @@ unsigned long get_wchan(struct task_struct *p)
2876 return 0;
2877 }
2878
2879 -unsigned long arch_randomize_brk(struct mm_struct *mm)
2880 -{
2881 - unsigned long range_end = mm->brk + 0x02000000;
2882 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2883 -}
2884 -
2885 #ifdef CONFIG_MMU
2886 /*
2887 * The vectors page is always readable from user space for the
2888 @@ -441,12 +435,12 @@ unsigned long arch_randomize_brk(struct mm_struct *mm)
2889 static struct vm_area_struct gate_vma = {
2890 .vm_start = 0xffff0000,
2891 .vm_end = 0xffff0000 + PAGE_SIZE,
2892 - .vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC,
2893 + .vm_flags = VM_NONE,
2894 };
2895
2896 static int __init gate_vma_init(void)
2897 {
2898 - gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2899 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2900 return 0;
2901 }
2902 arch_initcall(gate_vma_init);
2903 diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
2904 index 3653164..d83e55d 100644
2905 --- a/arch/arm/kernel/psci.c
2906 +++ b/arch/arm/kernel/psci.c
2907 @@ -24,7 +24,7 @@
2908 #include <asm/opcodes-virt.h>
2909 #include <asm/psci.h>
2910
2911 -struct psci_operations psci_ops;
2912 +struct psci_operations psci_ops __read_only;
2913
2914 static int (*invoke_psci_fn)(u32, u32, u32, u32);
2915
2916 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
2917 index 03deeff..741ce88 100644
2918 --- a/arch/arm/kernel/ptrace.c
2919 +++ b/arch/arm/kernel/ptrace.c
2920 @@ -937,10 +937,19 @@ static int tracehook_report_syscall(struct pt_regs *regs,
2921 return current_thread_info()->syscall;
2922 }
2923
2924 +#ifdef CONFIG_GRKERNSEC_SETXID
2925 +extern void gr_delayed_cred_worker(void);
2926 +#endif
2927 +
2928 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
2929 {
2930 current_thread_info()->syscall = scno;
2931
2932 +#ifdef CONFIG_GRKERNSEC_SETXID
2933 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
2934 + gr_delayed_cred_worker();
2935 +#endif
2936 +
2937 /* Do the secure computing check first; failures should be fast. */
2938 if (secure_computing(scno) == -1)
2939 return -1;
2940 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
2941 index b4b1d39..efdc9be 100644
2942 --- a/arch/arm/kernel/setup.c
2943 +++ b/arch/arm/kernel/setup.c
2944 @@ -97,21 +97,23 @@ EXPORT_SYMBOL(system_serial_high);
2945 unsigned int elf_hwcap __read_mostly;
2946 EXPORT_SYMBOL(elf_hwcap);
2947
2948 +pteval_t __supported_pte_mask __read_only;
2949 +pmdval_t __supported_pmd_mask __read_only;
2950
2951 #ifdef MULTI_CPU
2952 -struct processor processor __read_mostly;
2953 +struct processor processor;
2954 #endif
2955 #ifdef MULTI_TLB
2956 -struct cpu_tlb_fns cpu_tlb __read_mostly;
2957 +struct cpu_tlb_fns cpu_tlb __read_only;
2958 #endif
2959 #ifdef MULTI_USER
2960 -struct cpu_user_fns cpu_user __read_mostly;
2961 +struct cpu_user_fns cpu_user __read_only;
2962 #endif
2963 #ifdef MULTI_CACHE
2964 -struct cpu_cache_fns cpu_cache __read_mostly;
2965 +struct cpu_cache_fns cpu_cache __read_only;
2966 #endif
2967 #ifdef CONFIG_OUTER_CACHE
2968 -struct outer_cache_fns outer_cache __read_mostly;
2969 +struct outer_cache_fns outer_cache __read_only;
2970 EXPORT_SYMBOL(outer_cache);
2971 #endif
2972
2973 @@ -236,9 +238,13 @@ static int __get_cpu_architecture(void)
2974 asm("mrc p15, 0, %0, c0, c1, 4"
2975 : "=r" (mmfr0));
2976 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
2977 - (mmfr0 & 0x000000f0) >= 0x00000030)
2978 + (mmfr0 & 0x000000f0) >= 0x00000030) {
2979 cpu_arch = CPU_ARCH_ARMv7;
2980 - else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
2981 + if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
2982 + __supported_pte_mask |= L_PTE_PXN;
2983 + __supported_pmd_mask |= PMD_PXNTABLE;
2984 + }
2985 + } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
2986 (mmfr0 & 0x000000f0) == 0x00000020)
2987 cpu_arch = CPU_ARCH_ARMv6;
2988 else
2989 @@ -479,7 +485,7 @@ static void __init setup_processor(void)
2990 __cpu_architecture = __get_cpu_architecture();
2991
2992 #ifdef MULTI_CPU
2993 - processor = *list->proc;
2994 + memcpy((void *)&processor, list->proc, sizeof processor);
2995 #endif
2996 #ifdef MULTI_TLB
2997 cpu_tlb = *list->tlb;
2998 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
2999 index 296786b..a8d4dd5 100644
3000 --- a/arch/arm/kernel/signal.c
3001 +++ b/arch/arm/kernel/signal.c
3002 @@ -396,22 +396,14 @@ setup_return(struct pt_regs *regs, struct ksignal *ksig,
3003 __put_user(sigreturn_codes[idx+1], rc+1))
3004 return 1;
3005
3006 - if (cpsr & MODE32_BIT) {
3007 - /*
3008 - * 32-bit code can use the new high-page
3009 - * signal return code support.
3010 - */
3011 - retcode = KERN_SIGRETURN_CODE + (idx << 2) + thumb;
3012 - } else {
3013 - /*
3014 - * Ensure that the instruction cache sees
3015 - * the return code written onto the stack.
3016 - */
3017 - flush_icache_range((unsigned long)rc,
3018 - (unsigned long)(rc + 2));
3019 + /*
3020 + * Ensure that the instruction cache sees
3021 + * the return code written onto the stack.
3022 + */
3023 + flush_icache_range((unsigned long)rc,
3024 + (unsigned long)(rc + 2));
3025
3026 - retcode = ((unsigned long)rc) + thumb;
3027 - }
3028 + retcode = ((unsigned long)rc) + thumb;
3029 }
3030
3031 regs->ARM_r0 = map_sig(ksig->sig);
3032 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
3033 index 5919eb4..b5d6dfe 100644
3034 --- a/arch/arm/kernel/smp.c
3035 +++ b/arch/arm/kernel/smp.c
3036 @@ -70,7 +70,7 @@ enum ipi_msg_type {
3037
3038 static DECLARE_COMPLETION(cpu_running);
3039
3040 -static struct smp_operations smp_ops;
3041 +static struct smp_operations smp_ops __read_only;
3042
3043 void __init smp_set_ops(struct smp_operations *ops)
3044 {
3045 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
3046 index 18b32e8..b0c8dca 100644
3047 --- a/arch/arm/kernel/traps.c
3048 +++ b/arch/arm/kernel/traps.c
3049 @@ -57,7 +57,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
3050 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
3051 {
3052 #ifdef CONFIG_KALLSYMS
3053 - printk("[<%08lx>] (%pS) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
3054 + printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
3055 #else
3056 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
3057 #endif
3058 @@ -259,6 +259,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
3059 static int die_owner = -1;
3060 static unsigned int die_nest_count;
3061
3062 +extern void gr_handle_kernel_exploit(void);
3063 +
3064 static unsigned long oops_begin(void)
3065 {
3066 int cpu;
3067 @@ -301,6 +303,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3068 panic("Fatal exception in interrupt");
3069 if (panic_on_oops)
3070 panic("Fatal exception");
3071 +
3072 + gr_handle_kernel_exploit();
3073 +
3074 if (signr)
3075 do_exit(signr);
3076 }
3077 @@ -594,7 +599,9 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
3078 * The user helper at 0xffff0fe0 must be used instead.
3079 * (see entry-armv.S for details)
3080 */
3081 + pax_open_kernel();
3082 *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
3083 + pax_close_kernel();
3084 }
3085 return 0;
3086
3087 @@ -834,13 +841,10 @@ void __init early_trap_init(void *vectors_base)
3088 */
3089 kuser_get_tls_init(vectors);
3090
3091 - /*
3092 - * Copy signal return handlers into the vector page, and
3093 - * set sigreturn to be a pointer to these.
3094 - */
3095 - memcpy((void *)(vectors + KERN_SIGRETURN_CODE - CONFIG_VECTORS_BASE),
3096 - sigreturn_codes, sizeof(sigreturn_codes));
3097 -
3098 flush_icache_range(vectors, vectors + PAGE_SIZE);
3099 - modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3100 +
3101 +#ifndef CONFIG_PAX_MEMORY_UDEREF
3102 + modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3103 +#endif
3104 +
3105 }
3106 diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3107 index a871b8e..123b00a 100644
3108 --- a/arch/arm/kernel/vmlinux.lds.S
3109 +++ b/arch/arm/kernel/vmlinux.lds.S
3110 @@ -8,7 +8,11 @@
3111 #include <asm/thread_info.h>
3112 #include <asm/memory.h>
3113 #include <asm/page.h>
3114 -
3115 +
3116 +#ifdef CONFIG_PAX_KERNEXEC
3117 +#include <asm/pgtable.h>
3118 +#endif
3119 +
3120 #define PROC_INFO \
3121 . = ALIGN(4); \
3122 VMLINUX_SYMBOL(__proc_info_begin) = .; \
3123 @@ -94,6 +98,11 @@ SECTIONS
3124 _text = .;
3125 HEAD_TEXT
3126 }
3127 +
3128 +#ifdef CONFIG_PAX_KERNEXEC
3129 + . = ALIGN(1<<SECTION_SHIFT);
3130 +#endif
3131 +
3132 .text : { /* Real text segment */
3133 _stext = .; /* Text and read-only data */
3134 __exception_text_start = .;
3135 @@ -116,6 +125,8 @@ SECTIONS
3136 ARM_CPU_KEEP(PROC_INFO)
3137 }
3138
3139 + _etext = .; /* End of text section */
3140 +
3141 RO_DATA(PAGE_SIZE)
3142
3143 . = ALIGN(4);
3144 @@ -146,7 +157,9 @@ SECTIONS
3145
3146 NOTES
3147
3148 - _etext = .; /* End of text and rodata section */
3149 +#ifdef CONFIG_PAX_KERNEXEC
3150 + . = ALIGN(1<<SECTION_SHIFT);
3151 +#endif
3152
3153 #ifndef CONFIG_XIP_KERNEL
3154 . = ALIGN(PAGE_SIZE);
3155 @@ -207,6 +220,11 @@ SECTIONS
3156 . = PAGE_OFFSET + TEXT_OFFSET;
3157 #else
3158 __init_end = .;
3159 +
3160 +#ifdef CONFIG_PAX_KERNEXEC
3161 + . = ALIGN(1<<SECTION_SHIFT);
3162 +#endif
3163 +
3164 . = ALIGN(THREAD_SIZE);
3165 __data_loc = .;
3166 #endif
3167 diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3168 index 14a0d98..7771a7d 100644
3169 --- a/arch/arm/lib/clear_user.S
3170 +++ b/arch/arm/lib/clear_user.S
3171 @@ -12,14 +12,14 @@
3172
3173 .text
3174
3175 -/* Prototype: int __clear_user(void *addr, size_t sz)
3176 +/* Prototype: int ___clear_user(void *addr, size_t sz)
3177 * Purpose : clear some user memory
3178 * Params : addr - user memory address to clear
3179 * : sz - number of bytes to clear
3180 * Returns : number of bytes NOT cleared
3181 */
3182 ENTRY(__clear_user_std)
3183 -WEAK(__clear_user)
3184 +WEAK(___clear_user)
3185 stmfd sp!, {r1, lr}
3186 mov r2, #0
3187 cmp r1, #4
3188 @@ -44,7 +44,7 @@ WEAK(__clear_user)
3189 USER( strnebt r2, [r0])
3190 mov r0, #0
3191 ldmfd sp!, {r1, pc}
3192 -ENDPROC(__clear_user)
3193 +ENDPROC(___clear_user)
3194 ENDPROC(__clear_user_std)
3195
3196 .pushsection .fixup,"ax"
3197 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3198 index 66a477a..bee61d3 100644
3199 --- a/arch/arm/lib/copy_from_user.S
3200 +++ b/arch/arm/lib/copy_from_user.S
3201 @@ -16,7 +16,7 @@
3202 /*
3203 * Prototype:
3204 *
3205 - * size_t __copy_from_user(void *to, const void *from, size_t n)
3206 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
3207 *
3208 * Purpose:
3209 *
3210 @@ -84,11 +84,11 @@
3211
3212 .text
3213
3214 -ENTRY(__copy_from_user)
3215 +ENTRY(___copy_from_user)
3216
3217 #include "copy_template.S"
3218
3219 -ENDPROC(__copy_from_user)
3220 +ENDPROC(___copy_from_user)
3221
3222 .pushsection .fixup,"ax"
3223 .align 0
3224 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3225 index 6ee2f67..d1cce76 100644
3226 --- a/arch/arm/lib/copy_page.S
3227 +++ b/arch/arm/lib/copy_page.S
3228 @@ -10,6 +10,7 @@
3229 * ASM optimised string functions
3230 */
3231 #include <linux/linkage.h>
3232 +#include <linux/const.h>
3233 #include <asm/assembler.h>
3234 #include <asm/asm-offsets.h>
3235 #include <asm/cache.h>
3236 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3237 index d066df6..df28194 100644
3238 --- a/arch/arm/lib/copy_to_user.S
3239 +++ b/arch/arm/lib/copy_to_user.S
3240 @@ -16,7 +16,7 @@
3241 /*
3242 * Prototype:
3243 *
3244 - * size_t __copy_to_user(void *to, const void *from, size_t n)
3245 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
3246 *
3247 * Purpose:
3248 *
3249 @@ -88,11 +88,11 @@
3250 .text
3251
3252 ENTRY(__copy_to_user_std)
3253 -WEAK(__copy_to_user)
3254 +WEAK(___copy_to_user)
3255
3256 #include "copy_template.S"
3257
3258 -ENDPROC(__copy_to_user)
3259 +ENDPROC(___copy_to_user)
3260 ENDPROC(__copy_to_user_std)
3261
3262 .pushsection .fixup,"ax"
3263 diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3264 index 7d08b43..f7ca7ea 100644
3265 --- a/arch/arm/lib/csumpartialcopyuser.S
3266 +++ b/arch/arm/lib/csumpartialcopyuser.S
3267 @@ -57,8 +57,8 @@
3268 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3269 */
3270
3271 -#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3272 -#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3273 +#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3274 +#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3275
3276 #include "csumpartialcopygeneric.S"
3277
3278 diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3279 index 64dbfa5..84a3fd9 100644
3280 --- a/arch/arm/lib/delay.c
3281 +++ b/arch/arm/lib/delay.c
3282 @@ -28,7 +28,7 @@
3283 /*
3284 * Default to the loop-based delay implementation.
3285 */
3286 -struct arm_delay_ops arm_delay_ops = {
3287 +struct arm_delay_ops arm_delay_ops __read_only = {
3288 .delay = __loop_delay,
3289 .const_udelay = __loop_const_udelay,
3290 .udelay = __loop_udelay,
3291 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3292 index 025f742..8432b08 100644
3293 --- a/arch/arm/lib/uaccess_with_memcpy.c
3294 +++ b/arch/arm/lib/uaccess_with_memcpy.c
3295 @@ -104,7 +104,7 @@ out:
3296 }
3297
3298 unsigned long
3299 -__copy_to_user(void __user *to, const void *from, unsigned long n)
3300 +___copy_to_user(void __user *to, const void *from, unsigned long n)
3301 {
3302 /*
3303 * This test is stubbed out of the main function above to keep
3304 diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
3305 index f389228..592ef66 100644
3306 --- a/arch/arm/mach-kirkwood/common.c
3307 +++ b/arch/arm/mach-kirkwood/common.c
3308 @@ -149,7 +149,16 @@ static void clk_gate_fn_disable(struct clk_hw *hw)
3309 clk_gate_ops.disable(hw);
3310 }
3311
3312 -static struct clk_ops clk_gate_fn_ops;
3313 +static int clk_gate_fn_is_enabled(struct clk_hw *hw)
3314 +{
3315 + return clk_gate_ops.is_enabled(hw);
3316 +}
3317 +
3318 +static struct clk_ops clk_gate_fn_ops = {
3319 + .enable = clk_gate_fn_enable,
3320 + .disable = clk_gate_fn_disable,
3321 + .is_enabled = clk_gate_fn_is_enabled,
3322 +};
3323
3324 static struct clk __init *clk_register_gate_fn(struct device *dev,
3325 const char *name,
3326 @@ -183,14 +192,6 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
3327 gate_fn->fn_en = fn_en;
3328 gate_fn->fn_dis = fn_dis;
3329
3330 - /* ops is the gate ops, but with our enable/disable functions */
3331 - if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
3332 - clk_gate_fn_ops.disable != clk_gate_fn_disable) {
3333 - clk_gate_fn_ops = clk_gate_ops;
3334 - clk_gate_fn_ops.enable = clk_gate_fn_enable;
3335 - clk_gate_fn_ops.disable = clk_gate_fn_disable;
3336 - }
3337 -
3338 clk = clk_register(dev, &gate_fn->gate.hw);
3339
3340 if (IS_ERR(clk))
3341 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3342 index f6eeb87..cc90868 100644
3343 --- a/arch/arm/mach-omap2/board-n8x0.c
3344 +++ b/arch/arm/mach-omap2/board-n8x0.c
3345 @@ -631,7 +631,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3346 }
3347 #endif
3348
3349 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3350 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3351 .late_init = n8x0_menelaus_late_init,
3352 };
3353
3354 diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
3355 index 6c4da12..d9ca72d 100644
3356 --- a/arch/arm/mach-omap2/gpmc.c
3357 +++ b/arch/arm/mach-omap2/gpmc.c
3358 @@ -147,7 +147,6 @@ struct omap3_gpmc_regs {
3359 };
3360
3361 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
3362 -static struct irq_chip gpmc_irq_chip;
3363 static unsigned gpmc_irq_start;
3364
3365 static struct resource gpmc_mem_root;
3366 @@ -711,6 +710,18 @@ static void gpmc_irq_noop(struct irq_data *data) { }
3367
3368 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
3369
3370 +static struct irq_chip gpmc_irq_chip = {
3371 + .name = "gpmc",
3372 + .irq_startup = gpmc_irq_noop_ret,
3373 + .irq_enable = gpmc_irq_enable,
3374 + .irq_disable = gpmc_irq_disable,
3375 + .irq_shutdown = gpmc_irq_noop,
3376 + .irq_ack = gpmc_irq_noop,
3377 + .irq_mask = gpmc_irq_noop,
3378 + .irq_unmask = gpmc_irq_noop,
3379 +
3380 +};
3381 +
3382 static int gpmc_setup_irq(void)
3383 {
3384 int i;
3385 @@ -725,15 +736,6 @@ static int gpmc_setup_irq(void)
3386 return gpmc_irq_start;
3387 }
3388
3389 - gpmc_irq_chip.name = "gpmc";
3390 - gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
3391 - gpmc_irq_chip.irq_enable = gpmc_irq_enable;
3392 - gpmc_irq_chip.irq_disable = gpmc_irq_disable;
3393 - gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
3394 - gpmc_irq_chip.irq_ack = gpmc_irq_noop;
3395 - gpmc_irq_chip.irq_mask = gpmc_irq_noop;
3396 - gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
3397 -
3398 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
3399 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
3400
3401 diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3402 index f8bb3b9..831e7b8 100644
3403 --- a/arch/arm/mach-omap2/omap-wakeupgen.c
3404 +++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3405 @@ -339,7 +339,7 @@ static int __cpuinit irq_cpu_hotplug_notify(struct notifier_block *self,
3406 return NOTIFY_OK;
3407 }
3408
3409 -static struct notifier_block __refdata irq_hotplug_notifier = {
3410 +static struct notifier_block irq_hotplug_notifier = {
3411 .notifier_call = irq_cpu_hotplug_notify,
3412 };
3413
3414 diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3415 index e6d2307..d057195 100644
3416 --- a/arch/arm/mach-omap2/omap_device.c
3417 +++ b/arch/arm/mach-omap2/omap_device.c
3418 @@ -499,7 +499,7 @@ void omap_device_delete(struct omap_device *od)
3419 struct platform_device __init *omap_device_build(const char *pdev_name,
3420 int pdev_id,
3421 struct omap_hwmod *oh,
3422 - void *pdata, int pdata_len)
3423 + const void *pdata, int pdata_len)
3424 {
3425 struct omap_hwmod *ohs[] = { oh };
3426
3427 @@ -527,7 +527,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name,
3428 struct platform_device __init *omap_device_build_ss(const char *pdev_name,
3429 int pdev_id,
3430 struct omap_hwmod **ohs,
3431 - int oh_cnt, void *pdata,
3432 + int oh_cnt, const void *pdata,
3433 int pdata_len)
3434 {
3435 int ret = -ENOMEM;
3436 diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3437 index 044c31d..2ee0861 100644
3438 --- a/arch/arm/mach-omap2/omap_device.h
3439 +++ b/arch/arm/mach-omap2/omap_device.h
3440 @@ -72,12 +72,12 @@ int omap_device_idle(struct platform_device *pdev);
3441 /* Core code interface */
3442
3443 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3444 - struct omap_hwmod *oh, void *pdata,
3445 + struct omap_hwmod *oh, const void *pdata,
3446 int pdata_len);
3447
3448 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3449 struct omap_hwmod **oh, int oh_cnt,
3450 - void *pdata, int pdata_len);
3451 + const void *pdata, int pdata_len);
3452
3453 struct omap_device *omap_device_alloc(struct platform_device *pdev,
3454 struct omap_hwmod **ohs, int oh_cnt);
3455 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3456 index 7341eff..fd75e34 100644
3457 --- a/arch/arm/mach-omap2/omap_hwmod.c
3458 +++ b/arch/arm/mach-omap2/omap_hwmod.c
3459 @@ -194,10 +194,10 @@ struct omap_hwmod_soc_ops {
3460 int (*init_clkdm)(struct omap_hwmod *oh);
3461 void (*update_context_lost)(struct omap_hwmod *oh);
3462 int (*get_context_lost)(struct omap_hwmod *oh);
3463 -};
3464 +} __no_const;
3465
3466 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3467 -static struct omap_hwmod_soc_ops soc_ops;
3468 +static struct omap_hwmod_soc_ops soc_ops __read_only;
3469
3470 /* omap_hwmod_list contains all registered struct omap_hwmods */
3471 static LIST_HEAD(omap_hwmod_list);
3472 diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3473 index d15c7bb..b2d1f0c 100644
3474 --- a/arch/arm/mach-omap2/wd_timer.c
3475 +++ b/arch/arm/mach-omap2/wd_timer.c
3476 @@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3477 struct omap_hwmod *oh;
3478 char *oh_name = "wd_timer2";
3479 char *dev_name = "omap_wdt";
3480 - struct omap_wd_timer_platform_data pdata;
3481 + static struct omap_wd_timer_platform_data pdata = {
3482 + .read_reset_sources = prm_read_reset_sources
3483 + };
3484
3485 if (!cpu_class_is_omap2() || of_have_populated_dt())
3486 return 0;
3487 @@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3488 return -EINVAL;
3489 }
3490
3491 - pdata.read_reset_sources = prm_read_reset_sources;
3492 -
3493 pdev = omap_device_build(dev_name, id, oh, &pdata,
3494 sizeof(struct omap_wd_timer_platform_data));
3495 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
3496 diff --git a/arch/arm/mach-tegra/cpuidle-tegra20.c b/arch/arm/mach-tegra/cpuidle-tegra20.c
3497 index 0cdba8d..297993e 100644
3498 --- a/arch/arm/mach-tegra/cpuidle-tegra20.c
3499 +++ b/arch/arm/mach-tegra/cpuidle-tegra20.c
3500 @@ -181,7 +181,7 @@ static int tegra20_idle_lp2_coupled(struct cpuidle_device *dev,
3501 bool entered_lp2 = false;
3502
3503 if (tegra_pending_sgi())
3504 - ACCESS_ONCE(abort_flag) = true;
3505 + ACCESS_ONCE_RW(abort_flag) = true;
3506
3507 cpuidle_coupled_parallel_barrier(dev, &abort_barrier);
3508
3509 diff --git a/arch/arm/mach-ux500/setup.h b/arch/arm/mach-ux500/setup.h
3510 index cad3ca86..1d79e0f 100644
3511 --- a/arch/arm/mach-ux500/setup.h
3512 +++ b/arch/arm/mach-ux500/setup.h
3513 @@ -37,13 +37,6 @@ extern void ux500_timer_init(void);
3514 .type = MT_DEVICE, \
3515 }
3516
3517 -#define __MEM_DEV_DESC(x, sz) { \
3518 - .virtual = IO_ADDRESS(x), \
3519 - .pfn = __phys_to_pfn(x), \
3520 - .length = sz, \
3521 - .type = MT_MEMORY, \
3522 -}
3523 -
3524 extern struct smp_operations ux500_smp_ops;
3525 extern void ux500_cpu_die(unsigned int cpu);
3526
3527 diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3528 index 35955b5..b475042 100644
3529 --- a/arch/arm/mm/Kconfig
3530 +++ b/arch/arm/mm/Kconfig
3531 @@ -432,7 +432,7 @@ config CPU_32v5
3532
3533 config CPU_32v6
3534 bool
3535 - select CPU_USE_DOMAINS if CPU_V6 && MMU
3536 + select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3537 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3538
3539 config CPU_32v6K
3540 @@ -581,6 +581,7 @@ config CPU_CP15_MPU
3541
3542 config CPU_USE_DOMAINS
3543 bool
3544 + depends on !ARM_LPAE && !PAX_KERNEXEC
3545 help
3546 This option enables or disables the use of domain switching
3547 via the set_fs() function.
3548 diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3549 index 6f4585b..7b6f52b 100644
3550 --- a/arch/arm/mm/alignment.c
3551 +++ b/arch/arm/mm/alignment.c
3552 @@ -211,10 +211,12 @@ union offset_union {
3553 #define __get16_unaligned_check(ins,val,addr) \
3554 do { \
3555 unsigned int err = 0, v, a = addr; \
3556 + pax_open_userland(); \
3557 __get8_unaligned_check(ins,v,a,err); \
3558 val = v << ((BE) ? 8 : 0); \
3559 __get8_unaligned_check(ins,v,a,err); \
3560 val |= v << ((BE) ? 0 : 8); \
3561 + pax_close_userland(); \
3562 if (err) \
3563 goto fault; \
3564 } while (0)
3565 @@ -228,6 +230,7 @@ union offset_union {
3566 #define __get32_unaligned_check(ins,val,addr) \
3567 do { \
3568 unsigned int err = 0, v, a = addr; \
3569 + pax_open_userland(); \
3570 __get8_unaligned_check(ins,v,a,err); \
3571 val = v << ((BE) ? 24 : 0); \
3572 __get8_unaligned_check(ins,v,a,err); \
3573 @@ -236,6 +239,7 @@ union offset_union {
3574 val |= v << ((BE) ? 8 : 16); \
3575 __get8_unaligned_check(ins,v,a,err); \
3576 val |= v << ((BE) ? 0 : 24); \
3577 + pax_close_userland(); \
3578 if (err) \
3579 goto fault; \
3580 } while (0)
3581 @@ -249,6 +253,7 @@ union offset_union {
3582 #define __put16_unaligned_check(ins,val,addr) \
3583 do { \
3584 unsigned int err = 0, v = val, a = addr; \
3585 + pax_open_userland(); \
3586 __asm__( FIRST_BYTE_16 \
3587 ARM( "1: "ins" %1, [%2], #1\n" ) \
3588 THUMB( "1: "ins" %1, [%2]\n" ) \
3589 @@ -268,6 +273,7 @@ union offset_union {
3590 " .popsection\n" \
3591 : "=r" (err), "=&r" (v), "=&r" (a) \
3592 : "0" (err), "1" (v), "2" (a)); \
3593 + pax_close_userland(); \
3594 if (err) \
3595 goto fault; \
3596 } while (0)
3597 @@ -281,6 +287,7 @@ union offset_union {
3598 #define __put32_unaligned_check(ins,val,addr) \
3599 do { \
3600 unsigned int err = 0, v = val, a = addr; \
3601 + pax_open_userland(); \
3602 __asm__( FIRST_BYTE_32 \
3603 ARM( "1: "ins" %1, [%2], #1\n" ) \
3604 THUMB( "1: "ins" %1, [%2]\n" ) \
3605 @@ -310,6 +317,7 @@ union offset_union {
3606 " .popsection\n" \
3607 : "=r" (err), "=&r" (v), "=&r" (a) \
3608 : "0" (err), "1" (v), "2" (a)); \
3609 + pax_close_userland(); \
3610 if (err) \
3611 goto fault; \
3612 } while (0)
3613 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
3614 index 5dbf13f..1a60561 100644
3615 --- a/arch/arm/mm/fault.c
3616 +++ b/arch/arm/mm/fault.c
3617 @@ -25,6 +25,7 @@
3618 #include <asm/system_misc.h>
3619 #include <asm/system_info.h>
3620 #include <asm/tlbflush.h>
3621 +#include <asm/sections.h>
3622
3623 #include "fault.h"
3624
3625 @@ -138,6 +139,20 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
3626 if (fixup_exception(regs))
3627 return;
3628
3629 +#ifdef CONFIG_PAX_KERNEXEC
3630 + if ((fsr & FSR_WRITE) &&
3631 + (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
3632 + (MODULES_VADDR <= addr && addr < MODULES_END)))
3633 + {
3634 + if (current->signal->curr_ip)
3635 + 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),
3636 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3637 + else
3638 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
3639 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3640 + }
3641 +#endif
3642 +
3643 /*
3644 * No handler, we'll have to terminate things with extreme prejudice.
3645 */
3646 @@ -174,6 +189,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
3647 }
3648 #endif
3649
3650 +#ifdef CONFIG_PAX_PAGEEXEC
3651 + if (fsr & FSR_LNX_PF) {
3652 + pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
3653 + do_group_exit(SIGKILL);
3654 + }
3655 +#endif
3656 +
3657 tsk->thread.address = addr;
3658 tsk->thread.error_code = fsr;
3659 tsk->thread.trap_no = 14;
3660 @@ -398,6 +420,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3661 }
3662 #endif /* CONFIG_MMU */
3663
3664 +#ifdef CONFIG_PAX_PAGEEXEC
3665 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3666 +{
3667 + long i;
3668 +
3669 + printk(KERN_ERR "PAX: bytes at PC: ");
3670 + for (i = 0; i < 20; i++) {
3671 + unsigned char c;
3672 + if (get_user(c, (__force unsigned char __user *)pc+i))
3673 + printk(KERN_CONT "?? ");
3674 + else
3675 + printk(KERN_CONT "%02x ", c);
3676 + }
3677 + printk("\n");
3678 +
3679 + printk(KERN_ERR "PAX: bytes at SP-4: ");
3680 + for (i = -1; i < 20; i++) {
3681 + unsigned long c;
3682 + if (get_user(c, (__force unsigned long __user *)sp+i))
3683 + printk(KERN_CONT "???????? ");
3684 + else
3685 + printk(KERN_CONT "%08lx ", c);
3686 + }
3687 + printk("\n");
3688 +}
3689 +#endif
3690 +
3691 /*
3692 * First Level Translation Fault Handler
3693 *
3694 @@ -543,9 +592,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3695 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
3696 struct siginfo info;
3697
3698 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3699 + if (addr < TASK_SIZE && is_domain_fault(fsr)) {
3700 + if (current->signal->curr_ip)
3701 + 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),
3702 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3703 + else
3704 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3705 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3706 + goto die;
3707 + }
3708 +#endif
3709 +
3710 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
3711 return;
3712
3713 +die:
3714 printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
3715 inf->name, fsr, addr);
3716
3717 @@ -575,9 +637,49 @@ do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
3718 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
3719 struct siginfo info;
3720
3721 + if (user_mode(regs)) {
3722 + if (addr == 0xffff0fe0UL) {
3723 + /*
3724 + * PaX: __kuser_get_tls emulation
3725 + */
3726 + regs->ARM_r0 = current_thread_info()->tp_value;
3727 + regs->ARM_pc = regs->ARM_lr;
3728 + return;
3729 + }
3730 + }
3731 +
3732 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3733 + else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
3734 + if (current->signal->curr_ip)
3735 + 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),
3736 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3737 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3738 + else
3739 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
3740 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3741 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3742 + goto die;
3743 + }
3744 +#endif
3745 +
3746 +#ifdef CONFIG_PAX_REFCOUNT
3747 + if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
3748 + unsigned int bkpt;
3749 +
3750 + if (!probe_kernel_address((unsigned int *)addr, bkpt) && bkpt == 0xe12f1073) {
3751 + current->thread.error_code = ifsr;
3752 + current->thread.trap_no = 0;
3753 + pax_report_refcount_overflow(regs);
3754 + fixup_exception(regs);
3755 + return;
3756 + }
3757 + }
3758 +#endif
3759 +
3760 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
3761 return;
3762
3763 +die:
3764 printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
3765 inf->name, ifsr, addr);
3766
3767 diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
3768 index cf08bdf..772656c 100644
3769 --- a/arch/arm/mm/fault.h
3770 +++ b/arch/arm/mm/fault.h
3771 @@ -3,6 +3,7 @@
3772
3773 /*
3774 * Fault status register encodings. We steal bit 31 for our own purposes.
3775 + * Set when the FSR value is from an instruction fault.
3776 */
3777 #define FSR_LNX_PF (1 << 31)
3778 #define FSR_WRITE (1 << 11)
3779 @@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
3780 }
3781 #endif
3782
3783 +/* valid for LPAE and !LPAE */
3784 +static inline int is_xn_fault(unsigned int fsr)
3785 +{
3786 + return ((fsr_fs(fsr) & 0x3c) == 0xc);
3787 +}
3788 +
3789 +static inline int is_domain_fault(unsigned int fsr)
3790 +{
3791 + return ((fsr_fs(fsr) & 0xD) == 0x9);
3792 +}
3793 +
3794 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
3795 unsigned long search_exception_table(unsigned long addr);
3796
3797 diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
3798 index 9a5cdc0..a1182cf 100644
3799 --- a/arch/arm/mm/init.c
3800 +++ b/arch/arm/mm/init.c
3801 @@ -30,6 +30,8 @@
3802 #include <asm/setup.h>
3803 #include <asm/tlb.h>
3804 #include <asm/fixmap.h>
3805 +#include <asm/system_info.h>
3806 +#include <asm/cp15.h>
3807
3808 #include <asm/mach/arch.h>
3809 #include <asm/mach/map.h>
3810 @@ -726,7 +728,46 @@ void free_initmem(void)
3811 {
3812 #ifdef CONFIG_HAVE_TCM
3813 extern char __tcm_start, __tcm_end;
3814 +#endif
3815
3816 +#ifdef CONFIG_PAX_KERNEXEC
3817 + unsigned long addr;
3818 + pgd_t *pgd;
3819 + pud_t *pud;
3820 + pmd_t *pmd;
3821 + int cpu_arch = cpu_architecture();
3822 + unsigned int cr = get_cr();
3823 +
3824 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
3825 + /* make pages tables, etc before .text NX */
3826 + for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
3827 + pgd = pgd_offset_k(addr);
3828 + pud = pud_offset(pgd, addr);
3829 + pmd = pmd_offset(pud, addr);
3830 + __section_update(pmd, addr, PMD_SECT_XN);
3831 + }
3832 + /* make init NX */
3833 + for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
3834 + pgd = pgd_offset_k(addr);
3835 + pud = pud_offset(pgd, addr);
3836 + pmd = pmd_offset(pud, addr);
3837 + __section_update(pmd, addr, PMD_SECT_XN);
3838 + }
3839 + /* make kernel code/rodata RX */
3840 + for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
3841 + pgd = pgd_offset_k(addr);
3842 + pud = pud_offset(pgd, addr);
3843 + pmd = pmd_offset(pud, addr);
3844 +#ifdef CONFIG_ARM_LPAE
3845 + __section_update(pmd, addr, PMD_SECT_RDONLY);
3846 +#else
3847 + __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
3848 +#endif
3849 + }
3850 + }
3851 +#endif
3852 +
3853 +#ifdef CONFIG_HAVE_TCM
3854 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
3855 free_reserved_area(&__tcm_start, &__tcm_end, 0, "TCM link");
3856 #endif
3857 diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
3858 index 04d9006..c547d85 100644
3859 --- a/arch/arm/mm/ioremap.c
3860 +++ b/arch/arm/mm/ioremap.c
3861 @@ -392,9 +392,9 @@ __arm_ioremap_exec(unsigned long phys_addr, size_t size, bool cached)
3862 unsigned int mtype;
3863
3864 if (cached)
3865 - mtype = MT_MEMORY;
3866 + mtype = MT_MEMORY_RX;
3867 else
3868 - mtype = MT_MEMORY_NONCACHED;
3869 + mtype = MT_MEMORY_NONCACHED_RX;
3870
3871 return __arm_ioremap_caller(phys_addr, size, mtype,
3872 __builtin_return_address(0));
3873 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
3874 index 10062ce..8695745 100644
3875 --- a/arch/arm/mm/mmap.c
3876 +++ b/arch/arm/mm/mmap.c
3877 @@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3878 struct vm_area_struct *vma;
3879 int do_align = 0;
3880 int aliasing = cache_is_vipt_aliasing();
3881 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
3882 struct vm_unmapped_area_info info;
3883
3884 /*
3885 @@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3886 if (len > TASK_SIZE)
3887 return -ENOMEM;
3888
3889 +#ifdef CONFIG_PAX_RANDMMAP
3890 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
3891 +#endif
3892 +
3893 if (addr) {
3894 if (do_align)
3895 addr = COLOUR_ALIGN(addr, pgoff);
3896 @@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3897 addr = PAGE_ALIGN(addr);
3898
3899 vma = find_vma(mm, addr);
3900 - if (TASK_SIZE - len >= addr &&
3901 - (!vma || addr + len <= vma->vm_start))
3902 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
3903 return addr;
3904 }
3905
3906 @@ -99,6 +103,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
3907 info.high_limit = TASK_SIZE;
3908 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
3909 info.align_offset = pgoff << PAGE_SHIFT;
3910 + info.threadstack_offset = offset;
3911 return vm_unmapped_area(&info);
3912 }
3913
3914 @@ -112,6 +117,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3915 unsigned long addr = addr0;
3916 int do_align = 0;
3917 int aliasing = cache_is_vipt_aliasing();
3918 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
3919 struct vm_unmapped_area_info info;
3920
3921 /*
3922 @@ -132,6 +138,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3923 return addr;
3924 }
3925
3926 +#ifdef CONFIG_PAX_RANDMMAP
3927 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
3928 +#endif
3929 +
3930 /* requesting a specific address */
3931 if (addr) {
3932 if (do_align)
3933 @@ -139,8 +149,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3934 else
3935 addr = PAGE_ALIGN(addr);
3936 vma = find_vma(mm, addr);
3937 - if (TASK_SIZE - len >= addr &&
3938 - (!vma || addr + len <= vma->vm_start))
3939 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
3940 return addr;
3941 }
3942
3943 @@ -150,6 +159,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
3944 info.high_limit = mm->mmap_base;
3945 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
3946 info.align_offset = pgoff << PAGE_SHIFT;
3947 + info.threadstack_offset = offset;
3948 addr = vm_unmapped_area(&info);
3949
3950 /*
3951 @@ -173,6 +183,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
3952 {
3953 unsigned long random_factor = 0UL;
3954
3955 +#ifdef CONFIG_PAX_RANDMMAP
3956 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
3957 +#endif
3958 +
3959 /* 8 bits of randomness in 20 address space bits */
3960 if ((current->flags & PF_RANDOMIZE) &&
3961 !(current->personality & ADDR_NO_RANDOMIZE))
3962 @@ -180,10 +194,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
3963
3964 if (mmap_is_legacy()) {
3965 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
3966 +
3967 +#ifdef CONFIG_PAX_RANDMMAP
3968 + if (mm->pax_flags & MF_PAX_RANDMMAP)
3969 + mm->mmap_base += mm->delta_mmap;
3970 +#endif
3971 +
3972 mm->get_unmapped_area = arch_get_unmapped_area;
3973 mm->unmap_area = arch_unmap_area;
3974 } else {
3975 mm->mmap_base = mmap_base(random_factor);
3976 +
3977 +#ifdef CONFIG_PAX_RANDMMAP
3978 + if (mm->pax_flags & MF_PAX_RANDMMAP)
3979 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
3980 +#endif
3981 +
3982 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
3983 mm->unmap_area = arch_unmap_area_topdown;
3984 }
3985 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
3986 index 4d409e6..0015a7b 100644
3987 --- a/arch/arm/mm/mmu.c
3988 +++ b/arch/arm/mm/mmu.c
3989 @@ -36,6 +36,22 @@
3990 #include "mm.h"
3991 #include "tcm.h"
3992
3993 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3994 +void modify_domain(unsigned int dom, unsigned int type)
3995 +{
3996 + struct thread_info *thread = current_thread_info();
3997 + unsigned int domain = thread->cpu_domain;
3998 + /*
3999 + * DOMAIN_MANAGER might be defined to some other value,
4000 + * use the arch-defined constant
4001 + */
4002 + domain &= ~domain_val(dom, 3);
4003 + thread->cpu_domain = domain | domain_val(dom, type);
4004 + set_domain(thread->cpu_domain);
4005 +}
4006 +EXPORT_SYMBOL(modify_domain);
4007 +#endif
4008 +
4009 /*
4010 * empty_zero_page is a special page that is used for
4011 * zero-initialized data and COW.
4012 @@ -228,10 +244,18 @@ __setup("noalign", noalign_setup);
4013
4014 #endif /* ifdef CONFIG_CPU_CP15 / else */
4015
4016 -#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
4017 +#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY
4018 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
4019
4020 -static struct mem_type mem_types[] = {
4021 +#ifdef CONFIG_PAX_KERNEXEC
4022 +#define L_PTE_KERNEXEC L_PTE_RDONLY
4023 +#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
4024 +#else
4025 +#define L_PTE_KERNEXEC L_PTE_DIRTY
4026 +#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
4027 +#endif
4028 +
4029 +static struct mem_type mem_types[] __read_only = {
4030 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
4031 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
4032 L_PTE_SHARED,
4033 @@ -260,16 +284,16 @@ static struct mem_type mem_types[] = {
4034 [MT_UNCACHED] = {
4035 .prot_pte = PROT_PTE_DEVICE,
4036 .prot_l1 = PMD_TYPE_TABLE,
4037 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4038 + .prot_sect = PROT_SECT_DEVICE,
4039 .domain = DOMAIN_IO,
4040 },
4041 [MT_CACHECLEAN] = {
4042 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4043 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4044 .domain = DOMAIN_KERNEL,
4045 },
4046 #ifndef CONFIG_ARM_LPAE
4047 [MT_MINICLEAN] = {
4048 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
4049 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_RDONLY,
4050 .domain = DOMAIN_KERNEL,
4051 },
4052 #endif
4053 @@ -277,36 +301,54 @@ static struct mem_type mem_types[] = {
4054 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4055 L_PTE_RDONLY,
4056 .prot_l1 = PMD_TYPE_TABLE,
4057 - .domain = DOMAIN_USER,
4058 + .domain = DOMAIN_VECTORS,
4059 },
4060 [MT_HIGH_VECTORS] = {
4061 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4062 - L_PTE_USER | L_PTE_RDONLY,
4063 + L_PTE_RDONLY,
4064 .prot_l1 = PMD_TYPE_TABLE,
4065 - .domain = DOMAIN_USER,
4066 + .domain = DOMAIN_VECTORS,
4067 },
4068 - [MT_MEMORY] = {
4069 + [MT_MEMORY_RWX] = {
4070 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4071 .prot_l1 = PMD_TYPE_TABLE,
4072 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4073 .domain = DOMAIN_KERNEL,
4074 },
4075 + [MT_MEMORY_RW] = {
4076 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4077 + .prot_l1 = PMD_TYPE_TABLE,
4078 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4079 + .domain = DOMAIN_KERNEL,
4080 + },
4081 + [MT_MEMORY_RX] = {
4082 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4083 + .prot_l1 = PMD_TYPE_TABLE,
4084 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4085 + .domain = DOMAIN_KERNEL,
4086 + },
4087 [MT_ROM] = {
4088 - .prot_sect = PMD_TYPE_SECT,
4089 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4090 .domain = DOMAIN_KERNEL,
4091 },
4092 - [MT_MEMORY_NONCACHED] = {
4093 + [MT_MEMORY_NONCACHED_RW] = {
4094 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4095 L_PTE_MT_BUFFERABLE,
4096 .prot_l1 = PMD_TYPE_TABLE,
4097 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4098 .domain = DOMAIN_KERNEL,
4099 },
4100 + [MT_MEMORY_NONCACHED_RX] = {
4101 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4102 + L_PTE_MT_BUFFERABLE,
4103 + .prot_l1 = PMD_TYPE_TABLE,
4104 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4105 + .domain = DOMAIN_KERNEL,
4106 + },
4107 [MT_MEMORY_DTCM] = {
4108 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4109 - L_PTE_XN,
4110 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4111 .prot_l1 = PMD_TYPE_TABLE,
4112 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4113 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4114 .domain = DOMAIN_KERNEL,
4115 },
4116 [MT_MEMORY_ITCM] = {
4117 @@ -316,10 +358,10 @@ static struct mem_type mem_types[] = {
4118 },
4119 [MT_MEMORY_SO] = {
4120 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4121 - L_PTE_MT_UNCACHED | L_PTE_XN,
4122 + L_PTE_MT_UNCACHED,
4123 .prot_l1 = PMD_TYPE_TABLE,
4124 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
4125 - PMD_SECT_UNCACHED | PMD_SECT_XN,
4126 + PMD_SECT_UNCACHED,
4127 .domain = DOMAIN_KERNEL,
4128 },
4129 [MT_MEMORY_DMA_READY] = {
4130 @@ -405,9 +447,35 @@ static void __init build_mem_type_table(void)
4131 * to prevent speculative instruction fetches.
4132 */
4133 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
4134 + mem_types[MT_DEVICE].prot_pte |= L_PTE_XN;
4135 mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
4136 + mem_types[MT_DEVICE_NONSHARED].prot_pte |= L_PTE_XN;
4137 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
4138 + mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_XN;
4139 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
4140 + mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_XN;
4141 +
4142 + /* Mark other regions on ARMv6+ as execute-never */
4143 +
4144 +#ifdef CONFIG_PAX_KERNEXEC
4145 + mem_types[MT_UNCACHED].prot_sect |= PMD_SECT_XN;
4146 + mem_types[MT_UNCACHED].prot_pte |= L_PTE_XN;
4147 + mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_XN;
4148 + mem_types[MT_CACHECLEAN].prot_pte |= L_PTE_XN;
4149 +#ifndef CONFIG_ARM_LPAE
4150 + mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_XN;
4151 + mem_types[MT_MINICLEAN].prot_pte |= L_PTE_XN;
4152 +#endif
4153 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
4154 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_XN;
4155 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_XN;
4156 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= PMD_SECT_XN;
4157 + mem_types[MT_MEMORY_DTCM].prot_sect |= PMD_SECT_XN;
4158 + mem_types[MT_MEMORY_DTCM].prot_pte |= L_PTE_XN;
4159 +#endif
4160 +
4161 + mem_types[MT_MEMORY_SO].prot_sect |= PMD_SECT_XN;
4162 + mem_types[MT_MEMORY_SO].prot_pte |= L_PTE_XN;
4163 }
4164 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4165 /*
4166 @@ -468,6 +536,9 @@ static void __init build_mem_type_table(void)
4167 * from SVC mode and no access from userspace.
4168 */
4169 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4170 +#ifdef CONFIG_PAX_KERNEXEC
4171 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4172 +#endif
4173 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4174 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4175 #endif
4176 @@ -485,11 +556,17 @@ static void __init build_mem_type_table(void)
4177 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4178 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4179 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4180 - mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
4181 - mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
4182 + mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4183 + mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4184 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4185 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4186 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4187 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4188 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4189 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
4190 - mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
4191 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_S;
4192 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= L_PTE_SHARED;
4193 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_S;
4194 + mem_types[MT_MEMORY_NONCACHED_RX].prot_pte |= L_PTE_SHARED;
4195 }
4196 }
4197
4198 @@ -500,15 +577,20 @@ static void __init build_mem_type_table(void)
4199 if (cpu_arch >= CPU_ARCH_ARMv6) {
4200 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4201 /* Non-cacheable Normal is XCB = 001 */
4202 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4203 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4204 + PMD_SECT_BUFFERED;
4205 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4206 PMD_SECT_BUFFERED;
4207 } else {
4208 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4209 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4210 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4211 + PMD_SECT_TEX(1);
4212 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4213 PMD_SECT_TEX(1);
4214 }
4215 } else {
4216 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4217 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_BUFFERABLE;
4218 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_BUFFERABLE;
4219 }
4220
4221 #ifdef CONFIG_ARM_LPAE
4222 @@ -524,6 +606,8 @@ static void __init build_mem_type_table(void)
4223 vecs_pgprot |= PTE_EXT_AF;
4224 #endif
4225
4226 + user_pgprot |= __supported_pte_mask;
4227 +
4228 for (i = 0; i < 16; i++) {
4229 pteval_t v = pgprot_val(protection_map[i]);
4230 protection_map[i] = __pgprot(v | user_pgprot);
4231 @@ -541,10 +625,15 @@ static void __init build_mem_type_table(void)
4232
4233 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4234 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4235 - mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
4236 - mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
4237 + mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4238 + mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4239 + mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4240 + mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4241 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4242 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4243 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4244 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
4245 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= ecc_mask;
4246 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= ecc_mask;
4247 mem_types[MT_ROM].prot_sect |= cp->pmd;
4248
4249 switch (cp->pmd) {
4250 @@ -1166,18 +1255,15 @@ void __init arm_mm_memblock_reserve(void)
4251 * called function. This means you can't use any function or debugging
4252 * method which may touch any device, otherwise the kernel _will_ crash.
4253 */
4254 +
4255 +static char vectors[PAGE_SIZE] __read_only __aligned(PAGE_SIZE);
4256 +
4257 static void __init devicemaps_init(struct machine_desc *mdesc)
4258 {
4259 struct map_desc map;
4260 unsigned long addr;
4261 - void *vectors;
4262
4263 - /*
4264 - * Allocate the vector page early.
4265 - */
4266 - vectors = early_alloc(PAGE_SIZE);
4267 -
4268 - early_trap_init(vectors);
4269 + early_trap_init(&vectors);
4270
4271 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4272 pmd_clear(pmd_off_k(addr));
4273 @@ -1217,7 +1303,7 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
4274 * location (0xffff0000). If we aren't using high-vectors, also
4275 * create a mapping at the low-vectors virtual address.
4276 */
4277 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4278 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4279 map.virtual = 0xffff0000;
4280 map.length = PAGE_SIZE;
4281 map.type = MT_HIGH_VECTORS;
4282 @@ -1275,8 +1361,39 @@ static void __init map_lowmem(void)
4283 map.pfn = __phys_to_pfn(start);
4284 map.virtual = __phys_to_virt(start);
4285 map.length = end - start;
4286 - map.type = MT_MEMORY;
4287
4288 +#ifdef CONFIG_PAX_KERNEXEC
4289 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4290 + struct map_desc kernel;
4291 + struct map_desc initmap;
4292 +
4293 + /* when freeing initmem we will make this RW */
4294 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4295 + initmap.virtual = (unsigned long)__init_begin;
4296 + initmap.length = _sdata - __init_begin;
4297 + initmap.type = MT_MEMORY_RWX;
4298 + create_mapping(&initmap);
4299 +
4300 + /* when freeing initmem we will make this RX */
4301 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4302 + kernel.virtual = (unsigned long)_stext;
4303 + kernel.length = __init_begin - _stext;
4304 + kernel.type = MT_MEMORY_RWX;
4305 + create_mapping(&kernel);
4306 +
4307 + if (map.virtual < (unsigned long)_stext) {
4308 + map.length = (unsigned long)_stext - map.virtual;
4309 + map.type = MT_MEMORY_RWX;
4310 + create_mapping(&map);
4311 + }
4312 +
4313 + map.pfn = __phys_to_pfn(__pa(_sdata));
4314 + map.virtual = (unsigned long)_sdata;
4315 + map.length = end - __pa(_sdata);
4316 + }
4317 +#endif
4318 +
4319 + map.type = MT_MEMORY_RW;
4320 create_mapping(&map);
4321 }
4322 }
4323 diff --git a/arch/arm/mm/proc-v7-2level.S b/arch/arm/mm/proc-v7-2level.S
4324 index 9704097..3e36dde 100644
4325 --- a/arch/arm/mm/proc-v7-2level.S
4326 +++ b/arch/arm/mm/proc-v7-2level.S
4327 @@ -99,6 +99,9 @@ ENTRY(cpu_v7_set_pte_ext)
4328 tst r1, #L_PTE_XN
4329 orrne r3, r3, #PTE_EXT_XN
4330
4331 + tst r1, #L_PTE_PXN
4332 + orrne r3, r3, #PTE_EXT_PXN
4333 +
4334 tst r1, #L_PTE_YOUNG
4335 tstne r1, #L_PTE_VALID
4336 #ifndef CONFIG_CPU_USE_DOMAINS
4337 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4338 index a5bc92d..0bb4730 100644
4339 --- a/arch/arm/plat-omap/sram.c
4340 +++ b/arch/arm/plat-omap/sram.c
4341 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4342 * Looks like we need to preserve some bootloader code at the
4343 * beginning of SRAM for jumping to flash for reboot to work...
4344 */
4345 + pax_open_kernel();
4346 memset_io(omap_sram_base + omap_sram_skip, 0,
4347 omap_sram_size - omap_sram_skip);
4348 + pax_close_kernel();
4349 }
4350 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4351 index ce6d763..cfea917 100644
4352 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4353 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4354 @@ -47,7 +47,7 @@ struct samsung_dma_ops {
4355 int (*started)(unsigned ch);
4356 int (*flush)(unsigned ch);
4357 int (*stop)(unsigned ch);
4358 -};
4359 +} __no_const;
4360
4361 extern void *samsung_dmadev_get_ops(void);
4362 extern void *s3c_dma_get_ops(void);
4363 diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
4364 index f4726dc..39ed646 100644
4365 --- a/arch/arm64/kernel/debug-monitors.c
4366 +++ b/arch/arm64/kernel/debug-monitors.c
4367 @@ -149,7 +149,7 @@ static int __cpuinit os_lock_notify(struct notifier_block *self,
4368 return NOTIFY_OK;
4369 }
4370
4371 -static struct notifier_block __cpuinitdata os_lock_nb = {
4372 +static struct notifier_block os_lock_nb = {
4373 .notifier_call = os_lock_notify,
4374 };
4375
4376 diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c
4377 index 5ab825c..96aaec8 100644
4378 --- a/arch/arm64/kernel/hw_breakpoint.c
4379 +++ b/arch/arm64/kernel/hw_breakpoint.c
4380 @@ -831,7 +831,7 @@ static int __cpuinit hw_breakpoint_reset_notify(struct notifier_block *self,
4381 return NOTIFY_OK;
4382 }
4383
4384 -static struct notifier_block __cpuinitdata hw_breakpoint_reset_nb = {
4385 +static struct notifier_block hw_breakpoint_reset_nb = {
4386 .notifier_call = hw_breakpoint_reset_notify,
4387 };
4388
4389 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4390 index c3a58a1..78fbf54 100644
4391 --- a/arch/avr32/include/asm/cache.h
4392 +++ b/arch/avr32/include/asm/cache.h
4393 @@ -1,8 +1,10 @@
4394 #ifndef __ASM_AVR32_CACHE_H
4395 #define __ASM_AVR32_CACHE_H
4396
4397 +#include <linux/const.h>
4398 +
4399 #define L1_CACHE_SHIFT 5
4400 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4401 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4402
4403 /*
4404 * Memory returned by kmalloc() may be used for DMA, so we must make
4405 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4406 index d232888..87c8df1 100644
4407 --- a/arch/avr32/include/asm/elf.h
4408 +++ b/arch/avr32/include/asm/elf.h
4409 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4410 the loader. We need to make sure that it is out of the way of the program
4411 that it will "exec", and that there is sufficient room for the brk. */
4412
4413 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4414 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4415
4416 +#ifdef CONFIG_PAX_ASLR
4417 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4418 +
4419 +#define PAX_DELTA_MMAP_LEN 15
4420 +#define PAX_DELTA_STACK_LEN 15
4421 +#endif
4422
4423 /* This yields a mask that user programs can use to figure out what
4424 instruction set this CPU supports. This could be done in user space,
4425 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4426 index 479330b..53717a8 100644
4427 --- a/arch/avr32/include/asm/kmap_types.h
4428 +++ b/arch/avr32/include/asm/kmap_types.h
4429 @@ -2,9 +2,9 @@
4430 #define __ASM_AVR32_KMAP_TYPES_H
4431
4432 #ifdef CONFIG_DEBUG_HIGHMEM
4433 -# define KM_TYPE_NR 29
4434 +# define KM_TYPE_NR 30
4435 #else
4436 -# define KM_TYPE_NR 14
4437 +# define KM_TYPE_NR 15
4438 #endif
4439
4440 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4441 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4442 index b2f2d2d..d1c85cb 100644
4443 --- a/arch/avr32/mm/fault.c
4444 +++ b/arch/avr32/mm/fault.c
4445 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4446
4447 int exception_trace = 1;
4448
4449 +#ifdef CONFIG_PAX_PAGEEXEC
4450 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4451 +{
4452 + unsigned long i;
4453 +
4454 + printk(KERN_ERR "PAX: bytes at PC: ");
4455 + for (i = 0; i < 20; i++) {
4456 + unsigned char c;
4457 + if (get_user(c, (unsigned char *)pc+i))
4458 + printk(KERN_CONT "???????? ");
4459 + else
4460 + printk(KERN_CONT "%02x ", c);
4461 + }
4462 + printk("\n");
4463 +}
4464 +#endif
4465 +
4466 /*
4467 * This routine handles page faults. It determines the address and the
4468 * problem, and then passes it off to one of the appropriate routines.
4469 @@ -174,6 +191,16 @@ bad_area:
4470 up_read(&mm->mmap_sem);
4471
4472 if (user_mode(regs)) {
4473 +
4474 +#ifdef CONFIG_PAX_PAGEEXEC
4475 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4476 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4477 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4478 + do_group_exit(SIGKILL);
4479 + }
4480 + }
4481 +#endif
4482 +
4483 if (exception_trace && printk_ratelimit())
4484 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4485 "sp %08lx ecr %lu\n",
4486 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4487 index 568885a..f8008df 100644
4488 --- a/arch/blackfin/include/asm/cache.h
4489 +++ b/arch/blackfin/include/asm/cache.h
4490 @@ -7,6 +7,7 @@
4491 #ifndef __ARCH_BLACKFIN_CACHE_H
4492 #define __ARCH_BLACKFIN_CACHE_H
4493
4494 +#include <linux/const.h>
4495 #include <linux/linkage.h> /* for asmlinkage */
4496
4497 /*
4498 @@ -14,7 +15,7 @@
4499 * Blackfin loads 32 bytes for cache
4500 */
4501 #define L1_CACHE_SHIFT 5
4502 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4503 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4504 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4505
4506 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4507 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4508 index aea2718..3639a60 100644
4509 --- a/arch/cris/include/arch-v10/arch/cache.h
4510 +++ b/arch/cris/include/arch-v10/arch/cache.h
4511 @@ -1,8 +1,9 @@
4512 #ifndef _ASM_ARCH_CACHE_H
4513 #define _ASM_ARCH_CACHE_H
4514
4515 +#include <linux/const.h>
4516 /* Etrax 100LX have 32-byte cache-lines. */
4517 -#define L1_CACHE_BYTES 32
4518 #define L1_CACHE_SHIFT 5
4519 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4520
4521 #endif /* _ASM_ARCH_CACHE_H */
4522 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4523 index 7caf25d..ee65ac5 100644
4524 --- a/arch/cris/include/arch-v32/arch/cache.h
4525 +++ b/arch/cris/include/arch-v32/arch/cache.h
4526 @@ -1,11 +1,12 @@
4527 #ifndef _ASM_CRIS_ARCH_CACHE_H
4528 #define _ASM_CRIS_ARCH_CACHE_H
4529
4530 +#include <linux/const.h>
4531 #include <arch/hwregs/dma.h>
4532
4533 /* A cache-line is 32 bytes. */
4534 -#define L1_CACHE_BYTES 32
4535 #define L1_CACHE_SHIFT 5
4536 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4537
4538 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4539
4540 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4541 index b86329d..6709906 100644
4542 --- a/arch/frv/include/asm/atomic.h
4543 +++ b/arch/frv/include/asm/atomic.h
4544 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4545 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4546 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
4547
4548 +#define atomic64_read_unchecked(v) atomic64_read(v)
4549 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4550 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4551 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4552 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4553 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4554 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4555 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4556 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4557 +
4558 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4559 {
4560 int c, old;
4561 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4562 index 2797163..c2a401d 100644
4563 --- a/arch/frv/include/asm/cache.h
4564 +++ b/arch/frv/include/asm/cache.h
4565 @@ -12,10 +12,11 @@
4566 #ifndef __ASM_CACHE_H
4567 #define __ASM_CACHE_H
4568
4569 +#include <linux/const.h>
4570
4571 /* bytes per L1 cache line */
4572 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4573 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4574 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4575
4576 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4577 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4578 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4579 index 43901f2..0d8b865 100644
4580 --- a/arch/frv/include/asm/kmap_types.h
4581 +++ b/arch/frv/include/asm/kmap_types.h
4582 @@ -2,6 +2,6 @@
4583 #ifndef _ASM_KMAP_TYPES_H
4584 #define _ASM_KMAP_TYPES_H
4585
4586 -#define KM_TYPE_NR 17
4587 +#define KM_TYPE_NR 18
4588
4589 #endif
4590 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4591 index 836f147..4cf23f5 100644
4592 --- a/arch/frv/mm/elf-fdpic.c
4593 +++ b/arch/frv/mm/elf-fdpic.c
4594 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4595 {
4596 struct vm_area_struct *vma;
4597 struct vm_unmapped_area_info info;
4598 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4599
4600 if (len > TASK_SIZE)
4601 return -ENOMEM;
4602 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4603 if (addr) {
4604 addr = PAGE_ALIGN(addr);
4605 vma = find_vma(current->mm, addr);
4606 - if (TASK_SIZE - len >= addr &&
4607 - (!vma || addr + len <= vma->vm_start))
4608 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4609 goto success;
4610 }
4611
4612 @@ -85,6 +85,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4613 info.high_limit = (current->mm->start_stack - 0x00200000);
4614 info.align_mask = 0;
4615 info.align_offset = 0;
4616 + info.threadstack_offset = offset;
4617 addr = vm_unmapped_area(&info);
4618 if (!(addr & ~PAGE_MASK))
4619 goto success;
4620 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
4621 index f4ca594..adc72fd6 100644
4622 --- a/arch/hexagon/include/asm/cache.h
4623 +++ b/arch/hexagon/include/asm/cache.h
4624 @@ -21,9 +21,11 @@
4625 #ifndef __ASM_CACHE_H
4626 #define __ASM_CACHE_H
4627
4628 +#include <linux/const.h>
4629 +
4630 /* Bytes per L1 cache line */
4631 -#define L1_CACHE_SHIFT (5)
4632 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4633 +#define L1_CACHE_SHIFT 5
4634 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4635
4636 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
4637 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
4638 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
4639 index 6e6fe18..a6ae668 100644
4640 --- a/arch/ia64/include/asm/atomic.h
4641 +++ b/arch/ia64/include/asm/atomic.h
4642 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
4643 #define atomic64_inc(v) atomic64_add(1, (v))
4644 #define atomic64_dec(v) atomic64_sub(1, (v))
4645
4646 +#define atomic64_read_unchecked(v) atomic64_read(v)
4647 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4648 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4649 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4650 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4651 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4652 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4653 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4654 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4655 +
4656 /* Atomic operations are already serializing */
4657 #define smp_mb__before_atomic_dec() barrier()
4658 #define smp_mb__after_atomic_dec() barrier()
4659 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
4660 index 988254a..e1ee885 100644
4661 --- a/arch/ia64/include/asm/cache.h
4662 +++ b/arch/ia64/include/asm/cache.h
4663 @@ -1,6 +1,7 @@
4664 #ifndef _ASM_IA64_CACHE_H
4665 #define _ASM_IA64_CACHE_H
4666
4667 +#include <linux/const.h>
4668
4669 /*
4670 * Copyright (C) 1998-2000 Hewlett-Packard Co
4671 @@ -9,7 +10,7 @@
4672
4673 /* Bytes per L1 (data) cache line. */
4674 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
4675 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4676 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4677
4678 #ifdef CONFIG_SMP
4679 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
4680 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
4681 index 5a83c5c..4d7f553 100644
4682 --- a/arch/ia64/include/asm/elf.h
4683 +++ b/arch/ia64/include/asm/elf.h
4684 @@ -42,6 +42,13 @@
4685 */
4686 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
4687
4688 +#ifdef CONFIG_PAX_ASLR
4689 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
4690 +
4691 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4692 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4693 +#endif
4694 +
4695 #define PT_IA_64_UNWIND 0x70000001
4696
4697 /* IA-64 relocations: */
4698 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
4699 index 96a8d92..617a1cf 100644
4700 --- a/arch/ia64/include/asm/pgalloc.h
4701 +++ b/arch/ia64/include/asm/pgalloc.h
4702 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4703 pgd_val(*pgd_entry) = __pa(pud);
4704 }
4705
4706 +static inline void
4707 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4708 +{
4709 + pgd_populate(mm, pgd_entry, pud);
4710 +}
4711 +
4712 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
4713 {
4714 return quicklist_alloc(0, GFP_KERNEL, NULL);
4715 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4716 pud_val(*pud_entry) = __pa(pmd);
4717 }
4718
4719 +static inline void
4720 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4721 +{
4722 + pud_populate(mm, pud_entry, pmd);
4723 +}
4724 +
4725 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
4726 {
4727 return quicklist_alloc(0, GFP_KERNEL, NULL);
4728 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
4729 index 815810c..d60bd4c 100644
4730 --- a/arch/ia64/include/asm/pgtable.h
4731 +++ b/arch/ia64/include/asm/pgtable.h
4732 @@ -12,7 +12,7 @@
4733 * David Mosberger-Tang <davidm@hpl.hp.com>
4734 */
4735
4736 -
4737 +#include <linux/const.h>
4738 #include <asm/mman.h>
4739 #include <asm/page.h>
4740 #include <asm/processor.h>
4741 @@ -142,6 +142,17 @@
4742 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4743 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4744 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
4745 +
4746 +#ifdef CONFIG_PAX_PAGEEXEC
4747 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
4748 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4749 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4750 +#else
4751 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
4752 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
4753 +# define PAGE_COPY_NOEXEC PAGE_COPY
4754 +#endif
4755 +
4756 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
4757 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
4758 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
4759 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
4760 index 54ff557..70c88b7 100644
4761 --- a/arch/ia64/include/asm/spinlock.h
4762 +++ b/arch/ia64/include/asm/spinlock.h
4763 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
4764 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
4765
4766 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
4767 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
4768 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
4769 }
4770
4771 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
4772 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
4773 index 449c8c0..18965fb 100644
4774 --- a/arch/ia64/include/asm/uaccess.h
4775 +++ b/arch/ia64/include/asm/uaccess.h
4776 @@ -240,12 +240,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
4777 static inline unsigned long
4778 __copy_to_user (void __user *to, const void *from, unsigned long count)
4779 {
4780 + if (count > INT_MAX)
4781 + return count;
4782 +
4783 + if (!__builtin_constant_p(count))
4784 + check_object_size(from, count, true);
4785 +
4786 return __copy_user(to, (__force void __user *) from, count);
4787 }
4788
4789 static inline unsigned long
4790 __copy_from_user (void *to, const void __user *from, unsigned long count)
4791 {
4792 + if (count > INT_MAX)
4793 + return count;
4794 +
4795 + if (!__builtin_constant_p(count))
4796 + check_object_size(to, count, false);
4797 +
4798 return __copy_user((__force void __user *) to, from, count);
4799 }
4800
4801 @@ -255,10 +267,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4802 ({ \
4803 void __user *__cu_to = (to); \
4804 const void *__cu_from = (from); \
4805 - long __cu_len = (n); \
4806 + unsigned long __cu_len = (n); \
4807 \
4808 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
4809 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
4810 + if (!__builtin_constant_p(n)) \
4811 + check_object_size(__cu_from, __cu_len, true); \
4812 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
4813 + } \
4814 __cu_len; \
4815 })
4816
4817 @@ -266,11 +281,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4818 ({ \
4819 void *__cu_to = (to); \
4820 const void __user *__cu_from = (from); \
4821 - long __cu_len = (n); \
4822 + unsigned long __cu_len = (n); \
4823 \
4824 __chk_user_ptr(__cu_from); \
4825 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
4826 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
4827 + if (!__builtin_constant_p(n)) \
4828 + check_object_size(__cu_to, __cu_len, false); \
4829 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
4830 + } \
4831 __cu_len; \
4832 })
4833
4834 diff --git a/arch/ia64/kernel/err_inject.c b/arch/ia64/kernel/err_inject.c
4835 index 2d67317..07d8bfa 100644
4836 --- a/arch/ia64/kernel/err_inject.c
4837 +++ b/arch/ia64/kernel/err_inject.c
4838 @@ -256,7 +256,7 @@ static int __cpuinit err_inject_cpu_callback(struct notifier_block *nfb,
4839 return NOTIFY_OK;
4840 }
4841
4842 -static struct notifier_block __cpuinitdata err_inject_cpu_notifier =
4843 +static struct notifier_block err_inject_cpu_notifier =
4844 {
4845 .notifier_call = err_inject_cpu_callback,
4846 };
4847 diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
4848 index d7396db..b33e873 100644
4849 --- a/arch/ia64/kernel/mca.c
4850 +++ b/arch/ia64/kernel/mca.c
4851 @@ -1922,7 +1922,7 @@ static int __cpuinit mca_cpu_callback(struct notifier_block *nfb,
4852 return NOTIFY_OK;
4853 }
4854
4855 -static struct notifier_block mca_cpu_notifier __cpuinitdata = {
4856 +static struct notifier_block mca_cpu_notifier = {
4857 .notifier_call = mca_cpu_callback
4858 };
4859
4860 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
4861 index 24603be..948052d 100644
4862 --- a/arch/ia64/kernel/module.c
4863 +++ b/arch/ia64/kernel/module.c
4864 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
4865 void
4866 module_free (struct module *mod, void *module_region)
4867 {
4868 - if (mod && mod->arch.init_unw_table &&
4869 - module_region == mod->module_init) {
4870 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
4871 unw_remove_unwind_table(mod->arch.init_unw_table);
4872 mod->arch.init_unw_table = NULL;
4873 }
4874 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
4875 }
4876
4877 static inline int
4878 +in_init_rx (const struct module *mod, uint64_t addr)
4879 +{
4880 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
4881 +}
4882 +
4883 +static inline int
4884 +in_init_rw (const struct module *mod, uint64_t addr)
4885 +{
4886 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
4887 +}
4888 +
4889 +static inline int
4890 in_init (const struct module *mod, uint64_t addr)
4891 {
4892 - return addr - (uint64_t) mod->module_init < mod->init_size;
4893 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
4894 +}
4895 +
4896 +static inline int
4897 +in_core_rx (const struct module *mod, uint64_t addr)
4898 +{
4899 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
4900 +}
4901 +
4902 +static inline int
4903 +in_core_rw (const struct module *mod, uint64_t addr)
4904 +{
4905 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
4906 }
4907
4908 static inline int
4909 in_core (const struct module *mod, uint64_t addr)
4910 {
4911 - return addr - (uint64_t) mod->module_core < mod->core_size;
4912 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
4913 }
4914
4915 static inline int
4916 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
4917 break;
4918
4919 case RV_BDREL:
4920 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
4921 + if (in_init_rx(mod, val))
4922 + val -= (uint64_t) mod->module_init_rx;
4923 + else if (in_init_rw(mod, val))
4924 + val -= (uint64_t) mod->module_init_rw;
4925 + else if (in_core_rx(mod, val))
4926 + val -= (uint64_t) mod->module_core_rx;
4927 + else if (in_core_rw(mod, val))
4928 + val -= (uint64_t) mod->module_core_rw;
4929 break;
4930
4931 case RV_LTV:
4932 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
4933 * addresses have been selected...
4934 */
4935 uint64_t gp;
4936 - if (mod->core_size > MAX_LTOFF)
4937 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
4938 /*
4939 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
4940 * at the end of the module.
4941 */
4942 - gp = mod->core_size - MAX_LTOFF / 2;
4943 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
4944 else
4945 - gp = mod->core_size / 2;
4946 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
4947 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
4948 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
4949 mod->arch.gp = gp;
4950 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
4951 }
4952 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
4953 index 2b3c2d7..a318d84 100644
4954 --- a/arch/ia64/kernel/palinfo.c
4955 +++ b/arch/ia64/kernel/palinfo.c
4956 @@ -980,7 +980,7 @@ static int __cpuinit palinfo_cpu_callback(struct notifier_block *nfb,
4957 return NOTIFY_OK;
4958 }
4959
4960 -static struct notifier_block __refdata palinfo_cpu_notifier =
4961 +static struct notifier_block palinfo_cpu_notifier =
4962 {
4963 .notifier_call = palinfo_cpu_callback,
4964 .priority = 0,
4965 diff --git a/arch/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c
4966 index 4bc580a..7767f24 100644
4967 --- a/arch/ia64/kernel/salinfo.c
4968 +++ b/arch/ia64/kernel/salinfo.c
4969 @@ -609,7 +609,7 @@ salinfo_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu
4970 return NOTIFY_OK;
4971 }
4972
4973 -static struct notifier_block salinfo_cpu_notifier __cpuinitdata =
4974 +static struct notifier_block salinfo_cpu_notifier =
4975 {
4976 .notifier_call = salinfo_cpu_callback,
4977 .priority = 0,
4978 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
4979 index 41e33f8..65180b2 100644
4980 --- a/arch/ia64/kernel/sys_ia64.c
4981 +++ b/arch/ia64/kernel/sys_ia64.c
4982 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
4983 unsigned long align_mask = 0;
4984 struct mm_struct *mm = current->mm;
4985 struct vm_unmapped_area_info info;
4986 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4987
4988 if (len > RGN_MAP_LIMIT)
4989 return -ENOMEM;
4990 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
4991 if (REGION_NUMBER(addr) == RGN_HPAGE)
4992 addr = 0;
4993 #endif
4994 +
4995 +#ifdef CONFIG_PAX_RANDMMAP
4996 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4997 + addr = mm->free_area_cache;
4998 + else
4999 +#endif
5000 +
5001 if (!addr)
5002 addr = TASK_UNMAPPED_BASE;
5003
5004 @@ -61,6 +69,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5005 info.high_limit = TASK_SIZE;
5006 info.align_mask = align_mask;
5007 info.align_offset = 0;
5008 + info.threadstack_offset = offset;
5009 return vm_unmapped_area(&info);
5010 }
5011
5012 diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
5013 index dc00b2c..cce53c2 100644
5014 --- a/arch/ia64/kernel/topology.c
5015 +++ b/arch/ia64/kernel/topology.c
5016 @@ -445,7 +445,7 @@ static int __cpuinit cache_cpu_callback(struct notifier_block *nfb,
5017 return NOTIFY_OK;
5018 }
5019
5020 -static struct notifier_block __cpuinitdata cache_cpu_notifier =
5021 +static struct notifier_block cache_cpu_notifier =
5022 {
5023 .notifier_call = cache_cpu_callback
5024 };
5025 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
5026 index 0ccb28f..8992469 100644
5027 --- a/arch/ia64/kernel/vmlinux.lds.S
5028 +++ b/arch/ia64/kernel/vmlinux.lds.S
5029 @@ -198,7 +198,7 @@ SECTIONS {
5030 /* Per-cpu data: */
5031 . = ALIGN(PERCPU_PAGE_SIZE);
5032 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
5033 - __phys_per_cpu_start = __per_cpu_load;
5034 + __phys_per_cpu_start = per_cpu_load;
5035 /*
5036 * ensure percpu data fits
5037 * into percpu page size
5038 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
5039 index 6cf0341..d352594 100644
5040 --- a/arch/ia64/mm/fault.c
5041 +++ b/arch/ia64/mm/fault.c
5042 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
5043 return pte_present(pte);
5044 }
5045
5046 +#ifdef CONFIG_PAX_PAGEEXEC
5047 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5048 +{
5049 + unsigned long i;
5050 +
5051 + printk(KERN_ERR "PAX: bytes at PC: ");
5052 + for (i = 0; i < 8; i++) {
5053 + unsigned int c;
5054 + if (get_user(c, (unsigned int *)pc+i))
5055 + printk(KERN_CONT "???????? ");
5056 + else
5057 + printk(KERN_CONT "%08x ", c);
5058 + }
5059 + printk("\n");
5060 +}
5061 +#endif
5062 +
5063 # define VM_READ_BIT 0
5064 # define VM_WRITE_BIT 1
5065 # define VM_EXEC_BIT 2
5066 @@ -149,8 +166,21 @@ retry:
5067 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5068 goto bad_area;
5069
5070 - if ((vma->vm_flags & mask) != mask)
5071 + if ((vma->vm_flags & mask) != mask) {
5072 +
5073 +#ifdef CONFIG_PAX_PAGEEXEC
5074 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5075 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5076 + goto bad_area;
5077 +
5078 + up_read(&mm->mmap_sem);
5079 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5080 + do_group_exit(SIGKILL);
5081 + }
5082 +#endif
5083 +
5084 goto bad_area;
5085 + }
5086
5087 /*
5088 * If for any reason at all we couldn't handle the fault, make
5089 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5090 index 76069c1..c2aa816 100644
5091 --- a/arch/ia64/mm/hugetlbpage.c
5092 +++ b/arch/ia64/mm/hugetlbpage.c
5093 @@ -149,6 +149,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5094 unsigned long pgoff, unsigned long flags)
5095 {
5096 struct vm_unmapped_area_info info;
5097 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5098
5099 if (len > RGN_MAP_LIMIT)
5100 return -ENOMEM;
5101 @@ -172,6 +173,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5102 info.high_limit = HPAGE_REGION_BASE + RGN_MAP_LIMIT;
5103 info.align_mask = PAGE_MASK & (HPAGE_SIZE - 1);
5104 info.align_offset = 0;
5105 + info.threadstack_offset = offset;
5106 return vm_unmapped_area(&info);
5107 }
5108
5109 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5110 index d1fe4b4..2628f37 100644
5111 --- a/arch/ia64/mm/init.c
5112 +++ b/arch/ia64/mm/init.c
5113 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5114 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5115 vma->vm_end = vma->vm_start + PAGE_SIZE;
5116 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5117 +
5118 +#ifdef CONFIG_PAX_PAGEEXEC
5119 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5120 + vma->vm_flags &= ~VM_EXEC;
5121 +
5122 +#ifdef CONFIG_PAX_MPROTECT
5123 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5124 + vma->vm_flags &= ~VM_MAYEXEC;
5125 +#endif
5126 +
5127 + }
5128 +#endif
5129 +
5130 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5131 down_write(&current->mm->mmap_sem);
5132 if (insert_vm_struct(current->mm, vma)) {
5133 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5134 index 40b3ee9..8c2c112 100644
5135 --- a/arch/m32r/include/asm/cache.h
5136 +++ b/arch/m32r/include/asm/cache.h
5137 @@ -1,8 +1,10 @@
5138 #ifndef _ASM_M32R_CACHE_H
5139 #define _ASM_M32R_CACHE_H
5140
5141 +#include <linux/const.h>
5142 +
5143 /* L1 cache line size */
5144 #define L1_CACHE_SHIFT 4
5145 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5146 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5147
5148 #endif /* _ASM_M32R_CACHE_H */
5149 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5150 index 82abd15..d95ae5d 100644
5151 --- a/arch/m32r/lib/usercopy.c
5152 +++ b/arch/m32r/lib/usercopy.c
5153 @@ -14,6 +14,9 @@
5154 unsigned long
5155 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5156 {
5157 + if ((long)n < 0)
5158 + return n;
5159 +
5160 prefetch(from);
5161 if (access_ok(VERIFY_WRITE, to, n))
5162 __copy_user(to,from,n);
5163 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5164 unsigned long
5165 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5166 {
5167 + if ((long)n < 0)
5168 + return n;
5169 +
5170 prefetchw(to);
5171 if (access_ok(VERIFY_READ, from, n))
5172 __copy_user_zeroing(to,from,n);
5173 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5174 index 0395c51..5f26031 100644
5175 --- a/arch/m68k/include/asm/cache.h
5176 +++ b/arch/m68k/include/asm/cache.h
5177 @@ -4,9 +4,11 @@
5178 #ifndef __ARCH_M68K_CACHE_H
5179 #define __ARCH_M68K_CACHE_H
5180
5181 +#include <linux/const.h>
5182 +
5183 /* bytes per L1 cache line */
5184 #define L1_CACHE_SHIFT 4
5185 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5186 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5187
5188 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5189
5190 diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
5191 index 3c52fa6..11b2ad8 100644
5192 --- a/arch/metag/mm/hugetlbpage.c
5193 +++ b/arch/metag/mm/hugetlbpage.c
5194 @@ -200,6 +200,7 @@ hugetlb_get_unmapped_area_new_pmd(unsigned long len)
5195 info.high_limit = TASK_SIZE;
5196 info.align_mask = PAGE_MASK & HUGEPT_MASK;
5197 info.align_offset = 0;
5198 + info.threadstack_offset = 0;
5199 return vm_unmapped_area(&info);
5200 }
5201
5202 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5203 index 4efe96a..60e8699 100644
5204 --- a/arch/microblaze/include/asm/cache.h
5205 +++ b/arch/microblaze/include/asm/cache.h
5206 @@ -13,11 +13,12 @@
5207 #ifndef _ASM_MICROBLAZE_CACHE_H
5208 #define _ASM_MICROBLAZE_CACHE_H
5209
5210 +#include <linux/const.h>
5211 #include <asm/registers.h>
5212
5213 #define L1_CACHE_SHIFT 5
5214 /* word-granular cache in microblaze */
5215 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5216 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5217
5218 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5219
5220 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5221 index 08b6079..eb272cf 100644
5222 --- a/arch/mips/include/asm/atomic.h
5223 +++ b/arch/mips/include/asm/atomic.h
5224 @@ -21,6 +21,10 @@
5225 #include <asm/cmpxchg.h>
5226 #include <asm/war.h>
5227
5228 +#ifdef CONFIG_GENERIC_ATOMIC64
5229 +#include <asm-generic/atomic64.h>
5230 +#endif
5231 +
5232 #define ATOMIC_INIT(i) { (i) }
5233
5234 /*
5235 @@ -759,6 +763,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
5236 */
5237 #define atomic64_add_negative(i, v) (atomic64_add_return(i, (v)) < 0)
5238
5239 +#define atomic64_read_unchecked(v) atomic64_read(v)
5240 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5241 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5242 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5243 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5244 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5245 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5246 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5247 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5248 +
5249 #endif /* CONFIG_64BIT */
5250
5251 /*
5252 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
5253 index b4db69f..8f3b093 100644
5254 --- a/arch/mips/include/asm/cache.h
5255 +++ b/arch/mips/include/asm/cache.h
5256 @@ -9,10 +9,11 @@
5257 #ifndef _ASM_CACHE_H
5258 #define _ASM_CACHE_H
5259
5260 +#include <linux/const.h>
5261 #include <kmalloc.h>
5262
5263 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
5264 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5265 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5266
5267 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
5268 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5269 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
5270 index cf3ae24..238d22f 100644
5271 --- a/arch/mips/include/asm/elf.h
5272 +++ b/arch/mips/include/asm/elf.h
5273 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
5274 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
5275 #endif
5276
5277 +#ifdef CONFIG_PAX_ASLR
5278 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5279 +
5280 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5281 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5282 +#endif
5283 +
5284 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
5285 struct linux_binprm;
5286 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
5287 int uses_interp);
5288
5289 -struct mm_struct;
5290 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
5291 -#define arch_randomize_brk arch_randomize_brk
5292 -
5293 #endif /* _ASM_ELF_H */
5294 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
5295 index c1f6afa..38cc6e9 100644
5296 --- a/arch/mips/include/asm/exec.h
5297 +++ b/arch/mips/include/asm/exec.h
5298 @@ -12,6 +12,6 @@
5299 #ifndef _ASM_EXEC_H
5300 #define _ASM_EXEC_H
5301
5302 -extern unsigned long arch_align_stack(unsigned long sp);
5303 +#define arch_align_stack(x) ((x) & ~0xfUL)
5304
5305 #endif /* _ASM_EXEC_H */
5306 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
5307 index f59552f..3abe9b9 100644
5308 --- a/arch/mips/include/asm/page.h
5309 +++ b/arch/mips/include/asm/page.h
5310 @@ -95,7 +95,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
5311 #ifdef CONFIG_CPU_MIPS32
5312 typedef struct { unsigned long pte_low, pte_high; } pte_t;
5313 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
5314 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
5315 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
5316 #else
5317 typedef struct { unsigned long long pte; } pte_t;
5318 #define pte_val(x) ((x).pte)
5319 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
5320 index 881d18b..cea38bc 100644
5321 --- a/arch/mips/include/asm/pgalloc.h
5322 +++ b/arch/mips/include/asm/pgalloc.h
5323 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5324 {
5325 set_pud(pud, __pud((unsigned long)pmd));
5326 }
5327 +
5328 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5329 +{
5330 + pud_populate(mm, pud, pmd);
5331 +}
5332 #endif
5333
5334 /*
5335 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
5336 index 895320e..bf63e10 100644
5337 --- a/arch/mips/include/asm/thread_info.h
5338 +++ b/arch/mips/include/asm/thread_info.h
5339 @@ -115,6 +115,8 @@ static inline struct thread_info *current_thread_info(void)
5340 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
5341 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
5342 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
5343 +/* li takes a 32bit immediate */
5344 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
5345 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
5346
5347 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
5348 @@ -130,15 +132,18 @@ static inline struct thread_info *current_thread_info(void)
5349 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
5350 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
5351 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
5352 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
5353 +
5354 +#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5355
5356 /* work to do in syscall_trace_leave() */
5357 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT)
5358 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5359
5360 /* work to do on interrupt/exception return */
5361 #define _TIF_WORK_MASK \
5362 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
5363 /* work to do on any return to u-space */
5364 -#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT)
5365 +#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT | _TIF_GRSEC_SETXID)
5366
5367 #endif /* __KERNEL__ */
5368
5369 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
5370 index 1188e00..41cf144 100644
5371 --- a/arch/mips/kernel/binfmt_elfn32.c
5372 +++ b/arch/mips/kernel/binfmt_elfn32.c
5373 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5374 #undef ELF_ET_DYN_BASE
5375 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5376
5377 +#ifdef CONFIG_PAX_ASLR
5378 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5379 +
5380 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5381 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5382 +#endif
5383 +
5384 #include <asm/processor.h>
5385 #include <linux/module.h>
5386 #include <linux/elfcore.h>
5387 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
5388 index 202e581..689ca79 100644
5389 --- a/arch/mips/kernel/binfmt_elfo32.c
5390 +++ b/arch/mips/kernel/binfmt_elfo32.c
5391 @@ -56,6 +56,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5392 #undef ELF_ET_DYN_BASE
5393 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5394
5395 +#ifdef CONFIG_PAX_ASLR
5396 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5397 +
5398 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5399 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5400 +#endif
5401 +
5402 #include <asm/processor.h>
5403
5404 /*
5405 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
5406 index c6a041d..b3e7318 100644
5407 --- a/arch/mips/kernel/process.c
5408 +++ b/arch/mips/kernel/process.c
5409 @@ -563,15 +563,3 @@ unsigned long get_wchan(struct task_struct *task)
5410 out:
5411 return pc;
5412 }
5413 -
5414 -/*
5415 - * Don't forget that the stack pointer must be aligned on a 8 bytes
5416 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
5417 - */
5418 -unsigned long arch_align_stack(unsigned long sp)
5419 -{
5420 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
5421 - sp -= get_random_int() & ~PAGE_MASK;
5422 -
5423 - return sp & ALMASK;
5424 -}
5425 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
5426 index 9c6299c..2fb4c22 100644
5427 --- a/arch/mips/kernel/ptrace.c
5428 +++ b/arch/mips/kernel/ptrace.c
5429 @@ -528,6 +528,10 @@ static inline int audit_arch(void)
5430 return arch;
5431 }
5432
5433 +#ifdef CONFIG_GRKERNSEC_SETXID
5434 +extern void gr_delayed_cred_worker(void);
5435 +#endif
5436 +
5437 /*
5438 * Notification of system call entry/exit
5439 * - triggered by current->work.syscall_trace
5440 @@ -537,6 +541,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
5441 /* do the secure computing check first */
5442 secure_computing_strict(regs->regs[2]);
5443
5444 +#ifdef CONFIG_GRKERNSEC_SETXID
5445 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
5446 + gr_delayed_cred_worker();
5447 +#endif
5448 +
5449 if (!(current->ptrace & PT_PTRACED))
5450 goto out;
5451
5452 diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
5453 index 9b36424..e7f4154 100644
5454 --- a/arch/mips/kernel/scall32-o32.S
5455 +++ b/arch/mips/kernel/scall32-o32.S
5456 @@ -52,7 +52,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5457
5458 stack_done:
5459 lw t0, TI_FLAGS($28) # syscall tracing enabled?
5460 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5461 + li t1, _TIF_SYSCALL_WORK
5462 and t0, t1
5463 bnez t0, syscall_trace_entry # -> yes
5464
5465 diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
5466 index 97a5909..59622f8 100644
5467 --- a/arch/mips/kernel/scall64-64.S
5468 +++ b/arch/mips/kernel/scall64-64.S
5469 @@ -54,7 +54,7 @@ NESTED(handle_sys64, PT_SIZE, sp)
5470
5471 sd a3, PT_R26(sp) # save a3 for syscall restarting
5472
5473 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5474 + li t1, _TIF_SYSCALL_WORK
5475 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5476 and t0, t1, t0
5477 bnez t0, syscall_trace_entry
5478 diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
5479 index edcb659..fb2ab09 100644
5480 --- a/arch/mips/kernel/scall64-n32.S
5481 +++ b/arch/mips/kernel/scall64-n32.S
5482 @@ -47,7 +47,7 @@ NESTED(handle_sysn32, PT_SIZE, sp)
5483
5484 sd a3, PT_R26(sp) # save a3 for syscall restarting
5485
5486 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5487 + li t1, _TIF_SYSCALL_WORK
5488 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5489 and t0, t1, t0
5490 bnez t0, n32_syscall_trace_entry
5491 diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
5492 index 74f485d..47d2c38 100644
5493 --- a/arch/mips/kernel/scall64-o32.S
5494 +++ b/arch/mips/kernel/scall64-o32.S
5495 @@ -81,7 +81,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5496 PTR 4b, bad_stack
5497 .previous
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, trace_a_syscall
5504 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
5505 index 0fead53..a2c0fb5 100644
5506 --- a/arch/mips/mm/fault.c
5507 +++ b/arch/mips/mm/fault.c
5508 @@ -27,6 +27,23 @@
5509 #include <asm/highmem.h> /* For VMALLOC_END */
5510 #include <linux/kdebug.h>
5511
5512 +#ifdef CONFIG_PAX_PAGEEXEC
5513 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5514 +{
5515 + unsigned long i;
5516 +
5517 + printk(KERN_ERR "PAX: bytes at PC: ");
5518 + for (i = 0; i < 5; i++) {
5519 + unsigned int c;
5520 + if (get_user(c, (unsigned int *)pc+i))
5521 + printk(KERN_CONT "???????? ");
5522 + else
5523 + printk(KERN_CONT "%08x ", c);
5524 + }
5525 + printk("\n");
5526 +}
5527 +#endif
5528 +
5529 /*
5530 * This routine handles page faults. It determines the address,
5531 * and the problem, and then passes it off to one of the appropriate
5532 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
5533 index 7e5fe27..9656513 100644
5534 --- a/arch/mips/mm/mmap.c
5535 +++ b/arch/mips/mm/mmap.c
5536 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5537 struct vm_area_struct *vma;
5538 unsigned long addr = addr0;
5539 int do_color_align;
5540 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5541 struct vm_unmapped_area_info info;
5542
5543 if (unlikely(len > TASK_SIZE))
5544 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5545 do_color_align = 1;
5546
5547 /* requesting a specific address */
5548 +
5549 +#ifdef CONFIG_PAX_RANDMMAP
5550 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
5551 +#endif
5552 +
5553 if (addr) {
5554 if (do_color_align)
5555 addr = COLOUR_ALIGN(addr, pgoff);
5556 @@ -91,14 +97,14 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5557 addr = PAGE_ALIGN(addr);
5558
5559 vma = find_vma(mm, addr);
5560 - if (TASK_SIZE - len >= addr &&
5561 - (!vma || addr + len <= vma->vm_start))
5562 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len, offset))
5563 return addr;
5564 }
5565
5566 info.length = len;
5567 info.align_mask = do_color_align ? (PAGE_MASK & shm_align_mask) : 0;
5568 info.align_offset = pgoff << PAGE_SHIFT;
5569 + info.threadstack_offset = offset;
5570
5571 if (dir == DOWN) {
5572 info.flags = VM_UNMAPPED_AREA_TOPDOWN;
5573 @@ -146,6 +152,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5574 {
5575 unsigned long random_factor = 0UL;
5576
5577 +#ifdef CONFIG_PAX_RANDMMAP
5578 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
5579 +#endif
5580 +
5581 if (current->flags & PF_RANDOMIZE) {
5582 random_factor = get_random_int();
5583 random_factor = random_factor << PAGE_SHIFT;
5584 @@ -157,42 +167,27 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5585
5586 if (mmap_is_legacy()) {
5587 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
5588 +
5589 +#ifdef CONFIG_PAX_RANDMMAP
5590 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5591 + mm->mmap_base += mm->delta_mmap;
5592 +#endif
5593 +
5594 mm->get_unmapped_area = arch_get_unmapped_area;
5595 mm->unmap_area = arch_unmap_area;
5596 } else {
5597 mm->mmap_base = mmap_base(random_factor);
5598 +
5599 +#ifdef CONFIG_PAX_RANDMMAP
5600 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5601 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
5602 +#endif
5603 +
5604 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
5605 mm->unmap_area = arch_unmap_area_topdown;
5606 }
5607 }
5608
5609 -static inline unsigned long brk_rnd(void)
5610 -{
5611 - unsigned long rnd = get_random_int();
5612 -
5613 - rnd = rnd << PAGE_SHIFT;
5614 - /* 8MB for 32bit, 256MB for 64bit */
5615 - if (TASK_IS_32BIT_ADDR)
5616 - rnd = rnd & 0x7ffffful;
5617 - else
5618 - rnd = rnd & 0xffffffful;
5619 -
5620 - return rnd;
5621 -}
5622 -
5623 -unsigned long arch_randomize_brk(struct mm_struct *mm)
5624 -{
5625 - unsigned long base = mm->brk;
5626 - unsigned long ret;
5627 -
5628 - ret = PAGE_ALIGN(base + brk_rnd());
5629 -
5630 - if (ret < mm->brk)
5631 - return mm->brk;
5632 -
5633 - return ret;
5634 -}
5635 -
5636 int __virt_addr_valid(const volatile void *kaddr)
5637 {
5638 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
5639 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5640 index 967d144..db12197 100644
5641 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
5642 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5643 @@ -11,12 +11,14 @@
5644 #ifndef _ASM_PROC_CACHE_H
5645 #define _ASM_PROC_CACHE_H
5646
5647 +#include <linux/const.h>
5648 +
5649 /* L1 cache */
5650
5651 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5652 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
5653 -#define L1_CACHE_BYTES 16 /* bytes per entry */
5654 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
5655 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5656 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
5657
5658 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5659 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5660 index bcb5df2..84fabd2 100644
5661 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5662 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5663 @@ -16,13 +16,15 @@
5664 #ifndef _ASM_PROC_CACHE_H
5665 #define _ASM_PROC_CACHE_H
5666
5667 +#include <linux/const.h>
5668 +
5669 /*
5670 * L1 cache
5671 */
5672 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5673 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
5674 -#define L1_CACHE_BYTES 32 /* bytes per entry */
5675 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
5676 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5677 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
5678
5679 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5680 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
5681 index 4ce7a01..449202a 100644
5682 --- a/arch/openrisc/include/asm/cache.h
5683 +++ b/arch/openrisc/include/asm/cache.h
5684 @@ -19,11 +19,13 @@
5685 #ifndef __ASM_OPENRISC_CACHE_H
5686 #define __ASM_OPENRISC_CACHE_H
5687
5688 +#include <linux/const.h>
5689 +
5690 /* FIXME: How can we replace these with values from the CPU...
5691 * they shouldn't be hard-coded!
5692 */
5693
5694 -#define L1_CACHE_BYTES 16
5695 #define L1_CACHE_SHIFT 4
5696 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5697
5698 #endif /* __ASM_OPENRISC_CACHE_H */
5699 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
5700 index 472886c..00e7df9 100644
5701 --- a/arch/parisc/include/asm/atomic.h
5702 +++ b/arch/parisc/include/asm/atomic.h
5703 @@ -252,6 +252,16 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
5704 return dec;
5705 }
5706
5707 +#define atomic64_read_unchecked(v) atomic64_read(v)
5708 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5709 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5710 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5711 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5712 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5713 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5714 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5715 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5716 +
5717 #endif /* !CONFIG_64BIT */
5718
5719
5720 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
5721 index 47f11c7..3420df2 100644
5722 --- a/arch/parisc/include/asm/cache.h
5723 +++ b/arch/parisc/include/asm/cache.h
5724 @@ -5,6 +5,7 @@
5725 #ifndef __ARCH_PARISC_CACHE_H
5726 #define __ARCH_PARISC_CACHE_H
5727
5728 +#include <linux/const.h>
5729
5730 /*
5731 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
5732 @@ -15,13 +16,13 @@
5733 * just ruin performance.
5734 */
5735 #ifdef CONFIG_PA20
5736 -#define L1_CACHE_BYTES 64
5737 #define L1_CACHE_SHIFT 6
5738 #else
5739 -#define L1_CACHE_BYTES 32
5740 #define L1_CACHE_SHIFT 5
5741 #endif
5742
5743 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5744 +
5745 #ifndef __ASSEMBLY__
5746
5747 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5748 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
5749 index ad2b503..bdf1651 100644
5750 --- a/arch/parisc/include/asm/elf.h
5751 +++ b/arch/parisc/include/asm/elf.h
5752 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
5753
5754 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
5755
5756 +#ifdef CONFIG_PAX_ASLR
5757 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
5758 +
5759 +#define PAX_DELTA_MMAP_LEN 16
5760 +#define PAX_DELTA_STACK_LEN 16
5761 +#endif
5762 +
5763 /* This yields a mask that user programs can use to figure out what
5764 instruction set this CPU supports. This could be done in user space,
5765 but it's not easy, and we've already done it here. */
5766 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
5767 index fc987a1..6e068ef 100644
5768 --- a/arch/parisc/include/asm/pgalloc.h
5769 +++ b/arch/parisc/include/asm/pgalloc.h
5770 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
5771 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
5772 }
5773
5774 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
5775 +{
5776 + pgd_populate(mm, pgd, pmd);
5777 +}
5778 +
5779 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
5780 {
5781 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
5782 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
5783 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
5784 #define pmd_free(mm, x) do { } while (0)
5785 #define pgd_populate(mm, pmd, pte) BUG()
5786 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
5787
5788 #endif
5789
5790 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
5791 index 1e40d7f..a3eb445 100644
5792 --- a/arch/parisc/include/asm/pgtable.h
5793 +++ b/arch/parisc/include/asm/pgtable.h
5794 @@ -223,6 +223,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
5795 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
5796 #define PAGE_COPY PAGE_EXECREAD
5797 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
5798 +
5799 +#ifdef CONFIG_PAX_PAGEEXEC
5800 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
5801 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
5802 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
5803 +#else
5804 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
5805 +# define PAGE_COPY_NOEXEC PAGE_COPY
5806 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
5807 +#endif
5808 +
5809 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
5810 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
5811 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
5812 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
5813 index e0a8235..ce2f1e1 100644
5814 --- a/arch/parisc/include/asm/uaccess.h
5815 +++ b/arch/parisc/include/asm/uaccess.h
5816 @@ -245,10 +245,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
5817 const void __user *from,
5818 unsigned long n)
5819 {
5820 - int sz = __compiletime_object_size(to);
5821 + size_t sz = __compiletime_object_size(to);
5822 int ret = -EFAULT;
5823
5824 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
5825 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
5826 ret = __copy_from_user(to, from, n);
5827 else
5828 copy_from_user_overflow();
5829 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
5830 index 2a625fb..9908930 100644
5831 --- a/arch/parisc/kernel/module.c
5832 +++ b/arch/parisc/kernel/module.c
5833 @@ -98,16 +98,38 @@
5834
5835 /* three functions to determine where in the module core
5836 * or init pieces the location is */
5837 +static inline int in_init_rx(struct module *me, void *loc)
5838 +{
5839 + return (loc >= me->module_init_rx &&
5840 + loc < (me->module_init_rx + me->init_size_rx));
5841 +}
5842 +
5843 +static inline int in_init_rw(struct module *me, void *loc)
5844 +{
5845 + return (loc >= me->module_init_rw &&
5846 + loc < (me->module_init_rw + me->init_size_rw));
5847 +}
5848 +
5849 static inline int in_init(struct module *me, void *loc)
5850 {
5851 - return (loc >= me->module_init &&
5852 - loc <= (me->module_init + me->init_size));
5853 + return in_init_rx(me, loc) || in_init_rw(me, loc);
5854 +}
5855 +
5856 +static inline int in_core_rx(struct module *me, void *loc)
5857 +{
5858 + return (loc >= me->module_core_rx &&
5859 + loc < (me->module_core_rx + me->core_size_rx));
5860 +}
5861 +
5862 +static inline int in_core_rw(struct module *me, void *loc)
5863 +{
5864 + return (loc >= me->module_core_rw &&
5865 + loc < (me->module_core_rw + me->core_size_rw));
5866 }
5867
5868 static inline int in_core(struct module *me, void *loc)
5869 {
5870 - return (loc >= me->module_core &&
5871 - loc <= (me->module_core + me->core_size));
5872 + return in_core_rx(me, loc) || in_core_rw(me, loc);
5873 }
5874
5875 static inline int in_local(struct module *me, void *loc)
5876 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
5877 }
5878
5879 /* align things a bit */
5880 - me->core_size = ALIGN(me->core_size, 16);
5881 - me->arch.got_offset = me->core_size;
5882 - me->core_size += gots * sizeof(struct got_entry);
5883 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
5884 + me->arch.got_offset = me->core_size_rw;
5885 + me->core_size_rw += gots * sizeof(struct got_entry);
5886
5887 - me->core_size = ALIGN(me->core_size, 16);
5888 - me->arch.fdesc_offset = me->core_size;
5889 - me->core_size += fdescs * sizeof(Elf_Fdesc);
5890 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
5891 + me->arch.fdesc_offset = me->core_size_rw;
5892 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
5893
5894 me->arch.got_max = gots;
5895 me->arch.fdesc_max = fdescs;
5896 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
5897
5898 BUG_ON(value == 0);
5899
5900 - got = me->module_core + me->arch.got_offset;
5901 + got = me->module_core_rw + me->arch.got_offset;
5902 for (i = 0; got[i].addr; i++)
5903 if (got[i].addr == value)
5904 goto out;
5905 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
5906 #ifdef CONFIG_64BIT
5907 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
5908 {
5909 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
5910 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
5911
5912 if (!value) {
5913 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
5914 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
5915
5916 /* Create new one */
5917 fdesc->addr = value;
5918 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
5919 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
5920 return (Elf_Addr)fdesc;
5921 }
5922 #endif /* CONFIG_64BIT */
5923 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
5924
5925 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
5926 end = table + sechdrs[me->arch.unwind_section].sh_size;
5927 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
5928 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
5929
5930 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
5931 me->arch.unwind_section, table, end, gp);
5932 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
5933 index 5dfd248..64914ac 100644
5934 --- a/arch/parisc/kernel/sys_parisc.c
5935 +++ b/arch/parisc/kernel/sys_parisc.c
5936 @@ -33,9 +33,11 @@
5937 #include <linux/utsname.h>
5938 #include <linux/personality.h>
5939
5940 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
5941 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
5942 + unsigned long flags)
5943 {
5944 struct vm_unmapped_area_info info;
5945 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
5946
5947 info.flags = 0;
5948 info.length = len;
5949 @@ -43,6 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
5950 info.high_limit = TASK_SIZE;
5951 info.align_mask = 0;
5952 info.align_offset = 0;
5953 + info.threadstack_offset = offset;
5954 return vm_unmapped_area(&info);
5955 }
5956
5957 @@ -61,10 +64,11 @@ static int get_offset(struct address_space *mapping)
5958 return (unsigned long) mapping >> 8;
5959 }
5960
5961 -static unsigned long get_shared_area(struct address_space *mapping,
5962 - unsigned long addr, unsigned long len, unsigned long pgoff)
5963 +static unsigned long get_shared_area(struct file *filp, struct address_space *mapping,
5964 + unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
5965 {
5966 struct vm_unmapped_area_info info;
5967 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
5968
5969 info.flags = 0;
5970 info.length = len;
5971 @@ -72,6 +76,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
5972 info.high_limit = TASK_SIZE;
5973 info.align_mask = PAGE_MASK & (SHMLBA - 1);
5974 info.align_offset = (get_offset(mapping) + pgoff) << PAGE_SHIFT;
5975 + info.threadstack_offset = offset;
5976 return vm_unmapped_area(&info);
5977 }
5978
5979 @@ -86,15 +91,22 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
5980 return -EINVAL;
5981 return addr;
5982 }
5983 - if (!addr)
5984 + if (!addr) {
5985 addr = TASK_UNMAPPED_BASE;
5986
5987 +#ifdef CONFIG_PAX_RANDMMAP
5988 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
5989 + addr += current->mm->delta_mmap;
5990 +#endif
5991 +
5992 + }
5993 +
5994 if (filp) {
5995 - addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
5996 + addr = get_shared_area(filp, filp->f_mapping, addr, len, pgoff, flags);
5997 } else if(flags & MAP_SHARED) {
5998 - addr = get_shared_area(NULL, addr, len, pgoff);
5999 + addr = get_shared_area(filp, NULL, addr, len, pgoff, flags);
6000 } else {
6001 - addr = get_unshared_area(addr, len);
6002 + addr = get_unshared_area(filp, addr, len, flags);
6003 }
6004 return addr;
6005 }
6006 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
6007 index 04e47c6..7a8faf6 100644
6008 --- a/arch/parisc/kernel/traps.c
6009 +++ b/arch/parisc/kernel/traps.c
6010 @@ -727,9 +727,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
6011
6012 down_read(&current->mm->mmap_sem);
6013 vma = find_vma(current->mm,regs->iaoq[0]);
6014 - if (vma && (regs->iaoq[0] >= vma->vm_start)
6015 - && (vma->vm_flags & VM_EXEC)) {
6016 -
6017 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
6018 fault_address = regs->iaoq[0];
6019 fault_space = regs->iasq[0];
6020
6021 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
6022 index f247a34..dc0f219 100644
6023 --- a/arch/parisc/mm/fault.c
6024 +++ b/arch/parisc/mm/fault.c
6025 @@ -15,6 +15,7 @@
6026 #include <linux/sched.h>
6027 #include <linux/interrupt.h>
6028 #include <linux/module.h>
6029 +#include <linux/unistd.h>
6030
6031 #include <asm/uaccess.h>
6032 #include <asm/traps.h>
6033 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
6034 static unsigned long
6035 parisc_acctyp(unsigned long code, unsigned int inst)
6036 {
6037 - if (code == 6 || code == 16)
6038 + if (code == 6 || code == 7 || code == 16)
6039 return VM_EXEC;
6040
6041 switch (inst & 0xf0000000) {
6042 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
6043 }
6044 #endif
6045
6046 +#ifdef CONFIG_PAX_PAGEEXEC
6047 +/*
6048 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
6049 + *
6050 + * returns 1 when task should be killed
6051 + * 2 when rt_sigreturn trampoline was detected
6052 + * 3 when unpatched PLT trampoline was detected
6053 + */
6054 +static int pax_handle_fetch_fault(struct pt_regs *regs)
6055 +{
6056 +
6057 +#ifdef CONFIG_PAX_EMUPLT
6058 + int err;
6059 +
6060 + do { /* PaX: unpatched PLT emulation */
6061 + unsigned int bl, depwi;
6062 +
6063 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
6064 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
6065 +
6066 + if (err)
6067 + break;
6068 +
6069 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
6070 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
6071 +
6072 + err = get_user(ldw, (unsigned int *)addr);
6073 + err |= get_user(bv, (unsigned int *)(addr+4));
6074 + err |= get_user(ldw2, (unsigned int *)(addr+8));
6075 +
6076 + if (err)
6077 + break;
6078 +
6079 + if (ldw == 0x0E801096U &&
6080 + bv == 0xEAC0C000U &&
6081 + ldw2 == 0x0E881095U)
6082 + {
6083 + unsigned int resolver, map;
6084 +
6085 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
6086 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
6087 + if (err)
6088 + break;
6089 +
6090 + regs->gr[20] = instruction_pointer(regs)+8;
6091 + regs->gr[21] = map;
6092 + regs->gr[22] = resolver;
6093 + regs->iaoq[0] = resolver | 3UL;
6094 + regs->iaoq[1] = regs->iaoq[0] + 4;
6095 + return 3;
6096 + }
6097 + }
6098 + } while (0);
6099 +#endif
6100 +
6101 +#ifdef CONFIG_PAX_EMUTRAMP
6102 +
6103 +#ifndef CONFIG_PAX_EMUSIGRT
6104 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
6105 + return 1;
6106 +#endif
6107 +
6108 + do { /* PaX: rt_sigreturn emulation */
6109 + unsigned int ldi1, ldi2, bel, nop;
6110 +
6111 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
6112 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
6113 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
6114 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
6115 +
6116 + if (err)
6117 + break;
6118 +
6119 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
6120 + ldi2 == 0x3414015AU &&
6121 + bel == 0xE4008200U &&
6122 + nop == 0x08000240U)
6123 + {
6124 + regs->gr[25] = (ldi1 & 2) >> 1;
6125 + regs->gr[20] = __NR_rt_sigreturn;
6126 + regs->gr[31] = regs->iaoq[1] + 16;
6127 + regs->sr[0] = regs->iasq[1];
6128 + regs->iaoq[0] = 0x100UL;
6129 + regs->iaoq[1] = regs->iaoq[0] + 4;
6130 + regs->iasq[0] = regs->sr[2];
6131 + regs->iasq[1] = regs->sr[2];
6132 + return 2;
6133 + }
6134 + } while (0);
6135 +#endif
6136 +
6137 + return 1;
6138 +}
6139 +
6140 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6141 +{
6142 + unsigned long i;
6143 +
6144 + printk(KERN_ERR "PAX: bytes at PC: ");
6145 + for (i = 0; i < 5; i++) {
6146 + unsigned int c;
6147 + if (get_user(c, (unsigned int *)pc+i))
6148 + printk(KERN_CONT "???????? ");
6149 + else
6150 + printk(KERN_CONT "%08x ", c);
6151 + }
6152 + printk("\n");
6153 +}
6154 +#endif
6155 +
6156 int fixup_exception(struct pt_regs *regs)
6157 {
6158 const struct exception_table_entry *fix;
6159 @@ -194,8 +305,33 @@ good_area:
6160
6161 acc_type = parisc_acctyp(code,regs->iir);
6162
6163 - if ((vma->vm_flags & acc_type) != acc_type)
6164 + if ((vma->vm_flags & acc_type) != acc_type) {
6165 +
6166 +#ifdef CONFIG_PAX_PAGEEXEC
6167 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
6168 + (address & ~3UL) == instruction_pointer(regs))
6169 + {
6170 + up_read(&mm->mmap_sem);
6171 + switch (pax_handle_fetch_fault(regs)) {
6172 +
6173 +#ifdef CONFIG_PAX_EMUPLT
6174 + case 3:
6175 + return;
6176 +#endif
6177 +
6178 +#ifdef CONFIG_PAX_EMUTRAMP
6179 + case 2:
6180 + return;
6181 +#endif
6182 +
6183 + }
6184 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
6185 + do_group_exit(SIGKILL);
6186 + }
6187 +#endif
6188 +
6189 goto bad_area;
6190 + }
6191
6192 /*
6193 * If for any reason at all we couldn't handle the fault, make
6194 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
6195 index e3b1d41..8e81edf 100644
6196 --- a/arch/powerpc/include/asm/atomic.h
6197 +++ b/arch/powerpc/include/asm/atomic.h
6198 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
6199 return t1;
6200 }
6201
6202 +#define atomic64_read_unchecked(v) atomic64_read(v)
6203 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
6204 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
6205 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
6206 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
6207 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
6208 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
6209 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
6210 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
6211 +
6212 #endif /* __powerpc64__ */
6213
6214 #endif /* __KERNEL__ */
6215 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
6216 index 9e495c9..b6878e5 100644
6217 --- a/arch/powerpc/include/asm/cache.h
6218 +++ b/arch/powerpc/include/asm/cache.h
6219 @@ -3,6 +3,7 @@
6220
6221 #ifdef __KERNEL__
6222
6223 +#include <linux/const.h>
6224
6225 /* bytes per L1 cache line */
6226 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
6227 @@ -22,7 +23,7 @@
6228 #define L1_CACHE_SHIFT 7
6229 #endif
6230
6231 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6232 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6233
6234 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6235
6236 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
6237 index cc0655a..13eac2e 100644
6238 --- a/arch/powerpc/include/asm/elf.h
6239 +++ b/arch/powerpc/include/asm/elf.h
6240 @@ -28,8 +28,19 @@
6241 the loader. We need to make sure that it is out of the way of the program
6242 that it will "exec", and that there is sufficient room for the brk. */
6243
6244 -extern unsigned long randomize_et_dyn(unsigned long base);
6245 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
6246 +#define ELF_ET_DYN_BASE (0x20000000)
6247 +
6248 +#ifdef CONFIG_PAX_ASLR
6249 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
6250 +
6251 +#ifdef __powerpc64__
6252 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
6253 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
6254 +#else
6255 +#define PAX_DELTA_MMAP_LEN 15
6256 +#define PAX_DELTA_STACK_LEN 15
6257 +#endif
6258 +#endif
6259
6260 /*
6261 * Our registers are always unsigned longs, whether we're a 32 bit
6262 @@ -123,10 +134,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6263 (0x7ff >> (PAGE_SHIFT - 12)) : \
6264 (0x3ffff >> (PAGE_SHIFT - 12)))
6265
6266 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6267 -#define arch_randomize_brk arch_randomize_brk
6268 -
6269 -
6270 #ifdef CONFIG_SPU_BASE
6271 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
6272 #define NT_SPU 1
6273 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
6274 index 8196e9c..d83a9f3 100644
6275 --- a/arch/powerpc/include/asm/exec.h
6276 +++ b/arch/powerpc/include/asm/exec.h
6277 @@ -4,6 +4,6 @@
6278 #ifndef _ASM_POWERPC_EXEC_H
6279 #define _ASM_POWERPC_EXEC_H
6280
6281 -extern unsigned long arch_align_stack(unsigned long sp);
6282 +#define arch_align_stack(x) ((x) & ~0xfUL)
6283
6284 #endif /* _ASM_POWERPC_EXEC_H */
6285 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
6286 index 5acabbd..7ea14fa 100644
6287 --- a/arch/powerpc/include/asm/kmap_types.h
6288 +++ b/arch/powerpc/include/asm/kmap_types.h
6289 @@ -10,7 +10,7 @@
6290 * 2 of the License, or (at your option) any later version.
6291 */
6292
6293 -#define KM_TYPE_NR 16
6294 +#define KM_TYPE_NR 17
6295
6296 #endif /* __KERNEL__ */
6297 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
6298 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
6299 index 8565c25..2865190 100644
6300 --- a/arch/powerpc/include/asm/mman.h
6301 +++ b/arch/powerpc/include/asm/mman.h
6302 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
6303 }
6304 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
6305
6306 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
6307 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
6308 {
6309 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
6310 }
6311 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
6312 index 988c812..63c7d70 100644
6313 --- a/arch/powerpc/include/asm/page.h
6314 +++ b/arch/powerpc/include/asm/page.h
6315 @@ -220,8 +220,9 @@ extern long long virt_phys_offset;
6316 * and needs to be executable. This means the whole heap ends
6317 * up being executable.
6318 */
6319 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6320 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6321 +#define VM_DATA_DEFAULT_FLAGS32 \
6322 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6323 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6324
6325 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6326 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6327 @@ -249,6 +250,9 @@ extern long long virt_phys_offset;
6328 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
6329 #endif
6330
6331 +#define ktla_ktva(addr) (addr)
6332 +#define ktva_ktla(addr) (addr)
6333 +
6334 #ifndef CONFIG_PPC_BOOK3S_64
6335 /*
6336 * Use the top bit of the higher-level page table entries to indicate whether
6337 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
6338 index 88693ce..ac6f9ab 100644
6339 --- a/arch/powerpc/include/asm/page_64.h
6340 +++ b/arch/powerpc/include/asm/page_64.h
6341 @@ -153,15 +153,18 @@ do { \
6342 * stack by default, so in the absence of a PT_GNU_STACK program header
6343 * we turn execute permission off.
6344 */
6345 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6346 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6347 +#define VM_STACK_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_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6352 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6353
6354 +#ifndef CONFIG_PAX_PAGEEXEC
6355 #define VM_STACK_DEFAULT_FLAGS \
6356 (is_32bit_task() ? \
6357 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
6358 +#endif
6359
6360 #include <asm-generic/getorder.h>
6361
6362 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
6363 index b66ae72..4a378cd 100644
6364 --- a/arch/powerpc/include/asm/pgalloc-64.h
6365 +++ b/arch/powerpc/include/asm/pgalloc-64.h
6366 @@ -53,6 +53,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
6367 #ifndef CONFIG_PPC_64K_PAGES
6368
6369 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
6370 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
6371
6372 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
6373 {
6374 @@ -70,6 +71,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6375 pud_set(pud, (unsigned long)pmd);
6376 }
6377
6378 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6379 +{
6380 + pud_populate(mm, pud, pmd);
6381 +}
6382 +
6383 #define pmd_populate(mm, pmd, pte_page) \
6384 pmd_populate_kernel(mm, pmd, page_address(pte_page))
6385 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
6386 @@ -171,6 +177,7 @@ extern void __tlb_remove_table(void *_table);
6387 #endif
6388
6389 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
6390 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
6391
6392 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
6393 pte_t *pte)
6394 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
6395 index 7aeb955..19f748e 100644
6396 --- a/arch/powerpc/include/asm/pgtable.h
6397 +++ b/arch/powerpc/include/asm/pgtable.h
6398 @@ -2,6 +2,7 @@
6399 #define _ASM_POWERPC_PGTABLE_H
6400 #ifdef __KERNEL__
6401
6402 +#include <linux/const.h>
6403 #ifndef __ASSEMBLY__
6404 #include <asm/processor.h> /* For TASK_SIZE */
6405 #include <asm/mmu.h>
6406 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
6407 index 4aad413..85d86bf 100644
6408 --- a/arch/powerpc/include/asm/pte-hash32.h
6409 +++ b/arch/powerpc/include/asm/pte-hash32.h
6410 @@ -21,6 +21,7 @@
6411 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
6412 #define _PAGE_USER 0x004 /* usermode access allowed */
6413 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
6414 +#define _PAGE_EXEC _PAGE_GUARDED
6415 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
6416 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
6417 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
6418 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
6419 index 4a9e408..724aa59 100644
6420 --- a/arch/powerpc/include/asm/reg.h
6421 +++ b/arch/powerpc/include/asm/reg.h
6422 @@ -234,6 +234,7 @@
6423 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
6424 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
6425 #define DSISR_NOHPTE 0x40000000 /* no translation found */
6426 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
6427 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
6428 #define DSISR_ISSTORE 0x02000000 /* access was a store */
6429 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
6430 diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
6431 index ffbaabe..eabe843 100644
6432 --- a/arch/powerpc/include/asm/smp.h
6433 +++ b/arch/powerpc/include/asm/smp.h
6434 @@ -50,7 +50,7 @@ struct smp_ops_t {
6435 int (*cpu_disable)(void);
6436 void (*cpu_die)(unsigned int nr);
6437 int (*cpu_bootable)(unsigned int nr);
6438 -};
6439 +} __no_const;
6440
6441 extern void smp_send_debugger_break(void);
6442 extern void start_secondary_resume(void);
6443 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
6444 index ba7b197..d292e26 100644
6445 --- a/arch/powerpc/include/asm/thread_info.h
6446 +++ b/arch/powerpc/include/asm/thread_info.h
6447 @@ -93,7 +93,6 @@ static inline struct thread_info *current_thread_info(void)
6448 #define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
6449 TIF_NEED_RESCHED */
6450 #define TIF_32BIT 4 /* 32 bit binary */
6451 -#define TIF_PERFMON_WORK 5 /* work for pfm_handle_work() */
6452 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
6453 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
6454 #define TIF_SINGLESTEP 8 /* singlestepping active */
6455 @@ -107,6 +106,9 @@ static inline struct thread_info *current_thread_info(void)
6456 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
6457 for stack store? */
6458 #define TIF_MEMDIE 17 /* is terminating due to OOM killer */
6459 +#define TIF_PERFMON_WORK 18 /* work for pfm_handle_work() */
6460 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
6461 +#define TIF_GRSEC_SETXID 5 /* update credentials on syscall entry/exit */
6462
6463 /* as above, but as bit values */
6464 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6465 @@ -126,9 +128,10 @@ static inline struct thread_info *current_thread_info(void)
6466 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
6467 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
6468 #define _TIF_NOHZ (1<<TIF_NOHZ)
6469 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6470 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
6471 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
6472 - _TIF_NOHZ)
6473 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
6474
6475 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
6476 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
6477 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
6478 index 4db4959..aba5c41 100644
6479 --- a/arch/powerpc/include/asm/uaccess.h
6480 +++ b/arch/powerpc/include/asm/uaccess.h
6481 @@ -318,52 +318,6 @@ do { \
6482 extern unsigned long __copy_tofrom_user(void __user *to,
6483 const void __user *from, unsigned long size);
6484
6485 -#ifndef __powerpc64__
6486 -
6487 -static inline unsigned long copy_from_user(void *to,
6488 - const void __user *from, unsigned long n)
6489 -{
6490 - unsigned long over;
6491 -
6492 - if (access_ok(VERIFY_READ, from, n))
6493 - return __copy_tofrom_user((__force void __user *)to, from, n);
6494 - if ((unsigned long)from < TASK_SIZE) {
6495 - over = (unsigned long)from + n - TASK_SIZE;
6496 - return __copy_tofrom_user((__force void __user *)to, from,
6497 - n - over) + over;
6498 - }
6499 - return n;
6500 -}
6501 -
6502 -static inline unsigned long copy_to_user(void __user *to,
6503 - const void *from, unsigned long n)
6504 -{
6505 - unsigned long over;
6506 -
6507 - if (access_ok(VERIFY_WRITE, to, n))
6508 - return __copy_tofrom_user(to, (__force void __user *)from, n);
6509 - if ((unsigned long)to < TASK_SIZE) {
6510 - over = (unsigned long)to + n - TASK_SIZE;
6511 - return __copy_tofrom_user(to, (__force void __user *)from,
6512 - n - over) + over;
6513 - }
6514 - return n;
6515 -}
6516 -
6517 -#else /* __powerpc64__ */
6518 -
6519 -#define __copy_in_user(to, from, size) \
6520 - __copy_tofrom_user((to), (from), (size))
6521 -
6522 -extern unsigned long copy_from_user(void *to, const void __user *from,
6523 - unsigned long n);
6524 -extern unsigned long copy_to_user(void __user *to, const void *from,
6525 - unsigned long n);
6526 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
6527 - unsigned long n);
6528 -
6529 -#endif /* __powerpc64__ */
6530 -
6531 static inline unsigned long __copy_from_user_inatomic(void *to,
6532 const void __user *from, unsigned long n)
6533 {
6534 @@ -387,6 +341,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
6535 if (ret == 0)
6536 return 0;
6537 }
6538 +
6539 + if (!__builtin_constant_p(n))
6540 + check_object_size(to, n, false);
6541 +
6542 return __copy_tofrom_user((__force void __user *)to, from, n);
6543 }
6544
6545 @@ -413,6 +371,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
6546 if (ret == 0)
6547 return 0;
6548 }
6549 +
6550 + if (!__builtin_constant_p(n))
6551 + check_object_size(from, n, true);
6552 +
6553 return __copy_tofrom_user(to, (__force const void __user *)from, n);
6554 }
6555
6556 @@ -430,6 +392,92 @@ static inline unsigned long __copy_to_user(void __user *to,
6557 return __copy_to_user_inatomic(to, from, size);
6558 }
6559
6560 +#ifndef __powerpc64__
6561 +
6562 +static inline unsigned long __must_check copy_from_user(void *to,
6563 + const void __user *from, unsigned long n)
6564 +{
6565 + unsigned long over;
6566 +
6567 + if ((long)n < 0)
6568 + return n;
6569 +
6570 + if (access_ok(VERIFY_READ, from, n)) {
6571 + if (!__builtin_constant_p(n))
6572 + check_object_size(to, n, false);
6573 + return __copy_tofrom_user((__force void __user *)to, from, n);
6574 + }
6575 + if ((unsigned long)from < TASK_SIZE) {
6576 + over = (unsigned long)from + n - TASK_SIZE;
6577 + if (!__builtin_constant_p(n - over))
6578 + check_object_size(to, n - over, false);
6579 + return __copy_tofrom_user((__force void __user *)to, from,
6580 + n - over) + over;
6581 + }
6582 + return n;
6583 +}
6584 +
6585 +static inline unsigned long __must_check copy_to_user(void __user *to,
6586 + const void *from, unsigned long n)
6587 +{
6588 + unsigned long over;
6589 +
6590 + if ((long)n < 0)
6591 + return n;
6592 +
6593 + if (access_ok(VERIFY_WRITE, to, n)) {
6594 + if (!__builtin_constant_p(n))
6595 + check_object_size(from, n, true);
6596 + return __copy_tofrom_user(to, (__force void __user *)from, n);
6597 + }
6598 + if ((unsigned long)to < TASK_SIZE) {
6599 + over = (unsigned long)to + n - TASK_SIZE;
6600 + if (!__builtin_constant_p(n))
6601 + check_object_size(from, n - over, true);
6602 + return __copy_tofrom_user(to, (__force void __user *)from,
6603 + n - over) + over;
6604 + }
6605 + return n;
6606 +}
6607 +
6608 +#else /* __powerpc64__ */
6609 +
6610 +#define __copy_in_user(to, from, size) \
6611 + __copy_tofrom_user((to), (from), (size))
6612 +
6613 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
6614 +{
6615 + if ((long)n < 0 || n > INT_MAX)
6616 + return n;
6617 +
6618 + if (!__builtin_constant_p(n))
6619 + check_object_size(to, n, false);
6620 +
6621 + if (likely(access_ok(VERIFY_READ, from, n)))
6622 + n = __copy_from_user(to, from, n);
6623 + else
6624 + memset(to, 0, n);
6625 + return n;
6626 +}
6627 +
6628 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
6629 +{
6630 + if ((long)n < 0 || n > INT_MAX)
6631 + return n;
6632 +
6633 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
6634 + if (!__builtin_constant_p(n))
6635 + check_object_size(from, n, true);
6636 + n = __copy_to_user(to, from, n);
6637 + }
6638 + return n;
6639 +}
6640 +
6641 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
6642 + unsigned long n);
6643 +
6644 +#endif /* __powerpc64__ */
6645 +
6646 extern unsigned long __clear_user(void __user *addr, unsigned long size);
6647
6648 static inline unsigned long clear_user(void __user *addr, unsigned long size)
6649 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
6650 index 645170a..6cf0271 100644
6651 --- a/arch/powerpc/kernel/exceptions-64e.S
6652 +++ b/arch/powerpc/kernel/exceptions-64e.S
6653 @@ -757,6 +757,7 @@ storage_fault_common:
6654 std r14,_DAR(r1)
6655 std r15,_DSISR(r1)
6656 addi r3,r1,STACK_FRAME_OVERHEAD
6657 + bl .save_nvgprs
6658 mr r4,r14
6659 mr r5,r15
6660 ld r14,PACA_EXGEN+EX_R14(r13)
6661 @@ -765,8 +766,7 @@ storage_fault_common:
6662 cmpdi r3,0
6663 bne- 1f
6664 b .ret_from_except_lite
6665 -1: bl .save_nvgprs
6666 - mr r5,r3
6667 +1: mr r5,r3
6668 addi r3,r1,STACK_FRAME_OVERHEAD
6669 ld r4,_DAR(r1)
6670 bl .bad_page_fault
6671 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
6672 index 40e4a17..5a84b37 100644
6673 --- a/arch/powerpc/kernel/exceptions-64s.S
6674 +++ b/arch/powerpc/kernel/exceptions-64s.S
6675 @@ -1362,10 +1362,10 @@ handle_page_fault:
6676 11: ld r4,_DAR(r1)
6677 ld r5,_DSISR(r1)
6678 addi r3,r1,STACK_FRAME_OVERHEAD
6679 + bl .save_nvgprs
6680 bl .do_page_fault
6681 cmpdi r3,0
6682 beq+ 12f
6683 - bl .save_nvgprs
6684 mr r5,r3
6685 addi r3,r1,STACK_FRAME_OVERHEAD
6686 lwz r4,_DAR(r1)
6687 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
6688 index 2e3200c..72095ce 100644
6689 --- a/arch/powerpc/kernel/module_32.c
6690 +++ b/arch/powerpc/kernel/module_32.c
6691 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
6692 me->arch.core_plt_section = i;
6693 }
6694 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
6695 - printk("Module doesn't contain .plt or .init.plt sections.\n");
6696 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
6697 return -ENOEXEC;
6698 }
6699
6700 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
6701
6702 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
6703 /* Init, or core PLT? */
6704 - if (location >= mod->module_core
6705 - && location < mod->module_core + mod->core_size)
6706 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
6707 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
6708 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
6709 - else
6710 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
6711 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
6712 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
6713 + else {
6714 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
6715 + return ~0UL;
6716 + }
6717
6718 /* Find this entry, or if that fails, the next avail. entry */
6719 while (entry->jump[0]) {
6720 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
6721 index 076d124..6cb2cbf 100644
6722 --- a/arch/powerpc/kernel/process.c
6723 +++ b/arch/powerpc/kernel/process.c
6724 @@ -874,8 +874,8 @@ void show_regs(struct pt_regs * regs)
6725 * Lookup NIP late so we have the best change of getting the
6726 * above info out without failing
6727 */
6728 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
6729 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
6730 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
6731 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
6732 #endif
6733 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
6734 printk("PACATMSCRATCH [%llx]\n", get_paca()->tm_scratch);
6735 @@ -1335,10 +1335,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
6736 newsp = stack[0];
6737 ip = stack[STACK_FRAME_LR_SAVE];
6738 if (!firstframe || ip != lr) {
6739 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
6740 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
6741 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
6742 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
6743 - printk(" (%pS)",
6744 + printk(" (%pA)",
6745 (void *)current->ret_stack[curr_frame].ret);
6746 curr_frame--;
6747 }
6748 @@ -1358,7 +1358,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
6749 struct pt_regs *regs = (struct pt_regs *)
6750 (sp + STACK_FRAME_OVERHEAD);
6751 lr = regs->link;
6752 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
6753 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
6754 regs->trap, (void *)regs->nip, (void *)lr);
6755 firstframe = 1;
6756 }
6757 @@ -1394,58 +1394,3 @@ void notrace __ppc64_runlatch_off(void)
6758 mtspr(SPRN_CTRLT, ctrl);
6759 }
6760 #endif /* CONFIG_PPC64 */
6761 -
6762 -unsigned long arch_align_stack(unsigned long sp)
6763 -{
6764 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
6765 - sp -= get_random_int() & ~PAGE_MASK;
6766 - return sp & ~0xf;
6767 -}
6768 -
6769 -static inline unsigned long brk_rnd(void)
6770 -{
6771 - unsigned long rnd = 0;
6772 -
6773 - /* 8MB for 32bit, 1GB for 64bit */
6774 - if (is_32bit_task())
6775 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
6776 - else
6777 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
6778 -
6779 - return rnd << PAGE_SHIFT;
6780 -}
6781 -
6782 -unsigned long arch_randomize_brk(struct mm_struct *mm)
6783 -{
6784 - unsigned long base = mm->brk;
6785 - unsigned long ret;
6786 -
6787 -#ifdef CONFIG_PPC_STD_MMU_64
6788 - /*
6789 - * If we are using 1TB segments and we are allowed to randomise
6790 - * the heap, we can put it above 1TB so it is backed by a 1TB
6791 - * segment. Otherwise the heap will be in the bottom 1TB
6792 - * which always uses 256MB segments and this may result in a
6793 - * performance penalty.
6794 - */
6795 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
6796 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
6797 -#endif
6798 -
6799 - ret = PAGE_ALIGN(base + brk_rnd());
6800 -
6801 - if (ret < mm->brk)
6802 - return mm->brk;
6803 -
6804 - return ret;
6805 -}
6806 -
6807 -unsigned long randomize_et_dyn(unsigned long base)
6808 -{
6809 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
6810 -
6811 - if (ret < base)
6812 - return base;
6813 -
6814 - return ret;
6815 -}
6816 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
6817 index 98c2fc1..b73a4ca 100644
6818 --- a/arch/powerpc/kernel/ptrace.c
6819 +++ b/arch/powerpc/kernel/ptrace.c
6820 @@ -1781,6 +1781,10 @@ long arch_ptrace(struct task_struct *child, long request,
6821 return ret;
6822 }
6823
6824 +#ifdef CONFIG_GRKERNSEC_SETXID
6825 +extern void gr_delayed_cred_worker(void);
6826 +#endif
6827 +
6828 /*
6829 * We must return the syscall number to actually look up in the table.
6830 * This can be -1L to skip running any syscall at all.
6831 @@ -1793,6 +1797,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
6832
6833 secure_computing_strict(regs->gpr[0]);
6834
6835 +#ifdef CONFIG_GRKERNSEC_SETXID
6836 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6837 + gr_delayed_cred_worker();
6838 +#endif
6839 +
6840 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
6841 tracehook_report_syscall_entry(regs))
6842 /*
6843 @@ -1827,6 +1836,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
6844 {
6845 int step;
6846
6847 +#ifdef CONFIG_GRKERNSEC_SETXID
6848 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6849 + gr_delayed_cred_worker();
6850 +#endif
6851 +
6852 audit_syscall_exit(regs);
6853
6854 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
6855 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
6856 index 201385c..0f01828 100644
6857 --- a/arch/powerpc/kernel/signal_32.c
6858 +++ b/arch/powerpc/kernel/signal_32.c
6859 @@ -976,7 +976,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
6860 /* Save user registers on the stack */
6861 frame = &rt_sf->uc.uc_mcontext;
6862 addr = frame;
6863 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
6864 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
6865 sigret = 0;
6866 tramp = current->mm->context.vdso_base + vdso32_rt_sigtramp;
6867 } else {
6868 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
6869 index 3459473..2d40783 100644
6870 --- a/arch/powerpc/kernel/signal_64.c
6871 +++ b/arch/powerpc/kernel/signal_64.c
6872 @@ -749,7 +749,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
6873 #endif
6874
6875 /* Set up to return from userspace. */
6876 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
6877 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
6878 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
6879 } else {
6880 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
6881 diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
6882 index e68a845..8b140e6 100644
6883 --- a/arch/powerpc/kernel/sysfs.c
6884 +++ b/arch/powerpc/kernel/sysfs.c
6885 @@ -522,7 +522,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
6886 return NOTIFY_OK;
6887 }
6888
6889 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
6890 +static struct notifier_block sysfs_cpu_nb = {
6891 .notifier_call = sysfs_cpu_notify,
6892 };
6893
6894 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
6895 index c0e5caf..68e8305 100644
6896 --- a/arch/powerpc/kernel/traps.c
6897 +++ b/arch/powerpc/kernel/traps.c
6898 @@ -143,6 +143,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
6899 return flags;
6900 }
6901
6902 +extern void gr_handle_kernel_exploit(void);
6903 +
6904 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
6905 int signr)
6906 {
6907 @@ -192,6 +194,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
6908 panic("Fatal exception in interrupt");
6909 if (panic_on_oops)
6910 panic("Fatal exception");
6911 +
6912 + gr_handle_kernel_exploit();
6913 +
6914 do_exit(signr);
6915 }
6916
6917 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
6918 index d4f463a..8fb7431 100644
6919 --- a/arch/powerpc/kernel/vdso.c
6920 +++ b/arch/powerpc/kernel/vdso.c
6921 @@ -34,6 +34,7 @@
6922 #include <asm/firmware.h>
6923 #include <asm/vdso.h>
6924 #include <asm/vdso_datapage.h>
6925 +#include <asm/mman.h>
6926
6927 #include "setup.h"
6928
6929 @@ -222,7 +223,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
6930 vdso_base = VDSO32_MBASE;
6931 #endif
6932
6933 - current->mm->context.vdso_base = 0;
6934 + current->mm->context.vdso_base = ~0UL;
6935
6936 /* vDSO has a problem and was disabled, just don't "enable" it for the
6937 * process
6938 @@ -242,7 +243,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
6939 vdso_base = get_unmapped_area(NULL, vdso_base,
6940 (vdso_pages << PAGE_SHIFT) +
6941 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
6942 - 0, 0);
6943 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
6944 if (IS_ERR_VALUE(vdso_base)) {
6945 rc = vdso_base;
6946 goto fail_mmapsem;
6947 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
6948 index 5eea6f3..5d10396 100644
6949 --- a/arch/powerpc/lib/usercopy_64.c
6950 +++ b/arch/powerpc/lib/usercopy_64.c
6951 @@ -9,22 +9,6 @@
6952 #include <linux/module.h>
6953 #include <asm/uaccess.h>
6954
6955 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
6956 -{
6957 - if (likely(access_ok(VERIFY_READ, from, n)))
6958 - n = __copy_from_user(to, from, n);
6959 - else
6960 - memset(to, 0, n);
6961 - return n;
6962 -}
6963 -
6964 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
6965 -{
6966 - if (likely(access_ok(VERIFY_WRITE, to, n)))
6967 - n = __copy_to_user(to, from, n);
6968 - return n;
6969 -}
6970 -
6971 unsigned long copy_in_user(void __user *to, const void __user *from,
6972 unsigned long n)
6973 {
6974 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
6975 return n;
6976 }
6977
6978 -EXPORT_SYMBOL(copy_from_user);
6979 -EXPORT_SYMBOL(copy_to_user);
6980 EXPORT_SYMBOL(copy_in_user);
6981
6982 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
6983 index 8726779..a33c512 100644
6984 --- a/arch/powerpc/mm/fault.c
6985 +++ b/arch/powerpc/mm/fault.c
6986 @@ -33,6 +33,10 @@
6987 #include <linux/magic.h>
6988 #include <linux/ratelimit.h>
6989 #include <linux/context_tracking.h>
6990 +#include <linux/slab.h>
6991 +#include <linux/pagemap.h>
6992 +#include <linux/compiler.h>
6993 +#include <linux/unistd.h>
6994
6995 #include <asm/firmware.h>
6996 #include <asm/page.h>
6997 @@ -69,6 +73,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
6998 }
6999 #endif
7000
7001 +#ifdef CONFIG_PAX_PAGEEXEC
7002 +/*
7003 + * PaX: decide what to do with offenders (regs->nip = fault address)
7004 + *
7005 + * returns 1 when task should be killed
7006 + */
7007 +static int pax_handle_fetch_fault(struct pt_regs *regs)
7008 +{
7009 + return 1;
7010 +}
7011 +
7012 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7013 +{
7014 + unsigned long i;
7015 +
7016 + printk(KERN_ERR "PAX: bytes at PC: ");
7017 + for (i = 0; i < 5; i++) {
7018 + unsigned int c;
7019 + if (get_user(c, (unsigned int __user *)pc+i))
7020 + printk(KERN_CONT "???????? ");
7021 + else
7022 + printk(KERN_CONT "%08x ", c);
7023 + }
7024 + printk("\n");
7025 +}
7026 +#endif
7027 +
7028 /*
7029 * Check whether the instruction at regs->nip is a store using
7030 * an update addressing form which will update r1.
7031 @@ -216,7 +247,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
7032 * indicate errors in DSISR but can validly be set in SRR1.
7033 */
7034 if (trap == 0x400)
7035 - error_code &= 0x48200000;
7036 + error_code &= 0x58200000;
7037 else
7038 is_write = error_code & DSISR_ISSTORE;
7039 #else
7040 @@ -371,7 +402,7 @@ good_area:
7041 * "undefined". Of those that can be set, this is the only
7042 * one which seems bad.
7043 */
7044 - if (error_code & 0x10000000)
7045 + if (error_code & DSISR_GUARDED)
7046 /* Guarded storage error. */
7047 goto bad_area;
7048 #endif /* CONFIG_8xx */
7049 @@ -386,7 +417,7 @@ good_area:
7050 * processors use the same I/D cache coherency mechanism
7051 * as embedded.
7052 */
7053 - if (error_code & DSISR_PROTFAULT)
7054 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
7055 goto bad_area;
7056 #endif /* CONFIG_PPC_STD_MMU */
7057
7058 @@ -471,6 +502,23 @@ bad_area:
7059 bad_area_nosemaphore:
7060 /* User mode accesses cause a SIGSEGV */
7061 if (user_mode(regs)) {
7062 +
7063 +#ifdef CONFIG_PAX_PAGEEXEC
7064 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
7065 +#ifdef CONFIG_PPC_STD_MMU
7066 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
7067 +#else
7068 + if (is_exec && regs->nip == address) {
7069 +#endif
7070 + switch (pax_handle_fetch_fault(regs)) {
7071 + }
7072 +
7073 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
7074 + do_group_exit(SIGKILL);
7075 + }
7076 + }
7077 +#endif
7078 +
7079 _exception(SIGSEGV, regs, code, address);
7080 goto bail;
7081 }
7082 diff --git a/arch/powerpc/mm/mmap_64.c b/arch/powerpc/mm/mmap_64.c
7083 index 67a42ed..cd463e0 100644
7084 --- a/arch/powerpc/mm/mmap_64.c
7085 +++ b/arch/powerpc/mm/mmap_64.c
7086 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
7087 {
7088 unsigned long rnd = 0;
7089
7090 +#ifdef CONFIG_PAX_RANDMMAP
7091 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7092 +#endif
7093 +
7094 if (current->flags & PF_RANDOMIZE) {
7095 /* 8MB for 32bit, 1GB for 64bit */
7096 if (is_32bit_task())
7097 @@ -91,10 +95,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7098 */
7099 if (mmap_is_legacy()) {
7100 mm->mmap_base = TASK_UNMAPPED_BASE;
7101 +
7102 +#ifdef CONFIG_PAX_RANDMMAP
7103 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7104 + mm->mmap_base += mm->delta_mmap;
7105 +#endif
7106 +
7107 mm->get_unmapped_area = arch_get_unmapped_area;
7108 mm->unmap_area = arch_unmap_area;
7109 } else {
7110 mm->mmap_base = mmap_base();
7111 +
7112 +#ifdef CONFIG_PAX_RANDMMAP
7113 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7114 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7115 +#endif
7116 +
7117 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7118 mm->unmap_area = arch_unmap_area_topdown;
7119 }
7120 diff --git a/arch/powerpc/mm/mmu_context_nohash.c b/arch/powerpc/mm/mmu_context_nohash.c
7121 index e779642..e5bb889 100644
7122 --- a/arch/powerpc/mm/mmu_context_nohash.c
7123 +++ b/arch/powerpc/mm/mmu_context_nohash.c
7124 @@ -363,7 +363,7 @@ static int __cpuinit mmu_context_cpu_notify(struct notifier_block *self,
7125 return NOTIFY_OK;
7126 }
7127
7128 -static struct notifier_block __cpuinitdata mmu_context_cpu_nb = {
7129 +static struct notifier_block mmu_context_cpu_nb = {
7130 .notifier_call = mmu_context_cpu_notify,
7131 };
7132
7133 diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
7134 index 88c0425..717feb8 100644
7135 --- a/arch/powerpc/mm/numa.c
7136 +++ b/arch/powerpc/mm/numa.c
7137 @@ -919,7 +919,7 @@ static void __init *careful_zallocation(int nid, unsigned long size,
7138 return ret;
7139 }
7140
7141 -static struct notifier_block __cpuinitdata ppc64_numa_nb = {
7142 +static struct notifier_block ppc64_numa_nb = {
7143 .notifier_call = cpu_numa_callback,
7144 .priority = 1 /* Must run before sched domains notifier. */
7145 };
7146 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
7147 index 3e99c14..f00953c 100644
7148 --- a/arch/powerpc/mm/slice.c
7149 +++ b/arch/powerpc/mm/slice.c
7150 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
7151 if ((mm->task_size - len) < addr)
7152 return 0;
7153 vma = find_vma(mm, addr);
7154 - return (!vma || (addr + len) <= vma->vm_start);
7155 + return check_heap_stack_gap(vma, addr, len, 0);
7156 }
7157
7158 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
7159 @@ -277,6 +277,12 @@ static unsigned long slice_find_area_bottomup(struct mm_struct *mm,
7160 info.align_offset = 0;
7161
7162 addr = TASK_UNMAPPED_BASE;
7163 +
7164 +#ifdef CONFIG_PAX_RANDMMAP
7165 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7166 + addr += mm->delta_mmap;
7167 +#endif
7168 +
7169 while (addr < TASK_SIZE) {
7170 info.low_limit = addr;
7171 if (!slice_scan_available(addr, available, 1, &addr))
7172 @@ -410,6 +416,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
7173 if (fixed && addr > (mm->task_size - len))
7174 return -EINVAL;
7175
7176 +#ifdef CONFIG_PAX_RANDMMAP
7177 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
7178 + addr = 0;
7179 +#endif
7180 +
7181 /* If hint, make sure it matches our alignment restrictions */
7182 if (!fixed && addr) {
7183 addr = _ALIGN_UP(addr, 1ul << pshift);
7184 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
7185 index 9098692..3d54cd1 100644
7186 --- a/arch/powerpc/platforms/cell/spufs/file.c
7187 +++ b/arch/powerpc/platforms/cell/spufs/file.c
7188 @@ -280,9 +280,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
7189 return VM_FAULT_NOPAGE;
7190 }
7191
7192 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
7193 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
7194 unsigned long address,
7195 - void *buf, int len, int write)
7196 + void *buf, size_t len, int write)
7197 {
7198 struct spu_context *ctx = vma->vm_file->private_data;
7199 unsigned long offset = address - vma->vm_start;
7200 diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
7201 index bdb738a..49c9f95 100644
7202 --- a/arch/powerpc/platforms/powermac/smp.c
7203 +++ b/arch/powerpc/platforms/powermac/smp.c
7204 @@ -885,7 +885,7 @@ static int smp_core99_cpu_notify(struct notifier_block *self,
7205 return NOTIFY_OK;
7206 }
7207
7208 -static struct notifier_block __cpuinitdata smp_core99_cpu_nb = {
7209 +static struct notifier_block smp_core99_cpu_nb = {
7210 .notifier_call = smp_core99_cpu_notify,
7211 };
7212 #endif /* CONFIG_HOTPLUG_CPU */
7213 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
7214 index c797832..ce575c8 100644
7215 --- a/arch/s390/include/asm/atomic.h
7216 +++ b/arch/s390/include/asm/atomic.h
7217 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
7218 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
7219 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7220
7221 +#define atomic64_read_unchecked(v) atomic64_read(v)
7222 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7223 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7224 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7225 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7226 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7227 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7228 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7229 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7230 +
7231 #define smp_mb__before_atomic_dec() smp_mb()
7232 #define smp_mb__after_atomic_dec() smp_mb()
7233 #define smp_mb__before_atomic_inc() smp_mb()
7234 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
7235 index 4d7ccac..d03d0ad 100644
7236 --- a/arch/s390/include/asm/cache.h
7237 +++ b/arch/s390/include/asm/cache.h
7238 @@ -9,8 +9,10 @@
7239 #ifndef __ARCH_S390_CACHE_H
7240 #define __ARCH_S390_CACHE_H
7241
7242 -#define L1_CACHE_BYTES 256
7243 +#include <linux/const.h>
7244 +
7245 #define L1_CACHE_SHIFT 8
7246 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7247 #define NET_SKB_PAD 32
7248
7249 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7250 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
7251 index 78f4f87..598ce39 100644
7252 --- a/arch/s390/include/asm/elf.h
7253 +++ b/arch/s390/include/asm/elf.h
7254 @@ -162,8 +162,14 @@ extern unsigned int vdso_enabled;
7255 the loader. We need to make sure that it is out of the way of the program
7256 that it will "exec", and that there is sufficient room for the brk. */
7257
7258 -extern unsigned long randomize_et_dyn(unsigned long base);
7259 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
7260 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
7261 +
7262 +#ifdef CONFIG_PAX_ASLR
7263 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
7264 +
7265 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7266 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7267 +#endif
7268
7269 /* This yields a mask that user programs can use to figure out what
7270 instruction set this CPU supports. */
7271 @@ -222,9 +228,6 @@ struct linux_binprm;
7272 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
7273 int arch_setup_additional_pages(struct linux_binprm *, int);
7274
7275 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7276 -#define arch_randomize_brk arch_randomize_brk
7277 -
7278 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
7279
7280 #endif
7281 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
7282 index c4a93d6..4d2a9b4 100644
7283 --- a/arch/s390/include/asm/exec.h
7284 +++ b/arch/s390/include/asm/exec.h
7285 @@ -7,6 +7,6 @@
7286 #ifndef __ASM_EXEC_H
7287 #define __ASM_EXEC_H
7288
7289 -extern unsigned long arch_align_stack(unsigned long sp);
7290 +#define arch_align_stack(x) ((x) & ~0xfUL)
7291
7292 #endif /* __ASM_EXEC_H */
7293 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
7294 index 9c33ed4..e40cbef 100644
7295 --- a/arch/s390/include/asm/uaccess.h
7296 +++ b/arch/s390/include/asm/uaccess.h
7297 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
7298 copy_to_user(void __user *to, const void *from, unsigned long n)
7299 {
7300 might_fault();
7301 +
7302 + if ((long)n < 0)
7303 + return n;
7304 +
7305 return __copy_to_user(to, from, n);
7306 }
7307
7308 @@ -275,6 +279,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
7309 static inline unsigned long __must_check
7310 __copy_from_user(void *to, const void __user *from, unsigned long n)
7311 {
7312 + if ((long)n < 0)
7313 + return n;
7314 +
7315 if (__builtin_constant_p(n) && (n <= 256))
7316 return uaccess.copy_from_user_small(n, from, to);
7317 else
7318 @@ -306,10 +313,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
7319 static inline unsigned long __must_check
7320 copy_from_user(void *to, const void __user *from, unsigned long n)
7321 {
7322 - unsigned int sz = __compiletime_object_size(to);
7323 + size_t sz = __compiletime_object_size(to);
7324
7325 might_fault();
7326 - if (unlikely(sz != -1 && sz < n)) {
7327 +
7328 + if ((long)n < 0)
7329 + return n;
7330 +
7331 + if (unlikely(sz != (size_t)-1 && sz < n)) {
7332 copy_from_user_overflow();
7333 return n;
7334 }
7335 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
7336 index 7845e15..59c4353 100644
7337 --- a/arch/s390/kernel/module.c
7338 +++ b/arch/s390/kernel/module.c
7339 @@ -169,11 +169,11 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
7340
7341 /* Increase core size by size of got & plt and set start
7342 offsets for got and plt. */
7343 - me->core_size = ALIGN(me->core_size, 4);
7344 - me->arch.got_offset = me->core_size;
7345 - me->core_size += me->arch.got_size;
7346 - me->arch.plt_offset = me->core_size;
7347 - me->core_size += me->arch.plt_size;
7348 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
7349 + me->arch.got_offset = me->core_size_rw;
7350 + me->core_size_rw += me->arch.got_size;
7351 + me->arch.plt_offset = me->core_size_rx;
7352 + me->core_size_rx += me->arch.plt_size;
7353 return 0;
7354 }
7355
7356 @@ -289,7 +289,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7357 if (info->got_initialized == 0) {
7358 Elf_Addr *gotent;
7359
7360 - gotent = me->module_core + me->arch.got_offset +
7361 + gotent = me->module_core_rw + me->arch.got_offset +
7362 info->got_offset;
7363 *gotent = val;
7364 info->got_initialized = 1;
7365 @@ -312,7 +312,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7366 rc = apply_rela_bits(loc, val, 0, 64, 0);
7367 else if (r_type == R_390_GOTENT ||
7368 r_type == R_390_GOTPLTENT) {
7369 - val += (Elf_Addr) me->module_core - loc;
7370 + val += (Elf_Addr) me->module_core_rw - loc;
7371 rc = apply_rela_bits(loc, val, 1, 32, 1);
7372 }
7373 break;
7374 @@ -325,7 +325,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7375 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
7376 if (info->plt_initialized == 0) {
7377 unsigned int *ip;
7378 - ip = me->module_core + me->arch.plt_offset +
7379 + ip = me->module_core_rx + me->arch.plt_offset +
7380 info->plt_offset;
7381 #ifndef CONFIG_64BIT
7382 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
7383 @@ -350,7 +350,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7384 val - loc + 0xffffUL < 0x1ffffeUL) ||
7385 (r_type == R_390_PLT32DBL &&
7386 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
7387 - val = (Elf_Addr) me->module_core +
7388 + val = (Elf_Addr) me->module_core_rx +
7389 me->arch.plt_offset +
7390 info->plt_offset;
7391 val += rela->r_addend - loc;
7392 @@ -372,7 +372,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7393 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
7394 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
7395 val = val + rela->r_addend -
7396 - ((Elf_Addr) me->module_core + me->arch.got_offset);
7397 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
7398 if (r_type == R_390_GOTOFF16)
7399 rc = apply_rela_bits(loc, val, 0, 16, 0);
7400 else if (r_type == R_390_GOTOFF32)
7401 @@ -382,7 +382,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7402 break;
7403 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
7404 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
7405 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
7406 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
7407 rela->r_addend - loc;
7408 if (r_type == R_390_GOTPC)
7409 rc = apply_rela_bits(loc, val, 1, 32, 0);
7410 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
7411 index 2bc3edd..ab9d598 100644
7412 --- a/arch/s390/kernel/process.c
7413 +++ b/arch/s390/kernel/process.c
7414 @@ -236,39 +236,3 @@ unsigned long get_wchan(struct task_struct *p)
7415 }
7416 return 0;
7417 }
7418 -
7419 -unsigned long arch_align_stack(unsigned long sp)
7420 -{
7421 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
7422 - sp -= get_random_int() & ~PAGE_MASK;
7423 - return sp & ~0xf;
7424 -}
7425 -
7426 -static inline unsigned long brk_rnd(void)
7427 -{
7428 - /* 8MB for 32bit, 1GB for 64bit */
7429 - if (is_32bit_task())
7430 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
7431 - else
7432 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
7433 -}
7434 -
7435 -unsigned long arch_randomize_brk(struct mm_struct *mm)
7436 -{
7437 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
7438 -
7439 - if (ret < mm->brk)
7440 - return mm->brk;
7441 - return ret;
7442 -}
7443 -
7444 -unsigned long randomize_et_dyn(unsigned long base)
7445 -{
7446 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
7447 -
7448 - if (!(current->flags & PF_RANDOMIZE))
7449 - return base;
7450 - if (ret < base)
7451 - return base;
7452 - return ret;
7453 -}
7454 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
7455 index 06bafec..2bca531 100644
7456 --- a/arch/s390/mm/mmap.c
7457 +++ b/arch/s390/mm/mmap.c
7458 @@ -90,10 +90,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7459 */
7460 if (mmap_is_legacy()) {
7461 mm->mmap_base = TASK_UNMAPPED_BASE;
7462 +
7463 +#ifdef CONFIG_PAX_RANDMMAP
7464 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7465 + mm->mmap_base += mm->delta_mmap;
7466 +#endif
7467 +
7468 mm->get_unmapped_area = arch_get_unmapped_area;
7469 mm->unmap_area = arch_unmap_area;
7470 } else {
7471 mm->mmap_base = mmap_base();
7472 +
7473 +#ifdef CONFIG_PAX_RANDMMAP
7474 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7475 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7476 +#endif
7477 +
7478 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7479 mm->unmap_area = arch_unmap_area_topdown;
7480 }
7481 @@ -175,10 +187,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7482 */
7483 if (mmap_is_legacy()) {
7484 mm->mmap_base = TASK_UNMAPPED_BASE;
7485 +
7486 +#ifdef CONFIG_PAX_RANDMMAP
7487 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7488 + mm->mmap_base += mm->delta_mmap;
7489 +#endif
7490 +
7491 mm->get_unmapped_area = s390_get_unmapped_area;
7492 mm->unmap_area = arch_unmap_area;
7493 } else {
7494 mm->mmap_base = mmap_base();
7495 +
7496 +#ifdef CONFIG_PAX_RANDMMAP
7497 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7498 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7499 +#endif
7500 +
7501 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
7502 mm->unmap_area = arch_unmap_area_topdown;
7503 }
7504 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
7505 index ae3d59f..f65f075 100644
7506 --- a/arch/score/include/asm/cache.h
7507 +++ b/arch/score/include/asm/cache.h
7508 @@ -1,7 +1,9 @@
7509 #ifndef _ASM_SCORE_CACHE_H
7510 #define _ASM_SCORE_CACHE_H
7511
7512 +#include <linux/const.h>
7513 +
7514 #define L1_CACHE_SHIFT 4
7515 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7516 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7517
7518 #endif /* _ASM_SCORE_CACHE_H */
7519 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
7520 index f9f3cd5..58ff438 100644
7521 --- a/arch/score/include/asm/exec.h
7522 +++ b/arch/score/include/asm/exec.h
7523 @@ -1,6 +1,6 @@
7524 #ifndef _ASM_SCORE_EXEC_H
7525 #define _ASM_SCORE_EXEC_H
7526
7527 -extern unsigned long arch_align_stack(unsigned long sp);
7528 +#define arch_align_stack(x) (x)
7529
7530 #endif /* _ASM_SCORE_EXEC_H */
7531 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
7532 index f4c6d02..e9355c3 100644
7533 --- a/arch/score/kernel/process.c
7534 +++ b/arch/score/kernel/process.c
7535 @@ -116,8 +116,3 @@ unsigned long get_wchan(struct task_struct *task)
7536
7537 return task_pt_regs(task)->cp0_epc;
7538 }
7539 -
7540 -unsigned long arch_align_stack(unsigned long sp)
7541 -{
7542 - return sp;
7543 -}
7544 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
7545 index ef9e555..331bd29 100644
7546 --- a/arch/sh/include/asm/cache.h
7547 +++ b/arch/sh/include/asm/cache.h
7548 @@ -9,10 +9,11 @@
7549 #define __ASM_SH_CACHE_H
7550 #ifdef __KERNEL__
7551
7552 +#include <linux/const.h>
7553 #include <linux/init.h>
7554 #include <cpu/cache.h>
7555
7556 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7557 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7558
7559 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7560
7561 diff --git a/arch/sh/kernel/cpu/sh4a/smp-shx3.c b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7562 index 03f2b55..b0270327 100644
7563 --- a/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7564 +++ b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7565 @@ -143,7 +143,7 @@ shx3_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
7566 return NOTIFY_OK;
7567 }
7568
7569 -static struct notifier_block __cpuinitdata shx3_cpu_notifier = {
7570 +static struct notifier_block shx3_cpu_notifier = {
7571 .notifier_call = shx3_cpu_callback,
7572 };
7573
7574 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
7575 index 6777177..cb5e44f 100644
7576 --- a/arch/sh/mm/mmap.c
7577 +++ b/arch/sh/mm/mmap.c
7578 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7579 struct mm_struct *mm = current->mm;
7580 struct vm_area_struct *vma;
7581 int do_colour_align;
7582 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7583 struct vm_unmapped_area_info info;
7584
7585 if (flags & MAP_FIXED) {
7586 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7587 if (filp || (flags & MAP_SHARED))
7588 do_colour_align = 1;
7589
7590 +#ifdef CONFIG_PAX_RANDMMAP
7591 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7592 +#endif
7593 +
7594 if (addr) {
7595 if (do_colour_align)
7596 addr = COLOUR_ALIGN(addr, pgoff);
7597 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7598 addr = PAGE_ALIGN(addr);
7599
7600 vma = find_vma(mm, addr);
7601 - if (TASK_SIZE - len >= addr &&
7602 - (!vma || addr + len <= vma->vm_start))
7603 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7604 return addr;
7605 }
7606
7607 info.flags = 0;
7608 info.length = len;
7609 - info.low_limit = TASK_UNMAPPED_BASE;
7610 + info.low_limit = mm->mmap_base;
7611 info.high_limit = TASK_SIZE;
7612 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
7613 info.align_offset = pgoff << PAGE_SHIFT;
7614 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7615 struct mm_struct *mm = current->mm;
7616 unsigned long addr = addr0;
7617 int do_colour_align;
7618 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7619 struct vm_unmapped_area_info info;
7620
7621 if (flags & MAP_FIXED) {
7622 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7623 if (filp || (flags & MAP_SHARED))
7624 do_colour_align = 1;
7625
7626 +#ifdef CONFIG_PAX_RANDMMAP
7627 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7628 +#endif
7629 +
7630 /* requesting a specific address */
7631 if (addr) {
7632 if (do_colour_align)
7633 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7634 addr = PAGE_ALIGN(addr);
7635
7636 vma = find_vma(mm, addr);
7637 - if (TASK_SIZE - len >= addr &&
7638 - (!vma || addr + len <= vma->vm_start))
7639 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7640 return addr;
7641 }
7642
7643 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7644 VM_BUG_ON(addr != -ENOMEM);
7645 info.flags = 0;
7646 info.low_limit = TASK_UNMAPPED_BASE;
7647 +
7648 +#ifdef CONFIG_PAX_RANDMMAP
7649 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7650 + info.low_limit += mm->delta_mmap;
7651 +#endif
7652 +
7653 info.high_limit = TASK_SIZE;
7654 addr = vm_unmapped_area(&info);
7655 }
7656 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
7657 index be56a24..443328f 100644
7658 --- a/arch/sparc/include/asm/atomic_64.h
7659 +++ b/arch/sparc/include/asm/atomic_64.h
7660 @@ -14,18 +14,40 @@
7661 #define ATOMIC64_INIT(i) { (i) }
7662
7663 #define atomic_read(v) (*(volatile int *)&(v)->counter)
7664 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
7665 +{
7666 + return v->counter;
7667 +}
7668 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
7669 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
7670 +{
7671 + return v->counter;
7672 +}
7673
7674 #define atomic_set(v, i) (((v)->counter) = i)
7675 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
7676 +{
7677 + v->counter = i;
7678 +}
7679 #define atomic64_set(v, i) (((v)->counter) = i)
7680 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
7681 +{
7682 + v->counter = i;
7683 +}
7684
7685 extern void atomic_add(int, atomic_t *);
7686 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
7687 extern void atomic64_add(long, atomic64_t *);
7688 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
7689 extern void atomic_sub(int, atomic_t *);
7690 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
7691 extern void atomic64_sub(long, atomic64_t *);
7692 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
7693
7694 extern int atomic_add_ret(int, atomic_t *);
7695 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
7696 extern long atomic64_add_ret(long, atomic64_t *);
7697 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
7698 extern int atomic_sub_ret(int, atomic_t *);
7699 extern long atomic64_sub_ret(long, atomic64_t *);
7700
7701 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7702 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
7703
7704 #define atomic_inc_return(v) atomic_add_ret(1, v)
7705 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
7706 +{
7707 + return atomic_add_ret_unchecked(1, v);
7708 +}
7709 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
7710 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
7711 +{
7712 + return atomic64_add_ret_unchecked(1, v);
7713 +}
7714
7715 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
7716 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
7717
7718 #define atomic_add_return(i, v) atomic_add_ret(i, v)
7719 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
7720 +{
7721 + return atomic_add_ret_unchecked(i, v);
7722 +}
7723 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
7724 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
7725 +{
7726 + return atomic64_add_ret_unchecked(i, v);
7727 +}
7728
7729 /*
7730 * atomic_inc_and_test - increment and test
7731 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7732 * other cases.
7733 */
7734 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
7735 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
7736 +{
7737 + return atomic_inc_return_unchecked(v) == 0;
7738 +}
7739 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
7740
7741 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
7742 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7743 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
7744
7745 #define atomic_inc(v) atomic_add(1, v)
7746 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
7747 +{
7748 + atomic_add_unchecked(1, v);
7749 +}
7750 #define atomic64_inc(v) atomic64_add(1, v)
7751 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
7752 +{
7753 + atomic64_add_unchecked(1, v);
7754 +}
7755
7756 #define atomic_dec(v) atomic_sub(1, v)
7757 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
7758 +{
7759 + atomic_sub_unchecked(1, v);
7760 +}
7761 #define atomic64_dec(v) atomic64_sub(1, v)
7762 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
7763 +{
7764 + atomic64_sub_unchecked(1, v);
7765 +}
7766
7767 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
7768 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
7769
7770 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
7771 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
7772 +{
7773 + return cmpxchg(&v->counter, old, new);
7774 +}
7775 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
7776 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
7777 +{
7778 + return xchg(&v->counter, new);
7779 +}
7780
7781 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
7782 {
7783 - int c, old;
7784 + int c, old, new;
7785 c = atomic_read(v);
7786 for (;;) {
7787 - if (unlikely(c == (u)))
7788 + if (unlikely(c == u))
7789 break;
7790 - old = atomic_cmpxchg((v), c, c + (a));
7791 +
7792 + asm volatile("addcc %2, %0, %0\n"
7793 +
7794 +#ifdef CONFIG_PAX_REFCOUNT
7795 + "tvs %%icc, 6\n"
7796 +#endif
7797 +
7798 + : "=r" (new)
7799 + : "0" (c), "ir" (a)
7800 + : "cc");
7801 +
7802 + old = atomic_cmpxchg(v, c, new);
7803 if (likely(old == c))
7804 break;
7805 c = old;
7806 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
7807 #define atomic64_cmpxchg(v, o, n) \
7808 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
7809 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
7810 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
7811 +{
7812 + return xchg(&v->counter, new);
7813 +}
7814
7815 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
7816 {
7817 - long c, old;
7818 + long c, old, new;
7819 c = atomic64_read(v);
7820 for (;;) {
7821 - if (unlikely(c == (u)))
7822 + if (unlikely(c == u))
7823 break;
7824 - old = atomic64_cmpxchg((v), c, c + (a));
7825 +
7826 + asm volatile("addcc %2, %0, %0\n"
7827 +
7828 +#ifdef CONFIG_PAX_REFCOUNT
7829 + "tvs %%xcc, 6\n"
7830 +#endif
7831 +
7832 + : "=r" (new)
7833 + : "0" (c), "ir" (a)
7834 + : "cc");
7835 +
7836 + old = atomic64_cmpxchg(v, c, new);
7837 if (likely(old == c))
7838 break;
7839 c = old;
7840 }
7841 - return c != (u);
7842 + return c != u;
7843 }
7844
7845 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7846 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
7847 index 5bb6991..5c2132e 100644
7848 --- a/arch/sparc/include/asm/cache.h
7849 +++ b/arch/sparc/include/asm/cache.h
7850 @@ -7,10 +7,12 @@
7851 #ifndef _SPARC_CACHE_H
7852 #define _SPARC_CACHE_H
7853
7854 +#include <linux/const.h>
7855 +
7856 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
7857
7858 #define L1_CACHE_SHIFT 5
7859 -#define L1_CACHE_BYTES 32
7860 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7861
7862 #ifdef CONFIG_SPARC32
7863 #define SMP_CACHE_BYTES_SHIFT 5
7864 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
7865 index a24e41f..47677ff 100644
7866 --- a/arch/sparc/include/asm/elf_32.h
7867 +++ b/arch/sparc/include/asm/elf_32.h
7868 @@ -114,6 +114,13 @@ typedef struct {
7869
7870 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
7871
7872 +#ifdef CONFIG_PAX_ASLR
7873 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
7874 +
7875 +#define PAX_DELTA_MMAP_LEN 16
7876 +#define PAX_DELTA_STACK_LEN 16
7877 +#endif
7878 +
7879 /* This yields a mask that user programs can use to figure out what
7880 instruction set this cpu supports. This can NOT be done in userspace
7881 on Sparc. */
7882 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
7883 index 370ca1e..d4f4a98 100644
7884 --- a/arch/sparc/include/asm/elf_64.h
7885 +++ b/arch/sparc/include/asm/elf_64.h
7886 @@ -189,6 +189,13 @@ typedef struct {
7887 #define ELF_ET_DYN_BASE 0x0000010000000000UL
7888 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
7889
7890 +#ifdef CONFIG_PAX_ASLR
7891 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
7892 +
7893 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
7894 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
7895 +#endif
7896 +
7897 extern unsigned long sparc64_elf_hwcap;
7898 #define ELF_HWCAP sparc64_elf_hwcap
7899
7900 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
7901 index 9b1c36d..209298b 100644
7902 --- a/arch/sparc/include/asm/pgalloc_32.h
7903 +++ b/arch/sparc/include/asm/pgalloc_32.h
7904 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
7905 }
7906
7907 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
7908 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
7909
7910 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
7911 unsigned long address)
7912 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
7913 index bcfe063..b333142 100644
7914 --- a/arch/sparc/include/asm/pgalloc_64.h
7915 +++ b/arch/sparc/include/asm/pgalloc_64.h
7916 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
7917 }
7918
7919 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
7920 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
7921
7922 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
7923 {
7924 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
7925 index 6fc1348..390c50a 100644
7926 --- a/arch/sparc/include/asm/pgtable_32.h
7927 +++ b/arch/sparc/include/asm/pgtable_32.h
7928 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
7929 #define PAGE_SHARED SRMMU_PAGE_SHARED
7930 #define PAGE_COPY SRMMU_PAGE_COPY
7931 #define PAGE_READONLY SRMMU_PAGE_RDONLY
7932 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
7933 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
7934 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
7935 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
7936
7937 /* Top-level page directory - dummy used by init-mm.
7938 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
7939
7940 /* xwr */
7941 #define __P000 PAGE_NONE
7942 -#define __P001 PAGE_READONLY
7943 -#define __P010 PAGE_COPY
7944 -#define __P011 PAGE_COPY
7945 +#define __P001 PAGE_READONLY_NOEXEC
7946 +#define __P010 PAGE_COPY_NOEXEC
7947 +#define __P011 PAGE_COPY_NOEXEC
7948 #define __P100 PAGE_READONLY
7949 #define __P101 PAGE_READONLY
7950 #define __P110 PAGE_COPY
7951 #define __P111 PAGE_COPY
7952
7953 #define __S000 PAGE_NONE
7954 -#define __S001 PAGE_READONLY
7955 -#define __S010 PAGE_SHARED
7956 -#define __S011 PAGE_SHARED
7957 +#define __S001 PAGE_READONLY_NOEXEC
7958 +#define __S010 PAGE_SHARED_NOEXEC
7959 +#define __S011 PAGE_SHARED_NOEXEC
7960 #define __S100 PAGE_READONLY
7961 #define __S101 PAGE_READONLY
7962 #define __S110 PAGE_SHARED
7963 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
7964 index 79da178..c2eede8 100644
7965 --- a/arch/sparc/include/asm/pgtsrmmu.h
7966 +++ b/arch/sparc/include/asm/pgtsrmmu.h
7967 @@ -115,6 +115,11 @@
7968 SRMMU_EXEC | SRMMU_REF)
7969 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
7970 SRMMU_EXEC | SRMMU_REF)
7971 +
7972 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
7973 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
7974 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
7975 +
7976 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
7977 SRMMU_DIRTY | SRMMU_REF)
7978
7979 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
7980 index 9689176..63c18ea 100644
7981 --- a/arch/sparc/include/asm/spinlock_64.h
7982 +++ b/arch/sparc/include/asm/spinlock_64.h
7983 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
7984
7985 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
7986
7987 -static void inline arch_read_lock(arch_rwlock_t *lock)
7988 +static inline void arch_read_lock(arch_rwlock_t *lock)
7989 {
7990 unsigned long tmp1, tmp2;
7991
7992 __asm__ __volatile__ (
7993 "1: ldsw [%2], %0\n"
7994 " brlz,pn %0, 2f\n"
7995 -"4: add %0, 1, %1\n"
7996 +"4: addcc %0, 1, %1\n"
7997 +
7998 +#ifdef CONFIG_PAX_REFCOUNT
7999 +" tvs %%icc, 6\n"
8000 +#endif
8001 +
8002 " cas [%2], %0, %1\n"
8003 " cmp %0, %1\n"
8004 " bne,pn %%icc, 1b\n"
8005 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
8006 " .previous"
8007 : "=&r" (tmp1), "=&r" (tmp2)
8008 : "r" (lock)
8009 - : "memory");
8010 + : "memory", "cc");
8011 }
8012
8013 -static int inline arch_read_trylock(arch_rwlock_t *lock)
8014 +static inline int arch_read_trylock(arch_rwlock_t *lock)
8015 {
8016 int tmp1, tmp2;
8017
8018 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8019 "1: ldsw [%2], %0\n"
8020 " brlz,a,pn %0, 2f\n"
8021 " mov 0, %0\n"
8022 -" add %0, 1, %1\n"
8023 +" addcc %0, 1, %1\n"
8024 +
8025 +#ifdef CONFIG_PAX_REFCOUNT
8026 +" tvs %%icc, 6\n"
8027 +#endif
8028 +
8029 " cas [%2], %0, %1\n"
8030 " cmp %0, %1\n"
8031 " bne,pn %%icc, 1b\n"
8032 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8033 return tmp1;
8034 }
8035
8036 -static void inline arch_read_unlock(arch_rwlock_t *lock)
8037 +static inline void arch_read_unlock(arch_rwlock_t *lock)
8038 {
8039 unsigned long tmp1, tmp2;
8040
8041 __asm__ __volatile__(
8042 "1: lduw [%2], %0\n"
8043 -" sub %0, 1, %1\n"
8044 +" subcc %0, 1, %1\n"
8045 +
8046 +#ifdef CONFIG_PAX_REFCOUNT
8047 +" tvs %%icc, 6\n"
8048 +#endif
8049 +
8050 " cas [%2], %0, %1\n"
8051 " cmp %0, %1\n"
8052 " bne,pn %%xcc, 1b\n"
8053 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
8054 : "memory");
8055 }
8056
8057 -static void inline arch_write_lock(arch_rwlock_t *lock)
8058 +static inline void arch_write_lock(arch_rwlock_t *lock)
8059 {
8060 unsigned long mask, tmp1, tmp2;
8061
8062 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
8063 : "memory");
8064 }
8065
8066 -static void inline arch_write_unlock(arch_rwlock_t *lock)
8067 +static inline void arch_write_unlock(arch_rwlock_t *lock)
8068 {
8069 __asm__ __volatile__(
8070 " stw %%g0, [%0]"
8071 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
8072 : "memory");
8073 }
8074
8075 -static int inline arch_write_trylock(arch_rwlock_t *lock)
8076 +static inline int arch_write_trylock(arch_rwlock_t *lock)
8077 {
8078 unsigned long mask, tmp1, tmp2, result;
8079
8080 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
8081 index dd38075..e7cac83 100644
8082 --- a/arch/sparc/include/asm/thread_info_32.h
8083 +++ b/arch/sparc/include/asm/thread_info_32.h
8084 @@ -49,6 +49,8 @@ struct thread_info {
8085 unsigned long w_saved;
8086
8087 struct restart_block restart_block;
8088 +
8089 + unsigned long lowest_stack;
8090 };
8091
8092 /*
8093 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
8094 index d5e5042..9bfee76 100644
8095 --- a/arch/sparc/include/asm/thread_info_64.h
8096 +++ b/arch/sparc/include/asm/thread_info_64.h
8097 @@ -63,6 +63,8 @@ struct thread_info {
8098 struct pt_regs *kern_una_regs;
8099 unsigned int kern_una_insn;
8100
8101 + unsigned long lowest_stack;
8102 +
8103 unsigned long fpregs[0] __attribute__ ((aligned(64)));
8104 };
8105
8106 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
8107 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
8108 /* flag bit 6 is available */
8109 #define TIF_32BIT 7 /* 32-bit binary */
8110 -/* flag bit 8 is available */
8111 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
8112 #define TIF_SECCOMP 9 /* secure computing */
8113 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
8114 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
8115 +
8116 /* NOTE: Thread flags >= 12 should be ones we have no interest
8117 * in using in assembly, else we can't use the mask as
8118 * an immediate value in instructions such as andcc.
8119 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
8120 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
8121 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
8122 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
8123 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
8124
8125 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
8126 _TIF_DO_NOTIFY_RESUME_MASK | \
8127 _TIF_NEED_RESCHED)
8128 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
8129
8130 +#define _TIF_WORK_SYSCALL \
8131 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
8132 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
8133 +
8134 +
8135 /*
8136 * Thread-synchronous status.
8137 *
8138 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
8139 index 0167d26..767bb0c 100644
8140 --- a/arch/sparc/include/asm/uaccess.h
8141 +++ b/arch/sparc/include/asm/uaccess.h
8142 @@ -1,5 +1,6 @@
8143 #ifndef ___ASM_SPARC_UACCESS_H
8144 #define ___ASM_SPARC_UACCESS_H
8145 +
8146 #if defined(__sparc__) && defined(__arch64__)
8147 #include <asm/uaccess_64.h>
8148 #else
8149 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
8150 index 53a28dd..50c38c3 100644
8151 --- a/arch/sparc/include/asm/uaccess_32.h
8152 +++ b/arch/sparc/include/asm/uaccess_32.h
8153 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
8154
8155 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8156 {
8157 - if (n && __access_ok((unsigned long) to, n))
8158 + if ((long)n < 0)
8159 + return n;
8160 +
8161 + if (n && __access_ok((unsigned long) to, n)) {
8162 + if (!__builtin_constant_p(n))
8163 + check_object_size(from, n, true);
8164 return __copy_user(to, (__force void __user *) from, n);
8165 - else
8166 + } else
8167 return n;
8168 }
8169
8170 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
8171 {
8172 + if ((long)n < 0)
8173 + return n;
8174 +
8175 + if (!__builtin_constant_p(n))
8176 + check_object_size(from, n, true);
8177 +
8178 return __copy_user(to, (__force void __user *) from, n);
8179 }
8180
8181 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8182 {
8183 - if (n && __access_ok((unsigned long) from, n))
8184 + if ((long)n < 0)
8185 + return n;
8186 +
8187 + if (n && __access_ok((unsigned long) from, n)) {
8188 + if (!__builtin_constant_p(n))
8189 + check_object_size(to, n, false);
8190 return __copy_user((__force void __user *) to, from, n);
8191 - else
8192 + } else
8193 return n;
8194 }
8195
8196 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
8197 {
8198 + if ((long)n < 0)
8199 + return n;
8200 +
8201 return __copy_user((__force void __user *) to, from, n);
8202 }
8203
8204 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
8205 index e562d3c..191f176 100644
8206 --- a/arch/sparc/include/asm/uaccess_64.h
8207 +++ b/arch/sparc/include/asm/uaccess_64.h
8208 @@ -10,6 +10,7 @@
8209 #include <linux/compiler.h>
8210 #include <linux/string.h>
8211 #include <linux/thread_info.h>
8212 +#include <linux/kernel.h>
8213 #include <asm/asi.h>
8214 #include <asm/spitfire.h>
8215 #include <asm-generic/uaccess-unaligned.h>
8216 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
8217 static inline unsigned long __must_check
8218 copy_from_user(void *to, const void __user *from, unsigned long size)
8219 {
8220 - unsigned long ret = ___copy_from_user(to, from, size);
8221 + unsigned long ret;
8222
8223 + if ((long)size < 0 || size > INT_MAX)
8224 + return size;
8225 +
8226 + if (!__builtin_constant_p(size))
8227 + check_object_size(to, size, false);
8228 +
8229 + ret = ___copy_from_user(to, from, size);
8230 if (unlikely(ret))
8231 ret = copy_from_user_fixup(to, from, size);
8232
8233 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
8234 static inline unsigned long __must_check
8235 copy_to_user(void __user *to, const void *from, unsigned long size)
8236 {
8237 - unsigned long ret = ___copy_to_user(to, from, size);
8238 + unsigned long ret;
8239
8240 + if ((long)size < 0 || size > INT_MAX)
8241 + return size;
8242 +
8243 + if (!__builtin_constant_p(size))
8244 + check_object_size(from, size, true);
8245 +
8246 + ret = ___copy_to_user(to, from, size);
8247 if (unlikely(ret))
8248 ret = copy_to_user_fixup(to, from, size);
8249 return ret;
8250 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
8251 index d432fb2..6056af1 100644
8252 --- a/arch/sparc/kernel/Makefile
8253 +++ b/arch/sparc/kernel/Makefile
8254 @@ -3,7 +3,7 @@
8255 #
8256
8257 asflags-y := -ansi
8258 -ccflags-y := -Werror
8259 +#ccflags-y := -Werror
8260
8261 extra-y := head_$(BITS).o
8262
8263 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
8264 index fdd819d..5af08c8 100644
8265 --- a/arch/sparc/kernel/process_32.c
8266 +++ b/arch/sparc/kernel/process_32.c
8267 @@ -116,14 +116,14 @@ void show_regs(struct pt_regs *r)
8268
8269 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
8270 r->psr, r->pc, r->npc, r->y, print_tainted());
8271 - printk("PC: <%pS>\n", (void *) r->pc);
8272 + printk("PC: <%pA>\n", (void *) r->pc);
8273 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8274 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
8275 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
8276 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8277 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
8278 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
8279 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
8280 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
8281
8282 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8283 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
8284 @@ -160,7 +160,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8285 rw = (struct reg_window32 *) fp;
8286 pc = rw->ins[7];
8287 printk("[%08lx : ", pc);
8288 - printk("%pS ] ", (void *) pc);
8289 + printk("%pA ] ", (void *) pc);
8290 fp = rw->ins[6];
8291 } while (++count < 16);
8292 printk("\n");
8293 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
8294 index baebab2..9cd13b1 100644
8295 --- a/arch/sparc/kernel/process_64.c
8296 +++ b/arch/sparc/kernel/process_64.c
8297 @@ -158,7 +158,7 @@ static void show_regwindow(struct pt_regs *regs)
8298 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
8299 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
8300 if (regs->tstate & TSTATE_PRIV)
8301 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
8302 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
8303 }
8304
8305 void show_regs(struct pt_regs *regs)
8306 @@ -167,7 +167,7 @@ void show_regs(struct pt_regs *regs)
8307
8308 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
8309 regs->tpc, regs->tnpc, regs->y, print_tainted());
8310 - printk("TPC: <%pS>\n", (void *) regs->tpc);
8311 + printk("TPC: <%pA>\n", (void *) regs->tpc);
8312 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
8313 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
8314 regs->u_regs[3]);
8315 @@ -180,7 +180,7 @@ void show_regs(struct pt_regs *regs)
8316 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
8317 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
8318 regs->u_regs[15]);
8319 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
8320 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
8321 show_regwindow(regs);
8322 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
8323 }
8324 @@ -269,7 +269,7 @@ void arch_trigger_all_cpu_backtrace(void)
8325 ((tp && tp->task) ? tp->task->pid : -1));
8326
8327 if (gp->tstate & TSTATE_PRIV) {
8328 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
8329 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
8330 (void *) gp->tpc,
8331 (void *) gp->o7,
8332 (void *) gp->i7,
8333 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
8334 index 79cc0d1..ec62734 100644
8335 --- a/arch/sparc/kernel/prom_common.c
8336 +++ b/arch/sparc/kernel/prom_common.c
8337 @@ -144,7 +144,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
8338
8339 unsigned int prom_early_allocated __initdata;
8340
8341 -static struct of_pdt_ops prom_sparc_ops __initdata = {
8342 +static struct of_pdt_ops prom_sparc_ops __initconst = {
8343 .nextprop = prom_common_nextprop,
8344 .getproplen = prom_getproplen,
8345 .getproperty = prom_getproperty,
8346 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
8347 index 7ff45e4..a58f271 100644
8348 --- a/arch/sparc/kernel/ptrace_64.c
8349 +++ b/arch/sparc/kernel/ptrace_64.c
8350 @@ -1057,6 +1057,10 @@ long arch_ptrace(struct task_struct *child, long request,
8351 return ret;
8352 }
8353
8354 +#ifdef CONFIG_GRKERNSEC_SETXID
8355 +extern void gr_delayed_cred_worker(void);
8356 +#endif
8357 +
8358 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8359 {
8360 int ret = 0;
8361 @@ -1064,6 +1068,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8362 /* do the secure computing check first */
8363 secure_computing_strict(regs->u_regs[UREG_G1]);
8364
8365 +#ifdef CONFIG_GRKERNSEC_SETXID
8366 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8367 + gr_delayed_cred_worker();
8368 +#endif
8369 +
8370 if (test_thread_flag(TIF_SYSCALL_TRACE))
8371 ret = tracehook_report_syscall_entry(regs);
8372
8373 @@ -1084,6 +1093,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8374
8375 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
8376 {
8377 +#ifdef CONFIG_GRKERNSEC_SETXID
8378 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8379 + gr_delayed_cred_worker();
8380 +#endif
8381 +
8382 audit_syscall_exit(regs);
8383
8384 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8385 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
8386 index 3a8d184..49498a8 100644
8387 --- a/arch/sparc/kernel/sys_sparc_32.c
8388 +++ b/arch/sparc/kernel/sys_sparc_32.c
8389 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8390 if (len > TASK_SIZE - PAGE_SIZE)
8391 return -ENOMEM;
8392 if (!addr)
8393 - addr = TASK_UNMAPPED_BASE;
8394 + addr = current->mm->mmap_base;
8395
8396 info.flags = 0;
8397 info.length = len;
8398 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
8399 index 2daaaa6..d29bb82 100644
8400 --- a/arch/sparc/kernel/sys_sparc_64.c
8401 +++ b/arch/sparc/kernel/sys_sparc_64.c
8402 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8403 struct vm_area_struct * vma;
8404 unsigned long task_size = TASK_SIZE;
8405 int do_color_align;
8406 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8407 struct vm_unmapped_area_info info;
8408
8409 if (flags & MAP_FIXED) {
8410 /* We do not accept a shared mapping if it would violate
8411 * cache aliasing constraints.
8412 */
8413 - if ((flags & MAP_SHARED) &&
8414 + if ((filp || (flags & MAP_SHARED)) &&
8415 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8416 return -EINVAL;
8417 return addr;
8418 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8419 if (filp || (flags & MAP_SHARED))
8420 do_color_align = 1;
8421
8422 +#ifdef CONFIG_PAX_RANDMMAP
8423 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8424 +#endif
8425 +
8426 if (addr) {
8427 if (do_color_align)
8428 addr = COLOR_ALIGN(addr, pgoff);
8429 @@ -118,22 +123,28 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8430 addr = PAGE_ALIGN(addr);
8431
8432 vma = find_vma(mm, addr);
8433 - if (task_size - len >= addr &&
8434 - (!vma || addr + len <= vma->vm_start))
8435 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8436 return addr;
8437 }
8438
8439 info.flags = 0;
8440 info.length = len;
8441 - info.low_limit = TASK_UNMAPPED_BASE;
8442 + info.low_limit = mm->mmap_base;
8443 info.high_limit = min(task_size, VA_EXCLUDE_START);
8444 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
8445 info.align_offset = pgoff << PAGE_SHIFT;
8446 + info.threadstack_offset = offset;
8447 addr = vm_unmapped_area(&info);
8448
8449 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
8450 VM_BUG_ON(addr != -ENOMEM);
8451 info.low_limit = VA_EXCLUDE_END;
8452 +
8453 +#ifdef CONFIG_PAX_RANDMMAP
8454 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8455 + info.low_limit += mm->delta_mmap;
8456 +#endif
8457 +
8458 info.high_limit = task_size;
8459 addr = vm_unmapped_area(&info);
8460 }
8461 @@ -151,6 +162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8462 unsigned long task_size = STACK_TOP32;
8463 unsigned long addr = addr0;
8464 int do_color_align;
8465 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8466 struct vm_unmapped_area_info info;
8467
8468 /* This should only ever run for 32-bit processes. */
8469 @@ -160,7 +172,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8470 /* We do not accept a shared mapping if it would violate
8471 * cache aliasing constraints.
8472 */
8473 - if ((flags & MAP_SHARED) &&
8474 + if ((filp || (flags & MAP_SHARED)) &&
8475 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8476 return -EINVAL;
8477 return addr;
8478 @@ -173,6 +185,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8479 if (filp || (flags & MAP_SHARED))
8480 do_color_align = 1;
8481
8482 +#ifdef CONFIG_PAX_RANDMMAP
8483 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8484 +#endif
8485 +
8486 /* requesting a specific address */
8487 if (addr) {
8488 if (do_color_align)
8489 @@ -181,8 +197,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8490 addr = PAGE_ALIGN(addr);
8491
8492 vma = find_vma(mm, addr);
8493 - if (task_size - len >= addr &&
8494 - (!vma || addr + len <= vma->vm_start))
8495 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8496 return addr;
8497 }
8498
8499 @@ -192,6 +207,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8500 info.high_limit = mm->mmap_base;
8501 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
8502 info.align_offset = pgoff << PAGE_SHIFT;
8503 + info.threadstack_offset = offset;
8504 addr = vm_unmapped_area(&info);
8505
8506 /*
8507 @@ -204,6 +220,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8508 VM_BUG_ON(addr != -ENOMEM);
8509 info.flags = 0;
8510 info.low_limit = TASK_UNMAPPED_BASE;
8511 +
8512 +#ifdef CONFIG_PAX_RANDMMAP
8513 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8514 + info.low_limit += mm->delta_mmap;
8515 +#endif
8516 +
8517 info.high_limit = STACK_TOP32;
8518 addr = vm_unmapped_area(&info);
8519 }
8520 @@ -264,6 +286,10 @@ static unsigned long mmap_rnd(void)
8521 {
8522 unsigned long rnd = 0UL;
8523
8524 +#ifdef CONFIG_PAX_RANDMMAP
8525 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8526 +#endif
8527 +
8528 if (current->flags & PF_RANDOMIZE) {
8529 unsigned long val = get_random_int();
8530 if (test_thread_flag(TIF_32BIT))
8531 @@ -289,6 +315,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8532 gap == RLIM_INFINITY ||
8533 sysctl_legacy_va_layout) {
8534 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
8535 +
8536 +#ifdef CONFIG_PAX_RANDMMAP
8537 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8538 + mm->mmap_base += mm->delta_mmap;
8539 +#endif
8540 +
8541 mm->get_unmapped_area = arch_get_unmapped_area;
8542 mm->unmap_area = arch_unmap_area;
8543 } else {
8544 @@ -301,6 +333,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8545 gap = (task_size / 6 * 5);
8546
8547 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
8548 +
8549 +#ifdef CONFIG_PAX_RANDMMAP
8550 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8551 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8552 +#endif
8553 +
8554 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8555 mm->unmap_area = arch_unmap_area_topdown;
8556 }
8557 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
8558 index 22a1098..6255eb9 100644
8559 --- a/arch/sparc/kernel/syscalls.S
8560 +++ b/arch/sparc/kernel/syscalls.S
8561 @@ -52,7 +52,7 @@ sys32_rt_sigreturn:
8562 #endif
8563 .align 32
8564 1: ldx [%g6 + TI_FLAGS], %l5
8565 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8566 + andcc %l5, _TIF_WORK_SYSCALL, %g0
8567 be,pt %icc, rtrap
8568 nop
8569 call syscall_trace_leave
8570 @@ -184,7 +184,7 @@ linux_sparc_syscall32:
8571
8572 srl %i5, 0, %o5 ! IEU1
8573 srl %i2, 0, %o2 ! IEU0 Group
8574 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8575 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8576 bne,pn %icc, linux_syscall_trace32 ! CTI
8577 mov %i0, %l5 ! IEU1
8578 call %l7 ! CTI Group brk forced
8579 @@ -207,7 +207,7 @@ linux_sparc_syscall:
8580
8581 mov %i3, %o3 ! IEU1
8582 mov %i4, %o4 ! IEU0 Group
8583 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8584 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8585 bne,pn %icc, linux_syscall_trace ! CTI Group
8586 mov %i0, %l5 ! IEU0
8587 2: call %l7 ! CTI Group brk forced
8588 @@ -223,7 +223,7 @@ ret_sys_call:
8589
8590 cmp %o0, -ERESTART_RESTARTBLOCK
8591 bgeu,pn %xcc, 1f
8592 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8593 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8594 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
8595
8596 2:
8597 diff --git a/arch/sparc/kernel/sysfs.c b/arch/sparc/kernel/sysfs.c
8598 index 654e8aa..45f431b 100644
8599 --- a/arch/sparc/kernel/sysfs.c
8600 +++ b/arch/sparc/kernel/sysfs.c
8601 @@ -266,7 +266,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
8602 return NOTIFY_OK;
8603 }
8604
8605 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
8606 +static struct notifier_block sysfs_cpu_nb = {
8607 .notifier_call = sysfs_cpu_notify,
8608 };
8609
8610 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
8611 index 6629829..036032d 100644
8612 --- a/arch/sparc/kernel/traps_32.c
8613 +++ b/arch/sparc/kernel/traps_32.c
8614 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
8615 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
8616 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
8617
8618 +extern void gr_handle_kernel_exploit(void);
8619 +
8620 void die_if_kernel(char *str, struct pt_regs *regs)
8621 {
8622 static int die_counter;
8623 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8624 count++ < 30 &&
8625 (((unsigned long) rw) >= PAGE_OFFSET) &&
8626 !(((unsigned long) rw) & 0x7)) {
8627 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
8628 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
8629 (void *) rw->ins[7]);
8630 rw = (struct reg_window32 *)rw->ins[6];
8631 }
8632 }
8633 printk("Instruction DUMP:");
8634 instruction_dump ((unsigned long *) regs->pc);
8635 - if(regs->psr & PSR_PS)
8636 + if(regs->psr & PSR_PS) {
8637 + gr_handle_kernel_exploit();
8638 do_exit(SIGKILL);
8639 + }
8640 do_exit(SIGSEGV);
8641 }
8642
8643 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
8644 index b3f833a..ac74b2d 100644
8645 --- a/arch/sparc/kernel/traps_64.c
8646 +++ b/arch/sparc/kernel/traps_64.c
8647 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
8648 i + 1,
8649 p->trapstack[i].tstate, p->trapstack[i].tpc,
8650 p->trapstack[i].tnpc, p->trapstack[i].tt);
8651 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
8652 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
8653 }
8654 }
8655
8656 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
8657
8658 lvl -= 0x100;
8659 if (regs->tstate & TSTATE_PRIV) {
8660 +
8661 +#ifdef CONFIG_PAX_REFCOUNT
8662 + if (lvl == 6)
8663 + pax_report_refcount_overflow(regs);
8664 +#endif
8665 +
8666 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
8667 die_if_kernel(buffer, regs);
8668 }
8669 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
8670 void bad_trap_tl1(struct pt_regs *regs, long lvl)
8671 {
8672 char buffer[32];
8673 -
8674 +
8675 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
8676 0, lvl, SIGTRAP) == NOTIFY_STOP)
8677 return;
8678
8679 +#ifdef CONFIG_PAX_REFCOUNT
8680 + if (lvl == 6)
8681 + pax_report_refcount_overflow(regs);
8682 +#endif
8683 +
8684 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
8685
8686 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
8687 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
8688 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
8689 printk("%s" "ERROR(%d): ",
8690 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
8691 - printk("TPC<%pS>\n", (void *) regs->tpc);
8692 + printk("TPC<%pA>\n", (void *) regs->tpc);
8693 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
8694 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
8695 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
8696 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
8697 smp_processor_id(),
8698 (type & 0x1) ? 'I' : 'D',
8699 regs->tpc);
8700 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
8701 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
8702 panic("Irrecoverable Cheetah+ parity error.");
8703 }
8704
8705 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
8706 smp_processor_id(),
8707 (type & 0x1) ? 'I' : 'D',
8708 regs->tpc);
8709 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
8710 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
8711 }
8712
8713 struct sun4v_error_entry {
8714 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
8715
8716 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
8717 regs->tpc, tl);
8718 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
8719 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
8720 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
8721 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
8722 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
8723 (void *) regs->u_regs[UREG_I7]);
8724 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
8725 "pte[%lx] error[%lx]\n",
8726 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
8727
8728 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
8729 regs->tpc, tl);
8730 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
8731 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
8732 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
8733 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
8734 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
8735 (void *) regs->u_regs[UREG_I7]);
8736 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
8737 "pte[%lx] error[%lx]\n",
8738 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8739 fp = (unsigned long)sf->fp + STACK_BIAS;
8740 }
8741
8742 - printk(" [%016lx] %pS\n", pc, (void *) pc);
8743 + printk(" [%016lx] %pA\n", pc, (void *) pc);
8744 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
8745 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
8746 int index = tsk->curr_ret_stack;
8747 if (tsk->ret_stack && index >= graph) {
8748 pc = tsk->ret_stack[index - graph].ret;
8749 - printk(" [%016lx] %pS\n", pc, (void *) pc);
8750 + printk(" [%016lx] %pA\n", pc, (void *) pc);
8751 graph++;
8752 }
8753 }
8754 @@ -2360,6 +2371,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
8755 return (struct reg_window *) (fp + STACK_BIAS);
8756 }
8757
8758 +extern void gr_handle_kernel_exploit(void);
8759 +
8760 void die_if_kernel(char *str, struct pt_regs *regs)
8761 {
8762 static int die_counter;
8763 @@ -2388,7 +2401,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8764 while (rw &&
8765 count++ < 30 &&
8766 kstack_valid(tp, (unsigned long) rw)) {
8767 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
8768 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
8769 (void *) rw->ins[7]);
8770
8771 rw = kernel_stack_up(rw);
8772 @@ -2401,8 +2414,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8773 }
8774 user_instruction_dump ((unsigned int __user *) regs->tpc);
8775 }
8776 - if (regs->tstate & TSTATE_PRIV)
8777 + if (regs->tstate & TSTATE_PRIV) {
8778 + gr_handle_kernel_exploit();
8779 do_exit(SIGKILL);
8780 + }
8781 do_exit(SIGSEGV);
8782 }
8783 EXPORT_SYMBOL(die_if_kernel);
8784 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
8785 index 8201c25e..072a2a7 100644
8786 --- a/arch/sparc/kernel/unaligned_64.c
8787 +++ b/arch/sparc/kernel/unaligned_64.c
8788 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
8789 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
8790
8791 if (__ratelimit(&ratelimit)) {
8792 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
8793 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
8794 regs->tpc, (void *) regs->tpc);
8795 }
8796 }
8797 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
8798 index dbe119b..089c7c1 100644
8799 --- a/arch/sparc/lib/Makefile
8800 +++ b/arch/sparc/lib/Makefile
8801 @@ -2,7 +2,7 @@
8802 #
8803
8804 asflags-y := -ansi -DST_DIV0=0x02
8805 -ccflags-y := -Werror
8806 +#ccflags-y := -Werror
8807
8808 lib-$(CONFIG_SPARC32) += ashrdi3.o
8809 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
8810 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
8811 index 85c233d..68500e0 100644
8812 --- a/arch/sparc/lib/atomic_64.S
8813 +++ b/arch/sparc/lib/atomic_64.S
8814 @@ -17,7 +17,12 @@
8815 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
8816 BACKOFF_SETUP(%o2)
8817 1: lduw [%o1], %g1
8818 - add %g1, %o0, %g7
8819 + addcc %g1, %o0, %g7
8820 +
8821 +#ifdef CONFIG_PAX_REFCOUNT
8822 + tvs %icc, 6
8823 +#endif
8824 +
8825 cas [%o1], %g1, %g7
8826 cmp %g1, %g7
8827 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8828 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
8829 2: BACKOFF_SPIN(%o2, %o3, 1b)
8830 ENDPROC(atomic_add)
8831
8832 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8833 + BACKOFF_SETUP(%o2)
8834 +1: lduw [%o1], %g1
8835 + add %g1, %o0, %g7
8836 + cas [%o1], %g1, %g7
8837 + cmp %g1, %g7
8838 + bne,pn %icc, 2f
8839 + nop
8840 + retl
8841 + nop
8842 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8843 +ENDPROC(atomic_add_unchecked)
8844 +
8845 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8846 BACKOFF_SETUP(%o2)
8847 1: lduw [%o1], %g1
8848 - sub %g1, %o0, %g7
8849 + subcc %g1, %o0, %g7
8850 +
8851 +#ifdef CONFIG_PAX_REFCOUNT
8852 + tvs %icc, 6
8853 +#endif
8854 +
8855 cas [%o1], %g1, %g7
8856 cmp %g1, %g7
8857 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8858 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8859 2: BACKOFF_SPIN(%o2, %o3, 1b)
8860 ENDPROC(atomic_sub)
8861
8862 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
8863 + BACKOFF_SETUP(%o2)
8864 +1: lduw [%o1], %g1
8865 + sub %g1, %o0, %g7
8866 + cas [%o1], %g1, %g7
8867 + cmp %g1, %g7
8868 + bne,pn %icc, 2f
8869 + nop
8870 + retl
8871 + nop
8872 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8873 +ENDPROC(atomic_sub_unchecked)
8874 +
8875 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
8876 BACKOFF_SETUP(%o2)
8877 1: lduw [%o1], %g1
8878 - add %g1, %o0, %g7
8879 + addcc %g1, %o0, %g7
8880 +
8881 +#ifdef CONFIG_PAX_REFCOUNT
8882 + tvs %icc, 6
8883 +#endif
8884 +
8885 cas [%o1], %g1, %g7
8886 cmp %g1, %g7
8887 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
8888 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
8889 2: BACKOFF_SPIN(%o2, %o3, 1b)
8890 ENDPROC(atomic_add_ret)
8891
8892 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8893 + BACKOFF_SETUP(%o2)
8894 +1: lduw [%o1], %g1
8895 + addcc %g1, %o0, %g7
8896 + cas [%o1], %g1, %g7
8897 + cmp %g1, %g7
8898 + bne,pn %icc, 2f
8899 + add %g7, %o0, %g7
8900 + sra %g7, 0, %o0
8901 + retl
8902 + nop
8903 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8904 +ENDPROC(atomic_add_ret_unchecked)
8905 +
8906 ENTRY(atomic_sub_ret) /* %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 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
8920 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
8921 BACKOFF_SETUP(%o2)
8922 1: ldx [%o1], %g1
8923 - add %g1, %o0, %g7
8924 + addcc %g1, %o0, %g7
8925 +
8926 +#ifdef CONFIG_PAX_REFCOUNT
8927 + tvs %xcc, 6
8928 +#endif
8929 +
8930 casx [%o1], %g1, %g7
8931 cmp %g1, %g7
8932 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
8933 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
8934 2: BACKOFF_SPIN(%o2, %o3, 1b)
8935 ENDPROC(atomic64_add)
8936
8937 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8938 + BACKOFF_SETUP(%o2)
8939 +1: ldx [%o1], %g1
8940 + addcc %g1, %o0, %g7
8941 + casx [%o1], %g1, %g7
8942 + cmp %g1, %g7
8943 + bne,pn %xcc, 2f
8944 + nop
8945 + retl
8946 + nop
8947 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8948 +ENDPROC(atomic64_add_unchecked)
8949 +
8950 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8951 BACKOFF_SETUP(%o2)
8952 1: ldx [%o1], %g1
8953 - sub %g1, %o0, %g7
8954 + subcc %g1, %o0, %g7
8955 +
8956 +#ifdef CONFIG_PAX_REFCOUNT
8957 + tvs %xcc, 6
8958 +#endif
8959 +
8960 casx [%o1], %g1, %g7
8961 cmp %g1, %g7
8962 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
8963 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
8964 2: BACKOFF_SPIN(%o2, %o3, 1b)
8965 ENDPROC(atomic64_sub)
8966
8967 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
8968 + BACKOFF_SETUP(%o2)
8969 +1: ldx [%o1], %g1
8970 + subcc %g1, %o0, %g7
8971 + casx [%o1], %g1, %g7
8972 + cmp %g1, %g7
8973 + bne,pn %xcc, 2f
8974 + nop
8975 + retl
8976 + nop
8977 +2: BACKOFF_SPIN(%o2, %o3, 1b)
8978 +ENDPROC(atomic64_sub_unchecked)
8979 +
8980 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
8981 BACKOFF_SETUP(%o2)
8982 1: ldx [%o1], %g1
8983 - add %g1, %o0, %g7
8984 + addcc %g1, %o0, %g7
8985 +
8986 +#ifdef CONFIG_PAX_REFCOUNT
8987 + tvs %xcc, 6
8988 +#endif
8989 +
8990 casx [%o1], %g1, %g7
8991 cmp %g1, %g7
8992 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
8993 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
8994 2: BACKOFF_SPIN(%o2, %o3, 1b)
8995 ENDPROC(atomic64_add_ret)
8996
8997 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
8998 + BACKOFF_SETUP(%o2)
8999 +1: ldx [%o1], %g1
9000 + addcc %g1, %o0, %g7
9001 + casx [%o1], %g1, %g7
9002 + cmp %g1, %g7
9003 + bne,pn %xcc, 2f
9004 + add %g7, %o0, %g7
9005 + mov %g7, %o0
9006 + retl
9007 + nop
9008 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9009 +ENDPROC(atomic64_add_ret_unchecked)
9010 +
9011 ENTRY(atomic64_sub_ret) /* %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 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
9025 index 0c4e35e..745d3e4 100644
9026 --- a/arch/sparc/lib/ksyms.c
9027 +++ b/arch/sparc/lib/ksyms.c
9028 @@ -109,12 +109,18 @@ EXPORT_SYMBOL(__downgrade_write);
9029
9030 /* Atomic counter implementation. */
9031 EXPORT_SYMBOL(atomic_add);
9032 +EXPORT_SYMBOL(atomic_add_unchecked);
9033 EXPORT_SYMBOL(atomic_add_ret);
9034 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
9035 EXPORT_SYMBOL(atomic_sub);
9036 +EXPORT_SYMBOL(atomic_sub_unchecked);
9037 EXPORT_SYMBOL(atomic_sub_ret);
9038 EXPORT_SYMBOL(atomic64_add);
9039 +EXPORT_SYMBOL(atomic64_add_unchecked);
9040 EXPORT_SYMBOL(atomic64_add_ret);
9041 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
9042 EXPORT_SYMBOL(atomic64_sub);
9043 +EXPORT_SYMBOL(atomic64_sub_unchecked);
9044 EXPORT_SYMBOL(atomic64_sub_ret);
9045 EXPORT_SYMBOL(atomic64_dec_if_positive);
9046
9047 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
9048 index 30c3ecc..736f015 100644
9049 --- a/arch/sparc/mm/Makefile
9050 +++ b/arch/sparc/mm/Makefile
9051 @@ -2,7 +2,7 @@
9052 #
9053
9054 asflags-y := -ansi
9055 -ccflags-y := -Werror
9056 +#ccflags-y := -Werror
9057
9058 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
9059 obj-y += fault_$(BITS).o
9060 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
9061 index e98bfda..ea8d221 100644
9062 --- a/arch/sparc/mm/fault_32.c
9063 +++ b/arch/sparc/mm/fault_32.c
9064 @@ -21,6 +21,9 @@
9065 #include <linux/perf_event.h>
9066 #include <linux/interrupt.h>
9067 #include <linux/kdebug.h>
9068 +#include <linux/slab.h>
9069 +#include <linux/pagemap.h>
9070 +#include <linux/compiler.h>
9071
9072 #include <asm/page.h>
9073 #include <asm/pgtable.h>
9074 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
9075 return safe_compute_effective_address(regs, insn);
9076 }
9077
9078 +#ifdef CONFIG_PAX_PAGEEXEC
9079 +#ifdef CONFIG_PAX_DLRESOLVE
9080 +static void pax_emuplt_close(struct vm_area_struct *vma)
9081 +{
9082 + vma->vm_mm->call_dl_resolve = 0UL;
9083 +}
9084 +
9085 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9086 +{
9087 + unsigned int *kaddr;
9088 +
9089 + vmf->page = alloc_page(GFP_HIGHUSER);
9090 + if (!vmf->page)
9091 + return VM_FAULT_OOM;
9092 +
9093 + kaddr = kmap(vmf->page);
9094 + memset(kaddr, 0, PAGE_SIZE);
9095 + kaddr[0] = 0x9DE3BFA8U; /* save */
9096 + flush_dcache_page(vmf->page);
9097 + kunmap(vmf->page);
9098 + return VM_FAULT_MAJOR;
9099 +}
9100 +
9101 +static const struct vm_operations_struct pax_vm_ops = {
9102 + .close = pax_emuplt_close,
9103 + .fault = pax_emuplt_fault
9104 +};
9105 +
9106 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9107 +{
9108 + int ret;
9109 +
9110 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9111 + vma->vm_mm = current->mm;
9112 + vma->vm_start = addr;
9113 + vma->vm_end = addr + PAGE_SIZE;
9114 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9115 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9116 + vma->vm_ops = &pax_vm_ops;
9117 +
9118 + ret = insert_vm_struct(current->mm, vma);
9119 + if (ret)
9120 + return ret;
9121 +
9122 + ++current->mm->total_vm;
9123 + return 0;
9124 +}
9125 +#endif
9126 +
9127 +/*
9128 + * PaX: decide what to do with offenders (regs->pc = fault address)
9129 + *
9130 + * returns 1 when task should be killed
9131 + * 2 when patched PLT trampoline was detected
9132 + * 3 when unpatched PLT trampoline was detected
9133 + */
9134 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9135 +{
9136 +
9137 +#ifdef CONFIG_PAX_EMUPLT
9138 + int err;
9139 +
9140 + do { /* PaX: patched PLT emulation #1 */
9141 + unsigned int sethi1, sethi2, jmpl;
9142 +
9143 + err = get_user(sethi1, (unsigned int *)regs->pc);
9144 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
9145 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
9146 +
9147 + if (err)
9148 + break;
9149 +
9150 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9151 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9152 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9153 + {
9154 + unsigned int addr;
9155 +
9156 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9157 + addr = regs->u_regs[UREG_G1];
9158 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9159 + regs->pc = addr;
9160 + regs->npc = addr+4;
9161 + return 2;
9162 + }
9163 + } while (0);
9164 +
9165 + do { /* PaX: patched PLT emulation #2 */
9166 + unsigned int ba;
9167 +
9168 + err = get_user(ba, (unsigned int *)regs->pc);
9169 +
9170 + if (err)
9171 + break;
9172 +
9173 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9174 + unsigned int addr;
9175 +
9176 + if ((ba & 0xFFC00000U) == 0x30800000U)
9177 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9178 + else
9179 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9180 + regs->pc = addr;
9181 + regs->npc = addr+4;
9182 + return 2;
9183 + }
9184 + } while (0);
9185 +
9186 + do { /* PaX: patched PLT emulation #3 */
9187 + unsigned int sethi, bajmpl, nop;
9188 +
9189 + err = get_user(sethi, (unsigned int *)regs->pc);
9190 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
9191 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9192 +
9193 + if (err)
9194 + break;
9195 +
9196 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9197 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9198 + nop == 0x01000000U)
9199 + {
9200 + unsigned int addr;
9201 +
9202 + addr = (sethi & 0x003FFFFFU) << 10;
9203 + regs->u_regs[UREG_G1] = addr;
9204 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9205 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9206 + else
9207 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9208 + regs->pc = addr;
9209 + regs->npc = addr+4;
9210 + return 2;
9211 + }
9212 + } while (0);
9213 +
9214 + do { /* PaX: unpatched PLT emulation step 1 */
9215 + unsigned int sethi, ba, nop;
9216 +
9217 + err = get_user(sethi, (unsigned int *)regs->pc);
9218 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
9219 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9220 +
9221 + if (err)
9222 + break;
9223 +
9224 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9225 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9226 + nop == 0x01000000U)
9227 + {
9228 + unsigned int addr, save, call;
9229 +
9230 + if ((ba & 0xFFC00000U) == 0x30800000U)
9231 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9232 + else
9233 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9234 +
9235 + err = get_user(save, (unsigned int *)addr);
9236 + err |= get_user(call, (unsigned int *)(addr+4));
9237 + err |= get_user(nop, (unsigned int *)(addr+8));
9238 + if (err)
9239 + break;
9240 +
9241 +#ifdef CONFIG_PAX_DLRESOLVE
9242 + if (save == 0x9DE3BFA8U &&
9243 + (call & 0xC0000000U) == 0x40000000U &&
9244 + nop == 0x01000000U)
9245 + {
9246 + struct vm_area_struct *vma;
9247 + unsigned long call_dl_resolve;
9248 +
9249 + down_read(&current->mm->mmap_sem);
9250 + call_dl_resolve = current->mm->call_dl_resolve;
9251 + up_read(&current->mm->mmap_sem);
9252 + if (likely(call_dl_resolve))
9253 + goto emulate;
9254 +
9255 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9256 +
9257 + down_write(&current->mm->mmap_sem);
9258 + if (current->mm->call_dl_resolve) {
9259 + call_dl_resolve = current->mm->call_dl_resolve;
9260 + up_write(&current->mm->mmap_sem);
9261 + if (vma)
9262 + kmem_cache_free(vm_area_cachep, vma);
9263 + goto emulate;
9264 + }
9265 +
9266 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9267 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9268 + up_write(&current->mm->mmap_sem);
9269 + if (vma)
9270 + kmem_cache_free(vm_area_cachep, vma);
9271 + return 1;
9272 + }
9273 +
9274 + if (pax_insert_vma(vma, call_dl_resolve)) {
9275 + up_write(&current->mm->mmap_sem);
9276 + kmem_cache_free(vm_area_cachep, vma);
9277 + return 1;
9278 + }
9279 +
9280 + current->mm->call_dl_resolve = call_dl_resolve;
9281 + up_write(&current->mm->mmap_sem);
9282 +
9283 +emulate:
9284 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9285 + regs->pc = call_dl_resolve;
9286 + regs->npc = addr+4;
9287 + return 3;
9288 + }
9289 +#endif
9290 +
9291 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9292 + if ((save & 0xFFC00000U) == 0x05000000U &&
9293 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9294 + nop == 0x01000000U)
9295 + {
9296 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9297 + regs->u_regs[UREG_G2] = addr + 4;
9298 + addr = (save & 0x003FFFFFU) << 10;
9299 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9300 + regs->pc = addr;
9301 + regs->npc = addr+4;
9302 + return 3;
9303 + }
9304 + }
9305 + } while (0);
9306 +
9307 + do { /* PaX: unpatched PLT emulation step 2 */
9308 + unsigned int save, call, nop;
9309 +
9310 + err = get_user(save, (unsigned int *)(regs->pc-4));
9311 + err |= get_user(call, (unsigned int *)regs->pc);
9312 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
9313 + if (err)
9314 + break;
9315 +
9316 + if (save == 0x9DE3BFA8U &&
9317 + (call & 0xC0000000U) == 0x40000000U &&
9318 + nop == 0x01000000U)
9319 + {
9320 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
9321 +
9322 + regs->u_regs[UREG_RETPC] = regs->pc;
9323 + regs->pc = dl_resolve;
9324 + regs->npc = dl_resolve+4;
9325 + return 3;
9326 + }
9327 + } while (0);
9328 +#endif
9329 +
9330 + return 1;
9331 +}
9332 +
9333 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9334 +{
9335 + unsigned long i;
9336 +
9337 + printk(KERN_ERR "PAX: bytes at PC: ");
9338 + for (i = 0; i < 8; i++) {
9339 + unsigned int c;
9340 + if (get_user(c, (unsigned int *)pc+i))
9341 + printk(KERN_CONT "???????? ");
9342 + else
9343 + printk(KERN_CONT "%08x ", c);
9344 + }
9345 + printk("\n");
9346 +}
9347 +#endif
9348 +
9349 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
9350 int text_fault)
9351 {
9352 @@ -230,6 +504,24 @@ good_area:
9353 if (!(vma->vm_flags & VM_WRITE))
9354 goto bad_area;
9355 } else {
9356 +
9357 +#ifdef CONFIG_PAX_PAGEEXEC
9358 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
9359 + up_read(&mm->mmap_sem);
9360 + switch (pax_handle_fetch_fault(regs)) {
9361 +
9362 +#ifdef CONFIG_PAX_EMUPLT
9363 + case 2:
9364 + case 3:
9365 + return;
9366 +#endif
9367 +
9368 + }
9369 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
9370 + do_group_exit(SIGKILL);
9371 + }
9372 +#endif
9373 +
9374 /* Allow reads even for write-only mappings */
9375 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
9376 goto bad_area;
9377 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
9378 index 5062ff3..e0b75f3 100644
9379 --- a/arch/sparc/mm/fault_64.c
9380 +++ b/arch/sparc/mm/fault_64.c
9381 @@ -21,6 +21,9 @@
9382 #include <linux/kprobes.h>
9383 #include <linux/kdebug.h>
9384 #include <linux/percpu.h>
9385 +#include <linux/slab.h>
9386 +#include <linux/pagemap.h>
9387 +#include <linux/compiler.h>
9388
9389 #include <asm/page.h>
9390 #include <asm/pgtable.h>
9391 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
9392 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
9393 regs->tpc);
9394 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
9395 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
9396 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
9397 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
9398 dump_stack();
9399 unhandled_fault(regs->tpc, current, regs);
9400 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
9401 show_regs(regs);
9402 }
9403
9404 +#ifdef CONFIG_PAX_PAGEEXEC
9405 +#ifdef CONFIG_PAX_DLRESOLVE
9406 +static void pax_emuplt_close(struct vm_area_struct *vma)
9407 +{
9408 + vma->vm_mm->call_dl_resolve = 0UL;
9409 +}
9410 +
9411 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9412 +{
9413 + unsigned int *kaddr;
9414 +
9415 + vmf->page = alloc_page(GFP_HIGHUSER);
9416 + if (!vmf->page)
9417 + return VM_FAULT_OOM;
9418 +
9419 + kaddr = kmap(vmf->page);
9420 + memset(kaddr, 0, PAGE_SIZE);
9421 + kaddr[0] = 0x9DE3BFA8U; /* save */
9422 + flush_dcache_page(vmf->page);
9423 + kunmap(vmf->page);
9424 + return VM_FAULT_MAJOR;
9425 +}
9426 +
9427 +static const struct vm_operations_struct pax_vm_ops = {
9428 + .close = pax_emuplt_close,
9429 + .fault = pax_emuplt_fault
9430 +};
9431 +
9432 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9433 +{
9434 + int ret;
9435 +
9436 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9437 + vma->vm_mm = current->mm;
9438 + vma->vm_start = addr;
9439 + vma->vm_end = addr + PAGE_SIZE;
9440 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9441 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9442 + vma->vm_ops = &pax_vm_ops;
9443 +
9444 + ret = insert_vm_struct(current->mm, vma);
9445 + if (ret)
9446 + return ret;
9447 +
9448 + ++current->mm->total_vm;
9449 + return 0;
9450 +}
9451 +#endif
9452 +
9453 +/*
9454 + * PaX: decide what to do with offenders (regs->tpc = fault address)
9455 + *
9456 + * returns 1 when task should be killed
9457 + * 2 when patched PLT trampoline was detected
9458 + * 3 when unpatched PLT trampoline was detected
9459 + */
9460 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9461 +{
9462 +
9463 +#ifdef CONFIG_PAX_EMUPLT
9464 + int err;
9465 +
9466 + do { /* PaX: patched PLT emulation #1 */
9467 + unsigned int sethi1, sethi2, jmpl;
9468 +
9469 + err = get_user(sethi1, (unsigned int *)regs->tpc);
9470 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
9471 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
9472 +
9473 + if (err)
9474 + break;
9475 +
9476 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9477 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9478 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9479 + {
9480 + unsigned long addr;
9481 +
9482 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9483 + addr = regs->u_regs[UREG_G1];
9484 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9485 +
9486 + if (test_thread_flag(TIF_32BIT))
9487 + addr &= 0xFFFFFFFFUL;
9488 +
9489 + regs->tpc = addr;
9490 + regs->tnpc = addr+4;
9491 + return 2;
9492 + }
9493 + } while (0);
9494 +
9495 + do { /* PaX: patched PLT emulation #2 */
9496 + unsigned int ba;
9497 +
9498 + err = get_user(ba, (unsigned int *)regs->tpc);
9499 +
9500 + if (err)
9501 + break;
9502 +
9503 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9504 + unsigned long addr;
9505 +
9506 + if ((ba & 0xFFC00000U) == 0x30800000U)
9507 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9508 + else
9509 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9510 +
9511 + if (test_thread_flag(TIF_32BIT))
9512 + addr &= 0xFFFFFFFFUL;
9513 +
9514 + regs->tpc = addr;
9515 + regs->tnpc = addr+4;
9516 + return 2;
9517 + }
9518 + } while (0);
9519 +
9520 + do { /* PaX: patched PLT emulation #3 */
9521 + unsigned int sethi, bajmpl, nop;
9522 +
9523 + err = get_user(sethi, (unsigned int *)regs->tpc);
9524 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
9525 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9526 +
9527 + if (err)
9528 + break;
9529 +
9530 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9531 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9532 + nop == 0x01000000U)
9533 + {
9534 + unsigned long addr;
9535 +
9536 + addr = (sethi & 0x003FFFFFU) << 10;
9537 + regs->u_regs[UREG_G1] = addr;
9538 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9539 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9540 + else
9541 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9542 +
9543 + if (test_thread_flag(TIF_32BIT))
9544 + addr &= 0xFFFFFFFFUL;
9545 +
9546 + regs->tpc = addr;
9547 + regs->tnpc = addr+4;
9548 + return 2;
9549 + }
9550 + } while (0);
9551 +
9552 + do { /* PaX: patched PLT emulation #4 */
9553 + unsigned int sethi, mov1, call, mov2;
9554 +
9555 + err = get_user(sethi, (unsigned int *)regs->tpc);
9556 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
9557 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
9558 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
9559 +
9560 + if (err)
9561 + break;
9562 +
9563 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9564 + mov1 == 0x8210000FU &&
9565 + (call & 0xC0000000U) == 0x40000000U &&
9566 + mov2 == 0x9E100001U)
9567 + {
9568 + unsigned long addr;
9569 +
9570 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
9571 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
9572 +
9573 + if (test_thread_flag(TIF_32BIT))
9574 + addr &= 0xFFFFFFFFUL;
9575 +
9576 + regs->tpc = addr;
9577 + regs->tnpc = addr+4;
9578 + return 2;
9579 + }
9580 + } while (0);
9581 +
9582 + do { /* PaX: patched PLT emulation #5 */
9583 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
9584 +
9585 + err = get_user(sethi, (unsigned int *)regs->tpc);
9586 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
9587 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
9588 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
9589 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
9590 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
9591 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
9592 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
9593 +
9594 + if (err)
9595 + break;
9596 +
9597 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9598 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
9599 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9600 + (or1 & 0xFFFFE000U) == 0x82106000U &&
9601 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
9602 + sllx == 0x83287020U &&
9603 + jmpl == 0x81C04005U &&
9604 + nop == 0x01000000U)
9605 + {
9606 + unsigned long addr;
9607 +
9608 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
9609 + regs->u_regs[UREG_G1] <<= 32;
9610 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
9611 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
9612 + regs->tpc = addr;
9613 + regs->tnpc = addr+4;
9614 + return 2;
9615 + }
9616 + } while (0);
9617 +
9618 + do { /* PaX: patched PLT emulation #6 */
9619 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
9620 +
9621 + err = get_user(sethi, (unsigned int *)regs->tpc);
9622 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
9623 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
9624 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
9625 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
9626 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
9627 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
9628 +
9629 + if (err)
9630 + break;
9631 +
9632 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9633 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
9634 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9635 + sllx == 0x83287020U &&
9636 + (or & 0xFFFFE000U) == 0x8A116000U &&
9637 + jmpl == 0x81C04005U &&
9638 + nop == 0x01000000U)
9639 + {
9640 + unsigned long addr;
9641 +
9642 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
9643 + regs->u_regs[UREG_G1] <<= 32;
9644 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
9645 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
9646 + regs->tpc = addr;
9647 + regs->tnpc = addr+4;
9648 + return 2;
9649 + }
9650 + } while (0);
9651 +
9652 + do { /* PaX: unpatched PLT emulation step 1 */
9653 + unsigned int sethi, ba, nop;
9654 +
9655 + err = get_user(sethi, (unsigned int *)regs->tpc);
9656 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
9657 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9658 +
9659 + if (err)
9660 + break;
9661 +
9662 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9663 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9664 + nop == 0x01000000U)
9665 + {
9666 + unsigned long addr;
9667 + unsigned int save, call;
9668 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
9669 +
9670 + if ((ba & 0xFFC00000U) == 0x30800000U)
9671 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9672 + else
9673 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9674 +
9675 + if (test_thread_flag(TIF_32BIT))
9676 + addr &= 0xFFFFFFFFUL;
9677 +
9678 + err = get_user(save, (unsigned int *)addr);
9679 + err |= get_user(call, (unsigned int *)(addr+4));
9680 + err |= get_user(nop, (unsigned int *)(addr+8));
9681 + if (err)
9682 + break;
9683 +
9684 +#ifdef CONFIG_PAX_DLRESOLVE
9685 + if (save == 0x9DE3BFA8U &&
9686 + (call & 0xC0000000U) == 0x40000000U &&
9687 + nop == 0x01000000U)
9688 + {
9689 + struct vm_area_struct *vma;
9690 + unsigned long call_dl_resolve;
9691 +
9692 + down_read(&current->mm->mmap_sem);
9693 + call_dl_resolve = current->mm->call_dl_resolve;
9694 + up_read(&current->mm->mmap_sem);
9695 + if (likely(call_dl_resolve))
9696 + goto emulate;
9697 +
9698 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9699 +
9700 + down_write(&current->mm->mmap_sem);
9701 + if (current->mm->call_dl_resolve) {
9702 + call_dl_resolve = current->mm->call_dl_resolve;
9703 + up_write(&current->mm->mmap_sem);
9704 + if (vma)
9705 + kmem_cache_free(vm_area_cachep, vma);
9706 + goto emulate;
9707 + }
9708 +
9709 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9710 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9711 + up_write(&current->mm->mmap_sem);
9712 + if (vma)
9713 + kmem_cache_free(vm_area_cachep, vma);
9714 + return 1;
9715 + }
9716 +
9717 + if (pax_insert_vma(vma, call_dl_resolve)) {
9718 + up_write(&current->mm->mmap_sem);
9719 + kmem_cache_free(vm_area_cachep, vma);
9720 + return 1;
9721 + }
9722 +
9723 + current->mm->call_dl_resolve = call_dl_resolve;
9724 + up_write(&current->mm->mmap_sem);
9725 +
9726 +emulate:
9727 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9728 + regs->tpc = call_dl_resolve;
9729 + regs->tnpc = addr+4;
9730 + return 3;
9731 + }
9732 +#endif
9733 +
9734 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9735 + if ((save & 0xFFC00000U) == 0x05000000U &&
9736 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9737 + nop == 0x01000000U)
9738 + {
9739 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9740 + regs->u_regs[UREG_G2] = addr + 4;
9741 + addr = (save & 0x003FFFFFU) << 10;
9742 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9743 +
9744 + if (test_thread_flag(TIF_32BIT))
9745 + addr &= 0xFFFFFFFFUL;
9746 +
9747 + regs->tpc = addr;
9748 + regs->tnpc = addr+4;
9749 + return 3;
9750 + }
9751 +
9752 + /* PaX: 64-bit PLT stub */
9753 + err = get_user(sethi1, (unsigned int *)addr);
9754 + err |= get_user(sethi2, (unsigned int *)(addr+4));
9755 + err |= get_user(or1, (unsigned int *)(addr+8));
9756 + err |= get_user(or2, (unsigned int *)(addr+12));
9757 + err |= get_user(sllx, (unsigned int *)(addr+16));
9758 + err |= get_user(add, (unsigned int *)(addr+20));
9759 + err |= get_user(jmpl, (unsigned int *)(addr+24));
9760 + err |= get_user(nop, (unsigned int *)(addr+28));
9761 + if (err)
9762 + break;
9763 +
9764 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
9765 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9766 + (or1 & 0xFFFFE000U) == 0x88112000U &&
9767 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
9768 + sllx == 0x89293020U &&
9769 + add == 0x8A010005U &&
9770 + jmpl == 0x89C14000U &&
9771 + nop == 0x01000000U)
9772 + {
9773 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9774 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
9775 + regs->u_regs[UREG_G4] <<= 32;
9776 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
9777 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
9778 + regs->u_regs[UREG_G4] = addr + 24;
9779 + addr = regs->u_regs[UREG_G5];
9780 + regs->tpc = addr;
9781 + regs->tnpc = addr+4;
9782 + return 3;
9783 + }
9784 + }
9785 + } while (0);
9786 +
9787 +#ifdef CONFIG_PAX_DLRESOLVE
9788 + do { /* PaX: unpatched PLT emulation step 2 */
9789 + unsigned int save, call, nop;
9790 +
9791 + err = get_user(save, (unsigned int *)(regs->tpc-4));
9792 + err |= get_user(call, (unsigned int *)regs->tpc);
9793 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
9794 + if (err)
9795 + break;
9796 +
9797 + if (save == 0x9DE3BFA8U &&
9798 + (call & 0xC0000000U) == 0x40000000U &&
9799 + nop == 0x01000000U)
9800 + {
9801 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
9802 +
9803 + if (test_thread_flag(TIF_32BIT))
9804 + dl_resolve &= 0xFFFFFFFFUL;
9805 +
9806 + regs->u_regs[UREG_RETPC] = regs->tpc;
9807 + regs->tpc = dl_resolve;
9808 + regs->tnpc = dl_resolve+4;
9809 + return 3;
9810 + }
9811 + } while (0);
9812 +#endif
9813 +
9814 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
9815 + unsigned int sethi, ba, nop;
9816 +
9817 + err = get_user(sethi, (unsigned int *)regs->tpc);
9818 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
9819 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9820 +
9821 + if (err)
9822 + break;
9823 +
9824 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9825 + (ba & 0xFFF00000U) == 0x30600000U &&
9826 + nop == 0x01000000U)
9827 + {
9828 + unsigned long addr;
9829 +
9830 + addr = (sethi & 0x003FFFFFU) << 10;
9831 + regs->u_regs[UREG_G1] = addr;
9832 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9833 +
9834 + if (test_thread_flag(TIF_32BIT))
9835 + addr &= 0xFFFFFFFFUL;
9836 +
9837 + regs->tpc = addr;
9838 + regs->tnpc = addr+4;
9839 + return 2;
9840 + }
9841 + } while (0);
9842 +
9843 +#endif
9844 +
9845 + return 1;
9846 +}
9847 +
9848 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9849 +{
9850 + unsigned long i;
9851 +
9852 + printk(KERN_ERR "PAX: bytes at PC: ");
9853 + for (i = 0; i < 8; i++) {
9854 + unsigned int c;
9855 + if (get_user(c, (unsigned int *)pc+i))
9856 + printk(KERN_CONT "???????? ");
9857 + else
9858 + printk(KERN_CONT "%08x ", c);
9859 + }
9860 + printk("\n");
9861 +}
9862 +#endif
9863 +
9864 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
9865 {
9866 struct mm_struct *mm = current->mm;
9867 @@ -341,6 +804,29 @@ retry:
9868 if (!vma)
9869 goto bad_area;
9870
9871 +#ifdef CONFIG_PAX_PAGEEXEC
9872 + /* PaX: detect ITLB misses on non-exec pages */
9873 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
9874 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
9875 + {
9876 + if (address != regs->tpc)
9877 + goto good_area;
9878 +
9879 + up_read(&mm->mmap_sem);
9880 + switch (pax_handle_fetch_fault(regs)) {
9881 +
9882 +#ifdef CONFIG_PAX_EMUPLT
9883 + case 2:
9884 + case 3:
9885 + return;
9886 +#endif
9887 +
9888 + }
9889 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
9890 + do_group_exit(SIGKILL);
9891 + }
9892 +#endif
9893 +
9894 /* Pure DTLB misses do not tell us whether the fault causing
9895 * load/store/atomic was a write or not, it only says that there
9896 * was no match. So in such a case we (carefully) read the
9897 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
9898 index d2b5944..bd813f2 100644
9899 --- a/arch/sparc/mm/hugetlbpage.c
9900 +++ b/arch/sparc/mm/hugetlbpage.c
9901 @@ -38,7 +38,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
9902
9903 info.flags = 0;
9904 info.length = len;
9905 - info.low_limit = TASK_UNMAPPED_BASE;
9906 + info.low_limit = mm->mmap_base;
9907 info.high_limit = min(task_size, VA_EXCLUDE_START);
9908 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
9909 info.align_offset = 0;
9910 @@ -47,6 +47,12 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
9911 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
9912 VM_BUG_ON(addr != -ENOMEM);
9913 info.low_limit = VA_EXCLUDE_END;
9914 +
9915 +#ifdef CONFIG_PAX_RANDMMAP
9916 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9917 + info.low_limit += mm->delta_mmap;
9918 +#endif
9919 +
9920 info.high_limit = task_size;
9921 addr = vm_unmapped_area(&info);
9922 }
9923 @@ -85,6 +91,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9924 VM_BUG_ON(addr != -ENOMEM);
9925 info.flags = 0;
9926 info.low_limit = TASK_UNMAPPED_BASE;
9927 +
9928 +#ifdef CONFIG_PAX_RANDMMAP
9929 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9930 + info.low_limit += mm->delta_mmap;
9931 +#endif
9932 +
9933 info.high_limit = STACK_TOP32;
9934 addr = vm_unmapped_area(&info);
9935 }
9936 @@ -99,6 +111,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
9937 struct mm_struct *mm = current->mm;
9938 struct vm_area_struct *vma;
9939 unsigned long task_size = TASK_SIZE;
9940 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
9941
9942 if (test_thread_flag(TIF_32BIT))
9943 task_size = STACK_TOP32;
9944 @@ -114,11 +127,14 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
9945 return addr;
9946 }
9947
9948 +#ifdef CONFIG_PAX_RANDMMAP
9949 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9950 +#endif
9951 +
9952 if (addr) {
9953 addr = ALIGN(addr, HPAGE_SIZE);
9954 vma = find_vma(mm, addr);
9955 - if (task_size - len >= addr &&
9956 - (!vma || addr + len <= vma->vm_start))
9957 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9958 return addr;
9959 }
9960 if (mm->get_unmapped_area == arch_get_unmapped_area)
9961 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
9962 index f4500c6..889656c 100644
9963 --- a/arch/tile/include/asm/atomic_64.h
9964 +++ b/arch/tile/include/asm/atomic_64.h
9965 @@ -143,6 +143,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
9966
9967 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
9968
9969 +#define atomic64_read_unchecked(v) atomic64_read(v)
9970 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
9971 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
9972 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
9973 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
9974 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
9975 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
9976 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
9977 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
9978 +
9979 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
9980 #define smp_mb__before_atomic_dec() smp_mb()
9981 #define smp_mb__after_atomic_dec() smp_mb()
9982 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
9983 index a9a5299..0fce79e 100644
9984 --- a/arch/tile/include/asm/cache.h
9985 +++ b/arch/tile/include/asm/cache.h
9986 @@ -15,11 +15,12 @@
9987 #ifndef _ASM_TILE_CACHE_H
9988 #define _ASM_TILE_CACHE_H
9989
9990 +#include <linux/const.h>
9991 #include <arch/chip.h>
9992
9993 /* bytes per L1 data cache line */
9994 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
9995 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
9996 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
9997
9998 /* bytes per L2 cache line */
9999 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
10000 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
10001 index 8a082bc..7a6bf87 100644
10002 --- a/arch/tile/include/asm/uaccess.h
10003 +++ b/arch/tile/include/asm/uaccess.h
10004 @@ -408,9 +408,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
10005 const void __user *from,
10006 unsigned long n)
10007 {
10008 - int sz = __compiletime_object_size(to);
10009 + size_t sz = __compiletime_object_size(to);
10010
10011 - if (likely(sz == -1 || sz >= n))
10012 + if (likely(sz == (size_t)-1 || sz >= n))
10013 n = _copy_from_user(to, from, n);
10014 else
10015 copy_from_user_overflow();
10016 diff --git a/arch/tile/mm/hugetlbpage.c b/arch/tile/mm/hugetlbpage.c
10017 index 650ccff..45fe2d6 100644
10018 --- a/arch/tile/mm/hugetlbpage.c
10019 +++ b/arch/tile/mm/hugetlbpage.c
10020 @@ -239,6 +239,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
10021 info.high_limit = TASK_SIZE;
10022 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
10023 info.align_offset = 0;
10024 + info.threadstack_offset = 0;
10025 return vm_unmapped_area(&info);
10026 }
10027
10028 @@ -256,6 +257,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
10029 info.high_limit = current->mm->mmap_base;
10030 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
10031 info.align_offset = 0;
10032 + info.threadstack_offset = 0;
10033 addr = vm_unmapped_area(&info);
10034
10035 /*
10036 diff --git a/arch/um/Makefile b/arch/um/Makefile
10037 index 133f7de..1d6f2f1 100644
10038 --- a/arch/um/Makefile
10039 +++ b/arch/um/Makefile
10040 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
10041 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
10042 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
10043
10044 +ifdef CONSTIFY_PLUGIN
10045 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10046 +endif
10047 +
10048 #This will adjust *FLAGS accordingly to the platform.
10049 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
10050
10051 diff --git a/arch/um/defconfig b/arch/um/defconfig
10052 index 08107a7..ab22afe 100644
10053 --- a/arch/um/defconfig
10054 +++ b/arch/um/defconfig
10055 @@ -51,7 +51,6 @@ CONFIG_X86_CMPXCHG=y
10056 CONFIG_X86_L1_CACHE_SHIFT=5
10057 CONFIG_X86_XADD=y
10058 CONFIG_X86_PPRO_FENCE=y
10059 -CONFIG_X86_WP_WORKS_OK=y
10060 CONFIG_X86_INVLPG=y
10061 CONFIG_X86_BSWAP=y
10062 CONFIG_X86_POPAD_OK=y
10063 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
10064 index 19e1bdd..3665b77 100644
10065 --- a/arch/um/include/asm/cache.h
10066 +++ b/arch/um/include/asm/cache.h
10067 @@ -1,6 +1,7 @@
10068 #ifndef __UM_CACHE_H
10069 #define __UM_CACHE_H
10070
10071 +#include <linux/const.h>
10072
10073 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
10074 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
10075 @@ -12,6 +13,6 @@
10076 # define L1_CACHE_SHIFT 5
10077 #endif
10078
10079 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10080 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10081
10082 #endif
10083 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
10084 index 2e0a6b1..a64d0f5 100644
10085 --- a/arch/um/include/asm/kmap_types.h
10086 +++ b/arch/um/include/asm/kmap_types.h
10087 @@ -8,6 +8,6 @@
10088
10089 /* No more #include "asm/arch/kmap_types.h" ! */
10090
10091 -#define KM_TYPE_NR 14
10092 +#define KM_TYPE_NR 15
10093
10094 #endif
10095 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
10096 index 5ff53d9..5850cdf 100644
10097 --- a/arch/um/include/asm/page.h
10098 +++ b/arch/um/include/asm/page.h
10099 @@ -14,6 +14,9 @@
10100 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
10101 #define PAGE_MASK (~(PAGE_SIZE-1))
10102
10103 +#define ktla_ktva(addr) (addr)
10104 +#define ktva_ktla(addr) (addr)
10105 +
10106 #ifndef __ASSEMBLY__
10107
10108 struct page;
10109 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
10110 index 0032f92..cd151e0 100644
10111 --- a/arch/um/include/asm/pgtable-3level.h
10112 +++ b/arch/um/include/asm/pgtable-3level.h
10113 @@ -58,6 +58,7 @@
10114 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
10115 #define pud_populate(mm, pud, pmd) \
10116 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
10117 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
10118
10119 #ifdef CONFIG_64BIT
10120 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
10121 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
10122 index bbcef52..6a2a483 100644
10123 --- a/arch/um/kernel/process.c
10124 +++ b/arch/um/kernel/process.c
10125 @@ -367,22 +367,6 @@ int singlestepping(void * t)
10126 return 2;
10127 }
10128
10129 -/*
10130 - * Only x86 and x86_64 have an arch_align_stack().
10131 - * All other arches have "#define arch_align_stack(x) (x)"
10132 - * in their asm/system.h
10133 - * As this is included in UML from asm-um/system-generic.h,
10134 - * we can use it to behave as the subarch does.
10135 - */
10136 -#ifndef arch_align_stack
10137 -unsigned long arch_align_stack(unsigned long sp)
10138 -{
10139 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
10140 - sp -= get_random_int() % 8192;
10141 - return sp & ~0xf;
10142 -}
10143 -#endif
10144 -
10145 unsigned long get_wchan(struct task_struct *p)
10146 {
10147 unsigned long stack_page, sp, ip;
10148 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
10149 index ad8f795..2c7eec6 100644
10150 --- a/arch/unicore32/include/asm/cache.h
10151 +++ b/arch/unicore32/include/asm/cache.h
10152 @@ -12,8 +12,10 @@
10153 #ifndef __UNICORE_CACHE_H__
10154 #define __UNICORE_CACHE_H__
10155
10156 -#define L1_CACHE_SHIFT (5)
10157 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10158 +#include <linux/const.h>
10159 +
10160 +#define L1_CACHE_SHIFT 5
10161 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10162
10163 /*
10164 * Memory returned by kmalloc() may be used for DMA, so we must make
10165 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
10166 index fe120da..24177f7 100644
10167 --- a/arch/x86/Kconfig
10168 +++ b/arch/x86/Kconfig
10169 @@ -239,7 +239,7 @@ config X86_HT
10170
10171 config X86_32_LAZY_GS
10172 def_bool y
10173 - depends on X86_32 && !CC_STACKPROTECTOR
10174 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
10175
10176 config ARCH_HWEIGHT_CFLAGS
10177 string
10178 @@ -1073,6 +1073,7 @@ config MICROCODE_EARLY
10179
10180 config X86_MSR
10181 tristate "/dev/cpu/*/msr - Model-specific register support"
10182 + depends on !GRKERNSEC_KMEM
10183 ---help---
10184 This device gives privileged processes access to the x86
10185 Model-Specific Registers (MSRs). It is a character device with
10186 @@ -1096,7 +1097,7 @@ choice
10187
10188 config NOHIGHMEM
10189 bool "off"
10190 - depends on !X86_NUMAQ
10191 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10192 ---help---
10193 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
10194 However, the address space of 32-bit x86 processors is only 4
10195 @@ -1133,7 +1134,7 @@ config NOHIGHMEM
10196
10197 config HIGHMEM4G
10198 bool "4GB"
10199 - depends on !X86_NUMAQ
10200 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10201 ---help---
10202 Select this if you have a 32-bit processor and between 1 and 4
10203 gigabytes of physical RAM.
10204 @@ -1186,7 +1187,7 @@ config PAGE_OFFSET
10205 hex
10206 default 0xB0000000 if VMSPLIT_3G_OPT
10207 default 0x80000000 if VMSPLIT_2G
10208 - default 0x78000000 if VMSPLIT_2G_OPT
10209 + default 0x70000000 if VMSPLIT_2G_OPT
10210 default 0x40000000 if VMSPLIT_1G
10211 default 0xC0000000
10212 depends on X86_32
10213 @@ -1584,6 +1585,7 @@ config SECCOMP
10214
10215 config CC_STACKPROTECTOR
10216 bool "Enable -fstack-protector buffer overflow detection"
10217 + depends on X86_64 || !PAX_MEMORY_UDEREF
10218 ---help---
10219 This option turns on the -fstack-protector GCC feature. This
10220 feature puts, at the beginning of functions, a canary value on
10221 @@ -1703,6 +1705,8 @@ config X86_NEED_RELOCS
10222 config PHYSICAL_ALIGN
10223 hex "Alignment value to which kernel should be aligned" if X86_32
10224 default "0x1000000"
10225 + range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
10226 + range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
10227 range 0x2000 0x1000000
10228 ---help---
10229 This value puts the alignment restrictions on physical address
10230 @@ -1778,9 +1782,10 @@ config DEBUG_HOTPLUG_CPU0
10231 If unsure, say N.
10232
10233 config COMPAT_VDSO
10234 - def_bool y
10235 + def_bool n
10236 prompt "Compat VDSO support"
10237 depends on X86_32 || IA32_EMULATION
10238 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
10239 ---help---
10240 Map the 32-bit VDSO to the predictable old-style address too.
10241
10242 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
10243 index c026cca..14657ae 100644
10244 --- a/arch/x86/Kconfig.cpu
10245 +++ b/arch/x86/Kconfig.cpu
10246 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
10247
10248 config X86_F00F_BUG
10249 def_bool y
10250 - depends on M586MMX || M586TSC || M586 || M486
10251 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
10252
10253 config X86_INVD_BUG
10254 def_bool y
10255 @@ -327,7 +327,7 @@ config X86_INVD_BUG
10256
10257 config X86_ALIGNMENT_16
10258 def_bool y
10259 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10260 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10261
10262 config X86_INTEL_USERCOPY
10263 def_bool y
10264 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
10265 # generates cmov.
10266 config X86_CMOV
10267 def_bool y
10268 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10269 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10270
10271 config X86_MINIMUM_CPU_FAMILY
10272 int
10273 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
10274 index c198b7e..63eea60 100644
10275 --- a/arch/x86/Kconfig.debug
10276 +++ b/arch/x86/Kconfig.debug
10277 @@ -84,7 +84,7 @@ config X86_PTDUMP
10278 config DEBUG_RODATA
10279 bool "Write protect kernel read-only data structures"
10280 default y
10281 - depends on DEBUG_KERNEL
10282 + depends on DEBUG_KERNEL && BROKEN
10283 ---help---
10284 Mark the kernel read-only data as write-protected in the pagetables,
10285 in order to catch accidental (and incorrect) writes to such const
10286 @@ -102,7 +102,7 @@ config DEBUG_RODATA_TEST
10287
10288 config DEBUG_SET_MODULE_RONX
10289 bool "Set loadable kernel module data as NX and text as RO"
10290 - depends on MODULES
10291 + depends on MODULES && BROKEN
10292 ---help---
10293 This option helps catch unintended modifications to loadable
10294 kernel module's text and read-only data. It also prevents execution
10295 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
10296 index 5c47726..8c4fa67 100644
10297 --- a/arch/x86/Makefile
10298 +++ b/arch/x86/Makefile
10299 @@ -54,6 +54,7 @@ else
10300 UTS_MACHINE := x86_64
10301 CHECKFLAGS += -D__x86_64__ -m64
10302
10303 + biarch := $(call cc-option,-m64)
10304 KBUILD_AFLAGS += -m64
10305 KBUILD_CFLAGS += -m64
10306
10307 @@ -234,3 +235,12 @@ define archhelp
10308 echo ' FDARGS="..." arguments for the booted kernel'
10309 echo ' FDINITRD=file initrd for the booted kernel'
10310 endef
10311 +
10312 +define OLD_LD
10313 +
10314 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
10315 +*** Please upgrade your binutils to 2.18 or newer
10316 +endef
10317 +
10318 +archprepare:
10319 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
10320 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
10321 index 379814b..add62ce 100644
10322 --- a/arch/x86/boot/Makefile
10323 +++ b/arch/x86/boot/Makefile
10324 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
10325 $(call cc-option, -fno-stack-protector) \
10326 $(call cc-option, -mpreferred-stack-boundary=2)
10327 KBUILD_CFLAGS += $(call cc-option, -m32)
10328 +ifdef CONSTIFY_PLUGIN
10329 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10330 +endif
10331 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10332 GCOV_PROFILE := n
10333
10334 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
10335 index 878e4b9..20537ab 100644
10336 --- a/arch/x86/boot/bitops.h
10337 +++ b/arch/x86/boot/bitops.h
10338 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10339 u8 v;
10340 const u32 *p = (const u32 *)addr;
10341
10342 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10343 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10344 return v;
10345 }
10346
10347 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10348
10349 static inline void set_bit(int nr, void *addr)
10350 {
10351 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10352 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10353 }
10354
10355 #endif /* BOOT_BITOPS_H */
10356 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
10357 index 5b75319..331a4ca 100644
10358 --- a/arch/x86/boot/boot.h
10359 +++ b/arch/x86/boot/boot.h
10360 @@ -85,7 +85,7 @@ static inline void io_delay(void)
10361 static inline u16 ds(void)
10362 {
10363 u16 seg;
10364 - asm("movw %%ds,%0" : "=rm" (seg));
10365 + asm volatile("movw %%ds,%0" : "=rm" (seg));
10366 return seg;
10367 }
10368
10369 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
10370 static inline int memcmp(const void *s1, const void *s2, size_t len)
10371 {
10372 u8 diff;
10373 - asm("repe; cmpsb; setnz %0"
10374 + asm volatile("repe; cmpsb; setnz %0"
10375 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
10376 return diff;
10377 }
10378 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
10379 index 5ef205c..342191d 100644
10380 --- a/arch/x86/boot/compressed/Makefile
10381 +++ b/arch/x86/boot/compressed/Makefile
10382 @@ -14,6 +14,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
10383 KBUILD_CFLAGS += $(cflags-y)
10384 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
10385 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
10386 +ifdef CONSTIFY_PLUGIN
10387 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10388 +endif
10389
10390 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10391 GCOV_PROFILE := n
10392 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
10393 index c205035..5853587 100644
10394 --- a/arch/x86/boot/compressed/eboot.c
10395 +++ b/arch/x86/boot/compressed/eboot.c
10396 @@ -150,7 +150,6 @@ again:
10397 *addr = max_addr;
10398 }
10399
10400 -free_pool:
10401 efi_call_phys1(sys_table->boottime->free_pool, map);
10402
10403 fail:
10404 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
10405 if (i == map_size / desc_size)
10406 status = EFI_NOT_FOUND;
10407
10408 -free_pool:
10409 efi_call_phys1(sys_table->boottime->free_pool, map);
10410 fail:
10411 return status;
10412 diff --git a/arch/x86/boot/compressed/efi_stub_32.S b/arch/x86/boot/compressed/efi_stub_32.S
10413 index a53440e..c3dbf1e 100644
10414 --- a/arch/x86/boot/compressed/efi_stub_32.S
10415 +++ b/arch/x86/boot/compressed/efi_stub_32.S
10416 @@ -46,16 +46,13 @@ ENTRY(efi_call_phys)
10417 * parameter 2, ..., param n. To make things easy, we save the return
10418 * address of efi_call_phys in a global variable.
10419 */
10420 - popl %ecx
10421 - movl %ecx, saved_return_addr(%edx)
10422 - /* get the function pointer into ECX*/
10423 - popl %ecx
10424 - movl %ecx, efi_rt_function_ptr(%edx)
10425 + popl saved_return_addr(%edx)
10426 + popl efi_rt_function_ptr(%edx)
10427
10428 /*
10429 * 3. Call the physical function.
10430 */
10431 - call *%ecx
10432 + call *efi_rt_function_ptr(%edx)
10433
10434 /*
10435 * 4. Balance the stack. And because EAX contain the return value,
10436 @@ -67,15 +64,12 @@ ENTRY(efi_call_phys)
10437 1: popl %edx
10438 subl $1b, %edx
10439
10440 - movl efi_rt_function_ptr(%edx), %ecx
10441 - pushl %ecx
10442 + pushl efi_rt_function_ptr(%edx)
10443
10444 /*
10445 * 10. Push the saved return address onto the stack and return.
10446 */
10447 - movl saved_return_addr(%edx), %ecx
10448 - pushl %ecx
10449 - ret
10450 + jmpl *saved_return_addr(%edx)
10451 ENDPROC(efi_call_phys)
10452 .previous
10453
10454 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
10455 index 1e3184f..0d11e2e 100644
10456 --- a/arch/x86/boot/compressed/head_32.S
10457 +++ b/arch/x86/boot/compressed/head_32.S
10458 @@ -118,7 +118,7 @@ preferred_addr:
10459 notl %eax
10460 andl %eax, %ebx
10461 #else
10462 - movl $LOAD_PHYSICAL_ADDR, %ebx
10463 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10464 #endif
10465
10466 /* Target address to relocate to for decompression */
10467 @@ -204,7 +204,7 @@ relocated:
10468 * and where it was actually loaded.
10469 */
10470 movl %ebp, %ebx
10471 - subl $LOAD_PHYSICAL_ADDR, %ebx
10472 + subl $____LOAD_PHYSICAL_ADDR, %ebx
10473 jz 2f /* Nothing to be done if loaded at compiled addr. */
10474 /*
10475 * Process relocations.
10476 @@ -212,8 +212,7 @@ relocated:
10477
10478 1: subl $4, %edi
10479 movl (%edi), %ecx
10480 - testl %ecx, %ecx
10481 - jz 2f
10482 + jecxz 2f
10483 addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
10484 jmp 1b
10485 2:
10486 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
10487 index 16f24e6..47491a3 100644
10488 --- a/arch/x86/boot/compressed/head_64.S
10489 +++ b/arch/x86/boot/compressed/head_64.S
10490 @@ -97,7 +97,7 @@ ENTRY(startup_32)
10491 notl %eax
10492 andl %eax, %ebx
10493 #else
10494 - movl $LOAD_PHYSICAL_ADDR, %ebx
10495 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10496 #endif
10497
10498 /* Target address to relocate to for decompression */
10499 @@ -272,7 +272,7 @@ preferred_addr:
10500 notq %rax
10501 andq %rax, %rbp
10502 #else
10503 - movq $LOAD_PHYSICAL_ADDR, %rbp
10504 + movq $____LOAD_PHYSICAL_ADDR, %rbp
10505 #endif
10506
10507 /* Target address to relocate to for decompression */
10508 @@ -363,8 +363,8 @@ gdt:
10509 .long gdt
10510 .word 0
10511 .quad 0x0000000000000000 /* NULL descriptor */
10512 - .quad 0x00af9a000000ffff /* __KERNEL_CS */
10513 - .quad 0x00cf92000000ffff /* __KERNEL_DS */
10514 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
10515 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
10516 .quad 0x0080890000000000 /* TS descriptor */
10517 .quad 0x0000000000000000 /* TS continued */
10518 gdt_end:
10519 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
10520 index 7cb56c6..d382d84 100644
10521 --- a/arch/x86/boot/compressed/misc.c
10522 +++ b/arch/x86/boot/compressed/misc.c
10523 @@ -303,7 +303,7 @@ static void parse_elf(void *output)
10524 case PT_LOAD:
10525 #ifdef CONFIG_RELOCATABLE
10526 dest = output;
10527 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
10528 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
10529 #else
10530 dest = (void *)(phdr->p_paddr);
10531 #endif
10532 @@ -354,7 +354,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
10533 error("Destination address too large");
10534 #endif
10535 #ifndef CONFIG_RELOCATABLE
10536 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
10537 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
10538 error("Wrong destination address");
10539 #endif
10540
10541 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
10542 index 4d3ff03..e4972ff 100644
10543 --- a/arch/x86/boot/cpucheck.c
10544 +++ b/arch/x86/boot/cpucheck.c
10545 @@ -74,7 +74,7 @@ static int has_fpu(void)
10546 u16 fcw = -1, fsw = -1;
10547 u32 cr0;
10548
10549 - asm("movl %%cr0,%0" : "=r" (cr0));
10550 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
10551 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
10552 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
10553 asm volatile("movl %0,%%cr0" : : "r" (cr0));
10554 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
10555 {
10556 u32 f0, f1;
10557
10558 - asm("pushfl ; "
10559 + asm volatile("pushfl ; "
10560 "pushfl ; "
10561 "popl %0 ; "
10562 "movl %0,%1 ; "
10563 @@ -115,7 +115,7 @@ static void get_flags(void)
10564 set_bit(X86_FEATURE_FPU, cpu.flags);
10565
10566 if (has_eflag(X86_EFLAGS_ID)) {
10567 - asm("cpuid"
10568 + asm volatile("cpuid"
10569 : "=a" (max_intel_level),
10570 "=b" (cpu_vendor[0]),
10571 "=d" (cpu_vendor[1]),
10572 @@ -124,7 +124,7 @@ static void get_flags(void)
10573
10574 if (max_intel_level >= 0x00000001 &&
10575 max_intel_level <= 0x0000ffff) {
10576 - asm("cpuid"
10577 + asm volatile("cpuid"
10578 : "=a" (tfms),
10579 "=c" (cpu.flags[4]),
10580 "=d" (cpu.flags[0])
10581 @@ -136,7 +136,7 @@ static void get_flags(void)
10582 cpu.model += ((tfms >> 16) & 0xf) << 4;
10583 }
10584
10585 - asm("cpuid"
10586 + asm volatile("cpuid"
10587 : "=a" (max_amd_level)
10588 : "a" (0x80000000)
10589 : "ebx", "ecx", "edx");
10590 @@ -144,7 +144,7 @@ static void get_flags(void)
10591 if (max_amd_level >= 0x80000001 &&
10592 max_amd_level <= 0x8000ffff) {
10593 u32 eax = 0x80000001;
10594 - asm("cpuid"
10595 + asm volatile("cpuid"
10596 : "+a" (eax),
10597 "=c" (cpu.flags[6]),
10598 "=d" (cpu.flags[1])
10599 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10600 u32 ecx = MSR_K7_HWCR;
10601 u32 eax, edx;
10602
10603 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10604 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10605 eax &= ~(1 << 15);
10606 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10607 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10608
10609 get_flags(); /* Make sure it really did something */
10610 err = check_flags();
10611 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10612 u32 ecx = MSR_VIA_FCR;
10613 u32 eax, edx;
10614
10615 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10616 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10617 eax |= (1<<1)|(1<<7);
10618 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10619 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10620
10621 set_bit(X86_FEATURE_CX8, cpu.flags);
10622 err = check_flags();
10623 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10624 u32 eax, edx;
10625 u32 level = 1;
10626
10627 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10628 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10629 - asm("cpuid"
10630 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10631 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10632 + asm volatile("cpuid"
10633 : "+a" (level), "=d" (cpu.flags[0])
10634 : : "ecx", "ebx");
10635 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10636 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10637
10638 err = check_flags();
10639 }
10640 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
10641 index 9ec06a1..2c25e79 100644
10642 --- a/arch/x86/boot/header.S
10643 +++ b/arch/x86/boot/header.S
10644 @@ -409,10 +409,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
10645 # single linked list of
10646 # struct setup_data
10647
10648 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
10649 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
10650
10651 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
10652 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
10653 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
10654 +#else
10655 #define VO_INIT_SIZE (VO__end - VO__text)
10656 +#endif
10657 #if ZO_INIT_SIZE > VO_INIT_SIZE
10658 #define INIT_SIZE ZO_INIT_SIZE
10659 #else
10660 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
10661 index db75d07..8e6d0af 100644
10662 --- a/arch/x86/boot/memory.c
10663 +++ b/arch/x86/boot/memory.c
10664 @@ -19,7 +19,7 @@
10665
10666 static int detect_memory_e820(void)
10667 {
10668 - int count = 0;
10669 + unsigned int count = 0;
10670 struct biosregs ireg, oreg;
10671 struct e820entry *desc = boot_params.e820_map;
10672 static struct e820entry buf; /* static so it is zeroed */
10673 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
10674 index 11e8c6e..fdbb1ed 100644
10675 --- a/arch/x86/boot/video-vesa.c
10676 +++ b/arch/x86/boot/video-vesa.c
10677 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
10678
10679 boot_params.screen_info.vesapm_seg = oreg.es;
10680 boot_params.screen_info.vesapm_off = oreg.di;
10681 + boot_params.screen_info.vesapm_size = oreg.cx;
10682 }
10683
10684 /*
10685 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
10686 index 43eda28..5ab5fdb 100644
10687 --- a/arch/x86/boot/video.c
10688 +++ b/arch/x86/boot/video.c
10689 @@ -96,7 +96,7 @@ static void store_mode_params(void)
10690 static unsigned int get_entry(void)
10691 {
10692 char entry_buf[4];
10693 - int i, len = 0;
10694 + unsigned int i, len = 0;
10695 int key;
10696 unsigned int v;
10697
10698 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
10699 index 9105655..5e37f27 100644
10700 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
10701 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
10702 @@ -8,6 +8,8 @@
10703 * including this sentence is retained in full.
10704 */
10705
10706 +#include <asm/alternative-asm.h>
10707 +
10708 .extern crypto_ft_tab
10709 .extern crypto_it_tab
10710 .extern crypto_fl_tab
10711 @@ -70,6 +72,8 @@
10712 je B192; \
10713 leaq 32(r9),r9;
10714
10715 +#define ret pax_force_retaddr 0, 1; ret
10716 +
10717 #define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \
10718 movq r1,r2; \
10719 movq r3,r4; \
10720 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
10721 index 477e9d7..3ab339f 100644
10722 --- a/arch/x86/crypto/aesni-intel_asm.S
10723 +++ b/arch/x86/crypto/aesni-intel_asm.S
10724 @@ -31,6 +31,7 @@
10725
10726 #include <linux/linkage.h>
10727 #include <asm/inst.h>
10728 +#include <asm/alternative-asm.h>
10729
10730 #ifdef __x86_64__
10731 .data
10732 @@ -1441,6 +1442,7 @@ _return_T_done_decrypt:
10733 pop %r14
10734 pop %r13
10735 pop %r12
10736 + pax_force_retaddr 0, 1
10737 ret
10738 ENDPROC(aesni_gcm_dec)
10739
10740 @@ -1705,6 +1707,7 @@ _return_T_done_encrypt:
10741 pop %r14
10742 pop %r13
10743 pop %r12
10744 + pax_force_retaddr 0, 1
10745 ret
10746 ENDPROC(aesni_gcm_enc)
10747
10748 @@ -1722,6 +1725,7 @@ _key_expansion_256a:
10749 pxor %xmm1, %xmm0
10750 movaps %xmm0, (TKEYP)
10751 add $0x10, TKEYP
10752 + pax_force_retaddr_bts
10753 ret
10754 ENDPROC(_key_expansion_128)
10755 ENDPROC(_key_expansion_256a)
10756 @@ -1748,6 +1752,7 @@ _key_expansion_192a:
10757 shufps $0b01001110, %xmm2, %xmm1
10758 movaps %xmm1, 0x10(TKEYP)
10759 add $0x20, TKEYP
10760 + pax_force_retaddr_bts
10761 ret
10762 ENDPROC(_key_expansion_192a)
10763
10764 @@ -1768,6 +1773,7 @@ _key_expansion_192b:
10765
10766 movaps %xmm0, (TKEYP)
10767 add $0x10, TKEYP
10768 + pax_force_retaddr_bts
10769 ret
10770 ENDPROC(_key_expansion_192b)
10771
10772 @@ -1781,6 +1787,7 @@ _key_expansion_256b:
10773 pxor %xmm1, %xmm2
10774 movaps %xmm2, (TKEYP)
10775 add $0x10, TKEYP
10776 + pax_force_retaddr_bts
10777 ret
10778 ENDPROC(_key_expansion_256b)
10779
10780 @@ -1894,6 +1901,7 @@ ENTRY(aesni_set_key)
10781 #ifndef __x86_64__
10782 popl KEYP
10783 #endif
10784 + pax_force_retaddr 0, 1
10785 ret
10786 ENDPROC(aesni_set_key)
10787
10788 @@ -1916,6 +1924,7 @@ ENTRY(aesni_enc)
10789 popl KLEN
10790 popl KEYP
10791 #endif
10792 + pax_force_retaddr 0, 1
10793 ret
10794 ENDPROC(aesni_enc)
10795
10796 @@ -1974,6 +1983,7 @@ _aesni_enc1:
10797 AESENC KEY STATE
10798 movaps 0x70(TKEYP), KEY
10799 AESENCLAST KEY STATE
10800 + pax_force_retaddr_bts
10801 ret
10802 ENDPROC(_aesni_enc1)
10803
10804 @@ -2083,6 +2093,7 @@ _aesni_enc4:
10805 AESENCLAST KEY STATE2
10806 AESENCLAST KEY STATE3
10807 AESENCLAST KEY STATE4
10808 + pax_force_retaddr_bts
10809 ret
10810 ENDPROC(_aesni_enc4)
10811
10812 @@ -2106,6 +2117,7 @@ ENTRY(aesni_dec)
10813 popl KLEN
10814 popl KEYP
10815 #endif
10816 + pax_force_retaddr 0, 1
10817 ret
10818 ENDPROC(aesni_dec)
10819
10820 @@ -2164,6 +2176,7 @@ _aesni_dec1:
10821 AESDEC KEY STATE
10822 movaps 0x70(TKEYP), KEY
10823 AESDECLAST KEY STATE
10824 + pax_force_retaddr_bts
10825 ret
10826 ENDPROC(_aesni_dec1)
10827
10828 @@ -2273,6 +2286,7 @@ _aesni_dec4:
10829 AESDECLAST KEY STATE2
10830 AESDECLAST KEY STATE3
10831 AESDECLAST KEY STATE4
10832 + pax_force_retaddr_bts
10833 ret
10834 ENDPROC(_aesni_dec4)
10835
10836 @@ -2331,6 +2345,7 @@ ENTRY(aesni_ecb_enc)
10837 popl KEYP
10838 popl LEN
10839 #endif
10840 + pax_force_retaddr 0, 1
10841 ret
10842 ENDPROC(aesni_ecb_enc)
10843
10844 @@ -2390,6 +2405,7 @@ ENTRY(aesni_ecb_dec)
10845 popl KEYP
10846 popl LEN
10847 #endif
10848 + pax_force_retaddr 0, 1
10849 ret
10850 ENDPROC(aesni_ecb_dec)
10851
10852 @@ -2432,6 +2448,7 @@ ENTRY(aesni_cbc_enc)
10853 popl LEN
10854 popl IVP
10855 #endif
10856 + pax_force_retaddr 0, 1
10857 ret
10858 ENDPROC(aesni_cbc_enc)
10859
10860 @@ -2523,6 +2540,7 @@ ENTRY(aesni_cbc_dec)
10861 popl LEN
10862 popl IVP
10863 #endif
10864 + pax_force_retaddr 0, 1
10865 ret
10866 ENDPROC(aesni_cbc_dec)
10867
10868 @@ -2550,6 +2568,7 @@ _aesni_inc_init:
10869 mov $1, TCTR_LOW
10870 MOVQ_R64_XMM TCTR_LOW INC
10871 MOVQ_R64_XMM CTR TCTR_LOW
10872 + pax_force_retaddr_bts
10873 ret
10874 ENDPROC(_aesni_inc_init)
10875
10876 @@ -2579,6 +2598,7 @@ _aesni_inc:
10877 .Linc_low:
10878 movaps CTR, IV
10879 PSHUFB_XMM BSWAP_MASK IV
10880 + pax_force_retaddr_bts
10881 ret
10882 ENDPROC(_aesni_inc)
10883
10884 @@ -2640,6 +2660,7 @@ ENTRY(aesni_ctr_enc)
10885 .Lctr_enc_ret:
10886 movups IV, (IVP)
10887 .Lctr_enc_just_ret:
10888 + pax_force_retaddr 0, 1
10889 ret
10890 ENDPROC(aesni_ctr_enc)
10891
10892 @@ -2766,6 +2787,7 @@ ENTRY(aesni_xts_crypt8)
10893 pxor INC, STATE4
10894 movdqu STATE4, 0x70(OUTP)
10895
10896 + pax_force_retaddr 0, 1
10897 ret
10898 ENDPROC(aesni_xts_crypt8)
10899
10900 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
10901 index 246c670..4d1ed00 100644
10902 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
10903 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
10904 @@ -21,6 +21,7 @@
10905 */
10906
10907 #include <linux/linkage.h>
10908 +#include <asm/alternative-asm.h>
10909
10910 .file "blowfish-x86_64-asm.S"
10911 .text
10912 @@ -149,9 +150,11 @@ ENTRY(__blowfish_enc_blk)
10913 jnz .L__enc_xor;
10914
10915 write_block();
10916 + pax_force_retaddr 0, 1
10917 ret;
10918 .L__enc_xor:
10919 xor_block();
10920 + pax_force_retaddr 0, 1
10921 ret;
10922 ENDPROC(__blowfish_enc_blk)
10923
10924 @@ -183,6 +186,7 @@ ENTRY(blowfish_dec_blk)
10925
10926 movq %r11, %rbp;
10927
10928 + pax_force_retaddr 0, 1
10929 ret;
10930 ENDPROC(blowfish_dec_blk)
10931
10932 @@ -334,6 +338,7 @@ ENTRY(__blowfish_enc_blk_4way)
10933
10934 popq %rbx;
10935 popq %rbp;
10936 + pax_force_retaddr 0, 1
10937 ret;
10938
10939 .L__enc_xor4:
10940 @@ -341,6 +346,7 @@ ENTRY(__blowfish_enc_blk_4way)
10941
10942 popq %rbx;
10943 popq %rbp;
10944 + pax_force_retaddr 0, 1
10945 ret;
10946 ENDPROC(__blowfish_enc_blk_4way)
10947
10948 @@ -375,5 +381,6 @@ ENTRY(blowfish_dec_blk_4way)
10949 popq %rbx;
10950 popq %rbp;
10951
10952 + pax_force_retaddr 0, 1
10953 ret;
10954 ENDPROC(blowfish_dec_blk_4way)
10955 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
10956 index 310319c..ce174a4 100644
10957 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
10958 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
10959 @@ -21,6 +21,7 @@
10960 */
10961
10962 #include <linux/linkage.h>
10963 +#include <asm/alternative-asm.h>
10964
10965 .file "camellia-x86_64-asm_64.S"
10966 .text
10967 @@ -228,12 +229,14 @@ ENTRY(__camellia_enc_blk)
10968 enc_outunpack(mov, RT1);
10969
10970 movq RRBP, %rbp;
10971 + pax_force_retaddr 0, 1
10972 ret;
10973
10974 .L__enc_xor:
10975 enc_outunpack(xor, RT1);
10976
10977 movq RRBP, %rbp;
10978 + pax_force_retaddr 0, 1
10979 ret;
10980 ENDPROC(__camellia_enc_blk)
10981
10982 @@ -272,6 +275,7 @@ ENTRY(camellia_dec_blk)
10983 dec_outunpack();
10984
10985 movq RRBP, %rbp;
10986 + pax_force_retaddr 0, 1
10987 ret;
10988 ENDPROC(camellia_dec_blk)
10989
10990 @@ -463,6 +467,7 @@ ENTRY(__camellia_enc_blk_2way)
10991
10992 movq RRBP, %rbp;
10993 popq %rbx;
10994 + pax_force_retaddr 0, 1
10995 ret;
10996
10997 .L__enc2_xor:
10998 @@ -470,6 +475,7 @@ ENTRY(__camellia_enc_blk_2way)
10999
11000 movq RRBP, %rbp;
11001 popq %rbx;
11002 + pax_force_retaddr 0, 1
11003 ret;
11004 ENDPROC(__camellia_enc_blk_2way)
11005
11006 @@ -510,5 +516,6 @@ ENTRY(camellia_dec_blk_2way)
11007
11008 movq RRBP, %rbp;
11009 movq RXOR, %rbx;
11010 + pax_force_retaddr 0, 1
11011 ret;
11012 ENDPROC(camellia_dec_blk_2way)
11013 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11014 index c35fd5d..c1ee236 100644
11015 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11016 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11017 @@ -24,6 +24,7 @@
11018 */
11019
11020 #include <linux/linkage.h>
11021 +#include <asm/alternative-asm.h>
11022
11023 .file "cast5-avx-x86_64-asm_64.S"
11024
11025 @@ -281,6 +282,7 @@ __cast5_enc_blk16:
11026 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11027 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11028
11029 + pax_force_retaddr 0, 1
11030 ret;
11031 ENDPROC(__cast5_enc_blk16)
11032
11033 @@ -352,6 +354,7 @@ __cast5_dec_blk16:
11034 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11035 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11036
11037 + pax_force_retaddr 0, 1
11038 ret;
11039
11040 .L__skip_dec:
11041 @@ -388,6 +391,7 @@ ENTRY(cast5_ecb_enc_16way)
11042 vmovdqu RR4, (6*4*4)(%r11);
11043 vmovdqu RL4, (7*4*4)(%r11);
11044
11045 + pax_force_retaddr
11046 ret;
11047 ENDPROC(cast5_ecb_enc_16way)
11048
11049 @@ -420,6 +424,7 @@ ENTRY(cast5_ecb_dec_16way)
11050 vmovdqu RR4, (6*4*4)(%r11);
11051 vmovdqu RL4, (7*4*4)(%r11);
11052
11053 + pax_force_retaddr
11054 ret;
11055 ENDPROC(cast5_ecb_dec_16way)
11056
11057 @@ -469,6 +474,7 @@ ENTRY(cast5_cbc_dec_16way)
11058
11059 popq %r12;
11060
11061 + pax_force_retaddr
11062 ret;
11063 ENDPROC(cast5_cbc_dec_16way)
11064
11065 @@ -542,5 +548,6 @@ ENTRY(cast5_ctr_16way)
11066
11067 popq %r12;
11068
11069 + pax_force_retaddr
11070 ret;
11071 ENDPROC(cast5_ctr_16way)
11072 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11073 index e3531f8..18ded3a 100644
11074 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11075 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11076 @@ -24,6 +24,7 @@
11077 */
11078
11079 #include <linux/linkage.h>
11080 +#include <asm/alternative-asm.h>
11081 #include "glue_helper-asm-avx.S"
11082
11083 .file "cast6-avx-x86_64-asm_64.S"
11084 @@ -295,6 +296,7 @@ __cast6_enc_blk8:
11085 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11086 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11087
11088 + pax_force_retaddr 0, 1
11089 ret;
11090 ENDPROC(__cast6_enc_blk8)
11091
11092 @@ -340,6 +342,7 @@ __cast6_dec_blk8:
11093 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11094 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11095
11096 + pax_force_retaddr 0, 1
11097 ret;
11098 ENDPROC(__cast6_dec_blk8)
11099
11100 @@ -358,6 +361,7 @@ ENTRY(cast6_ecb_enc_8way)
11101
11102 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11103
11104 + pax_force_retaddr
11105 ret;
11106 ENDPROC(cast6_ecb_enc_8way)
11107
11108 @@ -376,6 +380,7 @@ ENTRY(cast6_ecb_dec_8way)
11109
11110 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11111
11112 + pax_force_retaddr
11113 ret;
11114 ENDPROC(cast6_ecb_dec_8way)
11115
11116 @@ -399,6 +404,7 @@ ENTRY(cast6_cbc_dec_8way)
11117
11118 popq %r12;
11119
11120 + pax_force_retaddr
11121 ret;
11122 ENDPROC(cast6_cbc_dec_8way)
11123
11124 @@ -424,6 +430,7 @@ ENTRY(cast6_ctr_8way)
11125
11126 popq %r12;
11127
11128 + pax_force_retaddr
11129 ret;
11130 ENDPROC(cast6_ctr_8way)
11131
11132 @@ -446,6 +453,7 @@ ENTRY(cast6_xts_enc_8way)
11133 /* dst <= regs xor IVs(in dst) */
11134 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11135
11136 + pax_force_retaddr
11137 ret;
11138 ENDPROC(cast6_xts_enc_8way)
11139
11140 @@ -468,5 +476,6 @@ ENTRY(cast6_xts_dec_8way)
11141 /* dst <= regs xor IVs(in dst) */
11142 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11143
11144 + pax_force_retaddr
11145 ret;
11146 ENDPROC(cast6_xts_dec_8way)
11147 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11148 index 9279e0b..9270820 100644
11149 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
11150 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11151 @@ -1,4 +1,5 @@
11152 #include <linux/linkage.h>
11153 +#include <asm/alternative-asm.h>
11154
11155 # enter salsa20_encrypt_bytes
11156 ENTRY(salsa20_encrypt_bytes)
11157 @@ -789,6 +790,7 @@ ENTRY(salsa20_encrypt_bytes)
11158 add %r11,%rsp
11159 mov %rdi,%rax
11160 mov %rsi,%rdx
11161 + pax_force_retaddr 0, 1
11162 ret
11163 # bytesatleast65:
11164 ._bytesatleast65:
11165 @@ -889,6 +891,7 @@ ENTRY(salsa20_keysetup)
11166 add %r11,%rsp
11167 mov %rdi,%rax
11168 mov %rsi,%rdx
11169 + pax_force_retaddr
11170 ret
11171 ENDPROC(salsa20_keysetup)
11172
11173 @@ -914,5 +917,6 @@ ENTRY(salsa20_ivsetup)
11174 add %r11,%rsp
11175 mov %rdi,%rax
11176 mov %rsi,%rdx
11177 + pax_force_retaddr
11178 ret
11179 ENDPROC(salsa20_ivsetup)
11180 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11181 index 2f202f4..d9164d6 100644
11182 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11183 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11184 @@ -24,6 +24,7 @@
11185 */
11186
11187 #include <linux/linkage.h>
11188 +#include <asm/alternative-asm.h>
11189 #include "glue_helper-asm-avx.S"
11190
11191 .file "serpent-avx-x86_64-asm_64.S"
11192 @@ -618,6 +619,7 @@ __serpent_enc_blk8_avx:
11193 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11194 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11195
11196 + pax_force_retaddr
11197 ret;
11198 ENDPROC(__serpent_enc_blk8_avx)
11199
11200 @@ -672,6 +674,7 @@ __serpent_dec_blk8_avx:
11201 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11202 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11203
11204 + pax_force_retaddr
11205 ret;
11206 ENDPROC(__serpent_dec_blk8_avx)
11207
11208 @@ -688,6 +691,7 @@ ENTRY(serpent_ecb_enc_8way_avx)
11209
11210 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11211
11212 + pax_force_retaddr
11213 ret;
11214 ENDPROC(serpent_ecb_enc_8way_avx)
11215
11216 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_8way_avx)
11217
11218 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11219
11220 + pax_force_retaddr
11221 ret;
11222 ENDPROC(serpent_ecb_dec_8way_avx)
11223
11224 @@ -720,6 +725,7 @@ ENTRY(serpent_cbc_dec_8way_avx)
11225
11226 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11227
11228 + pax_force_retaddr
11229 ret;
11230 ENDPROC(serpent_cbc_dec_8way_avx)
11231
11232 @@ -738,6 +744,7 @@ ENTRY(serpent_ctr_8way_avx)
11233
11234 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11235
11236 + pax_force_retaddr
11237 ret;
11238 ENDPROC(serpent_ctr_8way_avx)
11239
11240 @@ -758,6 +765,7 @@ ENTRY(serpent_xts_enc_8way_avx)
11241 /* dst <= regs xor IVs(in dst) */
11242 store_xts_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11243
11244 + pax_force_retaddr
11245 ret;
11246 ENDPROC(serpent_xts_enc_8way_avx)
11247
11248 @@ -778,5 +786,6 @@ ENTRY(serpent_xts_dec_8way_avx)
11249 /* dst <= regs xor IVs(in dst) */
11250 store_xts_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11251
11252 + pax_force_retaddr
11253 ret;
11254 ENDPROC(serpent_xts_dec_8way_avx)
11255 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11256 index acc066c..1559cc4 100644
11257 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11258 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11259 @@ -25,6 +25,7 @@
11260 */
11261
11262 #include <linux/linkage.h>
11263 +#include <asm/alternative-asm.h>
11264
11265 .file "serpent-sse2-x86_64-asm_64.S"
11266 .text
11267 @@ -690,12 +691,14 @@ ENTRY(__serpent_enc_blk_8way)
11268 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11269 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11270
11271 + pax_force_retaddr
11272 ret;
11273
11274 .L__enc_xor8:
11275 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11276 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11277
11278 + pax_force_retaddr
11279 ret;
11280 ENDPROC(__serpent_enc_blk_8way)
11281
11282 @@ -750,5 +753,6 @@ ENTRY(serpent_dec_blk_8way)
11283 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11284 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11285
11286 + pax_force_retaddr
11287 ret;
11288 ENDPROC(serpent_dec_blk_8way)
11289 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
11290 index a410950..3356d42 100644
11291 --- a/arch/x86/crypto/sha1_ssse3_asm.S
11292 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
11293 @@ -29,6 +29,7 @@
11294 */
11295
11296 #include <linux/linkage.h>
11297 +#include <asm/alternative-asm.h>
11298
11299 #define CTX %rdi // arg1
11300 #define BUF %rsi // arg2
11301 @@ -104,6 +105,7 @@
11302 pop %r12
11303 pop %rbp
11304 pop %rbx
11305 + pax_force_retaddr 0, 1
11306 ret
11307
11308 ENDPROC(\name)
11309 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11310 index 0505813..63b1d00 100644
11311 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11312 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
11313 @@ -24,6 +24,7 @@
11314 */
11315
11316 #include <linux/linkage.h>
11317 +#include <asm/alternative-asm.h>
11318 #include "glue_helper-asm-avx.S"
11319
11320 .file "twofish-avx-x86_64-asm_64.S"
11321 @@ -284,6 +285,7 @@ __twofish_enc_blk8:
11322 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
11323 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
11324
11325 + pax_force_retaddr 0, 1
11326 ret;
11327 ENDPROC(__twofish_enc_blk8)
11328
11329 @@ -324,6 +326,7 @@ __twofish_dec_blk8:
11330 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
11331 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
11332
11333 + pax_force_retaddr 0, 1
11334 ret;
11335 ENDPROC(__twofish_dec_blk8)
11336
11337 @@ -342,6 +345,7 @@ ENTRY(twofish_ecb_enc_8way)
11338
11339 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
11340
11341 + pax_force_retaddr 0, 1
11342 ret;
11343 ENDPROC(twofish_ecb_enc_8way)
11344
11345 @@ -360,6 +364,7 @@ ENTRY(twofish_ecb_dec_8way)
11346
11347 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11348
11349 + pax_force_retaddr 0, 1
11350 ret;
11351 ENDPROC(twofish_ecb_dec_8way)
11352
11353 @@ -383,6 +388,7 @@ ENTRY(twofish_cbc_dec_8way)
11354
11355 popq %r12;
11356
11357 + pax_force_retaddr 0, 1
11358 ret;
11359 ENDPROC(twofish_cbc_dec_8way)
11360
11361 @@ -408,6 +414,7 @@ ENTRY(twofish_ctr_8way)
11362
11363 popq %r12;
11364
11365 + pax_force_retaddr 0, 1
11366 ret;
11367 ENDPROC(twofish_ctr_8way)
11368
11369 @@ -430,6 +437,7 @@ ENTRY(twofish_xts_enc_8way)
11370 /* dst <= regs xor IVs(in dst) */
11371 store_xts_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
11372
11373 + pax_force_retaddr 0, 1
11374 ret;
11375 ENDPROC(twofish_xts_enc_8way)
11376
11377 @@ -452,5 +460,6 @@ ENTRY(twofish_xts_dec_8way)
11378 /* dst <= regs xor IVs(in dst) */
11379 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11380
11381 + pax_force_retaddr 0, 1
11382 ret;
11383 ENDPROC(twofish_xts_dec_8way)
11384 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11385 index 1c3b7ce..b365c5e 100644
11386 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11387 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
11388 @@ -21,6 +21,7 @@
11389 */
11390
11391 #include <linux/linkage.h>
11392 +#include <asm/alternative-asm.h>
11393
11394 .file "twofish-x86_64-asm-3way.S"
11395 .text
11396 @@ -258,6 +259,7 @@ ENTRY(__twofish_enc_blk_3way)
11397 popq %r13;
11398 popq %r14;
11399 popq %r15;
11400 + pax_force_retaddr 0, 1
11401 ret;
11402
11403 .L__enc_xor3:
11404 @@ -269,6 +271,7 @@ ENTRY(__twofish_enc_blk_3way)
11405 popq %r13;
11406 popq %r14;
11407 popq %r15;
11408 + pax_force_retaddr 0, 1
11409 ret;
11410 ENDPROC(__twofish_enc_blk_3way)
11411
11412 @@ -308,5 +311,6 @@ ENTRY(twofish_dec_blk_3way)
11413 popq %r13;
11414 popq %r14;
11415 popq %r15;
11416 + pax_force_retaddr 0, 1
11417 ret;
11418 ENDPROC(twofish_dec_blk_3way)
11419 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
11420 index a039d21..29e7615 100644
11421 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
11422 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
11423 @@ -22,6 +22,7 @@
11424
11425 #include <linux/linkage.h>
11426 #include <asm/asm-offsets.h>
11427 +#include <asm/alternative-asm.h>
11428
11429 #define a_offset 0
11430 #define b_offset 4
11431 @@ -265,6 +266,7 @@ ENTRY(twofish_enc_blk)
11432
11433 popq R1
11434 movq $1,%rax
11435 + pax_force_retaddr 0, 1
11436 ret
11437 ENDPROC(twofish_enc_blk)
11438
11439 @@ -317,5 +319,6 @@ ENTRY(twofish_dec_blk)
11440
11441 popq R1
11442 movq $1,%rax
11443 + pax_force_retaddr 0, 1
11444 ret
11445 ENDPROC(twofish_dec_blk)
11446 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
11447 index 52ff81c..98af645 100644
11448 --- a/arch/x86/ia32/ia32_aout.c
11449 +++ b/arch/x86/ia32/ia32_aout.c
11450 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
11451 unsigned long dump_start, dump_size;
11452 struct user32 dump;
11453
11454 + memset(&dump, 0, sizeof(dump));
11455 +
11456 fs = get_fs();
11457 set_fs(KERNEL_DS);
11458 has_dumped = 1;
11459 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
11460 index cf1a471..3bc4cf8 100644
11461 --- a/arch/x86/ia32/ia32_signal.c
11462 +++ b/arch/x86/ia32/ia32_signal.c
11463 @@ -340,7 +340,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
11464 sp -= frame_size;
11465 /* Align the stack pointer according to the i386 ABI,
11466 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
11467 - sp = ((sp + 4) & -16ul) - 4;
11468 + sp = ((sp - 12) & -16ul) - 4;
11469 return (void __user *) sp;
11470 }
11471
11472 @@ -398,7 +398,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
11473 * These are actually not used anymore, but left because some
11474 * gdb versions depend on them as a marker.
11475 */
11476 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11477 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11478 } put_user_catch(err);
11479
11480 if (err)
11481 @@ -440,7 +440,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
11482 0xb8,
11483 __NR_ia32_rt_sigreturn,
11484 0x80cd,
11485 - 0,
11486 + 0
11487 };
11488
11489 frame = get_sigframe(ksig, regs, sizeof(*frame), &fpstate);
11490 @@ -463,16 +463,18 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
11491
11492 if (ksig->ka.sa.sa_flags & SA_RESTORER)
11493 restorer = ksig->ka.sa.sa_restorer;
11494 + else if (current->mm->context.vdso)
11495 + /* Return stub is in 32bit vsyscall page */
11496 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
11497 else
11498 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
11499 - rt_sigreturn);
11500 + restorer = &frame->retcode;
11501 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
11502
11503 /*
11504 * Not actually used anymore, but left because some gdb
11505 * versions need it.
11506 */
11507 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
11508 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
11509 } put_user_catch(err);
11510
11511 err |= copy_siginfo_to_user32(&frame->info, &ksig->info);
11512 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
11513 index 474dc1b..24aaa3e 100644
11514 --- a/arch/x86/ia32/ia32entry.S
11515 +++ b/arch/x86/ia32/ia32entry.S
11516 @@ -15,8 +15,10 @@
11517 #include <asm/irqflags.h>
11518 #include <asm/asm.h>
11519 #include <asm/smap.h>
11520 +#include <asm/pgtable.h>
11521 #include <linux/linkage.h>
11522 #include <linux/err.h>
11523 +#include <asm/alternative-asm.h>
11524
11525 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
11526 #include <linux/elf-em.h>
11527 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
11528 ENDPROC(native_irq_enable_sysexit)
11529 #endif
11530
11531 + .macro pax_enter_kernel_user
11532 + pax_set_fptr_mask
11533 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11534 + call pax_enter_kernel_user
11535 +#endif
11536 + .endm
11537 +
11538 + .macro pax_exit_kernel_user
11539 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11540 + call pax_exit_kernel_user
11541 +#endif
11542 +#ifdef CONFIG_PAX_RANDKSTACK
11543 + pushq %rax
11544 + pushq %r11
11545 + call pax_randomize_kstack
11546 + popq %r11
11547 + popq %rax
11548 +#endif
11549 + .endm
11550 +
11551 + .macro pax_erase_kstack
11552 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
11553 + call pax_erase_kstack
11554 +#endif
11555 + .endm
11556 +
11557 /*
11558 * 32bit SYSENTER instruction entry.
11559 *
11560 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
11561 CFI_REGISTER rsp,rbp
11562 SWAPGS_UNSAFE_STACK
11563 movq PER_CPU_VAR(kernel_stack), %rsp
11564 - addq $(KERNEL_STACK_OFFSET),%rsp
11565 - /*
11566 - * No need to follow this irqs on/off section: the syscall
11567 - * disabled irqs, here we enable it straight after entry:
11568 - */
11569 - ENABLE_INTERRUPTS(CLBR_NONE)
11570 movl %ebp,%ebp /* zero extension */
11571 pushq_cfi $__USER32_DS
11572 /*CFI_REL_OFFSET ss,0*/
11573 @@ -135,24 +157,44 @@ ENTRY(ia32_sysenter_target)
11574 CFI_REL_OFFSET rsp,0
11575 pushfq_cfi
11576 /*CFI_REL_OFFSET rflags,0*/
11577 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
11578 - CFI_REGISTER rip,r10
11579 + orl $X86_EFLAGS_IF,(%rsp)
11580 + GET_THREAD_INFO(%r11)
11581 + movl TI_sysenter_return(%r11), %r11d
11582 + CFI_REGISTER rip,r11
11583 pushq_cfi $__USER32_CS
11584 /*CFI_REL_OFFSET cs,0*/
11585 movl %eax, %eax
11586 - pushq_cfi %r10
11587 + pushq_cfi %r11
11588 CFI_REL_OFFSET rip,0
11589 pushq_cfi %rax
11590 cld
11591 SAVE_ARGS 0,1,0
11592 + pax_enter_kernel_user
11593 +
11594 +#ifdef CONFIG_PAX_RANDKSTACK
11595 + pax_erase_kstack
11596 +#endif
11597 +
11598 + /*
11599 + * No need to follow this irqs on/off section: the syscall
11600 + * disabled irqs, here we enable it straight after entry:
11601 + */
11602 + ENABLE_INTERRUPTS(CLBR_NONE)
11603 /* no need to do an access_ok check here because rbp has been
11604 32bit zero extended */
11605 +
11606 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11607 + mov pax_user_shadow_base,%r11
11608 + add %r11,%rbp
11609 +#endif
11610 +
11611 ASM_STAC
11612 1: movl (%rbp),%ebp
11613 _ASM_EXTABLE(1b,ia32_badarg)
11614 ASM_CLAC
11615 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11616 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11617 + GET_THREAD_INFO(%r11)
11618 + orl $TS_COMPAT,TI_status(%r11)
11619 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11620 CFI_REMEMBER_STATE
11621 jnz sysenter_tracesys
11622 cmpq $(IA32_NR_syscalls-1),%rax
11623 @@ -162,12 +204,15 @@ sysenter_do_call:
11624 sysenter_dispatch:
11625 call *ia32_sys_call_table(,%rax,8)
11626 movq %rax,RAX-ARGOFFSET(%rsp)
11627 + GET_THREAD_INFO(%r11)
11628 DISABLE_INTERRUPTS(CLBR_NONE)
11629 TRACE_IRQS_OFF
11630 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11631 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
11632 jnz sysexit_audit
11633 sysexit_from_sys_call:
11634 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11635 + pax_exit_kernel_user
11636 + pax_erase_kstack
11637 + andl $~TS_COMPAT,TI_status(%r11)
11638 /* clear IF, that popfq doesn't enable interrupts early */
11639 andl $~0x200,EFLAGS-R11(%rsp)
11640 movl RIP-R11(%rsp),%edx /* User %eip */
11641 @@ -193,6 +238,9 @@ sysexit_from_sys_call:
11642 movl %eax,%esi /* 2nd arg: syscall number */
11643 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
11644 call __audit_syscall_entry
11645 +
11646 + pax_erase_kstack
11647 +
11648 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
11649 cmpq $(IA32_NR_syscalls-1),%rax
11650 ja ia32_badsys
11651 @@ -204,7 +252,7 @@ sysexit_from_sys_call:
11652 .endm
11653
11654 .macro auditsys_exit exit
11655 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11656 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11657 jnz ia32_ret_from_sys_call
11658 TRACE_IRQS_ON
11659 ENABLE_INTERRUPTS(CLBR_NONE)
11660 @@ -215,11 +263,12 @@ sysexit_from_sys_call:
11661 1: setbe %al /* 1 if error, 0 if not */
11662 movzbl %al,%edi /* zero-extend that into %edi */
11663 call __audit_syscall_exit
11664 + GET_THREAD_INFO(%r11)
11665 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
11666 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
11667 DISABLE_INTERRUPTS(CLBR_NONE)
11668 TRACE_IRQS_OFF
11669 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11670 + testl %edi,TI_flags(%r11)
11671 jz \exit
11672 CLEAR_RREGS -ARGOFFSET
11673 jmp int_with_check
11674 @@ -237,7 +286,7 @@ sysexit_audit:
11675
11676 sysenter_tracesys:
11677 #ifdef CONFIG_AUDITSYSCALL
11678 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11679 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11680 jz sysenter_auditsys
11681 #endif
11682 SAVE_REST
11683 @@ -249,6 +298,9 @@ sysenter_tracesys:
11684 RESTORE_REST
11685 cmpq $(IA32_NR_syscalls-1),%rax
11686 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
11687 +
11688 + pax_erase_kstack
11689 +
11690 jmp sysenter_do_call
11691 CFI_ENDPROC
11692 ENDPROC(ia32_sysenter_target)
11693 @@ -276,19 +328,25 @@ ENDPROC(ia32_sysenter_target)
11694 ENTRY(ia32_cstar_target)
11695 CFI_STARTPROC32 simple
11696 CFI_SIGNAL_FRAME
11697 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
11698 + CFI_DEF_CFA rsp,0
11699 CFI_REGISTER rip,rcx
11700 /*CFI_REGISTER rflags,r11*/
11701 SWAPGS_UNSAFE_STACK
11702 movl %esp,%r8d
11703 CFI_REGISTER rsp,r8
11704 movq PER_CPU_VAR(kernel_stack),%rsp
11705 + SAVE_ARGS 8*6,0,0
11706 + pax_enter_kernel_user
11707 +
11708 +#ifdef CONFIG_PAX_RANDKSTACK
11709 + pax_erase_kstack
11710 +#endif
11711 +
11712 /*
11713 * No need to follow this irqs on/off section: the syscall
11714 * disabled irqs and here we enable it straight after entry:
11715 */
11716 ENABLE_INTERRUPTS(CLBR_NONE)
11717 - SAVE_ARGS 8,0,0
11718 movl %eax,%eax /* zero extension */
11719 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
11720 movq %rcx,RIP-ARGOFFSET(%rsp)
11721 @@ -304,12 +362,19 @@ ENTRY(ia32_cstar_target)
11722 /* no need to do an access_ok check here because r8 has been
11723 32bit zero extended */
11724 /* hardware stack frame is complete now */
11725 +
11726 +#ifdef CONFIG_PAX_MEMORY_UDEREF
11727 + mov pax_user_shadow_base,%r11
11728 + add %r11,%r8
11729 +#endif
11730 +
11731 ASM_STAC
11732 1: movl (%r8),%r9d
11733 _ASM_EXTABLE(1b,ia32_badarg)
11734 ASM_CLAC
11735 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11736 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11737 + GET_THREAD_INFO(%r11)
11738 + orl $TS_COMPAT,TI_status(%r11)
11739 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11740 CFI_REMEMBER_STATE
11741 jnz cstar_tracesys
11742 cmpq $IA32_NR_syscalls-1,%rax
11743 @@ -319,12 +384,15 @@ cstar_do_call:
11744 cstar_dispatch:
11745 call *ia32_sys_call_table(,%rax,8)
11746 movq %rax,RAX-ARGOFFSET(%rsp)
11747 + GET_THREAD_INFO(%r11)
11748 DISABLE_INTERRUPTS(CLBR_NONE)
11749 TRACE_IRQS_OFF
11750 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11751 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
11752 jnz sysretl_audit
11753 sysretl_from_sys_call:
11754 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11755 + pax_exit_kernel_user
11756 + pax_erase_kstack
11757 + andl $~TS_COMPAT,TI_status(%r11)
11758 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
11759 movl RIP-ARGOFFSET(%rsp),%ecx
11760 CFI_REGISTER rip,rcx
11761 @@ -352,7 +420,7 @@ sysretl_audit:
11762
11763 cstar_tracesys:
11764 #ifdef CONFIG_AUDITSYSCALL
11765 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11766 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
11767 jz cstar_auditsys
11768 #endif
11769 xchgl %r9d,%ebp
11770 @@ -366,6 +434,9 @@ cstar_tracesys:
11771 xchgl %ebp,%r9d
11772 cmpq $(IA32_NR_syscalls-1),%rax
11773 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
11774 +
11775 + pax_erase_kstack
11776 +
11777 jmp cstar_do_call
11778 END(ia32_cstar_target)
11779
11780 @@ -407,19 +478,26 @@ ENTRY(ia32_syscall)
11781 CFI_REL_OFFSET rip,RIP-RIP
11782 PARAVIRT_ADJUST_EXCEPTION_FRAME
11783 SWAPGS
11784 - /*
11785 - * No need to follow this irqs on/off section: the syscall
11786 - * disabled irqs and here we enable it straight after entry:
11787 - */
11788 - ENABLE_INTERRUPTS(CLBR_NONE)
11789 movl %eax,%eax
11790 pushq_cfi %rax
11791 cld
11792 /* note the registers are not zero extended to the sf.
11793 this could be a problem. */
11794 SAVE_ARGS 0,1,0
11795 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11796 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
11797 + pax_enter_kernel_user
11798 +
11799 +#ifdef CONFIG_PAX_RANDKSTACK
11800 + pax_erase_kstack
11801 +#endif
11802 +
11803 + /*
11804 + * No need to follow this irqs on/off section: the syscall
11805 + * disabled irqs and here we enable it straight after entry:
11806 + */
11807 + ENABLE_INTERRUPTS(CLBR_NONE)
11808 + GET_THREAD_INFO(%r11)
11809 + orl $TS_COMPAT,TI_status(%r11)
11810 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
11811 jnz ia32_tracesys
11812 cmpq $(IA32_NR_syscalls-1),%rax
11813 ja ia32_badsys
11814 @@ -442,6 +520,9 @@ ia32_tracesys:
11815 RESTORE_REST
11816 cmpq $(IA32_NR_syscalls-1),%rax
11817 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
11818 +
11819 + pax_erase_kstack
11820 +
11821 jmp ia32_do_call
11822 END(ia32_syscall)
11823
11824 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
11825 index 8e0ceec..af13504 100644
11826 --- a/arch/x86/ia32/sys_ia32.c
11827 +++ b/arch/x86/ia32/sys_ia32.c
11828 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
11829 */
11830 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
11831 {
11832 - typeof(ubuf->st_uid) uid = 0;
11833 - typeof(ubuf->st_gid) gid = 0;
11834 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
11835 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
11836 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
11837 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
11838 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
11839 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
11840 index 372231c..a5aa1a1 100644
11841 --- a/arch/x86/include/asm/alternative-asm.h
11842 +++ b/arch/x86/include/asm/alternative-asm.h
11843 @@ -18,6 +18,45 @@
11844 .endm
11845 #endif
11846
11847 +#ifdef KERNEXEC_PLUGIN
11848 + .macro pax_force_retaddr_bts rip=0
11849 + btsq $63,\rip(%rsp)
11850 + .endm
11851 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
11852 + .macro pax_force_retaddr rip=0, reload=0
11853 + btsq $63,\rip(%rsp)
11854 + .endm
11855 + .macro pax_force_fptr ptr
11856 + btsq $63,\ptr
11857 + .endm
11858 + .macro pax_set_fptr_mask
11859 + .endm
11860 +#endif
11861 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
11862 + .macro pax_force_retaddr rip=0, reload=0
11863 + .if \reload
11864 + pax_set_fptr_mask
11865 + .endif
11866 + orq %r10,\rip(%rsp)
11867 + .endm
11868 + .macro pax_force_fptr ptr
11869 + orq %r10,\ptr
11870 + .endm
11871 + .macro pax_set_fptr_mask
11872 + movabs $0x8000000000000000,%r10
11873 + .endm
11874 +#endif
11875 +#else
11876 + .macro pax_force_retaddr rip=0, reload=0
11877 + .endm
11878 + .macro pax_force_fptr ptr
11879 + .endm
11880 + .macro pax_force_retaddr_bts rip=0
11881 + .endm
11882 + .macro pax_set_fptr_mask
11883 + .endm
11884 +#endif
11885 +
11886 .macro altinstruction_entry orig alt feature orig_len alt_len
11887 .long \orig - .
11888 .long \alt - .
11889 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
11890 index 58ed6d9..f1cbe58 100644
11891 --- a/arch/x86/include/asm/alternative.h
11892 +++ b/arch/x86/include/asm/alternative.h
11893 @@ -105,7 +105,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
11894 ".pushsection .discard,\"aw\",@progbits\n" \
11895 DISCARD_ENTRY(1) \
11896 ".popsection\n" \
11897 - ".pushsection .altinstr_replacement, \"ax\"\n" \
11898 + ".pushsection .altinstr_replacement, \"a\"\n" \
11899 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
11900 ".popsection"
11901
11902 @@ -119,7 +119,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
11903 DISCARD_ENTRY(1) \
11904 DISCARD_ENTRY(2) \
11905 ".popsection\n" \
11906 - ".pushsection .altinstr_replacement, \"ax\"\n" \
11907 + ".pushsection .altinstr_replacement, \"a\"\n" \
11908 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
11909 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
11910 ".popsection"
11911 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
11912 index 3388034..050f0b9 100644
11913 --- a/arch/x86/include/asm/apic.h
11914 +++ b/arch/x86/include/asm/apic.h
11915 @@ -44,7 +44,7 @@ static inline void generic_apic_probe(void)
11916
11917 #ifdef CONFIG_X86_LOCAL_APIC
11918
11919 -extern unsigned int apic_verbosity;
11920 +extern int apic_verbosity;
11921 extern int local_apic_timer_c2_ok;
11922
11923 extern int disable_apic;
11924 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
11925 index 20370c6..a2eb9b0 100644
11926 --- a/arch/x86/include/asm/apm.h
11927 +++ b/arch/x86/include/asm/apm.h
11928 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
11929 __asm__ __volatile__(APM_DO_ZERO_SEGS
11930 "pushl %%edi\n\t"
11931 "pushl %%ebp\n\t"
11932 - "lcall *%%cs:apm_bios_entry\n\t"
11933 + "lcall *%%ss:apm_bios_entry\n\t"
11934 "setc %%al\n\t"
11935 "popl %%ebp\n\t"
11936 "popl %%edi\n\t"
11937 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
11938 __asm__ __volatile__(APM_DO_ZERO_SEGS
11939 "pushl %%edi\n\t"
11940 "pushl %%ebp\n\t"
11941 - "lcall *%%cs:apm_bios_entry\n\t"
11942 + "lcall *%%ss:apm_bios_entry\n\t"
11943 "setc %%bl\n\t"
11944 "popl %%ebp\n\t"
11945 "popl %%edi\n\t"
11946 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
11947 index 722aa3b..3a0bb27 100644
11948 --- a/arch/x86/include/asm/atomic.h
11949 +++ b/arch/x86/include/asm/atomic.h
11950 @@ -22,7 +22,18 @@
11951 */
11952 static inline int atomic_read(const atomic_t *v)
11953 {
11954 - return (*(volatile int *)&(v)->counter);
11955 + return (*(volatile const int *)&(v)->counter);
11956 +}
11957 +
11958 +/**
11959 + * atomic_read_unchecked - read atomic variable
11960 + * @v: pointer of type atomic_unchecked_t
11961 + *
11962 + * Atomically reads the value of @v.
11963 + */
11964 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
11965 +{
11966 + return (*(volatile const int *)&(v)->counter);
11967 }
11968
11969 /**
11970 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
11971 }
11972
11973 /**
11974 + * atomic_set_unchecked - set atomic variable
11975 + * @v: pointer of type atomic_unchecked_t
11976 + * @i: required value
11977 + *
11978 + * Atomically sets the value of @v to @i.
11979 + */
11980 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
11981 +{
11982 + v->counter = i;
11983 +}
11984 +
11985 +/**
11986 * atomic_add - add integer to atomic variable
11987 * @i: integer value to add
11988 * @v: pointer of type atomic_t
11989 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
11990 */
11991 static inline void atomic_add(int i, atomic_t *v)
11992 {
11993 - asm volatile(LOCK_PREFIX "addl %1,%0"
11994 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
11995 +
11996 +#ifdef CONFIG_PAX_REFCOUNT
11997 + "jno 0f\n"
11998 + LOCK_PREFIX "subl %1,%0\n"
11999 + "int $4\n0:\n"
12000 + _ASM_EXTABLE(0b, 0b)
12001 +#endif
12002 +
12003 + : "+m" (v->counter)
12004 + : "ir" (i));
12005 +}
12006 +
12007 +/**
12008 + * atomic_add_unchecked - add integer to atomic variable
12009 + * @i: integer value to add
12010 + * @v: pointer of type atomic_unchecked_t
12011 + *
12012 + * Atomically adds @i to @v.
12013 + */
12014 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
12015 +{
12016 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
12017 : "+m" (v->counter)
12018 : "ir" (i));
12019 }
12020 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
12021 */
12022 static inline void atomic_sub(int i, atomic_t *v)
12023 {
12024 - asm volatile(LOCK_PREFIX "subl %1,%0"
12025 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
12026 +
12027 +#ifdef CONFIG_PAX_REFCOUNT
12028 + "jno 0f\n"
12029 + LOCK_PREFIX "addl %1,%0\n"
12030 + "int $4\n0:\n"
12031 + _ASM_EXTABLE(0b, 0b)
12032 +#endif
12033 +
12034 + : "+m" (v->counter)
12035 + : "ir" (i));
12036 +}
12037 +
12038 +/**
12039 + * atomic_sub_unchecked - subtract integer from atomic variable
12040 + * @i: integer value to subtract
12041 + * @v: pointer of type atomic_unchecked_t
12042 + *
12043 + * Atomically subtracts @i from @v.
12044 + */
12045 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
12046 +{
12047 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
12048 : "+m" (v->counter)
12049 : "ir" (i));
12050 }
12051 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12052 {
12053 unsigned char c;
12054
12055 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
12056 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
12057 +
12058 +#ifdef CONFIG_PAX_REFCOUNT
12059 + "jno 0f\n"
12060 + LOCK_PREFIX "addl %2,%0\n"
12061 + "int $4\n0:\n"
12062 + _ASM_EXTABLE(0b, 0b)
12063 +#endif
12064 +
12065 + "sete %1\n"
12066 : "+m" (v->counter), "=qm" (c)
12067 : "ir" (i) : "memory");
12068 return c;
12069 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12070 */
12071 static inline void atomic_inc(atomic_t *v)
12072 {
12073 - asm volatile(LOCK_PREFIX "incl %0"
12074 + asm volatile(LOCK_PREFIX "incl %0\n"
12075 +
12076 +#ifdef CONFIG_PAX_REFCOUNT
12077 + "jno 0f\n"
12078 + LOCK_PREFIX "decl %0\n"
12079 + "int $4\n0:\n"
12080 + _ASM_EXTABLE(0b, 0b)
12081 +#endif
12082 +
12083 + : "+m" (v->counter));
12084 +}
12085 +
12086 +/**
12087 + * atomic_inc_unchecked - increment atomic variable
12088 + * @v: pointer of type atomic_unchecked_t
12089 + *
12090 + * Atomically increments @v by 1.
12091 + */
12092 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
12093 +{
12094 + asm volatile(LOCK_PREFIX "incl %0\n"
12095 : "+m" (v->counter));
12096 }
12097
12098 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
12099 */
12100 static inline void atomic_dec(atomic_t *v)
12101 {
12102 - asm volatile(LOCK_PREFIX "decl %0"
12103 + asm volatile(LOCK_PREFIX "decl %0\n"
12104 +
12105 +#ifdef CONFIG_PAX_REFCOUNT
12106 + "jno 0f\n"
12107 + LOCK_PREFIX "incl %0\n"
12108 + "int $4\n0:\n"
12109 + _ASM_EXTABLE(0b, 0b)
12110 +#endif
12111 +
12112 + : "+m" (v->counter));
12113 +}
12114 +
12115 +/**
12116 + * atomic_dec_unchecked - decrement atomic variable
12117 + * @v: pointer of type atomic_unchecked_t
12118 + *
12119 + * Atomically decrements @v by 1.
12120 + */
12121 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
12122 +{
12123 + asm volatile(LOCK_PREFIX "decl %0\n"
12124 : "+m" (v->counter));
12125 }
12126
12127 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
12128 {
12129 unsigned char c;
12130
12131 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
12132 + asm volatile(LOCK_PREFIX "decl %0\n"
12133 +
12134 +#ifdef CONFIG_PAX_REFCOUNT
12135 + "jno 0f\n"
12136 + LOCK_PREFIX "incl %0\n"
12137 + "int $4\n0:\n"
12138 + _ASM_EXTABLE(0b, 0b)
12139 +#endif
12140 +
12141 + "sete %1\n"
12142 : "+m" (v->counter), "=qm" (c)
12143 : : "memory");
12144 return c != 0;
12145 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
12146 {
12147 unsigned char c;
12148
12149 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
12150 + asm volatile(LOCK_PREFIX "incl %0\n"
12151 +
12152 +#ifdef CONFIG_PAX_REFCOUNT
12153 + "jno 0f\n"
12154 + LOCK_PREFIX "decl %0\n"
12155 + "int $4\n0:\n"
12156 + _ASM_EXTABLE(0b, 0b)
12157 +#endif
12158 +
12159 + "sete %1\n"
12160 + : "+m" (v->counter), "=qm" (c)
12161 + : : "memory");
12162 + return c != 0;
12163 +}
12164 +
12165 +/**
12166 + * atomic_inc_and_test_unchecked - increment and test
12167 + * @v: pointer of type atomic_unchecked_t
12168 + *
12169 + * Atomically increments @v by 1
12170 + * and returns true if the result is zero, or false for all
12171 + * other cases.
12172 + */
12173 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
12174 +{
12175 + unsigned char c;
12176 +
12177 + asm volatile(LOCK_PREFIX "incl %0\n"
12178 + "sete %1\n"
12179 : "+m" (v->counter), "=qm" (c)
12180 : : "memory");
12181 return c != 0;
12182 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12183 {
12184 unsigned char c;
12185
12186 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
12187 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
12188 +
12189 +#ifdef CONFIG_PAX_REFCOUNT
12190 + "jno 0f\n"
12191 + LOCK_PREFIX "subl %2,%0\n"
12192 + "int $4\n0:\n"
12193 + _ASM_EXTABLE(0b, 0b)
12194 +#endif
12195 +
12196 + "sets %1\n"
12197 : "+m" (v->counter), "=qm" (c)
12198 : "ir" (i) : "memory");
12199 return c;
12200 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
12201 */
12202 static inline int atomic_add_return(int i, atomic_t *v)
12203 {
12204 + return i + xadd_check_overflow(&v->counter, i);
12205 +}
12206 +
12207 +/**
12208 + * atomic_add_return_unchecked - add integer and return
12209 + * @i: integer value to add
12210 + * @v: pointer of type atomic_unchecked_t
12211 + *
12212 + * Atomically adds @i to @v and returns @i + @v
12213 + */
12214 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
12215 +{
12216 return i + xadd(&v->counter, i);
12217 }
12218
12219 @@ -188,6 +362,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
12220 }
12221
12222 #define atomic_inc_return(v) (atomic_add_return(1, v))
12223 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
12224 +{
12225 + return atomic_add_return_unchecked(1, v);
12226 +}
12227 #define atomic_dec_return(v) (atomic_sub_return(1, v))
12228
12229 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12230 @@ -195,11 +373,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
12231 return cmpxchg(&v->counter, old, new);
12232 }
12233
12234 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
12235 +{
12236 + return cmpxchg(&v->counter, old, new);
12237 +}
12238 +
12239 static inline int atomic_xchg(atomic_t *v, int new)
12240 {
12241 return xchg(&v->counter, new);
12242 }
12243
12244 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
12245 +{
12246 + return xchg(&v->counter, new);
12247 +}
12248 +
12249 /**
12250 * __atomic_add_unless - add unless the number is already a given value
12251 * @v: pointer of type atomic_t
12252 @@ -211,12 +399,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
12253 */
12254 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12255 {
12256 - int c, old;
12257 + int c, old, new;
12258 c = atomic_read(v);
12259 for (;;) {
12260 - if (unlikely(c == (u)))
12261 + if (unlikely(c == u))
12262 break;
12263 - old = atomic_cmpxchg((v), c, c + (a));
12264 +
12265 + asm volatile("addl %2,%0\n"
12266 +
12267 +#ifdef CONFIG_PAX_REFCOUNT
12268 + "jno 0f\n"
12269 + "subl %2,%0\n"
12270 + "int $4\n0:\n"
12271 + _ASM_EXTABLE(0b, 0b)
12272 +#endif
12273 +
12274 + : "=r" (new)
12275 + : "0" (c), "ir" (a));
12276 +
12277 + old = atomic_cmpxchg(v, c, new);
12278 if (likely(old == c))
12279 break;
12280 c = old;
12281 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
12282 }
12283
12284 /**
12285 + * atomic_inc_not_zero_hint - increment if not null
12286 + * @v: pointer of type atomic_t
12287 + * @hint: probable value of the atomic before the increment
12288 + *
12289 + * This version of atomic_inc_not_zero() gives a hint of probable
12290 + * value of the atomic. This helps processor to not read the memory
12291 + * before doing the atomic read/modify/write cycle, lowering
12292 + * number of bus transactions on some arches.
12293 + *
12294 + * Returns: 0 if increment was not done, 1 otherwise.
12295 + */
12296 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
12297 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
12298 +{
12299 + int val, c = hint, new;
12300 +
12301 + /* sanity test, should be removed by compiler if hint is a constant */
12302 + if (!hint)
12303 + return __atomic_add_unless(v, 1, 0);
12304 +
12305 + do {
12306 + asm volatile("incl %0\n"
12307 +
12308 +#ifdef CONFIG_PAX_REFCOUNT
12309 + "jno 0f\n"
12310 + "decl %0\n"
12311 + "int $4\n0:\n"
12312 + _ASM_EXTABLE(0b, 0b)
12313 +#endif
12314 +
12315 + : "=r" (new)
12316 + : "0" (c));
12317 +
12318 + val = atomic_cmpxchg(v, c, new);
12319 + if (val == c)
12320 + return 1;
12321 + c = val;
12322 + } while (c);
12323 +
12324 + return 0;
12325 +}
12326 +
12327 +/**
12328 * atomic_inc_short - increment of a short integer
12329 * @v: pointer to type int
12330 *
12331 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
12332 #endif
12333
12334 /* These are x86-specific, used by some header files */
12335 -#define atomic_clear_mask(mask, addr) \
12336 - asm volatile(LOCK_PREFIX "andl %0,%1" \
12337 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
12338 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
12339 +{
12340 + asm volatile(LOCK_PREFIX "andl %1,%0"
12341 + : "+m" (v->counter)
12342 + : "r" (~(mask))
12343 + : "memory");
12344 +}
12345
12346 -#define atomic_set_mask(mask, addr) \
12347 - asm volatile(LOCK_PREFIX "orl %0,%1" \
12348 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
12349 - : "memory")
12350 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12351 +{
12352 + asm volatile(LOCK_PREFIX "andl %1,%0"
12353 + : "+m" (v->counter)
12354 + : "r" (~(mask))
12355 + : "memory");
12356 +}
12357 +
12358 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
12359 +{
12360 + asm volatile(LOCK_PREFIX "orl %1,%0"
12361 + : "+m" (v->counter)
12362 + : "r" (mask)
12363 + : "memory");
12364 +}
12365 +
12366 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
12367 +{
12368 + asm volatile(LOCK_PREFIX "orl %1,%0"
12369 + : "+m" (v->counter)
12370 + : "r" (mask)
12371 + : "memory");
12372 +}
12373
12374 /* Atomic operations are already serializing on x86 */
12375 #define smp_mb__before_atomic_dec() barrier()
12376 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
12377 index b154de7..aadebd8 100644
12378 --- a/arch/x86/include/asm/atomic64_32.h
12379 +++ b/arch/x86/include/asm/atomic64_32.h
12380 @@ -12,6 +12,14 @@ typedef struct {
12381 u64 __aligned(8) counter;
12382 } atomic64_t;
12383
12384 +#ifdef CONFIG_PAX_REFCOUNT
12385 +typedef struct {
12386 + u64 __aligned(8) counter;
12387 +} atomic64_unchecked_t;
12388 +#else
12389 +typedef atomic64_t atomic64_unchecked_t;
12390 +#endif
12391 +
12392 #define ATOMIC64_INIT(val) { (val) }
12393
12394 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
12395 @@ -37,21 +45,31 @@ typedef struct {
12396 ATOMIC64_DECL_ONE(sym##_386)
12397
12398 ATOMIC64_DECL_ONE(add_386);
12399 +ATOMIC64_DECL_ONE(add_unchecked_386);
12400 ATOMIC64_DECL_ONE(sub_386);
12401 +ATOMIC64_DECL_ONE(sub_unchecked_386);
12402 ATOMIC64_DECL_ONE(inc_386);
12403 +ATOMIC64_DECL_ONE(inc_unchecked_386);
12404 ATOMIC64_DECL_ONE(dec_386);
12405 +ATOMIC64_DECL_ONE(dec_unchecked_386);
12406 #endif
12407
12408 #define alternative_atomic64(f, out, in...) \
12409 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
12410
12411 ATOMIC64_DECL(read);
12412 +ATOMIC64_DECL(read_unchecked);
12413 ATOMIC64_DECL(set);
12414 +ATOMIC64_DECL(set_unchecked);
12415 ATOMIC64_DECL(xchg);
12416 ATOMIC64_DECL(add_return);
12417 +ATOMIC64_DECL(add_return_unchecked);
12418 ATOMIC64_DECL(sub_return);
12419 +ATOMIC64_DECL(sub_return_unchecked);
12420 ATOMIC64_DECL(inc_return);
12421 +ATOMIC64_DECL(inc_return_unchecked);
12422 ATOMIC64_DECL(dec_return);
12423 +ATOMIC64_DECL(dec_return_unchecked);
12424 ATOMIC64_DECL(dec_if_positive);
12425 ATOMIC64_DECL(inc_not_zero);
12426 ATOMIC64_DECL(add_unless);
12427 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
12428 }
12429
12430 /**
12431 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
12432 + * @p: pointer to type atomic64_unchecked_t
12433 + * @o: expected value
12434 + * @n: new value
12435 + *
12436 + * Atomically sets @v to @n if it was equal to @o and returns
12437 + * the old value.
12438 + */
12439 +
12440 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
12441 +{
12442 + return cmpxchg64(&v->counter, o, n);
12443 +}
12444 +
12445 +/**
12446 * atomic64_xchg - xchg atomic64 variable
12447 * @v: pointer to type atomic64_t
12448 * @n: value to assign
12449 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
12450 }
12451
12452 /**
12453 + * atomic64_set_unchecked - set atomic64 variable
12454 + * @v: pointer to type atomic64_unchecked_t
12455 + * @n: value to assign
12456 + *
12457 + * Atomically sets the value of @v to @n.
12458 + */
12459 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
12460 +{
12461 + unsigned high = (unsigned)(i >> 32);
12462 + unsigned low = (unsigned)i;
12463 + alternative_atomic64(set, /* no output */,
12464 + "S" (v), "b" (low), "c" (high)
12465 + : "eax", "edx", "memory");
12466 +}
12467 +
12468 +/**
12469 * atomic64_read - read atomic64 variable
12470 * @v: pointer to type atomic64_t
12471 *
12472 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
12473 }
12474
12475 /**
12476 + * atomic64_read_unchecked - read atomic64 variable
12477 + * @v: pointer to type atomic64_unchecked_t
12478 + *
12479 + * Atomically reads the value of @v and returns it.
12480 + */
12481 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
12482 +{
12483 + long long r;
12484 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
12485 + return r;
12486 + }
12487 +
12488 +/**
12489 * atomic64_add_return - add and return
12490 * @i: integer value to add
12491 * @v: pointer to type atomic64_t
12492 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
12493 return i;
12494 }
12495
12496 +/**
12497 + * atomic64_add_return_unchecked - add and return
12498 + * @i: integer value to add
12499 + * @v: pointer to type atomic64_unchecked_t
12500 + *
12501 + * Atomically adds @i to @v and returns @i + *@v
12502 + */
12503 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
12504 +{
12505 + alternative_atomic64(add_return_unchecked,
12506 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12507 + ASM_NO_INPUT_CLOBBER("memory"));
12508 + return i;
12509 +}
12510 +
12511 /*
12512 * Other variants with different arithmetic operators:
12513 */
12514 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
12515 return a;
12516 }
12517
12518 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
12519 +{
12520 + long long a;
12521 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
12522 + "S" (v) : "memory", "ecx");
12523 + return a;
12524 +}
12525 +
12526 static inline long long atomic64_dec_return(atomic64_t *v)
12527 {
12528 long long a;
12529 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
12530 }
12531
12532 /**
12533 + * atomic64_add_unchecked - add integer to atomic64 variable
12534 + * @i: integer value to add
12535 + * @v: pointer to type atomic64_unchecked_t
12536 + *
12537 + * Atomically adds @i to @v.
12538 + */
12539 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
12540 +{
12541 + __alternative_atomic64(add_unchecked, add_return_unchecked,
12542 + ASM_OUTPUT2("+A" (i), "+c" (v)),
12543 + ASM_NO_INPUT_CLOBBER("memory"));
12544 + return i;
12545 +}
12546 +
12547 +/**
12548 * atomic64_sub - subtract the atomic64 variable
12549 * @i: integer value to subtract
12550 * @v: pointer to type atomic64_t
12551 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
12552 index 0e1cbfc..5623683 100644
12553 --- a/arch/x86/include/asm/atomic64_64.h
12554 +++ b/arch/x86/include/asm/atomic64_64.h
12555 @@ -18,7 +18,19 @@
12556 */
12557 static inline long atomic64_read(const atomic64_t *v)
12558 {
12559 - return (*(volatile long *)&(v)->counter);
12560 + return (*(volatile const long *)&(v)->counter);
12561 +}
12562 +
12563 +/**
12564 + * atomic64_read_unchecked - read atomic64 variable
12565 + * @v: pointer of type atomic64_unchecked_t
12566 + *
12567 + * Atomically reads the value of @v.
12568 + * Doesn't imply a read memory barrier.
12569 + */
12570 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
12571 +{
12572 + return (*(volatile const long *)&(v)->counter);
12573 }
12574
12575 /**
12576 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
12577 }
12578
12579 /**
12580 + * atomic64_set_unchecked - set atomic64 variable
12581 + * @v: pointer to type atomic64_unchecked_t
12582 + * @i: required value
12583 + *
12584 + * Atomically sets the value of @v to @i.
12585 + */
12586 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
12587 +{
12588 + v->counter = i;
12589 +}
12590 +
12591 +/**
12592 * atomic64_add - add integer to atomic64 variable
12593 * @i: integer value to add
12594 * @v: pointer to type atomic64_t
12595 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
12596 */
12597 static inline void atomic64_add(long i, atomic64_t *v)
12598 {
12599 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
12600 +
12601 +#ifdef CONFIG_PAX_REFCOUNT
12602 + "jno 0f\n"
12603 + LOCK_PREFIX "subq %1,%0\n"
12604 + "int $4\n0:\n"
12605 + _ASM_EXTABLE(0b, 0b)
12606 +#endif
12607 +
12608 + : "=m" (v->counter)
12609 + : "er" (i), "m" (v->counter));
12610 +}
12611 +
12612 +/**
12613 + * atomic64_add_unchecked - add integer to atomic64 variable
12614 + * @i: integer value to add
12615 + * @v: pointer to type atomic64_unchecked_t
12616 + *
12617 + * Atomically adds @i to @v.
12618 + */
12619 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
12620 +{
12621 asm volatile(LOCK_PREFIX "addq %1,%0"
12622 : "=m" (v->counter)
12623 : "er" (i), "m" (v->counter));
12624 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
12625 */
12626 static inline void atomic64_sub(long i, atomic64_t *v)
12627 {
12628 - asm volatile(LOCK_PREFIX "subq %1,%0"
12629 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
12630 +
12631 +#ifdef CONFIG_PAX_REFCOUNT
12632 + "jno 0f\n"
12633 + LOCK_PREFIX "addq %1,%0\n"
12634 + "int $4\n0:\n"
12635 + _ASM_EXTABLE(0b, 0b)
12636 +#endif
12637 +
12638 + : "=m" (v->counter)
12639 + : "er" (i), "m" (v->counter));
12640 +}
12641 +
12642 +/**
12643 + * atomic64_sub_unchecked - subtract the atomic64 variable
12644 + * @i: integer value to subtract
12645 + * @v: pointer to type atomic64_unchecked_t
12646 + *
12647 + * Atomically subtracts @i from @v.
12648 + */
12649 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
12650 +{
12651 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
12652 : "=m" (v->counter)
12653 : "er" (i), "m" (v->counter));
12654 }
12655 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
12656 {
12657 unsigned char c;
12658
12659 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
12660 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
12661 +
12662 +#ifdef CONFIG_PAX_REFCOUNT
12663 + "jno 0f\n"
12664 + LOCK_PREFIX "addq %2,%0\n"
12665 + "int $4\n0:\n"
12666 + _ASM_EXTABLE(0b, 0b)
12667 +#endif
12668 +
12669 + "sete %1\n"
12670 : "=m" (v->counter), "=qm" (c)
12671 : "er" (i), "m" (v->counter) : "memory");
12672 return c;
12673 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
12674 */
12675 static inline void atomic64_inc(atomic64_t *v)
12676 {
12677 + asm volatile(LOCK_PREFIX "incq %0\n"
12678 +
12679 +#ifdef CONFIG_PAX_REFCOUNT
12680 + "jno 0f\n"
12681 + LOCK_PREFIX "decq %0\n"
12682 + "int $4\n0:\n"
12683 + _ASM_EXTABLE(0b, 0b)
12684 +#endif
12685 +
12686 + : "=m" (v->counter)
12687 + : "m" (v->counter));
12688 +}
12689 +
12690 +/**
12691 + * atomic64_inc_unchecked - increment atomic64 variable
12692 + * @v: pointer to type atomic64_unchecked_t
12693 + *
12694 + * Atomically increments @v by 1.
12695 + */
12696 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
12697 +{
12698 asm volatile(LOCK_PREFIX "incq %0"
12699 : "=m" (v->counter)
12700 : "m" (v->counter));
12701 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
12702 */
12703 static inline void atomic64_dec(atomic64_t *v)
12704 {
12705 - asm volatile(LOCK_PREFIX "decq %0"
12706 + asm volatile(LOCK_PREFIX "decq %0\n"
12707 +
12708 +#ifdef CONFIG_PAX_REFCOUNT
12709 + "jno 0f\n"
12710 + LOCK_PREFIX "incq %0\n"
12711 + "int $4\n0:\n"
12712 + _ASM_EXTABLE(0b, 0b)
12713 +#endif
12714 +
12715 + : "=m" (v->counter)
12716 + : "m" (v->counter));
12717 +}
12718 +
12719 +/**
12720 + * atomic64_dec_unchecked - decrement atomic64 variable
12721 + * @v: pointer to type atomic64_t
12722 + *
12723 + * Atomically decrements @v by 1.
12724 + */
12725 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
12726 +{
12727 + asm volatile(LOCK_PREFIX "decq %0\n"
12728 : "=m" (v->counter)
12729 : "m" (v->counter));
12730 }
12731 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
12732 {
12733 unsigned char c;
12734
12735 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
12736 + asm volatile(LOCK_PREFIX "decq %0\n"
12737 +
12738 +#ifdef CONFIG_PAX_REFCOUNT
12739 + "jno 0f\n"
12740 + LOCK_PREFIX "incq %0\n"
12741 + "int $4\n0:\n"
12742 + _ASM_EXTABLE(0b, 0b)
12743 +#endif
12744 +
12745 + "sete %1\n"
12746 : "=m" (v->counter), "=qm" (c)
12747 : "m" (v->counter) : "memory");
12748 return c != 0;
12749 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
12750 {
12751 unsigned char c;
12752
12753 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
12754 + asm volatile(LOCK_PREFIX "incq %0\n"
12755 +
12756 +#ifdef CONFIG_PAX_REFCOUNT
12757 + "jno 0f\n"
12758 + LOCK_PREFIX "decq %0\n"
12759 + "int $4\n0:\n"
12760 + _ASM_EXTABLE(0b, 0b)
12761 +#endif
12762 +
12763 + "sete %1\n"
12764 : "=m" (v->counter), "=qm" (c)
12765 : "m" (v->counter) : "memory");
12766 return c != 0;
12767 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
12768 {
12769 unsigned char c;
12770
12771 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
12772 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
12773 +
12774 +#ifdef CONFIG_PAX_REFCOUNT
12775 + "jno 0f\n"
12776 + LOCK_PREFIX "subq %2,%0\n"
12777 + "int $4\n0:\n"
12778 + _ASM_EXTABLE(0b, 0b)
12779 +#endif
12780 +
12781 + "sets %1\n"
12782 : "=m" (v->counter), "=qm" (c)
12783 : "er" (i), "m" (v->counter) : "memory");
12784 return c;
12785 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
12786 */
12787 static inline long atomic64_add_return(long i, atomic64_t *v)
12788 {
12789 + return i + xadd_check_overflow(&v->counter, i);
12790 +}
12791 +
12792 +/**
12793 + * atomic64_add_return_unchecked - add and return
12794 + * @i: integer value to add
12795 + * @v: pointer to type atomic64_unchecked_t
12796 + *
12797 + * Atomically adds @i to @v and returns @i + @v
12798 + */
12799 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
12800 +{
12801 return i + xadd(&v->counter, i);
12802 }
12803
12804 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
12805 }
12806
12807 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
12808 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
12809 +{
12810 + return atomic64_add_return_unchecked(1, v);
12811 +}
12812 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
12813
12814 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
12815 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
12816 return cmpxchg(&v->counter, old, new);
12817 }
12818
12819 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
12820 +{
12821 + return cmpxchg(&v->counter, old, new);
12822 +}
12823 +
12824 static inline long atomic64_xchg(atomic64_t *v, long new)
12825 {
12826 return xchg(&v->counter, new);
12827 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
12828 */
12829 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
12830 {
12831 - long c, old;
12832 + long c, old, new;
12833 c = atomic64_read(v);
12834 for (;;) {
12835 - if (unlikely(c == (u)))
12836 + if (unlikely(c == u))
12837 break;
12838 - old = atomic64_cmpxchg((v), c, c + (a));
12839 +
12840 + asm volatile("add %2,%0\n"
12841 +
12842 +#ifdef CONFIG_PAX_REFCOUNT
12843 + "jno 0f\n"
12844 + "sub %2,%0\n"
12845 + "int $4\n0:\n"
12846 + _ASM_EXTABLE(0b, 0b)
12847 +#endif
12848 +
12849 + : "=r" (new)
12850 + : "0" (c), "ir" (a));
12851 +
12852 + old = atomic64_cmpxchg(v, c, new);
12853 if (likely(old == c))
12854 break;
12855 c = old;
12856 }
12857 - return c != (u);
12858 + return c != u;
12859 }
12860
12861 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
12862 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
12863 index 6dfd019..28e188d 100644
12864 --- a/arch/x86/include/asm/bitops.h
12865 +++ b/arch/x86/include/asm/bitops.h
12866 @@ -40,7 +40,7 @@
12867 * a mask operation on a byte.
12868 */
12869 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
12870 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
12871 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
12872 #define CONST_MASK(nr) (1 << ((nr) & 7))
12873
12874 /**
12875 @@ -486,7 +486,7 @@ static inline int fls(int x)
12876 * at position 64.
12877 */
12878 #ifdef CONFIG_X86_64
12879 -static __always_inline int fls64(__u64 x)
12880 +static __always_inline long fls64(__u64 x)
12881 {
12882 int bitpos = -1;
12883 /*
12884 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
12885 index 4fa687a..60f2d39 100644
12886 --- a/arch/x86/include/asm/boot.h
12887 +++ b/arch/x86/include/asm/boot.h
12888 @@ -6,10 +6,15 @@
12889 #include <uapi/asm/boot.h>
12890
12891 /* Physical address where kernel should be loaded. */
12892 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
12893 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
12894 + (CONFIG_PHYSICAL_ALIGN - 1)) \
12895 & ~(CONFIG_PHYSICAL_ALIGN - 1))
12896
12897 +#ifndef __ASSEMBLY__
12898 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
12899 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
12900 +#endif
12901 +
12902 /* Minimum kernel alignment, as a power of two */
12903 #ifdef CONFIG_X86_64
12904 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
12905 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
12906 index 48f99f1..d78ebf9 100644
12907 --- a/arch/x86/include/asm/cache.h
12908 +++ b/arch/x86/include/asm/cache.h
12909 @@ -5,12 +5,13 @@
12910
12911 /* L1 cache line size */
12912 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
12913 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
12914 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
12915
12916 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
12917 +#define __read_only __attribute__((__section__(".data..read_only")))
12918
12919 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
12920 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
12921 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
12922
12923 #ifdef CONFIG_X86_VSMP
12924 #ifdef CONFIG_SMP
12925 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
12926 index 9863ee3..4a1f8e1 100644
12927 --- a/arch/x86/include/asm/cacheflush.h
12928 +++ b/arch/x86/include/asm/cacheflush.h
12929 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
12930 unsigned long pg_flags = pg->flags & _PGMT_MASK;
12931
12932 if (pg_flags == _PGMT_DEFAULT)
12933 - return -1;
12934 + return ~0UL;
12935 else if (pg_flags == _PGMT_WC)
12936 return _PAGE_CACHE_WC;
12937 else if (pg_flags == _PGMT_UC_MINUS)
12938 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
12939 index 46fc474..b02b0f9 100644
12940 --- a/arch/x86/include/asm/checksum_32.h
12941 +++ b/arch/x86/include/asm/checksum_32.h
12942 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
12943 int len, __wsum sum,
12944 int *src_err_ptr, int *dst_err_ptr);
12945
12946 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
12947 + int len, __wsum sum,
12948 + int *src_err_ptr, int *dst_err_ptr);
12949 +
12950 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
12951 + int len, __wsum sum,
12952 + int *src_err_ptr, int *dst_err_ptr);
12953 +
12954 /*
12955 * Note: when you get a NULL pointer exception here this means someone
12956 * passed in an incorrect kernel address to one of these functions.
12957 @@ -50,7 +58,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
12958 int *err_ptr)
12959 {
12960 might_sleep();
12961 - return csum_partial_copy_generic((__force void *)src, dst,
12962 + return csum_partial_copy_generic_from_user((__force void *)src, dst,
12963 len, sum, err_ptr, NULL);
12964 }
12965
12966 @@ -178,7 +186,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
12967 {
12968 might_sleep();
12969 if (access_ok(VERIFY_WRITE, dst, len))
12970 - return csum_partial_copy_generic(src, (__force void *)dst,
12971 + return csum_partial_copy_generic_to_user(src, (__force void *)dst,
12972 len, sum, NULL, err_ptr);
12973
12974 if (len)
12975 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
12976 index d47786a..ce1b05d 100644
12977 --- a/arch/x86/include/asm/cmpxchg.h
12978 +++ b/arch/x86/include/asm/cmpxchg.h
12979 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
12980 __compiletime_error("Bad argument size for cmpxchg");
12981 extern void __xadd_wrong_size(void)
12982 __compiletime_error("Bad argument size for xadd");
12983 +extern void __xadd_check_overflow_wrong_size(void)
12984 + __compiletime_error("Bad argument size for xadd_check_overflow");
12985 extern void __add_wrong_size(void)
12986 __compiletime_error("Bad argument size for add");
12987 +extern void __add_check_overflow_wrong_size(void)
12988 + __compiletime_error("Bad argument size for add_check_overflow");
12989
12990 /*
12991 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
12992 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
12993 __ret; \
12994 })
12995
12996 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
12997 + ({ \
12998 + __typeof__ (*(ptr)) __ret = (arg); \
12999 + switch (sizeof(*(ptr))) { \
13000 + case __X86_CASE_L: \
13001 + asm volatile (lock #op "l %0, %1\n" \
13002 + "jno 0f\n" \
13003 + "mov %0,%1\n" \
13004 + "int $4\n0:\n" \
13005 + _ASM_EXTABLE(0b, 0b) \
13006 + : "+r" (__ret), "+m" (*(ptr)) \
13007 + : : "memory", "cc"); \
13008 + break; \
13009 + case __X86_CASE_Q: \
13010 + asm volatile (lock #op "q %q0, %1\n" \
13011 + "jno 0f\n" \
13012 + "mov %0,%1\n" \
13013 + "int $4\n0:\n" \
13014 + _ASM_EXTABLE(0b, 0b) \
13015 + : "+r" (__ret), "+m" (*(ptr)) \
13016 + : : "memory", "cc"); \
13017 + break; \
13018 + default: \
13019 + __ ## op ## _check_overflow_wrong_size(); \
13020 + } \
13021 + __ret; \
13022 + })
13023 +
13024 /*
13025 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
13026 * Since this is generally used to protect other memory information, we
13027 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
13028 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
13029 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
13030
13031 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
13032 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
13033 +
13034 #define __add(ptr, inc, lock) \
13035 ({ \
13036 __typeof__ (*(ptr)) __ret = (inc); \
13037 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
13038 index 59c6c40..5e0b22c 100644
13039 --- a/arch/x86/include/asm/compat.h
13040 +++ b/arch/x86/include/asm/compat.h
13041 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
13042 typedef u32 compat_uint_t;
13043 typedef u32 compat_ulong_t;
13044 typedef u64 __attribute__((aligned(4))) compat_u64;
13045 -typedef u32 compat_uptr_t;
13046 +typedef u32 __user compat_uptr_t;
13047
13048 struct compat_timespec {
13049 compat_time_t tv_sec;
13050 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
13051 index e99ac27..e89e28c 100644
13052 --- a/arch/x86/include/asm/cpufeature.h
13053 +++ b/arch/x86/include/asm/cpufeature.h
13054 @@ -211,7 +211,7 @@
13055 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
13056 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
13057 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
13058 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
13059 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
13060 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
13061 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
13062 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
13063 @@ -394,7 +394,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
13064 ".section .discard,\"aw\",@progbits\n"
13065 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
13066 ".previous\n"
13067 - ".section .altinstr_replacement,\"ax\"\n"
13068 + ".section .altinstr_replacement,\"a\"\n"
13069 "3: movb $1,%0\n"
13070 "4:\n"
13071 ".previous\n"
13072 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
13073 index 8bf1c06..b6ae785 100644
13074 --- a/arch/x86/include/asm/desc.h
13075 +++ b/arch/x86/include/asm/desc.h
13076 @@ -4,6 +4,7 @@
13077 #include <asm/desc_defs.h>
13078 #include <asm/ldt.h>
13079 #include <asm/mmu.h>
13080 +#include <asm/pgtable.h>
13081
13082 #include <linux/smp.h>
13083 #include <linux/percpu.h>
13084 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13085
13086 desc->type = (info->read_exec_only ^ 1) << 1;
13087 desc->type |= info->contents << 2;
13088 + desc->type |= info->seg_not_present ^ 1;
13089
13090 desc->s = 1;
13091 desc->dpl = 0x3;
13092 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13093 }
13094
13095 extern struct desc_ptr idt_descr;
13096 -extern gate_desc idt_table[];
13097 extern struct desc_ptr nmi_idt_descr;
13098 -extern gate_desc nmi_idt_table[];
13099 -
13100 -struct gdt_page {
13101 - struct desc_struct gdt[GDT_ENTRIES];
13102 -} __attribute__((aligned(PAGE_SIZE)));
13103 -
13104 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
13105 +extern gate_desc idt_table[256];
13106 +extern gate_desc nmi_idt_table[256];
13107
13108 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
13109 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
13110 {
13111 - return per_cpu(gdt_page, cpu).gdt;
13112 + return cpu_gdt_table[cpu];
13113 }
13114
13115 #ifdef CONFIG_X86_64
13116 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
13117 unsigned long base, unsigned dpl, unsigned flags,
13118 unsigned short seg)
13119 {
13120 - gate->a = (seg << 16) | (base & 0xffff);
13121 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
13122 + gate->gate.offset_low = base;
13123 + gate->gate.seg = seg;
13124 + gate->gate.reserved = 0;
13125 + gate->gate.type = type;
13126 + gate->gate.s = 0;
13127 + gate->gate.dpl = dpl;
13128 + gate->gate.p = 1;
13129 + gate->gate.offset_high = base >> 16;
13130 }
13131
13132 #endif
13133 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
13134
13135 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
13136 {
13137 + pax_open_kernel();
13138 memcpy(&idt[entry], gate, sizeof(*gate));
13139 + pax_close_kernel();
13140 }
13141
13142 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
13143 {
13144 + pax_open_kernel();
13145 memcpy(&ldt[entry], desc, 8);
13146 + pax_close_kernel();
13147 }
13148
13149 static inline void
13150 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
13151 default: size = sizeof(*gdt); break;
13152 }
13153
13154 + pax_open_kernel();
13155 memcpy(&gdt[entry], desc, size);
13156 + pax_close_kernel();
13157 }
13158
13159 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
13160 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
13161
13162 static inline void native_load_tr_desc(void)
13163 {
13164 + pax_open_kernel();
13165 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
13166 + pax_close_kernel();
13167 }
13168
13169 static inline void native_load_gdt(const struct desc_ptr *dtr)
13170 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
13171 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
13172 unsigned int i;
13173
13174 + pax_open_kernel();
13175 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
13176 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
13177 + pax_close_kernel();
13178 }
13179
13180 #define _LDT_empty(info) \
13181 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
13182 preempt_enable();
13183 }
13184
13185 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
13186 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
13187 {
13188 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
13189 }
13190 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
13191 }
13192
13193 #ifdef CONFIG_X86_64
13194 -static inline void set_nmi_gate(int gate, void *addr)
13195 +static inline void set_nmi_gate(int gate, const void *addr)
13196 {
13197 gate_desc s;
13198
13199 @@ -320,7 +333,7 @@ static inline void set_nmi_gate(int gate, void *addr)
13200 }
13201 #endif
13202
13203 -static inline void _set_gate(int gate, unsigned type, void *addr,
13204 +static inline void _set_gate(int gate, unsigned type, const void *addr,
13205 unsigned dpl, unsigned ist, unsigned seg)
13206 {
13207 gate_desc s;
13208 @@ -339,7 +352,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
13209 * Pentium F0 0F bugfix can have resulted in the mapped
13210 * IDT being write-protected.
13211 */
13212 -static inline void set_intr_gate(unsigned int n, void *addr)
13213 +static inline void set_intr_gate(unsigned int n, const void *addr)
13214 {
13215 BUG_ON((unsigned)n > 0xFF);
13216 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
13217 @@ -369,19 +382,19 @@ static inline void alloc_intr_gate(unsigned int n, void *addr)
13218 /*
13219 * This routine sets up an interrupt gate at directory privilege level 3.
13220 */
13221 -static inline void set_system_intr_gate(unsigned int n, void *addr)
13222 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
13223 {
13224 BUG_ON((unsigned)n > 0xFF);
13225 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
13226 }
13227
13228 -static inline void set_system_trap_gate(unsigned int n, void *addr)
13229 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
13230 {
13231 BUG_ON((unsigned)n > 0xFF);
13232 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
13233 }
13234
13235 -static inline void set_trap_gate(unsigned int n, void *addr)
13236 +static inline void set_trap_gate(unsigned int n, const void *addr)
13237 {
13238 BUG_ON((unsigned)n > 0xFF);
13239 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
13240 @@ -390,19 +403,31 @@ static inline void set_trap_gate(unsigned int n, void *addr)
13241 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
13242 {
13243 BUG_ON((unsigned)n > 0xFF);
13244 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
13245 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
13246 }
13247
13248 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
13249 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
13250 {
13251 BUG_ON((unsigned)n > 0xFF);
13252 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
13253 }
13254
13255 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
13256 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
13257 {
13258 BUG_ON((unsigned)n > 0xFF);
13259 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
13260 }
13261
13262 +#ifdef CONFIG_X86_32
13263 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
13264 +{
13265 + struct desc_struct d;
13266 +
13267 + if (likely(limit))
13268 + limit = (limit - 1UL) >> PAGE_SHIFT;
13269 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
13270 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
13271 +}
13272 +#endif
13273 +
13274 #endif /* _ASM_X86_DESC_H */
13275 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
13276 index 278441f..b95a174 100644
13277 --- a/arch/x86/include/asm/desc_defs.h
13278 +++ b/arch/x86/include/asm/desc_defs.h
13279 @@ -31,6 +31,12 @@ struct desc_struct {
13280 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
13281 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
13282 };
13283 + struct {
13284 + u16 offset_low;
13285 + u16 seg;
13286 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
13287 + unsigned offset_high: 16;
13288 + } gate;
13289 };
13290 } __attribute__((packed));
13291
13292 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
13293 index ced283a..ffe04cc 100644
13294 --- a/arch/x86/include/asm/div64.h
13295 +++ b/arch/x86/include/asm/div64.h
13296 @@ -39,7 +39,7 @@
13297 __mod; \
13298 })
13299
13300 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13301 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
13302 {
13303 union {
13304 u64 v64;
13305 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
13306 index 9c999c1..3860cb8 100644
13307 --- a/arch/x86/include/asm/elf.h
13308 +++ b/arch/x86/include/asm/elf.h
13309 @@ -243,7 +243,25 @@ extern int force_personality32;
13310 the loader. We need to make sure that it is out of the way of the program
13311 that it will "exec", and that there is sufficient room for the brk. */
13312
13313 +#ifdef CONFIG_PAX_SEGMEXEC
13314 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
13315 +#else
13316 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
13317 +#endif
13318 +
13319 +#ifdef CONFIG_PAX_ASLR
13320 +#ifdef CONFIG_X86_32
13321 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
13322 +
13323 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13324 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
13325 +#else
13326 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
13327 +
13328 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13329 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
13330 +#endif
13331 +#endif
13332
13333 /* This yields a mask that user programs can use to figure out what
13334 instruction set this CPU supports. This could be done in user space,
13335 @@ -296,16 +314,12 @@ do { \
13336
13337 #define ARCH_DLINFO \
13338 do { \
13339 - if (vdso_enabled) \
13340 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13341 - (unsigned long)current->mm->context.vdso); \
13342 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13343 } while (0)
13344
13345 #define ARCH_DLINFO_X32 \
13346 do { \
13347 - if (vdso_enabled) \
13348 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
13349 - (unsigned long)current->mm->context.vdso); \
13350 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
13351 } while (0)
13352
13353 #define AT_SYSINFO 32
13354 @@ -320,7 +334,7 @@ else \
13355
13356 #endif /* !CONFIG_X86_32 */
13357
13358 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
13359 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
13360
13361 #define VDSO_ENTRY \
13362 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
13363 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
13364 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
13365 #define compat_arch_setup_additional_pages syscall32_setup_pages
13366
13367 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
13368 -#define arch_randomize_brk arch_randomize_brk
13369 -
13370 /*
13371 * True on X86_32 or when emulating IA32 on X86_64
13372 */
13373 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
13374 index 75ce3f4..882e801 100644
13375 --- a/arch/x86/include/asm/emergency-restart.h
13376 +++ b/arch/x86/include/asm/emergency-restart.h
13377 @@ -13,6 +13,6 @@ enum reboot_type {
13378
13379 extern enum reboot_type reboot_type;
13380
13381 -extern void machine_emergency_restart(void);
13382 +extern void machine_emergency_restart(void) __noreturn;
13383
13384 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
13385 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
13386 index e25cc33..425d099 100644
13387 --- a/arch/x86/include/asm/fpu-internal.h
13388 +++ b/arch/x86/include/asm/fpu-internal.h
13389 @@ -127,7 +127,9 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
13390 ({ \
13391 int err; \
13392 asm volatile(ASM_STAC "\n" \
13393 - "1:" #insn "\n\t" \
13394 + "1:" \
13395 + __copyuser_seg \
13396 + #insn "\n\t" \
13397 "2: " ASM_CLAC "\n" \
13398 ".section .fixup,\"ax\"\n" \
13399 "3: movl $-1,%[err]\n" \
13400 @@ -300,7 +302,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
13401 "emms\n\t" /* clear stack tags */
13402 "fildl %P[addr]", /* set F?P to defined value */
13403 X86_FEATURE_FXSAVE_LEAK,
13404 - [addr] "m" (tsk->thread.fpu.has_fpu));
13405 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
13406
13407 return fpu_restore_checking(&tsk->thread.fpu);
13408 }
13409 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
13410 index be27ba1..8f13ff9 100644
13411 --- a/arch/x86/include/asm/futex.h
13412 +++ b/arch/x86/include/asm/futex.h
13413 @@ -12,6 +12,7 @@
13414 #include <asm/smap.h>
13415
13416 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
13417 + typecheck(u32 __user *, uaddr); \
13418 asm volatile("\t" ASM_STAC "\n" \
13419 "1:\t" insn "\n" \
13420 "2:\t" ASM_CLAC "\n" \
13421 @@ -20,15 +21,16 @@
13422 "\tjmp\t2b\n" \
13423 "\t.previous\n" \
13424 _ASM_EXTABLE(1b, 3b) \
13425 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
13426 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
13427 : "i" (-EFAULT), "0" (oparg), "1" (0))
13428
13429 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
13430 + typecheck(u32 __user *, uaddr); \
13431 asm volatile("\t" ASM_STAC "\n" \
13432 "1:\tmovl %2, %0\n" \
13433 "\tmovl\t%0, %3\n" \
13434 "\t" insn "\n" \
13435 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
13436 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
13437 "\tjnz\t1b\n" \
13438 "3:\t" ASM_CLAC "\n" \
13439 "\t.section .fixup,\"ax\"\n" \
13440 @@ -38,7 +40,7 @@
13441 _ASM_EXTABLE(1b, 4b) \
13442 _ASM_EXTABLE(2b, 4b) \
13443 : "=&a" (oldval), "=&r" (ret), \
13444 - "+m" (*uaddr), "=&r" (tem) \
13445 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
13446 : "r" (oparg), "i" (-EFAULT), "1" (0))
13447
13448 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13449 @@ -59,10 +61,10 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
13450
13451 switch (op) {
13452 case FUTEX_OP_SET:
13453 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
13454 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
13455 break;
13456 case FUTEX_OP_ADD:
13457 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
13458 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
13459 uaddr, oparg);
13460 break;
13461 case FUTEX_OP_OR:
13462 @@ -116,14 +118,14 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
13463 return -EFAULT;
13464
13465 asm volatile("\t" ASM_STAC "\n"
13466 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
13467 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
13468 "2:\t" ASM_CLAC "\n"
13469 "\t.section .fixup, \"ax\"\n"
13470 "3:\tmov %3, %0\n"
13471 "\tjmp 2b\n"
13472 "\t.previous\n"
13473 _ASM_EXTABLE(1b, 3b)
13474 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
13475 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
13476 : "i" (-EFAULT), "r" (newval), "1" (oldval)
13477 : "memory"
13478 );
13479 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
13480 index 1da97ef..9c2ebff 100644
13481 --- a/arch/x86/include/asm/hw_irq.h
13482 +++ b/arch/x86/include/asm/hw_irq.h
13483 @@ -148,8 +148,8 @@ extern void setup_ioapic_dest(void);
13484 extern void enable_IO_APIC(void);
13485
13486 /* Statistics */
13487 -extern atomic_t irq_err_count;
13488 -extern atomic_t irq_mis_count;
13489 +extern atomic_unchecked_t irq_err_count;
13490 +extern atomic_unchecked_t irq_mis_count;
13491
13492 /* EISA */
13493 extern void eisa_set_level_irq(unsigned int irq);
13494 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
13495 index a203659..9889f1c 100644
13496 --- a/arch/x86/include/asm/i8259.h
13497 +++ b/arch/x86/include/asm/i8259.h
13498 @@ -62,7 +62,7 @@ struct legacy_pic {
13499 void (*init)(int auto_eoi);
13500 int (*irq_pending)(unsigned int irq);
13501 void (*make_irq)(unsigned int irq);
13502 -};
13503 +} __do_const;
13504
13505 extern struct legacy_pic *legacy_pic;
13506 extern struct legacy_pic null_legacy_pic;
13507 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
13508 index d8e8eef..1765f78 100644
13509 --- a/arch/x86/include/asm/io.h
13510 +++ b/arch/x86/include/asm/io.h
13511 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
13512 "m" (*(volatile type __force *)addr) barrier); }
13513
13514 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
13515 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
13516 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
13517 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
13518 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
13519
13520 build_mmio_read(__readb, "b", unsigned char, "=q", )
13521 -build_mmio_read(__readw, "w", unsigned short, "=r", )
13522 -build_mmio_read(__readl, "l", unsigned int, "=r", )
13523 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
13524 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
13525
13526 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
13527 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
13528 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
13529 return ioremap_nocache(offset, size);
13530 }
13531
13532 -extern void iounmap(volatile void __iomem *addr);
13533 +extern void iounmap(const volatile void __iomem *addr);
13534
13535 extern void set_iounmap_nonlazy(void);
13536
13537 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
13538
13539 #include <linux/vmalloc.h>
13540
13541 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
13542 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
13543 +{
13544 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13545 +}
13546 +
13547 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
13548 +{
13549 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
13550 +}
13551 +
13552 /*
13553 * Convert a virtual cached pointer to an uncached pointer
13554 */
13555 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
13556 index bba3cf8..06bc8da 100644
13557 --- a/arch/x86/include/asm/irqflags.h
13558 +++ b/arch/x86/include/asm/irqflags.h
13559 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
13560 sti; \
13561 sysexit
13562
13563 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
13564 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
13565 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
13566 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
13567 +
13568 #else
13569 #define INTERRUPT_RETURN iret
13570 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
13571 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
13572 index 5a6d287..f815789 100644
13573 --- a/arch/x86/include/asm/kprobes.h
13574 +++ b/arch/x86/include/asm/kprobes.h
13575 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
13576 #define RELATIVEJUMP_SIZE 5
13577 #define RELATIVECALL_OPCODE 0xe8
13578 #define RELATIVE_ADDR_SIZE 4
13579 -#define MAX_STACK_SIZE 64
13580 -#define MIN_STACK_SIZE(ADDR) \
13581 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
13582 - THREAD_SIZE - (unsigned long)(ADDR))) \
13583 - ? (MAX_STACK_SIZE) \
13584 - : (((unsigned long)current_thread_info()) + \
13585 - THREAD_SIZE - (unsigned long)(ADDR)))
13586 +#define MAX_STACK_SIZE 64UL
13587 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
13588
13589 #define flush_insn_slot(p) do { } while (0)
13590
13591 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
13592 index 2d89e39..baee879 100644
13593 --- a/arch/x86/include/asm/local.h
13594 +++ b/arch/x86/include/asm/local.h
13595 @@ -10,33 +10,97 @@ typedef struct {
13596 atomic_long_t a;
13597 } local_t;
13598
13599 +typedef struct {
13600 + atomic_long_unchecked_t a;
13601 +} local_unchecked_t;
13602 +
13603 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
13604
13605 #define local_read(l) atomic_long_read(&(l)->a)
13606 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
13607 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
13608 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
13609
13610 static inline void local_inc(local_t *l)
13611 {
13612 - asm volatile(_ASM_INC "%0"
13613 + asm volatile(_ASM_INC "%0\n"
13614 +
13615 +#ifdef CONFIG_PAX_REFCOUNT
13616 + "jno 0f\n"
13617 + _ASM_DEC "%0\n"
13618 + "int $4\n0:\n"
13619 + _ASM_EXTABLE(0b, 0b)
13620 +#endif
13621 +
13622 + : "+m" (l->a.counter));
13623 +}
13624 +
13625 +static inline void local_inc_unchecked(local_unchecked_t *l)
13626 +{
13627 + asm volatile(_ASM_INC "%0\n"
13628 : "+m" (l->a.counter));
13629 }
13630
13631 static inline void local_dec(local_t *l)
13632 {
13633 - asm volatile(_ASM_DEC "%0"
13634 + asm volatile(_ASM_DEC "%0\n"
13635 +
13636 +#ifdef CONFIG_PAX_REFCOUNT
13637 + "jno 0f\n"
13638 + _ASM_INC "%0\n"
13639 + "int $4\n0:\n"
13640 + _ASM_EXTABLE(0b, 0b)
13641 +#endif
13642 +
13643 + : "+m" (l->a.counter));
13644 +}
13645 +
13646 +static inline void local_dec_unchecked(local_unchecked_t *l)
13647 +{
13648 + asm volatile(_ASM_DEC "%0\n"
13649 : "+m" (l->a.counter));
13650 }
13651
13652 static inline void local_add(long i, local_t *l)
13653 {
13654 - asm volatile(_ASM_ADD "%1,%0"
13655 + asm volatile(_ASM_ADD "%1,%0\n"
13656 +
13657 +#ifdef CONFIG_PAX_REFCOUNT
13658 + "jno 0f\n"
13659 + _ASM_SUB "%1,%0\n"
13660 + "int $4\n0:\n"
13661 + _ASM_EXTABLE(0b, 0b)
13662 +#endif
13663 +
13664 + : "+m" (l->a.counter)
13665 + : "ir" (i));
13666 +}
13667 +
13668 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
13669 +{
13670 + asm volatile(_ASM_ADD "%1,%0\n"
13671 : "+m" (l->a.counter)
13672 : "ir" (i));
13673 }
13674
13675 static inline void local_sub(long i, local_t *l)
13676 {
13677 - asm volatile(_ASM_SUB "%1,%0"
13678 + asm volatile(_ASM_SUB "%1,%0\n"
13679 +
13680 +#ifdef CONFIG_PAX_REFCOUNT
13681 + "jno 0f\n"
13682 + _ASM_ADD "%1,%0\n"
13683 + "int $4\n0:\n"
13684 + _ASM_EXTABLE(0b, 0b)
13685 +#endif
13686 +
13687 + : "+m" (l->a.counter)
13688 + : "ir" (i));
13689 +}
13690 +
13691 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
13692 +{
13693 + asm volatile(_ASM_SUB "%1,%0\n"
13694 : "+m" (l->a.counter)
13695 : "ir" (i));
13696 }
13697 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
13698 {
13699 unsigned char c;
13700
13701 - asm volatile(_ASM_SUB "%2,%0; sete %1"
13702 + asm volatile(_ASM_SUB "%2,%0\n"
13703 +
13704 +#ifdef CONFIG_PAX_REFCOUNT
13705 + "jno 0f\n"
13706 + _ASM_ADD "%2,%0\n"
13707 + "int $4\n0:\n"
13708 + _ASM_EXTABLE(0b, 0b)
13709 +#endif
13710 +
13711 + "sete %1\n"
13712 : "+m" (l->a.counter), "=qm" (c)
13713 : "ir" (i) : "memory");
13714 return c;
13715 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
13716 {
13717 unsigned char c;
13718
13719 - asm volatile(_ASM_DEC "%0; sete %1"
13720 + asm volatile(_ASM_DEC "%0\n"
13721 +
13722 +#ifdef CONFIG_PAX_REFCOUNT
13723 + "jno 0f\n"
13724 + _ASM_INC "%0\n"
13725 + "int $4\n0:\n"
13726 + _ASM_EXTABLE(0b, 0b)
13727 +#endif
13728 +
13729 + "sete %1\n"
13730 : "+m" (l->a.counter), "=qm" (c)
13731 : : "memory");
13732 return c != 0;
13733 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
13734 {
13735 unsigned char c;
13736
13737 - asm volatile(_ASM_INC "%0; sete %1"
13738 + asm volatile(_ASM_INC "%0\n"
13739 +
13740 +#ifdef CONFIG_PAX_REFCOUNT
13741 + "jno 0f\n"
13742 + _ASM_DEC "%0\n"
13743 + "int $4\n0:\n"
13744 + _ASM_EXTABLE(0b, 0b)
13745 +#endif
13746 +
13747 + "sete %1\n"
13748 : "+m" (l->a.counter), "=qm" (c)
13749 : : "memory");
13750 return c != 0;
13751 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
13752 {
13753 unsigned char c;
13754
13755 - asm volatile(_ASM_ADD "%2,%0; sets %1"
13756 + asm volatile(_ASM_ADD "%2,%0\n"
13757 +
13758 +#ifdef CONFIG_PAX_REFCOUNT
13759 + "jno 0f\n"
13760 + _ASM_SUB "%2,%0\n"
13761 + "int $4\n0:\n"
13762 + _ASM_EXTABLE(0b, 0b)
13763 +#endif
13764 +
13765 + "sets %1\n"
13766 : "+m" (l->a.counter), "=qm" (c)
13767 : "ir" (i) : "memory");
13768 return c;
13769 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
13770 static inline long local_add_return(long i, local_t *l)
13771 {
13772 long __i = i;
13773 + asm volatile(_ASM_XADD "%0, %1\n"
13774 +
13775 +#ifdef CONFIG_PAX_REFCOUNT
13776 + "jno 0f\n"
13777 + _ASM_MOV "%0,%1\n"
13778 + "int $4\n0:\n"
13779 + _ASM_EXTABLE(0b, 0b)
13780 +#endif
13781 +
13782 + : "+r" (i), "+m" (l->a.counter)
13783 + : : "memory");
13784 + return i + __i;
13785 +}
13786 +
13787 +/**
13788 + * local_add_return_unchecked - add and return
13789 + * @i: integer value to add
13790 + * @l: pointer to type local_unchecked_t
13791 + *
13792 + * Atomically adds @i to @l and returns @i + @l
13793 + */
13794 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
13795 +{
13796 + long __i = i;
13797 asm volatile(_ASM_XADD "%0, %1;"
13798 : "+r" (i), "+m" (l->a.counter)
13799 : : "memory");
13800 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
13801
13802 #define local_cmpxchg(l, o, n) \
13803 (cmpxchg_local(&((l)->a.counter), (o), (n)))
13804 +#define local_cmpxchg_unchecked(l, o, n) \
13805 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
13806 /* Always has a lock prefix */
13807 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
13808
13809 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
13810 new file mode 100644
13811 index 0000000..2bfd3ba
13812 --- /dev/null
13813 +++ b/arch/x86/include/asm/mman.h
13814 @@ -0,0 +1,15 @@
13815 +#ifndef _X86_MMAN_H
13816 +#define _X86_MMAN_H
13817 +
13818 +#include <uapi/asm/mman.h>
13819 +
13820 +#ifdef __KERNEL__
13821 +#ifndef __ASSEMBLY__
13822 +#ifdef CONFIG_X86_32
13823 +#define arch_mmap_check i386_mmap_check
13824 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
13825 +#endif
13826 +#endif
13827 +#endif
13828 +
13829 +#endif /* X86_MMAN_H */
13830 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
13831 index 5f55e69..e20bfb1 100644
13832 --- a/arch/x86/include/asm/mmu.h
13833 +++ b/arch/x86/include/asm/mmu.h
13834 @@ -9,7 +9,7 @@
13835 * we put the segment information here.
13836 */
13837 typedef struct {
13838 - void *ldt;
13839 + struct desc_struct *ldt;
13840 int size;
13841
13842 #ifdef CONFIG_X86_64
13843 @@ -18,7 +18,19 @@ typedef struct {
13844 #endif
13845
13846 struct mutex lock;
13847 - void *vdso;
13848 + unsigned long vdso;
13849 +
13850 +#ifdef CONFIG_X86_32
13851 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
13852 + unsigned long user_cs_base;
13853 + unsigned long user_cs_limit;
13854 +
13855 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
13856 + cpumask_t cpu_user_cs_mask;
13857 +#endif
13858 +
13859 +#endif
13860 +#endif
13861 } mm_context_t;
13862
13863 #ifdef CONFIG_SMP
13864 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
13865 index cdbf367..adb37ac 100644
13866 --- a/arch/x86/include/asm/mmu_context.h
13867 +++ b/arch/x86/include/asm/mmu_context.h
13868 @@ -24,6 +24,18 @@ void destroy_context(struct mm_struct *mm);
13869
13870 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
13871 {
13872 +
13873 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
13874 + unsigned int i;
13875 + pgd_t *pgd;
13876 +
13877 + pax_open_kernel();
13878 + pgd = get_cpu_pgd(smp_processor_id());
13879 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
13880 + set_pgd_batched(pgd+i, native_make_pgd(0));
13881 + pax_close_kernel();
13882 +#endif
13883 +
13884 #ifdef CONFIG_SMP
13885 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
13886 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
13887 @@ -34,16 +46,30 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
13888 struct task_struct *tsk)
13889 {
13890 unsigned cpu = smp_processor_id();
13891 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13892 + int tlbstate = TLBSTATE_OK;
13893 +#endif
13894
13895 if (likely(prev != next)) {
13896 #ifdef CONFIG_SMP
13897 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13898 + tlbstate = this_cpu_read(cpu_tlbstate.state);
13899 +#endif
13900 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
13901 this_cpu_write(cpu_tlbstate.active_mm, next);
13902 #endif
13903 cpumask_set_cpu(cpu, mm_cpumask(next));
13904
13905 /* Re-load page tables */
13906 +#ifdef CONFIG_PAX_PER_CPU_PGD
13907 + pax_open_kernel();
13908 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
13909 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
13910 + pax_close_kernel();
13911 + load_cr3(get_cpu_pgd(cpu));
13912 +#else
13913 load_cr3(next->pgd);
13914 +#endif
13915
13916 /* stop flush ipis for the previous mm */
13917 cpumask_clear_cpu(cpu, mm_cpumask(prev));
13918 @@ -53,9 +79,38 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
13919 */
13920 if (unlikely(prev->context.ldt != next->context.ldt))
13921 load_LDT_nolock(&next->context);
13922 - }
13923 +
13924 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
13925 + if (!(__supported_pte_mask & _PAGE_NX)) {
13926 + smp_mb__before_clear_bit();
13927 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
13928 + smp_mb__after_clear_bit();
13929 + cpu_set(cpu, next->context.cpu_user_cs_mask);
13930 + }
13931 +#endif
13932 +
13933 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13934 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
13935 + prev->context.user_cs_limit != next->context.user_cs_limit))
13936 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
13937 #ifdef CONFIG_SMP
13938 + else if (unlikely(tlbstate != TLBSTATE_OK))
13939 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
13940 +#endif
13941 +#endif
13942 +
13943 + }
13944 else {
13945 +
13946 +#ifdef CONFIG_PAX_PER_CPU_PGD
13947 + pax_open_kernel();
13948 + __clone_user_pgds(get_cpu_pgd(cpu), next->pgd);
13949 + __shadow_user_pgds(get_cpu_pgd(cpu) + USER_PGD_PTRS, next->pgd);
13950 + pax_close_kernel();
13951 + load_cr3(get_cpu_pgd(cpu));
13952 +#endif
13953 +
13954 +#ifdef CONFIG_SMP
13955 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
13956 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
13957
13958 @@ -64,11 +119,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
13959 * tlb flush IPI delivery. We must reload CR3
13960 * to make sure to use no freed page tables.
13961 */
13962 +
13963 +#ifndef CONFIG_PAX_PER_CPU_PGD
13964 load_cr3(next->pgd);
13965 +#endif
13966 +
13967 load_LDT_nolock(&next->context);
13968 +
13969 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
13970 + if (!(__supported_pte_mask & _PAGE_NX))
13971 + cpu_set(cpu, next->context.cpu_user_cs_mask);
13972 +#endif
13973 +
13974 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
13975 +#ifdef CONFIG_PAX_PAGEEXEC
13976 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
13977 +#endif
13978 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
13979 +#endif
13980 +
13981 }
13982 +#endif
13983 }
13984 -#endif
13985 }
13986
13987 #define activate_mm(prev, next) \
13988 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
13989 index e3b7819..b257c64 100644
13990 --- a/arch/x86/include/asm/module.h
13991 +++ b/arch/x86/include/asm/module.h
13992 @@ -5,6 +5,7 @@
13993
13994 #ifdef CONFIG_X86_64
13995 /* X86_64 does not define MODULE_PROC_FAMILY */
13996 +#define MODULE_PROC_FAMILY ""
13997 #elif defined CONFIG_M486
13998 #define MODULE_PROC_FAMILY "486 "
13999 #elif defined CONFIG_M586
14000 @@ -57,8 +58,20 @@
14001 #error unknown processor family
14002 #endif
14003
14004 -#ifdef CONFIG_X86_32
14005 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
14006 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
14007 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
14008 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
14009 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
14010 +#else
14011 +#define MODULE_PAX_KERNEXEC ""
14012 #endif
14013
14014 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14015 +#define MODULE_PAX_UDEREF "UDEREF "
14016 +#else
14017 +#define MODULE_PAX_UDEREF ""
14018 +#endif
14019 +
14020 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
14021 +
14022 #endif /* _ASM_X86_MODULE_H */
14023 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
14024 index 86f9301..b365cda 100644
14025 --- a/arch/x86/include/asm/nmi.h
14026 +++ b/arch/x86/include/asm/nmi.h
14027 @@ -40,11 +40,11 @@ struct nmiaction {
14028 nmi_handler_t handler;
14029 unsigned long flags;
14030 const char *name;
14031 -};
14032 +} __do_const;
14033
14034 #define register_nmi_handler(t, fn, fg, n, init...) \
14035 ({ \
14036 - static struct nmiaction init fn##_na = { \
14037 + static const struct nmiaction init fn##_na = { \
14038 .handler = (fn), \
14039 .name = (n), \
14040 .flags = (fg), \
14041 @@ -52,7 +52,7 @@ struct nmiaction {
14042 __register_nmi_handler((t), &fn##_na); \
14043 })
14044
14045 -int __register_nmi_handler(unsigned int, struct nmiaction *);
14046 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
14047
14048 void unregister_nmi_handler(unsigned int, const char *);
14049
14050 diff --git a/arch/x86/include/asm/page.h b/arch/x86/include/asm/page.h
14051 index c878924..21f4889 100644
14052 --- a/arch/x86/include/asm/page.h
14053 +++ b/arch/x86/include/asm/page.h
14054 @@ -52,6 +52,7 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
14055 __phys_addr_symbol(__phys_reloc_hide((unsigned long)(x)))
14056
14057 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
14058 +#define __early_va(x) ((void *)((unsigned long)(x)+__START_KERNEL_map - phys_base))
14059
14060 #define __boot_va(x) __va(x)
14061 #define __boot_pa(x) __pa(x)
14062 diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h
14063 index 0f1ddee..e2fc3d1 100644
14064 --- a/arch/x86/include/asm/page_64.h
14065 +++ b/arch/x86/include/asm/page_64.h
14066 @@ -7,9 +7,9 @@
14067
14068 /* duplicated to the one in bootmem.h */
14069 extern unsigned long max_pfn;
14070 -extern unsigned long phys_base;
14071 +extern const unsigned long phys_base;
14072
14073 -static inline unsigned long __phys_addr_nodebug(unsigned long x)
14074 +static inline unsigned long __intentional_overflow(-1) __phys_addr_nodebug(unsigned long x)
14075 {
14076 unsigned long y = x - __START_KERNEL_map;
14077
14078 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
14079 index cfdc9ee..3f7b5d6 100644
14080 --- a/arch/x86/include/asm/paravirt.h
14081 +++ b/arch/x86/include/asm/paravirt.h
14082 @@ -560,7 +560,7 @@ static inline pmd_t __pmd(pmdval_t val)
14083 return (pmd_t) { ret };
14084 }
14085
14086 -static inline pmdval_t pmd_val(pmd_t pmd)
14087 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
14088 {
14089 pmdval_t ret;
14090
14091 @@ -626,6 +626,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
14092 val);
14093 }
14094
14095 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14096 +{
14097 + pgdval_t val = native_pgd_val(pgd);
14098 +
14099 + if (sizeof(pgdval_t) > sizeof(long))
14100 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
14101 + val, (u64)val >> 32);
14102 + else
14103 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
14104 + val);
14105 +}
14106 +
14107 static inline void pgd_clear(pgd_t *pgdp)
14108 {
14109 set_pgd(pgdp, __pgd(0));
14110 @@ -710,6 +722,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
14111 pv_mmu_ops.set_fixmap(idx, phys, flags);
14112 }
14113
14114 +#ifdef CONFIG_PAX_KERNEXEC
14115 +static inline unsigned long pax_open_kernel(void)
14116 +{
14117 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
14118 +}
14119 +
14120 +static inline unsigned long pax_close_kernel(void)
14121 +{
14122 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
14123 +}
14124 +#else
14125 +static inline unsigned long pax_open_kernel(void) { return 0; }
14126 +static inline unsigned long pax_close_kernel(void) { return 0; }
14127 +#endif
14128 +
14129 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
14130
14131 static inline int arch_spin_is_locked(struct arch_spinlock *lock)
14132 @@ -926,7 +953,7 @@ extern void default_banner(void);
14133
14134 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
14135 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
14136 -#define PARA_INDIRECT(addr) *%cs:addr
14137 +#define PARA_INDIRECT(addr) *%ss:addr
14138 #endif
14139
14140 #define INTERRUPT_RETURN \
14141 @@ -1001,6 +1028,21 @@ extern void default_banner(void);
14142 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
14143 CLBR_NONE, \
14144 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
14145 +
14146 +#define GET_CR0_INTO_RDI \
14147 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
14148 + mov %rax,%rdi
14149 +
14150 +#define SET_RDI_INTO_CR0 \
14151 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
14152 +
14153 +#define GET_CR3_INTO_RDI \
14154 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
14155 + mov %rax,%rdi
14156 +
14157 +#define SET_RDI_INTO_CR3 \
14158 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
14159 +
14160 #endif /* CONFIG_X86_32 */
14161
14162 #endif /* __ASSEMBLY__ */
14163 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
14164 index 0db1fca..52310cc 100644
14165 --- a/arch/x86/include/asm/paravirt_types.h
14166 +++ b/arch/x86/include/asm/paravirt_types.h
14167 @@ -84,7 +84,7 @@ struct pv_init_ops {
14168 */
14169 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
14170 unsigned long addr, unsigned len);
14171 -};
14172 +} __no_const;
14173
14174
14175 struct pv_lazy_ops {
14176 @@ -98,7 +98,7 @@ struct pv_time_ops {
14177 unsigned long long (*sched_clock)(void);
14178 unsigned long long (*steal_clock)(int cpu);
14179 unsigned long (*get_tsc_khz)(void);
14180 -};
14181 +} __no_const;
14182
14183 struct pv_cpu_ops {
14184 /* hooks for various privileged instructions */
14185 @@ -192,7 +192,7 @@ struct pv_cpu_ops {
14186
14187 void (*start_context_switch)(struct task_struct *prev);
14188 void (*end_context_switch)(struct task_struct *next);
14189 -};
14190 +} __no_const;
14191
14192 struct pv_irq_ops {
14193 /*
14194 @@ -223,7 +223,7 @@ struct pv_apic_ops {
14195 unsigned long start_eip,
14196 unsigned long start_esp);
14197 #endif
14198 -};
14199 +} __no_const;
14200
14201 struct pv_mmu_ops {
14202 unsigned long (*read_cr2)(void);
14203 @@ -313,6 +313,7 @@ struct pv_mmu_ops {
14204 struct paravirt_callee_save make_pud;
14205
14206 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
14207 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
14208 #endif /* PAGETABLE_LEVELS == 4 */
14209 #endif /* PAGETABLE_LEVELS >= 3 */
14210
14211 @@ -324,6 +325,12 @@ struct pv_mmu_ops {
14212 an mfn. We can tell which is which from the index. */
14213 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
14214 phys_addr_t phys, pgprot_t flags);
14215 +
14216 +#ifdef CONFIG_PAX_KERNEXEC
14217 + unsigned long (*pax_open_kernel)(void);
14218 + unsigned long (*pax_close_kernel)(void);
14219 +#endif
14220 +
14221 };
14222
14223 struct arch_spinlock;
14224 @@ -334,7 +341,7 @@ struct pv_lock_ops {
14225 void (*spin_lock_flags)(struct arch_spinlock *lock, unsigned long flags);
14226 int (*spin_trylock)(struct arch_spinlock *lock);
14227 void (*spin_unlock)(struct arch_spinlock *lock);
14228 -};
14229 +} __no_const;
14230
14231 /* This contains all the paravirt structures: we get a convenient
14232 * number for each function using the offset which we use to indicate
14233 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
14234 index b4389a4..7024269 100644
14235 --- a/arch/x86/include/asm/pgalloc.h
14236 +++ b/arch/x86/include/asm/pgalloc.h
14237 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
14238 pmd_t *pmd, pte_t *pte)
14239 {
14240 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14241 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
14242 +}
14243 +
14244 +static inline void pmd_populate_user(struct mm_struct *mm,
14245 + pmd_t *pmd, pte_t *pte)
14246 +{
14247 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
14248 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
14249 }
14250
14251 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
14252
14253 #ifdef CONFIG_X86_PAE
14254 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
14255 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
14256 +{
14257 + pud_populate(mm, pudp, pmd);
14258 +}
14259 #else /* !CONFIG_X86_PAE */
14260 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14261 {
14262 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14263 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
14264 }
14265 +
14266 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
14267 +{
14268 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
14269 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
14270 +}
14271 #endif /* CONFIG_X86_PAE */
14272
14273 #if PAGETABLE_LEVELS > 3
14274 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14275 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
14276 }
14277
14278 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
14279 +{
14280 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
14281 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
14282 +}
14283 +
14284 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
14285 {
14286 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
14287 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
14288 index f2b489c..4f7e2e5 100644
14289 --- a/arch/x86/include/asm/pgtable-2level.h
14290 +++ b/arch/x86/include/asm/pgtable-2level.h
14291 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
14292
14293 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14294 {
14295 + pax_open_kernel();
14296 *pmdp = pmd;
14297 + pax_close_kernel();
14298 }
14299
14300 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14301 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
14302 index 4cc9f2b..5fd9226 100644
14303 --- a/arch/x86/include/asm/pgtable-3level.h
14304 +++ b/arch/x86/include/asm/pgtable-3level.h
14305 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14306
14307 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14308 {
14309 + pax_open_kernel();
14310 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
14311 + pax_close_kernel();
14312 }
14313
14314 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14315 {
14316 + pax_open_kernel();
14317 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
14318 + pax_close_kernel();
14319 }
14320
14321 /*
14322 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
14323 index 1e67223..dd6e7ea 100644
14324 --- a/arch/x86/include/asm/pgtable.h
14325 +++ b/arch/x86/include/asm/pgtable.h
14326 @@ -44,6 +44,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14327
14328 #ifndef __PAGETABLE_PUD_FOLDED
14329 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
14330 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
14331 #define pgd_clear(pgd) native_pgd_clear(pgd)
14332 #endif
14333
14334 @@ -81,12 +82,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
14335
14336 #define arch_end_context_switch(prev) do {} while(0)
14337
14338 +#define pax_open_kernel() native_pax_open_kernel()
14339 +#define pax_close_kernel() native_pax_close_kernel()
14340 #endif /* CONFIG_PARAVIRT */
14341
14342 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
14343 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
14344 +
14345 +#ifdef CONFIG_PAX_KERNEXEC
14346 +static inline unsigned long native_pax_open_kernel(void)
14347 +{
14348 + unsigned long cr0;
14349 +
14350 + preempt_disable();
14351 + barrier();
14352 + cr0 = read_cr0() ^ X86_CR0_WP;
14353 + BUG_ON(cr0 & X86_CR0_WP);
14354 + write_cr0(cr0);
14355 + return cr0 ^ X86_CR0_WP;
14356 +}
14357 +
14358 +static inline unsigned long native_pax_close_kernel(void)
14359 +{
14360 + unsigned long cr0;
14361 +
14362 + cr0 = read_cr0() ^ X86_CR0_WP;
14363 + BUG_ON(!(cr0 & X86_CR0_WP));
14364 + write_cr0(cr0);
14365 + barrier();
14366 + preempt_enable_no_resched();
14367 + return cr0 ^ X86_CR0_WP;
14368 +}
14369 +#else
14370 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
14371 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
14372 +#endif
14373 +
14374 /*
14375 * The following only work if pte_present() is true.
14376 * Undefined behaviour if not..
14377 */
14378 +static inline int pte_user(pte_t pte)
14379 +{
14380 + return pte_val(pte) & _PAGE_USER;
14381 +}
14382 +
14383 static inline int pte_dirty(pte_t pte)
14384 {
14385 return pte_flags(pte) & _PAGE_DIRTY;
14386 @@ -147,6 +187,11 @@ static inline unsigned long pud_pfn(pud_t pud)
14387 return (pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT;
14388 }
14389
14390 +static inline unsigned long pgd_pfn(pgd_t pgd)
14391 +{
14392 + return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT;
14393 +}
14394 +
14395 #define pte_page(pte) pfn_to_page(pte_pfn(pte))
14396
14397 static inline int pmd_large(pmd_t pte)
14398 @@ -200,9 +245,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
14399 return pte_clear_flags(pte, _PAGE_RW);
14400 }
14401
14402 +static inline pte_t pte_mkread(pte_t pte)
14403 +{
14404 + return __pte(pte_val(pte) | _PAGE_USER);
14405 +}
14406 +
14407 static inline pte_t pte_mkexec(pte_t pte)
14408 {
14409 - return pte_clear_flags(pte, _PAGE_NX);
14410 +#ifdef CONFIG_X86_PAE
14411 + if (__supported_pte_mask & _PAGE_NX)
14412 + return pte_clear_flags(pte, _PAGE_NX);
14413 + else
14414 +#endif
14415 + return pte_set_flags(pte, _PAGE_USER);
14416 +}
14417 +
14418 +static inline pte_t pte_exprotect(pte_t pte)
14419 +{
14420 +#ifdef CONFIG_X86_PAE
14421 + if (__supported_pte_mask & _PAGE_NX)
14422 + return pte_set_flags(pte, _PAGE_NX);
14423 + else
14424 +#endif
14425 + return pte_clear_flags(pte, _PAGE_USER);
14426 }
14427
14428 static inline pte_t pte_mkdirty(pte_t pte)
14429 @@ -394,6 +459,15 @@ pte_t *populate_extra_pte(unsigned long vaddr);
14430 #endif
14431
14432 #ifndef __ASSEMBLY__
14433 +
14434 +#ifdef CONFIG_PAX_PER_CPU_PGD
14435 +extern pgd_t cpu_pgd[NR_CPUS][PTRS_PER_PGD];
14436 +static inline pgd_t *get_cpu_pgd(unsigned int cpu)
14437 +{
14438 + return cpu_pgd[cpu];
14439 +}
14440 +#endif
14441 +
14442 #include <linux/mm_types.h>
14443 #include <linux/log2.h>
14444
14445 @@ -529,7 +603,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
14446 * Currently stuck as a macro due to indirect forward reference to
14447 * linux/mmzone.h's __section_mem_map_addr() definition:
14448 */
14449 -#define pud_page(pud) pfn_to_page(pud_val(pud) >> PAGE_SHIFT)
14450 +#define pud_page(pud) pfn_to_page((pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT)
14451
14452 /* Find an entry in the second-level page table.. */
14453 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
14454 @@ -569,7 +643,7 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
14455 * Currently stuck as a macro due to indirect forward reference to
14456 * linux/mmzone.h's __section_mem_map_addr() definition:
14457 */
14458 -#define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)
14459 +#define pgd_page(pgd) pfn_to_page((pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT)
14460
14461 /* to find an entry in a page-table-directory. */
14462 static inline unsigned long pud_index(unsigned long address)
14463 @@ -584,7 +658,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
14464
14465 static inline int pgd_bad(pgd_t pgd)
14466 {
14467 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
14468 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
14469 }
14470
14471 static inline int pgd_none(pgd_t pgd)
14472 @@ -607,7 +681,12 @@ static inline int pgd_none(pgd_t pgd)
14473 * pgd_offset() returns a (pgd_t *)
14474 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
14475 */
14476 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
14477 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
14478 +
14479 +#ifdef CONFIG_PAX_PER_CPU_PGD
14480 +#define pgd_offset_cpu(cpu, address) (get_cpu_pgd(cpu) + pgd_index(address))
14481 +#endif
14482 +
14483 /*
14484 * a shortcut which implies the use of the kernel's pgd, instead
14485 * of a process's
14486 @@ -618,6 +697,22 @@ static inline int pgd_none(pgd_t pgd)
14487 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
14488 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
14489
14490 +#ifdef CONFIG_X86_32
14491 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
14492 +#else
14493 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
14494 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
14495 +
14496 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14497 +#ifdef __ASSEMBLY__
14498 +#define pax_user_shadow_base pax_user_shadow_base(%rip)
14499 +#else
14500 +extern unsigned long pax_user_shadow_base;
14501 +#endif
14502 +#endif
14503 +
14504 +#endif
14505 +
14506 #ifndef __ASSEMBLY__
14507
14508 extern int direct_gbpages;
14509 @@ -784,11 +879,24 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
14510 * dst and src can be on the same page, but the range must not overlap,
14511 * and must not cross a page boundary.
14512 */
14513 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
14514 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
14515 {
14516 - memcpy(dst, src, count * sizeof(pgd_t));
14517 + pax_open_kernel();
14518 + while (count--)
14519 + *dst++ = *src++;
14520 + pax_close_kernel();
14521 }
14522
14523 +#ifdef CONFIG_PAX_PER_CPU_PGD
14524 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
14525 +#endif
14526 +
14527 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
14528 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
14529 +#else
14530 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
14531 +#endif
14532 +
14533 #define PTE_SHIFT ilog2(PTRS_PER_PTE)
14534 static inline int page_level_shift(enum pg_level level)
14535 {
14536 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
14537 index 9ee3221..b979c6b 100644
14538 --- a/arch/x86/include/asm/pgtable_32.h
14539 +++ b/arch/x86/include/asm/pgtable_32.h
14540 @@ -25,9 +25,6 @@
14541 struct mm_struct;
14542 struct vm_area_struct;
14543
14544 -extern pgd_t swapper_pg_dir[1024];
14545 -extern pgd_t initial_page_table[1024];
14546 -
14547 static inline void pgtable_cache_init(void) { }
14548 static inline void check_pgt_cache(void) { }
14549 void paging_init(void);
14550 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14551 # include <asm/pgtable-2level.h>
14552 #endif
14553
14554 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
14555 +extern pgd_t initial_page_table[PTRS_PER_PGD];
14556 +#ifdef CONFIG_X86_PAE
14557 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
14558 +#endif
14559 +
14560 #if defined(CONFIG_HIGHPTE)
14561 #define pte_offset_map(dir, address) \
14562 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
14563 @@ -62,12 +65,17 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
14564 /* Clear a kernel PTE and flush it from the TLB */
14565 #define kpte_clear_flush(ptep, vaddr) \
14566 do { \
14567 + pax_open_kernel(); \
14568 pte_clear(&init_mm, (vaddr), (ptep)); \
14569 + pax_close_kernel(); \
14570 __flush_tlb_one((vaddr)); \
14571 } while (0)
14572
14573 #endif /* !__ASSEMBLY__ */
14574
14575 +#define HAVE_ARCH_UNMAPPED_AREA
14576 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
14577 +
14578 /*
14579 * kern_addr_valid() is (1) for FLATMEM and (0) for
14580 * SPARSEMEM and DISCONTIGMEM
14581 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
14582 index ed5903b..c7fe163 100644
14583 --- a/arch/x86/include/asm/pgtable_32_types.h
14584 +++ b/arch/x86/include/asm/pgtable_32_types.h
14585 @@ -8,7 +8,7 @@
14586 */
14587 #ifdef CONFIG_X86_PAE
14588 # include <asm/pgtable-3level_types.h>
14589 -# define PMD_SIZE (1UL << PMD_SHIFT)
14590 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
14591 # define PMD_MASK (~(PMD_SIZE - 1))
14592 #else
14593 # include <asm/pgtable-2level_types.h>
14594 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
14595 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
14596 #endif
14597
14598 +#ifdef CONFIG_PAX_KERNEXEC
14599 +#ifndef __ASSEMBLY__
14600 +extern unsigned char MODULES_EXEC_VADDR[];
14601 +extern unsigned char MODULES_EXEC_END[];
14602 +#endif
14603 +#include <asm/boot.h>
14604 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
14605 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
14606 +#else
14607 +#define ktla_ktva(addr) (addr)
14608 +#define ktva_ktla(addr) (addr)
14609 +#endif
14610 +
14611 #define MODULES_VADDR VMALLOC_START
14612 #define MODULES_END VMALLOC_END
14613 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
14614 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
14615 index e22c1db..23a625a 100644
14616 --- a/arch/x86/include/asm/pgtable_64.h
14617 +++ b/arch/x86/include/asm/pgtable_64.h
14618 @@ -16,10 +16,14 @@
14619
14620 extern pud_t level3_kernel_pgt[512];
14621 extern pud_t level3_ident_pgt[512];
14622 +extern pud_t level3_vmalloc_start_pgt[512];
14623 +extern pud_t level3_vmalloc_end_pgt[512];
14624 +extern pud_t level3_vmemmap_pgt[512];
14625 +extern pud_t level2_vmemmap_pgt[512];
14626 extern pmd_t level2_kernel_pgt[512];
14627 extern pmd_t level2_fixmap_pgt[512];
14628 -extern pmd_t level2_ident_pgt[512];
14629 -extern pgd_t init_level4_pgt[];
14630 +extern pmd_t level2_ident_pgt[512*2];
14631 +extern pgd_t init_level4_pgt[512];
14632
14633 #define swapper_pg_dir init_level4_pgt
14634
14635 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
14636
14637 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
14638 {
14639 + pax_open_kernel();
14640 *pmdp = pmd;
14641 + pax_close_kernel();
14642 }
14643
14644 static inline void native_pmd_clear(pmd_t *pmd)
14645 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
14646
14647 static inline void native_set_pud(pud_t *pudp, pud_t pud)
14648 {
14649 + pax_open_kernel();
14650 *pudp = pud;
14651 + pax_close_kernel();
14652 }
14653
14654 static inline void native_pud_clear(pud_t *pud)
14655 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
14656
14657 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
14658 {
14659 + pax_open_kernel();
14660 + *pgdp = pgd;
14661 + pax_close_kernel();
14662 +}
14663 +
14664 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
14665 +{
14666 *pgdp = pgd;
14667 }
14668
14669 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
14670 index 2d88344..4679fc3 100644
14671 --- a/arch/x86/include/asm/pgtable_64_types.h
14672 +++ b/arch/x86/include/asm/pgtable_64_types.h
14673 @@ -61,6 +61,11 @@ typedef struct { pteval_t pte; } pte_t;
14674 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
14675 #define MODULES_END _AC(0xffffffffff000000, UL)
14676 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
14677 +#define MODULES_EXEC_VADDR MODULES_VADDR
14678 +#define MODULES_EXEC_END MODULES_END
14679 +
14680 +#define ktla_ktva(addr) (addr)
14681 +#define ktva_ktla(addr) (addr)
14682
14683 #define EARLY_DYNAMIC_PAGE_TABLES 64
14684
14685 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
14686 index e642300..0ef8f31 100644
14687 --- a/arch/x86/include/asm/pgtable_types.h
14688 +++ b/arch/x86/include/asm/pgtable_types.h
14689 @@ -16,13 +16,12 @@
14690 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
14691 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
14692 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
14693 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
14694 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
14695 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
14696 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
14697 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
14698 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
14699 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
14700 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
14701 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
14702 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
14703 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
14704
14705 /* If _PAGE_BIT_PRESENT is clear, we use these: */
14706 @@ -40,7 +39,6 @@
14707 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
14708 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
14709 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
14710 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
14711 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
14712 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
14713 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
14714 @@ -57,8 +55,10 @@
14715
14716 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
14717 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
14718 -#else
14719 +#elif defined(CONFIG_KMEMCHECK)
14720 #define _PAGE_NX (_AT(pteval_t, 0))
14721 +#else
14722 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
14723 #endif
14724
14725 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
14726 @@ -116,6 +116,9 @@
14727 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
14728 _PAGE_ACCESSED)
14729
14730 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
14731 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
14732 +
14733 #define __PAGE_KERNEL_EXEC \
14734 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
14735 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
14736 @@ -126,7 +129,7 @@
14737 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
14738 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
14739 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
14740 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
14741 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
14742 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
14743 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
14744 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
14745 @@ -188,8 +191,8 @@
14746 * bits are combined, this will alow user to access the high address mapped
14747 * VDSO in the presence of CONFIG_COMPAT_VDSO
14748 */
14749 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
14750 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
14751 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
14752 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
14753 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
14754 #endif
14755
14756 @@ -227,7 +230,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
14757 {
14758 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
14759 }
14760 +#endif
14761
14762 +#if PAGETABLE_LEVELS == 3
14763 +#include <asm-generic/pgtable-nopud.h>
14764 +#endif
14765 +
14766 +#if PAGETABLE_LEVELS == 2
14767 +#include <asm-generic/pgtable-nopmd.h>
14768 +#endif
14769 +
14770 +#ifndef __ASSEMBLY__
14771 #if PAGETABLE_LEVELS > 3
14772 typedef struct { pudval_t pud; } pud_t;
14773
14774 @@ -241,8 +254,6 @@ static inline pudval_t native_pud_val(pud_t pud)
14775 return pud.pud;
14776 }
14777 #else
14778 -#include <asm-generic/pgtable-nopud.h>
14779 -
14780 static inline pudval_t native_pud_val(pud_t pud)
14781 {
14782 return native_pgd_val(pud.pgd);
14783 @@ -262,8 +273,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
14784 return pmd.pmd;
14785 }
14786 #else
14787 -#include <asm-generic/pgtable-nopmd.h>
14788 -
14789 static inline pmdval_t native_pmd_val(pmd_t pmd)
14790 {
14791 return native_pgd_val(pmd.pud.pgd);
14792 @@ -303,7 +312,6 @@ typedef struct page *pgtable_t;
14793
14794 extern pteval_t __supported_pte_mask;
14795 extern void set_nx(void);
14796 -extern int nx_enabled;
14797
14798 #define pgprot_writecombine pgprot_writecombine
14799 extern pgprot_t pgprot_writecombine(pgprot_t prot);
14800 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
14801 index 22224b3..4080dab 100644
14802 --- a/arch/x86/include/asm/processor.h
14803 +++ b/arch/x86/include/asm/processor.h
14804 @@ -282,7 +282,7 @@ struct tss_struct {
14805
14806 } ____cacheline_aligned;
14807
14808 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
14809 +extern struct tss_struct init_tss[NR_CPUS];
14810
14811 /*
14812 * Save the original ist values for checking stack pointers during debugging
14813 @@ -823,11 +823,18 @@ static inline void spin_lock_prefetch(const void *x)
14814 */
14815 #define TASK_SIZE PAGE_OFFSET
14816 #define TASK_SIZE_MAX TASK_SIZE
14817 +
14818 +#ifdef CONFIG_PAX_SEGMEXEC
14819 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
14820 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
14821 +#else
14822 #define STACK_TOP TASK_SIZE
14823 -#define STACK_TOP_MAX STACK_TOP
14824 +#endif
14825 +
14826 +#define STACK_TOP_MAX TASK_SIZE
14827
14828 #define INIT_THREAD { \
14829 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
14830 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
14831 .vm86_info = NULL, \
14832 .sysenter_cs = __KERNEL_CS, \
14833 .io_bitmap_ptr = NULL, \
14834 @@ -841,7 +848,7 @@ static inline void spin_lock_prefetch(const void *x)
14835 */
14836 #define INIT_TSS { \
14837 .x86_tss = { \
14838 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
14839 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
14840 .ss0 = __KERNEL_DS, \
14841 .ss1 = __KERNEL_CS, \
14842 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
14843 @@ -852,11 +859,7 @@ static inline void spin_lock_prefetch(const void *x)
14844 extern unsigned long thread_saved_pc(struct task_struct *tsk);
14845
14846 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
14847 -#define KSTK_TOP(info) \
14848 -({ \
14849 - unsigned long *__ptr = (unsigned long *)(info); \
14850 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
14851 -})
14852 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
14853
14854 /*
14855 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
14856 @@ -871,7 +874,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14857 #define task_pt_regs(task) \
14858 ({ \
14859 struct pt_regs *__regs__; \
14860 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
14861 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
14862 __regs__ - 1; \
14863 })
14864
14865 @@ -881,13 +884,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14866 /*
14867 * User space process size. 47bits minus one guard page.
14868 */
14869 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
14870 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
14871
14872 /* This decides where the kernel will search for a free chunk of vm
14873 * space during mmap's.
14874 */
14875 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
14876 - 0xc0000000 : 0xFFFFe000)
14877 + 0xc0000000 : 0xFFFFf000)
14878
14879 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
14880 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
14881 @@ -898,11 +901,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
14882 #define STACK_TOP_MAX TASK_SIZE_MAX
14883
14884 #define INIT_THREAD { \
14885 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
14886 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
14887 }
14888
14889 #define INIT_TSS { \
14890 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
14891 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
14892 }
14893
14894 /*
14895 @@ -930,6 +933,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
14896 */
14897 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
14898
14899 +#ifdef CONFIG_PAX_SEGMEXEC
14900 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
14901 +#endif
14902 +
14903 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
14904
14905 /* Get/set a process' ability to use the timestamp counter instruction */
14906 @@ -970,7 +977,7 @@ unsigned long calc_aperfmperf_ratio(struct aperfmperf *old,
14907 return ratio;
14908 }
14909
14910 -extern unsigned long arch_align_stack(unsigned long sp);
14911 +#define arch_align_stack(x) ((x) & ~0xfUL)
14912 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
14913
14914 void default_idle(void);
14915 @@ -980,6 +987,6 @@ bool xen_set_default_idle(void);
14916 #define xen_set_default_idle 0
14917 #endif
14918
14919 -void stop_this_cpu(void *dummy);
14920 +void stop_this_cpu(void *dummy) __noreturn;
14921
14922 #endif /* _ASM_X86_PROCESSOR_H */
14923 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
14924 index 942a086..6c26446 100644
14925 --- a/arch/x86/include/asm/ptrace.h
14926 +++ b/arch/x86/include/asm/ptrace.h
14927 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
14928 }
14929
14930 /*
14931 - * user_mode_vm(regs) determines whether a register set came from user mode.
14932 + * user_mode(regs) determines whether a register set came from user mode.
14933 * This is true if V8086 mode was enabled OR if the register set was from
14934 * protected mode with RPL-3 CS value. This tricky test checks that with
14935 * one comparison. Many places in the kernel can bypass this full check
14936 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
14937 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
14938 + * be used.
14939 */
14940 -static inline int user_mode(struct pt_regs *regs)
14941 +static inline int user_mode_novm(struct pt_regs *regs)
14942 {
14943 #ifdef CONFIG_X86_32
14944 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
14945 #else
14946 - return !!(regs->cs & 3);
14947 + return !!(regs->cs & SEGMENT_RPL_MASK);
14948 #endif
14949 }
14950
14951 -static inline int user_mode_vm(struct pt_regs *regs)
14952 +static inline int user_mode(struct pt_regs *regs)
14953 {
14954 #ifdef CONFIG_X86_32
14955 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
14956 USER_RPL;
14957 #else
14958 - return user_mode(regs);
14959 + return user_mode_novm(regs);
14960 #endif
14961 }
14962
14963 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
14964 #ifdef CONFIG_X86_64
14965 static inline bool user_64bit_mode(struct pt_regs *regs)
14966 {
14967 + unsigned long cs = regs->cs & 0xffff;
14968 #ifndef CONFIG_PARAVIRT
14969 /*
14970 * On non-paravirt systems, this is the only long mode CPL 3
14971 * selector. We do not allow long mode selectors in the LDT.
14972 */
14973 - return regs->cs == __USER_CS;
14974 + return cs == __USER_CS;
14975 #else
14976 /* Headers are too twisted for this to go in paravirt.h. */
14977 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
14978 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
14979 #endif
14980 }
14981
14982 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
14983 * Traps from the kernel do not save sp and ss.
14984 * Use the helper function to retrieve sp.
14985 */
14986 - if (offset == offsetof(struct pt_regs, sp) &&
14987 - regs->cs == __KERNEL_CS)
14988 - return kernel_stack_pointer(regs);
14989 + if (offset == offsetof(struct pt_regs, sp)) {
14990 + unsigned long cs = regs->cs & 0xffff;
14991 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
14992 + return kernel_stack_pointer(regs);
14993 + }
14994 #endif
14995 return *(unsigned long *)((unsigned long)regs + offset);
14996 }
14997 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
14998 index 9c6b890..5305f53 100644
14999 --- a/arch/x86/include/asm/realmode.h
15000 +++ b/arch/x86/include/asm/realmode.h
15001 @@ -22,16 +22,14 @@ struct real_mode_header {
15002 #endif
15003 /* APM/BIOS reboot */
15004 u32 machine_real_restart_asm;
15005 -#ifdef CONFIG_X86_64
15006 u32 machine_real_restart_seg;
15007 -#endif
15008 };
15009
15010 /* This must match data at trampoline_32/64.S */
15011 struct trampoline_header {
15012 #ifdef CONFIG_X86_32
15013 u32 start;
15014 - u16 gdt_pad;
15015 + u16 boot_cs;
15016 u16 gdt_limit;
15017 u32 gdt_base;
15018 #else
15019 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
15020 index a82c4f1..ac45053 100644
15021 --- a/arch/x86/include/asm/reboot.h
15022 +++ b/arch/x86/include/asm/reboot.h
15023 @@ -6,13 +6,13 @@
15024 struct pt_regs;
15025
15026 struct machine_ops {
15027 - void (*restart)(char *cmd);
15028 - void (*halt)(void);
15029 - void (*power_off)(void);
15030 + void (* __noreturn restart)(char *cmd);
15031 + void (* __noreturn halt)(void);
15032 + void (* __noreturn power_off)(void);
15033 void (*shutdown)(void);
15034 void (*crash_shutdown)(struct pt_regs *);
15035 - void (*emergency_restart)(void);
15036 -};
15037 + void (* __noreturn emergency_restart)(void);
15038 +} __no_const;
15039
15040 extern struct machine_ops machine_ops;
15041
15042 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
15043 index cad82c9..2e5c5c1 100644
15044 --- a/arch/x86/include/asm/rwsem.h
15045 +++ b/arch/x86/include/asm/rwsem.h
15046 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
15047 {
15048 asm volatile("# beginning down_read\n\t"
15049 LOCK_PREFIX _ASM_INC "(%1)\n\t"
15050 +
15051 +#ifdef CONFIG_PAX_REFCOUNT
15052 + "jno 0f\n"
15053 + LOCK_PREFIX _ASM_DEC "(%1)\n"
15054 + "int $4\n0:\n"
15055 + _ASM_EXTABLE(0b, 0b)
15056 +#endif
15057 +
15058 /* adds 0x00000001 */
15059 " jns 1f\n"
15060 " call call_rwsem_down_read_failed\n"
15061 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
15062 "1:\n\t"
15063 " mov %1,%2\n\t"
15064 " add %3,%2\n\t"
15065 +
15066 +#ifdef CONFIG_PAX_REFCOUNT
15067 + "jno 0f\n"
15068 + "sub %3,%2\n"
15069 + "int $4\n0:\n"
15070 + _ASM_EXTABLE(0b, 0b)
15071 +#endif
15072 +
15073 " jle 2f\n\t"
15074 LOCK_PREFIX " cmpxchg %2,%0\n\t"
15075 " jnz 1b\n\t"
15076 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
15077 long tmp;
15078 asm volatile("# beginning down_write\n\t"
15079 LOCK_PREFIX " xadd %1,(%2)\n\t"
15080 +
15081 +#ifdef CONFIG_PAX_REFCOUNT
15082 + "jno 0f\n"
15083 + "mov %1,(%2)\n"
15084 + "int $4\n0:\n"
15085 + _ASM_EXTABLE(0b, 0b)
15086 +#endif
15087 +
15088 /* adds 0xffff0001, returns the old value */
15089 " test " __ASM_SEL(%w1,%k1) "," __ASM_SEL(%w1,%k1) "\n\t"
15090 /* was the active mask 0 before? */
15091 @@ -155,6 +179,14 @@ static inline void __up_read(struct rw_semaphore *sem)
15092 long tmp;
15093 asm volatile("# beginning __up_read\n\t"
15094 LOCK_PREFIX " xadd %1,(%2)\n\t"
15095 +
15096 +#ifdef CONFIG_PAX_REFCOUNT
15097 + "jno 0f\n"
15098 + "mov %1,(%2)\n"
15099 + "int $4\n0:\n"
15100 + _ASM_EXTABLE(0b, 0b)
15101 +#endif
15102 +
15103 /* subtracts 1, returns the old value */
15104 " jns 1f\n\t"
15105 " call call_rwsem_wake\n" /* expects old value in %edx */
15106 @@ -173,6 +205,14 @@ static inline void __up_write(struct rw_semaphore *sem)
15107 long tmp;
15108 asm volatile("# beginning __up_write\n\t"
15109 LOCK_PREFIX " xadd %1,(%2)\n\t"
15110 +
15111 +#ifdef CONFIG_PAX_REFCOUNT
15112 + "jno 0f\n"
15113 + "mov %1,(%2)\n"
15114 + "int $4\n0:\n"
15115 + _ASM_EXTABLE(0b, 0b)
15116 +#endif
15117 +
15118 /* subtracts 0xffff0001, returns the old value */
15119 " jns 1f\n\t"
15120 " call call_rwsem_wake\n" /* expects old value in %edx */
15121 @@ -190,6 +230,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15122 {
15123 asm volatile("# beginning __downgrade_write\n\t"
15124 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
15125 +
15126 +#ifdef CONFIG_PAX_REFCOUNT
15127 + "jno 0f\n"
15128 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
15129 + "int $4\n0:\n"
15130 + _ASM_EXTABLE(0b, 0b)
15131 +#endif
15132 +
15133 /*
15134 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
15135 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
15136 @@ -208,7 +256,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
15137 */
15138 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15139 {
15140 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
15141 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
15142 +
15143 +#ifdef CONFIG_PAX_REFCOUNT
15144 + "jno 0f\n"
15145 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
15146 + "int $4\n0:\n"
15147 + _ASM_EXTABLE(0b, 0b)
15148 +#endif
15149 +
15150 : "+m" (sem->count)
15151 : "er" (delta));
15152 }
15153 @@ -218,7 +274,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
15154 */
15155 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
15156 {
15157 - return delta + xadd(&sem->count, delta);
15158 + return delta + xadd_check_overflow(&sem->count, delta);
15159 }
15160
15161 #endif /* __KERNEL__ */
15162 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
15163 index c48a950..c6d7468 100644
15164 --- a/arch/x86/include/asm/segment.h
15165 +++ b/arch/x86/include/asm/segment.h
15166 @@ -64,10 +64,15 @@
15167 * 26 - ESPFIX small SS
15168 * 27 - per-cpu [ offset to per-cpu data area ]
15169 * 28 - stack_canary-20 [ for stack protector ]
15170 - * 29 - unused
15171 - * 30 - unused
15172 + * 29 - PCI BIOS CS
15173 + * 30 - PCI BIOS DS
15174 * 31 - TSS for double fault handler
15175 */
15176 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
15177 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
15178 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
15179 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
15180 +
15181 #define GDT_ENTRY_TLS_MIN 6
15182 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
15183
15184 @@ -79,6 +84,8 @@
15185
15186 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
15187
15188 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
15189 +
15190 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
15191
15192 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
15193 @@ -104,6 +111,12 @@
15194 #define __KERNEL_STACK_CANARY 0
15195 #endif
15196
15197 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
15198 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
15199 +
15200 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
15201 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
15202 +
15203 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
15204
15205 /*
15206 @@ -141,7 +154,7 @@
15207 */
15208
15209 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
15210 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
15211 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
15212
15213
15214 #else
15215 @@ -165,6 +178,8 @@
15216 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
15217 #define __USER32_DS __USER_DS
15218
15219 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
15220 +
15221 #define GDT_ENTRY_TSS 8 /* needs two entries */
15222 #define GDT_ENTRY_LDT 10 /* needs two entries */
15223 #define GDT_ENTRY_TLS_MIN 12
15224 @@ -185,6 +200,7 @@
15225 #endif
15226
15227 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
15228 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
15229 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
15230 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
15231 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
15232 @@ -265,7 +281,7 @@ static inline unsigned long get_limit(unsigned long segment)
15233 {
15234 unsigned long __limit;
15235 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
15236 - return __limit + 1;
15237 + return __limit;
15238 }
15239
15240 #endif /* !__ASSEMBLY__ */
15241 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
15242 index b073aae..39f9bdd 100644
15243 --- a/arch/x86/include/asm/smp.h
15244 +++ b/arch/x86/include/asm/smp.h
15245 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
15246 /* cpus sharing the last level cache: */
15247 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
15248 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
15249 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
15250 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
15251
15252 static inline struct cpumask *cpu_sibling_mask(int cpu)
15253 {
15254 @@ -79,7 +79,7 @@ struct smp_ops {
15255
15256 void (*send_call_func_ipi)(const struct cpumask *mask);
15257 void (*send_call_func_single_ipi)(int cpu);
15258 -};
15259 +} __no_const;
15260
15261 /* Globals due to paravirt */
15262 extern void set_cpu_sibling_map(int cpu);
15263 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus __cpuinitdata;
15264 extern int safe_smp_processor_id(void);
15265
15266 #elif defined(CONFIG_X86_64_SMP)
15267 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15268 -
15269 -#define stack_smp_processor_id() \
15270 -({ \
15271 - struct thread_info *ti; \
15272 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
15273 - ti->cpu; \
15274 -})
15275 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
15276 +#define stack_smp_processor_id() raw_smp_processor_id()
15277 #define safe_smp_processor_id() smp_processor_id()
15278
15279 #endif
15280 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
15281 index 33692ea..350a534 100644
15282 --- a/arch/x86/include/asm/spinlock.h
15283 +++ b/arch/x86/include/asm/spinlock.h
15284 @@ -172,6 +172,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
15285 static inline void arch_read_lock(arch_rwlock_t *rw)
15286 {
15287 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
15288 +
15289 +#ifdef CONFIG_PAX_REFCOUNT
15290 + "jno 0f\n"
15291 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
15292 + "int $4\n0:\n"
15293 + _ASM_EXTABLE(0b, 0b)
15294 +#endif
15295 +
15296 "jns 1f\n"
15297 "call __read_lock_failed\n\t"
15298 "1:\n"
15299 @@ -181,6 +189,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
15300 static inline void arch_write_lock(arch_rwlock_t *rw)
15301 {
15302 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
15303 +
15304 +#ifdef CONFIG_PAX_REFCOUNT
15305 + "jno 0f\n"
15306 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
15307 + "int $4\n0:\n"
15308 + _ASM_EXTABLE(0b, 0b)
15309 +#endif
15310 +
15311 "jz 1f\n"
15312 "call __write_lock_failed\n\t"
15313 "1:\n"
15314 @@ -210,13 +226,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
15315
15316 static inline void arch_read_unlock(arch_rwlock_t *rw)
15317 {
15318 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
15319 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
15320 +
15321 +#ifdef CONFIG_PAX_REFCOUNT
15322 + "jno 0f\n"
15323 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
15324 + "int $4\n0:\n"
15325 + _ASM_EXTABLE(0b, 0b)
15326 +#endif
15327 +
15328 :"+m" (rw->lock) : : "memory");
15329 }
15330
15331 static inline void arch_write_unlock(arch_rwlock_t *rw)
15332 {
15333 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
15334 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
15335 +
15336 +#ifdef CONFIG_PAX_REFCOUNT
15337 + "jno 0f\n"
15338 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
15339 + "int $4\n0:\n"
15340 + _ASM_EXTABLE(0b, 0b)
15341 +#endif
15342 +
15343 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
15344 }
15345
15346 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
15347 index 6a99859..03cb807 100644
15348 --- a/arch/x86/include/asm/stackprotector.h
15349 +++ b/arch/x86/include/asm/stackprotector.h
15350 @@ -47,7 +47,7 @@
15351 * head_32 for boot CPU and setup_per_cpu_areas() for others.
15352 */
15353 #define GDT_STACK_CANARY_INIT \
15354 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
15355 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
15356
15357 /*
15358 * Initialize the stackprotector canary value.
15359 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
15360
15361 static inline void load_stack_canary_segment(void)
15362 {
15363 -#ifdef CONFIG_X86_32
15364 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
15365 asm volatile ("mov %0, %%gs" : : "r" (0));
15366 #endif
15367 }
15368 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
15369 index 70bbe39..4ae2bd4 100644
15370 --- a/arch/x86/include/asm/stacktrace.h
15371 +++ b/arch/x86/include/asm/stacktrace.h
15372 @@ -11,28 +11,20 @@
15373
15374 extern int kstack_depth_to_print;
15375
15376 -struct thread_info;
15377 +struct task_struct;
15378 struct stacktrace_ops;
15379
15380 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
15381 - unsigned long *stack,
15382 - unsigned long bp,
15383 - const struct stacktrace_ops *ops,
15384 - void *data,
15385 - unsigned long *end,
15386 - int *graph);
15387 +typedef unsigned long walk_stack_t(struct task_struct *task,
15388 + void *stack_start,
15389 + unsigned long *stack,
15390 + unsigned long bp,
15391 + const struct stacktrace_ops *ops,
15392 + void *data,
15393 + unsigned long *end,
15394 + int *graph);
15395
15396 -extern unsigned long
15397 -print_context_stack(struct thread_info *tinfo,
15398 - unsigned long *stack, unsigned long bp,
15399 - const struct stacktrace_ops *ops, void *data,
15400 - unsigned long *end, int *graph);
15401 -
15402 -extern unsigned long
15403 -print_context_stack_bp(struct thread_info *tinfo,
15404 - unsigned long *stack, unsigned long bp,
15405 - const struct stacktrace_ops *ops, void *data,
15406 - unsigned long *end, int *graph);
15407 +extern walk_stack_t print_context_stack;
15408 +extern walk_stack_t print_context_stack_bp;
15409
15410 /* Generic stack tracer with callbacks */
15411
15412 @@ -40,7 +32,7 @@ struct stacktrace_ops {
15413 void (*address)(void *data, unsigned long address, int reliable);
15414 /* On negative return stop dumping */
15415 int (*stack)(void *data, char *name);
15416 - walk_stack_t walk_stack;
15417 + walk_stack_t *walk_stack;
15418 };
15419
15420 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
15421 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
15422 index 4ec45b3..a4f0a8a 100644
15423 --- a/arch/x86/include/asm/switch_to.h
15424 +++ b/arch/x86/include/asm/switch_to.h
15425 @@ -108,7 +108,7 @@ do { \
15426 "call __switch_to\n\t" \
15427 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
15428 __switch_canary \
15429 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
15430 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
15431 "movq %%rax,%%rdi\n\t" \
15432 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
15433 "jnz ret_from_fork\n\t" \
15434 @@ -119,7 +119,7 @@ do { \
15435 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
15436 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
15437 [_tif_fork] "i" (_TIF_FORK), \
15438 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
15439 + [thread_info] "m" (current_tinfo), \
15440 [current_task] "m" (current_task) \
15441 __switch_canary_iparam \
15442 : "memory", "cc" __EXTRA_CLOBBER)
15443 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
15444 index a1df6e8..e002940 100644
15445 --- a/arch/x86/include/asm/thread_info.h
15446 +++ b/arch/x86/include/asm/thread_info.h
15447 @@ -10,6 +10,7 @@
15448 #include <linux/compiler.h>
15449 #include <asm/page.h>
15450 #include <asm/types.h>
15451 +#include <asm/percpu.h>
15452
15453 /*
15454 * low level task data that entry.S needs immediate access to
15455 @@ -23,7 +24,6 @@ struct exec_domain;
15456 #include <linux/atomic.h>
15457
15458 struct thread_info {
15459 - struct task_struct *task; /* main task structure */
15460 struct exec_domain *exec_domain; /* execution domain */
15461 __u32 flags; /* low level flags */
15462 __u32 status; /* thread synchronous flags */
15463 @@ -33,19 +33,13 @@ struct thread_info {
15464 mm_segment_t addr_limit;
15465 struct restart_block restart_block;
15466 void __user *sysenter_return;
15467 -#ifdef CONFIG_X86_32
15468 - unsigned long previous_esp; /* ESP of the previous stack in
15469 - case of nested (IRQ) stacks
15470 - */
15471 - __u8 supervisor_stack[0];
15472 -#endif
15473 + unsigned long lowest_stack;
15474 unsigned int sig_on_uaccess_error:1;
15475 unsigned int uaccess_err:1; /* uaccess failed */
15476 };
15477
15478 -#define INIT_THREAD_INFO(tsk) \
15479 +#define INIT_THREAD_INFO \
15480 { \
15481 - .task = &tsk, \
15482 .exec_domain = &default_exec_domain, \
15483 .flags = 0, \
15484 .cpu = 0, \
15485 @@ -56,7 +50,7 @@ struct thread_info {
15486 }, \
15487 }
15488
15489 -#define init_thread_info (init_thread_union.thread_info)
15490 +#define init_thread_info (init_thread_union.stack)
15491 #define init_stack (init_thread_union.stack)
15492
15493 #else /* !__ASSEMBLY__ */
15494 @@ -97,6 +91,7 @@ struct thread_info {
15495 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
15496 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
15497 #define TIF_X32 30 /* 32-bit native x86-64 binary */
15498 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
15499
15500 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
15501 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
15502 @@ -121,17 +116,18 @@ struct thread_info {
15503 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
15504 #define _TIF_ADDR32 (1 << TIF_ADDR32)
15505 #define _TIF_X32 (1 << TIF_X32)
15506 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
15507
15508 /* work to do in syscall_trace_enter() */
15509 #define _TIF_WORK_SYSCALL_ENTRY \
15510 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
15511 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
15512 - _TIF_NOHZ)
15513 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15514
15515 /* work to do in syscall_trace_leave() */
15516 #define _TIF_WORK_SYSCALL_EXIT \
15517 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
15518 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
15519 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
15520
15521 /* work to do on interrupt/exception return */
15522 #define _TIF_WORK_MASK \
15523 @@ -142,7 +138,7 @@ struct thread_info {
15524 /* work to do on any return to user space */
15525 #define _TIF_ALLWORK_MASK \
15526 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
15527 - _TIF_NOHZ)
15528 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
15529
15530 /* Only used for 64 bit */
15531 #define _TIF_DO_NOTIFY_MASK \
15532 @@ -158,45 +154,40 @@ struct thread_info {
15533
15534 #define PREEMPT_ACTIVE 0x10000000
15535
15536 -#ifdef CONFIG_X86_32
15537 -
15538 -#define STACK_WARN (THREAD_SIZE/8)
15539 -/*
15540 - * macros/functions for gaining access to the thread information structure
15541 - *
15542 - * preempt_count needs to be 1 initially, until the scheduler is functional.
15543 - */
15544 -#ifndef __ASSEMBLY__
15545 -
15546 -
15547 -/* how to get the current stack pointer from C */
15548 -register unsigned long current_stack_pointer asm("esp") __used;
15549 -
15550 -/* how to get the thread information struct from C */
15551 -static inline struct thread_info *current_thread_info(void)
15552 -{
15553 - return (struct thread_info *)
15554 - (current_stack_pointer & ~(THREAD_SIZE - 1));
15555 -}
15556 -
15557 -#else /* !__ASSEMBLY__ */
15558 -
15559 +#ifdef __ASSEMBLY__
15560 /* how to get the thread information struct from ASM */
15561 #define GET_THREAD_INFO(reg) \
15562 - movl $-THREAD_SIZE, reg; \
15563 - andl %esp, reg
15564 + mov PER_CPU_VAR(current_tinfo), reg
15565
15566 /* use this one if reg already contains %esp */
15567 -#define GET_THREAD_INFO_WITH_ESP(reg) \
15568 - andl $-THREAD_SIZE, reg
15569 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
15570 +#else
15571 +/* how to get the thread information struct from C */
15572 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
15573 +
15574 +static __always_inline struct thread_info *current_thread_info(void)
15575 +{
15576 + return this_cpu_read_stable(current_tinfo);
15577 +}
15578 +#endif
15579 +
15580 +#ifdef CONFIG_X86_32
15581 +
15582 +#define STACK_WARN (THREAD_SIZE/8)
15583 +/*
15584 + * macros/functions for gaining access to the thread information structure
15585 + *
15586 + * preempt_count needs to be 1 initially, until the scheduler is functional.
15587 + */
15588 +#ifndef __ASSEMBLY__
15589 +
15590 +/* how to get the current stack pointer from C */
15591 +register unsigned long current_stack_pointer asm("esp") __used;
15592
15593 #endif
15594
15595 #else /* X86_32 */
15596
15597 -#include <asm/percpu.h>
15598 -#define KERNEL_STACK_OFFSET (5*8)
15599 -
15600 /*
15601 * macros/functions for gaining access to the thread information structure
15602 * preempt_count needs to be 1 initially, until the scheduler is functional.
15603 @@ -204,27 +195,8 @@ static inline struct thread_info *current_thread_info(void)
15604 #ifndef __ASSEMBLY__
15605 DECLARE_PER_CPU(unsigned long, kernel_stack);
15606
15607 -static inline struct thread_info *current_thread_info(void)
15608 -{
15609 - struct thread_info *ti;
15610 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
15611 - KERNEL_STACK_OFFSET - THREAD_SIZE);
15612 - return ti;
15613 -}
15614 -
15615 -#else /* !__ASSEMBLY__ */
15616 -
15617 -/* how to get the thread information struct from ASM */
15618 -#define GET_THREAD_INFO(reg) \
15619 - movq PER_CPU_VAR(kernel_stack),reg ; \
15620 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
15621 -
15622 -/*
15623 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
15624 - * a certain register (to be used in assembler memory operands).
15625 - */
15626 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
15627 -
15628 +/* how to get the current stack pointer from C */
15629 +register unsigned long current_stack_pointer asm("rsp") __used;
15630 #endif
15631
15632 #endif /* !X86_32 */
15633 @@ -283,5 +255,12 @@ static inline bool is_ia32_task(void)
15634 extern void arch_task_cache_init(void);
15635 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
15636 extern void arch_release_task_struct(struct task_struct *tsk);
15637 +
15638 +#define __HAVE_THREAD_FUNCTIONS
15639 +#define task_thread_info(task) (&(task)->tinfo)
15640 +#define task_stack_page(task) ((task)->stack)
15641 +#define setup_thread_stack(p, org) do {} while (0)
15642 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
15643 +
15644 #endif
15645 #endif /* _ASM_X86_THREAD_INFO_H */
15646 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
15647 index 5ee2687..70d5895 100644
15648 --- a/arch/x86/include/asm/uaccess.h
15649 +++ b/arch/x86/include/asm/uaccess.h
15650 @@ -7,6 +7,7 @@
15651 #include <linux/compiler.h>
15652 #include <linux/thread_info.h>
15653 #include <linux/string.h>
15654 +#include <linux/sched.h>
15655 #include <asm/asm.h>
15656 #include <asm/page.h>
15657 #include <asm/smap.h>
15658 @@ -29,7 +30,12 @@
15659
15660 #define get_ds() (KERNEL_DS)
15661 #define get_fs() (current_thread_info()->addr_limit)
15662 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15663 +void __set_fs(mm_segment_t x);
15664 +void set_fs(mm_segment_t x);
15665 +#else
15666 #define set_fs(x) (current_thread_info()->addr_limit = (x))
15667 +#endif
15668
15669 #define segment_eq(a, b) ((a).seg == (b).seg)
15670
15671 @@ -77,8 +83,33 @@
15672 * checks that the pointer is in the user space range - after calling
15673 * this function, memory access functions may still return -EFAULT.
15674 */
15675 -#define access_ok(type, addr, size) \
15676 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
15677 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
15678 +#define access_ok(type, addr, size) \
15679 +({ \
15680 + long __size = size; \
15681 + unsigned long __addr = (unsigned long)addr; \
15682 + unsigned long __addr_ao = __addr & PAGE_MASK; \
15683 + unsigned long __end_ao = __addr + __size - 1; \
15684 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
15685 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
15686 + while(__addr_ao <= __end_ao) { \
15687 + char __c_ao; \
15688 + __addr_ao += PAGE_SIZE; \
15689 + if (__size > PAGE_SIZE) \
15690 + cond_resched(); \
15691 + if (__get_user(__c_ao, (char __user *)__addr)) \
15692 + break; \
15693 + if (type != VERIFY_WRITE) { \
15694 + __addr = __addr_ao; \
15695 + continue; \
15696 + } \
15697 + if (__put_user(__c_ao, (char __user *)__addr)) \
15698 + break; \
15699 + __addr = __addr_ao; \
15700 + } \
15701 + } \
15702 + __ret_ao; \
15703 +})
15704
15705 /*
15706 * The exception table consists of pairs of addresses relative to the
15707 @@ -176,13 +207,21 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
15708 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
15709 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
15710
15711 -
15712 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
15713 +#define __copyuser_seg "gs;"
15714 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
15715 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
15716 +#else
15717 +#define __copyuser_seg
15718 +#define __COPYUSER_SET_ES
15719 +#define __COPYUSER_RESTORE_ES
15720 +#endif
15721
15722 #ifdef CONFIG_X86_32
15723 #define __put_user_asm_u64(x, addr, err, errret) \
15724 asm volatile(ASM_STAC "\n" \
15725 - "1: movl %%eax,0(%2)\n" \
15726 - "2: movl %%edx,4(%2)\n" \
15727 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
15728 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
15729 "3: " ASM_CLAC "\n" \
15730 ".section .fixup,\"ax\"\n" \
15731 "4: movl %3,%0\n" \
15732 @@ -195,8 +234,8 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
15733
15734 #define __put_user_asm_ex_u64(x, addr) \
15735 asm volatile(ASM_STAC "\n" \
15736 - "1: movl %%eax,0(%1)\n" \
15737 - "2: movl %%edx,4(%1)\n" \
15738 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
15739 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
15740 "3: " ASM_CLAC "\n" \
15741 _ASM_EXTABLE_EX(1b, 2b) \
15742 _ASM_EXTABLE_EX(2b, 3b) \
15743 @@ -246,7 +285,7 @@ extern void __put_user_8(void);
15744 __typeof__(*(ptr)) __pu_val; \
15745 __chk_user_ptr(ptr); \
15746 might_fault(); \
15747 - __pu_val = x; \
15748 + __pu_val = (x); \
15749 switch (sizeof(*(ptr))) { \
15750 case 1: \
15751 __put_user_x(1, __pu_val, ptr, __ret_pu); \
15752 @@ -345,7 +384,7 @@ do { \
15753
15754 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
15755 asm volatile(ASM_STAC "\n" \
15756 - "1: mov"itype" %2,%"rtype"1\n" \
15757 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
15758 "2: " ASM_CLAC "\n" \
15759 ".section .fixup,\"ax\"\n" \
15760 "3: mov %3,%0\n" \
15761 @@ -353,7 +392,7 @@ do { \
15762 " jmp 2b\n" \
15763 ".previous\n" \
15764 _ASM_EXTABLE(1b, 3b) \
15765 - : "=r" (err), ltype(x) \
15766 + : "=r" (err), ltype (x) \
15767 : "m" (__m(addr)), "i" (errret), "0" (err))
15768
15769 #define __get_user_size_ex(x, ptr, size) \
15770 @@ -378,7 +417,7 @@ do { \
15771 } while (0)
15772
15773 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
15774 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
15775 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
15776 "2:\n" \
15777 _ASM_EXTABLE_EX(1b, 2b) \
15778 : ltype(x) : "m" (__m(addr)))
15779 @@ -395,13 +434,24 @@ do { \
15780 int __gu_err; \
15781 unsigned long __gu_val; \
15782 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
15783 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
15784 + (x) = (__typeof__(*(ptr)))__gu_val; \
15785 __gu_err; \
15786 })
15787
15788 /* FIXME: this hack is definitely wrong -AK */
15789 struct __large_struct { unsigned long buf[100]; };
15790 -#define __m(x) (*(struct __large_struct __user *)(x))
15791 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15792 +#define ____m(x) \
15793 +({ \
15794 + unsigned long ____x = (unsigned long)(x); \
15795 + if (____x < pax_user_shadow_base) \
15796 + ____x += pax_user_shadow_base; \
15797 + (typeof(x))____x; \
15798 +})
15799 +#else
15800 +#define ____m(x) (x)
15801 +#endif
15802 +#define __m(x) (*(struct __large_struct __user *)____m(x))
15803
15804 /*
15805 * Tell gcc we read from memory instead of writing: this is because
15806 @@ -410,7 +460,7 @@ struct __large_struct { unsigned long buf[100]; };
15807 */
15808 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
15809 asm volatile(ASM_STAC "\n" \
15810 - "1: mov"itype" %"rtype"1,%2\n" \
15811 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
15812 "2: " ASM_CLAC "\n" \
15813 ".section .fixup,\"ax\"\n" \
15814 "3: mov %3,%0\n" \
15815 @@ -418,10 +468,10 @@ struct __large_struct { unsigned long buf[100]; };
15816 ".previous\n" \
15817 _ASM_EXTABLE(1b, 3b) \
15818 : "=r"(err) \
15819 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
15820 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err))
15821
15822 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
15823 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
15824 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
15825 "2:\n" \
15826 _ASM_EXTABLE_EX(1b, 2b) \
15827 : : ltype(x), "m" (__m(addr)))
15828 @@ -460,8 +510,12 @@ struct __large_struct { unsigned long buf[100]; };
15829 * On error, the variable @x is set to zero.
15830 */
15831
15832 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15833 +#define __get_user(x, ptr) get_user((x), (ptr))
15834 +#else
15835 #define __get_user(x, ptr) \
15836 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
15837 +#endif
15838
15839 /**
15840 * __put_user: - Write a simple value into user space, with less checking.
15841 @@ -483,8 +537,12 @@ struct __large_struct { unsigned long buf[100]; };
15842 * Returns zero on success, or -EFAULT on error.
15843 */
15844
15845 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15846 +#define __put_user(x, ptr) put_user((x), (ptr))
15847 +#else
15848 #define __put_user(x, ptr) \
15849 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
15850 +#endif
15851
15852 #define __get_user_unaligned __get_user
15853 #define __put_user_unaligned __put_user
15854 @@ -502,7 +560,7 @@ struct __large_struct { unsigned long buf[100]; };
15855 #define get_user_ex(x, ptr) do { \
15856 unsigned long __gue_val; \
15857 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
15858 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
15859 + (x) = (__typeof__(*(ptr)))__gue_val; \
15860 } while (0)
15861
15862 #define put_user_try uaccess_try
15863 @@ -519,8 +577,8 @@ strncpy_from_user(char *dst, const char __user *src, long count);
15864 extern __must_check long strlen_user(const char __user *str);
15865 extern __must_check long strnlen_user(const char __user *str, long n);
15866
15867 -unsigned long __must_check clear_user(void __user *mem, unsigned long len);
15868 -unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
15869 +unsigned long __must_check clear_user(void __user *mem, unsigned long len) __size_overflow(2);
15870 +unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
15871
15872 /*
15873 * movsl can be slow when source and dest are not both 8-byte aligned
15874 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
15875 index 7f760a9..04b1c65 100644
15876 --- a/arch/x86/include/asm/uaccess_32.h
15877 +++ b/arch/x86/include/asm/uaccess_32.h
15878 @@ -11,15 +11,15 @@
15879 #include <asm/page.h>
15880
15881 unsigned long __must_check __copy_to_user_ll
15882 - (void __user *to, const void *from, unsigned long n);
15883 + (void __user *to, const void *from, unsigned long n) __size_overflow(3);
15884 unsigned long __must_check __copy_from_user_ll
15885 - (void *to, const void __user *from, unsigned long n);
15886 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15887 unsigned long __must_check __copy_from_user_ll_nozero
15888 - (void *to, const void __user *from, unsigned long n);
15889 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15890 unsigned long __must_check __copy_from_user_ll_nocache
15891 - (void *to, const void __user *from, unsigned long n);
15892 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15893 unsigned long __must_check __copy_from_user_ll_nocache_nozero
15894 - (void *to, const void __user *from, unsigned long n);
15895 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
15896
15897 /**
15898 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking.
15899 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
15900 static __always_inline unsigned long __must_check
15901 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
15902 {
15903 + if ((long)n < 0)
15904 + return n;
15905 +
15906 + check_object_size(from, n, true);
15907 +
15908 if (__builtin_constant_p(n)) {
15909 unsigned long ret;
15910
15911 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
15912 __copy_to_user(void __user *to, const void *from, unsigned long n)
15913 {
15914 might_fault();
15915 +
15916 return __copy_to_user_inatomic(to, from, n);
15917 }
15918
15919 static __always_inline unsigned long
15920 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
15921 {
15922 + if ((long)n < 0)
15923 + return n;
15924 +
15925 /* Avoid zeroing the tail if the copy fails..
15926 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
15927 * but as the zeroing behaviour is only significant when n is not
15928 @@ -137,6 +146,12 @@ static __always_inline unsigned long
15929 __copy_from_user(void *to, const void __user *from, unsigned long n)
15930 {
15931 might_fault();
15932 +
15933 + if ((long)n < 0)
15934 + return n;
15935 +
15936 + check_object_size(to, n, false);
15937 +
15938 if (__builtin_constant_p(n)) {
15939 unsigned long ret;
15940
15941 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
15942 const void __user *from, unsigned long n)
15943 {
15944 might_fault();
15945 +
15946 + if ((long)n < 0)
15947 + return n;
15948 +
15949 if (__builtin_constant_p(n)) {
15950 unsigned long ret;
15951
15952 @@ -181,15 +200,19 @@ static __always_inline unsigned long
15953 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
15954 unsigned long n)
15955 {
15956 - return __copy_from_user_ll_nocache_nozero(to, from, n);
15957 + if ((long)n < 0)
15958 + return n;
15959 +
15960 + return __copy_from_user_ll_nocache_nozero(to, from, n);
15961 }
15962
15963 -unsigned long __must_check copy_to_user(void __user *to,
15964 - const void *from, unsigned long n);
15965 -unsigned long __must_check _copy_from_user(void *to,
15966 - const void __user *from,
15967 - unsigned long n);
15968 -
15969 +extern void copy_to_user_overflow(void)
15970 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
15971 + __compiletime_error("copy_to_user() buffer size is not provably correct")
15972 +#else
15973 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
15974 +#endif
15975 +;
15976
15977 extern void copy_from_user_overflow(void)
15978 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
15979 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
15980 #endif
15981 ;
15982
15983 -static inline unsigned long __must_check copy_from_user(void *to,
15984 - const void __user *from,
15985 - unsigned long n)
15986 +/**
15987 + * copy_to_user: - Copy a block of data into user space.
15988 + * @to: Destination address, in user space.
15989 + * @from: Source address, in kernel space.
15990 + * @n: Number of bytes to copy.
15991 + *
15992 + * Context: User context only. This function may sleep.
15993 + *
15994 + * Copy data from kernel space to user space.
15995 + *
15996 + * Returns number of bytes that could not be copied.
15997 + * On success, this will be zero.
15998 + */
15999 +static inline unsigned long __must_check
16000 +copy_to_user(void __user *to, const void *from, unsigned long n)
16001 {
16002 - int sz = __compiletime_object_size(to);
16003 + size_t sz = __compiletime_object_size(from);
16004
16005 - if (likely(sz == -1 || sz >= n))
16006 - n = _copy_from_user(to, from, n);
16007 - else
16008 + if (unlikely(sz != (size_t)-1 && sz < n))
16009 + copy_to_user_overflow();
16010 + else if (access_ok(VERIFY_WRITE, to, n))
16011 + n = __copy_to_user(to, from, n);
16012 + return n;
16013 +}
16014 +
16015 +/**
16016 + * copy_from_user: - Copy a block of data from user space.
16017 + * @to: Destination address, in kernel space.
16018 + * @from: Source address, in user space.
16019 + * @n: Number of bytes to copy.
16020 + *
16021 + * Context: User context only. This function may sleep.
16022 + *
16023 + * Copy data from user space to kernel space.
16024 + *
16025 + * Returns number of bytes that could not be copied.
16026 + * On success, this will be zero.
16027 + *
16028 + * If some data could not be copied, this function will pad the copied
16029 + * data to the requested size using zero bytes.
16030 + */
16031 +static inline unsigned long __must_check
16032 +copy_from_user(void *to, const void __user *from, unsigned long n)
16033 +{
16034 + size_t sz = __compiletime_object_size(to);
16035 +
16036 + check_object_size(to, n, false);
16037 +
16038 + if (unlikely(sz != (size_t)-1 && sz < n))
16039 copy_from_user_overflow();
16040 -
16041 + else if (access_ok(VERIFY_READ, from, n))
16042 + n = __copy_from_user(to, from, n);
16043 + else if ((long)n > 0)
16044 + memset(to, 0, n);
16045 return n;
16046 }
16047
16048 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
16049 index 142810c..1f2a0a7 100644
16050 --- a/arch/x86/include/asm/uaccess_64.h
16051 +++ b/arch/x86/include/asm/uaccess_64.h
16052 @@ -10,6 +10,9 @@
16053 #include <asm/alternative.h>
16054 #include <asm/cpufeature.h>
16055 #include <asm/page.h>
16056 +#include <asm/pgtable.h>
16057 +
16058 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
16059
16060 /*
16061 * Copy To/From Userspace
16062 @@ -17,13 +20,13 @@
16063
16064 /* Handles exceptions in both to and from, but doesn't do access_ok */
16065 __must_check unsigned long
16066 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
16067 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
16068 __must_check unsigned long
16069 -copy_user_generic_string(void *to, const void *from, unsigned len);
16070 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
16071 __must_check unsigned long
16072 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
16073 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
16074
16075 -static __always_inline __must_check unsigned long
16076 +static __always_inline __must_check __size_overflow(3) unsigned long
16077 copy_user_generic(void *to, const void *from, unsigned len)
16078 {
16079 unsigned ret;
16080 @@ -41,142 +44,204 @@ copy_user_generic(void *to, const void *from, unsigned len)
16081 ASM_OUTPUT2("=a" (ret), "=D" (to), "=S" (from),
16082 "=d" (len)),
16083 "1" (to), "2" (from), "3" (len)
16084 - : "memory", "rcx", "r8", "r9", "r10", "r11");
16085 + : "memory", "rcx", "r8", "r9", "r11");
16086 return ret;
16087 }
16088
16089 +static __always_inline __must_check unsigned long
16090 +__copy_to_user(void __user *to, const void *from, unsigned long len);
16091 +static __always_inline __must_check unsigned long
16092 +__copy_from_user(void *to, const void __user *from, unsigned long len);
16093 __must_check unsigned long
16094 -_copy_to_user(void __user *to, const void *from, unsigned len);
16095 -__must_check unsigned long
16096 -_copy_from_user(void *to, const void __user *from, unsigned len);
16097 -__must_check unsigned long
16098 -copy_in_user(void __user *to, const void __user *from, unsigned len);
16099 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
16100 +
16101 +extern void copy_to_user_overflow(void)
16102 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16103 + __compiletime_error("copy_to_user() buffer size is not provably correct")
16104 +#else
16105 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
16106 +#endif
16107 +;
16108 +
16109 +extern void copy_from_user_overflow(void)
16110 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
16111 + __compiletime_error("copy_from_user() buffer size is not provably correct")
16112 +#else
16113 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
16114 +#endif
16115 +;
16116
16117 static inline unsigned long __must_check copy_from_user(void *to,
16118 const void __user *from,
16119 unsigned long n)
16120 {
16121 - int sz = __compiletime_object_size(to);
16122 -
16123 might_fault();
16124 - if (likely(sz == -1 || sz >= n))
16125 - n = _copy_from_user(to, from, n);
16126 -#ifdef CONFIG_DEBUG_VM
16127 - else
16128 - WARN(1, "Buffer overflow detected!\n");
16129 -#endif
16130 +
16131 + check_object_size(to, n, false);
16132 +
16133 + if (access_ok(VERIFY_READ, from, n))
16134 + n = __copy_from_user(to, from, n);
16135 + else if (n < INT_MAX)
16136 + memset(to, 0, n);
16137 return n;
16138 }
16139
16140 static __always_inline __must_check
16141 -int copy_to_user(void __user *dst, const void *src, unsigned size)
16142 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
16143 {
16144 might_fault();
16145
16146 - return _copy_to_user(dst, src, size);
16147 + if (access_ok(VERIFY_WRITE, dst, size))
16148 + size = __copy_to_user(dst, src, size);
16149 + return size;
16150 }
16151
16152 static __always_inline __must_check
16153 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
16154 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
16155 {
16156 - int ret = 0;
16157 + size_t sz = __compiletime_object_size(dst);
16158 + unsigned ret = 0;
16159
16160 might_fault();
16161 +
16162 + if (size > INT_MAX)
16163 + return size;
16164 +
16165 + check_object_size(dst, size, false);
16166 +
16167 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16168 + if (!__access_ok(VERIFY_READ, src, size))
16169 + return size;
16170 +#endif
16171 +
16172 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16173 + copy_from_user_overflow();
16174 + return size;
16175 + }
16176 +
16177 if (!__builtin_constant_p(size))
16178 - return copy_user_generic(dst, (__force void *)src, size);
16179 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16180 switch (size) {
16181 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
16182 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
16183 ret, "b", "b", "=q", 1);
16184 return ret;
16185 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
16186 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
16187 ret, "w", "w", "=r", 2);
16188 return ret;
16189 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
16190 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
16191 ret, "l", "k", "=r", 4);
16192 return ret;
16193 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
16194 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16195 ret, "q", "", "=r", 8);
16196 return ret;
16197 case 10:
16198 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16199 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16200 ret, "q", "", "=r", 10);
16201 if (unlikely(ret))
16202 return ret;
16203 __get_user_asm(*(u16 *)(8 + (char *)dst),
16204 - (u16 __user *)(8 + (char __user *)src),
16205 + (const u16 __user *)(8 + (const char __user *)src),
16206 ret, "w", "w", "=r", 2);
16207 return ret;
16208 case 16:
16209 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
16210 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
16211 ret, "q", "", "=r", 16);
16212 if (unlikely(ret))
16213 return ret;
16214 __get_user_asm(*(u64 *)(8 + (char *)dst),
16215 - (u64 __user *)(8 + (char __user *)src),
16216 + (const u64 __user *)(8 + (const char __user *)src),
16217 ret, "q", "", "=r", 8);
16218 return ret;
16219 default:
16220 - return copy_user_generic(dst, (__force void *)src, size);
16221 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16222 }
16223 }
16224
16225 static __always_inline __must_check
16226 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
16227 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
16228 {
16229 - int ret = 0;
16230 + size_t sz = __compiletime_object_size(src);
16231 + unsigned ret = 0;
16232
16233 might_fault();
16234 +
16235 + if (size > INT_MAX)
16236 + return size;
16237 +
16238 + check_object_size(src, size, true);
16239 +
16240 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16241 + if (!__access_ok(VERIFY_WRITE, dst, size))
16242 + return size;
16243 +#endif
16244 +
16245 + if (unlikely(sz != (size_t)-1 && sz < size)) {
16246 + copy_to_user_overflow();
16247 + return size;
16248 + }
16249 +
16250 if (!__builtin_constant_p(size))
16251 - return copy_user_generic((__force void *)dst, src, size);
16252 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16253 switch (size) {
16254 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
16255 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
16256 ret, "b", "b", "iq", 1);
16257 return ret;
16258 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
16259 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
16260 ret, "w", "w", "ir", 2);
16261 return ret;
16262 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
16263 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
16264 ret, "l", "k", "ir", 4);
16265 return ret;
16266 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
16267 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16268 ret, "q", "", "er", 8);
16269 return ret;
16270 case 10:
16271 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16272 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16273 ret, "q", "", "er", 10);
16274 if (unlikely(ret))
16275 return ret;
16276 asm("":::"memory");
16277 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
16278 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
16279 ret, "w", "w", "ir", 2);
16280 return ret;
16281 case 16:
16282 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
16283 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
16284 ret, "q", "", "er", 16);
16285 if (unlikely(ret))
16286 return ret;
16287 asm("":::"memory");
16288 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
16289 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
16290 ret, "q", "", "er", 8);
16291 return ret;
16292 default:
16293 - return copy_user_generic((__force void *)dst, src, size);
16294 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16295 }
16296 }
16297
16298 static __always_inline __must_check
16299 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16300 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
16301 {
16302 - int ret = 0;
16303 + unsigned ret = 0;
16304
16305 might_fault();
16306 +
16307 + if (size > INT_MAX)
16308 + return size;
16309 +
16310 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16311 + if (!__access_ok(VERIFY_READ, src, size))
16312 + return size;
16313 + if (!__access_ok(VERIFY_WRITE, dst, size))
16314 + return size;
16315 +#endif
16316 +
16317 if (!__builtin_constant_p(size))
16318 - return copy_user_generic((__force void *)dst,
16319 - (__force void *)src, size);
16320 + return copy_user_generic((__force_kernel void *)____m(dst),
16321 + (__force_kernel const void *)____m(src), size);
16322 switch (size) {
16323 case 1: {
16324 u8 tmp;
16325 - __get_user_asm(tmp, (u8 __user *)src,
16326 + __get_user_asm(tmp, (const u8 __user *)src,
16327 ret, "b", "b", "=q", 1);
16328 if (likely(!ret))
16329 __put_user_asm(tmp, (u8 __user *)dst,
16330 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16331 }
16332 case 2: {
16333 u16 tmp;
16334 - __get_user_asm(tmp, (u16 __user *)src,
16335 + __get_user_asm(tmp, (const u16 __user *)src,
16336 ret, "w", "w", "=r", 2);
16337 if (likely(!ret))
16338 __put_user_asm(tmp, (u16 __user *)dst,
16339 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16340
16341 case 4: {
16342 u32 tmp;
16343 - __get_user_asm(tmp, (u32 __user *)src,
16344 + __get_user_asm(tmp, (const u32 __user *)src,
16345 ret, "l", "k", "=r", 4);
16346 if (likely(!ret))
16347 __put_user_asm(tmp, (u32 __user *)dst,
16348 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16349 }
16350 case 8: {
16351 u64 tmp;
16352 - __get_user_asm(tmp, (u64 __user *)src,
16353 + __get_user_asm(tmp, (const u64 __user *)src,
16354 ret, "q", "", "=r", 8);
16355 if (likely(!ret))
16356 __put_user_asm(tmp, (u64 __user *)dst,
16357 @@ -212,41 +277,72 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
16358 return ret;
16359 }
16360 default:
16361 - return copy_user_generic((__force void *)dst,
16362 - (__force void *)src, size);
16363 + return copy_user_generic((__force_kernel void *)____m(dst),
16364 + (__force_kernel const void *)____m(src), size);
16365 }
16366 }
16367
16368 static __must_check __always_inline int
16369 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
16370 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
16371 {
16372 - return copy_user_generic(dst, (__force const void *)src, size);
16373 + if (size > INT_MAX)
16374 + return size;
16375 +
16376 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16377 + if (!__access_ok(VERIFY_READ, src, size))
16378 + return size;
16379 +#endif
16380 +
16381 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
16382 }
16383
16384 -static __must_check __always_inline int
16385 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
16386 +static __must_check __always_inline unsigned long
16387 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
16388 {
16389 - return copy_user_generic((__force void *)dst, src, size);
16390 + if (size > INT_MAX)
16391 + return size;
16392 +
16393 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16394 + if (!__access_ok(VERIFY_WRITE, dst, size))
16395 + return size;
16396 +#endif
16397 +
16398 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
16399 }
16400
16401 -extern long __copy_user_nocache(void *dst, const void __user *src,
16402 - unsigned size, int zerorest);
16403 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
16404 + unsigned long size, int zerorest) __size_overflow(3);
16405
16406 -static inline int
16407 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
16408 +static inline unsigned long __copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
16409 {
16410 might_sleep();
16411 +
16412 + if (size > INT_MAX)
16413 + return size;
16414 +
16415 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16416 + if (!__access_ok(VERIFY_READ, src, size))
16417 + return size;
16418 +#endif
16419 +
16420 return __copy_user_nocache(dst, src, size, 1);
16421 }
16422
16423 -static inline int
16424 -__copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16425 - unsigned size)
16426 +static inline unsigned long __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
16427 + unsigned long size)
16428 {
16429 + if (size > INT_MAX)
16430 + return size;
16431 +
16432 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16433 + if (!__access_ok(VERIFY_READ, src, size))
16434 + return size;
16435 +#endif
16436 +
16437 return __copy_user_nocache(dst, src, size, 0);
16438 }
16439
16440 -unsigned long
16441 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
16442 +extern unsigned long
16443 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
16444
16445 #endif /* _ASM_X86_UACCESS_64_H */
16446 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
16447 index 5b238981..77fdd78 100644
16448 --- a/arch/x86/include/asm/word-at-a-time.h
16449 +++ b/arch/x86/include/asm/word-at-a-time.h
16450 @@ -11,7 +11,7 @@
16451 * and shift, for example.
16452 */
16453 struct word_at_a_time {
16454 - const unsigned long one_bits, high_bits;
16455 + unsigned long one_bits, high_bits;
16456 };
16457
16458 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
16459 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
16460 index d8d9922..bf6cecb 100644
16461 --- a/arch/x86/include/asm/x86_init.h
16462 +++ b/arch/x86/include/asm/x86_init.h
16463 @@ -129,7 +129,7 @@ struct x86_init_ops {
16464 struct x86_init_timers timers;
16465 struct x86_init_iommu iommu;
16466 struct x86_init_pci pci;
16467 -};
16468 +} __no_const;
16469
16470 /**
16471 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
16472 @@ -140,7 +140,7 @@ struct x86_cpuinit_ops {
16473 void (*setup_percpu_clockev)(void);
16474 void (*early_percpu_clock_init)(void);
16475 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
16476 -};
16477 +} __no_const;
16478
16479 /**
16480 * struct x86_platform_ops - platform specific runtime functions
16481 @@ -166,7 +166,7 @@ struct x86_platform_ops {
16482 void (*save_sched_clock_state)(void);
16483 void (*restore_sched_clock_state)(void);
16484 void (*apic_post_init)(void);
16485 -};
16486 +} __no_const;
16487
16488 struct pci_dev;
16489 struct msi_msg;
16490 @@ -180,7 +180,7 @@ struct x86_msi_ops {
16491 void (*teardown_msi_irqs)(struct pci_dev *dev);
16492 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
16493 int (*setup_hpet_msi)(unsigned int irq, unsigned int id);
16494 -};
16495 +} __no_const;
16496
16497 struct IO_APIC_route_entry;
16498 struct io_apic_irq_attr;
16499 @@ -201,7 +201,7 @@ struct x86_io_apic_ops {
16500 unsigned int destination, int vector,
16501 struct io_apic_irq_attr *attr);
16502 void (*eoi_ioapic_pin)(int apic, int pin, int vector);
16503 -};
16504 +} __no_const;
16505
16506 extern struct x86_init_ops x86_init;
16507 extern struct x86_cpuinit_ops x86_cpuinit;
16508 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
16509 index 0415cda..b43d877 100644
16510 --- a/arch/x86/include/asm/xsave.h
16511 +++ b/arch/x86/include/asm/xsave.h
16512 @@ -71,7 +71,9 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16513 return -EFAULT;
16514
16515 __asm__ __volatile__(ASM_STAC "\n"
16516 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
16517 + "1:"
16518 + __copyuser_seg
16519 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
16520 "2: " ASM_CLAC "\n"
16521 ".section .fixup,\"ax\"\n"
16522 "3: movl $-1,%[err]\n"
16523 @@ -87,12 +89,14 @@ static inline int xsave_user(struct xsave_struct __user *buf)
16524 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
16525 {
16526 int err;
16527 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
16528 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
16529 u32 lmask = mask;
16530 u32 hmask = mask >> 32;
16531
16532 __asm__ __volatile__(ASM_STAC "\n"
16533 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16534 + "1:"
16535 + __copyuser_seg
16536 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
16537 "2: " ASM_CLAC "\n"
16538 ".section .fixup,\"ax\"\n"
16539 "3: movl $-1,%[err]\n"
16540 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
16541 index bbae024..e1528f9 100644
16542 --- a/arch/x86/include/uapi/asm/e820.h
16543 +++ b/arch/x86/include/uapi/asm/e820.h
16544 @@ -63,7 +63,7 @@ struct e820map {
16545 #define ISA_START_ADDRESS 0xa0000
16546 #define ISA_END_ADDRESS 0x100000
16547
16548 -#define BIOS_BEGIN 0x000a0000
16549 +#define BIOS_BEGIN 0x000c0000
16550 #define BIOS_END 0x00100000
16551
16552 #define BIOS_ROM_BASE 0xffe00000
16553 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
16554 index 7bd3bd3..5dac791 100644
16555 --- a/arch/x86/kernel/Makefile
16556 +++ b/arch/x86/kernel/Makefile
16557 @@ -22,7 +22,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
16558 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
16559 obj-$(CONFIG_IRQ_WORK) += irq_work.o
16560 obj-y += probe_roms.o
16561 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
16562 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
16563 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
16564 obj-y += syscall_$(BITS).o
16565 obj-$(CONFIG_X86_64) += vsyscall_64.o
16566 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
16567 index 230c8ea..f915130 100644
16568 --- a/arch/x86/kernel/acpi/boot.c
16569 +++ b/arch/x86/kernel/acpi/boot.c
16570 @@ -1361,7 +1361,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
16571 * If your system is blacklisted here, but you find that acpi=force
16572 * works for you, please contact linux-acpi@vger.kernel.org
16573 */
16574 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
16575 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
16576 /*
16577 * Boxes that need ACPI disabled
16578 */
16579 @@ -1436,7 +1436,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
16580 };
16581
16582 /* second table for DMI checks that should run after early-quirks */
16583 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
16584 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
16585 /*
16586 * HP laptops which use a DSDT reporting as HP/SB400/10000,
16587 * which includes some code which overrides all temperature
16588 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
16589 index b44577b..27d8443 100644
16590 --- a/arch/x86/kernel/acpi/sleep.c
16591 +++ b/arch/x86/kernel/acpi/sleep.c
16592 @@ -74,8 +74,12 @@ int acpi_suspend_lowlevel(void)
16593 #else /* CONFIG_64BIT */
16594 #ifdef CONFIG_SMP
16595 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
16596 +
16597 + pax_open_kernel();
16598 early_gdt_descr.address =
16599 (unsigned long)get_cpu_gdt_table(smp_processor_id());
16600 + pax_close_kernel();
16601 +
16602 initial_gs = per_cpu_offset(smp_processor_id());
16603 #endif
16604 initial_code = (unsigned long)wakeup_long64;
16605 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
16606 index d1daa66..59fecba 100644
16607 --- a/arch/x86/kernel/acpi/wakeup_32.S
16608 +++ b/arch/x86/kernel/acpi/wakeup_32.S
16609 @@ -29,13 +29,11 @@ wakeup_pmode_return:
16610 # and restore the stack ... but you need gdt for this to work
16611 movl saved_context_esp, %esp
16612
16613 - movl %cs:saved_magic, %eax
16614 - cmpl $0x12345678, %eax
16615 + cmpl $0x12345678, saved_magic
16616 jne bogus_magic
16617
16618 # jump to place where we left off
16619 - movl saved_eip, %eax
16620 - jmp *%eax
16621 + jmp *(saved_eip)
16622
16623 bogus_magic:
16624 jmp bogus_magic
16625 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
16626 index c15cf9a..0e63558 100644
16627 --- a/arch/x86/kernel/alternative.c
16628 +++ b/arch/x86/kernel/alternative.c
16629 @@ -268,6 +268,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
16630 */
16631 for (a = start; a < end; a++) {
16632 instr = (u8 *)&a->instr_offset + a->instr_offset;
16633 +
16634 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16635 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16636 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
16637 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16638 +#endif
16639 +
16640 replacement = (u8 *)&a->repl_offset + a->repl_offset;
16641 BUG_ON(a->replacementlen > a->instrlen);
16642 BUG_ON(a->instrlen > sizeof(insnbuf));
16643 @@ -299,10 +306,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
16644 for (poff = start; poff < end; poff++) {
16645 u8 *ptr = (u8 *)poff + *poff;
16646
16647 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16648 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16649 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16650 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16651 +#endif
16652 +
16653 if (!*poff || ptr < text || ptr >= text_end)
16654 continue;
16655 /* turn DS segment override prefix into lock prefix */
16656 - if (*ptr == 0x3e)
16657 + if (*ktla_ktva(ptr) == 0x3e)
16658 text_poke(ptr, ((unsigned char []){0xf0}), 1);
16659 }
16660 mutex_unlock(&text_mutex);
16661 @@ -317,10 +330,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
16662 for (poff = start; poff < end; poff++) {
16663 u8 *ptr = (u8 *)poff + *poff;
16664
16665 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
16666 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16667 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
16668 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
16669 +#endif
16670 +
16671 if (!*poff || ptr < text || ptr >= text_end)
16672 continue;
16673 /* turn lock prefix into DS segment override prefix */
16674 - if (*ptr == 0xf0)
16675 + if (*ktla_ktva(ptr) == 0xf0)
16676 text_poke(ptr, ((unsigned char []){0x3E}), 1);
16677 }
16678 mutex_unlock(&text_mutex);
16679 @@ -468,7 +487,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
16680
16681 BUG_ON(p->len > MAX_PATCH_LEN);
16682 /* prep the buffer with the original instructions */
16683 - memcpy(insnbuf, p->instr, p->len);
16684 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
16685 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
16686 (unsigned long)p->instr, p->len);
16687
16688 @@ -515,7 +534,7 @@ void __init alternative_instructions(void)
16689 if (!uniproc_patched || num_possible_cpus() == 1)
16690 free_init_pages("SMP alternatives",
16691 (unsigned long)__smp_locks,
16692 - (unsigned long)__smp_locks_end);
16693 + PAGE_ALIGN((unsigned long)__smp_locks_end));
16694 #endif
16695
16696 apply_paravirt(__parainstructions, __parainstructions_end);
16697 @@ -535,13 +554,17 @@ void __init alternative_instructions(void)
16698 * instructions. And on the local CPU you need to be protected again NMI or MCE
16699 * handlers seeing an inconsistent instruction while you patch.
16700 */
16701 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
16702 +void *__kprobes text_poke_early(void *addr, const void *opcode,
16703 size_t len)
16704 {
16705 unsigned long flags;
16706 local_irq_save(flags);
16707 - memcpy(addr, opcode, len);
16708 +
16709 + pax_open_kernel();
16710 + memcpy(ktla_ktva(addr), opcode, len);
16711 sync_core();
16712 + pax_close_kernel();
16713 +
16714 local_irq_restore(flags);
16715 /* Could also do a CLFLUSH here to speed up CPU recovery; but
16716 that causes hangs on some VIA CPUs. */
16717 @@ -563,36 +586,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
16718 */
16719 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
16720 {
16721 - unsigned long flags;
16722 - char *vaddr;
16723 + unsigned char *vaddr = ktla_ktva(addr);
16724 struct page *pages[2];
16725 - int i;
16726 + size_t i;
16727
16728 if (!core_kernel_text((unsigned long)addr)) {
16729 - pages[0] = vmalloc_to_page(addr);
16730 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
16731 + pages[0] = vmalloc_to_page(vaddr);
16732 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
16733 } else {
16734 - pages[0] = virt_to_page(addr);
16735 + pages[0] = virt_to_page(vaddr);
16736 WARN_ON(!PageReserved(pages[0]));
16737 - pages[1] = virt_to_page(addr + PAGE_SIZE);
16738 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
16739 }
16740 BUG_ON(!pages[0]);
16741 - local_irq_save(flags);
16742 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
16743 - if (pages[1])
16744 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
16745 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
16746 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
16747 - clear_fixmap(FIX_TEXT_POKE0);
16748 - if (pages[1])
16749 - clear_fixmap(FIX_TEXT_POKE1);
16750 - local_flush_tlb();
16751 - sync_core();
16752 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
16753 - that causes hangs on some VIA CPUs. */
16754 + text_poke_early(addr, opcode, len);
16755 for (i = 0; i < len; i++)
16756 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
16757 - local_irq_restore(flags);
16758 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
16759 return addr;
16760 }
16761
16762 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
16763 index 904611b..004dde6 100644
16764 --- a/arch/x86/kernel/apic/apic.c
16765 +++ b/arch/x86/kernel/apic/apic.c
16766 @@ -189,7 +189,7 @@ int first_system_vector = 0xfe;
16767 /*
16768 * Debug level, exported for io_apic.c
16769 */
16770 -unsigned int apic_verbosity;
16771 +int apic_verbosity;
16772
16773 int pic_mode;
16774
16775 @@ -1955,7 +1955,7 @@ void smp_error_interrupt(struct pt_regs *regs)
16776 apic_write(APIC_ESR, 0);
16777 v1 = apic_read(APIC_ESR);
16778 ack_APIC_irq();
16779 - atomic_inc(&irq_err_count);
16780 + atomic_inc_unchecked(&irq_err_count);
16781
16782 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
16783 smp_processor_id(), v0 , v1);
16784 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
16785 index 00c77cf..2dc6a2d 100644
16786 --- a/arch/x86/kernel/apic/apic_flat_64.c
16787 +++ b/arch/x86/kernel/apic/apic_flat_64.c
16788 @@ -157,7 +157,7 @@ static int flat_probe(void)
16789 return 1;
16790 }
16791
16792 -static struct apic apic_flat = {
16793 +static struct apic apic_flat __read_only = {
16794 .name = "flat",
16795 .probe = flat_probe,
16796 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
16797 @@ -271,7 +271,7 @@ static int physflat_probe(void)
16798 return 0;
16799 }
16800
16801 -static struct apic apic_physflat = {
16802 +static struct apic apic_physflat __read_only = {
16803
16804 .name = "physical flat",
16805 .probe = physflat_probe,
16806 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
16807 index e145f28..2752888 100644
16808 --- a/arch/x86/kernel/apic/apic_noop.c
16809 +++ b/arch/x86/kernel/apic/apic_noop.c
16810 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
16811 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
16812 }
16813
16814 -struct apic apic_noop = {
16815 +struct apic apic_noop __read_only = {
16816 .name = "noop",
16817 .probe = noop_probe,
16818 .acpi_madt_oem_check = NULL,
16819 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
16820 index d50e364..543bee3 100644
16821 --- a/arch/x86/kernel/apic/bigsmp_32.c
16822 +++ b/arch/x86/kernel/apic/bigsmp_32.c
16823 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
16824 return dmi_bigsmp;
16825 }
16826
16827 -static struct apic apic_bigsmp = {
16828 +static struct apic apic_bigsmp __read_only = {
16829
16830 .name = "bigsmp",
16831 .probe = probe_bigsmp,
16832 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
16833 index 0874799..a7a7892 100644
16834 --- a/arch/x86/kernel/apic/es7000_32.c
16835 +++ b/arch/x86/kernel/apic/es7000_32.c
16836 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
16837 return ret && es7000_apic_is_cluster();
16838 }
16839
16840 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
16841 -static struct apic __refdata apic_es7000_cluster = {
16842 +static struct apic apic_es7000_cluster __read_only = {
16843
16844 .name = "es7000",
16845 .probe = probe_es7000,
16846 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
16847 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
16848 };
16849
16850 -static struct apic __refdata apic_es7000 = {
16851 +static struct apic apic_es7000 __read_only = {
16852
16853 .name = "es7000",
16854 .probe = probe_es7000,
16855 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
16856 index 9ed796c..e930fe4 100644
16857 --- a/arch/x86/kernel/apic/io_apic.c
16858 +++ b/arch/x86/kernel/apic/io_apic.c
16859 @@ -1060,7 +1060,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
16860 }
16861 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
16862
16863 -void lock_vector_lock(void)
16864 +void lock_vector_lock(void) __acquires(vector_lock)
16865 {
16866 /* Used to the online set of cpus does not change
16867 * during assign_irq_vector.
16868 @@ -1068,7 +1068,7 @@ void lock_vector_lock(void)
16869 raw_spin_lock(&vector_lock);
16870 }
16871
16872 -void unlock_vector_lock(void)
16873 +void unlock_vector_lock(void) __releases(vector_lock)
16874 {
16875 raw_spin_unlock(&vector_lock);
16876 }
16877 @@ -2362,7 +2362,7 @@ static void ack_apic_edge(struct irq_data *data)
16878 ack_APIC_irq();
16879 }
16880
16881 -atomic_t irq_mis_count;
16882 +atomic_unchecked_t irq_mis_count;
16883
16884 #ifdef CONFIG_GENERIC_PENDING_IRQ
16885 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
16886 @@ -2503,7 +2503,7 @@ static void ack_apic_level(struct irq_data *data)
16887 * at the cpu.
16888 */
16889 if (!(v & (1 << (i & 0x1f)))) {
16890 - atomic_inc(&irq_mis_count);
16891 + atomic_inc_unchecked(&irq_mis_count);
16892
16893 eoi_ioapic_irq(irq, cfg);
16894 }
16895 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
16896 index d661ee9..791fd33 100644
16897 --- a/arch/x86/kernel/apic/numaq_32.c
16898 +++ b/arch/x86/kernel/apic/numaq_32.c
16899 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
16900 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
16901 }
16902
16903 -/* Use __refdata to keep false positive warning calm. */
16904 -static struct apic __refdata apic_numaq = {
16905 +static struct apic apic_numaq __read_only = {
16906
16907 .name = "NUMAQ",
16908 .probe = probe_numaq,
16909 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
16910 index eb35ef9..f184a21 100644
16911 --- a/arch/x86/kernel/apic/probe_32.c
16912 +++ b/arch/x86/kernel/apic/probe_32.c
16913 @@ -72,7 +72,7 @@ static int probe_default(void)
16914 return 1;
16915 }
16916
16917 -static struct apic apic_default = {
16918 +static struct apic apic_default __read_only = {
16919
16920 .name = "default",
16921 .probe = probe_default,
16922 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
16923 index 77c95c0..434f8a4 100644
16924 --- a/arch/x86/kernel/apic/summit_32.c
16925 +++ b/arch/x86/kernel/apic/summit_32.c
16926 @@ -486,7 +486,7 @@ void setup_summit(void)
16927 }
16928 #endif
16929
16930 -static struct apic apic_summit = {
16931 +static struct apic apic_summit __read_only = {
16932
16933 .name = "summit",
16934 .probe = probe_summit,
16935 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
16936 index c88baa4..757aee1 100644
16937 --- a/arch/x86/kernel/apic/x2apic_cluster.c
16938 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
16939 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
16940 return notifier_from_errno(err);
16941 }
16942
16943 -static struct notifier_block __refdata x2apic_cpu_notifier = {
16944 +static struct notifier_block x2apic_cpu_notifier = {
16945 .notifier_call = update_clusterinfo,
16946 };
16947
16948 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
16949 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
16950 }
16951
16952 -static struct apic apic_x2apic_cluster = {
16953 +static struct apic apic_x2apic_cluster __read_only = {
16954
16955 .name = "cluster x2apic",
16956 .probe = x2apic_cluster_probe,
16957 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
16958 index 562a76d..a003c0f 100644
16959 --- a/arch/x86/kernel/apic/x2apic_phys.c
16960 +++ b/arch/x86/kernel/apic/x2apic_phys.c
16961 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
16962 return apic == &apic_x2apic_phys;
16963 }
16964
16965 -static struct apic apic_x2apic_phys = {
16966 +static struct apic apic_x2apic_phys __read_only = {
16967
16968 .name = "physical x2apic",
16969 .probe = x2apic_phys_probe,
16970 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
16971 index 794f6eb..67e1db2 100644
16972 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
16973 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
16974 @@ -342,7 +342,7 @@ static int uv_probe(void)
16975 return apic == &apic_x2apic_uv_x;
16976 }
16977
16978 -static struct apic __refdata apic_x2apic_uv_x = {
16979 +static struct apic apic_x2apic_uv_x __read_only = {
16980
16981 .name = "UV large system",
16982 .probe = uv_probe,
16983 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
16984 index 53a4e27..038760a 100644
16985 --- a/arch/x86/kernel/apm_32.c
16986 +++ b/arch/x86/kernel/apm_32.c
16987 @@ -433,7 +433,7 @@ static DEFINE_MUTEX(apm_mutex);
16988 * This is for buggy BIOS's that refer to (real mode) segment 0x40
16989 * even though they are called in protected mode.
16990 */
16991 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
16992 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
16993 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
16994
16995 static const char driver_version[] = "1.16ac"; /* no spaces */
16996 @@ -611,7 +611,10 @@ static long __apm_bios_call(void *_call)
16997 BUG_ON(cpu != 0);
16998 gdt = get_cpu_gdt_table(cpu);
16999 save_desc_40 = gdt[0x40 / 8];
17000 +
17001 + pax_open_kernel();
17002 gdt[0x40 / 8] = bad_bios_desc;
17003 + pax_close_kernel();
17004
17005 apm_irq_save(flags);
17006 APM_DO_SAVE_SEGS;
17007 @@ -620,7 +623,11 @@ static long __apm_bios_call(void *_call)
17008 &call->esi);
17009 APM_DO_RESTORE_SEGS;
17010 apm_irq_restore(flags);
17011 +
17012 + pax_open_kernel();
17013 gdt[0x40 / 8] = save_desc_40;
17014 + pax_close_kernel();
17015 +
17016 put_cpu();
17017
17018 return call->eax & 0xff;
17019 @@ -687,7 +694,10 @@ static long __apm_bios_call_simple(void *_call)
17020 BUG_ON(cpu != 0);
17021 gdt = get_cpu_gdt_table(cpu);
17022 save_desc_40 = gdt[0x40 / 8];
17023 +
17024 + pax_open_kernel();
17025 gdt[0x40 / 8] = bad_bios_desc;
17026 + pax_close_kernel();
17027
17028 apm_irq_save(flags);
17029 APM_DO_SAVE_SEGS;
17030 @@ -695,7 +705,11 @@ static long __apm_bios_call_simple(void *_call)
17031 &call->eax);
17032 APM_DO_RESTORE_SEGS;
17033 apm_irq_restore(flags);
17034 +
17035 + pax_open_kernel();
17036 gdt[0x40 / 8] = save_desc_40;
17037 + pax_close_kernel();
17038 +
17039 put_cpu();
17040 return error;
17041 }
17042 @@ -2362,12 +2376,15 @@ static int __init apm_init(void)
17043 * code to that CPU.
17044 */
17045 gdt = get_cpu_gdt_table(0);
17046 +
17047 + pax_open_kernel();
17048 set_desc_base(&gdt[APM_CS >> 3],
17049 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
17050 set_desc_base(&gdt[APM_CS_16 >> 3],
17051 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
17052 set_desc_base(&gdt[APM_DS >> 3],
17053 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
17054 + pax_close_kernel();
17055
17056 proc_create("apm", 0, NULL, &apm_file_ops);
17057
17058 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
17059 index 2861082..6d4718e 100644
17060 --- a/arch/x86/kernel/asm-offsets.c
17061 +++ b/arch/x86/kernel/asm-offsets.c
17062 @@ -33,6 +33,8 @@ void common(void) {
17063 OFFSET(TI_status, thread_info, status);
17064 OFFSET(TI_addr_limit, thread_info, addr_limit);
17065 OFFSET(TI_preempt_count, thread_info, preempt_count);
17066 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
17067 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
17068
17069 BLANK();
17070 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
17071 @@ -53,8 +55,26 @@ void common(void) {
17072 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
17073 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
17074 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
17075 +
17076 +#ifdef CONFIG_PAX_KERNEXEC
17077 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
17078 #endif
17079
17080 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17081 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
17082 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
17083 +#ifdef CONFIG_X86_64
17084 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
17085 +#endif
17086 +#endif
17087 +
17088 +#endif
17089 +
17090 + BLANK();
17091 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
17092 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
17093 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
17094 +
17095 #ifdef CONFIG_XEN
17096 BLANK();
17097 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
17098 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
17099 index e7c798b..2b2019b 100644
17100 --- a/arch/x86/kernel/asm-offsets_64.c
17101 +++ b/arch/x86/kernel/asm-offsets_64.c
17102 @@ -77,6 +77,7 @@ int main(void)
17103 BLANK();
17104 #undef ENTRY
17105
17106 + DEFINE(TSS_size, sizeof(struct tss_struct));
17107 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
17108 BLANK();
17109
17110 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
17111 index b0684e4..22ccfd7 100644
17112 --- a/arch/x86/kernel/cpu/Makefile
17113 +++ b/arch/x86/kernel/cpu/Makefile
17114 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
17115 CFLAGS_REMOVE_perf_event.o = -pg
17116 endif
17117
17118 -# Make sure load_percpu_segment has no stackprotector
17119 -nostackp := $(call cc-option, -fno-stack-protector)
17120 -CFLAGS_common.o := $(nostackp)
17121 -
17122 obj-y := intel_cacheinfo.o scattered.o topology.o
17123 obj-y += proc.o capflags.o powerflags.o common.o
17124 obj-y += rdrand.o
17125 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
17126 index 5013a48..0782c53 100644
17127 --- a/arch/x86/kernel/cpu/amd.c
17128 +++ b/arch/x86/kernel/cpu/amd.c
17129 @@ -744,7 +744,7 @@ static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 *c,
17130 unsigned int size)
17131 {
17132 /* AMD errata T13 (order #21922) */
17133 - if ((c->x86 == 6)) {
17134 + if (c->x86 == 6) {
17135 /* Duron Rev A0 */
17136 if (c->x86_model == 3 && c->x86_mask == 0)
17137 size = 64;
17138 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
17139 index 22018f7..bc6f5e3 100644
17140 --- a/arch/x86/kernel/cpu/common.c
17141 +++ b/arch/x86/kernel/cpu/common.c
17142 @@ -88,60 +88,6 @@ static const struct cpu_dev __cpuinitconst default_cpu = {
17143
17144 static const struct cpu_dev *this_cpu __cpuinitdata = &default_cpu;
17145
17146 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
17147 -#ifdef CONFIG_X86_64
17148 - /*
17149 - * We need valid kernel segments for data and code in long mode too
17150 - * IRET will check the segment types kkeil 2000/10/28
17151 - * Also sysret mandates a special GDT layout
17152 - *
17153 - * TLS descriptors are currently at a different place compared to i386.
17154 - * Hopefully nobody expects them at a fixed place (Wine?)
17155 - */
17156 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
17157 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
17158 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
17159 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
17160 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
17161 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
17162 -#else
17163 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
17164 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17165 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
17166 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
17167 - /*
17168 - * Segments used for calling PnP BIOS have byte granularity.
17169 - * They code segments and data segments have fixed 64k limits,
17170 - * the transfer segment sizes are set at run time.
17171 - */
17172 - /* 32-bit code */
17173 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17174 - /* 16-bit code */
17175 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17176 - /* 16-bit data */
17177 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
17178 - /* 16-bit data */
17179 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
17180 - /* 16-bit data */
17181 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
17182 - /*
17183 - * The APM segments have byte granularity and their bases
17184 - * are set at run time. All have 64k limits.
17185 - */
17186 - /* 32-bit code */
17187 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
17188 - /* 16-bit code */
17189 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
17190 - /* data */
17191 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
17192 -
17193 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17194 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
17195 - GDT_STACK_CANARY_INIT
17196 -#endif
17197 -} };
17198 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
17199 -
17200 static int __init x86_xsave_setup(char *s)
17201 {
17202 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
17203 @@ -386,7 +332,7 @@ void switch_to_new_gdt(int cpu)
17204 {
17205 struct desc_ptr gdt_descr;
17206
17207 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
17208 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
17209 gdt_descr.size = GDT_SIZE - 1;
17210 load_gdt(&gdt_descr);
17211 /* Reload the per-cpu base */
17212 @@ -882,6 +828,10 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
17213 /* Filter out anything that depends on CPUID levels we don't have */
17214 filter_cpuid_features(c, true);
17215
17216 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
17217 + setup_clear_cpu_cap(X86_FEATURE_SEP);
17218 +#endif
17219 +
17220 /* If the model name is still unset, do table lookup. */
17221 if (!c->x86_model_id[0]) {
17222 const char *p;
17223 @@ -1069,10 +1019,12 @@ static __init int setup_disablecpuid(char *arg)
17224 }
17225 __setup("clearcpuid=", setup_disablecpuid);
17226
17227 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
17228 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
17229 +
17230 #ifdef CONFIG_X86_64
17231 struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
17232 -struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1,
17233 - (unsigned long) nmi_idt_table };
17234 +struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) nmi_idt_table };
17235
17236 DEFINE_PER_CPU_FIRST(union irq_stack_union,
17237 irq_stack_union) __aligned(PAGE_SIZE);
17238 @@ -1086,7 +1038,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
17239 EXPORT_PER_CPU_SYMBOL(current_task);
17240
17241 DEFINE_PER_CPU(unsigned long, kernel_stack) =
17242 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
17243 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
17244 EXPORT_PER_CPU_SYMBOL(kernel_stack);
17245
17246 DEFINE_PER_CPU(char *, irq_stack_ptr) =
17247 @@ -1231,7 +1183,7 @@ void __cpuinit cpu_init(void)
17248 load_ucode_ap();
17249
17250 cpu = stack_smp_processor_id();
17251 - t = &per_cpu(init_tss, cpu);
17252 + t = init_tss + cpu;
17253 oist = &per_cpu(orig_ist, cpu);
17254
17255 #ifdef CONFIG_NUMA
17256 @@ -1257,7 +1209,7 @@ void __cpuinit cpu_init(void)
17257 switch_to_new_gdt(cpu);
17258 loadsegment(fs, 0);
17259
17260 - load_idt((const struct desc_ptr *)&idt_descr);
17261 + load_idt(&idt_descr);
17262
17263 memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8);
17264 syscall_init();
17265 @@ -1266,7 +1218,6 @@ void __cpuinit cpu_init(void)
17266 wrmsrl(MSR_KERNEL_GS_BASE, 0);
17267 barrier();
17268
17269 - x86_configure_nx();
17270 enable_x2apic();
17271
17272 /*
17273 @@ -1318,7 +1269,7 @@ void __cpuinit cpu_init(void)
17274 {
17275 int cpu = smp_processor_id();
17276 struct task_struct *curr = current;
17277 - struct tss_struct *t = &per_cpu(init_tss, cpu);
17278 + struct tss_struct *t = init_tss + cpu;
17279 struct thread_struct *thread = &curr->thread;
17280
17281 show_ucode_info_early();
17282 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
17283 index 7c6f7d5..8cac382 100644
17284 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
17285 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
17286 @@ -1017,6 +1017,22 @@ static struct attribute *default_attrs[] = {
17287 };
17288
17289 #ifdef CONFIG_AMD_NB
17290 +static struct attribute *default_attrs_amd_nb[] = {
17291 + &type.attr,
17292 + &level.attr,
17293 + &coherency_line_size.attr,
17294 + &physical_line_partition.attr,
17295 + &ways_of_associativity.attr,
17296 + &number_of_sets.attr,
17297 + &size.attr,
17298 + &shared_cpu_map.attr,
17299 + &shared_cpu_list.attr,
17300 + NULL,
17301 + NULL,
17302 + NULL,
17303 + NULL
17304 +};
17305 +
17306 static struct attribute ** __cpuinit amd_l3_attrs(void)
17307 {
17308 static struct attribute **attrs;
17309 @@ -1027,18 +1043,7 @@ static struct attribute ** __cpuinit amd_l3_attrs(void)
17310
17311 n = ARRAY_SIZE(default_attrs);
17312
17313 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
17314 - n += 2;
17315 -
17316 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
17317 - n += 1;
17318 -
17319 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
17320 - if (attrs == NULL)
17321 - return attrs = default_attrs;
17322 -
17323 - for (n = 0; default_attrs[n]; n++)
17324 - attrs[n] = default_attrs[n];
17325 + attrs = default_attrs_amd_nb;
17326
17327 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
17328 attrs[n++] = &cache_disable_0.attr;
17329 @@ -1089,6 +1094,13 @@ static struct kobj_type ktype_cache = {
17330 .default_attrs = default_attrs,
17331 };
17332
17333 +#ifdef CONFIG_AMD_NB
17334 +static struct kobj_type ktype_cache_amd_nb = {
17335 + .sysfs_ops = &sysfs_ops,
17336 + .default_attrs = default_attrs_amd_nb,
17337 +};
17338 +#endif
17339 +
17340 static struct kobj_type ktype_percpu_entry = {
17341 .sysfs_ops = &sysfs_ops,
17342 };
17343 @@ -1154,20 +1166,26 @@ static int __cpuinit cache_add_dev(struct device *dev)
17344 return retval;
17345 }
17346
17347 +#ifdef CONFIG_AMD_NB
17348 + amd_l3_attrs();
17349 +#endif
17350 +
17351 for (i = 0; i < num_cache_leaves; i++) {
17352 + struct kobj_type *ktype;
17353 +
17354 this_object = INDEX_KOBJECT_PTR(cpu, i);
17355 this_object->cpu = cpu;
17356 this_object->index = i;
17357
17358 this_leaf = CPUID4_INFO_IDX(cpu, i);
17359
17360 - ktype_cache.default_attrs = default_attrs;
17361 + ktype = &ktype_cache;
17362 #ifdef CONFIG_AMD_NB
17363 if (this_leaf->base.nb)
17364 - ktype_cache.default_attrs = amd_l3_attrs();
17365 + ktype = &ktype_cache_amd_nb;
17366 #endif
17367 retval = kobject_init_and_add(&(this_object->kobj),
17368 - &ktype_cache,
17369 + ktype,
17370 per_cpu(ici_cache_kobject, cpu),
17371 "index%1lu", i);
17372 if (unlikely(retval)) {
17373 @@ -1222,7 +1240,7 @@ static int __cpuinit cacheinfo_cpu_callback(struct notifier_block *nfb,
17374 return NOTIFY_OK;
17375 }
17376
17377 -static struct notifier_block __cpuinitdata cacheinfo_cpu_notifier = {
17378 +static struct notifier_block cacheinfo_cpu_notifier = {
17379 .notifier_call = cacheinfo_cpu_callback,
17380 };
17381
17382 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
17383 index 9239504..b2471ce 100644
17384 --- a/arch/x86/kernel/cpu/mcheck/mce.c
17385 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
17386 @@ -45,6 +45,7 @@
17387 #include <asm/processor.h>
17388 #include <asm/mce.h>
17389 #include <asm/msr.h>
17390 +#include <asm/local.h>
17391
17392 #include "mce-internal.h"
17393
17394 @@ -246,7 +247,7 @@ static void print_mce(struct mce *m)
17395 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
17396 m->cs, m->ip);
17397
17398 - if (m->cs == __KERNEL_CS)
17399 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
17400 print_symbol("{%s}", m->ip);
17401 pr_cont("\n");
17402 }
17403 @@ -279,10 +280,10 @@ static void print_mce(struct mce *m)
17404
17405 #define PANIC_TIMEOUT 5 /* 5 seconds */
17406
17407 -static atomic_t mce_paniced;
17408 +static atomic_unchecked_t mce_paniced;
17409
17410 static int fake_panic;
17411 -static atomic_t mce_fake_paniced;
17412 +static atomic_unchecked_t mce_fake_paniced;
17413
17414 /* Panic in progress. Enable interrupts and wait for final IPI */
17415 static void wait_for_panic(void)
17416 @@ -306,7 +307,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17417 /*
17418 * Make sure only one CPU runs in machine check panic
17419 */
17420 - if (atomic_inc_return(&mce_paniced) > 1)
17421 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
17422 wait_for_panic();
17423 barrier();
17424
17425 @@ -314,7 +315,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17426 console_verbose();
17427 } else {
17428 /* Don't log too much for fake panic */
17429 - if (atomic_inc_return(&mce_fake_paniced) > 1)
17430 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
17431 return;
17432 }
17433 /* First print corrected ones that are still unlogged */
17434 @@ -353,7 +354,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
17435 if (!fake_panic) {
17436 if (panic_timeout == 0)
17437 panic_timeout = mca_cfg.panic_timeout;
17438 - panic(msg);
17439 + panic("%s", msg);
17440 } else
17441 pr_emerg(HW_ERR "Fake kernel panic: %s\n", msg);
17442 }
17443 @@ -683,7 +684,7 @@ static int mce_timed_out(u64 *t)
17444 * might have been modified by someone else.
17445 */
17446 rmb();
17447 - if (atomic_read(&mce_paniced))
17448 + if (atomic_read_unchecked(&mce_paniced))
17449 wait_for_panic();
17450 if (!mca_cfg.monarch_timeout)
17451 goto out;
17452 @@ -1654,7 +1655,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
17453 }
17454
17455 /* Call the installed machine check handler for this CPU setup. */
17456 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
17457 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
17458 unexpected_machine_check;
17459
17460 /*
17461 @@ -1677,7 +1678,9 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17462 return;
17463 }
17464
17465 + pax_open_kernel();
17466 machine_check_vector = do_machine_check;
17467 + pax_close_kernel();
17468
17469 __mcheck_cpu_init_generic();
17470 __mcheck_cpu_init_vendor(c);
17471 @@ -1691,7 +1694,7 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
17472 */
17473
17474 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
17475 -static int mce_chrdev_open_count; /* #times opened */
17476 +static local_t mce_chrdev_open_count; /* #times opened */
17477 static int mce_chrdev_open_exclu; /* already open exclusive? */
17478
17479 static int mce_chrdev_open(struct inode *inode, struct file *file)
17480 @@ -1699,7 +1702,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17481 spin_lock(&mce_chrdev_state_lock);
17482
17483 if (mce_chrdev_open_exclu ||
17484 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
17485 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
17486 spin_unlock(&mce_chrdev_state_lock);
17487
17488 return -EBUSY;
17489 @@ -1707,7 +1710,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
17490
17491 if (file->f_flags & O_EXCL)
17492 mce_chrdev_open_exclu = 1;
17493 - mce_chrdev_open_count++;
17494 + local_inc(&mce_chrdev_open_count);
17495
17496 spin_unlock(&mce_chrdev_state_lock);
17497
17498 @@ -1718,7 +1721,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
17499 {
17500 spin_lock(&mce_chrdev_state_lock);
17501
17502 - mce_chrdev_open_count--;
17503 + local_dec(&mce_chrdev_open_count);
17504 mce_chrdev_open_exclu = 0;
17505
17506 spin_unlock(&mce_chrdev_state_lock);
17507 @@ -2364,7 +2367,7 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
17508 return NOTIFY_OK;
17509 }
17510
17511 -static struct notifier_block mce_cpu_notifier __cpuinitdata = {
17512 +static struct notifier_block mce_cpu_notifier = {
17513 .notifier_call = mce_cpu_callback,
17514 };
17515
17516 @@ -2374,7 +2377,7 @@ static __init void mce_init_banks(void)
17517
17518 for (i = 0; i < mca_cfg.banks; i++) {
17519 struct mce_bank *b = &mce_banks[i];
17520 - struct device_attribute *a = &b->attr;
17521 + device_attribute_no_const *a = &b->attr;
17522
17523 sysfs_attr_init(&a->attr);
17524 a->attr.name = b->attrname;
17525 @@ -2442,7 +2445,7 @@ struct dentry *mce_get_debugfs_dir(void)
17526 static void mce_reset(void)
17527 {
17528 cpu_missing = 0;
17529 - atomic_set(&mce_fake_paniced, 0);
17530 + atomic_set_unchecked(&mce_fake_paniced, 0);
17531 atomic_set(&mce_executing, 0);
17532 atomic_set(&mce_callin, 0);
17533 atomic_set(&global_nwo, 0);
17534 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
17535 index 1c044b1..37a2a43 100644
17536 --- a/arch/x86/kernel/cpu/mcheck/p5.c
17537 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
17538 @@ -11,6 +11,7 @@
17539 #include <asm/processor.h>
17540 #include <asm/mce.h>
17541 #include <asm/msr.h>
17542 +#include <asm/pgtable.h>
17543
17544 /* By default disabled */
17545 int mce_p5_enabled __read_mostly;
17546 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
17547 if (!cpu_has(c, X86_FEATURE_MCE))
17548 return;
17549
17550 + pax_open_kernel();
17551 machine_check_vector = pentium_machine_check;
17552 + pax_close_kernel();
17553 /* Make sure the vector pointer is visible before we enable MCEs: */
17554 wmb();
17555
17556 diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17557 index 47a1870..8c019a7 100644
17558 --- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
17559 +++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
17560 @@ -288,7 +288,7 @@ thermal_throttle_cpu_callback(struct notifier_block *nfb,
17561 return notifier_from_errno(err);
17562 }
17563
17564 -static struct notifier_block thermal_throttle_cpu_notifier __cpuinitdata =
17565 +static struct notifier_block thermal_throttle_cpu_notifier =
17566 {
17567 .notifier_call = thermal_throttle_cpu_callback,
17568 };
17569 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
17570 index e9a701a..35317d6 100644
17571 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
17572 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
17573 @@ -10,6 +10,7 @@
17574 #include <asm/processor.h>
17575 #include <asm/mce.h>
17576 #include <asm/msr.h>
17577 +#include <asm/pgtable.h>
17578
17579 /* Machine check handler for WinChip C6: */
17580 static void winchip_machine_check(struct pt_regs *regs, long error_code)
17581 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
17582 {
17583 u32 lo, hi;
17584
17585 + pax_open_kernel();
17586 machine_check_vector = winchip_machine_check;
17587 + pax_close_kernel();
17588 /* Make sure the vector pointer is visible before we enable MCEs: */
17589 wmb();
17590
17591 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
17592 index 726bf96..81f0526 100644
17593 --- a/arch/x86/kernel/cpu/mtrr/main.c
17594 +++ b/arch/x86/kernel/cpu/mtrr/main.c
17595 @@ -62,7 +62,7 @@ static DEFINE_MUTEX(mtrr_mutex);
17596 u64 size_or_mask, size_and_mask;
17597 static bool mtrr_aps_delayed_init;
17598
17599 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
17600 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
17601
17602 const struct mtrr_ops *mtrr_if;
17603
17604 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
17605 index df5e41f..816c719 100644
17606 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
17607 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
17608 @@ -25,7 +25,7 @@ struct mtrr_ops {
17609 int (*validate_add_page)(unsigned long base, unsigned long size,
17610 unsigned int type);
17611 int (*have_wrcomb)(void);
17612 -};
17613 +} __do_const;
17614
17615 extern int generic_get_free_region(unsigned long base, unsigned long size,
17616 int replace_reg);
17617 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
17618 index 1025f3c..824f677 100644
17619 --- a/arch/x86/kernel/cpu/perf_event.c
17620 +++ b/arch/x86/kernel/cpu/perf_event.c
17621 @@ -1311,7 +1311,7 @@ static void __init pmu_check_apic(void)
17622 pr_info("no hardware sampling interrupt available.\n");
17623 }
17624
17625 -static struct attribute_group x86_pmu_format_group = {
17626 +static attribute_group_no_const x86_pmu_format_group = {
17627 .name = "format",
17628 .attrs = NULL,
17629 };
17630 @@ -1410,7 +1410,7 @@ static struct attribute *events_attr[] = {
17631 NULL,
17632 };
17633
17634 -static struct attribute_group x86_pmu_events_group = {
17635 +static attribute_group_no_const x86_pmu_events_group = {
17636 .name = "events",
17637 .attrs = events_attr,
17638 };
17639 @@ -1920,7 +1920,7 @@ static unsigned long get_segment_base(unsigned int segment)
17640 if (idx > GDT_ENTRIES)
17641 return 0;
17642
17643 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
17644 + desc = get_cpu_gdt_table(smp_processor_id());
17645 }
17646
17647 return get_desc_base(desc + idx);
17648 @@ -2010,7 +2010,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
17649 break;
17650
17651 perf_callchain_store(entry, frame.return_address);
17652 - fp = frame.next_frame;
17653 + fp = (const void __force_user *)frame.next_frame;
17654 }
17655 }
17656
17657 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
17658 index a9e2207..d70c83a 100644
17659 --- a/arch/x86/kernel/cpu/perf_event_intel.c
17660 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
17661 @@ -2022,10 +2022,10 @@ __init int intel_pmu_init(void)
17662 * v2 and above have a perf capabilities MSR
17663 */
17664 if (version > 1) {
17665 - u64 capabilities;
17666 + u64 capabilities = x86_pmu.intel_cap.capabilities;
17667
17668 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
17669 - x86_pmu.intel_cap.capabilities = capabilities;
17670 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
17671 + x86_pmu.intel_cap.capabilities = capabilities;
17672 }
17673
17674 intel_ds_init();
17675 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17676 index 52441a2..f94fae8 100644
17677 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17678 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
17679 @@ -3093,7 +3093,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
17680 static int __init uncore_type_init(struct intel_uncore_type *type)
17681 {
17682 struct intel_uncore_pmu *pmus;
17683 - struct attribute_group *attr_group;
17684 + attribute_group_no_const *attr_group;
17685 struct attribute **attrs;
17686 int i, j;
17687
17688 @@ -3518,7 +3518,7 @@ static int
17689 return NOTIFY_OK;
17690 }
17691
17692 -static struct notifier_block uncore_cpu_nb __cpuinitdata = {
17693 +static struct notifier_block uncore_cpu_nb = {
17694 .notifier_call = uncore_cpu_notifier,
17695 /*
17696 * to migrate uncore events, our notifier should be executed
17697 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17698 index f952891..4722ad4 100644
17699 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17700 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
17701 @@ -488,7 +488,7 @@ struct intel_uncore_box {
17702 struct uncore_event_desc {
17703 struct kobj_attribute attr;
17704 const char *config;
17705 -};
17706 +} __do_const;
17707
17708 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
17709 { \
17710 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
17711 index 1e4dbcf..b9a34c2 100644
17712 --- a/arch/x86/kernel/cpuid.c
17713 +++ b/arch/x86/kernel/cpuid.c
17714 @@ -171,7 +171,7 @@ static int __cpuinit cpuid_class_cpu_callback(struct notifier_block *nfb,
17715 return notifier_from_errno(err);
17716 }
17717
17718 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
17719 +static struct notifier_block cpuid_class_cpu_notifier =
17720 {
17721 .notifier_call = cpuid_class_cpu_callback,
17722 };
17723 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
17724 index 74467fe..18793d5 100644
17725 --- a/arch/x86/kernel/crash.c
17726 +++ b/arch/x86/kernel/crash.c
17727 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
17728 {
17729 #ifdef CONFIG_X86_32
17730 struct pt_regs fixed_regs;
17731 -#endif
17732
17733 -#ifdef CONFIG_X86_32
17734 - if (!user_mode_vm(regs)) {
17735 + if (!user_mode(regs)) {
17736 crash_fixup_ss_esp(&fixed_regs, regs);
17737 regs = &fixed_regs;
17738 }
17739 diff --git a/arch/x86/kernel/crash_dump_64.c b/arch/x86/kernel/crash_dump_64.c
17740 index afa64ad..dce67dd 100644
17741 --- a/arch/x86/kernel/crash_dump_64.c
17742 +++ b/arch/x86/kernel/crash_dump_64.c
17743 @@ -36,7 +36,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
17744 return -ENOMEM;
17745
17746 if (userbuf) {
17747 - if (copy_to_user(buf, vaddr + offset, csize)) {
17748 + if (copy_to_user((char __force_user *)buf, vaddr + offset, csize)) {
17749 iounmap(vaddr);
17750 return -EFAULT;
17751 }
17752 diff --git a/arch/x86/kernel/doublefault_32.c b/arch/x86/kernel/doublefault_32.c
17753 index 155a13f..1672b9b 100644
17754 --- a/arch/x86/kernel/doublefault_32.c
17755 +++ b/arch/x86/kernel/doublefault_32.c
17756 @@ -11,7 +11,7 @@
17757
17758 #define DOUBLEFAULT_STACKSIZE (1024)
17759 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
17760 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
17761 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
17762
17763 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
17764
17765 @@ -21,7 +21,7 @@ static void doublefault_fn(void)
17766 unsigned long gdt, tss;
17767
17768 native_store_gdt(&gdt_desc);
17769 - gdt = gdt_desc.address;
17770 + gdt = (unsigned long)gdt_desc.address;
17771
17772 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
17773
17774 @@ -58,10 +58,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
17775 /* 0x2 bit is always set */
17776 .flags = X86_EFLAGS_SF | 0x2,
17777 .sp = STACK_START,
17778 - .es = __USER_DS,
17779 + .es = __KERNEL_DS,
17780 .cs = __KERNEL_CS,
17781 .ss = __KERNEL_DS,
17782 - .ds = __USER_DS,
17783 + .ds = __KERNEL_DS,
17784 .fs = __KERNEL_PERCPU,
17785
17786 .__cr3 = __pa_nodebug(swapper_pg_dir),
17787 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
17788 index deb6421..622e0ed 100644
17789 --- a/arch/x86/kernel/dumpstack.c
17790 +++ b/arch/x86/kernel/dumpstack.c
17791 @@ -2,6 +2,9 @@
17792 * Copyright (C) 1991, 1992 Linus Torvalds
17793 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
17794 */
17795 +#ifdef CONFIG_GRKERNSEC_HIDESYM
17796 +#define __INCLUDED_BY_HIDESYM 1
17797 +#endif
17798 #include <linux/kallsyms.h>
17799 #include <linux/kprobes.h>
17800 #include <linux/uaccess.h>
17801 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
17802 static void
17803 print_ftrace_graph_addr(unsigned long addr, void *data,
17804 const struct stacktrace_ops *ops,
17805 - struct thread_info *tinfo, int *graph)
17806 + struct task_struct *task, int *graph)
17807 {
17808 - struct task_struct *task;
17809 unsigned long ret_addr;
17810 int index;
17811
17812 if (addr != (unsigned long)return_to_handler)
17813 return;
17814
17815 - task = tinfo->task;
17816 index = task->curr_ret_stack;
17817
17818 if (!task->ret_stack || index < *graph)
17819 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
17820 static inline void
17821 print_ftrace_graph_addr(unsigned long addr, void *data,
17822 const struct stacktrace_ops *ops,
17823 - struct thread_info *tinfo, int *graph)
17824 + struct task_struct *task, int *graph)
17825 { }
17826 #endif
17827
17828 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
17829 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
17830 */
17831
17832 -static inline int valid_stack_ptr(struct thread_info *tinfo,
17833 - void *p, unsigned int size, void *end)
17834 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
17835 {
17836 - void *t = tinfo;
17837 if (end) {
17838 if (p < end && p >= (end-THREAD_SIZE))
17839 return 1;
17840 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
17841 }
17842
17843 unsigned long
17844 -print_context_stack(struct thread_info *tinfo,
17845 +print_context_stack(struct task_struct *task, void *stack_start,
17846 unsigned long *stack, unsigned long bp,
17847 const struct stacktrace_ops *ops, void *data,
17848 unsigned long *end, int *graph)
17849 {
17850 struct stack_frame *frame = (struct stack_frame *)bp;
17851
17852 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
17853 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
17854 unsigned long addr;
17855
17856 addr = *stack;
17857 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
17858 } else {
17859 ops->address(data, addr, 0);
17860 }
17861 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
17862 + print_ftrace_graph_addr(addr, data, ops, task, graph);
17863 }
17864 stack++;
17865 }
17866 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
17867 EXPORT_SYMBOL_GPL(print_context_stack);
17868
17869 unsigned long
17870 -print_context_stack_bp(struct thread_info *tinfo,
17871 +print_context_stack_bp(struct task_struct *task, void *stack_start,
17872 unsigned long *stack, unsigned long bp,
17873 const struct stacktrace_ops *ops, void *data,
17874 unsigned long *end, int *graph)
17875 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
17876 struct stack_frame *frame = (struct stack_frame *)bp;
17877 unsigned long *ret_addr = &frame->return_address;
17878
17879 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
17880 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
17881 unsigned long addr = *ret_addr;
17882
17883 if (!__kernel_text_address(addr))
17884 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
17885 ops->address(data, addr, 1);
17886 frame = frame->next_frame;
17887 ret_addr = &frame->return_address;
17888 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
17889 + print_ftrace_graph_addr(addr, data, ops, task, graph);
17890 }
17891
17892 return (unsigned long)frame;
17893 @@ -219,6 +218,8 @@ unsigned __kprobes long oops_begin(void)
17894 }
17895 EXPORT_SYMBOL_GPL(oops_begin);
17896
17897 +extern void gr_handle_kernel_exploit(void);
17898 +
17899 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
17900 {
17901 if (regs && kexec_should_crash(current))
17902 @@ -240,7 +241,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
17903 panic("Fatal exception in interrupt");
17904 if (panic_on_oops)
17905 panic("Fatal exception");
17906 - do_exit(signr);
17907 +
17908 + gr_handle_kernel_exploit();
17909 +
17910 + do_group_exit(signr);
17911 }
17912
17913 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
17914 @@ -268,7 +272,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
17915 print_modules();
17916 show_regs(regs);
17917 #ifdef CONFIG_X86_32
17918 - if (user_mode_vm(regs)) {
17919 + if (user_mode(regs)) {
17920 sp = regs->sp;
17921 ss = regs->ss & 0xffff;
17922 } else {
17923 @@ -296,7 +300,7 @@ void die(const char *str, struct pt_regs *regs, long err)
17924 unsigned long flags = oops_begin();
17925 int sig = SIGSEGV;
17926
17927 - if (!user_mode_vm(regs))
17928 + if (!user_mode(regs))
17929 report_bug(regs->ip, regs);
17930
17931 if (__die(str, regs, err))
17932 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
17933 index f2a1770..540657f 100644
17934 --- a/arch/x86/kernel/dumpstack_32.c
17935 +++ b/arch/x86/kernel/dumpstack_32.c
17936 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
17937 bp = stack_frame(task, regs);
17938
17939 for (;;) {
17940 - struct thread_info *context;
17941 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
17942
17943 - context = (struct thread_info *)
17944 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
17945 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
17946 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
17947
17948 - stack = (unsigned long *)context->previous_esp;
17949 - if (!stack)
17950 + if (stack_start == task_stack_page(task))
17951 break;
17952 + stack = *(unsigned long **)stack_start;
17953 if (ops->stack(data, "IRQ") < 0)
17954 break;
17955 touch_nmi_watchdog();
17956 @@ -87,27 +85,28 @@ void show_regs(struct pt_regs *regs)
17957 int i;
17958
17959 show_regs_print_info(KERN_EMERG);
17960 - __show_regs(regs, !user_mode_vm(regs));
17961 + __show_regs(regs, !user_mode(regs));
17962
17963 /*
17964 * When in-kernel, we also print out the stack and code at the
17965 * time of the fault..
17966 */
17967 - if (!user_mode_vm(regs)) {
17968 + if (!user_mode(regs)) {
17969 unsigned int code_prologue = code_bytes * 43 / 64;
17970 unsigned int code_len = code_bytes;
17971 unsigned char c;
17972 u8 *ip;
17973 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
17974
17975 pr_emerg("Stack:\n");
17976 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
17977
17978 pr_emerg("Code:");
17979
17980 - ip = (u8 *)regs->ip - code_prologue;
17981 + ip = (u8 *)regs->ip - code_prologue + cs_base;
17982 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
17983 /* try starting at IP */
17984 - ip = (u8 *)regs->ip;
17985 + ip = (u8 *)regs->ip + cs_base;
17986 code_len = code_len - code_prologue + 1;
17987 }
17988 for (i = 0; i < code_len; i++, ip++) {
17989 @@ -116,7 +115,7 @@ void show_regs(struct pt_regs *regs)
17990 pr_cont(" Bad EIP value.");
17991 break;
17992 }
17993 - if (ip == (u8 *)regs->ip)
17994 + if (ip == (u8 *)regs->ip + cs_base)
17995 pr_cont(" <%02x>", c);
17996 else
17997 pr_cont(" %02x", c);
17998 @@ -129,6 +128,7 @@ int is_valid_bugaddr(unsigned long ip)
17999 {
18000 unsigned short ud2;
18001
18002 + ip = ktla_ktva(ip);
18003 if (ip < PAGE_OFFSET)
18004 return 0;
18005 if (probe_kernel_address((unsigned short *)ip, ud2))
18006 @@ -136,3 +136,15 @@ int is_valid_bugaddr(unsigned long ip)
18007
18008 return ud2 == 0x0b0f;
18009 }
18010 +
18011 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18012 +void pax_check_alloca(unsigned long size)
18013 +{
18014 + unsigned long sp = (unsigned long)&sp, stack_left;
18015 +
18016 + /* all kernel stacks are of the same size */
18017 + stack_left = sp & (THREAD_SIZE - 1);
18018 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18019 +}
18020 +EXPORT_SYMBOL(pax_check_alloca);
18021 +#endif
18022 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
18023 index addb207..99635fa 100644
18024 --- a/arch/x86/kernel/dumpstack_64.c
18025 +++ b/arch/x86/kernel/dumpstack_64.c
18026 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18027 unsigned long *irq_stack_end =
18028 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
18029 unsigned used = 0;
18030 - struct thread_info *tinfo;
18031 int graph = 0;
18032 unsigned long dummy;
18033 + void *stack_start;
18034
18035 if (!task)
18036 task = current;
18037 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18038 * current stack address. If the stacks consist of nested
18039 * exceptions
18040 */
18041 - tinfo = task_thread_info(task);
18042 for (;;) {
18043 char *id;
18044 unsigned long *estack_end;
18045 +
18046 estack_end = in_exception_stack(cpu, (unsigned long)stack,
18047 &used, &id);
18048
18049 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18050 if (ops->stack(data, id) < 0)
18051 break;
18052
18053 - bp = ops->walk_stack(tinfo, stack, bp, ops,
18054 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
18055 data, estack_end, &graph);
18056 ops->stack(data, "<EOE>");
18057 /*
18058 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18059 * second-to-last pointer (index -2 to end) in the
18060 * exception stack:
18061 */
18062 + if ((u16)estack_end[-1] != __KERNEL_DS)
18063 + goto out;
18064 stack = (unsigned long *) estack_end[-2];
18065 continue;
18066 }
18067 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18068 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
18069 if (ops->stack(data, "IRQ") < 0)
18070 break;
18071 - bp = ops->walk_stack(tinfo, stack, bp,
18072 + bp = ops->walk_stack(task, irq_stack, stack, bp,
18073 ops, data, irq_stack_end, &graph);
18074 /*
18075 * We link to the next stack (which would be
18076 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
18077 /*
18078 * This handles the process stack:
18079 */
18080 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
18081 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
18082 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
18083 +out:
18084 put_cpu();
18085 }
18086 EXPORT_SYMBOL(dump_trace);
18087 @@ -300,3 +304,50 @@ int is_valid_bugaddr(unsigned long ip)
18088
18089 return ud2 == 0x0b0f;
18090 }
18091 +
18092 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18093 +void pax_check_alloca(unsigned long size)
18094 +{
18095 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
18096 + unsigned cpu, used;
18097 + char *id;
18098 +
18099 + /* check the process stack first */
18100 + stack_start = (unsigned long)task_stack_page(current);
18101 + stack_end = stack_start + THREAD_SIZE;
18102 + if (likely(stack_start <= sp && sp < stack_end)) {
18103 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
18104 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18105 + return;
18106 + }
18107 +
18108 + cpu = get_cpu();
18109 +
18110 + /* check the irq stacks */
18111 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
18112 + stack_start = stack_end - IRQ_STACK_SIZE;
18113 + if (stack_start <= sp && sp < stack_end) {
18114 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
18115 + put_cpu();
18116 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18117 + return;
18118 + }
18119 +
18120 + /* check the exception stacks */
18121 + used = 0;
18122 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
18123 + stack_start = stack_end - EXCEPTION_STKSZ;
18124 + if (stack_end && stack_start <= sp && sp < stack_end) {
18125 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
18126 + put_cpu();
18127 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
18128 + return;
18129 + }
18130 +
18131 + put_cpu();
18132 +
18133 + /* unknown stack */
18134 + BUG();
18135 +}
18136 +EXPORT_SYMBOL(pax_check_alloca);
18137 +#endif
18138 diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
18139 index d32abea..74daf4f 100644
18140 --- a/arch/x86/kernel/e820.c
18141 +++ b/arch/x86/kernel/e820.c
18142 @@ -800,8 +800,8 @@ unsigned long __init e820_end_of_low_ram_pfn(void)
18143
18144 static void early_panic(char *msg)
18145 {
18146 - early_printk(msg);
18147 - panic(msg);
18148 + early_printk("%s", msg);
18149 + panic("%s", msg);
18150 }
18151
18152 static int userdef __initdata;
18153 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
18154 index d15f575..d692043 100644
18155 --- a/arch/x86/kernel/early_printk.c
18156 +++ b/arch/x86/kernel/early_printk.c
18157 @@ -7,6 +7,7 @@
18158 #include <linux/pci_regs.h>
18159 #include <linux/pci_ids.h>
18160 #include <linux/errno.h>
18161 +#include <linux/sched.h>
18162 #include <asm/io.h>
18163 #include <asm/processor.h>
18164 #include <asm/fcntl.h>
18165 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
18166 index 8f3e2de..caecc4e 100644
18167 --- a/arch/x86/kernel/entry_32.S
18168 +++ b/arch/x86/kernel/entry_32.S
18169 @@ -177,13 +177,153 @@
18170 /*CFI_REL_OFFSET gs, PT_GS*/
18171 .endm
18172 .macro SET_KERNEL_GS reg
18173 +
18174 +#ifdef CONFIG_CC_STACKPROTECTOR
18175 movl $(__KERNEL_STACK_CANARY), \reg
18176 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
18177 + movl $(__USER_DS), \reg
18178 +#else
18179 + xorl \reg, \reg
18180 +#endif
18181 +
18182 movl \reg, %gs
18183 .endm
18184
18185 #endif /* CONFIG_X86_32_LAZY_GS */
18186
18187 -.macro SAVE_ALL
18188 +.macro pax_enter_kernel
18189 +#ifdef CONFIG_PAX_KERNEXEC
18190 + call pax_enter_kernel
18191 +#endif
18192 +.endm
18193 +
18194 +.macro pax_exit_kernel
18195 +#ifdef CONFIG_PAX_KERNEXEC
18196 + call pax_exit_kernel
18197 +#endif
18198 +.endm
18199 +
18200 +#ifdef CONFIG_PAX_KERNEXEC
18201 +ENTRY(pax_enter_kernel)
18202 +#ifdef CONFIG_PARAVIRT
18203 + pushl %eax
18204 + pushl %ecx
18205 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
18206 + mov %eax, %esi
18207 +#else
18208 + mov %cr0, %esi
18209 +#endif
18210 + bts $16, %esi
18211 + jnc 1f
18212 + mov %cs, %esi
18213 + cmp $__KERNEL_CS, %esi
18214 + jz 3f
18215 + ljmp $__KERNEL_CS, $3f
18216 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
18217 +2:
18218 +#ifdef CONFIG_PARAVIRT
18219 + mov %esi, %eax
18220 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
18221 +#else
18222 + mov %esi, %cr0
18223 +#endif
18224 +3:
18225 +#ifdef CONFIG_PARAVIRT
18226 + popl %ecx
18227 + popl %eax
18228 +#endif
18229 + ret
18230 +ENDPROC(pax_enter_kernel)
18231 +
18232 +ENTRY(pax_exit_kernel)
18233 +#ifdef CONFIG_PARAVIRT
18234 + pushl %eax
18235 + pushl %ecx
18236 +#endif
18237 + mov %cs, %esi
18238 + cmp $__KERNEXEC_KERNEL_CS, %esi
18239 + jnz 2f
18240 +#ifdef CONFIG_PARAVIRT
18241 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
18242 + mov %eax, %esi
18243 +#else
18244 + mov %cr0, %esi
18245 +#endif
18246 + btr $16, %esi
18247 + ljmp $__KERNEL_CS, $1f
18248 +1:
18249 +#ifdef CONFIG_PARAVIRT
18250 + mov %esi, %eax
18251 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
18252 +#else
18253 + mov %esi, %cr0
18254 +#endif
18255 +2:
18256 +#ifdef CONFIG_PARAVIRT
18257 + popl %ecx
18258 + popl %eax
18259 +#endif
18260 + ret
18261 +ENDPROC(pax_exit_kernel)
18262 +#endif
18263 +
18264 + .macro pax_erase_kstack
18265 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18266 + call pax_erase_kstack
18267 +#endif
18268 + .endm
18269 +
18270 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
18271 +/*
18272 + * ebp: thread_info
18273 + */
18274 +ENTRY(pax_erase_kstack)
18275 + pushl %edi
18276 + pushl %ecx
18277 + pushl %eax
18278 +
18279 + mov TI_lowest_stack(%ebp), %edi
18280 + mov $-0xBEEF, %eax
18281 + std
18282 +
18283 +1: mov %edi, %ecx
18284 + and $THREAD_SIZE_asm - 1, %ecx
18285 + shr $2, %ecx
18286 + repne scasl
18287 + jecxz 2f
18288 +
18289 + cmp $2*16, %ecx
18290 + jc 2f
18291 +
18292 + mov $2*16, %ecx
18293 + repe scasl
18294 + jecxz 2f
18295 + jne 1b
18296 +
18297 +2: cld
18298 + mov %esp, %ecx
18299 + sub %edi, %ecx
18300 +
18301 + cmp $THREAD_SIZE_asm, %ecx
18302 + jb 3f
18303 + ud2
18304 +3:
18305 +
18306 + shr $2, %ecx
18307 + rep stosl
18308 +
18309 + mov TI_task_thread_sp0(%ebp), %edi
18310 + sub $128, %edi
18311 + mov %edi, TI_lowest_stack(%ebp)
18312 +
18313 + popl %eax
18314 + popl %ecx
18315 + popl %edi
18316 + ret
18317 +ENDPROC(pax_erase_kstack)
18318 +#endif
18319 +
18320 +.macro __SAVE_ALL _DS
18321 cld
18322 PUSH_GS
18323 pushl_cfi %fs
18324 @@ -206,7 +346,7 @@
18325 CFI_REL_OFFSET ecx, 0
18326 pushl_cfi %ebx
18327 CFI_REL_OFFSET ebx, 0
18328 - movl $(__USER_DS), %edx
18329 + movl $\_DS, %edx
18330 movl %edx, %ds
18331 movl %edx, %es
18332 movl $(__KERNEL_PERCPU), %edx
18333 @@ -214,6 +354,15 @@
18334 SET_KERNEL_GS %edx
18335 .endm
18336
18337 +.macro SAVE_ALL
18338 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
18339 + __SAVE_ALL __KERNEL_DS
18340 + pax_enter_kernel
18341 +#else
18342 + __SAVE_ALL __USER_DS
18343 +#endif
18344 +.endm
18345 +
18346 .macro RESTORE_INT_REGS
18347 popl_cfi %ebx
18348 CFI_RESTORE ebx
18349 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
18350 popfl_cfi
18351 jmp syscall_exit
18352 CFI_ENDPROC
18353 -END(ret_from_fork)
18354 +ENDPROC(ret_from_fork)
18355
18356 ENTRY(ret_from_kernel_thread)
18357 CFI_STARTPROC
18358 @@ -344,7 +493,15 @@ ret_from_intr:
18359 andl $SEGMENT_RPL_MASK, %eax
18360 #endif
18361 cmpl $USER_RPL, %eax
18362 +
18363 +#ifdef CONFIG_PAX_KERNEXEC
18364 + jae resume_userspace
18365 +
18366 + pax_exit_kernel
18367 + jmp resume_kernel
18368 +#else
18369 jb resume_kernel # not returning to v8086 or userspace
18370 +#endif
18371
18372 ENTRY(resume_userspace)
18373 LOCKDEP_SYS_EXIT
18374 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
18375 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
18376 # int/exception return?
18377 jne work_pending
18378 - jmp restore_all
18379 -END(ret_from_exception)
18380 + jmp restore_all_pax
18381 +ENDPROC(ret_from_exception)
18382
18383 #ifdef CONFIG_PREEMPT
18384 ENTRY(resume_kernel)
18385 @@ -372,7 +529,7 @@ need_resched:
18386 jz restore_all
18387 call preempt_schedule_irq
18388 jmp need_resched
18389 -END(resume_kernel)
18390 +ENDPROC(resume_kernel)
18391 #endif
18392 CFI_ENDPROC
18393 /*
18394 @@ -406,30 +563,45 @@ sysenter_past_esp:
18395 /*CFI_REL_OFFSET cs, 0*/
18396 /*
18397 * Push current_thread_info()->sysenter_return to the stack.
18398 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
18399 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
18400 */
18401 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
18402 + pushl_cfi $0
18403 CFI_REL_OFFSET eip, 0
18404
18405 pushl_cfi %eax
18406 SAVE_ALL
18407 + GET_THREAD_INFO(%ebp)
18408 + movl TI_sysenter_return(%ebp),%ebp
18409 + movl %ebp,PT_EIP(%esp)
18410 ENABLE_INTERRUPTS(CLBR_NONE)
18411
18412 /*
18413 * Load the potential sixth argument from user stack.
18414 * Careful about security.
18415 */
18416 + movl PT_OLDESP(%esp),%ebp
18417 +
18418 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18419 + mov PT_OLDSS(%esp),%ds
18420 +1: movl %ds:(%ebp),%ebp
18421 + push %ss
18422 + pop %ds
18423 +#else
18424 cmpl $__PAGE_OFFSET-3,%ebp
18425 jae syscall_fault
18426 ASM_STAC
18427 1: movl (%ebp),%ebp
18428 ASM_CLAC
18429 +#endif
18430 +
18431 movl %ebp,PT_EBP(%esp)
18432 _ASM_EXTABLE(1b,syscall_fault)
18433
18434 GET_THREAD_INFO(%ebp)
18435
18436 +#ifdef CONFIG_PAX_RANDKSTACK
18437 + pax_erase_kstack
18438 +#endif
18439 +
18440 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18441 jnz sysenter_audit
18442 sysenter_do_call:
18443 @@ -444,12 +616,24 @@ sysenter_do_call:
18444 testl $_TIF_ALLWORK_MASK, %ecx
18445 jne sysexit_audit
18446 sysenter_exit:
18447 +
18448 +#ifdef CONFIG_PAX_RANDKSTACK
18449 + pushl_cfi %eax
18450 + movl %esp, %eax
18451 + call pax_randomize_kstack
18452 + popl_cfi %eax
18453 +#endif
18454 +
18455 + pax_erase_kstack
18456 +
18457 /* if something modifies registers it must also disable sysexit */
18458 movl PT_EIP(%esp), %edx
18459 movl PT_OLDESP(%esp), %ecx
18460 xorl %ebp,%ebp
18461 TRACE_IRQS_ON
18462 1: mov PT_FS(%esp), %fs
18463 +2: mov PT_DS(%esp), %ds
18464 +3: mov PT_ES(%esp), %es
18465 PTGS_TO_GS
18466 ENABLE_INTERRUPTS_SYSEXIT
18467
18468 @@ -466,6 +650,9 @@ sysenter_audit:
18469 movl %eax,%edx /* 2nd arg: syscall number */
18470 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
18471 call __audit_syscall_entry
18472 +
18473 + pax_erase_kstack
18474 +
18475 pushl_cfi %ebx
18476 movl PT_EAX(%esp),%eax /* reload syscall number */
18477 jmp sysenter_do_call
18478 @@ -491,10 +678,16 @@ sysexit_audit:
18479
18480 CFI_ENDPROC
18481 .pushsection .fixup,"ax"
18482 -2: movl $0,PT_FS(%esp)
18483 +4: movl $0,PT_FS(%esp)
18484 + jmp 1b
18485 +5: movl $0,PT_DS(%esp)
18486 + jmp 1b
18487 +6: movl $0,PT_ES(%esp)
18488 jmp 1b
18489 .popsection
18490 - _ASM_EXTABLE(1b,2b)
18491 + _ASM_EXTABLE(1b,4b)
18492 + _ASM_EXTABLE(2b,5b)
18493 + _ASM_EXTABLE(3b,6b)
18494 PTGS_TO_GS_EX
18495 ENDPROC(ia32_sysenter_target)
18496
18497 @@ -509,6 +702,11 @@ ENTRY(system_call)
18498 pushl_cfi %eax # save orig_eax
18499 SAVE_ALL
18500 GET_THREAD_INFO(%ebp)
18501 +
18502 +#ifdef CONFIG_PAX_RANDKSTACK
18503 + pax_erase_kstack
18504 +#endif
18505 +
18506 # system call tracing in operation / emulation
18507 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
18508 jnz syscall_trace_entry
18509 @@ -527,6 +725,15 @@ syscall_exit:
18510 testl $_TIF_ALLWORK_MASK, %ecx # current->work
18511 jne syscall_exit_work
18512
18513 +restore_all_pax:
18514 +
18515 +#ifdef CONFIG_PAX_RANDKSTACK
18516 + movl %esp, %eax
18517 + call pax_randomize_kstack
18518 +#endif
18519 +
18520 + pax_erase_kstack
18521 +
18522 restore_all:
18523 TRACE_IRQS_IRET
18524 restore_all_notrace:
18525 @@ -583,14 +790,34 @@ ldt_ss:
18526 * compensating for the offset by changing to the ESPFIX segment with
18527 * a base address that matches for the difference.
18528 */
18529 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
18530 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
18531 mov %esp, %edx /* load kernel esp */
18532 mov PT_OLDESP(%esp), %eax /* load userspace esp */
18533 mov %dx, %ax /* eax: new kernel esp */
18534 sub %eax, %edx /* offset (low word is 0) */
18535 +#ifdef CONFIG_SMP
18536 + movl PER_CPU_VAR(cpu_number), %ebx
18537 + shll $PAGE_SHIFT_asm, %ebx
18538 + addl $cpu_gdt_table, %ebx
18539 +#else
18540 + movl $cpu_gdt_table, %ebx
18541 +#endif
18542 shr $16, %edx
18543 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
18544 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
18545 +
18546 +#ifdef CONFIG_PAX_KERNEXEC
18547 + mov %cr0, %esi
18548 + btr $16, %esi
18549 + mov %esi, %cr0
18550 +#endif
18551 +
18552 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
18553 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
18554 +
18555 +#ifdef CONFIG_PAX_KERNEXEC
18556 + bts $16, %esi
18557 + mov %esi, %cr0
18558 +#endif
18559 +
18560 pushl_cfi $__ESPFIX_SS
18561 pushl_cfi %eax /* new kernel esp */
18562 /* Disable interrupts, but do not irqtrace this section: we
18563 @@ -619,20 +846,18 @@ work_resched:
18564 movl TI_flags(%ebp), %ecx
18565 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
18566 # than syscall tracing?
18567 - jz restore_all
18568 + jz restore_all_pax
18569 testb $_TIF_NEED_RESCHED, %cl
18570 jnz work_resched
18571
18572 work_notifysig: # deal with pending signals and
18573 # notify-resume requests
18574 + movl %esp, %eax
18575 #ifdef CONFIG_VM86
18576 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
18577 - movl %esp, %eax
18578 jne work_notifysig_v86 # returning to kernel-space or
18579 # vm86-space
18580 1:
18581 -#else
18582 - movl %esp, %eax
18583 #endif
18584 TRACE_IRQS_ON
18585 ENABLE_INTERRUPTS(CLBR_NONE)
18586 @@ -653,7 +878,7 @@ work_notifysig_v86:
18587 movl %eax, %esp
18588 jmp 1b
18589 #endif
18590 -END(work_pending)
18591 +ENDPROC(work_pending)
18592
18593 # perform syscall exit tracing
18594 ALIGN
18595 @@ -661,11 +886,14 @@ syscall_trace_entry:
18596 movl $-ENOSYS,PT_EAX(%esp)
18597 movl %esp, %eax
18598 call syscall_trace_enter
18599 +
18600 + pax_erase_kstack
18601 +
18602 /* What it returned is what we'll actually use. */
18603 cmpl $(NR_syscalls), %eax
18604 jnae syscall_call
18605 jmp syscall_exit
18606 -END(syscall_trace_entry)
18607 +ENDPROC(syscall_trace_entry)
18608
18609 # perform syscall exit tracing
18610 ALIGN
18611 @@ -678,21 +906,25 @@ syscall_exit_work:
18612 movl %esp, %eax
18613 call syscall_trace_leave
18614 jmp resume_userspace
18615 -END(syscall_exit_work)
18616 +ENDPROC(syscall_exit_work)
18617 CFI_ENDPROC
18618
18619 RING0_INT_FRAME # can't unwind into user space anyway
18620 syscall_fault:
18621 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18622 + push %ss
18623 + pop %ds
18624 +#endif
18625 ASM_CLAC
18626 GET_THREAD_INFO(%ebp)
18627 movl $-EFAULT,PT_EAX(%esp)
18628 jmp resume_userspace
18629 -END(syscall_fault)
18630 +ENDPROC(syscall_fault)
18631
18632 syscall_badsys:
18633 movl $-ENOSYS,PT_EAX(%esp)
18634 jmp resume_userspace
18635 -END(syscall_badsys)
18636 +ENDPROC(syscall_badsys)
18637 CFI_ENDPROC
18638 /*
18639 * End of kprobes section
18640 @@ -708,8 +940,15 @@ END(syscall_badsys)
18641 * normal stack and adjusts ESP with the matching offset.
18642 */
18643 /* fixup the stack */
18644 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
18645 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
18646 +#ifdef CONFIG_SMP
18647 + movl PER_CPU_VAR(cpu_number), %ebx
18648 + shll $PAGE_SHIFT_asm, %ebx
18649 + addl $cpu_gdt_table, %ebx
18650 +#else
18651 + movl $cpu_gdt_table, %ebx
18652 +#endif
18653 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
18654 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
18655 shl $16, %eax
18656 addl %esp, %eax /* the adjusted stack pointer */
18657 pushl_cfi $__KERNEL_DS
18658 @@ -762,7 +1001,7 @@ vector=vector+1
18659 .endr
18660 2: jmp common_interrupt
18661 .endr
18662 -END(irq_entries_start)
18663 +ENDPROC(irq_entries_start)
18664
18665 .previous
18666 END(interrupt)
18667 @@ -813,7 +1052,7 @@ ENTRY(coprocessor_error)
18668 pushl_cfi $do_coprocessor_error
18669 jmp error_code
18670 CFI_ENDPROC
18671 -END(coprocessor_error)
18672 +ENDPROC(coprocessor_error)
18673
18674 ENTRY(simd_coprocessor_error)
18675 RING0_INT_FRAME
18676 @@ -835,7 +1074,7 @@ ENTRY(simd_coprocessor_error)
18677 #endif
18678 jmp error_code
18679 CFI_ENDPROC
18680 -END(simd_coprocessor_error)
18681 +ENDPROC(simd_coprocessor_error)
18682
18683 ENTRY(device_not_available)
18684 RING0_INT_FRAME
18685 @@ -844,18 +1083,18 @@ ENTRY(device_not_available)
18686 pushl_cfi $do_device_not_available
18687 jmp error_code
18688 CFI_ENDPROC
18689 -END(device_not_available)
18690 +ENDPROC(device_not_available)
18691
18692 #ifdef CONFIG_PARAVIRT
18693 ENTRY(native_iret)
18694 iret
18695 _ASM_EXTABLE(native_iret, iret_exc)
18696 -END(native_iret)
18697 +ENDPROC(native_iret)
18698
18699 ENTRY(native_irq_enable_sysexit)
18700 sti
18701 sysexit
18702 -END(native_irq_enable_sysexit)
18703 +ENDPROC(native_irq_enable_sysexit)
18704 #endif
18705
18706 ENTRY(overflow)
18707 @@ -865,7 +1104,7 @@ ENTRY(overflow)
18708 pushl_cfi $do_overflow
18709 jmp error_code
18710 CFI_ENDPROC
18711 -END(overflow)
18712 +ENDPROC(overflow)
18713
18714 ENTRY(bounds)
18715 RING0_INT_FRAME
18716 @@ -874,7 +1113,7 @@ ENTRY(bounds)
18717 pushl_cfi $do_bounds
18718 jmp error_code
18719 CFI_ENDPROC
18720 -END(bounds)
18721 +ENDPROC(bounds)
18722
18723 ENTRY(invalid_op)
18724 RING0_INT_FRAME
18725 @@ -883,7 +1122,7 @@ ENTRY(invalid_op)
18726 pushl_cfi $do_invalid_op
18727 jmp error_code
18728 CFI_ENDPROC
18729 -END(invalid_op)
18730 +ENDPROC(invalid_op)
18731
18732 ENTRY(coprocessor_segment_overrun)
18733 RING0_INT_FRAME
18734 @@ -892,7 +1131,7 @@ ENTRY(coprocessor_segment_overrun)
18735 pushl_cfi $do_coprocessor_segment_overrun
18736 jmp error_code
18737 CFI_ENDPROC
18738 -END(coprocessor_segment_overrun)
18739 +ENDPROC(coprocessor_segment_overrun)
18740
18741 ENTRY(invalid_TSS)
18742 RING0_EC_FRAME
18743 @@ -900,7 +1139,7 @@ ENTRY(invalid_TSS)
18744 pushl_cfi $do_invalid_TSS
18745 jmp error_code
18746 CFI_ENDPROC
18747 -END(invalid_TSS)
18748 +ENDPROC(invalid_TSS)
18749
18750 ENTRY(segment_not_present)
18751 RING0_EC_FRAME
18752 @@ -908,7 +1147,7 @@ ENTRY(segment_not_present)
18753 pushl_cfi $do_segment_not_present
18754 jmp error_code
18755 CFI_ENDPROC
18756 -END(segment_not_present)
18757 +ENDPROC(segment_not_present)
18758
18759 ENTRY(stack_segment)
18760 RING0_EC_FRAME
18761 @@ -916,7 +1155,7 @@ ENTRY(stack_segment)
18762 pushl_cfi $do_stack_segment
18763 jmp error_code
18764 CFI_ENDPROC
18765 -END(stack_segment)
18766 +ENDPROC(stack_segment)
18767
18768 ENTRY(alignment_check)
18769 RING0_EC_FRAME
18770 @@ -924,7 +1163,7 @@ ENTRY(alignment_check)
18771 pushl_cfi $do_alignment_check
18772 jmp error_code
18773 CFI_ENDPROC
18774 -END(alignment_check)
18775 +ENDPROC(alignment_check)
18776
18777 ENTRY(divide_error)
18778 RING0_INT_FRAME
18779 @@ -933,7 +1172,7 @@ ENTRY(divide_error)
18780 pushl_cfi $do_divide_error
18781 jmp error_code
18782 CFI_ENDPROC
18783 -END(divide_error)
18784 +ENDPROC(divide_error)
18785
18786 #ifdef CONFIG_X86_MCE
18787 ENTRY(machine_check)
18788 @@ -943,7 +1182,7 @@ ENTRY(machine_check)
18789 pushl_cfi machine_check_vector
18790 jmp error_code
18791 CFI_ENDPROC
18792 -END(machine_check)
18793 +ENDPROC(machine_check)
18794 #endif
18795
18796 ENTRY(spurious_interrupt_bug)
18797 @@ -953,7 +1192,7 @@ ENTRY(spurious_interrupt_bug)
18798 pushl_cfi $do_spurious_interrupt_bug
18799 jmp error_code
18800 CFI_ENDPROC
18801 -END(spurious_interrupt_bug)
18802 +ENDPROC(spurious_interrupt_bug)
18803 /*
18804 * End of kprobes section
18805 */
18806 @@ -1063,7 +1302,7 @@ BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
18807
18808 ENTRY(mcount)
18809 ret
18810 -END(mcount)
18811 +ENDPROC(mcount)
18812
18813 ENTRY(ftrace_caller)
18814 cmpl $0, function_trace_stop
18815 @@ -1096,7 +1335,7 @@ ftrace_graph_call:
18816 .globl ftrace_stub
18817 ftrace_stub:
18818 ret
18819 -END(ftrace_caller)
18820 +ENDPROC(ftrace_caller)
18821
18822 ENTRY(ftrace_regs_caller)
18823 pushf /* push flags before compare (in cs location) */
18824 @@ -1197,7 +1436,7 @@ trace:
18825 popl %ecx
18826 popl %eax
18827 jmp ftrace_stub
18828 -END(mcount)
18829 +ENDPROC(mcount)
18830 #endif /* CONFIG_DYNAMIC_FTRACE */
18831 #endif /* CONFIG_FUNCTION_TRACER */
18832
18833 @@ -1215,7 +1454,7 @@ ENTRY(ftrace_graph_caller)
18834 popl %ecx
18835 popl %eax
18836 ret
18837 -END(ftrace_graph_caller)
18838 +ENDPROC(ftrace_graph_caller)
18839
18840 .globl return_to_handler
18841 return_to_handler:
18842 @@ -1271,15 +1510,18 @@ error_code:
18843 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
18844 REG_TO_PTGS %ecx
18845 SET_KERNEL_GS %ecx
18846 - movl $(__USER_DS), %ecx
18847 + movl $(__KERNEL_DS), %ecx
18848 movl %ecx, %ds
18849 movl %ecx, %es
18850 +
18851 + pax_enter_kernel
18852 +
18853 TRACE_IRQS_OFF
18854 movl %esp,%eax # pt_regs pointer
18855 call *%edi
18856 jmp ret_from_exception
18857 CFI_ENDPROC
18858 -END(page_fault)
18859 +ENDPROC(page_fault)
18860
18861 /*
18862 * Debug traps and NMI can happen at the one SYSENTER instruction
18863 @@ -1322,7 +1564,7 @@ debug_stack_correct:
18864 call do_debug
18865 jmp ret_from_exception
18866 CFI_ENDPROC
18867 -END(debug)
18868 +ENDPROC(debug)
18869
18870 /*
18871 * NMI is doubly nasty. It can happen _while_ we're handling
18872 @@ -1360,6 +1602,9 @@ nmi_stack_correct:
18873 xorl %edx,%edx # zero error code
18874 movl %esp,%eax # pt_regs pointer
18875 call do_nmi
18876 +
18877 + pax_exit_kernel
18878 +
18879 jmp restore_all_notrace
18880 CFI_ENDPROC
18881
18882 @@ -1396,12 +1641,15 @@ nmi_espfix_stack:
18883 FIXUP_ESPFIX_STACK # %eax == %esp
18884 xorl %edx,%edx # zero error code
18885 call do_nmi
18886 +
18887 + pax_exit_kernel
18888 +
18889 RESTORE_REGS
18890 lss 12+4(%esp), %esp # back to espfix stack
18891 CFI_ADJUST_CFA_OFFSET -24
18892 jmp irq_return
18893 CFI_ENDPROC
18894 -END(nmi)
18895 +ENDPROC(nmi)
18896
18897 ENTRY(int3)
18898 RING0_INT_FRAME
18899 @@ -1414,14 +1662,14 @@ ENTRY(int3)
18900 call do_int3
18901 jmp ret_from_exception
18902 CFI_ENDPROC
18903 -END(int3)
18904 +ENDPROC(int3)
18905
18906 ENTRY(general_protection)
18907 RING0_EC_FRAME
18908 pushl_cfi $do_general_protection
18909 jmp error_code
18910 CFI_ENDPROC
18911 -END(general_protection)
18912 +ENDPROC(general_protection)
18913
18914 #ifdef CONFIG_KVM_GUEST
18915 ENTRY(async_page_fault)
18916 @@ -1430,7 +1678,7 @@ ENTRY(async_page_fault)
18917 pushl_cfi $do_async_page_fault
18918 jmp error_code
18919 CFI_ENDPROC
18920 -END(async_page_fault)
18921 +ENDPROC(async_page_fault)
18922 #endif
18923
18924 /*
18925 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
18926 index 7272089..6204f9c5 100644
18927 --- a/arch/x86/kernel/entry_64.S
18928 +++ b/arch/x86/kernel/entry_64.S
18929 @@ -59,6 +59,8 @@
18930 #include <asm/context_tracking.h>
18931 #include <asm/smap.h>
18932 #include <linux/err.h>
18933 +#include <asm/pgtable.h>
18934 +#include <asm/alternative-asm.h>
18935
18936 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
18937 #include <linux/elf-em.h>
18938 @@ -80,8 +82,9 @@
18939 #ifdef CONFIG_DYNAMIC_FTRACE
18940
18941 ENTRY(function_hook)
18942 + pax_force_retaddr
18943 retq
18944 -END(function_hook)
18945 +ENDPROC(function_hook)
18946
18947 /* skip is set if stack has been adjusted */
18948 .macro ftrace_caller_setup skip=0
18949 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
18950 #endif
18951
18952 GLOBAL(ftrace_stub)
18953 + pax_force_retaddr
18954 retq
18955 -END(ftrace_caller)
18956 +ENDPROC(ftrace_caller)
18957
18958 ENTRY(ftrace_regs_caller)
18959 /* Save the current flags before compare (in SS location)*/
18960 @@ -191,7 +195,7 @@ ftrace_restore_flags:
18961 popfq
18962 jmp ftrace_stub
18963
18964 -END(ftrace_regs_caller)
18965 +ENDPROC(ftrace_regs_caller)
18966
18967
18968 #else /* ! CONFIG_DYNAMIC_FTRACE */
18969 @@ -212,6 +216,7 @@ ENTRY(function_hook)
18970 #endif
18971
18972 GLOBAL(ftrace_stub)
18973 + pax_force_retaddr
18974 retq
18975
18976 trace:
18977 @@ -225,12 +230,13 @@ trace:
18978 #endif
18979 subq $MCOUNT_INSN_SIZE, %rdi
18980
18981 + pax_force_fptr ftrace_trace_function
18982 call *ftrace_trace_function
18983
18984 MCOUNT_RESTORE_FRAME
18985
18986 jmp ftrace_stub
18987 -END(function_hook)
18988 +ENDPROC(function_hook)
18989 #endif /* CONFIG_DYNAMIC_FTRACE */
18990 #endif /* CONFIG_FUNCTION_TRACER */
18991
18992 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
18993
18994 MCOUNT_RESTORE_FRAME
18995
18996 + pax_force_retaddr
18997 retq
18998 -END(ftrace_graph_caller)
18999 +ENDPROC(ftrace_graph_caller)
19000
19001 GLOBAL(return_to_handler)
19002 subq $24, %rsp
19003 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
19004 movq 8(%rsp), %rdx
19005 movq (%rsp), %rax
19006 addq $24, %rsp
19007 + pax_force_fptr %rdi
19008 jmp *%rdi
19009 +ENDPROC(return_to_handler)
19010 #endif
19011
19012
19013 @@ -284,6 +293,309 @@ ENTRY(native_usergs_sysret64)
19014 ENDPROC(native_usergs_sysret64)
19015 #endif /* CONFIG_PARAVIRT */
19016
19017 + .macro ljmpq sel, off
19018 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
19019 + .byte 0x48; ljmp *1234f(%rip)
19020 + .pushsection .rodata
19021 + .align 16
19022 + 1234: .quad \off; .word \sel
19023 + .popsection
19024 +#else
19025 + pushq $\sel
19026 + pushq $\off
19027 + lretq
19028 +#endif
19029 + .endm
19030 +
19031 + .macro pax_enter_kernel
19032 + pax_set_fptr_mask
19033 +#ifdef CONFIG_PAX_KERNEXEC
19034 + call pax_enter_kernel
19035 +#endif
19036 + .endm
19037 +
19038 + .macro pax_exit_kernel
19039 +#ifdef CONFIG_PAX_KERNEXEC
19040 + call pax_exit_kernel
19041 +#endif
19042 + .endm
19043 +
19044 +#ifdef CONFIG_PAX_KERNEXEC
19045 +ENTRY(pax_enter_kernel)
19046 + pushq %rdi
19047 +
19048 +#ifdef CONFIG_PARAVIRT
19049 + PV_SAVE_REGS(CLBR_RDI)
19050 +#endif
19051 +
19052 + GET_CR0_INTO_RDI
19053 + bts $16,%rdi
19054 + jnc 3f
19055 + mov %cs,%edi
19056 + cmp $__KERNEL_CS,%edi
19057 + jnz 2f
19058 +1:
19059 +
19060 +#ifdef CONFIG_PARAVIRT
19061 + PV_RESTORE_REGS(CLBR_RDI)
19062 +#endif
19063 +
19064 + popq %rdi
19065 + pax_force_retaddr
19066 + retq
19067 +
19068 +2: ljmpq __KERNEL_CS,1b
19069 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
19070 +4: SET_RDI_INTO_CR0
19071 + jmp 1b
19072 +ENDPROC(pax_enter_kernel)
19073 +
19074 +ENTRY(pax_exit_kernel)
19075 + pushq %rdi
19076 +
19077 +#ifdef CONFIG_PARAVIRT
19078 + PV_SAVE_REGS(CLBR_RDI)
19079 +#endif
19080 +
19081 + mov %cs,%rdi
19082 + cmp $__KERNEXEC_KERNEL_CS,%edi
19083 + jz 2f
19084 + GET_CR0_INTO_RDI
19085 + bts $16,%rdi
19086 + jnc 4f
19087 +1:
19088 +
19089 +#ifdef CONFIG_PARAVIRT
19090 + PV_RESTORE_REGS(CLBR_RDI);
19091 +#endif
19092 +
19093 + popq %rdi
19094 + pax_force_retaddr
19095 + retq
19096 +
19097 +2: GET_CR0_INTO_RDI
19098 + btr $16,%rdi
19099 + jnc 4f
19100 + ljmpq __KERNEL_CS,3f
19101 +3: SET_RDI_INTO_CR0
19102 + jmp 1b
19103 +4: ud2
19104 + jmp 4b
19105 +ENDPROC(pax_exit_kernel)
19106 +#endif
19107 +
19108 + .macro pax_enter_kernel_user
19109 + pax_set_fptr_mask
19110 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19111 + call pax_enter_kernel_user
19112 +#endif
19113 + .endm
19114 +
19115 + .macro pax_exit_kernel_user
19116 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19117 + call pax_exit_kernel_user
19118 +#endif
19119 +#ifdef CONFIG_PAX_RANDKSTACK
19120 + pushq %rax
19121 + pushq %r11
19122 + call pax_randomize_kstack
19123 + popq %r11
19124 + popq %rax
19125 +#endif
19126 + .endm
19127 +
19128 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19129 +ENTRY(pax_enter_kernel_user)
19130 + pushq %rdi
19131 + pushq %rbx
19132 +
19133 +#ifdef CONFIG_PARAVIRT
19134 + PV_SAVE_REGS(CLBR_RDI)
19135 +#endif
19136 +
19137 + GET_CR3_INTO_RDI
19138 + mov %rdi,%rbx
19139 + add $__START_KERNEL_map,%rbx
19140 + sub phys_base(%rip),%rbx
19141 +
19142 +#ifdef CONFIG_PARAVIRT
19143 + cmpl $0, pv_info+PARAVIRT_enabled
19144 + jz 1f
19145 + pushq %rdi
19146 + i = 0
19147 + .rept USER_PGD_PTRS
19148 + mov i*8(%rbx),%rsi
19149 + mov $0,%sil
19150 + lea i*8(%rbx),%rdi
19151 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19152 + i = i + 1
19153 + .endr
19154 + popq %rdi
19155 + jmp 2f
19156 +1:
19157 +#endif
19158 +
19159 + i = 0
19160 + .rept USER_PGD_PTRS
19161 + movb $0,i*8(%rbx)
19162 + i = i + 1
19163 + .endr
19164 +
19165 +#ifdef CONFIG_PARAVIRT
19166 +2:
19167 +#endif
19168 + SET_RDI_INTO_CR3
19169 +
19170 +#ifdef CONFIG_PAX_KERNEXEC
19171 + GET_CR0_INTO_RDI
19172 + bts $16,%rdi
19173 + SET_RDI_INTO_CR0
19174 +#endif
19175 +
19176 +#ifdef CONFIG_PARAVIRT
19177 + PV_RESTORE_REGS(CLBR_RDI)
19178 +#endif
19179 +
19180 + popq %rbx
19181 + popq %rdi
19182 + pax_force_retaddr
19183 + retq
19184 +ENDPROC(pax_enter_kernel_user)
19185 +
19186 +ENTRY(pax_exit_kernel_user)
19187 + pushq %rdi
19188 + pushq %rbx
19189 +
19190 +#ifdef CONFIG_PARAVIRT
19191 + PV_SAVE_REGS(CLBR_RDI)
19192 +#endif
19193 +
19194 +#ifdef CONFIG_PAX_KERNEXEC
19195 + GET_CR0_INTO_RDI
19196 + btr $16,%rdi
19197 + jnc 3f
19198 + SET_RDI_INTO_CR0
19199 +#endif
19200 +
19201 + GET_CR3_INTO_RDI
19202 + mov %rdi,%rbx
19203 + add $__START_KERNEL_map,%rbx
19204 + sub phys_base(%rip),%rbx
19205 +
19206 +#ifdef CONFIG_PARAVIRT
19207 + cmpl $0, pv_info+PARAVIRT_enabled
19208 + jz 1f
19209 + i = 0
19210 + .rept USER_PGD_PTRS
19211 + mov i*8(%rbx),%rsi
19212 + mov $0x67,%sil
19213 + lea i*8(%rbx),%rdi
19214 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
19215 + i = i + 1
19216 + .endr
19217 + jmp 2f
19218 +1:
19219 +#endif
19220 +
19221 + i = 0
19222 + .rept USER_PGD_PTRS
19223 + movb $0x67,i*8(%rbx)
19224 + i = i + 1
19225 + .endr
19226 +
19227 +#ifdef CONFIG_PARAVIRT
19228 +2: PV_RESTORE_REGS(CLBR_RDI)
19229 +#endif
19230 +
19231 + popq %rbx
19232 + popq %rdi
19233 + pax_force_retaddr
19234 + retq
19235 +3: ud2
19236 + jmp 3b
19237 +ENDPROC(pax_exit_kernel_user)
19238 +#endif
19239 +
19240 + .macro pax_enter_kernel_nmi
19241 + pax_set_fptr_mask
19242 +
19243 +#ifdef CONFIG_PAX_KERNEXEC
19244 + GET_CR0_INTO_RDI
19245 + bts $16,%rdi
19246 + jc 110f
19247 + SET_RDI_INTO_CR0
19248 + or $2,%ebx
19249 +110:
19250 +#endif
19251 + .endm
19252 +
19253 + .macro pax_exit_kernel_nmi
19254 +#ifdef CONFIG_PAX_KERNEXEC
19255 + btr $1,%ebx
19256 + jnc 110f
19257 + GET_CR0_INTO_RDI
19258 + btr $16,%rdi
19259 + SET_RDI_INTO_CR0
19260 +110:
19261 +#endif
19262 + .endm
19263 +
19264 + .macro pax_erase_kstack
19265 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19266 + call pax_erase_kstack
19267 +#endif
19268 + .endm
19269 +
19270 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19271 +ENTRY(pax_erase_kstack)
19272 + pushq %rdi
19273 + pushq %rcx
19274 + pushq %rax
19275 + pushq %r11
19276 +
19277 + GET_THREAD_INFO(%r11)
19278 + mov TI_lowest_stack(%r11), %rdi
19279 + mov $-0xBEEF, %rax
19280 + std
19281 +
19282 +1: mov %edi, %ecx
19283 + and $THREAD_SIZE_asm - 1, %ecx
19284 + shr $3, %ecx
19285 + repne scasq
19286 + jecxz 2f
19287 +
19288 + cmp $2*8, %ecx
19289 + jc 2f
19290 +
19291 + mov $2*8, %ecx
19292 + repe scasq
19293 + jecxz 2f
19294 + jne 1b
19295 +
19296 +2: cld
19297 + mov %esp, %ecx
19298 + sub %edi, %ecx
19299 +
19300 + cmp $THREAD_SIZE_asm, %rcx
19301 + jb 3f
19302 + ud2
19303 +3:
19304 +
19305 + shr $3, %ecx
19306 + rep stosq
19307 +
19308 + mov TI_task_thread_sp0(%r11), %rdi
19309 + sub $256, %rdi
19310 + mov %rdi, TI_lowest_stack(%r11)
19311 +
19312 + popq %r11
19313 + popq %rax
19314 + popq %rcx
19315 + popq %rdi
19316 + pax_force_retaddr
19317 + ret
19318 +ENDPROC(pax_erase_kstack)
19319 +#endif
19320
19321 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
19322 #ifdef CONFIG_TRACE_IRQFLAGS
19323 @@ -375,8 +687,8 @@ ENDPROC(native_usergs_sysret64)
19324 .endm
19325
19326 .macro UNFAKE_STACK_FRAME
19327 - addq $8*6, %rsp
19328 - CFI_ADJUST_CFA_OFFSET -(6*8)
19329 + addq $8*6 + ARG_SKIP, %rsp
19330 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
19331 .endm
19332
19333 /*
19334 @@ -463,7 +775,7 @@ ENDPROC(native_usergs_sysret64)
19335 movq %rsp, %rsi
19336
19337 leaq -RBP(%rsp),%rdi /* arg1 for handler */
19338 - testl $3, CS-RBP(%rsi)
19339 + testb $3, CS-RBP(%rsi)
19340 je 1f
19341 SWAPGS
19342 /*
19343 @@ -498,9 +810,10 @@ ENTRY(save_rest)
19344 movq_cfi r15, R15+16
19345 movq %r11, 8(%rsp) /* return address */
19346 FIXUP_TOP_OF_STACK %r11, 16
19347 + pax_force_retaddr
19348 ret
19349 CFI_ENDPROC
19350 -END(save_rest)
19351 +ENDPROC(save_rest)
19352
19353 /* save complete stack frame */
19354 .pushsection .kprobes.text, "ax"
19355 @@ -529,9 +842,10 @@ ENTRY(save_paranoid)
19356 js 1f /* negative -> in kernel */
19357 SWAPGS
19358 xorl %ebx,%ebx
19359 -1: ret
19360 +1: pax_force_retaddr_bts
19361 + ret
19362 CFI_ENDPROC
19363 -END(save_paranoid)
19364 +ENDPROC(save_paranoid)
19365 .popsection
19366
19367 /*
19368 @@ -553,7 +867,7 @@ ENTRY(ret_from_fork)
19369
19370 RESTORE_REST
19371
19372 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19373 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
19374 jz 1f
19375
19376 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
19377 @@ -571,7 +885,7 @@ ENTRY(ret_from_fork)
19378 RESTORE_REST
19379 jmp int_ret_from_sys_call
19380 CFI_ENDPROC
19381 -END(ret_from_fork)
19382 +ENDPROC(ret_from_fork)
19383
19384 /*
19385 * System call entry. Up to 6 arguments in registers are supported.
19386 @@ -608,7 +922,7 @@ END(ret_from_fork)
19387 ENTRY(system_call)
19388 CFI_STARTPROC simple
19389 CFI_SIGNAL_FRAME
19390 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
19391 + CFI_DEF_CFA rsp,0
19392 CFI_REGISTER rip,rcx
19393 /*CFI_REGISTER rflags,r11*/
19394 SWAPGS_UNSAFE_STACK
19395 @@ -621,16 +935,23 @@ GLOBAL(system_call_after_swapgs)
19396
19397 movq %rsp,PER_CPU_VAR(old_rsp)
19398 movq PER_CPU_VAR(kernel_stack),%rsp
19399 + SAVE_ARGS 8*6,0
19400 + pax_enter_kernel_user
19401 +
19402 +#ifdef CONFIG_PAX_RANDKSTACK
19403 + pax_erase_kstack
19404 +#endif
19405 +
19406 /*
19407 * No need to follow this irqs off/on section - it's straight
19408 * and short:
19409 */
19410 ENABLE_INTERRUPTS(CLBR_NONE)
19411 - SAVE_ARGS 8,0
19412 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
19413 movq %rcx,RIP-ARGOFFSET(%rsp)
19414 CFI_REL_OFFSET rip,RIP-ARGOFFSET
19415 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19416 + GET_THREAD_INFO(%rcx)
19417 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
19418 jnz tracesys
19419 system_call_fastpath:
19420 #if __SYSCALL_MASK == ~0
19421 @@ -640,7 +961,7 @@ system_call_fastpath:
19422 cmpl $__NR_syscall_max,%eax
19423 #endif
19424 ja badsys
19425 - movq %r10,%rcx
19426 + movq R10-ARGOFFSET(%rsp),%rcx
19427 call *sys_call_table(,%rax,8) # XXX: rip relative
19428 movq %rax,RAX-ARGOFFSET(%rsp)
19429 /*
19430 @@ -654,10 +975,13 @@ sysret_check:
19431 LOCKDEP_SYS_EXIT
19432 DISABLE_INTERRUPTS(CLBR_NONE)
19433 TRACE_IRQS_OFF
19434 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
19435 + GET_THREAD_INFO(%rcx)
19436 + movl TI_flags(%rcx),%edx
19437 andl %edi,%edx
19438 jnz sysret_careful
19439 CFI_REMEMBER_STATE
19440 + pax_exit_kernel_user
19441 + pax_erase_kstack
19442 /*
19443 * sysretq will re-enable interrupts:
19444 */
19445 @@ -709,14 +1033,18 @@ badsys:
19446 * jump back to the normal fast path.
19447 */
19448 auditsys:
19449 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
19450 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
19451 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
19452 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
19453 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
19454 movq %rax,%rsi /* 2nd arg: syscall number */
19455 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
19456 call __audit_syscall_entry
19457 +
19458 + pax_erase_kstack
19459 +
19460 LOAD_ARGS 0 /* reload call-clobbered registers */
19461 + pax_set_fptr_mask
19462 jmp system_call_fastpath
19463
19464 /*
19465 @@ -737,7 +1065,7 @@ sysret_audit:
19466 /* Do syscall tracing */
19467 tracesys:
19468 #ifdef CONFIG_AUDITSYSCALL
19469 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
19470 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
19471 jz auditsys
19472 #endif
19473 SAVE_REST
19474 @@ -745,12 +1073,16 @@ tracesys:
19475 FIXUP_TOP_OF_STACK %rdi
19476 movq %rsp,%rdi
19477 call syscall_trace_enter
19478 +
19479 + pax_erase_kstack
19480 +
19481 /*
19482 * Reload arg registers from stack in case ptrace changed them.
19483 * We don't reload %rax because syscall_trace_enter() returned
19484 * the value it wants us to use in the table lookup.
19485 */
19486 LOAD_ARGS ARGOFFSET, 1
19487 + pax_set_fptr_mask
19488 RESTORE_REST
19489 #if __SYSCALL_MASK == ~0
19490 cmpq $__NR_syscall_max,%rax
19491 @@ -759,7 +1091,7 @@ tracesys:
19492 cmpl $__NR_syscall_max,%eax
19493 #endif
19494 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
19495 - movq %r10,%rcx /* fixup for C */
19496 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
19497 call *sys_call_table(,%rax,8)
19498 movq %rax,RAX-ARGOFFSET(%rsp)
19499 /* Use IRET because user could have changed frame */
19500 @@ -780,7 +1112,9 @@ GLOBAL(int_with_check)
19501 andl %edi,%edx
19502 jnz int_careful
19503 andl $~TS_COMPAT,TI_status(%rcx)
19504 - jmp retint_swapgs
19505 + pax_exit_kernel_user
19506 + pax_erase_kstack
19507 + jmp retint_swapgs_pax
19508
19509 /* Either reschedule or signal or syscall exit tracking needed. */
19510 /* First do a reschedule test. */
19511 @@ -826,7 +1160,7 @@ int_restore_rest:
19512 TRACE_IRQS_OFF
19513 jmp int_with_check
19514 CFI_ENDPROC
19515 -END(system_call)
19516 +ENDPROC(system_call)
19517
19518 .macro FORK_LIKE func
19519 ENTRY(stub_\func)
19520 @@ -839,9 +1173,10 @@ ENTRY(stub_\func)
19521 DEFAULT_FRAME 0 8 /* offset 8: return address */
19522 call sys_\func
19523 RESTORE_TOP_OF_STACK %r11, 8
19524 + pax_force_retaddr
19525 ret $REST_SKIP /* pop extended registers */
19526 CFI_ENDPROC
19527 -END(stub_\func)
19528 +ENDPROC(stub_\func)
19529 .endm
19530
19531 .macro FIXED_FRAME label,func
19532 @@ -851,9 +1186,10 @@ ENTRY(\label)
19533 FIXUP_TOP_OF_STACK %r11, 8-ARGOFFSET
19534 call \func
19535 RESTORE_TOP_OF_STACK %r11, 8-ARGOFFSET
19536 + pax_force_retaddr
19537 ret
19538 CFI_ENDPROC
19539 -END(\label)
19540 +ENDPROC(\label)
19541 .endm
19542
19543 FORK_LIKE clone
19544 @@ -870,9 +1206,10 @@ ENTRY(ptregscall_common)
19545 movq_cfi_restore R12+8, r12
19546 movq_cfi_restore RBP+8, rbp
19547 movq_cfi_restore RBX+8, rbx
19548 + pax_force_retaddr
19549 ret $REST_SKIP /* pop extended registers */
19550 CFI_ENDPROC
19551 -END(ptregscall_common)
19552 +ENDPROC(ptregscall_common)
19553
19554 ENTRY(stub_execve)
19555 CFI_STARTPROC
19556 @@ -885,7 +1222,7 @@ ENTRY(stub_execve)
19557 RESTORE_REST
19558 jmp int_ret_from_sys_call
19559 CFI_ENDPROC
19560 -END(stub_execve)
19561 +ENDPROC(stub_execve)
19562
19563 /*
19564 * sigreturn is special because it needs to restore all registers on return.
19565 @@ -902,7 +1239,7 @@ ENTRY(stub_rt_sigreturn)
19566 RESTORE_REST
19567 jmp int_ret_from_sys_call
19568 CFI_ENDPROC
19569 -END(stub_rt_sigreturn)
19570 +ENDPROC(stub_rt_sigreturn)
19571
19572 #ifdef CONFIG_X86_X32_ABI
19573 ENTRY(stub_x32_rt_sigreturn)
19574 @@ -916,7 +1253,7 @@ ENTRY(stub_x32_rt_sigreturn)
19575 RESTORE_REST
19576 jmp int_ret_from_sys_call
19577 CFI_ENDPROC
19578 -END(stub_x32_rt_sigreturn)
19579 +ENDPROC(stub_x32_rt_sigreturn)
19580
19581 ENTRY(stub_x32_execve)
19582 CFI_STARTPROC
19583 @@ -930,7 +1267,7 @@ ENTRY(stub_x32_execve)
19584 RESTORE_REST
19585 jmp int_ret_from_sys_call
19586 CFI_ENDPROC
19587 -END(stub_x32_execve)
19588 +ENDPROC(stub_x32_execve)
19589
19590 #endif
19591
19592 @@ -967,7 +1304,7 @@ vector=vector+1
19593 2: jmp common_interrupt
19594 .endr
19595 CFI_ENDPROC
19596 -END(irq_entries_start)
19597 +ENDPROC(irq_entries_start)
19598
19599 .previous
19600 END(interrupt)
19601 @@ -987,6 +1324,16 @@ END(interrupt)
19602 subq $ORIG_RAX-RBP, %rsp
19603 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
19604 SAVE_ARGS_IRQ
19605 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19606 + testb $3, CS(%rdi)
19607 + jnz 1f
19608 + pax_enter_kernel
19609 + jmp 2f
19610 +1: pax_enter_kernel_user
19611 +2:
19612 +#else
19613 + pax_enter_kernel
19614 +#endif
19615 call \func
19616 .endm
19617
19618 @@ -1019,7 +1366,7 @@ ret_from_intr:
19619
19620 exit_intr:
19621 GET_THREAD_INFO(%rcx)
19622 - testl $3,CS-ARGOFFSET(%rsp)
19623 + testb $3,CS-ARGOFFSET(%rsp)
19624 je retint_kernel
19625
19626 /* Interrupt came from user space */
19627 @@ -1041,12 +1388,16 @@ retint_swapgs: /* return to user-space */
19628 * The iretq could re-enable interrupts:
19629 */
19630 DISABLE_INTERRUPTS(CLBR_ANY)
19631 + pax_exit_kernel_user
19632 +retint_swapgs_pax:
19633 TRACE_IRQS_IRETQ
19634 SWAPGS
19635 jmp restore_args
19636
19637 retint_restore_args: /* return to kernel space */
19638 DISABLE_INTERRUPTS(CLBR_ANY)
19639 + pax_exit_kernel
19640 + pax_force_retaddr (RIP-ARGOFFSET)
19641 /*
19642 * The iretq could re-enable interrupts:
19643 */
19644 @@ -1129,7 +1480,7 @@ ENTRY(retint_kernel)
19645 #endif
19646
19647 CFI_ENDPROC
19648 -END(common_interrupt)
19649 +ENDPROC(common_interrupt)
19650 /*
19651 * End of kprobes section
19652 */
19653 @@ -1147,7 +1498,7 @@ ENTRY(\sym)
19654 interrupt \do_sym
19655 jmp ret_from_intr
19656 CFI_ENDPROC
19657 -END(\sym)
19658 +ENDPROC(\sym)
19659 .endm
19660
19661 #ifdef CONFIG_SMP
19662 @@ -1208,12 +1559,22 @@ ENTRY(\sym)
19663 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19664 call error_entry
19665 DEFAULT_FRAME 0
19666 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19667 + testb $3, CS(%rsp)
19668 + jnz 1f
19669 + pax_enter_kernel
19670 + jmp 2f
19671 +1: pax_enter_kernel_user
19672 +2:
19673 +#else
19674 + pax_enter_kernel
19675 +#endif
19676 movq %rsp,%rdi /* pt_regs pointer */
19677 xorl %esi,%esi /* no error code */
19678 call \do_sym
19679 jmp error_exit /* %ebx: no swapgs flag */
19680 CFI_ENDPROC
19681 -END(\sym)
19682 +ENDPROC(\sym)
19683 .endm
19684
19685 .macro paranoidzeroentry sym do_sym
19686 @@ -1226,15 +1587,25 @@ ENTRY(\sym)
19687 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19688 call save_paranoid
19689 TRACE_IRQS_OFF
19690 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19691 + testb $3, CS(%rsp)
19692 + jnz 1f
19693 + pax_enter_kernel
19694 + jmp 2f
19695 +1: pax_enter_kernel_user
19696 +2:
19697 +#else
19698 + pax_enter_kernel
19699 +#endif
19700 movq %rsp,%rdi /* pt_regs pointer */
19701 xorl %esi,%esi /* no error code */
19702 call \do_sym
19703 jmp paranoid_exit /* %ebx: no swapgs flag */
19704 CFI_ENDPROC
19705 -END(\sym)
19706 +ENDPROC(\sym)
19707 .endm
19708
19709 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
19710 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
19711 .macro paranoidzeroentry_ist sym do_sym ist
19712 ENTRY(\sym)
19713 INTR_FRAME
19714 @@ -1245,14 +1616,30 @@ ENTRY(\sym)
19715 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19716 call save_paranoid
19717 TRACE_IRQS_OFF_DEBUG
19718 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19719 + testb $3, CS(%rsp)
19720 + jnz 1f
19721 + pax_enter_kernel
19722 + jmp 2f
19723 +1: pax_enter_kernel_user
19724 +2:
19725 +#else
19726 + pax_enter_kernel
19727 +#endif
19728 movq %rsp,%rdi /* pt_regs pointer */
19729 xorl %esi,%esi /* no error code */
19730 +#ifdef CONFIG_SMP
19731 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
19732 + lea init_tss(%r12), %r12
19733 +#else
19734 + lea init_tss(%rip), %r12
19735 +#endif
19736 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
19737 call \do_sym
19738 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
19739 jmp paranoid_exit /* %ebx: no swapgs flag */
19740 CFI_ENDPROC
19741 -END(\sym)
19742 +ENDPROC(\sym)
19743 .endm
19744
19745 .macro errorentry sym do_sym
19746 @@ -1264,13 +1651,23 @@ ENTRY(\sym)
19747 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
19748 call error_entry
19749 DEFAULT_FRAME 0
19750 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19751 + testb $3, CS(%rsp)
19752 + jnz 1f
19753 + pax_enter_kernel
19754 + jmp 2f
19755 +1: pax_enter_kernel_user
19756 +2:
19757 +#else
19758 + pax_enter_kernel
19759 +#endif
19760 movq %rsp,%rdi /* pt_regs pointer */
19761 movq ORIG_RAX(%rsp),%rsi /* get error code */
19762 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
19763 call \do_sym
19764 jmp error_exit /* %ebx: no swapgs flag */
19765 CFI_ENDPROC
19766 -END(\sym)
19767 +ENDPROC(\sym)
19768 .endm
19769
19770 /* error code is on the stack already */
19771 @@ -1284,13 +1681,23 @@ ENTRY(\sym)
19772 call save_paranoid
19773 DEFAULT_FRAME 0
19774 TRACE_IRQS_OFF
19775 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19776 + testb $3, CS(%rsp)
19777 + jnz 1f
19778 + pax_enter_kernel
19779 + jmp 2f
19780 +1: pax_enter_kernel_user
19781 +2:
19782 +#else
19783 + pax_enter_kernel
19784 +#endif
19785 movq %rsp,%rdi /* pt_regs pointer */
19786 movq ORIG_RAX(%rsp),%rsi /* get error code */
19787 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
19788 call \do_sym
19789 jmp paranoid_exit /* %ebx: no swapgs flag */
19790 CFI_ENDPROC
19791 -END(\sym)
19792 +ENDPROC(\sym)
19793 .endm
19794
19795 zeroentry divide_error do_divide_error
19796 @@ -1320,9 +1727,10 @@ gs_change:
19797 2: mfence /* workaround */
19798 SWAPGS
19799 popfq_cfi
19800 + pax_force_retaddr
19801 ret
19802 CFI_ENDPROC
19803 -END(native_load_gs_index)
19804 +ENDPROC(native_load_gs_index)
19805
19806 _ASM_EXTABLE(gs_change,bad_gs)
19807 .section .fixup,"ax"
19808 @@ -1350,9 +1758,10 @@ ENTRY(call_softirq)
19809 CFI_DEF_CFA_REGISTER rsp
19810 CFI_ADJUST_CFA_OFFSET -8
19811 decl PER_CPU_VAR(irq_count)
19812 + pax_force_retaddr
19813 ret
19814 CFI_ENDPROC
19815 -END(call_softirq)
19816 +ENDPROC(call_softirq)
19817
19818 #ifdef CONFIG_XEN
19819 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
19820 @@ -1390,7 +1799,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
19821 decl PER_CPU_VAR(irq_count)
19822 jmp error_exit
19823 CFI_ENDPROC
19824 -END(xen_do_hypervisor_callback)
19825 +ENDPROC(xen_do_hypervisor_callback)
19826
19827 /*
19828 * Hypervisor uses this for application faults while it executes.
19829 @@ -1449,7 +1858,7 @@ ENTRY(xen_failsafe_callback)
19830 SAVE_ALL
19831 jmp error_exit
19832 CFI_ENDPROC
19833 -END(xen_failsafe_callback)
19834 +ENDPROC(xen_failsafe_callback)
19835
19836 apicinterrupt HYPERVISOR_CALLBACK_VECTOR \
19837 xen_hvm_callback_vector xen_evtchn_do_upcall
19838 @@ -1501,18 +1910,33 @@ ENTRY(paranoid_exit)
19839 DEFAULT_FRAME
19840 DISABLE_INTERRUPTS(CLBR_NONE)
19841 TRACE_IRQS_OFF_DEBUG
19842 - testl %ebx,%ebx /* swapgs needed? */
19843 + testl $1,%ebx /* swapgs needed? */
19844 jnz paranoid_restore
19845 - testl $3,CS(%rsp)
19846 + testb $3,CS(%rsp)
19847 jnz paranoid_userspace
19848 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19849 + pax_exit_kernel
19850 + TRACE_IRQS_IRETQ 0
19851 + SWAPGS_UNSAFE_STACK
19852 + RESTORE_ALL 8
19853 + pax_force_retaddr_bts
19854 + jmp irq_return
19855 +#endif
19856 paranoid_swapgs:
19857 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19858 + pax_exit_kernel_user
19859 +#else
19860 + pax_exit_kernel
19861 +#endif
19862 TRACE_IRQS_IRETQ 0
19863 SWAPGS_UNSAFE_STACK
19864 RESTORE_ALL 8
19865 jmp irq_return
19866 paranoid_restore:
19867 + pax_exit_kernel
19868 TRACE_IRQS_IRETQ_DEBUG 0
19869 RESTORE_ALL 8
19870 + pax_force_retaddr_bts
19871 jmp irq_return
19872 paranoid_userspace:
19873 GET_THREAD_INFO(%rcx)
19874 @@ -1541,7 +1965,7 @@ paranoid_schedule:
19875 TRACE_IRQS_OFF
19876 jmp paranoid_userspace
19877 CFI_ENDPROC
19878 -END(paranoid_exit)
19879 +ENDPROC(paranoid_exit)
19880
19881 /*
19882 * Exception entry point. This expects an error code/orig_rax on the stack.
19883 @@ -1568,12 +1992,13 @@ ENTRY(error_entry)
19884 movq_cfi r14, R14+8
19885 movq_cfi r15, R15+8
19886 xorl %ebx,%ebx
19887 - testl $3,CS+8(%rsp)
19888 + testb $3,CS+8(%rsp)
19889 je error_kernelspace
19890 error_swapgs:
19891 SWAPGS
19892 error_sti:
19893 TRACE_IRQS_OFF
19894 + pax_force_retaddr_bts
19895 ret
19896
19897 /*
19898 @@ -1600,7 +2025,7 @@ bstep_iret:
19899 movq %rcx,RIP+8(%rsp)
19900 jmp error_swapgs
19901 CFI_ENDPROC
19902 -END(error_entry)
19903 +ENDPROC(error_entry)
19904
19905
19906 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
19907 @@ -1611,7 +2036,7 @@ ENTRY(error_exit)
19908 DISABLE_INTERRUPTS(CLBR_NONE)
19909 TRACE_IRQS_OFF
19910 GET_THREAD_INFO(%rcx)
19911 - testl %eax,%eax
19912 + testl $1,%eax
19913 jne retint_kernel
19914 LOCKDEP_SYS_EXIT_IRQ
19915 movl TI_flags(%rcx),%edx
19916 @@ -1620,7 +2045,7 @@ ENTRY(error_exit)
19917 jnz retint_careful
19918 jmp retint_swapgs
19919 CFI_ENDPROC
19920 -END(error_exit)
19921 +ENDPROC(error_exit)
19922
19923 /*
19924 * Test if a given stack is an NMI stack or not.
19925 @@ -1678,9 +2103,11 @@ ENTRY(nmi)
19926 * If %cs was not the kernel segment, then the NMI triggered in user
19927 * space, which means it is definitely not nested.
19928 */
19929 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
19930 + je 1f
19931 cmpl $__KERNEL_CS, 16(%rsp)
19932 jne first_nmi
19933 -
19934 +1:
19935 /*
19936 * Check the special variable on the stack to see if NMIs are
19937 * executing.
19938 @@ -1714,8 +2141,7 @@ nested_nmi:
19939
19940 1:
19941 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
19942 - leaq -1*8(%rsp), %rdx
19943 - movq %rdx, %rsp
19944 + subq $8, %rsp
19945 CFI_ADJUST_CFA_OFFSET 1*8
19946 leaq -10*8(%rsp), %rdx
19947 pushq_cfi $__KERNEL_DS
19948 @@ -1733,6 +2159,7 @@ nested_nmi_out:
19949 CFI_RESTORE rdx
19950
19951 /* No need to check faults here */
19952 +# pax_force_retaddr_bts
19953 INTERRUPT_RETURN
19954
19955 CFI_RESTORE_STATE
19956 @@ -1849,6 +2276,8 @@ end_repeat_nmi:
19957 */
19958 movq %cr2, %r12
19959
19960 + pax_enter_kernel_nmi
19961 +
19962 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
19963 movq %rsp,%rdi
19964 movq $-1,%rsi
19965 @@ -1861,26 +2290,31 @@ end_repeat_nmi:
19966 movq %r12, %cr2
19967 1:
19968
19969 - testl %ebx,%ebx /* swapgs needed? */
19970 + testl $1,%ebx /* swapgs needed? */
19971 jnz nmi_restore
19972 nmi_swapgs:
19973 SWAPGS_UNSAFE_STACK
19974 nmi_restore:
19975 + pax_exit_kernel_nmi
19976 /* Pop the extra iret frame at once */
19977 RESTORE_ALL 6*8
19978 + testb $3, 8(%rsp)
19979 + jnz 1f
19980 + pax_force_retaddr_bts
19981 +1:
19982
19983 /* Clear the NMI executing stack variable */
19984 movq $0, 5*8(%rsp)
19985 jmp irq_return
19986 CFI_ENDPROC
19987 -END(nmi)
19988 +ENDPROC(nmi)
19989
19990 ENTRY(ignore_sysret)
19991 CFI_STARTPROC
19992 mov $-ENOSYS,%eax
19993 sysret
19994 CFI_ENDPROC
19995 -END(ignore_sysret)
19996 +ENDPROC(ignore_sysret)
19997
19998 /*
19999 * End of kprobes section
20000 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
20001 index 42a392a..fbbd930 100644
20002 --- a/arch/x86/kernel/ftrace.c
20003 +++ b/arch/x86/kernel/ftrace.c
20004 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
20005 {
20006 unsigned char replaced[MCOUNT_INSN_SIZE];
20007
20008 + ip = ktla_ktva(ip);
20009 +
20010 /*
20011 * Note: Due to modules and __init, code can
20012 * disappear and change, we need to protect against faulting
20013 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
20014 unsigned char old[MCOUNT_INSN_SIZE], *new;
20015 int ret;
20016
20017 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
20018 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
20019 new = ftrace_call_replace(ip, (unsigned long)func);
20020
20021 /* See comment above by declaration of modifying_ftrace_code */
20022 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
20023 /* Also update the regs callback function */
20024 if (!ret) {
20025 ip = (unsigned long)(&ftrace_regs_call);
20026 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
20027 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
20028 new = ftrace_call_replace(ip, (unsigned long)func);
20029 ret = ftrace_modify_code(ip, old, new);
20030 }
20031 @@ -279,7 +281,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
20032 * kernel identity mapping to modify code.
20033 */
20034 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
20035 - ip = (unsigned long)__va(__pa_symbol(ip));
20036 + ip = (unsigned long)__va(__pa_symbol(ktla_ktva(ip)));
20037
20038 return probe_kernel_write((void *)ip, val, size);
20039 }
20040 @@ -289,7 +291,7 @@ static int add_break(unsigned long ip, const char *old)
20041 unsigned char replaced[MCOUNT_INSN_SIZE];
20042 unsigned char brk = BREAKPOINT_INSTRUCTION;
20043
20044 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
20045 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
20046 return -EFAULT;
20047
20048 /* Make sure it is what we expect it to be */
20049 @@ -637,7 +639,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
20050 return ret;
20051
20052 fail_update:
20053 - probe_kernel_write((void *)ip, &old_code[0], 1);
20054 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
20055 goto out;
20056 }
20057
20058 @@ -670,6 +672,8 @@ static int ftrace_mod_jmp(unsigned long ip,
20059 {
20060 unsigned char code[MCOUNT_INSN_SIZE];
20061
20062 + ip = ktla_ktva(ip);
20063 +
20064 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
20065 return -EFAULT;
20066
20067 diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
20068 index 55b6761..a6456fc 100644
20069 --- a/arch/x86/kernel/head64.c
20070 +++ b/arch/x86/kernel/head64.c
20071 @@ -67,12 +67,12 @@ again:
20072 pgd = *pgd_p;
20073
20074 /*
20075 - * The use of __START_KERNEL_map rather than __PAGE_OFFSET here is
20076 - * critical -- __PAGE_OFFSET would point us back into the dynamic
20077 + * The use of __early_va rather than __va here is critical:
20078 + * __va would point us back into the dynamic
20079 * range and we might end up looping forever...
20080 */
20081 if (pgd)
20082 - pud_p = (pudval_t *)((pgd & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
20083 + pud_p = (pudval_t *)(__early_va(pgd & PTE_PFN_MASK));
20084 else {
20085 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
20086 reset_early_page_tables();
20087 @@ -82,13 +82,13 @@ again:
20088 pud_p = (pudval_t *)early_dynamic_pgts[next_early_pgt++];
20089 for (i = 0; i < PTRS_PER_PUD; i++)
20090 pud_p[i] = 0;
20091 - *pgd_p = (pgdval_t)pud_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
20092 + *pgd_p = (pgdval_t)__pa(pud_p) + _KERNPG_TABLE;
20093 }
20094 pud_p += pud_index(address);
20095 pud = *pud_p;
20096
20097 if (pud)
20098 - pmd_p = (pmdval_t *)((pud & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
20099 + pmd_p = (pmdval_t *)(__early_va(pud & PTE_PFN_MASK));
20100 else {
20101 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
20102 reset_early_page_tables();
20103 @@ -98,7 +98,7 @@ again:
20104 pmd_p = (pmdval_t *)early_dynamic_pgts[next_early_pgt++];
20105 for (i = 0; i < PTRS_PER_PMD; i++)
20106 pmd_p[i] = 0;
20107 - *pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
20108 + *pud_p = (pudval_t)__pa(pmd_p) + _KERNPG_TABLE;
20109 }
20110 pmd = (physaddr & PMD_MASK) + early_pmd_flags;
20111 pmd_p[pmd_index(address)] = pmd;
20112 @@ -175,7 +175,6 @@ void __init x86_64_start_kernel(char * real_mode_data)
20113 if (console_loglevel == 10)
20114 early_printk("Kernel alive\n");
20115
20116 - clear_page(init_level4_pgt);
20117 /* set init_level4_pgt kernel high mapping*/
20118 init_level4_pgt[511] = early_level4_pgt[511];
20119
20120 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
20121 index 73afd11..d1670f5 100644
20122 --- a/arch/x86/kernel/head_32.S
20123 +++ b/arch/x86/kernel/head_32.S
20124 @@ -26,6 +26,12 @@
20125 /* Physical address */
20126 #define pa(X) ((X) - __PAGE_OFFSET)
20127
20128 +#ifdef CONFIG_PAX_KERNEXEC
20129 +#define ta(X) (X)
20130 +#else
20131 +#define ta(X) ((X) - __PAGE_OFFSET)
20132 +#endif
20133 +
20134 /*
20135 * References to members of the new_cpu_data structure.
20136 */
20137 @@ -55,11 +61,7 @@
20138 * and small than max_low_pfn, otherwise will waste some page table entries
20139 */
20140
20141 -#if PTRS_PER_PMD > 1
20142 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
20143 -#else
20144 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
20145 -#endif
20146 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
20147
20148 /* Number of possible pages in the lowmem region */
20149 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
20150 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
20151 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20152
20153 /*
20154 + * Real beginning of normal "text" segment
20155 + */
20156 +ENTRY(stext)
20157 +ENTRY(_stext)
20158 +
20159 +/*
20160 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
20161 * %esi points to the real-mode code as a 32-bit pointer.
20162 * CS and DS must be 4 GB flat segments, but we don't depend on
20163 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
20164 * can.
20165 */
20166 __HEAD
20167 +
20168 +#ifdef CONFIG_PAX_KERNEXEC
20169 + jmp startup_32
20170 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
20171 +.fill PAGE_SIZE-5,1,0xcc
20172 +#endif
20173 +
20174 ENTRY(startup_32)
20175 movl pa(stack_start),%ecx
20176
20177 @@ -106,6 +121,59 @@ ENTRY(startup_32)
20178 2:
20179 leal -__PAGE_OFFSET(%ecx),%esp
20180
20181 +#ifdef CONFIG_SMP
20182 + movl $pa(cpu_gdt_table),%edi
20183 + movl $__per_cpu_load,%eax
20184 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
20185 + rorl $16,%eax
20186 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
20187 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
20188 + movl $__per_cpu_end - 1,%eax
20189 + subl $__per_cpu_start,%eax
20190 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
20191 +#endif
20192 +
20193 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20194 + movl $NR_CPUS,%ecx
20195 + movl $pa(cpu_gdt_table),%edi
20196 +1:
20197 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
20198 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
20199 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
20200 + addl $PAGE_SIZE_asm,%edi
20201 + loop 1b
20202 +#endif
20203 +
20204 +#ifdef CONFIG_PAX_KERNEXEC
20205 + movl $pa(boot_gdt),%edi
20206 + movl $__LOAD_PHYSICAL_ADDR,%eax
20207 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
20208 + rorl $16,%eax
20209 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
20210 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
20211 + rorl $16,%eax
20212 +
20213 + ljmp $(__BOOT_CS),$1f
20214 +1:
20215 +
20216 + movl $NR_CPUS,%ecx
20217 + movl $pa(cpu_gdt_table),%edi
20218 + addl $__PAGE_OFFSET,%eax
20219 +1:
20220 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
20221 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
20222 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
20223 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
20224 + rorl $16,%eax
20225 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
20226 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
20227 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
20228 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
20229 + rorl $16,%eax
20230 + addl $PAGE_SIZE_asm,%edi
20231 + loop 1b
20232 +#endif
20233 +
20234 /*
20235 * Clear BSS first so that there are no surprises...
20236 */
20237 @@ -201,8 +269,11 @@ ENTRY(startup_32)
20238 movl %eax, pa(max_pfn_mapped)
20239
20240 /* Do early initialization of the fixmap area */
20241 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20242 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
20243 +#ifdef CONFIG_COMPAT_VDSO
20244 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
20245 +#else
20246 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
20247 +#endif
20248 #else /* Not PAE */
20249
20250 page_pde_offset = (__PAGE_OFFSET >> 20);
20251 @@ -232,8 +303,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20252 movl %eax, pa(max_pfn_mapped)
20253
20254 /* Do early initialization of the fixmap area */
20255 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
20256 - movl %eax,pa(initial_page_table+0xffc)
20257 +#ifdef CONFIG_COMPAT_VDSO
20258 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
20259 +#else
20260 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
20261 +#endif
20262 #endif
20263
20264 #ifdef CONFIG_PARAVIRT
20265 @@ -247,9 +321,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
20266 cmpl $num_subarch_entries, %eax
20267 jae bad_subarch
20268
20269 - movl pa(subarch_entries)(,%eax,4), %eax
20270 - subl $__PAGE_OFFSET, %eax
20271 - jmp *%eax
20272 + jmp *pa(subarch_entries)(,%eax,4)
20273
20274 bad_subarch:
20275 WEAK(lguest_entry)
20276 @@ -261,10 +333,10 @@ WEAK(xen_entry)
20277 __INITDATA
20278
20279 subarch_entries:
20280 - .long default_entry /* normal x86/PC */
20281 - .long lguest_entry /* lguest hypervisor */
20282 - .long xen_entry /* Xen hypervisor */
20283 - .long default_entry /* Moorestown MID */
20284 + .long ta(default_entry) /* normal x86/PC */
20285 + .long ta(lguest_entry) /* lguest hypervisor */
20286 + .long ta(xen_entry) /* Xen hypervisor */
20287 + .long ta(default_entry) /* Moorestown MID */
20288 num_subarch_entries = (. - subarch_entries) / 4
20289 .previous
20290 #else
20291 @@ -355,6 +427,7 @@ default_entry:
20292 movl pa(mmu_cr4_features),%eax
20293 movl %eax,%cr4
20294
20295 +#ifdef CONFIG_X86_PAE
20296 testb $X86_CR4_PAE, %al # check if PAE is enabled
20297 jz enable_paging
20298
20299 @@ -383,6 +456,9 @@ default_entry:
20300 /* Make changes effective */
20301 wrmsr
20302
20303 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
20304 +#endif
20305 +
20306 enable_paging:
20307
20308 /*
20309 @@ -451,14 +527,20 @@ is486:
20310 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
20311 movl %eax,%ss # after changing gdt.
20312
20313 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
20314 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
20315 movl %eax,%ds
20316 movl %eax,%es
20317
20318 movl $(__KERNEL_PERCPU), %eax
20319 movl %eax,%fs # set this cpu's percpu
20320
20321 +#ifdef CONFIG_CC_STACKPROTECTOR
20322 movl $(__KERNEL_STACK_CANARY),%eax
20323 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
20324 + movl $(__USER_DS),%eax
20325 +#else
20326 + xorl %eax,%eax
20327 +#endif
20328 movl %eax,%gs
20329
20330 xorl %eax,%eax # Clear LDT
20331 @@ -534,8 +616,11 @@ setup_once:
20332 * relocation. Manually set base address in stack canary
20333 * segment descriptor.
20334 */
20335 - movl $gdt_page,%eax
20336 + movl $cpu_gdt_table,%eax
20337 movl $stack_canary,%ecx
20338 +#ifdef CONFIG_SMP
20339 + addl $__per_cpu_load,%ecx
20340 +#endif
20341 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
20342 shrl $16, %ecx
20343 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
20344 @@ -566,7 +651,7 @@ ENDPROC(early_idt_handlers)
20345 /* This is global to keep gas from relaxing the jumps */
20346 ENTRY(early_idt_handler)
20347 cld
20348 - cmpl $2,%ss:early_recursion_flag
20349 + cmpl $1,%ss:early_recursion_flag
20350 je hlt_loop
20351 incl %ss:early_recursion_flag
20352
20353 @@ -604,8 +689,8 @@ ENTRY(early_idt_handler)
20354 pushl (20+6*4)(%esp) /* trapno */
20355 pushl $fault_msg
20356 call printk
20357 -#endif
20358 call dump_stack
20359 +#endif
20360 hlt_loop:
20361 hlt
20362 jmp hlt_loop
20363 @@ -624,8 +709,11 @@ ENDPROC(early_idt_handler)
20364 /* This is the default interrupt "handler" :-) */
20365 ALIGN
20366 ignore_int:
20367 - cld
20368 #ifdef CONFIG_PRINTK
20369 + cmpl $2,%ss:early_recursion_flag
20370 + je hlt_loop
20371 + incl %ss:early_recursion_flag
20372 + cld
20373 pushl %eax
20374 pushl %ecx
20375 pushl %edx
20376 @@ -634,9 +722,6 @@ ignore_int:
20377 movl $(__KERNEL_DS),%eax
20378 movl %eax,%ds
20379 movl %eax,%es
20380 - cmpl $2,early_recursion_flag
20381 - je hlt_loop
20382 - incl early_recursion_flag
20383 pushl 16(%esp)
20384 pushl 24(%esp)
20385 pushl 32(%esp)
20386 @@ -670,29 +755,43 @@ ENTRY(setup_once_ref)
20387 /*
20388 * BSS section
20389 */
20390 -__PAGE_ALIGNED_BSS
20391 - .align PAGE_SIZE
20392 #ifdef CONFIG_X86_PAE
20393 +.section .initial_pg_pmd,"a",@progbits
20394 initial_pg_pmd:
20395 .fill 1024*KPMDS,4,0
20396 #else
20397 +.section .initial_page_table,"a",@progbits
20398 ENTRY(initial_page_table)
20399 .fill 1024,4,0
20400 #endif
20401 +.section .initial_pg_fixmap,"a",@progbits
20402 initial_pg_fixmap:
20403 .fill 1024,4,0
20404 +.section .empty_zero_page,"a",@progbits
20405 ENTRY(empty_zero_page)
20406 .fill 4096,1,0
20407 +.section .swapper_pg_dir,"a",@progbits
20408 ENTRY(swapper_pg_dir)
20409 +#ifdef CONFIG_X86_PAE
20410 + .fill 4,8,0
20411 +#else
20412 .fill 1024,4,0
20413 +#endif
20414 +
20415 +/*
20416 + * The IDT has to be page-aligned to simplify the Pentium
20417 + * F0 0F bug workaround.. We have a special link segment
20418 + * for this.
20419 + */
20420 +.section .idt,"a",@progbits
20421 +ENTRY(idt_table)
20422 + .fill 256,8,0
20423
20424 /*
20425 * This starts the data section.
20426 */
20427 #ifdef CONFIG_X86_PAE
20428 -__PAGE_ALIGNED_DATA
20429 - /* Page-aligned for the benefit of paravirt? */
20430 - .align PAGE_SIZE
20431 +.section .initial_page_table,"a",@progbits
20432 ENTRY(initial_page_table)
20433 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
20434 # if KPMDS == 3
20435 @@ -711,12 +810,20 @@ ENTRY(initial_page_table)
20436 # error "Kernel PMDs should be 1, 2 or 3"
20437 # endif
20438 .align PAGE_SIZE /* needs to be page-sized too */
20439 +
20440 +#ifdef CONFIG_PAX_PER_CPU_PGD
20441 +ENTRY(cpu_pgd)
20442 + .rept NR_CPUS
20443 + .fill 4,8,0
20444 + .endr
20445 +#endif
20446 +
20447 #endif
20448
20449 .data
20450 .balign 4
20451 ENTRY(stack_start)
20452 - .long init_thread_union+THREAD_SIZE
20453 + .long init_thread_union+THREAD_SIZE-8
20454
20455 __INITRODATA
20456 int_msg:
20457 @@ -744,7 +851,7 @@ fault_msg:
20458 * segment size, and 32-bit linear address value:
20459 */
20460
20461 - .data
20462 +.section .rodata,"a",@progbits
20463 .globl boot_gdt_descr
20464 .globl idt_descr
20465
20466 @@ -753,7 +860,7 @@ fault_msg:
20467 .word 0 # 32 bit align gdt_desc.address
20468 boot_gdt_descr:
20469 .word __BOOT_DS+7
20470 - .long boot_gdt - __PAGE_OFFSET
20471 + .long pa(boot_gdt)
20472
20473 .word 0 # 32-bit align idt_desc.address
20474 idt_descr:
20475 @@ -764,7 +871,7 @@ idt_descr:
20476 .word 0 # 32 bit align gdt_desc.address
20477 ENTRY(early_gdt_descr)
20478 .word GDT_ENTRIES*8-1
20479 - .long gdt_page /* Overwritten for secondary CPUs */
20480 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
20481
20482 /*
20483 * The boot_gdt must mirror the equivalent in setup.S and is
20484 @@ -773,5 +880,65 @@ ENTRY(early_gdt_descr)
20485 .align L1_CACHE_BYTES
20486 ENTRY(boot_gdt)
20487 .fill GDT_ENTRY_BOOT_CS,8,0
20488 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
20489 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
20490 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
20491 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
20492 +
20493 + .align PAGE_SIZE_asm
20494 +ENTRY(cpu_gdt_table)
20495 + .rept NR_CPUS
20496 + .quad 0x0000000000000000 /* NULL descriptor */
20497 + .quad 0x0000000000000000 /* 0x0b reserved */
20498 + .quad 0x0000000000000000 /* 0x13 reserved */
20499 + .quad 0x0000000000000000 /* 0x1b reserved */
20500 +
20501 +#ifdef CONFIG_PAX_KERNEXEC
20502 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
20503 +#else
20504 + .quad 0x0000000000000000 /* 0x20 unused */
20505 +#endif
20506 +
20507 + .quad 0x0000000000000000 /* 0x28 unused */
20508 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
20509 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
20510 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
20511 + .quad 0x0000000000000000 /* 0x4b reserved */
20512 + .quad 0x0000000000000000 /* 0x53 reserved */
20513 + .quad 0x0000000000000000 /* 0x5b reserved */
20514 +
20515 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
20516 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
20517 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
20518 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
20519 +
20520 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
20521 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
20522 +
20523 + /*
20524 + * Segments used for calling PnP BIOS have byte granularity.
20525 + * The code segments and data segments have fixed 64k limits,
20526 + * the transfer segment sizes are set at run time.
20527 + */
20528 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
20529 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
20530 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
20531 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
20532 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
20533 +
20534 + /*
20535 + * The APM segments have byte granularity and their bases
20536 + * are set at run time. All have 64k limits.
20537 + */
20538 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
20539 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
20540 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
20541 +
20542 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
20543 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
20544 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
20545 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
20546 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
20547 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
20548 +
20549 + /* Be sure this is zeroed to avoid false validations in Xen */
20550 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
20551 + .endr
20552 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
20553 index 321d65e..863089b 100644
20554 --- a/arch/x86/kernel/head_64.S
20555 +++ b/arch/x86/kernel/head_64.S
20556 @@ -20,6 +20,8 @@
20557 #include <asm/processor-flags.h>
20558 #include <asm/percpu.h>
20559 #include <asm/nops.h>
20560 +#include <asm/cpufeature.h>
20561 +#include <asm/alternative-asm.h>
20562
20563 #ifdef CONFIG_PARAVIRT
20564 #include <asm/asm-offsets.h>
20565 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
20566 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
20567 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
20568 L3_START_KERNEL = pud_index(__START_KERNEL_map)
20569 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
20570 +L3_VMALLOC_START = pud_index(VMALLOC_START)
20571 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
20572 +L3_VMALLOC_END = pud_index(VMALLOC_END)
20573 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
20574 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
20575
20576 .text
20577 __HEAD
20578 @@ -89,11 +97,23 @@ startup_64:
20579 * Fixup the physical addresses in the page table
20580 */
20581 addq %rbp, early_level4_pgt + (L4_START_KERNEL*8)(%rip)
20582 + addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
20583 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
20584 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
20585 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
20586 + addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
20587
20588 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
20589 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
20590 + addq %rbp, level3_ident_pgt + (0*8)(%rip)
20591 +#ifndef CONFIG_XEN
20592 + addq %rbp, level3_ident_pgt + (1*8)(%rip)
20593 +#endif
20594
20595 - addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
20596 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
20597 +
20598 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
20599 + addq %rbp, level3_kernel_pgt + ((L3_START_KERNEL+1)*8)(%rip)
20600 +
20601 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
20602
20603 /*
20604 * Set up the identity mapping for the switchover. These
20605 @@ -177,8 +197,8 @@ ENTRY(secondary_startup_64)
20606 movq $(init_level4_pgt - __START_KERNEL_map), %rax
20607 1:
20608
20609 - /* Enable PAE mode and PGE */
20610 - movl $(X86_CR4_PAE | X86_CR4_PGE), %ecx
20611 + /* Enable PAE mode and PSE/PGE */
20612 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %ecx
20613 movq %rcx, %cr4
20614
20615 /* Setup early boot stage 4 level pagetables. */
20616 @@ -199,10 +219,18 @@ ENTRY(secondary_startup_64)
20617 movl $MSR_EFER, %ecx
20618 rdmsr
20619 btsl $_EFER_SCE, %eax /* Enable System Call */
20620 - btl $20,%edi /* No Execute supported? */
20621 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
20622 jnc 1f
20623 btsl $_EFER_NX, %eax
20624 btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
20625 + leaq init_level4_pgt(%rip), %rdi
20626 +#ifndef CONFIG_EFI
20627 + btsq $_PAGE_BIT_NX, 8*L4_PAGE_OFFSET(%rdi)
20628 +#endif
20629 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_START(%rdi)
20630 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_END(%rdi)
20631 + btsq $_PAGE_BIT_NX, 8*L4_VMEMMAP_START(%rdi)
20632 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
20633 1: wrmsr /* Make changes effective */
20634
20635 /* Setup cr0 */
20636 @@ -282,6 +310,7 @@ ENTRY(secondary_startup_64)
20637 * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
20638 * address given in m16:64.
20639 */
20640 + pax_set_fptr_mask
20641 movq initial_code(%rip),%rax
20642 pushq $0 # fake return address to stop unwinder
20643 pushq $__KERNEL_CS # set correct cs
20644 @@ -388,7 +417,7 @@ ENTRY(early_idt_handler)
20645 call dump_stack
20646 #ifdef CONFIG_KALLSYMS
20647 leaq early_idt_ripmsg(%rip),%rdi
20648 - movq 40(%rsp),%rsi # %rip again
20649 + movq 88(%rsp),%rsi # %rip again
20650 call __print_symbol
20651 #endif
20652 #endif /* EARLY_PRINTK */
20653 @@ -416,6 +445,7 @@ ENDPROC(early_idt_handler)
20654 early_recursion_flag:
20655 .long 0
20656
20657 + .section .rodata,"a",@progbits
20658 #ifdef CONFIG_EARLY_PRINTK
20659 early_idt_msg:
20660 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
20661 @@ -443,29 +473,52 @@ NEXT_PAGE(early_level4_pgt)
20662 NEXT_PAGE(early_dynamic_pgts)
20663 .fill 512*EARLY_DYNAMIC_PAGE_TABLES,8,0
20664
20665 - .data
20666 + .section .rodata,"a",@progbits
20667
20668 -#ifndef CONFIG_XEN
20669 NEXT_PAGE(init_level4_pgt)
20670 - .fill 512,8,0
20671 -#else
20672 -NEXT_PAGE(init_level4_pgt)
20673 - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20674 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
20675 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20676 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
20677 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
20678 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
20679 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
20680 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
20681 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20682 .org init_level4_pgt + L4_START_KERNEL*8, 0
20683 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
20684 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
20685
20686 +#ifdef CONFIG_PAX_PER_CPU_PGD
20687 +NEXT_PAGE(cpu_pgd)
20688 + .rept NR_CPUS
20689 + .fill 512,8,0
20690 + .endr
20691 +#endif
20692 +
20693 NEXT_PAGE(level3_ident_pgt)
20694 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
20695 +#ifdef CONFIG_XEN
20696 .fill 511, 8, 0
20697 +#else
20698 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
20699 + .fill 510,8,0
20700 +#endif
20701 +
20702 +NEXT_PAGE(level3_vmalloc_start_pgt)
20703 + .fill 512,8,0
20704 +
20705 +NEXT_PAGE(level3_vmalloc_end_pgt)
20706 + .fill 512,8,0
20707 +
20708 +NEXT_PAGE(level3_vmemmap_pgt)
20709 + .fill L3_VMEMMAP_START,8,0
20710 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
20711 +
20712 NEXT_PAGE(level2_ident_pgt)
20713 - /* Since I easily can, map the first 1G.
20714 + /* Since I easily can, map the first 2G.
20715 * Don't set NX because code runs from these pages.
20716 */
20717 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
20718 -#endif
20719 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
20720
20721 NEXT_PAGE(level3_kernel_pgt)
20722 .fill L3_START_KERNEL,8,0
20723 @@ -473,6 +526,9 @@ NEXT_PAGE(level3_kernel_pgt)
20724 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
20725 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
20726
20727 +NEXT_PAGE(level2_vmemmap_pgt)
20728 + .fill 512,8,0
20729 +
20730 NEXT_PAGE(level2_kernel_pgt)
20731 /*
20732 * 512 MB kernel mapping. We spend a full page on this pagetable
20733 @@ -488,39 +544,64 @@ NEXT_PAGE(level2_kernel_pgt)
20734 KERNEL_IMAGE_SIZE/PMD_SIZE)
20735
20736 NEXT_PAGE(level2_fixmap_pgt)
20737 - .fill 506,8,0
20738 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
20739 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
20740 - .fill 5,8,0
20741 + .fill 507,8,0
20742 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
20743 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
20744 + .fill 4,8,0
20745
20746 -NEXT_PAGE(level1_fixmap_pgt)
20747 +NEXT_PAGE(level1_vsyscall_pgt)
20748 .fill 512,8,0
20749
20750 #undef PMDS
20751
20752 - .data
20753 + .align PAGE_SIZE
20754 +ENTRY(cpu_gdt_table)
20755 + .rept NR_CPUS
20756 + .quad 0x0000000000000000 /* NULL descriptor */
20757 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
20758 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
20759 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
20760 + .quad 0x00cffb000000ffff /* __USER32_CS */
20761 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
20762 + .quad 0x00affb000000ffff /* __USER_CS */
20763 +
20764 +#ifdef CONFIG_PAX_KERNEXEC
20765 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
20766 +#else
20767 + .quad 0x0 /* unused */
20768 +#endif
20769 +
20770 + .quad 0,0 /* TSS */
20771 + .quad 0,0 /* LDT */
20772 + .quad 0,0,0 /* three TLS descriptors */
20773 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
20774 + /* asm/segment.h:GDT_ENTRIES must match this */
20775 +
20776 + /* zero the remaining page */
20777 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
20778 + .endr
20779 +
20780 .align 16
20781 .globl early_gdt_descr
20782 early_gdt_descr:
20783 .word GDT_ENTRIES*8-1
20784 early_gdt_descr_base:
20785 - .quad INIT_PER_CPU_VAR(gdt_page)
20786 + .quad cpu_gdt_table
20787
20788 ENTRY(phys_base)
20789 /* This must match the first entry in level2_kernel_pgt */
20790 .quad 0x0000000000000000
20791
20792 #include "../../x86/xen/xen-head.S"
20793 -
20794 - .section .bss, "aw", @nobits
20795 - .align L1_CACHE_BYTES
20796 -ENTRY(idt_table)
20797 - .skip IDT_ENTRIES * 16
20798
20799 - .align L1_CACHE_BYTES
20800 -ENTRY(nmi_idt_table)
20801 - .skip IDT_ENTRIES * 16
20802 -
20803 - __PAGE_ALIGNED_BSS
20804 + .section .rodata,"a",@progbits
20805 NEXT_PAGE(empty_zero_page)
20806 .skip PAGE_SIZE
20807 +
20808 + .align L1_CACHE_BYTES
20809 +ENTRY(idt_table)
20810 + .fill 512,8,0
20811 +
20812 + .align L1_CACHE_BYTES
20813 +ENTRY(nmi_idt_table)
20814 + .fill 512,8,0
20815 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
20816 index 0fa6912..37fce70 100644
20817 --- a/arch/x86/kernel/i386_ksyms_32.c
20818 +++ b/arch/x86/kernel/i386_ksyms_32.c
20819 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
20820 EXPORT_SYMBOL(cmpxchg8b_emu);
20821 #endif
20822
20823 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
20824 +
20825 /* Networking helper routines. */
20826 EXPORT_SYMBOL(csum_partial_copy_generic);
20827 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
20828 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
20829
20830 EXPORT_SYMBOL(__get_user_1);
20831 EXPORT_SYMBOL(__get_user_2);
20832 @@ -37,3 +41,7 @@ EXPORT_SYMBOL(strstr);
20833
20834 EXPORT_SYMBOL(csum_partial);
20835 EXPORT_SYMBOL(empty_zero_page);
20836 +
20837 +#ifdef CONFIG_PAX_KERNEXEC
20838 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
20839 +#endif
20840 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
20841 index cb33909..1163b40 100644
20842 --- a/arch/x86/kernel/i387.c
20843 +++ b/arch/x86/kernel/i387.c
20844 @@ -51,7 +51,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
20845 static inline bool interrupted_user_mode(void)
20846 {
20847 struct pt_regs *regs = get_irq_regs();
20848 - return regs && user_mode_vm(regs);
20849 + return regs && user_mode(regs);
20850 }
20851
20852 /*
20853 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
20854 index 9a5c460..84868423 100644
20855 --- a/arch/x86/kernel/i8259.c
20856 +++ b/arch/x86/kernel/i8259.c
20857 @@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
20858 static void make_8259A_irq(unsigned int irq)
20859 {
20860 disable_irq_nosync(irq);
20861 - io_apic_irqs &= ~(1<<irq);
20862 + io_apic_irqs &= ~(1UL<<irq);
20863 irq_set_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
20864 i8259A_chip.name);
20865 enable_irq(irq);
20866 @@ -209,7 +209,7 @@ spurious_8259A_irq:
20867 "spurious 8259A interrupt: IRQ%d.\n", irq);
20868 spurious_irq_mask |= irqmask;
20869 }
20870 - atomic_inc(&irq_err_count);
20871 + atomic_inc_unchecked(&irq_err_count);
20872 /*
20873 * Theoretically we do not have to handle this IRQ,
20874 * but in Linux this does not cause problems and is
20875 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
20876 /* (slave's support for AEOI in flat mode is to be investigated) */
20877 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
20878
20879 + pax_open_kernel();
20880 if (auto_eoi)
20881 /*
20882 * In AEOI mode we just have to mask the interrupt
20883 * when acking.
20884 */
20885 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
20886 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
20887 else
20888 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
20889 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
20890 + pax_close_kernel();
20891
20892 udelay(100); /* wait for 8259A to initialize */
20893
20894 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
20895 index a979b5b..1d6db75 100644
20896 --- a/arch/x86/kernel/io_delay.c
20897 +++ b/arch/x86/kernel/io_delay.c
20898 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
20899 * Quirk table for systems that misbehave (lock up, etc.) if port
20900 * 0x80 is used:
20901 */
20902 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
20903 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
20904 {
20905 .callback = dmi_io_delay_0xed_port,
20906 .ident = "Compaq Presario V6000",
20907 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
20908 index 4ddaf66..6292f4e 100644
20909 --- a/arch/x86/kernel/ioport.c
20910 +++ b/arch/x86/kernel/ioport.c
20911 @@ -6,6 +6,7 @@
20912 #include <linux/sched.h>
20913 #include <linux/kernel.h>
20914 #include <linux/capability.h>
20915 +#include <linux/security.h>
20916 #include <linux/errno.h>
20917 #include <linux/types.h>
20918 #include <linux/ioport.h>
20919 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
20920
20921 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
20922 return -EINVAL;
20923 +#ifdef CONFIG_GRKERNSEC_IO
20924 + if (turn_on && grsec_disable_privio) {
20925 + gr_handle_ioperm();
20926 + return -EPERM;
20927 + }
20928 +#endif
20929 if (turn_on && !capable(CAP_SYS_RAWIO))
20930 return -EPERM;
20931
20932 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
20933 * because the ->io_bitmap_max value must match the bitmap
20934 * contents:
20935 */
20936 - tss = &per_cpu(init_tss, get_cpu());
20937 + tss = init_tss + get_cpu();
20938
20939 if (turn_on)
20940 bitmap_clear(t->io_bitmap_ptr, from, num);
20941 @@ -103,6 +110,12 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
20942 return -EINVAL;
20943 /* Trying to gain more privileges? */
20944 if (level > old) {
20945 +#ifdef CONFIG_GRKERNSEC_IO
20946 + if (grsec_disable_privio) {
20947 + gr_handle_iopl();
20948 + return -EPERM;
20949 + }
20950 +#endif
20951 if (!capable(CAP_SYS_RAWIO))
20952 return -EPERM;
20953 }
20954 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
20955 index ac0631d..ff7cb62 100644
20956 --- a/arch/x86/kernel/irq.c
20957 +++ b/arch/x86/kernel/irq.c
20958 @@ -18,7 +18,7 @@
20959 #include <asm/mce.h>
20960 #include <asm/hw_irq.h>
20961
20962 -atomic_t irq_err_count;
20963 +atomic_unchecked_t irq_err_count;
20964
20965 /* Function pointer for generic interrupt vector handling */
20966 void (*x86_platform_ipi_callback)(void) = NULL;
20967 @@ -122,9 +122,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
20968 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
20969 seq_printf(p, " Machine check polls\n");
20970 #endif
20971 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
20972 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
20973 #if defined(CONFIG_X86_IO_APIC)
20974 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
20975 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
20976 #endif
20977 return 0;
20978 }
20979 @@ -164,7 +164,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
20980
20981 u64 arch_irq_stat(void)
20982 {
20983 - u64 sum = atomic_read(&irq_err_count);
20984 + u64 sum = atomic_read_unchecked(&irq_err_count);
20985 return sum;
20986 }
20987
20988 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
20989 index 344faf8..355f60d 100644
20990 --- a/arch/x86/kernel/irq_32.c
20991 +++ b/arch/x86/kernel/irq_32.c
20992 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
20993 __asm__ __volatile__("andl %%esp,%0" :
20994 "=r" (sp) : "0" (THREAD_SIZE - 1));
20995
20996 - return sp < (sizeof(struct thread_info) + STACK_WARN);
20997 + return sp < STACK_WARN;
20998 }
20999
21000 static void print_stack_overflow(void)
21001 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
21002 * per-CPU IRQ handling contexts (thread information and stack)
21003 */
21004 union irq_ctx {
21005 - struct thread_info tinfo;
21006 - u32 stack[THREAD_SIZE/sizeof(u32)];
21007 + unsigned long previous_esp;
21008 + u32 stack[THREAD_SIZE/sizeof(u32)];
21009 } __attribute__((aligned(THREAD_SIZE)));
21010
21011 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
21012 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
21013 static inline int
21014 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21015 {
21016 - union irq_ctx *curctx, *irqctx;
21017 + union irq_ctx *irqctx;
21018 u32 *isp, arg1, arg2;
21019
21020 - curctx = (union irq_ctx *) current_thread_info();
21021 irqctx = __this_cpu_read(hardirq_ctx);
21022
21023 /*
21024 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21025 * handler) we can't do that and just have to keep using the
21026 * current stack (which is the irq stack already after all)
21027 */
21028 - if (unlikely(curctx == irqctx))
21029 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
21030 return 0;
21031
21032 /* build the stack frame on the IRQ stack */
21033 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
21034 - irqctx->tinfo.task = curctx->tinfo.task;
21035 - irqctx->tinfo.previous_esp = current_stack_pointer;
21036 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
21037 + irqctx->previous_esp = current_stack_pointer;
21038
21039 - /* Copy the preempt_count so that the [soft]irq checks work. */
21040 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
21041 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21042 + __set_fs(MAKE_MM_SEG(0));
21043 +#endif
21044
21045 if (unlikely(overflow))
21046 call_on_stack(print_stack_overflow, isp);
21047 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21048 : "0" (irq), "1" (desc), "2" (isp),
21049 "D" (desc->handle_irq)
21050 : "memory", "cc", "ecx");
21051 +
21052 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21053 + __set_fs(current_thread_info()->addr_limit);
21054 +#endif
21055 +
21056 return 1;
21057 }
21058
21059 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
21060 */
21061 void __cpuinit irq_ctx_init(int cpu)
21062 {
21063 - union irq_ctx *irqctx;
21064 -
21065 if (per_cpu(hardirq_ctx, cpu))
21066 return;
21067
21068 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
21069 - THREADINFO_GFP,
21070 - THREAD_SIZE_ORDER));
21071 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
21072 - irqctx->tinfo.cpu = cpu;
21073 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
21074 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
21075 -
21076 - per_cpu(hardirq_ctx, cpu) = irqctx;
21077 -
21078 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
21079 - THREADINFO_GFP,
21080 - THREAD_SIZE_ORDER));
21081 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
21082 - irqctx->tinfo.cpu = cpu;
21083 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
21084 -
21085 - per_cpu(softirq_ctx, cpu) = irqctx;
21086 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
21087 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
21088 +
21089 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
21090 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
21091
21092 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
21093 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
21094 @@ -152,7 +141,6 @@ void __cpuinit irq_ctx_init(int cpu)
21095 asmlinkage void do_softirq(void)
21096 {
21097 unsigned long flags;
21098 - struct thread_info *curctx;
21099 union irq_ctx *irqctx;
21100 u32 *isp;
21101
21102 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
21103 local_irq_save(flags);
21104
21105 if (local_softirq_pending()) {
21106 - curctx = current_thread_info();
21107 irqctx = __this_cpu_read(softirq_ctx);
21108 - irqctx->tinfo.task = curctx->task;
21109 - irqctx->tinfo.previous_esp = current_stack_pointer;
21110 + irqctx->previous_esp = current_stack_pointer;
21111
21112 /* build the stack frame on the softirq stack */
21113 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
21114 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
21115 +
21116 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21117 + __set_fs(MAKE_MM_SEG(0));
21118 +#endif
21119
21120 call_on_stack(__do_softirq, isp);
21121 +
21122 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21123 + __set_fs(current_thread_info()->addr_limit);
21124 +#endif
21125 +
21126 /*
21127 * Shouldn't happen, we returned above if in_interrupt():
21128 */
21129 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
21130 if (unlikely(!desc))
21131 return false;
21132
21133 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21134 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
21135 if (unlikely(overflow))
21136 print_stack_overflow();
21137 desc->handle_irq(irq, desc);
21138 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
21139 index d04d3ec..ea4b374 100644
21140 --- a/arch/x86/kernel/irq_64.c
21141 +++ b/arch/x86/kernel/irq_64.c
21142 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
21143 u64 estack_top, estack_bottom;
21144 u64 curbase = (u64)task_stack_page(current);
21145
21146 - if (user_mode_vm(regs))
21147 + if (user_mode(regs))
21148 return;
21149
21150 if (regs->sp >= curbase + sizeof(struct thread_info) +
21151 diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
21152 index dc1404b..bbc43e7 100644
21153 --- a/arch/x86/kernel/kdebugfs.c
21154 +++ b/arch/x86/kernel/kdebugfs.c
21155 @@ -27,7 +27,7 @@ struct setup_data_node {
21156 u32 len;
21157 };
21158
21159 -static ssize_t setup_data_read(struct file *file, char __user *user_buf,
21160 +static ssize_t __size_overflow(3) setup_data_read(struct file *file, char __user *user_buf,
21161 size_t count, loff_t *ppos)
21162 {
21163 struct setup_data_node *node = file->private_data;
21164 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
21165 index 836f832..a8bda67 100644
21166 --- a/arch/x86/kernel/kgdb.c
21167 +++ b/arch/x86/kernel/kgdb.c
21168 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
21169 #ifdef CONFIG_X86_32
21170 switch (regno) {
21171 case GDB_SS:
21172 - if (!user_mode_vm(regs))
21173 + if (!user_mode(regs))
21174 *(unsigned long *)mem = __KERNEL_DS;
21175 break;
21176 case GDB_SP:
21177 - if (!user_mode_vm(regs))
21178 + if (!user_mode(regs))
21179 *(unsigned long *)mem = kernel_stack_pointer(regs);
21180 break;
21181 case GDB_GS:
21182 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
21183 bp->attr.bp_addr = breakinfo[breakno].addr;
21184 bp->attr.bp_len = breakinfo[breakno].len;
21185 bp->attr.bp_type = breakinfo[breakno].type;
21186 - info->address = breakinfo[breakno].addr;
21187 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
21188 + info->address = ktla_ktva(breakinfo[breakno].addr);
21189 + else
21190 + info->address = breakinfo[breakno].addr;
21191 info->len = breakinfo[breakno].len;
21192 info->type = breakinfo[breakno].type;
21193 val = arch_install_hw_breakpoint(bp);
21194 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
21195 case 'k':
21196 /* clear the trace bit */
21197 linux_regs->flags &= ~X86_EFLAGS_TF;
21198 - atomic_set(&kgdb_cpu_doing_single_step, -1);
21199 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
21200
21201 /* set the trace bit if we're stepping */
21202 if (remcomInBuffer[0] == 's') {
21203 linux_regs->flags |= X86_EFLAGS_TF;
21204 - atomic_set(&kgdb_cpu_doing_single_step,
21205 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
21206 raw_smp_processor_id());
21207 }
21208
21209 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
21210
21211 switch (cmd) {
21212 case DIE_DEBUG:
21213 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
21214 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
21215 if (user_mode(regs))
21216 return single_step_cont(regs, args);
21217 break;
21218 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21219 #endif /* CONFIG_DEBUG_RODATA */
21220
21221 bpt->type = BP_BREAKPOINT;
21222 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
21223 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
21224 BREAK_INSTR_SIZE);
21225 if (err)
21226 return err;
21227 - err = probe_kernel_write((char *)bpt->bpt_addr,
21228 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21229 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
21230 #ifdef CONFIG_DEBUG_RODATA
21231 if (!err)
21232 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
21233 return -EBUSY;
21234 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
21235 BREAK_INSTR_SIZE);
21236 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21237 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21238 if (err)
21239 return err;
21240 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
21241 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
21242 if (mutex_is_locked(&text_mutex))
21243 goto knl_write;
21244 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
21245 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
21246 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
21247 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
21248 goto knl_write;
21249 return err;
21250 knl_write:
21251 #endif /* CONFIG_DEBUG_RODATA */
21252 - return probe_kernel_write((char *)bpt->bpt_addr,
21253 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
21254 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
21255 }
21256
21257 diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
21258 index 211bce4..6e2580a 100644
21259 --- a/arch/x86/kernel/kprobes/core.c
21260 +++ b/arch/x86/kernel/kprobes/core.c
21261 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
21262 s32 raddr;
21263 } __packed *insn;
21264
21265 - insn = (struct __arch_relative_insn *)from;
21266 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
21267 +
21268 + pax_open_kernel();
21269 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
21270 insn->op = op;
21271 + pax_close_kernel();
21272 }
21273
21274 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
21275 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
21276 kprobe_opcode_t opcode;
21277 kprobe_opcode_t *orig_opcodes = opcodes;
21278
21279 - if (search_exception_tables((unsigned long)opcodes))
21280 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
21281 return 0; /* Page fault may occur on this address. */
21282
21283 retry:
21284 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
21285 * for the first byte, we can recover the original instruction
21286 * from it and kp->opcode.
21287 */
21288 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21289 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
21290 buf[0] = kp->opcode;
21291 - return (unsigned long)buf;
21292 + return ktva_ktla((unsigned long)buf);
21293 }
21294
21295 /*
21296 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21297 /* Another subsystem puts a breakpoint, failed to recover */
21298 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
21299 return 0;
21300 + pax_open_kernel();
21301 memcpy(dest, insn.kaddr, insn.length);
21302 + pax_close_kernel();
21303
21304 #ifdef CONFIG_X86_64
21305 if (insn_rip_relative(&insn)) {
21306 @@ -359,7 +364,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
21307 return 0;
21308 }
21309 disp = (u8 *) dest + insn_offset_displacement(&insn);
21310 + pax_open_kernel();
21311 *(s32 *) disp = (s32) newdisp;
21312 + pax_close_kernel();
21313 }
21314 #endif
21315 return insn.length;
21316 @@ -498,7 +505,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21317 * nor set current_kprobe, because it doesn't use single
21318 * stepping.
21319 */
21320 - regs->ip = (unsigned long)p->ainsn.insn;
21321 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21322 preempt_enable_no_resched();
21323 return;
21324 }
21325 @@ -515,9 +522,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
21326 regs->flags &= ~X86_EFLAGS_IF;
21327 /* single step inline if the instruction is an int3 */
21328 if (p->opcode == BREAKPOINT_INSTRUCTION)
21329 - regs->ip = (unsigned long)p->addr;
21330 + regs->ip = ktla_ktva((unsigned long)p->addr);
21331 else
21332 - regs->ip = (unsigned long)p->ainsn.insn;
21333 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
21334 }
21335
21336 /*
21337 @@ -596,7 +603,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
21338 setup_singlestep(p, regs, kcb, 0);
21339 return 1;
21340 }
21341 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
21342 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
21343 /*
21344 * The breakpoint instruction was removed right
21345 * after we hit it. Another cpu has removed
21346 @@ -642,6 +649,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
21347 " movq %rax, 152(%rsp)\n"
21348 RESTORE_REGS_STRING
21349 " popfq\n"
21350 +#ifdef KERNEXEC_PLUGIN
21351 + " btsq $63,(%rsp)\n"
21352 +#endif
21353 #else
21354 " pushf\n"
21355 SAVE_REGS_STRING
21356 @@ -779,7 +789,7 @@ static void __kprobes
21357 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
21358 {
21359 unsigned long *tos = stack_addr(regs);
21360 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
21361 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
21362 unsigned long orig_ip = (unsigned long)p->addr;
21363 kprobe_opcode_t *insn = p->ainsn.insn;
21364
21365 @@ -961,7 +971,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
21366 struct die_args *args = data;
21367 int ret = NOTIFY_DONE;
21368
21369 - if (args->regs && user_mode_vm(args->regs))
21370 + if (args->regs && user_mode(args->regs))
21371 return ret;
21372
21373 switch (val) {
21374 diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
21375 index 76dc6f0..66bdfc3 100644
21376 --- a/arch/x86/kernel/kprobes/opt.c
21377 +++ b/arch/x86/kernel/kprobes/opt.c
21378 @@ -79,6 +79,7 @@ found:
21379 /* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
21380 static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
21381 {
21382 + pax_open_kernel();
21383 #ifdef CONFIG_X86_64
21384 *addr++ = 0x48;
21385 *addr++ = 0xbf;
21386 @@ -86,6 +87,7 @@ static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long v
21387 *addr++ = 0xb8;
21388 #endif
21389 *(unsigned long *)addr = val;
21390 + pax_close_kernel();
21391 }
21392
21393 static void __used __kprobes kprobes_optinsn_template_holder(void)
21394 @@ -338,7 +340,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21395 * Verify if the address gap is in 2GB range, because this uses
21396 * a relative jump.
21397 */
21398 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
21399 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
21400 if (abs(rel) > 0x7fffffff)
21401 return -ERANGE;
21402
21403 @@ -353,16 +355,18 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
21404 op->optinsn.size = ret;
21405
21406 /* Copy arch-dep-instance from template */
21407 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
21408 + pax_open_kernel();
21409 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
21410 + pax_close_kernel();
21411
21412 /* Set probe information */
21413 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
21414
21415 /* Set probe function call */
21416 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
21417 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
21418
21419 /* Set returning jmp instruction at the tail of out-of-line buffer */
21420 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
21421 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
21422 (u8 *)op->kp.addr + op->optinsn.size);
21423
21424 flush_icache_range((unsigned long) buf,
21425 @@ -385,7 +389,7 @@ static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
21426 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
21427
21428 /* Backup instructions which will be replaced by jump address */
21429 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
21430 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
21431 RELATIVE_ADDR_SIZE);
21432
21433 insn_buf[0] = RELATIVEJUMP_OPCODE;
21434 @@ -483,7 +487,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
21435 /* This kprobe is really able to run optimized path. */
21436 op = container_of(p, struct optimized_kprobe, kp);
21437 /* Detour through copied instructions */
21438 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
21439 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
21440 if (!reenter)
21441 reset_current_kprobe();
21442 preempt_enable_no_resched();
21443 diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
21444 index cd6d9a5..16245a4 100644
21445 --- a/arch/x86/kernel/kvm.c
21446 +++ b/arch/x86/kernel/kvm.c
21447 @@ -455,7 +455,7 @@ static int __cpuinit kvm_cpu_notify(struct notifier_block *self,
21448 return NOTIFY_OK;
21449 }
21450
21451 -static struct notifier_block __cpuinitdata kvm_cpu_notifier = {
21452 +static struct notifier_block kvm_cpu_notifier = {
21453 .notifier_call = kvm_cpu_notify,
21454 };
21455 #endif
21456 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
21457 index ebc9873..1b9724b 100644
21458 --- a/arch/x86/kernel/ldt.c
21459 +++ b/arch/x86/kernel/ldt.c
21460 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
21461 if (reload) {
21462 #ifdef CONFIG_SMP
21463 preempt_disable();
21464 - load_LDT(pc);
21465 + load_LDT_nolock(pc);
21466 if (!cpumask_equal(mm_cpumask(current->mm),
21467 cpumask_of(smp_processor_id())))
21468 smp_call_function(flush_ldt, current->mm, 1);
21469 preempt_enable();
21470 #else
21471 - load_LDT(pc);
21472 + load_LDT_nolock(pc);
21473 #endif
21474 }
21475 if (oldsize) {
21476 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
21477 return err;
21478
21479 for (i = 0; i < old->size; i++)
21480 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
21481 + write_ldt_entry(new->ldt, i, old->ldt + i);
21482 return 0;
21483 }
21484
21485 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
21486 retval = copy_ldt(&mm->context, &old_mm->context);
21487 mutex_unlock(&old_mm->context.lock);
21488 }
21489 +
21490 + if (tsk == current) {
21491 + mm->context.vdso = 0;
21492 +
21493 +#ifdef CONFIG_X86_32
21494 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
21495 + mm->context.user_cs_base = 0UL;
21496 + mm->context.user_cs_limit = ~0UL;
21497 +
21498 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
21499 + cpus_clear(mm->context.cpu_user_cs_mask);
21500 +#endif
21501 +
21502 +#endif
21503 +#endif
21504 +
21505 + }
21506 +
21507 return retval;
21508 }
21509
21510 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
21511 }
21512 }
21513
21514 +#ifdef CONFIG_PAX_SEGMEXEC
21515 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
21516 + error = -EINVAL;
21517 + goto out_unlock;
21518 + }
21519 +#endif
21520 +
21521 fill_ldt(&ldt, &ldt_info);
21522 if (oldmode)
21523 ldt.avl = 0;
21524 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
21525 index 5b19e4d..6476a76 100644
21526 --- a/arch/x86/kernel/machine_kexec_32.c
21527 +++ b/arch/x86/kernel/machine_kexec_32.c
21528 @@ -26,7 +26,7 @@
21529 #include <asm/cacheflush.h>
21530 #include <asm/debugreg.h>
21531
21532 -static void set_idt(void *newidt, __u16 limit)
21533 +static void set_idt(struct desc_struct *newidt, __u16 limit)
21534 {
21535 struct desc_ptr curidt;
21536
21537 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
21538 }
21539
21540
21541 -static void set_gdt(void *newgdt, __u16 limit)
21542 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
21543 {
21544 struct desc_ptr curgdt;
21545
21546 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
21547 }
21548
21549 control_page = page_address(image->control_code_page);
21550 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
21551 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
21552
21553 relocate_kernel_ptr = control_page;
21554 page_list[PA_CONTROL_PAGE] = __pa(control_page);
21555 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
21556 index 22db92b..d546bec 100644
21557 --- a/arch/x86/kernel/microcode_core.c
21558 +++ b/arch/x86/kernel/microcode_core.c
21559 @@ -513,7 +513,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
21560 return NOTIFY_OK;
21561 }
21562
21563 -static struct notifier_block __refdata mc_cpu_notifier = {
21564 +static struct notifier_block mc_cpu_notifier = {
21565 .notifier_call = mc_cpu_callback,
21566 };
21567
21568 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
21569 index 5fb2ceb..3ae90bb 100644
21570 --- a/arch/x86/kernel/microcode_intel.c
21571 +++ b/arch/x86/kernel/microcode_intel.c
21572 @@ -293,13 +293,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
21573
21574 static int get_ucode_user(void *to, const void *from, size_t n)
21575 {
21576 - return copy_from_user(to, from, n);
21577 + return copy_from_user(to, (const void __force_user *)from, n);
21578 }
21579
21580 static enum ucode_state
21581 request_microcode_user(int cpu, const void __user *buf, size_t size)
21582 {
21583 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
21584 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
21585 }
21586
21587 static void microcode_fini_cpu(int cpu)
21588 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
21589 index 216a4d7..228255a 100644
21590 --- a/arch/x86/kernel/module.c
21591 +++ b/arch/x86/kernel/module.c
21592 @@ -43,15 +43,60 @@ do { \
21593 } while (0)
21594 #endif
21595
21596 -void *module_alloc(unsigned long size)
21597 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
21598 {
21599 - if (PAGE_ALIGN(size) > MODULES_LEN)
21600 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
21601 return NULL;
21602 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
21603 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
21604 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
21605 -1, __builtin_return_address(0));
21606 }
21607
21608 +void *module_alloc(unsigned long size)
21609 +{
21610 +
21611 +#ifdef CONFIG_PAX_KERNEXEC
21612 + return __module_alloc(size, PAGE_KERNEL);
21613 +#else
21614 + return __module_alloc(size, PAGE_KERNEL_EXEC);
21615 +#endif
21616 +
21617 +}
21618 +
21619 +#ifdef CONFIG_PAX_KERNEXEC
21620 +#ifdef CONFIG_X86_32
21621 +void *module_alloc_exec(unsigned long size)
21622 +{
21623 + struct vm_struct *area;
21624 +
21625 + if (size == 0)
21626 + return NULL;
21627 +
21628 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
21629 + return area ? area->addr : NULL;
21630 +}
21631 +EXPORT_SYMBOL(module_alloc_exec);
21632 +
21633 +void module_free_exec(struct module *mod, void *module_region)
21634 +{
21635 + vunmap(module_region);
21636 +}
21637 +EXPORT_SYMBOL(module_free_exec);
21638 +#else
21639 +void module_free_exec(struct module *mod, void *module_region)
21640 +{
21641 + module_free(mod, module_region);
21642 +}
21643 +EXPORT_SYMBOL(module_free_exec);
21644 +
21645 +void *module_alloc_exec(unsigned long size)
21646 +{
21647 + return __module_alloc(size, PAGE_KERNEL_RX);
21648 +}
21649 +EXPORT_SYMBOL(module_alloc_exec);
21650 +#endif
21651 +#endif
21652 +
21653 #ifdef CONFIG_X86_32
21654 int apply_relocate(Elf32_Shdr *sechdrs,
21655 const char *strtab,
21656 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21657 unsigned int i;
21658 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
21659 Elf32_Sym *sym;
21660 - uint32_t *location;
21661 + uint32_t *plocation, location;
21662
21663 DEBUGP("Applying relocate section %u to %u\n",
21664 relsec, sechdrs[relsec].sh_info);
21665 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
21666 /* This is where to make the change */
21667 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
21668 - + rel[i].r_offset;
21669 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
21670 + location = (uint32_t)plocation;
21671 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
21672 + plocation = ktla_ktva((void *)plocation);
21673 /* This is the symbol it is referring to. Note that all
21674 undefined symbols have been resolved. */
21675 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
21676 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
21677 switch (ELF32_R_TYPE(rel[i].r_info)) {
21678 case R_386_32:
21679 /* We add the value into the location given */
21680 - *location += sym->st_value;
21681 + pax_open_kernel();
21682 + *plocation += sym->st_value;
21683 + pax_close_kernel();
21684 break;
21685 case R_386_PC32:
21686 /* Add the value, subtract its position */
21687 - *location += sym->st_value - (uint32_t)location;
21688 + pax_open_kernel();
21689 + *plocation += sym->st_value - location;
21690 + pax_close_kernel();
21691 break;
21692 default:
21693 pr_err("%s: Unknown relocation: %u\n",
21694 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
21695 case R_X86_64_NONE:
21696 break;
21697 case R_X86_64_64:
21698 + pax_open_kernel();
21699 *(u64 *)loc = val;
21700 + pax_close_kernel();
21701 break;
21702 case R_X86_64_32:
21703 + pax_open_kernel();
21704 *(u32 *)loc = val;
21705 + pax_close_kernel();
21706 if (val != *(u32 *)loc)
21707 goto overflow;
21708 break;
21709 case R_X86_64_32S:
21710 + pax_open_kernel();
21711 *(s32 *)loc = val;
21712 + pax_close_kernel();
21713 if ((s64)val != *(s32 *)loc)
21714 goto overflow;
21715 break;
21716 case R_X86_64_PC32:
21717 val -= (u64)loc;
21718 + pax_open_kernel();
21719 *(u32 *)loc = val;
21720 + pax_close_kernel();
21721 +
21722 #if 0
21723 if ((s64)val != *(s32 *)loc)
21724 goto overflow;
21725 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
21726 index ce13049..e2e9c3c 100644
21727 --- a/arch/x86/kernel/msr.c
21728 +++ b/arch/x86/kernel/msr.c
21729 @@ -233,7 +233,7 @@ static int __cpuinit msr_class_cpu_callback(struct notifier_block *nfb,
21730 return notifier_from_errno(err);
21731 }
21732
21733 -static struct notifier_block __refdata msr_class_cpu_notifier = {
21734 +static struct notifier_block msr_class_cpu_notifier = {
21735 .notifier_call = msr_class_cpu_callback,
21736 };
21737
21738 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
21739 index 6030805..2d33f21 100644
21740 --- a/arch/x86/kernel/nmi.c
21741 +++ b/arch/x86/kernel/nmi.c
21742 @@ -105,7 +105,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
21743 return handled;
21744 }
21745
21746 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
21747 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
21748 {
21749 struct nmi_desc *desc = nmi_to_desc(type);
21750 unsigned long flags;
21751 @@ -129,9 +129,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
21752 * event confuses some handlers (kdump uses this flag)
21753 */
21754 if (action->flags & NMI_FLAG_FIRST)
21755 - list_add_rcu(&action->list, &desc->head);
21756 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
21757 else
21758 - list_add_tail_rcu(&action->list, &desc->head);
21759 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
21760
21761 spin_unlock_irqrestore(&desc->lock, flags);
21762 return 0;
21763 @@ -154,7 +154,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
21764 if (!strcmp(n->name, name)) {
21765 WARN(in_nmi(),
21766 "Trying to free NMI (%s) from NMI context!\n", n->name);
21767 - list_del_rcu(&n->list);
21768 + pax_list_del_rcu((struct list_head *)&n->list);
21769 break;
21770 }
21771 }
21772 @@ -479,6 +479,17 @@ static inline void nmi_nesting_postprocess(void)
21773 dotraplinkage notrace __kprobes void
21774 do_nmi(struct pt_regs *regs, long error_code)
21775 {
21776 +
21777 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
21778 + if (!user_mode(regs)) {
21779 + unsigned long cs = regs->cs & 0xFFFF;
21780 + unsigned long ip = ktva_ktla(regs->ip);
21781 +
21782 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
21783 + regs->ip = ip;
21784 + }
21785 +#endif
21786 +
21787 nmi_nesting_preprocess(regs);
21788
21789 nmi_enter();
21790 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
21791 index 6d9582e..f746287 100644
21792 --- a/arch/x86/kernel/nmi_selftest.c
21793 +++ b/arch/x86/kernel/nmi_selftest.c
21794 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
21795 {
21796 /* trap all the unknown NMIs we may generate */
21797 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
21798 - __initdata);
21799 + __initconst);
21800 }
21801
21802 static void __init cleanup_nmi_testsuite(void)
21803 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
21804 unsigned long timeout;
21805
21806 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
21807 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
21808 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
21809 nmi_fail = FAILURE;
21810 return;
21811 }
21812 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
21813 index 676b8c7..870ba04 100644
21814 --- a/arch/x86/kernel/paravirt-spinlocks.c
21815 +++ b/arch/x86/kernel/paravirt-spinlocks.c
21816 @@ -13,7 +13,7 @@ default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
21817 arch_spin_lock(lock);
21818 }
21819
21820 -struct pv_lock_ops pv_lock_ops = {
21821 +struct pv_lock_ops pv_lock_ops __read_only = {
21822 #ifdef CONFIG_SMP
21823 .spin_is_locked = __ticket_spin_is_locked,
21824 .spin_is_contended = __ticket_spin_is_contended,
21825 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
21826 index cd6de64..27c6af0 100644
21827 --- a/arch/x86/kernel/paravirt.c
21828 +++ b/arch/x86/kernel/paravirt.c
21829 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
21830 {
21831 return x;
21832 }
21833 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
21834 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
21835 +#endif
21836
21837 void __init default_banner(void)
21838 {
21839 @@ -147,15 +150,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
21840 if (opfunc == NULL)
21841 /* If there's no function, patch it with a ud2a (BUG) */
21842 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
21843 - else if (opfunc == _paravirt_nop)
21844 + else if (opfunc == (void *)_paravirt_nop)
21845 /* If the operation is a nop, then nop the callsite */
21846 ret = paravirt_patch_nop();
21847
21848 /* identity functions just return their single argument */
21849 - else if (opfunc == _paravirt_ident_32)
21850 + else if (opfunc == (void *)_paravirt_ident_32)
21851 ret = paravirt_patch_ident_32(insnbuf, len);
21852 - else if (opfunc == _paravirt_ident_64)
21853 + else if (opfunc == (void *)_paravirt_ident_64)
21854 ret = paravirt_patch_ident_64(insnbuf, len);
21855 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
21856 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
21857 + ret = paravirt_patch_ident_64(insnbuf, len);
21858 +#endif
21859
21860 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
21861 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
21862 @@ -180,7 +187,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
21863 if (insn_len > len || start == NULL)
21864 insn_len = len;
21865 else
21866 - memcpy(insnbuf, start, insn_len);
21867 + memcpy(insnbuf, ktla_ktva(start), insn_len);
21868
21869 return insn_len;
21870 }
21871 @@ -304,7 +311,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
21872 return this_cpu_read(paravirt_lazy_mode);
21873 }
21874
21875 -struct pv_info pv_info = {
21876 +struct pv_info pv_info __read_only = {
21877 .name = "bare hardware",
21878 .paravirt_enabled = 0,
21879 .kernel_rpl = 0,
21880 @@ -315,16 +322,16 @@ struct pv_info pv_info = {
21881 #endif
21882 };
21883
21884 -struct pv_init_ops pv_init_ops = {
21885 +struct pv_init_ops pv_init_ops __read_only = {
21886 .patch = native_patch,
21887 };
21888
21889 -struct pv_time_ops pv_time_ops = {
21890 +struct pv_time_ops pv_time_ops __read_only = {
21891 .sched_clock = native_sched_clock,
21892 .steal_clock = native_steal_clock,
21893 };
21894
21895 -struct pv_irq_ops pv_irq_ops = {
21896 +struct pv_irq_ops pv_irq_ops __read_only = {
21897 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
21898 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
21899 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
21900 @@ -336,7 +343,7 @@ struct pv_irq_ops pv_irq_ops = {
21901 #endif
21902 };
21903
21904 -struct pv_cpu_ops pv_cpu_ops = {
21905 +struct pv_cpu_ops pv_cpu_ops __read_only = {
21906 .cpuid = native_cpuid,
21907 .get_debugreg = native_get_debugreg,
21908 .set_debugreg = native_set_debugreg,
21909 @@ -394,21 +401,26 @@ struct pv_cpu_ops pv_cpu_ops = {
21910 .end_context_switch = paravirt_nop,
21911 };
21912
21913 -struct pv_apic_ops pv_apic_ops = {
21914 +struct pv_apic_ops pv_apic_ops __read_only= {
21915 #ifdef CONFIG_X86_LOCAL_APIC
21916 .startup_ipi_hook = paravirt_nop,
21917 #endif
21918 };
21919
21920 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
21921 +#ifdef CONFIG_X86_32
21922 +#ifdef CONFIG_X86_PAE
21923 +/* 64-bit pagetable entries */
21924 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
21925 +#else
21926 /* 32-bit pagetable entries */
21927 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
21928 +#endif
21929 #else
21930 /* 64-bit pagetable entries */
21931 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
21932 #endif
21933
21934 -struct pv_mmu_ops pv_mmu_ops = {
21935 +struct pv_mmu_ops pv_mmu_ops __read_only = {
21936
21937 .read_cr2 = native_read_cr2,
21938 .write_cr2 = native_write_cr2,
21939 @@ -458,6 +470,7 @@ struct pv_mmu_ops pv_mmu_ops = {
21940 .make_pud = PTE_IDENT,
21941
21942 .set_pgd = native_set_pgd,
21943 + .set_pgd_batched = native_set_pgd_batched,
21944 #endif
21945 #endif /* PAGETABLE_LEVELS >= 3 */
21946
21947 @@ -478,6 +491,12 @@ struct pv_mmu_ops pv_mmu_ops = {
21948 },
21949
21950 .set_fixmap = native_set_fixmap,
21951 +
21952 +#ifdef CONFIG_PAX_KERNEXEC
21953 + .pax_open_kernel = native_pax_open_kernel,
21954 + .pax_close_kernel = native_pax_close_kernel,
21955 +#endif
21956 +
21957 };
21958
21959 EXPORT_SYMBOL_GPL(pv_time_ops);
21960 diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
21961 index 299d493..2ccb0ee 100644
21962 --- a/arch/x86/kernel/pci-calgary_64.c
21963 +++ b/arch/x86/kernel/pci-calgary_64.c
21964 @@ -1339,7 +1339,7 @@ static void __init get_tce_space_from_tar(void)
21965 tce_space = be64_to_cpu(readq(target));
21966 tce_space = tce_space & TAR_SW_BITS;
21967
21968 - tce_space = tce_space & (~specified_table_size);
21969 + tce_space = tce_space & (~(unsigned long)specified_table_size);
21970 info->tce_space = (u64 *)__va(tce_space);
21971 }
21972 }
21973 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
21974 index 35ccf75..7a15747 100644
21975 --- a/arch/x86/kernel/pci-iommu_table.c
21976 +++ b/arch/x86/kernel/pci-iommu_table.c
21977 @@ -2,7 +2,7 @@
21978 #include <asm/iommu_table.h>
21979 #include <linux/string.h>
21980 #include <linux/kallsyms.h>
21981 -
21982 +#include <linux/sched.h>
21983
21984 #define DEBUG 1
21985
21986 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
21987 index 6c483ba..d10ce2f 100644
21988 --- a/arch/x86/kernel/pci-swiotlb.c
21989 +++ b/arch/x86/kernel/pci-swiotlb.c
21990 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
21991 void *vaddr, dma_addr_t dma_addr,
21992 struct dma_attrs *attrs)
21993 {
21994 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
21995 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
21996 }
21997
21998 static struct dma_map_ops swiotlb_dma_ops = {
21999 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
22000 index 81a5f5e..20f8b58 100644
22001 --- a/arch/x86/kernel/process.c
22002 +++ b/arch/x86/kernel/process.c
22003 @@ -36,7 +36,8 @@
22004 * section. Since TSS's are completely CPU-local, we want them
22005 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
22006 */
22007 -DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
22008 +struct tss_struct init_tss[NR_CPUS] ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
22009 +EXPORT_SYMBOL(init_tss);
22010
22011 #ifdef CONFIG_X86_64
22012 static DEFINE_PER_CPU(unsigned char, is_idle);
22013 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
22014 task_xstate_cachep =
22015 kmem_cache_create("task_xstate", xstate_size,
22016 __alignof__(union thread_xstate),
22017 - SLAB_PANIC | SLAB_NOTRACK, NULL);
22018 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
22019 }
22020
22021 /*
22022 @@ -105,7 +106,7 @@ void exit_thread(void)
22023 unsigned long *bp = t->io_bitmap_ptr;
22024
22025 if (bp) {
22026 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
22027 + struct tss_struct *tss = init_tss + get_cpu();
22028
22029 t->io_bitmap_ptr = NULL;
22030 clear_thread_flag(TIF_IO_BITMAP);
22031 @@ -125,6 +126,9 @@ void flush_thread(void)
22032 {
22033 struct task_struct *tsk = current;
22034
22035 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
22036 + loadsegment(gs, 0);
22037 +#endif
22038 flush_ptrace_hw_breakpoint(tsk);
22039 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
22040 drop_init_fpu(tsk);
22041 @@ -271,7 +275,7 @@ static void __exit_idle(void)
22042 void exit_idle(void)
22043 {
22044 /* idle loop has pid 0 */
22045 - if (current->pid)
22046 + if (task_pid_nr(current))
22047 return;
22048 __exit_idle();
22049 }
22050 @@ -327,7 +331,7 @@ bool xen_set_default_idle(void)
22051 return ret;
22052 }
22053 #endif
22054 -void stop_this_cpu(void *dummy)
22055 +__noreturn void stop_this_cpu(void *dummy)
22056 {
22057 local_irq_disable();
22058 /*
22059 @@ -456,16 +460,37 @@ static int __init idle_setup(char *str)
22060 }
22061 early_param("idle", idle_setup);
22062
22063 -unsigned long arch_align_stack(unsigned long sp)
22064 +#ifdef CONFIG_PAX_RANDKSTACK
22065 +void pax_randomize_kstack(struct pt_regs *regs)
22066 {
22067 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
22068 - sp -= get_random_int() % 8192;
22069 - return sp & ~0xf;
22070 -}
22071 + struct thread_struct *thread = &current->thread;
22072 + unsigned long time;
22073
22074 -unsigned long arch_randomize_brk(struct mm_struct *mm)
22075 -{
22076 - unsigned long range_end = mm->brk + 0x02000000;
22077 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
22078 -}
22079 + if (!randomize_va_space)
22080 + return;
22081 +
22082 + if (v8086_mode(regs))
22083 + return;
22084
22085 + rdtscl(time);
22086 +
22087 + /* P4 seems to return a 0 LSB, ignore it */
22088 +#ifdef CONFIG_MPENTIUM4
22089 + time &= 0x3EUL;
22090 + time <<= 2;
22091 +#elif defined(CONFIG_X86_64)
22092 + time &= 0xFUL;
22093 + time <<= 4;
22094 +#else
22095 + time &= 0x1FUL;
22096 + time <<= 3;
22097 +#endif
22098 +
22099 + thread->sp0 ^= time;
22100 + load_sp0(init_tss + smp_processor_id(), thread);
22101 +
22102 +#ifdef CONFIG_X86_64
22103 + this_cpu_write(kernel_stack, thread->sp0);
22104 +#endif
22105 +}
22106 +#endif
22107 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
22108 index 7305f7d..22f73d6 100644
22109 --- a/arch/x86/kernel/process_32.c
22110 +++ b/arch/x86/kernel/process_32.c
22111 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
22112 unsigned long thread_saved_pc(struct task_struct *tsk)
22113 {
22114 return ((unsigned long *)tsk->thread.sp)[3];
22115 +//XXX return tsk->thread.eip;
22116 }
22117
22118 void __show_regs(struct pt_regs *regs, int all)
22119 @@ -74,19 +75,18 @@ void __show_regs(struct pt_regs *regs, int all)
22120 unsigned long sp;
22121 unsigned short ss, gs;
22122
22123 - if (user_mode_vm(regs)) {
22124 + if (user_mode(regs)) {
22125 sp = regs->sp;
22126 ss = regs->ss & 0xffff;
22127 - gs = get_user_gs(regs);
22128 } else {
22129 sp = kernel_stack_pointer(regs);
22130 savesegment(ss, ss);
22131 - savesegment(gs, gs);
22132 }
22133 + gs = get_user_gs(regs);
22134
22135 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
22136 (u16)regs->cs, regs->ip, regs->flags,
22137 - smp_processor_id());
22138 + raw_smp_processor_id());
22139 print_symbol("EIP is at %s\n", regs->ip);
22140
22141 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
22142 @@ -128,20 +128,21 @@ void release_thread(struct task_struct *dead_task)
22143 int copy_thread(unsigned long clone_flags, unsigned long sp,
22144 unsigned long arg, struct task_struct *p)
22145 {
22146 - struct pt_regs *childregs = task_pt_regs(p);
22147 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
22148 struct task_struct *tsk;
22149 int err;
22150
22151 p->thread.sp = (unsigned long) childregs;
22152 p->thread.sp0 = (unsigned long) (childregs+1);
22153 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22154
22155 if (unlikely(p->flags & PF_KTHREAD)) {
22156 /* kernel thread */
22157 memset(childregs, 0, sizeof(struct pt_regs));
22158 p->thread.ip = (unsigned long) ret_from_kernel_thread;
22159 - task_user_gs(p) = __KERNEL_STACK_CANARY;
22160 - childregs->ds = __USER_DS;
22161 - childregs->es = __USER_DS;
22162 + savesegment(gs, childregs->gs);
22163 + childregs->ds = __KERNEL_DS;
22164 + childregs->es = __KERNEL_DS;
22165 childregs->fs = __KERNEL_PERCPU;
22166 childregs->bx = sp; /* function */
22167 childregs->bp = arg;
22168 @@ -248,7 +249,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22169 struct thread_struct *prev = &prev_p->thread,
22170 *next = &next_p->thread;
22171 int cpu = smp_processor_id();
22172 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22173 + struct tss_struct *tss = init_tss + cpu;
22174 fpu_switch_t fpu;
22175
22176 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
22177 @@ -272,6 +273,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22178 */
22179 lazy_save_gs(prev->gs);
22180
22181 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22182 + __set_fs(task_thread_info(next_p)->addr_limit);
22183 +#endif
22184 +
22185 /*
22186 * Load the per-thread Thread-Local Storage descriptor.
22187 */
22188 @@ -302,6 +307,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22189 */
22190 arch_end_context_switch(next_p);
22191
22192 + this_cpu_write(current_task, next_p);
22193 + this_cpu_write(current_tinfo, &next_p->tinfo);
22194 +
22195 /*
22196 * Restore %gs if needed (which is common)
22197 */
22198 @@ -310,8 +318,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22199
22200 switch_fpu_finish(next_p, fpu);
22201
22202 - this_cpu_write(current_task, next_p);
22203 -
22204 return prev_p;
22205 }
22206
22207 @@ -341,4 +347,3 @@ unsigned long get_wchan(struct task_struct *p)
22208 } while (count++ < 16);
22209 return 0;
22210 }
22211 -
22212 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
22213 index 355ae06..4530766 100644
22214 --- a/arch/x86/kernel/process_64.c
22215 +++ b/arch/x86/kernel/process_64.c
22216 @@ -151,10 +151,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
22217 struct pt_regs *childregs;
22218 struct task_struct *me = current;
22219
22220 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
22221 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
22222 childregs = task_pt_regs(p);
22223 p->thread.sp = (unsigned long) childregs;
22224 p->thread.usersp = me->thread.usersp;
22225 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
22226 set_tsk_thread_flag(p, TIF_FORK);
22227 p->fpu_counter = 0;
22228 p->thread.io_bitmap_ptr = NULL;
22229 @@ -273,7 +274,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22230 struct thread_struct *prev = &prev_p->thread;
22231 struct thread_struct *next = &next_p->thread;
22232 int cpu = smp_processor_id();
22233 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
22234 + struct tss_struct *tss = init_tss + cpu;
22235 unsigned fsindex, gsindex;
22236 fpu_switch_t fpu;
22237
22238 @@ -355,10 +356,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
22239 prev->usersp = this_cpu_read(old_rsp);
22240 this_cpu_write(old_rsp, next->usersp);
22241 this_cpu_write(current_task, next_p);
22242 + this_cpu_write(current_tinfo, &next_p->tinfo);
22243
22244 - this_cpu_write(kernel_stack,
22245 - (unsigned long)task_stack_page(next_p) +
22246 - THREAD_SIZE - KERNEL_STACK_OFFSET);
22247 + this_cpu_write(kernel_stack, next->sp0);
22248
22249 /*
22250 * Now maybe reload the debug registers and handle I/O bitmaps
22251 @@ -427,12 +427,11 @@ unsigned long get_wchan(struct task_struct *p)
22252 if (!p || p == current || p->state == TASK_RUNNING)
22253 return 0;
22254 stack = (unsigned long)task_stack_page(p);
22255 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
22256 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
22257 return 0;
22258 fp = *(u64 *)(p->thread.sp);
22259 do {
22260 - if (fp < (unsigned long)stack ||
22261 - fp >= (unsigned long)stack+THREAD_SIZE)
22262 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
22263 return 0;
22264 ip = *(u64 *)(fp+8);
22265 if (!in_sched_functions(ip))
22266 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
22267 index 29a8120..a50b5ee 100644
22268 --- a/arch/x86/kernel/ptrace.c
22269 +++ b/arch/x86/kernel/ptrace.c
22270 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
22271 {
22272 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
22273 unsigned long sp = (unsigned long)&regs->sp;
22274 - struct thread_info *tinfo;
22275
22276 - if (context == (sp & ~(THREAD_SIZE - 1)))
22277 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
22278 return sp;
22279
22280 - tinfo = (struct thread_info *)context;
22281 - if (tinfo->previous_esp)
22282 - return tinfo->previous_esp;
22283 + sp = *(unsigned long *)context;
22284 + if (sp)
22285 + return sp;
22286
22287 return (unsigned long)regs;
22288 }
22289 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
22290 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
22291 {
22292 int i;
22293 - int dr7 = 0;
22294 + unsigned long dr7 = 0;
22295 struct arch_hw_breakpoint *info;
22296
22297 for (i = 0; i < HBP_NUM; i++) {
22298 @@ -856,7 +855,7 @@ long arch_ptrace(struct task_struct *child, long request,
22299 unsigned long addr, unsigned long data)
22300 {
22301 int ret;
22302 - unsigned long __user *datap = (unsigned long __user *)data;
22303 + unsigned long __user *datap = (__force unsigned long __user *)data;
22304
22305 switch (request) {
22306 /* read the word at location addr in the USER area. */
22307 @@ -941,14 +940,14 @@ long arch_ptrace(struct task_struct *child, long request,
22308 if ((int) addr < 0)
22309 return -EIO;
22310 ret = do_get_thread_area(child, addr,
22311 - (struct user_desc __user *)data);
22312 + (__force struct user_desc __user *) data);
22313 break;
22314
22315 case PTRACE_SET_THREAD_AREA:
22316 if ((int) addr < 0)
22317 return -EIO;
22318 ret = do_set_thread_area(child, addr,
22319 - (struct user_desc __user *)data, 0);
22320 + (__force struct user_desc __user *) data, 0);
22321 break;
22322 #endif
22323
22324 @@ -1326,7 +1325,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
22325
22326 #ifdef CONFIG_X86_64
22327
22328 -static struct user_regset x86_64_regsets[] __read_mostly = {
22329 +static user_regset_no_const x86_64_regsets[] __read_only = {
22330 [REGSET_GENERAL] = {
22331 .core_note_type = NT_PRSTATUS,
22332 .n = sizeof(struct user_regs_struct) / sizeof(long),
22333 @@ -1367,7 +1366,7 @@ static const struct user_regset_view user_x86_64_view = {
22334 #endif /* CONFIG_X86_64 */
22335
22336 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
22337 -static struct user_regset x86_32_regsets[] __read_mostly = {
22338 +static user_regset_no_const x86_32_regsets[] __read_only = {
22339 [REGSET_GENERAL] = {
22340 .core_note_type = NT_PRSTATUS,
22341 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
22342 @@ -1420,7 +1419,7 @@ static const struct user_regset_view user_x86_32_view = {
22343 */
22344 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
22345
22346 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22347 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
22348 {
22349 #ifdef CONFIG_X86_64
22350 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
22351 @@ -1455,7 +1454,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
22352 memset(info, 0, sizeof(*info));
22353 info->si_signo = SIGTRAP;
22354 info->si_code = si_code;
22355 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
22356 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
22357 }
22358
22359 void user_single_step_siginfo(struct task_struct *tsk,
22360 @@ -1484,6 +1483,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
22361 # define IS_IA32 0
22362 #endif
22363
22364 +#ifdef CONFIG_GRKERNSEC_SETXID
22365 +extern void gr_delayed_cred_worker(void);
22366 +#endif
22367 +
22368 /*
22369 * We must return the syscall number to actually look up in the table.
22370 * This can be -1L to skip running any syscall at all.
22371 @@ -1494,6 +1497,11 @@ long syscall_trace_enter(struct pt_regs *regs)
22372
22373 user_exit();
22374
22375 +#ifdef CONFIG_GRKERNSEC_SETXID
22376 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22377 + gr_delayed_cred_worker();
22378 +#endif
22379 +
22380 /*
22381 * If we stepped into a sysenter/syscall insn, it trapped in
22382 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
22383 @@ -1549,6 +1557,11 @@ void syscall_trace_leave(struct pt_regs *regs)
22384 */
22385 user_exit();
22386
22387 +#ifdef CONFIG_GRKERNSEC_SETXID
22388 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
22389 + gr_delayed_cred_worker();
22390 +#endif
22391 +
22392 audit_syscall_exit(regs);
22393
22394 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
22395 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
22396 index 2cb9470..ff1fd80 100644
22397 --- a/arch/x86/kernel/pvclock.c
22398 +++ b/arch/x86/kernel/pvclock.c
22399 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
22400 return pv_tsc_khz;
22401 }
22402
22403 -static atomic64_t last_value = ATOMIC64_INIT(0);
22404 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
22405
22406 void pvclock_resume(void)
22407 {
22408 - atomic64_set(&last_value, 0);
22409 + atomic64_set_unchecked(&last_value, 0);
22410 }
22411
22412 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
22413 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
22414 * updating at the same time, and one of them could be slightly behind,
22415 * making the assumption that last_value always go forward fail to hold.
22416 */
22417 - last = atomic64_read(&last_value);
22418 + last = atomic64_read_unchecked(&last_value);
22419 do {
22420 if (ret < last)
22421 return last;
22422 - last = atomic64_cmpxchg(&last_value, last, ret);
22423 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
22424 } while (unlikely(last != ret));
22425
22426 return ret;
22427 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
22428 index 76fa1e9..abf09ea 100644
22429 --- a/arch/x86/kernel/reboot.c
22430 +++ b/arch/x86/kernel/reboot.c
22431 @@ -36,7 +36,7 @@ void (*pm_power_off)(void);
22432 EXPORT_SYMBOL(pm_power_off);
22433
22434 static const struct desc_ptr no_idt = {};
22435 -static int reboot_mode;
22436 +static unsigned short reboot_mode;
22437 enum reboot_type reboot_type = BOOT_ACPI;
22438 int reboot_force;
22439
22440 @@ -157,6 +157,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
22441
22442 void __noreturn machine_real_restart(unsigned int type)
22443 {
22444 +
22445 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
22446 + struct desc_struct *gdt;
22447 +#endif
22448 +
22449 local_irq_disable();
22450
22451 /*
22452 @@ -184,7 +189,29 @@ void __noreturn machine_real_restart(unsigned int type)
22453
22454 /* Jump to the identity-mapped low memory code */
22455 #ifdef CONFIG_X86_32
22456 - asm volatile("jmpl *%0" : :
22457 +
22458 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22459 + gdt = get_cpu_gdt_table(smp_processor_id());
22460 + pax_open_kernel();
22461 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22462 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
22463 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
22464 + loadsegment(ds, __KERNEL_DS);
22465 + loadsegment(es, __KERNEL_DS);
22466 + loadsegment(ss, __KERNEL_DS);
22467 +#endif
22468 +#ifdef CONFIG_PAX_KERNEXEC
22469 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
22470 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
22471 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
22472 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
22473 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
22474 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
22475 +#endif
22476 + pax_close_kernel();
22477 +#endif
22478 +
22479 + asm volatile("ljmpl *%0" : :
22480 "rm" (real_mode_header->machine_real_restart_asm),
22481 "a" (type));
22482 #else
22483 @@ -531,7 +558,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
22484 * try to force a triple fault and then cycle between hitting the keyboard
22485 * controller and doing that
22486 */
22487 -static void native_machine_emergency_restart(void)
22488 +static void __noreturn native_machine_emergency_restart(void)
22489 {
22490 int i;
22491 int attempt = 0;
22492 @@ -654,13 +681,13 @@ void native_machine_shutdown(void)
22493 #endif
22494 }
22495
22496 -static void __machine_emergency_restart(int emergency)
22497 +static void __noreturn __machine_emergency_restart(int emergency)
22498 {
22499 reboot_emergency = emergency;
22500 machine_ops.emergency_restart();
22501 }
22502
22503 -static void native_machine_restart(char *__unused)
22504 +static void __noreturn native_machine_restart(char *__unused)
22505 {
22506 pr_notice("machine restart\n");
22507
22508 @@ -669,7 +696,7 @@ static void native_machine_restart(char *__unused)
22509 __machine_emergency_restart(0);
22510 }
22511
22512 -static void native_machine_halt(void)
22513 +static void __noreturn native_machine_halt(void)
22514 {
22515 /* Stop other cpus and apics */
22516 machine_shutdown();
22517 @@ -679,7 +706,7 @@ static void native_machine_halt(void)
22518 stop_this_cpu(NULL);
22519 }
22520
22521 -static void native_machine_power_off(void)
22522 +static void __noreturn native_machine_power_off(void)
22523 {
22524 if (pm_power_off) {
22525 if (!reboot_force)
22526 @@ -688,9 +715,10 @@ static void native_machine_power_off(void)
22527 }
22528 /* A fallback in case there is no PM info available */
22529 tboot_shutdown(TB_SHUTDOWN_HALT);
22530 + unreachable();
22531 }
22532
22533 -struct machine_ops machine_ops = {
22534 +struct machine_ops machine_ops __read_only = {
22535 .power_off = native_machine_power_off,
22536 .shutdown = native_machine_shutdown,
22537 .emergency_restart = native_machine_emergency_restart,
22538 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
22539 index f2bb9c9..bed145d7 100644
22540 --- a/arch/x86/kernel/relocate_kernel_64.S
22541 +++ b/arch/x86/kernel/relocate_kernel_64.S
22542 @@ -11,6 +11,7 @@
22543 #include <asm/kexec.h>
22544 #include <asm/processor-flags.h>
22545 #include <asm/pgtable_types.h>
22546 +#include <asm/alternative-asm.h>
22547
22548 /*
22549 * Must be relocatable PIC code callable as a C function
22550 @@ -167,6 +168,7 @@ identity_mapped:
22551 xorq %r14, %r14
22552 xorq %r15, %r15
22553
22554 + pax_force_retaddr 0, 1
22555 ret
22556
22557 1:
22558 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
22559 index 56f7fcf..fa229f4 100644
22560 --- a/arch/x86/kernel/setup.c
22561 +++ b/arch/x86/kernel/setup.c
22562 @@ -110,6 +110,7 @@
22563 #include <asm/mce.h>
22564 #include <asm/alternative.h>
22565 #include <asm/prom.h>
22566 +#include <asm/boot.h>
22567
22568 /*
22569 * max_low_pfn_mapped: highest direct mapped pfn under 4GB
22570 @@ -444,7 +445,7 @@ static void __init parse_setup_data(void)
22571
22572 switch (data->type) {
22573 case SETUP_E820_EXT:
22574 - parse_e820_ext(data);
22575 + parse_e820_ext((struct setup_data __force_kernel *)data);
22576 break;
22577 case SETUP_DTB:
22578 add_dtb(pa_data);
22579 @@ -771,7 +772,7 @@ static void __init trim_bios_range(void)
22580 * area (640->1Mb) as ram even though it is not.
22581 * take them out.
22582 */
22583 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
22584 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
22585
22586 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
22587 }
22588 @@ -779,7 +780,7 @@ static void __init trim_bios_range(void)
22589 /* called before trim_bios_range() to spare extra sanitize */
22590 static void __init e820_add_kernel_range(void)
22591 {
22592 - u64 start = __pa_symbol(_text);
22593 + u64 start = __pa_symbol(ktla_ktva(_text));
22594 u64 size = __pa_symbol(_end) - start;
22595
22596 /*
22597 @@ -841,8 +842,12 @@ static void __init trim_low_memory_range(void)
22598
22599 void __init setup_arch(char **cmdline_p)
22600 {
22601 +#ifdef CONFIG_X86_32
22602 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(__bss_stop) - LOAD_PHYSICAL_ADDR);
22603 +#else
22604 memblock_reserve(__pa_symbol(_text),
22605 (unsigned long)__bss_stop - (unsigned long)_text);
22606 +#endif
22607
22608 early_reserve_initrd();
22609
22610 @@ -934,14 +939,14 @@ void __init setup_arch(char **cmdline_p)
22611
22612 if (!boot_params.hdr.root_flags)
22613 root_mountflags &= ~MS_RDONLY;
22614 - init_mm.start_code = (unsigned long) _text;
22615 - init_mm.end_code = (unsigned long) _etext;
22616 + init_mm.start_code = ktla_ktva((unsigned long) _text);
22617 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
22618 init_mm.end_data = (unsigned long) _edata;
22619 init_mm.brk = _brk_end;
22620
22621 - code_resource.start = __pa_symbol(_text);
22622 - code_resource.end = __pa_symbol(_etext)-1;
22623 - data_resource.start = __pa_symbol(_etext);
22624 + code_resource.start = __pa_symbol(ktla_ktva(_text));
22625 + code_resource.end = __pa_symbol(ktla_ktva(_etext))-1;
22626 + data_resource.start = __pa_symbol(_sdata);
22627 data_resource.end = __pa_symbol(_edata)-1;
22628 bss_resource.start = __pa_symbol(__bss_start);
22629 bss_resource.end = __pa_symbol(__bss_stop)-1;
22630 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
22631 index 5cdff03..80fa283 100644
22632 --- a/arch/x86/kernel/setup_percpu.c
22633 +++ b/arch/x86/kernel/setup_percpu.c
22634 @@ -21,19 +21,17 @@
22635 #include <asm/cpu.h>
22636 #include <asm/stackprotector.h>
22637
22638 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
22639 +#ifdef CONFIG_SMP
22640 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
22641 EXPORT_PER_CPU_SYMBOL(cpu_number);
22642 +#endif
22643
22644 -#ifdef CONFIG_X86_64
22645 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
22646 -#else
22647 -#define BOOT_PERCPU_OFFSET 0
22648 -#endif
22649
22650 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
22651 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
22652
22653 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
22654 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
22655 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
22656 };
22657 EXPORT_SYMBOL(__per_cpu_offset);
22658 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
22659 {
22660 #ifdef CONFIG_NEED_MULTIPLE_NODES
22661 pg_data_t *last = NULL;
22662 - unsigned int cpu;
22663 + int cpu;
22664
22665 for_each_possible_cpu(cpu) {
22666 int node = early_cpu_to_node(cpu);
22667 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
22668 {
22669 #ifdef CONFIG_X86_32
22670 struct desc_struct gdt;
22671 + unsigned long base = per_cpu_offset(cpu);
22672
22673 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
22674 - 0x2 | DESCTYPE_S, 0x8);
22675 - gdt.s = 1;
22676 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
22677 + 0x83 | DESCTYPE_S, 0xC);
22678 write_gdt_entry(get_cpu_gdt_table(cpu),
22679 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
22680 #endif
22681 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
22682 /* alrighty, percpu areas up and running */
22683 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
22684 for_each_possible_cpu(cpu) {
22685 +#ifdef CONFIG_CC_STACKPROTECTOR
22686 +#ifdef CONFIG_X86_32
22687 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
22688 +#endif
22689 +#endif
22690 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
22691 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
22692 per_cpu(cpu_number, cpu) = cpu;
22693 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
22694 */
22695 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
22696 #endif
22697 +#ifdef CONFIG_CC_STACKPROTECTOR
22698 +#ifdef CONFIG_X86_32
22699 + if (!cpu)
22700 + per_cpu(stack_canary.canary, cpu) = canary;
22701 +#endif
22702 +#endif
22703 /*
22704 * Up to this point, the boot CPU has been using .init.data
22705 * area. Reload any changed state for the boot CPU.
22706 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
22707 index 6956299..f20beae 100644
22708 --- a/arch/x86/kernel/signal.c
22709 +++ b/arch/x86/kernel/signal.c
22710 @@ -196,7 +196,7 @@ static unsigned long align_sigframe(unsigned long sp)
22711 * Align the stack pointer according to the i386 ABI,
22712 * i.e. so that on function entry ((sp + 4) & 15) == 0.
22713 */
22714 - sp = ((sp + 4) & -16ul) - 4;
22715 + sp = ((sp - 12) & -16ul) - 4;
22716 #else /* !CONFIG_X86_32 */
22717 sp = round_down(sp, 16) - 8;
22718 #endif
22719 @@ -304,9 +304,9 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
22720 }
22721
22722 if (current->mm->context.vdso)
22723 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22724 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
22725 else
22726 - restorer = &frame->retcode;
22727 + restorer = (void __user *)&frame->retcode;
22728 if (ksig->ka.sa.sa_flags & SA_RESTORER)
22729 restorer = ksig->ka.sa.sa_restorer;
22730
22731 @@ -320,7 +320,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
22732 * reasons and because gdb uses it as a signature to notice
22733 * signal handler stack frames.
22734 */
22735 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
22736 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
22737
22738 if (err)
22739 return -EFAULT;
22740 @@ -367,7 +367,10 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
22741 err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
22742
22743 /* Set up to return from userspace. */
22744 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22745 + if (current->mm->context.vdso)
22746 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
22747 + else
22748 + restorer = (void __user *)&frame->retcode;
22749 if (ksig->ka.sa.sa_flags & SA_RESTORER)
22750 restorer = ksig->ka.sa.sa_restorer;
22751 put_user_ex(restorer, &frame->pretcode);
22752 @@ -379,7 +382,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
22753 * reasons and because gdb uses it as a signature to notice
22754 * signal handler stack frames.
22755 */
22756 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
22757 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
22758 } put_user_catch(err);
22759
22760 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
22761 @@ -615,7 +618,12 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
22762 {
22763 int usig = signr_convert(ksig->sig);
22764 sigset_t *set = sigmask_to_save();
22765 - compat_sigset_t *cset = (compat_sigset_t *) set;
22766 + sigset_t sigcopy;
22767 + compat_sigset_t *cset;
22768 +
22769 + sigcopy = *set;
22770 +
22771 + cset = (compat_sigset_t *) &sigcopy;
22772
22773 /* Set up the stack frame */
22774 if (is_ia32_frame()) {
22775 @@ -626,7 +634,7 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
22776 } else if (is_x32_frame()) {
22777 return x32_setup_rt_frame(ksig, cset, regs);
22778 } else {
22779 - return __setup_rt_frame(ksig->sig, ksig, set, regs);
22780 + return __setup_rt_frame(ksig->sig, ksig, &sigcopy, regs);
22781 }
22782 }
22783
22784 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
22785 index 48d2b7d..90d328a 100644
22786 --- a/arch/x86/kernel/smp.c
22787 +++ b/arch/x86/kernel/smp.c
22788 @@ -285,7 +285,7 @@ static int __init nonmi_ipi_setup(char *str)
22789
22790 __setup("nonmi_ipi", nonmi_ipi_setup);
22791
22792 -struct smp_ops smp_ops = {
22793 +struct smp_ops smp_ops __read_only = {
22794 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
22795 .smp_prepare_cpus = native_smp_prepare_cpus,
22796 .smp_cpus_done = native_smp_cpus_done,
22797 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
22798 index bfd348e..4816ad8 100644
22799 --- a/arch/x86/kernel/smpboot.c
22800 +++ b/arch/x86/kernel/smpboot.c
22801 @@ -748,6 +748,7 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
22802 idle->thread.sp = (unsigned long) (((struct pt_regs *)
22803 (THREAD_SIZE + task_stack_page(idle))) - 1);
22804 per_cpu(current_task, cpu) = idle;
22805 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
22806
22807 #ifdef CONFIG_X86_32
22808 /* Stack for startup_32 can be just as for start_secondary onwards */
22809 @@ -755,11 +756,13 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
22810 #else
22811 clear_tsk_thread_flag(idle, TIF_FORK);
22812 initial_gs = per_cpu_offset(cpu);
22813 - per_cpu(kernel_stack, cpu) =
22814 - (unsigned long)task_stack_page(idle) -
22815 - KERNEL_STACK_OFFSET + THREAD_SIZE;
22816 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
22817 #endif
22818 +
22819 + pax_open_kernel();
22820 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
22821 + pax_close_kernel();
22822 +
22823 initial_code = (unsigned long)start_secondary;
22824 stack_start = idle->thread.sp;
22825
22826 @@ -908,6 +911,15 @@ int __cpuinit native_cpu_up(unsigned int cpu, struct task_struct *tidle)
22827 /* the FPU context is blank, nobody can own it */
22828 __cpu_disable_lazy_restore(cpu);
22829
22830 +#ifdef CONFIG_PAX_PER_CPU_PGD
22831 + clone_pgd_range(get_cpu_pgd(cpu) + KERNEL_PGD_BOUNDARY,
22832 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
22833 + KERNEL_PGD_PTRS);
22834 +#endif
22835 +
22836 + /* the FPU context is blank, nobody can own it */
22837 + __cpu_disable_lazy_restore(cpu);
22838 +
22839 err = do_boot_cpu(apicid, cpu, tidle);
22840 if (err) {
22841 pr_debug("do_boot_cpu failed %d\n", err);
22842 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
22843 index 9b4d51d..5d28b58 100644
22844 --- a/arch/x86/kernel/step.c
22845 +++ b/arch/x86/kernel/step.c
22846 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
22847 struct desc_struct *desc;
22848 unsigned long base;
22849
22850 - seg &= ~7UL;
22851 + seg >>= 3;
22852
22853 mutex_lock(&child->mm->context.lock);
22854 - if (unlikely((seg >> 3) >= child->mm->context.size))
22855 + if (unlikely(seg >= child->mm->context.size))
22856 addr = -1L; /* bogus selector, access would fault */
22857 else {
22858 desc = child->mm->context.ldt + seg;
22859 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
22860 addr += base;
22861 }
22862 mutex_unlock(&child->mm->context.lock);
22863 - }
22864 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
22865 + addr = ktla_ktva(addr);
22866
22867 return addr;
22868 }
22869 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
22870 unsigned char opcode[15];
22871 unsigned long addr = convert_ip_to_linear(child, regs);
22872
22873 + if (addr == -EINVAL)
22874 + return 0;
22875 +
22876 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
22877 for (i = 0; i < copied; i++) {
22878 switch (opcode[i]) {
22879 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
22880 new file mode 100644
22881 index 0000000..5877189
22882 --- /dev/null
22883 +++ b/arch/x86/kernel/sys_i386_32.c
22884 @@ -0,0 +1,189 @@
22885 +/*
22886 + * This file contains various random system calls that
22887 + * have a non-standard calling sequence on the Linux/i386
22888 + * platform.
22889 + */
22890 +
22891 +#include <linux/errno.h>
22892 +#include <linux/sched.h>
22893 +#include <linux/mm.h>
22894 +#include <linux/fs.h>
22895 +#include <linux/smp.h>
22896 +#include <linux/sem.h>
22897 +#include <linux/msg.h>
22898 +#include <linux/shm.h>
22899 +#include <linux/stat.h>
22900 +#include <linux/syscalls.h>
22901 +#include <linux/mman.h>
22902 +#include <linux/file.h>
22903 +#include <linux/utsname.h>
22904 +#include <linux/ipc.h>
22905 +#include <linux/elf.h>
22906 +
22907 +#include <linux/uaccess.h>
22908 +#include <linux/unistd.h>
22909 +
22910 +#include <asm/syscalls.h>
22911 +
22912 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
22913 +{
22914 + unsigned long pax_task_size = TASK_SIZE;
22915 +
22916 +#ifdef CONFIG_PAX_SEGMEXEC
22917 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
22918 + pax_task_size = SEGMEXEC_TASK_SIZE;
22919 +#endif
22920 +
22921 + if (flags & MAP_FIXED)
22922 + if (len > pax_task_size || addr > pax_task_size - len)
22923 + return -EINVAL;
22924 +
22925 + return 0;
22926 +}
22927 +
22928 +/*
22929 + * Align a virtual address to avoid aliasing in the I$ on AMD F15h.
22930 + */
22931 +static unsigned long get_align_mask(void)
22932 +{
22933 + if (va_align.flags < 0 || !(va_align.flags & ALIGN_VA_32))
22934 + return 0;
22935 +
22936 + if (!(current->flags & PF_RANDOMIZE))
22937 + return 0;
22938 +
22939 + return va_align.mask;
22940 +}
22941 +
22942 +unsigned long
22943 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
22944 + unsigned long len, unsigned long pgoff, unsigned long flags)
22945 +{
22946 + struct mm_struct *mm = current->mm;
22947 + struct vm_area_struct *vma;
22948 + unsigned long pax_task_size = TASK_SIZE;
22949 + struct vm_unmapped_area_info info;
22950 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
22951 +
22952 +#ifdef CONFIG_PAX_SEGMEXEC
22953 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
22954 + pax_task_size = SEGMEXEC_TASK_SIZE;
22955 +#endif
22956 +
22957 + pax_task_size -= PAGE_SIZE;
22958 +
22959 + if (len > pax_task_size)
22960 + return -ENOMEM;
22961 +
22962 + if (flags & MAP_FIXED)
22963 + return addr;
22964 +
22965 +#ifdef CONFIG_PAX_RANDMMAP
22966 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
22967 +#endif
22968 +
22969 + if (addr) {
22970 + addr = PAGE_ALIGN(addr);
22971 + if (pax_task_size - len >= addr) {
22972 + vma = find_vma(mm, addr);
22973 + if (check_heap_stack_gap(vma, addr, len, offset))
22974 + return addr;
22975 + }
22976 + }
22977 +
22978 + info.flags = 0;
22979 + info.length = len;
22980 + info.align_mask = filp ? get_align_mask() : 0;
22981 + info.align_offset = pgoff << PAGE_SHIFT;
22982 + info.threadstack_offset = offset;
22983 +
22984 +#ifdef CONFIG_PAX_PAGEEXEC
22985 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE)) {
22986 + info.low_limit = 0x00110000UL;
22987 + info.high_limit = mm->start_code;
22988 +
22989 +#ifdef CONFIG_PAX_RANDMMAP
22990 + if (mm->pax_flags & MF_PAX_RANDMMAP)
22991 + info.low_limit += mm->delta_mmap & 0x03FFF000UL;
22992 +#endif
22993 +
22994 + if (info.low_limit < info.high_limit) {
22995 + addr = vm_unmapped_area(&info);
22996 + if (!IS_ERR_VALUE(addr))
22997 + return addr;
22998 + }
22999 + } else
23000 +#endif
23001 +
23002 + info.low_limit = mm->mmap_base;
23003 + info.high_limit = pax_task_size;
23004 +
23005 + return vm_unmapped_area(&info);
23006 +}
23007 +
23008 +unsigned long
23009 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23010 + const unsigned long len, const unsigned long pgoff,
23011 + const unsigned long flags)
23012 +{
23013 + struct vm_area_struct *vma;
23014 + struct mm_struct *mm = current->mm;
23015 + unsigned long addr = addr0, pax_task_size = TASK_SIZE;
23016 + struct vm_unmapped_area_info info;
23017 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23018 +
23019 +#ifdef CONFIG_PAX_SEGMEXEC
23020 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
23021 + pax_task_size = SEGMEXEC_TASK_SIZE;
23022 +#endif
23023 +
23024 + pax_task_size -= PAGE_SIZE;
23025 +
23026 + /* requested length too big for entire address space */
23027 + if (len > pax_task_size)
23028 + return -ENOMEM;
23029 +
23030 + if (flags & MAP_FIXED)
23031 + return addr;
23032 +
23033 +#ifdef CONFIG_PAX_PAGEEXEC
23034 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
23035 + goto bottomup;
23036 +#endif
23037 +
23038 +#ifdef CONFIG_PAX_RANDMMAP
23039 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23040 +#endif
23041 +
23042 + /* requesting a specific address */
23043 + if (addr) {
23044 + addr = PAGE_ALIGN(addr);
23045 + if (pax_task_size - len >= addr) {
23046 + vma = find_vma(mm, addr);
23047 + if (check_heap_stack_gap(vma, addr, len, offset))
23048 + return addr;
23049 + }
23050 + }
23051 +
23052 + info.flags = VM_UNMAPPED_AREA_TOPDOWN;
23053 + info.length = len;
23054 + info.low_limit = PAGE_SIZE;
23055 + info.high_limit = mm->mmap_base;
23056 + info.align_mask = filp ? get_align_mask() : 0;
23057 + info.align_offset = pgoff << PAGE_SHIFT;
23058 + info.threadstack_offset = offset;
23059 +
23060 + addr = vm_unmapped_area(&info);
23061 + if (!(addr & ~PAGE_MASK))
23062 + return addr;
23063 + VM_BUG_ON(addr != -ENOMEM);
23064 +
23065 +bottomup:
23066 + /*
23067 + * A failed mmap() very likely causes application failure,
23068 + * so fall back to the bottom-up function here. This scenario
23069 + * can happen with large stack limits and large mmap()
23070 + * allocations.
23071 + */
23072 + return arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
23073 +}
23074 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
23075 index dbded5a..ace2781 100644
23076 --- a/arch/x86/kernel/sys_x86_64.c
23077 +++ b/arch/x86/kernel/sys_x86_64.c
23078 @@ -81,8 +81,8 @@ out:
23079 return error;
23080 }
23081
23082 -static void find_start_end(unsigned long flags, unsigned long *begin,
23083 - unsigned long *end)
23084 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
23085 + unsigned long *begin, unsigned long *end)
23086 {
23087 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
23088 unsigned long new_begin;
23089 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
23090 *begin = new_begin;
23091 }
23092 } else {
23093 - *begin = TASK_UNMAPPED_BASE;
23094 + *begin = mm->mmap_base;
23095 *end = TASK_SIZE;
23096 }
23097 }
23098 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
23099 struct vm_area_struct *vma;
23100 struct vm_unmapped_area_info info;
23101 unsigned long begin, end;
23102 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23103
23104 if (flags & MAP_FIXED)
23105 return addr;
23106
23107 - find_start_end(flags, &begin, &end);
23108 + find_start_end(mm, flags, &begin, &end);
23109
23110 if (len > end)
23111 return -ENOMEM;
23112
23113 +#ifdef CONFIG_PAX_RANDMMAP
23114 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23115 +#endif
23116 +
23117 if (addr) {
23118 addr = PAGE_ALIGN(addr);
23119 vma = find_vma(mm, addr);
23120 - if (end - len >= addr &&
23121 - (!vma || addr + len <= vma->vm_start))
23122 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
23123 return addr;
23124 }
23125
23126 @@ -137,6 +141,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
23127 info.high_limit = end;
23128 info.align_mask = filp ? get_align_mask() : 0;
23129 info.align_offset = pgoff << PAGE_SHIFT;
23130 + info.threadstack_offset = offset;
23131 return vm_unmapped_area(&info);
23132 }
23133
23134 @@ -149,6 +154,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23135 struct mm_struct *mm = current->mm;
23136 unsigned long addr = addr0;
23137 struct vm_unmapped_area_info info;
23138 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
23139
23140 /* requested length too big for entire address space */
23141 if (len > TASK_SIZE)
23142 @@ -161,12 +167,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23143 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
23144 goto bottomup;
23145
23146 +#ifdef CONFIG_PAX_RANDMMAP
23147 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
23148 +#endif
23149 +
23150 /* requesting a specific address */
23151 if (addr) {
23152 addr = PAGE_ALIGN(addr);
23153 vma = find_vma(mm, addr);
23154 - if (TASK_SIZE - len >= addr &&
23155 - (!vma || addr + len <= vma->vm_start))
23156 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
23157 return addr;
23158 }
23159
23160 @@ -176,6 +185,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
23161 info.high_limit = mm->mmap_base;
23162 info.align_mask = filp ? get_align_mask() : 0;
23163 info.align_offset = pgoff << PAGE_SHIFT;
23164 + info.threadstack_offset = offset;
23165 addr = vm_unmapped_area(&info);
23166 if (!(addr & ~PAGE_MASK))
23167 return addr;
23168 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
23169 index f84fe00..f41d9f1 100644
23170 --- a/arch/x86/kernel/tboot.c
23171 +++ b/arch/x86/kernel/tboot.c
23172 @@ -220,7 +220,7 @@ static int tboot_setup_sleep(void)
23173
23174 void tboot_shutdown(u32 shutdown_type)
23175 {
23176 - void (*shutdown)(void);
23177 + void (* __noreturn shutdown)(void);
23178
23179 if (!tboot_enabled())
23180 return;
23181 @@ -242,7 +242,7 @@ void tboot_shutdown(u32 shutdown_type)
23182
23183 switch_to_tboot_pt();
23184
23185 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
23186 + shutdown = (void *)tboot->shutdown_entry;
23187 shutdown();
23188
23189 /* should not reach here */
23190 @@ -300,7 +300,7 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
23191 return 0;
23192 }
23193
23194 -static atomic_t ap_wfs_count;
23195 +static atomic_unchecked_t ap_wfs_count;
23196
23197 static int tboot_wait_for_aps(int num_aps)
23198 {
23199 @@ -324,16 +324,16 @@ static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb,
23200 {
23201 switch (action) {
23202 case CPU_DYING:
23203 - atomic_inc(&ap_wfs_count);
23204 + atomic_inc_unchecked(&ap_wfs_count);
23205 if (num_online_cpus() == 1)
23206 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
23207 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
23208 return NOTIFY_BAD;
23209 break;
23210 }
23211 return NOTIFY_OK;
23212 }
23213
23214 -static struct notifier_block tboot_cpu_notifier __cpuinitdata =
23215 +static struct notifier_block tboot_cpu_notifier =
23216 {
23217 .notifier_call = tboot_cpu_callback,
23218 };
23219 @@ -345,7 +345,7 @@ static __init int tboot_late_init(void)
23220
23221 tboot_create_trampoline();
23222
23223 - atomic_set(&ap_wfs_count, 0);
23224 + atomic_set_unchecked(&ap_wfs_count, 0);
23225 register_hotcpu_notifier(&tboot_cpu_notifier);
23226
23227 acpi_os_set_prepare_sleep(&tboot_sleep);
23228 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
23229 index 24d3c91..d06b473 100644
23230 --- a/arch/x86/kernel/time.c
23231 +++ b/arch/x86/kernel/time.c
23232 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
23233 {
23234 unsigned long pc = instruction_pointer(regs);
23235
23236 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
23237 + if (!user_mode(regs) && in_lock_functions(pc)) {
23238 #ifdef CONFIG_FRAME_POINTER
23239 - return *(unsigned long *)(regs->bp + sizeof(long));
23240 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
23241 #else
23242 unsigned long *sp =
23243 (unsigned long *)kernel_stack_pointer(regs);
23244 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
23245 * or above a saved flags. Eflags has bits 22-31 zero,
23246 * kernel addresses don't.
23247 */
23248 +
23249 +#ifdef CONFIG_PAX_KERNEXEC
23250 + return ktla_ktva(sp[0]);
23251 +#else
23252 if (sp[0] >> 22)
23253 return sp[0];
23254 if (sp[1] >> 22)
23255 return sp[1];
23256 #endif
23257 +
23258 +#endif
23259 }
23260 return pc;
23261 }
23262 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
23263 index f7fec09..9991981 100644
23264 --- a/arch/x86/kernel/tls.c
23265 +++ b/arch/x86/kernel/tls.c
23266 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
23267 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
23268 return -EINVAL;
23269
23270 +#ifdef CONFIG_PAX_SEGMEXEC
23271 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
23272 + return -EINVAL;
23273 +#endif
23274 +
23275 set_tls_desc(p, idx, &info, 1);
23276
23277 return 0;
23278 @@ -200,7 +205,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
23279
23280 if (kbuf)
23281 info = kbuf;
23282 - else if (__copy_from_user(infobuf, ubuf, count))
23283 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
23284 return -EFAULT;
23285 else
23286 info = infobuf;
23287 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
23288 index 772e2a8..bad5bf6 100644
23289 --- a/arch/x86/kernel/traps.c
23290 +++ b/arch/x86/kernel/traps.c
23291 @@ -68,12 +68,6 @@
23292 #include <asm/setup.h>
23293
23294 asmlinkage int system_call(void);
23295 -
23296 -/*
23297 - * The IDT has to be page-aligned to simplify the Pentium
23298 - * F0 0F bug workaround.
23299 - */
23300 -gate_desc idt_table[NR_VECTORS] __page_aligned_data = { { { { 0, 0 } } }, };
23301 #endif
23302
23303 DECLARE_BITMAP(used_vectors, NR_VECTORS);
23304 @@ -106,11 +100,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
23305 }
23306
23307 static int __kprobes
23308 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23309 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
23310 struct pt_regs *regs, long error_code)
23311 {
23312 #ifdef CONFIG_X86_32
23313 - if (regs->flags & X86_VM_MASK) {
23314 + if (v8086_mode(regs)) {
23315 /*
23316 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
23317 * On nmi (interrupt 2), do_trap should not be called.
23318 @@ -123,12 +117,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23319 return -1;
23320 }
23321 #endif
23322 - if (!user_mode(regs)) {
23323 + if (!user_mode_novm(regs)) {
23324 if (!fixup_exception(regs)) {
23325 tsk->thread.error_code = error_code;
23326 tsk->thread.trap_nr = trapnr;
23327 +
23328 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23329 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
23330 + str = "PAX: suspicious stack segment fault";
23331 +#endif
23332 +
23333 die(str, regs, error_code);
23334 }
23335 +
23336 +#ifdef CONFIG_PAX_REFCOUNT
23337 + if (trapnr == 4)
23338 + pax_report_refcount_overflow(regs);
23339 +#endif
23340 +
23341 return 0;
23342 }
23343
23344 @@ -136,7 +142,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
23345 }
23346
23347 static void __kprobes
23348 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23349 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
23350 long error_code, siginfo_t *info)
23351 {
23352 struct task_struct *tsk = current;
23353 @@ -160,7 +166,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
23354 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
23355 printk_ratelimit()) {
23356 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
23357 - tsk->comm, tsk->pid, str,
23358 + tsk->comm, task_pid_nr(tsk), str,
23359 regs->ip, regs->sp, error_code);
23360 print_vma_addr(" in ", regs->ip);
23361 pr_cont("\n");
23362 @@ -273,7 +279,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
23363 conditional_sti(regs);
23364
23365 #ifdef CONFIG_X86_32
23366 - if (regs->flags & X86_VM_MASK) {
23367 + if (v8086_mode(regs)) {
23368 local_irq_enable();
23369 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
23370 goto exit;
23371 @@ -281,18 +287,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
23372 #endif
23373
23374 tsk = current;
23375 - if (!user_mode(regs)) {
23376 + if (!user_mode_novm(regs)) {
23377 if (fixup_exception(regs))
23378 goto exit;
23379
23380 tsk->thread.error_code = error_code;
23381 tsk->thread.trap_nr = X86_TRAP_GP;
23382 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
23383 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
23384 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
23385 +
23386 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23387 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
23388 + die("PAX: suspicious general protection fault", regs, error_code);
23389 + else
23390 +#endif
23391 +
23392 die("general protection fault", regs, error_code);
23393 + }
23394 goto exit;
23395 }
23396
23397 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
23398 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
23399 + struct mm_struct *mm = tsk->mm;
23400 + unsigned long limit;
23401 +
23402 + down_write(&mm->mmap_sem);
23403 + limit = mm->context.user_cs_limit;
23404 + if (limit < TASK_SIZE) {
23405 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
23406 + up_write(&mm->mmap_sem);
23407 + return;
23408 + }
23409 + up_write(&mm->mmap_sem);
23410 + }
23411 +#endif
23412 +
23413 tsk->thread.error_code = error_code;
23414 tsk->thread.trap_nr = X86_TRAP_GP;
23415
23416 @@ -450,7 +480,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23417 /* It's safe to allow irq's after DR6 has been saved */
23418 preempt_conditional_sti(regs);
23419
23420 - if (regs->flags & X86_VM_MASK) {
23421 + if (v8086_mode(regs)) {
23422 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
23423 X86_TRAP_DB);
23424 preempt_conditional_cli(regs);
23425 @@ -465,7 +495,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
23426 * We already checked v86 mode above, so we can check for kernel mode
23427 * by just checking the CPL of CS.
23428 */
23429 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
23430 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
23431 tsk->thread.debugreg6 &= ~DR_STEP;
23432 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
23433 regs->flags &= ~X86_EFLAGS_TF;
23434 @@ -497,7 +527,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
23435 return;
23436 conditional_sti(regs);
23437
23438 - if (!user_mode_vm(regs))
23439 + if (!user_mode(regs))
23440 {
23441 if (!fixup_exception(regs)) {
23442 task->thread.error_code = error_code;
23443 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
23444 index 2ed8459..7cf329f 100644
23445 --- a/arch/x86/kernel/uprobes.c
23446 +++ b/arch/x86/kernel/uprobes.c
23447 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
23448 int ret = NOTIFY_DONE;
23449
23450 /* We are only interested in userspace traps */
23451 - if (regs && !user_mode_vm(regs))
23452 + if (regs && !user_mode(regs))
23453 return NOTIFY_DONE;
23454
23455 switch (val) {
23456 @@ -719,7 +719,7 @@ arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, struct pt_regs
23457
23458 if (ncopied != rasize) {
23459 pr_err("uprobe: return address clobbered: pid=%d, %%sp=%#lx, "
23460 - "%%ip=%#lx\n", current->pid, regs->sp, regs->ip);
23461 + "%%ip=%#lx\n", task_pid_nr(current), regs->sp, regs->ip);
23462
23463 force_sig_info(SIGSEGV, SEND_SIG_FORCED, current);
23464 }
23465 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
23466 index b9242ba..50c5edd 100644
23467 --- a/arch/x86/kernel/verify_cpu.S
23468 +++ b/arch/x86/kernel/verify_cpu.S
23469 @@ -20,6 +20,7 @@
23470 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
23471 * arch/x86/kernel/trampoline_64.S: secondary processor verification
23472 * arch/x86/kernel/head_32.S: processor startup
23473 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
23474 *
23475 * verify_cpu, returns the status of longmode and SSE in register %eax.
23476 * 0: Success 1: Failure
23477 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
23478 index e8edcf5..27f9344 100644
23479 --- a/arch/x86/kernel/vm86_32.c
23480 +++ b/arch/x86/kernel/vm86_32.c
23481 @@ -44,6 +44,7 @@
23482 #include <linux/ptrace.h>
23483 #include <linux/audit.h>
23484 #include <linux/stddef.h>
23485 +#include <linux/grsecurity.h>
23486
23487 #include <asm/uaccess.h>
23488 #include <asm/io.h>
23489 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
23490 do_exit(SIGSEGV);
23491 }
23492
23493 - tss = &per_cpu(init_tss, get_cpu());
23494 + tss = init_tss + get_cpu();
23495 current->thread.sp0 = current->thread.saved_sp0;
23496 current->thread.sysenter_cs = __KERNEL_CS;
23497 load_sp0(tss, &current->thread);
23498 @@ -214,6 +215,14 @@ SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
23499
23500 if (tsk->thread.saved_sp0)
23501 return -EPERM;
23502 +
23503 +#ifdef CONFIG_GRKERNSEC_VM86
23504 + if (!capable(CAP_SYS_RAWIO)) {
23505 + gr_handle_vm86();
23506 + return -EPERM;
23507 + }
23508 +#endif
23509 +
23510 tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
23511 offsetof(struct kernel_vm86_struct, vm86plus) -
23512 sizeof(info.regs));
23513 @@ -238,6 +247,13 @@ SYSCALL_DEFINE2(vm86, unsigned long, cmd, unsigned long, arg)
23514 int tmp;
23515 struct vm86plus_struct __user *v86;
23516
23517 +#ifdef CONFIG_GRKERNSEC_VM86
23518 + if (!capable(CAP_SYS_RAWIO)) {
23519 + gr_handle_vm86();
23520 + return -EPERM;
23521 + }
23522 +#endif
23523 +
23524 tsk = current;
23525 switch (cmd) {
23526 case VM86_REQUEST_IRQ:
23527 @@ -318,7 +334,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
23528 tsk->thread.saved_fs = info->regs32->fs;
23529 tsk->thread.saved_gs = get_user_gs(info->regs32);
23530
23531 - tss = &per_cpu(init_tss, get_cpu());
23532 + tss = init_tss + get_cpu();
23533 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
23534 if (cpu_has_sep)
23535 tsk->thread.sysenter_cs = 0;
23536 @@ -525,7 +541,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
23537 goto cannot_handle;
23538 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
23539 goto cannot_handle;
23540 - intr_ptr = (unsigned long __user *) (i << 2);
23541 + intr_ptr = (__force unsigned long __user *) (i << 2);
23542 if (get_user(segoffs, intr_ptr))
23543 goto cannot_handle;
23544 if ((segoffs >> 16) == BIOSSEG)
23545 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
23546 index 10c4f30..57377c2 100644
23547 --- a/arch/x86/kernel/vmlinux.lds.S
23548 +++ b/arch/x86/kernel/vmlinux.lds.S
23549 @@ -26,6 +26,13 @@
23550 #include <asm/page_types.h>
23551 #include <asm/cache.h>
23552 #include <asm/boot.h>
23553 +#include <asm/segment.h>
23554 +
23555 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23556 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
23557 +#else
23558 +#define __KERNEL_TEXT_OFFSET 0
23559 +#endif
23560
23561 #undef i386 /* in case the preprocessor is a 32bit one */
23562
23563 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
23564
23565 PHDRS {
23566 text PT_LOAD FLAGS(5); /* R_E */
23567 +#ifdef CONFIG_X86_32
23568 + module PT_LOAD FLAGS(5); /* R_E */
23569 +#endif
23570 +#ifdef CONFIG_XEN
23571 + rodata PT_LOAD FLAGS(5); /* R_E */
23572 +#else
23573 + rodata PT_LOAD FLAGS(4); /* R__ */
23574 +#endif
23575 data PT_LOAD FLAGS(6); /* RW_ */
23576 -#ifdef CONFIG_X86_64
23577 + init.begin PT_LOAD FLAGS(6); /* RW_ */
23578 #ifdef CONFIG_SMP
23579 percpu PT_LOAD FLAGS(6); /* RW_ */
23580 #endif
23581 + text.init PT_LOAD FLAGS(5); /* R_E */
23582 + text.exit PT_LOAD FLAGS(5); /* R_E */
23583 init PT_LOAD FLAGS(7); /* RWE */
23584 -#endif
23585 note PT_NOTE FLAGS(0); /* ___ */
23586 }
23587
23588 SECTIONS
23589 {
23590 #ifdef CONFIG_X86_32
23591 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
23592 - phys_startup_32 = startup_32 - LOAD_OFFSET;
23593 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
23594 #else
23595 - . = __START_KERNEL;
23596 - phys_startup_64 = startup_64 - LOAD_OFFSET;
23597 + . = __START_KERNEL;
23598 #endif
23599
23600 /* Text and read-only data */
23601 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
23602 - _text = .;
23603 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23604 /* bootstrapping code */
23605 +#ifdef CONFIG_X86_32
23606 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23607 +#else
23608 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23609 +#endif
23610 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
23611 + _text = .;
23612 HEAD_TEXT
23613 . = ALIGN(8);
23614 _stext = .;
23615 @@ -104,13 +124,48 @@ SECTIONS
23616 IRQENTRY_TEXT
23617 *(.fixup)
23618 *(.gnu.warning)
23619 - /* End of text section */
23620 - _etext = .;
23621 } :text = 0x9090
23622
23623 - NOTES :text :note
23624 + . += __KERNEL_TEXT_OFFSET;
23625
23626 - EXCEPTION_TABLE(16) :text = 0x9090
23627 +#ifdef CONFIG_X86_32
23628 + . = ALIGN(PAGE_SIZE);
23629 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
23630 +
23631 +#ifdef CONFIG_PAX_KERNEXEC
23632 + MODULES_EXEC_VADDR = .;
23633 + BYTE(0)
23634 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
23635 + . = ALIGN(HPAGE_SIZE) - 1;
23636 + MODULES_EXEC_END = .;
23637 +#endif
23638 +
23639 + } :module
23640 +#endif
23641 +
23642 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
23643 + /* End of text section */
23644 + BYTE(0)
23645 + _etext = . - __KERNEL_TEXT_OFFSET;
23646 + }
23647 +
23648 +#ifdef CONFIG_X86_32
23649 + . = ALIGN(PAGE_SIZE);
23650 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
23651 + *(.idt)
23652 + . = ALIGN(PAGE_SIZE);
23653 + *(.empty_zero_page)
23654 + *(.initial_pg_fixmap)
23655 + *(.initial_pg_pmd)
23656 + *(.initial_page_table)
23657 + *(.swapper_pg_dir)
23658 + } :rodata
23659 +#endif
23660 +
23661 + . = ALIGN(PAGE_SIZE);
23662 + NOTES :rodata :note
23663 +
23664 + EXCEPTION_TABLE(16) :rodata
23665
23666 #if defined(CONFIG_DEBUG_RODATA)
23667 /* .text should occupy whole number of pages */
23668 @@ -122,16 +177,20 @@ SECTIONS
23669
23670 /* Data */
23671 .data : AT(ADDR(.data) - LOAD_OFFSET) {
23672 +
23673 +#ifdef CONFIG_PAX_KERNEXEC
23674 + . = ALIGN(HPAGE_SIZE);
23675 +#else
23676 + . = ALIGN(PAGE_SIZE);
23677 +#endif
23678 +
23679 /* Start of data section */
23680 _sdata = .;
23681
23682 /* init_task */
23683 INIT_TASK_DATA(THREAD_SIZE)
23684
23685 -#ifdef CONFIG_X86_32
23686 - /* 32 bit has nosave before _edata */
23687 NOSAVE_DATA
23688 -#endif
23689
23690 PAGE_ALIGNED_DATA(PAGE_SIZE)
23691
23692 @@ -172,12 +231,19 @@ SECTIONS
23693 #endif /* CONFIG_X86_64 */
23694
23695 /* Init code and data - will be freed after init */
23696 - . = ALIGN(PAGE_SIZE);
23697 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
23698 + BYTE(0)
23699 +
23700 +#ifdef CONFIG_PAX_KERNEXEC
23701 + . = ALIGN(HPAGE_SIZE);
23702 +#else
23703 + . = ALIGN(PAGE_SIZE);
23704 +#endif
23705 +
23706 __init_begin = .; /* paired with __init_end */
23707 - }
23708 + } :init.begin
23709
23710 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
23711 +#ifdef CONFIG_SMP
23712 /*
23713 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
23714 * output PHDR, so the next output section - .init.text - should
23715 @@ -186,12 +252,27 @@ SECTIONS
23716 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
23717 #endif
23718
23719 - INIT_TEXT_SECTION(PAGE_SIZE)
23720 -#ifdef CONFIG_X86_64
23721 - :init
23722 -#endif
23723 + . = ALIGN(PAGE_SIZE);
23724 + init_begin = .;
23725 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
23726 + VMLINUX_SYMBOL(_sinittext) = .;
23727 + INIT_TEXT
23728 + VMLINUX_SYMBOL(_einittext) = .;
23729 + . = ALIGN(PAGE_SIZE);
23730 + } :text.init
23731
23732 - INIT_DATA_SECTION(16)
23733 + /*
23734 + * .exit.text is discard at runtime, not link time, to deal with
23735 + * references from .altinstructions and .eh_frame
23736 + */
23737 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
23738 + EXIT_TEXT
23739 + . = ALIGN(16);
23740 + } :text.exit
23741 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
23742 +
23743 + . = ALIGN(PAGE_SIZE);
23744 + INIT_DATA_SECTION(16) :init
23745
23746 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
23747 __x86_cpu_dev_start = .;
23748 @@ -253,19 +334,12 @@ SECTIONS
23749 }
23750
23751 . = ALIGN(8);
23752 - /*
23753 - * .exit.text is discard at runtime, not link time, to deal with
23754 - * references from .altinstructions and .eh_frame
23755 - */
23756 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
23757 - EXIT_TEXT
23758 - }
23759
23760 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
23761 EXIT_DATA
23762 }
23763
23764 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
23765 +#ifndef CONFIG_SMP
23766 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
23767 #endif
23768
23769 @@ -284,16 +358,10 @@ SECTIONS
23770 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
23771 __smp_locks = .;
23772 *(.smp_locks)
23773 - . = ALIGN(PAGE_SIZE);
23774 __smp_locks_end = .;
23775 + . = ALIGN(PAGE_SIZE);
23776 }
23777
23778 -#ifdef CONFIG_X86_64
23779 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
23780 - NOSAVE_DATA
23781 - }
23782 -#endif
23783 -
23784 /* BSS */
23785 . = ALIGN(PAGE_SIZE);
23786 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
23787 @@ -309,6 +377,7 @@ SECTIONS
23788 __brk_base = .;
23789 . += 64 * 1024; /* 64k alignment slop space */
23790 *(.brk_reservation) /* areas brk users have reserved */
23791 + . = ALIGN(HPAGE_SIZE);
23792 __brk_limit = .;
23793 }
23794
23795 @@ -335,13 +404,12 @@ SECTIONS
23796 * for the boot processor.
23797 */
23798 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
23799 -INIT_PER_CPU(gdt_page);
23800 INIT_PER_CPU(irq_stack_union);
23801
23802 /*
23803 * Build-time check on the image size:
23804 */
23805 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
23806 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
23807 "kernel image bigger than KERNEL_IMAGE_SIZE");
23808
23809 #ifdef CONFIG_SMP
23810 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
23811 index 9a907a6..f83f921 100644
23812 --- a/arch/x86/kernel/vsyscall_64.c
23813 +++ b/arch/x86/kernel/vsyscall_64.c
23814 @@ -56,15 +56,13 @@
23815 DEFINE_VVAR(int, vgetcpu_mode);
23816 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
23817
23818 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
23819 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
23820
23821 static int __init vsyscall_setup(char *str)
23822 {
23823 if (str) {
23824 if (!strcmp("emulate", str))
23825 vsyscall_mode = EMULATE;
23826 - else if (!strcmp("native", str))
23827 - vsyscall_mode = NATIVE;
23828 else if (!strcmp("none", str))
23829 vsyscall_mode = NONE;
23830 else
23831 @@ -323,8 +321,7 @@ do_ret:
23832 return true;
23833
23834 sigsegv:
23835 - force_sig(SIGSEGV, current);
23836 - return true;
23837 + do_group_exit(SIGKILL);
23838 }
23839
23840 /*
23841 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
23842 extern char __vvar_page;
23843 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
23844
23845 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
23846 - vsyscall_mode == NATIVE
23847 - ? PAGE_KERNEL_VSYSCALL
23848 - : PAGE_KERNEL_VVAR);
23849 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
23850 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
23851 (unsigned long)VSYSCALL_START);
23852
23853 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
23854 index b014d94..6d6ca7b 100644
23855 --- a/arch/x86/kernel/x8664_ksyms_64.c
23856 +++ b/arch/x86/kernel/x8664_ksyms_64.c
23857 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
23858 EXPORT_SYMBOL(copy_user_generic_unrolled);
23859 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
23860 EXPORT_SYMBOL(__copy_user_nocache);
23861 -EXPORT_SYMBOL(_copy_from_user);
23862 -EXPORT_SYMBOL(_copy_to_user);
23863
23864 EXPORT_SYMBOL(copy_page);
23865 EXPORT_SYMBOL(clear_page);
23866 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
23867 index 45a14db..075bb9b 100644
23868 --- a/arch/x86/kernel/x86_init.c
23869 +++ b/arch/x86/kernel/x86_init.c
23870 @@ -85,7 +85,7 @@ struct x86_init_ops x86_init __initdata = {
23871 },
23872 };
23873
23874 -struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
23875 +struct x86_cpuinit_ops x86_cpuinit __cpuinitconst = {
23876 .early_percpu_clock_init = x86_init_noop,
23877 .setup_percpu_clockev = setup_secondary_APIC_clock,
23878 };
23879 @@ -93,7 +93,7 @@ struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
23880 static void default_nmi_init(void) { };
23881 static int default_i8042_detect(void) { return 1; };
23882
23883 -struct x86_platform_ops x86_platform = {
23884 +struct x86_platform_ops x86_platform __read_only = {
23885 .calibrate_tsc = native_calibrate_tsc,
23886 .get_wallclock = mach_get_cmos_time,
23887 .set_wallclock = mach_set_rtc_mmss,
23888 @@ -107,7 +107,7 @@ struct x86_platform_ops x86_platform = {
23889 };
23890
23891 EXPORT_SYMBOL_GPL(x86_platform);
23892 -struct x86_msi_ops x86_msi = {
23893 +struct x86_msi_ops x86_msi __read_only = {
23894 .setup_msi_irqs = native_setup_msi_irqs,
23895 .compose_msi_msg = native_compose_msi_msg,
23896 .teardown_msi_irq = native_teardown_msi_irq,
23897 @@ -116,7 +116,7 @@ struct x86_msi_ops x86_msi = {
23898 .setup_hpet_msi = default_setup_hpet_msi,
23899 };
23900
23901 -struct x86_io_apic_ops x86_io_apic_ops = {
23902 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
23903 .init = native_io_apic_init_mappings,
23904 .read = native_io_apic_read,
23905 .write = native_io_apic_write,
23906 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
23907 index ada87a3..afea76d 100644
23908 --- a/arch/x86/kernel/xsave.c
23909 +++ b/arch/x86/kernel/xsave.c
23910 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
23911 {
23912 int err;
23913
23914 + buf = (struct xsave_struct __user *)____m(buf);
23915 if (use_xsave())
23916 err = xsave_user(buf);
23917 else if (use_fxsr())
23918 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
23919 */
23920 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
23921 {
23922 + buf = (void __user *)____m(buf);
23923 if (use_xsave()) {
23924 if ((unsigned long)buf % 64 || fx_only) {
23925 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
23926 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
23927 index a20ecb5..d0e2194 100644
23928 --- a/arch/x86/kvm/cpuid.c
23929 +++ b/arch/x86/kvm/cpuid.c
23930 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
23931 struct kvm_cpuid2 *cpuid,
23932 struct kvm_cpuid_entry2 __user *entries)
23933 {
23934 - int r;
23935 + int r, i;
23936
23937 r = -E2BIG;
23938 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
23939 goto out;
23940 r = -EFAULT;
23941 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
23942 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
23943 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
23944 goto out;
23945 + for (i = 0; i < cpuid->nent; ++i) {
23946 + struct kvm_cpuid_entry2 cpuid_entry;
23947 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
23948 + goto out;
23949 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
23950 + }
23951 vcpu->arch.cpuid_nent = cpuid->nent;
23952 kvm_apic_set_version(vcpu);
23953 kvm_x86_ops->cpuid_update(vcpu);
23954 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
23955 struct kvm_cpuid2 *cpuid,
23956 struct kvm_cpuid_entry2 __user *entries)
23957 {
23958 - int r;
23959 + int r, i;
23960
23961 r = -E2BIG;
23962 if (cpuid->nent < vcpu->arch.cpuid_nent)
23963 goto out;
23964 r = -EFAULT;
23965 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
23966 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
23967 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
23968 goto out;
23969 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
23970 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
23971 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
23972 + goto out;
23973 + }
23974 return 0;
23975
23976 out:
23977 diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
23978 index 5953dce..f11a7d2 100644
23979 --- a/arch/x86/kvm/emulate.c
23980 +++ b/arch/x86/kvm/emulate.c
23981 @@ -329,6 +329,7 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
23982
23983 #define ____emulate_2op(ctxt, _op, _x, _y, _suffix, _dsttype) \
23984 do { \
23985 + unsigned long _tmp; \
23986 __asm__ __volatile__ ( \
23987 _PRE_EFLAGS("0", "4", "2") \
23988 _op _suffix " %"_x"3,%1; " \
23989 @@ -343,8 +344,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
23990 /* Raw emulation: instruction has two explicit operands. */
23991 #define __emulate_2op_nobyte(ctxt,_op,_wx,_wy,_lx,_ly,_qx,_qy) \
23992 do { \
23993 - unsigned long _tmp; \
23994 - \
23995 switch ((ctxt)->dst.bytes) { \
23996 case 2: \
23997 ____emulate_2op(ctxt,_op,_wx,_wy,"w",u16); \
23998 @@ -360,7 +359,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
23999
24000 #define __emulate_2op(ctxt,_op,_bx,_by,_wx,_wy,_lx,_ly,_qx,_qy) \
24001 do { \
24002 - unsigned long _tmp; \
24003 switch ((ctxt)->dst.bytes) { \
24004 case 1: \
24005 ____emulate_2op(ctxt,_op,_bx,_by,"b",u8); \
24006 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
24007 index 0eee2c8..94a32c3 100644
24008 --- a/arch/x86/kvm/lapic.c
24009 +++ b/arch/x86/kvm/lapic.c
24010 @@ -55,7 +55,7 @@
24011 #define APIC_BUS_CYCLE_NS 1
24012
24013 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
24014 -#define apic_debug(fmt, arg...)
24015 +#define apic_debug(fmt, arg...) do {} while (0)
24016
24017 #define APIC_LVT_NUM 6
24018 /* 14 is the version for Xeon and Pentium 8.4.8*/
24019 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
24020 index da20860..d19fdf5 100644
24021 --- a/arch/x86/kvm/paging_tmpl.h
24022 +++ b/arch/x86/kvm/paging_tmpl.h
24023 @@ -208,7 +208,7 @@ retry_walk:
24024 if (unlikely(kvm_is_error_hva(host_addr)))
24025 goto error;
24026
24027 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
24028 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
24029 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
24030 goto error;
24031 walker->ptep_user[walker->level - 1] = ptep_user;
24032 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
24033 index a14a6ea..dc86cf0 100644
24034 --- a/arch/x86/kvm/svm.c
24035 +++ b/arch/x86/kvm/svm.c
24036 @@ -3493,7 +3493,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
24037 int cpu = raw_smp_processor_id();
24038
24039 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
24040 +
24041 + pax_open_kernel();
24042 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
24043 + pax_close_kernel();
24044 +
24045 load_TR_desc();
24046 }
24047
24048 @@ -3894,6 +3898,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
24049 #endif
24050 #endif
24051
24052 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
24053 + __set_fs(current_thread_info()->addr_limit);
24054 +#endif
24055 +
24056 reload_tss(vcpu);
24057
24058 local_irq_disable();
24059 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
24060 index 260a919..65ddd76 100644
24061 --- a/arch/x86/kvm/vmx.c
24062 +++ b/arch/x86/kvm/vmx.c
24063 @@ -1311,12 +1311,12 @@ static void vmcs_write64(unsigned long field, u64 value)
24064 #endif
24065 }
24066
24067 -static void vmcs_clear_bits(unsigned long field, u32 mask)
24068 +static void vmcs_clear_bits(unsigned long field, unsigned long mask)
24069 {
24070 vmcs_writel(field, vmcs_readl(field) & ~mask);
24071 }
24072
24073 -static void vmcs_set_bits(unsigned long field, u32 mask)
24074 +static void vmcs_set_bits(unsigned long field, unsigned long mask)
24075 {
24076 vmcs_writel(field, vmcs_readl(field) | mask);
24077 }
24078 @@ -1517,7 +1517,11 @@ static void reload_tss(void)
24079 struct desc_struct *descs;
24080
24081 descs = (void *)gdt->address;
24082 +
24083 + pax_open_kernel();
24084 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
24085 + pax_close_kernel();
24086 +
24087 load_TR_desc();
24088 }
24089
24090 @@ -1741,6 +1745,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
24091 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
24092 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
24093
24094 +#ifdef CONFIG_PAX_PER_CPU_PGD
24095 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24096 +#endif
24097 +
24098 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
24099 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
24100 vmx->loaded_vmcs->cpu = cpu;
24101 @@ -2935,8 +2943,11 @@ static __init int hardware_setup(void)
24102 if (!cpu_has_vmx_flexpriority())
24103 flexpriority_enabled = 0;
24104
24105 - if (!cpu_has_vmx_tpr_shadow())
24106 - kvm_x86_ops->update_cr8_intercept = NULL;
24107 + if (!cpu_has_vmx_tpr_shadow()) {
24108 + pax_open_kernel();
24109 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
24110 + pax_close_kernel();
24111 + }
24112
24113 if (enable_ept && !cpu_has_vmx_ept_2m_page())
24114 kvm_disable_largepages();
24115 @@ -2947,13 +2958,15 @@ static __init int hardware_setup(void)
24116 if (!cpu_has_vmx_apicv())
24117 enable_apicv = 0;
24118
24119 + pax_open_kernel();
24120 if (enable_apicv)
24121 - kvm_x86_ops->update_cr8_intercept = NULL;
24122 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
24123 else {
24124 - kvm_x86_ops->hwapic_irr_update = NULL;
24125 - kvm_x86_ops->deliver_posted_interrupt = NULL;
24126 - kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
24127 + *(void **)&kvm_x86_ops->hwapic_irr_update = NULL;
24128 + *(void **)&kvm_x86_ops->deliver_posted_interrupt = NULL;
24129 + *(void **)&kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
24130 }
24131 + pax_close_kernel();
24132
24133 if (nested)
24134 nested_vmx_setup_ctls_msrs();
24135 @@ -4069,7 +4082,10 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
24136
24137 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
24138 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
24139 +
24140 +#ifndef CONFIG_PAX_PER_CPU_PGD
24141 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
24142 +#endif
24143
24144 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
24145 #ifdef CONFIG_X86_64
24146 @@ -4091,7 +4107,7 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
24147 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
24148 vmx->host_idt_base = dt.address;
24149
24150 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
24151 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
24152
24153 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
24154 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
24155 @@ -7023,6 +7039,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24156 "jmp 2f \n\t"
24157 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
24158 "2: "
24159 +
24160 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24161 + "ljmp %[cs],$3f\n\t"
24162 + "3: "
24163 +#endif
24164 +
24165 /* Save guest registers, load host registers, keep flags */
24166 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
24167 "pop %0 \n\t"
24168 @@ -7075,6 +7097,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24169 #endif
24170 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
24171 [wordsize]"i"(sizeof(ulong))
24172 +
24173 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24174 + ,[cs]"i"(__KERNEL_CS)
24175 +#endif
24176 +
24177 : "cc", "memory"
24178 #ifdef CONFIG_X86_64
24179 , "rax", "rbx", "rdi", "rsi"
24180 @@ -7088,7 +7115,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24181 if (debugctlmsr)
24182 update_debugctlmsr(debugctlmsr);
24183
24184 -#ifndef CONFIG_X86_64
24185 +#ifdef CONFIG_X86_32
24186 /*
24187 * The sysexit path does not restore ds/es, so we must set them to
24188 * a reasonable value ourselves.
24189 @@ -7097,8 +7124,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
24190 * may be executed in interrupt context, which saves and restore segments
24191 * around it, nullifying its effect.
24192 */
24193 - loadsegment(ds, __USER_DS);
24194 - loadsegment(es, __USER_DS);
24195 + loadsegment(ds, __KERNEL_DS);
24196 + loadsegment(es, __KERNEL_DS);
24197 + loadsegment(ss, __KERNEL_DS);
24198 +
24199 +#ifdef CONFIG_PAX_KERNEXEC
24200 + loadsegment(fs, __KERNEL_PERCPU);
24201 +#endif
24202 +
24203 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24204 + __set_fs(current_thread_info()->addr_limit);
24205 +#endif
24206 +
24207 #endif
24208
24209 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
24210 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
24211 index e8ba99c..ee9d7d9 100644
24212 --- a/arch/x86/kvm/x86.c
24213 +++ b/arch/x86/kvm/x86.c
24214 @@ -1725,8 +1725,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
24215 {
24216 struct kvm *kvm = vcpu->kvm;
24217 int lm = is_long_mode(vcpu);
24218 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24219 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24220 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
24221 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
24222 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
24223 : kvm->arch.xen_hvm_config.blob_size_32;
24224 u32 page_num = data & ~PAGE_MASK;
24225 @@ -2609,6 +2609,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
24226 if (n < msr_list.nmsrs)
24227 goto out;
24228 r = -EFAULT;
24229 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
24230 + goto out;
24231 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
24232 num_msrs_to_save * sizeof(u32)))
24233 goto out;
24234 @@ -5297,7 +5299,7 @@ static struct notifier_block pvclock_gtod_notifier = {
24235 };
24236 #endif
24237
24238 -int kvm_arch_init(void *opaque)
24239 +int kvm_arch_init(const void *opaque)
24240 {
24241 int r;
24242 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
24243 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
24244 index 7114c63..a1018fc 100644
24245 --- a/arch/x86/lguest/boot.c
24246 +++ b/arch/x86/lguest/boot.c
24247 @@ -1201,9 +1201,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
24248 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
24249 * Launcher to reboot us.
24250 */
24251 -static void lguest_restart(char *reason)
24252 +static __noreturn void lguest_restart(char *reason)
24253 {
24254 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
24255 + BUG();
24256 }
24257
24258 /*G:050
24259 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
24260 index 00933d5..3a64af9 100644
24261 --- a/arch/x86/lib/atomic64_386_32.S
24262 +++ b/arch/x86/lib/atomic64_386_32.S
24263 @@ -48,6 +48,10 @@ BEGIN(read)
24264 movl (v), %eax
24265 movl 4(v), %edx
24266 RET_ENDP
24267 +BEGIN(read_unchecked)
24268 + movl (v), %eax
24269 + movl 4(v), %edx
24270 +RET_ENDP
24271 #undef v
24272
24273 #define v %esi
24274 @@ -55,6 +59,10 @@ BEGIN(set)
24275 movl %ebx, (v)
24276 movl %ecx, 4(v)
24277 RET_ENDP
24278 +BEGIN(set_unchecked)
24279 + movl %ebx, (v)
24280 + movl %ecx, 4(v)
24281 +RET_ENDP
24282 #undef v
24283
24284 #define v %esi
24285 @@ -70,6 +78,20 @@ RET_ENDP
24286 BEGIN(add)
24287 addl %eax, (v)
24288 adcl %edx, 4(v)
24289 +
24290 +#ifdef CONFIG_PAX_REFCOUNT
24291 + jno 0f
24292 + subl %eax, (v)
24293 + sbbl %edx, 4(v)
24294 + int $4
24295 +0:
24296 + _ASM_EXTABLE(0b, 0b)
24297 +#endif
24298 +
24299 +RET_ENDP
24300 +BEGIN(add_unchecked)
24301 + addl %eax, (v)
24302 + adcl %edx, 4(v)
24303 RET_ENDP
24304 #undef v
24305
24306 @@ -77,6 +99,24 @@ RET_ENDP
24307 BEGIN(add_return)
24308 addl (v), %eax
24309 adcl 4(v), %edx
24310 +
24311 +#ifdef CONFIG_PAX_REFCOUNT
24312 + into
24313 +1234:
24314 + _ASM_EXTABLE(1234b, 2f)
24315 +#endif
24316 +
24317 + movl %eax, (v)
24318 + movl %edx, 4(v)
24319 +
24320 +#ifdef CONFIG_PAX_REFCOUNT
24321 +2:
24322 +#endif
24323 +
24324 +RET_ENDP
24325 +BEGIN(add_return_unchecked)
24326 + addl (v), %eax
24327 + adcl 4(v), %edx
24328 movl %eax, (v)
24329 movl %edx, 4(v)
24330 RET_ENDP
24331 @@ -86,6 +126,20 @@ RET_ENDP
24332 BEGIN(sub)
24333 subl %eax, (v)
24334 sbbl %edx, 4(v)
24335 +
24336 +#ifdef CONFIG_PAX_REFCOUNT
24337 + jno 0f
24338 + addl %eax, (v)
24339 + adcl %edx, 4(v)
24340 + int $4
24341 +0:
24342 + _ASM_EXTABLE(0b, 0b)
24343 +#endif
24344 +
24345 +RET_ENDP
24346 +BEGIN(sub_unchecked)
24347 + subl %eax, (v)
24348 + sbbl %edx, 4(v)
24349 RET_ENDP
24350 #undef v
24351
24352 @@ -96,6 +150,27 @@ BEGIN(sub_return)
24353 sbbl $0, %edx
24354 addl (v), %eax
24355 adcl 4(v), %edx
24356 +
24357 +#ifdef CONFIG_PAX_REFCOUNT
24358 + into
24359 +1234:
24360 + _ASM_EXTABLE(1234b, 2f)
24361 +#endif
24362 +
24363 + movl %eax, (v)
24364 + movl %edx, 4(v)
24365 +
24366 +#ifdef CONFIG_PAX_REFCOUNT
24367 +2:
24368 +#endif
24369 +
24370 +RET_ENDP
24371 +BEGIN(sub_return_unchecked)
24372 + negl %edx
24373 + negl %eax
24374 + sbbl $0, %edx
24375 + addl (v), %eax
24376 + adcl 4(v), %edx
24377 movl %eax, (v)
24378 movl %edx, 4(v)
24379 RET_ENDP
24380 @@ -105,6 +180,20 @@ RET_ENDP
24381 BEGIN(inc)
24382 addl $1, (v)
24383 adcl $0, 4(v)
24384 +
24385 +#ifdef CONFIG_PAX_REFCOUNT
24386 + jno 0f
24387 + subl $1, (v)
24388 + sbbl $0, 4(v)
24389 + int $4
24390 +0:
24391 + _ASM_EXTABLE(0b, 0b)
24392 +#endif
24393 +
24394 +RET_ENDP
24395 +BEGIN(inc_unchecked)
24396 + addl $1, (v)
24397 + adcl $0, 4(v)
24398 RET_ENDP
24399 #undef v
24400
24401 @@ -114,6 +203,26 @@ BEGIN(inc_return)
24402 movl 4(v), %edx
24403 addl $1, %eax
24404 adcl $0, %edx
24405 +
24406 +#ifdef CONFIG_PAX_REFCOUNT
24407 + into
24408 +1234:
24409 + _ASM_EXTABLE(1234b, 2f)
24410 +#endif
24411 +
24412 + movl %eax, (v)
24413 + movl %edx, 4(v)
24414 +
24415 +#ifdef CONFIG_PAX_REFCOUNT
24416 +2:
24417 +#endif
24418 +
24419 +RET_ENDP
24420 +BEGIN(inc_return_unchecked)
24421 + movl (v), %eax
24422 + movl 4(v), %edx
24423 + addl $1, %eax
24424 + adcl $0, %edx
24425 movl %eax, (v)
24426 movl %edx, 4(v)
24427 RET_ENDP
24428 @@ -123,6 +232,20 @@ RET_ENDP
24429 BEGIN(dec)
24430 subl $1, (v)
24431 sbbl $0, 4(v)
24432 +
24433 +#ifdef CONFIG_PAX_REFCOUNT
24434 + jno 0f
24435 + addl $1, (v)
24436 + adcl $0, 4(v)
24437 + int $4
24438 +0:
24439 + _ASM_EXTABLE(0b, 0b)
24440 +#endif
24441 +
24442 +RET_ENDP
24443 +BEGIN(dec_unchecked)
24444 + subl $1, (v)
24445 + sbbl $0, 4(v)
24446 RET_ENDP
24447 #undef v
24448
24449 @@ -132,6 +255,26 @@ BEGIN(dec_return)
24450 movl 4(v), %edx
24451 subl $1, %eax
24452 sbbl $0, %edx
24453 +
24454 +#ifdef CONFIG_PAX_REFCOUNT
24455 + into
24456 +1234:
24457 + _ASM_EXTABLE(1234b, 2f)
24458 +#endif
24459 +
24460 + movl %eax, (v)
24461 + movl %edx, 4(v)
24462 +
24463 +#ifdef CONFIG_PAX_REFCOUNT
24464 +2:
24465 +#endif
24466 +
24467 +RET_ENDP
24468 +BEGIN(dec_return_unchecked)
24469 + movl (v), %eax
24470 + movl 4(v), %edx
24471 + subl $1, %eax
24472 + sbbl $0, %edx
24473 movl %eax, (v)
24474 movl %edx, 4(v)
24475 RET_ENDP
24476 @@ -143,6 +286,13 @@ BEGIN(add_unless)
24477 adcl %edx, %edi
24478 addl (v), %eax
24479 adcl 4(v), %edx
24480 +
24481 +#ifdef CONFIG_PAX_REFCOUNT
24482 + into
24483 +1234:
24484 + _ASM_EXTABLE(1234b, 2f)
24485 +#endif
24486 +
24487 cmpl %eax, %ecx
24488 je 3f
24489 1:
24490 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
24491 1:
24492 addl $1, %eax
24493 adcl $0, %edx
24494 +
24495 +#ifdef CONFIG_PAX_REFCOUNT
24496 + into
24497 +1234:
24498 + _ASM_EXTABLE(1234b, 2f)
24499 +#endif
24500 +
24501 movl %eax, (v)
24502 movl %edx, 4(v)
24503 movl $1, %eax
24504 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
24505 movl 4(v), %edx
24506 subl $1, %eax
24507 sbbl $0, %edx
24508 +
24509 +#ifdef CONFIG_PAX_REFCOUNT
24510 + into
24511 +1234:
24512 + _ASM_EXTABLE(1234b, 1f)
24513 +#endif
24514 +
24515 js 1f
24516 movl %eax, (v)
24517 movl %edx, 4(v)
24518 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
24519 index f5cc9eb..51fa319 100644
24520 --- a/arch/x86/lib/atomic64_cx8_32.S
24521 +++ b/arch/x86/lib/atomic64_cx8_32.S
24522 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
24523 CFI_STARTPROC
24524
24525 read64 %ecx
24526 + pax_force_retaddr
24527 ret
24528 CFI_ENDPROC
24529 ENDPROC(atomic64_read_cx8)
24530
24531 +ENTRY(atomic64_read_unchecked_cx8)
24532 + CFI_STARTPROC
24533 +
24534 + read64 %ecx
24535 + pax_force_retaddr
24536 + ret
24537 + CFI_ENDPROC
24538 +ENDPROC(atomic64_read_unchecked_cx8)
24539 +
24540 ENTRY(atomic64_set_cx8)
24541 CFI_STARTPROC
24542
24543 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
24544 cmpxchg8b (%esi)
24545 jne 1b
24546
24547 + pax_force_retaddr
24548 ret
24549 CFI_ENDPROC
24550 ENDPROC(atomic64_set_cx8)
24551
24552 +ENTRY(atomic64_set_unchecked_cx8)
24553 + CFI_STARTPROC
24554 +
24555 +1:
24556 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
24557 + * are atomic on 586 and newer */
24558 + cmpxchg8b (%esi)
24559 + jne 1b
24560 +
24561 + pax_force_retaddr
24562 + ret
24563 + CFI_ENDPROC
24564 +ENDPROC(atomic64_set_unchecked_cx8)
24565 +
24566 ENTRY(atomic64_xchg_cx8)
24567 CFI_STARTPROC
24568
24569 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
24570 cmpxchg8b (%esi)
24571 jne 1b
24572
24573 + pax_force_retaddr
24574 ret
24575 CFI_ENDPROC
24576 ENDPROC(atomic64_xchg_cx8)
24577
24578 -.macro addsub_return func ins insc
24579 -ENTRY(atomic64_\func\()_return_cx8)
24580 +.macro addsub_return func ins insc unchecked=""
24581 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24582 CFI_STARTPROC
24583 SAVE ebp
24584 SAVE ebx
24585 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
24586 movl %edx, %ecx
24587 \ins\()l %esi, %ebx
24588 \insc\()l %edi, %ecx
24589 +
24590 +.ifb \unchecked
24591 +#ifdef CONFIG_PAX_REFCOUNT
24592 + into
24593 +2:
24594 + _ASM_EXTABLE(2b, 3f)
24595 +#endif
24596 +.endif
24597 +
24598 LOCK_PREFIX
24599 cmpxchg8b (%ebp)
24600 jne 1b
24601 -
24602 -10:
24603 movl %ebx, %eax
24604 movl %ecx, %edx
24605 +
24606 +.ifb \unchecked
24607 +#ifdef CONFIG_PAX_REFCOUNT
24608 +3:
24609 +#endif
24610 +.endif
24611 +
24612 RESTORE edi
24613 RESTORE esi
24614 RESTORE ebx
24615 RESTORE ebp
24616 + pax_force_retaddr
24617 ret
24618 CFI_ENDPROC
24619 -ENDPROC(atomic64_\func\()_return_cx8)
24620 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24621 .endm
24622
24623 addsub_return add add adc
24624 addsub_return sub sub sbb
24625 +addsub_return add add adc _unchecked
24626 +addsub_return sub sub sbb _unchecked
24627
24628 -.macro incdec_return func ins insc
24629 -ENTRY(atomic64_\func\()_return_cx8)
24630 +.macro incdec_return func ins insc unchecked=""
24631 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
24632 CFI_STARTPROC
24633 SAVE ebx
24634
24635 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
24636 movl %edx, %ecx
24637 \ins\()l $1, %ebx
24638 \insc\()l $0, %ecx
24639 +
24640 +.ifb \unchecked
24641 +#ifdef CONFIG_PAX_REFCOUNT
24642 + into
24643 +2:
24644 + _ASM_EXTABLE(2b, 3f)
24645 +#endif
24646 +.endif
24647 +
24648 LOCK_PREFIX
24649 cmpxchg8b (%esi)
24650 jne 1b
24651
24652 -10:
24653 movl %ebx, %eax
24654 movl %ecx, %edx
24655 +
24656 +.ifb \unchecked
24657 +#ifdef CONFIG_PAX_REFCOUNT
24658 +3:
24659 +#endif
24660 +.endif
24661 +
24662 RESTORE ebx
24663 + pax_force_retaddr
24664 ret
24665 CFI_ENDPROC
24666 -ENDPROC(atomic64_\func\()_return_cx8)
24667 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
24668 .endm
24669
24670 incdec_return inc add adc
24671 incdec_return dec sub sbb
24672 +incdec_return inc add adc _unchecked
24673 +incdec_return dec sub sbb _unchecked
24674
24675 ENTRY(atomic64_dec_if_positive_cx8)
24676 CFI_STARTPROC
24677 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
24678 movl %edx, %ecx
24679 subl $1, %ebx
24680 sbb $0, %ecx
24681 +
24682 +#ifdef CONFIG_PAX_REFCOUNT
24683 + into
24684 +1234:
24685 + _ASM_EXTABLE(1234b, 2f)
24686 +#endif
24687 +
24688 js 2f
24689 LOCK_PREFIX
24690 cmpxchg8b (%esi)
24691 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
24692 movl %ebx, %eax
24693 movl %ecx, %edx
24694 RESTORE ebx
24695 + pax_force_retaddr
24696 ret
24697 CFI_ENDPROC
24698 ENDPROC(atomic64_dec_if_positive_cx8)
24699 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
24700 movl %edx, %ecx
24701 addl %ebp, %ebx
24702 adcl %edi, %ecx
24703 +
24704 +#ifdef CONFIG_PAX_REFCOUNT
24705 + into
24706 +1234:
24707 + _ASM_EXTABLE(1234b, 3f)
24708 +#endif
24709 +
24710 LOCK_PREFIX
24711 cmpxchg8b (%esi)
24712 jne 1b
24713 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
24714 CFI_ADJUST_CFA_OFFSET -8
24715 RESTORE ebx
24716 RESTORE ebp
24717 + pax_force_retaddr
24718 ret
24719 4:
24720 cmpl %edx, 4(%esp)
24721 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
24722 xorl %ecx, %ecx
24723 addl $1, %ebx
24724 adcl %edx, %ecx
24725 +
24726 +#ifdef CONFIG_PAX_REFCOUNT
24727 + into
24728 +1234:
24729 + _ASM_EXTABLE(1234b, 3f)
24730 +#endif
24731 +
24732 LOCK_PREFIX
24733 cmpxchg8b (%esi)
24734 jne 1b
24735 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
24736 movl $1, %eax
24737 3:
24738 RESTORE ebx
24739 + pax_force_retaddr
24740 ret
24741 CFI_ENDPROC
24742 ENDPROC(atomic64_inc_not_zero_cx8)
24743 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
24744 index e78b8ee..7e173a8 100644
24745 --- a/arch/x86/lib/checksum_32.S
24746 +++ b/arch/x86/lib/checksum_32.S
24747 @@ -29,7 +29,8 @@
24748 #include <asm/dwarf2.h>
24749 #include <asm/errno.h>
24750 #include <asm/asm.h>
24751 -
24752 +#include <asm/segment.h>
24753 +
24754 /*
24755 * computes a partial checksum, e.g. for TCP/UDP fragments
24756 */
24757 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
24758
24759 #define ARGBASE 16
24760 #define FP 12
24761 -
24762 -ENTRY(csum_partial_copy_generic)
24763 +
24764 +ENTRY(csum_partial_copy_generic_to_user)
24765 CFI_STARTPROC
24766 +
24767 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24768 + pushl_cfi %gs
24769 + popl_cfi %es
24770 + jmp csum_partial_copy_generic
24771 +#endif
24772 +
24773 +ENTRY(csum_partial_copy_generic_from_user)
24774 +
24775 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24776 + pushl_cfi %gs
24777 + popl_cfi %ds
24778 +#endif
24779 +
24780 +ENTRY(csum_partial_copy_generic)
24781 subl $4,%esp
24782 CFI_ADJUST_CFA_OFFSET 4
24783 pushl_cfi %edi
24784 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
24785 jmp 4f
24786 SRC(1: movw (%esi), %bx )
24787 addl $2, %esi
24788 -DST( movw %bx, (%edi) )
24789 +DST( movw %bx, %es:(%edi) )
24790 addl $2, %edi
24791 addw %bx, %ax
24792 adcl $0, %eax
24793 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
24794 SRC(1: movl (%esi), %ebx )
24795 SRC( movl 4(%esi), %edx )
24796 adcl %ebx, %eax
24797 -DST( movl %ebx, (%edi) )
24798 +DST( movl %ebx, %es:(%edi) )
24799 adcl %edx, %eax
24800 -DST( movl %edx, 4(%edi) )
24801 +DST( movl %edx, %es:4(%edi) )
24802
24803 SRC( movl 8(%esi), %ebx )
24804 SRC( movl 12(%esi), %edx )
24805 adcl %ebx, %eax
24806 -DST( movl %ebx, 8(%edi) )
24807 +DST( movl %ebx, %es:8(%edi) )
24808 adcl %edx, %eax
24809 -DST( movl %edx, 12(%edi) )
24810 +DST( movl %edx, %es:12(%edi) )
24811
24812 SRC( movl 16(%esi), %ebx )
24813 SRC( movl 20(%esi), %edx )
24814 adcl %ebx, %eax
24815 -DST( movl %ebx, 16(%edi) )
24816 +DST( movl %ebx, %es:16(%edi) )
24817 adcl %edx, %eax
24818 -DST( movl %edx, 20(%edi) )
24819 +DST( movl %edx, %es:20(%edi) )
24820
24821 SRC( movl 24(%esi), %ebx )
24822 SRC( movl 28(%esi), %edx )
24823 adcl %ebx, %eax
24824 -DST( movl %ebx, 24(%edi) )
24825 +DST( movl %ebx, %es:24(%edi) )
24826 adcl %edx, %eax
24827 -DST( movl %edx, 28(%edi) )
24828 +DST( movl %edx, %es:28(%edi) )
24829
24830 lea 32(%esi), %esi
24831 lea 32(%edi), %edi
24832 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
24833 shrl $2, %edx # This clears CF
24834 SRC(3: movl (%esi), %ebx )
24835 adcl %ebx, %eax
24836 -DST( movl %ebx, (%edi) )
24837 +DST( movl %ebx, %es:(%edi) )
24838 lea 4(%esi), %esi
24839 lea 4(%edi), %edi
24840 dec %edx
24841 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
24842 jb 5f
24843 SRC( movw (%esi), %cx )
24844 leal 2(%esi), %esi
24845 -DST( movw %cx, (%edi) )
24846 +DST( movw %cx, %es:(%edi) )
24847 leal 2(%edi), %edi
24848 je 6f
24849 shll $16,%ecx
24850 SRC(5: movb (%esi), %cl )
24851 -DST( movb %cl, (%edi) )
24852 +DST( movb %cl, %es:(%edi) )
24853 6: addl %ecx, %eax
24854 adcl $0, %eax
24855 7:
24856 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
24857
24858 6001:
24859 movl ARGBASE+20(%esp), %ebx # src_err_ptr
24860 - movl $-EFAULT, (%ebx)
24861 + movl $-EFAULT, %ss:(%ebx)
24862
24863 # zero the complete destination - computing the rest
24864 # is too much work
24865 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
24866
24867 6002:
24868 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
24869 - movl $-EFAULT,(%ebx)
24870 + movl $-EFAULT,%ss:(%ebx)
24871 jmp 5000b
24872
24873 .previous
24874
24875 + pushl_cfi %ss
24876 + popl_cfi %ds
24877 + pushl_cfi %ss
24878 + popl_cfi %es
24879 popl_cfi %ebx
24880 CFI_RESTORE ebx
24881 popl_cfi %esi
24882 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
24883 popl_cfi %ecx # equivalent to addl $4,%esp
24884 ret
24885 CFI_ENDPROC
24886 -ENDPROC(csum_partial_copy_generic)
24887 +ENDPROC(csum_partial_copy_generic_to_user)
24888
24889 #else
24890
24891 /* Version for PentiumII/PPro */
24892
24893 #define ROUND1(x) \
24894 + nop; nop; nop; \
24895 SRC(movl x(%esi), %ebx ) ; \
24896 addl %ebx, %eax ; \
24897 - DST(movl %ebx, x(%edi) ) ;
24898 + DST(movl %ebx, %es:x(%edi)) ;
24899
24900 #define ROUND(x) \
24901 + nop; nop; nop; \
24902 SRC(movl x(%esi), %ebx ) ; \
24903 adcl %ebx, %eax ; \
24904 - DST(movl %ebx, x(%edi) ) ;
24905 + DST(movl %ebx, %es:x(%edi)) ;
24906
24907 #define ARGBASE 12
24908 -
24909 -ENTRY(csum_partial_copy_generic)
24910 +
24911 +ENTRY(csum_partial_copy_generic_to_user)
24912 CFI_STARTPROC
24913 +
24914 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24915 + pushl_cfi %gs
24916 + popl_cfi %es
24917 + jmp csum_partial_copy_generic
24918 +#endif
24919 +
24920 +ENTRY(csum_partial_copy_generic_from_user)
24921 +
24922 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24923 + pushl_cfi %gs
24924 + popl_cfi %ds
24925 +#endif
24926 +
24927 +ENTRY(csum_partial_copy_generic)
24928 pushl_cfi %ebx
24929 CFI_REL_OFFSET ebx, 0
24930 pushl_cfi %edi
24931 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
24932 subl %ebx, %edi
24933 lea -1(%esi),%edx
24934 andl $-32,%edx
24935 - lea 3f(%ebx,%ebx), %ebx
24936 + lea 3f(%ebx,%ebx,2), %ebx
24937 testl %esi, %esi
24938 jmp *%ebx
24939 1: addl $64,%esi
24940 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
24941 jb 5f
24942 SRC( movw (%esi), %dx )
24943 leal 2(%esi), %esi
24944 -DST( movw %dx, (%edi) )
24945 +DST( movw %dx, %es:(%edi) )
24946 leal 2(%edi), %edi
24947 je 6f
24948 shll $16,%edx
24949 5:
24950 SRC( movb (%esi), %dl )
24951 -DST( movb %dl, (%edi) )
24952 +DST( movb %dl, %es:(%edi) )
24953 6: addl %edx, %eax
24954 adcl $0, %eax
24955 7:
24956 .section .fixup, "ax"
24957 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
24958 - movl $-EFAULT, (%ebx)
24959 + movl $-EFAULT, %ss:(%ebx)
24960 # zero the complete destination (computing the rest is too much work)
24961 movl ARGBASE+8(%esp),%edi # dst
24962 movl ARGBASE+12(%esp),%ecx # len
24963 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
24964 rep; stosb
24965 jmp 7b
24966 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
24967 - movl $-EFAULT, (%ebx)
24968 + movl $-EFAULT, %ss:(%ebx)
24969 jmp 7b
24970 .previous
24971
24972 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24973 + pushl_cfi %ss
24974 + popl_cfi %ds
24975 + pushl_cfi %ss
24976 + popl_cfi %es
24977 +#endif
24978 +
24979 popl_cfi %esi
24980 CFI_RESTORE esi
24981 popl_cfi %edi
24982 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
24983 CFI_RESTORE ebx
24984 ret
24985 CFI_ENDPROC
24986 -ENDPROC(csum_partial_copy_generic)
24987 +ENDPROC(csum_partial_copy_generic_to_user)
24988
24989 #undef ROUND
24990 #undef ROUND1
24991 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
24992 index f2145cf..cea889d 100644
24993 --- a/arch/x86/lib/clear_page_64.S
24994 +++ b/arch/x86/lib/clear_page_64.S
24995 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
24996 movl $4096/8,%ecx
24997 xorl %eax,%eax
24998 rep stosq
24999 + pax_force_retaddr
25000 ret
25001 CFI_ENDPROC
25002 ENDPROC(clear_page_c)
25003 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
25004 movl $4096,%ecx
25005 xorl %eax,%eax
25006 rep stosb
25007 + pax_force_retaddr
25008 ret
25009 CFI_ENDPROC
25010 ENDPROC(clear_page_c_e)
25011 @@ -43,6 +45,7 @@ ENTRY(clear_page)
25012 leaq 64(%rdi),%rdi
25013 jnz .Lloop
25014 nop
25015 + pax_force_retaddr
25016 ret
25017 CFI_ENDPROC
25018 .Lclear_page_end:
25019 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
25020
25021 #include <asm/cpufeature.h>
25022
25023 - .section .altinstr_replacement,"ax"
25024 + .section .altinstr_replacement,"a"
25025 1: .byte 0xeb /* jmp <disp8> */
25026 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
25027 2: .byte 0xeb /* jmp <disp8> */
25028 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
25029 index 1e572c5..2a162cd 100644
25030 --- a/arch/x86/lib/cmpxchg16b_emu.S
25031 +++ b/arch/x86/lib/cmpxchg16b_emu.S
25032 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
25033
25034 popf
25035 mov $1, %al
25036 + pax_force_retaddr
25037 ret
25038
25039 not_same:
25040 popf
25041 xor %al,%al
25042 + pax_force_retaddr
25043 ret
25044
25045 CFI_ENDPROC
25046 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
25047 index 176cca6..1166c50 100644
25048 --- a/arch/x86/lib/copy_page_64.S
25049 +++ b/arch/x86/lib/copy_page_64.S
25050 @@ -9,6 +9,7 @@ copy_page_rep:
25051 CFI_STARTPROC
25052 movl $4096/8, %ecx
25053 rep movsq
25054 + pax_force_retaddr
25055 ret
25056 CFI_ENDPROC
25057 ENDPROC(copy_page_rep)
25058 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
25059
25060 ENTRY(copy_page)
25061 CFI_STARTPROC
25062 - subq $2*8, %rsp
25063 - CFI_ADJUST_CFA_OFFSET 2*8
25064 + subq $3*8, %rsp
25065 + CFI_ADJUST_CFA_OFFSET 3*8
25066 movq %rbx, (%rsp)
25067 CFI_REL_OFFSET rbx, 0
25068 movq %r12, 1*8(%rsp)
25069 CFI_REL_OFFSET r12, 1*8
25070 + movq %r13, 2*8(%rsp)
25071 + CFI_REL_OFFSET r13, 2*8
25072
25073 movl $(4096/64)-5, %ecx
25074 .p2align 4
25075 @@ -36,7 +39,7 @@ ENTRY(copy_page)
25076 movq 0x8*2(%rsi), %rdx
25077 movq 0x8*3(%rsi), %r8
25078 movq 0x8*4(%rsi), %r9
25079 - movq 0x8*5(%rsi), %r10
25080 + movq 0x8*5(%rsi), %r13
25081 movq 0x8*6(%rsi), %r11
25082 movq 0x8*7(%rsi), %r12
25083
25084 @@ -47,7 +50,7 @@ ENTRY(copy_page)
25085 movq %rdx, 0x8*2(%rdi)
25086 movq %r8, 0x8*3(%rdi)
25087 movq %r9, 0x8*4(%rdi)
25088 - movq %r10, 0x8*5(%rdi)
25089 + movq %r13, 0x8*5(%rdi)
25090 movq %r11, 0x8*6(%rdi)
25091 movq %r12, 0x8*7(%rdi)
25092
25093 @@ -66,7 +69,7 @@ ENTRY(copy_page)
25094 movq 0x8*2(%rsi), %rdx
25095 movq 0x8*3(%rsi), %r8
25096 movq 0x8*4(%rsi), %r9
25097 - movq 0x8*5(%rsi), %r10
25098 + movq 0x8*5(%rsi), %r13
25099 movq 0x8*6(%rsi), %r11
25100 movq 0x8*7(%rsi), %r12
25101
25102 @@ -75,7 +78,7 @@ ENTRY(copy_page)
25103 movq %rdx, 0x8*2(%rdi)
25104 movq %r8, 0x8*3(%rdi)
25105 movq %r9, 0x8*4(%rdi)
25106 - movq %r10, 0x8*5(%rdi)
25107 + movq %r13, 0x8*5(%rdi)
25108 movq %r11, 0x8*6(%rdi)
25109 movq %r12, 0x8*7(%rdi)
25110
25111 @@ -87,8 +90,11 @@ ENTRY(copy_page)
25112 CFI_RESTORE rbx
25113 movq 1*8(%rsp), %r12
25114 CFI_RESTORE r12
25115 - addq $2*8, %rsp
25116 - CFI_ADJUST_CFA_OFFSET -2*8
25117 + movq 2*8(%rsp), %r13
25118 + CFI_RESTORE r13
25119 + addq $3*8, %rsp
25120 + CFI_ADJUST_CFA_OFFSET -3*8
25121 + pax_force_retaddr
25122 ret
25123 .Lcopy_page_end:
25124 CFI_ENDPROC
25125 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
25126
25127 #include <asm/cpufeature.h>
25128
25129 - .section .altinstr_replacement,"ax"
25130 + .section .altinstr_replacement,"a"
25131 1: .byte 0xeb /* jmp <disp8> */
25132 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
25133 2:
25134 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
25135 index a30ca15..d25fab6 100644
25136 --- a/arch/x86/lib/copy_user_64.S
25137 +++ b/arch/x86/lib/copy_user_64.S
25138 @@ -18,6 +18,7 @@
25139 #include <asm/alternative-asm.h>
25140 #include <asm/asm.h>
25141 #include <asm/smap.h>
25142 +#include <asm/pgtable.h>
25143
25144 /*
25145 * By placing feature2 after feature1 in altinstructions section, we logically
25146 @@ -31,7 +32,7 @@
25147 .byte 0xe9 /* 32bit jump */
25148 .long \orig-1f /* by default jump to orig */
25149 1:
25150 - .section .altinstr_replacement,"ax"
25151 + .section .altinstr_replacement,"a"
25152 2: .byte 0xe9 /* near jump with 32bit immediate */
25153 .long \alt1-1b /* offset */ /* or alternatively to alt1 */
25154 3: .byte 0xe9 /* near jump with 32bit immediate */
25155 @@ -70,47 +71,20 @@
25156 #endif
25157 .endm
25158
25159 -/* Standard copy_to_user with segment limit checking */
25160 -ENTRY(_copy_to_user)
25161 - CFI_STARTPROC
25162 - GET_THREAD_INFO(%rax)
25163 - movq %rdi,%rcx
25164 - addq %rdx,%rcx
25165 - jc bad_to_user
25166 - cmpq TI_addr_limit(%rax),%rcx
25167 - ja bad_to_user
25168 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25169 - copy_user_generic_unrolled,copy_user_generic_string, \
25170 - copy_user_enhanced_fast_string
25171 - CFI_ENDPROC
25172 -ENDPROC(_copy_to_user)
25173 -
25174 -/* Standard copy_from_user with segment limit checking */
25175 -ENTRY(_copy_from_user)
25176 - CFI_STARTPROC
25177 - GET_THREAD_INFO(%rax)
25178 - movq %rsi,%rcx
25179 - addq %rdx,%rcx
25180 - jc bad_from_user
25181 - cmpq TI_addr_limit(%rax),%rcx
25182 - ja bad_from_user
25183 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
25184 - copy_user_generic_unrolled,copy_user_generic_string, \
25185 - copy_user_enhanced_fast_string
25186 - CFI_ENDPROC
25187 -ENDPROC(_copy_from_user)
25188 -
25189 .section .fixup,"ax"
25190 /* must zero dest */
25191 ENTRY(bad_from_user)
25192 bad_from_user:
25193 CFI_STARTPROC
25194 + testl %edx,%edx
25195 + js bad_to_user
25196 movl %edx,%ecx
25197 xorl %eax,%eax
25198 rep
25199 stosb
25200 bad_to_user:
25201 movl %edx,%eax
25202 + pax_force_retaddr
25203 ret
25204 CFI_ENDPROC
25205 ENDPROC(bad_from_user)
25206 @@ -141,19 +115,19 @@ ENTRY(copy_user_generic_unrolled)
25207 jz 17f
25208 1: movq (%rsi),%r8
25209 2: movq 1*8(%rsi),%r9
25210 -3: movq 2*8(%rsi),%r10
25211 +3: movq 2*8(%rsi),%rax
25212 4: movq 3*8(%rsi),%r11
25213 5: movq %r8,(%rdi)
25214 6: movq %r9,1*8(%rdi)
25215 -7: movq %r10,2*8(%rdi)
25216 +7: movq %rax,2*8(%rdi)
25217 8: movq %r11,3*8(%rdi)
25218 9: movq 4*8(%rsi),%r8
25219 10: movq 5*8(%rsi),%r9
25220 -11: movq 6*8(%rsi),%r10
25221 +11: movq 6*8(%rsi),%rax
25222 12: movq 7*8(%rsi),%r11
25223 13: movq %r8,4*8(%rdi)
25224 14: movq %r9,5*8(%rdi)
25225 -15: movq %r10,6*8(%rdi)
25226 +15: movq %rax,6*8(%rdi)
25227 16: movq %r11,7*8(%rdi)
25228 leaq 64(%rsi),%rsi
25229 leaq 64(%rdi),%rdi
25230 @@ -180,6 +154,7 @@ ENTRY(copy_user_generic_unrolled)
25231 jnz 21b
25232 23: xor %eax,%eax
25233 ASM_CLAC
25234 + pax_force_retaddr
25235 ret
25236
25237 .section .fixup,"ax"
25238 @@ -251,6 +226,7 @@ ENTRY(copy_user_generic_string)
25239 movsb
25240 4: xorl %eax,%eax
25241 ASM_CLAC
25242 + pax_force_retaddr
25243 ret
25244
25245 .section .fixup,"ax"
25246 @@ -286,6 +262,7 @@ ENTRY(copy_user_enhanced_fast_string)
25247 movsb
25248 2: xorl %eax,%eax
25249 ASM_CLAC
25250 + pax_force_retaddr
25251 ret
25252
25253 .section .fixup,"ax"
25254 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
25255 index 6a4f43c..f08b4a2 100644
25256 --- a/arch/x86/lib/copy_user_nocache_64.S
25257 +++ b/arch/x86/lib/copy_user_nocache_64.S
25258 @@ -8,6 +8,7 @@
25259
25260 #include <linux/linkage.h>
25261 #include <asm/dwarf2.h>
25262 +#include <asm/alternative-asm.h>
25263
25264 #define FIX_ALIGNMENT 1
25265
25266 @@ -16,6 +17,7 @@
25267 #include <asm/thread_info.h>
25268 #include <asm/asm.h>
25269 #include <asm/smap.h>
25270 +#include <asm/pgtable.h>
25271
25272 .macro ALIGN_DESTINATION
25273 #ifdef FIX_ALIGNMENT
25274 @@ -49,6 +51,15 @@
25275 */
25276 ENTRY(__copy_user_nocache)
25277 CFI_STARTPROC
25278 +
25279 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25280 + mov pax_user_shadow_base,%rcx
25281 + cmp %rcx,%rsi
25282 + jae 1f
25283 + add %rcx,%rsi
25284 +1:
25285 +#endif
25286 +
25287 ASM_STAC
25288 cmpl $8,%edx
25289 jb 20f /* less then 8 bytes, go to byte copy loop */
25290 @@ -59,19 +70,19 @@ ENTRY(__copy_user_nocache)
25291 jz 17f
25292 1: movq (%rsi),%r8
25293 2: movq 1*8(%rsi),%r9
25294 -3: movq 2*8(%rsi),%r10
25295 +3: movq 2*8(%rsi),%rax
25296 4: movq 3*8(%rsi),%r11
25297 5: movnti %r8,(%rdi)
25298 6: movnti %r9,1*8(%rdi)
25299 -7: movnti %r10,2*8(%rdi)
25300 +7: movnti %rax,2*8(%rdi)
25301 8: movnti %r11,3*8(%rdi)
25302 9: movq 4*8(%rsi),%r8
25303 10: movq 5*8(%rsi),%r9
25304 -11: movq 6*8(%rsi),%r10
25305 +11: movq 6*8(%rsi),%rax
25306 12: movq 7*8(%rsi),%r11
25307 13: movnti %r8,4*8(%rdi)
25308 14: movnti %r9,5*8(%rdi)
25309 -15: movnti %r10,6*8(%rdi)
25310 +15: movnti %rax,6*8(%rdi)
25311 16: movnti %r11,7*8(%rdi)
25312 leaq 64(%rsi),%rsi
25313 leaq 64(%rdi),%rdi
25314 @@ -99,6 +110,7 @@ ENTRY(__copy_user_nocache)
25315 23: xorl %eax,%eax
25316 ASM_CLAC
25317 sfence
25318 + pax_force_retaddr
25319 ret
25320
25321 .section .fixup,"ax"
25322 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
25323 index 2419d5f..953ee51 100644
25324 --- a/arch/x86/lib/csum-copy_64.S
25325 +++ b/arch/x86/lib/csum-copy_64.S
25326 @@ -9,6 +9,7 @@
25327 #include <asm/dwarf2.h>
25328 #include <asm/errno.h>
25329 #include <asm/asm.h>
25330 +#include <asm/alternative-asm.h>
25331
25332 /*
25333 * Checksum copy with exception handling.
25334 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
25335 CFI_RESTORE rbp
25336 addq $7*8, %rsp
25337 CFI_ADJUST_CFA_OFFSET -7*8
25338 + pax_force_retaddr 0, 1
25339 ret
25340 CFI_RESTORE_STATE
25341
25342 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
25343 index 25b7ae8..169fafc 100644
25344 --- a/arch/x86/lib/csum-wrappers_64.c
25345 +++ b/arch/x86/lib/csum-wrappers_64.c
25346 @@ -52,7 +52,7 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
25347 len -= 2;
25348 }
25349 }
25350 - isum = csum_partial_copy_generic((__force const void *)src,
25351 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
25352 dst, len, isum, errp, NULL);
25353 if (unlikely(*errp))
25354 goto out_err;
25355 @@ -105,7 +105,7 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
25356 }
25357
25358 *errp = 0;
25359 - return csum_partial_copy_generic(src, (void __force *)dst,
25360 + return csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
25361 len, isum, NULL, errp);
25362 }
25363 EXPORT_SYMBOL(csum_partial_copy_to_user);
25364 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
25365 index a451235..79fb5cf 100644
25366 --- a/arch/x86/lib/getuser.S
25367 +++ b/arch/x86/lib/getuser.S
25368 @@ -33,17 +33,40 @@
25369 #include <asm/thread_info.h>
25370 #include <asm/asm.h>
25371 #include <asm/smap.h>
25372 +#include <asm/segment.h>
25373 +#include <asm/pgtable.h>
25374 +#include <asm/alternative-asm.h>
25375 +
25376 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
25377 +#define __copyuser_seg gs;
25378 +#else
25379 +#define __copyuser_seg
25380 +#endif
25381
25382 .text
25383 ENTRY(__get_user_1)
25384 CFI_STARTPROC
25385 +
25386 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25387 GET_THREAD_INFO(%_ASM_DX)
25388 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25389 jae bad_get_user
25390 ASM_STAC
25391 -1: movzbl (%_ASM_AX),%edx
25392 +
25393 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25394 + mov pax_user_shadow_base,%_ASM_DX
25395 + cmp %_ASM_DX,%_ASM_AX
25396 + jae 1234f
25397 + add %_ASM_DX,%_ASM_AX
25398 +1234:
25399 +#endif
25400 +
25401 +#endif
25402 +
25403 +1: __copyuser_seg movzbl (%_ASM_AX),%edx
25404 xor %eax,%eax
25405 ASM_CLAC
25406 + pax_force_retaddr
25407 ret
25408 CFI_ENDPROC
25409 ENDPROC(__get_user_1)
25410 @@ -51,14 +74,28 @@ ENDPROC(__get_user_1)
25411 ENTRY(__get_user_2)
25412 CFI_STARTPROC
25413 add $1,%_ASM_AX
25414 +
25415 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25416 jc bad_get_user
25417 GET_THREAD_INFO(%_ASM_DX)
25418 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25419 jae bad_get_user
25420 ASM_STAC
25421 -2: movzwl -1(%_ASM_AX),%edx
25422 +
25423 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25424 + mov pax_user_shadow_base,%_ASM_DX
25425 + cmp %_ASM_DX,%_ASM_AX
25426 + jae 1234f
25427 + add %_ASM_DX,%_ASM_AX
25428 +1234:
25429 +#endif
25430 +
25431 +#endif
25432 +
25433 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
25434 xor %eax,%eax
25435 ASM_CLAC
25436 + pax_force_retaddr
25437 ret
25438 CFI_ENDPROC
25439 ENDPROC(__get_user_2)
25440 @@ -66,14 +103,28 @@ ENDPROC(__get_user_2)
25441 ENTRY(__get_user_4)
25442 CFI_STARTPROC
25443 add $3,%_ASM_AX
25444 +
25445 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
25446 jc bad_get_user
25447 GET_THREAD_INFO(%_ASM_DX)
25448 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25449 jae bad_get_user
25450 ASM_STAC
25451 -3: movl -3(%_ASM_AX),%edx
25452 +
25453 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
25454 + mov pax_user_shadow_base,%_ASM_DX
25455 + cmp %_ASM_DX,%_ASM_AX
25456 + jae 1234f
25457 + add %_ASM_DX,%_ASM_AX
25458 +1234:
25459 +#endif
25460 +
25461 +#endif
25462 +
25463 +3: __copyuser_seg movl -3(%_ASM_AX),%edx
25464 xor %eax,%eax
25465 ASM_CLAC
25466 + pax_force_retaddr
25467 ret
25468 CFI_ENDPROC
25469 ENDPROC(__get_user_4)
25470 @@ -86,10 +137,20 @@ ENTRY(__get_user_8)
25471 GET_THREAD_INFO(%_ASM_DX)
25472 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
25473 jae bad_get_user
25474 +
25475 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25476 + mov pax_user_shadow_base,%_ASM_DX
25477 + cmp %_ASM_DX,%_ASM_AX
25478 + jae 1234f
25479 + add %_ASM_DX,%_ASM_AX
25480 +1234:
25481 +#endif
25482 +
25483 ASM_STAC
25484 4: movq -7(%_ASM_AX),%rdx
25485 xor %eax,%eax
25486 ASM_CLAC
25487 + pax_force_retaddr
25488 ret
25489 #else
25490 add $7,%_ASM_AX
25491 @@ -102,6 +163,7 @@ ENTRY(__get_user_8)
25492 5: movl -3(%_ASM_AX),%ecx
25493 xor %eax,%eax
25494 ASM_CLAC
25495 + pax_force_retaddr
25496 ret
25497 #endif
25498 CFI_ENDPROC
25499 @@ -113,6 +175,7 @@ bad_get_user:
25500 xor %edx,%edx
25501 mov $(-EFAULT),%_ASM_AX
25502 ASM_CLAC
25503 + pax_force_retaddr
25504 ret
25505 CFI_ENDPROC
25506 END(bad_get_user)
25507 @@ -124,6 +187,7 @@ bad_get_user_8:
25508 xor %ecx,%ecx
25509 mov $(-EFAULT),%_ASM_AX
25510 ASM_CLAC
25511 + pax_force_retaddr
25512 ret
25513 CFI_ENDPROC
25514 END(bad_get_user_8)
25515 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
25516 index 54fcffe..7be149e 100644
25517 --- a/arch/x86/lib/insn.c
25518 +++ b/arch/x86/lib/insn.c
25519 @@ -20,8 +20,10 @@
25520
25521 #ifdef __KERNEL__
25522 #include <linux/string.h>
25523 +#include <asm/pgtable_types.h>
25524 #else
25525 #include <string.h>
25526 +#define ktla_ktva(addr) addr
25527 #endif
25528 #include <asm/inat.h>
25529 #include <asm/insn.h>
25530 @@ -53,8 +55,8 @@
25531 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
25532 {
25533 memset(insn, 0, sizeof(*insn));
25534 - insn->kaddr = kaddr;
25535 - insn->next_byte = kaddr;
25536 + insn->kaddr = ktla_ktva(kaddr);
25537 + insn->next_byte = ktla_ktva(kaddr);
25538 insn->x86_64 = x86_64 ? 1 : 0;
25539 insn->opnd_bytes = 4;
25540 if (x86_64)
25541 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
25542 index 05a95e7..326f2fa 100644
25543 --- a/arch/x86/lib/iomap_copy_64.S
25544 +++ b/arch/x86/lib/iomap_copy_64.S
25545 @@ -17,6 +17,7 @@
25546
25547 #include <linux/linkage.h>
25548 #include <asm/dwarf2.h>
25549 +#include <asm/alternative-asm.h>
25550
25551 /*
25552 * override generic version in lib/iomap_copy.c
25553 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
25554 CFI_STARTPROC
25555 movl %edx,%ecx
25556 rep movsd
25557 + pax_force_retaddr
25558 ret
25559 CFI_ENDPROC
25560 ENDPROC(__iowrite32_copy)
25561 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
25562 index 56313a3..aa84a79 100644
25563 --- a/arch/x86/lib/memcpy_64.S
25564 +++ b/arch/x86/lib/memcpy_64.S
25565 @@ -33,6 +33,7 @@
25566 rep movsq
25567 movl %edx, %ecx
25568 rep movsb
25569 + pax_force_retaddr
25570 ret
25571 .Lmemcpy_e:
25572 .previous
25573 @@ -49,6 +50,7 @@
25574 movq %rdi, %rax
25575 movq %rdx, %rcx
25576 rep movsb
25577 + pax_force_retaddr
25578 ret
25579 .Lmemcpy_e_e:
25580 .previous
25581 @@ -76,13 +78,13 @@ ENTRY(memcpy)
25582 */
25583 movq 0*8(%rsi), %r8
25584 movq 1*8(%rsi), %r9
25585 - movq 2*8(%rsi), %r10
25586 + movq 2*8(%rsi), %rcx
25587 movq 3*8(%rsi), %r11
25588 leaq 4*8(%rsi), %rsi
25589
25590 movq %r8, 0*8(%rdi)
25591 movq %r9, 1*8(%rdi)
25592 - movq %r10, 2*8(%rdi)
25593 + movq %rcx, 2*8(%rdi)
25594 movq %r11, 3*8(%rdi)
25595 leaq 4*8(%rdi), %rdi
25596 jae .Lcopy_forward_loop
25597 @@ -105,12 +107,12 @@ ENTRY(memcpy)
25598 subq $0x20, %rdx
25599 movq -1*8(%rsi), %r8
25600 movq -2*8(%rsi), %r9
25601 - movq -3*8(%rsi), %r10
25602 + movq -3*8(%rsi), %rcx
25603 movq -4*8(%rsi), %r11
25604 leaq -4*8(%rsi), %rsi
25605 movq %r8, -1*8(%rdi)
25606 movq %r9, -2*8(%rdi)
25607 - movq %r10, -3*8(%rdi)
25608 + movq %rcx, -3*8(%rdi)
25609 movq %r11, -4*8(%rdi)
25610 leaq -4*8(%rdi), %rdi
25611 jae .Lcopy_backward_loop
25612 @@ -130,12 +132,13 @@ ENTRY(memcpy)
25613 */
25614 movq 0*8(%rsi), %r8
25615 movq 1*8(%rsi), %r9
25616 - movq -2*8(%rsi, %rdx), %r10
25617 + movq -2*8(%rsi, %rdx), %rcx
25618 movq -1*8(%rsi, %rdx), %r11
25619 movq %r8, 0*8(%rdi)
25620 movq %r9, 1*8(%rdi)
25621 - movq %r10, -2*8(%rdi, %rdx)
25622 + movq %rcx, -2*8(%rdi, %rdx)
25623 movq %r11, -1*8(%rdi, %rdx)
25624 + pax_force_retaddr
25625 retq
25626 .p2align 4
25627 .Lless_16bytes:
25628 @@ -148,6 +151,7 @@ ENTRY(memcpy)
25629 movq -1*8(%rsi, %rdx), %r9
25630 movq %r8, 0*8(%rdi)
25631 movq %r9, -1*8(%rdi, %rdx)
25632 + pax_force_retaddr
25633 retq
25634 .p2align 4
25635 .Lless_8bytes:
25636 @@ -161,6 +165,7 @@ ENTRY(memcpy)
25637 movl -4(%rsi, %rdx), %r8d
25638 movl %ecx, (%rdi)
25639 movl %r8d, -4(%rdi, %rdx)
25640 + pax_force_retaddr
25641 retq
25642 .p2align 4
25643 .Lless_3bytes:
25644 @@ -179,6 +184,7 @@ ENTRY(memcpy)
25645 movb %cl, (%rdi)
25646
25647 .Lend:
25648 + pax_force_retaddr
25649 retq
25650 CFI_ENDPROC
25651 ENDPROC(memcpy)
25652 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
25653 index 65268a6..c9518d1 100644
25654 --- a/arch/x86/lib/memmove_64.S
25655 +++ b/arch/x86/lib/memmove_64.S
25656 @@ -61,13 +61,13 @@ ENTRY(memmove)
25657 5:
25658 sub $0x20, %rdx
25659 movq 0*8(%rsi), %r11
25660 - movq 1*8(%rsi), %r10
25661 + movq 1*8(%rsi), %rcx
25662 movq 2*8(%rsi), %r9
25663 movq 3*8(%rsi), %r8
25664 leaq 4*8(%rsi), %rsi
25665
25666 movq %r11, 0*8(%rdi)
25667 - movq %r10, 1*8(%rdi)
25668 + movq %rcx, 1*8(%rdi)
25669 movq %r9, 2*8(%rdi)
25670 movq %r8, 3*8(%rdi)
25671 leaq 4*8(%rdi), %rdi
25672 @@ -81,10 +81,10 @@ ENTRY(memmove)
25673 4:
25674 movq %rdx, %rcx
25675 movq -8(%rsi, %rdx), %r11
25676 - lea -8(%rdi, %rdx), %r10
25677 + lea -8(%rdi, %rdx), %r9
25678 shrq $3, %rcx
25679 rep movsq
25680 - movq %r11, (%r10)
25681 + movq %r11, (%r9)
25682 jmp 13f
25683 .Lmemmove_end_forward:
25684
25685 @@ -95,14 +95,14 @@ ENTRY(memmove)
25686 7:
25687 movq %rdx, %rcx
25688 movq (%rsi), %r11
25689 - movq %rdi, %r10
25690 + movq %rdi, %r9
25691 leaq -8(%rsi, %rdx), %rsi
25692 leaq -8(%rdi, %rdx), %rdi
25693 shrq $3, %rcx
25694 std
25695 rep movsq
25696 cld
25697 - movq %r11, (%r10)
25698 + movq %r11, (%r9)
25699 jmp 13f
25700
25701 /*
25702 @@ -127,13 +127,13 @@ ENTRY(memmove)
25703 8:
25704 subq $0x20, %rdx
25705 movq -1*8(%rsi), %r11
25706 - movq -2*8(%rsi), %r10
25707 + movq -2*8(%rsi), %rcx
25708 movq -3*8(%rsi), %r9
25709 movq -4*8(%rsi), %r8
25710 leaq -4*8(%rsi), %rsi
25711
25712 movq %r11, -1*8(%rdi)
25713 - movq %r10, -2*8(%rdi)
25714 + movq %rcx, -2*8(%rdi)
25715 movq %r9, -3*8(%rdi)
25716 movq %r8, -4*8(%rdi)
25717 leaq -4*8(%rdi), %rdi
25718 @@ -151,11 +151,11 @@ ENTRY(memmove)
25719 * Move data from 16 bytes to 31 bytes.
25720 */
25721 movq 0*8(%rsi), %r11
25722 - movq 1*8(%rsi), %r10
25723 + movq 1*8(%rsi), %rcx
25724 movq -2*8(%rsi, %rdx), %r9
25725 movq -1*8(%rsi, %rdx), %r8
25726 movq %r11, 0*8(%rdi)
25727 - movq %r10, 1*8(%rdi)
25728 + movq %rcx, 1*8(%rdi)
25729 movq %r9, -2*8(%rdi, %rdx)
25730 movq %r8, -1*8(%rdi, %rdx)
25731 jmp 13f
25732 @@ -167,9 +167,9 @@ ENTRY(memmove)
25733 * Move data from 8 bytes to 15 bytes.
25734 */
25735 movq 0*8(%rsi), %r11
25736 - movq -1*8(%rsi, %rdx), %r10
25737 + movq -1*8(%rsi, %rdx), %r9
25738 movq %r11, 0*8(%rdi)
25739 - movq %r10, -1*8(%rdi, %rdx)
25740 + movq %r9, -1*8(%rdi, %rdx)
25741 jmp 13f
25742 10:
25743 cmpq $4, %rdx
25744 @@ -178,9 +178,9 @@ ENTRY(memmove)
25745 * Move data from 4 bytes to 7 bytes.
25746 */
25747 movl (%rsi), %r11d
25748 - movl -4(%rsi, %rdx), %r10d
25749 + movl -4(%rsi, %rdx), %r9d
25750 movl %r11d, (%rdi)
25751 - movl %r10d, -4(%rdi, %rdx)
25752 + movl %r9d, -4(%rdi, %rdx)
25753 jmp 13f
25754 11:
25755 cmp $2, %rdx
25756 @@ -189,9 +189,9 @@ ENTRY(memmove)
25757 * Move data from 2 bytes to 3 bytes.
25758 */
25759 movw (%rsi), %r11w
25760 - movw -2(%rsi, %rdx), %r10w
25761 + movw -2(%rsi, %rdx), %r9w
25762 movw %r11w, (%rdi)
25763 - movw %r10w, -2(%rdi, %rdx)
25764 + movw %r9w, -2(%rdi, %rdx)
25765 jmp 13f
25766 12:
25767 cmp $1, %rdx
25768 @@ -202,6 +202,7 @@ ENTRY(memmove)
25769 movb (%rsi), %r11b
25770 movb %r11b, (%rdi)
25771 13:
25772 + pax_force_retaddr
25773 retq
25774 CFI_ENDPROC
25775
25776 @@ -210,6 +211,7 @@ ENTRY(memmove)
25777 /* Forward moving data. */
25778 movq %rdx, %rcx
25779 rep movsb
25780 + pax_force_retaddr
25781 retq
25782 .Lmemmove_end_forward_efs:
25783 .previous
25784 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
25785 index 2dcb380..963660a 100644
25786 --- a/arch/x86/lib/memset_64.S
25787 +++ b/arch/x86/lib/memset_64.S
25788 @@ -30,6 +30,7 @@
25789 movl %edx,%ecx
25790 rep stosb
25791 movq %r9,%rax
25792 + pax_force_retaddr
25793 ret
25794 .Lmemset_e:
25795 .previous
25796 @@ -52,6 +53,7 @@
25797 movq %rdx,%rcx
25798 rep stosb
25799 movq %r9,%rax
25800 + pax_force_retaddr
25801 ret
25802 .Lmemset_e_e:
25803 .previous
25804 @@ -59,7 +61,7 @@
25805 ENTRY(memset)
25806 ENTRY(__memset)
25807 CFI_STARTPROC
25808 - movq %rdi,%r10
25809 + movq %rdi,%r11
25810
25811 /* expand byte value */
25812 movzbl %sil,%ecx
25813 @@ -117,7 +119,8 @@ ENTRY(__memset)
25814 jnz .Lloop_1
25815
25816 .Lende:
25817 - movq %r10,%rax
25818 + movq %r11,%rax
25819 + pax_force_retaddr
25820 ret
25821
25822 CFI_RESTORE_STATE
25823 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
25824 index c9f2d9b..e7fd2c0 100644
25825 --- a/arch/x86/lib/mmx_32.c
25826 +++ b/arch/x86/lib/mmx_32.c
25827 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
25828 {
25829 void *p;
25830 int i;
25831 + unsigned long cr0;
25832
25833 if (unlikely(in_interrupt()))
25834 return __memcpy(to, from, len);
25835 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
25836 kernel_fpu_begin();
25837
25838 __asm__ __volatile__ (
25839 - "1: prefetch (%0)\n" /* This set is 28 bytes */
25840 - " prefetch 64(%0)\n"
25841 - " prefetch 128(%0)\n"
25842 - " prefetch 192(%0)\n"
25843 - " prefetch 256(%0)\n"
25844 + "1: prefetch (%1)\n" /* This set is 28 bytes */
25845 + " prefetch 64(%1)\n"
25846 + " prefetch 128(%1)\n"
25847 + " prefetch 192(%1)\n"
25848 + " prefetch 256(%1)\n"
25849 "2: \n"
25850 ".section .fixup, \"ax\"\n"
25851 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25852 + "3: \n"
25853 +
25854 +#ifdef CONFIG_PAX_KERNEXEC
25855 + " movl %%cr0, %0\n"
25856 + " movl %0, %%eax\n"
25857 + " andl $0xFFFEFFFF, %%eax\n"
25858 + " movl %%eax, %%cr0\n"
25859 +#endif
25860 +
25861 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25862 +
25863 +#ifdef CONFIG_PAX_KERNEXEC
25864 + " movl %0, %%cr0\n"
25865 +#endif
25866 +
25867 " jmp 2b\n"
25868 ".previous\n"
25869 _ASM_EXTABLE(1b, 3b)
25870 - : : "r" (from));
25871 + : "=&r" (cr0) : "r" (from) : "ax");
25872
25873 for ( ; i > 5; i--) {
25874 __asm__ __volatile__ (
25875 - "1: prefetch 320(%0)\n"
25876 - "2: movq (%0), %%mm0\n"
25877 - " movq 8(%0), %%mm1\n"
25878 - " movq 16(%0), %%mm2\n"
25879 - " movq 24(%0), %%mm3\n"
25880 - " movq %%mm0, (%1)\n"
25881 - " movq %%mm1, 8(%1)\n"
25882 - " movq %%mm2, 16(%1)\n"
25883 - " movq %%mm3, 24(%1)\n"
25884 - " movq 32(%0), %%mm0\n"
25885 - " movq 40(%0), %%mm1\n"
25886 - " movq 48(%0), %%mm2\n"
25887 - " movq 56(%0), %%mm3\n"
25888 - " movq %%mm0, 32(%1)\n"
25889 - " movq %%mm1, 40(%1)\n"
25890 - " movq %%mm2, 48(%1)\n"
25891 - " movq %%mm3, 56(%1)\n"
25892 + "1: prefetch 320(%1)\n"
25893 + "2: movq (%1), %%mm0\n"
25894 + " movq 8(%1), %%mm1\n"
25895 + " movq 16(%1), %%mm2\n"
25896 + " movq 24(%1), %%mm3\n"
25897 + " movq %%mm0, (%2)\n"
25898 + " movq %%mm1, 8(%2)\n"
25899 + " movq %%mm2, 16(%2)\n"
25900 + " movq %%mm3, 24(%2)\n"
25901 + " movq 32(%1), %%mm0\n"
25902 + " movq 40(%1), %%mm1\n"
25903 + " movq 48(%1), %%mm2\n"
25904 + " movq 56(%1), %%mm3\n"
25905 + " movq %%mm0, 32(%2)\n"
25906 + " movq %%mm1, 40(%2)\n"
25907 + " movq %%mm2, 48(%2)\n"
25908 + " movq %%mm3, 56(%2)\n"
25909 ".section .fixup, \"ax\"\n"
25910 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25911 + "3:\n"
25912 +
25913 +#ifdef CONFIG_PAX_KERNEXEC
25914 + " movl %%cr0, %0\n"
25915 + " movl %0, %%eax\n"
25916 + " andl $0xFFFEFFFF, %%eax\n"
25917 + " movl %%eax, %%cr0\n"
25918 +#endif
25919 +
25920 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
25921 +
25922 +#ifdef CONFIG_PAX_KERNEXEC
25923 + " movl %0, %%cr0\n"
25924 +#endif
25925 +
25926 " jmp 2b\n"
25927 ".previous\n"
25928 _ASM_EXTABLE(1b, 3b)
25929 - : : "r" (from), "r" (to) : "memory");
25930 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
25931
25932 from += 64;
25933 to += 64;
25934 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
25935 static void fast_copy_page(void *to, void *from)
25936 {
25937 int i;
25938 + unsigned long cr0;
25939
25940 kernel_fpu_begin();
25941
25942 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
25943 * but that is for later. -AV
25944 */
25945 __asm__ __volatile__(
25946 - "1: prefetch (%0)\n"
25947 - " prefetch 64(%0)\n"
25948 - " prefetch 128(%0)\n"
25949 - " prefetch 192(%0)\n"
25950 - " prefetch 256(%0)\n"
25951 + "1: prefetch (%1)\n"
25952 + " prefetch 64(%1)\n"
25953 + " prefetch 128(%1)\n"
25954 + " prefetch 192(%1)\n"
25955 + " prefetch 256(%1)\n"
25956 "2: \n"
25957 ".section .fixup, \"ax\"\n"
25958 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25959 + "3: \n"
25960 +
25961 +#ifdef CONFIG_PAX_KERNEXEC
25962 + " movl %%cr0, %0\n"
25963 + " movl %0, %%eax\n"
25964 + " andl $0xFFFEFFFF, %%eax\n"
25965 + " movl %%eax, %%cr0\n"
25966 +#endif
25967 +
25968 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
25969 +
25970 +#ifdef CONFIG_PAX_KERNEXEC
25971 + " movl %0, %%cr0\n"
25972 +#endif
25973 +
25974 " jmp 2b\n"
25975 ".previous\n"
25976 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
25977 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
25978
25979 for (i = 0; i < (4096-320)/64; i++) {
25980 __asm__ __volatile__ (
25981 - "1: prefetch 320(%0)\n"
25982 - "2: movq (%0), %%mm0\n"
25983 - " movntq %%mm0, (%1)\n"
25984 - " movq 8(%0), %%mm1\n"
25985 - " movntq %%mm1, 8(%1)\n"
25986 - " movq 16(%0), %%mm2\n"
25987 - " movntq %%mm2, 16(%1)\n"
25988 - " movq 24(%0), %%mm3\n"
25989 - " movntq %%mm3, 24(%1)\n"
25990 - " movq 32(%0), %%mm4\n"
25991 - " movntq %%mm4, 32(%1)\n"
25992 - " movq 40(%0), %%mm5\n"
25993 - " movntq %%mm5, 40(%1)\n"
25994 - " movq 48(%0), %%mm6\n"
25995 - " movntq %%mm6, 48(%1)\n"
25996 - " movq 56(%0), %%mm7\n"
25997 - " movntq %%mm7, 56(%1)\n"
25998 + "1: prefetch 320(%1)\n"
25999 + "2: movq (%1), %%mm0\n"
26000 + " movntq %%mm0, (%2)\n"
26001 + " movq 8(%1), %%mm1\n"
26002 + " movntq %%mm1, 8(%2)\n"
26003 + " movq 16(%1), %%mm2\n"
26004 + " movntq %%mm2, 16(%2)\n"
26005 + " movq 24(%1), %%mm3\n"
26006 + " movntq %%mm3, 24(%2)\n"
26007 + " movq 32(%1), %%mm4\n"
26008 + " movntq %%mm4, 32(%2)\n"
26009 + " movq 40(%1), %%mm5\n"
26010 + " movntq %%mm5, 40(%2)\n"
26011 + " movq 48(%1), %%mm6\n"
26012 + " movntq %%mm6, 48(%2)\n"
26013 + " movq 56(%1), %%mm7\n"
26014 + " movntq %%mm7, 56(%2)\n"
26015 ".section .fixup, \"ax\"\n"
26016 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26017 + "3:\n"
26018 +
26019 +#ifdef CONFIG_PAX_KERNEXEC
26020 + " movl %%cr0, %0\n"
26021 + " movl %0, %%eax\n"
26022 + " andl $0xFFFEFFFF, %%eax\n"
26023 + " movl %%eax, %%cr0\n"
26024 +#endif
26025 +
26026 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26027 +
26028 +#ifdef CONFIG_PAX_KERNEXEC
26029 + " movl %0, %%cr0\n"
26030 +#endif
26031 +
26032 " jmp 2b\n"
26033 ".previous\n"
26034 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
26035 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26036
26037 from += 64;
26038 to += 64;
26039 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
26040 static void fast_copy_page(void *to, void *from)
26041 {
26042 int i;
26043 + unsigned long cr0;
26044
26045 kernel_fpu_begin();
26046
26047 __asm__ __volatile__ (
26048 - "1: prefetch (%0)\n"
26049 - " prefetch 64(%0)\n"
26050 - " prefetch 128(%0)\n"
26051 - " prefetch 192(%0)\n"
26052 - " prefetch 256(%0)\n"
26053 + "1: prefetch (%1)\n"
26054 + " prefetch 64(%1)\n"
26055 + " prefetch 128(%1)\n"
26056 + " prefetch 192(%1)\n"
26057 + " prefetch 256(%1)\n"
26058 "2: \n"
26059 ".section .fixup, \"ax\"\n"
26060 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26061 + "3: \n"
26062 +
26063 +#ifdef CONFIG_PAX_KERNEXEC
26064 + " movl %%cr0, %0\n"
26065 + " movl %0, %%eax\n"
26066 + " andl $0xFFFEFFFF, %%eax\n"
26067 + " movl %%eax, %%cr0\n"
26068 +#endif
26069 +
26070 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
26071 +
26072 +#ifdef CONFIG_PAX_KERNEXEC
26073 + " movl %0, %%cr0\n"
26074 +#endif
26075 +
26076 " jmp 2b\n"
26077 ".previous\n"
26078 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
26079 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
26080
26081 for (i = 0; i < 4096/64; i++) {
26082 __asm__ __volatile__ (
26083 - "1: prefetch 320(%0)\n"
26084 - "2: movq (%0), %%mm0\n"
26085 - " movq 8(%0), %%mm1\n"
26086 - " movq 16(%0), %%mm2\n"
26087 - " movq 24(%0), %%mm3\n"
26088 - " movq %%mm0, (%1)\n"
26089 - " movq %%mm1, 8(%1)\n"
26090 - " movq %%mm2, 16(%1)\n"
26091 - " movq %%mm3, 24(%1)\n"
26092 - " movq 32(%0), %%mm0\n"
26093 - " movq 40(%0), %%mm1\n"
26094 - " movq 48(%0), %%mm2\n"
26095 - " movq 56(%0), %%mm3\n"
26096 - " movq %%mm0, 32(%1)\n"
26097 - " movq %%mm1, 40(%1)\n"
26098 - " movq %%mm2, 48(%1)\n"
26099 - " movq %%mm3, 56(%1)\n"
26100 + "1: prefetch 320(%1)\n"
26101 + "2: movq (%1), %%mm0\n"
26102 + " movq 8(%1), %%mm1\n"
26103 + " movq 16(%1), %%mm2\n"
26104 + " movq 24(%1), %%mm3\n"
26105 + " movq %%mm0, (%2)\n"
26106 + " movq %%mm1, 8(%2)\n"
26107 + " movq %%mm2, 16(%2)\n"
26108 + " movq %%mm3, 24(%2)\n"
26109 + " movq 32(%1), %%mm0\n"
26110 + " movq 40(%1), %%mm1\n"
26111 + " movq 48(%1), %%mm2\n"
26112 + " movq 56(%1), %%mm3\n"
26113 + " movq %%mm0, 32(%2)\n"
26114 + " movq %%mm1, 40(%2)\n"
26115 + " movq %%mm2, 48(%2)\n"
26116 + " movq %%mm3, 56(%2)\n"
26117 ".section .fixup, \"ax\"\n"
26118 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26119 + "3:\n"
26120 +
26121 +#ifdef CONFIG_PAX_KERNEXEC
26122 + " movl %%cr0, %0\n"
26123 + " movl %0, %%eax\n"
26124 + " andl $0xFFFEFFFF, %%eax\n"
26125 + " movl %%eax, %%cr0\n"
26126 +#endif
26127 +
26128 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
26129 +
26130 +#ifdef CONFIG_PAX_KERNEXEC
26131 + " movl %0, %%cr0\n"
26132 +#endif
26133 +
26134 " jmp 2b\n"
26135 ".previous\n"
26136 _ASM_EXTABLE(1b, 3b)
26137 - : : "r" (from), "r" (to) : "memory");
26138 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
26139
26140 from += 64;
26141 to += 64;
26142 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
26143 index f6d13ee..aca5f0b 100644
26144 --- a/arch/x86/lib/msr-reg.S
26145 +++ b/arch/x86/lib/msr-reg.S
26146 @@ -3,6 +3,7 @@
26147 #include <asm/dwarf2.h>
26148 #include <asm/asm.h>
26149 #include <asm/msr.h>
26150 +#include <asm/alternative-asm.h>
26151
26152 #ifdef CONFIG_X86_64
26153 /*
26154 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
26155 CFI_STARTPROC
26156 pushq_cfi %rbx
26157 pushq_cfi %rbp
26158 - movq %rdi, %r10 /* Save pointer */
26159 + movq %rdi, %r9 /* Save pointer */
26160 xorl %r11d, %r11d /* Return value */
26161 movl (%rdi), %eax
26162 movl 4(%rdi), %ecx
26163 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
26164 movl 28(%rdi), %edi
26165 CFI_REMEMBER_STATE
26166 1: \op
26167 -2: movl %eax, (%r10)
26168 +2: movl %eax, (%r9)
26169 movl %r11d, %eax /* Return value */
26170 - movl %ecx, 4(%r10)
26171 - movl %edx, 8(%r10)
26172 - movl %ebx, 12(%r10)
26173 - movl %ebp, 20(%r10)
26174 - movl %esi, 24(%r10)
26175 - movl %edi, 28(%r10)
26176 + movl %ecx, 4(%r9)
26177 + movl %edx, 8(%r9)
26178 + movl %ebx, 12(%r9)
26179 + movl %ebp, 20(%r9)
26180 + movl %esi, 24(%r9)
26181 + movl %edi, 28(%r9)
26182 popq_cfi %rbp
26183 popq_cfi %rbx
26184 + pax_force_retaddr
26185 ret
26186 3:
26187 CFI_RESTORE_STATE
26188 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
26189 index fc6ba17..d4d989d 100644
26190 --- a/arch/x86/lib/putuser.S
26191 +++ b/arch/x86/lib/putuser.S
26192 @@ -16,7 +16,9 @@
26193 #include <asm/errno.h>
26194 #include <asm/asm.h>
26195 #include <asm/smap.h>
26196 -
26197 +#include <asm/segment.h>
26198 +#include <asm/pgtable.h>
26199 +#include <asm/alternative-asm.h>
26200
26201 /*
26202 * __put_user_X
26203 @@ -30,57 +32,125 @@
26204 * as they get called from within inline assembly.
26205 */
26206
26207 -#define ENTER CFI_STARTPROC ; \
26208 - GET_THREAD_INFO(%_ASM_BX)
26209 -#define EXIT ASM_CLAC ; \
26210 - ret ; \
26211 +#define ENTER CFI_STARTPROC
26212 +#define EXIT ASM_CLAC ; \
26213 + pax_force_retaddr ; \
26214 + ret ; \
26215 CFI_ENDPROC
26216
26217 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26218 +#define _DEST %_ASM_CX,%_ASM_BX
26219 +#else
26220 +#define _DEST %_ASM_CX
26221 +#endif
26222 +
26223 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
26224 +#define __copyuser_seg gs;
26225 +#else
26226 +#define __copyuser_seg
26227 +#endif
26228 +
26229 .text
26230 ENTRY(__put_user_1)
26231 ENTER
26232 +
26233 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26234 + GET_THREAD_INFO(%_ASM_BX)
26235 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
26236 jae bad_put_user
26237 ASM_STAC
26238 -1: movb %al,(%_ASM_CX)
26239 +
26240 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26241 + mov pax_user_shadow_base,%_ASM_BX
26242 + cmp %_ASM_BX,%_ASM_CX
26243 + jb 1234f
26244 + xor %ebx,%ebx
26245 +1234:
26246 +#endif
26247 +
26248 +#endif
26249 +
26250 +1: __copyuser_seg movb %al,(_DEST)
26251 xor %eax,%eax
26252 EXIT
26253 ENDPROC(__put_user_1)
26254
26255 ENTRY(__put_user_2)
26256 ENTER
26257 +
26258 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26259 + GET_THREAD_INFO(%_ASM_BX)
26260 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26261 sub $1,%_ASM_BX
26262 cmp %_ASM_BX,%_ASM_CX
26263 jae bad_put_user
26264 ASM_STAC
26265 -2: movw %ax,(%_ASM_CX)
26266 +
26267 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26268 + mov pax_user_shadow_base,%_ASM_BX
26269 + cmp %_ASM_BX,%_ASM_CX
26270 + jb 1234f
26271 + xor %ebx,%ebx
26272 +1234:
26273 +#endif
26274 +
26275 +#endif
26276 +
26277 +2: __copyuser_seg movw %ax,(_DEST)
26278 xor %eax,%eax
26279 EXIT
26280 ENDPROC(__put_user_2)
26281
26282 ENTRY(__put_user_4)
26283 ENTER
26284 +
26285 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26286 + GET_THREAD_INFO(%_ASM_BX)
26287 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26288 sub $3,%_ASM_BX
26289 cmp %_ASM_BX,%_ASM_CX
26290 jae bad_put_user
26291 ASM_STAC
26292 -3: movl %eax,(%_ASM_CX)
26293 +
26294 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26295 + mov pax_user_shadow_base,%_ASM_BX
26296 + cmp %_ASM_BX,%_ASM_CX
26297 + jb 1234f
26298 + xor %ebx,%ebx
26299 +1234:
26300 +#endif
26301 +
26302 +#endif
26303 +
26304 +3: __copyuser_seg movl %eax,(_DEST)
26305 xor %eax,%eax
26306 EXIT
26307 ENDPROC(__put_user_4)
26308
26309 ENTRY(__put_user_8)
26310 ENTER
26311 +
26312 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
26313 + GET_THREAD_INFO(%_ASM_BX)
26314 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
26315 sub $7,%_ASM_BX
26316 cmp %_ASM_BX,%_ASM_CX
26317 jae bad_put_user
26318 ASM_STAC
26319 -4: mov %_ASM_AX,(%_ASM_CX)
26320 +
26321 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
26322 + mov pax_user_shadow_base,%_ASM_BX
26323 + cmp %_ASM_BX,%_ASM_CX
26324 + jb 1234f
26325 + xor %ebx,%ebx
26326 +1234:
26327 +#endif
26328 +
26329 +#endif
26330 +
26331 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
26332 #ifdef CONFIG_X86_32
26333 -5: movl %edx,4(%_ASM_CX)
26334 +5: __copyuser_seg movl %edx,4(_DEST)
26335 #endif
26336 xor %eax,%eax
26337 EXIT
26338 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
26339 index 1cad221..de671ee 100644
26340 --- a/arch/x86/lib/rwlock.S
26341 +++ b/arch/x86/lib/rwlock.S
26342 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
26343 FRAME
26344 0: LOCK_PREFIX
26345 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26346 +
26347 +#ifdef CONFIG_PAX_REFCOUNT
26348 + jno 1234f
26349 + LOCK_PREFIX
26350 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26351 + int $4
26352 +1234:
26353 + _ASM_EXTABLE(1234b, 1234b)
26354 +#endif
26355 +
26356 1: rep; nop
26357 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
26358 jne 1b
26359 LOCK_PREFIX
26360 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
26361 +
26362 +#ifdef CONFIG_PAX_REFCOUNT
26363 + jno 1234f
26364 + LOCK_PREFIX
26365 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
26366 + int $4
26367 +1234:
26368 + _ASM_EXTABLE(1234b, 1234b)
26369 +#endif
26370 +
26371 jnz 0b
26372 ENDFRAME
26373 + pax_force_retaddr
26374 ret
26375 CFI_ENDPROC
26376 END(__write_lock_failed)
26377 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
26378 FRAME
26379 0: LOCK_PREFIX
26380 READ_LOCK_SIZE(inc) (%__lock_ptr)
26381 +
26382 +#ifdef CONFIG_PAX_REFCOUNT
26383 + jno 1234f
26384 + LOCK_PREFIX
26385 + READ_LOCK_SIZE(dec) (%__lock_ptr)
26386 + int $4
26387 +1234:
26388 + _ASM_EXTABLE(1234b, 1234b)
26389 +#endif
26390 +
26391 1: rep; nop
26392 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
26393 js 1b
26394 LOCK_PREFIX
26395 READ_LOCK_SIZE(dec) (%__lock_ptr)
26396 +
26397 +#ifdef CONFIG_PAX_REFCOUNT
26398 + jno 1234f
26399 + LOCK_PREFIX
26400 + READ_LOCK_SIZE(inc) (%__lock_ptr)
26401 + int $4
26402 +1234:
26403 + _ASM_EXTABLE(1234b, 1234b)
26404 +#endif
26405 +
26406 js 0b
26407 ENDFRAME
26408 + pax_force_retaddr
26409 ret
26410 CFI_ENDPROC
26411 END(__read_lock_failed)
26412 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
26413 index 5dff5f0..cadebf4 100644
26414 --- a/arch/x86/lib/rwsem.S
26415 +++ b/arch/x86/lib/rwsem.S
26416 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
26417 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26418 CFI_RESTORE __ASM_REG(dx)
26419 restore_common_regs
26420 + pax_force_retaddr
26421 ret
26422 CFI_ENDPROC
26423 ENDPROC(call_rwsem_down_read_failed)
26424 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
26425 movq %rax,%rdi
26426 call rwsem_down_write_failed
26427 restore_common_regs
26428 + pax_force_retaddr
26429 ret
26430 CFI_ENDPROC
26431 ENDPROC(call_rwsem_down_write_failed)
26432 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
26433 movq %rax,%rdi
26434 call rwsem_wake
26435 restore_common_regs
26436 -1: ret
26437 +1: pax_force_retaddr
26438 + ret
26439 CFI_ENDPROC
26440 ENDPROC(call_rwsem_wake)
26441
26442 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
26443 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
26444 CFI_RESTORE __ASM_REG(dx)
26445 restore_common_regs
26446 + pax_force_retaddr
26447 ret
26448 CFI_ENDPROC
26449 ENDPROC(call_rwsem_downgrade_wake)
26450 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
26451 index a63efd6..ccecad8 100644
26452 --- a/arch/x86/lib/thunk_64.S
26453 +++ b/arch/x86/lib/thunk_64.S
26454 @@ -8,6 +8,7 @@
26455 #include <linux/linkage.h>
26456 #include <asm/dwarf2.h>
26457 #include <asm/calling.h>
26458 +#include <asm/alternative-asm.h>
26459
26460 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
26461 .macro THUNK name, func, put_ret_addr_in_rdi=0
26462 @@ -41,5 +42,6 @@
26463 SAVE_ARGS
26464 restore:
26465 RESTORE_ARGS
26466 + pax_force_retaddr
26467 ret
26468 CFI_ENDPROC
26469 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
26470 index 3eb18ac..6890bc3 100644
26471 --- a/arch/x86/lib/usercopy_32.c
26472 +++ b/arch/x86/lib/usercopy_32.c
26473 @@ -42,11 +42,13 @@ do { \
26474 int __d0; \
26475 might_fault(); \
26476 __asm__ __volatile__( \
26477 + __COPYUSER_SET_ES \
26478 ASM_STAC "\n" \
26479 "0: rep; stosl\n" \
26480 " movl %2,%0\n" \
26481 "1: rep; stosb\n" \
26482 "2: " ASM_CLAC "\n" \
26483 + __COPYUSER_RESTORE_ES \
26484 ".section .fixup,\"ax\"\n" \
26485 "3: lea 0(%2,%0,4),%0\n" \
26486 " jmp 2b\n" \
26487 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
26488
26489 #ifdef CONFIG_X86_INTEL_USERCOPY
26490 static unsigned long
26491 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
26492 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
26493 {
26494 int d0, d1;
26495 __asm__ __volatile__(
26496 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26497 " .align 2,0x90\n"
26498 "3: movl 0(%4), %%eax\n"
26499 "4: movl 4(%4), %%edx\n"
26500 - "5: movl %%eax, 0(%3)\n"
26501 - "6: movl %%edx, 4(%3)\n"
26502 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
26503 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
26504 "7: movl 8(%4), %%eax\n"
26505 "8: movl 12(%4),%%edx\n"
26506 - "9: movl %%eax, 8(%3)\n"
26507 - "10: movl %%edx, 12(%3)\n"
26508 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
26509 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
26510 "11: movl 16(%4), %%eax\n"
26511 "12: movl 20(%4), %%edx\n"
26512 - "13: movl %%eax, 16(%3)\n"
26513 - "14: movl %%edx, 20(%3)\n"
26514 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
26515 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
26516 "15: movl 24(%4), %%eax\n"
26517 "16: movl 28(%4), %%edx\n"
26518 - "17: movl %%eax, 24(%3)\n"
26519 - "18: movl %%edx, 28(%3)\n"
26520 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
26521 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
26522 "19: movl 32(%4), %%eax\n"
26523 "20: movl 36(%4), %%edx\n"
26524 - "21: movl %%eax, 32(%3)\n"
26525 - "22: movl %%edx, 36(%3)\n"
26526 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
26527 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
26528 "23: movl 40(%4), %%eax\n"
26529 "24: movl 44(%4), %%edx\n"
26530 - "25: movl %%eax, 40(%3)\n"
26531 - "26: movl %%edx, 44(%3)\n"
26532 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
26533 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
26534 "27: movl 48(%4), %%eax\n"
26535 "28: movl 52(%4), %%edx\n"
26536 - "29: movl %%eax, 48(%3)\n"
26537 - "30: movl %%edx, 52(%3)\n"
26538 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
26539 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
26540 "31: movl 56(%4), %%eax\n"
26541 "32: movl 60(%4), %%edx\n"
26542 - "33: movl %%eax, 56(%3)\n"
26543 - "34: movl %%edx, 60(%3)\n"
26544 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
26545 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
26546 " addl $-64, %0\n"
26547 " addl $64, %4\n"
26548 " addl $64, %3\n"
26549 @@ -149,10 +151,12 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26550 " shrl $2, %0\n"
26551 " andl $3, %%eax\n"
26552 " cld\n"
26553 + __COPYUSER_SET_ES
26554 "99: rep; movsl\n"
26555 "36: movl %%eax, %0\n"
26556 "37: rep; movsb\n"
26557 "100:\n"
26558 + __COPYUSER_RESTORE_ES
26559 ".section .fixup,\"ax\"\n"
26560 "101: lea 0(%%eax,%0,4),%0\n"
26561 " jmp 100b\n"
26562 @@ -202,46 +206,150 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
26563 }
26564
26565 static unsigned long
26566 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
26567 +{
26568 + int d0, d1;
26569 + __asm__ __volatile__(
26570 + " .align 2,0x90\n"
26571 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
26572 + " cmpl $67, %0\n"
26573 + " jbe 3f\n"
26574 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
26575 + " .align 2,0x90\n"
26576 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
26577 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
26578 + "5: movl %%eax, 0(%3)\n"
26579 + "6: movl %%edx, 4(%3)\n"
26580 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
26581 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
26582 + "9: movl %%eax, 8(%3)\n"
26583 + "10: movl %%edx, 12(%3)\n"
26584 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
26585 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
26586 + "13: movl %%eax, 16(%3)\n"
26587 + "14: movl %%edx, 20(%3)\n"
26588 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
26589 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
26590 + "17: movl %%eax, 24(%3)\n"
26591 + "18: movl %%edx, 28(%3)\n"
26592 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
26593 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
26594 + "21: movl %%eax, 32(%3)\n"
26595 + "22: movl %%edx, 36(%3)\n"
26596 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
26597 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
26598 + "25: movl %%eax, 40(%3)\n"
26599 + "26: movl %%edx, 44(%3)\n"
26600 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
26601 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
26602 + "29: movl %%eax, 48(%3)\n"
26603 + "30: movl %%edx, 52(%3)\n"
26604 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
26605 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
26606 + "33: movl %%eax, 56(%3)\n"
26607 + "34: movl %%edx, 60(%3)\n"
26608 + " addl $-64, %0\n"
26609 + " addl $64, %4\n"
26610 + " addl $64, %3\n"
26611 + " cmpl $63, %0\n"
26612 + " ja 1b\n"
26613 + "35: movl %0, %%eax\n"
26614 + " shrl $2, %0\n"
26615 + " andl $3, %%eax\n"
26616 + " cld\n"
26617 + "99: rep; "__copyuser_seg" movsl\n"
26618 + "36: movl %%eax, %0\n"
26619 + "37: rep; "__copyuser_seg" movsb\n"
26620 + "100:\n"
26621 + ".section .fixup,\"ax\"\n"
26622 + "101: lea 0(%%eax,%0,4),%0\n"
26623 + " jmp 100b\n"
26624 + ".previous\n"
26625 + _ASM_EXTABLE(1b,100b)
26626 + _ASM_EXTABLE(2b,100b)
26627 + _ASM_EXTABLE(3b,100b)
26628 + _ASM_EXTABLE(4b,100b)
26629 + _ASM_EXTABLE(5b,100b)
26630 + _ASM_EXTABLE(6b,100b)
26631 + _ASM_EXTABLE(7b,100b)
26632 + _ASM_EXTABLE(8b,100b)
26633 + _ASM_EXTABLE(9b,100b)
26634 + _ASM_EXTABLE(10b,100b)
26635 + _ASM_EXTABLE(11b,100b)
26636 + _ASM_EXTABLE(12b,100b)
26637 + _ASM_EXTABLE(13b,100b)
26638 + _ASM_EXTABLE(14b,100b)
26639 + _ASM_EXTABLE(15b,100b)
26640 + _ASM_EXTABLE(16b,100b)
26641 + _ASM_EXTABLE(17b,100b)
26642 + _ASM_EXTABLE(18b,100b)
26643 + _ASM_EXTABLE(19b,100b)
26644 + _ASM_EXTABLE(20b,100b)
26645 + _ASM_EXTABLE(21b,100b)
26646 + _ASM_EXTABLE(22b,100b)
26647 + _ASM_EXTABLE(23b,100b)
26648 + _ASM_EXTABLE(24b,100b)
26649 + _ASM_EXTABLE(25b,100b)
26650 + _ASM_EXTABLE(26b,100b)
26651 + _ASM_EXTABLE(27b,100b)
26652 + _ASM_EXTABLE(28b,100b)
26653 + _ASM_EXTABLE(29b,100b)
26654 + _ASM_EXTABLE(30b,100b)
26655 + _ASM_EXTABLE(31b,100b)
26656 + _ASM_EXTABLE(32b,100b)
26657 + _ASM_EXTABLE(33b,100b)
26658 + _ASM_EXTABLE(34b,100b)
26659 + _ASM_EXTABLE(35b,100b)
26660 + _ASM_EXTABLE(36b,100b)
26661 + _ASM_EXTABLE(37b,100b)
26662 + _ASM_EXTABLE(99b,101b)
26663 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
26664 + : "1"(to), "2"(from), "0"(size)
26665 + : "eax", "edx", "memory");
26666 + return size;
26667 +}
26668 +
26669 +static unsigned long __size_overflow(3)
26670 __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26671 {
26672 int d0, d1;
26673 __asm__ __volatile__(
26674 " .align 2,0x90\n"
26675 - "0: movl 32(%4), %%eax\n"
26676 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26677 " cmpl $67, %0\n"
26678 " jbe 2f\n"
26679 - "1: movl 64(%4), %%eax\n"
26680 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26681 " .align 2,0x90\n"
26682 - "2: movl 0(%4), %%eax\n"
26683 - "21: movl 4(%4), %%edx\n"
26684 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26685 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26686 " movl %%eax, 0(%3)\n"
26687 " movl %%edx, 4(%3)\n"
26688 - "3: movl 8(%4), %%eax\n"
26689 - "31: movl 12(%4),%%edx\n"
26690 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26691 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26692 " movl %%eax, 8(%3)\n"
26693 " movl %%edx, 12(%3)\n"
26694 - "4: movl 16(%4), %%eax\n"
26695 - "41: movl 20(%4), %%edx\n"
26696 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26697 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26698 " movl %%eax, 16(%3)\n"
26699 " movl %%edx, 20(%3)\n"
26700 - "10: movl 24(%4), %%eax\n"
26701 - "51: movl 28(%4), %%edx\n"
26702 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26703 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26704 " movl %%eax, 24(%3)\n"
26705 " movl %%edx, 28(%3)\n"
26706 - "11: movl 32(%4), %%eax\n"
26707 - "61: movl 36(%4), %%edx\n"
26708 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26709 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26710 " movl %%eax, 32(%3)\n"
26711 " movl %%edx, 36(%3)\n"
26712 - "12: movl 40(%4), %%eax\n"
26713 - "71: movl 44(%4), %%edx\n"
26714 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26715 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26716 " movl %%eax, 40(%3)\n"
26717 " movl %%edx, 44(%3)\n"
26718 - "13: movl 48(%4), %%eax\n"
26719 - "81: movl 52(%4), %%edx\n"
26720 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26721 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26722 " movl %%eax, 48(%3)\n"
26723 " movl %%edx, 52(%3)\n"
26724 - "14: movl 56(%4), %%eax\n"
26725 - "91: movl 60(%4), %%edx\n"
26726 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26727 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26728 " movl %%eax, 56(%3)\n"
26729 " movl %%edx, 60(%3)\n"
26730 " addl $-64, %0\n"
26731 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26732 " shrl $2, %0\n"
26733 " andl $3, %%eax\n"
26734 " cld\n"
26735 - "6: rep; movsl\n"
26736 + "6: rep; "__copyuser_seg" movsl\n"
26737 " movl %%eax,%0\n"
26738 - "7: rep; movsb\n"
26739 + "7: rep; "__copyuser_seg" movsb\n"
26740 "8:\n"
26741 ".section .fixup,\"ax\"\n"
26742 "9: lea 0(%%eax,%0,4),%0\n"
26743 @@ -298,48 +406,48 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
26744 * hyoshiok@miraclelinux.com
26745 */
26746
26747 -static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26748 +static unsigned long __size_overflow(3) __copy_user_zeroing_intel_nocache(void *to,
26749 const void __user *from, unsigned long size)
26750 {
26751 int d0, d1;
26752
26753 __asm__ __volatile__(
26754 " .align 2,0x90\n"
26755 - "0: movl 32(%4), %%eax\n"
26756 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26757 " cmpl $67, %0\n"
26758 " jbe 2f\n"
26759 - "1: movl 64(%4), %%eax\n"
26760 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26761 " .align 2,0x90\n"
26762 - "2: movl 0(%4), %%eax\n"
26763 - "21: movl 4(%4), %%edx\n"
26764 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26765 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26766 " movnti %%eax, 0(%3)\n"
26767 " movnti %%edx, 4(%3)\n"
26768 - "3: movl 8(%4), %%eax\n"
26769 - "31: movl 12(%4),%%edx\n"
26770 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26771 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26772 " movnti %%eax, 8(%3)\n"
26773 " movnti %%edx, 12(%3)\n"
26774 - "4: movl 16(%4), %%eax\n"
26775 - "41: movl 20(%4), %%edx\n"
26776 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26777 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26778 " movnti %%eax, 16(%3)\n"
26779 " movnti %%edx, 20(%3)\n"
26780 - "10: movl 24(%4), %%eax\n"
26781 - "51: movl 28(%4), %%edx\n"
26782 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26783 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26784 " movnti %%eax, 24(%3)\n"
26785 " movnti %%edx, 28(%3)\n"
26786 - "11: movl 32(%4), %%eax\n"
26787 - "61: movl 36(%4), %%edx\n"
26788 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26789 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26790 " movnti %%eax, 32(%3)\n"
26791 " movnti %%edx, 36(%3)\n"
26792 - "12: movl 40(%4), %%eax\n"
26793 - "71: movl 44(%4), %%edx\n"
26794 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26795 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26796 " movnti %%eax, 40(%3)\n"
26797 " movnti %%edx, 44(%3)\n"
26798 - "13: movl 48(%4), %%eax\n"
26799 - "81: movl 52(%4), %%edx\n"
26800 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26801 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26802 " movnti %%eax, 48(%3)\n"
26803 " movnti %%edx, 52(%3)\n"
26804 - "14: movl 56(%4), %%eax\n"
26805 - "91: movl 60(%4), %%edx\n"
26806 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26807 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26808 " movnti %%eax, 56(%3)\n"
26809 " movnti %%edx, 60(%3)\n"
26810 " addl $-64, %0\n"
26811 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26812 " shrl $2, %0\n"
26813 " andl $3, %%eax\n"
26814 " cld\n"
26815 - "6: rep; movsl\n"
26816 + "6: rep; "__copyuser_seg" movsl\n"
26817 " movl %%eax,%0\n"
26818 - "7: rep; movsb\n"
26819 + "7: rep; "__copyuser_seg" movsb\n"
26820 "8:\n"
26821 ".section .fixup,\"ax\"\n"
26822 "9: lea 0(%%eax,%0,4),%0\n"
26823 @@ -392,48 +500,48 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
26824 return size;
26825 }
26826
26827 -static unsigned long __copy_user_intel_nocache(void *to,
26828 +static unsigned long __size_overflow(3) __copy_user_intel_nocache(void *to,
26829 const void __user *from, unsigned long size)
26830 {
26831 int d0, d1;
26832
26833 __asm__ __volatile__(
26834 " .align 2,0x90\n"
26835 - "0: movl 32(%4), %%eax\n"
26836 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
26837 " cmpl $67, %0\n"
26838 " jbe 2f\n"
26839 - "1: movl 64(%4), %%eax\n"
26840 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
26841 " .align 2,0x90\n"
26842 - "2: movl 0(%4), %%eax\n"
26843 - "21: movl 4(%4), %%edx\n"
26844 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
26845 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
26846 " movnti %%eax, 0(%3)\n"
26847 " movnti %%edx, 4(%3)\n"
26848 - "3: movl 8(%4), %%eax\n"
26849 - "31: movl 12(%4),%%edx\n"
26850 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
26851 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
26852 " movnti %%eax, 8(%3)\n"
26853 " movnti %%edx, 12(%3)\n"
26854 - "4: movl 16(%4), %%eax\n"
26855 - "41: movl 20(%4), %%edx\n"
26856 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
26857 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
26858 " movnti %%eax, 16(%3)\n"
26859 " movnti %%edx, 20(%3)\n"
26860 - "10: movl 24(%4), %%eax\n"
26861 - "51: movl 28(%4), %%edx\n"
26862 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
26863 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
26864 " movnti %%eax, 24(%3)\n"
26865 " movnti %%edx, 28(%3)\n"
26866 - "11: movl 32(%4), %%eax\n"
26867 - "61: movl 36(%4), %%edx\n"
26868 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
26869 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
26870 " movnti %%eax, 32(%3)\n"
26871 " movnti %%edx, 36(%3)\n"
26872 - "12: movl 40(%4), %%eax\n"
26873 - "71: movl 44(%4), %%edx\n"
26874 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
26875 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
26876 " movnti %%eax, 40(%3)\n"
26877 " movnti %%edx, 44(%3)\n"
26878 - "13: movl 48(%4), %%eax\n"
26879 - "81: movl 52(%4), %%edx\n"
26880 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
26881 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
26882 " movnti %%eax, 48(%3)\n"
26883 " movnti %%edx, 52(%3)\n"
26884 - "14: movl 56(%4), %%eax\n"
26885 - "91: movl 60(%4), %%edx\n"
26886 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
26887 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
26888 " movnti %%eax, 56(%3)\n"
26889 " movnti %%edx, 60(%3)\n"
26890 " addl $-64, %0\n"
26891 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
26892 " shrl $2, %0\n"
26893 " andl $3, %%eax\n"
26894 " cld\n"
26895 - "6: rep; movsl\n"
26896 + "6: rep; "__copyuser_seg" movsl\n"
26897 " movl %%eax,%0\n"
26898 - "7: rep; movsb\n"
26899 + "7: rep; "__copyuser_seg" movsb\n"
26900 "8:\n"
26901 ".section .fixup,\"ax\"\n"
26902 "9: lea 0(%%eax,%0,4),%0\n"
26903 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
26904 */
26905 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
26906 unsigned long size);
26907 -unsigned long __copy_user_intel(void __user *to, const void *from,
26908 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
26909 + unsigned long size);
26910 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
26911 unsigned long size);
26912 unsigned long __copy_user_zeroing_intel_nocache(void *to,
26913 const void __user *from, unsigned long size);
26914 #endif /* CONFIG_X86_INTEL_USERCOPY */
26915
26916 /* Generic arbitrary sized copy. */
26917 -#define __copy_user(to, from, size) \
26918 +#define __copy_user(to, from, size, prefix, set, restore) \
26919 do { \
26920 int __d0, __d1, __d2; \
26921 __asm__ __volatile__( \
26922 + set \
26923 " cmp $7,%0\n" \
26924 " jbe 1f\n" \
26925 " movl %1,%0\n" \
26926 " negl %0\n" \
26927 " andl $7,%0\n" \
26928 " subl %0,%3\n" \
26929 - "4: rep; movsb\n" \
26930 + "4: rep; "prefix"movsb\n" \
26931 " movl %3,%0\n" \
26932 " shrl $2,%0\n" \
26933 " andl $3,%3\n" \
26934 " .align 2,0x90\n" \
26935 - "0: rep; movsl\n" \
26936 + "0: rep; "prefix"movsl\n" \
26937 " movl %3,%0\n" \
26938 - "1: rep; movsb\n" \
26939 + "1: rep; "prefix"movsb\n" \
26940 "2:\n" \
26941 + restore \
26942 ".section .fixup,\"ax\"\n" \
26943 "5: addl %3,%0\n" \
26944 " jmp 2b\n" \
26945 @@ -538,14 +650,14 @@ do { \
26946 " negl %0\n" \
26947 " andl $7,%0\n" \
26948 " subl %0,%3\n" \
26949 - "4: rep; movsb\n" \
26950 + "4: rep; "__copyuser_seg"movsb\n" \
26951 " movl %3,%0\n" \
26952 " shrl $2,%0\n" \
26953 " andl $3,%3\n" \
26954 " .align 2,0x90\n" \
26955 - "0: rep; movsl\n" \
26956 + "0: rep; "__copyuser_seg"movsl\n" \
26957 " movl %3,%0\n" \
26958 - "1: rep; movsb\n" \
26959 + "1: rep; "__copyuser_seg"movsb\n" \
26960 "2:\n" \
26961 ".section .fixup,\"ax\"\n" \
26962 "5: addl %3,%0\n" \
26963 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
26964 {
26965 stac();
26966 if (movsl_is_ok(to, from, n))
26967 - __copy_user(to, from, n);
26968 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
26969 else
26970 - n = __copy_user_intel(to, from, n);
26971 + n = __generic_copy_to_user_intel(to, from, n);
26972 clac();
26973 return n;
26974 }
26975 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
26976 {
26977 stac();
26978 if (movsl_is_ok(to, from, n))
26979 - __copy_user(to, from, n);
26980 + __copy_user(to, from, n, __copyuser_seg, "", "");
26981 else
26982 - n = __copy_user_intel((void __user *)to,
26983 - (const void *)from, n);
26984 + n = __generic_copy_from_user_intel(to, from, n);
26985 clac();
26986 return n;
26987 }
26988 @@ -632,60 +743,38 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
26989 if (n > 64 && cpu_has_xmm2)
26990 n = __copy_user_intel_nocache(to, from, n);
26991 else
26992 - __copy_user(to, from, n);
26993 + __copy_user(to, from, n, __copyuser_seg, "", "");
26994 #else
26995 - __copy_user(to, from, n);
26996 + __copy_user(to, from, n, __copyuser_seg, "", "");
26997 #endif
26998 clac();
26999 return n;
27000 }
27001 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
27002
27003 -/**
27004 - * copy_to_user: - Copy a block of data into user space.
27005 - * @to: Destination address, in user space.
27006 - * @from: Source address, in kernel space.
27007 - * @n: Number of bytes to copy.
27008 - *
27009 - * Context: User context only. This function may sleep.
27010 - *
27011 - * Copy data from kernel space to user space.
27012 - *
27013 - * Returns number of bytes that could not be copied.
27014 - * On success, this will be zero.
27015 - */
27016 -unsigned long
27017 -copy_to_user(void __user *to, const void *from, unsigned long n)
27018 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27019 +void __set_fs(mm_segment_t x)
27020 {
27021 - if (access_ok(VERIFY_WRITE, to, n))
27022 - n = __copy_to_user(to, from, n);
27023 - return n;
27024 + switch (x.seg) {
27025 + case 0:
27026 + loadsegment(gs, 0);
27027 + break;
27028 + case TASK_SIZE_MAX:
27029 + loadsegment(gs, __USER_DS);
27030 + break;
27031 + case -1UL:
27032 + loadsegment(gs, __KERNEL_DS);
27033 + break;
27034 + default:
27035 + BUG();
27036 + }
27037 }
27038 -EXPORT_SYMBOL(copy_to_user);
27039 +EXPORT_SYMBOL(__set_fs);
27040
27041 -/**
27042 - * copy_from_user: - Copy a block of data from user space.
27043 - * @to: Destination address, in kernel space.
27044 - * @from: Source address, in user space.
27045 - * @n: Number of bytes to copy.
27046 - *
27047 - * Context: User context only. This function may sleep.
27048 - *
27049 - * Copy data from user space to kernel space.
27050 - *
27051 - * Returns number of bytes that could not be copied.
27052 - * On success, this will be zero.
27053 - *
27054 - * If some data could not be copied, this function will pad the copied
27055 - * data to the requested size using zero bytes.
27056 - */
27057 -unsigned long
27058 -_copy_from_user(void *to, const void __user *from, unsigned long n)
27059 +void set_fs(mm_segment_t x)
27060 {
27061 - if (access_ok(VERIFY_READ, from, n))
27062 - n = __copy_from_user(to, from, n);
27063 - else
27064 - memset(to, 0, n);
27065 - return n;
27066 + current_thread_info()->addr_limit = x;
27067 + __set_fs(x);
27068 }
27069 -EXPORT_SYMBOL(_copy_from_user);
27070 +EXPORT_SYMBOL(set_fs);
27071 +#endif
27072 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
27073 index 906fea3..5646695 100644
27074 --- a/arch/x86/lib/usercopy_64.c
27075 +++ b/arch/x86/lib/usercopy_64.c
27076 @@ -39,7 +39,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
27077 _ASM_EXTABLE(0b,3b)
27078 _ASM_EXTABLE(1b,2b)
27079 : [size8] "=&c"(size), [dst] "=&D" (__d0)
27080 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
27081 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
27082 [zero] "r" (0UL), [eight] "r" (8UL));
27083 clac();
27084 return size;
27085 @@ -54,12 +54,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
27086 }
27087 EXPORT_SYMBOL(clear_user);
27088
27089 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
27090 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
27091 {
27092 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
27093 - return copy_user_generic((__force void *)to, (__force void *)from, len);
27094 - }
27095 - return len;
27096 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
27097 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
27098 + return len;
27099 }
27100 EXPORT_SYMBOL(copy_in_user);
27101
27102 @@ -69,7 +68,7 @@ EXPORT_SYMBOL(copy_in_user);
27103 * it is not necessary to optimize tail handling.
27104 */
27105 unsigned long
27106 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
27107 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
27108 {
27109 char c;
27110 unsigned zero_len;
27111 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
27112 index 903ec1e..c4166b2 100644
27113 --- a/arch/x86/mm/extable.c
27114 +++ b/arch/x86/mm/extable.c
27115 @@ -6,12 +6,24 @@
27116 static inline unsigned long
27117 ex_insn_addr(const struct exception_table_entry *x)
27118 {
27119 - return (unsigned long)&x->insn + x->insn;
27120 + unsigned long reloc = 0;
27121 +
27122 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27123 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27124 +#endif
27125 +
27126 + return (unsigned long)&x->insn + x->insn + reloc;
27127 }
27128 static inline unsigned long
27129 ex_fixup_addr(const struct exception_table_entry *x)
27130 {
27131 - return (unsigned long)&x->fixup + x->fixup;
27132 + unsigned long reloc = 0;
27133 +
27134 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27135 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27136 +#endif
27137 +
27138 + return (unsigned long)&x->fixup + x->fixup + reloc;
27139 }
27140
27141 int fixup_exception(struct pt_regs *regs)
27142 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
27143 unsigned long new_ip;
27144
27145 #ifdef CONFIG_PNPBIOS
27146 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
27147 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
27148 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
27149 extern u32 pnp_bios_is_utter_crap;
27150 pnp_bios_is_utter_crap = 1;
27151 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
27152 i += 4;
27153 p->fixup -= i;
27154 i += 4;
27155 +
27156 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27157 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
27158 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27159 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
27160 +#endif
27161 +
27162 }
27163 }
27164
27165 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
27166 index 654be4a..d36985f 100644
27167 --- a/arch/x86/mm/fault.c
27168 +++ b/arch/x86/mm/fault.c
27169 @@ -14,11 +14,18 @@
27170 #include <linux/hugetlb.h> /* hstate_index_to_shift */
27171 #include <linux/prefetch.h> /* prefetchw */
27172 #include <linux/context_tracking.h> /* exception_enter(), ... */
27173 +#include <linux/unistd.h>
27174 +#include <linux/compiler.h>
27175
27176 #include <asm/traps.h> /* dotraplinkage, ... */
27177 #include <asm/pgalloc.h> /* pgd_*(), ... */
27178 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
27179 #include <asm/fixmap.h> /* VSYSCALL_START */
27180 +#include <asm/tlbflush.h>
27181 +
27182 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27183 +#include <asm/stacktrace.h>
27184 +#endif
27185
27186 /*
27187 * Page fault error code bits:
27188 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
27189 int ret = 0;
27190
27191 /* kprobe_running() needs smp_processor_id() */
27192 - if (kprobes_built_in() && !user_mode_vm(regs)) {
27193 + if (kprobes_built_in() && !user_mode(regs)) {
27194 preempt_disable();
27195 if (kprobe_running() && kprobe_fault_handler(regs, 14))
27196 ret = 1;
27197 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
27198 return !instr_lo || (instr_lo>>1) == 1;
27199 case 0x00:
27200 /* Prefetch instruction is 0x0F0D or 0x0F18 */
27201 - if (probe_kernel_address(instr, opcode))
27202 + if (user_mode(regs)) {
27203 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27204 + return 0;
27205 + } else if (probe_kernel_address(instr, opcode))
27206 return 0;
27207
27208 *prefetch = (instr_lo == 0xF) &&
27209 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
27210 while (instr < max_instr) {
27211 unsigned char opcode;
27212
27213 - if (probe_kernel_address(instr, opcode))
27214 + if (user_mode(regs)) {
27215 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
27216 + break;
27217 + } else if (probe_kernel_address(instr, opcode))
27218 break;
27219
27220 instr++;
27221 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
27222 force_sig_info(si_signo, &info, tsk);
27223 }
27224
27225 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27226 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
27227 +#endif
27228 +
27229 +#ifdef CONFIG_PAX_EMUTRAMP
27230 +static int pax_handle_fetch_fault(struct pt_regs *regs);
27231 +#endif
27232 +
27233 +#ifdef CONFIG_PAX_PAGEEXEC
27234 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
27235 +{
27236 + pgd_t *pgd;
27237 + pud_t *pud;
27238 + pmd_t *pmd;
27239 +
27240 + pgd = pgd_offset(mm, address);
27241 + if (!pgd_present(*pgd))
27242 + return NULL;
27243 + pud = pud_offset(pgd, address);
27244 + if (!pud_present(*pud))
27245 + return NULL;
27246 + pmd = pmd_offset(pud, address);
27247 + if (!pmd_present(*pmd))
27248 + return NULL;
27249 + return pmd;
27250 +}
27251 +#endif
27252 +
27253 DEFINE_SPINLOCK(pgd_lock);
27254 LIST_HEAD(pgd_list);
27255
27256 @@ -232,10 +273,22 @@ void vmalloc_sync_all(void)
27257 for (address = VMALLOC_START & PMD_MASK;
27258 address >= TASK_SIZE && address < FIXADDR_TOP;
27259 address += PMD_SIZE) {
27260 +
27261 +#ifdef CONFIG_PAX_PER_CPU_PGD
27262 + unsigned long cpu;
27263 +#else
27264 struct page *page;
27265 +#endif
27266
27267 spin_lock(&pgd_lock);
27268 +
27269 +#ifdef CONFIG_PAX_PER_CPU_PGD
27270 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
27271 + pgd_t *pgd = get_cpu_pgd(cpu);
27272 + pmd_t *ret;
27273 +#else
27274 list_for_each_entry(page, &pgd_list, lru) {
27275 + pgd_t *pgd;
27276 spinlock_t *pgt_lock;
27277 pmd_t *ret;
27278
27279 @@ -243,8 +296,14 @@ void vmalloc_sync_all(void)
27280 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
27281
27282 spin_lock(pgt_lock);
27283 - ret = vmalloc_sync_one(page_address(page), address);
27284 + pgd = page_address(page);
27285 +#endif
27286 +
27287 + ret = vmalloc_sync_one(pgd, address);
27288 +
27289 +#ifndef CONFIG_PAX_PER_CPU_PGD
27290 spin_unlock(pgt_lock);
27291 +#endif
27292
27293 if (!ret)
27294 break;
27295 @@ -278,6 +337,11 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27296 * an interrupt in the middle of a task switch..
27297 */
27298 pgd_paddr = read_cr3();
27299 +
27300 +#ifdef CONFIG_PAX_PER_CPU_PGD
27301 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (pgd_paddr & PHYSICAL_PAGE_MASK));
27302 +#endif
27303 +
27304 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
27305 if (!pmd_k)
27306 return -1;
27307 @@ -373,7 +437,14 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
27308 * happen within a race in page table update. In the later
27309 * case just flush:
27310 */
27311 +
27312 +#ifdef CONFIG_PAX_PER_CPU_PGD
27313 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id())) != (read_cr3() & PHYSICAL_PAGE_MASK));
27314 + pgd = pgd_offset_cpu(smp_processor_id(), address);
27315 +#else
27316 pgd = pgd_offset(current->active_mm, address);
27317 +#endif
27318 +
27319 pgd_ref = pgd_offset_k(address);
27320 if (pgd_none(*pgd_ref))
27321 return -1;
27322 @@ -543,7 +614,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
27323 static int is_errata100(struct pt_regs *regs, unsigned long address)
27324 {
27325 #ifdef CONFIG_X86_64
27326 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
27327 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
27328 return 1;
27329 #endif
27330 return 0;
27331 @@ -570,7 +641,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
27332 }
27333
27334 static const char nx_warning[] = KERN_CRIT
27335 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
27336 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
27337
27338 static void
27339 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27340 @@ -579,15 +650,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
27341 if (!oops_may_print())
27342 return;
27343
27344 - if (error_code & PF_INSTR) {
27345 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
27346 unsigned int level;
27347
27348 pte_t *pte = lookup_address(address, &level);
27349
27350 if (pte && pte_present(*pte) && !pte_exec(*pte))
27351 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
27352 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
27353 }
27354
27355 +#ifdef CONFIG_PAX_KERNEXEC
27356 + if (init_mm.start_code <= address && address < init_mm.end_code) {
27357 + if (current->signal->curr_ip)
27358 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
27359 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
27360 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27361 + else
27362 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
27363 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
27364 + }
27365 +#endif
27366 +
27367 printk(KERN_ALERT "BUG: unable to handle kernel ");
27368 if (address < PAGE_SIZE)
27369 printk(KERN_CONT "NULL pointer dereference");
27370 @@ -750,6 +833,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
27371 return;
27372 }
27373 #endif
27374 +
27375 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27376 + if (pax_is_fetch_fault(regs, error_code, address)) {
27377 +
27378 +#ifdef CONFIG_PAX_EMUTRAMP
27379 + switch (pax_handle_fetch_fault(regs)) {
27380 + case 2:
27381 + return;
27382 + }
27383 +#endif
27384 +
27385 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27386 + do_group_exit(SIGKILL);
27387 + }
27388 +#endif
27389 +
27390 /* Kernel addresses are always protection faults: */
27391 if (address >= TASK_SIZE)
27392 error_code |= PF_PROT;
27393 @@ -835,7 +934,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
27394 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
27395 printk(KERN_ERR
27396 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
27397 - tsk->comm, tsk->pid, address);
27398 + tsk->comm, task_pid_nr(tsk), address);
27399 code = BUS_MCEERR_AR;
27400 }
27401 #endif
27402 @@ -898,6 +997,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
27403 return 1;
27404 }
27405
27406 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27407 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
27408 +{
27409 + pte_t *pte;
27410 + pmd_t *pmd;
27411 + spinlock_t *ptl;
27412 + unsigned char pte_mask;
27413 +
27414 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
27415 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
27416 + return 0;
27417 +
27418 + /* PaX: it's our fault, let's handle it if we can */
27419 +
27420 + /* PaX: take a look at read faults before acquiring any locks */
27421 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
27422 + /* instruction fetch attempt from a protected page in user mode */
27423 + up_read(&mm->mmap_sem);
27424 +
27425 +#ifdef CONFIG_PAX_EMUTRAMP
27426 + switch (pax_handle_fetch_fault(regs)) {
27427 + case 2:
27428 + return 1;
27429 + }
27430 +#endif
27431 +
27432 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
27433 + do_group_exit(SIGKILL);
27434 + }
27435 +
27436 + pmd = pax_get_pmd(mm, address);
27437 + if (unlikely(!pmd))
27438 + return 0;
27439 +
27440 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
27441 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
27442 + pte_unmap_unlock(pte, ptl);
27443 + return 0;
27444 + }
27445 +
27446 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
27447 + /* write attempt to a protected page in user mode */
27448 + pte_unmap_unlock(pte, ptl);
27449 + return 0;
27450 + }
27451 +
27452 +#ifdef CONFIG_SMP
27453 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
27454 +#else
27455 + if (likely(address > get_limit(regs->cs)))
27456 +#endif
27457 + {
27458 + set_pte(pte, pte_mkread(*pte));
27459 + __flush_tlb_one(address);
27460 + pte_unmap_unlock(pte, ptl);
27461 + up_read(&mm->mmap_sem);
27462 + return 1;
27463 + }
27464 +
27465 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
27466 +
27467 + /*
27468 + * PaX: fill DTLB with user rights and retry
27469 + */
27470 + __asm__ __volatile__ (
27471 + "orb %2,(%1)\n"
27472 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
27473 +/*
27474 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
27475 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
27476 + * page fault when examined during a TLB load attempt. this is true not only
27477 + * for PTEs holding a non-present entry but also present entries that will
27478 + * raise a page fault (such as those set up by PaX, or the copy-on-write
27479 + * mechanism). in effect it means that we do *not* need to flush the TLBs
27480 + * for our target pages since their PTEs are simply not in the TLBs at all.
27481 +
27482 + * the best thing in omitting it is that we gain around 15-20% speed in the
27483 + * fast path of the page fault handler and can get rid of tracing since we
27484 + * can no longer flush unintended entries.
27485 + */
27486 + "invlpg (%0)\n"
27487 +#endif
27488 + __copyuser_seg"testb $0,(%0)\n"
27489 + "xorb %3,(%1)\n"
27490 + :
27491 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
27492 + : "memory", "cc");
27493 + pte_unmap_unlock(pte, ptl);
27494 + up_read(&mm->mmap_sem);
27495 + return 1;
27496 +}
27497 +#endif
27498 +
27499 /*
27500 * Handle a spurious fault caused by a stale TLB entry.
27501 *
27502 @@ -964,6 +1156,9 @@ int show_unhandled_signals = 1;
27503 static inline int
27504 access_error(unsigned long error_code, struct vm_area_struct *vma)
27505 {
27506 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
27507 + return 1;
27508 +
27509 if (error_code & PF_WRITE) {
27510 /* write, present and write, not present: */
27511 if (unlikely(!(vma->vm_flags & VM_WRITE)))
27512 @@ -992,7 +1187,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
27513 if (error_code & PF_USER)
27514 return false;
27515
27516 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
27517 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
27518 return false;
27519
27520 return true;
27521 @@ -1008,18 +1203,33 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27522 {
27523 struct vm_area_struct *vma;
27524 struct task_struct *tsk;
27525 - unsigned long address;
27526 struct mm_struct *mm;
27527 int fault;
27528 int write = error_code & PF_WRITE;
27529 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
27530 (write ? FAULT_FLAG_WRITE : 0);
27531
27532 - tsk = current;
27533 - mm = tsk->mm;
27534 -
27535 /* Get the faulting address: */
27536 - address = read_cr2();
27537 + unsigned long address = read_cr2();
27538 +
27539 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27540 + if (!user_mode(regs) && address < 2 * pax_user_shadow_base) {
27541 + if (!search_exception_tables(regs->ip)) {
27542 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27543 + bad_area_nosemaphore(regs, error_code, address);
27544 + return;
27545 + }
27546 + if (address < pax_user_shadow_base) {
27547 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
27548 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
27549 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
27550 + } else
27551 + address -= pax_user_shadow_base;
27552 + }
27553 +#endif
27554 +
27555 + tsk = current;
27556 + mm = tsk->mm;
27557
27558 /*
27559 * Detect and handle instructions that would cause a page fault for
27560 @@ -1080,7 +1290,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
27561 * User-mode registers count as a user access even for any
27562 * potential system fault or CPU buglet:
27563 */
27564 - if (user_mode_vm(regs)) {
27565 + if (user_mode(regs)) {
27566 local_irq_enable();
27567 error_code |= PF_USER;
27568 } else {
27569 @@ -1142,6 +1352,11 @@ retry:
27570 might_sleep();
27571 }
27572
27573 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
27574 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
27575 + return;
27576 +#endif
27577 +
27578 vma = find_vma(mm, address);
27579 if (unlikely(!vma)) {
27580 bad_area(regs, error_code, address);
27581 @@ -1153,18 +1368,24 @@ retry:
27582 bad_area(regs, error_code, address);
27583 return;
27584 }
27585 - if (error_code & PF_USER) {
27586 - /*
27587 - * Accessing the stack below %sp is always a bug.
27588 - * The large cushion allows instructions like enter
27589 - * and pusha to work. ("enter $65535, $31" pushes
27590 - * 32 pointers and then decrements %sp by 65535.)
27591 - */
27592 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
27593 - bad_area(regs, error_code, address);
27594 - return;
27595 - }
27596 + /*
27597 + * Accessing the stack below %sp is always a bug.
27598 + * The large cushion allows instructions like enter
27599 + * and pusha to work. ("enter $65535, $31" pushes
27600 + * 32 pointers and then decrements %sp by 65535.)
27601 + */
27602 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
27603 + bad_area(regs, error_code, address);
27604 + return;
27605 }
27606 +
27607 +#ifdef CONFIG_PAX_SEGMEXEC
27608 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
27609 + bad_area(regs, error_code, address);
27610 + return;
27611 + }
27612 +#endif
27613 +
27614 if (unlikely(expand_stack(vma, address))) {
27615 bad_area(regs, error_code, address);
27616 return;
27617 @@ -1230,3 +1451,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
27618 __do_page_fault(regs, error_code);
27619 exception_exit(prev_state);
27620 }
27621 +
27622 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27623 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
27624 +{
27625 + struct mm_struct *mm = current->mm;
27626 + unsigned long ip = regs->ip;
27627 +
27628 + if (v8086_mode(regs))
27629 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
27630 +
27631 +#ifdef CONFIG_PAX_PAGEEXEC
27632 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
27633 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
27634 + return true;
27635 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
27636 + return true;
27637 + return false;
27638 + }
27639 +#endif
27640 +
27641 +#ifdef CONFIG_PAX_SEGMEXEC
27642 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
27643 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
27644 + return true;
27645 + return false;
27646 + }
27647 +#endif
27648 +
27649 + return false;
27650 +}
27651 +#endif
27652 +
27653 +#ifdef CONFIG_PAX_EMUTRAMP
27654 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
27655 +{
27656 + int err;
27657 +
27658 + do { /* PaX: libffi trampoline emulation */
27659 + unsigned char mov, jmp;
27660 + unsigned int addr1, addr2;
27661 +
27662 +#ifdef CONFIG_X86_64
27663 + if ((regs->ip + 9) >> 32)
27664 + break;
27665 +#endif
27666 +
27667 + err = get_user(mov, (unsigned char __user *)regs->ip);
27668 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27669 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
27670 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27671 +
27672 + if (err)
27673 + break;
27674 +
27675 + if (mov == 0xB8 && jmp == 0xE9) {
27676 + regs->ax = addr1;
27677 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
27678 + return 2;
27679 + }
27680 + } while (0);
27681 +
27682 + do { /* PaX: gcc trampoline emulation #1 */
27683 + unsigned char mov1, mov2;
27684 + unsigned short jmp;
27685 + unsigned int addr1, addr2;
27686 +
27687 +#ifdef CONFIG_X86_64
27688 + if ((regs->ip + 11) >> 32)
27689 + break;
27690 +#endif
27691 +
27692 + err = get_user(mov1, (unsigned char __user *)regs->ip);
27693 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27694 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
27695 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27696 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
27697 +
27698 + if (err)
27699 + break;
27700 +
27701 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
27702 + regs->cx = addr1;
27703 + regs->ax = addr2;
27704 + regs->ip = addr2;
27705 + return 2;
27706 + }
27707 + } while (0);
27708 +
27709 + do { /* PaX: gcc trampoline emulation #2 */
27710 + unsigned char mov, jmp;
27711 + unsigned int addr1, addr2;
27712 +
27713 +#ifdef CONFIG_X86_64
27714 + if ((regs->ip + 9) >> 32)
27715 + break;
27716 +#endif
27717 +
27718 + err = get_user(mov, (unsigned char __user *)regs->ip);
27719 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
27720 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
27721 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
27722 +
27723 + if (err)
27724 + break;
27725 +
27726 + if (mov == 0xB9 && jmp == 0xE9) {
27727 + regs->cx = addr1;
27728 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
27729 + return 2;
27730 + }
27731 + } while (0);
27732 +
27733 + return 1; /* PaX in action */
27734 +}
27735 +
27736 +#ifdef CONFIG_X86_64
27737 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
27738 +{
27739 + int err;
27740 +
27741 + do { /* PaX: libffi trampoline emulation */
27742 + unsigned short mov1, mov2, jmp1;
27743 + unsigned char stcclc, jmp2;
27744 + unsigned long addr1, addr2;
27745 +
27746 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27747 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
27748 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
27749 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
27750 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
27751 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
27752 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
27753 +
27754 + if (err)
27755 + break;
27756 +
27757 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27758 + regs->r11 = addr1;
27759 + regs->r10 = addr2;
27760 + if (stcclc == 0xF8)
27761 + regs->flags &= ~X86_EFLAGS_CF;
27762 + else
27763 + regs->flags |= X86_EFLAGS_CF;
27764 + regs->ip = addr1;
27765 + return 2;
27766 + }
27767 + } while (0);
27768 +
27769 + do { /* PaX: gcc trampoline emulation #1 */
27770 + unsigned short mov1, mov2, jmp1;
27771 + unsigned char jmp2;
27772 + unsigned int addr1;
27773 + unsigned long addr2;
27774 +
27775 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27776 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
27777 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
27778 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
27779 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
27780 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
27781 +
27782 + if (err)
27783 + break;
27784 +
27785 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27786 + regs->r11 = addr1;
27787 + regs->r10 = addr2;
27788 + regs->ip = addr1;
27789 + return 2;
27790 + }
27791 + } while (0);
27792 +
27793 + do { /* PaX: gcc trampoline emulation #2 */
27794 + unsigned short mov1, mov2, jmp1;
27795 + unsigned char jmp2;
27796 + unsigned long addr1, addr2;
27797 +
27798 + err = get_user(mov1, (unsigned short __user *)regs->ip);
27799 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
27800 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
27801 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
27802 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
27803 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
27804 +
27805 + if (err)
27806 + break;
27807 +
27808 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
27809 + regs->r11 = addr1;
27810 + regs->r10 = addr2;
27811 + regs->ip = addr1;
27812 + return 2;
27813 + }
27814 + } while (0);
27815 +
27816 + return 1; /* PaX in action */
27817 +}
27818 +#endif
27819 +
27820 +/*
27821 + * PaX: decide what to do with offenders (regs->ip = fault address)
27822 + *
27823 + * returns 1 when task should be killed
27824 + * 2 when gcc trampoline was detected
27825 + */
27826 +static int pax_handle_fetch_fault(struct pt_regs *regs)
27827 +{
27828 + if (v8086_mode(regs))
27829 + return 1;
27830 +
27831 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
27832 + return 1;
27833 +
27834 +#ifdef CONFIG_X86_32
27835 + return pax_handle_fetch_fault_32(regs);
27836 +#else
27837 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
27838 + return pax_handle_fetch_fault_32(regs);
27839 + else
27840 + return pax_handle_fetch_fault_64(regs);
27841 +#endif
27842 +}
27843 +#endif
27844 +
27845 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
27846 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
27847 +{
27848 + long i;
27849 +
27850 + printk(KERN_ERR "PAX: bytes at PC: ");
27851 + for (i = 0; i < 20; i++) {
27852 + unsigned char c;
27853 + if (get_user(c, (unsigned char __force_user *)pc+i))
27854 + printk(KERN_CONT "?? ");
27855 + else
27856 + printk(KERN_CONT "%02x ", c);
27857 + }
27858 + printk("\n");
27859 +
27860 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
27861 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
27862 + unsigned long c;
27863 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
27864 +#ifdef CONFIG_X86_32
27865 + printk(KERN_CONT "???????? ");
27866 +#else
27867 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
27868 + printk(KERN_CONT "???????? ???????? ");
27869 + else
27870 + printk(KERN_CONT "???????????????? ");
27871 +#endif
27872 + } else {
27873 +#ifdef CONFIG_X86_64
27874 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
27875 + printk(KERN_CONT "%08x ", (unsigned int)c);
27876 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
27877 + } else
27878 +#endif
27879 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
27880 + }
27881 + }
27882 + printk("\n");
27883 +}
27884 +#endif
27885 +
27886 +/**
27887 + * probe_kernel_write(): safely attempt to write to a location
27888 + * @dst: address to write to
27889 + * @src: pointer to the data that shall be written
27890 + * @size: size of the data chunk
27891 + *
27892 + * Safely write to address @dst from the buffer at @src. If a kernel fault
27893 + * happens, handle that and return -EFAULT.
27894 + */
27895 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
27896 +{
27897 + long ret;
27898 + mm_segment_t old_fs = get_fs();
27899 +
27900 + set_fs(KERNEL_DS);
27901 + pagefault_disable();
27902 + pax_open_kernel();
27903 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
27904 + pax_close_kernel();
27905 + pagefault_enable();
27906 + set_fs(old_fs);
27907 +
27908 + return ret ? -EFAULT : 0;
27909 +}
27910 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
27911 index dd74e46..7d26398 100644
27912 --- a/arch/x86/mm/gup.c
27913 +++ b/arch/x86/mm/gup.c
27914 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
27915 addr = start;
27916 len = (unsigned long) nr_pages << PAGE_SHIFT;
27917 end = start + len;
27918 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
27919 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
27920 (void __user *)start, len)))
27921 return 0;
27922
27923 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
27924 index 252b8f5..4dcfdc1 100644
27925 --- a/arch/x86/mm/highmem_32.c
27926 +++ b/arch/x86/mm/highmem_32.c
27927 @@ -44,7 +44,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
27928 idx = type + KM_TYPE_NR*smp_processor_id();
27929 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
27930 BUG_ON(!pte_none(*(kmap_pte-idx)));
27931 +
27932 + pax_open_kernel();
27933 set_pte(kmap_pte-idx, mk_pte(page, prot));
27934 + pax_close_kernel();
27935 +
27936 arch_flush_lazy_mmu_mode();
27937
27938 return (void *)vaddr;
27939 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
27940 index ae1aa71..d9bea75 100644
27941 --- a/arch/x86/mm/hugetlbpage.c
27942 +++ b/arch/x86/mm/hugetlbpage.c
27943 @@ -271,23 +271,30 @@ follow_huge_pud(struct mm_struct *mm, unsigned long address,
27944 #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
27945 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
27946 unsigned long addr, unsigned long len,
27947 - unsigned long pgoff, unsigned long flags)
27948 + unsigned long pgoff, unsigned long flags, unsigned long offset)
27949 {
27950 struct hstate *h = hstate_file(file);
27951 struct vm_unmapped_area_info info;
27952 -
27953 +
27954 info.flags = 0;
27955 info.length = len;
27956 info.low_limit = TASK_UNMAPPED_BASE;
27957 +
27958 +#ifdef CONFIG_PAX_RANDMMAP
27959 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
27960 + info.low_limit += current->mm->delta_mmap;
27961 +#endif
27962 +
27963 info.high_limit = TASK_SIZE;
27964 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
27965 info.align_offset = 0;
27966 + info.threadstack_offset = offset;
27967 return vm_unmapped_area(&info);
27968 }
27969
27970 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
27971 unsigned long addr0, unsigned long len,
27972 - unsigned long pgoff, unsigned long flags)
27973 + unsigned long pgoff, unsigned long flags, unsigned long offset)
27974 {
27975 struct hstate *h = hstate_file(file);
27976 struct vm_unmapped_area_info info;
27977 @@ -299,6 +306,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
27978 info.high_limit = current->mm->mmap_base;
27979 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
27980 info.align_offset = 0;
27981 + info.threadstack_offset = offset;
27982 addr = vm_unmapped_area(&info);
27983
27984 /*
27985 @@ -311,6 +319,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
27986 VM_BUG_ON(addr != -ENOMEM);
27987 info.flags = 0;
27988 info.low_limit = TASK_UNMAPPED_BASE;
27989 +
27990 +#ifdef CONFIG_PAX_RANDMMAP
27991 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
27992 + info.low_limit += current->mm->delta_mmap;
27993 +#endif
27994 +
27995 info.high_limit = TASK_SIZE;
27996 addr = vm_unmapped_area(&info);
27997 }
27998 @@ -325,10 +339,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
27999 struct hstate *h = hstate_file(file);
28000 struct mm_struct *mm = current->mm;
28001 struct vm_area_struct *vma;
28002 + unsigned long pax_task_size = TASK_SIZE;
28003 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
28004
28005 if (len & ~huge_page_mask(h))
28006 return -EINVAL;
28007 - if (len > TASK_SIZE)
28008 +
28009 +#ifdef CONFIG_PAX_SEGMEXEC
28010 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28011 + pax_task_size = SEGMEXEC_TASK_SIZE;
28012 +#endif
28013 +
28014 + pax_task_size -= PAGE_SIZE;
28015 +
28016 + if (len > pax_task_size)
28017 return -ENOMEM;
28018
28019 if (flags & MAP_FIXED) {
28020 @@ -337,19 +361,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
28021 return addr;
28022 }
28023
28024 +#ifdef CONFIG_PAX_RANDMMAP
28025 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
28026 +#endif
28027 +
28028 if (addr) {
28029 addr = ALIGN(addr, huge_page_size(h));
28030 vma = find_vma(mm, addr);
28031 - if (TASK_SIZE - len >= addr &&
28032 - (!vma || addr + len <= vma->vm_start))
28033 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
28034 return addr;
28035 }
28036 if (mm->get_unmapped_area == arch_get_unmapped_area)
28037 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
28038 - pgoff, flags);
28039 + pgoff, flags, offset);
28040 else
28041 return hugetlb_get_unmapped_area_topdown(file, addr, len,
28042 - pgoff, flags);
28043 + pgoff, flags, offset);
28044 }
28045
28046 #endif /*HAVE_ARCH_HUGETLB_UNMAPPED_AREA*/
28047 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
28048 index 1f34e92..d252637 100644
28049 --- a/arch/x86/mm/init.c
28050 +++ b/arch/x86/mm/init.c
28051 @@ -4,6 +4,7 @@
28052 #include <linux/swap.h>
28053 #include <linux/memblock.h>
28054 #include <linux/bootmem.h> /* for max_low_pfn */
28055 +#include <linux/tboot.h>
28056
28057 #include <asm/cacheflush.h>
28058 #include <asm/e820.h>
28059 @@ -17,6 +18,8 @@
28060 #include <asm/proto.h>
28061 #include <asm/dma.h> /* for MAX_DMA_PFN */
28062 #include <asm/microcode.h>
28063 +#include <asm/desc.h>
28064 +#include <asm/bios_ebda.h>
28065
28066 #include "mm_internal.h"
28067
28068 @@ -465,7 +468,15 @@ void __init init_mem_mapping(void)
28069 early_ioremap_page_table_range_init();
28070 #endif
28071
28072 +#ifdef CONFIG_PAX_PER_CPU_PGD
28073 + clone_pgd_range(get_cpu_pgd(0) + KERNEL_PGD_BOUNDARY,
28074 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
28075 + KERNEL_PGD_PTRS);
28076 + load_cr3(get_cpu_pgd(0));
28077 +#else
28078 load_cr3(swapper_pg_dir);
28079 +#endif
28080 +
28081 __flush_tlb_all();
28082
28083 early_memtest(0, max_pfn_mapped << PAGE_SHIFT);
28084 @@ -481,10 +492,40 @@ void __init init_mem_mapping(void)
28085 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
28086 * mmio resources as well as potential bios/acpi data regions.
28087 */
28088 +
28089 +#ifdef CONFIG_GRKERNSEC_KMEM
28090 +static unsigned int ebda_start __read_only;
28091 +static unsigned int ebda_end __read_only;
28092 +#endif
28093 +
28094 int devmem_is_allowed(unsigned long pagenr)
28095 {
28096 - if (pagenr < 256)
28097 +#ifdef CONFIG_GRKERNSEC_KMEM
28098 + /* allow BDA */
28099 + if (!pagenr)
28100 return 1;
28101 + /* allow EBDA */
28102 + if (pagenr >= ebda_start && pagenr < ebda_end)
28103 + return 1;
28104 + /* if tboot is in use, allow access to its hardcoded serial log range */
28105 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
28106 + return 1;
28107 +#else
28108 + if (!pagenr)
28109 + return 1;
28110 +#ifdef CONFIG_VM86
28111 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
28112 + return 1;
28113 +#endif
28114 +#endif
28115 +
28116 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
28117 + return 1;
28118 +#ifdef CONFIG_GRKERNSEC_KMEM
28119 + /* throw out everything else below 1MB */
28120 + if (pagenr <= 256)
28121 + return 0;
28122 +#endif
28123 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
28124 return 0;
28125 if (!page_is_ram(pagenr))
28126 @@ -538,8 +579,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
28127 #endif
28128 }
28129
28130 +#ifdef CONFIG_GRKERNSEC_KMEM
28131 +static inline void gr_init_ebda(void)
28132 +{
28133 + unsigned int ebda_addr;
28134 + unsigned int ebda_size = 0;
28135 +
28136 + ebda_addr = get_bios_ebda();
28137 + if (ebda_addr) {
28138 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
28139 + ebda_size <<= 10;
28140 + }
28141 + if (ebda_addr && ebda_size) {
28142 + ebda_start = ebda_addr >> PAGE_SHIFT;
28143 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
28144 + } else {
28145 + ebda_start = 0x9f000 >> PAGE_SHIFT;
28146 + ebda_end = 0xa0000 >> PAGE_SHIFT;
28147 + }
28148 +}
28149 +#else
28150 +static inline void gr_init_ebda(void) { }
28151 +#endif
28152 +
28153 void free_initmem(void)
28154 {
28155 +#ifdef CONFIG_PAX_KERNEXEC
28156 +#ifdef CONFIG_X86_32
28157 + /* PaX: limit KERNEL_CS to actual size */
28158 + unsigned long addr, limit;
28159 + struct desc_struct d;
28160 + int cpu;
28161 +#else
28162 + pgd_t *pgd;
28163 + pud_t *pud;
28164 + pmd_t *pmd;
28165 + unsigned long addr, end;
28166 +#endif
28167 +#endif
28168 +
28169 + gr_init_ebda();
28170 +
28171 +#ifdef CONFIG_PAX_KERNEXEC
28172 +#ifdef CONFIG_X86_32
28173 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
28174 + limit = (limit - 1UL) >> PAGE_SHIFT;
28175 +
28176 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
28177 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
28178 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
28179 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
28180 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
28181 + }
28182 +
28183 + /* PaX: make KERNEL_CS read-only */
28184 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
28185 + if (!paravirt_enabled())
28186 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
28187 +/*
28188 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
28189 + pgd = pgd_offset_k(addr);
28190 + pud = pud_offset(pgd, addr);
28191 + pmd = pmd_offset(pud, addr);
28192 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28193 + }
28194 +*/
28195 +#ifdef CONFIG_X86_PAE
28196 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
28197 +/*
28198 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
28199 + pgd = pgd_offset_k(addr);
28200 + pud = pud_offset(pgd, addr);
28201 + pmd = pmd_offset(pud, addr);
28202 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28203 + }
28204 +*/
28205 +#endif
28206 +
28207 +#ifdef CONFIG_MODULES
28208 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
28209 +#endif
28210 +
28211 +#else
28212 + /* PaX: make kernel code/rodata read-only, rest non-executable */
28213 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
28214 + pgd = pgd_offset_k(addr);
28215 + pud = pud_offset(pgd, addr);
28216 + pmd = pmd_offset(pud, addr);
28217 + if (!pmd_present(*pmd))
28218 + continue;
28219 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
28220 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28221 + else
28222 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
28223 + }
28224 +
28225 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
28226 + end = addr + KERNEL_IMAGE_SIZE;
28227 + for (; addr < end; addr += PMD_SIZE) {
28228 + pgd = pgd_offset_k(addr);
28229 + pud = pud_offset(pgd, addr);
28230 + pmd = pmd_offset(pud, addr);
28231 + if (!pmd_present(*pmd))
28232 + continue;
28233 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
28234 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
28235 + }
28236 +#endif
28237 +
28238 + flush_tlb_all();
28239 +#endif
28240 +
28241 free_init_pages("unused kernel memory",
28242 (unsigned long)(&__init_begin),
28243 (unsigned long)(&__init_end));
28244 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
28245 index 3ac7e31..89611b7 100644
28246 --- a/arch/x86/mm/init_32.c
28247 +++ b/arch/x86/mm/init_32.c
28248 @@ -62,33 +62,6 @@ static noinline int do_test_wp_bit(void);
28249 bool __read_mostly __vmalloc_start_set = false;
28250
28251 /*
28252 - * Creates a middle page table and puts a pointer to it in the
28253 - * given global directory entry. This only returns the gd entry
28254 - * in non-PAE compilation mode, since the middle layer is folded.
28255 - */
28256 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
28257 -{
28258 - pud_t *pud;
28259 - pmd_t *pmd_table;
28260 -
28261 -#ifdef CONFIG_X86_PAE
28262 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
28263 - pmd_table = (pmd_t *)alloc_low_page();
28264 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
28265 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
28266 - pud = pud_offset(pgd, 0);
28267 - BUG_ON(pmd_table != pmd_offset(pud, 0));
28268 -
28269 - return pmd_table;
28270 - }
28271 -#endif
28272 - pud = pud_offset(pgd, 0);
28273 - pmd_table = pmd_offset(pud, 0);
28274 -
28275 - return pmd_table;
28276 -}
28277 -
28278 -/*
28279 * Create a page table and place a pointer to it in a middle page
28280 * directory entry:
28281 */
28282 @@ -98,13 +71,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
28283 pte_t *page_table = (pte_t *)alloc_low_page();
28284
28285 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
28286 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
28287 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
28288 +#else
28289 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
28290 +#endif
28291 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
28292 }
28293
28294 return pte_offset_kernel(pmd, 0);
28295 }
28296
28297 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
28298 +{
28299 + pud_t *pud;
28300 + pmd_t *pmd_table;
28301 +
28302 + pud = pud_offset(pgd, 0);
28303 + pmd_table = pmd_offset(pud, 0);
28304 +
28305 + return pmd_table;
28306 +}
28307 +
28308 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
28309 {
28310 int pgd_idx = pgd_index(vaddr);
28311 @@ -208,6 +196,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28312 int pgd_idx, pmd_idx;
28313 unsigned long vaddr;
28314 pgd_t *pgd;
28315 + pud_t *pud;
28316 pmd_t *pmd;
28317 pte_t *pte = NULL;
28318 unsigned long count = page_table_range_init_count(start, end);
28319 @@ -222,8 +211,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28320 pgd = pgd_base + pgd_idx;
28321
28322 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
28323 - pmd = one_md_table_init(pgd);
28324 - pmd = pmd + pmd_index(vaddr);
28325 + pud = pud_offset(pgd, vaddr);
28326 + pmd = pmd_offset(pud, vaddr);
28327 +
28328 +#ifdef CONFIG_X86_PAE
28329 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28330 +#endif
28331 +
28332 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
28333 pmd++, pmd_idx++) {
28334 pte = page_table_kmap_check(one_page_table_init(pmd),
28335 @@ -235,11 +229,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
28336 }
28337 }
28338
28339 -static inline int is_kernel_text(unsigned long addr)
28340 +static inline int is_kernel_text(unsigned long start, unsigned long end)
28341 {
28342 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
28343 - return 1;
28344 - return 0;
28345 + if ((start > ktla_ktva((unsigned long)_etext) ||
28346 + end <= ktla_ktva((unsigned long)_stext)) &&
28347 + (start > ktla_ktva((unsigned long)_einittext) ||
28348 + end <= ktla_ktva((unsigned long)_sinittext)) &&
28349 +
28350 +#ifdef CONFIG_ACPI_SLEEP
28351 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
28352 +#endif
28353 +
28354 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
28355 + return 0;
28356 + return 1;
28357 }
28358
28359 /*
28360 @@ -256,9 +259,10 @@ kernel_physical_mapping_init(unsigned long start,
28361 unsigned long last_map_addr = end;
28362 unsigned long start_pfn, end_pfn;
28363 pgd_t *pgd_base = swapper_pg_dir;
28364 - int pgd_idx, pmd_idx, pte_ofs;
28365 + unsigned int pgd_idx, pmd_idx, pte_ofs;
28366 unsigned long pfn;
28367 pgd_t *pgd;
28368 + pud_t *pud;
28369 pmd_t *pmd;
28370 pte_t *pte;
28371 unsigned pages_2m, pages_4k;
28372 @@ -291,8 +295,13 @@ repeat:
28373 pfn = start_pfn;
28374 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28375 pgd = pgd_base + pgd_idx;
28376 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
28377 - pmd = one_md_table_init(pgd);
28378 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
28379 + pud = pud_offset(pgd, 0);
28380 + pmd = pmd_offset(pud, 0);
28381 +
28382 +#ifdef CONFIG_X86_PAE
28383 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
28384 +#endif
28385
28386 if (pfn >= end_pfn)
28387 continue;
28388 @@ -304,14 +313,13 @@ repeat:
28389 #endif
28390 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
28391 pmd++, pmd_idx++) {
28392 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
28393 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
28394
28395 /*
28396 * Map with big pages if possible, otherwise
28397 * create normal page tables:
28398 */
28399 if (use_pse) {
28400 - unsigned int addr2;
28401 pgprot_t prot = PAGE_KERNEL_LARGE;
28402 /*
28403 * first pass will use the same initial
28404 @@ -322,11 +330,7 @@ repeat:
28405 _PAGE_PSE);
28406
28407 pfn &= PMD_MASK >> PAGE_SHIFT;
28408 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
28409 - PAGE_OFFSET + PAGE_SIZE-1;
28410 -
28411 - if (is_kernel_text(addr) ||
28412 - is_kernel_text(addr2))
28413 + if (is_kernel_text(address, address + PMD_SIZE))
28414 prot = PAGE_KERNEL_LARGE_EXEC;
28415
28416 pages_2m++;
28417 @@ -343,7 +347,7 @@ repeat:
28418 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
28419 pte += pte_ofs;
28420 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
28421 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
28422 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
28423 pgprot_t prot = PAGE_KERNEL;
28424 /*
28425 * first pass will use the same initial
28426 @@ -351,7 +355,7 @@ repeat:
28427 */
28428 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
28429
28430 - if (is_kernel_text(addr))
28431 + if (is_kernel_text(address, address + PAGE_SIZE))
28432 prot = PAGE_KERNEL_EXEC;
28433
28434 pages_4k++;
28435 @@ -474,7 +478,7 @@ void __init native_pagetable_init(void)
28436
28437 pud = pud_offset(pgd, va);
28438 pmd = pmd_offset(pud, va);
28439 - if (!pmd_present(*pmd))
28440 + if (!pmd_present(*pmd)) // PAX TODO || pmd_large(*pmd))
28441 break;
28442
28443 /* should not be large page here */
28444 @@ -532,12 +536,10 @@ void __init early_ioremap_page_table_range_init(void)
28445
28446 static void __init pagetable_init(void)
28447 {
28448 - pgd_t *pgd_base = swapper_pg_dir;
28449 -
28450 - permanent_kmaps_init(pgd_base);
28451 + permanent_kmaps_init(swapper_pg_dir);
28452 }
28453
28454 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28455 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
28456 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28457
28458 /* user-defined highmem size */
28459 @@ -772,7 +774,7 @@ void __init mem_init(void)
28460 after_bootmem = 1;
28461
28462 codesize = (unsigned long) &_etext - (unsigned long) &_text;
28463 - datasize = (unsigned long) &_edata - (unsigned long) &_etext;
28464 + datasize = (unsigned long) &_edata - (unsigned long) &_sdata;
28465 initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
28466
28467 printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
28468 @@ -813,10 +815,10 @@ void __init mem_init(void)
28469 ((unsigned long)&__init_end -
28470 (unsigned long)&__init_begin) >> 10,
28471
28472 - (unsigned long)&_etext, (unsigned long)&_edata,
28473 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
28474 + (unsigned long)&_sdata, (unsigned long)&_edata,
28475 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
28476
28477 - (unsigned long)&_text, (unsigned long)&_etext,
28478 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
28479 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
28480
28481 /*
28482 @@ -906,6 +908,7 @@ void set_kernel_text_rw(void)
28483 if (!kernel_set_to_readonly)
28484 return;
28485
28486 + start = ktla_ktva(start);
28487 pr_debug("Set kernel text: %lx - %lx for read write\n",
28488 start, start+size);
28489
28490 @@ -920,6 +923,7 @@ void set_kernel_text_ro(void)
28491 if (!kernel_set_to_readonly)
28492 return;
28493
28494 + start = ktla_ktva(start);
28495 pr_debug("Set kernel text: %lx - %lx for read only\n",
28496 start, start+size);
28497
28498 @@ -948,6 +952,7 @@ void mark_rodata_ro(void)
28499 unsigned long start = PFN_ALIGN(_text);
28500 unsigned long size = PFN_ALIGN(_etext) - start;
28501
28502 + start = ktla_ktva(start);
28503 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
28504 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
28505 size >> 10);
28506 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
28507 index bb00c46..f31d2f0 100644
28508 --- a/arch/x86/mm/init_64.c
28509 +++ b/arch/x86/mm/init_64.c
28510 @@ -151,7 +151,7 @@ early_param("gbpages", parse_direct_gbpages_on);
28511 * around without checking the pgd every time.
28512 */
28513
28514 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
28515 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
28516 EXPORT_SYMBOL_GPL(__supported_pte_mask);
28517
28518 int force_personality32;
28519 @@ -184,12 +184,22 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28520
28521 for (address = start; address <= end; address += PGDIR_SIZE) {
28522 const pgd_t *pgd_ref = pgd_offset_k(address);
28523 +
28524 +#ifdef CONFIG_PAX_PER_CPU_PGD
28525 + unsigned long cpu;
28526 +#else
28527 struct page *page;
28528 +#endif
28529
28530 if (pgd_none(*pgd_ref))
28531 continue;
28532
28533 spin_lock(&pgd_lock);
28534 +
28535 +#ifdef CONFIG_PAX_PER_CPU_PGD
28536 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
28537 + pgd_t *pgd = pgd_offset_cpu(cpu, address);
28538 +#else
28539 list_for_each_entry(page, &pgd_list, lru) {
28540 pgd_t *pgd;
28541 spinlock_t *pgt_lock;
28542 @@ -198,6 +208,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28543 /* the pgt_lock only for Xen */
28544 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
28545 spin_lock(pgt_lock);
28546 +#endif
28547
28548 if (pgd_none(*pgd))
28549 set_pgd(pgd, *pgd_ref);
28550 @@ -205,7 +216,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
28551 BUG_ON(pgd_page_vaddr(*pgd)
28552 != pgd_page_vaddr(*pgd_ref));
28553
28554 +#ifndef CONFIG_PAX_PER_CPU_PGD
28555 spin_unlock(pgt_lock);
28556 +#endif
28557 +
28558 }
28559 spin_unlock(&pgd_lock);
28560 }
28561 @@ -238,7 +252,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
28562 {
28563 if (pgd_none(*pgd)) {
28564 pud_t *pud = (pud_t *)spp_getpage();
28565 - pgd_populate(&init_mm, pgd, pud);
28566 + pgd_populate_kernel(&init_mm, pgd, pud);
28567 if (pud != pud_offset(pgd, 0))
28568 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
28569 pud, pud_offset(pgd, 0));
28570 @@ -250,7 +264,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
28571 {
28572 if (pud_none(*pud)) {
28573 pmd_t *pmd = (pmd_t *) spp_getpage();
28574 - pud_populate(&init_mm, pud, pmd);
28575 + pud_populate_kernel(&init_mm, pud, pmd);
28576 if (pmd != pmd_offset(pud, 0))
28577 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
28578 pmd, pmd_offset(pud, 0));
28579 @@ -279,7 +293,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
28580 pmd = fill_pmd(pud, vaddr);
28581 pte = fill_pte(pmd, vaddr);
28582
28583 + pax_open_kernel();
28584 set_pte(pte, new_pte);
28585 + pax_close_kernel();
28586
28587 /*
28588 * It's enough to flush this one mapping.
28589 @@ -338,14 +354,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
28590 pgd = pgd_offset_k((unsigned long)__va(phys));
28591 if (pgd_none(*pgd)) {
28592 pud = (pud_t *) spp_getpage();
28593 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
28594 - _PAGE_USER));
28595 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
28596 }
28597 pud = pud_offset(pgd, (unsigned long)__va(phys));
28598 if (pud_none(*pud)) {
28599 pmd = (pmd_t *) spp_getpage();
28600 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
28601 - _PAGE_USER));
28602 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
28603 }
28604 pmd = pmd_offset(pud, phys);
28605 BUG_ON(!pmd_none(*pmd));
28606 @@ -586,7 +600,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
28607 prot);
28608
28609 spin_lock(&init_mm.page_table_lock);
28610 - pud_populate(&init_mm, pud, pmd);
28611 + pud_populate_kernel(&init_mm, pud, pmd);
28612 spin_unlock(&init_mm.page_table_lock);
28613 }
28614 __flush_tlb_all();
28615 @@ -627,7 +641,7 @@ kernel_physical_mapping_init(unsigned long start,
28616 page_size_mask);
28617
28618 spin_lock(&init_mm.page_table_lock);
28619 - pgd_populate(&init_mm, pgd, pud);
28620 + pgd_populate_kernel(&init_mm, pgd, pud);
28621 spin_unlock(&init_mm.page_table_lock);
28622 pgd_changed = true;
28623 }
28624 @@ -1221,8 +1235,8 @@ int kern_addr_valid(unsigned long addr)
28625 static struct vm_area_struct gate_vma = {
28626 .vm_start = VSYSCALL_START,
28627 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
28628 - .vm_page_prot = PAGE_READONLY_EXEC,
28629 - .vm_flags = VM_READ | VM_EXEC
28630 + .vm_page_prot = PAGE_READONLY,
28631 + .vm_flags = VM_READ
28632 };
28633
28634 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
28635 @@ -1256,7 +1270,7 @@ int in_gate_area_no_mm(unsigned long addr)
28636
28637 const char *arch_vma_name(struct vm_area_struct *vma)
28638 {
28639 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
28640 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
28641 return "[vdso]";
28642 if (vma == &gate_vma)
28643 return "[vsyscall]";
28644 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
28645 index 7b179b4..6bd17777 100644
28646 --- a/arch/x86/mm/iomap_32.c
28647 +++ b/arch/x86/mm/iomap_32.c
28648 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
28649 type = kmap_atomic_idx_push();
28650 idx = type + KM_TYPE_NR * smp_processor_id();
28651 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
28652 +
28653 + pax_open_kernel();
28654 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
28655 + pax_close_kernel();
28656 +
28657 arch_flush_lazy_mmu_mode();
28658
28659 return (void *)vaddr;
28660 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
28661 index 9a1e658..da003f3 100644
28662 --- a/arch/x86/mm/ioremap.c
28663 +++ b/arch/x86/mm/ioremap.c
28664 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
28665 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
28666 int is_ram = page_is_ram(pfn);
28667
28668 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
28669 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
28670 return NULL;
28671 WARN_ON_ONCE(is_ram);
28672 }
28673 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
28674 *
28675 * Caller must ensure there is only one unmapping for the same pointer.
28676 */
28677 -void iounmap(volatile void __iomem *addr)
28678 +void iounmap(const volatile void __iomem *addr)
28679 {
28680 struct vm_struct *p, *o;
28681
28682 @@ -310,6 +310,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
28683
28684 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
28685 if (page_is_ram(start >> PAGE_SHIFT))
28686 +#ifdef CONFIG_HIGHMEM
28687 + if ((start >> PAGE_SHIFT) < max_low_pfn)
28688 +#endif
28689 return __va(phys);
28690
28691 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
28692 @@ -322,6 +325,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
28693 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
28694 {
28695 if (page_is_ram(phys >> PAGE_SHIFT))
28696 +#ifdef CONFIG_HIGHMEM
28697 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
28698 +#endif
28699 return;
28700
28701 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
28702 @@ -339,7 +345,7 @@ static int __init early_ioremap_debug_setup(char *str)
28703 early_param("early_ioremap_debug", early_ioremap_debug_setup);
28704
28705 static __initdata int after_paging_init;
28706 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
28707 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
28708
28709 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
28710 {
28711 @@ -376,8 +382,7 @@ void __init early_ioremap_init(void)
28712 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
28713
28714 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
28715 - memset(bm_pte, 0, sizeof(bm_pte));
28716 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
28717 + pmd_populate_user(&init_mm, pmd, bm_pte);
28718
28719 /*
28720 * The boot-ioremap range spans multiple pmds, for which
28721 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
28722 index d87dd6d..bf3fa66 100644
28723 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
28724 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
28725 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
28726 * memory (e.g. tracked pages)? For now, we need this to avoid
28727 * invoking kmemcheck for PnP BIOS calls.
28728 */
28729 - if (regs->flags & X86_VM_MASK)
28730 + if (v8086_mode(regs))
28731 return false;
28732 - if (regs->cs != __KERNEL_CS)
28733 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
28734 return false;
28735
28736 pte = kmemcheck_pte_lookup(address);
28737 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
28738 index 845df68..1d8d29f 100644
28739 --- a/arch/x86/mm/mmap.c
28740 +++ b/arch/x86/mm/mmap.c
28741 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
28742 * Leave an at least ~128 MB hole with possible stack randomization.
28743 */
28744 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
28745 -#define MAX_GAP (TASK_SIZE/6*5)
28746 +#define MAX_GAP (pax_task_size/6*5)
28747
28748 static int mmap_is_legacy(void)
28749 {
28750 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
28751 return rnd << PAGE_SHIFT;
28752 }
28753
28754 -static unsigned long mmap_base(void)
28755 +static unsigned long mmap_base(struct mm_struct *mm)
28756 {
28757 unsigned long gap = rlimit(RLIMIT_STACK);
28758 + unsigned long pax_task_size = TASK_SIZE;
28759 +
28760 +#ifdef CONFIG_PAX_SEGMEXEC
28761 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28762 + pax_task_size = SEGMEXEC_TASK_SIZE;
28763 +#endif
28764
28765 if (gap < MIN_GAP)
28766 gap = MIN_GAP;
28767 else if (gap > MAX_GAP)
28768 gap = MAX_GAP;
28769
28770 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
28771 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
28772 }
28773
28774 /*
28775 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
28776 * does, but not when emulating X86_32
28777 */
28778 -static unsigned long mmap_legacy_base(void)
28779 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
28780 {
28781 - if (mmap_is_ia32())
28782 + if (mmap_is_ia32()) {
28783 +
28784 +#ifdef CONFIG_PAX_SEGMEXEC
28785 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
28786 + return SEGMEXEC_TASK_UNMAPPED_BASE;
28787 + else
28788 +#endif
28789 +
28790 return TASK_UNMAPPED_BASE;
28791 - else
28792 + } else
28793 return TASK_UNMAPPED_BASE + mmap_rnd();
28794 }
28795
28796 @@ -113,11 +126,23 @@ static unsigned long mmap_legacy_base(void)
28797 void arch_pick_mmap_layout(struct mm_struct *mm)
28798 {
28799 if (mmap_is_legacy()) {
28800 - mm->mmap_base = mmap_legacy_base();
28801 + mm->mmap_base = mmap_legacy_base(mm);
28802 +
28803 +#ifdef CONFIG_PAX_RANDMMAP
28804 + if (mm->pax_flags & MF_PAX_RANDMMAP)
28805 + mm->mmap_base += mm->delta_mmap;
28806 +#endif
28807 +
28808 mm->get_unmapped_area = arch_get_unmapped_area;
28809 mm->unmap_area = arch_unmap_area;
28810 } else {
28811 - mm->mmap_base = mmap_base();
28812 + mm->mmap_base = mmap_base(mm);
28813 +
28814 +#ifdef CONFIG_PAX_RANDMMAP
28815 + if (mm->pax_flags & MF_PAX_RANDMMAP)
28816 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
28817 +#endif
28818 +
28819 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
28820 mm->unmap_area = arch_unmap_area_topdown;
28821 }
28822 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
28823 index dc0b727..f612039 100644
28824 --- a/arch/x86/mm/mmio-mod.c
28825 +++ b/arch/x86/mm/mmio-mod.c
28826 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
28827 break;
28828 default:
28829 {
28830 - unsigned char *ip = (unsigned char *)instptr;
28831 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
28832 my_trace->opcode = MMIO_UNKNOWN_OP;
28833 my_trace->width = 0;
28834 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
28835 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
28836 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
28837 void __iomem *addr)
28838 {
28839 - static atomic_t next_id;
28840 + static atomic_unchecked_t next_id;
28841 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
28842 /* These are page-unaligned. */
28843 struct mmiotrace_map map = {
28844 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
28845 .private = trace
28846 },
28847 .phys = offset,
28848 - .id = atomic_inc_return(&next_id)
28849 + .id = atomic_inc_return_unchecked(&next_id)
28850 };
28851 map.map_id = trace->id;
28852
28853 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
28854 ioremap_trace_core(offset, size, addr);
28855 }
28856
28857 -static void iounmap_trace_core(volatile void __iomem *addr)
28858 +static void iounmap_trace_core(const volatile void __iomem *addr)
28859 {
28860 struct mmiotrace_map map = {
28861 .phys = 0,
28862 @@ -328,7 +328,7 @@ not_enabled:
28863 }
28864 }
28865
28866 -void mmiotrace_iounmap(volatile void __iomem *addr)
28867 +void mmiotrace_iounmap(const volatile void __iomem *addr)
28868 {
28869 might_sleep();
28870 if (is_enabled()) /* recheck and proper locking in *_core() */
28871 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
28872 index a71c4e2..301ae44 100644
28873 --- a/arch/x86/mm/numa.c
28874 +++ b/arch/x86/mm/numa.c
28875 @@ -474,7 +474,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
28876 return true;
28877 }
28878
28879 -static int __init numa_register_memblks(struct numa_meminfo *mi)
28880 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
28881 {
28882 unsigned long uninitialized_var(pfn_align);
28883 int i, nid;
28884 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
28885 index d0b1773..4c3327c 100644
28886 --- a/arch/x86/mm/pageattr-test.c
28887 +++ b/arch/x86/mm/pageattr-test.c
28888 @@ -36,7 +36,7 @@ enum {
28889
28890 static int pte_testbit(pte_t pte)
28891 {
28892 - return pte_flags(pte) & _PAGE_UNUSED1;
28893 + return pte_flags(pte) & _PAGE_CPA_TEST;
28894 }
28895
28896 struct split_state {
28897 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
28898 index bb32480..aef8278 100644
28899 --- a/arch/x86/mm/pageattr.c
28900 +++ b/arch/x86/mm/pageattr.c
28901 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28902 */
28903 #ifdef CONFIG_PCI_BIOS
28904 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
28905 - pgprot_val(forbidden) |= _PAGE_NX;
28906 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28907 #endif
28908
28909 /*
28910 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28911 * Does not cover __inittext since that is gone later on. On
28912 * 64bit we do not enforce !NX on the low mapping
28913 */
28914 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
28915 - pgprot_val(forbidden) |= _PAGE_NX;
28916 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
28917 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28918
28919 +#ifdef CONFIG_DEBUG_RODATA
28920 /*
28921 * The .rodata section needs to be read-only. Using the pfn
28922 * catches all aliases.
28923 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28924 if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT,
28925 __pa_symbol(__end_rodata) >> PAGE_SHIFT))
28926 pgprot_val(forbidden) |= _PAGE_RW;
28927 +#endif
28928
28929 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
28930 /*
28931 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
28932 }
28933 #endif
28934
28935 +#ifdef CONFIG_PAX_KERNEXEC
28936 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
28937 + pgprot_val(forbidden) |= _PAGE_RW;
28938 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
28939 + }
28940 +#endif
28941 +
28942 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
28943
28944 return prot;
28945 @@ -400,23 +409,37 @@ EXPORT_SYMBOL_GPL(slow_virt_to_phys);
28946 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
28947 {
28948 /* change init_mm */
28949 + pax_open_kernel();
28950 set_pte_atomic(kpte, pte);
28951 +
28952 #ifdef CONFIG_X86_32
28953 if (!SHARED_KERNEL_PMD) {
28954 +
28955 +#ifdef CONFIG_PAX_PER_CPU_PGD
28956 + unsigned long cpu;
28957 +#else
28958 struct page *page;
28959 +#endif
28960
28961 +#ifdef CONFIG_PAX_PER_CPU_PGD
28962 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
28963 + pgd_t *pgd = get_cpu_pgd(cpu);
28964 +#else
28965 list_for_each_entry(page, &pgd_list, lru) {
28966 - pgd_t *pgd;
28967 + pgd_t *pgd = (pgd_t *)page_address(page);
28968 +#endif
28969 +
28970 pud_t *pud;
28971 pmd_t *pmd;
28972
28973 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
28974 + pgd += pgd_index(address);
28975 pud = pud_offset(pgd, address);
28976 pmd = pmd_offset(pud, address);
28977 set_pte_atomic((pte_t *)pmd, pte);
28978 }
28979 }
28980 #endif
28981 + pax_close_kernel();
28982 }
28983
28984 static int
28985 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
28986 index 6574388..87e9bef 100644
28987 --- a/arch/x86/mm/pat.c
28988 +++ b/arch/x86/mm/pat.c
28989 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
28990
28991 if (!entry) {
28992 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
28993 - current->comm, current->pid, start, end - 1);
28994 + current->comm, task_pid_nr(current), start, end - 1);
28995 return -EINVAL;
28996 }
28997
28998 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
28999
29000 while (cursor < to) {
29001 if (!devmem_is_allowed(pfn)) {
29002 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
29003 - current->comm, from, to - 1);
29004 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
29005 + current->comm, from, to - 1, cursor);
29006 return 0;
29007 }
29008 cursor += PAGE_SIZE;
29009 @@ -577,7 +577,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
29010 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
29011 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
29012 "for [mem %#010Lx-%#010Lx]\n",
29013 - current->comm, current->pid,
29014 + current->comm, task_pid_nr(current),
29015 cattr_name(flags),
29016 base, (unsigned long long)(base + size-1));
29017 return -EINVAL;
29018 @@ -612,7 +612,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29019 flags = lookup_memtype(paddr);
29020 if (want_flags != flags) {
29021 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
29022 - current->comm, current->pid,
29023 + current->comm, task_pid_nr(current),
29024 cattr_name(want_flags),
29025 (unsigned long long)paddr,
29026 (unsigned long long)(paddr + size - 1),
29027 @@ -634,7 +634,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
29028 free_memtype(paddr, paddr + size);
29029 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
29030 " for [mem %#010Lx-%#010Lx], got %s\n",
29031 - current->comm, current->pid,
29032 + current->comm, task_pid_nr(current),
29033 cattr_name(want_flags),
29034 (unsigned long long)paddr,
29035 (unsigned long long)(paddr + size - 1),
29036 diff --git a/arch/x86/mm/pat_rbtree.c b/arch/x86/mm/pat_rbtree.c
29037 index 415f6c4..d319983 100644
29038 --- a/arch/x86/mm/pat_rbtree.c
29039 +++ b/arch/x86/mm/pat_rbtree.c
29040 @@ -160,7 +160,7 @@ success:
29041
29042 failure:
29043 printk(KERN_INFO "%s:%d conflicting memory types "
29044 - "%Lx-%Lx %s<->%s\n", current->comm, current->pid, start,
29045 + "%Lx-%Lx %s<->%s\n", current->comm, task_pid_nr(current), start,
29046 end, cattr_name(found_type), cattr_name(match->type));
29047 return -EBUSY;
29048 }
29049 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
29050 index 9f0614d..92ae64a 100644
29051 --- a/arch/x86/mm/pf_in.c
29052 +++ b/arch/x86/mm/pf_in.c
29053 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
29054 int i;
29055 enum reason_type rv = OTHERS;
29056
29057 - p = (unsigned char *)ins_addr;
29058 + p = (unsigned char *)ktla_ktva(ins_addr);
29059 p += skip_prefix(p, &prf);
29060 p += get_opcode(p, &opcode);
29061
29062 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
29063 struct prefix_bits prf;
29064 int i;
29065
29066 - p = (unsigned char *)ins_addr;
29067 + p = (unsigned char *)ktla_ktva(ins_addr);
29068 p += skip_prefix(p, &prf);
29069 p += get_opcode(p, &opcode);
29070
29071 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
29072 struct prefix_bits prf;
29073 int i;
29074
29075 - p = (unsigned char *)ins_addr;
29076 + p = (unsigned char *)ktla_ktva(ins_addr);
29077 p += skip_prefix(p, &prf);
29078 p += get_opcode(p, &opcode);
29079
29080 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
29081 struct prefix_bits prf;
29082 int i;
29083
29084 - p = (unsigned char *)ins_addr;
29085 + p = (unsigned char *)ktla_ktva(ins_addr);
29086 p += skip_prefix(p, &prf);
29087 p += get_opcode(p, &opcode);
29088 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
29089 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
29090 struct prefix_bits prf;
29091 int i;
29092
29093 - p = (unsigned char *)ins_addr;
29094 + p = (unsigned char *)ktla_ktva(ins_addr);
29095 p += skip_prefix(p, &prf);
29096 p += get_opcode(p, &opcode);
29097 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
29098 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
29099 index 17fda6a..489c74a 100644
29100 --- a/arch/x86/mm/pgtable.c
29101 +++ b/arch/x86/mm/pgtable.c
29102 @@ -91,10 +91,64 @@ static inline void pgd_list_del(pgd_t *pgd)
29103 list_del(&page->lru);
29104 }
29105
29106 -#define UNSHARED_PTRS_PER_PGD \
29107 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29108 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29109 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
29110
29111 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
29112 +{
29113 + unsigned int count = USER_PGD_PTRS;
29114
29115 + while (count--)
29116 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
29117 +}
29118 +#endif
29119 +
29120 +#ifdef CONFIG_PAX_PER_CPU_PGD
29121 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
29122 +{
29123 + unsigned int count = USER_PGD_PTRS;
29124 +
29125 + while (count--) {
29126 + pgd_t pgd;
29127 +
29128 +#ifdef CONFIG_X86_64
29129 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
29130 +#else
29131 + pgd = *src++;
29132 +#endif
29133 +
29134 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29135 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
29136 +#endif
29137 +
29138 + *dst++ = pgd;
29139 + }
29140 +
29141 +}
29142 +#endif
29143 +
29144 +#ifdef CONFIG_X86_64
29145 +#define pxd_t pud_t
29146 +#define pyd_t pgd_t
29147 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
29148 +#define pxd_free(mm, pud) pud_free((mm), (pud))
29149 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
29150 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
29151 +#define PYD_SIZE PGDIR_SIZE
29152 +#else
29153 +#define pxd_t pmd_t
29154 +#define pyd_t pud_t
29155 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
29156 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
29157 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
29158 +#define pyd_offset(mm, address) pud_offset((mm), (address))
29159 +#define PYD_SIZE PUD_SIZE
29160 +#endif
29161 +
29162 +#ifdef CONFIG_PAX_PER_CPU_PGD
29163 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
29164 +static inline void pgd_dtor(pgd_t *pgd) {}
29165 +#else
29166 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
29167 {
29168 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
29169 @@ -135,6 +189,7 @@ static void pgd_dtor(pgd_t *pgd)
29170 pgd_list_del(pgd);
29171 spin_unlock(&pgd_lock);
29172 }
29173 +#endif
29174
29175 /*
29176 * List of all pgd's needed for non-PAE so it can invalidate entries
29177 @@ -147,7 +202,7 @@ static void pgd_dtor(pgd_t *pgd)
29178 * -- nyc
29179 */
29180
29181 -#ifdef CONFIG_X86_PAE
29182 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
29183 /*
29184 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
29185 * updating the top-level pagetable entries to guarantee the
29186 @@ -159,7 +214,7 @@ static void pgd_dtor(pgd_t *pgd)
29187 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
29188 * and initialize the kernel pmds here.
29189 */
29190 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
29191 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
29192
29193 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29194 {
29195 @@ -177,36 +232,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
29196 */
29197 flush_tlb_mm(mm);
29198 }
29199 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
29200 +#define PREALLOCATED_PXDS USER_PGD_PTRS
29201 #else /* !CONFIG_X86_PAE */
29202
29203 /* No need to prepopulate any pagetable entries in non-PAE modes. */
29204 -#define PREALLOCATED_PMDS 0
29205 +#define PREALLOCATED_PXDS 0
29206
29207 #endif /* CONFIG_X86_PAE */
29208
29209 -static void free_pmds(pmd_t *pmds[])
29210 +static void free_pxds(pxd_t *pxds[])
29211 {
29212 int i;
29213
29214 - for(i = 0; i < PREALLOCATED_PMDS; i++)
29215 - if (pmds[i])
29216 - free_page((unsigned long)pmds[i]);
29217 + for(i = 0; i < PREALLOCATED_PXDS; i++)
29218 + if (pxds[i])
29219 + free_page((unsigned long)pxds[i]);
29220 }
29221
29222 -static int preallocate_pmds(pmd_t *pmds[])
29223 +static int preallocate_pxds(pxd_t *pxds[])
29224 {
29225 int i;
29226 bool failed = false;
29227
29228 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29229 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
29230 - if (pmd == NULL)
29231 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29232 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
29233 + if (pxd == NULL)
29234 failed = true;
29235 - pmds[i] = pmd;
29236 + pxds[i] = pxd;
29237 }
29238
29239 if (failed) {
29240 - free_pmds(pmds);
29241 + free_pxds(pxds);
29242 return -ENOMEM;
29243 }
29244
29245 @@ -219,51 +276,55 @@ static int preallocate_pmds(pmd_t *pmds[])
29246 * preallocate which never got a corresponding vma will need to be
29247 * freed manually.
29248 */
29249 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
29250 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
29251 {
29252 int i;
29253
29254 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
29255 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
29256 pgd_t pgd = pgdp[i];
29257
29258 if (pgd_val(pgd) != 0) {
29259 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
29260 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
29261
29262 - pgdp[i] = native_make_pgd(0);
29263 + set_pgd(pgdp + i, native_make_pgd(0));
29264
29265 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
29266 - pmd_free(mm, pmd);
29267 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
29268 + pxd_free(mm, pxd);
29269 }
29270 }
29271 }
29272
29273 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
29274 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
29275 {
29276 - pud_t *pud;
29277 + pyd_t *pyd;
29278 unsigned long addr;
29279 int i;
29280
29281 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
29282 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
29283 return;
29284
29285 - pud = pud_offset(pgd, 0);
29286 +#ifdef CONFIG_X86_64
29287 + pyd = pyd_offset(mm, 0L);
29288 +#else
29289 + pyd = pyd_offset(pgd, 0L);
29290 +#endif
29291
29292 - for (addr = i = 0; i < PREALLOCATED_PMDS;
29293 - i++, pud++, addr += PUD_SIZE) {
29294 - pmd_t *pmd = pmds[i];
29295 + for (addr = i = 0; i < PREALLOCATED_PXDS;
29296 + i++, pyd++, addr += PYD_SIZE) {
29297 + pxd_t *pxd = pxds[i];
29298
29299 if (i >= KERNEL_PGD_BOUNDARY)
29300 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29301 - sizeof(pmd_t) * PTRS_PER_PMD);
29302 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
29303 + sizeof(pxd_t) * PTRS_PER_PMD);
29304
29305 - pud_populate(mm, pud, pmd);
29306 + pyd_populate(mm, pyd, pxd);
29307 }
29308 }
29309
29310 pgd_t *pgd_alloc(struct mm_struct *mm)
29311 {
29312 pgd_t *pgd;
29313 - pmd_t *pmds[PREALLOCATED_PMDS];
29314 + pxd_t *pxds[PREALLOCATED_PXDS];
29315
29316 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
29317
29318 @@ -272,11 +333,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29319
29320 mm->pgd = pgd;
29321
29322 - if (preallocate_pmds(pmds) != 0)
29323 + if (preallocate_pxds(pxds) != 0)
29324 goto out_free_pgd;
29325
29326 if (paravirt_pgd_alloc(mm) != 0)
29327 - goto out_free_pmds;
29328 + goto out_free_pxds;
29329
29330 /*
29331 * Make sure that pre-populating the pmds is atomic with
29332 @@ -286,14 +347,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
29333 spin_lock(&pgd_lock);
29334
29335 pgd_ctor(mm, pgd);
29336 - pgd_prepopulate_pmd(mm, pgd, pmds);
29337 + pgd_prepopulate_pxd(mm, pgd, pxds);
29338
29339 spin_unlock(&pgd_lock);
29340
29341 return pgd;
29342
29343 -out_free_pmds:
29344 - free_pmds(pmds);
29345 +out_free_pxds:
29346 + free_pxds(pxds);
29347 out_free_pgd:
29348 free_page((unsigned long)pgd);
29349 out:
29350 @@ -302,7 +363,7 @@ out:
29351
29352 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
29353 {
29354 - pgd_mop_up_pmds(mm, pgd);
29355 + pgd_mop_up_pxds(mm, pgd);
29356 pgd_dtor(pgd);
29357 paravirt_pgd_free(mm, pgd);
29358 free_page((unsigned long)pgd);
29359 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
29360 index a69bcb8..19068ab 100644
29361 --- a/arch/x86/mm/pgtable_32.c
29362 +++ b/arch/x86/mm/pgtable_32.c
29363 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
29364 return;
29365 }
29366 pte = pte_offset_kernel(pmd, vaddr);
29367 +
29368 + pax_open_kernel();
29369 if (pte_val(pteval))
29370 set_pte_at(&init_mm, vaddr, pte, pteval);
29371 else
29372 pte_clear(&init_mm, vaddr, pte);
29373 + pax_close_kernel();
29374
29375 /*
29376 * It's enough to flush this one mapping.
29377 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
29378 index e666cbb..61788c45 100644
29379 --- a/arch/x86/mm/physaddr.c
29380 +++ b/arch/x86/mm/physaddr.c
29381 @@ -10,7 +10,7 @@
29382 #ifdef CONFIG_X86_64
29383
29384 #ifdef CONFIG_DEBUG_VIRTUAL
29385 -unsigned long __phys_addr(unsigned long x)
29386 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29387 {
29388 unsigned long y = x - __START_KERNEL_map;
29389
29390 @@ -67,7 +67,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
29391 #else
29392
29393 #ifdef CONFIG_DEBUG_VIRTUAL
29394 -unsigned long __phys_addr(unsigned long x)
29395 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
29396 {
29397 unsigned long phys_addr = x - PAGE_OFFSET;
29398 /* VMALLOC_* aren't constants */
29399 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
29400 index 410531d..0f16030 100644
29401 --- a/arch/x86/mm/setup_nx.c
29402 +++ b/arch/x86/mm/setup_nx.c
29403 @@ -5,8 +5,10 @@
29404 #include <asm/pgtable.h>
29405 #include <asm/proto.h>
29406
29407 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29408 static int disable_nx __cpuinitdata;
29409
29410 +#ifndef CONFIG_PAX_PAGEEXEC
29411 /*
29412 * noexec = on|off
29413 *
29414 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
29415 return 0;
29416 }
29417 early_param("noexec", noexec_setup);
29418 +#endif
29419 +
29420 +#endif
29421
29422 void __cpuinit x86_configure_nx(void)
29423 {
29424 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
29425 if (cpu_has_nx && !disable_nx)
29426 __supported_pte_mask |= _PAGE_NX;
29427 else
29428 +#endif
29429 __supported_pte_mask &= ~_PAGE_NX;
29430 }
29431
29432 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
29433 index 282375f..e03a98f 100644
29434 --- a/arch/x86/mm/tlb.c
29435 +++ b/arch/x86/mm/tlb.c
29436 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
29437 BUG();
29438 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
29439 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
29440 +
29441 +#ifndef CONFIG_PAX_PER_CPU_PGD
29442 load_cr3(swapper_pg_dir);
29443 +#endif
29444 +
29445 }
29446 }
29447 EXPORT_SYMBOL_GPL(leave_mm);
29448 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
29449 index 877b9a1..a8ecf42 100644
29450 --- a/arch/x86/net/bpf_jit.S
29451 +++ b/arch/x86/net/bpf_jit.S
29452 @@ -9,6 +9,7 @@
29453 */
29454 #include <linux/linkage.h>
29455 #include <asm/dwarf2.h>
29456 +#include <asm/alternative-asm.h>
29457
29458 /*
29459 * Calling convention :
29460 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
29461 jle bpf_slow_path_word
29462 mov (SKBDATA,%rsi),%eax
29463 bswap %eax /* ntohl() */
29464 + pax_force_retaddr
29465 ret
29466
29467 sk_load_half:
29468 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
29469 jle bpf_slow_path_half
29470 movzwl (SKBDATA,%rsi),%eax
29471 rol $8,%ax # ntohs()
29472 + pax_force_retaddr
29473 ret
29474
29475 sk_load_byte:
29476 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
29477 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
29478 jle bpf_slow_path_byte
29479 movzbl (SKBDATA,%rsi),%eax
29480 + pax_force_retaddr
29481 ret
29482
29483 /**
29484 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
29485 movzbl (SKBDATA,%rsi),%ebx
29486 and $15,%bl
29487 shl $2,%bl
29488 + pax_force_retaddr
29489 ret
29490
29491 /* rsi contains offset and can be scratched */
29492 @@ -109,6 +114,7 @@ bpf_slow_path_word:
29493 js bpf_error
29494 mov -12(%rbp),%eax
29495 bswap %eax
29496 + pax_force_retaddr
29497 ret
29498
29499 bpf_slow_path_half:
29500 @@ -117,12 +123,14 @@ bpf_slow_path_half:
29501 mov -12(%rbp),%ax
29502 rol $8,%ax
29503 movzwl %ax,%eax
29504 + pax_force_retaddr
29505 ret
29506
29507 bpf_slow_path_byte:
29508 bpf_slow_path_common(1)
29509 js bpf_error
29510 movzbl -12(%rbp),%eax
29511 + pax_force_retaddr
29512 ret
29513
29514 bpf_slow_path_byte_msh:
29515 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
29516 and $15,%al
29517 shl $2,%al
29518 xchg %eax,%ebx
29519 + pax_force_retaddr
29520 ret
29521
29522 #define sk_negative_common(SIZE) \
29523 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
29524 sk_negative_common(4)
29525 mov (%rax), %eax
29526 bswap %eax
29527 + pax_force_retaddr
29528 ret
29529
29530 bpf_slow_path_half_neg:
29531 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
29532 mov (%rax),%ax
29533 rol $8,%ax
29534 movzwl %ax,%eax
29535 + pax_force_retaddr
29536 ret
29537
29538 bpf_slow_path_byte_neg:
29539 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
29540 .globl sk_load_byte_negative_offset
29541 sk_negative_common(1)
29542 movzbl (%rax), %eax
29543 + pax_force_retaddr
29544 ret
29545
29546 bpf_slow_path_byte_msh_neg:
29547 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
29548 and $15,%al
29549 shl $2,%al
29550 xchg %eax,%ebx
29551 + pax_force_retaddr
29552 ret
29553
29554 bpf_error:
29555 @@ -197,4 +210,5 @@ bpf_error:
29556 xor %eax,%eax
29557 mov -8(%rbp),%rbx
29558 leaveq
29559 + pax_force_retaddr
29560 ret
29561 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
29562 index f66b540..3e88dfb 100644
29563 --- a/arch/x86/net/bpf_jit_comp.c
29564 +++ b/arch/x86/net/bpf_jit_comp.c
29565 @@ -12,6 +12,7 @@
29566 #include <linux/netdevice.h>
29567 #include <linux/filter.h>
29568 #include <linux/if_vlan.h>
29569 +#include <linux/random.h>
29570
29571 /*
29572 * Conventions :
29573 @@ -49,13 +50,90 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
29574 return ptr + len;
29575 }
29576
29577 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29578 +#define MAX_INSTR_CODE_SIZE 96
29579 +#else
29580 +#define MAX_INSTR_CODE_SIZE 64
29581 +#endif
29582 +
29583 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
29584
29585 #define EMIT1(b1) EMIT(b1, 1)
29586 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
29587 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
29588 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
29589 +
29590 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29591 +/* original constant will appear in ecx */
29592 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
29593 +do { \
29594 + /* mov ecx, randkey */ \
29595 + EMIT1(0xb9); \
29596 + EMIT(_key, 4); \
29597 + /* xor ecx, randkey ^ off */ \
29598 + EMIT2(0x81, 0xf1); \
29599 + EMIT((_key) ^ (_off), 4); \
29600 +} while (0)
29601 +
29602 +#define EMIT1_off32(b1, _off) \
29603 +do { \
29604 + switch (b1) { \
29605 + case 0x05: /* add eax, imm32 */ \
29606 + case 0x2d: /* sub eax, imm32 */ \
29607 + case 0x25: /* and eax, imm32 */ \
29608 + case 0x0d: /* or eax, imm32 */ \
29609 + case 0xb8: /* mov eax, imm32 */ \
29610 + case 0x35: /* xor eax, imm32 */ \
29611 + case 0x3d: /* cmp eax, imm32 */ \
29612 + case 0xa9: /* test eax, imm32 */ \
29613 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29614 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
29615 + break; \
29616 + case 0xbb: /* mov ebx, imm32 */ \
29617 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29618 + /* mov ebx, ecx */ \
29619 + EMIT2(0x89, 0xcb); \
29620 + break; \
29621 + case 0xbe: /* mov esi, imm32 */ \
29622 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29623 + /* mov esi, ecx */ \
29624 + EMIT2(0x89, 0xce); \
29625 + break; \
29626 + case 0xe8: /* call rel imm32, always to known funcs */ \
29627 + EMIT1(b1); \
29628 + EMIT(_off, 4); \
29629 + break; \
29630 + case 0xe9: /* jmp rel imm32 */ \
29631 + EMIT1(b1); \
29632 + EMIT(_off, 4); \
29633 + /* prevent fall-through, we're not called if off = 0 */ \
29634 + EMIT(0xcccccccc, 4); \
29635 + EMIT(0xcccccccc, 4); \
29636 + break; \
29637 + default: \
29638 + BUILD_BUG(); \
29639 + } \
29640 +} while (0)
29641 +
29642 +#define EMIT2_off32(b1, b2, _off) \
29643 +do { \
29644 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
29645 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
29646 + EMIT(randkey, 4); \
29647 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
29648 + EMIT((_off) - randkey, 4); \
29649 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
29650 + DILUTE_CONST_SEQUENCE(_off, randkey); \
29651 + /* imul eax, ecx */ \
29652 + EMIT3(0x0f, 0xaf, 0xc1); \
29653 + } else { \
29654 + BUILD_BUG(); \
29655 + } \
29656 +} while (0)
29657 +#else
29658 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
29659 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
29660 +#endif
29661
29662 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
29663 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
29664 @@ -90,6 +168,24 @@ do { \
29665 #define X86_JBE 0x76
29666 #define X86_JA 0x77
29667
29668 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29669 +#define APPEND_FLOW_VERIFY() \
29670 +do { \
29671 + /* mov ecx, randkey */ \
29672 + EMIT1(0xb9); \
29673 + EMIT(randkey, 4); \
29674 + /* cmp ecx, randkey */ \
29675 + EMIT2(0x81, 0xf9); \
29676 + EMIT(randkey, 4); \
29677 + /* jz after 8 int 3s */ \
29678 + EMIT2(0x74, 0x08); \
29679 + EMIT(0xcccccccc, 4); \
29680 + EMIT(0xcccccccc, 4); \
29681 +} while (0)
29682 +#else
29683 +#define APPEND_FLOW_VERIFY() do { } while (0)
29684 +#endif
29685 +
29686 #define EMIT_COND_JMP(op, offset) \
29687 do { \
29688 if (is_near(offset)) \
29689 @@ -97,6 +193,7 @@ do { \
29690 else { \
29691 EMIT2(0x0f, op + 0x10); \
29692 EMIT(offset, 4); /* jxx .+off32 */ \
29693 + APPEND_FLOW_VERIFY(); \
29694 } \
29695 } while (0)
29696
29697 @@ -121,6 +218,11 @@ static inline void bpf_flush_icache(void *start, void *end)
29698 set_fs(old_fs);
29699 }
29700
29701 +struct bpf_jit_work {
29702 + struct work_struct work;
29703 + void *image;
29704 +};
29705 +
29706 #define CHOOSE_LOAD_FUNC(K, func) \
29707 ((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative_offset : func) : func##_positive_offset)
29708
29709 @@ -146,7 +248,7 @@ static int pkt_type_offset(void)
29710
29711 void bpf_jit_compile(struct sk_filter *fp)
29712 {
29713 - u8 temp[64];
29714 + u8 temp[MAX_INSTR_CODE_SIZE];
29715 u8 *prog;
29716 unsigned int proglen, oldproglen = 0;
29717 int ilen, i;
29718 @@ -159,6 +261,9 @@ void bpf_jit_compile(struct sk_filter *fp)
29719 unsigned int *addrs;
29720 const struct sock_filter *filter = fp->insns;
29721 int flen = fp->len;
29722 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29723 + unsigned int randkey;
29724 +#endif
29725
29726 if (!bpf_jit_enable)
29727 return;
29728 @@ -167,11 +272,19 @@ void bpf_jit_compile(struct sk_filter *fp)
29729 if (addrs == NULL)
29730 return;
29731
29732 + fp->work = kmalloc(sizeof(*fp->work), GFP_KERNEL);
29733 + if (!fp->work)
29734 + goto out;
29735 +
29736 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29737 + randkey = get_random_int();
29738 +#endif
29739 +
29740 /* Before first pass, make a rough estimation of addrs[]
29741 - * each bpf instruction is translated to less than 64 bytes
29742 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
29743 */
29744 for (proglen = 0, i = 0; i < flen; i++) {
29745 - proglen += 64;
29746 + proglen += MAX_INSTR_CODE_SIZE;
29747 addrs[i] = proglen;
29748 }
29749 cleanup_addr = proglen; /* epilogue address */
29750 @@ -282,10 +395,8 @@ void bpf_jit_compile(struct sk_filter *fp)
29751 case BPF_S_ALU_MUL_K: /* A *= K */
29752 if (is_imm8(K))
29753 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
29754 - else {
29755 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
29756 - EMIT(K, 4);
29757 - }
29758 + else
29759 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
29760 break;
29761 case BPF_S_ALU_DIV_X: /* A /= X; */
29762 seen |= SEEN_XREG;
29763 @@ -325,13 +436,23 @@ void bpf_jit_compile(struct sk_filter *fp)
29764 break;
29765 case BPF_S_ALU_MOD_K: /* A %= K; */
29766 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
29767 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29768 + DILUTE_CONST_SEQUENCE(K, randkey);
29769 +#else
29770 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
29771 +#endif
29772 EMIT2(0xf7, 0xf1); /* div %ecx */
29773 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
29774 break;
29775 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
29776 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
29777 + DILUTE_CONST_SEQUENCE(K, randkey);
29778 + // imul rax, rcx
29779 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
29780 +#else
29781 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
29782 EMIT(K, 4);
29783 +#endif
29784 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
29785 break;
29786 case BPF_S_ALU_AND_X:
29787 @@ -602,8 +723,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
29788 if (is_imm8(K)) {
29789 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
29790 } else {
29791 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
29792 - EMIT(K, 4);
29793 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
29794 }
29795 } else {
29796 EMIT2(0x89,0xde); /* mov %ebx,%esi */
29797 @@ -686,17 +806,18 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29798 break;
29799 default:
29800 /* hmm, too complex filter, give up with jit compiler */
29801 - goto out;
29802 + goto error;
29803 }
29804 ilen = prog - temp;
29805 if (image) {
29806 if (unlikely(proglen + ilen > oldproglen)) {
29807 pr_err("bpb_jit_compile fatal error\n");
29808 - kfree(addrs);
29809 - module_free(NULL, image);
29810 - return;
29811 + module_free_exec(NULL, image);
29812 + goto error;
29813 }
29814 + pax_open_kernel();
29815 memcpy(image + proglen, temp, ilen);
29816 + pax_close_kernel();
29817 }
29818 proglen += ilen;
29819 addrs[i] = proglen;
29820 @@ -717,11 +838,9 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29821 break;
29822 }
29823 if (proglen == oldproglen) {
29824 - image = module_alloc(max_t(unsigned int,
29825 - proglen,
29826 - sizeof(struct work_struct)));
29827 + image = module_alloc_exec(proglen);
29828 if (!image)
29829 - goto out;
29830 + goto error;
29831 }
29832 oldproglen = proglen;
29833 }
29834 @@ -732,7 +851,10 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
29835 if (image) {
29836 bpf_flush_icache(image, image + proglen);
29837 fp->bpf_func = (void *)image;
29838 - }
29839 + } else
29840 +error:
29841 + kfree(fp->work);
29842 +
29843 out:
29844 kfree(addrs);
29845 return;
29846 @@ -740,18 +862,20 @@ out:
29847
29848 static void jit_free_defer(struct work_struct *arg)
29849 {
29850 - module_free(NULL, arg);
29851 + module_free_exec(NULL, ((struct bpf_jit_work *)arg)->image);
29852 + kfree(arg);
29853 }
29854
29855 /* run from softirq, we must use a work_struct to call
29856 - * module_free() from process context
29857 + * module_free_exec() from process context
29858 */
29859 void bpf_jit_free(struct sk_filter *fp)
29860 {
29861 if (fp->bpf_func != sk_run_filter) {
29862 - struct work_struct *work = (struct work_struct *)fp->bpf_func;
29863 + struct work_struct *work = &fp->work->work;
29864
29865 INIT_WORK(work, jit_free_defer);
29866 + fp->work->image = fp->bpf_func;
29867 schedule_work(work);
29868 }
29869 }
29870 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
29871 index d6aa6e8..266395a 100644
29872 --- a/arch/x86/oprofile/backtrace.c
29873 +++ b/arch/x86/oprofile/backtrace.c
29874 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
29875 struct stack_frame_ia32 *fp;
29876 unsigned long bytes;
29877
29878 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
29879 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
29880 if (bytes != sizeof(bufhead))
29881 return NULL;
29882
29883 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
29884 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
29885
29886 oprofile_add_trace(bufhead[0].return_address);
29887
29888 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
29889 struct stack_frame bufhead[2];
29890 unsigned long bytes;
29891
29892 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
29893 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
29894 if (bytes != sizeof(bufhead))
29895 return NULL;
29896
29897 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
29898 {
29899 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
29900
29901 - if (!user_mode_vm(regs)) {
29902 + if (!user_mode(regs)) {
29903 unsigned long stack = kernel_stack_pointer(regs);
29904 if (depth)
29905 dump_trace(NULL, regs, (unsigned long *)stack, 0,
29906 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
29907 index 48768df..ba9143c 100644
29908 --- a/arch/x86/oprofile/nmi_int.c
29909 +++ b/arch/x86/oprofile/nmi_int.c
29910 @@ -23,6 +23,7 @@
29911 #include <asm/nmi.h>
29912 #include <asm/msr.h>
29913 #include <asm/apic.h>
29914 +#include <asm/pgtable.h>
29915
29916 #include "op_counter.h"
29917 #include "op_x86_model.h"
29918 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
29919 if (ret)
29920 return ret;
29921
29922 - if (!model->num_virt_counters)
29923 - model->num_virt_counters = model->num_counters;
29924 + if (!model->num_virt_counters) {
29925 + pax_open_kernel();
29926 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
29927 + pax_close_kernel();
29928 + }
29929
29930 mux_init(ops);
29931
29932 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
29933 index b2b9443..be58856 100644
29934 --- a/arch/x86/oprofile/op_model_amd.c
29935 +++ b/arch/x86/oprofile/op_model_amd.c
29936 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
29937 num_counters = AMD64_NUM_COUNTERS;
29938 }
29939
29940 - op_amd_spec.num_counters = num_counters;
29941 - op_amd_spec.num_controls = num_counters;
29942 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
29943 + pax_open_kernel();
29944 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
29945 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
29946 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
29947 + pax_close_kernel();
29948
29949 return 0;
29950 }
29951 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
29952 index d90528e..0127e2b 100644
29953 --- a/arch/x86/oprofile/op_model_ppro.c
29954 +++ b/arch/x86/oprofile/op_model_ppro.c
29955 @@ -19,6 +19,7 @@
29956 #include <asm/msr.h>
29957 #include <asm/apic.h>
29958 #include <asm/nmi.h>
29959 +#include <asm/pgtable.h>
29960
29961 #include "op_x86_model.h"
29962 #include "op_counter.h"
29963 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
29964
29965 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
29966
29967 - op_arch_perfmon_spec.num_counters = num_counters;
29968 - op_arch_perfmon_spec.num_controls = num_counters;
29969 + pax_open_kernel();
29970 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
29971 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
29972 + pax_close_kernel();
29973 }
29974
29975 static int arch_perfmon_init(struct oprofile_operations *ignore)
29976 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
29977 index 71e8a67..6a313bb 100644
29978 --- a/arch/x86/oprofile/op_x86_model.h
29979 +++ b/arch/x86/oprofile/op_x86_model.h
29980 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
29981 void (*switch_ctrl)(struct op_x86_model_spec const *model,
29982 struct op_msrs const * const msrs);
29983 #endif
29984 -};
29985 +} __do_const;
29986
29987 struct op_counter_config;
29988
29989 diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
29990 index e9e6ed5..e47ae67 100644
29991 --- a/arch/x86/pci/amd_bus.c
29992 +++ b/arch/x86/pci/amd_bus.c
29993 @@ -337,7 +337,7 @@ static int __cpuinit amd_cpu_notify(struct notifier_block *self,
29994 return NOTIFY_OK;
29995 }
29996
29997 -static struct notifier_block __cpuinitdata amd_cpu_notifier = {
29998 +static struct notifier_block amd_cpu_notifier = {
29999 .notifier_call = amd_cpu_notify,
30000 };
30001
30002 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
30003 index 372e9b8..e775a6c 100644
30004 --- a/arch/x86/pci/irq.c
30005 +++ b/arch/x86/pci/irq.c
30006 @@ -50,7 +50,7 @@ struct irq_router {
30007 struct irq_router_handler {
30008 u16 vendor;
30009 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
30010 -};
30011 +} __do_const;
30012
30013 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
30014 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
30015 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
30016 return 0;
30017 }
30018
30019 -static __initdata struct irq_router_handler pirq_routers[] = {
30020 +static __initconst const struct irq_router_handler pirq_routers[] = {
30021 { PCI_VENDOR_ID_INTEL, intel_router_probe },
30022 { PCI_VENDOR_ID_AL, ali_router_probe },
30023 { PCI_VENDOR_ID_ITE, ite_router_probe },
30024 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
30025 static void __init pirq_find_router(struct irq_router *r)
30026 {
30027 struct irq_routing_table *rt = pirq_table;
30028 - struct irq_router_handler *h;
30029 + const struct irq_router_handler *h;
30030
30031 #ifdef CONFIG_PCI_BIOS
30032 if (!rt->signature) {
30033 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
30034 return 0;
30035 }
30036
30037 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
30038 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
30039 {
30040 .callback = fix_broken_hp_bios_irq9,
30041 .ident = "HP Pavilion N5400 Series Laptop",
30042 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
30043 index 6eb18c4..20d83de 100644
30044 --- a/arch/x86/pci/mrst.c
30045 +++ b/arch/x86/pci/mrst.c
30046 @@ -238,7 +238,9 @@ int __init pci_mrst_init(void)
30047 printk(KERN_INFO "Intel MID platform detected, using MID PCI ops\n");
30048 pci_mmcfg_late_init();
30049 pcibios_enable_irq = mrst_pci_irq_enable;
30050 - pci_root_ops = pci_mrst_ops;
30051 + pax_open_kernel();
30052 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
30053 + pax_close_kernel();
30054 pci_soc_mode = 1;
30055 /* Continue with standard init */
30056 return 1;
30057 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
30058 index c77b24a..c979855 100644
30059 --- a/arch/x86/pci/pcbios.c
30060 +++ b/arch/x86/pci/pcbios.c
30061 @@ -79,7 +79,7 @@ union bios32 {
30062 static struct {
30063 unsigned long address;
30064 unsigned short segment;
30065 -} bios32_indirect = { 0, __KERNEL_CS };
30066 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
30067
30068 /*
30069 * Returns the entry point for the given service, NULL on error
30070 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
30071 unsigned long length; /* %ecx */
30072 unsigned long entry; /* %edx */
30073 unsigned long flags;
30074 + struct desc_struct d, *gdt;
30075
30076 local_irq_save(flags);
30077 - __asm__("lcall *(%%edi); cld"
30078 +
30079 + gdt = get_cpu_gdt_table(smp_processor_id());
30080 +
30081 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
30082 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30083 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
30084 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30085 +
30086 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
30087 : "=a" (return_code),
30088 "=b" (address),
30089 "=c" (length),
30090 "=d" (entry)
30091 : "0" (service),
30092 "1" (0),
30093 - "D" (&bios32_indirect));
30094 + "D" (&bios32_indirect),
30095 + "r"(__PCIBIOS_DS)
30096 + : "memory");
30097 +
30098 + pax_open_kernel();
30099 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
30100 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
30101 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
30102 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
30103 + pax_close_kernel();
30104 +
30105 local_irq_restore(flags);
30106
30107 switch (return_code) {
30108 - case 0:
30109 - return address + entry;
30110 - case 0x80: /* Not present */
30111 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30112 - return 0;
30113 - default: /* Shouldn't happen */
30114 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30115 - service, return_code);
30116 + case 0: {
30117 + int cpu;
30118 + unsigned char flags;
30119 +
30120 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
30121 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
30122 + printk(KERN_WARNING "bios32_service: not valid\n");
30123 return 0;
30124 + }
30125 + address = address + PAGE_OFFSET;
30126 + length += 16UL; /* some BIOSs underreport this... */
30127 + flags = 4;
30128 + if (length >= 64*1024*1024) {
30129 + length >>= PAGE_SHIFT;
30130 + flags |= 8;
30131 + }
30132 +
30133 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
30134 + gdt = get_cpu_gdt_table(cpu);
30135 + pack_descriptor(&d, address, length, 0x9b, flags);
30136 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
30137 + pack_descriptor(&d, address, length, 0x93, flags);
30138 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
30139 + }
30140 + return entry;
30141 + }
30142 + case 0x80: /* Not present */
30143 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
30144 + return 0;
30145 + default: /* Shouldn't happen */
30146 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
30147 + service, return_code);
30148 + return 0;
30149 }
30150 }
30151
30152 static struct {
30153 unsigned long address;
30154 unsigned short segment;
30155 -} pci_indirect = { 0, __KERNEL_CS };
30156 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
30157
30158 -static int pci_bios_present;
30159 +static int pci_bios_present __read_only;
30160
30161 static int check_pcibios(void)
30162 {
30163 @@ -131,11 +174,13 @@ static int check_pcibios(void)
30164 unsigned long flags, pcibios_entry;
30165
30166 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
30167 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
30168 + pci_indirect.address = pcibios_entry;
30169
30170 local_irq_save(flags);
30171 - __asm__(
30172 - "lcall *(%%edi); cld\n\t"
30173 + __asm__("movw %w6, %%ds\n\t"
30174 + "lcall *%%ss:(%%edi); cld\n\t"
30175 + "push %%ss\n\t"
30176 + "pop %%ds\n\t"
30177 "jc 1f\n\t"
30178 "xor %%ah, %%ah\n"
30179 "1:"
30180 @@ -144,7 +189,8 @@ static int check_pcibios(void)
30181 "=b" (ebx),
30182 "=c" (ecx)
30183 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
30184 - "D" (&pci_indirect)
30185 + "D" (&pci_indirect),
30186 + "r" (__PCIBIOS_DS)
30187 : "memory");
30188 local_irq_restore(flags);
30189
30190 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30191
30192 switch (len) {
30193 case 1:
30194 - __asm__("lcall *(%%esi); cld\n\t"
30195 + __asm__("movw %w6, %%ds\n\t"
30196 + "lcall *%%ss:(%%esi); cld\n\t"
30197 + "push %%ss\n\t"
30198 + "pop %%ds\n\t"
30199 "jc 1f\n\t"
30200 "xor %%ah, %%ah\n"
30201 "1:"
30202 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30203 : "1" (PCIBIOS_READ_CONFIG_BYTE),
30204 "b" (bx),
30205 "D" ((long)reg),
30206 - "S" (&pci_indirect));
30207 + "S" (&pci_indirect),
30208 + "r" (__PCIBIOS_DS));
30209 /*
30210 * Zero-extend the result beyond 8 bits, do not trust the
30211 * BIOS having done it:
30212 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30213 *value &= 0xff;
30214 break;
30215 case 2:
30216 - __asm__("lcall *(%%esi); cld\n\t"
30217 + __asm__("movw %w6, %%ds\n\t"
30218 + "lcall *%%ss:(%%esi); cld\n\t"
30219 + "push %%ss\n\t"
30220 + "pop %%ds\n\t"
30221 "jc 1f\n\t"
30222 "xor %%ah, %%ah\n"
30223 "1:"
30224 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30225 : "1" (PCIBIOS_READ_CONFIG_WORD),
30226 "b" (bx),
30227 "D" ((long)reg),
30228 - "S" (&pci_indirect));
30229 + "S" (&pci_indirect),
30230 + "r" (__PCIBIOS_DS));
30231 /*
30232 * Zero-extend the result beyond 16 bits, do not trust the
30233 * BIOS having done it:
30234 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30235 *value &= 0xffff;
30236 break;
30237 case 4:
30238 - __asm__("lcall *(%%esi); cld\n\t"
30239 + __asm__("movw %w6, %%ds\n\t"
30240 + "lcall *%%ss:(%%esi); cld\n\t"
30241 + "push %%ss\n\t"
30242 + "pop %%ds\n\t"
30243 "jc 1f\n\t"
30244 "xor %%ah, %%ah\n"
30245 "1:"
30246 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
30247 : "1" (PCIBIOS_READ_CONFIG_DWORD),
30248 "b" (bx),
30249 "D" ((long)reg),
30250 - "S" (&pci_indirect));
30251 + "S" (&pci_indirect),
30252 + "r" (__PCIBIOS_DS));
30253 break;
30254 }
30255
30256 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30257
30258 switch (len) {
30259 case 1:
30260 - __asm__("lcall *(%%esi); cld\n\t"
30261 + __asm__("movw %w6, %%ds\n\t"
30262 + "lcall *%%ss:(%%esi); cld\n\t"
30263 + "push %%ss\n\t"
30264 + "pop %%ds\n\t"
30265 "jc 1f\n\t"
30266 "xor %%ah, %%ah\n"
30267 "1:"
30268 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30269 "c" (value),
30270 "b" (bx),
30271 "D" ((long)reg),
30272 - "S" (&pci_indirect));
30273 + "S" (&pci_indirect),
30274 + "r" (__PCIBIOS_DS));
30275 break;
30276 case 2:
30277 - __asm__("lcall *(%%esi); cld\n\t"
30278 + __asm__("movw %w6, %%ds\n\t"
30279 + "lcall *%%ss:(%%esi); cld\n\t"
30280 + "push %%ss\n\t"
30281 + "pop %%ds\n\t"
30282 "jc 1f\n\t"
30283 "xor %%ah, %%ah\n"
30284 "1:"
30285 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30286 "c" (value),
30287 "b" (bx),
30288 "D" ((long)reg),
30289 - "S" (&pci_indirect));
30290 + "S" (&pci_indirect),
30291 + "r" (__PCIBIOS_DS));
30292 break;
30293 case 4:
30294 - __asm__("lcall *(%%esi); cld\n\t"
30295 + __asm__("movw %w6, %%ds\n\t"
30296 + "lcall *%%ss:(%%esi); cld\n\t"
30297 + "push %%ss\n\t"
30298 + "pop %%ds\n\t"
30299 "jc 1f\n\t"
30300 "xor %%ah, %%ah\n"
30301 "1:"
30302 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
30303 "c" (value),
30304 "b" (bx),
30305 "D" ((long)reg),
30306 - "S" (&pci_indirect));
30307 + "S" (&pci_indirect),
30308 + "r" (__PCIBIOS_DS));
30309 break;
30310 }
30311
30312 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30313
30314 DBG("PCI: Fetching IRQ routing table... ");
30315 __asm__("push %%es\n\t"
30316 + "movw %w8, %%ds\n\t"
30317 "push %%ds\n\t"
30318 "pop %%es\n\t"
30319 - "lcall *(%%esi); cld\n\t"
30320 + "lcall *%%ss:(%%esi); cld\n\t"
30321 "pop %%es\n\t"
30322 + "push %%ss\n\t"
30323 + "pop %%ds\n"
30324 "jc 1f\n\t"
30325 "xor %%ah, %%ah\n"
30326 "1:"
30327 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
30328 "1" (0),
30329 "D" ((long) &opt),
30330 "S" (&pci_indirect),
30331 - "m" (opt)
30332 + "m" (opt),
30333 + "r" (__PCIBIOS_DS)
30334 : "memory");
30335 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
30336 if (ret & 0xff00)
30337 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30338 {
30339 int ret;
30340
30341 - __asm__("lcall *(%%esi); cld\n\t"
30342 + __asm__("movw %w5, %%ds\n\t"
30343 + "lcall *%%ss:(%%esi); cld\n\t"
30344 + "push %%ss\n\t"
30345 + "pop %%ds\n"
30346 "jc 1f\n\t"
30347 "xor %%ah, %%ah\n"
30348 "1:"
30349 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
30350 : "0" (PCIBIOS_SET_PCI_HW_INT),
30351 "b" ((dev->bus->number << 8) | dev->devfn),
30352 "c" ((irq << 8) | (pin + 10)),
30353 - "S" (&pci_indirect));
30354 + "S" (&pci_indirect),
30355 + "r" (__PCIBIOS_DS));
30356 return !(ret & 0xff00);
30357 }
30358 EXPORT_SYMBOL(pcibios_set_irq_routing);
30359 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
30360 index 40e4469..0592924 100644
30361 --- a/arch/x86/platform/efi/efi_32.c
30362 +++ b/arch/x86/platform/efi/efi_32.c
30363 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
30364 {
30365 struct desc_ptr gdt_descr;
30366
30367 +#ifdef CONFIG_PAX_KERNEXEC
30368 + struct desc_struct d;
30369 +#endif
30370 +
30371 local_irq_save(efi_rt_eflags);
30372
30373 load_cr3(initial_page_table);
30374 __flush_tlb_all();
30375
30376 +#ifdef CONFIG_PAX_KERNEXEC
30377 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
30378 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30379 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
30380 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30381 +#endif
30382 +
30383 gdt_descr.address = __pa(get_cpu_gdt_table(0));
30384 gdt_descr.size = GDT_SIZE - 1;
30385 load_gdt(&gdt_descr);
30386 @@ -58,11 +69,24 @@ void efi_call_phys_epilog(void)
30387 {
30388 struct desc_ptr gdt_descr;
30389
30390 +#ifdef CONFIG_PAX_KERNEXEC
30391 + struct desc_struct d;
30392 +
30393 + memset(&d, 0, sizeof d);
30394 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
30395 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
30396 +#endif
30397 +
30398 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
30399 gdt_descr.size = GDT_SIZE - 1;
30400 load_gdt(&gdt_descr);
30401
30402 +#ifdef CONFIG_PAX_PER_CPU_PGD
30403 + load_cr3(get_cpu_pgd(smp_processor_id()));
30404 +#else
30405 load_cr3(swapper_pg_dir);
30406 +#endif
30407 +
30408 __flush_tlb_all();
30409
30410 local_irq_restore(efi_rt_eflags);
30411 diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
30412 index 39a0e7f1..ecc2f1e 100644
30413 --- a/arch/x86/platform/efi/efi_64.c
30414 +++ b/arch/x86/platform/efi/efi_64.c
30415 @@ -76,6 +76,11 @@ void __init efi_call_phys_prelog(void)
30416 vaddress = (unsigned long)__va(pgd * PGDIR_SIZE);
30417 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), *pgd_offset_k(vaddress));
30418 }
30419 +
30420 +#ifdef CONFIG_PAX_PER_CPU_PGD
30421 + load_cr3(swapper_pg_dir);
30422 +#endif
30423 +
30424 __flush_tlb_all();
30425 }
30426
30427 @@ -89,6 +94,11 @@ void __init efi_call_phys_epilog(void)
30428 for (pgd = 0; pgd < n_pgds; pgd++)
30429 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), save_pgd[pgd]);
30430 kfree(save_pgd);
30431 +
30432 +#ifdef CONFIG_PAX_PER_CPU_PGD
30433 + load_cr3(get_cpu_pgd(smp_processor_id()));
30434 +#endif
30435 +
30436 __flush_tlb_all();
30437 local_irq_restore(efi_flags);
30438 early_code_mapping_set_exec(0);
30439 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
30440 index fbe66e6..eae5e38 100644
30441 --- a/arch/x86/platform/efi/efi_stub_32.S
30442 +++ b/arch/x86/platform/efi/efi_stub_32.S
30443 @@ -6,7 +6,9 @@
30444 */
30445
30446 #include <linux/linkage.h>
30447 +#include <linux/init.h>
30448 #include <asm/page_types.h>
30449 +#include <asm/segment.h>
30450
30451 /*
30452 * efi_call_phys(void *, ...) is a function with variable parameters.
30453 @@ -20,7 +22,7 @@
30454 * service functions will comply with gcc calling convention, too.
30455 */
30456
30457 -.text
30458 +__INIT
30459 ENTRY(efi_call_phys)
30460 /*
30461 * 0. The function can only be called in Linux kernel. So CS has been
30462 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
30463 * The mapping of lower virtual memory has been created in prelog and
30464 * epilog.
30465 */
30466 - movl $1f, %edx
30467 - subl $__PAGE_OFFSET, %edx
30468 - jmp *%edx
30469 +#ifdef CONFIG_PAX_KERNEXEC
30470 + movl $(__KERNEXEC_EFI_DS), %edx
30471 + mov %edx, %ds
30472 + mov %edx, %es
30473 + mov %edx, %ss
30474 + addl $2f,(1f)
30475 + ljmp *(1f)
30476 +
30477 +__INITDATA
30478 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
30479 +.previous
30480 +
30481 +2:
30482 + subl $2b,(1b)
30483 +#else
30484 + jmp 1f-__PAGE_OFFSET
30485 1:
30486 +#endif
30487
30488 /*
30489 * 2. Now on the top of stack is the return
30490 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
30491 * parameter 2, ..., param n. To make things easy, we save the return
30492 * address of efi_call_phys in a global variable.
30493 */
30494 - popl %edx
30495 - movl %edx, saved_return_addr
30496 - /* get the function pointer into ECX*/
30497 - popl %ecx
30498 - movl %ecx, efi_rt_function_ptr
30499 - movl $2f, %edx
30500 - subl $__PAGE_OFFSET, %edx
30501 - pushl %edx
30502 + popl (saved_return_addr)
30503 + popl (efi_rt_function_ptr)
30504
30505 /*
30506 * 3. Clear PG bit in %CR0.
30507 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
30508 /*
30509 * 5. Call the physical function.
30510 */
30511 - jmp *%ecx
30512 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
30513
30514 -2:
30515 /*
30516 * 6. After EFI runtime service returns, control will return to
30517 * following instruction. We'd better readjust stack pointer first.
30518 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
30519 movl %cr0, %edx
30520 orl $0x80000000, %edx
30521 movl %edx, %cr0
30522 - jmp 1f
30523 -1:
30524 +
30525 /*
30526 * 8. Now restore the virtual mode from flat mode by
30527 * adding EIP with PAGE_OFFSET.
30528 */
30529 - movl $1f, %edx
30530 - jmp *%edx
30531 +#ifdef CONFIG_PAX_KERNEXEC
30532 + movl $(__KERNEL_DS), %edx
30533 + mov %edx, %ds
30534 + mov %edx, %es
30535 + mov %edx, %ss
30536 + ljmp $(__KERNEL_CS),$1f
30537 +#else
30538 + jmp 1f+__PAGE_OFFSET
30539 +#endif
30540 1:
30541
30542 /*
30543 * 9. Balance the stack. And because EAX contain the return value,
30544 * we'd better not clobber it.
30545 */
30546 - leal efi_rt_function_ptr, %edx
30547 - movl (%edx), %ecx
30548 - pushl %ecx
30549 + pushl (efi_rt_function_ptr)
30550
30551 /*
30552 - * 10. Push the saved return address onto the stack and return.
30553 + * 10. Return to the saved return address.
30554 */
30555 - leal saved_return_addr, %edx
30556 - movl (%edx), %ecx
30557 - pushl %ecx
30558 - ret
30559 + jmpl *(saved_return_addr)
30560 ENDPROC(efi_call_phys)
30561 .previous
30562
30563 -.data
30564 +__INITDATA
30565 saved_return_addr:
30566 .long 0
30567 efi_rt_function_ptr:
30568 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
30569 index 4c07cca..2c8427d 100644
30570 --- a/arch/x86/platform/efi/efi_stub_64.S
30571 +++ b/arch/x86/platform/efi/efi_stub_64.S
30572 @@ -7,6 +7,7 @@
30573 */
30574
30575 #include <linux/linkage.h>
30576 +#include <asm/alternative-asm.h>
30577
30578 #define SAVE_XMM \
30579 mov %rsp, %rax; \
30580 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
30581 call *%rdi
30582 addq $32, %rsp
30583 RESTORE_XMM
30584 + pax_force_retaddr 0, 1
30585 ret
30586 ENDPROC(efi_call0)
30587
30588 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
30589 call *%rdi
30590 addq $32, %rsp
30591 RESTORE_XMM
30592 + pax_force_retaddr 0, 1
30593 ret
30594 ENDPROC(efi_call1)
30595
30596 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
30597 call *%rdi
30598 addq $32, %rsp
30599 RESTORE_XMM
30600 + pax_force_retaddr 0, 1
30601 ret
30602 ENDPROC(efi_call2)
30603
30604 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
30605 call *%rdi
30606 addq $32, %rsp
30607 RESTORE_XMM
30608 + pax_force_retaddr 0, 1
30609 ret
30610 ENDPROC(efi_call3)
30611
30612 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
30613 call *%rdi
30614 addq $32, %rsp
30615 RESTORE_XMM
30616 + pax_force_retaddr 0, 1
30617 ret
30618 ENDPROC(efi_call4)
30619
30620 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
30621 call *%rdi
30622 addq $48, %rsp
30623 RESTORE_XMM
30624 + pax_force_retaddr 0, 1
30625 ret
30626 ENDPROC(efi_call5)
30627
30628 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
30629 call *%rdi
30630 addq $48, %rsp
30631 RESTORE_XMM
30632 + pax_force_retaddr 0, 1
30633 ret
30634 ENDPROC(efi_call6)
30635 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
30636 index a0a0a43..a48e233 100644
30637 --- a/arch/x86/platform/mrst/mrst.c
30638 +++ b/arch/x86/platform/mrst/mrst.c
30639 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
30640 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
30641 int sfi_mrtc_num;
30642
30643 -static void mrst_power_off(void)
30644 +static __noreturn void mrst_power_off(void)
30645 {
30646 + BUG();
30647 }
30648
30649 -static void mrst_reboot(void)
30650 +static __noreturn void mrst_reboot(void)
30651 {
30652 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
30653 + BUG();
30654 }
30655
30656 /* parse all the mtimer info to a static mtimer array */
30657 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
30658 index d6ee929..3637cb5 100644
30659 --- a/arch/x86/platform/olpc/olpc_dt.c
30660 +++ b/arch/x86/platform/olpc/olpc_dt.c
30661 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
30662 return res;
30663 }
30664
30665 -static struct of_pdt_ops prom_olpc_ops __initdata = {
30666 +static struct of_pdt_ops prom_olpc_ops __initconst = {
30667 .nextprop = olpc_dt_nextprop,
30668 .getproplen = olpc_dt_getproplen,
30669 .getproperty = olpc_dt_getproperty,
30670 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
30671 index 1cf5b30..fd45732 100644
30672 --- a/arch/x86/power/cpu.c
30673 +++ b/arch/x86/power/cpu.c
30674 @@ -137,11 +137,8 @@ static void do_fpu_end(void)
30675 static void fix_processor_context(void)
30676 {
30677 int cpu = smp_processor_id();
30678 - struct tss_struct *t = &per_cpu(init_tss, cpu);
30679 -#ifdef CONFIG_X86_64
30680 - struct desc_struct *desc = get_cpu_gdt_table(cpu);
30681 - tss_desc tss;
30682 -#endif
30683 + struct tss_struct *t = init_tss + cpu;
30684 +
30685 set_tss_desc(cpu, t); /*
30686 * This just modifies memory; should not be
30687 * necessary. But... This is necessary, because
30688 @@ -150,10 +147,6 @@ static void fix_processor_context(void)
30689 */
30690
30691 #ifdef CONFIG_X86_64
30692 - memcpy(&tss, &desc[GDT_ENTRY_TSS], sizeof(tss_desc));
30693 - tss.type = 0x9; /* The available 64-bit TSS (see AMD vol 2, pg 91 */
30694 - write_gdt_entry(desc, GDT_ENTRY_TSS, &tss, DESC_TSS);
30695 -
30696 syscall_init(); /* This sets MSR_*STAR and related */
30697 #endif
30698 load_TR_desc(); /* This does ltr */
30699 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
30700 index a44f457..9140171 100644
30701 --- a/arch/x86/realmode/init.c
30702 +++ b/arch/x86/realmode/init.c
30703 @@ -70,7 +70,13 @@ void __init setup_real_mode(void)
30704 __va(real_mode_header->trampoline_header);
30705
30706 #ifdef CONFIG_X86_32
30707 - trampoline_header->start = __pa_symbol(startup_32_smp);
30708 + trampoline_header->start = __pa_symbol(ktla_ktva(startup_32_smp));
30709 +
30710 +#ifdef CONFIG_PAX_KERNEXEC
30711 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
30712 +#endif
30713 +
30714 + trampoline_header->boot_cs = __BOOT_CS;
30715 trampoline_header->gdt_limit = __BOOT_DS + 7;
30716 trampoline_header->gdt_base = __pa_symbol(boot_gdt);
30717 #else
30718 @@ -86,7 +92,7 @@ void __init setup_real_mode(void)
30719 *trampoline_cr4_features = read_cr4();
30720
30721 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
30722 - trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
30723 + trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd & ~_PAGE_NX;
30724 trampoline_pgd[511] = init_level4_pgt[511].pgd;
30725 #endif
30726 }
30727 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
30728 index 8869287..d577672 100644
30729 --- a/arch/x86/realmode/rm/Makefile
30730 +++ b/arch/x86/realmode/rm/Makefile
30731 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
30732 $(call cc-option, -fno-unit-at-a-time)) \
30733 $(call cc-option, -fno-stack-protector) \
30734 $(call cc-option, -mpreferred-stack-boundary=2)
30735 +ifdef CONSTIFY_PLUGIN
30736 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
30737 +endif
30738 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
30739 GCOV_PROFILE := n
30740 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
30741 index a28221d..93c40f1 100644
30742 --- a/arch/x86/realmode/rm/header.S
30743 +++ b/arch/x86/realmode/rm/header.S
30744 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
30745 #endif
30746 /* APM/BIOS reboot */
30747 .long pa_machine_real_restart_asm
30748 -#ifdef CONFIG_X86_64
30749 +#ifdef CONFIG_X86_32
30750 + .long __KERNEL_CS
30751 +#else
30752 .long __KERNEL32_CS
30753 #endif
30754 END(real_mode_header)
30755 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
30756 index c1b2791..f9e31c7 100644
30757 --- a/arch/x86/realmode/rm/trampoline_32.S
30758 +++ b/arch/x86/realmode/rm/trampoline_32.S
30759 @@ -25,6 +25,12 @@
30760 #include <asm/page_types.h>
30761 #include "realmode.h"
30762
30763 +#ifdef CONFIG_PAX_KERNEXEC
30764 +#define ta(X) (X)
30765 +#else
30766 +#define ta(X) (pa_ ## X)
30767 +#endif
30768 +
30769 .text
30770 .code16
30771
30772 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
30773
30774 cli # We should be safe anyway
30775
30776 - movl tr_start, %eax # where we need to go
30777 -
30778 movl $0xA5A5A5A5, trampoline_status
30779 # write marker for master knows we're running
30780
30781 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
30782 movw $1, %dx # protected mode (PE) bit
30783 lmsw %dx # into protected mode
30784
30785 - ljmpl $__BOOT_CS, $pa_startup_32
30786 + ljmpl *(trampoline_header)
30787
30788 .section ".text32","ax"
30789 .code32
30790 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
30791 .balign 8
30792 GLOBAL(trampoline_header)
30793 tr_start: .space 4
30794 - tr_gdt_pad: .space 2
30795 + tr_boot_cs: .space 2
30796 tr_gdt: .space 6
30797 END(trampoline_header)
30798
30799 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
30800 index bb360dc..3e5945f 100644
30801 --- a/arch/x86/realmode/rm/trampoline_64.S
30802 +++ b/arch/x86/realmode/rm/trampoline_64.S
30803 @@ -107,7 +107,7 @@ ENTRY(startup_32)
30804 wrmsr
30805
30806 # Enable paging and in turn activate Long Mode
30807 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
30808 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
30809 movl %eax, %cr0
30810
30811 /*
30812 diff --git a/arch/x86/tools/Makefile b/arch/x86/tools/Makefile
30813 index e812034..c747134 100644
30814 --- a/arch/x86/tools/Makefile
30815 +++ b/arch/x86/tools/Makefile
30816 @@ -37,7 +37,7 @@ $(obj)/test_get_len.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/in
30817
30818 $(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
30819
30820 -HOST_EXTRACFLAGS += -I$(srctree)/tools/include
30821 +HOST_EXTRACFLAGS += -I$(srctree)/tools/include -ggdb
30822 hostprogs-y += relocs
30823 relocs-objs := relocs_32.o relocs_64.o relocs_common.o
30824 relocs: $(obj)/relocs
30825 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
30826 index f7bab68..b6d9886 100644
30827 --- a/arch/x86/tools/relocs.c
30828 +++ b/arch/x86/tools/relocs.c
30829 @@ -1,5 +1,7 @@
30830 /* This is included from relocs_32/64.c */
30831
30832 +#include "../../../include/generated/autoconf.h"
30833 +
30834 #define ElfW(type) _ElfW(ELF_BITS, type)
30835 #define _ElfW(bits, type) __ElfW(bits, type)
30836 #define __ElfW(bits, type) Elf##bits##_##type
30837 @@ -11,6 +13,7 @@
30838 #define Elf_Sym ElfW(Sym)
30839
30840 static Elf_Ehdr ehdr;
30841 +static Elf_Phdr *phdr;
30842
30843 struct relocs {
30844 uint32_t *offset;
30845 @@ -383,9 +386,39 @@ static void read_ehdr(FILE *fp)
30846 }
30847 }
30848
30849 +static void read_phdrs(FILE *fp)
30850 +{
30851 + unsigned int i;
30852 +
30853 + phdr = calloc(ehdr.e_phnum, sizeof(Elf_Phdr));
30854 + if (!phdr) {
30855 + die("Unable to allocate %d program headers\n",
30856 + ehdr.e_phnum);
30857 + }
30858 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
30859 + die("Seek to %d failed: %s\n",
30860 + ehdr.e_phoff, strerror(errno));
30861 + }
30862 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
30863 + die("Cannot read ELF program headers: %s\n",
30864 + strerror(errno));
30865 + }
30866 + for(i = 0; i < ehdr.e_phnum; i++) {
30867 + phdr[i].p_type = elf_word_to_cpu(phdr[i].p_type);
30868 + phdr[i].p_offset = elf_off_to_cpu(phdr[i].p_offset);
30869 + phdr[i].p_vaddr = elf_addr_to_cpu(phdr[i].p_vaddr);
30870 + phdr[i].p_paddr = elf_addr_to_cpu(phdr[i].p_paddr);
30871 + phdr[i].p_filesz = elf_word_to_cpu(phdr[i].p_filesz);
30872 + phdr[i].p_memsz = elf_word_to_cpu(phdr[i].p_memsz);
30873 + phdr[i].p_flags = elf_word_to_cpu(phdr[i].p_flags);
30874 + phdr[i].p_align = elf_word_to_cpu(phdr[i].p_align);
30875 + }
30876 +
30877 +}
30878 +
30879 static void read_shdrs(FILE *fp)
30880 {
30881 - int i;
30882 + unsigned int i;
30883 Elf_Shdr shdr;
30884
30885 secs = calloc(ehdr.e_shnum, sizeof(struct section));
30886 @@ -420,7 +453,7 @@ static void read_shdrs(FILE *fp)
30887
30888 static void read_strtabs(FILE *fp)
30889 {
30890 - int i;
30891 + unsigned int i;
30892 for (i = 0; i < ehdr.e_shnum; i++) {
30893 struct section *sec = &secs[i];
30894 if (sec->shdr.sh_type != SHT_STRTAB) {
30895 @@ -445,7 +478,7 @@ static void read_strtabs(FILE *fp)
30896
30897 static void read_symtabs(FILE *fp)
30898 {
30899 - int i,j;
30900 + unsigned int i,j;
30901 for (i = 0; i < ehdr.e_shnum; i++) {
30902 struct section *sec = &secs[i];
30903 if (sec->shdr.sh_type != SHT_SYMTAB) {
30904 @@ -476,9 +509,11 @@ static void read_symtabs(FILE *fp)
30905 }
30906
30907
30908 -static void read_relocs(FILE *fp)
30909 +static void read_relocs(FILE *fp, int use_real_mode)
30910 {
30911 - int i,j;
30912 + unsigned int i,j;
30913 + uint32_t base;
30914 +
30915 for (i = 0; i < ehdr.e_shnum; i++) {
30916 struct section *sec = &secs[i];
30917 if (sec->shdr.sh_type != SHT_REL_TYPE) {
30918 @@ -498,9 +533,22 @@ static void read_relocs(FILE *fp)
30919 die("Cannot read symbol table: %s\n",
30920 strerror(errno));
30921 }
30922 + base = 0;
30923 +
30924 +#ifdef CONFIG_X86_32
30925 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
30926 + if (phdr[j].p_type != PT_LOAD )
30927 + continue;
30928 + 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)
30929 + continue;
30930 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
30931 + break;
30932 + }
30933 +#endif
30934 +
30935 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf_Rel); j++) {
30936 Elf_Rel *rel = &sec->reltab[j];
30937 - rel->r_offset = elf_addr_to_cpu(rel->r_offset);
30938 + rel->r_offset = elf_addr_to_cpu(rel->r_offset) + base;
30939 rel->r_info = elf_xword_to_cpu(rel->r_info);
30940 #if (SHT_REL_TYPE == SHT_RELA)
30941 rel->r_addend = elf_xword_to_cpu(rel->r_addend);
30942 @@ -512,7 +560,7 @@ static void read_relocs(FILE *fp)
30943
30944 static void print_absolute_symbols(void)
30945 {
30946 - int i;
30947 + unsigned int i;
30948 const char *format;
30949
30950 if (ELF_BITS == 64)
30951 @@ -525,7 +573,7 @@ static void print_absolute_symbols(void)
30952 for (i = 0; i < ehdr.e_shnum; i++) {
30953 struct section *sec = &secs[i];
30954 char *sym_strtab;
30955 - int j;
30956 + unsigned int j;
30957
30958 if (sec->shdr.sh_type != SHT_SYMTAB) {
30959 continue;
30960 @@ -552,7 +600,7 @@ static void print_absolute_symbols(void)
30961
30962 static void print_absolute_relocs(void)
30963 {
30964 - int i, printed = 0;
30965 + unsigned int i, printed = 0;
30966 const char *format;
30967
30968 if (ELF_BITS == 64)
30969 @@ -565,7 +613,7 @@ static void print_absolute_relocs(void)
30970 struct section *sec_applies, *sec_symtab;
30971 char *sym_strtab;
30972 Elf_Sym *sh_symtab;
30973 - int j;
30974 + unsigned int j;
30975 if (sec->shdr.sh_type != SHT_REL_TYPE) {
30976 continue;
30977 }
30978 @@ -642,13 +690,13 @@ static void add_reloc(struct relocs *r, uint32_t offset)
30979 static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
30980 Elf_Sym *sym, const char *symname))
30981 {
30982 - int i;
30983 + unsigned int i;
30984 /* Walk through the relocations */
30985 for (i = 0; i < ehdr.e_shnum; i++) {
30986 char *sym_strtab;
30987 Elf_Sym *sh_symtab;
30988 struct section *sec_applies, *sec_symtab;
30989 - int j;
30990 + unsigned int j;
30991 struct section *sec = &secs[i];
30992
30993 if (sec->shdr.sh_type != SHT_REL_TYPE) {
30994 @@ -812,6 +860,23 @@ static int do_reloc32(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
30995 {
30996 unsigned r_type = ELF32_R_TYPE(rel->r_info);
30997 int shn_abs = (sym->st_shndx == SHN_ABS) && !is_reloc(S_REL, symname);
30998 + char *sym_strtab = sec->link->link->strtab;
30999 +
31000 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
31001 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
31002 + return 0;
31003 +
31004 +#ifdef CONFIG_PAX_KERNEXEC
31005 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
31006 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
31007 + return 0;
31008 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
31009 + return 0;
31010 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
31011 + return 0;
31012 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
31013 + return 0;
31014 +#endif
31015
31016 switch (r_type) {
31017 case R_386_NONE:
31018 @@ -950,7 +1015,7 @@ static int write32_as_text(uint32_t v, FILE *f)
31019
31020 static void emit_relocs(int as_text, int use_real_mode)
31021 {
31022 - int i;
31023 + unsigned int i;
31024 int (*write_reloc)(uint32_t, FILE *) = write32;
31025 int (*do_reloc)(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
31026 const char *symname);
31027 @@ -1026,10 +1091,11 @@ void process(FILE *fp, int use_real_mode, int as_text,
31028 {
31029 regex_init(use_real_mode);
31030 read_ehdr(fp);
31031 + read_phdrs(fp);
31032 read_shdrs(fp);
31033 read_strtabs(fp);
31034 read_symtabs(fp);
31035 - read_relocs(fp);
31036 + read_relocs(fp, use_real_mode);
31037 if (ELF_BITS == 64)
31038 percpu_init();
31039 if (show_absolute_syms) {
31040 diff --git a/arch/x86/um/tls_32.c b/arch/x86/um/tls_32.c
31041 index 80ffa5b..a33bd15 100644
31042 --- a/arch/x86/um/tls_32.c
31043 +++ b/arch/x86/um/tls_32.c
31044 @@ -260,7 +260,7 @@ out:
31045 if (unlikely(task == current &&
31046 !t->arch.tls_array[idx - GDT_ENTRY_TLS_MIN].flushed)) {
31047 printk(KERN_ERR "get_tls_entry: task with pid %d got here "
31048 - "without flushed TLS.", current->pid);
31049 + "without flushed TLS.", task_pid_nr(current));
31050 }
31051
31052 return 0;
31053 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
31054 index fd14be1..e3c79c0 100644
31055 --- a/arch/x86/vdso/Makefile
31056 +++ b/arch/x86/vdso/Makefile
31057 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
31058 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
31059 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
31060
31061 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
31062 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
31063 GCOV_PROFILE := n
31064
31065 #
31066 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
31067 index 0faad64..39ef157 100644
31068 --- a/arch/x86/vdso/vdso32-setup.c
31069 +++ b/arch/x86/vdso/vdso32-setup.c
31070 @@ -25,6 +25,7 @@
31071 #include <asm/tlbflush.h>
31072 #include <asm/vdso.h>
31073 #include <asm/proto.h>
31074 +#include <asm/mman.h>
31075
31076 enum {
31077 VDSO_DISABLED = 0,
31078 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
31079 void enable_sep_cpu(void)
31080 {
31081 int cpu = get_cpu();
31082 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
31083 + struct tss_struct *tss = init_tss + cpu;
31084
31085 if (!boot_cpu_has(X86_FEATURE_SEP)) {
31086 put_cpu();
31087 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
31088 gate_vma.vm_start = FIXADDR_USER_START;
31089 gate_vma.vm_end = FIXADDR_USER_END;
31090 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
31091 - gate_vma.vm_page_prot = __P101;
31092 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
31093
31094 return 0;
31095 }
31096 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31097 if (compat)
31098 addr = VDSO_HIGH_BASE;
31099 else {
31100 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
31101 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
31102 if (IS_ERR_VALUE(addr)) {
31103 ret = addr;
31104 goto up_fail;
31105 }
31106 }
31107
31108 - current->mm->context.vdso = (void *)addr;
31109 + current->mm->context.vdso = addr;
31110
31111 if (compat_uses_vma || !compat) {
31112 /*
31113 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31114 }
31115
31116 current_thread_info()->sysenter_return =
31117 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31118 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
31119
31120 up_fail:
31121 if (ret)
31122 - current->mm->context.vdso = NULL;
31123 + current->mm->context.vdso = 0;
31124
31125 up_write(&mm->mmap_sem);
31126
31127 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
31128
31129 const char *arch_vma_name(struct vm_area_struct *vma)
31130 {
31131 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
31132 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
31133 return "[vdso]";
31134 +
31135 +#ifdef CONFIG_PAX_SEGMEXEC
31136 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
31137 + return "[vdso]";
31138 +#endif
31139 +
31140 return NULL;
31141 }
31142
31143 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
31144 * Check to see if the corresponding task was created in compat vdso
31145 * mode.
31146 */
31147 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
31148 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
31149 return &gate_vma;
31150 return NULL;
31151 }
31152 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
31153 index 431e875..cbb23f3 100644
31154 --- a/arch/x86/vdso/vma.c
31155 +++ b/arch/x86/vdso/vma.c
31156 @@ -16,8 +16,6 @@
31157 #include <asm/vdso.h>
31158 #include <asm/page.h>
31159
31160 -unsigned int __read_mostly vdso_enabled = 1;
31161 -
31162 extern char vdso_start[], vdso_end[];
31163 extern unsigned short vdso_sync_cpuid;
31164
31165 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
31166 * unaligned here as a result of stack start randomization.
31167 */
31168 addr = PAGE_ALIGN(addr);
31169 - addr = align_vdso_addr(addr);
31170
31171 return addr;
31172 }
31173 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
31174 unsigned size)
31175 {
31176 struct mm_struct *mm = current->mm;
31177 - unsigned long addr;
31178 + unsigned long addr = 0;
31179 int ret;
31180
31181 - if (!vdso_enabled)
31182 - return 0;
31183 -
31184 down_write(&mm->mmap_sem);
31185 +
31186 +#ifdef CONFIG_PAX_RANDMMAP
31187 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
31188 +#endif
31189 +
31190 addr = vdso_addr(mm->start_stack, size);
31191 + addr = align_vdso_addr(addr);
31192 addr = get_unmapped_area(NULL, addr, size, 0, 0);
31193 if (IS_ERR_VALUE(addr)) {
31194 ret = addr;
31195 goto up_fail;
31196 }
31197
31198 - current->mm->context.vdso = (void *)addr;
31199 + mm->context.vdso = addr;
31200
31201 ret = install_special_mapping(mm, addr, size,
31202 VM_READ|VM_EXEC|
31203 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
31204 pages);
31205 - if (ret) {
31206 - current->mm->context.vdso = NULL;
31207 - goto up_fail;
31208 - }
31209 + if (ret)
31210 + mm->context.vdso = 0;
31211
31212 up_fail:
31213 up_write(&mm->mmap_sem);
31214 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
31215 vdsox32_size);
31216 }
31217 #endif
31218 -
31219 -static __init int vdso_setup(char *s)
31220 -{
31221 - vdso_enabled = simple_strtoul(s, NULL, 0);
31222 - return 0;
31223 -}
31224 -__setup("vdso=", vdso_setup);
31225 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
31226 index a492be2..08678da 100644
31227 --- a/arch/x86/xen/enlighten.c
31228 +++ b/arch/x86/xen/enlighten.c
31229 @@ -123,8 +123,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
31230
31231 struct shared_info xen_dummy_shared_info;
31232
31233 -void *xen_initial_gdt;
31234 -
31235 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
31236 __read_mostly int xen_have_vector_callback;
31237 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
31238 @@ -542,8 +540,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
31239 {
31240 unsigned long va = dtr->address;
31241 unsigned int size = dtr->size + 1;
31242 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31243 - unsigned long frames[pages];
31244 + unsigned long frames[65536 / PAGE_SIZE];
31245 int f;
31246
31247 /*
31248 @@ -591,8 +588,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31249 {
31250 unsigned long va = dtr->address;
31251 unsigned int size = dtr->size + 1;
31252 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
31253 - unsigned long frames[pages];
31254 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
31255 int f;
31256
31257 /*
31258 @@ -600,7 +596,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
31259 * 8-byte entries, or 16 4k pages..
31260 */
31261
31262 - BUG_ON(size > 65536);
31263 + BUG_ON(size > GDT_SIZE);
31264 BUG_ON(va & ~PAGE_MASK);
31265
31266 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
31267 @@ -985,7 +981,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
31268 return 0;
31269 }
31270
31271 -static void set_xen_basic_apic_ops(void)
31272 +static void __init set_xen_basic_apic_ops(void)
31273 {
31274 apic->read = xen_apic_read;
31275 apic->write = xen_apic_write;
31276 @@ -1290,30 +1286,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
31277 #endif
31278 };
31279
31280 -static void xen_reboot(int reason)
31281 +static __noreturn void xen_reboot(int reason)
31282 {
31283 struct sched_shutdown r = { .reason = reason };
31284
31285 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
31286 - BUG();
31287 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
31288 + BUG();
31289 }
31290
31291 -static void xen_restart(char *msg)
31292 +static __noreturn void xen_restart(char *msg)
31293 {
31294 xen_reboot(SHUTDOWN_reboot);
31295 }
31296
31297 -static void xen_emergency_restart(void)
31298 +static __noreturn void xen_emergency_restart(void)
31299 {
31300 xen_reboot(SHUTDOWN_reboot);
31301 }
31302
31303 -static void xen_machine_halt(void)
31304 +static __noreturn void xen_machine_halt(void)
31305 {
31306 xen_reboot(SHUTDOWN_poweroff);
31307 }
31308
31309 -static void xen_machine_power_off(void)
31310 +static __noreturn void xen_machine_power_off(void)
31311 {
31312 if (pm_power_off)
31313 pm_power_off();
31314 @@ -1464,7 +1460,17 @@ asmlinkage void __init xen_start_kernel(void)
31315 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
31316
31317 /* Work out if we support NX */
31318 - x86_configure_nx();
31319 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
31320 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
31321 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
31322 + unsigned l, h;
31323 +
31324 + __supported_pte_mask |= _PAGE_NX;
31325 + rdmsr(MSR_EFER, l, h);
31326 + l |= EFER_NX;
31327 + wrmsr(MSR_EFER, l, h);
31328 + }
31329 +#endif
31330
31331 xen_setup_features();
31332
31333 @@ -1495,13 +1501,6 @@ asmlinkage void __init xen_start_kernel(void)
31334
31335 machine_ops = xen_machine_ops;
31336
31337 - /*
31338 - * The only reliable way to retain the initial address of the
31339 - * percpu gdt_page is to remember it here, so we can go and
31340 - * mark it RW later, when the initial percpu area is freed.
31341 - */
31342 - xen_initial_gdt = &per_cpu(gdt_page, 0);
31343 -
31344 xen_smp_init();
31345
31346 #ifdef CONFIG_ACPI_NUMA
31347 @@ -1700,7 +1699,7 @@ static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self,
31348 return NOTIFY_OK;
31349 }
31350
31351 -static struct notifier_block xen_hvm_cpu_notifier __cpuinitdata = {
31352 +static struct notifier_block xen_hvm_cpu_notifier = {
31353 .notifier_call = xen_hvm_cpu_notify,
31354 };
31355
31356 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
31357 index fdc3ba2..3daee39 100644
31358 --- a/arch/x86/xen/mmu.c
31359 +++ b/arch/x86/xen/mmu.c
31360 @@ -1894,6 +1894,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31361 /* L3_k[510] -> level2_kernel_pgt
31362 * L3_i[511] -> level2_fixmap_pgt */
31363 convert_pfn_mfn(level3_kernel_pgt);
31364 + convert_pfn_mfn(level3_vmalloc_start_pgt);
31365 + convert_pfn_mfn(level3_vmalloc_end_pgt);
31366 + convert_pfn_mfn(level3_vmemmap_pgt);
31367
31368 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
31369 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
31370 @@ -1923,8 +1926,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
31371 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
31372 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
31373 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
31374 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
31375 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
31376 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
31377 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
31378 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
31379 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
31380 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
31381 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
31382
31383 @@ -2108,6 +2115,7 @@ static void __init xen_post_allocator_init(void)
31384 pv_mmu_ops.set_pud = xen_set_pud;
31385 #if PAGETABLE_LEVELS == 4
31386 pv_mmu_ops.set_pgd = xen_set_pgd;
31387 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
31388 #endif
31389
31390 /* This will work as long as patching hasn't happened yet
31391 @@ -2186,6 +2194,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
31392 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
31393 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
31394 .set_pgd = xen_set_pgd_hyper,
31395 + .set_pgd_batched = xen_set_pgd_hyper,
31396
31397 .alloc_pud = xen_alloc_pmd_init,
31398 .release_pud = xen_release_pmd_init,
31399 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
31400 index d99cae8..18401e1 100644
31401 --- a/arch/x86/xen/smp.c
31402 +++ b/arch/x86/xen/smp.c
31403 @@ -240,11 +240,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
31404 {
31405 BUG_ON(smp_processor_id() != 0);
31406 native_smp_prepare_boot_cpu();
31407 -
31408 - /* We've switched to the "real" per-cpu gdt, so make sure the
31409 - old memory can be recycled */
31410 - make_lowmem_page_readwrite(xen_initial_gdt);
31411 -
31412 xen_filter_cpu_maps();
31413 xen_setup_vcpu_info_placement();
31414 }
31415 @@ -314,7 +309,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
31416 ctxt->user_regs.ss = __KERNEL_DS;
31417 #ifdef CONFIG_X86_32
31418 ctxt->user_regs.fs = __KERNEL_PERCPU;
31419 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
31420 + savesegment(gs, ctxt->user_regs.gs);
31421 #else
31422 ctxt->gs_base_kernel = per_cpu_offset(cpu);
31423 #endif
31424 @@ -324,8 +319,8 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
31425
31426 {
31427 ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
31428 - ctxt->user_regs.ds = __USER_DS;
31429 - ctxt->user_regs.es = __USER_DS;
31430 + ctxt->user_regs.ds = __KERNEL_DS;
31431 + ctxt->user_regs.es = __KERNEL_DS;
31432
31433 xen_copy_trap_info(ctxt->trap_ctxt);
31434
31435 @@ -370,13 +365,12 @@ static int __cpuinit xen_cpu_up(unsigned int cpu, struct task_struct *idle)
31436 int rc;
31437
31438 per_cpu(current_task, cpu) = idle;
31439 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
31440 #ifdef CONFIG_X86_32
31441 irq_ctx_init(cpu);
31442 #else
31443 clear_tsk_thread_flag(idle, TIF_FORK);
31444 - per_cpu(kernel_stack, cpu) =
31445 - (unsigned long)task_stack_page(idle) -
31446 - KERNEL_STACK_OFFSET + THREAD_SIZE;
31447 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
31448 #endif
31449 xen_setup_runstate_info(cpu);
31450 xen_setup_timer(cpu);
31451 @@ -651,7 +645,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
31452
31453 void __init xen_smp_init(void)
31454 {
31455 - smp_ops = xen_smp_ops;
31456 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
31457 xen_fill_possible_map();
31458 xen_init_spinlocks();
31459 }
31460 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
31461 index 33ca6e4..0ded929 100644
31462 --- a/arch/x86/xen/xen-asm_32.S
31463 +++ b/arch/x86/xen/xen-asm_32.S
31464 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
31465 ESP_OFFSET=4 # bytes pushed onto stack
31466
31467 /*
31468 - * Store vcpu_info pointer for easy access. Do it this way to
31469 - * avoid having to reload %fs
31470 + * Store vcpu_info pointer for easy access.
31471 */
31472 #ifdef CONFIG_SMP
31473 - GET_THREAD_INFO(%eax)
31474 - movl %ss:TI_cpu(%eax), %eax
31475 - movl %ss:__per_cpu_offset(,%eax,4), %eax
31476 - mov %ss:xen_vcpu(%eax), %eax
31477 + push %fs
31478 + mov $(__KERNEL_PERCPU), %eax
31479 + mov %eax, %fs
31480 + mov PER_CPU_VAR(xen_vcpu), %eax
31481 + pop %fs
31482 #else
31483 movl %ss:xen_vcpu, %eax
31484 #endif
31485 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
31486 index 7faed58..ba4427c 100644
31487 --- a/arch/x86/xen/xen-head.S
31488 +++ b/arch/x86/xen/xen-head.S
31489 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
31490 #ifdef CONFIG_X86_32
31491 mov %esi,xen_start_info
31492 mov $init_thread_union+THREAD_SIZE,%esp
31493 +#ifdef CONFIG_SMP
31494 + movl $cpu_gdt_table,%edi
31495 + movl $__per_cpu_load,%eax
31496 + movw %ax,__KERNEL_PERCPU + 2(%edi)
31497 + rorl $16,%eax
31498 + movb %al,__KERNEL_PERCPU + 4(%edi)
31499 + movb %ah,__KERNEL_PERCPU + 7(%edi)
31500 + movl $__per_cpu_end - 1,%eax
31501 + subl $__per_cpu_start,%eax
31502 + movw %ax,__KERNEL_PERCPU + 0(%edi)
31503 +#endif
31504 #else
31505 mov %rsi,xen_start_info
31506 mov $init_thread_union+THREAD_SIZE,%rsp
31507 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
31508 index a95b417..b6dbd0b 100644
31509 --- a/arch/x86/xen/xen-ops.h
31510 +++ b/arch/x86/xen/xen-ops.h
31511 @@ -10,8 +10,6 @@
31512 extern const char xen_hypervisor_callback[];
31513 extern const char xen_failsafe_callback[];
31514
31515 -extern void *xen_initial_gdt;
31516 -
31517 struct trap_info;
31518 void xen_copy_trap_info(struct trap_info *traps);
31519
31520 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
31521 index 525bd3d..ef888b1 100644
31522 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
31523 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
31524 @@ -119,9 +119,9 @@
31525 ----------------------------------------------------------------------*/
31526
31527 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
31528 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
31529 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
31530 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
31531 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31532
31533 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
31534 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
31535 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
31536 index 2f33760..835e50a 100644
31537 --- a/arch/xtensa/variants/fsf/include/variant/core.h
31538 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
31539 @@ -11,6 +11,7 @@
31540 #ifndef _XTENSA_CORE_H
31541 #define _XTENSA_CORE_H
31542
31543 +#include <linux/const.h>
31544
31545 /****************************************************************************
31546 Parameters Useful for Any Code, USER or PRIVILEGED
31547 @@ -112,9 +113,9 @@
31548 ----------------------------------------------------------------------*/
31549
31550 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31551 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31552 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31553 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31554 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31555
31556 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
31557 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
31558 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
31559 index af00795..2bb8105 100644
31560 --- a/arch/xtensa/variants/s6000/include/variant/core.h
31561 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
31562 @@ -11,6 +11,7 @@
31563 #ifndef _XTENSA_CORE_CONFIGURATION_H
31564 #define _XTENSA_CORE_CONFIGURATION_H
31565
31566 +#include <linux/const.h>
31567
31568 /****************************************************************************
31569 Parameters Useful for Any Code, USER or PRIVILEGED
31570 @@ -118,9 +119,9 @@
31571 ----------------------------------------------------------------------*/
31572
31573 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
31574 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
31575 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
31576 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
31577 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
31578
31579 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
31580 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
31581 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
31582 index 58916af..eb9dbcf6 100644
31583 --- a/block/blk-iopoll.c
31584 +++ b/block/blk-iopoll.c
31585 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
31586 }
31587 EXPORT_SYMBOL(blk_iopoll_complete);
31588
31589 -static void blk_iopoll_softirq(struct softirq_action *h)
31590 +static void blk_iopoll_softirq(void)
31591 {
31592 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
31593 int rearm = 0, budget = blk_iopoll_budget;
31594 @@ -209,7 +209,7 @@ static int __cpuinit blk_iopoll_cpu_notify(struct notifier_block *self,
31595 return NOTIFY_OK;
31596 }
31597
31598 -static struct notifier_block __cpuinitdata blk_iopoll_cpu_notifier = {
31599 +static struct notifier_block blk_iopoll_cpu_notifier = {
31600 .notifier_call = blk_iopoll_cpu_notify,
31601 };
31602
31603 diff --git a/block/blk-map.c b/block/blk-map.c
31604 index 623e1cd..ca1e109 100644
31605 --- a/block/blk-map.c
31606 +++ b/block/blk-map.c
31607 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
31608 if (!len || !kbuf)
31609 return -EINVAL;
31610
31611 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
31612 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
31613 if (do_copy)
31614 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
31615 else
31616 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
31617 index 467c8de..f3628c5 100644
31618 --- a/block/blk-softirq.c
31619 +++ b/block/blk-softirq.c
31620 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
31621 * Softirq action handler - move entries to local list and loop over them
31622 * while passing them to the queue registered handler.
31623 */
31624 -static void blk_done_softirq(struct softirq_action *h)
31625 +static void blk_done_softirq(void)
31626 {
31627 struct list_head *cpu_list, local_list;
31628
31629 @@ -98,7 +98,7 @@ static int __cpuinit blk_cpu_notify(struct notifier_block *self,
31630 return NOTIFY_OK;
31631 }
31632
31633 -static struct notifier_block __cpuinitdata blk_cpu_notifier = {
31634 +static struct notifier_block blk_cpu_notifier = {
31635 .notifier_call = blk_cpu_notify,
31636 };
31637
31638 diff --git a/block/bsg.c b/block/bsg.c
31639 index 420a5a9..23834aa 100644
31640 --- a/block/bsg.c
31641 +++ b/block/bsg.c
31642 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
31643 struct sg_io_v4 *hdr, struct bsg_device *bd,
31644 fmode_t has_write_perm)
31645 {
31646 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31647 + unsigned char *cmdptr;
31648 +
31649 if (hdr->request_len > BLK_MAX_CDB) {
31650 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
31651 if (!rq->cmd)
31652 return -ENOMEM;
31653 - }
31654 + cmdptr = rq->cmd;
31655 + } else
31656 + cmdptr = tmpcmd;
31657
31658 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
31659 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
31660 hdr->request_len))
31661 return -EFAULT;
31662
31663 + if (cmdptr != rq->cmd)
31664 + memcpy(rq->cmd, cmdptr, hdr->request_len);
31665 +
31666 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
31667 if (blk_verify_command(rq->cmd, has_write_perm))
31668 return -EPERM;
31669 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
31670 index 7c668c8..db3521c 100644
31671 --- a/block/compat_ioctl.c
31672 +++ b/block/compat_ioctl.c
31673 @@ -340,7 +340,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
31674 err |= __get_user(f->spec1, &uf->spec1);
31675 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
31676 err |= __get_user(name, &uf->name);
31677 - f->name = compat_ptr(name);
31678 + f->name = (void __force_kernel *)compat_ptr(name);
31679 if (err) {
31680 err = -EFAULT;
31681 goto out;
31682 diff --git a/block/genhd.c b/block/genhd.c
31683 index 20625ee..10aa34d 100644
31684 --- a/block/genhd.c
31685 +++ b/block/genhd.c
31686 @@ -467,21 +467,24 @@ static char *bdevt_str(dev_t devt, char *buf)
31687
31688 /*
31689 * Register device numbers dev..(dev+range-1)
31690 - * range must be nonzero
31691 + * Noop if @range is zero.
31692 * The hash chain is sorted on range, so that subranges can override.
31693 */
31694 void blk_register_region(dev_t devt, unsigned long range, struct module *module,
31695 struct kobject *(*probe)(dev_t, int *, void *),
31696 int (*lock)(dev_t, void *), void *data)
31697 {
31698 - kobj_map(bdev_map, devt, range, module, probe, lock, data);
31699 + if (range)
31700 + kobj_map(bdev_map, devt, range, module, probe, lock, data);
31701 }
31702
31703 EXPORT_SYMBOL(blk_register_region);
31704
31705 +/* undo blk_register_region(), noop if @range is zero */
31706 void blk_unregister_region(dev_t devt, unsigned long range)
31707 {
31708 - kobj_unmap(bdev_map, devt, range);
31709 + if (range)
31710 + kobj_unmap(bdev_map, devt, range);
31711 }
31712
31713 EXPORT_SYMBOL(blk_unregister_region);
31714 @@ -512,7 +515,7 @@ static void register_disk(struct gendisk *disk)
31715
31716 ddev->parent = disk->driverfs_dev;
31717
31718 - dev_set_name(ddev, disk->disk_name);
31719 + dev_set_name(ddev, "%s", disk->disk_name);
31720
31721 /* delay uevents, until we scanned partition table */
31722 dev_set_uevent_suppress(ddev, 1);
31723 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
31724 index c85fc89..51e690b 100644
31725 --- a/block/partitions/efi.c
31726 +++ b/block/partitions/efi.c
31727 @@ -234,14 +234,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
31728 if (!gpt)
31729 return NULL;
31730
31731 + if (!le32_to_cpu(gpt->num_partition_entries))
31732 + return NULL;
31733 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
31734 + if (!pte)
31735 + return NULL;
31736 +
31737 count = le32_to_cpu(gpt->num_partition_entries) *
31738 le32_to_cpu(gpt->sizeof_partition_entry);
31739 - if (!count)
31740 - return NULL;
31741 - pte = kmalloc(count, GFP_KERNEL);
31742 - if (!pte)
31743 - return NULL;
31744 -
31745 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
31746 (u8 *) pte,
31747 count) < count) {
31748 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
31749 index a5ffcc9..3cedc9c 100644
31750 --- a/block/scsi_ioctl.c
31751 +++ b/block/scsi_ioctl.c
31752 @@ -224,8 +224,20 @@ EXPORT_SYMBOL(blk_verify_command);
31753 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
31754 struct sg_io_hdr *hdr, fmode_t mode)
31755 {
31756 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
31757 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31758 + unsigned char *cmdptr;
31759 +
31760 + if (rq->cmd != rq->__cmd)
31761 + cmdptr = rq->cmd;
31762 + else
31763 + cmdptr = tmpcmd;
31764 +
31765 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
31766 return -EFAULT;
31767 +
31768 + if (cmdptr != rq->cmd)
31769 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
31770 +
31771 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
31772 return -EPERM;
31773
31774 @@ -434,6 +446,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
31775 int err;
31776 unsigned int in_len, out_len, bytes, opcode, cmdlen;
31777 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
31778 + unsigned char tmpcmd[sizeof(rq->__cmd)];
31779 + unsigned char *cmdptr;
31780
31781 if (!sic)
31782 return -EINVAL;
31783 @@ -467,9 +481,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
31784 */
31785 err = -EFAULT;
31786 rq->cmd_len = cmdlen;
31787 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
31788 +
31789 + if (rq->cmd != rq->__cmd)
31790 + cmdptr = rq->cmd;
31791 + else
31792 + cmdptr = tmpcmd;
31793 +
31794 + if (copy_from_user(cmdptr, sic->data, cmdlen))
31795 goto error;
31796
31797 + if (rq->cmd != cmdptr)
31798 + memcpy(rq->cmd, cmdptr, cmdlen);
31799 +
31800 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
31801 goto error;
31802
31803 diff --git a/crypto/algapi.c b/crypto/algapi.c
31804 index 6149a6e..55ed50d 100644
31805 --- a/crypto/algapi.c
31806 +++ b/crypto/algapi.c
31807 @@ -495,7 +495,7 @@ static struct crypto_template *__crypto_lookup_template(const char *name)
31808
31809 struct crypto_template *crypto_lookup_template(const char *name)
31810 {
31811 - return try_then_request_module(__crypto_lookup_template(name), name);
31812 + return try_then_request_module(__crypto_lookup_template(name), "%s", name);
31813 }
31814 EXPORT_SYMBOL_GPL(crypto_lookup_template);
31815
31816 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
31817 index 7bdd61b..afec999 100644
31818 --- a/crypto/cryptd.c
31819 +++ b/crypto/cryptd.c
31820 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
31821
31822 struct cryptd_blkcipher_request_ctx {
31823 crypto_completion_t complete;
31824 -};
31825 +} __no_const;
31826
31827 struct cryptd_hash_ctx {
31828 struct crypto_shash *child;
31829 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
31830
31831 struct cryptd_aead_request_ctx {
31832 crypto_completion_t complete;
31833 -};
31834 +} __no_const;
31835
31836 static void cryptd_queue_worker(struct work_struct *work);
31837
31838 diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
31839 index b2c99dc..476c9fb 100644
31840 --- a/crypto/pcrypt.c
31841 +++ b/crypto/pcrypt.c
31842 @@ -440,7 +440,7 @@ static int pcrypt_sysfs_add(struct padata_instance *pinst, const char *name)
31843 int ret;
31844
31845 pinst->kobj.kset = pcrypt_kset;
31846 - ret = kobject_add(&pinst->kobj, NULL, name);
31847 + ret = kobject_add(&pinst->kobj, NULL, "%s", name);
31848 if (!ret)
31849 kobject_uevent(&pinst->kobj, KOBJ_ADD);
31850
31851 @@ -455,8 +455,8 @@ static int pcrypt_init_padata(struct padata_pcrypt *pcrypt,
31852
31853 get_online_cpus();
31854
31855 - pcrypt->wq = alloc_workqueue(name,
31856 - WQ_MEM_RECLAIM | WQ_CPU_INTENSIVE, 1);
31857 + pcrypt->wq = alloc_workqueue("%s",
31858 + WQ_MEM_RECLAIM | WQ_CPU_INTENSIVE, 1, name);
31859 if (!pcrypt->wq)
31860 goto err;
31861
31862 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
31863 index f220d64..d359ad6 100644
31864 --- a/drivers/acpi/apei/apei-internal.h
31865 +++ b/drivers/acpi/apei/apei-internal.h
31866 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
31867 struct apei_exec_ins_type {
31868 u32 flags;
31869 apei_exec_ins_func_t run;
31870 -};
31871 +} __do_const;
31872
31873 struct apei_exec_context {
31874 u32 ip;
31875 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
31876 index 33dc6a0..4b24b47 100644
31877 --- a/drivers/acpi/apei/cper.c
31878 +++ b/drivers/acpi/apei/cper.c
31879 @@ -39,12 +39,12 @@
31880 */
31881 u64 cper_next_record_id(void)
31882 {
31883 - static atomic64_t seq;
31884 + static atomic64_unchecked_t seq;
31885
31886 - if (!atomic64_read(&seq))
31887 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
31888 + if (!atomic64_read_unchecked(&seq))
31889 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
31890
31891 - return atomic64_inc_return(&seq);
31892 + return atomic64_inc_return_unchecked(&seq);
31893 }
31894 EXPORT_SYMBOL_GPL(cper_next_record_id);
31895
31896 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
31897 index be60399..778b33e8 100644
31898 --- a/drivers/acpi/bgrt.c
31899 +++ b/drivers/acpi/bgrt.c
31900 @@ -87,8 +87,10 @@ static int __init bgrt_init(void)
31901 return -ENODEV;
31902
31903 sysfs_bin_attr_init(&image_attr);
31904 - image_attr.private = bgrt_image;
31905 - image_attr.size = bgrt_image_size;
31906 + pax_open_kernel();
31907 + *(void **)&image_attr.private = bgrt_image;
31908 + *(size_t *)&image_attr.size = bgrt_image_size;
31909 + pax_close_kernel();
31910
31911 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
31912 if (!bgrt_kobj)
31913 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
31914 index cb96296..b81293b 100644
31915 --- a/drivers/acpi/blacklist.c
31916 +++ b/drivers/acpi/blacklist.c
31917 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
31918 u32 is_critical_error;
31919 };
31920
31921 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
31922 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
31923
31924 /*
31925 * POLICY: If *anything* doesn't work, put it on the blacklist.
31926 @@ -193,7 +193,7 @@ static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
31927 return 0;
31928 }
31929
31930 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
31931 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
31932 {
31933 .callback = dmi_disable_osi_vista,
31934 .ident = "Fujitsu Siemens",
31935 diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
31936 index 7586544..636a2f0 100644
31937 --- a/drivers/acpi/ec_sys.c
31938 +++ b/drivers/acpi/ec_sys.c
31939 @@ -12,6 +12,7 @@
31940 #include <linux/acpi.h>
31941 #include <linux/debugfs.h>
31942 #include <linux/module.h>
31943 +#include <linux/uaccess.h>
31944 #include "internal.h"
31945
31946 MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>");
31947 @@ -34,7 +35,7 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
31948 * struct acpi_ec *ec = ((struct seq_file *)f->private_data)->private;
31949 */
31950 unsigned int size = EC_SPACE_SIZE;
31951 - u8 *data = (u8 *) buf;
31952 + u8 data;
31953 loff_t init_off = *off;
31954 int err = 0;
31955
31956 @@ -47,9 +48,11 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
31957 size = count;
31958
31959 while (size) {
31960 - err = ec_read(*off, &data[*off - init_off]);
31961 + err = ec_read(*off, &data);
31962 if (err)
31963 return err;
31964 + if (put_user(data, &buf[*off - init_off]))
31965 + return -EFAULT;
31966 *off += 1;
31967 size--;
31968 }
31969 @@ -65,7 +68,6 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
31970
31971 unsigned int size = count;
31972 loff_t init_off = *off;
31973 - u8 *data = (u8 *) buf;
31974 int err = 0;
31975
31976 if (*off >= EC_SPACE_SIZE)
31977 @@ -76,7 +78,9 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
31978 }
31979
31980 while (size) {
31981 - u8 byte_write = data[*off - init_off];
31982 + u8 byte_write;
31983 + if (get_user(byte_write, &buf[*off - init_off]))
31984 + return -EFAULT;
31985 err = ec_write(*off, byte_write);
31986 if (err)
31987 return err;
31988 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
31989 index eb133c7..f571552 100644
31990 --- a/drivers/acpi/processor_idle.c
31991 +++ b/drivers/acpi/processor_idle.c
31992 @@ -994,7 +994,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
31993 {
31994 int i, count = CPUIDLE_DRIVER_STATE_START;
31995 struct acpi_processor_cx *cx;
31996 - struct cpuidle_state *state;
31997 + cpuidle_state_no_const *state;
31998 struct cpuidle_driver *drv = &acpi_idle_driver;
31999
32000 if (!pr->flags.power_setup_done)
32001 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
32002 index fcae5fa..e9f71ea 100644
32003 --- a/drivers/acpi/sysfs.c
32004 +++ b/drivers/acpi/sysfs.c
32005 @@ -423,11 +423,11 @@ static u32 num_counters;
32006 static struct attribute **all_attrs;
32007 static u32 acpi_gpe_count;
32008
32009 -static struct attribute_group interrupt_stats_attr_group = {
32010 +static attribute_group_no_const interrupt_stats_attr_group = {
32011 .name = "interrupts",
32012 };
32013
32014 -static struct kobj_attribute *counter_attrs;
32015 +static kobj_attribute_no_const *counter_attrs;
32016
32017 static void delete_gpe_attr_array(void)
32018 {
32019 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
32020 index a70ff15..f1ff44e 100644
32021 --- a/drivers/ata/libahci.c
32022 +++ b/drivers/ata/libahci.c
32023 @@ -1230,7 +1230,7 @@ int ahci_kick_engine(struct ata_port *ap)
32024 }
32025 EXPORT_SYMBOL_GPL(ahci_kick_engine);
32026
32027 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
32028 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
32029 struct ata_taskfile *tf, int is_cmd, u16 flags,
32030 unsigned long timeout_msec)
32031 {
32032 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
32033 index adf002a..39bb8f9 100644
32034 --- a/drivers/ata/libata-core.c
32035 +++ b/drivers/ata/libata-core.c
32036 @@ -4792,7 +4792,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
32037 struct ata_port *ap;
32038 unsigned int tag;
32039
32040 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32041 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32042 ap = qc->ap;
32043
32044 qc->flags = 0;
32045 @@ -4808,7 +4808,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
32046 struct ata_port *ap;
32047 struct ata_link *link;
32048
32049 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32050 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
32051 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
32052 ap = qc->ap;
32053 link = qc->dev->link;
32054 @@ -5926,6 +5926,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
32055 return;
32056
32057 spin_lock(&lock);
32058 + pax_open_kernel();
32059
32060 for (cur = ops->inherits; cur; cur = cur->inherits) {
32061 void **inherit = (void **)cur;
32062 @@ -5939,8 +5940,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
32063 if (IS_ERR(*pp))
32064 *pp = NULL;
32065
32066 - ops->inherits = NULL;
32067 + *(struct ata_port_operations **)&ops->inherits = NULL;
32068
32069 + pax_close_kernel();
32070 spin_unlock(&lock);
32071 }
32072
32073 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
32074 index 7638121..357a965 100644
32075 --- a/drivers/ata/pata_arasan_cf.c
32076 +++ b/drivers/ata/pata_arasan_cf.c
32077 @@ -865,7 +865,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
32078 /* Handle platform specific quirks */
32079 if (quirk) {
32080 if (quirk & CF_BROKEN_PIO) {
32081 - ap->ops->set_piomode = NULL;
32082 + pax_open_kernel();
32083 + *(void **)&ap->ops->set_piomode = NULL;
32084 + pax_close_kernel();
32085 ap->pio_mask = 0;
32086 }
32087 if (quirk & CF_BROKEN_MWDMA)
32088 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
32089 index f9b983a..887b9d8 100644
32090 --- a/drivers/atm/adummy.c
32091 +++ b/drivers/atm/adummy.c
32092 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
32093 vcc->pop(vcc, skb);
32094 else
32095 dev_kfree_skb_any(skb);
32096 - atomic_inc(&vcc->stats->tx);
32097 + atomic_inc_unchecked(&vcc->stats->tx);
32098
32099 return 0;
32100 }
32101 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
32102 index 77a7480d..05cde58 100644
32103 --- a/drivers/atm/ambassador.c
32104 +++ b/drivers/atm/ambassador.c
32105 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
32106 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
32107
32108 // VC layer stats
32109 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32110 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32111
32112 // free the descriptor
32113 kfree (tx_descr);
32114 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
32115 dump_skb ("<<<", vc, skb);
32116
32117 // VC layer stats
32118 - atomic_inc(&atm_vcc->stats->rx);
32119 + atomic_inc_unchecked(&atm_vcc->stats->rx);
32120 __net_timestamp(skb);
32121 // end of our responsibility
32122 atm_vcc->push (atm_vcc, skb);
32123 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
32124 } else {
32125 PRINTK (KERN_INFO, "dropped over-size frame");
32126 // should we count this?
32127 - atomic_inc(&atm_vcc->stats->rx_drop);
32128 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32129 }
32130
32131 } else {
32132 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
32133 }
32134
32135 if (check_area (skb->data, skb->len)) {
32136 - atomic_inc(&atm_vcc->stats->tx_err);
32137 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
32138 return -ENOMEM; // ?
32139 }
32140
32141 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
32142 index 0e3f8f9..765a7a5 100644
32143 --- a/drivers/atm/atmtcp.c
32144 +++ b/drivers/atm/atmtcp.c
32145 @@ -206,7 +206,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32146 if (vcc->pop) vcc->pop(vcc,skb);
32147 else dev_kfree_skb(skb);
32148 if (dev_data) return 0;
32149 - atomic_inc(&vcc->stats->tx_err);
32150 + atomic_inc_unchecked(&vcc->stats->tx_err);
32151 return -ENOLINK;
32152 }
32153 size = skb->len+sizeof(struct atmtcp_hdr);
32154 @@ -214,7 +214,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32155 if (!new_skb) {
32156 if (vcc->pop) vcc->pop(vcc,skb);
32157 else dev_kfree_skb(skb);
32158 - atomic_inc(&vcc->stats->tx_err);
32159 + atomic_inc_unchecked(&vcc->stats->tx_err);
32160 return -ENOBUFS;
32161 }
32162 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
32163 @@ -225,8 +225,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
32164 if (vcc->pop) vcc->pop(vcc,skb);
32165 else dev_kfree_skb(skb);
32166 out_vcc->push(out_vcc,new_skb);
32167 - atomic_inc(&vcc->stats->tx);
32168 - atomic_inc(&out_vcc->stats->rx);
32169 + atomic_inc_unchecked(&vcc->stats->tx);
32170 + atomic_inc_unchecked(&out_vcc->stats->rx);
32171 return 0;
32172 }
32173
32174 @@ -299,7 +299,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32175 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
32176 read_unlock(&vcc_sklist_lock);
32177 if (!out_vcc) {
32178 - atomic_inc(&vcc->stats->tx_err);
32179 + atomic_inc_unchecked(&vcc->stats->tx_err);
32180 goto done;
32181 }
32182 skb_pull(skb,sizeof(struct atmtcp_hdr));
32183 @@ -311,8 +311,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
32184 __net_timestamp(new_skb);
32185 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
32186 out_vcc->push(out_vcc,new_skb);
32187 - atomic_inc(&vcc->stats->tx);
32188 - atomic_inc(&out_vcc->stats->rx);
32189 + atomic_inc_unchecked(&vcc->stats->tx);
32190 + atomic_inc_unchecked(&out_vcc->stats->rx);
32191 done:
32192 if (vcc->pop) vcc->pop(vcc,skb);
32193 else dev_kfree_skb(skb);
32194 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
32195 index b1955ba..b179940 100644
32196 --- a/drivers/atm/eni.c
32197 +++ b/drivers/atm/eni.c
32198 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
32199 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
32200 vcc->dev->number);
32201 length = 0;
32202 - atomic_inc(&vcc->stats->rx_err);
32203 + atomic_inc_unchecked(&vcc->stats->rx_err);
32204 }
32205 else {
32206 length = ATM_CELL_SIZE-1; /* no HEC */
32207 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32208 size);
32209 }
32210 eff = length = 0;
32211 - atomic_inc(&vcc->stats->rx_err);
32212 + atomic_inc_unchecked(&vcc->stats->rx_err);
32213 }
32214 else {
32215 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
32216 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
32217 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
32218 vcc->dev->number,vcc->vci,length,size << 2,descr);
32219 length = eff = 0;
32220 - atomic_inc(&vcc->stats->rx_err);
32221 + atomic_inc_unchecked(&vcc->stats->rx_err);
32222 }
32223 }
32224 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
32225 @@ -767,7 +767,7 @@ rx_dequeued++;
32226 vcc->push(vcc,skb);
32227 pushed++;
32228 }
32229 - atomic_inc(&vcc->stats->rx);
32230 + atomic_inc_unchecked(&vcc->stats->rx);
32231 }
32232 wake_up(&eni_dev->rx_wait);
32233 }
32234 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
32235 PCI_DMA_TODEVICE);
32236 if (vcc->pop) vcc->pop(vcc,skb);
32237 else dev_kfree_skb_irq(skb);
32238 - atomic_inc(&vcc->stats->tx);
32239 + atomic_inc_unchecked(&vcc->stats->tx);
32240 wake_up(&eni_dev->tx_wait);
32241 dma_complete++;
32242 }
32243 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
32244 index b41c948..a002b17 100644
32245 --- a/drivers/atm/firestream.c
32246 +++ b/drivers/atm/firestream.c
32247 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
32248 }
32249 }
32250
32251 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32252 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32253
32254 fs_dprintk (FS_DEBUG_TXMEM, "i");
32255 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
32256 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32257 #endif
32258 skb_put (skb, qe->p1 & 0xffff);
32259 ATM_SKB(skb)->vcc = atm_vcc;
32260 - atomic_inc(&atm_vcc->stats->rx);
32261 + atomic_inc_unchecked(&atm_vcc->stats->rx);
32262 __net_timestamp(skb);
32263 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
32264 atm_vcc->push (atm_vcc, skb);
32265 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
32266 kfree (pe);
32267 }
32268 if (atm_vcc)
32269 - atomic_inc(&atm_vcc->stats->rx_drop);
32270 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32271 break;
32272 case 0x1f: /* Reassembly abort: no buffers. */
32273 /* Silently increment error counter. */
32274 if (atm_vcc)
32275 - atomic_inc(&atm_vcc->stats->rx_drop);
32276 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
32277 break;
32278 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
32279 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
32280 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
32281 index 204814e..cede831 100644
32282 --- a/drivers/atm/fore200e.c
32283 +++ b/drivers/atm/fore200e.c
32284 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
32285 #endif
32286 /* check error condition */
32287 if (*entry->status & STATUS_ERROR)
32288 - atomic_inc(&vcc->stats->tx_err);
32289 + atomic_inc_unchecked(&vcc->stats->tx_err);
32290 else
32291 - atomic_inc(&vcc->stats->tx);
32292 + atomic_inc_unchecked(&vcc->stats->tx);
32293 }
32294 }
32295
32296 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32297 if (skb == NULL) {
32298 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
32299
32300 - atomic_inc(&vcc->stats->rx_drop);
32301 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32302 return -ENOMEM;
32303 }
32304
32305 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
32306
32307 dev_kfree_skb_any(skb);
32308
32309 - atomic_inc(&vcc->stats->rx_drop);
32310 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32311 return -ENOMEM;
32312 }
32313
32314 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32315
32316 vcc->push(vcc, skb);
32317 - atomic_inc(&vcc->stats->rx);
32318 + atomic_inc_unchecked(&vcc->stats->rx);
32319
32320 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
32321
32322 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
32323 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
32324 fore200e->atm_dev->number,
32325 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
32326 - atomic_inc(&vcc->stats->rx_err);
32327 + atomic_inc_unchecked(&vcc->stats->rx_err);
32328 }
32329 }
32330
32331 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
32332 goto retry_here;
32333 }
32334
32335 - atomic_inc(&vcc->stats->tx_err);
32336 + atomic_inc_unchecked(&vcc->stats->tx_err);
32337
32338 fore200e->tx_sat++;
32339 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
32340 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
32341 index 507362a..a845e57 100644
32342 --- a/drivers/atm/he.c
32343 +++ b/drivers/atm/he.c
32344 @@ -1698,7 +1698,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32345
32346 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
32347 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
32348 - atomic_inc(&vcc->stats->rx_drop);
32349 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32350 goto return_host_buffers;
32351 }
32352
32353 @@ -1725,7 +1725,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32354 RBRQ_LEN_ERR(he_dev->rbrq_head)
32355 ? "LEN_ERR" : "",
32356 vcc->vpi, vcc->vci);
32357 - atomic_inc(&vcc->stats->rx_err);
32358 + atomic_inc_unchecked(&vcc->stats->rx_err);
32359 goto return_host_buffers;
32360 }
32361
32362 @@ -1777,7 +1777,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
32363 vcc->push(vcc, skb);
32364 spin_lock(&he_dev->global_lock);
32365
32366 - atomic_inc(&vcc->stats->rx);
32367 + atomic_inc_unchecked(&vcc->stats->rx);
32368
32369 return_host_buffers:
32370 ++pdus_assembled;
32371 @@ -2103,7 +2103,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
32372 tpd->vcc->pop(tpd->vcc, tpd->skb);
32373 else
32374 dev_kfree_skb_any(tpd->skb);
32375 - atomic_inc(&tpd->vcc->stats->tx_err);
32376 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
32377 }
32378 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
32379 return;
32380 @@ -2515,7 +2515,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32381 vcc->pop(vcc, skb);
32382 else
32383 dev_kfree_skb_any(skb);
32384 - atomic_inc(&vcc->stats->tx_err);
32385 + atomic_inc_unchecked(&vcc->stats->tx_err);
32386 return -EINVAL;
32387 }
32388
32389 @@ -2526,7 +2526,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32390 vcc->pop(vcc, skb);
32391 else
32392 dev_kfree_skb_any(skb);
32393 - atomic_inc(&vcc->stats->tx_err);
32394 + atomic_inc_unchecked(&vcc->stats->tx_err);
32395 return -EINVAL;
32396 }
32397 #endif
32398 @@ -2538,7 +2538,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32399 vcc->pop(vcc, skb);
32400 else
32401 dev_kfree_skb_any(skb);
32402 - atomic_inc(&vcc->stats->tx_err);
32403 + atomic_inc_unchecked(&vcc->stats->tx_err);
32404 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32405 return -ENOMEM;
32406 }
32407 @@ -2580,7 +2580,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32408 vcc->pop(vcc, skb);
32409 else
32410 dev_kfree_skb_any(skb);
32411 - atomic_inc(&vcc->stats->tx_err);
32412 + atomic_inc_unchecked(&vcc->stats->tx_err);
32413 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32414 return -ENOMEM;
32415 }
32416 @@ -2611,7 +2611,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
32417 __enqueue_tpd(he_dev, tpd, cid);
32418 spin_unlock_irqrestore(&he_dev->global_lock, flags);
32419
32420 - atomic_inc(&vcc->stats->tx);
32421 + atomic_inc_unchecked(&vcc->stats->tx);
32422
32423 return 0;
32424 }
32425 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
32426 index 1dc0519..1aadaf7 100644
32427 --- a/drivers/atm/horizon.c
32428 +++ b/drivers/atm/horizon.c
32429 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
32430 {
32431 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
32432 // VC layer stats
32433 - atomic_inc(&vcc->stats->rx);
32434 + atomic_inc_unchecked(&vcc->stats->rx);
32435 __net_timestamp(skb);
32436 // end of our responsibility
32437 vcc->push (vcc, skb);
32438 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
32439 dev->tx_iovec = NULL;
32440
32441 // VC layer stats
32442 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
32443 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
32444
32445 // free the skb
32446 hrz_kfree_skb (skb);
32447 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
32448 index 272f009..a18ba55 100644
32449 --- a/drivers/atm/idt77252.c
32450 +++ b/drivers/atm/idt77252.c
32451 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
32452 else
32453 dev_kfree_skb(skb);
32454
32455 - atomic_inc(&vcc->stats->tx);
32456 + atomic_inc_unchecked(&vcc->stats->tx);
32457 }
32458
32459 atomic_dec(&scq->used);
32460 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32461 if ((sb = dev_alloc_skb(64)) == NULL) {
32462 printk("%s: Can't allocate buffers for aal0.\n",
32463 card->name);
32464 - atomic_add(i, &vcc->stats->rx_drop);
32465 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32466 break;
32467 }
32468 if (!atm_charge(vcc, sb->truesize)) {
32469 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
32470 card->name);
32471 - atomic_add(i - 1, &vcc->stats->rx_drop);
32472 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
32473 dev_kfree_skb(sb);
32474 break;
32475 }
32476 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32477 ATM_SKB(sb)->vcc = vcc;
32478 __net_timestamp(sb);
32479 vcc->push(vcc, sb);
32480 - atomic_inc(&vcc->stats->rx);
32481 + atomic_inc_unchecked(&vcc->stats->rx);
32482
32483 cell += ATM_CELL_PAYLOAD;
32484 }
32485 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32486 "(CDC: %08x)\n",
32487 card->name, len, rpp->len, readl(SAR_REG_CDC));
32488 recycle_rx_pool_skb(card, rpp);
32489 - atomic_inc(&vcc->stats->rx_err);
32490 + atomic_inc_unchecked(&vcc->stats->rx_err);
32491 return;
32492 }
32493 if (stat & SAR_RSQE_CRC) {
32494 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
32495 recycle_rx_pool_skb(card, rpp);
32496 - atomic_inc(&vcc->stats->rx_err);
32497 + atomic_inc_unchecked(&vcc->stats->rx_err);
32498 return;
32499 }
32500 if (skb_queue_len(&rpp->queue) > 1) {
32501 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32502 RXPRINTK("%s: Can't alloc RX skb.\n",
32503 card->name);
32504 recycle_rx_pool_skb(card, rpp);
32505 - atomic_inc(&vcc->stats->rx_err);
32506 + atomic_inc_unchecked(&vcc->stats->rx_err);
32507 return;
32508 }
32509 if (!atm_charge(vcc, skb->truesize)) {
32510 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32511 __net_timestamp(skb);
32512
32513 vcc->push(vcc, skb);
32514 - atomic_inc(&vcc->stats->rx);
32515 + atomic_inc_unchecked(&vcc->stats->rx);
32516
32517 return;
32518 }
32519 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
32520 __net_timestamp(skb);
32521
32522 vcc->push(vcc, skb);
32523 - atomic_inc(&vcc->stats->rx);
32524 + atomic_inc_unchecked(&vcc->stats->rx);
32525
32526 if (skb->truesize > SAR_FB_SIZE_3)
32527 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
32528 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
32529 if (vcc->qos.aal != ATM_AAL0) {
32530 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
32531 card->name, vpi, vci);
32532 - atomic_inc(&vcc->stats->rx_drop);
32533 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32534 goto drop;
32535 }
32536
32537 if ((sb = dev_alloc_skb(64)) == NULL) {
32538 printk("%s: Can't allocate buffers for AAL0.\n",
32539 card->name);
32540 - atomic_inc(&vcc->stats->rx_err);
32541 + atomic_inc_unchecked(&vcc->stats->rx_err);
32542 goto drop;
32543 }
32544
32545 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
32546 ATM_SKB(sb)->vcc = vcc;
32547 __net_timestamp(sb);
32548 vcc->push(vcc, sb);
32549 - atomic_inc(&vcc->stats->rx);
32550 + atomic_inc_unchecked(&vcc->stats->rx);
32551
32552 drop:
32553 skb_pull(queue, 64);
32554 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32555
32556 if (vc == NULL) {
32557 printk("%s: NULL connection in send().\n", card->name);
32558 - atomic_inc(&vcc->stats->tx_err);
32559 + atomic_inc_unchecked(&vcc->stats->tx_err);
32560 dev_kfree_skb(skb);
32561 return -EINVAL;
32562 }
32563 if (!test_bit(VCF_TX, &vc->flags)) {
32564 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
32565 - atomic_inc(&vcc->stats->tx_err);
32566 + atomic_inc_unchecked(&vcc->stats->tx_err);
32567 dev_kfree_skb(skb);
32568 return -EINVAL;
32569 }
32570 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32571 break;
32572 default:
32573 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
32574 - atomic_inc(&vcc->stats->tx_err);
32575 + atomic_inc_unchecked(&vcc->stats->tx_err);
32576 dev_kfree_skb(skb);
32577 return -EINVAL;
32578 }
32579
32580 if (skb_shinfo(skb)->nr_frags != 0) {
32581 printk("%s: No scatter-gather yet.\n", card->name);
32582 - atomic_inc(&vcc->stats->tx_err);
32583 + atomic_inc_unchecked(&vcc->stats->tx_err);
32584 dev_kfree_skb(skb);
32585 return -EINVAL;
32586 }
32587 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
32588
32589 err = queue_skb(card, vc, skb, oam);
32590 if (err) {
32591 - atomic_inc(&vcc->stats->tx_err);
32592 + atomic_inc_unchecked(&vcc->stats->tx_err);
32593 dev_kfree_skb(skb);
32594 return err;
32595 }
32596 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
32597 skb = dev_alloc_skb(64);
32598 if (!skb) {
32599 printk("%s: Out of memory in send_oam().\n", card->name);
32600 - atomic_inc(&vcc->stats->tx_err);
32601 + atomic_inc_unchecked(&vcc->stats->tx_err);
32602 return -ENOMEM;
32603 }
32604 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
32605 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
32606 index 4217f29..88f547a 100644
32607 --- a/drivers/atm/iphase.c
32608 +++ b/drivers/atm/iphase.c
32609 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
32610 status = (u_short) (buf_desc_ptr->desc_mode);
32611 if (status & (RX_CER | RX_PTE | RX_OFL))
32612 {
32613 - atomic_inc(&vcc->stats->rx_err);
32614 + atomic_inc_unchecked(&vcc->stats->rx_err);
32615 IF_ERR(printk("IA: bad packet, dropping it");)
32616 if (status & RX_CER) {
32617 IF_ERR(printk(" cause: packet CRC error\n");)
32618 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
32619 len = dma_addr - buf_addr;
32620 if (len > iadev->rx_buf_sz) {
32621 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
32622 - atomic_inc(&vcc->stats->rx_err);
32623 + atomic_inc_unchecked(&vcc->stats->rx_err);
32624 goto out_free_desc;
32625 }
32626
32627 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32628 ia_vcc = INPH_IA_VCC(vcc);
32629 if (ia_vcc == NULL)
32630 {
32631 - atomic_inc(&vcc->stats->rx_err);
32632 + atomic_inc_unchecked(&vcc->stats->rx_err);
32633 atm_return(vcc, skb->truesize);
32634 dev_kfree_skb_any(skb);
32635 goto INCR_DLE;
32636 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32637 if ((length > iadev->rx_buf_sz) || (length >
32638 (skb->len - sizeof(struct cpcs_trailer))))
32639 {
32640 - atomic_inc(&vcc->stats->rx_err);
32641 + atomic_inc_unchecked(&vcc->stats->rx_err);
32642 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
32643 length, skb->len);)
32644 atm_return(vcc, skb->truesize);
32645 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
32646
32647 IF_RX(printk("rx_dle_intr: skb push");)
32648 vcc->push(vcc,skb);
32649 - atomic_inc(&vcc->stats->rx);
32650 + atomic_inc_unchecked(&vcc->stats->rx);
32651 iadev->rx_pkt_cnt++;
32652 }
32653 INCR_DLE:
32654 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
32655 {
32656 struct k_sonet_stats *stats;
32657 stats = &PRIV(_ia_dev[board])->sonet_stats;
32658 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
32659 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
32660 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
32661 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
32662 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
32663 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
32664 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
32665 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
32666 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
32667 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
32668 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
32669 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
32670 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
32671 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
32672 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
32673 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
32674 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
32675 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
32676 }
32677 ia_cmds.status = 0;
32678 break;
32679 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32680 if ((desc == 0) || (desc > iadev->num_tx_desc))
32681 {
32682 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
32683 - atomic_inc(&vcc->stats->tx);
32684 + atomic_inc_unchecked(&vcc->stats->tx);
32685 if (vcc->pop)
32686 vcc->pop(vcc, skb);
32687 else
32688 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
32689 ATM_DESC(skb) = vcc->vci;
32690 skb_queue_tail(&iadev->tx_dma_q, skb);
32691
32692 - atomic_inc(&vcc->stats->tx);
32693 + atomic_inc_unchecked(&vcc->stats->tx);
32694 iadev->tx_pkt_cnt++;
32695 /* Increment transaction counter */
32696 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
32697
32698 #if 0
32699 /* add flow control logic */
32700 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
32701 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
32702 if (iavcc->vc_desc_cnt > 10) {
32703 vcc->tx_quota = vcc->tx_quota * 3 / 4;
32704 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
32705 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
32706 index fa7d701..1e404c7 100644
32707 --- a/drivers/atm/lanai.c
32708 +++ b/drivers/atm/lanai.c
32709 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
32710 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
32711 lanai_endtx(lanai, lvcc);
32712 lanai_free_skb(lvcc->tx.atmvcc, skb);
32713 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
32714 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
32715 }
32716
32717 /* Try to fill the buffer - don't call unless there is backlog */
32718 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
32719 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
32720 __net_timestamp(skb);
32721 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
32722 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
32723 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
32724 out:
32725 lvcc->rx.buf.ptr = end;
32726 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
32727 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32728 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
32729 "vcc %d\n", lanai->number, (unsigned int) s, vci);
32730 lanai->stats.service_rxnotaal5++;
32731 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32732 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32733 return 0;
32734 }
32735 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
32736 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32737 int bytes;
32738 read_unlock(&vcc_sklist_lock);
32739 DPRINTK("got trashed rx pdu on vci %d\n", vci);
32740 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32741 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32742 lvcc->stats.x.aal5.service_trash++;
32743 bytes = (SERVICE_GET_END(s) * 16) -
32744 (((unsigned long) lvcc->rx.buf.ptr) -
32745 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32746 }
32747 if (s & SERVICE_STREAM) {
32748 read_unlock(&vcc_sklist_lock);
32749 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32750 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32751 lvcc->stats.x.aal5.service_stream++;
32752 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
32753 "PDU on VCI %d!\n", lanai->number, vci);
32754 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
32755 return 0;
32756 }
32757 DPRINTK("got rx crc error on vci %d\n", vci);
32758 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
32759 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
32760 lvcc->stats.x.aal5.service_rxcrc++;
32761 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
32762 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
32763 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
32764 index 6587dc2..149833d 100644
32765 --- a/drivers/atm/nicstar.c
32766 +++ b/drivers/atm/nicstar.c
32767 @@ -1641,7 +1641,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32768 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
32769 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
32770 card->index);
32771 - atomic_inc(&vcc->stats->tx_err);
32772 + atomic_inc_unchecked(&vcc->stats->tx_err);
32773 dev_kfree_skb_any(skb);
32774 return -EINVAL;
32775 }
32776 @@ -1649,7 +1649,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32777 if (!vc->tx) {
32778 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
32779 card->index);
32780 - atomic_inc(&vcc->stats->tx_err);
32781 + atomic_inc_unchecked(&vcc->stats->tx_err);
32782 dev_kfree_skb_any(skb);
32783 return -EINVAL;
32784 }
32785 @@ -1657,14 +1657,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32786 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
32787 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
32788 card->index);
32789 - atomic_inc(&vcc->stats->tx_err);
32790 + atomic_inc_unchecked(&vcc->stats->tx_err);
32791 dev_kfree_skb_any(skb);
32792 return -EINVAL;
32793 }
32794
32795 if (skb_shinfo(skb)->nr_frags != 0) {
32796 printk("nicstar%d: No scatter-gather yet.\n", card->index);
32797 - atomic_inc(&vcc->stats->tx_err);
32798 + atomic_inc_unchecked(&vcc->stats->tx_err);
32799 dev_kfree_skb_any(skb);
32800 return -EINVAL;
32801 }
32802 @@ -1712,11 +1712,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
32803 }
32804
32805 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
32806 - atomic_inc(&vcc->stats->tx_err);
32807 + atomic_inc_unchecked(&vcc->stats->tx_err);
32808 dev_kfree_skb_any(skb);
32809 return -EIO;
32810 }
32811 - atomic_inc(&vcc->stats->tx);
32812 + atomic_inc_unchecked(&vcc->stats->tx);
32813
32814 return 0;
32815 }
32816 @@ -2033,14 +2033,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32817 printk
32818 ("nicstar%d: Can't allocate buffers for aal0.\n",
32819 card->index);
32820 - atomic_add(i, &vcc->stats->rx_drop);
32821 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
32822 break;
32823 }
32824 if (!atm_charge(vcc, sb->truesize)) {
32825 RXPRINTK
32826 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
32827 card->index);
32828 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
32829 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
32830 dev_kfree_skb_any(sb);
32831 break;
32832 }
32833 @@ -2055,7 +2055,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32834 ATM_SKB(sb)->vcc = vcc;
32835 __net_timestamp(sb);
32836 vcc->push(vcc, sb);
32837 - atomic_inc(&vcc->stats->rx);
32838 + atomic_inc_unchecked(&vcc->stats->rx);
32839 cell += ATM_CELL_PAYLOAD;
32840 }
32841
32842 @@ -2072,7 +2072,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32843 if (iovb == NULL) {
32844 printk("nicstar%d: Out of iovec buffers.\n",
32845 card->index);
32846 - atomic_inc(&vcc->stats->rx_drop);
32847 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32848 recycle_rx_buf(card, skb);
32849 return;
32850 }
32851 @@ -2096,7 +2096,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32852 small or large buffer itself. */
32853 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
32854 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
32855 - atomic_inc(&vcc->stats->rx_err);
32856 + atomic_inc_unchecked(&vcc->stats->rx_err);
32857 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32858 NS_MAX_IOVECS);
32859 NS_PRV_IOVCNT(iovb) = 0;
32860 @@ -2116,7 +2116,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32861 ("nicstar%d: Expected a small buffer, and this is not one.\n",
32862 card->index);
32863 which_list(card, skb);
32864 - atomic_inc(&vcc->stats->rx_err);
32865 + atomic_inc_unchecked(&vcc->stats->rx_err);
32866 recycle_rx_buf(card, skb);
32867 vc->rx_iov = NULL;
32868 recycle_iov_buf(card, iovb);
32869 @@ -2129,7 +2129,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32870 ("nicstar%d: Expected a large buffer, and this is not one.\n",
32871 card->index);
32872 which_list(card, skb);
32873 - atomic_inc(&vcc->stats->rx_err);
32874 + atomic_inc_unchecked(&vcc->stats->rx_err);
32875 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32876 NS_PRV_IOVCNT(iovb));
32877 vc->rx_iov = NULL;
32878 @@ -2152,7 +2152,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32879 printk(" - PDU size mismatch.\n");
32880 else
32881 printk(".\n");
32882 - atomic_inc(&vcc->stats->rx_err);
32883 + atomic_inc_unchecked(&vcc->stats->rx_err);
32884 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
32885 NS_PRV_IOVCNT(iovb));
32886 vc->rx_iov = NULL;
32887 @@ -2166,7 +2166,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32888 /* skb points to a small buffer */
32889 if (!atm_charge(vcc, skb->truesize)) {
32890 push_rxbufs(card, skb);
32891 - atomic_inc(&vcc->stats->rx_drop);
32892 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32893 } else {
32894 skb_put(skb, len);
32895 dequeue_sm_buf(card, skb);
32896 @@ -2176,7 +2176,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32897 ATM_SKB(skb)->vcc = vcc;
32898 __net_timestamp(skb);
32899 vcc->push(vcc, skb);
32900 - atomic_inc(&vcc->stats->rx);
32901 + atomic_inc_unchecked(&vcc->stats->rx);
32902 }
32903 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
32904 struct sk_buff *sb;
32905 @@ -2187,7 +2187,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32906 if (len <= NS_SMBUFSIZE) {
32907 if (!atm_charge(vcc, sb->truesize)) {
32908 push_rxbufs(card, sb);
32909 - atomic_inc(&vcc->stats->rx_drop);
32910 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32911 } else {
32912 skb_put(sb, len);
32913 dequeue_sm_buf(card, sb);
32914 @@ -2197,7 +2197,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32915 ATM_SKB(sb)->vcc = vcc;
32916 __net_timestamp(sb);
32917 vcc->push(vcc, sb);
32918 - atomic_inc(&vcc->stats->rx);
32919 + atomic_inc_unchecked(&vcc->stats->rx);
32920 }
32921
32922 push_rxbufs(card, skb);
32923 @@ -2206,7 +2206,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32924
32925 if (!atm_charge(vcc, skb->truesize)) {
32926 push_rxbufs(card, skb);
32927 - atomic_inc(&vcc->stats->rx_drop);
32928 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32929 } else {
32930 dequeue_lg_buf(card, skb);
32931 #ifdef NS_USE_DESTRUCTORS
32932 @@ -2219,7 +2219,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32933 ATM_SKB(skb)->vcc = vcc;
32934 __net_timestamp(skb);
32935 vcc->push(vcc, skb);
32936 - atomic_inc(&vcc->stats->rx);
32937 + atomic_inc_unchecked(&vcc->stats->rx);
32938 }
32939
32940 push_rxbufs(card, sb);
32941 @@ -2240,7 +2240,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32942 printk
32943 ("nicstar%d: Out of huge buffers.\n",
32944 card->index);
32945 - atomic_inc(&vcc->stats->rx_drop);
32946 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32947 recycle_iovec_rx_bufs(card,
32948 (struct iovec *)
32949 iovb->data,
32950 @@ -2291,7 +2291,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32951 card->hbpool.count++;
32952 } else
32953 dev_kfree_skb_any(hb);
32954 - atomic_inc(&vcc->stats->rx_drop);
32955 + atomic_inc_unchecked(&vcc->stats->rx_drop);
32956 } else {
32957 /* Copy the small buffer to the huge buffer */
32958 sb = (struct sk_buff *)iov->iov_base;
32959 @@ -2328,7 +2328,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
32960 #endif /* NS_USE_DESTRUCTORS */
32961 __net_timestamp(hb);
32962 vcc->push(vcc, hb);
32963 - atomic_inc(&vcc->stats->rx);
32964 + atomic_inc_unchecked(&vcc->stats->rx);
32965 }
32966 }
32967
32968 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
32969 index 32784d1..4a8434a 100644
32970 --- a/drivers/atm/solos-pci.c
32971 +++ b/drivers/atm/solos-pci.c
32972 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
32973 }
32974 atm_charge(vcc, skb->truesize);
32975 vcc->push(vcc, skb);
32976 - atomic_inc(&vcc->stats->rx);
32977 + atomic_inc_unchecked(&vcc->stats->rx);
32978 break;
32979
32980 case PKT_STATUS:
32981 @@ -1116,7 +1116,7 @@ static uint32_t fpga_tx(struct solos_card *card)
32982 vcc = SKB_CB(oldskb)->vcc;
32983
32984 if (vcc) {
32985 - atomic_inc(&vcc->stats->tx);
32986 + atomic_inc_unchecked(&vcc->stats->tx);
32987 solos_pop(vcc, oldskb);
32988 } else {
32989 dev_kfree_skb_irq(oldskb);
32990 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
32991 index 0215934..ce9f5b1 100644
32992 --- a/drivers/atm/suni.c
32993 +++ b/drivers/atm/suni.c
32994 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
32995
32996
32997 #define ADD_LIMITED(s,v) \
32998 - atomic_add((v),&stats->s); \
32999 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
33000 + atomic_add_unchecked((v),&stats->s); \
33001 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
33002
33003
33004 static void suni_hz(unsigned long from_timer)
33005 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
33006 index 5120a96..e2572bd 100644
33007 --- a/drivers/atm/uPD98402.c
33008 +++ b/drivers/atm/uPD98402.c
33009 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
33010 struct sonet_stats tmp;
33011 int error = 0;
33012
33013 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
33014 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
33015 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
33016 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
33017 if (zero && !error) {
33018 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
33019
33020
33021 #define ADD_LIMITED(s,v) \
33022 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
33023 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
33024 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
33025 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
33026 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
33027 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
33028
33029
33030 static void stat_event(struct atm_dev *dev)
33031 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
33032 if (reason & uPD98402_INT_PFM) stat_event(dev);
33033 if (reason & uPD98402_INT_PCO) {
33034 (void) GET(PCOCR); /* clear interrupt cause */
33035 - atomic_add(GET(HECCT),
33036 + atomic_add_unchecked(GET(HECCT),
33037 &PRIV(dev)->sonet_stats.uncorr_hcs);
33038 }
33039 if ((reason & uPD98402_INT_RFO) &&
33040 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
33041 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
33042 uPD98402_INT_LOS),PIMR); /* enable them */
33043 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
33044 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
33045 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
33046 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
33047 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
33048 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
33049 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
33050 return 0;
33051 }
33052
33053 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
33054 index 969c3c2..9b72956 100644
33055 --- a/drivers/atm/zatm.c
33056 +++ b/drivers/atm/zatm.c
33057 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
33058 }
33059 if (!size) {
33060 dev_kfree_skb_irq(skb);
33061 - if (vcc) atomic_inc(&vcc->stats->rx_err);
33062 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
33063 continue;
33064 }
33065 if (!atm_charge(vcc,skb->truesize)) {
33066 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
33067 skb->len = size;
33068 ATM_SKB(skb)->vcc = vcc;
33069 vcc->push(vcc,skb);
33070 - atomic_inc(&vcc->stats->rx);
33071 + atomic_inc_unchecked(&vcc->stats->rx);
33072 }
33073 zout(pos & 0xffff,MTA(mbx));
33074 #if 0 /* probably a stupid idea */
33075 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
33076 skb_queue_head(&zatm_vcc->backlog,skb);
33077 break;
33078 }
33079 - atomic_inc(&vcc->stats->tx);
33080 + atomic_inc_unchecked(&vcc->stats->tx);
33081 wake_up(&zatm_vcc->tx_wait);
33082 }
33083
33084 diff --git a/drivers/base/attribute_container.c b/drivers/base/attribute_container.c
33085 index d78b204..ecc1929 100644
33086 --- a/drivers/base/attribute_container.c
33087 +++ b/drivers/base/attribute_container.c
33088 @@ -167,7 +167,7 @@ attribute_container_add_device(struct device *dev,
33089 ic->classdev.parent = get_device(dev);
33090 ic->classdev.class = cont->class;
33091 cont->class->dev_release = attribute_container_release;
33092 - dev_set_name(&ic->classdev, dev_name(dev));
33093 + dev_set_name(&ic->classdev, "%s", dev_name(dev));
33094 if (fn)
33095 fn(cont, dev, &ic->classdev);
33096 else
33097 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
33098 index d414331..b4dd4ba 100644
33099 --- a/drivers/base/bus.c
33100 +++ b/drivers/base/bus.c
33101 @@ -1163,7 +1163,7 @@ int subsys_interface_register(struct subsys_interface *sif)
33102 return -EINVAL;
33103
33104 mutex_lock(&subsys->p->mutex);
33105 - list_add_tail(&sif->node, &subsys->p->interfaces);
33106 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
33107 if (sif->add_dev) {
33108 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
33109 while ((dev = subsys_dev_iter_next(&iter)))
33110 @@ -1188,7 +1188,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
33111 subsys = sif->subsys;
33112
33113 mutex_lock(&subsys->p->mutex);
33114 - list_del_init(&sif->node);
33115 + pax_list_del_init((struct list_head *)&sif->node);
33116 if (sif->remove_dev) {
33117 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
33118 while ((dev = subsys_dev_iter_next(&iter)))
33119 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
33120 index 7413d06..79155fa 100644
33121 --- a/drivers/base/devtmpfs.c
33122 +++ b/drivers/base/devtmpfs.c
33123 @@ -354,7 +354,7 @@ int devtmpfs_mount(const char *mntdir)
33124 if (!thread)
33125 return 0;
33126
33127 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
33128 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
33129 if (err)
33130 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
33131 else
33132 @@ -380,11 +380,11 @@ static int devtmpfsd(void *p)
33133 *err = sys_unshare(CLONE_NEWNS);
33134 if (*err)
33135 goto out;
33136 - *err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
33137 + *err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)"/", (char __force_user *)"devtmpfs", MS_SILENT, (char __force_user *)options);
33138 if (*err)
33139 goto out;
33140 - sys_chdir("/.."); /* will traverse into overmounted root */
33141 - sys_chroot(".");
33142 + sys_chdir((char __force_user *)"/.."); /* will traverse into overmounted root */
33143 + sys_chroot((char __force_user *)".");
33144 complete(&setup_done);
33145 while (1) {
33146 spin_lock(&req_lock);
33147 diff --git a/drivers/base/node.c b/drivers/base/node.c
33148 index 7616a77c..8f57f51 100644
33149 --- a/drivers/base/node.c
33150 +++ b/drivers/base/node.c
33151 @@ -626,7 +626,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
33152 struct node_attr {
33153 struct device_attribute attr;
33154 enum node_states state;
33155 -};
33156 +} __do_const;
33157
33158 static ssize_t show_node_state(struct device *dev,
33159 struct device_attribute *attr, char *buf)
33160 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
33161 index 7072404..76dcebd 100644
33162 --- a/drivers/base/power/domain.c
33163 +++ b/drivers/base/power/domain.c
33164 @@ -1850,7 +1850,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
33165 {
33166 struct cpuidle_driver *cpuidle_drv;
33167 struct gpd_cpu_data *cpu_data;
33168 - struct cpuidle_state *idle_state;
33169 + cpuidle_state_no_const *idle_state;
33170 int ret = 0;
33171
33172 if (IS_ERR_OR_NULL(genpd) || state < 0)
33173 @@ -1918,7 +1918,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
33174 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
33175 {
33176 struct gpd_cpu_data *cpu_data;
33177 - struct cpuidle_state *idle_state;
33178 + cpuidle_state_no_const *idle_state;
33179 int ret = 0;
33180
33181 if (IS_ERR_OR_NULL(genpd))
33182 diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
33183 index a53ebd2..8f73eeb 100644
33184 --- a/drivers/base/power/sysfs.c
33185 +++ b/drivers/base/power/sysfs.c
33186 @@ -185,7 +185,7 @@ static ssize_t rtpm_status_show(struct device *dev,
33187 return -EIO;
33188 }
33189 }
33190 - return sprintf(buf, p);
33191 + return sprintf(buf, "%s", p);
33192 }
33193
33194 static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
33195 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
33196 index 79715e7..df06b3b 100644
33197 --- a/drivers/base/power/wakeup.c
33198 +++ b/drivers/base/power/wakeup.c
33199 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
33200 * They need to be modified together atomically, so it's better to use one
33201 * atomic variable to hold them both.
33202 */
33203 -static atomic_t combined_event_count = ATOMIC_INIT(0);
33204 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
33205
33206 #define IN_PROGRESS_BITS (sizeof(int) * 4)
33207 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
33208
33209 static void split_counters(unsigned int *cnt, unsigned int *inpr)
33210 {
33211 - unsigned int comb = atomic_read(&combined_event_count);
33212 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
33213
33214 *cnt = (comb >> IN_PROGRESS_BITS);
33215 *inpr = comb & MAX_IN_PROGRESS;
33216 @@ -395,7 +395,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
33217 ws->start_prevent_time = ws->last_time;
33218
33219 /* Increment the counter of events in progress. */
33220 - cec = atomic_inc_return(&combined_event_count);
33221 + cec = atomic_inc_return_unchecked(&combined_event_count);
33222
33223 trace_wakeup_source_activate(ws->name, cec);
33224 }
33225 @@ -521,7 +521,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
33226 * Increment the counter of registered wakeup events and decrement the
33227 * couter of wakeup events in progress simultaneously.
33228 */
33229 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
33230 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
33231 trace_wakeup_source_deactivate(ws->name, cec);
33232
33233 split_counters(&cnt, &inpr);
33234 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
33235 index e8d11b6..7b1b36f 100644
33236 --- a/drivers/base/syscore.c
33237 +++ b/drivers/base/syscore.c
33238 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
33239 void register_syscore_ops(struct syscore_ops *ops)
33240 {
33241 mutex_lock(&syscore_ops_lock);
33242 - list_add_tail(&ops->node, &syscore_ops_list);
33243 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
33244 mutex_unlock(&syscore_ops_lock);
33245 }
33246 EXPORT_SYMBOL_GPL(register_syscore_ops);
33247 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
33248 void unregister_syscore_ops(struct syscore_ops *ops)
33249 {
33250 mutex_lock(&syscore_ops_lock);
33251 - list_del(&ops->node);
33252 + pax_list_del((struct list_head *)&ops->node);
33253 mutex_unlock(&syscore_ops_lock);
33254 }
33255 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
33256 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
33257 index 62b6c2c..4a11354 100644
33258 --- a/drivers/block/cciss.c
33259 +++ b/drivers/block/cciss.c
33260 @@ -1189,6 +1189,8 @@ static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode,
33261 int err;
33262 u32 cp;
33263
33264 + memset(&arg64, 0, sizeof(arg64));
33265 +
33266 err = 0;
33267 err |=
33268 copy_from_user(&arg64.LUN_info, &arg32->LUN_info,
33269 @@ -3010,7 +3012,7 @@ static void start_io(ctlr_info_t *h)
33270 while (!list_empty(&h->reqQ)) {
33271 c = list_entry(h->reqQ.next, CommandList_struct, list);
33272 /* can't do anything if fifo is full */
33273 - if ((h->access.fifo_full(h))) {
33274 + if ((h->access->fifo_full(h))) {
33275 dev_warn(&h->pdev->dev, "fifo full\n");
33276 break;
33277 }
33278 @@ -3020,7 +3022,7 @@ static void start_io(ctlr_info_t *h)
33279 h->Qdepth--;
33280
33281 /* Tell the controller execute command */
33282 - h->access.submit_command(h, c);
33283 + h->access->submit_command(h, c);
33284
33285 /* Put job onto the completed Q */
33286 addQ(&h->cmpQ, c);
33287 @@ -3446,17 +3448,17 @@ startio:
33288
33289 static inline unsigned long get_next_completion(ctlr_info_t *h)
33290 {
33291 - return h->access.command_completed(h);
33292 + return h->access->command_completed(h);
33293 }
33294
33295 static inline int interrupt_pending(ctlr_info_t *h)
33296 {
33297 - return h->access.intr_pending(h);
33298 + return h->access->intr_pending(h);
33299 }
33300
33301 static inline long interrupt_not_for_us(ctlr_info_t *h)
33302 {
33303 - return ((h->access.intr_pending(h) == 0) ||
33304 + return ((h->access->intr_pending(h) == 0) ||
33305 (h->interrupts_enabled == 0));
33306 }
33307
33308 @@ -3489,7 +3491,7 @@ static inline u32 next_command(ctlr_info_t *h)
33309 u32 a;
33310
33311 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
33312 - return h->access.command_completed(h);
33313 + return h->access->command_completed(h);
33314
33315 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
33316 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
33317 @@ -4046,7 +4048,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
33318 trans_support & CFGTBL_Trans_use_short_tags);
33319
33320 /* Change the access methods to the performant access methods */
33321 - h->access = SA5_performant_access;
33322 + h->access = &SA5_performant_access;
33323 h->transMethod = CFGTBL_Trans_Performant;
33324
33325 return;
33326 @@ -4319,7 +4321,7 @@ static int cciss_pci_init(ctlr_info_t *h)
33327 if (prod_index < 0)
33328 return -ENODEV;
33329 h->product_name = products[prod_index].product_name;
33330 - h->access = *(products[prod_index].access);
33331 + h->access = products[prod_index].access;
33332
33333 if (cciss_board_disabled(h)) {
33334 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
33335 @@ -5051,7 +5053,7 @@ reinit_after_soft_reset:
33336 }
33337
33338 /* make sure the board interrupts are off */
33339 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33340 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33341 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
33342 if (rc)
33343 goto clean2;
33344 @@ -5101,7 +5103,7 @@ reinit_after_soft_reset:
33345 * fake ones to scoop up any residual completions.
33346 */
33347 spin_lock_irqsave(&h->lock, flags);
33348 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33349 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33350 spin_unlock_irqrestore(&h->lock, flags);
33351 free_irq(h->intr[h->intr_mode], h);
33352 rc = cciss_request_irq(h, cciss_msix_discard_completions,
33353 @@ -5121,9 +5123,9 @@ reinit_after_soft_reset:
33354 dev_info(&h->pdev->dev, "Board READY.\n");
33355 dev_info(&h->pdev->dev,
33356 "Waiting for stale completions to drain.\n");
33357 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33358 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33359 msleep(10000);
33360 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33361 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33362
33363 rc = controller_reset_failed(h->cfgtable);
33364 if (rc)
33365 @@ -5146,7 +5148,7 @@ reinit_after_soft_reset:
33366 cciss_scsi_setup(h);
33367
33368 /* Turn the interrupts on so we can service requests */
33369 - h->access.set_intr_mask(h, CCISS_INTR_ON);
33370 + h->access->set_intr_mask(h, CCISS_INTR_ON);
33371
33372 /* Get the firmware version */
33373 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
33374 @@ -5218,7 +5220,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
33375 kfree(flush_buf);
33376 if (return_code != IO_OK)
33377 dev_warn(&h->pdev->dev, "Error flushing cache\n");
33378 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
33379 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
33380 free_irq(h->intr[h->intr_mode], h);
33381 }
33382
33383 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
33384 index 7fda30e..eb5dfe0 100644
33385 --- a/drivers/block/cciss.h
33386 +++ b/drivers/block/cciss.h
33387 @@ -101,7 +101,7 @@ struct ctlr_info
33388 /* information about each logical volume */
33389 drive_info_struct *drv[CISS_MAX_LUN];
33390
33391 - struct access_method access;
33392 + struct access_method *access;
33393
33394 /* queue and queue Info */
33395 struct list_head reqQ;
33396 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
33397 index 639d26b..fd6ad1f 100644
33398 --- a/drivers/block/cpqarray.c
33399 +++ b/drivers/block/cpqarray.c
33400 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33401 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
33402 goto Enomem4;
33403 }
33404 - hba[i]->access.set_intr_mask(hba[i], 0);
33405 + hba[i]->access->set_intr_mask(hba[i], 0);
33406 if (request_irq(hba[i]->intr, do_ida_intr,
33407 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
33408 {
33409 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
33410 add_timer(&hba[i]->timer);
33411
33412 /* Enable IRQ now that spinlock and rate limit timer are set up */
33413 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33414 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
33415
33416 for(j=0; j<NWD; j++) {
33417 struct gendisk *disk = ida_gendisk[i][j];
33418 @@ -694,7 +694,7 @@ DBGINFO(
33419 for(i=0; i<NR_PRODUCTS; i++) {
33420 if (board_id == products[i].board_id) {
33421 c->product_name = products[i].product_name;
33422 - c->access = *(products[i].access);
33423 + c->access = products[i].access;
33424 break;
33425 }
33426 }
33427 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
33428 hba[ctlr]->intr = intr;
33429 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
33430 hba[ctlr]->product_name = products[j].product_name;
33431 - hba[ctlr]->access = *(products[j].access);
33432 + hba[ctlr]->access = products[j].access;
33433 hba[ctlr]->ctlr = ctlr;
33434 hba[ctlr]->board_id = board_id;
33435 hba[ctlr]->pci_dev = NULL; /* not PCI */
33436 @@ -978,7 +978,7 @@ static void start_io(ctlr_info_t *h)
33437
33438 while((c = h->reqQ) != NULL) {
33439 /* Can't do anything if we're busy */
33440 - if (h->access.fifo_full(h) == 0)
33441 + if (h->access->fifo_full(h) == 0)
33442 return;
33443
33444 /* Get the first entry from the request Q */
33445 @@ -986,7 +986,7 @@ static void start_io(ctlr_info_t *h)
33446 h->Qdepth--;
33447
33448 /* Tell the controller to do our bidding */
33449 - h->access.submit_command(h, c);
33450 + h->access->submit_command(h, c);
33451
33452 /* Get onto the completion Q */
33453 addQ(&h->cmpQ, c);
33454 @@ -1048,7 +1048,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33455 unsigned long flags;
33456 __u32 a,a1;
33457
33458 - istat = h->access.intr_pending(h);
33459 + istat = h->access->intr_pending(h);
33460 /* Is this interrupt for us? */
33461 if (istat == 0)
33462 return IRQ_NONE;
33463 @@ -1059,7 +1059,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
33464 */
33465 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
33466 if (istat & FIFO_NOT_EMPTY) {
33467 - while((a = h->access.command_completed(h))) {
33468 + while((a = h->access->command_completed(h))) {
33469 a1 = a; a &= ~3;
33470 if ((c = h->cmpQ) == NULL)
33471 {
33472 @@ -1193,6 +1193,7 @@ out_passthru:
33473 ida_pci_info_struct pciinfo;
33474
33475 if (!arg) return -EINVAL;
33476 + memset(&pciinfo, 0, sizeof(pciinfo));
33477 pciinfo.bus = host->pci_dev->bus->number;
33478 pciinfo.dev_fn = host->pci_dev->devfn;
33479 pciinfo.board_id = host->board_id;
33480 @@ -1447,11 +1448,11 @@ static int sendcmd(
33481 /*
33482 * Disable interrupt
33483 */
33484 - info_p->access.set_intr_mask(info_p, 0);
33485 + info_p->access->set_intr_mask(info_p, 0);
33486 /* Make sure there is room in the command FIFO */
33487 /* Actually it should be completely empty at this time. */
33488 for (i = 200000; i > 0; i--) {
33489 - temp = info_p->access.fifo_full(info_p);
33490 + temp = info_p->access->fifo_full(info_p);
33491 if (temp != 0) {
33492 break;
33493 }
33494 @@ -1464,7 +1465,7 @@ DBG(
33495 /*
33496 * Send the cmd
33497 */
33498 - info_p->access.submit_command(info_p, c);
33499 + info_p->access->submit_command(info_p, c);
33500 complete = pollcomplete(ctlr);
33501
33502 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
33503 @@ -1547,9 +1548,9 @@ static int revalidate_allvol(ctlr_info_t *host)
33504 * we check the new geometry. Then turn interrupts back on when
33505 * we're done.
33506 */
33507 - host->access.set_intr_mask(host, 0);
33508 + host->access->set_intr_mask(host, 0);
33509 getgeometry(ctlr);
33510 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
33511 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
33512
33513 for(i=0; i<NWD; i++) {
33514 struct gendisk *disk = ida_gendisk[ctlr][i];
33515 @@ -1589,7 +1590,7 @@ static int pollcomplete(int ctlr)
33516 /* Wait (up to 2 seconds) for a command to complete */
33517
33518 for (i = 200000; i > 0; i--) {
33519 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
33520 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
33521 if (done == 0) {
33522 udelay(10); /* a short fixed delay */
33523 } else
33524 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
33525 index be73e9d..7fbf140 100644
33526 --- a/drivers/block/cpqarray.h
33527 +++ b/drivers/block/cpqarray.h
33528 @@ -99,7 +99,7 @@ struct ctlr_info {
33529 drv_info_t drv[NWD];
33530 struct proc_dir_entry *proc;
33531
33532 - struct access_method access;
33533 + struct access_method *access;
33534
33535 cmdlist_t *reqQ;
33536 cmdlist_t *cmpQ;
33537 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
33538 index f943aac..99bfd19 100644
33539 --- a/drivers/block/drbd/drbd_int.h
33540 +++ b/drivers/block/drbd/drbd_int.h
33541 @@ -582,7 +582,7 @@ struct drbd_epoch {
33542 struct drbd_tconn *tconn;
33543 struct list_head list;
33544 unsigned int barrier_nr;
33545 - atomic_t epoch_size; /* increased on every request added. */
33546 + atomic_unchecked_t epoch_size; /* increased on every request added. */
33547 atomic_t active; /* increased on every req. added, and dec on every finished. */
33548 unsigned long flags;
33549 };
33550 @@ -1021,7 +1021,7 @@ struct drbd_conf {
33551 unsigned int al_tr_number;
33552 int al_tr_cycle;
33553 wait_queue_head_t seq_wait;
33554 - atomic_t packet_seq;
33555 + atomic_unchecked_t packet_seq;
33556 unsigned int peer_seq;
33557 spinlock_t peer_seq_lock;
33558 unsigned int minor;
33559 @@ -1562,7 +1562,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
33560 char __user *uoptval;
33561 int err;
33562
33563 - uoptval = (char __user __force *)optval;
33564 + uoptval = (char __force_user *)optval;
33565
33566 set_fs(KERNEL_DS);
33567 if (level == SOL_SOCKET)
33568 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
33569 index a5dca6a..bb27967 100644
33570 --- a/drivers/block/drbd/drbd_main.c
33571 +++ b/drivers/block/drbd/drbd_main.c
33572 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
33573 p->sector = sector;
33574 p->block_id = block_id;
33575 p->blksize = blksize;
33576 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33577 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33578 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
33579 }
33580
33581 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
33582 return -EIO;
33583 p->sector = cpu_to_be64(req->i.sector);
33584 p->block_id = (unsigned long)req;
33585 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
33586 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
33587 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
33588 if (mdev->state.conn >= C_SYNC_SOURCE &&
33589 mdev->state.conn <= C_PAUSED_SYNC_T)
33590 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
33591 {
33592 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
33593
33594 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
33595 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
33596 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
33597 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
33598 kfree(tconn->current_epoch);
33599
33600 idr_destroy(&tconn->volumes);
33601 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
33602 index 4222aff..1f79506 100644
33603 --- a/drivers/block/drbd/drbd_receiver.c
33604 +++ b/drivers/block/drbd/drbd_receiver.c
33605 @@ -834,7 +834,7 @@ int drbd_connected(struct drbd_conf *mdev)
33606 {
33607 int err;
33608
33609 - atomic_set(&mdev->packet_seq, 0);
33610 + atomic_set_unchecked(&mdev->packet_seq, 0);
33611 mdev->peer_seq = 0;
33612
33613 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
33614 @@ -1193,7 +1193,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33615 do {
33616 next_epoch = NULL;
33617
33618 - epoch_size = atomic_read(&epoch->epoch_size);
33619 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
33620
33621 switch (ev & ~EV_CLEANUP) {
33622 case EV_PUT:
33623 @@ -1233,7 +1233,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
33624 rv = FE_DESTROYED;
33625 } else {
33626 epoch->flags = 0;
33627 - atomic_set(&epoch->epoch_size, 0);
33628 + atomic_set_unchecked(&epoch->epoch_size, 0);
33629 /* atomic_set(&epoch->active, 0); is already zero */
33630 if (rv == FE_STILL_LIVE)
33631 rv = FE_RECYCLED;
33632 @@ -1451,7 +1451,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33633 conn_wait_active_ee_empty(tconn);
33634 drbd_flush(tconn);
33635
33636 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33637 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33638 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
33639 if (epoch)
33640 break;
33641 @@ -1464,11 +1464,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
33642 }
33643
33644 epoch->flags = 0;
33645 - atomic_set(&epoch->epoch_size, 0);
33646 + atomic_set_unchecked(&epoch->epoch_size, 0);
33647 atomic_set(&epoch->active, 0);
33648
33649 spin_lock(&tconn->epoch_lock);
33650 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
33651 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
33652 list_add(&epoch->list, &tconn->current_epoch->list);
33653 tconn->current_epoch = epoch;
33654 tconn->epochs++;
33655 @@ -2172,7 +2172,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33656
33657 err = wait_for_and_update_peer_seq(mdev, peer_seq);
33658 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
33659 - atomic_inc(&tconn->current_epoch->epoch_size);
33660 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
33661 err2 = drbd_drain_block(mdev, pi->size);
33662 if (!err)
33663 err = err2;
33664 @@ -2206,7 +2206,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
33665
33666 spin_lock(&tconn->epoch_lock);
33667 peer_req->epoch = tconn->current_epoch;
33668 - atomic_inc(&peer_req->epoch->epoch_size);
33669 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
33670 atomic_inc(&peer_req->epoch->active);
33671 spin_unlock(&tconn->epoch_lock);
33672
33673 @@ -4347,7 +4347,7 @@ struct data_cmd {
33674 int expect_payload;
33675 size_t pkt_size;
33676 int (*fn)(struct drbd_tconn *, struct packet_info *);
33677 -};
33678 +} __do_const;
33679
33680 static struct data_cmd drbd_cmd_handler[] = {
33681 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
33682 @@ -4467,7 +4467,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
33683 if (!list_empty(&tconn->current_epoch->list))
33684 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
33685 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
33686 - atomic_set(&tconn->current_epoch->epoch_size, 0);
33687 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
33688 tconn->send.seen_any_write_yet = false;
33689
33690 conn_info(tconn, "Connection closed\n");
33691 @@ -5223,7 +5223,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
33692 struct asender_cmd {
33693 size_t pkt_size;
33694 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
33695 -};
33696 +} __do_const;
33697
33698 static struct asender_cmd asender_tbl[] = {
33699 [P_PING] = { 0, got_Ping },
33700 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
33701 index d92d50f..a7e9d97 100644
33702 --- a/drivers/block/loop.c
33703 +++ b/drivers/block/loop.c
33704 @@ -232,7 +232,7 @@ static int __do_lo_send_write(struct file *file,
33705
33706 file_start_write(file);
33707 set_fs(get_ds());
33708 - bw = file->f_op->write(file, buf, len, &pos);
33709 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
33710 set_fs(old_fs);
33711 file_end_write(file);
33712 if (likely(bw == len))
33713 diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
33714 index 037288e..00f80b3 100644
33715 --- a/drivers/block/nbd.c
33716 +++ b/drivers/block/nbd.c
33717 @@ -714,7 +714,7 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
33718 else
33719 blk_queue_flush(nbd->disk->queue, 0);
33720
33721 - thread = kthread_create(nbd_thread, nbd, nbd->disk->disk_name);
33722 + thread = kthread_create(nbd_thread, nbd, "%s", nbd->disk->disk_name);
33723 if (IS_ERR(thread)) {
33724 mutex_lock(&nbd->tx_lock);
33725 return PTR_ERR(thread);
33726 diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
33727 index f5d0ea1..c62380a 100644
33728 --- a/drivers/block/pktcdvd.c
33729 +++ b/drivers/block/pktcdvd.c
33730 @@ -84,7 +84,7 @@
33731 #define MAX_SPEED 0xffff
33732
33733 #define ZONE(sector, pd) (((sector) + (pd)->offset) & \
33734 - ~(sector_t)((pd)->settings.size - 1))
33735 + ~(sector_t)((pd)->settings.size - 1UL))
33736
33737 static DEFINE_MUTEX(pktcdvd_mutex);
33738 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
33739 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
33740 index d620b44..d7538c2 100644
33741 --- a/drivers/cdrom/cdrom.c
33742 +++ b/drivers/cdrom/cdrom.c
33743 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
33744 ENSURE(reset, CDC_RESET);
33745 ENSURE(generic_packet, CDC_GENERIC_PACKET);
33746 cdi->mc_flags = 0;
33747 - cdo->n_minors = 0;
33748 cdi->options = CDO_USE_FFLAGS;
33749
33750 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
33751 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
33752 else
33753 cdi->cdda_method = CDDA_OLD;
33754
33755 - if (!cdo->generic_packet)
33756 - cdo->generic_packet = cdrom_dummy_generic_packet;
33757 + if (!cdo->generic_packet) {
33758 + pax_open_kernel();
33759 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
33760 + pax_close_kernel();
33761 + }
33762
33763 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
33764 mutex_lock(&cdrom_mutex);
33765 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
33766 if (cdi->exit)
33767 cdi->exit(cdi);
33768
33769 - cdi->ops->n_minors--;
33770 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
33771 }
33772
33773 @@ -2107,7 +2108,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf,
33774 */
33775 nr = nframes;
33776 do {
33777 - cgc.buffer = kmalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
33778 + cgc.buffer = kzalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
33779 if (cgc.buffer)
33780 break;
33781
33782 @@ -2882,7 +2883,7 @@ static noinline int mmc_ioctl_cdrom_read_data(struct cdrom_device_info *cdi,
33783 if (lba < 0)
33784 return -EINVAL;
33785
33786 - cgc->buffer = kmalloc(blocksize, GFP_KERNEL);
33787 + cgc->buffer = kzalloc(blocksize, GFP_KERNEL);
33788 if (cgc->buffer == NULL)
33789 return -ENOMEM;
33790
33791 @@ -3429,7 +3430,7 @@ static int cdrom_print_info(const char *header, int val, char *info,
33792 struct cdrom_device_info *cdi;
33793 int ret;
33794
33795 - ret = scnprintf(info + *pos, max_size - *pos, header);
33796 + ret = scnprintf(info + *pos, max_size - *pos, "%s", header);
33797 if (!ret)
33798 return 1;
33799
33800 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
33801 index 4afcb65..a68a32d 100644
33802 --- a/drivers/cdrom/gdrom.c
33803 +++ b/drivers/cdrom/gdrom.c
33804 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
33805 .audio_ioctl = gdrom_audio_ioctl,
33806 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
33807 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
33808 - .n_minors = 1,
33809 };
33810
33811 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
33812 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
33813 index 3bb6fa3..34013fb 100644
33814 --- a/drivers/char/Kconfig
33815 +++ b/drivers/char/Kconfig
33816 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
33817
33818 config DEVKMEM
33819 bool "/dev/kmem virtual device support"
33820 - default y
33821 + default n
33822 + depends on !GRKERNSEC_KMEM
33823 help
33824 Say Y here if you want to support the /dev/kmem device. The
33825 /dev/kmem device is rarely used, but can be used for certain
33826 @@ -582,6 +583,7 @@ config DEVPORT
33827 bool
33828 depends on !M68K
33829 depends on ISA || PCI
33830 + depends on !GRKERNSEC_KMEM
33831 default y
33832
33833 source "drivers/s390/char/Kconfig"
33834 diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
33835 index a48e05b..6bac831 100644
33836 --- a/drivers/char/agp/compat_ioctl.c
33837 +++ b/drivers/char/agp/compat_ioctl.c
33838 @@ -108,7 +108,7 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
33839 return -ENOMEM;
33840 }
33841
33842 - if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
33843 + if (copy_from_user(usegment, (void __force_user *) ureserve.seg_list,
33844 sizeof(*usegment) * ureserve.seg_count)) {
33845 kfree(usegment);
33846 kfree(ksegment);
33847 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
33848 index 2e04433..771f2cc 100644
33849 --- a/drivers/char/agp/frontend.c
33850 +++ b/drivers/char/agp/frontend.c
33851 @@ -817,7 +817,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
33852 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
33853 return -EFAULT;
33854
33855 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
33856 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
33857 return -EFAULT;
33858
33859 client = agp_find_client_by_pid(reserve.pid);
33860 @@ -847,7 +847,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
33861 if (segment == NULL)
33862 return -ENOMEM;
33863
33864 - if (copy_from_user(segment, (void __user *) reserve.seg_list,
33865 + if (copy_from_user(segment, (void __force_user *) reserve.seg_list,
33866 sizeof(struct agp_segment) * reserve.seg_count)) {
33867 kfree(segment);
33868 return -EFAULT;
33869 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
33870 index 4f94375..413694e 100644
33871 --- a/drivers/char/genrtc.c
33872 +++ b/drivers/char/genrtc.c
33873 @@ -273,6 +273,7 @@ static int gen_rtc_ioctl(struct file *file,
33874 switch (cmd) {
33875
33876 case RTC_PLL_GET:
33877 + memset(&pll, 0, sizeof(pll));
33878 if (get_rtc_pll(&pll))
33879 return -EINVAL;
33880 else
33881 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
33882 index d784650..e8bfd69 100644
33883 --- a/drivers/char/hpet.c
33884 +++ b/drivers/char/hpet.c
33885 @@ -559,7 +559,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
33886 }
33887
33888 static int
33889 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
33890 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
33891 struct hpet_info *info)
33892 {
33893 struct hpet_timer __iomem *timer;
33894 diff --git a/drivers/char/hw_random/intel-rng.c b/drivers/char/hw_random/intel-rng.c
33895 index 86fe45c..c0ea948 100644
33896 --- a/drivers/char/hw_random/intel-rng.c
33897 +++ b/drivers/char/hw_random/intel-rng.c
33898 @@ -314,7 +314,7 @@ PFX "RNG, try using the 'no_fwh_detect' option.\n";
33899
33900 if (no_fwh_detect)
33901 return -ENODEV;
33902 - printk(warning);
33903 + printk("%s", warning);
33904 return -EBUSY;
33905 }
33906
33907 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
33908 index 4445fa1..7c6de37 100644
33909 --- a/drivers/char/ipmi/ipmi_msghandler.c
33910 +++ b/drivers/char/ipmi/ipmi_msghandler.c
33911 @@ -420,7 +420,7 @@ struct ipmi_smi {
33912 struct proc_dir_entry *proc_dir;
33913 char proc_dir_name[10];
33914
33915 - atomic_t stats[IPMI_NUM_STATS];
33916 + atomic_unchecked_t stats[IPMI_NUM_STATS];
33917
33918 /*
33919 * run_to_completion duplicate of smb_info, smi_info
33920 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
33921
33922
33923 #define ipmi_inc_stat(intf, stat) \
33924 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
33925 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
33926 #define ipmi_get_stat(intf, stat) \
33927 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
33928 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
33929
33930 static int is_lan_addr(struct ipmi_addr *addr)
33931 {
33932 @@ -2883,7 +2883,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
33933 INIT_LIST_HEAD(&intf->cmd_rcvrs);
33934 init_waitqueue_head(&intf->waitq);
33935 for (i = 0; i < IPMI_NUM_STATS; i++)
33936 - atomic_set(&intf->stats[i], 0);
33937 + atomic_set_unchecked(&intf->stats[i], 0);
33938
33939 intf->proc_dir = NULL;
33940
33941 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
33942 index af4b23f..79806fc 100644
33943 --- a/drivers/char/ipmi/ipmi_si_intf.c
33944 +++ b/drivers/char/ipmi/ipmi_si_intf.c
33945 @@ -275,7 +275,7 @@ struct smi_info {
33946 unsigned char slave_addr;
33947
33948 /* Counters and things for the proc filesystem. */
33949 - atomic_t stats[SI_NUM_STATS];
33950 + atomic_unchecked_t stats[SI_NUM_STATS];
33951
33952 struct task_struct *thread;
33953
33954 @@ -284,9 +284,9 @@ struct smi_info {
33955 };
33956
33957 #define smi_inc_stat(smi, stat) \
33958 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
33959 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
33960 #define smi_get_stat(smi, stat) \
33961 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
33962 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
33963
33964 #define SI_MAX_PARMS 4
33965
33966 @@ -3258,7 +3258,7 @@ static int try_smi_init(struct smi_info *new_smi)
33967 atomic_set(&new_smi->req_events, 0);
33968 new_smi->run_to_completion = 0;
33969 for (i = 0; i < SI_NUM_STATS; i++)
33970 - atomic_set(&new_smi->stats[i], 0);
33971 + atomic_set_unchecked(&new_smi->stats[i], 0);
33972
33973 new_smi->interrupt_disabled = 1;
33974 atomic_set(&new_smi->stop_operation, 0);
33975 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
33976 index 1ccbe94..6ad651a 100644
33977 --- a/drivers/char/mem.c
33978 +++ b/drivers/char/mem.c
33979 @@ -18,6 +18,7 @@
33980 #include <linux/raw.h>
33981 #include <linux/tty.h>
33982 #include <linux/capability.h>
33983 +#include <linux/security.h>
33984 #include <linux/ptrace.h>
33985 #include <linux/device.h>
33986 #include <linux/highmem.h>
33987 @@ -38,6 +39,10 @@
33988
33989 #define DEVPORT_MINOR 4
33990
33991 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
33992 +extern const struct file_operations grsec_fops;
33993 +#endif
33994 +
33995 static inline unsigned long size_inside_page(unsigned long start,
33996 unsigned long size)
33997 {
33998 @@ -69,9 +74,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
33999
34000 while (cursor < to) {
34001 if (!devmem_is_allowed(pfn)) {
34002 +#ifdef CONFIG_GRKERNSEC_KMEM
34003 + gr_handle_mem_readwrite(from, to);
34004 +#else
34005 printk(KERN_INFO
34006 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
34007 current->comm, from, to);
34008 +#endif
34009 return 0;
34010 }
34011 cursor += PAGE_SIZE;
34012 @@ -79,6 +88,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34013 }
34014 return 1;
34015 }
34016 +#elif defined(CONFIG_GRKERNSEC_KMEM)
34017 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34018 +{
34019 + return 0;
34020 +}
34021 #else
34022 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
34023 {
34024 @@ -121,6 +135,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
34025
34026 while (count > 0) {
34027 unsigned long remaining;
34028 + char *temp;
34029
34030 sz = size_inside_page(p, count);
34031
34032 @@ -136,7 +151,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
34033 if (!ptr)
34034 return -EFAULT;
34035
34036 - remaining = copy_to_user(buf, ptr, sz);
34037 +#ifdef CONFIG_PAX_USERCOPY
34038 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
34039 + if (!temp) {
34040 + unxlate_dev_mem_ptr(p, ptr);
34041 + return -ENOMEM;
34042 + }
34043 + memcpy(temp, ptr, sz);
34044 +#else
34045 + temp = ptr;
34046 +#endif
34047 +
34048 + remaining = copy_to_user(buf, temp, sz);
34049 +
34050 +#ifdef CONFIG_PAX_USERCOPY
34051 + kfree(temp);
34052 +#endif
34053 +
34054 unxlate_dev_mem_ptr(p, ptr);
34055 if (remaining)
34056 return -EFAULT;
34057 @@ -379,7 +410,7 @@ static ssize_t read_oldmem(struct file *file, char __user *buf,
34058 else
34059 csize = count;
34060
34061 - rc = copy_oldmem_page(pfn, buf, csize, offset, 1);
34062 + rc = copy_oldmem_page(pfn, (char __force_kernel *)buf, csize, offset, 1);
34063 if (rc < 0)
34064 return rc;
34065 buf += csize;
34066 @@ -399,9 +430,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34067 size_t count, loff_t *ppos)
34068 {
34069 unsigned long p = *ppos;
34070 - ssize_t low_count, read, sz;
34071 + ssize_t low_count, read, sz, err = 0;
34072 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
34073 - int err = 0;
34074
34075 read = 0;
34076 if (p < (unsigned long) high_memory) {
34077 @@ -423,6 +453,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34078 }
34079 #endif
34080 while (low_count > 0) {
34081 + char *temp;
34082 +
34083 sz = size_inside_page(p, low_count);
34084
34085 /*
34086 @@ -432,7 +464,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
34087 */
34088 kbuf = xlate_dev_kmem_ptr((char *)p);
34089
34090 - if (copy_to_user(buf, kbuf, sz))
34091 +#ifdef CONFIG_PAX_USERCOPY
34092 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
34093 + if (!temp)
34094 + return -ENOMEM;
34095 + memcpy(temp, kbuf, sz);
34096 +#else
34097 + temp = kbuf;
34098 +#endif
34099 +
34100 + err = copy_to_user(buf, temp, sz);
34101 +
34102 +#ifdef CONFIG_PAX_USERCOPY
34103 + kfree(temp);
34104 +#endif
34105 +
34106 + if (err)
34107 return -EFAULT;
34108 buf += sz;
34109 p += sz;
34110 @@ -869,6 +916,9 @@ static const struct memdev {
34111 #ifdef CONFIG_CRASH_DUMP
34112 [12] = { "oldmem", 0, &oldmem_fops, NULL },
34113 #endif
34114 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
34115 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
34116 +#endif
34117 };
34118
34119 static int memory_open(struct inode *inode, struct file *filp)
34120 @@ -940,7 +990,7 @@ static int __init chr_dev_init(void)
34121 continue;
34122
34123 device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor),
34124 - NULL, devlist[minor].name);
34125 + NULL, "%s", devlist[minor].name);
34126 }
34127
34128 return tty_init();
34129 diff --git a/drivers/char/mwave/tp3780i.c b/drivers/char/mwave/tp3780i.c
34130 index c689697..04e6d6a2 100644
34131 --- a/drivers/char/mwave/tp3780i.c
34132 +++ b/drivers/char/mwave/tp3780i.c
34133 @@ -479,6 +479,7 @@ int tp3780I_QueryAbilities(THINKPAD_BD_DATA * pBDData, MW_ABILITIES * pAbilities
34134 PRINTK_2(TRACE_TP3780I,
34135 "tp3780i::tp3780I_QueryAbilities entry pBDData %p\n", pBDData);
34136
34137 + memset(pAbilities, 0, sizeof(*pAbilities));
34138 /* fill out standard constant fields */
34139 pAbilities->instr_per_sec = pBDData->rDspSettings.uIps;
34140 pAbilities->data_size = pBDData->rDspSettings.uDStoreSize;
34141 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
34142 index 9df78e2..01ba9ae 100644
34143 --- a/drivers/char/nvram.c
34144 +++ b/drivers/char/nvram.c
34145 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
34146
34147 spin_unlock_irq(&rtc_lock);
34148
34149 - if (copy_to_user(buf, contents, tmp - contents))
34150 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
34151 return -EFAULT;
34152
34153 *ppos = i;
34154 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
34155 index 5c5cc00..ac9edb7 100644
34156 --- a/drivers/char/pcmcia/synclink_cs.c
34157 +++ b/drivers/char/pcmcia/synclink_cs.c
34158 @@ -2345,9 +2345,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
34159
34160 if (debug_level >= DEBUG_LEVEL_INFO)
34161 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
34162 - __FILE__, __LINE__, info->device_name, port->count);
34163 + __FILE__, __LINE__, info->device_name, atomic_read(&port->count));
34164
34165 - WARN_ON(!port->count);
34166 + WARN_ON(!atomic_read(&port->count));
34167
34168 if (tty_port_close_start(port, tty, filp) == 0)
34169 goto cleanup;
34170 @@ -2365,7 +2365,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
34171 cleanup:
34172 if (debug_level >= DEBUG_LEVEL_INFO)
34173 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__, __LINE__,
34174 - tty->driver->name, port->count);
34175 + tty->driver->name, atomic_read(&port->count));
34176 }
34177
34178 /* Wait until the transmitter is empty.
34179 @@ -2507,7 +2507,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
34180
34181 if (debug_level >= DEBUG_LEVEL_INFO)
34182 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
34183 - __FILE__, __LINE__, tty->driver->name, port->count);
34184 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
34185
34186 /* If port is closing, signal caller to try again */
34187 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
34188 @@ -2527,11 +2527,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
34189 goto cleanup;
34190 }
34191 spin_lock(&port->lock);
34192 - port->count++;
34193 + atomic_inc(&port->count);
34194 spin_unlock(&port->lock);
34195 spin_unlock_irqrestore(&info->netlock, flags);
34196
34197 - if (port->count == 1) {
34198 + if (atomic_read(&port->count) == 1) {
34199 /* 1st open on this device, init hardware */
34200 retval = startup(info, tty);
34201 if (retval < 0)
34202 @@ -3920,7 +3920,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
34203 unsigned short new_crctype;
34204
34205 /* return error if TTY interface open */
34206 - if (info->port.count)
34207 + if (atomic_read(&info->port.count))
34208 return -EBUSY;
34209
34210 switch (encoding)
34211 @@ -4024,7 +4024,7 @@ static int hdlcdev_open(struct net_device *dev)
34212
34213 /* arbitrate between network and tty opens */
34214 spin_lock_irqsave(&info->netlock, flags);
34215 - if (info->port.count != 0 || info->netcount != 0) {
34216 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
34217 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
34218 spin_unlock_irqrestore(&info->netlock, flags);
34219 return -EBUSY;
34220 @@ -4114,7 +4114,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
34221 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name);
34222
34223 /* return error if TTY interface open */
34224 - if (info->port.count)
34225 + if (atomic_read(&info->port.count))
34226 return -EBUSY;
34227
34228 if (cmd != SIOCWANDEV)
34229 diff --git a/drivers/char/random.c b/drivers/char/random.c
34230 index 35487e8..dac8bd1 100644
34231 --- a/drivers/char/random.c
34232 +++ b/drivers/char/random.c
34233 @@ -272,8 +272,13 @@
34234 /*
34235 * Configuration information
34236 */
34237 +#ifdef CONFIG_GRKERNSEC_RANDNET
34238 +#define INPUT_POOL_WORDS 512
34239 +#define OUTPUT_POOL_WORDS 128
34240 +#else
34241 #define INPUT_POOL_WORDS 128
34242 #define OUTPUT_POOL_WORDS 32
34243 +#endif
34244 #define SEC_XFER_SIZE 512
34245 #define EXTRACT_SIZE 10
34246
34247 @@ -313,10 +318,17 @@ static struct poolinfo {
34248 int poolwords;
34249 int tap1, tap2, tap3, tap4, tap5;
34250 } poolinfo_table[] = {
34251 +#ifdef CONFIG_GRKERNSEC_RANDNET
34252 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
34253 + { 512, 411, 308, 208, 104, 1 },
34254 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
34255 + { 128, 103, 76, 51, 25, 1 },
34256 +#else
34257 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
34258 { 128, 103, 76, 51, 25, 1 },
34259 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
34260 { 32, 26, 20, 14, 7, 1 },
34261 +#endif
34262 #if 0
34263 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
34264 { 2048, 1638, 1231, 819, 411, 1 },
34265 @@ -524,8 +536,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
34266 input_rotate += i ? 7 : 14;
34267 }
34268
34269 - ACCESS_ONCE(r->input_rotate) = input_rotate;
34270 - ACCESS_ONCE(r->add_ptr) = i;
34271 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
34272 + ACCESS_ONCE_RW(r->add_ptr) = i;
34273 smp_wmb();
34274
34275 if (out)
34276 @@ -1032,7 +1044,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
34277
34278 extract_buf(r, tmp);
34279 i = min_t(int, nbytes, EXTRACT_SIZE);
34280 - if (copy_to_user(buf, tmp, i)) {
34281 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
34282 ret = -EFAULT;
34283 break;
34284 }
34285 @@ -1368,7 +1380,7 @@ EXPORT_SYMBOL(generate_random_uuid);
34286 #include <linux/sysctl.h>
34287
34288 static int min_read_thresh = 8, min_write_thresh;
34289 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
34290 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
34291 static int max_write_thresh = INPUT_POOL_WORDS * 32;
34292 static char sysctl_bootid[16];
34293
34294 @@ -1384,7 +1396,7 @@ static char sysctl_bootid[16];
34295 static int proc_do_uuid(ctl_table *table, int write,
34296 void __user *buffer, size_t *lenp, loff_t *ppos)
34297 {
34298 - ctl_table fake_table;
34299 + ctl_table_no_const fake_table;
34300 unsigned char buf[64], tmp_uuid[16], *uuid;
34301
34302 uuid = table->data;
34303 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
34304 index bf2349db..5456d53 100644
34305 --- a/drivers/char/sonypi.c
34306 +++ b/drivers/char/sonypi.c
34307 @@ -54,6 +54,7 @@
34308
34309 #include <asm/uaccess.h>
34310 #include <asm/io.h>
34311 +#include <asm/local.h>
34312
34313 #include <linux/sonypi.h>
34314
34315 @@ -490,7 +491,7 @@ static struct sonypi_device {
34316 spinlock_t fifo_lock;
34317 wait_queue_head_t fifo_proc_list;
34318 struct fasync_struct *fifo_async;
34319 - int open_count;
34320 + local_t open_count;
34321 int model;
34322 struct input_dev *input_jog_dev;
34323 struct input_dev *input_key_dev;
34324 @@ -897,7 +898,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
34325 static int sonypi_misc_release(struct inode *inode, struct file *file)
34326 {
34327 mutex_lock(&sonypi_device.lock);
34328 - sonypi_device.open_count--;
34329 + local_dec(&sonypi_device.open_count);
34330 mutex_unlock(&sonypi_device.lock);
34331 return 0;
34332 }
34333 @@ -906,9 +907,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
34334 {
34335 mutex_lock(&sonypi_device.lock);
34336 /* Flush input queue on first open */
34337 - if (!sonypi_device.open_count)
34338 + if (!local_read(&sonypi_device.open_count))
34339 kfifo_reset(&sonypi_device.fifo);
34340 - sonypi_device.open_count++;
34341 + local_inc(&sonypi_device.open_count);
34342 mutex_unlock(&sonypi_device.lock);
34343
34344 return 0;
34345 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
34346 index 64420b3..5c40b56 100644
34347 --- a/drivers/char/tpm/tpm_acpi.c
34348 +++ b/drivers/char/tpm/tpm_acpi.c
34349 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
34350 virt = acpi_os_map_memory(start, len);
34351 if (!virt) {
34352 kfree(log->bios_event_log);
34353 + log->bios_event_log = NULL;
34354 printk("%s: ERROR - Unable to map memory\n", __func__);
34355 return -EIO;
34356 }
34357
34358 - memcpy_fromio(log->bios_event_log, virt, len);
34359 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
34360
34361 acpi_os_unmap_memory(virt, len);
34362 return 0;
34363 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
34364 index 84ddc55..1d32f1e 100644
34365 --- a/drivers/char/tpm/tpm_eventlog.c
34366 +++ b/drivers/char/tpm/tpm_eventlog.c
34367 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
34368 event = addr;
34369
34370 if ((event->event_type == 0 && event->event_size == 0) ||
34371 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
34372 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
34373 return NULL;
34374
34375 return addr;
34376 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
34377 return NULL;
34378
34379 if ((event->event_type == 0 && event->event_size == 0) ||
34380 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
34381 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
34382 return NULL;
34383
34384 (*pos)++;
34385 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
34386 int i;
34387
34388 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
34389 - seq_putc(m, data[i]);
34390 + if (!seq_putc(m, data[i]))
34391 + return -EFAULT;
34392
34393 return 0;
34394 }
34395 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
34396 index 1b456fe..2510242 100644
34397 --- a/drivers/char/virtio_console.c
34398 +++ b/drivers/char/virtio_console.c
34399 @@ -679,7 +679,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
34400 if (to_user) {
34401 ssize_t ret;
34402
34403 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
34404 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
34405 if (ret)
34406 return -EFAULT;
34407 } else {
34408 @@ -778,7 +778,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
34409 if (!port_has_data(port) && !port->host_connected)
34410 return 0;
34411
34412 - return fill_readbuf(port, ubuf, count, true);
34413 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
34414 }
34415
34416 static int wait_port_writable(struct port *port, bool nonblock)
34417 diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
34418 index a33f46f..a720eed 100644
34419 --- a/drivers/clk/clk-composite.c
34420 +++ b/drivers/clk/clk-composite.c
34421 @@ -122,7 +122,7 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
34422 struct clk *clk;
34423 struct clk_init_data init;
34424 struct clk_composite *composite;
34425 - struct clk_ops *clk_composite_ops;
34426 + clk_ops_no_const *clk_composite_ops;
34427
34428 composite = kzalloc(sizeof(*composite), GFP_KERNEL);
34429 if (!composite) {
34430 diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
34431 index a2b2541..bc1e7ff 100644
34432 --- a/drivers/clocksource/arm_arch_timer.c
34433 +++ b/drivers/clocksource/arm_arch_timer.c
34434 @@ -264,7 +264,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
34435 return NOTIFY_OK;
34436 }
34437
34438 -static struct notifier_block arch_timer_cpu_nb __cpuinitdata = {
34439 +static struct notifier_block arch_timer_cpu_nb = {
34440 .notifier_call = arch_timer_cpu_notify,
34441 };
34442
34443 diff --git a/drivers/clocksource/metag_generic.c b/drivers/clocksource/metag_generic.c
34444 index ade7513..069445f 100644
34445 --- a/drivers/clocksource/metag_generic.c
34446 +++ b/drivers/clocksource/metag_generic.c
34447 @@ -169,7 +169,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
34448 return NOTIFY_OK;
34449 }
34450
34451 -static struct notifier_block __cpuinitdata arch_timer_cpu_nb = {
34452 +static struct notifier_block arch_timer_cpu_nb = {
34453 .notifier_call = arch_timer_cpu_notify,
34454 };
34455
34456 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
34457 index edc089e..bc7c0bc 100644
34458 --- a/drivers/cpufreq/acpi-cpufreq.c
34459 +++ b/drivers/cpufreq/acpi-cpufreq.c
34460 @@ -172,7 +172,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
34461 return sprintf(buf, "%u\n", boost_enabled);
34462 }
34463
34464 -static struct global_attr global_boost = __ATTR(boost, 0644,
34465 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
34466 show_global_boost,
34467 store_global_boost);
34468
34469 @@ -705,8 +705,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34470 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
34471 per_cpu(acfreq_data, cpu) = data;
34472
34473 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
34474 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34475 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
34476 + pax_open_kernel();
34477 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
34478 + pax_close_kernel();
34479 + }
34480
34481 result = acpi_processor_register_performance(data->acpi_data, cpu);
34482 if (result)
34483 @@ -832,7 +835,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34484 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
34485 break;
34486 case ACPI_ADR_SPACE_FIXED_HARDWARE:
34487 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34488 + pax_open_kernel();
34489 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
34490 + pax_close_kernel();
34491 policy->cur = get_cur_freq_on_cpu(cpu);
34492 break;
34493 default:
34494 @@ -843,8 +848,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
34495 acpi_processor_notify_smm(THIS_MODULE);
34496
34497 /* Check for APERF/MPERF support in hardware */
34498 - if (boot_cpu_has(X86_FEATURE_APERFMPERF))
34499 - acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34500 + if (boot_cpu_has(X86_FEATURE_APERFMPERF)) {
34501 + pax_open_kernel();
34502 + *(void **)&acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
34503 + pax_close_kernel();
34504 + }
34505
34506 pr_debug("CPU%u - ACPI performance management activated.\n", cpu);
34507 for (i = 0; i < perf->state_count; i++)
34508 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
34509 index 2d53f47..eb3803e 100644
34510 --- a/drivers/cpufreq/cpufreq.c
34511 +++ b/drivers/cpufreq/cpufreq.c
34512 @@ -1851,7 +1851,7 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
34513 return NOTIFY_OK;
34514 }
34515
34516 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
34517 +static struct notifier_block cpufreq_cpu_notifier = {
34518 .notifier_call = cpufreq_cpu_callback,
34519 };
34520
34521 @@ -1883,8 +1883,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
34522
34523 pr_debug("trying to register driver %s\n", driver_data->name);
34524
34525 - if (driver_data->setpolicy)
34526 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
34527 + if (driver_data->setpolicy) {
34528 + pax_open_kernel();
34529 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
34530 + pax_close_kernel();
34531 + }
34532
34533 write_lock_irqsave(&cpufreq_driver_lock, flags);
34534 if (cpufreq_driver) {
34535 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
34536 index dc9b72e..11c0302 100644
34537 --- a/drivers/cpufreq/cpufreq_governor.c
34538 +++ b/drivers/cpufreq/cpufreq_governor.c
34539 @@ -238,7 +238,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
34540 struct dbs_data *dbs_data;
34541 struct od_cpu_dbs_info_s *od_dbs_info = NULL;
34542 struct cs_cpu_dbs_info_s *cs_dbs_info = NULL;
34543 - struct od_ops *od_ops = NULL;
34544 + const struct od_ops *od_ops = NULL;
34545 struct od_dbs_tuners *od_tuners = NULL;
34546 struct cs_dbs_tuners *cs_tuners = NULL;
34547 struct cpu_dbs_common_info *cpu_cdbs;
34548 @@ -301,7 +301,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
34549
34550 if ((cdata->governor == GOV_CONSERVATIVE) &&
34551 (!policy->governor->initialized)) {
34552 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
34553 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
34554
34555 cpufreq_register_notifier(cs_ops->notifier_block,
34556 CPUFREQ_TRANSITION_NOTIFIER);
34557 @@ -318,7 +318,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
34558
34559 if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) &&
34560 (policy->governor->initialized == 1)) {
34561 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
34562 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
34563
34564 cpufreq_unregister_notifier(cs_ops->notifier_block,
34565 CPUFREQ_TRANSITION_NOTIFIER);
34566 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
34567 index e16a961..0e68927 100644
34568 --- a/drivers/cpufreq/cpufreq_governor.h
34569 +++ b/drivers/cpufreq/cpufreq_governor.h
34570 @@ -204,7 +204,7 @@ struct common_dbs_data {
34571 void (*exit)(struct dbs_data *dbs_data);
34572
34573 /* Governor specific ops, see below */
34574 - void *gov_ops;
34575 + const void *gov_ops;
34576 };
34577
34578 /* Governer Per policy data */
34579 diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
34580 index 93eb5cb..f8ab572 100644
34581 --- a/drivers/cpufreq/cpufreq_ondemand.c
34582 +++ b/drivers/cpufreq/cpufreq_ondemand.c
34583 @@ -615,14 +615,18 @@ void od_register_powersave_bias_handler(unsigned int (*f)
34584 (struct cpufreq_policy *, unsigned int, unsigned int),
34585 unsigned int powersave_bias)
34586 {
34587 - od_ops.powersave_bias_target = f;
34588 + pax_open_kernel();
34589 + *(void **)&od_ops.powersave_bias_target = f;
34590 + pax_close_kernel();
34591 od_set_powersave_bias(powersave_bias);
34592 }
34593 EXPORT_SYMBOL_GPL(od_register_powersave_bias_handler);
34594
34595 void od_unregister_powersave_bias_handler(void)
34596 {
34597 - od_ops.powersave_bias_target = generic_powersave_bias_target;
34598 + pax_open_kernel();
34599 + *(void **)&od_ops.powersave_bias_target = generic_powersave_bias_target;
34600 + pax_close_kernel();
34601 od_set_powersave_bias(0);
34602 }
34603 EXPORT_SYMBOL_GPL(od_unregister_powersave_bias_handler);
34604 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
34605 index fb65dec..b88254d 100644
34606 --- a/drivers/cpufreq/cpufreq_stats.c
34607 +++ b/drivers/cpufreq/cpufreq_stats.c
34608 @@ -366,7 +366,7 @@ static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
34609 }
34610
34611 /* priority=1 so this will get called before cpufreq_remove_dev */
34612 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
34613 +static struct notifier_block cpufreq_stat_cpu_notifier = {
34614 .notifier_call = cpufreq_stat_cpu_callback,
34615 .priority = 1,
34616 };
34617 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
34618 index 421ef37..e708530c 100644
34619 --- a/drivers/cpufreq/p4-clockmod.c
34620 +++ b/drivers/cpufreq/p4-clockmod.c
34621 @@ -160,10 +160,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34622 case 0x0F: /* Core Duo */
34623 case 0x16: /* Celeron Core */
34624 case 0x1C: /* Atom */
34625 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34626 + pax_open_kernel();
34627 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34628 + pax_close_kernel();
34629 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
34630 case 0x0D: /* Pentium M (Dothan) */
34631 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34632 + pax_open_kernel();
34633 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34634 + pax_close_kernel();
34635 /* fall through */
34636 case 0x09: /* Pentium M (Banias) */
34637 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
34638 @@ -175,7 +179,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
34639
34640 /* on P-4s, the TSC runs with constant frequency independent whether
34641 * throttling is active or not. */
34642 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34643 + pax_open_kernel();
34644 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
34645 + pax_close_kernel();
34646
34647 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
34648 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
34649 diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
34650 index c71ee14..7c2e183 100644
34651 --- a/drivers/cpufreq/sparc-us3-cpufreq.c
34652 +++ b/drivers/cpufreq/sparc-us3-cpufreq.c
34653 @@ -18,14 +18,12 @@
34654 #include <asm/head.h>
34655 #include <asm/timer.h>
34656
34657 -static struct cpufreq_driver *cpufreq_us3_driver;
34658 -
34659 struct us3_freq_percpu_info {
34660 struct cpufreq_frequency_table table[4];
34661 };
34662
34663 /* Indexed by cpu number. */
34664 -static struct us3_freq_percpu_info *us3_freq_table;
34665 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
34666
34667 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
34668 * in the Safari config register.
34669 @@ -186,12 +184,25 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
34670
34671 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
34672 {
34673 - if (cpufreq_us3_driver)
34674 - us3_set_cpu_divider_index(policy, 0);
34675 + us3_set_cpu_divider_index(policy->cpu, 0);
34676
34677 return 0;
34678 }
34679
34680 +static int __init us3_freq_init(void);
34681 +static void __exit us3_freq_exit(void);
34682 +
34683 +static struct cpufreq_driver cpufreq_us3_driver = {
34684 + .init = us3_freq_cpu_init,
34685 + .verify = us3_freq_verify,
34686 + .target = us3_freq_target,
34687 + .get = us3_freq_get,
34688 + .exit = us3_freq_cpu_exit,
34689 + .owner = THIS_MODULE,
34690 + .name = "UltraSPARC-III",
34691 +
34692 +};
34693 +
34694 static int __init us3_freq_init(void)
34695 {
34696 unsigned long manuf, impl, ver;
34697 @@ -208,57 +219,15 @@ static int __init us3_freq_init(void)
34698 (impl == CHEETAH_IMPL ||
34699 impl == CHEETAH_PLUS_IMPL ||
34700 impl == JAGUAR_IMPL ||
34701 - impl == PANTHER_IMPL)) {
34702 - struct cpufreq_driver *driver;
34703 -
34704 - ret = -ENOMEM;
34705 - driver = kzalloc(sizeof(struct cpufreq_driver), GFP_KERNEL);
34706 - if (!driver)
34707 - goto err_out;
34708 -
34709 - us3_freq_table = kzalloc(
34710 - (NR_CPUS * sizeof(struct us3_freq_percpu_info)),
34711 - GFP_KERNEL);
34712 - if (!us3_freq_table)
34713 - goto err_out;
34714 -
34715 - driver->init = us3_freq_cpu_init;
34716 - driver->verify = us3_freq_verify;
34717 - driver->target = us3_freq_target;
34718 - driver->get = us3_freq_get;
34719 - driver->exit = us3_freq_cpu_exit;
34720 - driver->owner = THIS_MODULE,
34721 - strcpy(driver->name, "UltraSPARC-III");
34722 -
34723 - cpufreq_us3_driver = driver;
34724 - ret = cpufreq_register_driver(driver);
34725 - if (ret)
34726 - goto err_out;
34727 -
34728 - return 0;
34729 -
34730 -err_out:
34731 - if (driver) {
34732 - kfree(driver);
34733 - cpufreq_us3_driver = NULL;
34734 - }
34735 - kfree(us3_freq_table);
34736 - us3_freq_table = NULL;
34737 - return ret;
34738 - }
34739 + impl == PANTHER_IMPL))
34740 + return cpufreq_register_driver(&cpufreq_us3_driver);
34741
34742 return -ENODEV;
34743 }
34744
34745 static void __exit us3_freq_exit(void)
34746 {
34747 - if (cpufreq_us3_driver) {
34748 - cpufreq_unregister_driver(cpufreq_us3_driver);
34749 - kfree(cpufreq_us3_driver);
34750 - cpufreq_us3_driver = NULL;
34751 - kfree(us3_freq_table);
34752 - us3_freq_table = NULL;
34753 - }
34754 + cpufreq_unregister_driver(&cpufreq_us3_driver);
34755 }
34756
34757 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
34758 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
34759 index 618e6f4..e89d915 100644
34760 --- a/drivers/cpufreq/speedstep-centrino.c
34761 +++ b/drivers/cpufreq/speedstep-centrino.c
34762 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
34763 !cpu_has(cpu, X86_FEATURE_EST))
34764 return -ENODEV;
34765
34766 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
34767 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34768 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
34769 + pax_open_kernel();
34770 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
34771 + pax_close_kernel();
34772 + }
34773
34774 if (policy->cpu != 0)
34775 return -ENODEV;
34776 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
34777 index c3a93fe..e808f24 100644
34778 --- a/drivers/cpuidle/cpuidle.c
34779 +++ b/drivers/cpuidle/cpuidle.c
34780 @@ -254,7 +254,7 @@ static int poll_idle(struct cpuidle_device *dev,
34781
34782 static void poll_idle_init(struct cpuidle_driver *drv)
34783 {
34784 - struct cpuidle_state *state = &drv->states[0];
34785 + cpuidle_state_no_const *state = &drv->states[0];
34786
34787 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
34788 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
34789 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
34790 index ea2f8e7..70ac501 100644
34791 --- a/drivers/cpuidle/governor.c
34792 +++ b/drivers/cpuidle/governor.c
34793 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
34794 mutex_lock(&cpuidle_lock);
34795 if (__cpuidle_find_governor(gov->name) == NULL) {
34796 ret = 0;
34797 - list_add_tail(&gov->governor_list, &cpuidle_governors);
34798 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
34799 if (!cpuidle_curr_governor ||
34800 cpuidle_curr_governor->rating < gov->rating)
34801 cpuidle_switch_governor(gov);
34802 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
34803 new_gov = cpuidle_replace_governor(gov->rating);
34804 cpuidle_switch_governor(new_gov);
34805 }
34806 - list_del(&gov->governor_list);
34807 + pax_list_del((struct list_head *)&gov->governor_list);
34808 mutex_unlock(&cpuidle_lock);
34809 }
34810
34811 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
34812 index 428754a..8bdf9cc 100644
34813 --- a/drivers/cpuidle/sysfs.c
34814 +++ b/drivers/cpuidle/sysfs.c
34815 @@ -131,7 +131,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
34816 NULL
34817 };
34818
34819 -static struct attribute_group cpuidle_attr_group = {
34820 +static attribute_group_no_const cpuidle_attr_group = {
34821 .attrs = cpuidle_default_attrs,
34822 .name = "cpuidle",
34823 };
34824 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
34825 index 3b36797..db0b0c0 100644
34826 --- a/drivers/devfreq/devfreq.c
34827 +++ b/drivers/devfreq/devfreq.c
34828 @@ -477,7 +477,7 @@ struct devfreq *devfreq_add_device(struct device *dev,
34829 GFP_KERNEL);
34830 devfreq->last_stat_updated = jiffies;
34831
34832 - dev_set_name(&devfreq->dev, dev_name(dev));
34833 + dev_set_name(&devfreq->dev, "%s", dev_name(dev));
34834 err = device_register(&devfreq->dev);
34835 if (err) {
34836 put_device(&devfreq->dev);
34837 @@ -588,7 +588,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
34838 goto err_out;
34839 }
34840
34841 - list_add(&governor->node, &devfreq_governor_list);
34842 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
34843
34844 list_for_each_entry(devfreq, &devfreq_list, node) {
34845 int ret = 0;
34846 @@ -676,7 +676,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
34847 }
34848 }
34849
34850 - list_del(&governor->node);
34851 + pax_list_del((struct list_head *)&governor->node);
34852 err_out:
34853 mutex_unlock(&devfreq_list_lock);
34854
34855 diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
34856 index b70709b..1d8d02a 100644
34857 --- a/drivers/dma/sh/shdma.c
34858 +++ b/drivers/dma/sh/shdma.c
34859 @@ -476,7 +476,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
34860 return ret;
34861 }
34862
34863 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
34864 +static struct notifier_block sh_dmae_nmi_notifier = {
34865 .notifier_call = sh_dmae_nmi_handler,
34866
34867 /* Run before NMI debug handler and KGDB */
34868 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
34869 index 67610a6..30f8a11 100644
34870 --- a/drivers/edac/edac_mc_sysfs.c
34871 +++ b/drivers/edac/edac_mc_sysfs.c
34872 @@ -148,7 +148,7 @@ static const char * const edac_caps[] = {
34873 struct dev_ch_attribute {
34874 struct device_attribute attr;
34875 int channel;
34876 -};
34877 +} __do_const;
34878
34879 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
34880 struct dev_ch_attribute dev_attr_legacy_##_name = \
34881 @@ -1003,14 +1003,16 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
34882 }
34883
34884 if (mci->set_sdram_scrub_rate || mci->get_sdram_scrub_rate) {
34885 + pax_open_kernel();
34886 if (mci->get_sdram_scrub_rate) {
34887 - dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
34888 - dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
34889 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
34890 + *(void **)&dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
34891 }
34892 if (mci->set_sdram_scrub_rate) {
34893 - dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
34894 - dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
34895 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
34896 + *(void **)&dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
34897 }
34898 + pax_close_kernel();
34899 err = device_create_file(&mci->dev,
34900 &dev_attr_sdram_scrub_rate);
34901 if (err) {
34902 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
34903 index e8658e4..22746d6 100644
34904 --- a/drivers/edac/edac_pci_sysfs.c
34905 +++ b/drivers/edac/edac_pci_sysfs.c
34906 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
34907 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
34908 static int edac_pci_poll_msec = 1000; /* one second workq period */
34909
34910 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
34911 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
34912 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
34913 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
34914
34915 static struct kobject *edac_pci_top_main_kobj;
34916 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
34917 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
34918 void *value;
34919 ssize_t(*show) (void *, char *);
34920 ssize_t(*store) (void *, const char *, size_t);
34921 -};
34922 +} __do_const;
34923
34924 /* Set of show/store abstract level functions for PCI Parity object */
34925 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
34926 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34927 edac_printk(KERN_CRIT, EDAC_PCI,
34928 "Signaled System Error on %s\n",
34929 pci_name(dev));
34930 - atomic_inc(&pci_nonparity_count);
34931 + atomic_inc_unchecked(&pci_nonparity_count);
34932 }
34933
34934 if (status & (PCI_STATUS_PARITY)) {
34935 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34936 "Master Data Parity Error on %s\n",
34937 pci_name(dev));
34938
34939 - atomic_inc(&pci_parity_count);
34940 + atomic_inc_unchecked(&pci_parity_count);
34941 }
34942
34943 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34944 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34945 "Detected Parity Error on %s\n",
34946 pci_name(dev));
34947
34948 - atomic_inc(&pci_parity_count);
34949 + atomic_inc_unchecked(&pci_parity_count);
34950 }
34951 }
34952
34953 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34954 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
34955 "Signaled System Error on %s\n",
34956 pci_name(dev));
34957 - atomic_inc(&pci_nonparity_count);
34958 + atomic_inc_unchecked(&pci_nonparity_count);
34959 }
34960
34961 if (status & (PCI_STATUS_PARITY)) {
34962 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34963 "Master Data Parity Error on "
34964 "%s\n", pci_name(dev));
34965
34966 - atomic_inc(&pci_parity_count);
34967 + atomic_inc_unchecked(&pci_parity_count);
34968 }
34969
34970 if (status & (PCI_STATUS_DETECTED_PARITY)) {
34971 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
34972 "Detected Parity Error on %s\n",
34973 pci_name(dev));
34974
34975 - atomic_inc(&pci_parity_count);
34976 + atomic_inc_unchecked(&pci_parity_count);
34977 }
34978 }
34979 }
34980 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
34981 if (!check_pci_errors)
34982 return;
34983
34984 - before_count = atomic_read(&pci_parity_count);
34985 + before_count = atomic_read_unchecked(&pci_parity_count);
34986
34987 /* scan all PCI devices looking for a Parity Error on devices and
34988 * bridges.
34989 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
34990 /* Only if operator has selected panic on PCI Error */
34991 if (edac_pci_get_panic_on_pe()) {
34992 /* If the count is different 'after' from 'before' */
34993 - if (before_count != atomic_read(&pci_parity_count))
34994 + if (before_count != atomic_read_unchecked(&pci_parity_count))
34995 panic("EDAC: PCI Parity Error");
34996 }
34997 }
34998 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
34999 index 51b7e3a..aa8a3e8 100644
35000 --- a/drivers/edac/mce_amd.h
35001 +++ b/drivers/edac/mce_amd.h
35002 @@ -77,7 +77,7 @@ struct amd_decoder_ops {
35003 bool (*mc0_mce)(u16, u8);
35004 bool (*mc1_mce)(u16, u8);
35005 bool (*mc2_mce)(u16, u8);
35006 -};
35007 +} __no_const;
35008
35009 void amd_report_gart_errors(bool);
35010 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
35011 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
35012 index 57ea7f4..789e3c3 100644
35013 --- a/drivers/firewire/core-card.c
35014 +++ b/drivers/firewire/core-card.c
35015 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
35016
35017 void fw_core_remove_card(struct fw_card *card)
35018 {
35019 - struct fw_card_driver dummy_driver = dummy_driver_template;
35020 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
35021
35022 card->driver->update_phy_reg(card, 4,
35023 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
35024 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
35025 index 664a6ff..af13580 100644
35026 --- a/drivers/firewire/core-device.c
35027 +++ b/drivers/firewire/core-device.c
35028 @@ -232,7 +232,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
35029 struct config_rom_attribute {
35030 struct device_attribute attr;
35031 u32 key;
35032 -};
35033 +} __do_const;
35034
35035 static ssize_t show_immediate(struct device *dev,
35036 struct device_attribute *dattr, char *buf)
35037 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
35038 index 28a94c7..58da63a 100644
35039 --- a/drivers/firewire/core-transaction.c
35040 +++ b/drivers/firewire/core-transaction.c
35041 @@ -38,6 +38,7 @@
35042 #include <linux/timer.h>
35043 #include <linux/types.h>
35044 #include <linux/workqueue.h>
35045 +#include <linux/sched.h>
35046
35047 #include <asm/byteorder.h>
35048
35049 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
35050 index 515a42c..5ecf3ba 100644
35051 --- a/drivers/firewire/core.h
35052 +++ b/drivers/firewire/core.h
35053 @@ -111,6 +111,7 @@ struct fw_card_driver {
35054
35055 int (*stop_iso)(struct fw_iso_context *ctx);
35056 };
35057 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
35058
35059 void fw_card_initialize(struct fw_card *card,
35060 const struct fw_card_driver *driver, struct device *device);
35061 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
35062 index 94a58a0..f5eba42 100644
35063 --- a/drivers/firmware/dmi-id.c
35064 +++ b/drivers/firmware/dmi-id.c
35065 @@ -16,7 +16,7 @@
35066 struct dmi_device_attribute{
35067 struct device_attribute dev_attr;
35068 int field;
35069 -};
35070 +} __do_const;
35071 #define to_dmi_dev_attr(_dev_attr) \
35072 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
35073
35074 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
35075 index b95159b..841ae55 100644
35076 --- a/drivers/firmware/dmi_scan.c
35077 +++ b/drivers/firmware/dmi_scan.c
35078 @@ -497,11 +497,6 @@ void __init dmi_scan_machine(void)
35079 }
35080 }
35081 else {
35082 - /*
35083 - * no iounmap() for that ioremap(); it would be a no-op, but
35084 - * it's so early in setup that sucker gets confused into doing
35085 - * what it shouldn't if we actually call it.
35086 - */
35087 p = dmi_ioremap(0xF0000, 0x10000);
35088 if (p == NULL)
35089 goto error;
35090 @@ -786,7 +781,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
35091 if (buf == NULL)
35092 return -1;
35093
35094 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
35095 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
35096
35097 iounmap(buf);
35098 return 0;
35099 diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
35100 index 5145fa3..0d3babd 100644
35101 --- a/drivers/firmware/efi/efi.c
35102 +++ b/drivers/firmware/efi/efi.c
35103 @@ -65,14 +65,16 @@ static struct attribute_group efi_subsys_attr_group = {
35104 };
35105
35106 static struct efivars generic_efivars;
35107 -static struct efivar_operations generic_ops;
35108 +static efivar_operations_no_const generic_ops __read_only;
35109
35110 static int generic_ops_register(void)
35111 {
35112 - generic_ops.get_variable = efi.get_variable;
35113 - generic_ops.set_variable = efi.set_variable;
35114 - generic_ops.get_next_variable = efi.get_next_variable;
35115 - generic_ops.query_variable_store = efi_query_variable_store;
35116 + pax_open_kernel();
35117 + *(void **)&generic_ops.get_variable = efi.get_variable;
35118 + *(void **)&generic_ops.set_variable = efi.set_variable;
35119 + *(void **)&generic_ops.get_next_variable = efi.get_next_variable;
35120 + *(void **)&generic_ops.query_variable_store = efi_query_variable_store;
35121 + pax_close_kernel();
35122
35123 return efivars_register(&generic_efivars, &generic_ops, efi_kobj);
35124 }
35125 diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
35126 index 8bd1bb6..c48b0c6 100644
35127 --- a/drivers/firmware/efi/efivars.c
35128 +++ b/drivers/firmware/efi/efivars.c
35129 @@ -452,7 +452,7 @@ efivar_create_sysfs_entry(struct efivar_entry *new_var)
35130 static int
35131 create_efivars_bin_attributes(void)
35132 {
35133 - struct bin_attribute *attr;
35134 + bin_attribute_no_const *attr;
35135 int error;
35136
35137 /* new_var */
35138 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
35139 index 2a90ba6..07f3733 100644
35140 --- a/drivers/firmware/google/memconsole.c
35141 +++ b/drivers/firmware/google/memconsole.c
35142 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
35143 if (!found_memconsole())
35144 return -ENODEV;
35145
35146 - memconsole_bin_attr.size = memconsole_length;
35147 + pax_open_kernel();
35148 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
35149 + pax_close_kernel();
35150
35151 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
35152
35153 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
35154 index e16d932..f0206ef 100644
35155 --- a/drivers/gpio/gpio-ich.c
35156 +++ b/drivers/gpio/gpio-ich.c
35157 @@ -69,7 +69,7 @@ struct ichx_desc {
35158 /* Some chipsets have quirks, let these use their own request/get */
35159 int (*request)(struct gpio_chip *chip, unsigned offset);
35160 int (*get)(struct gpio_chip *chip, unsigned offset);
35161 -};
35162 +} __do_const;
35163
35164 static struct {
35165 spinlock_t lock;
35166 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
35167 index 9902732..64b62dd 100644
35168 --- a/drivers/gpio/gpio-vr41xx.c
35169 +++ b/drivers/gpio/gpio-vr41xx.c
35170 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
35171 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
35172 maskl, pendl, maskh, pendh);
35173
35174 - atomic_inc(&irq_err_count);
35175 + atomic_inc_unchecked(&irq_err_count);
35176
35177 return -EINVAL;
35178 }
35179 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
35180 index ed1334e..ee0dd42 100644
35181 --- a/drivers/gpu/drm/drm_crtc_helper.c
35182 +++ b/drivers/gpu/drm/drm_crtc_helper.c
35183 @@ -321,7 +321,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
35184 struct drm_crtc *tmp;
35185 int crtc_mask = 1;
35186
35187 - WARN(!crtc, "checking null crtc?\n");
35188 + BUG_ON(!crtc);
35189
35190 dev = crtc->dev;
35191
35192 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
35193 index 9cc247f..36aa285 100644
35194 --- a/drivers/gpu/drm/drm_drv.c
35195 +++ b/drivers/gpu/drm/drm_drv.c
35196 @@ -306,7 +306,7 @@ module_exit(drm_core_exit);
35197 /**
35198 * Copy and IOCTL return string to user space
35199 */
35200 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
35201 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
35202 {
35203 int len;
35204
35205 @@ -376,7 +376,7 @@ long drm_ioctl(struct file *filp,
35206 struct drm_file *file_priv = filp->private_data;
35207 struct drm_device *dev;
35208 const struct drm_ioctl_desc *ioctl = NULL;
35209 - drm_ioctl_t *func;
35210 + drm_ioctl_no_const_t func;
35211 unsigned int nr = DRM_IOCTL_NR(cmd);
35212 int retcode = -EINVAL;
35213 char stack_kdata[128];
35214 @@ -389,7 +389,7 @@ long drm_ioctl(struct file *filp,
35215 return -ENODEV;
35216
35217 atomic_inc(&dev->ioctl_count);
35218 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
35219 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
35220 ++file_priv->ioctl_count;
35221
35222 if ((nr >= DRM_CORE_IOCTL_COUNT) &&
35223 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
35224 index 429e07d..e681a2c 100644
35225 --- a/drivers/gpu/drm/drm_fops.c
35226 +++ b/drivers/gpu/drm/drm_fops.c
35227 @@ -71,7 +71,7 @@ static int drm_setup(struct drm_device * dev)
35228 }
35229
35230 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
35231 - atomic_set(&dev->counts[i], 0);
35232 + atomic_set_unchecked(&dev->counts[i], 0);
35233
35234 dev->sigdata.lock = NULL;
35235
35236 @@ -135,7 +135,7 @@ int drm_open(struct inode *inode, struct file *filp)
35237 if (drm_device_is_unplugged(dev))
35238 return -ENODEV;
35239
35240 - if (!dev->open_count++)
35241 + if (local_inc_return(&dev->open_count) == 1)
35242 need_setup = 1;
35243 mutex_lock(&dev->struct_mutex);
35244 old_imapping = inode->i_mapping;
35245 @@ -151,7 +151,7 @@ int drm_open(struct inode *inode, struct file *filp)
35246 retcode = drm_open_helper(inode, filp, dev);
35247 if (retcode)
35248 goto err_undo;
35249 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
35250 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
35251 if (need_setup) {
35252 retcode = drm_setup(dev);
35253 if (retcode)
35254 @@ -166,7 +166,7 @@ err_undo:
35255 iput(container_of(dev->dev_mapping, struct inode, i_data));
35256 dev->dev_mapping = old_mapping;
35257 mutex_unlock(&dev->struct_mutex);
35258 - dev->open_count--;
35259 + local_dec(&dev->open_count);
35260 return retcode;
35261 }
35262 EXPORT_SYMBOL(drm_open);
35263 @@ -441,7 +441,7 @@ int drm_release(struct inode *inode, struct file *filp)
35264
35265 mutex_lock(&drm_global_mutex);
35266
35267 - DRM_DEBUG("open_count = %d\n", dev->open_count);
35268 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
35269
35270 if (dev->driver->preclose)
35271 dev->driver->preclose(dev, file_priv);
35272 @@ -450,10 +450,10 @@ int drm_release(struct inode *inode, struct file *filp)
35273 * Begin inline drm_release
35274 */
35275
35276 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
35277 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
35278 task_pid_nr(current),
35279 (long)old_encode_dev(file_priv->minor->device),
35280 - dev->open_count);
35281 + local_read(&dev->open_count));
35282
35283 /* Release any auth tokens that might point to this file_priv,
35284 (do that under the drm_global_mutex) */
35285 @@ -550,8 +550,8 @@ int drm_release(struct inode *inode, struct file *filp)
35286 * End inline drm_release
35287 */
35288
35289 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
35290 - if (!--dev->open_count) {
35291 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
35292 + if (local_dec_and_test(&dev->open_count)) {
35293 if (atomic_read(&dev->ioctl_count)) {
35294 DRM_ERROR("Device busy: %d\n",
35295 atomic_read(&dev->ioctl_count));
35296 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
35297 index f731116..629842c 100644
35298 --- a/drivers/gpu/drm/drm_global.c
35299 +++ b/drivers/gpu/drm/drm_global.c
35300 @@ -36,7 +36,7 @@
35301 struct drm_global_item {
35302 struct mutex mutex;
35303 void *object;
35304 - int refcount;
35305 + atomic_t refcount;
35306 };
35307
35308 static struct drm_global_item glob[DRM_GLOBAL_NUM];
35309 @@ -49,7 +49,7 @@ void drm_global_init(void)
35310 struct drm_global_item *item = &glob[i];
35311 mutex_init(&item->mutex);
35312 item->object = NULL;
35313 - item->refcount = 0;
35314 + atomic_set(&item->refcount, 0);
35315 }
35316 }
35317
35318 @@ -59,7 +59,7 @@ void drm_global_release(void)
35319 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
35320 struct drm_global_item *item = &glob[i];
35321 BUG_ON(item->object != NULL);
35322 - BUG_ON(item->refcount != 0);
35323 + BUG_ON(atomic_read(&item->refcount) != 0);
35324 }
35325 }
35326
35327 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
35328 void *object;
35329
35330 mutex_lock(&item->mutex);
35331 - if (item->refcount == 0) {
35332 + if (atomic_read(&item->refcount) == 0) {
35333 item->object = kzalloc(ref->size, GFP_KERNEL);
35334 if (unlikely(item->object == NULL)) {
35335 ret = -ENOMEM;
35336 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
35337 goto out_err;
35338
35339 }
35340 - ++item->refcount;
35341 + atomic_inc(&item->refcount);
35342 ref->object = item->object;
35343 object = item->object;
35344 mutex_unlock(&item->mutex);
35345 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
35346 struct drm_global_item *item = &glob[ref->global_type];
35347
35348 mutex_lock(&item->mutex);
35349 - BUG_ON(item->refcount == 0);
35350 + BUG_ON(atomic_read(&item->refcount) == 0);
35351 BUG_ON(ref->object != item->object);
35352 - if (--item->refcount == 0) {
35353 + if (atomic_dec_and_test(&item->refcount)) {
35354 ref->release(ref);
35355 item->object = NULL;
35356 }
35357 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
35358 index d4b20ce..77a8d41 100644
35359 --- a/drivers/gpu/drm/drm_info.c
35360 +++ b/drivers/gpu/drm/drm_info.c
35361 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
35362 struct drm_local_map *map;
35363 struct drm_map_list *r_list;
35364
35365 - /* Hardcoded from _DRM_FRAME_BUFFER,
35366 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
35367 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
35368 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
35369 + static const char * const types[] = {
35370 + [_DRM_FRAME_BUFFER] = "FB",
35371 + [_DRM_REGISTERS] = "REG",
35372 + [_DRM_SHM] = "SHM",
35373 + [_DRM_AGP] = "AGP",
35374 + [_DRM_SCATTER_GATHER] = "SG",
35375 + [_DRM_CONSISTENT] = "PCI",
35376 + [_DRM_GEM] = "GEM" };
35377 const char *type;
35378 int i;
35379
35380 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
35381 map = r_list->map;
35382 if (!map)
35383 continue;
35384 - if (map->type < 0 || map->type > 5)
35385 + if (map->type >= ARRAY_SIZE(types))
35386 type = "??";
35387 else
35388 type = types[map->type];
35389 @@ -253,7 +257,11 @@ int drm_vma_info(struct seq_file *m, void *data)
35390 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
35391 vma->vm_flags & VM_LOCKED ? 'l' : '-',
35392 vma->vm_flags & VM_IO ? 'i' : '-',
35393 +#ifdef CONFIG_GRKERNSEC_HIDESYM
35394 + 0);
35395 +#else
35396 vma->vm_pgoff);
35397 +#endif
35398
35399 #if defined(__i386__)
35400 pgprot = pgprot_val(vma->vm_page_prot);
35401 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
35402 index 2f4c434..dd12cd2 100644
35403 --- a/drivers/gpu/drm/drm_ioc32.c
35404 +++ b/drivers/gpu/drm/drm_ioc32.c
35405 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
35406 request = compat_alloc_user_space(nbytes);
35407 if (!access_ok(VERIFY_WRITE, request, nbytes))
35408 return -EFAULT;
35409 - list = (struct drm_buf_desc *) (request + 1);
35410 + list = (struct drm_buf_desc __user *) (request + 1);
35411
35412 if (__put_user(count, &request->count)
35413 || __put_user(list, &request->list))
35414 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
35415 request = compat_alloc_user_space(nbytes);
35416 if (!access_ok(VERIFY_WRITE, request, nbytes))
35417 return -EFAULT;
35418 - list = (struct drm_buf_pub *) (request + 1);
35419 + list = (struct drm_buf_pub __user *) (request + 1);
35420
35421 if (__put_user(count, &request->count)
35422 || __put_user(list, &request->list))
35423 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
35424 return 0;
35425 }
35426
35427 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
35428 +drm_ioctl_compat_t drm_compat_ioctls[] = {
35429 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
35430 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
35431 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
35432 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
35433 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35434 {
35435 unsigned int nr = DRM_IOCTL_NR(cmd);
35436 - drm_ioctl_compat_t *fn;
35437 int ret;
35438
35439 /* Assume that ioctls without an explicit compat routine will just
35440 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35441 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
35442 return drm_ioctl(filp, cmd, arg);
35443
35444 - fn = drm_compat_ioctls[nr];
35445 -
35446 - if (fn != NULL)
35447 - ret = (*fn) (filp, cmd, arg);
35448 + if (drm_compat_ioctls[nr] != NULL)
35449 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
35450 else
35451 ret = drm_ioctl(filp, cmd, arg);
35452
35453 diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
35454 index e77bd8b..1571b85 100644
35455 --- a/drivers/gpu/drm/drm_ioctl.c
35456 +++ b/drivers/gpu/drm/drm_ioctl.c
35457 @@ -252,7 +252,7 @@ int drm_getstats(struct drm_device *dev, void *data,
35458 stats->data[i].value =
35459 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
35460 else
35461 - stats->data[i].value = atomic_read(&dev->counts[i]);
35462 + stats->data[i].value = atomic_read_unchecked(&dev->counts[i]);
35463 stats->data[i].type = dev->types[i];
35464 }
35465
35466 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
35467 index d752c96..fe08455 100644
35468 --- a/drivers/gpu/drm/drm_lock.c
35469 +++ b/drivers/gpu/drm/drm_lock.c
35470 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
35471 if (drm_lock_take(&master->lock, lock->context)) {
35472 master->lock.file_priv = file_priv;
35473 master->lock.lock_time = jiffies;
35474 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
35475 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
35476 break; /* Got lock */
35477 }
35478
35479 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
35480 return -EINVAL;
35481 }
35482
35483 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
35484 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
35485
35486 if (drm_lock_free(&master->lock, lock->context)) {
35487 /* FIXME: Should really bail out here. */
35488 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
35489 index 16f3ec5..b28f9ca 100644
35490 --- a/drivers/gpu/drm/drm_stub.c
35491 +++ b/drivers/gpu/drm/drm_stub.c
35492 @@ -501,7 +501,7 @@ void drm_unplug_dev(struct drm_device *dev)
35493
35494 drm_device_set_unplugged(dev);
35495
35496 - if (dev->open_count == 0) {
35497 + if (local_read(&dev->open_count) == 0) {
35498 drm_put_dev(dev);
35499 }
35500 mutex_unlock(&drm_global_mutex);
35501 diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
35502 index 0229665..f61329c 100644
35503 --- a/drivers/gpu/drm/drm_sysfs.c
35504 +++ b/drivers/gpu/drm/drm_sysfs.c
35505 @@ -499,7 +499,7 @@ EXPORT_SYMBOL(drm_sysfs_hotplug_event);
35506 int drm_sysfs_device_add(struct drm_minor *minor)
35507 {
35508 int err;
35509 - char *minor_str;
35510 + const char *minor_str;
35511
35512 minor->kdev.parent = minor->dev->dev;
35513
35514 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
35515 index 004ecdf..db1f6e0 100644
35516 --- a/drivers/gpu/drm/i810/i810_dma.c
35517 +++ b/drivers/gpu/drm/i810/i810_dma.c
35518 @@ -945,8 +945,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
35519 dma->buflist[vertex->idx],
35520 vertex->discard, vertex->used);
35521
35522 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35523 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35524 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
35525 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35526 sarea_priv->last_enqueue = dev_priv->counter - 1;
35527 sarea_priv->last_dispatch = (int)hw_status[5];
35528
35529 @@ -1106,8 +1106,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
35530 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
35531 mc->last_render);
35532
35533 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35534 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
35535 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
35536 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
35537 sarea_priv->last_enqueue = dev_priv->counter - 1;
35538 sarea_priv->last_dispatch = (int)hw_status[5];
35539
35540 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
35541 index 6e0acad..93c8289 100644
35542 --- a/drivers/gpu/drm/i810/i810_drv.h
35543 +++ b/drivers/gpu/drm/i810/i810_drv.h
35544 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
35545 int page_flipping;
35546
35547 wait_queue_head_t irq_queue;
35548 - atomic_t irq_received;
35549 - atomic_t irq_emitted;
35550 + atomic_unchecked_t irq_received;
35551 + atomic_unchecked_t irq_emitted;
35552
35553 int front_offset;
35554 } drm_i810_private_t;
35555 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
35556 index e913d32..4d9b351 100644
35557 --- a/drivers/gpu/drm/i915/i915_debugfs.c
35558 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
35559 @@ -499,7 +499,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
35560 I915_READ(GTIMR));
35561 }
35562 seq_printf(m, "Interrupts received: %d\n",
35563 - atomic_read(&dev_priv->irq_received));
35564 + atomic_read_unchecked(&dev_priv->irq_received));
35565 for_each_ring(ring, dev_priv, i) {
35566 if (IS_GEN6(dev) || IS_GEN7(dev)) {
35567 seq_printf(m,
35568 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
35569 index 3b315ba..aac280f 100644
35570 --- a/drivers/gpu/drm/i915/i915_dma.c
35571 +++ b/drivers/gpu/drm/i915/i915_dma.c
35572 @@ -1259,7 +1259,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
35573 bool can_switch;
35574
35575 spin_lock(&dev->count_lock);
35576 - can_switch = (dev->open_count == 0);
35577 + can_switch = (local_read(&dev->open_count) == 0);
35578 spin_unlock(&dev->count_lock);
35579 return can_switch;
35580 }
35581 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
35582 index 9669a0b..bb65176 100644
35583 --- a/drivers/gpu/drm/i915/i915_drv.h
35584 +++ b/drivers/gpu/drm/i915/i915_drv.h
35585 @@ -915,7 +915,7 @@ typedef struct drm_i915_private {
35586 drm_dma_handle_t *status_page_dmah;
35587 struct resource mch_res;
35588
35589 - atomic_t irq_received;
35590 + atomic_unchecked_t irq_received;
35591
35592 /* protects the irq masks */
35593 spinlock_t irq_lock;
35594 @@ -1811,7 +1811,7 @@ extern struct i2c_adapter *intel_gmbus_get_adapter(
35595 struct drm_i915_private *dev_priv, unsigned port);
35596 extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
35597 extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
35598 -extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35599 +static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
35600 {
35601 return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
35602 }
35603 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35604 index 117ce38..eefd237 100644
35605 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35606 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
35607 @@ -727,9 +727,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
35608
35609 static int
35610 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
35611 - int count)
35612 + unsigned int count)
35613 {
35614 - int i;
35615 + unsigned int i;
35616 int relocs_total = 0;
35617 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
35618
35619 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
35620 index 3c59584..500f2e9 100644
35621 --- a/drivers/gpu/drm/i915/i915_ioc32.c
35622 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
35623 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
35624 (unsigned long)request);
35625 }
35626
35627 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35628 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
35629 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
35630 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
35631 [DRM_I915_GETPARAM] = compat_i915_getparam,
35632 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
35633 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35634 {
35635 unsigned int nr = DRM_IOCTL_NR(cmd);
35636 - drm_ioctl_compat_t *fn = NULL;
35637 int ret;
35638
35639 if (nr < DRM_COMMAND_BASE)
35640 return drm_compat_ioctl(filp, cmd, arg);
35641
35642 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
35643 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35644 -
35645 - if (fn != NULL)
35646 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
35647 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
35648 ret = (*fn) (filp, cmd, arg);
35649 - else
35650 + } else
35651 ret = drm_ioctl(filp, cmd, arg);
35652
35653 return ret;
35654 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
35655 index 0aa2ef0..77c03d0 100644
35656 --- a/drivers/gpu/drm/i915/i915_irq.c
35657 +++ b/drivers/gpu/drm/i915/i915_irq.c
35658 @@ -679,7 +679,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
35659 int pipe;
35660 u32 pipe_stats[I915_MAX_PIPES];
35661
35662 - atomic_inc(&dev_priv->irq_received);
35663 + atomic_inc_unchecked(&dev_priv->irq_received);
35664
35665 while (true) {
35666 iir = I915_READ(VLV_IIR);
35667 @@ -844,7 +844,7 @@ static irqreturn_t ivybridge_irq_handler(int irq, void *arg)
35668 irqreturn_t ret = IRQ_NONE;
35669 int i;
35670
35671 - atomic_inc(&dev_priv->irq_received);
35672 + atomic_inc_unchecked(&dev_priv->irq_received);
35673
35674 /* disable master interrupt before clearing iir */
35675 de_ier = I915_READ(DEIER);
35676 @@ -934,7 +934,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
35677 int ret = IRQ_NONE;
35678 u32 de_iir, gt_iir, de_ier, pm_iir, sde_ier;
35679
35680 - atomic_inc(&dev_priv->irq_received);
35681 + atomic_inc_unchecked(&dev_priv->irq_received);
35682
35683 /* disable master interrupt before clearing iir */
35684 de_ier = I915_READ(DEIER);
35685 @@ -2098,7 +2098,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
35686 {
35687 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35688
35689 - atomic_set(&dev_priv->irq_received, 0);
35690 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35691
35692 I915_WRITE(HWSTAM, 0xeffe);
35693
35694 @@ -2133,7 +2133,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
35695 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35696 int pipe;
35697
35698 - atomic_set(&dev_priv->irq_received, 0);
35699 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35700
35701 /* VLV magic */
35702 I915_WRITE(VLV_IMR, 0);
35703 @@ -2420,7 +2420,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
35704 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35705 int pipe;
35706
35707 - atomic_set(&dev_priv->irq_received, 0);
35708 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35709
35710 for_each_pipe(pipe)
35711 I915_WRITE(PIPESTAT(pipe), 0);
35712 @@ -2499,7 +2499,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
35713 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
35714 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
35715
35716 - atomic_inc(&dev_priv->irq_received);
35717 + atomic_inc_unchecked(&dev_priv->irq_received);
35718
35719 iir = I915_READ16(IIR);
35720 if (iir == 0)
35721 @@ -2574,7 +2574,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
35722 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35723 int pipe;
35724
35725 - atomic_set(&dev_priv->irq_received, 0);
35726 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35727
35728 if (I915_HAS_HOTPLUG(dev)) {
35729 I915_WRITE(PORT_HOTPLUG_EN, 0);
35730 @@ -2673,7 +2673,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
35731 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
35732 int pipe, ret = IRQ_NONE;
35733
35734 - atomic_inc(&dev_priv->irq_received);
35735 + atomic_inc_unchecked(&dev_priv->irq_received);
35736
35737 iir = I915_READ(IIR);
35738 do {
35739 @@ -2800,7 +2800,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
35740 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
35741 int pipe;
35742
35743 - atomic_set(&dev_priv->irq_received, 0);
35744 + atomic_set_unchecked(&dev_priv->irq_received, 0);
35745
35746 I915_WRITE(PORT_HOTPLUG_EN, 0);
35747 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
35748 @@ -2907,7 +2907,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
35749 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
35750 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
35751
35752 - atomic_inc(&dev_priv->irq_received);
35753 + atomic_inc_unchecked(&dev_priv->irq_received);
35754
35755 iir = I915_READ(IIR);
35756
35757 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
35758 index 56746dc..b5a214f 100644
35759 --- a/drivers/gpu/drm/i915/intel_display.c
35760 +++ b/drivers/gpu/drm/i915/intel_display.c
35761 @@ -8919,13 +8919,13 @@ struct intel_quirk {
35762 int subsystem_vendor;
35763 int subsystem_device;
35764 void (*hook)(struct drm_device *dev);
35765 -};
35766 +} __do_const;
35767
35768 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
35769 struct intel_dmi_quirk {
35770 void (*hook)(struct drm_device *dev);
35771 const struct dmi_system_id (*dmi_id_list)[];
35772 -};
35773 +} __do_const;
35774
35775 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35776 {
35777 @@ -8933,18 +8933,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
35778 return 1;
35779 }
35780
35781 -static const struct intel_dmi_quirk intel_dmi_quirks[] = {
35782 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
35783 {
35784 - .dmi_id_list = &(const struct dmi_system_id[]) {
35785 - {
35786 - .callback = intel_dmi_reverse_brightness,
35787 - .ident = "NCR Corporation",
35788 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35789 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
35790 - },
35791 - },
35792 - { } /* terminating entry */
35793 + .callback = intel_dmi_reverse_brightness,
35794 + .ident = "NCR Corporation",
35795 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
35796 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
35797 },
35798 + },
35799 + { } /* terminating entry */
35800 +};
35801 +
35802 +static const struct intel_dmi_quirk intel_dmi_quirks[] = {
35803 + {
35804 + .dmi_id_list = &intel_dmi_quirks_table,
35805 .hook = quirk_invert_brightness,
35806 },
35807 };
35808 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
35809 index 54558a0..2d97005 100644
35810 --- a/drivers/gpu/drm/mga/mga_drv.h
35811 +++ b/drivers/gpu/drm/mga/mga_drv.h
35812 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
35813 u32 clear_cmd;
35814 u32 maccess;
35815
35816 - atomic_t vbl_received; /**< Number of vblanks received. */
35817 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
35818 wait_queue_head_t fence_queue;
35819 - atomic_t last_fence_retired;
35820 + atomic_unchecked_t last_fence_retired;
35821 u32 next_fence_to_post;
35822
35823 unsigned int fb_cpp;
35824 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
35825 index 709e90d..89a1c0d 100644
35826 --- a/drivers/gpu/drm/mga/mga_ioc32.c
35827 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
35828 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
35829 return 0;
35830 }
35831
35832 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
35833 +drm_ioctl_compat_t mga_compat_ioctls[] = {
35834 [DRM_MGA_INIT] = compat_mga_init,
35835 [DRM_MGA_GETPARAM] = compat_mga_getparam,
35836 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
35837 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
35838 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
35839 {
35840 unsigned int nr = DRM_IOCTL_NR(cmd);
35841 - drm_ioctl_compat_t *fn = NULL;
35842 int ret;
35843
35844 if (nr < DRM_COMMAND_BASE)
35845 return drm_compat_ioctl(filp, cmd, arg);
35846
35847 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
35848 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35849 -
35850 - if (fn != NULL)
35851 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
35852 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
35853 ret = (*fn) (filp, cmd, arg);
35854 - else
35855 + } else
35856 ret = drm_ioctl(filp, cmd, arg);
35857
35858 return ret;
35859 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
35860 index 598c281..60d590e 100644
35861 --- a/drivers/gpu/drm/mga/mga_irq.c
35862 +++ b/drivers/gpu/drm/mga/mga_irq.c
35863 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
35864 if (crtc != 0)
35865 return 0;
35866
35867 - return atomic_read(&dev_priv->vbl_received);
35868 + return atomic_read_unchecked(&dev_priv->vbl_received);
35869 }
35870
35871
35872 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35873 /* VBLANK interrupt */
35874 if (status & MGA_VLINEPEN) {
35875 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
35876 - atomic_inc(&dev_priv->vbl_received);
35877 + atomic_inc_unchecked(&dev_priv->vbl_received);
35878 drm_handle_vblank(dev, 0);
35879 handled = 1;
35880 }
35881 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
35882 if ((prim_start & ~0x03) != (prim_end & ~0x03))
35883 MGA_WRITE(MGA_PRIMEND, prim_end);
35884
35885 - atomic_inc(&dev_priv->last_fence_retired);
35886 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
35887 DRM_WAKEUP(&dev_priv->fence_queue);
35888 handled = 1;
35889 }
35890 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
35891 * using fences.
35892 */
35893 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
35894 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
35895 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
35896 - *sequence) <= (1 << 23)));
35897
35898 *sequence = cur_fence;
35899 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
35900 index 6aa2137..fe8dc55 100644
35901 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
35902 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
35903 @@ -965,7 +965,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
35904 struct bit_table {
35905 const char id;
35906 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
35907 -};
35908 +} __no_const;
35909
35910 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
35911
35912 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
35913 index f2b30f8..d0f9a95 100644
35914 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
35915 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
35916 @@ -92,7 +92,7 @@ struct nouveau_drm {
35917 struct drm_global_reference mem_global_ref;
35918 struct ttm_bo_global_ref bo_global_ref;
35919 struct ttm_bo_device bdev;
35920 - atomic_t validate_sequence;
35921 + atomic_unchecked_t validate_sequence;
35922 int (*move)(struct nouveau_channel *,
35923 struct ttm_buffer_object *,
35924 struct ttm_mem_reg *, struct ttm_mem_reg *);
35925 diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
35926 index b4b4d0c..b7edc15 100644
35927 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
35928 +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
35929 @@ -322,7 +322,7 @@ validate_init(struct nouveau_channel *chan, struct drm_file *file_priv,
35930 int ret, i;
35931 struct nouveau_bo *res_bo = NULL;
35932
35933 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
35934 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
35935 retry:
35936 if (++trycnt > 100000) {
35937 NV_ERROR(cli, "%s failed and gave up.\n", __func__);
35938 @@ -359,7 +359,7 @@ retry:
35939 if (ret) {
35940 validate_fini(op, NULL);
35941 if (unlikely(ret == -EAGAIN)) {
35942 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
35943 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
35944 ret = ttm_bo_reserve_slowpath(&nvbo->bo, true,
35945 sequence);
35946 if (!ret)
35947 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35948 index 08214bc..9208577 100644
35949 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35950 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
35951 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
35952 unsigned long arg)
35953 {
35954 unsigned int nr = DRM_IOCTL_NR(cmd);
35955 - drm_ioctl_compat_t *fn = NULL;
35956 + drm_ioctl_compat_t fn = NULL;
35957 int ret;
35958
35959 if (nr < DRM_COMMAND_BASE)
35960 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
35961 index 25d3495..d81aaf6 100644
35962 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
35963 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
35964 @@ -62,7 +62,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
35965 bool can_switch;
35966
35967 spin_lock(&dev->count_lock);
35968 - can_switch = (dev->open_count == 0);
35969 + can_switch = (local_read(&dev->open_count) == 0);
35970 spin_unlock(&dev->count_lock);
35971 return can_switch;
35972 }
35973 diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
35974 index 489cb8c..0b8d0d3 100644
35975 --- a/drivers/gpu/drm/qxl/qxl_ttm.c
35976 +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
35977 @@ -103,7 +103,7 @@ static void qxl_ttm_global_fini(struct qxl_device *qdev)
35978 }
35979 }
35980
35981 -static struct vm_operations_struct qxl_ttm_vm_ops;
35982 +static vm_operations_struct_no_const qxl_ttm_vm_ops __read_only;
35983 static const struct vm_operations_struct *ttm_vm_ops;
35984
35985 static int qxl_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
35986 @@ -147,8 +147,10 @@ int qxl_mmap(struct file *filp, struct vm_area_struct *vma)
35987 return r;
35988 if (unlikely(ttm_vm_ops == NULL)) {
35989 ttm_vm_ops = vma->vm_ops;
35990 + pax_open_kernel();
35991 qxl_ttm_vm_ops = *ttm_vm_ops;
35992 qxl_ttm_vm_ops.fault = &qxl_ttm_fault;
35993 + pax_close_kernel();
35994 }
35995 vma->vm_ops = &qxl_ttm_vm_ops;
35996 return 0;
35997 @@ -556,25 +558,23 @@ static int qxl_mm_dump_table(struct seq_file *m, void *data)
35998 static int qxl_ttm_debugfs_init(struct qxl_device *qdev)
35999 {
36000 #if defined(CONFIG_DEBUG_FS)
36001 - static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES];
36002 - static char qxl_mem_types_names[QXL_DEBUGFS_MEM_TYPES][32];
36003 - unsigned i;
36004 + static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES] = {
36005 + {
36006 + .name = "qxl_mem_mm",
36007 + .show = &qxl_mm_dump_table,
36008 + },
36009 + {
36010 + .name = "qxl_surf_mm",
36011 + .show = &qxl_mm_dump_table,
36012 + }
36013 + };
36014
36015 - for (i = 0; i < QXL_DEBUGFS_MEM_TYPES; i++) {
36016 - if (i == 0)
36017 - sprintf(qxl_mem_types_names[i], "qxl_mem_mm");
36018 - else
36019 - sprintf(qxl_mem_types_names[i], "qxl_surf_mm");
36020 - qxl_mem_types_list[i].name = qxl_mem_types_names[i];
36021 - qxl_mem_types_list[i].show = &qxl_mm_dump_table;
36022 - qxl_mem_types_list[i].driver_features = 0;
36023 - if (i == 0)
36024 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
36025 - else
36026 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
36027 + pax_open_kernel();
36028 + *(void **)&qxl_mem_types_list[0].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
36029 + *(void **)&qxl_mem_types_list[1].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
36030 + pax_close_kernel();
36031
36032 - }
36033 - return qxl_debugfs_add_files(qdev, qxl_mem_types_list, i);
36034 + return qxl_debugfs_add_files(qdev, qxl_mem_types_list, QXL_DEBUGFS_MEM_TYPES);
36035 #else
36036 return 0;
36037 #endif
36038 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
36039 index d4660cf..70dbe65 100644
36040 --- a/drivers/gpu/drm/r128/r128_cce.c
36041 +++ b/drivers/gpu/drm/r128/r128_cce.c
36042 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
36043
36044 /* GH: Simple idle check.
36045 */
36046 - atomic_set(&dev_priv->idle_count, 0);
36047 + atomic_set_unchecked(&dev_priv->idle_count, 0);
36048
36049 /* We don't support anything other than bus-mastering ring mode,
36050 * but the ring can be in either AGP or PCI space for the ring
36051 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
36052 index 930c71b..499aded 100644
36053 --- a/drivers/gpu/drm/r128/r128_drv.h
36054 +++ b/drivers/gpu/drm/r128/r128_drv.h
36055 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
36056 int is_pci;
36057 unsigned long cce_buffers_offset;
36058
36059 - atomic_t idle_count;
36060 + atomic_unchecked_t idle_count;
36061
36062 int page_flipping;
36063 int current_page;
36064 u32 crtc_offset;
36065 u32 crtc_offset_cntl;
36066
36067 - atomic_t vbl_received;
36068 + atomic_unchecked_t vbl_received;
36069
36070 u32 color_fmt;
36071 unsigned int front_offset;
36072 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
36073 index a954c54..9cc595c 100644
36074 --- a/drivers/gpu/drm/r128/r128_ioc32.c
36075 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
36076 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
36077 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
36078 }
36079
36080 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
36081 +drm_ioctl_compat_t r128_compat_ioctls[] = {
36082 [DRM_R128_INIT] = compat_r128_init,
36083 [DRM_R128_DEPTH] = compat_r128_depth,
36084 [DRM_R128_STIPPLE] = compat_r128_stipple,
36085 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
36086 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
36087 {
36088 unsigned int nr = DRM_IOCTL_NR(cmd);
36089 - drm_ioctl_compat_t *fn = NULL;
36090 int ret;
36091
36092 if (nr < DRM_COMMAND_BASE)
36093 return drm_compat_ioctl(filp, cmd, arg);
36094
36095 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
36096 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
36097 -
36098 - if (fn != NULL)
36099 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
36100 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
36101 ret = (*fn) (filp, cmd, arg);
36102 - else
36103 + } else
36104 ret = drm_ioctl(filp, cmd, arg);
36105
36106 return ret;
36107 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
36108 index 2ea4f09..d391371 100644
36109 --- a/drivers/gpu/drm/r128/r128_irq.c
36110 +++ b/drivers/gpu/drm/r128/r128_irq.c
36111 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
36112 if (crtc != 0)
36113 return 0;
36114
36115 - return atomic_read(&dev_priv->vbl_received);
36116 + return atomic_read_unchecked(&dev_priv->vbl_received);
36117 }
36118
36119 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
36120 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
36121 /* VBLANK interrupt */
36122 if (status & R128_CRTC_VBLANK_INT) {
36123 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
36124 - atomic_inc(&dev_priv->vbl_received);
36125 + atomic_inc_unchecked(&dev_priv->vbl_received);
36126 drm_handle_vblank(dev, 0);
36127 return IRQ_HANDLED;
36128 }
36129 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
36130 index 19bb7e6..de7e2a2 100644
36131 --- a/drivers/gpu/drm/r128/r128_state.c
36132 +++ b/drivers/gpu/drm/r128/r128_state.c
36133 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
36134
36135 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
36136 {
36137 - if (atomic_read(&dev_priv->idle_count) == 0)
36138 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
36139 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
36140 else
36141 - atomic_set(&dev_priv->idle_count, 0);
36142 + atomic_set_unchecked(&dev_priv->idle_count, 0);
36143 }
36144
36145 #endif
36146 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
36147 index 5a82b6b..9e69c73 100644
36148 --- a/drivers/gpu/drm/radeon/mkregtable.c
36149 +++ b/drivers/gpu/drm/radeon/mkregtable.c
36150 @@ -637,14 +637,14 @@ static int parser_auth(struct table *t, const char *filename)
36151 regex_t mask_rex;
36152 regmatch_t match[4];
36153 char buf[1024];
36154 - size_t end;
36155 + long end;
36156 int len;
36157 int done = 0;
36158 int r;
36159 unsigned o;
36160 struct offset *offset;
36161 char last_reg_s[10];
36162 - int last_reg;
36163 + unsigned long last_reg;
36164
36165 if (regcomp
36166 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
36167 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
36168 index b0dc0b6..a9bfe9c 100644
36169 --- a/drivers/gpu/drm/radeon/radeon_device.c
36170 +++ b/drivers/gpu/drm/radeon/radeon_device.c
36171 @@ -1014,7 +1014,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
36172 bool can_switch;
36173
36174 spin_lock(&dev->count_lock);
36175 - can_switch = (dev->open_count == 0);
36176 + can_switch = (local_read(&dev->open_count) == 0);
36177 spin_unlock(&dev->count_lock);
36178 return can_switch;
36179 }
36180 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
36181 index b369d42..8dd04eb 100644
36182 --- a/drivers/gpu/drm/radeon/radeon_drv.h
36183 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
36184 @@ -258,7 +258,7 @@ typedef struct drm_radeon_private {
36185
36186 /* SW interrupt */
36187 wait_queue_head_t swi_queue;
36188 - atomic_t swi_emitted;
36189 + atomic_unchecked_t swi_emitted;
36190 int vblank_crtc;
36191 uint32_t irq_enable_reg;
36192 uint32_t r500_disp_irq_reg;
36193 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
36194 index c180df8..5fd8186 100644
36195 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
36196 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
36197 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
36198 request = compat_alloc_user_space(sizeof(*request));
36199 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
36200 || __put_user(req32.param, &request->param)
36201 - || __put_user((void __user *)(unsigned long)req32.value,
36202 + || __put_user((unsigned long)req32.value,
36203 &request->value))
36204 return -EFAULT;
36205
36206 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
36207 #define compat_radeon_cp_setparam NULL
36208 #endif /* X86_64 || IA64 */
36209
36210 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
36211 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
36212 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
36213 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
36214 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
36215 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
36216 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
36217 {
36218 unsigned int nr = DRM_IOCTL_NR(cmd);
36219 - drm_ioctl_compat_t *fn = NULL;
36220 int ret;
36221
36222 if (nr < DRM_COMMAND_BASE)
36223 return drm_compat_ioctl(filp, cmd, arg);
36224
36225 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
36226 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
36227 -
36228 - if (fn != NULL)
36229 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
36230 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
36231 ret = (*fn) (filp, cmd, arg);
36232 - else
36233 + } else
36234 ret = drm_ioctl(filp, cmd, arg);
36235
36236 return ret;
36237 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
36238 index 8d68e97..9dcfed8 100644
36239 --- a/drivers/gpu/drm/radeon/radeon_irq.c
36240 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
36241 @@ -226,8 +226,8 @@ static int radeon_emit_irq(struct drm_device * dev)
36242 unsigned int ret;
36243 RING_LOCALS;
36244
36245 - atomic_inc(&dev_priv->swi_emitted);
36246 - ret = atomic_read(&dev_priv->swi_emitted);
36247 + atomic_inc_unchecked(&dev_priv->swi_emitted);
36248 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
36249
36250 BEGIN_RING(4);
36251 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
36252 @@ -353,7 +353,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
36253 drm_radeon_private_t *dev_priv =
36254 (drm_radeon_private_t *) dev->dev_private;
36255
36256 - atomic_set(&dev_priv->swi_emitted, 0);
36257 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
36258 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
36259
36260 dev->max_vblank_count = 0x001fffff;
36261 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
36262 index 4d20910..6726b6d 100644
36263 --- a/drivers/gpu/drm/radeon/radeon_state.c
36264 +++ b/drivers/gpu/drm/radeon/radeon_state.c
36265 @@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
36266 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
36267 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
36268
36269 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
36270 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
36271 sarea_priv->nbox * sizeof(depth_boxes[0])))
36272 return -EFAULT;
36273
36274 @@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
36275 {
36276 drm_radeon_private_t *dev_priv = dev->dev_private;
36277 drm_radeon_getparam_t *param = data;
36278 - int value;
36279 + int value = 0;
36280
36281 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
36282
36283 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
36284 index 6c0ce89..57a2529 100644
36285 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
36286 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
36287 @@ -782,7 +782,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
36288 man->size = size >> PAGE_SHIFT;
36289 }
36290
36291 -static struct vm_operations_struct radeon_ttm_vm_ops;
36292 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
36293 static const struct vm_operations_struct *ttm_vm_ops = NULL;
36294
36295 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
36296 @@ -823,8 +823,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
36297 }
36298 if (unlikely(ttm_vm_ops == NULL)) {
36299 ttm_vm_ops = vma->vm_ops;
36300 + pax_open_kernel();
36301 radeon_ttm_vm_ops = *ttm_vm_ops;
36302 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
36303 + pax_close_kernel();
36304 }
36305 vma->vm_ops = &radeon_ttm_vm_ops;
36306 return 0;
36307 @@ -853,38 +855,33 @@ static int radeon_mm_dump_table(struct seq_file *m, void *data)
36308 static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
36309 {
36310 #if defined(CONFIG_DEBUG_FS)
36311 - static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2];
36312 - static char radeon_mem_types_names[RADEON_DEBUGFS_MEM_TYPES+2][32];
36313 + static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2] = {
36314 + {
36315 + .name = "radeon_vram_mm",
36316 + .show = &radeon_mm_dump_table,
36317 + },
36318 + {
36319 + .name = "radeon_gtt_mm",
36320 + .show = &radeon_mm_dump_table,
36321 + },
36322 + {
36323 + .name = "ttm_page_pool",
36324 + .show = &ttm_page_alloc_debugfs,
36325 + },
36326 + {
36327 + .name = "ttm_dma_page_pool",
36328 + .show = &ttm_dma_page_alloc_debugfs,
36329 + },
36330 + };
36331 unsigned i;
36332
36333 - for (i = 0; i < RADEON_DEBUGFS_MEM_TYPES; i++) {
36334 - if (i == 0)
36335 - sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
36336 - else
36337 - sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
36338 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36339 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
36340 - radeon_mem_types_list[i].driver_features = 0;
36341 - if (i == 0)
36342 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
36343 - else
36344 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
36345 -
36346 - }
36347 - /* Add ttm page pool to debugfs */
36348 - sprintf(radeon_mem_types_names[i], "ttm_page_pool");
36349 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36350 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
36351 - radeon_mem_types_list[i].driver_features = 0;
36352 - radeon_mem_types_list[i++].data = NULL;
36353 + pax_open_kernel();
36354 + *(void **)&radeon_mem_types_list[0].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
36355 + *(void **)&radeon_mem_types_list[1].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
36356 + pax_close_kernel();
36357 #ifdef CONFIG_SWIOTLB
36358 - if (swiotlb_nr_tbl()) {
36359 - sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
36360 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
36361 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
36362 - radeon_mem_types_list[i].driver_features = 0;
36363 - radeon_mem_types_list[i++].data = NULL;
36364 - }
36365 + if (swiotlb_nr_tbl())
36366 + i++;
36367 #endif
36368 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
36369
36370 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
36371 index 55880d5..9e95342 100644
36372 --- a/drivers/gpu/drm/radeon/rs690.c
36373 +++ b/drivers/gpu/drm/radeon/rs690.c
36374 @@ -327,9 +327,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
36375 if (rdev->pm.max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
36376 rdev->pm.sideport_bandwidth.full)
36377 rdev->pm.max_bandwidth = rdev->pm.sideport_bandwidth;
36378 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
36379 + read_delay_latency.full = dfixed_const(800 * 1000);
36380 read_delay_latency.full = dfixed_div(read_delay_latency,
36381 rdev->pm.igp_sideport_mclk);
36382 + a.full = dfixed_const(370);
36383 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
36384 } else {
36385 if (rdev->pm.max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
36386 rdev->pm.k8_bandwidth.full)
36387 diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
36388 index dbc2def..0a9f710 100644
36389 --- a/drivers/gpu/drm/ttm/ttm_memory.c
36390 +++ b/drivers/gpu/drm/ttm/ttm_memory.c
36391 @@ -264,7 +264,7 @@ static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob,
36392 zone->glob = glob;
36393 glob->zone_kernel = zone;
36394 ret = kobject_init_and_add(
36395 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
36396 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
36397 if (unlikely(ret != 0)) {
36398 kobject_put(&zone->kobj);
36399 return ret;
36400 @@ -347,7 +347,7 @@ static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob,
36401 zone->glob = glob;
36402 glob->zone_dma32 = zone;
36403 ret = kobject_init_and_add(
36404 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
36405 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
36406 if (unlikely(ret != 0)) {
36407 kobject_put(&zone->kobj);
36408 return ret;
36409 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
36410 index bd2a3b4..122d9ad 100644
36411 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
36412 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
36413 @@ -394,9 +394,9 @@ static int ttm_pool_get_num_unused_pages(void)
36414 static int ttm_pool_mm_shrink(struct shrinker *shrink,
36415 struct shrink_control *sc)
36416 {
36417 - static atomic_t start_pool = ATOMIC_INIT(0);
36418 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
36419 unsigned i;
36420 - unsigned pool_offset = atomic_add_return(1, &start_pool);
36421 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
36422 struct ttm_page_pool *pool;
36423 int shrink_pages = sc->nr_to_scan;
36424
36425 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
36426 index dc0c065..58a0782 100644
36427 --- a/drivers/gpu/drm/udl/udl_fb.c
36428 +++ b/drivers/gpu/drm/udl/udl_fb.c
36429 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
36430 fb_deferred_io_cleanup(info);
36431 kfree(info->fbdefio);
36432 info->fbdefio = NULL;
36433 - info->fbops->fb_mmap = udl_fb_mmap;
36434 }
36435
36436 pr_warn("released /dev/fb%d user=%d count=%d\n",
36437 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
36438 index 893a650..6190d3b 100644
36439 --- a/drivers/gpu/drm/via/via_drv.h
36440 +++ b/drivers/gpu/drm/via/via_drv.h
36441 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
36442 typedef uint32_t maskarray_t[5];
36443
36444 typedef struct drm_via_irq {
36445 - atomic_t irq_received;
36446 + atomic_unchecked_t irq_received;
36447 uint32_t pending_mask;
36448 uint32_t enable_mask;
36449 wait_queue_head_t irq_queue;
36450 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
36451 struct timeval last_vblank;
36452 int last_vblank_valid;
36453 unsigned usec_per_vblank;
36454 - atomic_t vbl_received;
36455 + atomic_unchecked_t vbl_received;
36456 drm_via_state_t hc_state;
36457 char pci_buf[VIA_PCI_BUF_SIZE];
36458 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
36459 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
36460 index ac98964..5dbf512 100644
36461 --- a/drivers/gpu/drm/via/via_irq.c
36462 +++ b/drivers/gpu/drm/via/via_irq.c
36463 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
36464 if (crtc != 0)
36465 return 0;
36466
36467 - return atomic_read(&dev_priv->vbl_received);
36468 + return atomic_read_unchecked(&dev_priv->vbl_received);
36469 }
36470
36471 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36472 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36473
36474 status = VIA_READ(VIA_REG_INTERRUPT);
36475 if (status & VIA_IRQ_VBLANK_PENDING) {
36476 - atomic_inc(&dev_priv->vbl_received);
36477 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
36478 + atomic_inc_unchecked(&dev_priv->vbl_received);
36479 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
36480 do_gettimeofday(&cur_vblank);
36481 if (dev_priv->last_vblank_valid) {
36482 dev_priv->usec_per_vblank =
36483 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36484 dev_priv->last_vblank = cur_vblank;
36485 dev_priv->last_vblank_valid = 1;
36486 }
36487 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
36488 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
36489 DRM_DEBUG("US per vblank is: %u\n",
36490 dev_priv->usec_per_vblank);
36491 }
36492 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
36493
36494 for (i = 0; i < dev_priv->num_irqs; ++i) {
36495 if (status & cur_irq->pending_mask) {
36496 - atomic_inc(&cur_irq->irq_received);
36497 + atomic_inc_unchecked(&cur_irq->irq_received);
36498 DRM_WAKEUP(&cur_irq->irq_queue);
36499 handled = 1;
36500 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
36501 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
36502 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
36503 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
36504 masks[irq][4]));
36505 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
36506 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
36507 } else {
36508 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
36509 (((cur_irq_sequence =
36510 - atomic_read(&cur_irq->irq_received)) -
36511 + atomic_read_unchecked(&cur_irq->irq_received)) -
36512 *sequence) <= (1 << 23)));
36513 }
36514 *sequence = cur_irq_sequence;
36515 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
36516 }
36517
36518 for (i = 0; i < dev_priv->num_irqs; ++i) {
36519 - atomic_set(&cur_irq->irq_received, 0);
36520 + atomic_set_unchecked(&cur_irq->irq_received, 0);
36521 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
36522 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
36523 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
36524 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
36525 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
36526 case VIA_IRQ_RELATIVE:
36527 irqwait->request.sequence +=
36528 - atomic_read(&cur_irq->irq_received);
36529 + atomic_read_unchecked(&cur_irq->irq_received);
36530 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
36531 case VIA_IRQ_ABSOLUTE:
36532 break;
36533 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36534 index 13aeda7..4a952d1 100644
36535 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36536 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
36537 @@ -290,7 +290,7 @@ struct vmw_private {
36538 * Fencing and IRQs.
36539 */
36540
36541 - atomic_t marker_seq;
36542 + atomic_unchecked_t marker_seq;
36543 wait_queue_head_t fence_queue;
36544 wait_queue_head_t fifo_queue;
36545 int fence_queue_waiters; /* Protected by hw_mutex */
36546 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36547 index 3eb1486..0a47ee9 100644
36548 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36549 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
36550 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
36551 (unsigned int) min,
36552 (unsigned int) fifo->capabilities);
36553
36554 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
36555 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
36556 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
36557 vmw_marker_queue_init(&fifo->marker_queue);
36558 return vmw_fifo_send_fence(dev_priv, &dummy);
36559 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
36560 if (reserveable)
36561 iowrite32(bytes, fifo_mem +
36562 SVGA_FIFO_RESERVED);
36563 - return fifo_mem + (next_cmd >> 2);
36564 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
36565 } else {
36566 need_bounce = true;
36567 }
36568 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36569
36570 fm = vmw_fifo_reserve(dev_priv, bytes);
36571 if (unlikely(fm == NULL)) {
36572 - *seqno = atomic_read(&dev_priv->marker_seq);
36573 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36574 ret = -ENOMEM;
36575 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
36576 false, 3*HZ);
36577 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
36578 }
36579
36580 do {
36581 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
36582 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
36583 } while (*seqno == 0);
36584
36585 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
36586 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
36587 index c509d40..3b640c3 100644
36588 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
36589 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
36590 @@ -138,7 +138,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
36591 int ret;
36592
36593 num_clips = arg->num_clips;
36594 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
36595 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
36596
36597 if (unlikely(num_clips == 0))
36598 return 0;
36599 @@ -222,7 +222,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
36600 int ret;
36601
36602 num_clips = arg->num_clips;
36603 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
36604 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
36605
36606 if (unlikely(num_clips == 0))
36607 return 0;
36608 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36609 index 4640adb..e1384ed 100644
36610 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36611 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
36612 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
36613 * emitted. Then the fence is stale and signaled.
36614 */
36615
36616 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
36617 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
36618 > VMW_FENCE_WRAP);
36619
36620 return ret;
36621 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
36622
36623 if (fifo_idle)
36624 down_read(&fifo_state->rwsem);
36625 - signal_seq = atomic_read(&dev_priv->marker_seq);
36626 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
36627 ret = 0;
36628
36629 for (;;) {
36630 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36631 index 8a8725c2..afed796 100644
36632 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36633 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
36634 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
36635 while (!vmw_lag_lt(queue, us)) {
36636 spin_lock(&queue->lock);
36637 if (list_empty(&queue->head))
36638 - seqno = atomic_read(&dev_priv->marker_seq);
36639 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
36640 else {
36641 marker = list_first_entry(&queue->head,
36642 struct vmw_marker, head);
36643 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
36644 index 264f550..f92dd8c 100644
36645 --- a/drivers/hid/hid-core.c
36646 +++ b/drivers/hid/hid-core.c
36647 @@ -2269,7 +2269,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
36648
36649 int hid_add_device(struct hid_device *hdev)
36650 {
36651 - static atomic_t id = ATOMIC_INIT(0);
36652 + static atomic_unchecked_t id = ATOMIC_INIT(0);
36653 int ret;
36654
36655 if (WARN_ON(hdev->status & HID_STAT_ADDED))
36656 @@ -2303,7 +2303,7 @@ int hid_add_device(struct hid_device *hdev)
36657 /* XXX hack, any other cleaner solution after the driver core
36658 * is converted to allow more than 20 bytes as the device name? */
36659 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
36660 - hdev->vendor, hdev->product, atomic_inc_return(&id));
36661 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
36662
36663 hid_debug_register(hdev, dev_name(&hdev->dev));
36664 ret = device_add(&hdev->dev);
36665 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
36666 index 90124ff..3761764 100644
36667 --- a/drivers/hid/hid-wiimote-debug.c
36668 +++ b/drivers/hid/hid-wiimote-debug.c
36669 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
36670 else if (size == 0)
36671 return -EIO;
36672
36673 - if (copy_to_user(u, buf, size))
36674 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
36675 return -EFAULT;
36676
36677 *off += size;
36678 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
36679 index 0b122f8..b1d8160 100644
36680 --- a/drivers/hv/channel.c
36681 +++ b/drivers/hv/channel.c
36682 @@ -394,8 +394,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
36683 int ret = 0;
36684 int t;
36685
36686 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
36687 - atomic_inc(&vmbus_connection.next_gpadl_handle);
36688 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
36689 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
36690
36691 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
36692 if (ret)
36693 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
36694 index ae49237..380d4c9 100644
36695 --- a/drivers/hv/hv.c
36696 +++ b/drivers/hv/hv.c
36697 @@ -112,7 +112,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
36698 u64 output_address = (output) ? virt_to_phys(output) : 0;
36699 u32 output_address_hi = output_address >> 32;
36700 u32 output_address_lo = output_address & 0xFFFFFFFF;
36701 - void *hypercall_page = hv_context.hypercall_page;
36702 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
36703
36704 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
36705 "=a"(hv_status_lo) : "d" (control_hi),
36706 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
36707 index 12f2f9e..679603c 100644
36708 --- a/drivers/hv/hyperv_vmbus.h
36709 +++ b/drivers/hv/hyperv_vmbus.h
36710 @@ -591,7 +591,7 @@ enum vmbus_connect_state {
36711 struct vmbus_connection {
36712 enum vmbus_connect_state conn_state;
36713
36714 - atomic_t next_gpadl_handle;
36715 + atomic_unchecked_t next_gpadl_handle;
36716
36717 /*
36718 * Represents channel interrupts. Each bit position represents a
36719 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
36720 index bf421e0..ce2c897 100644
36721 --- a/drivers/hv/vmbus_drv.c
36722 +++ b/drivers/hv/vmbus_drv.c
36723 @@ -668,10 +668,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
36724 {
36725 int ret = 0;
36726
36727 - static atomic_t device_num = ATOMIC_INIT(0);
36728 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
36729
36730 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
36731 - atomic_inc_return(&device_num));
36732 + atomic_inc_return_unchecked(&device_num));
36733
36734 child_device_obj->device.bus = &hv_bus;
36735 child_device_obj->device.parent = &hv_acpi_dev->dev;
36736 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
36737 index 6351aba..dc4aaf4 100644
36738 --- a/drivers/hwmon/acpi_power_meter.c
36739 +++ b/drivers/hwmon/acpi_power_meter.c
36740 @@ -117,7 +117,7 @@ struct sensor_template {
36741 struct device_attribute *devattr,
36742 const char *buf, size_t count);
36743 int index;
36744 -};
36745 +} __do_const;
36746
36747 /* Averaging interval */
36748 static int update_avg_interval(struct acpi_power_meter_resource *resource)
36749 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
36750 struct sensor_template *attrs)
36751 {
36752 struct device *dev = &resource->acpi_dev->dev;
36753 - struct sensor_device_attribute *sensors =
36754 + sensor_device_attribute_no_const *sensors =
36755 &resource->sensors[resource->num_sensors];
36756 int res = 0;
36757
36758 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
36759 index 62c2e32..8f2859a 100644
36760 --- a/drivers/hwmon/applesmc.c
36761 +++ b/drivers/hwmon/applesmc.c
36762 @@ -1084,7 +1084,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
36763 {
36764 struct applesmc_node_group *grp;
36765 struct applesmc_dev_attr *node;
36766 - struct attribute *attr;
36767 + attribute_no_const *attr;
36768 int ret, i;
36769
36770 for (grp = groups; grp->format; grp++) {
36771 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
36772 index b25c643..a13460d 100644
36773 --- a/drivers/hwmon/asus_atk0110.c
36774 +++ b/drivers/hwmon/asus_atk0110.c
36775 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
36776 struct atk_sensor_data {
36777 struct list_head list;
36778 struct atk_data *data;
36779 - struct device_attribute label_attr;
36780 - struct device_attribute input_attr;
36781 - struct device_attribute limit1_attr;
36782 - struct device_attribute limit2_attr;
36783 + device_attribute_no_const label_attr;
36784 + device_attribute_no_const input_attr;
36785 + device_attribute_no_const limit1_attr;
36786 + device_attribute_no_const limit2_attr;
36787 char label_attr_name[ATTR_NAME_SIZE];
36788 char input_attr_name[ATTR_NAME_SIZE];
36789 char limit1_attr_name[ATTR_NAME_SIZE];
36790 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
36791 static struct device_attribute atk_name_attr =
36792 __ATTR(name, 0444, atk_name_show, NULL);
36793
36794 -static void atk_init_attribute(struct device_attribute *attr, char *name,
36795 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
36796 sysfs_show_func show)
36797 {
36798 sysfs_attr_init(&attr->attr);
36799 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
36800 index 658ce3a..0d0c2f3 100644
36801 --- a/drivers/hwmon/coretemp.c
36802 +++ b/drivers/hwmon/coretemp.c
36803 @@ -790,7 +790,7 @@ static int __cpuinit coretemp_cpu_callback(struct notifier_block *nfb,
36804 return NOTIFY_OK;
36805 }
36806
36807 -static struct notifier_block coretemp_cpu_notifier __refdata = {
36808 +static struct notifier_block coretemp_cpu_notifier = {
36809 .notifier_call = coretemp_cpu_callback,
36810 };
36811
36812 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
36813 index 1429f6e..ee03d59 100644
36814 --- a/drivers/hwmon/ibmaem.c
36815 +++ b/drivers/hwmon/ibmaem.c
36816 @@ -926,7 +926,7 @@ static int aem_register_sensors(struct aem_data *data,
36817 struct aem_rw_sensor_template *rw)
36818 {
36819 struct device *dev = &data->pdev->dev;
36820 - struct sensor_device_attribute *sensors = data->sensors;
36821 + sensor_device_attribute_no_const *sensors = data->sensors;
36822 int err;
36823
36824 /* Set up read-only sensors */
36825 diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
36826 index 52b77af..aed1ddf 100644
36827 --- a/drivers/hwmon/iio_hwmon.c
36828 +++ b/drivers/hwmon/iio_hwmon.c
36829 @@ -73,7 +73,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
36830 {
36831 struct device *dev = &pdev->dev;
36832 struct iio_hwmon_state *st;
36833 - struct sensor_device_attribute *a;
36834 + sensor_device_attribute_no_const *a;
36835 int ret, i;
36836 int in_i = 1, temp_i = 1, curr_i = 1;
36837 enum iio_chan_type type;
36838 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
36839 index 9add6092..ee7ba3f 100644
36840 --- a/drivers/hwmon/pmbus/pmbus_core.c
36841 +++ b/drivers/hwmon/pmbus/pmbus_core.c
36842 @@ -781,7 +781,7 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
36843 return 0;
36844 }
36845
36846 -static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
36847 +static void pmbus_dev_attr_init(device_attribute_no_const *dev_attr,
36848 const char *name,
36849 umode_t mode,
36850 ssize_t (*show)(struct device *dev,
36851 @@ -798,7 +798,7 @@ static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
36852 dev_attr->store = store;
36853 }
36854
36855 -static void pmbus_attr_init(struct sensor_device_attribute *a,
36856 +static void pmbus_attr_init(sensor_device_attribute_no_const *a,
36857 const char *name,
36858 umode_t mode,
36859 ssize_t (*show)(struct device *dev,
36860 @@ -820,7 +820,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
36861 u16 reg, u8 mask)
36862 {
36863 struct pmbus_boolean *boolean;
36864 - struct sensor_device_attribute *a;
36865 + sensor_device_attribute_no_const *a;
36866
36867 boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL);
36868 if (!boolean)
36869 @@ -845,7 +845,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
36870 bool update, bool readonly)
36871 {
36872 struct pmbus_sensor *sensor;
36873 - struct device_attribute *a;
36874 + device_attribute_no_const *a;
36875
36876 sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL);
36877 if (!sensor)
36878 @@ -876,7 +876,7 @@ static int pmbus_add_label(struct pmbus_data *data,
36879 const char *lstring, int index)
36880 {
36881 struct pmbus_label *label;
36882 - struct device_attribute *a;
36883 + device_attribute_no_const *a;
36884
36885 label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL);
36886 if (!label)
36887 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
36888 index 2507f90..1645765 100644
36889 --- a/drivers/hwmon/sht15.c
36890 +++ b/drivers/hwmon/sht15.c
36891 @@ -169,7 +169,7 @@ struct sht15_data {
36892 int supply_uv;
36893 bool supply_uv_valid;
36894 struct work_struct update_supply_work;
36895 - atomic_t interrupt_handled;
36896 + atomic_unchecked_t interrupt_handled;
36897 };
36898
36899 /**
36900 @@ -542,13 +542,13 @@ static int sht15_measurement(struct sht15_data *data,
36901 ret = gpio_direction_input(data->pdata->gpio_data);
36902 if (ret)
36903 return ret;
36904 - atomic_set(&data->interrupt_handled, 0);
36905 + atomic_set_unchecked(&data->interrupt_handled, 0);
36906
36907 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36908 if (gpio_get_value(data->pdata->gpio_data) == 0) {
36909 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
36910 /* Only relevant if the interrupt hasn't occurred. */
36911 - if (!atomic_read(&data->interrupt_handled))
36912 + if (!atomic_read_unchecked(&data->interrupt_handled))
36913 schedule_work(&data->read_work);
36914 }
36915 ret = wait_event_timeout(data->wait_queue,
36916 @@ -820,7 +820,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
36917
36918 /* First disable the interrupt */
36919 disable_irq_nosync(irq);
36920 - atomic_inc(&data->interrupt_handled);
36921 + atomic_inc_unchecked(&data->interrupt_handled);
36922 /* Then schedule a reading work struct */
36923 if (data->state != SHT15_READING_NOTHING)
36924 schedule_work(&data->read_work);
36925 @@ -842,11 +842,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
36926 * If not, then start the interrupt again - care here as could
36927 * have gone low in meantime so verify it hasn't!
36928 */
36929 - atomic_set(&data->interrupt_handled, 0);
36930 + atomic_set_unchecked(&data->interrupt_handled, 0);
36931 enable_irq(gpio_to_irq(data->pdata->gpio_data));
36932 /* If still not occurred or another handler was scheduled */
36933 if (gpio_get_value(data->pdata->gpio_data)
36934 - || atomic_read(&data->interrupt_handled))
36935 + || atomic_read_unchecked(&data->interrupt_handled))
36936 return;
36937 }
36938
36939 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
36940 index 76f157b..9c0db1b 100644
36941 --- a/drivers/hwmon/via-cputemp.c
36942 +++ b/drivers/hwmon/via-cputemp.c
36943 @@ -296,7 +296,7 @@ static int __cpuinit via_cputemp_cpu_callback(struct notifier_block *nfb,
36944 return NOTIFY_OK;
36945 }
36946
36947 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
36948 +static struct notifier_block via_cputemp_cpu_notifier = {
36949 .notifier_call = via_cputemp_cpu_callback,
36950 };
36951
36952 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
36953 index 07f01ac..d79ad3d 100644
36954 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
36955 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
36956 @@ -43,7 +43,7 @@
36957 extern struct i2c_adapter amd756_smbus;
36958
36959 static struct i2c_adapter *s4882_adapter;
36960 -static struct i2c_algorithm *s4882_algo;
36961 +static i2c_algorithm_no_const *s4882_algo;
36962
36963 /* Wrapper access functions for multiplexed SMBus */
36964 static DEFINE_MUTEX(amd756_lock);
36965 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
36966 index 2ca268d..c6acbdf 100644
36967 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
36968 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
36969 @@ -41,7 +41,7 @@
36970 extern struct i2c_adapter *nforce2_smbus;
36971
36972 static struct i2c_adapter *s4985_adapter;
36973 -static struct i2c_algorithm *s4985_algo;
36974 +static i2c_algorithm_no_const *s4985_algo;
36975
36976 /* Wrapper access functions for multiplexed SMBus */
36977 static DEFINE_MUTEX(nforce2_lock);
36978 diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
36979 index c3ccdea..5b3dc1a 100644
36980 --- a/drivers/i2c/i2c-dev.c
36981 +++ b/drivers/i2c/i2c-dev.c
36982 @@ -271,7 +271,7 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client,
36983 break;
36984 }
36985
36986 - data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
36987 + data_ptrs[i] = (u8 __force_user *)rdwr_pa[i].buf;
36988 rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len);
36989 if (IS_ERR(rdwr_pa[i].buf)) {
36990 res = PTR_ERR(rdwr_pa[i].buf);
36991 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
36992 index 2ff6204..218c16e 100644
36993 --- a/drivers/ide/ide-cd.c
36994 +++ b/drivers/ide/ide-cd.c
36995 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
36996 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
36997 if ((unsigned long)buf & alignment
36998 || blk_rq_bytes(rq) & q->dma_pad_mask
36999 - || object_is_on_stack(buf))
37000 + || object_starts_on_stack(buf))
37001 drive->dma = 0;
37002 }
37003 }
37004 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
37005 index e145931..08bfc59 100644
37006 --- a/drivers/iio/industrialio-core.c
37007 +++ b/drivers/iio/industrialio-core.c
37008 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
37009 }
37010
37011 static
37012 -int __iio_device_attr_init(struct device_attribute *dev_attr,
37013 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
37014 const char *postfix,
37015 struct iio_chan_spec const *chan,
37016 ssize_t (*readfunc)(struct device *dev,
37017 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
37018 index 784b97c..c9ceadf 100644
37019 --- a/drivers/infiniband/core/cm.c
37020 +++ b/drivers/infiniband/core/cm.c
37021 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
37022
37023 struct cm_counter_group {
37024 struct kobject obj;
37025 - atomic_long_t counter[CM_ATTR_COUNT];
37026 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
37027 };
37028
37029 struct cm_counter_attribute {
37030 @@ -1395,7 +1395,7 @@ static void cm_dup_req_handler(struct cm_work *work,
37031 struct ib_mad_send_buf *msg = NULL;
37032 int ret;
37033
37034 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37035 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37036 counter[CM_REQ_COUNTER]);
37037
37038 /* Quick state check to discard duplicate REQs. */
37039 @@ -1779,7 +1779,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
37040 if (!cm_id_priv)
37041 return;
37042
37043 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37044 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37045 counter[CM_REP_COUNTER]);
37046 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
37047 if (ret)
37048 @@ -1946,7 +1946,7 @@ static int cm_rtu_handler(struct cm_work *work)
37049 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
37050 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
37051 spin_unlock_irq(&cm_id_priv->lock);
37052 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37053 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37054 counter[CM_RTU_COUNTER]);
37055 goto out;
37056 }
37057 @@ -2129,7 +2129,7 @@ static int cm_dreq_handler(struct cm_work *work)
37058 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
37059 dreq_msg->local_comm_id);
37060 if (!cm_id_priv) {
37061 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37062 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37063 counter[CM_DREQ_COUNTER]);
37064 cm_issue_drep(work->port, work->mad_recv_wc);
37065 return -EINVAL;
37066 @@ -2154,7 +2154,7 @@ static int cm_dreq_handler(struct cm_work *work)
37067 case IB_CM_MRA_REP_RCVD:
37068 break;
37069 case IB_CM_TIMEWAIT:
37070 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37071 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37072 counter[CM_DREQ_COUNTER]);
37073 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
37074 goto unlock;
37075 @@ -2168,7 +2168,7 @@ static int cm_dreq_handler(struct cm_work *work)
37076 cm_free_msg(msg);
37077 goto deref;
37078 case IB_CM_DREQ_RCVD:
37079 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37080 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37081 counter[CM_DREQ_COUNTER]);
37082 goto unlock;
37083 default:
37084 @@ -2535,7 +2535,7 @@ static int cm_mra_handler(struct cm_work *work)
37085 ib_modify_mad(cm_id_priv->av.port->mad_agent,
37086 cm_id_priv->msg, timeout)) {
37087 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
37088 - atomic_long_inc(&work->port->
37089 + atomic_long_inc_unchecked(&work->port->
37090 counter_group[CM_RECV_DUPLICATES].
37091 counter[CM_MRA_COUNTER]);
37092 goto out;
37093 @@ -2544,7 +2544,7 @@ static int cm_mra_handler(struct cm_work *work)
37094 break;
37095 case IB_CM_MRA_REQ_RCVD:
37096 case IB_CM_MRA_REP_RCVD:
37097 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37098 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37099 counter[CM_MRA_COUNTER]);
37100 /* fall through */
37101 default:
37102 @@ -2706,7 +2706,7 @@ static int cm_lap_handler(struct cm_work *work)
37103 case IB_CM_LAP_IDLE:
37104 break;
37105 case IB_CM_MRA_LAP_SENT:
37106 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37107 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37108 counter[CM_LAP_COUNTER]);
37109 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
37110 goto unlock;
37111 @@ -2722,7 +2722,7 @@ static int cm_lap_handler(struct cm_work *work)
37112 cm_free_msg(msg);
37113 goto deref;
37114 case IB_CM_LAP_RCVD:
37115 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37116 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37117 counter[CM_LAP_COUNTER]);
37118 goto unlock;
37119 default:
37120 @@ -3006,7 +3006,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
37121 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
37122 if (cur_cm_id_priv) {
37123 spin_unlock_irq(&cm.lock);
37124 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
37125 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
37126 counter[CM_SIDR_REQ_COUNTER]);
37127 goto out; /* Duplicate message. */
37128 }
37129 @@ -3218,10 +3218,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
37130 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
37131 msg->retries = 1;
37132
37133 - atomic_long_add(1 + msg->retries,
37134 + atomic_long_add_unchecked(1 + msg->retries,
37135 &port->counter_group[CM_XMIT].counter[attr_index]);
37136 if (msg->retries)
37137 - atomic_long_add(msg->retries,
37138 + atomic_long_add_unchecked(msg->retries,
37139 &port->counter_group[CM_XMIT_RETRIES].
37140 counter[attr_index]);
37141
37142 @@ -3431,7 +3431,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
37143 }
37144
37145 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
37146 - atomic_long_inc(&port->counter_group[CM_RECV].
37147 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
37148 counter[attr_id - CM_ATTR_ID_OFFSET]);
37149
37150 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
37151 @@ -3636,7 +3636,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
37152 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
37153
37154 return sprintf(buf, "%ld\n",
37155 - atomic_long_read(&group->counter[cm_attr->index]));
37156 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
37157 }
37158
37159 static const struct sysfs_ops cm_counter_ops = {
37160 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
37161 index 9f5ad7c..588cd84 100644
37162 --- a/drivers/infiniband/core/fmr_pool.c
37163 +++ b/drivers/infiniband/core/fmr_pool.c
37164 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
37165
37166 struct task_struct *thread;
37167
37168 - atomic_t req_ser;
37169 - atomic_t flush_ser;
37170 + atomic_unchecked_t req_ser;
37171 + atomic_unchecked_t flush_ser;
37172
37173 wait_queue_head_t force_wait;
37174 };
37175 @@ -179,10 +179,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
37176 struct ib_fmr_pool *pool = pool_ptr;
37177
37178 do {
37179 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
37180 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
37181 ib_fmr_batch_release(pool);
37182
37183 - atomic_inc(&pool->flush_ser);
37184 + atomic_inc_unchecked(&pool->flush_ser);
37185 wake_up_interruptible(&pool->force_wait);
37186
37187 if (pool->flush_function)
37188 @@ -190,7 +190,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
37189 }
37190
37191 set_current_state(TASK_INTERRUPTIBLE);
37192 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
37193 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
37194 !kthread_should_stop())
37195 schedule();
37196 __set_current_state(TASK_RUNNING);
37197 @@ -282,8 +282,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
37198 pool->dirty_watermark = params->dirty_watermark;
37199 pool->dirty_len = 0;
37200 spin_lock_init(&pool->pool_lock);
37201 - atomic_set(&pool->req_ser, 0);
37202 - atomic_set(&pool->flush_ser, 0);
37203 + atomic_set_unchecked(&pool->req_ser, 0);
37204 + atomic_set_unchecked(&pool->flush_ser, 0);
37205 init_waitqueue_head(&pool->force_wait);
37206
37207 pool->thread = kthread_run(ib_fmr_cleanup_thread,
37208 @@ -411,11 +411,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
37209 }
37210 spin_unlock_irq(&pool->pool_lock);
37211
37212 - serial = atomic_inc_return(&pool->req_ser);
37213 + serial = atomic_inc_return_unchecked(&pool->req_ser);
37214 wake_up_process(pool->thread);
37215
37216 if (wait_event_interruptible(pool->force_wait,
37217 - atomic_read(&pool->flush_ser) - serial >= 0))
37218 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
37219 return -EINTR;
37220
37221 return 0;
37222 @@ -525,7 +525,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
37223 } else {
37224 list_add_tail(&fmr->list, &pool->dirty_list);
37225 if (++pool->dirty_len >= pool->dirty_watermark) {
37226 - atomic_inc(&pool->req_ser);
37227 + atomic_inc_unchecked(&pool->req_ser);
37228 wake_up_process(pool->thread);
37229 }
37230 }
37231 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
37232 index 4cb8eb2..146bf60 100644
37233 --- a/drivers/infiniband/hw/cxgb4/mem.c
37234 +++ b/drivers/infiniband/hw/cxgb4/mem.c
37235 @@ -249,7 +249,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
37236 int err;
37237 struct fw_ri_tpte tpt;
37238 u32 stag_idx;
37239 - static atomic_t key;
37240 + static atomic_unchecked_t key;
37241
37242 if (c4iw_fatal_error(rdev))
37243 return -EIO;
37244 @@ -266,7 +266,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
37245 if (rdev->stats.stag.cur > rdev->stats.stag.max)
37246 rdev->stats.stag.max = rdev->stats.stag.cur;
37247 mutex_unlock(&rdev->stats.lock);
37248 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
37249 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
37250 }
37251 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
37252 __func__, stag_state, type, pdid, stag_idx);
37253 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
37254 index 79b3dbc..96e5fcc 100644
37255 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
37256 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
37257 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
37258 struct ib_atomic_eth *ateth;
37259 struct ipath_ack_entry *e;
37260 u64 vaddr;
37261 - atomic64_t *maddr;
37262 + atomic64_unchecked_t *maddr;
37263 u64 sdata;
37264 u32 rkey;
37265 u8 next;
37266 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
37267 IB_ACCESS_REMOTE_ATOMIC)))
37268 goto nack_acc_unlck;
37269 /* Perform atomic OP and save result. */
37270 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
37271 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
37272 sdata = be64_to_cpu(ateth->swap_data);
37273 e = &qp->s_ack_queue[qp->r_head_ack_queue];
37274 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
37275 - (u64) atomic64_add_return(sdata, maddr) - sdata :
37276 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
37277 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
37278 be64_to_cpu(ateth->compare_data),
37279 sdata);
37280 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
37281 index 1f95bba..9530f87 100644
37282 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
37283 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
37284 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
37285 unsigned long flags;
37286 struct ib_wc wc;
37287 u64 sdata;
37288 - atomic64_t *maddr;
37289 + atomic64_unchecked_t *maddr;
37290 enum ib_wc_status send_status;
37291
37292 /*
37293 @@ -382,11 +382,11 @@ again:
37294 IB_ACCESS_REMOTE_ATOMIC)))
37295 goto acc_err;
37296 /* Perform atomic OP and save result. */
37297 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
37298 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
37299 sdata = wqe->wr.wr.atomic.compare_add;
37300 *(u64 *) sqp->s_sge.sge.vaddr =
37301 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
37302 - (u64) atomic64_add_return(sdata, maddr) - sdata :
37303 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
37304 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
37305 sdata, wqe->wr.wr.atomic.swap);
37306 goto send_comp;
37307 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
37308 index 9d3e5c1..d9afe4a 100644
37309 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
37310 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
37311 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
37312 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
37313 }
37314
37315 -int mthca_QUERY_FW(struct mthca_dev *dev)
37316 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
37317 {
37318 struct mthca_mailbox *mailbox;
37319 u32 *outbox;
37320 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
37321 index ed9a989..e0c5871 100644
37322 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
37323 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
37324 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
37325 return key;
37326 }
37327
37328 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
37329 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
37330 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
37331 {
37332 struct mthca_mailbox *mailbox;
37333 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
37334 index 4291410..d2ab1fb 100644
37335 --- a/drivers/infiniband/hw/nes/nes.c
37336 +++ b/drivers/infiniband/hw/nes/nes.c
37337 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
37338 LIST_HEAD(nes_adapter_list);
37339 static LIST_HEAD(nes_dev_list);
37340
37341 -atomic_t qps_destroyed;
37342 +atomic_unchecked_t qps_destroyed;
37343
37344 static unsigned int ee_flsh_adapter;
37345 static unsigned int sysfs_nonidx_addr;
37346 @@ -269,7 +269,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
37347 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
37348 struct nes_adapter *nesadapter = nesdev->nesadapter;
37349
37350 - atomic_inc(&qps_destroyed);
37351 + atomic_inc_unchecked(&qps_destroyed);
37352
37353 /* Free the control structures */
37354
37355 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
37356 index 33cc589..3bd6538 100644
37357 --- a/drivers/infiniband/hw/nes/nes.h
37358 +++ b/drivers/infiniband/hw/nes/nes.h
37359 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
37360 extern unsigned int wqm_quanta;
37361 extern struct list_head nes_adapter_list;
37362
37363 -extern atomic_t cm_connects;
37364 -extern atomic_t cm_accepts;
37365 -extern atomic_t cm_disconnects;
37366 -extern atomic_t cm_closes;
37367 -extern atomic_t cm_connecteds;
37368 -extern atomic_t cm_connect_reqs;
37369 -extern atomic_t cm_rejects;
37370 -extern atomic_t mod_qp_timouts;
37371 -extern atomic_t qps_created;
37372 -extern atomic_t qps_destroyed;
37373 -extern atomic_t sw_qps_destroyed;
37374 +extern atomic_unchecked_t cm_connects;
37375 +extern atomic_unchecked_t cm_accepts;
37376 +extern atomic_unchecked_t cm_disconnects;
37377 +extern atomic_unchecked_t cm_closes;
37378 +extern atomic_unchecked_t cm_connecteds;
37379 +extern atomic_unchecked_t cm_connect_reqs;
37380 +extern atomic_unchecked_t cm_rejects;
37381 +extern atomic_unchecked_t mod_qp_timouts;
37382 +extern atomic_unchecked_t qps_created;
37383 +extern atomic_unchecked_t qps_destroyed;
37384 +extern atomic_unchecked_t sw_qps_destroyed;
37385 extern u32 mh_detected;
37386 extern u32 mh_pauses_sent;
37387 extern u32 cm_packets_sent;
37388 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
37389 extern u32 cm_packets_received;
37390 extern u32 cm_packets_dropped;
37391 extern u32 cm_packets_retrans;
37392 -extern atomic_t cm_listens_created;
37393 -extern atomic_t cm_listens_destroyed;
37394 +extern atomic_unchecked_t cm_listens_created;
37395 +extern atomic_unchecked_t cm_listens_destroyed;
37396 extern u32 cm_backlog_drops;
37397 -extern atomic_t cm_loopbacks;
37398 -extern atomic_t cm_nodes_created;
37399 -extern atomic_t cm_nodes_destroyed;
37400 -extern atomic_t cm_accel_dropped_pkts;
37401 -extern atomic_t cm_resets_recvd;
37402 -extern atomic_t pau_qps_created;
37403 -extern atomic_t pau_qps_destroyed;
37404 +extern atomic_unchecked_t cm_loopbacks;
37405 +extern atomic_unchecked_t cm_nodes_created;
37406 +extern atomic_unchecked_t cm_nodes_destroyed;
37407 +extern atomic_unchecked_t cm_accel_dropped_pkts;
37408 +extern atomic_unchecked_t cm_resets_recvd;
37409 +extern atomic_unchecked_t pau_qps_created;
37410 +extern atomic_unchecked_t pau_qps_destroyed;
37411
37412 extern u32 int_mod_timer_init;
37413 extern u32 int_mod_cq_depth_256;
37414 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
37415 index 24b9f1a..00fd004 100644
37416 --- a/drivers/infiniband/hw/nes/nes_cm.c
37417 +++ b/drivers/infiniband/hw/nes/nes_cm.c
37418 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
37419 u32 cm_packets_retrans;
37420 u32 cm_packets_created;
37421 u32 cm_packets_received;
37422 -atomic_t cm_listens_created;
37423 -atomic_t cm_listens_destroyed;
37424 +atomic_unchecked_t cm_listens_created;
37425 +atomic_unchecked_t cm_listens_destroyed;
37426 u32 cm_backlog_drops;
37427 -atomic_t cm_loopbacks;
37428 -atomic_t cm_nodes_created;
37429 -atomic_t cm_nodes_destroyed;
37430 -atomic_t cm_accel_dropped_pkts;
37431 -atomic_t cm_resets_recvd;
37432 +atomic_unchecked_t cm_loopbacks;
37433 +atomic_unchecked_t cm_nodes_created;
37434 +atomic_unchecked_t cm_nodes_destroyed;
37435 +atomic_unchecked_t cm_accel_dropped_pkts;
37436 +atomic_unchecked_t cm_resets_recvd;
37437
37438 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
37439 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
37440 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
37441
37442 static struct nes_cm_core *g_cm_core;
37443
37444 -atomic_t cm_connects;
37445 -atomic_t cm_accepts;
37446 -atomic_t cm_disconnects;
37447 -atomic_t cm_closes;
37448 -atomic_t cm_connecteds;
37449 -atomic_t cm_connect_reqs;
37450 -atomic_t cm_rejects;
37451 +atomic_unchecked_t cm_connects;
37452 +atomic_unchecked_t cm_accepts;
37453 +atomic_unchecked_t cm_disconnects;
37454 +atomic_unchecked_t cm_closes;
37455 +atomic_unchecked_t cm_connecteds;
37456 +atomic_unchecked_t cm_connect_reqs;
37457 +atomic_unchecked_t cm_rejects;
37458
37459 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
37460 {
37461 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
37462 kfree(listener);
37463 listener = NULL;
37464 ret = 0;
37465 - atomic_inc(&cm_listens_destroyed);
37466 + atomic_inc_unchecked(&cm_listens_destroyed);
37467 } else {
37468 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
37469 }
37470 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
37471 cm_node->rem_mac);
37472
37473 add_hte_node(cm_core, cm_node);
37474 - atomic_inc(&cm_nodes_created);
37475 + atomic_inc_unchecked(&cm_nodes_created);
37476
37477 return cm_node;
37478 }
37479 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
37480 }
37481
37482 atomic_dec(&cm_core->node_cnt);
37483 - atomic_inc(&cm_nodes_destroyed);
37484 + atomic_inc_unchecked(&cm_nodes_destroyed);
37485 nesqp = cm_node->nesqp;
37486 if (nesqp) {
37487 nesqp->cm_node = NULL;
37488 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
37489
37490 static void drop_packet(struct sk_buff *skb)
37491 {
37492 - atomic_inc(&cm_accel_dropped_pkts);
37493 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
37494 dev_kfree_skb_any(skb);
37495 }
37496
37497 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
37498 {
37499
37500 int reset = 0; /* whether to send reset in case of err.. */
37501 - atomic_inc(&cm_resets_recvd);
37502 + atomic_inc_unchecked(&cm_resets_recvd);
37503 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
37504 " refcnt=%d\n", cm_node, cm_node->state,
37505 atomic_read(&cm_node->ref_count));
37506 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
37507 rem_ref_cm_node(cm_node->cm_core, cm_node);
37508 return NULL;
37509 }
37510 - atomic_inc(&cm_loopbacks);
37511 + atomic_inc_unchecked(&cm_loopbacks);
37512 loopbackremotenode->loopbackpartner = cm_node;
37513 loopbackremotenode->tcp_cntxt.rcv_wscale =
37514 NES_CM_DEFAULT_RCV_WND_SCALE;
37515 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
37516 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
37517 else {
37518 rem_ref_cm_node(cm_core, cm_node);
37519 - atomic_inc(&cm_accel_dropped_pkts);
37520 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
37521 dev_kfree_skb_any(skb);
37522 }
37523 break;
37524 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
37525
37526 if ((cm_id) && (cm_id->event_handler)) {
37527 if (issue_disconn) {
37528 - atomic_inc(&cm_disconnects);
37529 + atomic_inc_unchecked(&cm_disconnects);
37530 cm_event.event = IW_CM_EVENT_DISCONNECT;
37531 cm_event.status = disconn_status;
37532 cm_event.local_addr = cm_id->local_addr;
37533 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
37534 }
37535
37536 if (issue_close) {
37537 - atomic_inc(&cm_closes);
37538 + atomic_inc_unchecked(&cm_closes);
37539 nes_disconnect(nesqp, 1);
37540
37541 cm_id->provider_data = nesqp;
37542 @@ -3033,7 +3033,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
37543
37544 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
37545 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
37546 - atomic_inc(&cm_accepts);
37547 + atomic_inc_unchecked(&cm_accepts);
37548
37549 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
37550 netdev_refcnt_read(nesvnic->netdev));
37551 @@ -3228,7 +3228,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
37552 struct nes_cm_core *cm_core;
37553 u8 *start_buff;
37554
37555 - atomic_inc(&cm_rejects);
37556 + atomic_inc_unchecked(&cm_rejects);
37557 cm_node = (struct nes_cm_node *)cm_id->provider_data;
37558 loopback = cm_node->loopbackpartner;
37559 cm_core = cm_node->cm_core;
37560 @@ -3288,7 +3288,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
37561 ntohl(cm_id->local_addr.sin_addr.s_addr),
37562 ntohs(cm_id->local_addr.sin_port));
37563
37564 - atomic_inc(&cm_connects);
37565 + atomic_inc_unchecked(&cm_connects);
37566 nesqp->active_conn = 1;
37567
37568 /* cache the cm_id in the qp */
37569 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
37570 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
37571 return err;
37572 }
37573 - atomic_inc(&cm_listens_created);
37574 + atomic_inc_unchecked(&cm_listens_created);
37575 }
37576
37577 cm_id->add_ref(cm_id);
37578 @@ -3499,7 +3499,7 @@ static void cm_event_connected(struct nes_cm_event *event)
37579
37580 if (nesqp->destroyed)
37581 return;
37582 - atomic_inc(&cm_connecteds);
37583 + atomic_inc_unchecked(&cm_connecteds);
37584 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
37585 " local port 0x%04X. jiffies = %lu.\n",
37586 nesqp->hwqp.qp_id,
37587 @@ -3679,7 +3679,7 @@ static void cm_event_reset(struct nes_cm_event *event)
37588
37589 cm_id->add_ref(cm_id);
37590 ret = cm_id->event_handler(cm_id, &cm_event);
37591 - atomic_inc(&cm_closes);
37592 + atomic_inc_unchecked(&cm_closes);
37593 cm_event.event = IW_CM_EVENT_CLOSE;
37594 cm_event.status = 0;
37595 cm_event.provider_data = cm_id->provider_data;
37596 @@ -3715,7 +3715,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
37597 return;
37598 cm_id = cm_node->cm_id;
37599
37600 - atomic_inc(&cm_connect_reqs);
37601 + atomic_inc_unchecked(&cm_connect_reqs);
37602 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
37603 cm_node, cm_id, jiffies);
37604
37605 @@ -3755,7 +3755,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
37606 return;
37607 cm_id = cm_node->cm_id;
37608
37609 - atomic_inc(&cm_connect_reqs);
37610 + atomic_inc_unchecked(&cm_connect_reqs);
37611 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
37612 cm_node, cm_id, jiffies);
37613
37614 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
37615 index 4166452..fc952c3 100644
37616 --- a/drivers/infiniband/hw/nes/nes_mgt.c
37617 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
37618 @@ -40,8 +40,8 @@
37619 #include "nes.h"
37620 #include "nes_mgt.h"
37621
37622 -atomic_t pau_qps_created;
37623 -atomic_t pau_qps_destroyed;
37624 +atomic_unchecked_t pau_qps_created;
37625 +atomic_unchecked_t pau_qps_destroyed;
37626
37627 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
37628 {
37629 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
37630 {
37631 struct sk_buff *skb;
37632 unsigned long flags;
37633 - atomic_inc(&pau_qps_destroyed);
37634 + atomic_inc_unchecked(&pau_qps_destroyed);
37635
37636 /* Free packets that have not yet been forwarded */
37637 /* Lock is acquired by skb_dequeue when removing the skb */
37638 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
37639 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
37640 skb_queue_head_init(&nesqp->pau_list);
37641 spin_lock_init(&nesqp->pau_lock);
37642 - atomic_inc(&pau_qps_created);
37643 + atomic_inc_unchecked(&pau_qps_created);
37644 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
37645 }
37646
37647 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
37648 index 49eb511..a774366 100644
37649 --- a/drivers/infiniband/hw/nes/nes_nic.c
37650 +++ b/drivers/infiniband/hw/nes/nes_nic.c
37651 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
37652 target_stat_values[++index] = mh_detected;
37653 target_stat_values[++index] = mh_pauses_sent;
37654 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
37655 - target_stat_values[++index] = atomic_read(&cm_connects);
37656 - target_stat_values[++index] = atomic_read(&cm_accepts);
37657 - target_stat_values[++index] = atomic_read(&cm_disconnects);
37658 - target_stat_values[++index] = atomic_read(&cm_connecteds);
37659 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
37660 - target_stat_values[++index] = atomic_read(&cm_rejects);
37661 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
37662 - target_stat_values[++index] = atomic_read(&qps_created);
37663 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
37664 - target_stat_values[++index] = atomic_read(&qps_destroyed);
37665 - target_stat_values[++index] = atomic_read(&cm_closes);
37666 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
37667 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
37668 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
37669 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
37670 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
37671 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
37672 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
37673 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
37674 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
37675 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
37676 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
37677 target_stat_values[++index] = cm_packets_sent;
37678 target_stat_values[++index] = cm_packets_bounced;
37679 target_stat_values[++index] = cm_packets_created;
37680 target_stat_values[++index] = cm_packets_received;
37681 target_stat_values[++index] = cm_packets_dropped;
37682 target_stat_values[++index] = cm_packets_retrans;
37683 - target_stat_values[++index] = atomic_read(&cm_listens_created);
37684 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
37685 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
37686 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
37687 target_stat_values[++index] = cm_backlog_drops;
37688 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
37689 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
37690 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
37691 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
37692 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
37693 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
37694 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
37695 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
37696 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
37697 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
37698 target_stat_values[++index] = nesadapter->free_4kpbl;
37699 target_stat_values[++index] = nesadapter->free_256pbl;
37700 target_stat_values[++index] = int_mod_timer_init;
37701 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
37702 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
37703 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
37704 - target_stat_values[++index] = atomic_read(&pau_qps_created);
37705 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
37706 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
37707 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
37708 }
37709
37710 /**
37711 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
37712 index 8f67fe2..8960859 100644
37713 --- a/drivers/infiniband/hw/nes/nes_verbs.c
37714 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
37715 @@ -46,9 +46,9 @@
37716
37717 #include <rdma/ib_umem.h>
37718
37719 -atomic_t mod_qp_timouts;
37720 -atomic_t qps_created;
37721 -atomic_t sw_qps_destroyed;
37722 +atomic_unchecked_t mod_qp_timouts;
37723 +atomic_unchecked_t qps_created;
37724 +atomic_unchecked_t sw_qps_destroyed;
37725
37726 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
37727
37728 @@ -1134,7 +1134,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
37729 if (init_attr->create_flags)
37730 return ERR_PTR(-EINVAL);
37731
37732 - atomic_inc(&qps_created);
37733 + atomic_inc_unchecked(&qps_created);
37734 switch (init_attr->qp_type) {
37735 case IB_QPT_RC:
37736 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
37737 @@ -1465,7 +1465,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
37738 struct iw_cm_event cm_event;
37739 int ret = 0;
37740
37741 - atomic_inc(&sw_qps_destroyed);
37742 + atomic_inc_unchecked(&sw_qps_destroyed);
37743 nesqp->destroyed = 1;
37744
37745 /* Blow away the connection if it exists. */
37746 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
37747 index 4d11575..3e890e5 100644
37748 --- a/drivers/infiniband/hw/qib/qib.h
37749 +++ b/drivers/infiniband/hw/qib/qib.h
37750 @@ -51,6 +51,7 @@
37751 #include <linux/completion.h>
37752 #include <linux/kref.h>
37753 #include <linux/sched.h>
37754 +#include <linux/slab.h>
37755
37756 #include "qib_common.h"
37757 #include "qib_verbs.h"
37758 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
37759 index da739d9..da1c7f4 100644
37760 --- a/drivers/input/gameport/gameport.c
37761 +++ b/drivers/input/gameport/gameport.c
37762 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
37763 */
37764 static void gameport_init_port(struct gameport *gameport)
37765 {
37766 - static atomic_t gameport_no = ATOMIC_INIT(0);
37767 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
37768
37769 __module_get(THIS_MODULE);
37770
37771 mutex_init(&gameport->drv_mutex);
37772 device_initialize(&gameport->dev);
37773 dev_set_name(&gameport->dev, "gameport%lu",
37774 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
37775 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
37776 gameport->dev.bus = &gameport_bus;
37777 gameport->dev.release = gameport_release_port;
37778 if (gameport->parent)
37779 diff --git a/drivers/input/input.c b/drivers/input/input.c
37780 index c044699..174d71a 100644
37781 --- a/drivers/input/input.c
37782 +++ b/drivers/input/input.c
37783 @@ -2019,7 +2019,7 @@ static void devm_input_device_unregister(struct device *dev, void *res)
37784 */
37785 int input_register_device(struct input_dev *dev)
37786 {
37787 - static atomic_t input_no = ATOMIC_INIT(0);
37788 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
37789 struct input_devres *devres = NULL;
37790 struct input_handler *handler;
37791 unsigned int packet_size;
37792 @@ -2074,7 +2074,7 @@ int input_register_device(struct input_dev *dev)
37793 dev->setkeycode = input_default_setkeycode;
37794
37795 dev_set_name(&dev->dev, "input%ld",
37796 - (unsigned long) atomic_inc_return(&input_no) - 1);
37797 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
37798
37799 error = device_add(&dev->dev);
37800 if (error)
37801 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
37802 index 04c69af..5f92d00 100644
37803 --- a/drivers/input/joystick/sidewinder.c
37804 +++ b/drivers/input/joystick/sidewinder.c
37805 @@ -30,6 +30,7 @@
37806 #include <linux/kernel.h>
37807 #include <linux/module.h>
37808 #include <linux/slab.h>
37809 +#include <linux/sched.h>
37810 #include <linux/init.h>
37811 #include <linux/input.h>
37812 #include <linux/gameport.h>
37813 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
37814 index fa061d4..4a6957c 100644
37815 --- a/drivers/input/joystick/xpad.c
37816 +++ b/drivers/input/joystick/xpad.c
37817 @@ -735,7 +735,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
37818
37819 static int xpad_led_probe(struct usb_xpad *xpad)
37820 {
37821 - static atomic_t led_seq = ATOMIC_INIT(0);
37822 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
37823 long led_no;
37824 struct xpad_led *led;
37825 struct led_classdev *led_cdev;
37826 @@ -748,7 +748,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
37827 if (!led)
37828 return -ENOMEM;
37829
37830 - led_no = (long)atomic_inc_return(&led_seq) - 1;
37831 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
37832
37833 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
37834 led->xpad = xpad;
37835 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
37836 index 2f0b39d..7370f13 100644
37837 --- a/drivers/input/mouse/psmouse.h
37838 +++ b/drivers/input/mouse/psmouse.h
37839 @@ -116,7 +116,7 @@ struct psmouse_attribute {
37840 ssize_t (*set)(struct psmouse *psmouse, void *data,
37841 const char *buf, size_t count);
37842 bool protect;
37843 -};
37844 +} __do_const;
37845 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
37846
37847 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
37848 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
37849 index 4c842c3..590b0bf 100644
37850 --- a/drivers/input/mousedev.c
37851 +++ b/drivers/input/mousedev.c
37852 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
37853
37854 spin_unlock_irq(&client->packet_lock);
37855
37856 - if (copy_to_user(buffer, data, count))
37857 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
37858 return -EFAULT;
37859
37860 return count;
37861 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
37862 index 25fc597..558bf3b3 100644
37863 --- a/drivers/input/serio/serio.c
37864 +++ b/drivers/input/serio/serio.c
37865 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
37866 */
37867 static void serio_init_port(struct serio *serio)
37868 {
37869 - static atomic_t serio_no = ATOMIC_INIT(0);
37870 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
37871
37872 __module_get(THIS_MODULE);
37873
37874 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
37875 mutex_init(&serio->drv_mutex);
37876 device_initialize(&serio->dev);
37877 dev_set_name(&serio->dev, "serio%ld",
37878 - (long)atomic_inc_return(&serio_no) - 1);
37879 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
37880 serio->dev.bus = &serio_bus;
37881 serio->dev.release = serio_release_port;
37882 serio->dev.groups = serio_device_attr_groups;
37883 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
37884 index d8f98b1..f62a640 100644
37885 --- a/drivers/iommu/iommu.c
37886 +++ b/drivers/iommu/iommu.c
37887 @@ -583,7 +583,7 @@ static struct notifier_block iommu_bus_nb = {
37888 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
37889 {
37890 bus_register_notifier(bus, &iommu_bus_nb);
37891 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
37892 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
37893 }
37894
37895 /**
37896 diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
37897 index dcfea4e..f4226b2 100644
37898 --- a/drivers/iommu/irq_remapping.c
37899 +++ b/drivers/iommu/irq_remapping.c
37900 @@ -354,7 +354,7 @@ int setup_hpet_msi_remapped(unsigned int irq, unsigned int id)
37901 void panic_if_irq_remap(const char *msg)
37902 {
37903 if (irq_remapping_enabled)
37904 - panic(msg);
37905 + panic("%s", msg);
37906 }
37907
37908 static void ir_ack_apic_edge(struct irq_data *data)
37909 @@ -375,10 +375,12 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
37910
37911 void irq_remap_modify_chip_defaults(struct irq_chip *chip)
37912 {
37913 - chip->irq_print_chip = ir_print_prefix;
37914 - chip->irq_ack = ir_ack_apic_edge;
37915 - chip->irq_eoi = ir_ack_apic_level;
37916 - chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
37917 + pax_open_kernel();
37918 + *(void **)&chip->irq_print_chip = ir_print_prefix;
37919 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
37920 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
37921 + *(void **)&chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
37922 + pax_close_kernel();
37923 }
37924
37925 bool setup_remapped_irq(int irq, struct irq_cfg *cfg, struct irq_chip *chip)
37926 diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
37927 index 19ceaa6..3625818 100644
37928 --- a/drivers/irqchip/irq-gic.c
37929 +++ b/drivers/irqchip/irq-gic.c
37930 @@ -84,7 +84,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
37931 * Supported arch specific GIC irq extension.
37932 * Default make them NULL.
37933 */
37934 -struct irq_chip gic_arch_extn = {
37935 +irq_chip_no_const gic_arch_extn = {
37936 .irq_eoi = NULL,
37937 .irq_mask = NULL,
37938 .irq_unmask = NULL,
37939 @@ -333,7 +333,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
37940 chained_irq_exit(chip, desc);
37941 }
37942
37943 -static struct irq_chip gic_chip = {
37944 +static irq_chip_no_const gic_chip __read_only = {
37945 .name = "GIC",
37946 .irq_mask = gic_mask_irq,
37947 .irq_unmask = gic_unmask_irq,
37948 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
37949 index ac6f72b..81150f2 100644
37950 --- a/drivers/isdn/capi/capi.c
37951 +++ b/drivers/isdn/capi/capi.c
37952 @@ -81,8 +81,8 @@ struct capiminor {
37953
37954 struct capi20_appl *ap;
37955 u32 ncci;
37956 - atomic_t datahandle;
37957 - atomic_t msgid;
37958 + atomic_unchecked_t datahandle;
37959 + atomic_unchecked_t msgid;
37960
37961 struct tty_port port;
37962 int ttyinstop;
37963 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
37964 capimsg_setu16(s, 2, mp->ap->applid);
37965 capimsg_setu8 (s, 4, CAPI_DATA_B3);
37966 capimsg_setu8 (s, 5, CAPI_RESP);
37967 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
37968 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
37969 capimsg_setu32(s, 8, mp->ncci);
37970 capimsg_setu16(s, 12, datahandle);
37971 }
37972 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
37973 mp->outbytes -= len;
37974 spin_unlock_bh(&mp->outlock);
37975
37976 - datahandle = atomic_inc_return(&mp->datahandle);
37977 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
37978 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
37979 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
37980 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
37981 capimsg_setu16(skb->data, 2, mp->ap->applid);
37982 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
37983 capimsg_setu8 (skb->data, 5, CAPI_REQ);
37984 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
37985 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
37986 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
37987 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
37988 capimsg_setu16(skb->data, 16, len); /* Data length */
37989 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
37990 index 600c79b..3752bab 100644
37991 --- a/drivers/isdn/gigaset/interface.c
37992 +++ b/drivers/isdn/gigaset/interface.c
37993 @@ -130,9 +130,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
37994 }
37995 tty->driver_data = cs;
37996
37997 - ++cs->port.count;
37998 + atomic_inc(&cs->port.count);
37999
38000 - if (cs->port.count == 1) {
38001 + if (atomic_read(&cs->port.count) == 1) {
38002 tty_port_tty_set(&cs->port, tty);
38003 cs->port.low_latency = 1;
38004 }
38005 @@ -156,9 +156,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
38006
38007 if (!cs->connected)
38008 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
38009 - else if (!cs->port.count)
38010 + else if (!atomic_read(&cs->port.count))
38011 dev_warn(cs->dev, "%s: device not opened\n", __func__);
38012 - else if (!--cs->port.count)
38013 + else if (!atomic_dec_return(&cs->port.count))
38014 tty_port_tty_set(&cs->port, NULL);
38015
38016 mutex_unlock(&cs->mutex);
38017 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
38018 index 4d9b195..455075c 100644
38019 --- a/drivers/isdn/hardware/avm/b1.c
38020 +++ b/drivers/isdn/hardware/avm/b1.c
38021 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
38022 }
38023 if (left) {
38024 if (t4file->user) {
38025 - if (copy_from_user(buf, dp, left))
38026 + if (left > sizeof buf || copy_from_user(buf, dp, left))
38027 return -EFAULT;
38028 } else {
38029 memcpy(buf, dp, left);
38030 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
38031 }
38032 if (left) {
38033 if (config->user) {
38034 - if (copy_from_user(buf, dp, left))
38035 + if (left > sizeof buf || copy_from_user(buf, dp, left))
38036 return -EFAULT;
38037 } else {
38038 memcpy(buf, dp, left);
38039 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
38040 index 3c5f249..5fac4d0 100644
38041 --- a/drivers/isdn/i4l/isdn_tty.c
38042 +++ b/drivers/isdn/i4l/isdn_tty.c
38043 @@ -1508,9 +1508,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
38044
38045 #ifdef ISDN_DEBUG_MODEM_OPEN
38046 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
38047 - port->count);
38048 + atomic_read(&port->count));
38049 #endif
38050 - port->count++;
38051 + atomic_inc(&port->count);
38052 port->tty = tty;
38053 /*
38054 * Start up serial port
38055 @@ -1554,7 +1554,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
38056 #endif
38057 return;
38058 }
38059 - if ((tty->count == 1) && (port->count != 1)) {
38060 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
38061 /*
38062 * Uh, oh. tty->count is 1, which means that the tty
38063 * structure will be freed. Info->count should always
38064 @@ -1563,15 +1563,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
38065 * serial port won't be shutdown.
38066 */
38067 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
38068 - "info->count is %d\n", port->count);
38069 - port->count = 1;
38070 + "info->count is %d\n", atomic_read(&port->count));
38071 + atomic_set(&port->count, 1);
38072 }
38073 - if (--port->count < 0) {
38074 + if (atomic_dec_return(&port->count) < 0) {
38075 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
38076 - info->line, port->count);
38077 - port->count = 0;
38078 + info->line, atomic_read(&port->count));
38079 + atomic_set(&port->count, 0);
38080 }
38081 - if (port->count) {
38082 + if (atomic_read(&port->count)) {
38083 #ifdef ISDN_DEBUG_MODEM_OPEN
38084 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
38085 #endif
38086 @@ -1625,7 +1625,7 @@ isdn_tty_hangup(struct tty_struct *tty)
38087 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
38088 return;
38089 isdn_tty_shutdown(info);
38090 - port->count = 0;
38091 + atomic_set(&port->count, 0);
38092 port->flags &= ~ASYNC_NORMAL_ACTIVE;
38093 port->tty = NULL;
38094 wake_up_interruptible(&port->open_wait);
38095 @@ -1970,7 +1970,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
38096 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
38097 modem_info *info = &dev->mdm.info[i];
38098
38099 - if (info->port.count == 0)
38100 + if (atomic_read(&info->port.count) == 0)
38101 continue;
38102 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
38103 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
38104 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
38105 index e74df7c..03a03ba 100644
38106 --- a/drivers/isdn/icn/icn.c
38107 +++ b/drivers/isdn/icn/icn.c
38108 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
38109 if (count > len)
38110 count = len;
38111 if (user) {
38112 - if (copy_from_user(msg, buf, count))
38113 + if (count > sizeof msg || copy_from_user(msg, buf, count))
38114 return -EFAULT;
38115 } else
38116 memcpy(msg, buf, count);
38117 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
38118 index 6a8405d..0bd1c7e 100644
38119 --- a/drivers/leds/leds-clevo-mail.c
38120 +++ b/drivers/leds/leds-clevo-mail.c
38121 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
38122 * detected as working, but in reality it is not) as low as
38123 * possible.
38124 */
38125 -static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
38126 +static const struct dmi_system_id __initconst clevo_mail_led_dmi_table[] = {
38127 {
38128 .callback = clevo_mail_led_dmi_callback,
38129 .ident = "Clevo D410J",
38130 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
38131 index 64e204e..c6bf189 100644
38132 --- a/drivers/leds/leds-ss4200.c
38133 +++ b/drivers/leds/leds-ss4200.c
38134 @@ -91,7 +91,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
38135 * detected as working, but in reality it is not) as low as
38136 * possible.
38137 */
38138 -static struct dmi_system_id __initdata nas_led_whitelist[] = {
38139 +static const struct dmi_system_id __initconst nas_led_whitelist[] = {
38140 {
38141 .callback = ss4200_led_dmi_callback,
38142 .ident = "Intel SS4200-E",
38143 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
38144 index 0bf1e4e..b4bf44e 100644
38145 --- a/drivers/lguest/core.c
38146 +++ b/drivers/lguest/core.c
38147 @@ -97,9 +97,17 @@ static __init int map_switcher(void)
38148 * The end address needs +1 because __get_vm_area allocates an
38149 * extra guard page, so we need space for that.
38150 */
38151 +
38152 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
38153 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
38154 + VM_ALLOC | VM_KERNEXEC, switcher_addr, switcher_addr
38155 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
38156 +#else
38157 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
38158 VM_ALLOC, switcher_addr, switcher_addr
38159 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
38160 +#endif
38161 +
38162 if (!switcher_vma) {
38163 err = -ENOMEM;
38164 printk("lguest: could not map switcher pages high\n");
38165 @@ -124,7 +132,7 @@ static __init int map_switcher(void)
38166 * Now the Switcher is mapped at the right address, we can't fail!
38167 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
38168 */
38169 - memcpy(switcher_vma->addr, start_switcher_text,
38170 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
38171 end_switcher_text - start_switcher_text);
38172
38173 printk(KERN_INFO "lguest: mapped switcher at %p\n",
38174 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
38175 index 5b9ac32..2ef4f26 100644
38176 --- a/drivers/lguest/page_tables.c
38177 +++ b/drivers/lguest/page_tables.c
38178 @@ -559,7 +559,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
38179 /*:*/
38180
38181 #ifdef CONFIG_X86_PAE
38182 -static void release_pmd(pmd_t *spmd)
38183 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
38184 {
38185 /* If the entry's not present, there's nothing to release. */
38186 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
38187 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
38188 index f0a3347..f6608b2 100644
38189 --- a/drivers/lguest/x86/core.c
38190 +++ b/drivers/lguest/x86/core.c
38191 @@ -59,7 +59,7 @@ static struct {
38192 /* Offset from where switcher.S was compiled to where we've copied it */
38193 static unsigned long switcher_offset(void)
38194 {
38195 - return switcher_addr - (unsigned long)start_switcher_text;
38196 + return switcher_addr - (unsigned long)ktla_ktva(start_switcher_text);
38197 }
38198
38199 /* This cpu's struct lguest_pages (after the Switcher text page) */
38200 @@ -99,7 +99,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
38201 * These copies are pretty cheap, so we do them unconditionally: */
38202 /* Save the current Host top-level page directory.
38203 */
38204 +
38205 +#ifdef CONFIG_PAX_PER_CPU_PGD
38206 + pages->state.host_cr3 = read_cr3();
38207 +#else
38208 pages->state.host_cr3 = __pa(current->mm->pgd);
38209 +#endif
38210 +
38211 /*
38212 * Set up the Guest's page tables to see this CPU's pages (and no
38213 * other CPU's pages).
38214 @@ -475,7 +481,7 @@ void __init lguest_arch_host_init(void)
38215 * compiled-in switcher code and the high-mapped copy we just made.
38216 */
38217 for (i = 0; i < IDT_ENTRIES; i++)
38218 - default_idt_entries[i] += switcher_offset();
38219 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
38220
38221 /*
38222 * Set up the Switcher's per-cpu areas.
38223 @@ -558,7 +564,7 @@ void __init lguest_arch_host_init(void)
38224 * it will be undisturbed when we switch. To change %cs and jump we
38225 * need this structure to feed to Intel's "lcall" instruction.
38226 */
38227 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
38228 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
38229 lguest_entry.segment = LGUEST_CS;
38230
38231 /*
38232 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
38233 index 40634b0..4f5855e 100644
38234 --- a/drivers/lguest/x86/switcher_32.S
38235 +++ b/drivers/lguest/x86/switcher_32.S
38236 @@ -87,6 +87,7 @@
38237 #include <asm/page.h>
38238 #include <asm/segment.h>
38239 #include <asm/lguest.h>
38240 +#include <asm/processor-flags.h>
38241
38242 // We mark the start of the code to copy
38243 // It's placed in .text tho it's never run here
38244 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
38245 // Changes type when we load it: damn Intel!
38246 // For after we switch over our page tables
38247 // That entry will be read-only: we'd crash.
38248 +
38249 +#ifdef CONFIG_PAX_KERNEXEC
38250 + mov %cr0, %edx
38251 + xor $X86_CR0_WP, %edx
38252 + mov %edx, %cr0
38253 +#endif
38254 +
38255 movl $(GDT_ENTRY_TSS*8), %edx
38256 ltr %dx
38257
38258 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
38259 // Let's clear it again for our return.
38260 // The GDT descriptor of the Host
38261 // Points to the table after two "size" bytes
38262 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
38263 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
38264 // Clear "used" from type field (byte 5, bit 2)
38265 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
38266 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
38267 +
38268 +#ifdef CONFIG_PAX_KERNEXEC
38269 + mov %cr0, %eax
38270 + xor $X86_CR0_WP, %eax
38271 + mov %eax, %cr0
38272 +#endif
38273
38274 // Once our page table's switched, the Guest is live!
38275 // The Host fades as we run this final step.
38276 @@ -295,13 +309,12 @@ deliver_to_host:
38277 // I consulted gcc, and it gave
38278 // These instructions, which I gladly credit:
38279 leal (%edx,%ebx,8), %eax
38280 - movzwl (%eax),%edx
38281 - movl 4(%eax), %eax
38282 - xorw %ax, %ax
38283 - orl %eax, %edx
38284 + movl 4(%eax), %edx
38285 + movw (%eax), %dx
38286 // Now the address of the handler's in %edx
38287 // We call it now: its "iret" drops us home.
38288 - jmp *%edx
38289 + ljmp $__KERNEL_CS, $1f
38290 +1: jmp *%edx
38291
38292 // Every interrupt can come to us here
38293 // But we must truly tell each apart.
38294 diff --git a/drivers/md/bcache/closure.h b/drivers/md/bcache/closure.h
38295 index 0003992..854bbce 100644
38296 --- a/drivers/md/bcache/closure.h
38297 +++ b/drivers/md/bcache/closure.h
38298 @@ -622,7 +622,7 @@ static inline void closure_wake_up(struct closure_waitlist *list)
38299 static inline void set_closure_fn(struct closure *cl, closure_fn *fn,
38300 struct workqueue_struct *wq)
38301 {
38302 - BUG_ON(object_is_on_stack(cl));
38303 + BUG_ON(object_starts_on_stack(cl));
38304 closure_set_ip(cl);
38305 cl->fn = fn;
38306 cl->wq = wq;
38307 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
38308 index 5a2c754..0fa55db 100644
38309 --- a/drivers/md/bitmap.c
38310 +++ b/drivers/md/bitmap.c
38311 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
38312 chunk_kb ? "KB" : "B");
38313 if (bitmap->storage.file) {
38314 seq_printf(seq, ", file: ");
38315 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
38316 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
38317 }
38318
38319 seq_printf(seq, "\n");
38320 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
38321 index aa04f02..2a1309e 100644
38322 --- a/drivers/md/dm-ioctl.c
38323 +++ b/drivers/md/dm-ioctl.c
38324 @@ -1694,7 +1694,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
38325 cmd == DM_LIST_VERSIONS_CMD)
38326 return 0;
38327
38328 - if ((cmd == DM_DEV_CREATE_CMD)) {
38329 + if (cmd == DM_DEV_CREATE_CMD) {
38330 if (!*param->name) {
38331 DMWARN("name not supplied when creating device");
38332 return -EINVAL;
38333 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
38334 index 699b5be..eac0a15 100644
38335 --- a/drivers/md/dm-raid1.c
38336 +++ b/drivers/md/dm-raid1.c
38337 @@ -40,7 +40,7 @@ enum dm_raid1_error {
38338
38339 struct mirror {
38340 struct mirror_set *ms;
38341 - atomic_t error_count;
38342 + atomic_unchecked_t error_count;
38343 unsigned long error_type;
38344 struct dm_dev *dev;
38345 sector_t offset;
38346 @@ -186,7 +186,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
38347 struct mirror *m;
38348
38349 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
38350 - if (!atomic_read(&m->error_count))
38351 + if (!atomic_read_unchecked(&m->error_count))
38352 return m;
38353
38354 return NULL;
38355 @@ -218,7 +218,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
38356 * simple way to tell if a device has encountered
38357 * errors.
38358 */
38359 - atomic_inc(&m->error_count);
38360 + atomic_inc_unchecked(&m->error_count);
38361
38362 if (test_and_set_bit(error_type, &m->error_type))
38363 return;
38364 @@ -409,7 +409,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
38365 struct mirror *m = get_default_mirror(ms);
38366
38367 do {
38368 - if (likely(!atomic_read(&m->error_count)))
38369 + if (likely(!atomic_read_unchecked(&m->error_count)))
38370 return m;
38371
38372 if (m-- == ms->mirror)
38373 @@ -423,7 +423,7 @@ static int default_ok(struct mirror *m)
38374 {
38375 struct mirror *default_mirror = get_default_mirror(m->ms);
38376
38377 - return !atomic_read(&default_mirror->error_count);
38378 + return !atomic_read_unchecked(&default_mirror->error_count);
38379 }
38380
38381 static int mirror_available(struct mirror_set *ms, struct bio *bio)
38382 @@ -560,7 +560,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
38383 */
38384 if (likely(region_in_sync(ms, region, 1)))
38385 m = choose_mirror(ms, bio->bi_sector);
38386 - else if (m && atomic_read(&m->error_count))
38387 + else if (m && atomic_read_unchecked(&m->error_count))
38388 m = NULL;
38389
38390 if (likely(m))
38391 @@ -927,7 +927,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
38392 }
38393
38394 ms->mirror[mirror].ms = ms;
38395 - atomic_set(&(ms->mirror[mirror].error_count), 0);
38396 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
38397 ms->mirror[mirror].error_type = 0;
38398 ms->mirror[mirror].offset = offset;
38399
38400 @@ -1340,7 +1340,7 @@ static void mirror_resume(struct dm_target *ti)
38401 */
38402 static char device_status_char(struct mirror *m)
38403 {
38404 - if (!atomic_read(&(m->error_count)))
38405 + if (!atomic_read_unchecked(&(m->error_count)))
38406 return 'A';
38407
38408 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
38409 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
38410 index d907ca6..cfb8384 100644
38411 --- a/drivers/md/dm-stripe.c
38412 +++ b/drivers/md/dm-stripe.c
38413 @@ -20,7 +20,7 @@ struct stripe {
38414 struct dm_dev *dev;
38415 sector_t physical_start;
38416
38417 - atomic_t error_count;
38418 + atomic_unchecked_t error_count;
38419 };
38420
38421 struct stripe_c {
38422 @@ -185,7 +185,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
38423 kfree(sc);
38424 return r;
38425 }
38426 - atomic_set(&(sc->stripe[i].error_count), 0);
38427 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
38428 }
38429
38430 ti->private = sc;
38431 @@ -326,7 +326,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
38432 DMEMIT("%d ", sc->stripes);
38433 for (i = 0; i < sc->stripes; i++) {
38434 DMEMIT("%s ", sc->stripe[i].dev->name);
38435 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
38436 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
38437 'D' : 'A';
38438 }
38439 buffer[i] = '\0';
38440 @@ -371,8 +371,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
38441 */
38442 for (i = 0; i < sc->stripes; i++)
38443 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
38444 - atomic_inc(&(sc->stripe[i].error_count));
38445 - if (atomic_read(&(sc->stripe[i].error_count)) <
38446 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
38447 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
38448 DM_IO_ERROR_THRESHOLD)
38449 schedule_work(&sc->trigger_event);
38450 }
38451 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
38452 index 1ff252a..ee384c1 100644
38453 --- a/drivers/md/dm-table.c
38454 +++ b/drivers/md/dm-table.c
38455 @@ -389,7 +389,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
38456 if (!dev_size)
38457 return 0;
38458
38459 - if ((start >= dev_size) || (start + len > dev_size)) {
38460 + if ((start >= dev_size) || (len > dev_size - start)) {
38461 DMWARN("%s: %s too small for target: "
38462 "start=%llu, len=%llu, dev_size=%llu",
38463 dm_device_name(ti->table->md), bdevname(bdev, b),
38464 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
38465 index 60bce43..9b997d0 100644
38466 --- a/drivers/md/dm-thin-metadata.c
38467 +++ b/drivers/md/dm-thin-metadata.c
38468 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
38469 {
38470 pmd->info.tm = pmd->tm;
38471 pmd->info.levels = 2;
38472 - pmd->info.value_type.context = pmd->data_sm;
38473 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
38474 pmd->info.value_type.size = sizeof(__le64);
38475 pmd->info.value_type.inc = data_block_inc;
38476 pmd->info.value_type.dec = data_block_dec;
38477 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
38478
38479 pmd->bl_info.tm = pmd->tm;
38480 pmd->bl_info.levels = 1;
38481 - pmd->bl_info.value_type.context = pmd->data_sm;
38482 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
38483 pmd->bl_info.value_type.size = sizeof(__le64);
38484 pmd->bl_info.value_type.inc = data_block_inc;
38485 pmd->bl_info.value_type.dec = data_block_dec;
38486 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
38487 index d5370a9..8761bbc 100644
38488 --- a/drivers/md/dm.c
38489 +++ b/drivers/md/dm.c
38490 @@ -169,9 +169,9 @@ struct mapped_device {
38491 /*
38492 * Event handling.
38493 */
38494 - atomic_t event_nr;
38495 + atomic_unchecked_t event_nr;
38496 wait_queue_head_t eventq;
38497 - atomic_t uevent_seq;
38498 + atomic_unchecked_t uevent_seq;
38499 struct list_head uevent_list;
38500 spinlock_t uevent_lock; /* Protect access to uevent_list */
38501
38502 @@ -1877,8 +1877,8 @@ static struct mapped_device *alloc_dev(int minor)
38503 rwlock_init(&md->map_lock);
38504 atomic_set(&md->holders, 1);
38505 atomic_set(&md->open_count, 0);
38506 - atomic_set(&md->event_nr, 0);
38507 - atomic_set(&md->uevent_seq, 0);
38508 + atomic_set_unchecked(&md->event_nr, 0);
38509 + atomic_set_unchecked(&md->uevent_seq, 0);
38510 INIT_LIST_HEAD(&md->uevent_list);
38511 spin_lock_init(&md->uevent_lock);
38512
38513 @@ -2026,7 +2026,7 @@ static void event_callback(void *context)
38514
38515 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
38516
38517 - atomic_inc(&md->event_nr);
38518 + atomic_inc_unchecked(&md->event_nr);
38519 wake_up(&md->eventq);
38520 }
38521
38522 @@ -2683,18 +2683,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
38523
38524 uint32_t dm_next_uevent_seq(struct mapped_device *md)
38525 {
38526 - return atomic_add_return(1, &md->uevent_seq);
38527 + return atomic_add_return_unchecked(1, &md->uevent_seq);
38528 }
38529
38530 uint32_t dm_get_event_nr(struct mapped_device *md)
38531 {
38532 - return atomic_read(&md->event_nr);
38533 + return atomic_read_unchecked(&md->event_nr);
38534 }
38535
38536 int dm_wait_event(struct mapped_device *md, int event_nr)
38537 {
38538 return wait_event_interruptible(md->eventq,
38539 - (event_nr != atomic_read(&md->event_nr)));
38540 + (event_nr != atomic_read_unchecked(&md->event_nr)));
38541 }
38542
38543 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
38544 diff --git a/drivers/md/md.c b/drivers/md/md.c
38545 index 9b82377..6b6922d 100644
38546 --- a/drivers/md/md.c
38547 +++ b/drivers/md/md.c
38548 @@ -234,10 +234,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
38549 * start build, activate spare
38550 */
38551 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
38552 -static atomic_t md_event_count;
38553 +static atomic_unchecked_t md_event_count;
38554 void md_new_event(struct mddev *mddev)
38555 {
38556 - atomic_inc(&md_event_count);
38557 + atomic_inc_unchecked(&md_event_count);
38558 wake_up(&md_event_waiters);
38559 }
38560 EXPORT_SYMBOL_GPL(md_new_event);
38561 @@ -247,7 +247,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
38562 */
38563 static void md_new_event_inintr(struct mddev *mddev)
38564 {
38565 - atomic_inc(&md_event_count);
38566 + atomic_inc_unchecked(&md_event_count);
38567 wake_up(&md_event_waiters);
38568 }
38569
38570 @@ -1501,7 +1501,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
38571 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
38572 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
38573 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
38574 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
38575 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
38576
38577 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
38578 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
38579 @@ -1745,7 +1745,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
38580 else
38581 sb->resync_offset = cpu_to_le64(0);
38582
38583 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
38584 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
38585
38586 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
38587 sb->size = cpu_to_le64(mddev->dev_sectors);
38588 @@ -2750,7 +2750,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
38589 static ssize_t
38590 errors_show(struct md_rdev *rdev, char *page)
38591 {
38592 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
38593 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
38594 }
38595
38596 static ssize_t
38597 @@ -2759,7 +2759,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
38598 char *e;
38599 unsigned long n = simple_strtoul(buf, &e, 10);
38600 if (*buf && (*e == 0 || *e == '\n')) {
38601 - atomic_set(&rdev->corrected_errors, n);
38602 + atomic_set_unchecked(&rdev->corrected_errors, n);
38603 return len;
38604 }
38605 return -EINVAL;
38606 @@ -3207,8 +3207,8 @@ int md_rdev_init(struct md_rdev *rdev)
38607 rdev->sb_loaded = 0;
38608 rdev->bb_page = NULL;
38609 atomic_set(&rdev->nr_pending, 0);
38610 - atomic_set(&rdev->read_errors, 0);
38611 - atomic_set(&rdev->corrected_errors, 0);
38612 + atomic_set_unchecked(&rdev->read_errors, 0);
38613 + atomic_set_unchecked(&rdev->corrected_errors, 0);
38614
38615 INIT_LIST_HEAD(&rdev->same_set);
38616 init_waitqueue_head(&rdev->blocked_wait);
38617 @@ -7009,7 +7009,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
38618
38619 spin_unlock(&pers_lock);
38620 seq_printf(seq, "\n");
38621 - seq->poll_event = atomic_read(&md_event_count);
38622 + seq->poll_event = atomic_read_unchecked(&md_event_count);
38623 return 0;
38624 }
38625 if (v == (void*)2) {
38626 @@ -7112,7 +7112,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
38627 return error;
38628
38629 seq = file->private_data;
38630 - seq->poll_event = atomic_read(&md_event_count);
38631 + seq->poll_event = atomic_read_unchecked(&md_event_count);
38632 return error;
38633 }
38634
38635 @@ -7126,7 +7126,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
38636 /* always allow read */
38637 mask = POLLIN | POLLRDNORM;
38638
38639 - if (seq->poll_event != atomic_read(&md_event_count))
38640 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
38641 mask |= POLLERR | POLLPRI;
38642 return mask;
38643 }
38644 @@ -7170,7 +7170,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
38645 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
38646 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
38647 (int)part_stat_read(&disk->part0, sectors[1]) -
38648 - atomic_read(&disk->sync_io);
38649 + atomic_read_unchecked(&disk->sync_io);
38650 /* sync IO will cause sync_io to increase before the disk_stats
38651 * as sync_io is counted when a request starts, and
38652 * disk_stats is counted when it completes.
38653 diff --git a/drivers/md/md.h b/drivers/md/md.h
38654 index 653f992b6..6af6c40 100644
38655 --- a/drivers/md/md.h
38656 +++ b/drivers/md/md.h
38657 @@ -94,13 +94,13 @@ struct md_rdev {
38658 * only maintained for arrays that
38659 * support hot removal
38660 */
38661 - atomic_t read_errors; /* number of consecutive read errors that
38662 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
38663 * we have tried to ignore.
38664 */
38665 struct timespec last_read_error; /* monotonic time since our
38666 * last read error
38667 */
38668 - atomic_t corrected_errors; /* number of corrected read errors,
38669 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
38670 * for reporting to userspace and storing
38671 * in superblock.
38672 */
38673 @@ -434,7 +434,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
38674
38675 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
38676 {
38677 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38678 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
38679 }
38680
38681 struct md_personality
38682 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
38683 index 3e6d115..ffecdeb 100644
38684 --- a/drivers/md/persistent-data/dm-space-map.h
38685 +++ b/drivers/md/persistent-data/dm-space-map.h
38686 @@ -71,6 +71,7 @@ struct dm_space_map {
38687 dm_sm_threshold_fn fn,
38688 void *context);
38689 };
38690 +typedef struct dm_space_map __no_const dm_space_map_no_const;
38691
38692 /*----------------------------------------------------------------*/
38693
38694 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
38695 index 6e17f81..140f717 100644
38696 --- a/drivers/md/raid1.c
38697 +++ b/drivers/md/raid1.c
38698 @@ -1822,7 +1822,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
38699 if (r1_sync_page_io(rdev, sect, s,
38700 bio->bi_io_vec[idx].bv_page,
38701 READ) != 0)
38702 - atomic_add(s, &rdev->corrected_errors);
38703 + atomic_add_unchecked(s, &rdev->corrected_errors);
38704 }
38705 sectors -= s;
38706 sect += s;
38707 @@ -2042,7 +2042,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
38708 test_bit(In_sync, &rdev->flags)) {
38709 if (r1_sync_page_io(rdev, sect, s,
38710 conf->tmppage, READ)) {
38711 - atomic_add(s, &rdev->corrected_errors);
38712 + atomic_add_unchecked(s, &rdev->corrected_errors);
38713 printk(KERN_INFO
38714 "md/raid1:%s: read error corrected "
38715 "(%d sectors at %llu on %s)\n",
38716 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
38717 index 6ddae25..514caa9 100644
38718 --- a/drivers/md/raid10.c
38719 +++ b/drivers/md/raid10.c
38720 @@ -1940,7 +1940,7 @@ static void end_sync_read(struct bio *bio, int error)
38721 /* The write handler will notice the lack of
38722 * R10BIO_Uptodate and record any errors etc
38723 */
38724 - atomic_add(r10_bio->sectors,
38725 + atomic_add_unchecked(r10_bio->sectors,
38726 &conf->mirrors[d].rdev->corrected_errors);
38727
38728 /* for reconstruct, we always reschedule after a read.
38729 @@ -2286,7 +2286,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38730 {
38731 struct timespec cur_time_mon;
38732 unsigned long hours_since_last;
38733 - unsigned int read_errors = atomic_read(&rdev->read_errors);
38734 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
38735
38736 ktime_get_ts(&cur_time_mon);
38737
38738 @@ -2308,9 +2308,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
38739 * overflowing the shift of read_errors by hours_since_last.
38740 */
38741 if (hours_since_last >= 8 * sizeof(read_errors))
38742 - atomic_set(&rdev->read_errors, 0);
38743 + atomic_set_unchecked(&rdev->read_errors, 0);
38744 else
38745 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
38746 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
38747 }
38748
38749 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
38750 @@ -2364,8 +2364,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38751 return;
38752
38753 check_decay_read_errors(mddev, rdev);
38754 - atomic_inc(&rdev->read_errors);
38755 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
38756 + atomic_inc_unchecked(&rdev->read_errors);
38757 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
38758 char b[BDEVNAME_SIZE];
38759 bdevname(rdev->bdev, b);
38760
38761 @@ -2373,7 +2373,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38762 "md/raid10:%s: %s: Raid device exceeded "
38763 "read_error threshold [cur %d:max %d]\n",
38764 mdname(mddev), b,
38765 - atomic_read(&rdev->read_errors), max_read_errors);
38766 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
38767 printk(KERN_NOTICE
38768 "md/raid10:%s: %s: Failing raid device\n",
38769 mdname(mddev), b);
38770 @@ -2528,7 +2528,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
38771 sect +
38772 choose_data_offset(r10_bio, rdev)),
38773 bdevname(rdev->bdev, b));
38774 - atomic_add(s, &rdev->corrected_errors);
38775 + atomic_add_unchecked(s, &rdev->corrected_errors);
38776 }
38777
38778 rdev_dec_pending(rdev, mddev);
38779 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
38780 index 05e4a10..48fbe37 100644
38781 --- a/drivers/md/raid5.c
38782 +++ b/drivers/md/raid5.c
38783 @@ -1764,21 +1764,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
38784 mdname(conf->mddev), STRIPE_SECTORS,
38785 (unsigned long long)s,
38786 bdevname(rdev->bdev, b));
38787 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
38788 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
38789 clear_bit(R5_ReadError, &sh->dev[i].flags);
38790 clear_bit(R5_ReWrite, &sh->dev[i].flags);
38791 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
38792 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
38793
38794 - if (atomic_read(&rdev->read_errors))
38795 - atomic_set(&rdev->read_errors, 0);
38796 + if (atomic_read_unchecked(&rdev->read_errors))
38797 + atomic_set_unchecked(&rdev->read_errors, 0);
38798 } else {
38799 const char *bdn = bdevname(rdev->bdev, b);
38800 int retry = 0;
38801 int set_bad = 0;
38802
38803 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
38804 - atomic_inc(&rdev->read_errors);
38805 + atomic_inc_unchecked(&rdev->read_errors);
38806 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
38807 printk_ratelimited(
38808 KERN_WARNING
38809 @@ -1806,7 +1806,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
38810 mdname(conf->mddev),
38811 (unsigned long long)s,
38812 bdn);
38813 - } else if (atomic_read(&rdev->read_errors)
38814 + } else if (atomic_read_unchecked(&rdev->read_errors)
38815 > conf->max_nr_stripes)
38816 printk(KERN_WARNING
38817 "md/raid:%s: Too many read errors, failing device %s.\n",
38818 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
38819 index 401ef64..836e563 100644
38820 --- a/drivers/media/dvb-core/dvbdev.c
38821 +++ b/drivers/media/dvb-core/dvbdev.c
38822 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
38823 const struct dvb_device *template, void *priv, int type)
38824 {
38825 struct dvb_device *dvbdev;
38826 - struct file_operations *dvbdevfops;
38827 + file_operations_no_const *dvbdevfops;
38828 struct device *clsdev;
38829 int minor;
38830 int id;
38831 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
38832 index 9b6c3bb..baeb5c7 100644
38833 --- a/drivers/media/dvb-frontends/dib3000.h
38834 +++ b/drivers/media/dvb-frontends/dib3000.h
38835 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
38836 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
38837 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
38838 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
38839 -};
38840 +} __no_const;
38841
38842 #if IS_ENABLED(CONFIG_DVB_DIB3000MB)
38843 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
38844 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
38845 index c7a9be1..683f6f8 100644
38846 --- a/drivers/media/pci/cx88/cx88-video.c
38847 +++ b/drivers/media/pci/cx88/cx88-video.c
38848 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
38849
38850 /* ------------------------------------------------------------------ */
38851
38852 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38853 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38854 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38855 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38856 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38857 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
38858
38859 module_param_array(video_nr, int, NULL, 0444);
38860 module_param_array(vbi_nr, int, NULL, 0444);
38861 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
38862 index d338b19..aae4f9e 100644
38863 --- a/drivers/media/platform/omap/omap_vout.c
38864 +++ b/drivers/media/platform/omap/omap_vout.c
38865 @@ -63,7 +63,6 @@ enum omap_vout_channels {
38866 OMAP_VIDEO2,
38867 };
38868
38869 -static struct videobuf_queue_ops video_vbq_ops;
38870 /* Variables configurable through module params*/
38871 static u32 video1_numbuffers = 3;
38872 static u32 video2_numbuffers = 3;
38873 @@ -1015,6 +1014,12 @@ static int omap_vout_open(struct file *file)
38874 {
38875 struct videobuf_queue *q;
38876 struct omap_vout_device *vout = NULL;
38877 + static struct videobuf_queue_ops video_vbq_ops = {
38878 + .buf_setup = omap_vout_buffer_setup,
38879 + .buf_prepare = omap_vout_buffer_prepare,
38880 + .buf_release = omap_vout_buffer_release,
38881 + .buf_queue = omap_vout_buffer_queue,
38882 + };
38883
38884 vout = video_drvdata(file);
38885 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
38886 @@ -1032,10 +1037,6 @@ static int omap_vout_open(struct file *file)
38887 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
38888
38889 q = &vout->vbq;
38890 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
38891 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
38892 - video_vbq_ops.buf_release = omap_vout_buffer_release;
38893 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
38894 spin_lock_init(&vout->vbq_lock);
38895
38896 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
38897 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
38898 index 04e6490..2df65bf 100644
38899 --- a/drivers/media/platform/s5p-tv/mixer.h
38900 +++ b/drivers/media/platform/s5p-tv/mixer.h
38901 @@ -156,7 +156,7 @@ struct mxr_layer {
38902 /** layer index (unique identifier) */
38903 int idx;
38904 /** callbacks for layer methods */
38905 - struct mxr_layer_ops ops;
38906 + struct mxr_layer_ops *ops;
38907 /** format array */
38908 const struct mxr_format **fmt_array;
38909 /** size of format array */
38910 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38911 index b93a21f..2535195 100644
38912 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38913 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
38914 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
38915 {
38916 struct mxr_layer *layer;
38917 int ret;
38918 - struct mxr_layer_ops ops = {
38919 + static struct mxr_layer_ops ops = {
38920 .release = mxr_graph_layer_release,
38921 .buffer_set = mxr_graph_buffer_set,
38922 .stream_set = mxr_graph_stream_set,
38923 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
38924 index b713403..53cb5ad 100644
38925 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
38926 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
38927 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
38928 layer->update_buf = next;
38929 }
38930
38931 - layer->ops.buffer_set(layer, layer->update_buf);
38932 + layer->ops->buffer_set(layer, layer->update_buf);
38933
38934 if (done && done != layer->shadow_buf)
38935 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
38936 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
38937 index ef0efdf..8c78eb6 100644
38938 --- a/drivers/media/platform/s5p-tv/mixer_video.c
38939 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
38940 @@ -209,7 +209,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
38941 layer->geo.src.height = layer->geo.src.full_height;
38942
38943 mxr_geometry_dump(mdev, &layer->geo);
38944 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38945 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38946 mxr_geometry_dump(mdev, &layer->geo);
38947 }
38948
38949 @@ -227,7 +227,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
38950 layer->geo.dst.full_width = mbus_fmt.width;
38951 layer->geo.dst.full_height = mbus_fmt.height;
38952 layer->geo.dst.field = mbus_fmt.field;
38953 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38954 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
38955
38956 mxr_geometry_dump(mdev, &layer->geo);
38957 }
38958 @@ -333,7 +333,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
38959 /* set source size to highest accepted value */
38960 geo->src.full_width = max(geo->dst.full_width, pix->width);
38961 geo->src.full_height = max(geo->dst.full_height, pix->height);
38962 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38963 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38964 mxr_geometry_dump(mdev, &layer->geo);
38965 /* set cropping to total visible screen */
38966 geo->src.width = pix->width;
38967 @@ -341,12 +341,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
38968 geo->src.x_offset = 0;
38969 geo->src.y_offset = 0;
38970 /* assure consistency of geometry */
38971 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
38972 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
38973 mxr_geometry_dump(mdev, &layer->geo);
38974 /* set full size to lowest possible value */
38975 geo->src.full_width = 0;
38976 geo->src.full_height = 0;
38977 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38978 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
38979 mxr_geometry_dump(mdev, &layer->geo);
38980
38981 /* returning results */
38982 @@ -473,7 +473,7 @@ static int mxr_s_selection(struct file *file, void *fh,
38983 target->width = s->r.width;
38984 target->height = s->r.height;
38985
38986 - layer->ops.fix_geometry(layer, stage, s->flags);
38987 + layer->ops->fix_geometry(layer, stage, s->flags);
38988
38989 /* retrieve update selection rectangle */
38990 res.left = target->x_offset;
38991 @@ -954,13 +954,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
38992 mxr_output_get(mdev);
38993
38994 mxr_layer_update_output(layer);
38995 - layer->ops.format_set(layer);
38996 + layer->ops->format_set(layer);
38997 /* enabling layer in hardware */
38998 spin_lock_irqsave(&layer->enq_slock, flags);
38999 layer->state = MXR_LAYER_STREAMING;
39000 spin_unlock_irqrestore(&layer->enq_slock, flags);
39001
39002 - layer->ops.stream_set(layer, MXR_ENABLE);
39003 + layer->ops->stream_set(layer, MXR_ENABLE);
39004 mxr_streamer_get(mdev);
39005
39006 return 0;
39007 @@ -1030,7 +1030,7 @@ static int stop_streaming(struct vb2_queue *vq)
39008 spin_unlock_irqrestore(&layer->enq_slock, flags);
39009
39010 /* disabling layer in hardware */
39011 - layer->ops.stream_set(layer, MXR_DISABLE);
39012 + layer->ops->stream_set(layer, MXR_DISABLE);
39013 /* remove one streamer */
39014 mxr_streamer_put(mdev);
39015 /* allow changes in output configuration */
39016 @@ -1069,8 +1069,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
39017
39018 void mxr_layer_release(struct mxr_layer *layer)
39019 {
39020 - if (layer->ops.release)
39021 - layer->ops.release(layer);
39022 + if (layer->ops->release)
39023 + layer->ops->release(layer);
39024 }
39025
39026 void mxr_base_layer_release(struct mxr_layer *layer)
39027 @@ -1096,7 +1096,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
39028
39029 layer->mdev = mdev;
39030 layer->idx = idx;
39031 - layer->ops = *ops;
39032 + layer->ops = ops;
39033
39034 spin_lock_init(&layer->enq_slock);
39035 INIT_LIST_HEAD(&layer->enq_list);
39036 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
39037 index 3d13a63..da31bf1 100644
39038 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
39039 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
39040 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
39041 {
39042 struct mxr_layer *layer;
39043 int ret;
39044 - struct mxr_layer_ops ops = {
39045 + static struct mxr_layer_ops ops = {
39046 .release = mxr_vp_layer_release,
39047 .buffer_set = mxr_vp_buffer_set,
39048 .stream_set = mxr_vp_stream_set,
39049 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
39050 index 545c04c..a14bded 100644
39051 --- a/drivers/media/radio/radio-cadet.c
39052 +++ b/drivers/media/radio/radio-cadet.c
39053 @@ -324,6 +324,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
39054 unsigned char readbuf[RDS_BUFFER];
39055 int i = 0;
39056
39057 + if (count > RDS_BUFFER)
39058 + return -EFAULT;
39059 mutex_lock(&dev->lock);
39060 if (dev->rdsstat == 0)
39061 cadet_start_rds(dev);
39062 @@ -339,7 +341,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
39063 while (i < count && dev->rdsin != dev->rdsout)
39064 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
39065
39066 - if (i && copy_to_user(data, readbuf, i))
39067 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
39068 i = -EFAULT;
39069 unlock:
39070 mutex_unlock(&dev->lock);
39071 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
39072 index 3940bb0..fb3952a 100644
39073 --- a/drivers/media/usb/dvb-usb/cxusb.c
39074 +++ b/drivers/media/usb/dvb-usb/cxusb.c
39075 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
39076
39077 struct dib0700_adapter_state {
39078 int (*set_param_save) (struct dvb_frontend *);
39079 -};
39080 +} __no_const;
39081
39082 static int dib7070_set_param_override(struct dvb_frontend *fe)
39083 {
39084 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
39085 index 6e237b6..dc25556 100644
39086 --- a/drivers/media/usb/dvb-usb/dw2102.c
39087 +++ b/drivers/media/usb/dvb-usb/dw2102.c
39088 @@ -118,7 +118,7 @@ struct su3000_state {
39089
39090 struct s6x0_state {
39091 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
39092 -};
39093 +} __no_const;
39094
39095 /* debug */
39096 static int dvb_usb_dw2102_debug;
39097 diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
39098 index f129551..ecf6514 100644
39099 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
39100 +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
39101 @@ -326,7 +326,7 @@ struct v4l2_buffer32 {
39102 __u32 reserved;
39103 };
39104
39105 -static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
39106 +static int get_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
39107 enum v4l2_memory memory)
39108 {
39109 void __user *up_pln;
39110 @@ -355,7 +355,7 @@ static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
39111 return 0;
39112 }
39113
39114 -static int put_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
39115 +static int put_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
39116 enum v4l2_memory memory)
39117 {
39118 if (copy_in_user(up32, up, 2 * sizeof(__u32)) ||
39119 @@ -772,7 +772,7 @@ static int put_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subde
39120 put_user(kp->start_block, &up->start_block) ||
39121 put_user(kp->blocks, &up->blocks) ||
39122 put_user(tmp, &up->edid) ||
39123 - copy_to_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
39124 + copy_to_user(up->reserved, kp->reserved, sizeof(kp->reserved)))
39125 return -EFAULT;
39126 return 0;
39127 }
39128 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
39129 index 7658586..1079260 100644
39130 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
39131 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
39132 @@ -1995,7 +1995,8 @@ struct v4l2_ioctl_info {
39133 struct file *file, void *fh, void *p);
39134 } u;
39135 void (*debug)(const void *arg, bool write_only);
39136 -};
39137 +} __do_const;
39138 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
39139
39140 /* This control needs a priority check */
39141 #define INFO_FL_PRIO (1 << 0)
39142 @@ -2177,7 +2178,7 @@ static long __video_do_ioctl(struct file *file,
39143 struct video_device *vfd = video_devdata(file);
39144 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
39145 bool write_only = false;
39146 - struct v4l2_ioctl_info default_info;
39147 + v4l2_ioctl_info_no_const default_info;
39148 const struct v4l2_ioctl_info *info;
39149 void *fh = file->private_data;
39150 struct v4l2_fh *vfh = NULL;
39151 @@ -2251,7 +2252,7 @@ done:
39152 }
39153
39154 static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
39155 - void * __user *user_ptr, void ***kernel_ptr)
39156 + void __user **user_ptr, void ***kernel_ptr)
39157 {
39158 int ret = 0;
39159
39160 @@ -2267,7 +2268,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
39161 ret = -EINVAL;
39162 break;
39163 }
39164 - *user_ptr = (void __user *)buf->m.planes;
39165 + *user_ptr = (void __force_user *)buf->m.planes;
39166 *kernel_ptr = (void *)&buf->m.planes;
39167 *array_size = sizeof(struct v4l2_plane) * buf->length;
39168 ret = 1;
39169 @@ -2302,7 +2303,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
39170 ret = -EINVAL;
39171 break;
39172 }
39173 - *user_ptr = (void __user *)ctrls->controls;
39174 + *user_ptr = (void __force_user *)ctrls->controls;
39175 *kernel_ptr = (void *)&ctrls->controls;
39176 *array_size = sizeof(struct v4l2_ext_control)
39177 * ctrls->count;
39178 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
39179 index 767ff4d..c69d259 100644
39180 --- a/drivers/message/fusion/mptbase.c
39181 +++ b/drivers/message/fusion/mptbase.c
39182 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
39183 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
39184 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
39185
39186 +#ifdef CONFIG_GRKERNSEC_HIDESYM
39187 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
39188 +#else
39189 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
39190 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
39191 +#endif
39192 +
39193 /*
39194 * Rounding UP to nearest 4-kB boundary here...
39195 */
39196 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
39197 ioc->facts.GlobalCredits);
39198
39199 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
39200 +#ifdef CONFIG_GRKERNSEC_HIDESYM
39201 + NULL, NULL);
39202 +#else
39203 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
39204 +#endif
39205 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
39206 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
39207 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
39208 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
39209 index dd239bd..689c4f7 100644
39210 --- a/drivers/message/fusion/mptsas.c
39211 +++ b/drivers/message/fusion/mptsas.c
39212 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
39213 return 0;
39214 }
39215
39216 +static inline void
39217 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
39218 +{
39219 + if (phy_info->port_details) {
39220 + phy_info->port_details->rphy = rphy;
39221 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
39222 + ioc->name, rphy));
39223 + }
39224 +
39225 + if (rphy) {
39226 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
39227 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
39228 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
39229 + ioc->name, rphy, rphy->dev.release));
39230 + }
39231 +}
39232 +
39233 /* no mutex */
39234 static void
39235 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
39236 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
39237 return NULL;
39238 }
39239
39240 -static inline void
39241 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
39242 -{
39243 - if (phy_info->port_details) {
39244 - phy_info->port_details->rphy = rphy;
39245 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
39246 - ioc->name, rphy));
39247 - }
39248 -
39249 - if (rphy) {
39250 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
39251 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
39252 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
39253 - ioc->name, rphy, rphy->dev.release));
39254 - }
39255 -}
39256 -
39257 static inline struct sas_port *
39258 mptsas_get_port(struct mptsas_phyinfo *phy_info)
39259 {
39260 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
39261 index 727819c..ad74694 100644
39262 --- a/drivers/message/fusion/mptscsih.c
39263 +++ b/drivers/message/fusion/mptscsih.c
39264 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
39265
39266 h = shost_priv(SChost);
39267
39268 - if (h) {
39269 - if (h->info_kbuf == NULL)
39270 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
39271 - return h->info_kbuf;
39272 - h->info_kbuf[0] = '\0';
39273 + if (!h)
39274 + return NULL;
39275
39276 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
39277 - h->info_kbuf[size-1] = '\0';
39278 - }
39279 + if (h->info_kbuf == NULL)
39280 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
39281 + return h->info_kbuf;
39282 + h->info_kbuf[0] = '\0';
39283 +
39284 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
39285 + h->info_kbuf[size-1] = '\0';
39286
39287 return h->info_kbuf;
39288 }
39289 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
39290 index b7d87cd..9890039 100644
39291 --- a/drivers/message/i2o/i2o_proc.c
39292 +++ b/drivers/message/i2o/i2o_proc.c
39293 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
39294 "Array Controller Device"
39295 };
39296
39297 -static char *chtostr(char *tmp, u8 *chars, int n)
39298 -{
39299 - tmp[0] = 0;
39300 - return strncat(tmp, (char *)chars, n);
39301 -}
39302 -
39303 static int i2o_report_query_status(struct seq_file *seq, int block_status,
39304 char *group)
39305 {
39306 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
39307 } *result;
39308
39309 i2o_exec_execute_ddm_table ddm_table;
39310 - char tmp[28 + 1];
39311
39312 result = kmalloc(sizeof(*result), GFP_KERNEL);
39313 if (!result)
39314 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
39315
39316 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
39317 seq_printf(seq, "%-#8x", ddm_table.module_id);
39318 - seq_printf(seq, "%-29s",
39319 - chtostr(tmp, ddm_table.module_name_version, 28));
39320 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
39321 seq_printf(seq, "%9d ", ddm_table.data_size);
39322 seq_printf(seq, "%8d", ddm_table.code_size);
39323
39324 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
39325
39326 i2o_driver_result_table *result;
39327 i2o_driver_store_table *dst;
39328 - char tmp[28 + 1];
39329
39330 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
39331 if (result == NULL)
39332 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
39333
39334 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
39335 seq_printf(seq, "%-#8x", dst->module_id);
39336 - seq_printf(seq, "%-29s",
39337 - chtostr(tmp, dst->module_name_version, 28));
39338 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
39339 + seq_printf(seq, "%-.28s", dst->module_name_version);
39340 + seq_printf(seq, "%-.8s", dst->date);
39341 seq_printf(seq, "%8d ", dst->module_size);
39342 seq_printf(seq, "%8d ", dst->mpb_size);
39343 seq_printf(seq, "0x%04x", dst->module_flags);
39344 @@ -1250,7 +1240,6 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
39345 // == (allow) 512d bytes (max)
39346 static u16 *work16 = (u16 *) work32;
39347 int token;
39348 - char tmp[16 + 1];
39349
39350 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
39351
39352 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
39353 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
39354 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
39355 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
39356 - seq_printf(seq, "Vendor info : %s\n",
39357 - chtostr(tmp, (u8 *) (work32 + 2), 16));
39358 - seq_printf(seq, "Product info : %s\n",
39359 - chtostr(tmp, (u8 *) (work32 + 6), 16));
39360 - seq_printf(seq, "Description : %s\n",
39361 - chtostr(tmp, (u8 *) (work32 + 10), 16));
39362 - seq_printf(seq, "Product rev. : %s\n",
39363 - chtostr(tmp, (u8 *) (work32 + 14), 8));
39364 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
39365 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
39366 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
39367 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
39368
39369 seq_printf(seq, "Serial number : ");
39370 print_serial_number(seq, (u8 *) (work32 + 16),
39371 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
39372 u8 pad[256]; // allow up to 256 byte (max) serial number
39373 } result;
39374
39375 - char tmp[24 + 1];
39376 -
39377 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
39378
39379 if (token < 0) {
39380 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
39381 }
39382
39383 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
39384 - seq_printf(seq, "Module name : %s\n",
39385 - chtostr(tmp, result.module_name, 24));
39386 - seq_printf(seq, "Module revision : %s\n",
39387 - chtostr(tmp, result.module_rev, 8));
39388 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
39389 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
39390
39391 seq_printf(seq, "Serial number : ");
39392 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
39393 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
39394 u8 instance_number[4];
39395 } result;
39396
39397 - char tmp[64 + 1];
39398 -
39399 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
39400
39401 if (token < 0) {
39402 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
39403 return 0;
39404 }
39405
39406 - seq_printf(seq, "Device name : %s\n",
39407 - chtostr(tmp, result.device_name, 64));
39408 - seq_printf(seq, "Service name : %s\n",
39409 - chtostr(tmp, result.service_name, 64));
39410 - seq_printf(seq, "Physical name : %s\n",
39411 - chtostr(tmp, result.physical_location, 64));
39412 - seq_printf(seq, "Instance number : %s\n",
39413 - chtostr(tmp, result.instance_number, 4));
39414 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
39415 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
39416 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
39417 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
39418
39419 return 0;
39420 }
39421 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
39422 index a8c08f3..155fe3d 100644
39423 --- a/drivers/message/i2o/iop.c
39424 +++ b/drivers/message/i2o/iop.c
39425 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
39426
39427 spin_lock_irqsave(&c->context_list_lock, flags);
39428
39429 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
39430 - atomic_inc(&c->context_list_counter);
39431 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
39432 + atomic_inc_unchecked(&c->context_list_counter);
39433
39434 - entry->context = atomic_read(&c->context_list_counter);
39435 + entry->context = atomic_read_unchecked(&c->context_list_counter);
39436
39437 list_add(&entry->list, &c->context_list);
39438
39439 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
39440
39441 #if BITS_PER_LONG == 64
39442 spin_lock_init(&c->context_list_lock);
39443 - atomic_set(&c->context_list_counter, 0);
39444 + atomic_set_unchecked(&c->context_list_counter, 0);
39445 INIT_LIST_HEAD(&c->context_list);
39446 #endif
39447
39448 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
39449 index 45ece11..8efa218 100644
39450 --- a/drivers/mfd/janz-cmodio.c
39451 +++ b/drivers/mfd/janz-cmodio.c
39452 @@ -13,6 +13,7 @@
39453
39454 #include <linux/kernel.h>
39455 #include <linux/module.h>
39456 +#include <linux/slab.h>
39457 #include <linux/init.h>
39458 #include <linux/pci.h>
39459 #include <linux/interrupt.h>
39460 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
39461 index a5f9888..1c0ed56 100644
39462 --- a/drivers/mfd/twl4030-irq.c
39463 +++ b/drivers/mfd/twl4030-irq.c
39464 @@ -35,6 +35,7 @@
39465 #include <linux/of.h>
39466 #include <linux/irqdomain.h>
39467 #include <linux/i2c/twl.h>
39468 +#include <asm/pgtable.h>
39469
39470 #include "twl-core.h"
39471
39472 @@ -728,10 +729,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
39473 * Install an irq handler for each of the SIH modules;
39474 * clone dummy irq_chip since PIH can't *do* anything
39475 */
39476 - twl4030_irq_chip = dummy_irq_chip;
39477 - twl4030_irq_chip.name = "twl4030";
39478 + pax_open_kernel();
39479 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
39480 + *(const char **)&twl4030_irq_chip.name = "twl4030";
39481
39482 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
39483 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
39484 + pax_close_kernel();
39485
39486 for (i = irq_base; i < irq_end; i++) {
39487 irq_set_chip_and_handler(i, &twl4030_irq_chip,
39488 diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
39489 index 277a8db..0e0b754 100644
39490 --- a/drivers/mfd/twl6030-irq.c
39491 +++ b/drivers/mfd/twl6030-irq.c
39492 @@ -387,10 +387,12 @@ int twl6030_init_irq(struct device *dev, int irq_num)
39493 * install an irq handler for each of the modules;
39494 * clone dummy irq_chip since PIH can't *do* anything
39495 */
39496 - twl6030_irq_chip = dummy_irq_chip;
39497 - twl6030_irq_chip.name = "twl6030";
39498 - twl6030_irq_chip.irq_set_type = NULL;
39499 - twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
39500 + pax_open_kernel();
39501 + memcpy((void *)&twl6030_irq_chip, &dummy_irq_chip, sizeof twl6030_irq_chip);
39502 + *(const char **)&twl6030_irq_chip.name = "twl6030";
39503 + *(void **)&twl6030_irq_chip.irq_set_type = NULL;
39504 + *(void **)&twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
39505 + pax_close_kernel();
39506
39507 for (i = irq_base; i < irq_end; i++) {
39508 irq_set_chip_and_handler(i, &twl6030_irq_chip,
39509 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
39510 index f32550a..e3e52a2 100644
39511 --- a/drivers/misc/c2port/core.c
39512 +++ b/drivers/misc/c2port/core.c
39513 @@ -920,7 +920,9 @@ struct c2port_device *c2port_device_register(char *name,
39514 mutex_init(&c2dev->mutex);
39515
39516 /* Create binary file */
39517 - c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
39518 + pax_open_kernel();
39519 + *(size_t *)&c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
39520 + pax_close_kernel();
39521 ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
39522 if (unlikely(ret))
39523 goto error_device_create_bin_file;
39524 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
39525 index 36f5d52..32311c3 100644
39526 --- a/drivers/misc/kgdbts.c
39527 +++ b/drivers/misc/kgdbts.c
39528 @@ -834,7 +834,7 @@ static void run_plant_and_detach_test(int is_early)
39529 char before[BREAK_INSTR_SIZE];
39530 char after[BREAK_INSTR_SIZE];
39531
39532 - probe_kernel_read(before, (char *)kgdbts_break_test,
39533 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
39534 BREAK_INSTR_SIZE);
39535 init_simple_test();
39536 ts.tst = plant_and_detach_test;
39537 @@ -842,7 +842,7 @@ static void run_plant_and_detach_test(int is_early)
39538 /* Activate test with initial breakpoint */
39539 if (!is_early)
39540 kgdb_breakpoint();
39541 - probe_kernel_read(after, (char *)kgdbts_break_test,
39542 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
39543 BREAK_INSTR_SIZE);
39544 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
39545 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
39546 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
39547 index 4cd4a3d..b48cbc7 100644
39548 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
39549 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
39550 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
39551 * the lid is closed. This leads to interrupts as soon as a little move
39552 * is done.
39553 */
39554 - atomic_inc(&lis3->count);
39555 + atomic_inc_unchecked(&lis3->count);
39556
39557 wake_up_interruptible(&lis3->misc_wait);
39558 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
39559 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
39560 if (lis3->pm_dev)
39561 pm_runtime_get_sync(lis3->pm_dev);
39562
39563 - atomic_set(&lis3->count, 0);
39564 + atomic_set_unchecked(&lis3->count, 0);
39565 return 0;
39566 }
39567
39568 @@ -616,7 +616,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
39569 add_wait_queue(&lis3->misc_wait, &wait);
39570 while (true) {
39571 set_current_state(TASK_INTERRUPTIBLE);
39572 - data = atomic_xchg(&lis3->count, 0);
39573 + data = atomic_xchg_unchecked(&lis3->count, 0);
39574 if (data)
39575 break;
39576
39577 @@ -657,7 +657,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
39578 struct lis3lv02d, miscdev);
39579
39580 poll_wait(file, &lis3->misc_wait, wait);
39581 - if (atomic_read(&lis3->count))
39582 + if (atomic_read_unchecked(&lis3->count))
39583 return POLLIN | POLLRDNORM;
39584 return 0;
39585 }
39586 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
39587 index c439c82..1f20f57 100644
39588 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
39589 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
39590 @@ -297,7 +297,7 @@ struct lis3lv02d {
39591 struct input_polled_dev *idev; /* input device */
39592 struct platform_device *pdev; /* platform device */
39593 struct regulator_bulk_data regulators[2];
39594 - atomic_t count; /* interrupt count after last read */
39595 + atomic_unchecked_t count; /* interrupt count after last read */
39596 union axis_conversion ac; /* hw -> logical axis */
39597 int mapped_btns[3];
39598
39599 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
39600 index 2f30bad..c4c13d0 100644
39601 --- a/drivers/misc/sgi-gru/gruhandles.c
39602 +++ b/drivers/misc/sgi-gru/gruhandles.c
39603 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
39604 unsigned long nsec;
39605
39606 nsec = CLKS2NSEC(clks);
39607 - atomic_long_inc(&mcs_op_statistics[op].count);
39608 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
39609 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
39610 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
39611 if (mcs_op_statistics[op].max < nsec)
39612 mcs_op_statistics[op].max = nsec;
39613 }
39614 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
39615 index 797d796..ae8f01e 100644
39616 --- a/drivers/misc/sgi-gru/gruprocfs.c
39617 +++ b/drivers/misc/sgi-gru/gruprocfs.c
39618 @@ -32,9 +32,9 @@
39619
39620 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
39621
39622 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
39623 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
39624 {
39625 - unsigned long val = atomic_long_read(v);
39626 + unsigned long val = atomic_long_read_unchecked(v);
39627
39628 seq_printf(s, "%16lu %s\n", val, id);
39629 }
39630 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
39631
39632 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
39633 for (op = 0; op < mcsop_last; op++) {
39634 - count = atomic_long_read(&mcs_op_statistics[op].count);
39635 - total = atomic_long_read(&mcs_op_statistics[op].total);
39636 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
39637 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
39638 max = mcs_op_statistics[op].max;
39639 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
39640 count ? total / count : 0, max);
39641 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
39642 index 5c3ce24..4915ccb 100644
39643 --- a/drivers/misc/sgi-gru/grutables.h
39644 +++ b/drivers/misc/sgi-gru/grutables.h
39645 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
39646 * GRU statistics.
39647 */
39648 struct gru_stats_s {
39649 - atomic_long_t vdata_alloc;
39650 - atomic_long_t vdata_free;
39651 - atomic_long_t gts_alloc;
39652 - atomic_long_t gts_free;
39653 - atomic_long_t gms_alloc;
39654 - atomic_long_t gms_free;
39655 - atomic_long_t gts_double_allocate;
39656 - atomic_long_t assign_context;
39657 - atomic_long_t assign_context_failed;
39658 - atomic_long_t free_context;
39659 - atomic_long_t load_user_context;
39660 - atomic_long_t load_kernel_context;
39661 - atomic_long_t lock_kernel_context;
39662 - atomic_long_t unlock_kernel_context;
39663 - atomic_long_t steal_user_context;
39664 - atomic_long_t steal_kernel_context;
39665 - atomic_long_t steal_context_failed;
39666 - atomic_long_t nopfn;
39667 - atomic_long_t asid_new;
39668 - atomic_long_t asid_next;
39669 - atomic_long_t asid_wrap;
39670 - atomic_long_t asid_reuse;
39671 - atomic_long_t intr;
39672 - atomic_long_t intr_cbr;
39673 - atomic_long_t intr_tfh;
39674 - atomic_long_t intr_spurious;
39675 - atomic_long_t intr_mm_lock_failed;
39676 - atomic_long_t call_os;
39677 - atomic_long_t call_os_wait_queue;
39678 - atomic_long_t user_flush_tlb;
39679 - atomic_long_t user_unload_context;
39680 - atomic_long_t user_exception;
39681 - atomic_long_t set_context_option;
39682 - atomic_long_t check_context_retarget_intr;
39683 - atomic_long_t check_context_unload;
39684 - atomic_long_t tlb_dropin;
39685 - atomic_long_t tlb_preload_page;
39686 - atomic_long_t tlb_dropin_fail_no_asid;
39687 - atomic_long_t tlb_dropin_fail_upm;
39688 - atomic_long_t tlb_dropin_fail_invalid;
39689 - atomic_long_t tlb_dropin_fail_range_active;
39690 - atomic_long_t tlb_dropin_fail_idle;
39691 - atomic_long_t tlb_dropin_fail_fmm;
39692 - atomic_long_t tlb_dropin_fail_no_exception;
39693 - atomic_long_t tfh_stale_on_fault;
39694 - atomic_long_t mmu_invalidate_range;
39695 - atomic_long_t mmu_invalidate_page;
39696 - atomic_long_t flush_tlb;
39697 - atomic_long_t flush_tlb_gru;
39698 - atomic_long_t flush_tlb_gru_tgh;
39699 - atomic_long_t flush_tlb_gru_zero_asid;
39700 + atomic_long_unchecked_t vdata_alloc;
39701 + atomic_long_unchecked_t vdata_free;
39702 + atomic_long_unchecked_t gts_alloc;
39703 + atomic_long_unchecked_t gts_free;
39704 + atomic_long_unchecked_t gms_alloc;
39705 + atomic_long_unchecked_t gms_free;
39706 + atomic_long_unchecked_t gts_double_allocate;
39707 + atomic_long_unchecked_t assign_context;
39708 + atomic_long_unchecked_t assign_context_failed;
39709 + atomic_long_unchecked_t free_context;
39710 + atomic_long_unchecked_t load_user_context;
39711 + atomic_long_unchecked_t load_kernel_context;
39712 + atomic_long_unchecked_t lock_kernel_context;
39713 + atomic_long_unchecked_t unlock_kernel_context;
39714 + atomic_long_unchecked_t steal_user_context;
39715 + atomic_long_unchecked_t steal_kernel_context;
39716 + atomic_long_unchecked_t steal_context_failed;
39717 + atomic_long_unchecked_t nopfn;
39718 + atomic_long_unchecked_t asid_new;
39719 + atomic_long_unchecked_t asid_next;
39720 + atomic_long_unchecked_t asid_wrap;
39721 + atomic_long_unchecked_t asid_reuse;
39722 + atomic_long_unchecked_t intr;
39723 + atomic_long_unchecked_t intr_cbr;
39724 + atomic_long_unchecked_t intr_tfh;
39725 + atomic_long_unchecked_t intr_spurious;
39726 + atomic_long_unchecked_t intr_mm_lock_failed;
39727 + atomic_long_unchecked_t call_os;
39728 + atomic_long_unchecked_t call_os_wait_queue;
39729 + atomic_long_unchecked_t user_flush_tlb;
39730 + atomic_long_unchecked_t user_unload_context;
39731 + atomic_long_unchecked_t user_exception;
39732 + atomic_long_unchecked_t set_context_option;
39733 + atomic_long_unchecked_t check_context_retarget_intr;
39734 + atomic_long_unchecked_t check_context_unload;
39735 + atomic_long_unchecked_t tlb_dropin;
39736 + atomic_long_unchecked_t tlb_preload_page;
39737 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
39738 + atomic_long_unchecked_t tlb_dropin_fail_upm;
39739 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
39740 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
39741 + atomic_long_unchecked_t tlb_dropin_fail_idle;
39742 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
39743 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
39744 + atomic_long_unchecked_t tfh_stale_on_fault;
39745 + atomic_long_unchecked_t mmu_invalidate_range;
39746 + atomic_long_unchecked_t mmu_invalidate_page;
39747 + atomic_long_unchecked_t flush_tlb;
39748 + atomic_long_unchecked_t flush_tlb_gru;
39749 + atomic_long_unchecked_t flush_tlb_gru_tgh;
39750 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
39751
39752 - atomic_long_t copy_gpa;
39753 - atomic_long_t read_gpa;
39754 + atomic_long_unchecked_t copy_gpa;
39755 + atomic_long_unchecked_t read_gpa;
39756
39757 - atomic_long_t mesq_receive;
39758 - atomic_long_t mesq_receive_none;
39759 - atomic_long_t mesq_send;
39760 - atomic_long_t mesq_send_failed;
39761 - atomic_long_t mesq_noop;
39762 - atomic_long_t mesq_send_unexpected_error;
39763 - atomic_long_t mesq_send_lb_overflow;
39764 - atomic_long_t mesq_send_qlimit_reached;
39765 - atomic_long_t mesq_send_amo_nacked;
39766 - atomic_long_t mesq_send_put_nacked;
39767 - atomic_long_t mesq_page_overflow;
39768 - atomic_long_t mesq_qf_locked;
39769 - atomic_long_t mesq_qf_noop_not_full;
39770 - atomic_long_t mesq_qf_switch_head_failed;
39771 - atomic_long_t mesq_qf_unexpected_error;
39772 - atomic_long_t mesq_noop_unexpected_error;
39773 - atomic_long_t mesq_noop_lb_overflow;
39774 - atomic_long_t mesq_noop_qlimit_reached;
39775 - atomic_long_t mesq_noop_amo_nacked;
39776 - atomic_long_t mesq_noop_put_nacked;
39777 - atomic_long_t mesq_noop_page_overflow;
39778 + atomic_long_unchecked_t mesq_receive;
39779 + atomic_long_unchecked_t mesq_receive_none;
39780 + atomic_long_unchecked_t mesq_send;
39781 + atomic_long_unchecked_t mesq_send_failed;
39782 + atomic_long_unchecked_t mesq_noop;
39783 + atomic_long_unchecked_t mesq_send_unexpected_error;
39784 + atomic_long_unchecked_t mesq_send_lb_overflow;
39785 + atomic_long_unchecked_t mesq_send_qlimit_reached;
39786 + atomic_long_unchecked_t mesq_send_amo_nacked;
39787 + atomic_long_unchecked_t mesq_send_put_nacked;
39788 + atomic_long_unchecked_t mesq_page_overflow;
39789 + atomic_long_unchecked_t mesq_qf_locked;
39790 + atomic_long_unchecked_t mesq_qf_noop_not_full;
39791 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
39792 + atomic_long_unchecked_t mesq_qf_unexpected_error;
39793 + atomic_long_unchecked_t mesq_noop_unexpected_error;
39794 + atomic_long_unchecked_t mesq_noop_lb_overflow;
39795 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
39796 + atomic_long_unchecked_t mesq_noop_amo_nacked;
39797 + atomic_long_unchecked_t mesq_noop_put_nacked;
39798 + atomic_long_unchecked_t mesq_noop_page_overflow;
39799
39800 };
39801
39802 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
39803 tghop_invalidate, mcsop_last};
39804
39805 struct mcs_op_statistic {
39806 - atomic_long_t count;
39807 - atomic_long_t total;
39808 + atomic_long_unchecked_t count;
39809 + atomic_long_unchecked_t total;
39810 unsigned long max;
39811 };
39812
39813 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
39814
39815 #define STAT(id) do { \
39816 if (gru_options & OPT_STATS) \
39817 - atomic_long_inc(&gru_stats.id); \
39818 + atomic_long_inc_unchecked(&gru_stats.id); \
39819 } while (0)
39820
39821 #ifdef CONFIG_SGI_GRU_DEBUG
39822 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
39823 index c862cd4..0d176fe 100644
39824 --- a/drivers/misc/sgi-xp/xp.h
39825 +++ b/drivers/misc/sgi-xp/xp.h
39826 @@ -288,7 +288,7 @@ struct xpc_interface {
39827 xpc_notify_func, void *);
39828 void (*received) (short, int, void *);
39829 enum xp_retval (*partid_to_nasids) (short, void *);
39830 -};
39831 +} __no_const;
39832
39833 extern struct xpc_interface xpc_interface;
39834
39835 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
39836 index b94d5f7..7f494c5 100644
39837 --- a/drivers/misc/sgi-xp/xpc.h
39838 +++ b/drivers/misc/sgi-xp/xpc.h
39839 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
39840 void (*received_payload) (struct xpc_channel *, void *);
39841 void (*notify_senders_of_disconnect) (struct xpc_channel *);
39842 };
39843 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
39844
39845 /* struct xpc_partition act_state values (for XPC HB) */
39846
39847 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
39848 /* found in xpc_main.c */
39849 extern struct device *xpc_part;
39850 extern struct device *xpc_chan;
39851 -extern struct xpc_arch_operations xpc_arch_ops;
39852 +extern xpc_arch_operations_no_const xpc_arch_ops;
39853 extern int xpc_disengage_timelimit;
39854 extern int xpc_disengage_timedout;
39855 extern int xpc_activate_IRQ_rcvd;
39856 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
39857 index d971817..33bdca5 100644
39858 --- a/drivers/misc/sgi-xp/xpc_main.c
39859 +++ b/drivers/misc/sgi-xp/xpc_main.c
39860 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
39861 .notifier_call = xpc_system_die,
39862 };
39863
39864 -struct xpc_arch_operations xpc_arch_ops;
39865 +xpc_arch_operations_no_const xpc_arch_ops;
39866
39867 /*
39868 * Timer function to enforce the timelimit on the partition disengage.
39869 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
39870
39871 if (((die_args->trapnr == X86_TRAP_MF) ||
39872 (die_args->trapnr == X86_TRAP_XF)) &&
39873 - !user_mode_vm(die_args->regs))
39874 + !user_mode(die_args->regs))
39875 xpc_die_deactivate();
39876
39877 break;
39878 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
39879 index 49f04bc..65660c2 100644
39880 --- a/drivers/mmc/core/mmc_ops.c
39881 +++ b/drivers/mmc/core/mmc_ops.c
39882 @@ -247,7 +247,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
39883 void *data_buf;
39884 int is_on_stack;
39885
39886 - is_on_stack = object_is_on_stack(buf);
39887 + is_on_stack = object_starts_on_stack(buf);
39888 if (is_on_stack) {
39889 /*
39890 * dma onto stack is unsafe/nonportable, but callers to this
39891 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
39892 index 0b74189..818358f 100644
39893 --- a/drivers/mmc/host/dw_mmc.h
39894 +++ b/drivers/mmc/host/dw_mmc.h
39895 @@ -202,5 +202,5 @@ struct dw_mci_drv_data {
39896 void (*prepare_command)(struct dw_mci *host, u32 *cmdr);
39897 void (*set_ios)(struct dw_mci *host, struct mmc_ios *ios);
39898 int (*parse_dt)(struct dw_mci *host);
39899 -};
39900 +} __do_const;
39901 #endif /* _DW_MMC_H_ */
39902 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
39903 index c6f6246..60760a8 100644
39904 --- a/drivers/mmc/host/sdhci-s3c.c
39905 +++ b/drivers/mmc/host/sdhci-s3c.c
39906 @@ -664,9 +664,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
39907 * we can use overriding functions instead of default.
39908 */
39909 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
39910 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39911 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39912 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39913 + pax_open_kernel();
39914 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
39915 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
39916 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
39917 + pax_close_kernel();
39918 }
39919
39920 /* It supports additional host capabilities if needed */
39921 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
39922 index 0c8bb6b..6f35deb 100644
39923 --- a/drivers/mtd/nand/denali.c
39924 +++ b/drivers/mtd/nand/denali.c
39925 @@ -24,6 +24,7 @@
39926 #include <linux/slab.h>
39927 #include <linux/mtd/mtd.h>
39928 #include <linux/module.h>
39929 +#include <linux/slab.h>
39930
39931 #include "denali.h"
39932
39933 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
39934 index 51b9d6a..52af9a7 100644
39935 --- a/drivers/mtd/nftlmount.c
39936 +++ b/drivers/mtd/nftlmount.c
39937 @@ -24,6 +24,7 @@
39938 #include <asm/errno.h>
39939 #include <linux/delay.h>
39940 #include <linux/slab.h>
39941 +#include <linux/sched.h>
39942 #include <linux/mtd/mtd.h>
39943 #include <linux/mtd/nand.h>
39944 #include <linux/mtd/nftl.h>
39945 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
39946 index f9d5615..99dd95f 100644
39947 --- a/drivers/mtd/sm_ftl.c
39948 +++ b/drivers/mtd/sm_ftl.c
39949 @@ -56,7 +56,7 @@ ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
39950 #define SM_CIS_VENDOR_OFFSET 0x59
39951 struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
39952 {
39953 - struct attribute_group *attr_group;
39954 + attribute_group_no_const *attr_group;
39955 struct attribute **attributes;
39956 struct sm_sysfs_attribute *vendor_attribute;
39957
39958 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
39959 index f975696..4597e21 100644
39960 --- a/drivers/net/bonding/bond_main.c
39961 +++ b/drivers/net/bonding/bond_main.c
39962 @@ -4870,7 +4870,7 @@ static unsigned int bond_get_num_tx_queues(void)
39963 return tx_queues;
39964 }
39965
39966 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
39967 +static struct rtnl_link_ops bond_link_ops = {
39968 .kind = "bond",
39969 .priv_size = sizeof(struct bonding),
39970 .setup = bond_setup,
39971 @@ -4995,8 +4995,8 @@ static void __exit bonding_exit(void)
39972
39973 bond_destroy_debugfs();
39974
39975 - rtnl_link_unregister(&bond_link_ops);
39976 unregister_pernet_subsys(&bond_net_ops);
39977 + rtnl_link_unregister(&bond_link_ops);
39978
39979 #ifdef CONFIG_NET_POLL_CONTROLLER
39980 /*
39981 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
39982 index e1d2643..7f4133b 100644
39983 --- a/drivers/net/ethernet/8390/ax88796.c
39984 +++ b/drivers/net/ethernet/8390/ax88796.c
39985 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
39986 if (ax->plat->reg_offsets)
39987 ei_local->reg_offset = ax->plat->reg_offsets;
39988 else {
39989 + resource_size_t _mem_size = mem_size;
39990 + do_div(_mem_size, 0x18);
39991 ei_local->reg_offset = ax->reg_offsets;
39992 for (ret = 0; ret < 0x18; ret++)
39993 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
39994 + ax->reg_offsets[ret] = _mem_size * ret;
39995 }
39996
39997 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
39998 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
39999 index 151675d..0139a9d 100644
40000 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
40001 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
40002 @@ -1112,7 +1112,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
40003 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
40004 {
40005 /* RX_MODE controlling object */
40006 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
40007 + bnx2x_init_rx_mode_obj(bp);
40008
40009 /* multicast configuration controlling object */
40010 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
40011 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
40012 index 32a9609..0b1c53a 100644
40013 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
40014 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
40015 @@ -2387,15 +2387,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
40016 return rc;
40017 }
40018
40019 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
40020 - struct bnx2x_rx_mode_obj *o)
40021 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
40022 {
40023 if (CHIP_IS_E1x(bp)) {
40024 - o->wait_comp = bnx2x_empty_rx_mode_wait;
40025 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
40026 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
40027 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
40028 } else {
40029 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
40030 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
40031 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
40032 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
40033 }
40034 }
40035
40036 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
40037 index 43c00bc..dd1d03d 100644
40038 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
40039 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
40040 @@ -1321,8 +1321,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
40041
40042 /********************* RX MODE ****************/
40043
40044 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
40045 - struct bnx2x_rx_mode_obj *o);
40046 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
40047
40048 /**
40049 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
40050 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
40051 index ff6e30e..87e8452 100644
40052 --- a/drivers/net/ethernet/broadcom/tg3.h
40053 +++ b/drivers/net/ethernet/broadcom/tg3.h
40054 @@ -147,6 +147,7 @@
40055 #define CHIPREV_ID_5750_A0 0x4000
40056 #define CHIPREV_ID_5750_A1 0x4001
40057 #define CHIPREV_ID_5750_A3 0x4003
40058 +#define CHIPREV_ID_5750_C1 0x4201
40059 #define CHIPREV_ID_5750_C2 0x4202
40060 #define CHIPREV_ID_5752_A0_HW 0x5000
40061 #define CHIPREV_ID_5752_A0 0x6000
40062 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
40063 index 8cffcdf..aadf043 100644
40064 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
40065 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
40066 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
40067 */
40068 struct l2t_skb_cb {
40069 arp_failure_handler_func arp_failure_handler;
40070 -};
40071 +} __no_const;
40072
40073 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
40074
40075 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
40076 index 4c83003..2a2a5b9 100644
40077 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
40078 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
40079 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
40080 for (i=0; i<ETH_ALEN; i++) {
40081 tmp.addr[i] = dev->dev_addr[i];
40082 }
40083 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
40084 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
40085 break;
40086
40087 case DE4X5_SET_HWADDR: /* Set the hardware address */
40088 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
40089 spin_lock_irqsave(&lp->lock, flags);
40090 memcpy(&statbuf, &lp->pktStats, ioc->len);
40091 spin_unlock_irqrestore(&lp->lock, flags);
40092 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
40093 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
40094 return -EFAULT;
40095 break;
40096 }
40097 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
40098 index a0b4be5..d8cb082 100644
40099 --- a/drivers/net/ethernet/emulex/benet/be_main.c
40100 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
40101 @@ -469,7 +469,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
40102
40103 if (wrapped)
40104 newacc += 65536;
40105 - ACCESS_ONCE(*acc) = newacc;
40106 + ACCESS_ONCE_RW(*acc) = newacc;
40107 }
40108
40109 void populate_erx_stats(struct be_adapter *adapter,
40110 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
40111 index 21b85fb..b49e5fc 100644
40112 --- a/drivers/net/ethernet/faraday/ftgmac100.c
40113 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
40114 @@ -31,6 +31,8 @@
40115 #include <linux/netdevice.h>
40116 #include <linux/phy.h>
40117 #include <linux/platform_device.h>
40118 +#include <linux/interrupt.h>
40119 +#include <linux/irqreturn.h>
40120 #include <net/ip.h>
40121
40122 #include "ftgmac100.h"
40123 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
40124 index a6eda8d..935d273 100644
40125 --- a/drivers/net/ethernet/faraday/ftmac100.c
40126 +++ b/drivers/net/ethernet/faraday/ftmac100.c
40127 @@ -31,6 +31,8 @@
40128 #include <linux/module.h>
40129 #include <linux/netdevice.h>
40130 #include <linux/platform_device.h>
40131 +#include <linux/interrupt.h>
40132 +#include <linux/irqreturn.h>
40133
40134 #include "ftmac100.h"
40135
40136 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
40137 index 331987d..3be1135 100644
40138 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
40139 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
40140 @@ -776,7 +776,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
40141 }
40142
40143 /* update the base incval used to calculate frequency adjustment */
40144 - ACCESS_ONCE(adapter->base_incval) = incval;
40145 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
40146 smp_mb();
40147
40148 /* need lock to prevent incorrect read while modifying cyclecounter */
40149 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
40150 index fbe5363..266b4e3 100644
40151 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
40152 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
40153 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
40154 struct __vxge_hw_fifo *fifo;
40155 struct vxge_hw_fifo_config *config;
40156 u32 txdl_size, txdl_per_memblock;
40157 - struct vxge_hw_mempool_cbs fifo_mp_callback;
40158 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
40159 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
40160 + };
40161 +
40162 struct __vxge_hw_virtualpath *vpath;
40163
40164 if ((vp == NULL) || (attr == NULL)) {
40165 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
40166 goto exit;
40167 }
40168
40169 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
40170 -
40171 fifo->mempool =
40172 __vxge_hw_mempool_create(vpath->hldev,
40173 fifo->config->memblock_size,
40174 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
40175 index 5e7fb1d..f8d1810 100644
40176 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
40177 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
40178 @@ -1948,7 +1948,9 @@ int qlcnic_83xx_config_default_opmode(struct qlcnic_adapter *adapter)
40179 op_mode = QLC_83XX_DEFAULT_OPMODE;
40180
40181 if (op_mode == QLC_83XX_DEFAULT_OPMODE) {
40182 - adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
40183 + pax_open_kernel();
40184 + *(void **)&adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
40185 + pax_close_kernel();
40186 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
40187 } else {
40188 return -EIO;
40189 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
40190 index b0c3de9..fc5857e 100644
40191 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
40192 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
40193 @@ -200,15 +200,21 @@ int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
40194 if (priv_level == QLCNIC_NON_PRIV_FUNC) {
40195 ahw->op_mode = QLCNIC_NON_PRIV_FUNC;
40196 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
40197 - nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
40198 + pax_open_kernel();
40199 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
40200 + pax_close_kernel();
40201 } else if (priv_level == QLCNIC_PRIV_FUNC) {
40202 ahw->op_mode = QLCNIC_PRIV_FUNC;
40203 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
40204 - nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
40205 + pax_open_kernel();
40206 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
40207 + pax_close_kernel();
40208 } else if (priv_level == QLCNIC_MGMT_FUNC) {
40209 ahw->op_mode = QLCNIC_MGMT_FUNC;
40210 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
40211 - nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
40212 + pax_open_kernel();
40213 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
40214 + pax_close_kernel();
40215 } else {
40216 return -EIO;
40217 }
40218 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
40219 index 393f961..d343034 100644
40220 --- a/drivers/net/ethernet/realtek/r8169.c
40221 +++ b/drivers/net/ethernet/realtek/r8169.c
40222 @@ -753,22 +753,22 @@ struct rtl8169_private {
40223 struct mdio_ops {
40224 void (*write)(struct rtl8169_private *, int, int);
40225 int (*read)(struct rtl8169_private *, int);
40226 - } mdio_ops;
40227 + } __no_const mdio_ops;
40228
40229 struct pll_power_ops {
40230 void (*down)(struct rtl8169_private *);
40231 void (*up)(struct rtl8169_private *);
40232 - } pll_power_ops;
40233 + } __no_const pll_power_ops;
40234
40235 struct jumbo_ops {
40236 void (*enable)(struct rtl8169_private *);
40237 void (*disable)(struct rtl8169_private *);
40238 - } jumbo_ops;
40239 + } __no_const jumbo_ops;
40240
40241 struct csi_ops {
40242 void (*write)(struct rtl8169_private *, int, int);
40243 u32 (*read)(struct rtl8169_private *, int);
40244 - } csi_ops;
40245 + } __no_const csi_ops;
40246
40247 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
40248 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
40249 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
40250 index 9a95abf..36df7f9 100644
40251 --- a/drivers/net/ethernet/sfc/ptp.c
40252 +++ b/drivers/net/ethernet/sfc/ptp.c
40253 @@ -535,7 +535,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
40254 (u32)((u64)ptp->start.dma_addr >> 32));
40255
40256 /* Clear flag that signals MC ready */
40257 - ACCESS_ONCE(*start) = 0;
40258 + ACCESS_ONCE_RW(*start) = 0;
40259 efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
40260 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
40261
40262 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40263 index 50617c5..b13724c 100644
40264 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40265 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
40266 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
40267
40268 writel(value, ioaddr + MMC_CNTRL);
40269
40270 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
40271 - MMC_CNTRL, value);
40272 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
40273 +// MMC_CNTRL, value);
40274 }
40275
40276 /* To mask all all interrupts.*/
40277 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
40278 index e6fe0d8..2b7d752 100644
40279 --- a/drivers/net/hyperv/hyperv_net.h
40280 +++ b/drivers/net/hyperv/hyperv_net.h
40281 @@ -101,7 +101,7 @@ struct rndis_device {
40282
40283 enum rndis_device_state state;
40284 bool link_state;
40285 - atomic_t new_req_id;
40286 + atomic_unchecked_t new_req_id;
40287
40288 spinlock_t request_lock;
40289 struct list_head req_list;
40290 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
40291 index 0775f0a..d4fb316 100644
40292 --- a/drivers/net/hyperv/rndis_filter.c
40293 +++ b/drivers/net/hyperv/rndis_filter.c
40294 @@ -104,7 +104,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
40295 * template
40296 */
40297 set = &rndis_msg->msg.set_req;
40298 - set->req_id = atomic_inc_return(&dev->new_req_id);
40299 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
40300
40301 /* Add to the request list */
40302 spin_lock_irqsave(&dev->request_lock, flags);
40303 @@ -752,7 +752,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
40304
40305 /* Setup the rndis set */
40306 halt = &request->request_msg.msg.halt_req;
40307 - halt->req_id = atomic_inc_return(&dev->new_req_id);
40308 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
40309
40310 /* Ignore return since this msg is optional. */
40311 rndis_filter_send_request(dev, request);
40312 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
40313 index bf0d55e..82bcfbd1 100644
40314 --- a/drivers/net/ieee802154/fakehard.c
40315 +++ b/drivers/net/ieee802154/fakehard.c
40316 @@ -364,7 +364,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
40317 phy->transmit_power = 0xbf;
40318
40319 dev->netdev_ops = &fake_ops;
40320 - dev->ml_priv = &fake_mlme;
40321 + dev->ml_priv = (void *)&fake_mlme;
40322
40323 priv = netdev_priv(dev);
40324 priv->phy = phy;
40325 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
40326 index 6e91931..2b0ebe7 100644
40327 --- a/drivers/net/macvlan.c
40328 +++ b/drivers/net/macvlan.c
40329 @@ -905,13 +905,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
40330 int macvlan_link_register(struct rtnl_link_ops *ops)
40331 {
40332 /* common fields */
40333 - ops->priv_size = sizeof(struct macvlan_dev);
40334 - ops->validate = macvlan_validate;
40335 - ops->maxtype = IFLA_MACVLAN_MAX;
40336 - ops->policy = macvlan_policy;
40337 - ops->changelink = macvlan_changelink;
40338 - ops->get_size = macvlan_get_size;
40339 - ops->fill_info = macvlan_fill_info;
40340 + pax_open_kernel();
40341 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
40342 + *(void **)&ops->validate = macvlan_validate;
40343 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
40344 + *(const void **)&ops->policy = macvlan_policy;
40345 + *(void **)&ops->changelink = macvlan_changelink;
40346 + *(void **)&ops->get_size = macvlan_get_size;
40347 + *(void **)&ops->fill_info = macvlan_fill_info;
40348 + pax_close_kernel();
40349
40350 return rtnl_link_register(ops);
40351 };
40352 @@ -967,7 +969,7 @@ static int macvlan_device_event(struct notifier_block *unused,
40353 return NOTIFY_DONE;
40354 }
40355
40356 -static struct notifier_block macvlan_notifier_block __read_mostly = {
40357 +static struct notifier_block macvlan_notifier_block = {
40358 .notifier_call = macvlan_device_event,
40359 };
40360
40361 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
40362 index b6dd6a7..5c38a02 100644
40363 --- a/drivers/net/macvtap.c
40364 +++ b/drivers/net/macvtap.c
40365 @@ -1094,7 +1094,7 @@ static int macvtap_device_event(struct notifier_block *unused,
40366 return NOTIFY_DONE;
40367 }
40368
40369 -static struct notifier_block macvtap_notifier_block __read_mostly = {
40370 +static struct notifier_block macvtap_notifier_block = {
40371 .notifier_call = macvtap_device_event,
40372 };
40373
40374 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
40375 index daec9b0..6428fcb 100644
40376 --- a/drivers/net/phy/mdio-bitbang.c
40377 +++ b/drivers/net/phy/mdio-bitbang.c
40378 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
40379 struct mdiobb_ctrl *ctrl = bus->priv;
40380
40381 module_put(ctrl->ops->owner);
40382 + mdiobus_unregister(bus);
40383 mdiobus_free(bus);
40384 }
40385 EXPORT_SYMBOL(free_mdio_bitbang);
40386 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
40387 index 72ff14b..11d442d 100644
40388 --- a/drivers/net/ppp/ppp_generic.c
40389 +++ b/drivers/net/ppp/ppp_generic.c
40390 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
40391 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
40392 struct ppp_stats stats;
40393 struct ppp_comp_stats cstats;
40394 - char *vers;
40395
40396 switch (cmd) {
40397 case SIOCGPPPSTATS:
40398 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
40399 break;
40400
40401 case SIOCGPPPVER:
40402 - vers = PPP_VERSION;
40403 - if (copy_to_user(addr, vers, strlen(vers) + 1))
40404 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
40405 break;
40406 err = 0;
40407 break;
40408 diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
40409 index 1252d9c..80e660b 100644
40410 --- a/drivers/net/slip/slhc.c
40411 +++ b/drivers/net/slip/slhc.c
40412 @@ -488,7 +488,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
40413 register struct tcphdr *thp;
40414 register struct iphdr *ip;
40415 register struct cstate *cs;
40416 - int len, hdrlen;
40417 + long len, hdrlen;
40418 unsigned char *cp = icp;
40419
40420 /* We've got a compressed packet; read the change byte */
40421 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
40422 index b305105..8ead6df 100644
40423 --- a/drivers/net/team/team.c
40424 +++ b/drivers/net/team/team.c
40425 @@ -2682,7 +2682,7 @@ static int team_device_event(struct notifier_block *unused,
40426 return NOTIFY_DONE;
40427 }
40428
40429 -static struct notifier_block team_notifier_block __read_mostly = {
40430 +static struct notifier_block team_notifier_block = {
40431 .notifier_call = team_device_event,
40432 };
40433
40434 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
40435 index 9c61f87..213609e 100644
40436 --- a/drivers/net/tun.c
40437 +++ b/drivers/net/tun.c
40438 @@ -1852,7 +1852,7 @@ unlock:
40439 }
40440
40441 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
40442 - unsigned long arg, int ifreq_len)
40443 + unsigned long arg, size_t ifreq_len)
40444 {
40445 struct tun_file *tfile = file->private_data;
40446 struct tun_struct *tun;
40447 @@ -1864,6 +1864,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
40448 int vnet_hdr_sz;
40449 int ret;
40450
40451 + if (ifreq_len > sizeof ifr)
40452 + return -EFAULT;
40453 +
40454 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
40455 if (copy_from_user(&ifr, argp, ifreq_len))
40456 return -EFAULT;
40457 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
40458 index cba1d46..f703766 100644
40459 --- a/drivers/net/usb/hso.c
40460 +++ b/drivers/net/usb/hso.c
40461 @@ -71,7 +71,7 @@
40462 #include <asm/byteorder.h>
40463 #include <linux/serial_core.h>
40464 #include <linux/serial.h>
40465 -
40466 +#include <asm/local.h>
40467
40468 #define MOD_AUTHOR "Option Wireless"
40469 #define MOD_DESCRIPTION "USB High Speed Option driver"
40470 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
40471 struct urb *urb;
40472
40473 urb = serial->rx_urb[0];
40474 - if (serial->port.count > 0) {
40475 + if (atomic_read(&serial->port.count) > 0) {
40476 count = put_rxbuf_data(urb, serial);
40477 if (count == -1)
40478 return;
40479 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
40480 DUMP1(urb->transfer_buffer, urb->actual_length);
40481
40482 /* Anyone listening? */
40483 - if (serial->port.count == 0)
40484 + if (atomic_read(&serial->port.count) == 0)
40485 return;
40486
40487 if (status == 0) {
40488 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
40489 tty_port_tty_set(&serial->port, tty);
40490
40491 /* check for port already opened, if not set the termios */
40492 - serial->port.count++;
40493 - if (serial->port.count == 1) {
40494 + if (atomic_inc_return(&serial->port.count) == 1) {
40495 serial->rx_state = RX_IDLE;
40496 /* Force default termio settings */
40497 _hso_serial_set_termios(tty, NULL);
40498 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
40499 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
40500 if (result) {
40501 hso_stop_serial_device(serial->parent);
40502 - serial->port.count--;
40503 + atomic_dec(&serial->port.count);
40504 kref_put(&serial->parent->ref, hso_serial_ref_free);
40505 }
40506 } else {
40507 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
40508
40509 /* reset the rts and dtr */
40510 /* do the actual close */
40511 - serial->port.count--;
40512 + atomic_dec(&serial->port.count);
40513
40514 - if (serial->port.count <= 0) {
40515 - serial->port.count = 0;
40516 + if (atomic_read(&serial->port.count) <= 0) {
40517 + atomic_set(&serial->port.count, 0);
40518 tty_port_tty_set(&serial->port, NULL);
40519 if (!usb_gone)
40520 hso_stop_serial_device(serial->parent);
40521 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
40522
40523 /* the actual setup */
40524 spin_lock_irqsave(&serial->serial_lock, flags);
40525 - if (serial->port.count)
40526 + if (atomic_read(&serial->port.count))
40527 _hso_serial_set_termios(tty, old);
40528 else
40529 tty->termios = *old;
40530 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
40531 D1("Pending read interrupt on port %d\n", i);
40532 spin_lock(&serial->serial_lock);
40533 if (serial->rx_state == RX_IDLE &&
40534 - serial->port.count > 0) {
40535 + atomic_read(&serial->port.count) > 0) {
40536 /* Setup and send a ctrl req read on
40537 * port i */
40538 if (!serial->rx_urb_filled[0]) {
40539 @@ -3057,7 +3056,7 @@ static int hso_resume(struct usb_interface *iface)
40540 /* Start all serial ports */
40541 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
40542 if (serial_table[i] && (serial_table[i]->interface == iface)) {
40543 - if (dev2ser(serial_table[i])->port.count) {
40544 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
40545 result =
40546 hso_start_serial_device(serial_table[i], GFP_NOIO);
40547 hso_kick_transmit(dev2ser(serial_table[i]));
40548 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
40549 index 57325f3..36b181f 100644
40550 --- a/drivers/net/vxlan.c
40551 +++ b/drivers/net/vxlan.c
40552 @@ -1579,7 +1579,7 @@ nla_put_failure:
40553 return -EMSGSIZE;
40554 }
40555
40556 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
40557 +static struct rtnl_link_ops vxlan_link_ops = {
40558 .kind = "vxlan",
40559 .maxtype = IFLA_VXLAN_MAX,
40560 .policy = vxlan_policy,
40561 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
40562 index 34c8a33..3261fdc 100644
40563 --- a/drivers/net/wireless/at76c50x-usb.c
40564 +++ b/drivers/net/wireless/at76c50x-usb.c
40565 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
40566 }
40567
40568 /* Convert timeout from the DFU status to jiffies */
40569 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
40570 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
40571 {
40572 return msecs_to_jiffies((s->poll_timeout[2] << 16)
40573 | (s->poll_timeout[1] << 8)
40574 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40575 index 8d78253..bebbb68 100644
40576 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40577 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
40578 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40579 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
40580 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
40581
40582 - ACCESS_ONCE(ads->ds_link) = i->link;
40583 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
40584 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
40585 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
40586
40587 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
40588 ctl6 = SM(i->keytype, AR_EncrType);
40589 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40590
40591 if ((i->is_first || i->is_last) &&
40592 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
40593 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
40594 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
40595 | set11nTries(i->rates, 1)
40596 | set11nTries(i->rates, 2)
40597 | set11nTries(i->rates, 3)
40598 | (i->dur_update ? AR_DurUpdateEna : 0)
40599 | SM(0, AR_BurstDur);
40600
40601 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
40602 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
40603 | set11nRate(i->rates, 1)
40604 | set11nRate(i->rates, 2)
40605 | set11nRate(i->rates, 3);
40606 } else {
40607 - ACCESS_ONCE(ads->ds_ctl2) = 0;
40608 - ACCESS_ONCE(ads->ds_ctl3) = 0;
40609 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
40610 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
40611 }
40612
40613 if (!i->is_first) {
40614 - ACCESS_ONCE(ads->ds_ctl0) = 0;
40615 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
40616 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
40617 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
40618 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
40619 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
40620 return;
40621 }
40622
40623 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40624 break;
40625 }
40626
40627 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
40628 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
40629 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
40630 | SM(i->txpower, AR_XmitPower)
40631 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
40632 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40633 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
40634 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
40635
40636 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
40637 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
40638 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
40639 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
40640
40641 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
40642 return;
40643
40644 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
40645 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
40646 | set11nPktDurRTSCTS(i->rates, 1);
40647
40648 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
40649 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
40650 | set11nPktDurRTSCTS(i->rates, 3);
40651
40652 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
40653 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
40654 | set11nRateFlags(i->rates, 1)
40655 | set11nRateFlags(i->rates, 2)
40656 | set11nRateFlags(i->rates, 3)
40657 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40658 index 301bf72..3f5654f 100644
40659 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40660 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
40661 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40662 (i->qcu << AR_TxQcuNum_S) | desc_len;
40663
40664 checksum += val;
40665 - ACCESS_ONCE(ads->info) = val;
40666 + ACCESS_ONCE_RW(ads->info) = val;
40667
40668 checksum += i->link;
40669 - ACCESS_ONCE(ads->link) = i->link;
40670 + ACCESS_ONCE_RW(ads->link) = i->link;
40671
40672 checksum += i->buf_addr[0];
40673 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
40674 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
40675 checksum += i->buf_addr[1];
40676 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
40677 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
40678 checksum += i->buf_addr[2];
40679 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
40680 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
40681 checksum += i->buf_addr[3];
40682 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
40683 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
40684
40685 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
40686 - ACCESS_ONCE(ads->ctl3) = val;
40687 + ACCESS_ONCE_RW(ads->ctl3) = val;
40688 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
40689 - ACCESS_ONCE(ads->ctl5) = val;
40690 + ACCESS_ONCE_RW(ads->ctl5) = val;
40691 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
40692 - ACCESS_ONCE(ads->ctl7) = val;
40693 + ACCESS_ONCE_RW(ads->ctl7) = val;
40694 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
40695 - ACCESS_ONCE(ads->ctl9) = val;
40696 + ACCESS_ONCE_RW(ads->ctl9) = val;
40697
40698 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
40699 - ACCESS_ONCE(ads->ctl10) = checksum;
40700 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
40701
40702 if (i->is_first || i->is_last) {
40703 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
40704 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
40705 | set11nTries(i->rates, 1)
40706 | set11nTries(i->rates, 2)
40707 | set11nTries(i->rates, 3)
40708 | (i->dur_update ? AR_DurUpdateEna : 0)
40709 | SM(0, AR_BurstDur);
40710
40711 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
40712 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
40713 | set11nRate(i->rates, 1)
40714 | set11nRate(i->rates, 2)
40715 | set11nRate(i->rates, 3);
40716 } else {
40717 - ACCESS_ONCE(ads->ctl13) = 0;
40718 - ACCESS_ONCE(ads->ctl14) = 0;
40719 + ACCESS_ONCE_RW(ads->ctl13) = 0;
40720 + ACCESS_ONCE_RW(ads->ctl14) = 0;
40721 }
40722
40723 ads->ctl20 = 0;
40724 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40725
40726 ctl17 = SM(i->keytype, AR_EncrType);
40727 if (!i->is_first) {
40728 - ACCESS_ONCE(ads->ctl11) = 0;
40729 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
40730 - ACCESS_ONCE(ads->ctl15) = 0;
40731 - ACCESS_ONCE(ads->ctl16) = 0;
40732 - ACCESS_ONCE(ads->ctl17) = ctl17;
40733 - ACCESS_ONCE(ads->ctl18) = 0;
40734 - ACCESS_ONCE(ads->ctl19) = 0;
40735 + ACCESS_ONCE_RW(ads->ctl11) = 0;
40736 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
40737 + ACCESS_ONCE_RW(ads->ctl15) = 0;
40738 + ACCESS_ONCE_RW(ads->ctl16) = 0;
40739 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
40740 + ACCESS_ONCE_RW(ads->ctl18) = 0;
40741 + ACCESS_ONCE_RW(ads->ctl19) = 0;
40742 return;
40743 }
40744
40745 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
40746 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
40747 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
40748 | SM(i->txpower, AR_XmitPower)
40749 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
40750 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
40751 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
40752 ctl12 |= SM(val, AR_PAPRDChainMask);
40753
40754 - ACCESS_ONCE(ads->ctl12) = ctl12;
40755 - ACCESS_ONCE(ads->ctl17) = ctl17;
40756 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
40757 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
40758
40759 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
40760 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
40761 | set11nPktDurRTSCTS(i->rates, 1);
40762
40763 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
40764 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
40765 | set11nPktDurRTSCTS(i->rates, 3);
40766
40767 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
40768 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
40769 | set11nRateFlags(i->rates, 1)
40770 | set11nRateFlags(i->rates, 2)
40771 | set11nRateFlags(i->rates, 3)
40772 | SM(i->rtscts_rate, AR_RTSCTSRate);
40773
40774 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
40775 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
40776 }
40777
40778 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
40779 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
40780 index ae30343..a117806 100644
40781 --- a/drivers/net/wireless/ath/ath9k/hw.h
40782 +++ b/drivers/net/wireless/ath/ath9k/hw.h
40783 @@ -652,7 +652,7 @@ struct ath_hw_private_ops {
40784
40785 /* ANI */
40786 void (*ani_cache_ini_regs)(struct ath_hw *ah);
40787 -};
40788 +} __no_const;
40789
40790 /**
40791 * struct ath_spec_scan - parameters for Atheros spectral scan
40792 @@ -721,7 +721,7 @@ struct ath_hw_ops {
40793 struct ath_spec_scan *param);
40794 void (*spectral_scan_trigger)(struct ath_hw *ah);
40795 void (*spectral_scan_wait)(struct ath_hw *ah);
40796 -};
40797 +} __no_const;
40798
40799 struct ath_nf_limits {
40800 s16 max;
40801 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
40802 index b37a582..680835d 100644
40803 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
40804 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
40805 @@ -3639,7 +3639,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
40806 */
40807 if (il3945_mod_params.disable_hw_scan) {
40808 D_INFO("Disabling hw_scan\n");
40809 - il3945_mac_ops.hw_scan = NULL;
40810 + pax_open_kernel();
40811 + *(void **)&il3945_mac_ops.hw_scan = NULL;
40812 + pax_close_kernel();
40813 }
40814
40815 D_INFO("*** LOAD DRIVER ***\n");
40816 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40817 index d532948..a1cb592 100644
40818 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40819 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
40820 @@ -203,7 +203,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
40821 {
40822 struct iwl_priv *priv = file->private_data;
40823 char buf[64];
40824 - int buf_size;
40825 + size_t buf_size;
40826 u32 offset, len;
40827
40828 memset(buf, 0, sizeof(buf));
40829 @@ -473,7 +473,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
40830 struct iwl_priv *priv = file->private_data;
40831
40832 char buf[8];
40833 - int buf_size;
40834 + size_t buf_size;
40835 u32 reset_flag;
40836
40837 memset(buf, 0, sizeof(buf));
40838 @@ -554,7 +554,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
40839 {
40840 struct iwl_priv *priv = file->private_data;
40841 char buf[8];
40842 - int buf_size;
40843 + size_t buf_size;
40844 int ht40;
40845
40846 memset(buf, 0, sizeof(buf));
40847 @@ -606,7 +606,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
40848 {
40849 struct iwl_priv *priv = file->private_data;
40850 char buf[8];
40851 - int buf_size;
40852 + size_t buf_size;
40853 int value;
40854
40855 memset(buf, 0, sizeof(buf));
40856 @@ -1871,7 +1871,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
40857 {
40858 struct iwl_priv *priv = file->private_data;
40859 char buf[8];
40860 - int buf_size;
40861 + size_t buf_size;
40862 int clear;
40863
40864 memset(buf, 0, sizeof(buf));
40865 @@ -1916,7 +1916,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
40866 {
40867 struct iwl_priv *priv = file->private_data;
40868 char buf[8];
40869 - int buf_size;
40870 + size_t buf_size;
40871 int trace;
40872
40873 memset(buf, 0, sizeof(buf));
40874 @@ -1987,7 +1987,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
40875 {
40876 struct iwl_priv *priv = file->private_data;
40877 char buf[8];
40878 - int buf_size;
40879 + size_t buf_size;
40880 int missed;
40881
40882 memset(buf, 0, sizeof(buf));
40883 @@ -2028,7 +2028,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
40884
40885 struct iwl_priv *priv = file->private_data;
40886 char buf[8];
40887 - int buf_size;
40888 + size_t buf_size;
40889 int plcp;
40890
40891 memset(buf, 0, sizeof(buf));
40892 @@ -2088,7 +2088,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
40893
40894 struct iwl_priv *priv = file->private_data;
40895 char buf[8];
40896 - int buf_size;
40897 + size_t buf_size;
40898 int flush;
40899
40900 memset(buf, 0, sizeof(buf));
40901 @@ -2178,7 +2178,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
40902
40903 struct iwl_priv *priv = file->private_data;
40904 char buf[8];
40905 - int buf_size;
40906 + size_t buf_size;
40907 int rts;
40908
40909 if (!priv->cfg->ht_params)
40910 @@ -2220,7 +2220,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
40911 {
40912 struct iwl_priv *priv = file->private_data;
40913 char buf[8];
40914 - int buf_size;
40915 + size_t buf_size;
40916
40917 memset(buf, 0, sizeof(buf));
40918 buf_size = min(count, sizeof(buf) - 1);
40919 @@ -2254,7 +2254,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
40920 struct iwl_priv *priv = file->private_data;
40921 u32 event_log_flag;
40922 char buf[8];
40923 - int buf_size;
40924 + size_t buf_size;
40925
40926 /* check that the interface is up */
40927 if (!iwl_is_ready(priv))
40928 @@ -2308,7 +2308,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
40929 struct iwl_priv *priv = file->private_data;
40930 char buf[8];
40931 u32 calib_disabled;
40932 - int buf_size;
40933 + size_t buf_size;
40934
40935 memset(buf, 0, sizeof(buf));
40936 buf_size = min(count, sizeof(buf) - 1);
40937 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
40938 index 50ba0a4..29424e7 100644
40939 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
40940 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
40941 @@ -1329,7 +1329,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
40942 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
40943
40944 char buf[8];
40945 - int buf_size;
40946 + size_t buf_size;
40947 u32 reset_flag;
40948
40949 memset(buf, 0, sizeof(buf));
40950 @@ -1350,7 +1350,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
40951 {
40952 struct iwl_trans *trans = file->private_data;
40953 char buf[8];
40954 - int buf_size;
40955 + size_t buf_size;
40956 int csr;
40957
40958 memset(buf, 0, sizeof(buf));
40959 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
40960 index cb34c78..9fec0dc 100644
40961 --- a/drivers/net/wireless/mac80211_hwsim.c
40962 +++ b/drivers/net/wireless/mac80211_hwsim.c
40963 @@ -2195,25 +2195,19 @@ static int __init init_mac80211_hwsim(void)
40964
40965 if (channels > 1) {
40966 hwsim_if_comb.num_different_channels = channels;
40967 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
40968 - mac80211_hwsim_ops.cancel_hw_scan =
40969 - mac80211_hwsim_cancel_hw_scan;
40970 - mac80211_hwsim_ops.sw_scan_start = NULL;
40971 - mac80211_hwsim_ops.sw_scan_complete = NULL;
40972 - mac80211_hwsim_ops.remain_on_channel =
40973 - mac80211_hwsim_roc;
40974 - mac80211_hwsim_ops.cancel_remain_on_channel =
40975 - mac80211_hwsim_croc;
40976 - mac80211_hwsim_ops.add_chanctx =
40977 - mac80211_hwsim_add_chanctx;
40978 - mac80211_hwsim_ops.remove_chanctx =
40979 - mac80211_hwsim_remove_chanctx;
40980 - mac80211_hwsim_ops.change_chanctx =
40981 - mac80211_hwsim_change_chanctx;
40982 - mac80211_hwsim_ops.assign_vif_chanctx =
40983 - mac80211_hwsim_assign_vif_chanctx;
40984 - mac80211_hwsim_ops.unassign_vif_chanctx =
40985 - mac80211_hwsim_unassign_vif_chanctx;
40986 + pax_open_kernel();
40987 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
40988 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
40989 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
40990 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
40991 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
40992 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
40993 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
40994 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
40995 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
40996 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
40997 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
40998 + pax_close_kernel();
40999 }
41000
41001 spin_lock_init(&hwsim_radio_lock);
41002 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
41003 index 8169a85..7fa3b47 100644
41004 --- a/drivers/net/wireless/rndis_wlan.c
41005 +++ b/drivers/net/wireless/rndis_wlan.c
41006 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
41007
41008 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
41009
41010 - if (rts_threshold < 0 || rts_threshold > 2347)
41011 + if (rts_threshold > 2347)
41012 rts_threshold = 2347;
41013
41014 tmp = cpu_to_le32(rts_threshold);
41015 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
41016 index 7510723..5ba37f5 100644
41017 --- a/drivers/net/wireless/rt2x00/rt2x00.h
41018 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
41019 @@ -386,7 +386,7 @@ struct rt2x00_intf {
41020 * for hardware which doesn't support hardware
41021 * sequence counting.
41022 */
41023 - atomic_t seqno;
41024 + atomic_unchecked_t seqno;
41025 };
41026
41027 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
41028 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
41029 index 2c12311..7b77f24 100644
41030 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
41031 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
41032 @@ -252,9 +252,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
41033 * sequence counter given by mac80211.
41034 */
41035 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
41036 - seqno = atomic_add_return(0x10, &intf->seqno);
41037 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
41038 else
41039 - seqno = atomic_read(&intf->seqno);
41040 + seqno = atomic_read_unchecked(&intf->seqno);
41041
41042 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
41043 hdr->seq_ctrl |= cpu_to_le16(seqno);
41044 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
41045 index e2b3d9c..67a5184 100644
41046 --- a/drivers/net/wireless/ti/wl1251/sdio.c
41047 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
41048 @@ -271,13 +271,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
41049
41050 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
41051
41052 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
41053 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
41054 + pax_open_kernel();
41055 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
41056 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
41057 + pax_close_kernel();
41058
41059 wl1251_info("using dedicated interrupt line");
41060 } else {
41061 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
41062 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
41063 + pax_open_kernel();
41064 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
41065 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
41066 + pax_close_kernel();
41067
41068 wl1251_info("using SDIO interrupt");
41069 }
41070 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
41071 index 1c627da..69f7d17 100644
41072 --- a/drivers/net/wireless/ti/wl12xx/main.c
41073 +++ b/drivers/net/wireless/ti/wl12xx/main.c
41074 @@ -656,7 +656,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
41075 sizeof(wl->conf.mem));
41076
41077 /* read data preparation is only needed by wl127x */
41078 - wl->ops->prepare_read = wl127x_prepare_read;
41079 + pax_open_kernel();
41080 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
41081 + pax_close_kernel();
41082
41083 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
41084 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
41085 @@ -681,7 +683,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
41086 sizeof(wl->conf.mem));
41087
41088 /* read data preparation is only needed by wl127x */
41089 - wl->ops->prepare_read = wl127x_prepare_read;
41090 + pax_open_kernel();
41091 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
41092 + pax_close_kernel();
41093
41094 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
41095 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
41096 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
41097 index 9fa692d..b31fee0 100644
41098 --- a/drivers/net/wireless/ti/wl18xx/main.c
41099 +++ b/drivers/net/wireless/ti/wl18xx/main.c
41100 @@ -1687,8 +1687,10 @@ static int wl18xx_setup(struct wl1271 *wl)
41101 }
41102
41103 if (!checksum_param) {
41104 - wl18xx_ops.set_rx_csum = NULL;
41105 - wl18xx_ops.init_vif = NULL;
41106 + pax_open_kernel();
41107 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
41108 + *(void **)&wl18xx_ops.init_vif = NULL;
41109 + pax_close_kernel();
41110 }
41111
41112 /* Enable 11a Band only if we have 5G antennas */
41113 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
41114 index 7ef0b4a..ff65c28 100644
41115 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
41116 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
41117 @@ -386,7 +386,7 @@ static inline void handle_regs_int(struct urb *urb)
41118 {
41119 struct zd_usb *usb = urb->context;
41120 struct zd_usb_interrupt *intr = &usb->intr;
41121 - int len;
41122 + unsigned int len;
41123 u16 int_num;
41124
41125 ZD_ASSERT(in_interrupt());
41126 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
41127 index d93b2b6..ae50401 100644
41128 --- a/drivers/oprofile/buffer_sync.c
41129 +++ b/drivers/oprofile/buffer_sync.c
41130 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
41131 if (cookie == NO_COOKIE)
41132 offset = pc;
41133 if (cookie == INVALID_COOKIE) {
41134 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
41135 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
41136 offset = pc;
41137 }
41138 if (cookie != last_cookie) {
41139 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
41140 /* add userspace sample */
41141
41142 if (!mm) {
41143 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
41144 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
41145 return 0;
41146 }
41147
41148 cookie = lookup_dcookie(mm, s->eip, &offset);
41149
41150 if (cookie == INVALID_COOKIE) {
41151 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
41152 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
41153 return 0;
41154 }
41155
41156 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
41157 /* ignore backtraces if failed to add a sample */
41158 if (state == sb_bt_start) {
41159 state = sb_bt_ignore;
41160 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
41161 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
41162 }
41163 }
41164 release_mm(mm);
41165 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
41166 index c0cc4e7..44d4e54 100644
41167 --- a/drivers/oprofile/event_buffer.c
41168 +++ b/drivers/oprofile/event_buffer.c
41169 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
41170 }
41171
41172 if (buffer_pos == buffer_size) {
41173 - atomic_inc(&oprofile_stats.event_lost_overflow);
41174 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
41175 return;
41176 }
41177
41178 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
41179 index ed2c3ec..deda85a 100644
41180 --- a/drivers/oprofile/oprof.c
41181 +++ b/drivers/oprofile/oprof.c
41182 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
41183 if (oprofile_ops.switch_events())
41184 return;
41185
41186 - atomic_inc(&oprofile_stats.multiplex_counter);
41187 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
41188 start_switch_worker();
41189 }
41190
41191 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
41192 index 84a208d..d61b0a1 100644
41193 --- a/drivers/oprofile/oprofile_files.c
41194 +++ b/drivers/oprofile/oprofile_files.c
41195 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
41196
41197 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
41198
41199 -static ssize_t timeout_read(struct file *file, char __user *buf,
41200 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
41201 size_t count, loff_t *offset)
41202 {
41203 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
41204 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
41205 index 917d28e..d62d981 100644
41206 --- a/drivers/oprofile/oprofile_stats.c
41207 +++ b/drivers/oprofile/oprofile_stats.c
41208 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
41209 cpu_buf->sample_invalid_eip = 0;
41210 }
41211
41212 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
41213 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
41214 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
41215 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
41216 - atomic_set(&oprofile_stats.multiplex_counter, 0);
41217 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
41218 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
41219 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
41220 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
41221 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
41222 }
41223
41224
41225 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
41226 index 38b6fc0..b5cbfce 100644
41227 --- a/drivers/oprofile/oprofile_stats.h
41228 +++ b/drivers/oprofile/oprofile_stats.h
41229 @@ -13,11 +13,11 @@
41230 #include <linux/atomic.h>
41231
41232 struct oprofile_stat_struct {
41233 - atomic_t sample_lost_no_mm;
41234 - atomic_t sample_lost_no_mapping;
41235 - atomic_t bt_lost_no_mapping;
41236 - atomic_t event_lost_overflow;
41237 - atomic_t multiplex_counter;
41238 + atomic_unchecked_t sample_lost_no_mm;
41239 + atomic_unchecked_t sample_lost_no_mapping;
41240 + atomic_unchecked_t bt_lost_no_mapping;
41241 + atomic_unchecked_t event_lost_overflow;
41242 + atomic_unchecked_t multiplex_counter;
41243 };
41244
41245 extern struct oprofile_stat_struct oprofile_stats;
41246 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
41247 index 7c12d9c..558bf3bb 100644
41248 --- a/drivers/oprofile/oprofilefs.c
41249 +++ b/drivers/oprofile/oprofilefs.c
41250 @@ -190,7 +190,7 @@ static const struct file_operations atomic_ro_fops = {
41251
41252
41253 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
41254 - char const *name, atomic_t *val)
41255 + char const *name, atomic_unchecked_t *val)
41256 {
41257 return __oprofilefs_create_file(sb, root, name,
41258 &atomic_ro_fops, 0444, val);
41259 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
41260 index 93404f7..4a313d8 100644
41261 --- a/drivers/oprofile/timer_int.c
41262 +++ b/drivers/oprofile/timer_int.c
41263 @@ -93,7 +93,7 @@ static int __cpuinit oprofile_cpu_notify(struct notifier_block *self,
41264 return NOTIFY_OK;
41265 }
41266
41267 -static struct notifier_block __refdata oprofile_cpu_notifier = {
41268 +static struct notifier_block oprofile_cpu_notifier = {
41269 .notifier_call = oprofile_cpu_notify,
41270 };
41271
41272 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
41273 index 92ed045..62d39bd7 100644
41274 --- a/drivers/parport/procfs.c
41275 +++ b/drivers/parport/procfs.c
41276 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
41277
41278 *ppos += len;
41279
41280 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
41281 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
41282 }
41283
41284 #ifdef CONFIG_PARPORT_1284
41285 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
41286
41287 *ppos += len;
41288
41289 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
41290 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
41291 }
41292 #endif /* IEEE1284.3 support. */
41293
41294 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
41295 index c35e8ad..fc33beb 100644
41296 --- a/drivers/pci/hotplug/acpiphp_ibm.c
41297 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
41298 @@ -464,7 +464,9 @@ static int __init ibm_acpiphp_init(void)
41299 goto init_cleanup;
41300 }
41301
41302 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
41303 + pax_open_kernel();
41304 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
41305 + pax_close_kernel();
41306 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
41307
41308 return retval;
41309 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
41310 index a6a71c4..c91097b 100644
41311 --- a/drivers/pci/hotplug/cpcihp_generic.c
41312 +++ b/drivers/pci/hotplug/cpcihp_generic.c
41313 @@ -73,7 +73,6 @@ static u16 port;
41314 static unsigned int enum_bit;
41315 static u8 enum_mask;
41316
41317 -static struct cpci_hp_controller_ops generic_hpc_ops;
41318 static struct cpci_hp_controller generic_hpc;
41319
41320 static int __init validate_parameters(void)
41321 @@ -139,6 +138,10 @@ static int query_enum(void)
41322 return ((value & enum_mask) == enum_mask);
41323 }
41324
41325 +static struct cpci_hp_controller_ops generic_hpc_ops = {
41326 + .query_enum = query_enum,
41327 +};
41328 +
41329 static int __init cpcihp_generic_init(void)
41330 {
41331 int status;
41332 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
41333 pci_dev_put(dev);
41334
41335 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
41336 - generic_hpc_ops.query_enum = query_enum;
41337 generic_hpc.ops = &generic_hpc_ops;
41338
41339 status = cpci_hp_register_controller(&generic_hpc);
41340 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
41341 index 449b4bb..257e2e8 100644
41342 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
41343 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
41344 @@ -59,7 +59,6 @@
41345 /* local variables */
41346 static bool debug;
41347 static bool poll;
41348 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
41349 static struct cpci_hp_controller zt5550_hpc;
41350
41351 /* Primary cPCI bus bridge device */
41352 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
41353 return 0;
41354 }
41355
41356 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
41357 + .query_enum = zt5550_hc_query_enum,
41358 +};
41359 +
41360 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
41361 {
41362 int status;
41363 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
41364 dbg("returned from zt5550_hc_config");
41365
41366 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
41367 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
41368 zt5550_hpc.ops = &zt5550_hpc_ops;
41369 if(!poll) {
41370 zt5550_hpc.irq = hc_dev->irq;
41371 zt5550_hpc.irq_flags = IRQF_SHARED;
41372 zt5550_hpc.dev_id = hc_dev;
41373
41374 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
41375 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
41376 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
41377 + pax_open_kernel();
41378 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
41379 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
41380 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
41381 + pax_open_kernel();
41382 } else {
41383 info("using ENUM# polling mode");
41384 }
41385 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
41386 index 76ba8a1..20ca857 100644
41387 --- a/drivers/pci/hotplug/cpqphp_nvram.c
41388 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
41389 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
41390
41391 void compaq_nvram_init (void __iomem *rom_start)
41392 {
41393 +
41394 +#ifndef CONFIG_PAX_KERNEXEC
41395 if (rom_start) {
41396 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
41397 }
41398 +#endif
41399 +
41400 dbg("int15 entry = %p\n", compaq_int15_entry_point);
41401
41402 /* initialize our int15 lock */
41403 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
41404 index ec20f74..c1d961e 100644
41405 --- a/drivers/pci/hotplug/pci_hotplug_core.c
41406 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
41407 @@ -441,8 +441,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
41408 return -EINVAL;
41409 }
41410
41411 - slot->ops->owner = owner;
41412 - slot->ops->mod_name = mod_name;
41413 + pax_open_kernel();
41414 + *(struct module **)&slot->ops->owner = owner;
41415 + *(const char **)&slot->ops->mod_name = mod_name;
41416 + pax_close_kernel();
41417
41418 mutex_lock(&pci_hp_mutex);
41419 /*
41420 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
41421 index 7d72c5e..edce02c 100644
41422 --- a/drivers/pci/hotplug/pciehp_core.c
41423 +++ b/drivers/pci/hotplug/pciehp_core.c
41424 @@ -91,7 +91,7 @@ static int init_slot(struct controller *ctrl)
41425 struct slot *slot = ctrl->slot;
41426 struct hotplug_slot *hotplug = NULL;
41427 struct hotplug_slot_info *info = NULL;
41428 - struct hotplug_slot_ops *ops = NULL;
41429 + hotplug_slot_ops_no_const *ops = NULL;
41430 char name[SLOT_NAME_SIZE];
41431 int retval = -ENOMEM;
41432
41433 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
41434 index 5b4a9d9..cd5ac1f 100644
41435 --- a/drivers/pci/pci-sysfs.c
41436 +++ b/drivers/pci/pci-sysfs.c
41437 @@ -1071,7 +1071,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
41438 {
41439 /* allocate attribute structure, piggyback attribute name */
41440 int name_len = write_combine ? 13 : 10;
41441 - struct bin_attribute *res_attr;
41442 + bin_attribute_no_const *res_attr;
41443 int retval;
41444
41445 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
41446 @@ -1256,7 +1256,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
41447 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
41448 {
41449 int retval;
41450 - struct bin_attribute *attr;
41451 + bin_attribute_no_const *attr;
41452
41453 /* If the device has VPD, try to expose it in sysfs. */
41454 if (dev->vpd) {
41455 @@ -1303,7 +1303,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
41456 {
41457 int retval;
41458 int rom_size = 0;
41459 - struct bin_attribute *attr;
41460 + bin_attribute_no_const *attr;
41461
41462 if (!sysfs_initialized)
41463 return -EACCES;
41464 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
41465 index d1182c4..2a138ec 100644
41466 --- a/drivers/pci/pci.h
41467 +++ b/drivers/pci/pci.h
41468 @@ -92,7 +92,7 @@ struct pci_vpd_ops {
41469 struct pci_vpd {
41470 unsigned int len;
41471 const struct pci_vpd_ops *ops;
41472 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
41473 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
41474 };
41475
41476 int pci_vpd_pci22_init(struct pci_dev *dev);
41477 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
41478 index d320df6..ca9a8f6 100644
41479 --- a/drivers/pci/pcie/aspm.c
41480 +++ b/drivers/pci/pcie/aspm.c
41481 @@ -27,9 +27,9 @@
41482 #define MODULE_PARAM_PREFIX "pcie_aspm."
41483
41484 /* Note: those are not register definitions */
41485 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
41486 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
41487 -#define ASPM_STATE_L1 (4) /* L1 state */
41488 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
41489 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
41490 +#define ASPM_STATE_L1 (4U) /* L1 state */
41491 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
41492 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
41493
41494 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
41495 index 70f10fa..cb5e917 100644
41496 --- a/drivers/pci/probe.c
41497 +++ b/drivers/pci/probe.c
41498 @@ -173,7 +173,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
41499 struct pci_bus_region region;
41500 bool bar_too_big = false, bar_disabled = false;
41501
41502 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
41503 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
41504
41505 /* No printks while decoding is disabled! */
41506 if (!dev->mmio_always_on) {
41507 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
41508 index 0812608..b04018c4 100644
41509 --- a/drivers/pci/proc.c
41510 +++ b/drivers/pci/proc.c
41511 @@ -453,7 +453,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
41512 static int __init pci_proc_init(void)
41513 {
41514 struct pci_dev *dev = NULL;
41515 +
41516 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
41517 +#ifdef CONFIG_GRKERNSEC_PROC_USER
41518 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
41519 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
41520 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
41521 +#endif
41522 +#else
41523 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
41524 +#endif
41525 proc_create("devices", 0, proc_bus_pci_dir,
41526 &proc_bus_pci_dev_operations);
41527 proc_initialized = 1;
41528 diff --git a/drivers/platform/x86/chromeos_laptop.c b/drivers/platform/x86/chromeos_laptop.c
41529 index 3e5b4497..dcdfb70 100644
41530 --- a/drivers/platform/x86/chromeos_laptop.c
41531 +++ b/drivers/platform/x86/chromeos_laptop.c
41532 @@ -301,7 +301,7 @@ static int __init setup_tsl2563_als(const struct dmi_system_id *id)
41533 return 0;
41534 }
41535
41536 -static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = {
41537 +static struct dmi_system_id __initconst chromeos_laptop_dmi_table[] = {
41538 {
41539 .ident = "Samsung Series 5 550 - Touchpad",
41540 .matches = {
41541 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
41542 index 6b22938..bc9700e 100644
41543 --- a/drivers/platform/x86/msi-laptop.c
41544 +++ b/drivers/platform/x86/msi-laptop.c
41545 @@ -1000,12 +1000,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
41546
41547 if (!quirks->ec_read_only) {
41548 /* allow userland write sysfs file */
41549 - dev_attr_bluetooth.store = store_bluetooth;
41550 - dev_attr_wlan.store = store_wlan;
41551 - dev_attr_threeg.store = store_threeg;
41552 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
41553 - dev_attr_wlan.attr.mode |= S_IWUSR;
41554 - dev_attr_threeg.attr.mode |= S_IWUSR;
41555 + pax_open_kernel();
41556 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
41557 + *(void **)&dev_attr_wlan.store = store_wlan;
41558 + *(void **)&dev_attr_threeg.store = store_threeg;
41559 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
41560 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
41561 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
41562 + pax_close_kernel();
41563 }
41564
41565 /* disable hardware control by fn key */
41566 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
41567 index 2ac045f..39c443d 100644
41568 --- a/drivers/platform/x86/sony-laptop.c
41569 +++ b/drivers/platform/x86/sony-laptop.c
41570 @@ -2483,7 +2483,7 @@ static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
41571 }
41572
41573 /* High speed charging function */
41574 -static struct device_attribute *hsc_handle;
41575 +static device_attribute_no_const *hsc_handle;
41576
41577 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
41578 struct device_attribute *attr,
41579 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
41580 index 54d31c0..3f896d3 100644
41581 --- a/drivers/platform/x86/thinkpad_acpi.c
41582 +++ b/drivers/platform/x86/thinkpad_acpi.c
41583 @@ -2093,7 +2093,7 @@ static int hotkey_mask_get(void)
41584 return 0;
41585 }
41586
41587 -void static hotkey_mask_warn_incomplete_mask(void)
41588 +static void hotkey_mask_warn_incomplete_mask(void)
41589 {
41590 /* log only what the user can fix... */
41591 const u32 wantedmask = hotkey_driver_mask &
41592 @@ -2324,11 +2324,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
41593 }
41594 }
41595
41596 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41597 - struct tp_nvram_state *newn,
41598 - const u32 event_mask)
41599 -{
41600 -
41601 #define TPACPI_COMPARE_KEY(__scancode, __member) \
41602 do { \
41603 if ((event_mask & (1 << __scancode)) && \
41604 @@ -2342,36 +2337,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41605 tpacpi_hotkey_send_key(__scancode); \
41606 } while (0)
41607
41608 - void issue_volchange(const unsigned int oldvol,
41609 - const unsigned int newvol)
41610 - {
41611 - unsigned int i = oldvol;
41612 +static void issue_volchange(const unsigned int oldvol,
41613 + const unsigned int newvol,
41614 + const u32 event_mask)
41615 +{
41616 + unsigned int i = oldvol;
41617
41618 - while (i > newvol) {
41619 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
41620 - i--;
41621 - }
41622 - while (i < newvol) {
41623 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41624 - i++;
41625 - }
41626 + while (i > newvol) {
41627 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
41628 + i--;
41629 }
41630 + while (i < newvol) {
41631 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41632 + i++;
41633 + }
41634 +}
41635
41636 - void issue_brightnesschange(const unsigned int oldbrt,
41637 - const unsigned int newbrt)
41638 - {
41639 - unsigned int i = oldbrt;
41640 +static void issue_brightnesschange(const unsigned int oldbrt,
41641 + const unsigned int newbrt,
41642 + const u32 event_mask)
41643 +{
41644 + unsigned int i = oldbrt;
41645
41646 - while (i > newbrt) {
41647 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
41648 - i--;
41649 - }
41650 - while (i < newbrt) {
41651 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41652 - i++;
41653 - }
41654 + while (i > newbrt) {
41655 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
41656 + i--;
41657 + }
41658 + while (i < newbrt) {
41659 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41660 + i++;
41661 }
41662 +}
41663
41664 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41665 + struct tp_nvram_state *newn,
41666 + const u32 event_mask)
41667 +{
41668 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
41669 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
41670 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
41671 @@ -2405,7 +2406,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41672 oldn->volume_level != newn->volume_level) {
41673 /* recently muted, or repeated mute keypress, or
41674 * multiple presses ending in mute */
41675 - issue_volchange(oldn->volume_level, newn->volume_level);
41676 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
41677 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
41678 }
41679 } else {
41680 @@ -2415,7 +2416,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41681 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
41682 }
41683 if (oldn->volume_level != newn->volume_level) {
41684 - issue_volchange(oldn->volume_level, newn->volume_level);
41685 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
41686 } else if (oldn->volume_toggle != newn->volume_toggle) {
41687 /* repeated vol up/down keypress at end of scale ? */
41688 if (newn->volume_level == 0)
41689 @@ -2428,7 +2429,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41690 /* handle brightness */
41691 if (oldn->brightness_level != newn->brightness_level) {
41692 issue_brightnesschange(oldn->brightness_level,
41693 - newn->brightness_level);
41694 + newn->brightness_level,
41695 + event_mask);
41696 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
41697 /* repeated key presses that didn't change state */
41698 if (newn->brightness_level == 0)
41699 @@ -2437,10 +2439,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
41700 && !tp_features.bright_unkfw)
41701 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
41702 }
41703 +}
41704
41705 #undef TPACPI_COMPARE_KEY
41706 #undef TPACPI_MAY_SEND_KEY
41707 -}
41708
41709 /*
41710 * Polling driver
41711 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
41712 index 769d265..a3a05ca 100644
41713 --- a/drivers/pnp/pnpbios/bioscalls.c
41714 +++ b/drivers/pnp/pnpbios/bioscalls.c
41715 @@ -58,7 +58,7 @@ do { \
41716 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
41717 } while(0)
41718
41719 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
41720 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
41721 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
41722
41723 /*
41724 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
41725
41726 cpu = get_cpu();
41727 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
41728 +
41729 + pax_open_kernel();
41730 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
41731 + pax_close_kernel();
41732
41733 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
41734 spin_lock_irqsave(&pnp_bios_lock, flags);
41735 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
41736 :"memory");
41737 spin_unlock_irqrestore(&pnp_bios_lock, flags);
41738
41739 + pax_open_kernel();
41740 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
41741 + pax_close_kernel();
41742 +
41743 put_cpu();
41744
41745 /* If we get here and this is set then the PnP BIOS faulted on us. */
41746 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
41747 return status;
41748 }
41749
41750 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
41751 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
41752 {
41753 int i;
41754
41755 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
41756 pnp_bios_callpoint.offset = header->fields.pm16offset;
41757 pnp_bios_callpoint.segment = PNP_CS16;
41758
41759 + pax_open_kernel();
41760 +
41761 for_each_possible_cpu(i) {
41762 struct desc_struct *gdt = get_cpu_gdt_table(i);
41763 if (!gdt)
41764 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
41765 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
41766 (unsigned long)__va(header->fields.pm16dseg));
41767 }
41768 +
41769 + pax_close_kernel();
41770 }
41771 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
41772 index 3e6db1c..1fbbdae 100644
41773 --- a/drivers/pnp/resource.c
41774 +++ b/drivers/pnp/resource.c
41775 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
41776 return 1;
41777
41778 /* check if the resource is valid */
41779 - if (*irq < 0 || *irq > 15)
41780 + if (*irq > 15)
41781 return 0;
41782
41783 /* check if the resource is reserved */
41784 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
41785 return 1;
41786
41787 /* check if the resource is valid */
41788 - if (*dma < 0 || *dma == 4 || *dma > 7)
41789 + if (*dma == 4 || *dma > 7)
41790 return 0;
41791
41792 /* check if the resource is reserved */
41793 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
41794 index 0c52e2a..3421ab7 100644
41795 --- a/drivers/power/pda_power.c
41796 +++ b/drivers/power/pda_power.c
41797 @@ -37,7 +37,11 @@ static int polling;
41798
41799 #if IS_ENABLED(CONFIG_USB_PHY)
41800 static struct usb_phy *transceiver;
41801 -static struct notifier_block otg_nb;
41802 +static int otg_handle_notification(struct notifier_block *nb,
41803 + unsigned long event, void *unused);
41804 +static struct notifier_block otg_nb = {
41805 + .notifier_call = otg_handle_notification
41806 +};
41807 #endif
41808
41809 static struct regulator *ac_draw;
41810 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
41811
41812 #if IS_ENABLED(CONFIG_USB_PHY)
41813 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
41814 - otg_nb.notifier_call = otg_handle_notification;
41815 ret = usb_register_notifier(transceiver, &otg_nb);
41816 if (ret) {
41817 dev_err(dev, "failure to register otg notifier\n");
41818 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
41819 index cc439fd..8fa30df 100644
41820 --- a/drivers/power/power_supply.h
41821 +++ b/drivers/power/power_supply.h
41822 @@ -16,12 +16,12 @@ struct power_supply;
41823
41824 #ifdef CONFIG_SYSFS
41825
41826 -extern void power_supply_init_attrs(struct device_type *dev_type);
41827 +extern void power_supply_init_attrs(void);
41828 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
41829
41830 #else
41831
41832 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
41833 +static inline void power_supply_init_attrs(void) {}
41834 #define power_supply_uevent NULL
41835
41836 #endif /* CONFIG_SYSFS */
41837 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
41838 index 1c517c3..ffa2f17 100644
41839 --- a/drivers/power/power_supply_core.c
41840 +++ b/drivers/power/power_supply_core.c
41841 @@ -24,7 +24,10 @@
41842 struct class *power_supply_class;
41843 EXPORT_SYMBOL_GPL(power_supply_class);
41844
41845 -static struct device_type power_supply_dev_type;
41846 +extern const struct attribute_group *power_supply_attr_groups[];
41847 +static struct device_type power_supply_dev_type = {
41848 + .groups = power_supply_attr_groups,
41849 +};
41850
41851 static bool __power_supply_is_supplied_by(struct power_supply *supplier,
41852 struct power_supply *supply)
41853 @@ -554,7 +557,7 @@ static int __init power_supply_class_init(void)
41854 return PTR_ERR(power_supply_class);
41855
41856 power_supply_class->dev_uevent = power_supply_uevent;
41857 - power_supply_init_attrs(&power_supply_dev_type);
41858 + power_supply_init_attrs();
41859
41860 return 0;
41861 }
41862 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
41863 index 29178f7..c65f324 100644
41864 --- a/drivers/power/power_supply_sysfs.c
41865 +++ b/drivers/power/power_supply_sysfs.c
41866 @@ -230,17 +230,15 @@ static struct attribute_group power_supply_attr_group = {
41867 .is_visible = power_supply_attr_is_visible,
41868 };
41869
41870 -static const struct attribute_group *power_supply_attr_groups[] = {
41871 +const struct attribute_group *power_supply_attr_groups[] = {
41872 &power_supply_attr_group,
41873 NULL,
41874 };
41875
41876 -void power_supply_init_attrs(struct device_type *dev_type)
41877 +void power_supply_init_attrs(void)
41878 {
41879 int i;
41880
41881 - dev_type->groups = power_supply_attr_groups;
41882 -
41883 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
41884 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
41885 }
41886 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
41887 index d428ef9..fdc0357 100644
41888 --- a/drivers/regulator/max8660.c
41889 +++ b/drivers/regulator/max8660.c
41890 @@ -333,8 +333,10 @@ static int max8660_probe(struct i2c_client *client,
41891 max8660->shadow_regs[MAX8660_OVER1] = 5;
41892 } else {
41893 /* Otherwise devices can be toggled via software */
41894 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
41895 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
41896 + pax_open_kernel();
41897 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
41898 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
41899 + pax_close_kernel();
41900 }
41901
41902 /*
41903 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
41904 index adb1414..c13e0ce 100644
41905 --- a/drivers/regulator/max8973-regulator.c
41906 +++ b/drivers/regulator/max8973-regulator.c
41907 @@ -401,9 +401,11 @@ static int max8973_probe(struct i2c_client *client,
41908 if (!pdata->enable_ext_control) {
41909 max->desc.enable_reg = MAX8973_VOUT;
41910 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
41911 - max8973_dcdc_ops.enable = regulator_enable_regmap;
41912 - max8973_dcdc_ops.disable = regulator_disable_regmap;
41913 - max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41914 + pax_open_kernel();
41915 + *(void **)&max8973_dcdc_ops.enable = regulator_enable_regmap;
41916 + *(void **)&max8973_dcdc_ops.disable = regulator_disable_regmap;
41917 + *(void **)&max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
41918 + pax_close_kernel();
41919 }
41920
41921 max->enable_external_control = pdata->enable_ext_control;
41922 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
41923 index b716283..3cc4349 100644
41924 --- a/drivers/regulator/mc13892-regulator.c
41925 +++ b/drivers/regulator/mc13892-regulator.c
41926 @@ -582,10 +582,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
41927 }
41928 mc13xxx_unlock(mc13892);
41929
41930 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
41931 + pax_open_kernel();
41932 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
41933 = mc13892_vcam_set_mode;
41934 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
41935 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
41936 = mc13892_vcam_get_mode;
41937 + pax_close_kernel();
41938
41939 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
41940 ARRAY_SIZE(mc13892_regulators));
41941 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
41942 index f1cb706..4c7832a 100644
41943 --- a/drivers/rtc/rtc-cmos.c
41944 +++ b/drivers/rtc/rtc-cmos.c
41945 @@ -724,7 +724,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
41946 hpet_rtc_timer_init();
41947
41948 /* export at least the first block of NVRAM */
41949 - nvram.size = address_space - NVRAM_OFFSET;
41950 + pax_open_kernel();
41951 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
41952 + pax_close_kernel();
41953 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
41954 if (retval < 0) {
41955 dev_dbg(dev, "can't create nvram file? %d\n", retval);
41956 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
41957 index d049393..bb20be0 100644
41958 --- a/drivers/rtc/rtc-dev.c
41959 +++ b/drivers/rtc/rtc-dev.c
41960 @@ -16,6 +16,7 @@
41961 #include <linux/module.h>
41962 #include <linux/rtc.h>
41963 #include <linux/sched.h>
41964 +#include <linux/grsecurity.h>
41965 #include "rtc-core.h"
41966
41967 static dev_t rtc_devt;
41968 @@ -347,6 +348,8 @@ static long rtc_dev_ioctl(struct file *file,
41969 if (copy_from_user(&tm, uarg, sizeof(tm)))
41970 return -EFAULT;
41971
41972 + gr_log_timechange();
41973 +
41974 return rtc_set_time(rtc, &tm);
41975
41976 case RTC_PIE_ON:
41977 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
41978 index b53992a..776df84 100644
41979 --- a/drivers/rtc/rtc-ds1307.c
41980 +++ b/drivers/rtc/rtc-ds1307.c
41981 @@ -107,7 +107,7 @@ struct ds1307 {
41982 u8 offset; /* register's offset */
41983 u8 regs[11];
41984 u16 nvram_offset;
41985 - struct bin_attribute *nvram;
41986 + bin_attribute_no_const *nvram;
41987 enum ds_type type;
41988 unsigned long flags;
41989 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
41990 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
41991 index 130f29a..6179d03 100644
41992 --- a/drivers/rtc/rtc-m48t59.c
41993 +++ b/drivers/rtc/rtc-m48t59.c
41994 @@ -482,7 +482,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
41995 goto out;
41996 }
41997
41998 - m48t59_nvram_attr.size = pdata->offset;
41999 + pax_open_kernel();
42000 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
42001 + pax_close_kernel();
42002
42003 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
42004 if (ret) {
42005 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
42006 index e693af6..2e525b6 100644
42007 --- a/drivers/scsi/bfa/bfa_fcpim.h
42008 +++ b/drivers/scsi/bfa/bfa_fcpim.h
42009 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
42010
42011 struct bfa_itn_s {
42012 bfa_isr_func_t isr;
42013 -};
42014 +} __no_const;
42015
42016 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
42017 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
42018 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
42019 index 23a90e7..9cf04ee 100644
42020 --- a/drivers/scsi/bfa/bfa_ioc.h
42021 +++ b/drivers/scsi/bfa/bfa_ioc.h
42022 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
42023 bfa_ioc_disable_cbfn_t disable_cbfn;
42024 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
42025 bfa_ioc_reset_cbfn_t reset_cbfn;
42026 -};
42027 +} __no_const;
42028
42029 /*
42030 * IOC event notification mechanism.
42031 @@ -346,7 +346,7 @@ struct bfa_ioc_hwif_s {
42032 void (*ioc_sync_ack) (struct bfa_ioc_s *ioc);
42033 bfa_boolean_t (*ioc_sync_complete) (struct bfa_ioc_s *ioc);
42034 bfa_boolean_t (*ioc_lpu_read_stat) (struct bfa_ioc_s *ioc);
42035 -};
42036 +} __no_const;
42037
42038 /*
42039 * Queue element to wait for room in request queue. FIFO order is
42040 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
42041 index df0c3c7..b00e1d0 100644
42042 --- a/drivers/scsi/hosts.c
42043 +++ b/drivers/scsi/hosts.c
42044 @@ -42,7 +42,7 @@
42045 #include "scsi_logging.h"
42046
42047
42048 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
42049 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
42050
42051
42052 static void scsi_host_cls_release(struct device *dev)
42053 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
42054 * subtract one because we increment first then return, but we need to
42055 * know what the next host number was before increment
42056 */
42057 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
42058 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
42059 shost->dma_channel = 0xff;
42060
42061 /* These three are default values which can be overridden */
42062 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
42063 index 7f4f790..b75b92a 100644
42064 --- a/drivers/scsi/hpsa.c
42065 +++ b/drivers/scsi/hpsa.c
42066 @@ -554,7 +554,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
42067 unsigned long flags;
42068
42069 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
42070 - return h->access.command_completed(h, q);
42071 + return h->access->command_completed(h, q);
42072
42073 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
42074 a = rq->head[rq->current_entry];
42075 @@ -3422,7 +3422,7 @@ static void start_io(struct ctlr_info *h)
42076 while (!list_empty(&h->reqQ)) {
42077 c = list_entry(h->reqQ.next, struct CommandList, list);
42078 /* can't do anything if fifo is full */
42079 - if ((h->access.fifo_full(h))) {
42080 + if ((h->access->fifo_full(h))) {
42081 dev_warn(&h->pdev->dev, "fifo full\n");
42082 break;
42083 }
42084 @@ -3444,7 +3444,7 @@ static void start_io(struct ctlr_info *h)
42085
42086 /* Tell the controller execute command */
42087 spin_unlock_irqrestore(&h->lock, flags);
42088 - h->access.submit_command(h, c);
42089 + h->access->submit_command(h, c);
42090 spin_lock_irqsave(&h->lock, flags);
42091 }
42092 spin_unlock_irqrestore(&h->lock, flags);
42093 @@ -3452,17 +3452,17 @@ static void start_io(struct ctlr_info *h)
42094
42095 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
42096 {
42097 - return h->access.command_completed(h, q);
42098 + return h->access->command_completed(h, q);
42099 }
42100
42101 static inline bool interrupt_pending(struct ctlr_info *h)
42102 {
42103 - return h->access.intr_pending(h);
42104 + return h->access->intr_pending(h);
42105 }
42106
42107 static inline long interrupt_not_for_us(struct ctlr_info *h)
42108 {
42109 - return (h->access.intr_pending(h) == 0) ||
42110 + return (h->access->intr_pending(h) == 0) ||
42111 (h->interrupts_enabled == 0);
42112 }
42113
42114 @@ -4364,7 +4364,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
42115 if (prod_index < 0)
42116 return -ENODEV;
42117 h->product_name = products[prod_index].product_name;
42118 - h->access = *(products[prod_index].access);
42119 + h->access = products[prod_index].access;
42120
42121 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
42122 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
42123 @@ -4646,7 +4646,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
42124
42125 assert_spin_locked(&lockup_detector_lock);
42126 remove_ctlr_from_lockup_detector_list(h);
42127 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42128 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42129 spin_lock_irqsave(&h->lock, flags);
42130 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
42131 spin_unlock_irqrestore(&h->lock, flags);
42132 @@ -4823,7 +4823,7 @@ reinit_after_soft_reset:
42133 }
42134
42135 /* make sure the board interrupts are off */
42136 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42137 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42138
42139 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
42140 goto clean2;
42141 @@ -4857,7 +4857,7 @@ reinit_after_soft_reset:
42142 * fake ones to scoop up any residual completions.
42143 */
42144 spin_lock_irqsave(&h->lock, flags);
42145 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42146 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42147 spin_unlock_irqrestore(&h->lock, flags);
42148 free_irqs(h);
42149 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
42150 @@ -4876,9 +4876,9 @@ reinit_after_soft_reset:
42151 dev_info(&h->pdev->dev, "Board READY.\n");
42152 dev_info(&h->pdev->dev,
42153 "Waiting for stale completions to drain.\n");
42154 - h->access.set_intr_mask(h, HPSA_INTR_ON);
42155 + h->access->set_intr_mask(h, HPSA_INTR_ON);
42156 msleep(10000);
42157 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42158 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42159
42160 rc = controller_reset_failed(h->cfgtable);
42161 if (rc)
42162 @@ -4899,7 +4899,7 @@ reinit_after_soft_reset:
42163 }
42164
42165 /* Turn the interrupts on so we can service requests */
42166 - h->access.set_intr_mask(h, HPSA_INTR_ON);
42167 + h->access->set_intr_mask(h, HPSA_INTR_ON);
42168
42169 hpsa_hba_inquiry(h);
42170 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
42171 @@ -4954,7 +4954,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
42172 * To write all data in the battery backed cache to disks
42173 */
42174 hpsa_flush_cache(h);
42175 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
42176 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
42177 hpsa_free_irqs_and_disable_msix(h);
42178 }
42179
42180 @@ -5122,7 +5122,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
42181 return;
42182 }
42183 /* Change the access methods to the performant access methods */
42184 - h->access = SA5_performant_access;
42185 + h->access = &SA5_performant_access;
42186 h->transMethod = CFGTBL_Trans_Performant;
42187 }
42188
42189 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
42190 index 9816479..c5d4e97 100644
42191 --- a/drivers/scsi/hpsa.h
42192 +++ b/drivers/scsi/hpsa.h
42193 @@ -79,7 +79,7 @@ struct ctlr_info {
42194 unsigned int msix_vector;
42195 unsigned int msi_vector;
42196 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
42197 - struct access_method access;
42198 + struct access_method *access;
42199
42200 /* queue and queue Info */
42201 struct list_head reqQ;
42202 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
42203 index 8b928c6..9c76300 100644
42204 --- a/drivers/scsi/libfc/fc_exch.c
42205 +++ b/drivers/scsi/libfc/fc_exch.c
42206 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
42207 u16 pool_max_index;
42208
42209 struct {
42210 - atomic_t no_free_exch;
42211 - atomic_t no_free_exch_xid;
42212 - atomic_t xid_not_found;
42213 - atomic_t xid_busy;
42214 - atomic_t seq_not_found;
42215 - atomic_t non_bls_resp;
42216 + atomic_unchecked_t no_free_exch;
42217 + atomic_unchecked_t no_free_exch_xid;
42218 + atomic_unchecked_t xid_not_found;
42219 + atomic_unchecked_t xid_busy;
42220 + atomic_unchecked_t seq_not_found;
42221 + atomic_unchecked_t non_bls_resp;
42222 } stats;
42223 };
42224
42225 @@ -736,7 +736,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
42226 /* allocate memory for exchange */
42227 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
42228 if (!ep) {
42229 - atomic_inc(&mp->stats.no_free_exch);
42230 + atomic_inc_unchecked(&mp->stats.no_free_exch);
42231 goto out;
42232 }
42233 memset(ep, 0, sizeof(*ep));
42234 @@ -797,7 +797,7 @@ out:
42235 return ep;
42236 err:
42237 spin_unlock_bh(&pool->lock);
42238 - atomic_inc(&mp->stats.no_free_exch_xid);
42239 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
42240 mempool_free(ep, mp->ep_pool);
42241 return NULL;
42242 }
42243 @@ -940,7 +940,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42244 xid = ntohs(fh->fh_ox_id); /* we originated exch */
42245 ep = fc_exch_find(mp, xid);
42246 if (!ep) {
42247 - atomic_inc(&mp->stats.xid_not_found);
42248 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42249 reject = FC_RJT_OX_ID;
42250 goto out;
42251 }
42252 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42253 ep = fc_exch_find(mp, xid);
42254 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
42255 if (ep) {
42256 - atomic_inc(&mp->stats.xid_busy);
42257 + atomic_inc_unchecked(&mp->stats.xid_busy);
42258 reject = FC_RJT_RX_ID;
42259 goto rel;
42260 }
42261 @@ -981,7 +981,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42262 }
42263 xid = ep->xid; /* get our XID */
42264 } else if (!ep) {
42265 - atomic_inc(&mp->stats.xid_not_found);
42266 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42267 reject = FC_RJT_RX_ID; /* XID not found */
42268 goto out;
42269 }
42270 @@ -998,7 +998,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
42271 } else {
42272 sp = &ep->seq;
42273 if (sp->id != fh->fh_seq_id) {
42274 - atomic_inc(&mp->stats.seq_not_found);
42275 + atomic_inc_unchecked(&mp->stats.seq_not_found);
42276 if (f_ctl & FC_FC_END_SEQ) {
42277 /*
42278 * Update sequence_id based on incoming last
42279 @@ -1448,22 +1448,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42280
42281 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
42282 if (!ep) {
42283 - atomic_inc(&mp->stats.xid_not_found);
42284 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42285 goto out;
42286 }
42287 if (ep->esb_stat & ESB_ST_COMPLETE) {
42288 - atomic_inc(&mp->stats.xid_not_found);
42289 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42290 goto rel;
42291 }
42292 if (ep->rxid == FC_XID_UNKNOWN)
42293 ep->rxid = ntohs(fh->fh_rx_id);
42294 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
42295 - atomic_inc(&mp->stats.xid_not_found);
42296 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42297 goto rel;
42298 }
42299 if (ep->did != ntoh24(fh->fh_s_id) &&
42300 ep->did != FC_FID_FLOGI) {
42301 - atomic_inc(&mp->stats.xid_not_found);
42302 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42303 goto rel;
42304 }
42305 sof = fr_sof(fp);
42306 @@ -1472,7 +1472,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42307 sp->ssb_stat |= SSB_ST_RESP;
42308 sp->id = fh->fh_seq_id;
42309 } else if (sp->id != fh->fh_seq_id) {
42310 - atomic_inc(&mp->stats.seq_not_found);
42311 + atomic_inc_unchecked(&mp->stats.seq_not_found);
42312 goto rel;
42313 }
42314
42315 @@ -1536,9 +1536,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
42316 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
42317
42318 if (!sp)
42319 - atomic_inc(&mp->stats.xid_not_found);
42320 + atomic_inc_unchecked(&mp->stats.xid_not_found);
42321 else
42322 - atomic_inc(&mp->stats.non_bls_resp);
42323 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
42324
42325 fc_frame_free(fp);
42326 }
42327 @@ -2185,13 +2185,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
42328
42329 list_for_each_entry(ema, &lport->ema_list, ema_list) {
42330 mp = ema->mp;
42331 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
42332 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
42333 st->fc_no_free_exch_xid +=
42334 - atomic_read(&mp->stats.no_free_exch_xid);
42335 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
42336 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
42337 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
42338 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
42339 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
42340 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
42341 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
42342 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
42343 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
42344 }
42345 }
42346 EXPORT_SYMBOL(fc_exch_update_stats);
42347 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
42348 index 161c98e..6d563b3 100644
42349 --- a/drivers/scsi/libsas/sas_ata.c
42350 +++ b/drivers/scsi/libsas/sas_ata.c
42351 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
42352 .postreset = ata_std_postreset,
42353 .error_handler = ata_std_error_handler,
42354 .post_internal_cmd = sas_ata_post_internal,
42355 - .qc_defer = ata_std_qc_defer,
42356 + .qc_defer = ata_std_qc_defer,
42357 .qc_prep = ata_noop_qc_prep,
42358 .qc_issue = sas_ata_qc_issue,
42359 .qc_fill_rtf = sas_ata_qc_fill_rtf,
42360 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
42361 index bcc56ca..6f4174a 100644
42362 --- a/drivers/scsi/lpfc/lpfc.h
42363 +++ b/drivers/scsi/lpfc/lpfc.h
42364 @@ -431,7 +431,7 @@ struct lpfc_vport {
42365 struct dentry *debug_nodelist;
42366 struct dentry *vport_debugfs_root;
42367 struct lpfc_debugfs_trc *disc_trc;
42368 - atomic_t disc_trc_cnt;
42369 + atomic_unchecked_t disc_trc_cnt;
42370 #endif
42371 uint8_t stat_data_enabled;
42372 uint8_t stat_data_blocked;
42373 @@ -865,8 +865,8 @@ struct lpfc_hba {
42374 struct timer_list fabric_block_timer;
42375 unsigned long bit_flags;
42376 #define FABRIC_COMANDS_BLOCKED 0
42377 - atomic_t num_rsrc_err;
42378 - atomic_t num_cmd_success;
42379 + atomic_unchecked_t num_rsrc_err;
42380 + atomic_unchecked_t num_cmd_success;
42381 unsigned long last_rsrc_error_time;
42382 unsigned long last_ramp_down_time;
42383 unsigned long last_ramp_up_time;
42384 @@ -902,7 +902,7 @@ struct lpfc_hba {
42385
42386 struct dentry *debug_slow_ring_trc;
42387 struct lpfc_debugfs_trc *slow_ring_trc;
42388 - atomic_t slow_ring_trc_cnt;
42389 + atomic_unchecked_t slow_ring_trc_cnt;
42390 /* iDiag debugfs sub-directory */
42391 struct dentry *idiag_root;
42392 struct dentry *idiag_pci_cfg;
42393 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
42394 index f525ecb..32549a4 100644
42395 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
42396 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
42397 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
42398
42399 #include <linux/debugfs.h>
42400
42401 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
42402 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
42403 static unsigned long lpfc_debugfs_start_time = 0L;
42404
42405 /* iDiag */
42406 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
42407 lpfc_debugfs_enable = 0;
42408
42409 len = 0;
42410 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
42411 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
42412 (lpfc_debugfs_max_disc_trc - 1);
42413 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
42414 dtp = vport->disc_trc + i;
42415 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
42416 lpfc_debugfs_enable = 0;
42417
42418 len = 0;
42419 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
42420 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
42421 (lpfc_debugfs_max_slow_ring_trc - 1);
42422 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
42423 dtp = phba->slow_ring_trc + i;
42424 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
42425 !vport || !vport->disc_trc)
42426 return;
42427
42428 - index = atomic_inc_return(&vport->disc_trc_cnt) &
42429 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
42430 (lpfc_debugfs_max_disc_trc - 1);
42431 dtp = vport->disc_trc + index;
42432 dtp->fmt = fmt;
42433 dtp->data1 = data1;
42434 dtp->data2 = data2;
42435 dtp->data3 = data3;
42436 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
42437 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
42438 dtp->jif = jiffies;
42439 #endif
42440 return;
42441 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
42442 !phba || !phba->slow_ring_trc)
42443 return;
42444
42445 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
42446 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
42447 (lpfc_debugfs_max_slow_ring_trc - 1);
42448 dtp = phba->slow_ring_trc + index;
42449 dtp->fmt = fmt;
42450 dtp->data1 = data1;
42451 dtp->data2 = data2;
42452 dtp->data3 = data3;
42453 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
42454 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
42455 dtp->jif = jiffies;
42456 #endif
42457 return;
42458 @@ -4182,7 +4182,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42459 "slow_ring buffer\n");
42460 goto debug_failed;
42461 }
42462 - atomic_set(&phba->slow_ring_trc_cnt, 0);
42463 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
42464 memset(phba->slow_ring_trc, 0,
42465 (sizeof(struct lpfc_debugfs_trc) *
42466 lpfc_debugfs_max_slow_ring_trc));
42467 @@ -4228,7 +4228,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
42468 "buffer\n");
42469 goto debug_failed;
42470 }
42471 - atomic_set(&vport->disc_trc_cnt, 0);
42472 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
42473
42474 snprintf(name, sizeof(name), "discovery_trace");
42475 vport->debug_disc_trc =
42476 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
42477 index cb465b2..2e7b25f 100644
42478 --- a/drivers/scsi/lpfc/lpfc_init.c
42479 +++ b/drivers/scsi/lpfc/lpfc_init.c
42480 @@ -10950,8 +10950,10 @@ lpfc_init(void)
42481 "misc_register returned with status %d", error);
42482
42483 if (lpfc_enable_npiv) {
42484 - lpfc_transport_functions.vport_create = lpfc_vport_create;
42485 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
42486 + pax_open_kernel();
42487 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
42488 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
42489 + pax_close_kernel();
42490 }
42491 lpfc_transport_template =
42492 fc_attach_transport(&lpfc_transport_functions);
42493 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
42494 index 8523b278e..ce1d812 100644
42495 --- a/drivers/scsi/lpfc/lpfc_scsi.c
42496 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
42497 @@ -331,7 +331,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
42498 uint32_t evt_posted;
42499
42500 spin_lock_irqsave(&phba->hbalock, flags);
42501 - atomic_inc(&phba->num_rsrc_err);
42502 + atomic_inc_unchecked(&phba->num_rsrc_err);
42503 phba->last_rsrc_error_time = jiffies;
42504
42505 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
42506 @@ -372,7 +372,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
42507 unsigned long flags;
42508 struct lpfc_hba *phba = vport->phba;
42509 uint32_t evt_posted;
42510 - atomic_inc(&phba->num_cmd_success);
42511 + atomic_inc_unchecked(&phba->num_cmd_success);
42512
42513 if (vport->cfg_lun_queue_depth <= queue_depth)
42514 return;
42515 @@ -416,8 +416,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
42516 unsigned long num_rsrc_err, num_cmd_success;
42517 int i;
42518
42519 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
42520 - num_cmd_success = atomic_read(&phba->num_cmd_success);
42521 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
42522 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
42523
42524 /*
42525 * The error and success command counters are global per
42526 @@ -445,8 +445,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
42527 }
42528 }
42529 lpfc_destroy_vport_work_array(phba, vports);
42530 - atomic_set(&phba->num_rsrc_err, 0);
42531 - atomic_set(&phba->num_cmd_success, 0);
42532 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
42533 + atomic_set_unchecked(&phba->num_cmd_success, 0);
42534 }
42535
42536 /**
42537 @@ -480,8 +480,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
42538 }
42539 }
42540 lpfc_destroy_vport_work_array(phba, vports);
42541 - atomic_set(&phba->num_rsrc_err, 0);
42542 - atomic_set(&phba->num_cmd_success, 0);
42543 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
42544 + atomic_set_unchecked(&phba->num_cmd_success, 0);
42545 }
42546
42547 /**
42548 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
42549 index 8e1b737..50ff510 100644
42550 --- a/drivers/scsi/pmcraid.c
42551 +++ b/drivers/scsi/pmcraid.c
42552 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
42553 res->scsi_dev = scsi_dev;
42554 scsi_dev->hostdata = res;
42555 res->change_detected = 0;
42556 - atomic_set(&res->read_failures, 0);
42557 - atomic_set(&res->write_failures, 0);
42558 + atomic_set_unchecked(&res->read_failures, 0);
42559 + atomic_set_unchecked(&res->write_failures, 0);
42560 rc = 0;
42561 }
42562 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
42563 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
42564
42565 /* If this was a SCSI read/write command keep count of errors */
42566 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
42567 - atomic_inc(&res->read_failures);
42568 + atomic_inc_unchecked(&res->read_failures);
42569 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
42570 - atomic_inc(&res->write_failures);
42571 + atomic_inc_unchecked(&res->write_failures);
42572
42573 if (!RES_IS_GSCSI(res->cfg_entry) &&
42574 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
42575 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
42576 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
42577 * hrrq_id assigned here in queuecommand
42578 */
42579 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
42580 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
42581 pinstance->num_hrrq;
42582 cmd->cmd_done = pmcraid_io_done;
42583
42584 @@ -3846,7 +3846,7 @@ static long pmcraid_ioctl_passthrough(
42585 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
42586 * hrrq_id assigned here in queuecommand
42587 */
42588 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
42589 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
42590 pinstance->num_hrrq;
42591
42592 if (request_size) {
42593 @@ -4483,7 +4483,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
42594
42595 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
42596 /* add resources only after host is added into system */
42597 - if (!atomic_read(&pinstance->expose_resources))
42598 + if (!atomic_read_unchecked(&pinstance->expose_resources))
42599 return;
42600
42601 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
42602 @@ -5310,8 +5310,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
42603 init_waitqueue_head(&pinstance->reset_wait_q);
42604
42605 atomic_set(&pinstance->outstanding_cmds, 0);
42606 - atomic_set(&pinstance->last_message_id, 0);
42607 - atomic_set(&pinstance->expose_resources, 0);
42608 + atomic_set_unchecked(&pinstance->last_message_id, 0);
42609 + atomic_set_unchecked(&pinstance->expose_resources, 0);
42610
42611 INIT_LIST_HEAD(&pinstance->free_res_q);
42612 INIT_LIST_HEAD(&pinstance->used_res_q);
42613 @@ -6024,7 +6024,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
42614 /* Schedule worker thread to handle CCN and take care of adding and
42615 * removing devices to OS
42616 */
42617 - atomic_set(&pinstance->expose_resources, 1);
42618 + atomic_set_unchecked(&pinstance->expose_resources, 1);
42619 schedule_work(&pinstance->worker_q);
42620 return rc;
42621
42622 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
42623 index e1d150f..6c6df44 100644
42624 --- a/drivers/scsi/pmcraid.h
42625 +++ b/drivers/scsi/pmcraid.h
42626 @@ -748,7 +748,7 @@ struct pmcraid_instance {
42627 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
42628
42629 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
42630 - atomic_t last_message_id;
42631 + atomic_unchecked_t last_message_id;
42632
42633 /* configuration table */
42634 struct pmcraid_config_table *cfg_table;
42635 @@ -777,7 +777,7 @@ struct pmcraid_instance {
42636 atomic_t outstanding_cmds;
42637
42638 /* should add/delete resources to mid-layer now ?*/
42639 - atomic_t expose_resources;
42640 + atomic_unchecked_t expose_resources;
42641
42642
42643
42644 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
42645 struct pmcraid_config_table_entry_ext cfg_entry_ext;
42646 };
42647 struct scsi_device *scsi_dev; /* Link scsi_device structure */
42648 - atomic_t read_failures; /* count of failed READ commands */
42649 - atomic_t write_failures; /* count of failed WRITE commands */
42650 + atomic_unchecked_t read_failures; /* count of failed READ commands */
42651 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
42652
42653 /* To indicate add/delete/modify during CCN */
42654 u8 change_detected;
42655 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
42656 index bf60c63..74d4dce 100644
42657 --- a/drivers/scsi/qla2xxx/qla_attr.c
42658 +++ b/drivers/scsi/qla2xxx/qla_attr.c
42659 @@ -2001,7 +2001,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
42660 return 0;
42661 }
42662
42663 -struct fc_function_template qla2xxx_transport_functions = {
42664 +fc_function_template_no_const qla2xxx_transport_functions = {
42665
42666 .show_host_node_name = 1,
42667 .show_host_port_name = 1,
42668 @@ -2048,7 +2048,7 @@ struct fc_function_template qla2xxx_transport_functions = {
42669 .bsg_timeout = qla24xx_bsg_timeout,
42670 };
42671
42672 -struct fc_function_template qla2xxx_transport_vport_functions = {
42673 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
42674
42675 .show_host_node_name = 1,
42676 .show_host_port_name = 1,
42677 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
42678 index 026bfde..90c4018 100644
42679 --- a/drivers/scsi/qla2xxx/qla_gbl.h
42680 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
42681 @@ -528,8 +528,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
42682 struct device_attribute;
42683 extern struct device_attribute *qla2x00_host_attrs[];
42684 struct fc_function_template;
42685 -extern struct fc_function_template qla2xxx_transport_functions;
42686 -extern struct fc_function_template qla2xxx_transport_vport_functions;
42687 +extern fc_function_template_no_const qla2xxx_transport_functions;
42688 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
42689 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
42690 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
42691 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
42692 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
42693 index ad72c1d..afc9a98 100644
42694 --- a/drivers/scsi/qla2xxx/qla_os.c
42695 +++ b/drivers/scsi/qla2xxx/qla_os.c
42696 @@ -1571,8 +1571,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
42697 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
42698 /* Ok, a 64bit DMA mask is applicable. */
42699 ha->flags.enable_64bit_addressing = 1;
42700 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
42701 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
42702 + pax_open_kernel();
42703 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
42704 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
42705 + pax_close_kernel();
42706 return;
42707 }
42708 }
42709 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
42710 index ddf16a8..80f4dd0 100644
42711 --- a/drivers/scsi/qla4xxx/ql4_def.h
42712 +++ b/drivers/scsi/qla4xxx/ql4_def.h
42713 @@ -291,7 +291,7 @@ struct ddb_entry {
42714 * (4000 only) */
42715 atomic_t relogin_timer; /* Max Time to wait for
42716 * relogin to complete */
42717 - atomic_t relogin_retry_count; /* Num of times relogin has been
42718 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
42719 * retried */
42720 uint32_t default_time2wait; /* Default Min time between
42721 * relogins (+aens) */
42722 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
42723 index 4d231c1..2892c37 100644
42724 --- a/drivers/scsi/qla4xxx/ql4_os.c
42725 +++ b/drivers/scsi/qla4xxx/ql4_os.c
42726 @@ -2971,12 +2971,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
42727 */
42728 if (!iscsi_is_session_online(cls_sess)) {
42729 /* Reset retry relogin timer */
42730 - atomic_inc(&ddb_entry->relogin_retry_count);
42731 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
42732 DEBUG2(ql4_printk(KERN_INFO, ha,
42733 "%s: index[%d] relogin timed out-retrying"
42734 " relogin (%d), retry (%d)\n", __func__,
42735 ddb_entry->fw_ddb_index,
42736 - atomic_read(&ddb_entry->relogin_retry_count),
42737 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
42738 ddb_entry->default_time2wait + 4));
42739 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
42740 atomic_set(&ddb_entry->retry_relogin_timer,
42741 @@ -5081,7 +5081,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
42742
42743 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
42744 atomic_set(&ddb_entry->relogin_timer, 0);
42745 - atomic_set(&ddb_entry->relogin_retry_count, 0);
42746 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
42747 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
42748 ddb_entry->default_relogin_timeout =
42749 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
42750 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
42751 index 2c0d0ec..4e8681a 100644
42752 --- a/drivers/scsi/scsi.c
42753 +++ b/drivers/scsi/scsi.c
42754 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
42755 unsigned long timeout;
42756 int rtn = 0;
42757
42758 - atomic_inc(&cmd->device->iorequest_cnt);
42759 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
42760
42761 /* check if the device is still usable */
42762 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
42763 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
42764 index 86d5220..f22c51a 100644
42765 --- a/drivers/scsi/scsi_lib.c
42766 +++ b/drivers/scsi/scsi_lib.c
42767 @@ -1458,7 +1458,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
42768 shost = sdev->host;
42769 scsi_init_cmd_errh(cmd);
42770 cmd->result = DID_NO_CONNECT << 16;
42771 - atomic_inc(&cmd->device->iorequest_cnt);
42772 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
42773
42774 /*
42775 * SCSI request completion path will do scsi_device_unbusy(),
42776 @@ -1484,9 +1484,9 @@ static void scsi_softirq_done(struct request *rq)
42777
42778 INIT_LIST_HEAD(&cmd->eh_entry);
42779
42780 - atomic_inc(&cmd->device->iodone_cnt);
42781 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
42782 if (cmd->result)
42783 - atomic_inc(&cmd->device->ioerr_cnt);
42784 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
42785
42786 disposition = scsi_decide_disposition(cmd);
42787 if (disposition != SUCCESS &&
42788 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
42789 index 931a7d9..0c2a754 100644
42790 --- a/drivers/scsi/scsi_sysfs.c
42791 +++ b/drivers/scsi/scsi_sysfs.c
42792 @@ -658,7 +658,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
42793 char *buf) \
42794 { \
42795 struct scsi_device *sdev = to_scsi_device(dev); \
42796 - unsigned long long count = atomic_read(&sdev->field); \
42797 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
42798 return snprintf(buf, 20, "0x%llx\n", count); \
42799 } \
42800 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
42801 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
42802 index 84a1fdf..693b0d6 100644
42803 --- a/drivers/scsi/scsi_tgt_lib.c
42804 +++ b/drivers/scsi/scsi_tgt_lib.c
42805 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
42806 int err;
42807
42808 dprintk("%lx %u\n", uaddr, len);
42809 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
42810 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
42811 if (err) {
42812 /*
42813 * TODO: need to fixup sg_tablesize, max_segment_size,
42814 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
42815 index e106c27..11a380e 100644
42816 --- a/drivers/scsi/scsi_transport_fc.c
42817 +++ b/drivers/scsi/scsi_transport_fc.c
42818 @@ -497,7 +497,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
42819 * Netlink Infrastructure
42820 */
42821
42822 -static atomic_t fc_event_seq;
42823 +static atomic_unchecked_t fc_event_seq;
42824
42825 /**
42826 * fc_get_event_number - Obtain the next sequential FC event number
42827 @@ -510,7 +510,7 @@ static atomic_t fc_event_seq;
42828 u32
42829 fc_get_event_number(void)
42830 {
42831 - return atomic_add_return(1, &fc_event_seq);
42832 + return atomic_add_return_unchecked(1, &fc_event_seq);
42833 }
42834 EXPORT_SYMBOL(fc_get_event_number);
42835
42836 @@ -654,7 +654,7 @@ static __init int fc_transport_init(void)
42837 {
42838 int error;
42839
42840 - atomic_set(&fc_event_seq, 0);
42841 + atomic_set_unchecked(&fc_event_seq, 0);
42842
42843 error = transport_class_register(&fc_host_class);
42844 if (error)
42845 @@ -844,7 +844,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
42846 char *cp;
42847
42848 *val = simple_strtoul(buf, &cp, 0);
42849 - if ((*cp && (*cp != '\n')) || (*val < 0))
42850 + if (*cp && (*cp != '\n'))
42851 return -EINVAL;
42852 /*
42853 * Check for overflow; dev_loss_tmo is u32
42854 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
42855 index 133926b..903000d 100644
42856 --- a/drivers/scsi/scsi_transport_iscsi.c
42857 +++ b/drivers/scsi/scsi_transport_iscsi.c
42858 @@ -80,7 +80,7 @@ struct iscsi_internal {
42859 struct transport_container session_cont;
42860 };
42861
42862 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
42863 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
42864 static struct workqueue_struct *iscsi_eh_timer_workq;
42865
42866 static DEFINE_IDA(iscsi_sess_ida);
42867 @@ -1738,7 +1738,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
42868 int err;
42869
42870 ihost = shost->shost_data;
42871 - session->sid = atomic_add_return(1, &iscsi_session_nr);
42872 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
42873
42874 if (target_id == ISCSI_MAX_TARGET) {
42875 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
42876 @@ -3944,7 +3944,7 @@ static __init int iscsi_transport_init(void)
42877 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
42878 ISCSI_TRANSPORT_VERSION);
42879
42880 - atomic_set(&iscsi_session_nr, 0);
42881 + atomic_set_unchecked(&iscsi_session_nr, 0);
42882
42883 err = class_register(&iscsi_transport_class);
42884 if (err)
42885 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
42886 index f379c7f..e8fc69c 100644
42887 --- a/drivers/scsi/scsi_transport_srp.c
42888 +++ b/drivers/scsi/scsi_transport_srp.c
42889 @@ -33,7 +33,7 @@
42890 #include "scsi_transport_srp_internal.h"
42891
42892 struct srp_host_attrs {
42893 - atomic_t next_port_id;
42894 + atomic_unchecked_t next_port_id;
42895 };
42896 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
42897
42898 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
42899 struct Scsi_Host *shost = dev_to_shost(dev);
42900 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
42901
42902 - atomic_set(&srp_host->next_port_id, 0);
42903 + atomic_set_unchecked(&srp_host->next_port_id, 0);
42904 return 0;
42905 }
42906
42907 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
42908 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
42909 rport->roles = ids->roles;
42910
42911 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
42912 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
42913 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
42914
42915 transport_setup_device(&rport->dev);
42916 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
42917 index c1c5552..1cf226c 100644
42918 --- a/drivers/scsi/sd.c
42919 +++ b/drivers/scsi/sd.c
42920 @@ -2918,7 +2918,7 @@ static int sd_probe(struct device *dev)
42921 sdkp->disk = gd;
42922 sdkp->index = index;
42923 atomic_set(&sdkp->openers, 0);
42924 - atomic_set(&sdkp->device->ioerr_cnt, 0);
42925 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
42926
42927 if (!sdp->request_queue->rq_timeout) {
42928 if (sdp->type != TYPE_MOD)
42929 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
42930 index df5e961..df6b97f 100644
42931 --- a/drivers/scsi/sg.c
42932 +++ b/drivers/scsi/sg.c
42933 @@ -1102,7 +1102,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
42934 sdp->disk->disk_name,
42935 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
42936 NULL,
42937 - (char *)arg);
42938 + (char __user *)arg);
42939 case BLKTRACESTART:
42940 return blk_trace_startstop(sdp->device->request_queue, 1);
42941 case BLKTRACESTOP:
42942 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
42943 index 32b7bb1..2f1c4bd 100644
42944 --- a/drivers/spi/spi.c
42945 +++ b/drivers/spi/spi.c
42946 @@ -1631,7 +1631,7 @@ int spi_bus_unlock(struct spi_master *master)
42947 EXPORT_SYMBOL_GPL(spi_bus_unlock);
42948
42949 /* portable code must never pass more than 32 bytes */
42950 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
42951 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
42952
42953 static u8 *buf;
42954
42955 diff --git a/drivers/staging/media/solo6x10/solo6x10-core.c b/drivers/staging/media/solo6x10/solo6x10-core.c
42956 index 3675020..e80d92c 100644
42957 --- a/drivers/staging/media/solo6x10/solo6x10-core.c
42958 +++ b/drivers/staging/media/solo6x10/solo6x10-core.c
42959 @@ -434,7 +434,7 @@ static void solo_device_release(struct device *dev)
42960
42961 static int solo_sysfs_init(struct solo_dev *solo_dev)
42962 {
42963 - struct bin_attribute *sdram_attr = &solo_dev->sdram_attr;
42964 + bin_attribute_no_const *sdram_attr = &solo_dev->sdram_attr;
42965 struct device *dev = &solo_dev->dev;
42966 const char *driver;
42967 int i;
42968 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
42969 index 34afc16..ffe44dd 100644
42970 --- a/drivers/staging/octeon/ethernet-rx.c
42971 +++ b/drivers/staging/octeon/ethernet-rx.c
42972 @@ -421,11 +421,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
42973 /* Increment RX stats for virtual ports */
42974 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
42975 #ifdef CONFIG_64BIT
42976 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
42977 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
42978 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
42979 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
42980 #else
42981 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
42982 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
42983 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
42984 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
42985 #endif
42986 }
42987 netif_receive_skb(skb);
42988 @@ -437,9 +437,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
42989 dev->name);
42990 */
42991 #ifdef CONFIG_64BIT
42992 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
42993 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
42994 #else
42995 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
42996 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
42997 #endif
42998 dev_kfree_skb_irq(skb);
42999 }
43000 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
43001 index c3a90e7..023619a 100644
43002 --- a/drivers/staging/octeon/ethernet.c
43003 +++ b/drivers/staging/octeon/ethernet.c
43004 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
43005 * since the RX tasklet also increments it.
43006 */
43007 #ifdef CONFIG_64BIT
43008 - atomic64_add(rx_status.dropped_packets,
43009 - (atomic64_t *)&priv->stats.rx_dropped);
43010 + atomic64_add_unchecked(rx_status.dropped_packets,
43011 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
43012 #else
43013 - atomic_add(rx_status.dropped_packets,
43014 - (atomic_t *)&priv->stats.rx_dropped);
43015 + atomic_add_unchecked(rx_status.dropped_packets,
43016 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
43017 #endif
43018 }
43019
43020 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
43021 index dc23395..cf7e9b1 100644
43022 --- a/drivers/staging/rtl8712/rtl871x_io.h
43023 +++ b/drivers/staging/rtl8712/rtl871x_io.h
43024 @@ -108,7 +108,7 @@ struct _io_ops {
43025 u8 *pmem);
43026 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
43027 u8 *pmem);
43028 -};
43029 +} __no_const;
43030
43031 struct io_req {
43032 struct list_head list;
43033 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
43034 index 1f5088b..0e59820 100644
43035 --- a/drivers/staging/sbe-2t3e3/netdev.c
43036 +++ b/drivers/staging/sbe-2t3e3/netdev.c
43037 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43038 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
43039
43040 if (rlen)
43041 - if (copy_to_user(data, &resp, rlen))
43042 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
43043 return -EFAULT;
43044
43045 return 0;
43046 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
43047 index a863a98..d272795 100644
43048 --- a/drivers/staging/usbip/vhci.h
43049 +++ b/drivers/staging/usbip/vhci.h
43050 @@ -83,7 +83,7 @@ struct vhci_hcd {
43051 unsigned resuming:1;
43052 unsigned long re_timeout;
43053
43054 - atomic_t seqnum;
43055 + atomic_unchecked_t seqnum;
43056
43057 /*
43058 * NOTE:
43059 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
43060 index d7974cb..d78076b 100644
43061 --- a/drivers/staging/usbip/vhci_hcd.c
43062 +++ b/drivers/staging/usbip/vhci_hcd.c
43063 @@ -441,7 +441,7 @@ static void vhci_tx_urb(struct urb *urb)
43064
43065 spin_lock(&vdev->priv_lock);
43066
43067 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
43068 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
43069 if (priv->seqnum == 0xffff)
43070 dev_info(&urb->dev->dev, "seqnum max\n");
43071
43072 @@ -687,7 +687,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
43073 return -ENOMEM;
43074 }
43075
43076 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
43077 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
43078 if (unlink->seqnum == 0xffff)
43079 pr_info("seqnum max\n");
43080
43081 @@ -891,7 +891,7 @@ static int vhci_start(struct usb_hcd *hcd)
43082 vdev->rhport = rhport;
43083 }
43084
43085 - atomic_set(&vhci->seqnum, 0);
43086 + atomic_set_unchecked(&vhci->seqnum, 0);
43087 spin_lock_init(&vhci->lock);
43088
43089 hcd->power_budget = 0; /* no limit */
43090 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
43091 index d07fcb5..358e1e1 100644
43092 --- a/drivers/staging/usbip/vhci_rx.c
43093 +++ b/drivers/staging/usbip/vhci_rx.c
43094 @@ -80,7 +80,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
43095 if (!urb) {
43096 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
43097 pr_info("max seqnum %d\n",
43098 - atomic_read(&the_controller->seqnum));
43099 + atomic_read_unchecked(&the_controller->seqnum));
43100 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
43101 return;
43102 }
43103 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
43104 index 8417c2f..ef5ebd6 100644
43105 --- a/drivers/staging/vt6655/hostap.c
43106 +++ b/drivers/staging/vt6655/hostap.c
43107 @@ -69,14 +69,13 @@ static int msglevel = MSG_LEVEL_INFO;
43108 *
43109 */
43110
43111 +static net_device_ops_no_const apdev_netdev_ops;
43112 +
43113 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43114 {
43115 PSDevice apdev_priv;
43116 struct net_device *dev = pDevice->dev;
43117 int ret;
43118 - const struct net_device_ops apdev_netdev_ops = {
43119 - .ndo_start_xmit = pDevice->tx_80211,
43120 - };
43121
43122 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
43123
43124 @@ -88,6 +87,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
43125 *apdev_priv = *pDevice;
43126 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
43127
43128 + /* only half broken now */
43129 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
43130 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
43131
43132 pDevice->apdev->type = ARPHRD_IEEE80211;
43133 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
43134 index c699a30..b90a5fd 100644
43135 --- a/drivers/staging/vt6656/hostap.c
43136 +++ b/drivers/staging/vt6656/hostap.c
43137 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
43138 *
43139 */
43140
43141 +static net_device_ops_no_const apdev_netdev_ops;
43142 +
43143 static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
43144 {
43145 struct vnt_private *apdev_priv;
43146 struct net_device *dev = pDevice->dev;
43147 int ret;
43148 - const struct net_device_ops apdev_netdev_ops = {
43149 - .ndo_start_xmit = pDevice->tx_80211,
43150 - };
43151
43152 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
43153
43154 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
43155 *apdev_priv = *pDevice;
43156 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
43157
43158 + /* only half broken now */
43159 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
43160 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
43161
43162 pDevice->apdev->type = ARPHRD_IEEE80211;
43163 diff --git a/drivers/staging/zcache/tmem.c b/drivers/staging/zcache/tmem.c
43164 index d7e51e4..d07eaab 100644
43165 --- a/drivers/staging/zcache/tmem.c
43166 +++ b/drivers/staging/zcache/tmem.c
43167 @@ -51,7 +51,7 @@
43168 * A tmem host implementation must use this function to register callbacks
43169 * for memory allocation.
43170 */
43171 -static struct tmem_hostops tmem_hostops;
43172 +static tmem_hostops_no_const tmem_hostops;
43173
43174 static void tmem_objnode_tree_init(void);
43175
43176 @@ -65,7 +65,7 @@ void tmem_register_hostops(struct tmem_hostops *m)
43177 * A tmem host implementation must use this function to register
43178 * callbacks for a page-accessible memory (PAM) implementation.
43179 */
43180 -static struct tmem_pamops tmem_pamops;
43181 +static tmem_pamops_no_const tmem_pamops;
43182
43183 void tmem_register_pamops(struct tmem_pamops *m)
43184 {
43185 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
43186 index d128ce2..a43980c 100644
43187 --- a/drivers/staging/zcache/tmem.h
43188 +++ b/drivers/staging/zcache/tmem.h
43189 @@ -226,6 +226,7 @@ struct tmem_pamops {
43190 int (*replace_in_obj)(void *, struct tmem_obj *);
43191 #endif
43192 };
43193 +typedef struct tmem_pamops __no_const tmem_pamops_no_const;
43194 extern void tmem_register_pamops(struct tmem_pamops *m);
43195
43196 /* memory allocation methods provided by the host implementation */
43197 @@ -235,6 +236,7 @@ struct tmem_hostops {
43198 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
43199 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
43200 };
43201 +typedef struct tmem_hostops __no_const tmem_hostops_no_const;
43202 extern void tmem_register_hostops(struct tmem_hostops *m);
43203
43204 /* core tmem accessor functions */
43205 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
43206 index 4630481..c26782a 100644
43207 --- a/drivers/target/target_core_device.c
43208 +++ b/drivers/target/target_core_device.c
43209 @@ -1400,7 +1400,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
43210 spin_lock_init(&dev->se_port_lock);
43211 spin_lock_init(&dev->se_tmr_lock);
43212 spin_lock_init(&dev->qf_cmd_lock);
43213 - atomic_set(&dev->dev_ordered_id, 0);
43214 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
43215 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
43216 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
43217 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
43218 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
43219 index 21e3158..43c6004 100644
43220 --- a/drivers/target/target_core_transport.c
43221 +++ b/drivers/target/target_core_transport.c
43222 @@ -1080,7 +1080,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
43223 * Used to determine when ORDERED commands should go from
43224 * Dormant to Active status.
43225 */
43226 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
43227 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
43228 smp_mb__after_atomic_inc();
43229 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
43230 cmd->se_ordered_id, cmd->sam_task_attr,
43231 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
43232 index 33f83fe..d80f8e1 100644
43233 --- a/drivers/tty/cyclades.c
43234 +++ b/drivers/tty/cyclades.c
43235 @@ -1570,10 +1570,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
43236 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
43237 info->port.count);
43238 #endif
43239 - info->port.count++;
43240 + atomic_inc(&info->port.count);
43241 #ifdef CY_DEBUG_COUNT
43242 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
43243 - current->pid, info->port.count);
43244 + current->pid, atomic_read(&info->port.count));
43245 #endif
43246
43247 /*
43248 @@ -3972,7 +3972,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
43249 for (j = 0; j < cy_card[i].nports; j++) {
43250 info = &cy_card[i].ports[j];
43251
43252 - if (info->port.count) {
43253 + if (atomic_read(&info->port.count)) {
43254 /* XXX is the ldisc num worth this? */
43255 struct tty_struct *tty;
43256 struct tty_ldisc *ld;
43257 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
43258 index eb255e8..f637a57 100644
43259 --- a/drivers/tty/hvc/hvc_console.c
43260 +++ b/drivers/tty/hvc/hvc_console.c
43261 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
43262
43263 spin_lock_irqsave(&hp->port.lock, flags);
43264 /* Check and then increment for fast path open. */
43265 - if (hp->port.count++ > 0) {
43266 + if (atomic_inc_return(&hp->port.count) > 1) {
43267 spin_unlock_irqrestore(&hp->port.lock, flags);
43268 hvc_kick();
43269 return 0;
43270 @@ -388,7 +388,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
43271
43272 spin_lock_irqsave(&hp->port.lock, flags);
43273
43274 - if (--hp->port.count == 0) {
43275 + if (atomic_dec_return(&hp->port.count) == 0) {
43276 spin_unlock_irqrestore(&hp->port.lock, flags);
43277 /* We are done with the tty pointer now. */
43278 tty_port_tty_set(&hp->port, NULL);
43279 @@ -406,9 +406,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
43280 */
43281 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
43282 } else {
43283 - if (hp->port.count < 0)
43284 + if (atomic_read(&hp->port.count) < 0)
43285 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
43286 - hp->vtermno, hp->port.count);
43287 + hp->vtermno, atomic_read(&hp->port.count));
43288 spin_unlock_irqrestore(&hp->port.lock, flags);
43289 }
43290 }
43291 @@ -438,12 +438,12 @@ static void hvc_hangup(struct tty_struct *tty)
43292 * open->hangup case this can be called after the final close so prevent
43293 * that from happening for now.
43294 */
43295 - if (hp->port.count <= 0) {
43296 + if (atomic_read(&hp->port.count) <= 0) {
43297 spin_unlock_irqrestore(&hp->port.lock, flags);
43298 return;
43299 }
43300
43301 - hp->port.count = 0;
43302 + atomic_set(&hp->port.count, 0);
43303 spin_unlock_irqrestore(&hp->port.lock, flags);
43304 tty_port_tty_set(&hp->port, NULL);
43305
43306 @@ -491,7 +491,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
43307 return -EPIPE;
43308
43309 /* FIXME what's this (unprotected) check for? */
43310 - if (hp->port.count <= 0)
43311 + if (atomic_read(&hp->port.count) <= 0)
43312 return -EIO;
43313
43314 spin_lock_irqsave(&hp->lock, flags);
43315 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
43316 index 81e939e..95ead10 100644
43317 --- a/drivers/tty/hvc/hvcs.c
43318 +++ b/drivers/tty/hvc/hvcs.c
43319 @@ -83,6 +83,7 @@
43320 #include <asm/hvcserver.h>
43321 #include <asm/uaccess.h>
43322 #include <asm/vio.h>
43323 +#include <asm/local.h>
43324
43325 /*
43326 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
43327 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
43328
43329 spin_lock_irqsave(&hvcsd->lock, flags);
43330
43331 - if (hvcsd->port.count > 0) {
43332 + if (atomic_read(&hvcsd->port.count) > 0) {
43333 spin_unlock_irqrestore(&hvcsd->lock, flags);
43334 printk(KERN_INFO "HVCS: vterm state unchanged. "
43335 "The hvcs device node is still in use.\n");
43336 @@ -1127,7 +1128,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
43337 }
43338 }
43339
43340 - hvcsd->port.count = 0;
43341 + atomic_set(&hvcsd->port.count, 0);
43342 hvcsd->port.tty = tty;
43343 tty->driver_data = hvcsd;
43344
43345 @@ -1180,7 +1181,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
43346 unsigned long flags;
43347
43348 spin_lock_irqsave(&hvcsd->lock, flags);
43349 - hvcsd->port.count++;
43350 + atomic_inc(&hvcsd->port.count);
43351 hvcsd->todo_mask |= HVCS_SCHED_READ;
43352 spin_unlock_irqrestore(&hvcsd->lock, flags);
43353
43354 @@ -1216,7 +1217,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
43355 hvcsd = tty->driver_data;
43356
43357 spin_lock_irqsave(&hvcsd->lock, flags);
43358 - if (--hvcsd->port.count == 0) {
43359 + if (atomic_dec_and_test(&hvcsd->port.count)) {
43360
43361 vio_disable_interrupts(hvcsd->vdev);
43362
43363 @@ -1241,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
43364
43365 free_irq(irq, hvcsd);
43366 return;
43367 - } else if (hvcsd->port.count < 0) {
43368 + } else if (atomic_read(&hvcsd->port.count) < 0) {
43369 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
43370 " is missmanaged.\n",
43371 - hvcsd->vdev->unit_address, hvcsd->port.count);
43372 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
43373 }
43374
43375 spin_unlock_irqrestore(&hvcsd->lock, flags);
43376 @@ -1266,7 +1267,7 @@ static void hvcs_hangup(struct tty_struct * tty)
43377
43378 spin_lock_irqsave(&hvcsd->lock, flags);
43379 /* Preserve this so that we know how many kref refs to put */
43380 - temp_open_count = hvcsd->port.count;
43381 + temp_open_count = atomic_read(&hvcsd->port.count);
43382
43383 /*
43384 * Don't kref put inside the spinlock because the destruction
43385 @@ -1281,7 +1282,7 @@ static void hvcs_hangup(struct tty_struct * tty)
43386 tty->driver_data = NULL;
43387 hvcsd->port.tty = NULL;
43388
43389 - hvcsd->port.count = 0;
43390 + atomic_set(&hvcsd->port.count, 0);
43391
43392 /* This will drop any buffered data on the floor which is OK in a hangup
43393 * scenario. */
43394 @@ -1352,7 +1353,7 @@ static int hvcs_write(struct tty_struct *tty,
43395 * the middle of a write operation? This is a crummy place to do this
43396 * but we want to keep it all in the spinlock.
43397 */
43398 - if (hvcsd->port.count <= 0) {
43399 + if (atomic_read(&hvcsd->port.count) <= 0) {
43400 spin_unlock_irqrestore(&hvcsd->lock, flags);
43401 return -ENODEV;
43402 }
43403 @@ -1426,7 +1427,7 @@ static int hvcs_write_room(struct tty_struct *tty)
43404 {
43405 struct hvcs_struct *hvcsd = tty->driver_data;
43406
43407 - if (!hvcsd || hvcsd->port.count <= 0)
43408 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
43409 return 0;
43410
43411 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
43412 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
43413 index 8fd72ff..34a0bed 100644
43414 --- a/drivers/tty/ipwireless/tty.c
43415 +++ b/drivers/tty/ipwireless/tty.c
43416 @@ -29,6 +29,7 @@
43417 #include <linux/tty_driver.h>
43418 #include <linux/tty_flip.h>
43419 #include <linux/uaccess.h>
43420 +#include <asm/local.h>
43421
43422 #include "tty.h"
43423 #include "network.h"
43424 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
43425 mutex_unlock(&tty->ipw_tty_mutex);
43426 return -ENODEV;
43427 }
43428 - if (tty->port.count == 0)
43429 + if (atomic_read(&tty->port.count) == 0)
43430 tty->tx_bytes_queued = 0;
43431
43432 - tty->port.count++;
43433 + atomic_inc(&tty->port.count);
43434
43435 tty->port.tty = linux_tty;
43436 linux_tty->driver_data = tty;
43437 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
43438
43439 static void do_ipw_close(struct ipw_tty *tty)
43440 {
43441 - tty->port.count--;
43442 -
43443 - if (tty->port.count == 0) {
43444 + if (atomic_dec_return(&tty->port.count) == 0) {
43445 struct tty_struct *linux_tty = tty->port.tty;
43446
43447 if (linux_tty != NULL) {
43448 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
43449 return;
43450
43451 mutex_lock(&tty->ipw_tty_mutex);
43452 - if (tty->port.count == 0) {
43453 + if (atomic_read(&tty->port.count) == 0) {
43454 mutex_unlock(&tty->ipw_tty_mutex);
43455 return;
43456 }
43457 @@ -164,7 +163,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
43458
43459 mutex_lock(&tty->ipw_tty_mutex);
43460
43461 - if (!tty->port.count) {
43462 + if (!atomic_read(&tty->port.count)) {
43463 mutex_unlock(&tty->ipw_tty_mutex);
43464 return;
43465 }
43466 @@ -206,7 +205,7 @@ static int ipw_write(struct tty_struct *linux_tty,
43467 return -ENODEV;
43468
43469 mutex_lock(&tty->ipw_tty_mutex);
43470 - if (!tty->port.count) {
43471 + if (!atomic_read(&tty->port.count)) {
43472 mutex_unlock(&tty->ipw_tty_mutex);
43473 return -EINVAL;
43474 }
43475 @@ -246,7 +245,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
43476 if (!tty)
43477 return -ENODEV;
43478
43479 - if (!tty->port.count)
43480 + if (!atomic_read(&tty->port.count))
43481 return -EINVAL;
43482
43483 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
43484 @@ -288,7 +287,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
43485 if (!tty)
43486 return 0;
43487
43488 - if (!tty->port.count)
43489 + if (!atomic_read(&tty->port.count))
43490 return 0;
43491
43492 return tty->tx_bytes_queued;
43493 @@ -369,7 +368,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
43494 if (!tty)
43495 return -ENODEV;
43496
43497 - if (!tty->port.count)
43498 + if (!atomic_read(&tty->port.count))
43499 return -EINVAL;
43500
43501 return get_control_lines(tty);
43502 @@ -385,7 +384,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
43503 if (!tty)
43504 return -ENODEV;
43505
43506 - if (!tty->port.count)
43507 + if (!atomic_read(&tty->port.count))
43508 return -EINVAL;
43509
43510 return set_control_lines(tty, set, clear);
43511 @@ -399,7 +398,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
43512 if (!tty)
43513 return -ENODEV;
43514
43515 - if (!tty->port.count)
43516 + if (!atomic_read(&tty->port.count))
43517 return -EINVAL;
43518
43519 /* FIXME: Exactly how is the tty object locked here .. */
43520 @@ -555,7 +554,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
43521 * are gone */
43522 mutex_lock(&ttyj->ipw_tty_mutex);
43523 }
43524 - while (ttyj->port.count)
43525 + while (atomic_read(&ttyj->port.count))
43526 do_ipw_close(ttyj);
43527 ipwireless_disassociate_network_ttys(network,
43528 ttyj->channel_idx);
43529 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
43530 index 1deaca4..c8582d4 100644
43531 --- a/drivers/tty/moxa.c
43532 +++ b/drivers/tty/moxa.c
43533 @@ -1189,7 +1189,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
43534 }
43535
43536 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
43537 - ch->port.count++;
43538 + atomic_inc(&ch->port.count);
43539 tty->driver_data = ch;
43540 tty_port_tty_set(&ch->port, tty);
43541 mutex_lock(&ch->port.mutex);
43542 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
43543 index 6422390..49003ac8 100644
43544 --- a/drivers/tty/n_gsm.c
43545 +++ b/drivers/tty/n_gsm.c
43546 @@ -1632,7 +1632,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
43547 spin_lock_init(&dlci->lock);
43548 mutex_init(&dlci->mutex);
43549 dlci->fifo = &dlci->_fifo;
43550 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
43551 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
43552 kfree(dlci);
43553 return NULL;
43554 }
43555 @@ -2932,7 +2932,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
43556 struct gsm_dlci *dlci = tty->driver_data;
43557 struct tty_port *port = &dlci->port;
43558
43559 - port->count++;
43560 + atomic_inc(&port->count);
43561 dlci_get(dlci);
43562 dlci_get(dlci->gsm->dlci[0]);
43563 mux_get(dlci->gsm);
43564 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
43565 index 6c7fe90..9241dab 100644
43566 --- a/drivers/tty/n_tty.c
43567 +++ b/drivers/tty/n_tty.c
43568 @@ -2203,6 +2203,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
43569 {
43570 *ops = tty_ldisc_N_TTY;
43571 ops->owner = NULL;
43572 - ops->refcount = ops->flags = 0;
43573 + atomic_set(&ops->refcount, 0);
43574 + ops->flags = 0;
43575 }
43576 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
43577 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
43578 index abfd990..5ab5da9 100644
43579 --- a/drivers/tty/pty.c
43580 +++ b/drivers/tty/pty.c
43581 @@ -796,8 +796,10 @@ static void __init unix98_pty_init(void)
43582 panic("Couldn't register Unix98 pts driver");
43583
43584 /* Now create the /dev/ptmx special device */
43585 + pax_open_kernel();
43586 tty_default_fops(&ptmx_fops);
43587 - ptmx_fops.open = ptmx_open;
43588 + *(void **)&ptmx_fops.open = ptmx_open;
43589 + pax_close_kernel();
43590
43591 cdev_init(&ptmx_cdev, &ptmx_fops);
43592 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
43593 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
43594 index 354564e..fe50d9a 100644
43595 --- a/drivers/tty/rocket.c
43596 +++ b/drivers/tty/rocket.c
43597 @@ -914,7 +914,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
43598 tty->driver_data = info;
43599 tty_port_tty_set(port, tty);
43600
43601 - if (port->count++ == 0) {
43602 + if (atomic_inc_return(&port->count) == 1) {
43603 atomic_inc(&rp_num_ports_open);
43604
43605 #ifdef ROCKET_DEBUG_OPEN
43606 @@ -923,7 +923,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
43607 #endif
43608 }
43609 #ifdef ROCKET_DEBUG_OPEN
43610 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
43611 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
43612 #endif
43613
43614 /*
43615 @@ -1515,7 +1515,7 @@ static void rp_hangup(struct tty_struct *tty)
43616 spin_unlock_irqrestore(&info->port.lock, flags);
43617 return;
43618 }
43619 - if (info->port.count)
43620 + if (atomic_read(&info->port.count))
43621 atomic_dec(&rp_num_ports_open);
43622 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
43623 spin_unlock_irqrestore(&info->port.lock, flags);
43624 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
43625 index 1002054..dd644a8 100644
43626 --- a/drivers/tty/serial/kgdboc.c
43627 +++ b/drivers/tty/serial/kgdboc.c
43628 @@ -24,8 +24,9 @@
43629 #define MAX_CONFIG_LEN 40
43630
43631 static struct kgdb_io kgdboc_io_ops;
43632 +static struct kgdb_io kgdboc_io_ops_console;
43633
43634 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
43635 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
43636 static int configured = -1;
43637
43638 static char config[MAX_CONFIG_LEN];
43639 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
43640 kgdboc_unregister_kbd();
43641 if (configured == 1)
43642 kgdb_unregister_io_module(&kgdboc_io_ops);
43643 + else if (configured == 2)
43644 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
43645 }
43646
43647 static int configure_kgdboc(void)
43648 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
43649 int err;
43650 char *cptr = config;
43651 struct console *cons;
43652 + int is_console = 0;
43653
43654 err = kgdboc_option_setup(config);
43655 if (err || !strlen(config) || isspace(config[0]))
43656 goto noconfig;
43657
43658 err = -ENODEV;
43659 - kgdboc_io_ops.is_console = 0;
43660 kgdb_tty_driver = NULL;
43661
43662 kgdboc_use_kms = 0;
43663 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
43664 int idx;
43665 if (cons->device && cons->device(cons, &idx) == p &&
43666 idx == tty_line) {
43667 - kgdboc_io_ops.is_console = 1;
43668 + is_console = 1;
43669 break;
43670 }
43671 cons = cons->next;
43672 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
43673 kgdb_tty_line = tty_line;
43674
43675 do_register:
43676 - err = kgdb_register_io_module(&kgdboc_io_ops);
43677 + if (is_console) {
43678 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
43679 + configured = 2;
43680 + } else {
43681 + err = kgdb_register_io_module(&kgdboc_io_ops);
43682 + configured = 1;
43683 + }
43684 if (err)
43685 goto noconfig;
43686
43687 @@ -205,8 +214,6 @@ do_register:
43688 if (err)
43689 goto nmi_con_failed;
43690
43691 - configured = 1;
43692 -
43693 return 0;
43694
43695 nmi_con_failed:
43696 @@ -223,7 +230,7 @@ noconfig:
43697 static int __init init_kgdboc(void)
43698 {
43699 /* Already configured? */
43700 - if (configured == 1)
43701 + if (configured >= 1)
43702 return 0;
43703
43704 return configure_kgdboc();
43705 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
43706 if (config[len - 1] == '\n')
43707 config[len - 1] = '\0';
43708
43709 - if (configured == 1)
43710 + if (configured >= 1)
43711 cleanup_kgdboc();
43712
43713 /* Go and configure with the new params. */
43714 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
43715 .post_exception = kgdboc_post_exp_handler,
43716 };
43717
43718 +static struct kgdb_io kgdboc_io_ops_console = {
43719 + .name = "kgdboc",
43720 + .read_char = kgdboc_get_char,
43721 + .write_char = kgdboc_put_char,
43722 + .pre_exception = kgdboc_pre_exp_handler,
43723 + .post_exception = kgdboc_post_exp_handler,
43724 + .is_console = 1
43725 +};
43726 +
43727 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
43728 /* This is only available if kgdboc is a built in for early debugging */
43729 static int __init kgdboc_early_init(char *opt)
43730 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
43731 index 0c8a9fa..234a95f 100644
43732 --- a/drivers/tty/serial/samsung.c
43733 +++ b/drivers/tty/serial/samsung.c
43734 @@ -453,11 +453,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
43735 }
43736 }
43737
43738 +static int s3c64xx_serial_startup(struct uart_port *port);
43739 static int s3c24xx_serial_startup(struct uart_port *port)
43740 {
43741 struct s3c24xx_uart_port *ourport = to_ourport(port);
43742 int ret;
43743
43744 + /* Startup sequence is different for s3c64xx and higher SoC's */
43745 + if (s3c24xx_serial_has_interrupt_mask(port))
43746 + return s3c64xx_serial_startup(port);
43747 +
43748 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
43749 port->mapbase, port->membase);
43750
43751 @@ -1124,10 +1129,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
43752 /* setup info for port */
43753 port->dev = &platdev->dev;
43754
43755 - /* Startup sequence is different for s3c64xx and higher SoC's */
43756 - if (s3c24xx_serial_has_interrupt_mask(port))
43757 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
43758 -
43759 port->uartclk = 1;
43760
43761 if (cfg->uart_flags & UPF_CONS_FLOW) {
43762 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
43763 index f87dbfd..42ad4b1 100644
43764 --- a/drivers/tty/serial/serial_core.c
43765 +++ b/drivers/tty/serial/serial_core.c
43766 @@ -1454,7 +1454,7 @@ static void uart_hangup(struct tty_struct *tty)
43767 uart_flush_buffer(tty);
43768 uart_shutdown(tty, state);
43769 spin_lock_irqsave(&port->lock, flags);
43770 - port->count = 0;
43771 + atomic_set(&port->count, 0);
43772 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
43773 spin_unlock_irqrestore(&port->lock, flags);
43774 tty_port_tty_set(port, NULL);
43775 @@ -1550,7 +1550,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43776 goto end;
43777 }
43778
43779 - port->count++;
43780 + atomic_inc(&port->count);
43781 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
43782 retval = -ENXIO;
43783 goto err_dec_count;
43784 @@ -1578,7 +1578,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43785 /*
43786 * Make sure the device is in D0 state.
43787 */
43788 - if (port->count == 1)
43789 + if (atomic_read(&port->count) == 1)
43790 uart_change_pm(state, UART_PM_STATE_ON);
43791
43792 /*
43793 @@ -1596,7 +1596,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
43794 end:
43795 return retval;
43796 err_dec_count:
43797 - port->count--;
43798 + atomic_inc(&port->count);
43799 mutex_unlock(&port->mutex);
43800 goto end;
43801 }
43802 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
43803 index 8eaf1ab..85c030d 100644
43804 --- a/drivers/tty/synclink.c
43805 +++ b/drivers/tty/synclink.c
43806 @@ -3090,7 +3090,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43807
43808 if (debug_level >= DEBUG_LEVEL_INFO)
43809 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
43810 - __FILE__,__LINE__, info->device_name, info->port.count);
43811 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
43812
43813 if (tty_port_close_start(&info->port, tty, filp) == 0)
43814 goto cleanup;
43815 @@ -3108,7 +3108,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
43816 cleanup:
43817 if (debug_level >= DEBUG_LEVEL_INFO)
43818 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
43819 - tty->driver->name, info->port.count);
43820 + tty->driver->name, atomic_read(&info->port.count));
43821
43822 } /* end of mgsl_close() */
43823
43824 @@ -3207,8 +3207,8 @@ static void mgsl_hangup(struct tty_struct *tty)
43825
43826 mgsl_flush_buffer(tty);
43827 shutdown(info);
43828 -
43829 - info->port.count = 0;
43830 +
43831 + atomic_set(&info->port.count, 0);
43832 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43833 info->port.tty = NULL;
43834
43835 @@ -3297,12 +3297,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43836
43837 if (debug_level >= DEBUG_LEVEL_INFO)
43838 printk("%s(%d):block_til_ready before block on %s count=%d\n",
43839 - __FILE__,__LINE__, tty->driver->name, port->count );
43840 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43841
43842 spin_lock_irqsave(&info->irq_spinlock, flags);
43843 if (!tty_hung_up_p(filp)) {
43844 extra_count = true;
43845 - port->count--;
43846 + atomic_dec(&port->count);
43847 }
43848 spin_unlock_irqrestore(&info->irq_spinlock, flags);
43849 port->blocked_open++;
43850 @@ -3331,7 +3331,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43851
43852 if (debug_level >= DEBUG_LEVEL_INFO)
43853 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
43854 - __FILE__,__LINE__, tty->driver->name, port->count );
43855 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43856
43857 tty_unlock(tty);
43858 schedule();
43859 @@ -3343,12 +3343,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
43860
43861 /* FIXME: Racy on hangup during close wait */
43862 if (extra_count)
43863 - port->count++;
43864 + atomic_inc(&port->count);
43865 port->blocked_open--;
43866
43867 if (debug_level >= DEBUG_LEVEL_INFO)
43868 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
43869 - __FILE__,__LINE__, tty->driver->name, port->count );
43870 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
43871
43872 if (!retval)
43873 port->flags |= ASYNC_NORMAL_ACTIVE;
43874 @@ -3400,7 +3400,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
43875
43876 if (debug_level >= DEBUG_LEVEL_INFO)
43877 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
43878 - __FILE__,__LINE__,tty->driver->name, info->port.count);
43879 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
43880
43881 /* If port is closing, signal caller to try again */
43882 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43883 @@ -3419,10 +3419,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
43884 spin_unlock_irqrestore(&info->netlock, flags);
43885 goto cleanup;
43886 }
43887 - info->port.count++;
43888 + atomic_inc(&info->port.count);
43889 spin_unlock_irqrestore(&info->netlock, flags);
43890
43891 - if (info->port.count == 1) {
43892 + if (atomic_read(&info->port.count) == 1) {
43893 /* 1st open on this device, init hardware */
43894 retval = startup(info);
43895 if (retval < 0)
43896 @@ -3446,8 +3446,8 @@ cleanup:
43897 if (retval) {
43898 if (tty->count == 1)
43899 info->port.tty = NULL; /* tty layer will release tty struct */
43900 - if(info->port.count)
43901 - info->port.count--;
43902 + if (atomic_read(&info->port.count))
43903 + atomic_dec(&info->port.count);
43904 }
43905
43906 return retval;
43907 @@ -7665,7 +7665,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
43908 unsigned short new_crctype;
43909
43910 /* return error if TTY interface open */
43911 - if (info->port.count)
43912 + if (atomic_read(&info->port.count))
43913 return -EBUSY;
43914
43915 switch (encoding)
43916 @@ -7760,7 +7760,7 @@ static int hdlcdev_open(struct net_device *dev)
43917
43918 /* arbitrate between network and tty opens */
43919 spin_lock_irqsave(&info->netlock, flags);
43920 - if (info->port.count != 0 || info->netcount != 0) {
43921 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
43922 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
43923 spin_unlock_irqrestore(&info->netlock, flags);
43924 return -EBUSY;
43925 @@ -7846,7 +7846,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
43926 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
43927
43928 /* return error if TTY interface open */
43929 - if (info->port.count)
43930 + if (atomic_read(&info->port.count))
43931 return -EBUSY;
43932
43933 if (cmd != SIOCWANDEV)
43934 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
43935 index 1abf946..1ee34fc 100644
43936 --- a/drivers/tty/synclink_gt.c
43937 +++ b/drivers/tty/synclink_gt.c
43938 @@ -670,7 +670,7 @@ static int open(struct tty_struct *tty, struct file *filp)
43939 tty->driver_data = info;
43940 info->port.tty = tty;
43941
43942 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
43943 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
43944
43945 /* If port is closing, signal caller to try again */
43946 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
43947 @@ -691,10 +691,10 @@ static int open(struct tty_struct *tty, struct file *filp)
43948 mutex_unlock(&info->port.mutex);
43949 goto cleanup;
43950 }
43951 - info->port.count++;
43952 + atomic_inc(&info->port.count);
43953 spin_unlock_irqrestore(&info->netlock, flags);
43954
43955 - if (info->port.count == 1) {
43956 + if (atomic_read(&info->port.count) == 1) {
43957 /* 1st open on this device, init hardware */
43958 retval = startup(info);
43959 if (retval < 0) {
43960 @@ -715,8 +715,8 @@ cleanup:
43961 if (retval) {
43962 if (tty->count == 1)
43963 info->port.tty = NULL; /* tty layer will release tty struct */
43964 - if(info->port.count)
43965 - info->port.count--;
43966 + if(atomic_read(&info->port.count))
43967 + atomic_dec(&info->port.count);
43968 }
43969
43970 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
43971 @@ -729,7 +729,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43972
43973 if (sanity_check(info, tty->name, "close"))
43974 return;
43975 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
43976 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
43977
43978 if (tty_port_close_start(&info->port, tty, filp) == 0)
43979 goto cleanup;
43980 @@ -746,7 +746,7 @@ static void close(struct tty_struct *tty, struct file *filp)
43981 tty_port_close_end(&info->port, tty);
43982 info->port.tty = NULL;
43983 cleanup:
43984 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
43985 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
43986 }
43987
43988 static void hangup(struct tty_struct *tty)
43989 @@ -764,7 +764,7 @@ static void hangup(struct tty_struct *tty)
43990 shutdown(info);
43991
43992 spin_lock_irqsave(&info->port.lock, flags);
43993 - info->port.count = 0;
43994 + atomic_set(&info->port.count, 0);
43995 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
43996 info->port.tty = NULL;
43997 spin_unlock_irqrestore(&info->port.lock, flags);
43998 @@ -1449,7 +1449,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
43999 unsigned short new_crctype;
44000
44001 /* return error if TTY interface open */
44002 - if (info->port.count)
44003 + if (atomic_read(&info->port.count))
44004 return -EBUSY;
44005
44006 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
44007 @@ -1544,7 +1544,7 @@ static int hdlcdev_open(struct net_device *dev)
44008
44009 /* arbitrate between network and tty opens */
44010 spin_lock_irqsave(&info->netlock, flags);
44011 - if (info->port.count != 0 || info->netcount != 0) {
44012 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
44013 DBGINFO(("%s hdlc_open busy\n", dev->name));
44014 spin_unlock_irqrestore(&info->netlock, flags);
44015 return -EBUSY;
44016 @@ -1629,7 +1629,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44017 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
44018
44019 /* return error if TTY interface open */
44020 - if (info->port.count)
44021 + if (atomic_read(&info->port.count))
44022 return -EBUSY;
44023
44024 if (cmd != SIOCWANDEV)
44025 @@ -2413,7 +2413,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
44026 if (port == NULL)
44027 continue;
44028 spin_lock(&port->lock);
44029 - if ((port->port.count || port->netcount) &&
44030 + if ((atomic_read(&port->port.count) || port->netcount) &&
44031 port->pending_bh && !port->bh_running &&
44032 !port->bh_requested) {
44033 DBGISR(("%s bh queued\n", port->device_name));
44034 @@ -3302,7 +3302,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44035 spin_lock_irqsave(&info->lock, flags);
44036 if (!tty_hung_up_p(filp)) {
44037 extra_count = true;
44038 - port->count--;
44039 + atomic_dec(&port->count);
44040 }
44041 spin_unlock_irqrestore(&info->lock, flags);
44042 port->blocked_open++;
44043 @@ -3339,7 +3339,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44044 remove_wait_queue(&port->open_wait, &wait);
44045
44046 if (extra_count)
44047 - port->count++;
44048 + atomic_inc(&port->count);
44049 port->blocked_open--;
44050
44051 if (!retval)
44052 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
44053 index ff17138..e38b41e 100644
44054 --- a/drivers/tty/synclinkmp.c
44055 +++ b/drivers/tty/synclinkmp.c
44056 @@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
44057
44058 if (debug_level >= DEBUG_LEVEL_INFO)
44059 printk("%s(%d):%s open(), old ref count = %d\n",
44060 - __FILE__,__LINE__,tty->driver->name, info->port.count);
44061 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
44062
44063 /* If port is closing, signal caller to try again */
44064 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
44065 @@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
44066 spin_unlock_irqrestore(&info->netlock, flags);
44067 goto cleanup;
44068 }
44069 - info->port.count++;
44070 + atomic_inc(&info->port.count);
44071 spin_unlock_irqrestore(&info->netlock, flags);
44072
44073 - if (info->port.count == 1) {
44074 + if (atomic_read(&info->port.count) == 1) {
44075 /* 1st open on this device, init hardware */
44076 retval = startup(info);
44077 if (retval < 0)
44078 @@ -796,8 +796,8 @@ cleanup:
44079 if (retval) {
44080 if (tty->count == 1)
44081 info->port.tty = NULL; /* tty layer will release tty struct */
44082 - if(info->port.count)
44083 - info->port.count--;
44084 + if(atomic_read(&info->port.count))
44085 + atomic_dec(&info->port.count);
44086 }
44087
44088 return retval;
44089 @@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44090
44091 if (debug_level >= DEBUG_LEVEL_INFO)
44092 printk("%s(%d):%s close() entry, count=%d\n",
44093 - __FILE__,__LINE__, info->device_name, info->port.count);
44094 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
44095
44096 if (tty_port_close_start(&info->port, tty, filp) == 0)
44097 goto cleanup;
44098 @@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
44099 cleanup:
44100 if (debug_level >= DEBUG_LEVEL_INFO)
44101 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
44102 - tty->driver->name, info->port.count);
44103 + tty->driver->name, atomic_read(&info->port.count));
44104 }
44105
44106 /* Called by tty_hangup() when a hangup is signaled.
44107 @@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
44108 shutdown(info);
44109
44110 spin_lock_irqsave(&info->port.lock, flags);
44111 - info->port.count = 0;
44112 + atomic_set(&info->port.count, 0);
44113 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
44114 info->port.tty = NULL;
44115 spin_unlock_irqrestore(&info->port.lock, flags);
44116 @@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
44117 unsigned short new_crctype;
44118
44119 /* return error if TTY interface open */
44120 - if (info->port.count)
44121 + if (atomic_read(&info->port.count))
44122 return -EBUSY;
44123
44124 switch (encoding)
44125 @@ -1660,7 +1660,7 @@ static int hdlcdev_open(struct net_device *dev)
44126
44127 /* arbitrate between network and tty opens */
44128 spin_lock_irqsave(&info->netlock, flags);
44129 - if (info->port.count != 0 || info->netcount != 0) {
44130 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
44131 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
44132 spin_unlock_irqrestore(&info->netlock, flags);
44133 return -EBUSY;
44134 @@ -1746,7 +1746,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44135 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
44136
44137 /* return error if TTY interface open */
44138 - if (info->port.count)
44139 + if (atomic_read(&info->port.count))
44140 return -EBUSY;
44141
44142 if (cmd != SIOCWANDEV)
44143 @@ -2620,7 +2620,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
44144 * do not request bottom half processing if the
44145 * device is not open in a normal mode.
44146 */
44147 - if ( port && (port->port.count || port->netcount) &&
44148 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
44149 port->pending_bh && !port->bh_running &&
44150 !port->bh_requested ) {
44151 if ( debug_level >= DEBUG_LEVEL_ISR )
44152 @@ -3318,12 +3318,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44153
44154 if (debug_level >= DEBUG_LEVEL_INFO)
44155 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
44156 - __FILE__,__LINE__, tty->driver->name, port->count );
44157 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44158
44159 spin_lock_irqsave(&info->lock, flags);
44160 if (!tty_hung_up_p(filp)) {
44161 extra_count = true;
44162 - port->count--;
44163 + atomic_dec(&port->count);
44164 }
44165 spin_unlock_irqrestore(&info->lock, flags);
44166 port->blocked_open++;
44167 @@ -3352,7 +3352,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44168
44169 if (debug_level >= DEBUG_LEVEL_INFO)
44170 printk("%s(%d):%s block_til_ready() count=%d\n",
44171 - __FILE__,__LINE__, tty->driver->name, port->count );
44172 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44173
44174 tty_unlock(tty);
44175 schedule();
44176 @@ -3363,12 +3363,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
44177 remove_wait_queue(&port->open_wait, &wait);
44178
44179 if (extra_count)
44180 - port->count++;
44181 + atomic_inc(&port->count);
44182 port->blocked_open--;
44183
44184 if (debug_level >= DEBUG_LEVEL_INFO)
44185 printk("%s(%d):%s block_til_ready() after, count=%d\n",
44186 - __FILE__,__LINE__, tty->driver->name, port->count );
44187 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
44188
44189 if (!retval)
44190 port->flags |= ASYNC_NORMAL_ACTIVE;
44191 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
44192 index b51c154..17d55d1 100644
44193 --- a/drivers/tty/sysrq.c
44194 +++ b/drivers/tty/sysrq.c
44195 @@ -1022,7 +1022,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
44196 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
44197 size_t count, loff_t *ppos)
44198 {
44199 - if (count) {
44200 + if (count && capable(CAP_SYS_ADMIN)) {
44201 char c;
44202
44203 if (get_user(c, buf))
44204 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
44205 index 6464029..9ff6738 100644
44206 --- a/drivers/tty/tty_io.c
44207 +++ b/drivers/tty/tty_io.c
44208 @@ -3464,7 +3464,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
44209
44210 void tty_default_fops(struct file_operations *fops)
44211 {
44212 - *fops = tty_fops;
44213 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
44214 }
44215
44216 /*
44217 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
44218 index 1afe192..73d2c20 100644
44219 --- a/drivers/tty/tty_ldisc.c
44220 +++ b/drivers/tty/tty_ldisc.c
44221 @@ -66,7 +66,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
44222 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44223 tty_ldiscs[disc] = new_ldisc;
44224 new_ldisc->num = disc;
44225 - new_ldisc->refcount = 0;
44226 + atomic_set(&new_ldisc->refcount, 0);
44227 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44228
44229 return ret;
44230 @@ -94,7 +94,7 @@ int tty_unregister_ldisc(int disc)
44231 return -EINVAL;
44232
44233 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44234 - if (tty_ldiscs[disc]->refcount)
44235 + if (atomic_read(&tty_ldiscs[disc]->refcount))
44236 ret = -EBUSY;
44237 else
44238 tty_ldiscs[disc] = NULL;
44239 @@ -115,7 +115,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
44240 if (ldops) {
44241 ret = ERR_PTR(-EAGAIN);
44242 if (try_module_get(ldops->owner)) {
44243 - ldops->refcount++;
44244 + atomic_inc(&ldops->refcount);
44245 ret = ldops;
44246 }
44247 }
44248 @@ -128,7 +128,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
44249 unsigned long flags;
44250
44251 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
44252 - ldops->refcount--;
44253 + atomic_dec(&ldops->refcount);
44254 module_put(ldops->owner);
44255 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44256 }
44257 @@ -196,7 +196,7 @@ static inline void tty_ldisc_put(struct tty_ldisc *ld)
44258 /* unreleased reader reference(s) will cause this WARN */
44259 WARN_ON(!atomic_dec_and_test(&ld->users));
44260
44261 - ld->ops->refcount--;
44262 + atomic_dec(&ld->ops->refcount);
44263 module_put(ld->ops->owner);
44264 kfree(ld);
44265 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
44266 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
44267 index 121aeb9..0d2c4b9 100644
44268 --- a/drivers/tty/tty_port.c
44269 +++ b/drivers/tty/tty_port.c
44270 @@ -232,7 +232,7 @@ void tty_port_hangup(struct tty_port *port)
44271 unsigned long flags;
44272
44273 spin_lock_irqsave(&port->lock, flags);
44274 - port->count = 0;
44275 + atomic_set(&port->count, 0);
44276 port->flags &= ~ASYNC_NORMAL_ACTIVE;
44277 tty = port->tty;
44278 if (tty)
44279 @@ -391,7 +391,7 @@ int tty_port_block_til_ready(struct tty_port *port,
44280 /* The port lock protects the port counts */
44281 spin_lock_irqsave(&port->lock, flags);
44282 if (!tty_hung_up_p(filp))
44283 - port->count--;
44284 + atomic_dec(&port->count);
44285 port->blocked_open++;
44286 spin_unlock_irqrestore(&port->lock, flags);
44287
44288 @@ -433,7 +433,7 @@ int tty_port_block_til_ready(struct tty_port *port,
44289 we must not mess that up further */
44290 spin_lock_irqsave(&port->lock, flags);
44291 if (!tty_hung_up_p(filp))
44292 - port->count++;
44293 + atomic_inc(&port->count);
44294 port->blocked_open--;
44295 if (retval == 0)
44296 port->flags |= ASYNC_NORMAL_ACTIVE;
44297 @@ -467,19 +467,19 @@ int tty_port_close_start(struct tty_port *port,
44298 return 0;
44299 }
44300
44301 - if (tty->count == 1 && port->count != 1) {
44302 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
44303 printk(KERN_WARNING
44304 "tty_port_close_start: tty->count = 1 port count = %d.\n",
44305 - port->count);
44306 - port->count = 1;
44307 + atomic_read(&port->count));
44308 + atomic_set(&port->count, 1);
44309 }
44310 - if (--port->count < 0) {
44311 + if (atomic_dec_return(&port->count) < 0) {
44312 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
44313 - port->count);
44314 - port->count = 0;
44315 + atomic_read(&port->count));
44316 + atomic_set(&port->count, 0);
44317 }
44318
44319 - if (port->count) {
44320 + if (atomic_read(&port->count)) {
44321 spin_unlock_irqrestore(&port->lock, flags);
44322 if (port->ops->drop)
44323 port->ops->drop(port);
44324 @@ -565,7 +565,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
44325 {
44326 spin_lock_irq(&port->lock);
44327 if (!tty_hung_up_p(filp))
44328 - ++port->count;
44329 + atomic_inc(&port->count);
44330 spin_unlock_irq(&port->lock);
44331 tty_port_tty_set(port, tty);
44332
44333 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
44334 index a9af1b9a..1e08e7f 100644
44335 --- a/drivers/tty/vt/keyboard.c
44336 +++ b/drivers/tty/vt/keyboard.c
44337 @@ -647,6 +647,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
44338 kbd->kbdmode == VC_OFF) &&
44339 value != KVAL(K_SAK))
44340 return; /* SAK is allowed even in raw mode */
44341 +
44342 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
44343 + {
44344 + void *func = fn_handler[value];
44345 + if (func == fn_show_state || func == fn_show_ptregs ||
44346 + func == fn_show_mem)
44347 + return;
44348 + }
44349 +#endif
44350 +
44351 fn_handler[value](vc);
44352 }
44353
44354 @@ -1795,9 +1805,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
44355 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
44356 return -EFAULT;
44357
44358 - if (!capable(CAP_SYS_TTY_CONFIG))
44359 - perm = 0;
44360 -
44361 switch (cmd) {
44362 case KDGKBENT:
44363 /* Ensure another thread doesn't free it under us */
44364 @@ -1812,6 +1819,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
44365 spin_unlock_irqrestore(&kbd_event_lock, flags);
44366 return put_user(val, &user_kbe->kb_value);
44367 case KDSKBENT:
44368 + if (!capable(CAP_SYS_TTY_CONFIG))
44369 + perm = 0;
44370 +
44371 if (!perm)
44372 return -EPERM;
44373 if (!i && v == K_NOSUCHMAP) {
44374 @@ -1902,9 +1912,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
44375 int i, j, k;
44376 int ret;
44377
44378 - if (!capable(CAP_SYS_TTY_CONFIG))
44379 - perm = 0;
44380 -
44381 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
44382 if (!kbs) {
44383 ret = -ENOMEM;
44384 @@ -1938,6 +1945,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
44385 kfree(kbs);
44386 return ((p && *p) ? -EOVERFLOW : 0);
44387 case KDSKBSENT:
44388 + if (!capable(CAP_SYS_TTY_CONFIG))
44389 + perm = 0;
44390 +
44391 if (!perm) {
44392 ret = -EPERM;
44393 goto reterr;
44394 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
44395 index b645c47..a55c182 100644
44396 --- a/drivers/uio/uio.c
44397 +++ b/drivers/uio/uio.c
44398 @@ -25,6 +25,7 @@
44399 #include <linux/kobject.h>
44400 #include <linux/cdev.h>
44401 #include <linux/uio_driver.h>
44402 +#include <asm/local.h>
44403
44404 #define UIO_MAX_DEVICES (1U << MINORBITS)
44405
44406 @@ -32,10 +33,10 @@ struct uio_device {
44407 struct module *owner;
44408 struct device *dev;
44409 int minor;
44410 - atomic_t event;
44411 + atomic_unchecked_t event;
44412 struct fasync_struct *async_queue;
44413 wait_queue_head_t wait;
44414 - int vma_count;
44415 + local_t vma_count;
44416 struct uio_info *info;
44417 struct kobject *map_dir;
44418 struct kobject *portio_dir;
44419 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
44420 struct device_attribute *attr, char *buf)
44421 {
44422 struct uio_device *idev = dev_get_drvdata(dev);
44423 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
44424 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
44425 }
44426
44427 static struct device_attribute uio_class_attributes[] = {
44428 @@ -398,7 +399,7 @@ void uio_event_notify(struct uio_info *info)
44429 {
44430 struct uio_device *idev = info->uio_dev;
44431
44432 - atomic_inc(&idev->event);
44433 + atomic_inc_unchecked(&idev->event);
44434 wake_up_interruptible(&idev->wait);
44435 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
44436 }
44437 @@ -451,7 +452,7 @@ static int uio_open(struct inode *inode, struct file *filep)
44438 }
44439
44440 listener->dev = idev;
44441 - listener->event_count = atomic_read(&idev->event);
44442 + listener->event_count = atomic_read_unchecked(&idev->event);
44443 filep->private_data = listener;
44444
44445 if (idev->info->open) {
44446 @@ -502,7 +503,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
44447 return -EIO;
44448
44449 poll_wait(filep, &idev->wait, wait);
44450 - if (listener->event_count != atomic_read(&idev->event))
44451 + if (listener->event_count != atomic_read_unchecked(&idev->event))
44452 return POLLIN | POLLRDNORM;
44453 return 0;
44454 }
44455 @@ -527,7 +528,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
44456 do {
44457 set_current_state(TASK_INTERRUPTIBLE);
44458
44459 - event_count = atomic_read(&idev->event);
44460 + event_count = atomic_read_unchecked(&idev->event);
44461 if (event_count != listener->event_count) {
44462 if (copy_to_user(buf, &event_count, count))
44463 retval = -EFAULT;
44464 @@ -596,13 +597,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
44465 static void uio_vma_open(struct vm_area_struct *vma)
44466 {
44467 struct uio_device *idev = vma->vm_private_data;
44468 - idev->vma_count++;
44469 + local_inc(&idev->vma_count);
44470 }
44471
44472 static void uio_vma_close(struct vm_area_struct *vma)
44473 {
44474 struct uio_device *idev = vma->vm_private_data;
44475 - idev->vma_count--;
44476 + local_dec(&idev->vma_count);
44477 }
44478
44479 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
44480 @@ -809,7 +810,7 @@ int __uio_register_device(struct module *owner,
44481 idev->owner = owner;
44482 idev->info = info;
44483 init_waitqueue_head(&idev->wait);
44484 - atomic_set(&idev->event, 0);
44485 + atomic_set_unchecked(&idev->event, 0);
44486
44487 ret = uio_get_minor(idev);
44488 if (ret)
44489 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
44490 index 8a7eb77..c00402f 100644
44491 --- a/drivers/usb/atm/cxacru.c
44492 +++ b/drivers/usb/atm/cxacru.c
44493 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
44494 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
44495 if (ret < 2)
44496 return -EINVAL;
44497 - if (index < 0 || index > 0x7f)
44498 + if (index > 0x7f)
44499 return -EINVAL;
44500 pos += tmp;
44501
44502 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
44503 index d3527dd..26effa2 100644
44504 --- a/drivers/usb/atm/usbatm.c
44505 +++ b/drivers/usb/atm/usbatm.c
44506 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44507 if (printk_ratelimit())
44508 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
44509 __func__, vpi, vci);
44510 - atomic_inc(&vcc->stats->rx_err);
44511 + atomic_inc_unchecked(&vcc->stats->rx_err);
44512 return;
44513 }
44514
44515 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44516 if (length > ATM_MAX_AAL5_PDU) {
44517 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
44518 __func__, length, vcc);
44519 - atomic_inc(&vcc->stats->rx_err);
44520 + atomic_inc_unchecked(&vcc->stats->rx_err);
44521 goto out;
44522 }
44523
44524 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44525 if (sarb->len < pdu_length) {
44526 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
44527 __func__, pdu_length, sarb->len, vcc);
44528 - atomic_inc(&vcc->stats->rx_err);
44529 + atomic_inc_unchecked(&vcc->stats->rx_err);
44530 goto out;
44531 }
44532
44533 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
44534 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
44535 __func__, vcc);
44536 - atomic_inc(&vcc->stats->rx_err);
44537 + atomic_inc_unchecked(&vcc->stats->rx_err);
44538 goto out;
44539 }
44540
44541 @@ -389,7 +389,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44542 if (printk_ratelimit())
44543 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
44544 __func__, length);
44545 - atomic_inc(&vcc->stats->rx_drop);
44546 + atomic_inc_unchecked(&vcc->stats->rx_drop);
44547 goto out;
44548 }
44549
44550 @@ -417,7 +417,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
44551
44552 vcc->push(vcc, skb);
44553
44554 - atomic_inc(&vcc->stats->rx);
44555 + atomic_inc_unchecked(&vcc->stats->rx);
44556 out:
44557 skb_trim(sarb, 0);
44558 }
44559 @@ -623,7 +623,7 @@ static void usbatm_tx_process(unsigned long data)
44560 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
44561
44562 usbatm_pop(vcc, skb);
44563 - atomic_inc(&vcc->stats->tx);
44564 + atomic_inc_unchecked(&vcc->stats->tx);
44565
44566 skb = skb_dequeue(&instance->sndqueue);
44567 }
44568 @@ -779,11 +779,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
44569 if (!left--)
44570 return sprintf(page,
44571 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
44572 - atomic_read(&atm_dev->stats.aal5.tx),
44573 - atomic_read(&atm_dev->stats.aal5.tx_err),
44574 - atomic_read(&atm_dev->stats.aal5.rx),
44575 - atomic_read(&atm_dev->stats.aal5.rx_err),
44576 - atomic_read(&atm_dev->stats.aal5.rx_drop));
44577 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
44578 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
44579 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
44580 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
44581 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
44582
44583 if (!left--) {
44584 if (instance->disconnected)
44585 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
44586 index 2a3bbdf..91d72cf 100644
44587 --- a/drivers/usb/core/devices.c
44588 +++ b/drivers/usb/core/devices.c
44589 @@ -126,7 +126,7 @@ static const char format_endpt[] =
44590 * time it gets called.
44591 */
44592 static struct device_connect_event {
44593 - atomic_t count;
44594 + atomic_unchecked_t count;
44595 wait_queue_head_t wait;
44596 } device_event = {
44597 .count = ATOMIC_INIT(1),
44598 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
44599
44600 void usbfs_conn_disc_event(void)
44601 {
44602 - atomic_add(2, &device_event.count);
44603 + atomic_add_unchecked(2, &device_event.count);
44604 wake_up(&device_event.wait);
44605 }
44606
44607 @@ -652,7 +652,7 @@ static unsigned int usb_device_poll(struct file *file,
44608
44609 poll_wait(file, &device_event.wait, wait);
44610
44611 - event_count = atomic_read(&device_event.count);
44612 + event_count = atomic_read_unchecked(&device_event.count);
44613 if (file->f_version != event_count) {
44614 file->f_version = event_count;
44615 return POLLIN | POLLRDNORM;
44616 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
44617 index d53547d..6a22d02 100644
44618 --- a/drivers/usb/core/hcd.c
44619 +++ b/drivers/usb/core/hcd.c
44620 @@ -1526,7 +1526,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
44621 */
44622 usb_get_urb(urb);
44623 atomic_inc(&urb->use_count);
44624 - atomic_inc(&urb->dev->urbnum);
44625 + atomic_inc_unchecked(&urb->dev->urbnum);
44626 usbmon_urb_submit(&hcd->self, urb);
44627
44628 /* NOTE requirements on root-hub callers (usbfs and the hub
44629 @@ -1553,7 +1553,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
44630 urb->hcpriv = NULL;
44631 INIT_LIST_HEAD(&urb->urb_list);
44632 atomic_dec(&urb->use_count);
44633 - atomic_dec(&urb->dev->urbnum);
44634 + atomic_dec_unchecked(&urb->dev->urbnum);
44635 if (atomic_read(&urb->reject))
44636 wake_up(&usb_kill_urb_queue);
44637 usb_put_urb(urb);
44638 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
44639 index 444d30e..f15c850 100644
44640 --- a/drivers/usb/core/message.c
44641 +++ b/drivers/usb/core/message.c
44642 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
44643 * method can wait for it to complete. Since you don't have a handle on the
44644 * URB used, you can't cancel the request.
44645 */
44646 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44647 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
44648 __u8 requesttype, __u16 value, __u16 index, void *data,
44649 __u16 size, int timeout)
44650 {
44651 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
44652 index aa38db4..0a08682 100644
44653 --- a/drivers/usb/core/sysfs.c
44654 +++ b/drivers/usb/core/sysfs.c
44655 @@ -239,7 +239,7 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
44656 struct usb_device *udev;
44657
44658 udev = to_usb_device(dev);
44659 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
44660 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
44661 }
44662 static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);
44663
44664 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
44665 index b10da72..43aa0b2 100644
44666 --- a/drivers/usb/core/usb.c
44667 +++ b/drivers/usb/core/usb.c
44668 @@ -389,7 +389,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
44669 set_dev_node(&dev->dev, dev_to_node(bus->controller));
44670 dev->state = USB_STATE_ATTACHED;
44671 dev->lpm_disable_count = 1;
44672 - atomic_set(&dev->urbnum, 0);
44673 + atomic_set_unchecked(&dev->urbnum, 0);
44674
44675 INIT_LIST_HEAD(&dev->ep0.urb_list);
44676 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
44677 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
44678 index 5e29dde..eca992f 100644
44679 --- a/drivers/usb/early/ehci-dbgp.c
44680 +++ b/drivers/usb/early/ehci-dbgp.c
44681 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
44682
44683 #ifdef CONFIG_KGDB
44684 static struct kgdb_io kgdbdbgp_io_ops;
44685 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
44686 +static struct kgdb_io kgdbdbgp_io_ops_console;
44687 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
44688 #else
44689 #define dbgp_kgdb_mode (0)
44690 #endif
44691 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
44692 .write_char = kgdbdbgp_write_char,
44693 };
44694
44695 +static struct kgdb_io kgdbdbgp_io_ops_console = {
44696 + .name = "kgdbdbgp",
44697 + .read_char = kgdbdbgp_read_char,
44698 + .write_char = kgdbdbgp_write_char,
44699 + .is_console = 1
44700 +};
44701 +
44702 static int kgdbdbgp_wait_time;
44703
44704 static int __init kgdbdbgp_parse_config(char *str)
44705 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
44706 ptr++;
44707 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
44708 }
44709 - kgdb_register_io_module(&kgdbdbgp_io_ops);
44710 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
44711 + if (early_dbgp_console.index != -1)
44712 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
44713 + else
44714 + kgdb_register_io_module(&kgdbdbgp_io_ops);
44715
44716 return 0;
44717 }
44718 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
44719 index b369292..9f3ba40 100644
44720 --- a/drivers/usb/gadget/u_serial.c
44721 +++ b/drivers/usb/gadget/u_serial.c
44722 @@ -733,9 +733,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44723 spin_lock_irq(&port->port_lock);
44724
44725 /* already open? Great. */
44726 - if (port->port.count) {
44727 + if (atomic_read(&port->port.count)) {
44728 status = 0;
44729 - port->port.count++;
44730 + atomic_inc(&port->port.count);
44731
44732 /* currently opening/closing? wait ... */
44733 } else if (port->openclose) {
44734 @@ -794,7 +794,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
44735 tty->driver_data = port;
44736 port->port.tty = tty;
44737
44738 - port->port.count = 1;
44739 + atomic_set(&port->port.count, 1);
44740 port->openclose = false;
44741
44742 /* if connected, start the I/O stream */
44743 @@ -836,11 +836,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44744
44745 spin_lock_irq(&port->port_lock);
44746
44747 - if (port->port.count != 1) {
44748 - if (port->port.count == 0)
44749 + if (atomic_read(&port->port.count) != 1) {
44750 + if (atomic_read(&port->port.count) == 0)
44751 WARN_ON(1);
44752 else
44753 - --port->port.count;
44754 + atomic_dec(&port->port.count);
44755 goto exit;
44756 }
44757
44758 @@ -850,7 +850,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
44759 * and sleep if necessary
44760 */
44761 port->openclose = true;
44762 - port->port.count = 0;
44763 + atomic_set(&port->port.count, 0);
44764
44765 gser = port->port_usb;
44766 if (gser && gser->disconnect)
44767 @@ -1066,7 +1066,7 @@ static int gs_closed(struct gs_port *port)
44768 int cond;
44769
44770 spin_lock_irq(&port->port_lock);
44771 - cond = (port->port.count == 0) && !port->openclose;
44772 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
44773 spin_unlock_irq(&port->port_lock);
44774 return cond;
44775 }
44776 @@ -1209,7 +1209,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
44777 /* if it's already open, start I/O ... and notify the serial
44778 * protocol about open/close status (connect/disconnect).
44779 */
44780 - if (port->port.count) {
44781 + if (atomic_read(&port->port.count)) {
44782 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
44783 gs_start_io(port);
44784 if (gser->connect)
44785 @@ -1256,7 +1256,7 @@ void gserial_disconnect(struct gserial *gser)
44786
44787 port->port_usb = NULL;
44788 gser->ioport = NULL;
44789 - if (port->port.count > 0 || port->openclose) {
44790 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
44791 wake_up_interruptible(&port->drain_wait);
44792 if (port->port.tty)
44793 tty_hangup(port->port.tty);
44794 @@ -1272,7 +1272,7 @@ void gserial_disconnect(struct gserial *gser)
44795
44796 /* finally, free any unused/unusable I/O buffers */
44797 spin_lock_irqsave(&port->port_lock, flags);
44798 - if (port->port.count == 0 && !port->openclose)
44799 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
44800 gs_buf_free(&port->port_write_buf);
44801 gs_free_requests(gser->out, &port->read_pool, NULL);
44802 gs_free_requests(gser->out, &port->read_queue, NULL);
44803 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
44804 index 5f3bcd3..bfca43f 100644
44805 --- a/drivers/usb/serial/console.c
44806 +++ b/drivers/usb/serial/console.c
44807 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
44808
44809 info->port = port;
44810
44811 - ++port->port.count;
44812 + atomic_inc(&port->port.count);
44813 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
44814 if (serial->type->set_termios) {
44815 /*
44816 @@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options)
44817 }
44818 /* Now that any required fake tty operations are completed restore
44819 * the tty port count */
44820 - --port->port.count;
44821 + atomic_dec(&port->port.count);
44822 /* The console is special in terms of closing the device so
44823 * indicate this port is now acting as a system console. */
44824 port->port.console = 1;
44825 @@ -187,7 +187,7 @@ static int usb_console_setup(struct console *co, char *options)
44826 free_tty:
44827 kfree(tty);
44828 reset_open_count:
44829 - port->port.count = 0;
44830 + atomic_set(&port->port.count, 0);
44831 usb_autopm_put_interface(serial->interface);
44832 error_get_interface:
44833 usb_serial_put(serial);
44834 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
44835 index 75f70f0..d467e1a 100644
44836 --- a/drivers/usb/storage/usb.h
44837 +++ b/drivers/usb/storage/usb.h
44838 @@ -63,7 +63,7 @@ struct us_unusual_dev {
44839 __u8 useProtocol;
44840 __u8 useTransport;
44841 int (*initFunction)(struct us_data *);
44842 -};
44843 +} __do_const;
44844
44845
44846 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
44847 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
44848 index d6bea3e..60b250e 100644
44849 --- a/drivers/usb/wusbcore/wa-hc.h
44850 +++ b/drivers/usb/wusbcore/wa-hc.h
44851 @@ -192,7 +192,7 @@ struct wahc {
44852 struct list_head xfer_delayed_list;
44853 spinlock_t xfer_list_lock;
44854 struct work_struct xfer_work;
44855 - atomic_t xfer_id_count;
44856 + atomic_unchecked_t xfer_id_count;
44857 };
44858
44859
44860 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
44861 INIT_LIST_HEAD(&wa->xfer_delayed_list);
44862 spin_lock_init(&wa->xfer_list_lock);
44863 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
44864 - atomic_set(&wa->xfer_id_count, 1);
44865 + atomic_set_unchecked(&wa->xfer_id_count, 1);
44866 }
44867
44868 /**
44869 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
44870 index 6ef94bc..1b41265 100644
44871 --- a/drivers/usb/wusbcore/wa-xfer.c
44872 +++ b/drivers/usb/wusbcore/wa-xfer.c
44873 @@ -296,7 +296,7 @@ out:
44874 */
44875 static void wa_xfer_id_init(struct wa_xfer *xfer)
44876 {
44877 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
44878 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
44879 }
44880
44881 /*
44882 diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
44883 index 5174eba..86e764a 100644
44884 --- a/drivers/vhost/vringh.c
44885 +++ b/drivers/vhost/vringh.c
44886 @@ -800,7 +800,7 @@ static inline int getu16_kern(u16 *val, const u16 *p)
44887
44888 static inline int putu16_kern(u16 *p, u16 val)
44889 {
44890 - ACCESS_ONCE(*p) = val;
44891 + ACCESS_ONCE_RW(*p) = val;
44892 return 0;
44893 }
44894
44895 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
44896 index 8c55011..eed4ae1a 100644
44897 --- a/drivers/video/aty/aty128fb.c
44898 +++ b/drivers/video/aty/aty128fb.c
44899 @@ -149,7 +149,7 @@ enum {
44900 };
44901
44902 /* Must match above enum */
44903 -static char * const r128_family[] = {
44904 +static const char * const r128_family[] = {
44905 "AGP",
44906 "PCI",
44907 "PRO AGP",
44908 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
44909 index 4f27fdc..d3537e6 100644
44910 --- a/drivers/video/aty/atyfb_base.c
44911 +++ b/drivers/video/aty/atyfb_base.c
44912 @@ -1325,10 +1325,14 @@ static int atyfb_set_par(struct fb_info *info)
44913 par->accel_flags = var->accel_flags; /* hack */
44914
44915 if (var->accel_flags) {
44916 - info->fbops->fb_sync = atyfb_sync;
44917 + pax_open_kernel();
44918 + *(void **)&info->fbops->fb_sync = atyfb_sync;
44919 + pax_close_kernel();
44920 info->flags &= ~FBINFO_HWACCEL_DISABLED;
44921 } else {
44922 - info->fbops->fb_sync = NULL;
44923 + pax_open_kernel();
44924 + *(void **)&info->fbops->fb_sync = NULL;
44925 + pax_close_kernel();
44926 info->flags |= FBINFO_HWACCEL_DISABLED;
44927 }
44928
44929 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
44930 index 95ec042..e6affdd 100644
44931 --- a/drivers/video/aty/mach64_cursor.c
44932 +++ b/drivers/video/aty/mach64_cursor.c
44933 @@ -7,6 +7,7 @@
44934 #include <linux/string.h>
44935
44936 #include <asm/io.h>
44937 +#include <asm/pgtable.h>
44938
44939 #ifdef __sparc__
44940 #include <asm/fbio.h>
44941 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
44942 info->sprite.buf_align = 16; /* and 64 lines tall. */
44943 info->sprite.flags = FB_PIXMAP_IO;
44944
44945 - info->fbops->fb_cursor = atyfb_cursor;
44946 + pax_open_kernel();
44947 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
44948 + pax_close_kernel();
44949
44950 return 0;
44951 }
44952 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
44953 index bca6ccc..252107e 100644
44954 --- a/drivers/video/backlight/kb3886_bl.c
44955 +++ b/drivers/video/backlight/kb3886_bl.c
44956 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
44957 static unsigned long kb3886bl_flags;
44958 #define KB3886BL_SUSPENDED 0x01
44959
44960 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
44961 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
44962 {
44963 .ident = "Sahara Touch-iT",
44964 .matches = {
44965 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
44966 index 900aa4e..6d49418 100644
44967 --- a/drivers/video/fb_defio.c
44968 +++ b/drivers/video/fb_defio.c
44969 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
44970
44971 BUG_ON(!fbdefio);
44972 mutex_init(&fbdefio->lock);
44973 - info->fbops->fb_mmap = fb_deferred_io_mmap;
44974 + pax_open_kernel();
44975 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
44976 + pax_close_kernel();
44977 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
44978 INIT_LIST_HEAD(&fbdefio->pagelist);
44979 if (fbdefio->delay == 0) /* set a default of 1 s */
44980 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
44981 page->mapping = NULL;
44982 }
44983
44984 - info->fbops->fb_mmap = NULL;
44985 + *(void **)&info->fbops->fb_mmap = NULL;
44986 mutex_destroy(&fbdefio->lock);
44987 }
44988 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
44989 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
44990 index 5c3960d..15cf8fc 100644
44991 --- a/drivers/video/fbcmap.c
44992 +++ b/drivers/video/fbcmap.c
44993 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
44994 rc = -ENODEV;
44995 goto out;
44996 }
44997 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
44998 - !info->fbops->fb_setcmap)) {
44999 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
45000 rc = -EINVAL;
45001 goto out1;
45002 }
45003 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
45004 index 098bfc6..796841d 100644
45005 --- a/drivers/video/fbmem.c
45006 +++ b/drivers/video/fbmem.c
45007 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
45008 image->dx += image->width + 8;
45009 }
45010 } else if (rotate == FB_ROTATE_UD) {
45011 - for (x = 0; x < num && image->dx >= 0; x++) {
45012 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
45013 info->fbops->fb_imageblit(info, image);
45014 image->dx -= image->width + 8;
45015 }
45016 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
45017 image->dy += image->height + 8;
45018 }
45019 } else if (rotate == FB_ROTATE_CCW) {
45020 - for (x = 0; x < num && image->dy >= 0; x++) {
45021 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
45022 info->fbops->fb_imageblit(info, image);
45023 image->dy -= image->height + 8;
45024 }
45025 @@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
45026 return -EFAULT;
45027 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
45028 return -EINVAL;
45029 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
45030 + if (con2fb.framebuffer >= FB_MAX)
45031 return -EINVAL;
45032 if (!registered_fb[con2fb.framebuffer])
45033 request_module("fb%d", con2fb.framebuffer);
45034 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
45035 index 7672d2e..b56437f 100644
45036 --- a/drivers/video/i810/i810_accel.c
45037 +++ b/drivers/video/i810/i810_accel.c
45038 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
45039 }
45040 }
45041 printk("ringbuffer lockup!!!\n");
45042 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
45043 i810_report_error(mmio);
45044 par->dev_flags |= LOCKUP;
45045 info->pixmap.scan_align = 1;
45046 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
45047 index 3c14e43..eafa544 100644
45048 --- a/drivers/video/logo/logo_linux_clut224.ppm
45049 +++ b/drivers/video/logo/logo_linux_clut224.ppm
45050 @@ -1,1604 +1,1123 @@
45051 P3
45052 -# Standard 224-color Linux logo
45053 80 80
45054 255
45055 - 0 0 0 0 0 0 0 0 0 0 0 0
45056 - 0 0 0 0 0 0 0 0 0 0 0 0
45057 - 0 0 0 0 0 0 0 0 0 0 0 0
45058 - 0 0 0 0 0 0 0 0 0 0 0 0
45059 - 0 0 0 0 0 0 0 0 0 0 0 0
45060 - 0 0 0 0 0 0 0 0 0 0 0 0
45061 - 0 0 0 0 0 0 0 0 0 0 0 0
45062 - 0 0 0 0 0 0 0 0 0 0 0 0
45063 - 0 0 0 0 0 0 0 0 0 0 0 0
45064 - 6 6 6 6 6 6 10 10 10 10 10 10
45065 - 10 10 10 6 6 6 6 6 6 6 6 6
45066 - 0 0 0 0 0 0 0 0 0 0 0 0
45067 - 0 0 0 0 0 0 0 0 0 0 0 0
45068 - 0 0 0 0 0 0 0 0 0 0 0 0
45069 - 0 0 0 0 0 0 0 0 0 0 0 0
45070 - 0 0 0 0 0 0 0 0 0 0 0 0
45071 - 0 0 0 0 0 0 0 0 0 0 0 0
45072 - 0 0 0 0 0 0 0 0 0 0 0 0
45073 - 0 0 0 0 0 0 0 0 0 0 0 0
45074 - 0 0 0 0 0 0 0 0 0 0 0 0
45075 - 0 0 0 0 0 0 0 0 0 0 0 0
45076 - 0 0 0 0 0 0 0 0 0 0 0 0
45077 - 0 0 0 0 0 0 0 0 0 0 0 0
45078 - 0 0 0 0 0 0 0 0 0 0 0 0
45079 - 0 0 0 0 0 0 0 0 0 0 0 0
45080 - 0 0 0 0 0 0 0 0 0 0 0 0
45081 - 0 0 0 0 0 0 0 0 0 0 0 0
45082 - 0 0 0 0 0 0 0 0 0 0 0 0
45083 - 0 0 0 6 6 6 10 10 10 14 14 14
45084 - 22 22 22 26 26 26 30 30 30 34 34 34
45085 - 30 30 30 30 30 30 26 26 26 18 18 18
45086 - 14 14 14 10 10 10 6 6 6 0 0 0
45087 - 0 0 0 0 0 0 0 0 0 0 0 0
45088 - 0 0 0 0 0 0 0 0 0 0 0 0
45089 - 0 0 0 0 0 0 0 0 0 0 0 0
45090 - 0 0 0 0 0 0 0 0 0 0 0 0
45091 - 0 0 0 0 0 0 0 0 0 0 0 0
45092 - 0 0 0 0 0 0 0 0 0 0 0 0
45093 - 0 0 0 0 0 0 0 0 0 0 0 0
45094 - 0 0 0 0 0 0 0 0 0 0 0 0
45095 - 0 0 0 0 0 0 0 0 0 0 0 0
45096 - 0 0 0 0 0 1 0 0 1 0 0 0
45097 - 0 0 0 0 0 0 0 0 0 0 0 0
45098 - 0 0 0 0 0 0 0 0 0 0 0 0
45099 - 0 0 0 0 0 0 0 0 0 0 0 0
45100 - 0 0 0 0 0 0 0 0 0 0 0 0
45101 - 0 0 0 0 0 0 0 0 0 0 0 0
45102 - 0 0 0 0 0 0 0 0 0 0 0 0
45103 - 6 6 6 14 14 14 26 26 26 42 42 42
45104 - 54 54 54 66 66 66 78 78 78 78 78 78
45105 - 78 78 78 74 74 74 66 66 66 54 54 54
45106 - 42 42 42 26 26 26 18 18 18 10 10 10
45107 - 6 6 6 0 0 0 0 0 0 0 0 0
45108 - 0 0 0 0 0 0 0 0 0 0 0 0
45109 - 0 0 0 0 0 0 0 0 0 0 0 0
45110 - 0 0 0 0 0 0 0 0 0 0 0 0
45111 - 0 0 0 0 0 0 0 0 0 0 0 0
45112 - 0 0 0 0 0 0 0 0 0 0 0 0
45113 - 0 0 0 0 0 0 0 0 0 0 0 0
45114 - 0 0 0 0 0 0 0 0 0 0 0 0
45115 - 0 0 0 0 0 0 0 0 0 0 0 0
45116 - 0 0 1 0 0 0 0 0 0 0 0 0
45117 - 0 0 0 0 0 0 0 0 0 0 0 0
45118 - 0 0 0 0 0 0 0 0 0 0 0 0
45119 - 0 0 0 0 0 0 0 0 0 0 0 0
45120 - 0 0 0 0 0 0 0 0 0 0 0 0
45121 - 0 0 0 0 0 0 0 0 0 0 0 0
45122 - 0 0 0 0 0 0 0 0 0 10 10 10
45123 - 22 22 22 42 42 42 66 66 66 86 86 86
45124 - 66 66 66 38 38 38 38 38 38 22 22 22
45125 - 26 26 26 34 34 34 54 54 54 66 66 66
45126 - 86 86 86 70 70 70 46 46 46 26 26 26
45127 - 14 14 14 6 6 6 0 0 0 0 0 0
45128 - 0 0 0 0 0 0 0 0 0 0 0 0
45129 - 0 0 0 0 0 0 0 0 0 0 0 0
45130 - 0 0 0 0 0 0 0 0 0 0 0 0
45131 - 0 0 0 0 0 0 0 0 0 0 0 0
45132 - 0 0 0 0 0 0 0 0 0 0 0 0
45133 - 0 0 0 0 0 0 0 0 0 0 0 0
45134 - 0 0 0 0 0 0 0 0 0 0 0 0
45135 - 0 0 0 0 0 0 0 0 0 0 0 0
45136 - 0 0 1 0 0 1 0 0 1 0 0 0
45137 - 0 0 0 0 0 0 0 0 0 0 0 0
45138 - 0 0 0 0 0 0 0 0 0 0 0 0
45139 - 0 0 0 0 0 0 0 0 0 0 0 0
45140 - 0 0 0 0 0 0 0 0 0 0 0 0
45141 - 0 0 0 0 0 0 0 0 0 0 0 0
45142 - 0 0 0 0 0 0 10 10 10 26 26 26
45143 - 50 50 50 82 82 82 58 58 58 6 6 6
45144 - 2 2 6 2 2 6 2 2 6 2 2 6
45145 - 2 2 6 2 2 6 2 2 6 2 2 6
45146 - 6 6 6 54 54 54 86 86 86 66 66 66
45147 - 38 38 38 18 18 18 6 6 6 0 0 0
45148 - 0 0 0 0 0 0 0 0 0 0 0 0
45149 - 0 0 0 0 0 0 0 0 0 0 0 0
45150 - 0 0 0 0 0 0 0 0 0 0 0 0
45151 - 0 0 0 0 0 0 0 0 0 0 0 0
45152 - 0 0 0 0 0 0 0 0 0 0 0 0
45153 - 0 0 0 0 0 0 0 0 0 0 0 0
45154 - 0 0 0 0 0 0 0 0 0 0 0 0
45155 - 0 0 0 0 0 0 0 0 0 0 0 0
45156 - 0 0 0 0 0 0 0 0 0 0 0 0
45157 - 0 0 0 0 0 0 0 0 0 0 0 0
45158 - 0 0 0 0 0 0 0 0 0 0 0 0
45159 - 0 0 0 0 0 0 0 0 0 0 0 0
45160 - 0 0 0 0 0 0 0 0 0 0 0 0
45161 - 0 0 0 0 0 0 0 0 0 0 0 0
45162 - 0 0 0 6 6 6 22 22 22 50 50 50
45163 - 78 78 78 34 34 34 2 2 6 2 2 6
45164 - 2 2 6 2 2 6 2 2 6 2 2 6
45165 - 2 2 6 2 2 6 2 2 6 2 2 6
45166 - 2 2 6 2 2 6 6 6 6 70 70 70
45167 - 78 78 78 46 46 46 22 22 22 6 6 6
45168 - 0 0 0 0 0 0 0 0 0 0 0 0
45169 - 0 0 0 0 0 0 0 0 0 0 0 0
45170 - 0 0 0 0 0 0 0 0 0 0 0 0
45171 - 0 0 0 0 0 0 0 0 0 0 0 0
45172 - 0 0 0 0 0 0 0 0 0 0 0 0
45173 - 0 0 0 0 0 0 0 0 0 0 0 0
45174 - 0 0 0 0 0 0 0 0 0 0 0 0
45175 - 0 0 0 0 0 0 0 0 0 0 0 0
45176 - 0 0 1 0 0 1 0 0 1 0 0 0
45177 - 0 0 0 0 0 0 0 0 0 0 0 0
45178 - 0 0 0 0 0 0 0 0 0 0 0 0
45179 - 0 0 0 0 0 0 0 0 0 0 0 0
45180 - 0 0 0 0 0 0 0 0 0 0 0 0
45181 - 0 0 0 0 0 0 0 0 0 0 0 0
45182 - 6 6 6 18 18 18 42 42 42 82 82 82
45183 - 26 26 26 2 2 6 2 2 6 2 2 6
45184 - 2 2 6 2 2 6 2 2 6 2 2 6
45185 - 2 2 6 2 2 6 2 2 6 14 14 14
45186 - 46 46 46 34 34 34 6 6 6 2 2 6
45187 - 42 42 42 78 78 78 42 42 42 18 18 18
45188 - 6 6 6 0 0 0 0 0 0 0 0 0
45189 - 0 0 0 0 0 0 0 0 0 0 0 0
45190 - 0 0 0 0 0 0 0 0 0 0 0 0
45191 - 0 0 0 0 0 0 0 0 0 0 0 0
45192 - 0 0 0 0 0 0 0 0 0 0 0 0
45193 - 0 0 0 0 0 0 0 0 0 0 0 0
45194 - 0 0 0 0 0 0 0 0 0 0 0 0
45195 - 0 0 0 0 0 0 0 0 0 0 0 0
45196 - 0 0 1 0 0 0 0 0 1 0 0 0
45197 - 0 0 0 0 0 0 0 0 0 0 0 0
45198 - 0 0 0 0 0 0 0 0 0 0 0 0
45199 - 0 0 0 0 0 0 0 0 0 0 0 0
45200 - 0 0 0 0 0 0 0 0 0 0 0 0
45201 - 0 0 0 0 0 0 0 0 0 0 0 0
45202 - 10 10 10 30 30 30 66 66 66 58 58 58
45203 - 2 2 6 2 2 6 2 2 6 2 2 6
45204 - 2 2 6 2 2 6 2 2 6 2 2 6
45205 - 2 2 6 2 2 6 2 2 6 26 26 26
45206 - 86 86 86 101 101 101 46 46 46 10 10 10
45207 - 2 2 6 58 58 58 70 70 70 34 34 34
45208 - 10 10 10 0 0 0 0 0 0 0 0 0
45209 - 0 0 0 0 0 0 0 0 0 0 0 0
45210 - 0 0 0 0 0 0 0 0 0 0 0 0
45211 - 0 0 0 0 0 0 0 0 0 0 0 0
45212 - 0 0 0 0 0 0 0 0 0 0 0 0
45213 - 0 0 0 0 0 0 0 0 0 0 0 0
45214 - 0 0 0 0 0 0 0 0 0 0 0 0
45215 - 0 0 0 0 0 0 0 0 0 0 0 0
45216 - 0 0 1 0 0 1 0 0 1 0 0 0
45217 - 0 0 0 0 0 0 0 0 0 0 0 0
45218 - 0 0 0 0 0 0 0 0 0 0 0 0
45219 - 0 0 0 0 0 0 0 0 0 0 0 0
45220 - 0 0 0 0 0 0 0 0 0 0 0 0
45221 - 0 0 0 0 0 0 0 0 0 0 0 0
45222 - 14 14 14 42 42 42 86 86 86 10 10 10
45223 - 2 2 6 2 2 6 2 2 6 2 2 6
45224 - 2 2 6 2 2 6 2 2 6 2 2 6
45225 - 2 2 6 2 2 6 2 2 6 30 30 30
45226 - 94 94 94 94 94 94 58 58 58 26 26 26
45227 - 2 2 6 6 6 6 78 78 78 54 54 54
45228 - 22 22 22 6 6 6 0 0 0 0 0 0
45229 - 0 0 0 0 0 0 0 0 0 0 0 0
45230 - 0 0 0 0 0 0 0 0 0 0 0 0
45231 - 0 0 0 0 0 0 0 0 0 0 0 0
45232 - 0 0 0 0 0 0 0 0 0 0 0 0
45233 - 0 0 0 0 0 0 0 0 0 0 0 0
45234 - 0 0 0 0 0 0 0 0 0 0 0 0
45235 - 0 0 0 0 0 0 0 0 0 0 0 0
45236 - 0 0 0 0 0 0 0 0 0 0 0 0
45237 - 0 0 0 0 0 0 0 0 0 0 0 0
45238 - 0 0 0 0 0 0 0 0 0 0 0 0
45239 - 0 0 0 0 0 0 0 0 0 0 0 0
45240 - 0 0 0 0 0 0 0 0 0 0 0 0
45241 - 0 0 0 0 0 0 0 0 0 6 6 6
45242 - 22 22 22 62 62 62 62 62 62 2 2 6
45243 - 2 2 6 2 2 6 2 2 6 2 2 6
45244 - 2 2 6 2 2 6 2 2 6 2 2 6
45245 - 2 2 6 2 2 6 2 2 6 26 26 26
45246 - 54 54 54 38 38 38 18 18 18 10 10 10
45247 - 2 2 6 2 2 6 34 34 34 82 82 82
45248 - 38 38 38 14 14 14 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 1 0 0 1 0 0 0
45257 - 0 0 0 0 0 0 0 0 0 0 0 0
45258 - 0 0 0 0 0 0 0 0 0 0 0 0
45259 - 0 0 0 0 0 0 0 0 0 0 0 0
45260 - 0 0 0 0 0 0 0 0 0 0 0 0
45261 - 0 0 0 0 0 0 0 0 0 6 6 6
45262 - 30 30 30 78 78 78 30 30 30 2 2 6
45263 - 2 2 6 2 2 6 2 2 6 2 2 6
45264 - 2 2 6 2 2 6 2 2 6 2 2 6
45265 - 2 2 6 2 2 6 2 2 6 10 10 10
45266 - 10 10 10 2 2 6 2 2 6 2 2 6
45267 - 2 2 6 2 2 6 2 2 6 78 78 78
45268 - 50 50 50 18 18 18 6 6 6 0 0 0
45269 - 0 0 0 0 0 0 0 0 0 0 0 0
45270 - 0 0 0 0 0 0 0 0 0 0 0 0
45271 - 0 0 0 0 0 0 0 0 0 0 0 0
45272 - 0 0 0 0 0 0 0 0 0 0 0 0
45273 - 0 0 0 0 0 0 0 0 0 0 0 0
45274 - 0 0 0 0 0 0 0 0 0 0 0 0
45275 - 0 0 0 0 0 0 0 0 0 0 0 0
45276 - 0 0 1 0 0 0 0 0 0 0 0 0
45277 - 0 0 0 0 0 0 0 0 0 0 0 0
45278 - 0 0 0 0 0 0 0 0 0 0 0 0
45279 - 0 0 0 0 0 0 0 0 0 0 0 0
45280 - 0 0 0 0 0 0 0 0 0 0 0 0
45281 - 0 0 0 0 0 0 0 0 0 10 10 10
45282 - 38 38 38 86 86 86 14 14 14 2 2 6
45283 - 2 2 6 2 2 6 2 2 6 2 2 6
45284 - 2 2 6 2 2 6 2 2 6 2 2 6
45285 - 2 2 6 2 2 6 2 2 6 2 2 6
45286 - 2 2 6 2 2 6 2 2 6 2 2 6
45287 - 2 2 6 2 2 6 2 2 6 54 54 54
45288 - 66 66 66 26 26 26 6 6 6 0 0 0
45289 - 0 0 0 0 0 0 0 0 0 0 0 0
45290 - 0 0 0 0 0 0 0 0 0 0 0 0
45291 - 0 0 0 0 0 0 0 0 0 0 0 0
45292 - 0 0 0 0 0 0 0 0 0 0 0 0
45293 - 0 0 0 0 0 0 0 0 0 0 0 0
45294 - 0 0 0 0 0 0 0 0 0 0 0 0
45295 - 0 0 0 0 0 0 0 0 0 0 0 0
45296 - 0 0 0 0 0 1 0 0 1 0 0 0
45297 - 0 0 0 0 0 0 0 0 0 0 0 0
45298 - 0 0 0 0 0 0 0 0 0 0 0 0
45299 - 0 0 0 0 0 0 0 0 0 0 0 0
45300 - 0 0 0 0 0 0 0 0 0 0 0 0
45301 - 0 0 0 0 0 0 0 0 0 14 14 14
45302 - 42 42 42 82 82 82 2 2 6 2 2 6
45303 - 2 2 6 6 6 6 10 10 10 2 2 6
45304 - 2 2 6 2 2 6 2 2 6 2 2 6
45305 - 2 2 6 2 2 6 2 2 6 6 6 6
45306 - 14 14 14 10 10 10 2 2 6 2 2 6
45307 - 2 2 6 2 2 6 2 2 6 18 18 18
45308 - 82 82 82 34 34 34 10 10 10 0 0 0
45309 - 0 0 0 0 0 0 0 0 0 0 0 0
45310 - 0 0 0 0 0 0 0 0 0 0 0 0
45311 - 0 0 0 0 0 0 0 0 0 0 0 0
45312 - 0 0 0 0 0 0 0 0 0 0 0 0
45313 - 0 0 0 0 0 0 0 0 0 0 0 0
45314 - 0 0 0 0 0 0 0 0 0 0 0 0
45315 - 0 0 0 0 0 0 0 0 0 0 0 0
45316 - 0 0 1 0 0 0 0 0 0 0 0 0
45317 - 0 0 0 0 0 0 0 0 0 0 0 0
45318 - 0 0 0 0 0 0 0 0 0 0 0 0
45319 - 0 0 0 0 0 0 0 0 0 0 0 0
45320 - 0 0 0 0 0 0 0 0 0 0 0 0
45321 - 0 0 0 0 0 0 0 0 0 14 14 14
45322 - 46 46 46 86 86 86 2 2 6 2 2 6
45323 - 6 6 6 6 6 6 22 22 22 34 34 34
45324 - 6 6 6 2 2 6 2 2 6 2 2 6
45325 - 2 2 6 2 2 6 18 18 18 34 34 34
45326 - 10 10 10 50 50 50 22 22 22 2 2 6
45327 - 2 2 6 2 2 6 2 2 6 10 10 10
45328 - 86 86 86 42 42 42 14 14 14 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 1 0 0 1 0 0 1 0 0 0
45337 - 0 0 0 0 0 0 0 0 0 0 0 0
45338 - 0 0 0 0 0 0 0 0 0 0 0 0
45339 - 0 0 0 0 0 0 0 0 0 0 0 0
45340 - 0 0 0 0 0 0 0 0 0 0 0 0
45341 - 0 0 0 0 0 0 0 0 0 14 14 14
45342 - 46 46 46 86 86 86 2 2 6 2 2 6
45343 - 38 38 38 116 116 116 94 94 94 22 22 22
45344 - 22 22 22 2 2 6 2 2 6 2 2 6
45345 - 14 14 14 86 86 86 138 138 138 162 162 162
45346 -154 154 154 38 38 38 26 26 26 6 6 6
45347 - 2 2 6 2 2 6 2 2 6 2 2 6
45348 - 86 86 86 46 46 46 14 14 14 0 0 0
45349 - 0 0 0 0 0 0 0 0 0 0 0 0
45350 - 0 0 0 0 0 0 0 0 0 0 0 0
45351 - 0 0 0 0 0 0 0 0 0 0 0 0
45352 - 0 0 0 0 0 0 0 0 0 0 0 0
45353 - 0 0 0 0 0 0 0 0 0 0 0 0
45354 - 0 0 0 0 0 0 0 0 0 0 0 0
45355 - 0 0 0 0 0 0 0 0 0 0 0 0
45356 - 0 0 0 0 0 0 0 0 0 0 0 0
45357 - 0 0 0 0 0 0 0 0 0 0 0 0
45358 - 0 0 0 0 0 0 0 0 0 0 0 0
45359 - 0 0 0 0 0 0 0 0 0 0 0 0
45360 - 0 0 0 0 0 0 0 0 0 0 0 0
45361 - 0 0 0 0 0 0 0 0 0 14 14 14
45362 - 46 46 46 86 86 86 2 2 6 14 14 14
45363 -134 134 134 198 198 198 195 195 195 116 116 116
45364 - 10 10 10 2 2 6 2 2 6 6 6 6
45365 -101 98 89 187 187 187 210 210 210 218 218 218
45366 -214 214 214 134 134 134 14 14 14 6 6 6
45367 - 2 2 6 2 2 6 2 2 6 2 2 6
45368 - 86 86 86 50 50 50 18 18 18 6 6 6
45369 - 0 0 0 0 0 0 0 0 0 0 0 0
45370 - 0 0 0 0 0 0 0 0 0 0 0 0
45371 - 0 0 0 0 0 0 0 0 0 0 0 0
45372 - 0 0 0 0 0 0 0 0 0 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 1 0 0 0
45376 - 0 0 1 0 0 1 0 0 1 0 0 0
45377 - 0 0 0 0 0 0 0 0 0 0 0 0
45378 - 0 0 0 0 0 0 0 0 0 0 0 0
45379 - 0 0 0 0 0 0 0 0 0 0 0 0
45380 - 0 0 0 0 0 0 0 0 0 0 0 0
45381 - 0 0 0 0 0 0 0 0 0 14 14 14
45382 - 46 46 46 86 86 86 2 2 6 54 54 54
45383 -218 218 218 195 195 195 226 226 226 246 246 246
45384 - 58 58 58 2 2 6 2 2 6 30 30 30
45385 -210 210 210 253 253 253 174 174 174 123 123 123
45386 -221 221 221 234 234 234 74 74 74 2 2 6
45387 - 2 2 6 2 2 6 2 2 6 2 2 6
45388 - 70 70 70 58 58 58 22 22 22 6 6 6
45389 - 0 0 0 0 0 0 0 0 0 0 0 0
45390 - 0 0 0 0 0 0 0 0 0 0 0 0
45391 - 0 0 0 0 0 0 0 0 0 0 0 0
45392 - 0 0 0 0 0 0 0 0 0 0 0 0
45393 - 0 0 0 0 0 0 0 0 0 0 0 0
45394 - 0 0 0 0 0 0 0 0 0 0 0 0
45395 - 0 0 0 0 0 0 0 0 0 0 0 0
45396 - 0 0 0 0 0 0 0 0 0 0 0 0
45397 - 0 0 0 0 0 0 0 0 0 0 0 0
45398 - 0 0 0 0 0 0 0 0 0 0 0 0
45399 - 0 0 0 0 0 0 0 0 0 0 0 0
45400 - 0 0 0 0 0 0 0 0 0 0 0 0
45401 - 0 0 0 0 0 0 0 0 0 14 14 14
45402 - 46 46 46 82 82 82 2 2 6 106 106 106
45403 -170 170 170 26 26 26 86 86 86 226 226 226
45404 -123 123 123 10 10 10 14 14 14 46 46 46
45405 -231 231 231 190 190 190 6 6 6 70 70 70
45406 - 90 90 90 238 238 238 158 158 158 2 2 6
45407 - 2 2 6 2 2 6 2 2 6 2 2 6
45408 - 70 70 70 58 58 58 22 22 22 6 6 6
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 1 0 0 0
45416 - 0 0 1 0 0 1 0 0 1 0 0 0
45417 - 0 0 0 0 0 0 0 0 0 0 0 0
45418 - 0 0 0 0 0 0 0 0 0 0 0 0
45419 - 0 0 0 0 0 0 0 0 0 0 0 0
45420 - 0 0 0 0 0 0 0 0 0 0 0 0
45421 - 0 0 0 0 0 0 0 0 0 14 14 14
45422 - 42 42 42 86 86 86 6 6 6 116 116 116
45423 -106 106 106 6 6 6 70 70 70 149 149 149
45424 -128 128 128 18 18 18 38 38 38 54 54 54
45425 -221 221 221 106 106 106 2 2 6 14 14 14
45426 - 46 46 46 190 190 190 198 198 198 2 2 6
45427 - 2 2 6 2 2 6 2 2 6 2 2 6
45428 - 74 74 74 62 62 62 22 22 22 6 6 6
45429 - 0 0 0 0 0 0 0 0 0 0 0 0
45430 - 0 0 0 0 0 0 0 0 0 0 0 0
45431 - 0 0 0 0 0 0 0 0 0 0 0 0
45432 - 0 0 0 0 0 0 0 0 0 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 1 0 0 0
45436 - 0 0 1 0 0 0 0 0 1 0 0 0
45437 - 0 0 0 0 0 0 0 0 0 0 0 0
45438 - 0 0 0 0 0 0 0 0 0 0 0 0
45439 - 0 0 0 0 0 0 0 0 0 0 0 0
45440 - 0 0 0 0 0 0 0 0 0 0 0 0
45441 - 0 0 0 0 0 0 0 0 0 14 14 14
45442 - 42 42 42 94 94 94 14 14 14 101 101 101
45443 -128 128 128 2 2 6 18 18 18 116 116 116
45444 -118 98 46 121 92 8 121 92 8 98 78 10
45445 -162 162 162 106 106 106 2 2 6 2 2 6
45446 - 2 2 6 195 195 195 195 195 195 6 6 6
45447 - 2 2 6 2 2 6 2 2 6 2 2 6
45448 - 74 74 74 62 62 62 22 22 22 6 6 6
45449 - 0 0 0 0 0 0 0 0 0 0 0 0
45450 - 0 0 0 0 0 0 0 0 0 0 0 0
45451 - 0 0 0 0 0 0 0 0 0 0 0 0
45452 - 0 0 0 0 0 0 0 0 0 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 1 0 0 1
45456 - 0 0 1 0 0 0 0 0 1 0 0 0
45457 - 0 0 0 0 0 0 0 0 0 0 0 0
45458 - 0 0 0 0 0 0 0 0 0 0 0 0
45459 - 0 0 0 0 0 0 0 0 0 0 0 0
45460 - 0 0 0 0 0 0 0 0 0 0 0 0
45461 - 0 0 0 0 0 0 0 0 0 10 10 10
45462 - 38 38 38 90 90 90 14 14 14 58 58 58
45463 -210 210 210 26 26 26 54 38 6 154 114 10
45464 -226 170 11 236 186 11 225 175 15 184 144 12
45465 -215 174 15 175 146 61 37 26 9 2 2 6
45466 - 70 70 70 246 246 246 138 138 138 2 2 6
45467 - 2 2 6 2 2 6 2 2 6 2 2 6
45468 - 70 70 70 66 66 66 26 26 26 6 6 6
45469 - 0 0 0 0 0 0 0 0 0 0 0 0
45470 - 0 0 0 0 0 0 0 0 0 0 0 0
45471 - 0 0 0 0 0 0 0 0 0 0 0 0
45472 - 0 0 0 0 0 0 0 0 0 0 0 0
45473 - 0 0 0 0 0 0 0 0 0 0 0 0
45474 - 0 0 0 0 0 0 0 0 0 0 0 0
45475 - 0 0 0 0 0 0 0 0 0 0 0 0
45476 - 0 0 0 0 0 0 0 0 0 0 0 0
45477 - 0 0 0 0 0 0 0 0 0 0 0 0
45478 - 0 0 0 0 0 0 0 0 0 0 0 0
45479 - 0 0 0 0 0 0 0 0 0 0 0 0
45480 - 0 0 0 0 0 0 0 0 0 0 0 0
45481 - 0 0 0 0 0 0 0 0 0 10 10 10
45482 - 38 38 38 86 86 86 14 14 14 10 10 10
45483 -195 195 195 188 164 115 192 133 9 225 175 15
45484 -239 182 13 234 190 10 232 195 16 232 200 30
45485 -245 207 45 241 208 19 232 195 16 184 144 12
45486 -218 194 134 211 206 186 42 42 42 2 2 6
45487 - 2 2 6 2 2 6 2 2 6 2 2 6
45488 - 50 50 50 74 74 74 30 30 30 6 6 6
45489 - 0 0 0 0 0 0 0 0 0 0 0 0
45490 - 0 0 0 0 0 0 0 0 0 0 0 0
45491 - 0 0 0 0 0 0 0 0 0 0 0 0
45492 - 0 0 0 0 0 0 0 0 0 0 0 0
45493 - 0 0 0 0 0 0 0 0 0 0 0 0
45494 - 0 0 0 0 0 0 0 0 0 0 0 0
45495 - 0 0 0 0 0 0 0 0 0 0 0 0
45496 - 0 0 0 0 0 0 0 0 0 0 0 0
45497 - 0 0 0 0 0 0 0 0 0 0 0 0
45498 - 0 0 0 0 0 0 0 0 0 0 0 0
45499 - 0 0 0 0 0 0 0 0 0 0 0 0
45500 - 0 0 0 0 0 0 0 0 0 0 0 0
45501 - 0 0 0 0 0 0 0 0 0 10 10 10
45502 - 34 34 34 86 86 86 14 14 14 2 2 6
45503 -121 87 25 192 133 9 219 162 10 239 182 13
45504 -236 186 11 232 195 16 241 208 19 244 214 54
45505 -246 218 60 246 218 38 246 215 20 241 208 19
45506 -241 208 19 226 184 13 121 87 25 2 2 6
45507 - 2 2 6 2 2 6 2 2 6 2 2 6
45508 - 50 50 50 82 82 82 34 34 34 10 10 10
45509 - 0 0 0 0 0 0 0 0 0 0 0 0
45510 - 0 0 0 0 0 0 0 0 0 0 0 0
45511 - 0 0 0 0 0 0 0 0 0 0 0 0
45512 - 0 0 0 0 0 0 0 0 0 0 0 0
45513 - 0 0 0 0 0 0 0 0 0 0 0 0
45514 - 0 0 0 0 0 0 0 0 0 0 0 0
45515 - 0 0 0 0 0 0 0 0 0 0 0 0
45516 - 0 0 0 0 0 0 0 0 0 0 0 0
45517 - 0 0 0 0 0 0 0 0 0 0 0 0
45518 - 0 0 0 0 0 0 0 0 0 0 0 0
45519 - 0 0 0 0 0 0 0 0 0 0 0 0
45520 - 0 0 0 0 0 0 0 0 0 0 0 0
45521 - 0 0 0 0 0 0 0 0 0 10 10 10
45522 - 34 34 34 82 82 82 30 30 30 61 42 6
45523 -180 123 7 206 145 10 230 174 11 239 182 13
45524 -234 190 10 238 202 15 241 208 19 246 218 74
45525 -246 218 38 246 215 20 246 215 20 246 215 20
45526 -226 184 13 215 174 15 184 144 12 6 6 6
45527 - 2 2 6 2 2 6 2 2 6 2 2 6
45528 - 26 26 26 94 94 94 42 42 42 14 14 14
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 0 0 0
45536 - 0 0 0 0 0 0 0 0 0 0 0 0
45537 - 0 0 0 0 0 0 0 0 0 0 0 0
45538 - 0 0 0 0 0 0 0 0 0 0 0 0
45539 - 0 0 0 0 0 0 0 0 0 0 0 0
45540 - 0 0 0 0 0 0 0 0 0 0 0 0
45541 - 0 0 0 0 0 0 0 0 0 10 10 10
45542 - 30 30 30 78 78 78 50 50 50 104 69 6
45543 -192 133 9 216 158 10 236 178 12 236 186 11
45544 -232 195 16 241 208 19 244 214 54 245 215 43
45545 -246 215 20 246 215 20 241 208 19 198 155 10
45546 -200 144 11 216 158 10 156 118 10 2 2 6
45547 - 2 2 6 2 2 6 2 2 6 2 2 6
45548 - 6 6 6 90 90 90 54 54 54 18 18 18
45549 - 6 6 6 0 0 0 0 0 0 0 0 0
45550 - 0 0 0 0 0 0 0 0 0 0 0 0
45551 - 0 0 0 0 0 0 0 0 0 0 0 0
45552 - 0 0 0 0 0 0 0 0 0 0 0 0
45553 - 0 0 0 0 0 0 0 0 0 0 0 0
45554 - 0 0 0 0 0 0 0 0 0 0 0 0
45555 - 0 0 0 0 0 0 0 0 0 0 0 0
45556 - 0 0 0 0 0 0 0 0 0 0 0 0
45557 - 0 0 0 0 0 0 0 0 0 0 0 0
45558 - 0 0 0 0 0 0 0 0 0 0 0 0
45559 - 0 0 0 0 0 0 0 0 0 0 0 0
45560 - 0 0 0 0 0 0 0 0 0 0 0 0
45561 - 0 0 0 0 0 0 0 0 0 10 10 10
45562 - 30 30 30 78 78 78 46 46 46 22 22 22
45563 -137 92 6 210 162 10 239 182 13 238 190 10
45564 -238 202 15 241 208 19 246 215 20 246 215 20
45565 -241 208 19 203 166 17 185 133 11 210 150 10
45566 -216 158 10 210 150 10 102 78 10 2 2 6
45567 - 6 6 6 54 54 54 14 14 14 2 2 6
45568 - 2 2 6 62 62 62 74 74 74 30 30 30
45569 - 10 10 10 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 0 0 0
45576 - 0 0 0 0 0 0 0 0 0 0 0 0
45577 - 0 0 0 0 0 0 0 0 0 0 0 0
45578 - 0 0 0 0 0 0 0 0 0 0 0 0
45579 - 0 0 0 0 0 0 0 0 0 0 0 0
45580 - 0 0 0 0 0 0 0 0 0 0 0 0
45581 - 0 0 0 0 0 0 0 0 0 10 10 10
45582 - 34 34 34 78 78 78 50 50 50 6 6 6
45583 - 94 70 30 139 102 15 190 146 13 226 184 13
45584 -232 200 30 232 195 16 215 174 15 190 146 13
45585 -168 122 10 192 133 9 210 150 10 213 154 11
45586 -202 150 34 182 157 106 101 98 89 2 2 6
45587 - 2 2 6 78 78 78 116 116 116 58 58 58
45588 - 2 2 6 22 22 22 90 90 90 46 46 46
45589 - 18 18 18 6 6 6 0 0 0 0 0 0
45590 - 0 0 0 0 0 0 0 0 0 0 0 0
45591 - 0 0 0 0 0 0 0 0 0 0 0 0
45592 - 0 0 0 0 0 0 0 0 0 0 0 0
45593 - 0 0 0 0 0 0 0 0 0 0 0 0
45594 - 0 0 0 0 0 0 0 0 0 0 0 0
45595 - 0 0 0 0 0 0 0 0 0 0 0 0
45596 - 0 0 0 0 0 0 0 0 0 0 0 0
45597 - 0 0 0 0 0 0 0 0 0 0 0 0
45598 - 0 0 0 0 0 0 0 0 0 0 0 0
45599 - 0 0 0 0 0 0 0 0 0 0 0 0
45600 - 0 0 0 0 0 0 0 0 0 0 0 0
45601 - 0 0 0 0 0 0 0 0 0 10 10 10
45602 - 38 38 38 86 86 86 50 50 50 6 6 6
45603 -128 128 128 174 154 114 156 107 11 168 122 10
45604 -198 155 10 184 144 12 197 138 11 200 144 11
45605 -206 145 10 206 145 10 197 138 11 188 164 115
45606 -195 195 195 198 198 198 174 174 174 14 14 14
45607 - 2 2 6 22 22 22 116 116 116 116 116 116
45608 - 22 22 22 2 2 6 74 74 74 70 70 70
45609 - 30 30 30 10 10 10 0 0 0 0 0 0
45610 - 0 0 0 0 0 0 0 0 0 0 0 0
45611 - 0 0 0 0 0 0 0 0 0 0 0 0
45612 - 0 0 0 0 0 0 0 0 0 0 0 0
45613 - 0 0 0 0 0 0 0 0 0 0 0 0
45614 - 0 0 0 0 0 0 0 0 0 0 0 0
45615 - 0 0 0 0 0 0 0 0 0 0 0 0
45616 - 0 0 0 0 0 0 0 0 0 0 0 0
45617 - 0 0 0 0 0 0 0 0 0 0 0 0
45618 - 0 0 0 0 0 0 0 0 0 0 0 0
45619 - 0 0 0 0 0 0 0 0 0 0 0 0
45620 - 0 0 0 0 0 0 0 0 0 0 0 0
45621 - 0 0 0 0 0 0 6 6 6 18 18 18
45622 - 50 50 50 101 101 101 26 26 26 10 10 10
45623 -138 138 138 190 190 190 174 154 114 156 107 11
45624 -197 138 11 200 144 11 197 138 11 192 133 9
45625 -180 123 7 190 142 34 190 178 144 187 187 187
45626 -202 202 202 221 221 221 214 214 214 66 66 66
45627 - 2 2 6 2 2 6 50 50 50 62 62 62
45628 - 6 6 6 2 2 6 10 10 10 90 90 90
45629 - 50 50 50 18 18 18 6 6 6 0 0 0
45630 - 0 0 0 0 0 0 0 0 0 0 0 0
45631 - 0 0 0 0 0 0 0 0 0 0 0 0
45632 - 0 0 0 0 0 0 0 0 0 0 0 0
45633 - 0 0 0 0 0 0 0 0 0 0 0 0
45634 - 0 0 0 0 0 0 0 0 0 0 0 0
45635 - 0 0 0 0 0 0 0 0 0 0 0 0
45636 - 0 0 0 0 0 0 0 0 0 0 0 0
45637 - 0 0 0 0 0 0 0 0 0 0 0 0
45638 - 0 0 0 0 0 0 0 0 0 0 0 0
45639 - 0 0 0 0 0 0 0 0 0 0 0 0
45640 - 0 0 0 0 0 0 0 0 0 0 0 0
45641 - 0 0 0 0 0 0 10 10 10 34 34 34
45642 - 74 74 74 74 74 74 2 2 6 6 6 6
45643 -144 144 144 198 198 198 190 190 190 178 166 146
45644 -154 121 60 156 107 11 156 107 11 168 124 44
45645 -174 154 114 187 187 187 190 190 190 210 210 210
45646 -246 246 246 253 253 253 253 253 253 182 182 182
45647 - 6 6 6 2 2 6 2 2 6 2 2 6
45648 - 2 2 6 2 2 6 2 2 6 62 62 62
45649 - 74 74 74 34 34 34 14 14 14 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 0 0 0
45656 - 0 0 0 0 0 0 0 0 0 0 0 0
45657 - 0 0 0 0 0 0 0 0 0 0 0 0
45658 - 0 0 0 0 0 0 0 0 0 0 0 0
45659 - 0 0 0 0 0 0 0 0 0 0 0 0
45660 - 0 0 0 0 0 0 0 0 0 0 0 0
45661 - 0 0 0 10 10 10 22 22 22 54 54 54
45662 - 94 94 94 18 18 18 2 2 6 46 46 46
45663 -234 234 234 221 221 221 190 190 190 190 190 190
45664 -190 190 190 187 187 187 187 187 187 190 190 190
45665 -190 190 190 195 195 195 214 214 214 242 242 242
45666 -253 253 253 253 253 253 253 253 253 253 253 253
45667 - 82 82 82 2 2 6 2 2 6 2 2 6
45668 - 2 2 6 2 2 6 2 2 6 14 14 14
45669 - 86 86 86 54 54 54 22 22 22 6 6 6
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 0 0 0
45676 - 0 0 0 0 0 0 0 0 0 0 0 0
45677 - 0 0 0 0 0 0 0 0 0 0 0 0
45678 - 0 0 0 0 0 0 0 0 0 0 0 0
45679 - 0 0 0 0 0 0 0 0 0 0 0 0
45680 - 0 0 0 0 0 0 0 0 0 0 0 0
45681 - 6 6 6 18 18 18 46 46 46 90 90 90
45682 - 46 46 46 18 18 18 6 6 6 182 182 182
45683 -253 253 253 246 246 246 206 206 206 190 190 190
45684 -190 190 190 190 190 190 190 190 190 190 190 190
45685 -206 206 206 231 231 231 250 250 250 253 253 253
45686 -253 253 253 253 253 253 253 253 253 253 253 253
45687 -202 202 202 14 14 14 2 2 6 2 2 6
45688 - 2 2 6 2 2 6 2 2 6 2 2 6
45689 - 42 42 42 86 86 86 42 42 42 18 18 18
45690 - 6 6 6 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 0 0 0
45696 - 0 0 0 0 0 0 0 0 0 0 0 0
45697 - 0 0 0 0 0 0 0 0 0 0 0 0
45698 - 0 0 0 0 0 0 0 0 0 0 0 0
45699 - 0 0 0 0 0 0 0 0 0 0 0 0
45700 - 0 0 0 0 0 0 0 0 0 6 6 6
45701 - 14 14 14 38 38 38 74 74 74 66 66 66
45702 - 2 2 6 6 6 6 90 90 90 250 250 250
45703 -253 253 253 253 253 253 238 238 238 198 198 198
45704 -190 190 190 190 190 190 195 195 195 221 221 221
45705 -246 246 246 253 253 253 253 253 253 253 253 253
45706 -253 253 253 253 253 253 253 253 253 253 253 253
45707 -253 253 253 82 82 82 2 2 6 2 2 6
45708 - 2 2 6 2 2 6 2 2 6 2 2 6
45709 - 2 2 6 78 78 78 70 70 70 34 34 34
45710 - 14 14 14 6 6 6 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 0 0 0
45716 - 0 0 0 0 0 0 0 0 0 0 0 0
45717 - 0 0 0 0 0 0 0 0 0 0 0 0
45718 - 0 0 0 0 0 0 0 0 0 0 0 0
45719 - 0 0 0 0 0 0 0 0 0 0 0 0
45720 - 0 0 0 0 0 0 0 0 0 14 14 14
45721 - 34 34 34 66 66 66 78 78 78 6 6 6
45722 - 2 2 6 18 18 18 218 218 218 253 253 253
45723 -253 253 253 253 253 253 253 253 253 246 246 246
45724 -226 226 226 231 231 231 246 246 246 253 253 253
45725 -253 253 253 253 253 253 253 253 253 253 253 253
45726 -253 253 253 253 253 253 253 253 253 253 253 253
45727 -253 253 253 178 178 178 2 2 6 2 2 6
45728 - 2 2 6 2 2 6 2 2 6 2 2 6
45729 - 2 2 6 18 18 18 90 90 90 62 62 62
45730 - 30 30 30 10 10 10 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 0 0 0
45736 - 0 0 0 0 0 0 0 0 0 0 0 0
45737 - 0 0 0 0 0 0 0 0 0 0 0 0
45738 - 0 0 0 0 0 0 0 0 0 0 0 0
45739 - 0 0 0 0 0 0 0 0 0 0 0 0
45740 - 0 0 0 0 0 0 10 10 10 26 26 26
45741 - 58 58 58 90 90 90 18 18 18 2 2 6
45742 - 2 2 6 110 110 110 253 253 253 253 253 253
45743 -253 253 253 253 253 253 253 253 253 253 253 253
45744 -250 250 250 253 253 253 253 253 253 253 253 253
45745 -253 253 253 253 253 253 253 253 253 253 253 253
45746 -253 253 253 253 253 253 253 253 253 253 253 253
45747 -253 253 253 231 231 231 18 18 18 2 2 6
45748 - 2 2 6 2 2 6 2 2 6 2 2 6
45749 - 2 2 6 2 2 6 18 18 18 94 94 94
45750 - 54 54 54 26 26 26 10 10 10 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 0 0 0
45756 - 0 0 0 0 0 0 0 0 0 0 0 0
45757 - 0 0 0 0 0 0 0 0 0 0 0 0
45758 - 0 0 0 0 0 0 0 0 0 0 0 0
45759 - 0 0 0 0 0 0 0 0 0 0 0 0
45760 - 0 0 0 6 6 6 22 22 22 50 50 50
45761 - 90 90 90 26 26 26 2 2 6 2 2 6
45762 - 14 14 14 195 195 195 250 250 250 253 253 253
45763 -253 253 253 253 253 253 253 253 253 253 253 253
45764 -253 253 253 253 253 253 253 253 253 253 253 253
45765 -253 253 253 253 253 253 253 253 253 253 253 253
45766 -253 253 253 253 253 253 253 253 253 253 253 253
45767 -250 250 250 242 242 242 54 54 54 2 2 6
45768 - 2 2 6 2 2 6 2 2 6 2 2 6
45769 - 2 2 6 2 2 6 2 2 6 38 38 38
45770 - 86 86 86 50 50 50 22 22 22 6 6 6
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 0 0 0
45776 - 0 0 0 0 0 0 0 0 0 0 0 0
45777 - 0 0 0 0 0 0 0 0 0 0 0 0
45778 - 0 0 0 0 0 0 0 0 0 0 0 0
45779 - 0 0 0 0 0 0 0 0 0 0 0 0
45780 - 6 6 6 14 14 14 38 38 38 82 82 82
45781 - 34 34 34 2 2 6 2 2 6 2 2 6
45782 - 42 42 42 195 195 195 246 246 246 253 253 253
45783 -253 253 253 253 253 253 253 253 253 250 250 250
45784 -242 242 242 242 242 242 250 250 250 253 253 253
45785 -253 253 253 253 253 253 253 253 253 253 253 253
45786 -253 253 253 250 250 250 246 246 246 238 238 238
45787 -226 226 226 231 231 231 101 101 101 6 6 6
45788 - 2 2 6 2 2 6 2 2 6 2 2 6
45789 - 2 2 6 2 2 6 2 2 6 2 2 6
45790 - 38 38 38 82 82 82 42 42 42 14 14 14
45791 - 6 6 6 0 0 0 0 0 0 0 0 0
45792 - 0 0 0 0 0 0 0 0 0 0 0 0
45793 - 0 0 0 0 0 0 0 0 0 0 0 0
45794 - 0 0 0 0 0 0 0 0 0 0 0 0
45795 - 0 0 0 0 0 0 0 0 0 0 0 0
45796 - 0 0 0 0 0 0 0 0 0 0 0 0
45797 - 0 0 0 0 0 0 0 0 0 0 0 0
45798 - 0 0 0 0 0 0 0 0 0 0 0 0
45799 - 0 0 0 0 0 0 0 0 0 0 0 0
45800 - 10 10 10 26 26 26 62 62 62 66 66 66
45801 - 2 2 6 2 2 6 2 2 6 6 6 6
45802 - 70 70 70 170 170 170 206 206 206 234 234 234
45803 -246 246 246 250 250 250 250 250 250 238 238 238
45804 -226 226 226 231 231 231 238 238 238 250 250 250
45805 -250 250 250 250 250 250 246 246 246 231 231 231
45806 -214 214 214 206 206 206 202 202 202 202 202 202
45807 -198 198 198 202 202 202 182 182 182 18 18 18
45808 - 2 2 6 2 2 6 2 2 6 2 2 6
45809 - 2 2 6 2 2 6 2 2 6 2 2 6
45810 - 2 2 6 62 62 62 66 66 66 30 30 30
45811 - 10 10 10 0 0 0 0 0 0 0 0 0
45812 - 0 0 0 0 0 0 0 0 0 0 0 0
45813 - 0 0 0 0 0 0 0 0 0 0 0 0
45814 - 0 0 0 0 0 0 0 0 0 0 0 0
45815 - 0 0 0 0 0 0 0 0 0 0 0 0
45816 - 0 0 0 0 0 0 0 0 0 0 0 0
45817 - 0 0 0 0 0 0 0 0 0 0 0 0
45818 - 0 0 0 0 0 0 0 0 0 0 0 0
45819 - 0 0 0 0 0 0 0 0 0 0 0 0
45820 - 14 14 14 42 42 42 82 82 82 18 18 18
45821 - 2 2 6 2 2 6 2 2 6 10 10 10
45822 - 94 94 94 182 182 182 218 218 218 242 242 242
45823 -250 250 250 253 253 253 253 253 253 250 250 250
45824 -234 234 234 253 253 253 253 253 253 253 253 253
45825 -253 253 253 253 253 253 253 253 253 246 246 246
45826 -238 238 238 226 226 226 210 210 210 202 202 202
45827 -195 195 195 195 195 195 210 210 210 158 158 158
45828 - 6 6 6 14 14 14 50 50 50 14 14 14
45829 - 2 2 6 2 2 6 2 2 6 2 2 6
45830 - 2 2 6 6 6 6 86 86 86 46 46 46
45831 - 18 18 18 6 6 6 0 0 0 0 0 0
45832 - 0 0 0 0 0 0 0 0 0 0 0 0
45833 - 0 0 0 0 0 0 0 0 0 0 0 0
45834 - 0 0 0 0 0 0 0 0 0 0 0 0
45835 - 0 0 0 0 0 0 0 0 0 0 0 0
45836 - 0 0 0 0 0 0 0 0 0 0 0 0
45837 - 0 0 0 0 0 0 0 0 0 0 0 0
45838 - 0 0 0 0 0 0 0 0 0 0 0 0
45839 - 0 0 0 0 0 0 0 0 0 6 6 6
45840 - 22 22 22 54 54 54 70 70 70 2 2 6
45841 - 2 2 6 10 10 10 2 2 6 22 22 22
45842 -166 166 166 231 231 231 250 250 250 253 253 253
45843 -253 253 253 253 253 253 253 253 253 250 250 250
45844 -242 242 242 253 253 253 253 253 253 253 253 253
45845 -253 253 253 253 253 253 253 253 253 253 253 253
45846 -253 253 253 253 253 253 253 253 253 246 246 246
45847 -231 231 231 206 206 206 198 198 198 226 226 226
45848 - 94 94 94 2 2 6 6 6 6 38 38 38
45849 - 30 30 30 2 2 6 2 2 6 2 2 6
45850 - 2 2 6 2 2 6 62 62 62 66 66 66
45851 - 26 26 26 10 10 10 0 0 0 0 0 0
45852 - 0 0 0 0 0 0 0 0 0 0 0 0
45853 - 0 0 0 0 0 0 0 0 0 0 0 0
45854 - 0 0 0 0 0 0 0 0 0 0 0 0
45855 - 0 0 0 0 0 0 0 0 0 0 0 0
45856 - 0 0 0 0 0 0 0 0 0 0 0 0
45857 - 0 0 0 0 0 0 0 0 0 0 0 0
45858 - 0 0 0 0 0 0 0 0 0 0 0 0
45859 - 0 0 0 0 0 0 0 0 0 10 10 10
45860 - 30 30 30 74 74 74 50 50 50 2 2 6
45861 - 26 26 26 26 26 26 2 2 6 106 106 106
45862 -238 238 238 253 253 253 253 253 253 253 253 253
45863 -253 253 253 253 253 253 253 253 253 253 253 253
45864 -253 253 253 253 253 253 253 253 253 253 253 253
45865 -253 253 253 253 253 253 253 253 253 253 253 253
45866 -253 253 253 253 253 253 253 253 253 253 253 253
45867 -253 253 253 246 246 246 218 218 218 202 202 202
45868 -210 210 210 14 14 14 2 2 6 2 2 6
45869 - 30 30 30 22 22 22 2 2 6 2 2 6
45870 - 2 2 6 2 2 6 18 18 18 86 86 86
45871 - 42 42 42 14 14 14 0 0 0 0 0 0
45872 - 0 0 0 0 0 0 0 0 0 0 0 0
45873 - 0 0 0 0 0 0 0 0 0 0 0 0
45874 - 0 0 0 0 0 0 0 0 0 0 0 0
45875 - 0 0 0 0 0 0 0 0 0 0 0 0
45876 - 0 0 0 0 0 0 0 0 0 0 0 0
45877 - 0 0 0 0 0 0 0 0 0 0 0 0
45878 - 0 0 0 0 0 0 0 0 0 0 0 0
45879 - 0 0 0 0 0 0 0 0 0 14 14 14
45880 - 42 42 42 90 90 90 22 22 22 2 2 6
45881 - 42 42 42 2 2 6 18 18 18 218 218 218
45882 -253 253 253 253 253 253 253 253 253 253 253 253
45883 -253 253 253 253 253 253 253 253 253 253 253 253
45884 -253 253 253 253 253 253 253 253 253 253 253 253
45885 -253 253 253 253 253 253 253 253 253 253 253 253
45886 -253 253 253 253 253 253 253 253 253 253 253 253
45887 -253 253 253 253 253 253 250 250 250 221 221 221
45888 -218 218 218 101 101 101 2 2 6 14 14 14
45889 - 18 18 18 38 38 38 10 10 10 2 2 6
45890 - 2 2 6 2 2 6 2 2 6 78 78 78
45891 - 58 58 58 22 22 22 6 6 6 0 0 0
45892 - 0 0 0 0 0 0 0 0 0 0 0 0
45893 - 0 0 0 0 0 0 0 0 0 0 0 0
45894 - 0 0 0 0 0 0 0 0 0 0 0 0
45895 - 0 0 0 0 0 0 0 0 0 0 0 0
45896 - 0 0 0 0 0 0 0 0 0 0 0 0
45897 - 0 0 0 0 0 0 0 0 0 0 0 0
45898 - 0 0 0 0 0 0 0 0 0 0 0 0
45899 - 0 0 0 0 0 0 6 6 6 18 18 18
45900 - 54 54 54 82 82 82 2 2 6 26 26 26
45901 - 22 22 22 2 2 6 123 123 123 253 253 253
45902 -253 253 253 253 253 253 253 253 253 253 253 253
45903 -253 253 253 253 253 253 253 253 253 253 253 253
45904 -253 253 253 253 253 253 253 253 253 253 253 253
45905 -253 253 253 253 253 253 253 253 253 253 253 253
45906 -253 253 253 253 253 253 253 253 253 253 253 253
45907 -253 253 253 253 253 253 253 253 253 250 250 250
45908 -238 238 238 198 198 198 6 6 6 38 38 38
45909 - 58 58 58 26 26 26 38 38 38 2 2 6
45910 - 2 2 6 2 2 6 2 2 6 46 46 46
45911 - 78 78 78 30 30 30 10 10 10 0 0 0
45912 - 0 0 0 0 0 0 0 0 0 0 0 0
45913 - 0 0 0 0 0 0 0 0 0 0 0 0
45914 - 0 0 0 0 0 0 0 0 0 0 0 0
45915 - 0 0 0 0 0 0 0 0 0 0 0 0
45916 - 0 0 0 0 0 0 0 0 0 0 0 0
45917 - 0 0 0 0 0 0 0 0 0 0 0 0
45918 - 0 0 0 0 0 0 0 0 0 0 0 0
45919 - 0 0 0 0 0 0 10 10 10 30 30 30
45920 - 74 74 74 58 58 58 2 2 6 42 42 42
45921 - 2 2 6 22 22 22 231 231 231 253 253 253
45922 -253 253 253 253 253 253 253 253 253 253 253 253
45923 -253 253 253 253 253 253 253 253 253 250 250 250
45924 -253 253 253 253 253 253 253 253 253 253 253 253
45925 -253 253 253 253 253 253 253 253 253 253 253 253
45926 -253 253 253 253 253 253 253 253 253 253 253 253
45927 -253 253 253 253 253 253 253 253 253 253 253 253
45928 -253 253 253 246 246 246 46 46 46 38 38 38
45929 - 42 42 42 14 14 14 38 38 38 14 14 14
45930 - 2 2 6 2 2 6 2 2 6 6 6 6
45931 - 86 86 86 46 46 46 14 14 14 0 0 0
45932 - 0 0 0 0 0 0 0 0 0 0 0 0
45933 - 0 0 0 0 0 0 0 0 0 0 0 0
45934 - 0 0 0 0 0 0 0 0 0 0 0 0
45935 - 0 0 0 0 0 0 0 0 0 0 0 0
45936 - 0 0 0 0 0 0 0 0 0 0 0 0
45937 - 0 0 0 0 0 0 0 0 0 0 0 0
45938 - 0 0 0 0 0 0 0 0 0 0 0 0
45939 - 0 0 0 6 6 6 14 14 14 42 42 42
45940 - 90 90 90 18 18 18 18 18 18 26 26 26
45941 - 2 2 6 116 116 116 253 253 253 253 253 253
45942 -253 253 253 253 253 253 253 253 253 253 253 253
45943 -253 253 253 253 253 253 250 250 250 238 238 238
45944 -253 253 253 253 253 253 253 253 253 253 253 253
45945 -253 253 253 253 253 253 253 253 253 253 253 253
45946 -253 253 253 253 253 253 253 253 253 253 253 253
45947 -253 253 253 253 253 253 253 253 253 253 253 253
45948 -253 253 253 253 253 253 94 94 94 6 6 6
45949 - 2 2 6 2 2 6 10 10 10 34 34 34
45950 - 2 2 6 2 2 6 2 2 6 2 2 6
45951 - 74 74 74 58 58 58 22 22 22 6 6 6
45952 - 0 0 0 0 0 0 0 0 0 0 0 0
45953 - 0 0 0 0 0 0 0 0 0 0 0 0
45954 - 0 0 0 0 0 0 0 0 0 0 0 0
45955 - 0 0 0 0 0 0 0 0 0 0 0 0
45956 - 0 0 0 0 0 0 0 0 0 0 0 0
45957 - 0 0 0 0 0 0 0 0 0 0 0 0
45958 - 0 0 0 0 0 0 0 0 0 0 0 0
45959 - 0 0 0 10 10 10 26 26 26 66 66 66
45960 - 82 82 82 2 2 6 38 38 38 6 6 6
45961 - 14 14 14 210 210 210 253 253 253 253 253 253
45962 -253 253 253 253 253 253 253 253 253 253 253 253
45963 -253 253 253 253 253 253 246 246 246 242 242 242
45964 -253 253 253 253 253 253 253 253 253 253 253 253
45965 -253 253 253 253 253 253 253 253 253 253 253 253
45966 -253 253 253 253 253 253 253 253 253 253 253 253
45967 -253 253 253 253 253 253 253 253 253 253 253 253
45968 -253 253 253 253 253 253 144 144 144 2 2 6
45969 - 2 2 6 2 2 6 2 2 6 46 46 46
45970 - 2 2 6 2 2 6 2 2 6 2 2 6
45971 - 42 42 42 74 74 74 30 30 30 10 10 10
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 - 0 0 0 0 0 0 0 0 0 0 0 0
45975 - 0 0 0 0 0 0 0 0 0 0 0 0
45976 - 0 0 0 0 0 0 0 0 0 0 0 0
45977 - 0 0 0 0 0 0 0 0 0 0 0 0
45978 - 0 0 0 0 0 0 0 0 0 0 0 0
45979 - 6 6 6 14 14 14 42 42 42 90 90 90
45980 - 26 26 26 6 6 6 42 42 42 2 2 6
45981 - 74 74 74 250 250 250 253 253 253 253 253 253
45982 -253 253 253 253 253 253 253 253 253 253 253 253
45983 -253 253 253 253 253 253 242 242 242 242 242 242
45984 -253 253 253 253 253 253 253 253 253 253 253 253
45985 -253 253 253 253 253 253 253 253 253 253 253 253
45986 -253 253 253 253 253 253 253 253 253 253 253 253
45987 -253 253 253 253 253 253 253 253 253 253 253 253
45988 -253 253 253 253 253 253 182 182 182 2 2 6
45989 - 2 2 6 2 2 6 2 2 6 46 46 46
45990 - 2 2 6 2 2 6 2 2 6 2 2 6
45991 - 10 10 10 86 86 86 38 38 38 10 10 10
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 - 0 0 0 0 0 0 0 0 0 0 0 0
45995 - 0 0 0 0 0 0 0 0 0 0 0 0
45996 - 0 0 0 0 0 0 0 0 0 0 0 0
45997 - 0 0 0 0 0 0 0 0 0 0 0 0
45998 - 0 0 0 0 0 0 0 0 0 0 0 0
45999 - 10 10 10 26 26 26 66 66 66 82 82 82
46000 - 2 2 6 22 22 22 18 18 18 2 2 6
46001 -149 149 149 253 253 253 253 253 253 253 253 253
46002 -253 253 253 253 253 253 253 253 253 253 253 253
46003 -253 253 253 253 253 253 234 234 234 242 242 242
46004 -253 253 253 253 253 253 253 253 253 253 253 253
46005 -253 253 253 253 253 253 253 253 253 253 253 253
46006 -253 253 253 253 253 253 253 253 253 253 253 253
46007 -253 253 253 253 253 253 253 253 253 253 253 253
46008 -253 253 253 253 253 253 206 206 206 2 2 6
46009 - 2 2 6 2 2 6 2 2 6 38 38 38
46010 - 2 2 6 2 2 6 2 2 6 2 2 6
46011 - 6 6 6 86 86 86 46 46 46 14 14 14
46012 - 0 0 0 0 0 0 0 0 0 0 0 0
46013 - 0 0 0 0 0 0 0 0 0 0 0 0
46014 - 0 0 0 0 0 0 0 0 0 0 0 0
46015 - 0 0 0 0 0 0 0 0 0 0 0 0
46016 - 0 0 0 0 0 0 0 0 0 0 0 0
46017 - 0 0 0 0 0 0 0 0 0 0 0 0
46018 - 0 0 0 0 0 0 0 0 0 6 6 6
46019 - 18 18 18 46 46 46 86 86 86 18 18 18
46020 - 2 2 6 34 34 34 10 10 10 6 6 6
46021 -210 210 210 253 253 253 253 253 253 253 253 253
46022 -253 253 253 253 253 253 253 253 253 253 253 253
46023 -253 253 253 253 253 253 234 234 234 242 242 242
46024 -253 253 253 253 253 253 253 253 253 253 253 253
46025 -253 253 253 253 253 253 253 253 253 253 253 253
46026 -253 253 253 253 253 253 253 253 253 253 253 253
46027 -253 253 253 253 253 253 253 253 253 253 253 253
46028 -253 253 253 253 253 253 221 221 221 6 6 6
46029 - 2 2 6 2 2 6 6 6 6 30 30 30
46030 - 2 2 6 2 2 6 2 2 6 2 2 6
46031 - 2 2 6 82 82 82 54 54 54 18 18 18
46032 - 6 6 6 0 0 0 0 0 0 0 0 0
46033 - 0 0 0 0 0 0 0 0 0 0 0 0
46034 - 0 0 0 0 0 0 0 0 0 0 0 0
46035 - 0 0 0 0 0 0 0 0 0 0 0 0
46036 - 0 0 0 0 0 0 0 0 0 0 0 0
46037 - 0 0 0 0 0 0 0 0 0 0 0 0
46038 - 0 0 0 0 0 0 0 0 0 10 10 10
46039 - 26 26 26 66 66 66 62 62 62 2 2 6
46040 - 2 2 6 38 38 38 10 10 10 26 26 26
46041 -238 238 238 253 253 253 253 253 253 253 253 253
46042 -253 253 253 253 253 253 253 253 253 253 253 253
46043 -253 253 253 253 253 253 231 231 231 238 238 238
46044 -253 253 253 253 253 253 253 253 253 253 253 253
46045 -253 253 253 253 253 253 253 253 253 253 253 253
46046 -253 253 253 253 253 253 253 253 253 253 253 253
46047 -253 253 253 253 253 253 253 253 253 253 253 253
46048 -253 253 253 253 253 253 231 231 231 6 6 6
46049 - 2 2 6 2 2 6 10 10 10 30 30 30
46050 - 2 2 6 2 2 6 2 2 6 2 2 6
46051 - 2 2 6 66 66 66 58 58 58 22 22 22
46052 - 6 6 6 0 0 0 0 0 0 0 0 0
46053 - 0 0 0 0 0 0 0 0 0 0 0 0
46054 - 0 0 0 0 0 0 0 0 0 0 0 0
46055 - 0 0 0 0 0 0 0 0 0 0 0 0
46056 - 0 0 0 0 0 0 0 0 0 0 0 0
46057 - 0 0 0 0 0 0 0 0 0 0 0 0
46058 - 0 0 0 0 0 0 0 0 0 10 10 10
46059 - 38 38 38 78 78 78 6 6 6 2 2 6
46060 - 2 2 6 46 46 46 14 14 14 42 42 42
46061 -246 246 246 253 253 253 253 253 253 253 253 253
46062 -253 253 253 253 253 253 253 253 253 253 253 253
46063 -253 253 253 253 253 253 231 231 231 242 242 242
46064 -253 253 253 253 253 253 253 253 253 253 253 253
46065 -253 253 253 253 253 253 253 253 253 253 253 253
46066 -253 253 253 253 253 253 253 253 253 253 253 253
46067 -253 253 253 253 253 253 253 253 253 253 253 253
46068 -253 253 253 253 253 253 234 234 234 10 10 10
46069 - 2 2 6 2 2 6 22 22 22 14 14 14
46070 - 2 2 6 2 2 6 2 2 6 2 2 6
46071 - 2 2 6 66 66 66 62 62 62 22 22 22
46072 - 6 6 6 0 0 0 0 0 0 0 0 0
46073 - 0 0 0 0 0 0 0 0 0 0 0 0
46074 - 0 0 0 0 0 0 0 0 0 0 0 0
46075 - 0 0 0 0 0 0 0 0 0 0 0 0
46076 - 0 0 0 0 0 0 0 0 0 0 0 0
46077 - 0 0 0 0 0 0 0 0 0 0 0 0
46078 - 0 0 0 0 0 0 6 6 6 18 18 18
46079 - 50 50 50 74 74 74 2 2 6 2 2 6
46080 - 14 14 14 70 70 70 34 34 34 62 62 62
46081 -250 250 250 253 253 253 253 253 253 253 253 253
46082 -253 253 253 253 253 253 253 253 253 253 253 253
46083 -253 253 253 253 253 253 231 231 231 246 246 246
46084 -253 253 253 253 253 253 253 253 253 253 253 253
46085 -253 253 253 253 253 253 253 253 253 253 253 253
46086 -253 253 253 253 253 253 253 253 253 253 253 253
46087 -253 253 253 253 253 253 253 253 253 253 253 253
46088 -253 253 253 253 253 253 234 234 234 14 14 14
46089 - 2 2 6 2 2 6 30 30 30 2 2 6
46090 - 2 2 6 2 2 6 2 2 6 2 2 6
46091 - 2 2 6 66 66 66 62 62 62 22 22 22
46092 - 6 6 6 0 0 0 0 0 0 0 0 0
46093 - 0 0 0 0 0 0 0 0 0 0 0 0
46094 - 0 0 0 0 0 0 0 0 0 0 0 0
46095 - 0 0 0 0 0 0 0 0 0 0 0 0
46096 - 0 0 0 0 0 0 0 0 0 0 0 0
46097 - 0 0 0 0 0 0 0 0 0 0 0 0
46098 - 0 0 0 0 0 0 6 6 6 18 18 18
46099 - 54 54 54 62 62 62 2 2 6 2 2 6
46100 - 2 2 6 30 30 30 46 46 46 70 70 70
46101 -250 250 250 253 253 253 253 253 253 253 253 253
46102 -253 253 253 253 253 253 253 253 253 253 253 253
46103 -253 253 253 253 253 253 231 231 231 246 246 246
46104 -253 253 253 253 253 253 253 253 253 253 253 253
46105 -253 253 253 253 253 253 253 253 253 253 253 253
46106 -253 253 253 253 253 253 253 253 253 253 253 253
46107 -253 253 253 253 253 253 253 253 253 253 253 253
46108 -253 253 253 253 253 253 226 226 226 10 10 10
46109 - 2 2 6 6 6 6 30 30 30 2 2 6
46110 - 2 2 6 2 2 6 2 2 6 2 2 6
46111 - 2 2 6 66 66 66 58 58 58 22 22 22
46112 - 6 6 6 0 0 0 0 0 0 0 0 0
46113 - 0 0 0 0 0 0 0 0 0 0 0 0
46114 - 0 0 0 0 0 0 0 0 0 0 0 0
46115 - 0 0 0 0 0 0 0 0 0 0 0 0
46116 - 0 0 0 0 0 0 0 0 0 0 0 0
46117 - 0 0 0 0 0 0 0 0 0 0 0 0
46118 - 0 0 0 0 0 0 6 6 6 22 22 22
46119 - 58 58 58 62 62 62 2 2 6 2 2 6
46120 - 2 2 6 2 2 6 30 30 30 78 78 78
46121 -250 250 250 253 253 253 253 253 253 253 253 253
46122 -253 253 253 253 253 253 253 253 253 253 253 253
46123 -253 253 253 253 253 253 231 231 231 246 246 246
46124 -253 253 253 253 253 253 253 253 253 253 253 253
46125 -253 253 253 253 253 253 253 253 253 253 253 253
46126 -253 253 253 253 253 253 253 253 253 253 253 253
46127 -253 253 253 253 253 253 253 253 253 253 253 253
46128 -253 253 253 253 253 253 206 206 206 2 2 6
46129 - 22 22 22 34 34 34 18 14 6 22 22 22
46130 - 26 26 26 18 18 18 6 6 6 2 2 6
46131 - 2 2 6 82 82 82 54 54 54 18 18 18
46132 - 6 6 6 0 0 0 0 0 0 0 0 0
46133 - 0 0 0 0 0 0 0 0 0 0 0 0
46134 - 0 0 0 0 0 0 0 0 0 0 0 0
46135 - 0 0 0 0 0 0 0 0 0 0 0 0
46136 - 0 0 0 0 0 0 0 0 0 0 0 0
46137 - 0 0 0 0 0 0 0 0 0 0 0 0
46138 - 0 0 0 0 0 0 6 6 6 26 26 26
46139 - 62 62 62 106 106 106 74 54 14 185 133 11
46140 -210 162 10 121 92 8 6 6 6 62 62 62
46141 -238 238 238 253 253 253 253 253 253 253 253 253
46142 -253 253 253 253 253 253 253 253 253 253 253 253
46143 -253 253 253 253 253 253 231 231 231 246 246 246
46144 -253 253 253 253 253 253 253 253 253 253 253 253
46145 -253 253 253 253 253 253 253 253 253 253 253 253
46146 -253 253 253 253 253 253 253 253 253 253 253 253
46147 -253 253 253 253 253 253 253 253 253 253 253 253
46148 -253 253 253 253 253 253 158 158 158 18 18 18
46149 - 14 14 14 2 2 6 2 2 6 2 2 6
46150 - 6 6 6 18 18 18 66 66 66 38 38 38
46151 - 6 6 6 94 94 94 50 50 50 18 18 18
46152 - 6 6 6 0 0 0 0 0 0 0 0 0
46153 - 0 0 0 0 0 0 0 0 0 0 0 0
46154 - 0 0 0 0 0 0 0 0 0 0 0 0
46155 - 0 0 0 0 0 0 0 0 0 0 0 0
46156 - 0 0 0 0 0 0 0 0 0 0 0 0
46157 - 0 0 0 0 0 0 0 0 0 6 6 6
46158 - 10 10 10 10 10 10 18 18 18 38 38 38
46159 - 78 78 78 142 134 106 216 158 10 242 186 14
46160 -246 190 14 246 190 14 156 118 10 10 10 10
46161 - 90 90 90 238 238 238 253 253 253 253 253 253
46162 -253 253 253 253 253 253 253 253 253 253 253 253
46163 -253 253 253 253 253 253 231 231 231 250 250 250
46164 -253 253 253 253 253 253 253 253 253 253 253 253
46165 -253 253 253 253 253 253 253 253 253 253 253 253
46166 -253 253 253 253 253 253 253 253 253 253 253 253
46167 -253 253 253 253 253 253 253 253 253 246 230 190
46168 -238 204 91 238 204 91 181 142 44 37 26 9
46169 - 2 2 6 2 2 6 2 2 6 2 2 6
46170 - 2 2 6 2 2 6 38 38 38 46 46 46
46171 - 26 26 26 106 106 106 54 54 54 18 18 18
46172 - 6 6 6 0 0 0 0 0 0 0 0 0
46173 - 0 0 0 0 0 0 0 0 0 0 0 0
46174 - 0 0 0 0 0 0 0 0 0 0 0 0
46175 - 0 0 0 0 0 0 0 0 0 0 0 0
46176 - 0 0 0 0 0 0 0 0 0 0 0 0
46177 - 0 0 0 6 6 6 14 14 14 22 22 22
46178 - 30 30 30 38 38 38 50 50 50 70 70 70
46179 -106 106 106 190 142 34 226 170 11 242 186 14
46180 -246 190 14 246 190 14 246 190 14 154 114 10
46181 - 6 6 6 74 74 74 226 226 226 253 253 253
46182 -253 253 253 253 253 253 253 253 253 253 253 253
46183 -253 253 253 253 253 253 231 231 231 250 250 250
46184 -253 253 253 253 253 253 253 253 253 253 253 253
46185 -253 253 253 253 253 253 253 253 253 253 253 253
46186 -253 253 253 253 253 253 253 253 253 253 253 253
46187 -253 253 253 253 253 253 253 253 253 228 184 62
46188 -241 196 14 241 208 19 232 195 16 38 30 10
46189 - 2 2 6 2 2 6 2 2 6 2 2 6
46190 - 2 2 6 6 6 6 30 30 30 26 26 26
46191 -203 166 17 154 142 90 66 66 66 26 26 26
46192 - 6 6 6 0 0 0 0 0 0 0 0 0
46193 - 0 0 0 0 0 0 0 0 0 0 0 0
46194 - 0 0 0 0 0 0 0 0 0 0 0 0
46195 - 0 0 0 0 0 0 0 0 0 0 0 0
46196 - 0 0 0 0 0 0 0 0 0 0 0 0
46197 - 6 6 6 18 18 18 38 38 38 58 58 58
46198 - 78 78 78 86 86 86 101 101 101 123 123 123
46199 -175 146 61 210 150 10 234 174 13 246 186 14
46200 -246 190 14 246 190 14 246 190 14 238 190 10
46201 -102 78 10 2 2 6 46 46 46 198 198 198
46202 -253 253 253 253 253 253 253 253 253 253 253 253
46203 -253 253 253 253 253 253 234 234 234 242 242 242
46204 -253 253 253 253 253 253 253 253 253 253 253 253
46205 -253 253 253 253 253 253 253 253 253 253 253 253
46206 -253 253 253 253 253 253 253 253 253 253 253 253
46207 -253 253 253 253 253 253 253 253 253 224 178 62
46208 -242 186 14 241 196 14 210 166 10 22 18 6
46209 - 2 2 6 2 2 6 2 2 6 2 2 6
46210 - 2 2 6 2 2 6 6 6 6 121 92 8
46211 -238 202 15 232 195 16 82 82 82 34 34 34
46212 - 10 10 10 0 0 0 0 0 0 0 0 0
46213 - 0 0 0 0 0 0 0 0 0 0 0 0
46214 - 0 0 0 0 0 0 0 0 0 0 0 0
46215 - 0 0 0 0 0 0 0 0 0 0 0 0
46216 - 0 0 0 0 0 0 0 0 0 0 0 0
46217 - 14 14 14 38 38 38 70 70 70 154 122 46
46218 -190 142 34 200 144 11 197 138 11 197 138 11
46219 -213 154 11 226 170 11 242 186 14 246 190 14
46220 -246 190 14 246 190 14 246 190 14 246 190 14
46221 -225 175 15 46 32 6 2 2 6 22 22 22
46222 -158 158 158 250 250 250 253 253 253 253 253 253
46223 -253 253 253 253 253 253 253 253 253 253 253 253
46224 -253 253 253 253 253 253 253 253 253 253 253 253
46225 -253 253 253 253 253 253 253 253 253 253 253 253
46226 -253 253 253 253 253 253 253 253 253 253 253 253
46227 -253 253 253 250 250 250 242 242 242 224 178 62
46228 -239 182 13 236 186 11 213 154 11 46 32 6
46229 - 2 2 6 2 2 6 2 2 6 2 2 6
46230 - 2 2 6 2 2 6 61 42 6 225 175 15
46231 -238 190 10 236 186 11 112 100 78 42 42 42
46232 - 14 14 14 0 0 0 0 0 0 0 0 0
46233 - 0 0 0 0 0 0 0 0 0 0 0 0
46234 - 0 0 0 0 0 0 0 0 0 0 0 0
46235 - 0 0 0 0 0 0 0 0 0 0 0 0
46236 - 0 0 0 0 0 0 0 0 0 6 6 6
46237 - 22 22 22 54 54 54 154 122 46 213 154 11
46238 -226 170 11 230 174 11 226 170 11 226 170 11
46239 -236 178 12 242 186 14 246 190 14 246 190 14
46240 -246 190 14 246 190 14 246 190 14 246 190 14
46241 -241 196 14 184 144 12 10 10 10 2 2 6
46242 - 6 6 6 116 116 116 242 242 242 253 253 253
46243 -253 253 253 253 253 253 253 253 253 253 253 253
46244 -253 253 253 253 253 253 253 253 253 253 253 253
46245 -253 253 253 253 253 253 253 253 253 253 253 253
46246 -253 253 253 253 253 253 253 253 253 253 253 253
46247 -253 253 253 231 231 231 198 198 198 214 170 54
46248 -236 178 12 236 178 12 210 150 10 137 92 6
46249 - 18 14 6 2 2 6 2 2 6 2 2 6
46250 - 6 6 6 70 47 6 200 144 11 236 178 12
46251 -239 182 13 239 182 13 124 112 88 58 58 58
46252 - 22 22 22 6 6 6 0 0 0 0 0 0
46253 - 0 0 0 0 0 0 0 0 0 0 0 0
46254 - 0 0 0 0 0 0 0 0 0 0 0 0
46255 - 0 0 0 0 0 0 0 0 0 0 0 0
46256 - 0 0 0 0 0 0 0 0 0 10 10 10
46257 - 30 30 30 70 70 70 180 133 36 226 170 11
46258 -239 182 13 242 186 14 242 186 14 246 186 14
46259 -246 190 14 246 190 14 246 190 14 246 190 14
46260 -246 190 14 246 190 14 246 190 14 246 190 14
46261 -246 190 14 232 195 16 98 70 6 2 2 6
46262 - 2 2 6 2 2 6 66 66 66 221 221 221
46263 -253 253 253 253 253 253 253 253 253 253 253 253
46264 -253 253 253 253 253 253 253 253 253 253 253 253
46265 -253 253 253 253 253 253 253 253 253 253 253 253
46266 -253 253 253 253 253 253 253 253 253 253 253 253
46267 -253 253 253 206 206 206 198 198 198 214 166 58
46268 -230 174 11 230 174 11 216 158 10 192 133 9
46269 -163 110 8 116 81 8 102 78 10 116 81 8
46270 -167 114 7 197 138 11 226 170 11 239 182 13
46271 -242 186 14 242 186 14 162 146 94 78 78 78
46272 - 34 34 34 14 14 14 6 6 6 0 0 0
46273 - 0 0 0 0 0 0 0 0 0 0 0 0
46274 - 0 0 0 0 0 0 0 0 0 0 0 0
46275 - 0 0 0 0 0 0 0 0 0 0 0 0
46276 - 0 0 0 0 0 0 0 0 0 6 6 6
46277 - 30 30 30 78 78 78 190 142 34 226 170 11
46278 -239 182 13 246 190 14 246 190 14 246 190 14
46279 -246 190 14 246 190 14 246 190 14 246 190 14
46280 -246 190 14 246 190 14 246 190 14 246 190 14
46281 -246 190 14 241 196 14 203 166 17 22 18 6
46282 - 2 2 6 2 2 6 2 2 6 38 38 38
46283 -218 218 218 253 253 253 253 253 253 253 253 253
46284 -253 253 253 253 253 253 253 253 253 253 253 253
46285 -253 253 253 253 253 253 253 253 253 253 253 253
46286 -253 253 253 253 253 253 253 253 253 253 253 253
46287 -250 250 250 206 206 206 198 198 198 202 162 69
46288 -226 170 11 236 178 12 224 166 10 210 150 10
46289 -200 144 11 197 138 11 192 133 9 197 138 11
46290 -210 150 10 226 170 11 242 186 14 246 190 14
46291 -246 190 14 246 186 14 225 175 15 124 112 88
46292 - 62 62 62 30 30 30 14 14 14 6 6 6
46293 - 0 0 0 0 0 0 0 0 0 0 0 0
46294 - 0 0 0 0 0 0 0 0 0 0 0 0
46295 - 0 0 0 0 0 0 0 0 0 0 0 0
46296 - 0 0 0 0 0 0 0 0 0 10 10 10
46297 - 30 30 30 78 78 78 174 135 50 224 166 10
46298 -239 182 13 246 190 14 246 190 14 246 190 14
46299 -246 190 14 246 190 14 246 190 14 246 190 14
46300 -246 190 14 246 190 14 246 190 14 246 190 14
46301 -246 190 14 246 190 14 241 196 14 139 102 15
46302 - 2 2 6 2 2 6 2 2 6 2 2 6
46303 - 78 78 78 250 250 250 253 253 253 253 253 253
46304 -253 253 253 253 253 253 253 253 253 253 253 253
46305 -253 253 253 253 253 253 253 253 253 253 253 253
46306 -253 253 253 253 253 253 253 253 253 253 253 253
46307 -250 250 250 214 214 214 198 198 198 190 150 46
46308 -219 162 10 236 178 12 234 174 13 224 166 10
46309 -216 158 10 213 154 11 213 154 11 216 158 10
46310 -226 170 11 239 182 13 246 190 14 246 190 14
46311 -246 190 14 246 190 14 242 186 14 206 162 42
46312 -101 101 101 58 58 58 30 30 30 14 14 14
46313 - 6 6 6 0 0 0 0 0 0 0 0 0
46314 - 0 0 0 0 0 0 0 0 0 0 0 0
46315 - 0 0 0 0 0 0 0 0 0 0 0 0
46316 - 0 0 0 0 0 0 0 0 0 10 10 10
46317 - 30 30 30 74 74 74 174 135 50 216 158 10
46318 -236 178 12 246 190 14 246 190 14 246 190 14
46319 -246 190 14 246 190 14 246 190 14 246 190 14
46320 -246 190 14 246 190 14 246 190 14 246 190 14
46321 -246 190 14 246 190 14 241 196 14 226 184 13
46322 - 61 42 6 2 2 6 2 2 6 2 2 6
46323 - 22 22 22 238 238 238 253 253 253 253 253 253
46324 -253 253 253 253 253 253 253 253 253 253 253 253
46325 -253 253 253 253 253 253 253 253 253 253 253 253
46326 -253 253 253 253 253 253 253 253 253 253 253 253
46327 -253 253 253 226 226 226 187 187 187 180 133 36
46328 -216 158 10 236 178 12 239 182 13 236 178 12
46329 -230 174 11 226 170 11 226 170 11 230 174 11
46330 -236 178 12 242 186 14 246 190 14 246 190 14
46331 -246 190 14 246 190 14 246 186 14 239 182 13
46332 -206 162 42 106 106 106 66 66 66 34 34 34
46333 - 14 14 14 6 6 6 0 0 0 0 0 0
46334 - 0 0 0 0 0 0 0 0 0 0 0 0
46335 - 0 0 0 0 0 0 0 0 0 0 0 0
46336 - 0 0 0 0 0 0 0 0 0 6 6 6
46337 - 26 26 26 70 70 70 163 133 67 213 154 11
46338 -236 178 12 246 190 14 246 190 14 246 190 14
46339 -246 190 14 246 190 14 246 190 14 246 190 14
46340 -246 190 14 246 190 14 246 190 14 246 190 14
46341 -246 190 14 246 190 14 246 190 14 241 196 14
46342 -190 146 13 18 14 6 2 2 6 2 2 6
46343 - 46 46 46 246 246 246 253 253 253 253 253 253
46344 -253 253 253 253 253 253 253 253 253 253 253 253
46345 -253 253 253 253 253 253 253 253 253 253 253 253
46346 -253 253 253 253 253 253 253 253 253 253 253 253
46347 -253 253 253 221 221 221 86 86 86 156 107 11
46348 -216 158 10 236 178 12 242 186 14 246 186 14
46349 -242 186 14 239 182 13 239 182 13 242 186 14
46350 -242 186 14 246 186 14 246 190 14 246 190 14
46351 -246 190 14 246 190 14 246 190 14 246 190 14
46352 -242 186 14 225 175 15 142 122 72 66 66 66
46353 - 30 30 30 10 10 10 0 0 0 0 0 0
46354 - 0 0 0 0 0 0 0 0 0 0 0 0
46355 - 0 0 0 0 0 0 0 0 0 0 0 0
46356 - 0 0 0 0 0 0 0 0 0 6 6 6
46357 - 26 26 26 70 70 70 163 133 67 210 150 10
46358 -236 178 12 246 190 14 246 190 14 246 190 14
46359 -246 190 14 246 190 14 246 190 14 246 190 14
46360 -246 190 14 246 190 14 246 190 14 246 190 14
46361 -246 190 14 246 190 14 246 190 14 246 190 14
46362 -232 195 16 121 92 8 34 34 34 106 106 106
46363 -221 221 221 253 253 253 253 253 253 253 253 253
46364 -253 253 253 253 253 253 253 253 253 253 253 253
46365 -253 253 253 253 253 253 253 253 253 253 253 253
46366 -253 253 253 253 253 253 253 253 253 253 253 253
46367 -242 242 242 82 82 82 18 14 6 163 110 8
46368 -216 158 10 236 178 12 242 186 14 246 190 14
46369 -246 190 14 246 190 14 246 190 14 246 190 14
46370 -246 190 14 246 190 14 246 190 14 246 190 14
46371 -246 190 14 246 190 14 246 190 14 246 190 14
46372 -246 190 14 246 190 14 242 186 14 163 133 67
46373 - 46 46 46 18 18 18 6 6 6 0 0 0
46374 - 0 0 0 0 0 0 0 0 0 0 0 0
46375 - 0 0 0 0 0 0 0 0 0 0 0 0
46376 - 0 0 0 0 0 0 0 0 0 10 10 10
46377 - 30 30 30 78 78 78 163 133 67 210 150 10
46378 -236 178 12 246 186 14 246 190 14 246 190 14
46379 -246 190 14 246 190 14 246 190 14 246 190 14
46380 -246 190 14 246 190 14 246 190 14 246 190 14
46381 -246 190 14 246 190 14 246 190 14 246 190 14
46382 -241 196 14 215 174 15 190 178 144 253 253 253
46383 -253 253 253 253 253 253 253 253 253 253 253 253
46384 -253 253 253 253 253 253 253 253 253 253 253 253
46385 -253 253 253 253 253 253 253 253 253 253 253 253
46386 -253 253 253 253 253 253 253 253 253 218 218 218
46387 - 58 58 58 2 2 6 22 18 6 167 114 7
46388 -216 158 10 236 178 12 246 186 14 246 190 14
46389 -246 190 14 246 190 14 246 190 14 246 190 14
46390 -246 190 14 246 190 14 246 190 14 246 190 14
46391 -246 190 14 246 190 14 246 190 14 246 190 14
46392 -246 190 14 246 186 14 242 186 14 190 150 46
46393 - 54 54 54 22 22 22 6 6 6 0 0 0
46394 - 0 0 0 0 0 0 0 0 0 0 0 0
46395 - 0 0 0 0 0 0 0 0 0 0 0 0
46396 - 0 0 0 0 0 0 0 0 0 14 14 14
46397 - 38 38 38 86 86 86 180 133 36 213 154 11
46398 -236 178 12 246 186 14 246 190 14 246 190 14
46399 -246 190 14 246 190 14 246 190 14 246 190 14
46400 -246 190 14 246 190 14 246 190 14 246 190 14
46401 -246 190 14 246 190 14 246 190 14 246 190 14
46402 -246 190 14 232 195 16 190 146 13 214 214 214
46403 -253 253 253 253 253 253 253 253 253 253 253 253
46404 -253 253 253 253 253 253 253 253 253 253 253 253
46405 -253 253 253 253 253 253 253 253 253 253 253 253
46406 -253 253 253 250 250 250 170 170 170 26 26 26
46407 - 2 2 6 2 2 6 37 26 9 163 110 8
46408 -219 162 10 239 182 13 246 186 14 246 190 14
46409 -246 190 14 246 190 14 246 190 14 246 190 14
46410 -246 190 14 246 190 14 246 190 14 246 190 14
46411 -246 190 14 246 190 14 246 190 14 246 190 14
46412 -246 186 14 236 178 12 224 166 10 142 122 72
46413 - 46 46 46 18 18 18 6 6 6 0 0 0
46414 - 0 0 0 0 0 0 0 0 0 0 0 0
46415 - 0 0 0 0 0 0 0 0 0 0 0 0
46416 - 0 0 0 0 0 0 6 6 6 18 18 18
46417 - 50 50 50 109 106 95 192 133 9 224 166 10
46418 -242 186 14 246 190 14 246 190 14 246 190 14
46419 -246 190 14 246 190 14 246 190 14 246 190 14
46420 -246 190 14 246 190 14 246 190 14 246 190 14
46421 -246 190 14 246 190 14 246 190 14 246 190 14
46422 -242 186 14 226 184 13 210 162 10 142 110 46
46423 -226 226 226 253 253 253 253 253 253 253 253 253
46424 -253 253 253 253 253 253 253 253 253 253 253 253
46425 -253 253 253 253 253 253 253 253 253 253 253 253
46426 -198 198 198 66 66 66 2 2 6 2 2 6
46427 - 2 2 6 2 2 6 50 34 6 156 107 11
46428 -219 162 10 239 182 13 246 186 14 246 190 14
46429 -246 190 14 246 190 14 246 190 14 246 190 14
46430 -246 190 14 246 190 14 246 190 14 246 190 14
46431 -246 190 14 246 190 14 246 190 14 242 186 14
46432 -234 174 13 213 154 11 154 122 46 66 66 66
46433 - 30 30 30 10 10 10 0 0 0 0 0 0
46434 - 0 0 0 0 0 0 0 0 0 0 0 0
46435 - 0 0 0 0 0 0 0 0 0 0 0 0
46436 - 0 0 0 0 0 0 6 6 6 22 22 22
46437 - 58 58 58 154 121 60 206 145 10 234 174 13
46438 -242 186 14 246 186 14 246 190 14 246 190 14
46439 -246 190 14 246 190 14 246 190 14 246 190 14
46440 -246 190 14 246 190 14 246 190 14 246 190 14
46441 -246 190 14 246 190 14 246 190 14 246 190 14
46442 -246 186 14 236 178 12 210 162 10 163 110 8
46443 - 61 42 6 138 138 138 218 218 218 250 250 250
46444 -253 253 253 253 253 253 253 253 253 250 250 250
46445 -242 242 242 210 210 210 144 144 144 66 66 66
46446 - 6 6 6 2 2 6 2 2 6 2 2 6
46447 - 2 2 6 2 2 6 61 42 6 163 110 8
46448 -216 158 10 236 178 12 246 190 14 246 190 14
46449 -246 190 14 246 190 14 246 190 14 246 190 14
46450 -246 190 14 246 190 14 246 190 14 246 190 14
46451 -246 190 14 239 182 13 230 174 11 216 158 10
46452 -190 142 34 124 112 88 70 70 70 38 38 38
46453 - 18 18 18 6 6 6 0 0 0 0 0 0
46454 - 0 0 0 0 0 0 0 0 0 0 0 0
46455 - 0 0 0 0 0 0 0 0 0 0 0 0
46456 - 0 0 0 0 0 0 6 6 6 22 22 22
46457 - 62 62 62 168 124 44 206 145 10 224 166 10
46458 -236 178 12 239 182 13 242 186 14 242 186 14
46459 -246 186 14 246 190 14 246 190 14 246 190 14
46460 -246 190 14 246 190 14 246 190 14 246 190 14
46461 -246 190 14 246 190 14 246 190 14 246 190 14
46462 -246 190 14 236 178 12 216 158 10 175 118 6
46463 - 80 54 7 2 2 6 6 6 6 30 30 30
46464 - 54 54 54 62 62 62 50 50 50 38 38 38
46465 - 14 14 14 2 2 6 2 2 6 2 2 6
46466 - 2 2 6 2 2 6 2 2 6 2 2 6
46467 - 2 2 6 6 6 6 80 54 7 167 114 7
46468 -213 154 11 236 178 12 246 190 14 246 190 14
46469 -246 190 14 246 190 14 246 190 14 246 190 14
46470 -246 190 14 242 186 14 239 182 13 239 182 13
46471 -230 174 11 210 150 10 174 135 50 124 112 88
46472 - 82 82 82 54 54 54 34 34 34 18 18 18
46473 - 6 6 6 0 0 0 0 0 0 0 0 0
46474 - 0 0 0 0 0 0 0 0 0 0 0 0
46475 - 0 0 0 0 0 0 0 0 0 0 0 0
46476 - 0 0 0 0 0 0 6 6 6 18 18 18
46477 - 50 50 50 158 118 36 192 133 9 200 144 11
46478 -216 158 10 219 162 10 224 166 10 226 170 11
46479 -230 174 11 236 178 12 239 182 13 239 182 13
46480 -242 186 14 246 186 14 246 190 14 246 190 14
46481 -246 190 14 246 190 14 246 190 14 246 190 14
46482 -246 186 14 230 174 11 210 150 10 163 110 8
46483 -104 69 6 10 10 10 2 2 6 2 2 6
46484 - 2 2 6 2 2 6 2 2 6 2 2 6
46485 - 2 2 6 2 2 6 2 2 6 2 2 6
46486 - 2 2 6 2 2 6 2 2 6 2 2 6
46487 - 2 2 6 6 6 6 91 60 6 167 114 7
46488 -206 145 10 230 174 11 242 186 14 246 190 14
46489 -246 190 14 246 190 14 246 186 14 242 186 14
46490 -239 182 13 230 174 11 224 166 10 213 154 11
46491 -180 133 36 124 112 88 86 86 86 58 58 58
46492 - 38 38 38 22 22 22 10 10 10 6 6 6
46493 - 0 0 0 0 0 0 0 0 0 0 0 0
46494 - 0 0 0 0 0 0 0 0 0 0 0 0
46495 - 0 0 0 0 0 0 0 0 0 0 0 0
46496 - 0 0 0 0 0 0 0 0 0 14 14 14
46497 - 34 34 34 70 70 70 138 110 50 158 118 36
46498 -167 114 7 180 123 7 192 133 9 197 138 11
46499 -200 144 11 206 145 10 213 154 11 219 162 10
46500 -224 166 10 230 174 11 239 182 13 242 186 14
46501 -246 186 14 246 186 14 246 186 14 246 186 14
46502 -239 182 13 216 158 10 185 133 11 152 99 6
46503 -104 69 6 18 14 6 2 2 6 2 2 6
46504 - 2 2 6 2 2 6 2 2 6 2 2 6
46505 - 2 2 6 2 2 6 2 2 6 2 2 6
46506 - 2 2 6 2 2 6 2 2 6 2 2 6
46507 - 2 2 6 6 6 6 80 54 7 152 99 6
46508 -192 133 9 219 162 10 236 178 12 239 182 13
46509 -246 186 14 242 186 14 239 182 13 236 178 12
46510 -224 166 10 206 145 10 192 133 9 154 121 60
46511 - 94 94 94 62 62 62 42 42 42 22 22 22
46512 - 14 14 14 6 6 6 0 0 0 0 0 0
46513 - 0 0 0 0 0 0 0 0 0 0 0 0
46514 - 0 0 0 0 0 0 0 0 0 0 0 0
46515 - 0 0 0 0 0 0 0 0 0 0 0 0
46516 - 0 0 0 0 0 0 0 0 0 6 6 6
46517 - 18 18 18 34 34 34 58 58 58 78 78 78
46518 -101 98 89 124 112 88 142 110 46 156 107 11
46519 -163 110 8 167 114 7 175 118 6 180 123 7
46520 -185 133 11 197 138 11 210 150 10 219 162 10
46521 -226 170 11 236 178 12 236 178 12 234 174 13
46522 -219 162 10 197 138 11 163 110 8 130 83 6
46523 - 91 60 6 10 10 10 2 2 6 2 2 6
46524 - 18 18 18 38 38 38 38 38 38 38 38 38
46525 - 38 38 38 38 38 38 38 38 38 38 38 38
46526 - 38 38 38 38 38 38 26 26 26 2 2 6
46527 - 2 2 6 6 6 6 70 47 6 137 92 6
46528 -175 118 6 200 144 11 219 162 10 230 174 11
46529 -234 174 13 230 174 11 219 162 10 210 150 10
46530 -192 133 9 163 110 8 124 112 88 82 82 82
46531 - 50 50 50 30 30 30 14 14 14 6 6 6
46532 - 0 0 0 0 0 0 0 0 0 0 0 0
46533 - 0 0 0 0 0 0 0 0 0 0 0 0
46534 - 0 0 0 0 0 0 0 0 0 0 0 0
46535 - 0 0 0 0 0 0 0 0 0 0 0 0
46536 - 0 0 0 0 0 0 0 0 0 0 0 0
46537 - 6 6 6 14 14 14 22 22 22 34 34 34
46538 - 42 42 42 58 58 58 74 74 74 86 86 86
46539 -101 98 89 122 102 70 130 98 46 121 87 25
46540 -137 92 6 152 99 6 163 110 8 180 123 7
46541 -185 133 11 197 138 11 206 145 10 200 144 11
46542 -180 123 7 156 107 11 130 83 6 104 69 6
46543 - 50 34 6 54 54 54 110 110 110 101 98 89
46544 - 86 86 86 82 82 82 78 78 78 78 78 78
46545 - 78 78 78 78 78 78 78 78 78 78 78 78
46546 - 78 78 78 82 82 82 86 86 86 94 94 94
46547 -106 106 106 101 101 101 86 66 34 124 80 6
46548 -156 107 11 180 123 7 192 133 9 200 144 11
46549 -206 145 10 200 144 11 192 133 9 175 118 6
46550 -139 102 15 109 106 95 70 70 70 42 42 42
46551 - 22 22 22 10 10 10 0 0 0 0 0 0
46552 - 0 0 0 0 0 0 0 0 0 0 0 0
46553 - 0 0 0 0 0 0 0 0 0 0 0 0
46554 - 0 0 0 0 0 0 0 0 0 0 0 0
46555 - 0 0 0 0 0 0 0 0 0 0 0 0
46556 - 0 0 0 0 0 0 0 0 0 0 0 0
46557 - 0 0 0 0 0 0 6 6 6 10 10 10
46558 - 14 14 14 22 22 22 30 30 30 38 38 38
46559 - 50 50 50 62 62 62 74 74 74 90 90 90
46560 -101 98 89 112 100 78 121 87 25 124 80 6
46561 -137 92 6 152 99 6 152 99 6 152 99 6
46562 -138 86 6 124 80 6 98 70 6 86 66 30
46563 -101 98 89 82 82 82 58 58 58 46 46 46
46564 - 38 38 38 34 34 34 34 34 34 34 34 34
46565 - 34 34 34 34 34 34 34 34 34 34 34 34
46566 - 34 34 34 34 34 34 38 38 38 42 42 42
46567 - 54 54 54 82 82 82 94 86 76 91 60 6
46568 -134 86 6 156 107 11 167 114 7 175 118 6
46569 -175 118 6 167 114 7 152 99 6 121 87 25
46570 -101 98 89 62 62 62 34 34 34 18 18 18
46571 - 6 6 6 0 0 0 0 0 0 0 0 0
46572 - 0 0 0 0 0 0 0 0 0 0 0 0
46573 - 0 0 0 0 0 0 0 0 0 0 0 0
46574 - 0 0 0 0 0 0 0 0 0 0 0 0
46575 - 0 0 0 0 0 0 0 0 0 0 0 0
46576 - 0 0 0 0 0 0 0 0 0 0 0 0
46577 - 0 0 0 0 0 0 0 0 0 0 0 0
46578 - 0 0 0 6 6 6 6 6 6 10 10 10
46579 - 18 18 18 22 22 22 30 30 30 42 42 42
46580 - 50 50 50 66 66 66 86 86 86 101 98 89
46581 -106 86 58 98 70 6 104 69 6 104 69 6
46582 -104 69 6 91 60 6 82 62 34 90 90 90
46583 - 62 62 62 38 38 38 22 22 22 14 14 14
46584 - 10 10 10 10 10 10 10 10 10 10 10 10
46585 - 10 10 10 10 10 10 6 6 6 10 10 10
46586 - 10 10 10 10 10 10 10 10 10 14 14 14
46587 - 22 22 22 42 42 42 70 70 70 89 81 66
46588 - 80 54 7 104 69 6 124 80 6 137 92 6
46589 -134 86 6 116 81 8 100 82 52 86 86 86
46590 - 58 58 58 30 30 30 14 14 14 6 6 6
46591 - 0 0 0 0 0 0 0 0 0 0 0 0
46592 - 0 0 0 0 0 0 0 0 0 0 0 0
46593 - 0 0 0 0 0 0 0 0 0 0 0 0
46594 - 0 0 0 0 0 0 0 0 0 0 0 0
46595 - 0 0 0 0 0 0 0 0 0 0 0 0
46596 - 0 0 0 0 0 0 0 0 0 0 0 0
46597 - 0 0 0 0 0 0 0 0 0 0 0 0
46598 - 0 0 0 0 0 0 0 0 0 0 0 0
46599 - 0 0 0 6 6 6 10 10 10 14 14 14
46600 - 18 18 18 26 26 26 38 38 38 54 54 54
46601 - 70 70 70 86 86 86 94 86 76 89 81 66
46602 - 89 81 66 86 86 86 74 74 74 50 50 50
46603 - 30 30 30 14 14 14 6 6 6 0 0 0
46604 - 0 0 0 0 0 0 0 0 0 0 0 0
46605 - 0 0 0 0 0 0 0 0 0 0 0 0
46606 - 0 0 0 0 0 0 0 0 0 0 0 0
46607 - 6 6 6 18 18 18 34 34 34 58 58 58
46608 - 82 82 82 89 81 66 89 81 66 89 81 66
46609 - 94 86 66 94 86 76 74 74 74 50 50 50
46610 - 26 26 26 14 14 14 6 6 6 0 0 0
46611 - 0 0 0 0 0 0 0 0 0 0 0 0
46612 - 0 0 0 0 0 0 0 0 0 0 0 0
46613 - 0 0 0 0 0 0 0 0 0 0 0 0
46614 - 0 0 0 0 0 0 0 0 0 0 0 0
46615 - 0 0 0 0 0 0 0 0 0 0 0 0
46616 - 0 0 0 0 0 0 0 0 0 0 0 0
46617 - 0 0 0 0 0 0 0 0 0 0 0 0
46618 - 0 0 0 0 0 0 0 0 0 0 0 0
46619 - 0 0 0 0 0 0 0 0 0 0 0 0
46620 - 6 6 6 6 6 6 14 14 14 18 18 18
46621 - 30 30 30 38 38 38 46 46 46 54 54 54
46622 - 50 50 50 42 42 42 30 30 30 18 18 18
46623 - 10 10 10 0 0 0 0 0 0 0 0 0
46624 - 0 0 0 0 0 0 0 0 0 0 0 0
46625 - 0 0 0 0 0 0 0 0 0 0 0 0
46626 - 0 0 0 0 0 0 0 0 0 0 0 0
46627 - 0 0 0 6 6 6 14 14 14 26 26 26
46628 - 38 38 38 50 50 50 58 58 58 58 58 58
46629 - 54 54 54 42 42 42 30 30 30 18 18 18
46630 - 10 10 10 0 0 0 0 0 0 0 0 0
46631 - 0 0 0 0 0 0 0 0 0 0 0 0
46632 - 0 0 0 0 0 0 0 0 0 0 0 0
46633 - 0 0 0 0 0 0 0 0 0 0 0 0
46634 - 0 0 0 0 0 0 0 0 0 0 0 0
46635 - 0 0 0 0 0 0 0 0 0 0 0 0
46636 - 0 0 0 0 0 0 0 0 0 0 0 0
46637 - 0 0 0 0 0 0 0 0 0 0 0 0
46638 - 0 0 0 0 0 0 0 0 0 0 0 0
46639 - 0 0 0 0 0 0 0 0 0 0 0 0
46640 - 0 0 0 0 0 0 0 0 0 6 6 6
46641 - 6 6 6 10 10 10 14 14 14 18 18 18
46642 - 18 18 18 14 14 14 10 10 10 6 6 6
46643 - 0 0 0 0 0 0 0 0 0 0 0 0
46644 - 0 0 0 0 0 0 0 0 0 0 0 0
46645 - 0 0 0 0 0 0 0 0 0 0 0 0
46646 - 0 0 0 0 0 0 0 0 0 0 0 0
46647 - 0 0 0 0 0 0 0 0 0 6 6 6
46648 - 14 14 14 18 18 18 22 22 22 22 22 22
46649 - 18 18 18 14 14 14 10 10 10 6 6 6
46650 - 0 0 0 0 0 0 0 0 0 0 0 0
46651 - 0 0 0 0 0 0 0 0 0 0 0 0
46652 - 0 0 0 0 0 0 0 0 0 0 0 0
46653 - 0 0 0 0 0 0 0 0 0 0 0 0
46654 - 0 0 0 0 0 0 0 0 0 0 0 0
46655 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46656 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46657 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46658 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46659 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46660 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46661 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46662 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46663 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46664 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46665 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46666 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46667 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46668 +4 4 4 4 4 4
46669 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46670 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46671 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46672 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46673 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46674 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46675 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46676 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46677 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46678 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46679 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46680 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46681 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46682 +4 4 4 4 4 4
46683 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46684 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46685 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46686 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46687 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46688 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46689 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46690 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46691 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46692 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46693 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46694 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46695 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46696 +4 4 4 4 4 4
46697 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46698 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46699 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46700 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46701 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46702 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46703 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46704 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46705 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46706 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46707 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46708 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46709 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46710 +4 4 4 4 4 4
46711 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46712 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46713 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46714 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46715 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46716 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46717 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46718 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46719 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46720 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46721 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46722 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46723 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46724 +4 4 4 4 4 4
46725 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46726 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46727 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46728 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46729 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46730 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46731 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46732 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46733 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46734 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46735 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46736 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46737 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46738 +4 4 4 4 4 4
46739 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46740 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46741 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46742 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46743 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
46744 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
46745 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46746 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46747 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46748 +4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
46749 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46750 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
46751 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46752 +4 4 4 4 4 4
46753 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46754 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46755 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46756 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46757 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
46758 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
46759 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46760 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46761 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46762 +4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
46763 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
46764 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
46765 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46766 +4 4 4 4 4 4
46767 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46768 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46769 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46770 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46771 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
46772 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
46773 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46774 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46775 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46776 +4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
46777 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
46778 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
46779 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
46780 +4 4 4 4 4 4
46781 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46782 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46783 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46784 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
46785 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
46786 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
46787 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
46788 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46789 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
46790 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
46791 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
46792 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
46793 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
46794 +4 4 4 4 4 4
46795 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46796 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46797 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46798 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
46799 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
46800 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
46801 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
46802 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
46803 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
46804 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
46805 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
46806 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
46807 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
46808 +4 4 4 4 4 4
46809 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46810 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46811 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
46812 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
46813 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
46814 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
46815 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
46816 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
46817 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
46818 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
46819 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
46820 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
46821 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
46822 +4 4 4 4 4 4
46823 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46824 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46825 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
46826 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
46827 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
46828 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
46829 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
46830 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
46831 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
46832 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
46833 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
46834 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
46835 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
46836 +4 4 4 4 4 4
46837 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46838 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46839 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
46840 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
46841 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
46842 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
46843 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
46844 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
46845 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
46846 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
46847 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
46848 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
46849 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
46850 +4 4 4 4 4 4
46851 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46852 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
46853 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
46854 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
46855 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
46856 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
46857 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
46858 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
46859 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
46860 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
46861 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
46862 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
46863 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
46864 +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 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
46868 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
46869 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
46870 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
46871 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
46872 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
46873 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
46874 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
46875 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
46876 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
46877 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
46878 +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 3 3 3 0 0 0
46881 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
46882 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
46883 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
46884 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
46885 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
46886 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
46887 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
46888 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
46889 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
46890 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
46891 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
46892 +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 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
46895 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
46896 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
46897 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
46898 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
46899 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
46900 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
46901 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
46902 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
46903 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
46904 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
46905 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
46906 +0 0 0 4 4 4
46907 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
46908 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
46909 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
46910 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
46911 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
46912 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
46913 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
46914 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
46915 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
46916 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
46917 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
46918 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
46919 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
46920 +2 0 0 0 0 0
46921 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
46922 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
46923 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
46924 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
46925 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
46926 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
46927 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
46928 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
46929 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
46930 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
46931 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
46932 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
46933 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
46934 +37 38 37 0 0 0
46935 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
46936 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
46937 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
46938 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
46939 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
46940 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
46941 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
46942 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
46943 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
46944 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
46945 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
46946 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
46947 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
46948 +85 115 134 4 0 0
46949 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
46950 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
46951 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
46952 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
46953 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
46954 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
46955 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
46956 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
46957 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
46958 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
46959 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
46960 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
46961 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
46962 +60 73 81 4 0 0
46963 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
46964 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
46965 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
46966 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
46967 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
46968 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
46969 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
46970 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
46971 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
46972 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
46973 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
46974 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
46975 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
46976 +16 19 21 4 0 0
46977 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
46978 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
46979 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
46980 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
46981 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
46982 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
46983 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
46984 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
46985 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
46986 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
46987 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
46988 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
46989 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
46990 +4 0 0 4 3 3
46991 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
46992 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
46993 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
46994 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
46995 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
46996 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
46997 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
46998 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
46999 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
47000 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
47001 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
47002 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
47003 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
47004 +3 2 2 4 4 4
47005 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
47006 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
47007 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
47008 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
47009 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
47010 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
47011 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
47012 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
47013 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
47014 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
47015 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
47016 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
47017 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
47018 +4 4 4 4 4 4
47019 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
47020 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
47021 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
47022 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
47023 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
47024 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
47025 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
47026 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
47027 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
47028 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
47029 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
47030 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
47031 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
47032 +4 4 4 4 4 4
47033 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
47034 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
47035 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
47036 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
47037 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
47038 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
47039 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
47040 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
47041 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
47042 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
47043 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
47044 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
47045 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
47046 +5 5 5 5 5 5
47047 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
47048 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
47049 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
47050 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
47051 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
47052 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47053 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
47054 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
47055 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
47056 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
47057 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
47058 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
47059 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
47060 +5 5 5 4 4 4
47061 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
47062 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
47063 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
47064 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
47065 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47066 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
47067 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
47068 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
47069 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
47070 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
47071 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
47072 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
47073 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47074 +4 4 4 4 4 4
47075 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
47076 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
47077 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
47078 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
47079 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
47080 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47081 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47082 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
47083 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
47084 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
47085 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
47086 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
47087 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47088 +4 4 4 4 4 4
47089 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
47090 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
47091 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
47092 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
47093 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47094 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
47095 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
47096 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
47097 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
47098 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
47099 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
47100 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47101 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47102 +4 4 4 4 4 4
47103 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
47104 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
47105 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
47106 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
47107 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47108 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47109 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
47110 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
47111 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
47112 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
47113 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
47114 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47115 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47116 +4 4 4 4 4 4
47117 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
47118 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
47119 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
47120 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
47121 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47122 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
47123 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
47124 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
47125 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
47126 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
47127 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47128 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47129 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47130 +4 4 4 4 4 4
47131 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
47132 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
47133 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
47134 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
47135 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
47136 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
47137 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
47138 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
47139 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
47140 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
47141 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
47142 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47143 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47144 +4 4 4 4 4 4
47145 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
47146 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
47147 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
47148 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
47149 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
47150 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
47151 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
47152 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
47153 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
47154 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
47155 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
47156 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47157 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47158 +4 4 4 4 4 4
47159 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
47160 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
47161 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
47162 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
47163 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
47164 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
47165 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
47166 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
47167 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
47168 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
47169 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47170 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47171 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47172 +4 4 4 4 4 4
47173 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
47174 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
47175 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
47176 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
47177 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47178 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
47179 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
47180 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
47181 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
47182 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
47183 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47184 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47185 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47186 +4 4 4 4 4 4
47187 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
47188 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
47189 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
47190 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
47191 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47192 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
47193 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
47194 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
47195 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
47196 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
47197 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47198 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47199 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47200 +4 4 4 4 4 4
47201 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
47202 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
47203 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
47204 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
47205 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47206 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
47207 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
47208 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
47209 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
47210 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47211 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47212 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47213 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47214 +4 4 4 4 4 4
47215 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
47216 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
47217 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
47218 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
47219 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
47220 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
47221 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
47222 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
47223 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47224 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47225 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47226 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47227 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47228 +4 4 4 4 4 4
47229 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
47230 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
47231 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
47232 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
47233 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47234 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
47235 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
47236 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
47237 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47238 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47239 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47240 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47241 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47242 +4 4 4 4 4 4
47243 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
47244 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
47245 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
47246 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
47247 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
47248 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
47249 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
47250 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
47251 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47252 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47253 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47254 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47255 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47256 +4 4 4 4 4 4
47257 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
47258 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
47259 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47260 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
47261 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
47262 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
47263 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
47264 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
47265 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
47266 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47267 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47268 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47269 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47270 +4 4 4 4 4 4
47271 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
47272 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
47273 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
47274 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
47275 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
47276 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
47277 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
47278 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
47279 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47280 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47281 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47282 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47283 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47284 +4 4 4 4 4 4
47285 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
47286 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
47287 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47288 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
47289 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
47290 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
47291 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
47292 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
47293 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
47294 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47295 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47296 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47297 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47298 +4 4 4 4 4 4
47299 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
47300 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
47301 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
47302 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
47303 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
47304 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
47305 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
47306 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
47307 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47308 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47309 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47310 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47311 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47312 +4 4 4 4 4 4
47313 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47314 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
47315 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
47316 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
47317 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
47318 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
47319 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
47320 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
47321 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47322 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47323 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47324 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47325 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47326 +4 4 4 4 4 4
47327 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
47328 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
47329 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
47330 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
47331 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
47332 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
47333 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47334 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
47335 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
47336 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47337 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47338 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47339 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47340 +4 4 4 4 4 4
47341 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47342 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
47343 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
47344 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
47345 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
47346 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
47347 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
47348 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
47349 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
47350 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47351 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47352 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47353 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47354 +4 4 4 4 4 4
47355 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
47356 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
47357 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
47358 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
47359 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
47360 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
47361 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
47362 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
47363 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
47364 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47365 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47366 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47367 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47368 +4 4 4 4 4 4
47369 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47370 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
47371 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
47372 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
47373 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
47374 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
47375 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
47376 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
47377 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
47378 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47379 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47380 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47381 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47382 +4 4 4 4 4 4
47383 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
47384 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
47385 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
47386 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
47387 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
47388 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
47389 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
47390 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
47391 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
47392 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47393 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47394 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47395 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47396 +4 4 4 4 4 4
47397 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
47398 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
47399 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
47400 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
47401 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
47402 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
47403 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
47404 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
47405 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
47406 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
47407 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47408 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47409 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47410 +4 4 4 4 4 4
47411 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
47412 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
47413 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
47414 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
47415 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
47416 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
47417 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
47418 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
47419 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
47420 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
47421 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47422 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47423 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47424 +4 4 4 4 4 4
47425 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
47426 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
47427 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
47428 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
47429 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
47430 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
47431 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
47432 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
47433 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
47434 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
47435 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47436 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47437 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47438 +4 4 4 4 4 4
47439 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
47440 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
47441 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
47442 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
47443 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
47444 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
47445 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47446 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
47447 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
47448 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
47449 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47450 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47451 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47452 +4 4 4 4 4 4
47453 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
47454 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
47455 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
47456 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
47457 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
47458 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
47459 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
47460 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
47461 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
47462 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
47463 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47464 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47465 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47466 +4 4 4 4 4 4
47467 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
47468 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
47469 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
47470 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
47471 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
47472 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
47473 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
47474 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
47475 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
47476 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
47477 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47478 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47479 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47480 +4 4 4 4 4 4
47481 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47482 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
47483 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
47484 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
47485 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
47486 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
47487 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
47488 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
47489 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
47490 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
47491 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47492 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47493 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47494 +4 4 4 4 4 4
47495 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
47496 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
47497 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
47498 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
47499 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
47500 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
47501 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
47502 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
47503 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
47504 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
47505 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47506 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47507 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47508 +4 4 4 4 4 4
47509 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
47510 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
47511 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
47512 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
47513 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
47514 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
47515 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
47516 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
47517 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
47518 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47519 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47520 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47521 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47522 +4 4 4 4 4 4
47523 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
47524 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47525 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
47526 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
47527 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
47528 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
47529 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
47530 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
47531 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
47532 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47533 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47534 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47535 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47536 +4 4 4 4 4 4
47537 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
47538 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
47539 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
47540 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
47541 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
47542 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
47543 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
47544 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
47545 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
47546 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47547 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47548 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47549 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47550 +4 4 4 4 4 4
47551 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
47552 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
47553 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
47554 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
47555 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
47556 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
47557 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
47558 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
47559 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47560 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47561 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47562 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47563 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47564 +4 4 4 4 4 4
47565 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
47566 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
47567 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
47568 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
47569 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
47570 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
47571 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
47572 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
47573 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47574 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47575 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47576 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47577 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47578 +4 4 4 4 4 4
47579 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
47580 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
47581 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
47582 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
47583 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
47584 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
47585 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
47586 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
47587 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47588 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47589 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47590 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47591 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47592 +4 4 4 4 4 4
47593 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47594 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
47595 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47596 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
47597 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
47598 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
47599 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
47600 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
47601 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47602 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47603 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47604 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47605 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47606 +4 4 4 4 4 4
47607 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47608 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
47609 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
47610 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
47611 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
47612 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
47613 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
47614 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
47615 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47616 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47617 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47618 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47619 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47620 +4 4 4 4 4 4
47621 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47622 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
47623 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
47624 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47625 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
47626 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
47627 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
47628 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47629 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47630 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47631 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47632 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47633 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47634 +4 4 4 4 4 4
47635 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47636 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47637 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47638 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
47639 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
47640 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
47641 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
47642 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
47643 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47644 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47645 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47646 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47647 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47648 +4 4 4 4 4 4
47649 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47650 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47651 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
47652 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47653 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
47654 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
47655 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
47656 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47657 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47658 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47659 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47660 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47661 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47662 +4 4 4 4 4 4
47663 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47664 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47665 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47666 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
47667 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
47668 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
47669 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
47670 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47671 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47672 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47673 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47674 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47675 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47676 +4 4 4 4 4 4
47677 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47678 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47679 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47680 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
47681 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
47682 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
47683 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
47684 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47685 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47686 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47687 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47688 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47689 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47690 +4 4 4 4 4 4
47691 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47692 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47693 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47694 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
47695 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
47696 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
47697 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
47698 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47699 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47700 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47701 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47702 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47703 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47704 +4 4 4 4 4 4
47705 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47706 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47707 +4 4 4 4 4 4 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 5 5 5
47709 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
47710 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
47711 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
47712 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47713 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47714 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47715 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47716 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47717 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47718 +4 4 4 4 4 4
47719 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47720 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47721 +4 4 4 4 4 4 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 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
47724 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
47725 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
47726 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47727 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47728 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47729 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47730 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47731 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47732 +4 4 4 4 4 4
47733 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47734 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47735 +4 4 4 4 4 4 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 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
47738 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
47739 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47740 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47741 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47742 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47743 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47744 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47745 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47746 +4 4 4 4 4 4
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 5 5 5 4 3 3 6 6 6
47752 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
47753 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47754 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47755 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47756 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47757 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47758 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47759 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47760 +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 5 5 5 4 3 3
47766 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
47767 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47768 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47769 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47770 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47771 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47772 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47773 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
47774 +4 4 4 4 4 4
47775 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
47776 index fe92eed..106e085 100644
47777 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
47778 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
47779 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
47780 struct mb862xxfb_par *par = info->par;
47781
47782 if (info->var.bits_per_pixel == 32) {
47783 - info->fbops->fb_fillrect = cfb_fillrect;
47784 - info->fbops->fb_copyarea = cfb_copyarea;
47785 - info->fbops->fb_imageblit = cfb_imageblit;
47786 + pax_open_kernel();
47787 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47788 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47789 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47790 + pax_close_kernel();
47791 } else {
47792 outreg(disp, GC_L0EM, 3);
47793 - info->fbops->fb_fillrect = mb86290fb_fillrect;
47794 - info->fbops->fb_copyarea = mb86290fb_copyarea;
47795 - info->fbops->fb_imageblit = mb86290fb_imageblit;
47796 + pax_open_kernel();
47797 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
47798 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
47799 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
47800 + pax_close_kernel();
47801 }
47802 outreg(draw, GDC_REG_DRAW_BASE, 0);
47803 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
47804 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
47805 index ff22871..b129bed 100644
47806 --- a/drivers/video/nvidia/nvidia.c
47807 +++ b/drivers/video/nvidia/nvidia.c
47808 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
47809 info->fix.line_length = (info->var.xres_virtual *
47810 info->var.bits_per_pixel) >> 3;
47811 if (info->var.accel_flags) {
47812 - info->fbops->fb_imageblit = nvidiafb_imageblit;
47813 - info->fbops->fb_fillrect = nvidiafb_fillrect;
47814 - info->fbops->fb_copyarea = nvidiafb_copyarea;
47815 - info->fbops->fb_sync = nvidiafb_sync;
47816 + pax_open_kernel();
47817 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
47818 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
47819 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
47820 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
47821 + pax_close_kernel();
47822 info->pixmap.scan_align = 4;
47823 info->flags &= ~FBINFO_HWACCEL_DISABLED;
47824 info->flags |= FBINFO_READS_FAST;
47825 NVResetGraphics(info);
47826 } else {
47827 - info->fbops->fb_imageblit = cfb_imageblit;
47828 - info->fbops->fb_fillrect = cfb_fillrect;
47829 - info->fbops->fb_copyarea = cfb_copyarea;
47830 - info->fbops->fb_sync = NULL;
47831 + pax_open_kernel();
47832 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
47833 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
47834 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
47835 + *(void **)&info->fbops->fb_sync = NULL;
47836 + pax_close_kernel();
47837 info->pixmap.scan_align = 1;
47838 info->flags |= FBINFO_HWACCEL_DISABLED;
47839 info->flags &= ~FBINFO_READS_FAST;
47840 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
47841 info->pixmap.size = 8 * 1024;
47842 info->pixmap.flags = FB_PIXMAP_SYSTEM;
47843
47844 - if (!hwcur)
47845 - info->fbops->fb_cursor = NULL;
47846 + if (!hwcur) {
47847 + pax_open_kernel();
47848 + *(void **)&info->fbops->fb_cursor = NULL;
47849 + pax_close_kernel();
47850 + }
47851
47852 info->var.accel_flags = (!noaccel);
47853
47854 diff --git a/drivers/video/output.c b/drivers/video/output.c
47855 index 0d6f2cd..6285b97 100644
47856 --- a/drivers/video/output.c
47857 +++ b/drivers/video/output.c
47858 @@ -97,7 +97,7 @@ struct output_device *video_output_register(const char *name,
47859 new_dev->props = op;
47860 new_dev->dev.class = &video_output_class;
47861 new_dev->dev.parent = dev;
47862 - dev_set_name(&new_dev->dev, name);
47863 + dev_set_name(&new_dev->dev, "%s", name);
47864 dev_set_drvdata(&new_dev->dev, devdata);
47865 ret_code = device_register(&new_dev->dev);
47866 if (ret_code) {
47867 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
47868 index 05c2dc3..ea1f391 100644
47869 --- a/drivers/video/s1d13xxxfb.c
47870 +++ b/drivers/video/s1d13xxxfb.c
47871 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
47872
47873 switch(prod_id) {
47874 case S1D13506_PROD_ID: /* activate acceleration */
47875 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
47876 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
47877 + pax_open_kernel();
47878 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
47879 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
47880 + pax_close_kernel();
47881 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
47882 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
47883 break;
47884 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
47885 index b2b33fc..f9f4658 100644
47886 --- a/drivers/video/smscufx.c
47887 +++ b/drivers/video/smscufx.c
47888 @@ -1175,7 +1175,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
47889 fb_deferred_io_cleanup(info);
47890 kfree(info->fbdefio);
47891 info->fbdefio = NULL;
47892 - info->fbops->fb_mmap = ufx_ops_mmap;
47893 + pax_open_kernel();
47894 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
47895 + pax_close_kernel();
47896 }
47897
47898 pr_debug("released /dev/fb%d user=%d count=%d",
47899 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
47900 index ec03e72..f578436 100644
47901 --- a/drivers/video/udlfb.c
47902 +++ b/drivers/video/udlfb.c
47903 @@ -623,11 +623,11 @@ int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
47904 dlfb_urb_completion(urb);
47905
47906 error:
47907 - atomic_add(bytes_sent, &dev->bytes_sent);
47908 - atomic_add(bytes_identical, &dev->bytes_identical);
47909 - atomic_add(width*height*2, &dev->bytes_rendered);
47910 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
47911 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
47912 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
47913 end_cycles = get_cycles();
47914 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
47915 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
47916 >> 10)), /* Kcycles */
47917 &dev->cpu_kcycles_used);
47918
47919 @@ -748,11 +748,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
47920 dlfb_urb_completion(urb);
47921
47922 error:
47923 - atomic_add(bytes_sent, &dev->bytes_sent);
47924 - atomic_add(bytes_identical, &dev->bytes_identical);
47925 - atomic_add(bytes_rendered, &dev->bytes_rendered);
47926 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
47927 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
47928 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
47929 end_cycles = get_cycles();
47930 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
47931 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
47932 >> 10)), /* Kcycles */
47933 &dev->cpu_kcycles_used);
47934 }
47935 @@ -993,7 +993,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
47936 fb_deferred_io_cleanup(info);
47937 kfree(info->fbdefio);
47938 info->fbdefio = NULL;
47939 - info->fbops->fb_mmap = dlfb_ops_mmap;
47940 + pax_open_kernel();
47941 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
47942 + pax_close_kernel();
47943 }
47944
47945 pr_warn("released /dev/fb%d user=%d count=%d\n",
47946 @@ -1376,7 +1378,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
47947 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47948 struct dlfb_data *dev = fb_info->par;
47949 return snprintf(buf, PAGE_SIZE, "%u\n",
47950 - atomic_read(&dev->bytes_rendered));
47951 + atomic_read_unchecked(&dev->bytes_rendered));
47952 }
47953
47954 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
47955 @@ -1384,7 +1386,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
47956 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47957 struct dlfb_data *dev = fb_info->par;
47958 return snprintf(buf, PAGE_SIZE, "%u\n",
47959 - atomic_read(&dev->bytes_identical));
47960 + atomic_read_unchecked(&dev->bytes_identical));
47961 }
47962
47963 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
47964 @@ -1392,7 +1394,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
47965 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47966 struct dlfb_data *dev = fb_info->par;
47967 return snprintf(buf, PAGE_SIZE, "%u\n",
47968 - atomic_read(&dev->bytes_sent));
47969 + atomic_read_unchecked(&dev->bytes_sent));
47970 }
47971
47972 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
47973 @@ -1400,7 +1402,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
47974 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47975 struct dlfb_data *dev = fb_info->par;
47976 return snprintf(buf, PAGE_SIZE, "%u\n",
47977 - atomic_read(&dev->cpu_kcycles_used));
47978 + atomic_read_unchecked(&dev->cpu_kcycles_used));
47979 }
47980
47981 static ssize_t edid_show(
47982 @@ -1460,10 +1462,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
47983 struct fb_info *fb_info = dev_get_drvdata(fbdev);
47984 struct dlfb_data *dev = fb_info->par;
47985
47986 - atomic_set(&dev->bytes_rendered, 0);
47987 - atomic_set(&dev->bytes_identical, 0);
47988 - atomic_set(&dev->bytes_sent, 0);
47989 - atomic_set(&dev->cpu_kcycles_used, 0);
47990 + atomic_set_unchecked(&dev->bytes_rendered, 0);
47991 + atomic_set_unchecked(&dev->bytes_identical, 0);
47992 + atomic_set_unchecked(&dev->bytes_sent, 0);
47993 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
47994
47995 return count;
47996 }
47997 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
47998 index e328a61..1b08ecb 100644
47999 --- a/drivers/video/uvesafb.c
48000 +++ b/drivers/video/uvesafb.c
48001 @@ -19,6 +19,7 @@
48002 #include <linux/io.h>
48003 #include <linux/mutex.h>
48004 #include <linux/slab.h>
48005 +#include <linux/moduleloader.h>
48006 #include <video/edid.h>
48007 #include <video/uvesafb.h>
48008 #ifdef CONFIG_X86
48009 @@ -569,10 +570,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
48010 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
48011 par->pmi_setpal = par->ypan = 0;
48012 } else {
48013 +
48014 +#ifdef CONFIG_PAX_KERNEXEC
48015 +#ifdef CONFIG_MODULES
48016 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
48017 +#endif
48018 + if (!par->pmi_code) {
48019 + par->pmi_setpal = par->ypan = 0;
48020 + return 0;
48021 + }
48022 +#endif
48023 +
48024 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
48025 + task->t.regs.edi);
48026 +
48027 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48028 + pax_open_kernel();
48029 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
48030 + pax_close_kernel();
48031 +
48032 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
48033 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
48034 +#else
48035 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
48036 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
48037 +#endif
48038 +
48039 printk(KERN_INFO "uvesafb: protected mode interface info at "
48040 "%04x:%04x\n",
48041 (u16)task->t.regs.es, (u16)task->t.regs.edi);
48042 @@ -817,13 +840,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
48043 par->ypan = ypan;
48044
48045 if (par->pmi_setpal || par->ypan) {
48046 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
48047 if (__supported_pte_mask & _PAGE_NX) {
48048 par->pmi_setpal = par->ypan = 0;
48049 printk(KERN_WARNING "uvesafb: NX protection is actively."
48050 "We have better not to use the PMI.\n");
48051 - } else {
48052 + } else
48053 +#endif
48054 uvesafb_vbe_getpmi(task, par);
48055 - }
48056 }
48057 #else
48058 /* The protected mode interface is not available on non-x86. */
48059 @@ -1457,8 +1481,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
48060 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
48061
48062 /* Disable blanking if the user requested so. */
48063 - if (!blank)
48064 - info->fbops->fb_blank = NULL;
48065 + if (!blank) {
48066 + pax_open_kernel();
48067 + *(void **)&info->fbops->fb_blank = NULL;
48068 + pax_close_kernel();
48069 + }
48070
48071 /*
48072 * Find out how much IO memory is required for the mode with
48073 @@ -1534,8 +1561,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
48074 info->flags = FBINFO_FLAG_DEFAULT |
48075 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
48076
48077 - if (!par->ypan)
48078 - info->fbops->fb_pan_display = NULL;
48079 + if (!par->ypan) {
48080 + pax_open_kernel();
48081 + *(void **)&info->fbops->fb_pan_display = NULL;
48082 + pax_close_kernel();
48083 + }
48084 }
48085
48086 static void uvesafb_init_mtrr(struct fb_info *info)
48087 @@ -1836,6 +1866,11 @@ out:
48088 if (par->vbe_modes)
48089 kfree(par->vbe_modes);
48090
48091 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48092 + if (par->pmi_code)
48093 + module_free_exec(NULL, par->pmi_code);
48094 +#endif
48095 +
48096 framebuffer_release(info);
48097 return err;
48098 }
48099 @@ -1862,6 +1897,12 @@ static int uvesafb_remove(struct platform_device *dev)
48100 kfree(par->vbe_state_orig);
48101 if (par->vbe_state_saved)
48102 kfree(par->vbe_state_saved);
48103 +
48104 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48105 + if (par->pmi_code)
48106 + module_free_exec(NULL, par->pmi_code);
48107 +#endif
48108 +
48109 }
48110
48111 framebuffer_release(info);
48112 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
48113 index 501b340..d80aa17 100644
48114 --- a/drivers/video/vesafb.c
48115 +++ b/drivers/video/vesafb.c
48116 @@ -9,6 +9,7 @@
48117 */
48118
48119 #include <linux/module.h>
48120 +#include <linux/moduleloader.h>
48121 #include <linux/kernel.h>
48122 #include <linux/errno.h>
48123 #include <linux/string.h>
48124 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
48125 static int vram_total __initdata; /* Set total amount of memory */
48126 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
48127 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
48128 -static void (*pmi_start)(void) __read_mostly;
48129 -static void (*pmi_pal) (void) __read_mostly;
48130 +static void (*pmi_start)(void) __read_only;
48131 +static void (*pmi_pal) (void) __read_only;
48132 static int depth __read_mostly;
48133 static int vga_compat __read_mostly;
48134 /* --------------------------------------------------------------------- */
48135 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
48136 unsigned int size_vmode;
48137 unsigned int size_remap;
48138 unsigned int size_total;
48139 + void *pmi_code = NULL;
48140
48141 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
48142 return -ENODEV;
48143 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
48144 size_remap = size_total;
48145 vesafb_fix.smem_len = size_remap;
48146
48147 -#ifndef __i386__
48148 - screen_info.vesapm_seg = 0;
48149 -#endif
48150 -
48151 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
48152 printk(KERN_WARNING
48153 "vesafb: cannot reserve video memory at 0x%lx\n",
48154 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
48155 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
48156 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
48157
48158 +#ifdef __i386__
48159 +
48160 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48161 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
48162 + if (!pmi_code)
48163 +#elif !defined(CONFIG_PAX_KERNEXEC)
48164 + if (0)
48165 +#endif
48166 +
48167 +#endif
48168 + screen_info.vesapm_seg = 0;
48169 +
48170 if (screen_info.vesapm_seg) {
48171 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
48172 - screen_info.vesapm_seg,screen_info.vesapm_off);
48173 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
48174 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
48175 }
48176
48177 if (screen_info.vesapm_seg < 0xc000)
48178 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
48179
48180 if (ypan || pmi_setpal) {
48181 unsigned short *pmi_base;
48182 +
48183 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
48184 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
48185 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
48186 +
48187 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48188 + pax_open_kernel();
48189 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
48190 +#else
48191 + pmi_code = pmi_base;
48192 +#endif
48193 +
48194 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
48195 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
48196 +
48197 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48198 + pmi_start = ktva_ktla(pmi_start);
48199 + pmi_pal = ktva_ktla(pmi_pal);
48200 + pax_close_kernel();
48201 +#endif
48202 +
48203 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
48204 if (pmi_base[3]) {
48205 printk(KERN_INFO "vesafb: pmi: ports = ");
48206 @@ -472,8 +498,11 @@ static int __init vesafb_probe(struct platform_device *dev)
48207 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
48208 (ypan ? FBINFO_HWACCEL_YPAN : 0);
48209
48210 - if (!ypan)
48211 - info->fbops->fb_pan_display = NULL;
48212 + if (!ypan) {
48213 + pax_open_kernel();
48214 + *(void **)&info->fbops->fb_pan_display = NULL;
48215 + pax_close_kernel();
48216 + }
48217
48218 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
48219 err = -ENOMEM;
48220 @@ -488,6 +517,11 @@ static int __init vesafb_probe(struct platform_device *dev)
48221 info->node, info->fix.id);
48222 return 0;
48223 err:
48224 +
48225 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
48226 + module_free_exec(NULL, pmi_code);
48227 +#endif
48228 +
48229 if (info->screen_base)
48230 iounmap(info->screen_base);
48231 framebuffer_release(info);
48232 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
48233 index 88714ae..16c2e11 100644
48234 --- a/drivers/video/via/via_clock.h
48235 +++ b/drivers/video/via/via_clock.h
48236 @@ -56,7 +56,7 @@ struct via_clock {
48237
48238 void (*set_engine_pll_state)(u8 state);
48239 void (*set_engine_pll)(struct via_pll_config config);
48240 -};
48241 +} __no_const;
48242
48243
48244 static inline u32 get_pll_internal_frequency(u32 ref_freq,
48245 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
48246 index fef20db..d28b1ab 100644
48247 --- a/drivers/xen/xenfs/xenstored.c
48248 +++ b/drivers/xen/xenfs/xenstored.c
48249 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
48250 static int xsd_kva_open(struct inode *inode, struct file *file)
48251 {
48252 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
48253 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48254 + NULL);
48255 +#else
48256 xen_store_interface);
48257 +#endif
48258 +
48259 if (!file->private_data)
48260 return -ENOMEM;
48261 return 0;
48262 diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
48263 index 055562c..fdfb10d 100644
48264 --- a/fs/9p/vfs_addr.c
48265 +++ b/fs/9p/vfs_addr.c
48266 @@ -186,7 +186,7 @@ static int v9fs_vfs_writepage_locked(struct page *page)
48267
48268 retval = v9fs_file_write_internal(inode,
48269 v9inode->writeback_fid,
48270 - (__force const char __user *)buffer,
48271 + (const char __force_user *)buffer,
48272 len, &offset, 0);
48273 if (retval > 0)
48274 retval = 0;
48275 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
48276 index d86edc8..40ff2fb 100644
48277 --- a/fs/9p/vfs_inode.c
48278 +++ b/fs/9p/vfs_inode.c
48279 @@ -1314,7 +1314,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
48280 void
48281 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
48282 {
48283 - char *s = nd_get_link(nd);
48284 + const char *s = nd_get_link(nd);
48285
48286 p9_debug(P9_DEBUG_VFS, " %s %s\n",
48287 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
48288 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
48289 index 370b24c..ff0be7b 100644
48290 --- a/fs/Kconfig.binfmt
48291 +++ b/fs/Kconfig.binfmt
48292 @@ -103,7 +103,7 @@ config HAVE_AOUT
48293
48294 config BINFMT_AOUT
48295 tristate "Kernel support for a.out and ECOFF binaries"
48296 - depends on HAVE_AOUT
48297 + depends on HAVE_AOUT && BROKEN
48298 ---help---
48299 A.out (Assembler.OUTput) is a set of formats for libraries and
48300 executables used in the earliest versions of UNIX. Linux used
48301 diff --git a/fs/aio.c b/fs/aio.c
48302 index 2bbcacf..8614116 100644
48303 --- a/fs/aio.c
48304 +++ b/fs/aio.c
48305 @@ -160,7 +160,7 @@ static int aio_setup_ring(struct kioctx *ctx)
48306 size += sizeof(struct io_event) * nr_events;
48307 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
48308
48309 - if (nr_pages < 0)
48310 + if (nr_pages <= 0)
48311 return -EINVAL;
48312
48313 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
48314 @@ -950,6 +950,7 @@ static ssize_t aio_rw_vect_retry(struct kiocb *iocb, int rw, aio_rw_op *rw_op)
48315 static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat)
48316 {
48317 ssize_t ret;
48318 + struct iovec iovstack;
48319
48320 kiocb->ki_nr_segs = kiocb->ki_nbytes;
48321
48322 @@ -957,17 +958,22 @@ static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat)
48323 if (compat)
48324 ret = compat_rw_copy_check_uvector(rw,
48325 (struct compat_iovec __user *)kiocb->ki_buf,
48326 - kiocb->ki_nr_segs, 1, &kiocb->ki_inline_vec,
48327 + kiocb->ki_nr_segs, 1, &iovstack,
48328 &kiocb->ki_iovec);
48329 else
48330 #endif
48331 ret = rw_copy_check_uvector(rw,
48332 (struct iovec __user *)kiocb->ki_buf,
48333 - kiocb->ki_nr_segs, 1, &kiocb->ki_inline_vec,
48334 + kiocb->ki_nr_segs, 1, &iovstack,
48335 &kiocb->ki_iovec);
48336 if (ret < 0)
48337 return ret;
48338
48339 + if (kiocb->ki_iovec == &iovstack) {
48340 + kiocb->ki_inline_vec = iovstack;
48341 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
48342 + }
48343 +
48344 /* ki_nbytes now reflect bytes instead of segs */
48345 kiocb->ki_nbytes = ret;
48346 return 0;
48347 diff --git a/fs/attr.c b/fs/attr.c
48348 index 1449adb..a2038c2 100644
48349 --- a/fs/attr.c
48350 +++ b/fs/attr.c
48351 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
48352 unsigned long limit;
48353
48354 limit = rlimit(RLIMIT_FSIZE);
48355 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
48356 if (limit != RLIM_INFINITY && offset > limit)
48357 goto out_sig;
48358 if (offset > inode->i_sb->s_maxbytes)
48359 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
48360 index 3db70da..7aeec5b 100644
48361 --- a/fs/autofs4/waitq.c
48362 +++ b/fs/autofs4/waitq.c
48363 @@ -59,7 +59,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
48364 {
48365 unsigned long sigpipe, flags;
48366 mm_segment_t fs;
48367 - const char *data = (const char *)addr;
48368 + const char __user *data = (const char __force_user *)addr;
48369 ssize_t wr = 0;
48370
48371 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
48372 @@ -346,6 +346,10 @@ static int validate_request(struct autofs_wait_queue **wait,
48373 return 1;
48374 }
48375
48376 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48377 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
48378 +#endif
48379 +
48380 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
48381 enum autofs_notify notify)
48382 {
48383 @@ -379,7 +383,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
48384
48385 /* If this is a direct mount request create a dummy name */
48386 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
48387 +#ifdef CONFIG_GRKERNSEC_HIDESYM
48388 + /* this name does get written to userland via autofs4_write() */
48389 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
48390 +#else
48391 qstr.len = sprintf(name, "%p", dentry);
48392 +#endif
48393 else {
48394 qstr.len = autofs4_getpath(sbi, dentry, &name);
48395 if (!qstr.len) {
48396 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
48397 index 2722387..c8dd2a7 100644
48398 --- a/fs/befs/endian.h
48399 +++ b/fs/befs/endian.h
48400 @@ -11,7 +11,7 @@
48401
48402 #include <asm/byteorder.h>
48403
48404 -static inline u64
48405 +static inline u64 __intentional_overflow(-1)
48406 fs64_to_cpu(const struct super_block *sb, fs64 n)
48407 {
48408 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
48409 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
48410 return (__force fs64)cpu_to_be64(n);
48411 }
48412
48413 -static inline u32
48414 +static inline u32 __intentional_overflow(-1)
48415 fs32_to_cpu(const struct super_block *sb, fs32 n)
48416 {
48417 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
48418 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
48419 index f95dddc..b1e2c1c 100644
48420 --- a/fs/befs/linuxvfs.c
48421 +++ b/fs/befs/linuxvfs.c
48422 @@ -510,7 +510,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
48423 {
48424 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
48425 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
48426 - char *link = nd_get_link(nd);
48427 + const char *link = nd_get_link(nd);
48428 if (!IS_ERR(link))
48429 kfree(link);
48430 }
48431 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
48432 index bce8769..7fc7544 100644
48433 --- a/fs/binfmt_aout.c
48434 +++ b/fs/binfmt_aout.c
48435 @@ -16,6 +16,7 @@
48436 #include <linux/string.h>
48437 #include <linux/fs.h>
48438 #include <linux/file.h>
48439 +#include <linux/security.h>
48440 #include <linux/stat.h>
48441 #include <linux/fcntl.h>
48442 #include <linux/ptrace.h>
48443 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
48444 #endif
48445 # define START_STACK(u) ((void __user *)u.start_stack)
48446
48447 + memset(&dump, 0, sizeof(dump));
48448 +
48449 fs = get_fs();
48450 set_fs(KERNEL_DS);
48451 has_dumped = 1;
48452 @@ -69,10 +72,12 @@ static int aout_core_dump(struct coredump_params *cprm)
48453
48454 /* If the size of the dump file exceeds the rlimit, then see what would happen
48455 if we wrote the stack, but not the data area. */
48456 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
48457 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
48458 dump.u_dsize = 0;
48459
48460 /* Make sure we have enough room to write the stack and data areas. */
48461 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
48462 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
48463 dump.u_ssize = 0;
48464
48465 @@ -233,6 +238,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
48466 rlim = rlimit(RLIMIT_DATA);
48467 if (rlim >= RLIM_INFINITY)
48468 rlim = ~0;
48469 +
48470 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
48471 if (ex.a_data + ex.a_bss > rlim)
48472 return -ENOMEM;
48473
48474 @@ -267,6 +274,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
48475
48476 install_exec_creds(bprm);
48477
48478 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48479 + current->mm->pax_flags = 0UL;
48480 +#endif
48481 +
48482 +#ifdef CONFIG_PAX_PAGEEXEC
48483 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
48484 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
48485 +
48486 +#ifdef CONFIG_PAX_EMUTRAMP
48487 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
48488 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
48489 +#endif
48490 +
48491 +#ifdef CONFIG_PAX_MPROTECT
48492 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
48493 + current->mm->pax_flags |= MF_PAX_MPROTECT;
48494 +#endif
48495 +
48496 + }
48497 +#endif
48498 +
48499 if (N_MAGIC(ex) == OMAGIC) {
48500 unsigned long text_addr, map_size;
48501 loff_t pos;
48502 @@ -324,7 +352,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
48503 }
48504
48505 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
48506 - PROT_READ | PROT_WRITE | PROT_EXEC,
48507 + PROT_READ | PROT_WRITE,
48508 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
48509 fd_offset + ex.a_text);
48510 if (error != N_DATADDR(ex)) {
48511 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
48512 index f8a0b0e..8186af0 100644
48513 --- a/fs/binfmt_elf.c
48514 +++ b/fs/binfmt_elf.c
48515 @@ -34,6 +34,7 @@
48516 #include <linux/utsname.h>
48517 #include <linux/coredump.h>
48518 #include <linux/sched.h>
48519 +#include <linux/xattr.h>
48520 #include <asm/uaccess.h>
48521 #include <asm/param.h>
48522 #include <asm/page.h>
48523 @@ -60,6 +61,10 @@ static int elf_core_dump(struct coredump_params *cprm);
48524 #define elf_core_dump NULL
48525 #endif
48526
48527 +#ifdef CONFIG_PAX_MPROTECT
48528 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
48529 +#endif
48530 +
48531 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
48532 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
48533 #else
48534 @@ -79,6 +84,11 @@ static struct linux_binfmt elf_format = {
48535 .load_binary = load_elf_binary,
48536 .load_shlib = load_elf_library,
48537 .core_dump = elf_core_dump,
48538 +
48539 +#ifdef CONFIG_PAX_MPROTECT
48540 + .handle_mprotect= elf_handle_mprotect,
48541 +#endif
48542 +
48543 .min_coredump = ELF_EXEC_PAGESIZE,
48544 };
48545
48546 @@ -86,6 +96,8 @@ static struct linux_binfmt elf_format = {
48547
48548 static int set_brk(unsigned long start, unsigned long end)
48549 {
48550 + unsigned long e = end;
48551 +
48552 start = ELF_PAGEALIGN(start);
48553 end = ELF_PAGEALIGN(end);
48554 if (end > start) {
48555 @@ -94,7 +106,7 @@ static int set_brk(unsigned long start, unsigned long end)
48556 if (BAD_ADDR(addr))
48557 return addr;
48558 }
48559 - current->mm->start_brk = current->mm->brk = end;
48560 + current->mm->start_brk = current->mm->brk = e;
48561 return 0;
48562 }
48563
48564 @@ -155,12 +167,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48565 elf_addr_t __user *u_rand_bytes;
48566 const char *k_platform = ELF_PLATFORM;
48567 const char *k_base_platform = ELF_BASE_PLATFORM;
48568 - unsigned char k_rand_bytes[16];
48569 + u32 k_rand_bytes[4];
48570 int items;
48571 elf_addr_t *elf_info;
48572 int ei_index = 0;
48573 const struct cred *cred = current_cred();
48574 struct vm_area_struct *vma;
48575 + unsigned long saved_auxv[AT_VECTOR_SIZE];
48576
48577 /*
48578 * In some cases (e.g. Hyper-Threading), we want to avoid L1
48579 @@ -202,8 +215,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48580 * Generate 16 random bytes for userspace PRNG seeding.
48581 */
48582 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
48583 - u_rand_bytes = (elf_addr_t __user *)
48584 - STACK_ALLOC(p, sizeof(k_rand_bytes));
48585 + prandom_seed(k_rand_bytes[0] ^ prandom_u32());
48586 + prandom_seed(k_rand_bytes[1] ^ prandom_u32());
48587 + prandom_seed(k_rand_bytes[2] ^ prandom_u32());
48588 + prandom_seed(k_rand_bytes[3] ^ prandom_u32());
48589 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
48590 + u_rand_bytes = (elf_addr_t __user *) p;
48591 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
48592 return -EFAULT;
48593
48594 @@ -318,9 +335,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
48595 return -EFAULT;
48596 current->mm->env_end = p;
48597
48598 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
48599 +
48600 /* Put the elf_info on the stack in the right place. */
48601 sp = (elf_addr_t __user *)envp + 1;
48602 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
48603 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
48604 return -EFAULT;
48605 return 0;
48606 }
48607 @@ -388,15 +407,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
48608 an ELF header */
48609
48610 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48611 - struct file *interpreter, unsigned long *interp_map_addr,
48612 - unsigned long no_base)
48613 + struct file *interpreter, unsigned long no_base)
48614 {
48615 struct elf_phdr *elf_phdata;
48616 struct elf_phdr *eppnt;
48617 - unsigned long load_addr = 0;
48618 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
48619 int load_addr_set = 0;
48620 unsigned long last_bss = 0, elf_bss = 0;
48621 - unsigned long error = ~0UL;
48622 + unsigned long error = -EINVAL;
48623 unsigned long total_size;
48624 int retval, i, size;
48625
48626 @@ -442,6 +460,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48627 goto out_close;
48628 }
48629
48630 +#ifdef CONFIG_PAX_SEGMEXEC
48631 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
48632 + pax_task_size = SEGMEXEC_TASK_SIZE;
48633 +#endif
48634 +
48635 eppnt = elf_phdata;
48636 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
48637 if (eppnt->p_type == PT_LOAD) {
48638 @@ -465,8 +488,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48639 map_addr = elf_map(interpreter, load_addr + vaddr,
48640 eppnt, elf_prot, elf_type, total_size);
48641 total_size = 0;
48642 - if (!*interp_map_addr)
48643 - *interp_map_addr = map_addr;
48644 error = map_addr;
48645 if (BAD_ADDR(map_addr))
48646 goto out_close;
48647 @@ -485,8 +506,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
48648 k = load_addr + eppnt->p_vaddr;
48649 if (BAD_ADDR(k) ||
48650 eppnt->p_filesz > eppnt->p_memsz ||
48651 - eppnt->p_memsz > TASK_SIZE ||
48652 - TASK_SIZE - eppnt->p_memsz < k) {
48653 + eppnt->p_memsz > pax_task_size ||
48654 + pax_task_size - eppnt->p_memsz < k) {
48655 error = -ENOMEM;
48656 goto out_close;
48657 }
48658 @@ -538,6 +559,315 @@ out:
48659 return error;
48660 }
48661
48662 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48663 +#ifdef CONFIG_PAX_SOFTMODE
48664 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
48665 +{
48666 + unsigned long pax_flags = 0UL;
48667 +
48668 +#ifdef CONFIG_PAX_PAGEEXEC
48669 + if (elf_phdata->p_flags & PF_PAGEEXEC)
48670 + pax_flags |= MF_PAX_PAGEEXEC;
48671 +#endif
48672 +
48673 +#ifdef CONFIG_PAX_SEGMEXEC
48674 + if (elf_phdata->p_flags & PF_SEGMEXEC)
48675 + pax_flags |= MF_PAX_SEGMEXEC;
48676 +#endif
48677 +
48678 +#ifdef CONFIG_PAX_EMUTRAMP
48679 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
48680 + pax_flags |= MF_PAX_EMUTRAMP;
48681 +#endif
48682 +
48683 +#ifdef CONFIG_PAX_MPROTECT
48684 + if (elf_phdata->p_flags & PF_MPROTECT)
48685 + pax_flags |= MF_PAX_MPROTECT;
48686 +#endif
48687 +
48688 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48689 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
48690 + pax_flags |= MF_PAX_RANDMMAP;
48691 +#endif
48692 +
48693 + return pax_flags;
48694 +}
48695 +#endif
48696 +
48697 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
48698 +{
48699 + unsigned long pax_flags = 0UL;
48700 +
48701 +#ifdef CONFIG_PAX_PAGEEXEC
48702 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
48703 + pax_flags |= MF_PAX_PAGEEXEC;
48704 +#endif
48705 +
48706 +#ifdef CONFIG_PAX_SEGMEXEC
48707 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
48708 + pax_flags |= MF_PAX_SEGMEXEC;
48709 +#endif
48710 +
48711 +#ifdef CONFIG_PAX_EMUTRAMP
48712 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
48713 + pax_flags |= MF_PAX_EMUTRAMP;
48714 +#endif
48715 +
48716 +#ifdef CONFIG_PAX_MPROTECT
48717 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
48718 + pax_flags |= MF_PAX_MPROTECT;
48719 +#endif
48720 +
48721 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48722 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
48723 + pax_flags |= MF_PAX_RANDMMAP;
48724 +#endif
48725 +
48726 + return pax_flags;
48727 +}
48728 +#endif
48729 +
48730 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
48731 +#ifdef CONFIG_PAX_SOFTMODE
48732 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
48733 +{
48734 + unsigned long pax_flags = 0UL;
48735 +
48736 +#ifdef CONFIG_PAX_PAGEEXEC
48737 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
48738 + pax_flags |= MF_PAX_PAGEEXEC;
48739 +#endif
48740 +
48741 +#ifdef CONFIG_PAX_SEGMEXEC
48742 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
48743 + pax_flags |= MF_PAX_SEGMEXEC;
48744 +#endif
48745 +
48746 +#ifdef CONFIG_PAX_EMUTRAMP
48747 + if ((pax_flags_softmode & MF_PAX_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
48748 + pax_flags |= MF_PAX_EMUTRAMP;
48749 +#endif
48750 +
48751 +#ifdef CONFIG_PAX_MPROTECT
48752 + if (pax_flags_softmode & MF_PAX_MPROTECT)
48753 + pax_flags |= MF_PAX_MPROTECT;
48754 +#endif
48755 +
48756 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48757 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
48758 + pax_flags |= MF_PAX_RANDMMAP;
48759 +#endif
48760 +
48761 + return pax_flags;
48762 +}
48763 +#endif
48764 +
48765 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
48766 +{
48767 + unsigned long pax_flags = 0UL;
48768 +
48769 +#ifdef CONFIG_PAX_PAGEEXEC
48770 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
48771 + pax_flags |= MF_PAX_PAGEEXEC;
48772 +#endif
48773 +
48774 +#ifdef CONFIG_PAX_SEGMEXEC
48775 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
48776 + pax_flags |= MF_PAX_SEGMEXEC;
48777 +#endif
48778 +
48779 +#ifdef CONFIG_PAX_EMUTRAMP
48780 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
48781 + pax_flags |= MF_PAX_EMUTRAMP;
48782 +#endif
48783 +
48784 +#ifdef CONFIG_PAX_MPROTECT
48785 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
48786 + pax_flags |= MF_PAX_MPROTECT;
48787 +#endif
48788 +
48789 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
48790 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
48791 + pax_flags |= MF_PAX_RANDMMAP;
48792 +#endif
48793 +
48794 + return pax_flags;
48795 +}
48796 +#endif
48797 +
48798 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
48799 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
48800 +{
48801 + unsigned long pax_flags = 0UL;
48802 +
48803 +#ifdef CONFIG_PAX_EI_PAX
48804 +
48805 +#ifdef CONFIG_PAX_PAGEEXEC
48806 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
48807 + pax_flags |= MF_PAX_PAGEEXEC;
48808 +#endif
48809 +
48810 +#ifdef CONFIG_PAX_SEGMEXEC
48811 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
48812 + pax_flags |= MF_PAX_SEGMEXEC;
48813 +#endif
48814 +
48815 +#ifdef CONFIG_PAX_EMUTRAMP
48816 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
48817 + pax_flags |= MF_PAX_EMUTRAMP;
48818 +#endif
48819 +
48820 +#ifdef CONFIG_PAX_MPROTECT
48821 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
48822 + pax_flags |= MF_PAX_MPROTECT;
48823 +#endif
48824 +
48825 +#ifdef CONFIG_PAX_ASLR
48826 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
48827 + pax_flags |= MF_PAX_RANDMMAP;
48828 +#endif
48829 +
48830 +#else
48831 +
48832 +#ifdef CONFIG_PAX_PAGEEXEC
48833 + pax_flags |= MF_PAX_PAGEEXEC;
48834 +#endif
48835 +
48836 +#ifdef CONFIG_PAX_SEGMEXEC
48837 + pax_flags |= MF_PAX_SEGMEXEC;
48838 +#endif
48839 +
48840 +#ifdef CONFIG_PAX_MPROTECT
48841 + pax_flags |= MF_PAX_MPROTECT;
48842 +#endif
48843 +
48844 +#ifdef CONFIG_PAX_RANDMMAP
48845 + if (randomize_va_space)
48846 + pax_flags |= MF_PAX_RANDMMAP;
48847 +#endif
48848 +
48849 +#endif
48850 +
48851 + return pax_flags;
48852 +}
48853 +
48854 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
48855 +{
48856 +
48857 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
48858 + unsigned long i;
48859 +
48860 + for (i = 0UL; i < elf_ex->e_phnum; i++)
48861 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
48862 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
48863 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
48864 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
48865 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
48866 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
48867 + return ~0UL;
48868 +
48869 +#ifdef CONFIG_PAX_SOFTMODE
48870 + if (pax_softmode)
48871 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
48872 + else
48873 +#endif
48874 +
48875 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
48876 + break;
48877 + }
48878 +#endif
48879 +
48880 + return ~0UL;
48881 +}
48882 +
48883 +static unsigned long pax_parse_xattr_pax(struct file * const file)
48884 +{
48885 +
48886 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
48887 + ssize_t xattr_size, i;
48888 + unsigned char xattr_value[sizeof("pemrs") - 1];
48889 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
48890 +
48891 + xattr_size = pax_getxattr(file->f_path.dentry, xattr_value, sizeof xattr_value);
48892 + if (xattr_size <= 0 || xattr_size > sizeof xattr_value)
48893 + return ~0UL;
48894 +
48895 + for (i = 0; i < xattr_size; i++)
48896 + switch (xattr_value[i]) {
48897 + default:
48898 + return ~0UL;
48899 +
48900 +#define parse_flag(option1, option2, flag) \
48901 + case option1: \
48902 + if (pax_flags_hardmode & MF_PAX_##flag) \
48903 + return ~0UL; \
48904 + pax_flags_hardmode |= MF_PAX_##flag; \
48905 + break; \
48906 + case option2: \
48907 + if (pax_flags_softmode & MF_PAX_##flag) \
48908 + return ~0UL; \
48909 + pax_flags_softmode |= MF_PAX_##flag; \
48910 + break;
48911 +
48912 + parse_flag('p', 'P', PAGEEXEC);
48913 + parse_flag('e', 'E', EMUTRAMP);
48914 + parse_flag('m', 'M', MPROTECT);
48915 + parse_flag('r', 'R', RANDMMAP);
48916 + parse_flag('s', 'S', SEGMEXEC);
48917 +
48918 +#undef parse_flag
48919 + }
48920 +
48921 + if (pax_flags_hardmode & pax_flags_softmode)
48922 + return ~0UL;
48923 +
48924 +#ifdef CONFIG_PAX_SOFTMODE
48925 + if (pax_softmode)
48926 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
48927 + else
48928 +#endif
48929 +
48930 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
48931 +#else
48932 + return ~0UL;
48933 +#endif
48934 +
48935 +}
48936 +
48937 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
48938 +{
48939 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
48940 +
48941 + pax_flags = pax_parse_ei_pax(elf_ex);
48942 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
48943 + xattr_pax_flags = pax_parse_xattr_pax(file);
48944 +
48945 + if (pt_pax_flags == ~0UL)
48946 + pt_pax_flags = xattr_pax_flags;
48947 + else if (xattr_pax_flags == ~0UL)
48948 + xattr_pax_flags = pt_pax_flags;
48949 + if (pt_pax_flags != xattr_pax_flags)
48950 + return -EINVAL;
48951 + if (pt_pax_flags != ~0UL)
48952 + pax_flags = pt_pax_flags;
48953 +
48954 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
48955 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
48956 + if ((__supported_pte_mask & _PAGE_NX))
48957 + pax_flags &= ~MF_PAX_SEGMEXEC;
48958 + else
48959 + pax_flags &= ~MF_PAX_PAGEEXEC;
48960 + }
48961 +#endif
48962 +
48963 + if (0 > pax_check_flags(&pax_flags))
48964 + return -EINVAL;
48965 +
48966 + current->mm->pax_flags = pax_flags;
48967 + return 0;
48968 +}
48969 +#endif
48970 +
48971 /*
48972 * These are the functions used to load ELF style executables and shared
48973 * libraries. There is no binary dependent code anywhere else.
48974 @@ -554,6 +884,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
48975 {
48976 unsigned int random_variable = 0;
48977
48978 +#ifdef CONFIG_PAX_RANDUSTACK
48979 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
48980 + return stack_top - current->mm->delta_stack;
48981 +#endif
48982 +
48983 if ((current->flags & PF_RANDOMIZE) &&
48984 !(current->personality & ADDR_NO_RANDOMIZE)) {
48985 random_variable = get_random_int() & STACK_RND_MASK;
48986 @@ -572,7 +907,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
48987 unsigned long load_addr = 0, load_bias = 0;
48988 int load_addr_set = 0;
48989 char * elf_interpreter = NULL;
48990 - unsigned long error;
48991 + unsigned long error = 0;
48992 struct elf_phdr *elf_ppnt, *elf_phdata;
48993 unsigned long elf_bss, elf_brk;
48994 int retval, i;
48995 @@ -582,12 +917,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
48996 unsigned long start_code, end_code, start_data, end_data;
48997 unsigned long reloc_func_desc __maybe_unused = 0;
48998 int executable_stack = EXSTACK_DEFAULT;
48999 - unsigned long def_flags = 0;
49000 struct pt_regs *regs = current_pt_regs();
49001 struct {
49002 struct elfhdr elf_ex;
49003 struct elfhdr interp_elf_ex;
49004 } *loc;
49005 + unsigned long pax_task_size = TASK_SIZE;
49006
49007 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
49008 if (!loc) {
49009 @@ -723,11 +1058,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
49010 goto out_free_dentry;
49011
49012 /* OK, This is the point of no return */
49013 - current->mm->def_flags = def_flags;
49014 +
49015 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
49016 + current->mm->pax_flags = 0UL;
49017 +#endif
49018 +
49019 +#ifdef CONFIG_PAX_DLRESOLVE
49020 + current->mm->call_dl_resolve = 0UL;
49021 +#endif
49022 +
49023 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
49024 + current->mm->call_syscall = 0UL;
49025 +#endif
49026 +
49027 +#ifdef CONFIG_PAX_ASLR
49028 + current->mm->delta_mmap = 0UL;
49029 + current->mm->delta_stack = 0UL;
49030 +#endif
49031 +
49032 + current->mm->def_flags = 0;
49033 +
49034 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
49035 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
49036 + send_sig(SIGKILL, current, 0);
49037 + goto out_free_dentry;
49038 + }
49039 +#endif
49040 +
49041 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
49042 + pax_set_initial_flags(bprm);
49043 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
49044 + if (pax_set_initial_flags_func)
49045 + (pax_set_initial_flags_func)(bprm);
49046 +#endif
49047 +
49048 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
49049 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
49050 + current->mm->context.user_cs_limit = PAGE_SIZE;
49051 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
49052 + }
49053 +#endif
49054 +
49055 +#ifdef CONFIG_PAX_SEGMEXEC
49056 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
49057 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
49058 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
49059 + pax_task_size = SEGMEXEC_TASK_SIZE;
49060 + current->mm->def_flags |= VM_NOHUGEPAGE;
49061 + }
49062 +#endif
49063 +
49064 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
49065 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49066 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
49067 + put_cpu();
49068 + }
49069 +#endif
49070
49071 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
49072 may depend on the personality. */
49073 SET_PERSONALITY(loc->elf_ex);
49074 +
49075 +#ifdef CONFIG_PAX_ASLR
49076 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
49077 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
49078 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
49079 + }
49080 +#endif
49081 +
49082 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
49083 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
49084 + executable_stack = EXSTACK_DISABLE_X;
49085 + current->personality &= ~READ_IMPLIES_EXEC;
49086 + } else
49087 +#endif
49088 +
49089 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
49090 current->personality |= READ_IMPLIES_EXEC;
49091
49092 @@ -819,6 +1224,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
49093 #else
49094 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
49095 #endif
49096 +
49097 +#ifdef CONFIG_PAX_RANDMMAP
49098 + /* PaX: randomize base address at the default exe base if requested */
49099 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
49100 +#ifdef CONFIG_SPARC64
49101 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
49102 +#else
49103 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
49104 +#endif
49105 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
49106 + elf_flags |= MAP_FIXED;
49107 + }
49108 +#endif
49109 +
49110 }
49111
49112 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
49113 @@ -851,9 +1270,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
49114 * allowed task size. Note that p_filesz must always be
49115 * <= p_memsz so it is only necessary to check p_memsz.
49116 */
49117 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
49118 - elf_ppnt->p_memsz > TASK_SIZE ||
49119 - TASK_SIZE - elf_ppnt->p_memsz < k) {
49120 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
49121 + elf_ppnt->p_memsz > pax_task_size ||
49122 + pax_task_size - elf_ppnt->p_memsz < k) {
49123 /* set_brk can never work. Avoid overflows. */
49124 send_sig(SIGKILL, current, 0);
49125 retval = -EINVAL;
49126 @@ -892,17 +1311,45 @@ static int load_elf_binary(struct linux_binprm *bprm)
49127 goto out_free_dentry;
49128 }
49129 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
49130 - send_sig(SIGSEGV, current, 0);
49131 - retval = -EFAULT; /* Nobody gets to see this, but.. */
49132 - goto out_free_dentry;
49133 + /*
49134 + * This bss-zeroing can fail if the ELF
49135 + * file specifies odd protections. So
49136 + * we don't check the return value
49137 + */
49138 }
49139
49140 +#ifdef CONFIG_PAX_RANDMMAP
49141 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
49142 + unsigned long start, size, flags;
49143 + vm_flags_t vm_flags;
49144 +
49145 + start = ELF_PAGEALIGN(elf_brk);
49146 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
49147 + flags = MAP_FIXED | MAP_PRIVATE;
49148 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
49149 +
49150 + down_write(&current->mm->mmap_sem);
49151 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
49152 + retval = -ENOMEM;
49153 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
49154 +// if (current->personality & ADDR_NO_RANDOMIZE)
49155 +// vm_flags |= VM_READ | VM_MAYREAD;
49156 + start = mmap_region(NULL, start, PAGE_ALIGN(size), vm_flags, 0);
49157 + retval = IS_ERR_VALUE(start) ? start : 0;
49158 + }
49159 + up_write(&current->mm->mmap_sem);
49160 + if (retval == 0)
49161 + retval = set_brk(start + size, start + size + PAGE_SIZE);
49162 + if (retval < 0) {
49163 + send_sig(SIGKILL, current, 0);
49164 + goto out_free_dentry;
49165 + }
49166 + }
49167 +#endif
49168 +
49169 if (elf_interpreter) {
49170 - unsigned long interp_map_addr = 0;
49171 -
49172 elf_entry = load_elf_interp(&loc->interp_elf_ex,
49173 interpreter,
49174 - &interp_map_addr,
49175 load_bias);
49176 if (!IS_ERR((void *)elf_entry)) {
49177 /*
49178 @@ -1124,7 +1571,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
49179 * Decide what to dump of a segment, part, all or none.
49180 */
49181 static unsigned long vma_dump_size(struct vm_area_struct *vma,
49182 - unsigned long mm_flags)
49183 + unsigned long mm_flags, long signr)
49184 {
49185 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
49186
49187 @@ -1162,7 +1609,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
49188 if (vma->vm_file == NULL)
49189 return 0;
49190
49191 - if (FILTER(MAPPED_PRIVATE))
49192 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
49193 goto whole;
49194
49195 /*
49196 @@ -1387,9 +1834,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
49197 {
49198 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
49199 int i = 0;
49200 - do
49201 + do {
49202 i += 2;
49203 - while (auxv[i - 2] != AT_NULL);
49204 + } while (auxv[i - 2] != AT_NULL);
49205 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
49206 }
49207
49208 @@ -1398,7 +1845,7 @@ static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
49209 {
49210 mm_segment_t old_fs = get_fs();
49211 set_fs(KERNEL_DS);
49212 - copy_siginfo_to_user((user_siginfo_t __user *) csigdata, siginfo);
49213 + copy_siginfo_to_user((user_siginfo_t __force_user *) csigdata, siginfo);
49214 set_fs(old_fs);
49215 fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata);
49216 }
49217 @@ -2019,14 +2466,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
49218 }
49219
49220 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
49221 - unsigned long mm_flags)
49222 + struct coredump_params *cprm)
49223 {
49224 struct vm_area_struct *vma;
49225 size_t size = 0;
49226
49227 for (vma = first_vma(current, gate_vma); vma != NULL;
49228 vma = next_vma(vma, gate_vma))
49229 - size += vma_dump_size(vma, mm_flags);
49230 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49231 return size;
49232 }
49233
49234 @@ -2119,7 +2566,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49235
49236 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
49237
49238 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
49239 + offset += elf_core_vma_data_size(gate_vma, cprm);
49240 offset += elf_core_extra_data_size();
49241 e_shoff = offset;
49242
49243 @@ -2133,10 +2580,12 @@ static int elf_core_dump(struct coredump_params *cprm)
49244 offset = dataoff;
49245
49246 size += sizeof(*elf);
49247 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49248 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
49249 goto end_coredump;
49250
49251 size += sizeof(*phdr4note);
49252 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49253 if (size > cprm->limit
49254 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
49255 goto end_coredump;
49256 @@ -2150,7 +2599,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49257 phdr.p_offset = offset;
49258 phdr.p_vaddr = vma->vm_start;
49259 phdr.p_paddr = 0;
49260 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
49261 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49262 phdr.p_memsz = vma->vm_end - vma->vm_start;
49263 offset += phdr.p_filesz;
49264 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
49265 @@ -2161,6 +2610,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49266 phdr.p_align = ELF_EXEC_PAGESIZE;
49267
49268 size += sizeof(phdr);
49269 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49270 if (size > cprm->limit
49271 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
49272 goto end_coredump;
49273 @@ -2185,7 +2635,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49274 unsigned long addr;
49275 unsigned long end;
49276
49277 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
49278 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
49279
49280 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
49281 struct page *page;
49282 @@ -2194,6 +2644,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49283 page = get_dump_page(addr);
49284 if (page) {
49285 void *kaddr = kmap(page);
49286 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
49287 stop = ((size += PAGE_SIZE) > cprm->limit) ||
49288 !dump_write(cprm->file, kaddr,
49289 PAGE_SIZE);
49290 @@ -2211,6 +2662,7 @@ static int elf_core_dump(struct coredump_params *cprm)
49291
49292 if (e_phnum == PN_XNUM) {
49293 size += sizeof(*shdr4extnum);
49294 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
49295 if (size > cprm->limit
49296 || !dump_write(cprm->file, shdr4extnum,
49297 sizeof(*shdr4extnum)))
49298 @@ -2231,6 +2683,97 @@ out:
49299
49300 #endif /* CONFIG_ELF_CORE */
49301
49302 +#ifdef CONFIG_PAX_MPROTECT
49303 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
49304 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
49305 + * we'll remove VM_MAYWRITE for good on RELRO segments.
49306 + *
49307 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
49308 + * basis because we want to allow the common case and not the special ones.
49309 + */
49310 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
49311 +{
49312 + struct elfhdr elf_h;
49313 + struct elf_phdr elf_p;
49314 + unsigned long i;
49315 + unsigned long oldflags;
49316 + bool is_textrel_rw, is_textrel_rx, is_relro;
49317 +
49318 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT))
49319 + return;
49320 +
49321 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
49322 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
49323 +
49324 +#ifdef CONFIG_PAX_ELFRELOCS
49325 + /* possible TEXTREL */
49326 + is_textrel_rw = vma->vm_file && !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
49327 + 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);
49328 +#else
49329 + is_textrel_rw = false;
49330 + is_textrel_rx = false;
49331 +#endif
49332 +
49333 + /* possible RELRO */
49334 + is_relro = vma->vm_file && vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
49335 +
49336 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
49337 + return;
49338 +
49339 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
49340 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
49341 +
49342 +#ifdef CONFIG_PAX_ETEXECRELOCS
49343 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
49344 +#else
49345 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
49346 +#endif
49347 +
49348 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
49349 + !elf_check_arch(&elf_h) ||
49350 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
49351 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
49352 + return;
49353 +
49354 + for (i = 0UL; i < elf_h.e_phnum; i++) {
49355 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
49356 + return;
49357 + switch (elf_p.p_type) {
49358 + case PT_DYNAMIC:
49359 + if (!is_textrel_rw && !is_textrel_rx)
49360 + continue;
49361 + i = 0UL;
49362 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
49363 + elf_dyn dyn;
49364 +
49365 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
49366 + return;
49367 + if (dyn.d_tag == DT_NULL)
49368 + return;
49369 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
49370 + gr_log_textrel(vma);
49371 + if (is_textrel_rw)
49372 + vma->vm_flags |= VM_MAYWRITE;
49373 + else
49374 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
49375 + vma->vm_flags &= ~VM_MAYWRITE;
49376 + return;
49377 + }
49378 + i++;
49379 + }
49380 + return;
49381 +
49382 + case PT_GNU_RELRO:
49383 + if (!is_relro)
49384 + continue;
49385 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
49386 + vma->vm_flags &= ~VM_MAYWRITE;
49387 + return;
49388 + }
49389 + }
49390 +}
49391 +#endif
49392 +
49393 static int __init init_elf_binfmt(void)
49394 {
49395 register_binfmt(&elf_format);
49396 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
49397 index d50bbe5..af3b649 100644
49398 --- a/fs/binfmt_flat.c
49399 +++ b/fs/binfmt_flat.c
49400 @@ -566,7 +566,9 @@ static int load_flat_file(struct linux_binprm * bprm,
49401 realdatastart = (unsigned long) -ENOMEM;
49402 printk("Unable to allocate RAM for process data, errno %d\n",
49403 (int)-realdatastart);
49404 + down_write(&current->mm->mmap_sem);
49405 vm_munmap(textpos, text_len);
49406 + up_write(&current->mm->mmap_sem);
49407 ret = realdatastart;
49408 goto err;
49409 }
49410 @@ -590,8 +592,10 @@ static int load_flat_file(struct linux_binprm * bprm,
49411 }
49412 if (IS_ERR_VALUE(result)) {
49413 printk("Unable to read data+bss, errno %d\n", (int)-result);
49414 + down_write(&current->mm->mmap_sem);
49415 vm_munmap(textpos, text_len);
49416 vm_munmap(realdatastart, len);
49417 + up_write(&current->mm->mmap_sem);
49418 ret = result;
49419 goto err;
49420 }
49421 @@ -653,8 +657,10 @@ static int load_flat_file(struct linux_binprm * bprm,
49422 }
49423 if (IS_ERR_VALUE(result)) {
49424 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
49425 + down_write(&current->mm->mmap_sem);
49426 vm_munmap(textpos, text_len + data_len + extra +
49427 MAX_SHARED_LIBS * sizeof(unsigned long));
49428 + up_write(&current->mm->mmap_sem);
49429 ret = result;
49430 goto err;
49431 }
49432 diff --git a/fs/bio.c b/fs/bio.c
49433 index 94bbc04..6fe78a4 100644
49434 --- a/fs/bio.c
49435 +++ b/fs/bio.c
49436 @@ -1096,7 +1096,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
49437 /*
49438 * Overflow, abort
49439 */
49440 - if (end < start)
49441 + if (end < start || end - start > INT_MAX - nr_pages)
49442 return ERR_PTR(-EINVAL);
49443
49444 nr_pages += end - start;
49445 @@ -1230,7 +1230,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
49446 /*
49447 * Overflow, abort
49448 */
49449 - if (end < start)
49450 + if (end < start || end - start > INT_MAX - nr_pages)
49451 return ERR_PTR(-EINVAL);
49452
49453 nr_pages += end - start;
49454 @@ -1492,7 +1492,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
49455 const int read = bio_data_dir(bio) == READ;
49456 struct bio_map_data *bmd = bio->bi_private;
49457 int i;
49458 - char *p = bmd->sgvecs[0].iov_base;
49459 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
49460
49461 bio_for_each_segment_all(bvec, bio, i) {
49462 char *addr = page_address(bvec->bv_page);
49463 diff --git a/fs/block_dev.c b/fs/block_dev.c
49464 index 2091db8..81dafe9 100644
49465 --- a/fs/block_dev.c
49466 +++ b/fs/block_dev.c
49467 @@ -651,7 +651,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
49468 else if (bdev->bd_contains == bdev)
49469 return true; /* is a whole device which isn't held */
49470
49471 - else if (whole->bd_holder == bd_may_claim)
49472 + else if (whole->bd_holder == (void *)bd_may_claim)
49473 return true; /* is a partition of a device that is being partitioned */
49474 else if (whole->bd_holder != NULL)
49475 return false; /* is a partition of a held device */
49476 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
49477 index 02fae7f..48da375 100644
49478 --- a/fs/btrfs/ctree.c
49479 +++ b/fs/btrfs/ctree.c
49480 @@ -1076,9 +1076,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
49481 free_extent_buffer(buf);
49482 add_root_to_dirty_list(root);
49483 } else {
49484 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
49485 - parent_start = parent->start;
49486 - else
49487 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
49488 + if (parent)
49489 + parent_start = parent->start;
49490 + else
49491 + parent_start = 0;
49492 + } else
49493 parent_start = 0;
49494
49495 WARN_ON(trans->transid != btrfs_header_generation(parent));
49496 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
49497 index 0f81d67..0ad55fe 100644
49498 --- a/fs/btrfs/ioctl.c
49499 +++ b/fs/btrfs/ioctl.c
49500 @@ -3084,9 +3084,12 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
49501 for (i = 0; i < num_types; i++) {
49502 struct btrfs_space_info *tmp;
49503
49504 + /* Don't copy in more than we allocated */
49505 if (!slot_count)
49506 break;
49507
49508 + slot_count--;
49509 +
49510 info = NULL;
49511 rcu_read_lock();
49512 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
49513 @@ -3108,10 +3111,7 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
49514 memcpy(dest, &space, sizeof(space));
49515 dest++;
49516 space_args.total_spaces++;
49517 - slot_count--;
49518 }
49519 - if (!slot_count)
49520 - break;
49521 }
49522 up_read(&info->groups_sem);
49523 }
49524 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
49525 index f0857e0..e7023c5 100644
49526 --- a/fs/btrfs/super.c
49527 +++ b/fs/btrfs/super.c
49528 @@ -265,7 +265,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
49529 function, line, errstr);
49530 return;
49531 }
49532 - ACCESS_ONCE(trans->transaction->aborted) = errno;
49533 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
49534 __btrfs_std_error(root->fs_info, function, line, errno, NULL);
49535 }
49536 /*
49537 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
49538 index 622f469..e8d2d55 100644
49539 --- a/fs/cachefiles/bind.c
49540 +++ b/fs/cachefiles/bind.c
49541 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
49542 args);
49543
49544 /* start by checking things over */
49545 - ASSERT(cache->fstop_percent >= 0 &&
49546 - cache->fstop_percent < cache->fcull_percent &&
49547 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
49548 cache->fcull_percent < cache->frun_percent &&
49549 cache->frun_percent < 100);
49550
49551 - ASSERT(cache->bstop_percent >= 0 &&
49552 - cache->bstop_percent < cache->bcull_percent &&
49553 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
49554 cache->bcull_percent < cache->brun_percent &&
49555 cache->brun_percent < 100);
49556
49557 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
49558 index 0a1467b..6a53245 100644
49559 --- a/fs/cachefiles/daemon.c
49560 +++ b/fs/cachefiles/daemon.c
49561 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
49562 if (n > buflen)
49563 return -EMSGSIZE;
49564
49565 - if (copy_to_user(_buffer, buffer, n) != 0)
49566 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
49567 return -EFAULT;
49568
49569 return n;
49570 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
49571 if (test_bit(CACHEFILES_DEAD, &cache->flags))
49572 return -EIO;
49573
49574 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
49575 + if (datalen > PAGE_SIZE - 1)
49576 return -EOPNOTSUPP;
49577
49578 /* drag the command string into the kernel so we can parse it */
49579 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
49580 if (args[0] != '%' || args[1] != '\0')
49581 return -EINVAL;
49582
49583 - if (fstop < 0 || fstop >= cache->fcull_percent)
49584 + if (fstop >= cache->fcull_percent)
49585 return cachefiles_daemon_range_error(cache, args);
49586
49587 cache->fstop_percent = fstop;
49588 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
49589 if (args[0] != '%' || args[1] != '\0')
49590 return -EINVAL;
49591
49592 - if (bstop < 0 || bstop >= cache->bcull_percent)
49593 + if (bstop >= cache->bcull_percent)
49594 return cachefiles_daemon_range_error(cache, args);
49595
49596 cache->bstop_percent = bstop;
49597 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
49598 index 4938251..7e01445 100644
49599 --- a/fs/cachefiles/internal.h
49600 +++ b/fs/cachefiles/internal.h
49601 @@ -59,7 +59,7 @@ struct cachefiles_cache {
49602 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
49603 struct rb_root active_nodes; /* active nodes (can't be culled) */
49604 rwlock_t active_lock; /* lock for active_nodes */
49605 - atomic_t gravecounter; /* graveyard uniquifier */
49606 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
49607 unsigned frun_percent; /* when to stop culling (% files) */
49608 unsigned fcull_percent; /* when to start culling (% files) */
49609 unsigned fstop_percent; /* when to stop allocating (% files) */
49610 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
49611 * proc.c
49612 */
49613 #ifdef CONFIG_CACHEFILES_HISTOGRAM
49614 -extern atomic_t cachefiles_lookup_histogram[HZ];
49615 -extern atomic_t cachefiles_mkdir_histogram[HZ];
49616 -extern atomic_t cachefiles_create_histogram[HZ];
49617 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49618 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49619 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
49620
49621 extern int __init cachefiles_proc_init(void);
49622 extern void cachefiles_proc_cleanup(void);
49623 static inline
49624 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
49625 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
49626 {
49627 unsigned long jif = jiffies - start_jif;
49628 if (jif >= HZ)
49629 jif = HZ - 1;
49630 - atomic_inc(&histogram[jif]);
49631 + atomic_inc_unchecked(&histogram[jif]);
49632 }
49633
49634 #else
49635 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
49636 index 8c01c5fc..15f982e 100644
49637 --- a/fs/cachefiles/namei.c
49638 +++ b/fs/cachefiles/namei.c
49639 @@ -317,7 +317,7 @@ try_again:
49640 /* first step is to make up a grave dentry in the graveyard */
49641 sprintf(nbuffer, "%08x%08x",
49642 (uint32_t) get_seconds(),
49643 - (uint32_t) atomic_inc_return(&cache->gravecounter));
49644 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
49645
49646 /* do the multiway lock magic */
49647 trap = lock_rename(cache->graveyard, dir);
49648 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
49649 index eccd339..4c1d995 100644
49650 --- a/fs/cachefiles/proc.c
49651 +++ b/fs/cachefiles/proc.c
49652 @@ -14,9 +14,9 @@
49653 #include <linux/seq_file.h>
49654 #include "internal.h"
49655
49656 -atomic_t cachefiles_lookup_histogram[HZ];
49657 -atomic_t cachefiles_mkdir_histogram[HZ];
49658 -atomic_t cachefiles_create_histogram[HZ];
49659 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
49660 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
49661 +atomic_unchecked_t cachefiles_create_histogram[HZ];
49662
49663 /*
49664 * display the latency histogram
49665 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
49666 return 0;
49667 default:
49668 index = (unsigned long) v - 3;
49669 - x = atomic_read(&cachefiles_lookup_histogram[index]);
49670 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
49671 - z = atomic_read(&cachefiles_create_histogram[index]);
49672 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
49673 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
49674 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
49675 if (x == 0 && y == 0 && z == 0)
49676 return 0;
49677
49678 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
49679 index 317f9ee..3d24511 100644
49680 --- a/fs/cachefiles/rdwr.c
49681 +++ b/fs/cachefiles/rdwr.c
49682 @@ -966,7 +966,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
49683 old_fs = get_fs();
49684 set_fs(KERNEL_DS);
49685 ret = file->f_op->write(
49686 - file, (const void __user *) data, len, &pos);
49687 + file, (const void __force_user *) data, len, &pos);
49688 set_fs(old_fs);
49689 kunmap(page);
49690 file_end_write(file);
49691 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
49692 index f02d82b..2632cf86 100644
49693 --- a/fs/ceph/dir.c
49694 +++ b/fs/ceph/dir.c
49695 @@ -243,7 +243,7 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
49696 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
49697 struct ceph_mds_client *mdsc = fsc->mdsc;
49698 unsigned frag = fpos_frag(filp->f_pos);
49699 - int off = fpos_off(filp->f_pos);
49700 + unsigned int off = fpos_off(filp->f_pos);
49701 int err;
49702 u32 ftype;
49703 struct ceph_mds_reply_info_parsed *rinfo;
49704 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
49705 index d597483..747901b 100644
49706 --- a/fs/cifs/cifs_debug.c
49707 +++ b/fs/cifs/cifs_debug.c
49708 @@ -284,8 +284,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49709
49710 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
49711 #ifdef CONFIG_CIFS_STATS2
49712 - atomic_set(&totBufAllocCount, 0);
49713 - atomic_set(&totSmBufAllocCount, 0);
49714 + atomic_set_unchecked(&totBufAllocCount, 0);
49715 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49716 #endif /* CONFIG_CIFS_STATS2 */
49717 spin_lock(&cifs_tcp_ses_lock);
49718 list_for_each(tmp1, &cifs_tcp_ses_list) {
49719 @@ -298,7 +298,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
49720 tcon = list_entry(tmp3,
49721 struct cifs_tcon,
49722 tcon_list);
49723 - atomic_set(&tcon->num_smbs_sent, 0);
49724 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
49725 if (server->ops->clear_stats)
49726 server->ops->clear_stats(tcon);
49727 }
49728 @@ -330,8 +330,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49729 smBufAllocCount.counter, cifs_min_small);
49730 #ifdef CONFIG_CIFS_STATS2
49731 seq_printf(m, "Total Large %d Small %d Allocations\n",
49732 - atomic_read(&totBufAllocCount),
49733 - atomic_read(&totSmBufAllocCount));
49734 + atomic_read_unchecked(&totBufAllocCount),
49735 + atomic_read_unchecked(&totSmBufAllocCount));
49736 #endif /* CONFIG_CIFS_STATS2 */
49737
49738 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
49739 @@ -360,7 +360,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
49740 if (tcon->need_reconnect)
49741 seq_puts(m, "\tDISCONNECTED ");
49742 seq_printf(m, "\nSMBs: %d",
49743 - atomic_read(&tcon->num_smbs_sent));
49744 + atomic_read_unchecked(&tcon->num_smbs_sent));
49745 if (server->ops->print_stats)
49746 server->ops->print_stats(m, tcon);
49747 }
49748 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
49749 index 3752b9f..8db5569 100644
49750 --- a/fs/cifs/cifsfs.c
49751 +++ b/fs/cifs/cifsfs.c
49752 @@ -1035,7 +1035,7 @@ cifs_init_request_bufs(void)
49753 */
49754 cifs_req_cachep = kmem_cache_create("cifs_request",
49755 CIFSMaxBufSize + max_hdr_size, 0,
49756 - SLAB_HWCACHE_ALIGN, NULL);
49757 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
49758 if (cifs_req_cachep == NULL)
49759 return -ENOMEM;
49760
49761 @@ -1062,7 +1062,7 @@ cifs_init_request_bufs(void)
49762 efficient to alloc 1 per page off the slab compared to 17K (5page)
49763 alloc of large cifs buffers even when page debugging is on */
49764 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
49765 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
49766 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
49767 NULL);
49768 if (cifs_sm_req_cachep == NULL) {
49769 mempool_destroy(cifs_req_poolp);
49770 @@ -1147,8 +1147,8 @@ init_cifs(void)
49771 atomic_set(&bufAllocCount, 0);
49772 atomic_set(&smBufAllocCount, 0);
49773 #ifdef CONFIG_CIFS_STATS2
49774 - atomic_set(&totBufAllocCount, 0);
49775 - atomic_set(&totSmBufAllocCount, 0);
49776 + atomic_set_unchecked(&totBufAllocCount, 0);
49777 + atomic_set_unchecked(&totSmBufAllocCount, 0);
49778 #endif /* CONFIG_CIFS_STATS2 */
49779
49780 atomic_set(&midCount, 0);
49781 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
49782 index 4f07f6f..55de8ce 100644
49783 --- a/fs/cifs/cifsglob.h
49784 +++ b/fs/cifs/cifsglob.h
49785 @@ -751,35 +751,35 @@ struct cifs_tcon {
49786 __u16 Flags; /* optional support bits */
49787 enum statusEnum tidStatus;
49788 #ifdef CONFIG_CIFS_STATS
49789 - atomic_t num_smbs_sent;
49790 + atomic_unchecked_t num_smbs_sent;
49791 union {
49792 struct {
49793 - atomic_t num_writes;
49794 - atomic_t num_reads;
49795 - atomic_t num_flushes;
49796 - atomic_t num_oplock_brks;
49797 - atomic_t num_opens;
49798 - atomic_t num_closes;
49799 - atomic_t num_deletes;
49800 - atomic_t num_mkdirs;
49801 - atomic_t num_posixopens;
49802 - atomic_t num_posixmkdirs;
49803 - atomic_t num_rmdirs;
49804 - atomic_t num_renames;
49805 - atomic_t num_t2renames;
49806 - atomic_t num_ffirst;
49807 - atomic_t num_fnext;
49808 - atomic_t num_fclose;
49809 - atomic_t num_hardlinks;
49810 - atomic_t num_symlinks;
49811 - atomic_t num_locks;
49812 - atomic_t num_acl_get;
49813 - atomic_t num_acl_set;
49814 + atomic_unchecked_t num_writes;
49815 + atomic_unchecked_t num_reads;
49816 + atomic_unchecked_t num_flushes;
49817 + atomic_unchecked_t num_oplock_brks;
49818 + atomic_unchecked_t num_opens;
49819 + atomic_unchecked_t num_closes;
49820 + atomic_unchecked_t num_deletes;
49821 + atomic_unchecked_t num_mkdirs;
49822 + atomic_unchecked_t num_posixopens;
49823 + atomic_unchecked_t num_posixmkdirs;
49824 + atomic_unchecked_t num_rmdirs;
49825 + atomic_unchecked_t num_renames;
49826 + atomic_unchecked_t num_t2renames;
49827 + atomic_unchecked_t num_ffirst;
49828 + atomic_unchecked_t num_fnext;
49829 + atomic_unchecked_t num_fclose;
49830 + atomic_unchecked_t num_hardlinks;
49831 + atomic_unchecked_t num_symlinks;
49832 + atomic_unchecked_t num_locks;
49833 + atomic_unchecked_t num_acl_get;
49834 + atomic_unchecked_t num_acl_set;
49835 } cifs_stats;
49836 #ifdef CONFIG_CIFS_SMB2
49837 struct {
49838 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
49839 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
49840 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
49841 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
49842 } smb2_stats;
49843 #endif /* CONFIG_CIFS_SMB2 */
49844 } stats;
49845 @@ -1080,7 +1080,7 @@ convert_delimiter(char *path, char delim)
49846 }
49847
49848 #ifdef CONFIG_CIFS_STATS
49849 -#define cifs_stats_inc atomic_inc
49850 +#define cifs_stats_inc atomic_inc_unchecked
49851
49852 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
49853 unsigned int bytes)
49854 @@ -1445,8 +1445,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
49855 /* Various Debug counters */
49856 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
49857 #ifdef CONFIG_CIFS_STATS2
49858 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
49859 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
49860 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
49861 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
49862 #endif
49863 GLOBAL_EXTERN atomic_t smBufAllocCount;
49864 GLOBAL_EXTERN atomic_t midCount;
49865 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
49866 index b83c3f5..6437caa 100644
49867 --- a/fs/cifs/link.c
49868 +++ b/fs/cifs/link.c
49869 @@ -616,7 +616,7 @@ symlink_exit:
49870
49871 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
49872 {
49873 - char *p = nd_get_link(nd);
49874 + const char *p = nd_get_link(nd);
49875 if (!IS_ERR(p))
49876 kfree(p);
49877 }
49878 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
49879 index 1bec014..f329411 100644
49880 --- a/fs/cifs/misc.c
49881 +++ b/fs/cifs/misc.c
49882 @@ -169,7 +169,7 @@ cifs_buf_get(void)
49883 memset(ret_buf, 0, buf_size + 3);
49884 atomic_inc(&bufAllocCount);
49885 #ifdef CONFIG_CIFS_STATS2
49886 - atomic_inc(&totBufAllocCount);
49887 + atomic_inc_unchecked(&totBufAllocCount);
49888 #endif /* CONFIG_CIFS_STATS2 */
49889 }
49890
49891 @@ -204,7 +204,7 @@ cifs_small_buf_get(void)
49892 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
49893 atomic_inc(&smBufAllocCount);
49894 #ifdef CONFIG_CIFS_STATS2
49895 - atomic_inc(&totSmBufAllocCount);
49896 + atomic_inc_unchecked(&totSmBufAllocCount);
49897 #endif /* CONFIG_CIFS_STATS2 */
49898
49899 }
49900 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
49901 index 3efdb9d..e845a5e 100644
49902 --- a/fs/cifs/smb1ops.c
49903 +++ b/fs/cifs/smb1ops.c
49904 @@ -591,27 +591,27 @@ static void
49905 cifs_clear_stats(struct cifs_tcon *tcon)
49906 {
49907 #ifdef CONFIG_CIFS_STATS
49908 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
49909 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
49910 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
49911 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
49912 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
49913 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
49914 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
49915 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
49916 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
49917 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
49918 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
49919 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
49920 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
49921 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
49922 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
49923 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
49924 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
49925 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
49926 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
49927 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
49928 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
49929 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
49930 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
49931 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
49932 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
49933 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
49934 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
49935 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
49936 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
49937 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
49938 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
49939 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
49940 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
49941 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
49942 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
49943 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
49944 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
49945 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
49946 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
49947 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
49948 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
49949 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
49950 #endif
49951 }
49952
49953 @@ -620,36 +620,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
49954 {
49955 #ifdef CONFIG_CIFS_STATS
49956 seq_printf(m, " Oplocks breaks: %d",
49957 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
49958 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
49959 seq_printf(m, "\nReads: %d Bytes: %llu",
49960 - atomic_read(&tcon->stats.cifs_stats.num_reads),
49961 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
49962 (long long)(tcon->bytes_read));
49963 seq_printf(m, "\nWrites: %d Bytes: %llu",
49964 - atomic_read(&tcon->stats.cifs_stats.num_writes),
49965 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
49966 (long long)(tcon->bytes_written));
49967 seq_printf(m, "\nFlushes: %d",
49968 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
49969 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
49970 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
49971 - atomic_read(&tcon->stats.cifs_stats.num_locks),
49972 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
49973 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
49974 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
49975 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
49976 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
49977 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
49978 - atomic_read(&tcon->stats.cifs_stats.num_opens),
49979 - atomic_read(&tcon->stats.cifs_stats.num_closes),
49980 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
49981 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
49982 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
49983 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
49984 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
49985 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
49986 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
49987 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
49988 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
49989 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
49990 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
49991 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
49992 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
49993 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
49994 seq_printf(m, "\nRenames: %d T2 Renames %d",
49995 - atomic_read(&tcon->stats.cifs_stats.num_renames),
49996 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
49997 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
49998 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
49999 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
50000 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
50001 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
50002 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
50003 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
50004 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
50005 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
50006 #endif
50007 }
50008
50009 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
50010 index f2e76f3..c44fac7 100644
50011 --- a/fs/cifs/smb2ops.c
50012 +++ b/fs/cifs/smb2ops.c
50013 @@ -274,8 +274,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
50014 #ifdef CONFIG_CIFS_STATS
50015 int i;
50016 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
50017 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
50018 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
50019 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
50020 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
50021 }
50022 #endif
50023 }
50024 @@ -284,66 +284,66 @@ static void
50025 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
50026 {
50027 #ifdef CONFIG_CIFS_STATS
50028 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
50029 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
50030 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
50031 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
50032 seq_printf(m, "\nNegotiates: %d sent %d failed",
50033 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
50034 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
50035 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
50036 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
50037 seq_printf(m, "\nSessionSetups: %d sent %d failed",
50038 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
50039 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
50040 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
50041 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
50042 #define SMB2LOGOFF 0x0002 /* trivial request/resp */
50043 seq_printf(m, "\nLogoffs: %d sent %d failed",
50044 - atomic_read(&sent[SMB2_LOGOFF_HE]),
50045 - atomic_read(&failed[SMB2_LOGOFF_HE]));
50046 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
50047 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
50048 seq_printf(m, "\nTreeConnects: %d sent %d failed",
50049 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
50050 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
50051 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
50052 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
50053 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
50054 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
50055 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
50056 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
50057 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
50058 seq_printf(m, "\nCreates: %d sent %d failed",
50059 - atomic_read(&sent[SMB2_CREATE_HE]),
50060 - atomic_read(&failed[SMB2_CREATE_HE]));
50061 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
50062 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
50063 seq_printf(m, "\nCloses: %d sent %d failed",
50064 - atomic_read(&sent[SMB2_CLOSE_HE]),
50065 - atomic_read(&failed[SMB2_CLOSE_HE]));
50066 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
50067 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
50068 seq_printf(m, "\nFlushes: %d sent %d failed",
50069 - atomic_read(&sent[SMB2_FLUSH_HE]),
50070 - atomic_read(&failed[SMB2_FLUSH_HE]));
50071 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
50072 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
50073 seq_printf(m, "\nReads: %d sent %d failed",
50074 - atomic_read(&sent[SMB2_READ_HE]),
50075 - atomic_read(&failed[SMB2_READ_HE]));
50076 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
50077 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
50078 seq_printf(m, "\nWrites: %d sent %d failed",
50079 - atomic_read(&sent[SMB2_WRITE_HE]),
50080 - atomic_read(&failed[SMB2_WRITE_HE]));
50081 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
50082 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
50083 seq_printf(m, "\nLocks: %d sent %d failed",
50084 - atomic_read(&sent[SMB2_LOCK_HE]),
50085 - atomic_read(&failed[SMB2_LOCK_HE]));
50086 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
50087 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
50088 seq_printf(m, "\nIOCTLs: %d sent %d failed",
50089 - atomic_read(&sent[SMB2_IOCTL_HE]),
50090 - atomic_read(&failed[SMB2_IOCTL_HE]));
50091 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
50092 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
50093 seq_printf(m, "\nCancels: %d sent %d failed",
50094 - atomic_read(&sent[SMB2_CANCEL_HE]),
50095 - atomic_read(&failed[SMB2_CANCEL_HE]));
50096 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
50097 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
50098 seq_printf(m, "\nEchos: %d sent %d failed",
50099 - atomic_read(&sent[SMB2_ECHO_HE]),
50100 - atomic_read(&failed[SMB2_ECHO_HE]));
50101 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
50102 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
50103 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
50104 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
50105 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
50106 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
50107 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
50108 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
50109 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
50110 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
50111 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
50112 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
50113 seq_printf(m, "\nQueryInfos: %d sent %d failed",
50114 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
50115 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
50116 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
50117 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
50118 seq_printf(m, "\nSetInfos: %d sent %d failed",
50119 - atomic_read(&sent[SMB2_SET_INFO_HE]),
50120 - atomic_read(&failed[SMB2_SET_INFO_HE]));
50121 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
50122 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
50123 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
50124 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
50125 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
50126 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
50127 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
50128 #endif
50129 }
50130
50131 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
50132 index 2b95ce2..d079d75 100644
50133 --- a/fs/cifs/smb2pdu.c
50134 +++ b/fs/cifs/smb2pdu.c
50135 @@ -1760,8 +1760,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
50136 default:
50137 cifs_dbg(VFS, "info level %u isn't supported\n",
50138 srch_inf->info_level);
50139 - rc = -EINVAL;
50140 - goto qdir_exit;
50141 + return -EINVAL;
50142 }
50143
50144 req->FileIndex = cpu_to_le32(index);
50145 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
50146 index 1da168c..8bc7ff6 100644
50147 --- a/fs/coda/cache.c
50148 +++ b/fs/coda/cache.c
50149 @@ -24,7 +24,7 @@
50150 #include "coda_linux.h"
50151 #include "coda_cache.h"
50152
50153 -static atomic_t permission_epoch = ATOMIC_INIT(0);
50154 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
50155
50156 /* replace or extend an acl cache hit */
50157 void coda_cache_enter(struct inode *inode, int mask)
50158 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
50159 struct coda_inode_info *cii = ITOC(inode);
50160
50161 spin_lock(&cii->c_lock);
50162 - cii->c_cached_epoch = atomic_read(&permission_epoch);
50163 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
50164 if (!uid_eq(cii->c_uid, current_fsuid())) {
50165 cii->c_uid = current_fsuid();
50166 cii->c_cached_perm = mask;
50167 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
50168 {
50169 struct coda_inode_info *cii = ITOC(inode);
50170 spin_lock(&cii->c_lock);
50171 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
50172 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
50173 spin_unlock(&cii->c_lock);
50174 }
50175
50176 /* remove all acl caches */
50177 void coda_cache_clear_all(struct super_block *sb)
50178 {
50179 - atomic_inc(&permission_epoch);
50180 + atomic_inc_unchecked(&permission_epoch);
50181 }
50182
50183
50184 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
50185 spin_lock(&cii->c_lock);
50186 hit = (mask & cii->c_cached_perm) == mask &&
50187 uid_eq(cii->c_uid, current_fsuid()) &&
50188 - cii->c_cached_epoch == atomic_read(&permission_epoch);
50189 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
50190 spin_unlock(&cii->c_lock);
50191
50192 return hit;
50193 diff --git a/fs/compat.c b/fs/compat.c
50194 index fc3b55d..7b568ae 100644
50195 --- a/fs/compat.c
50196 +++ b/fs/compat.c
50197 @@ -54,7 +54,7 @@
50198 #include <asm/ioctls.h>
50199 #include "internal.h"
50200
50201 -int compat_log = 1;
50202 +int compat_log = 0;
50203
50204 int compat_printk(const char *fmt, ...)
50205 {
50206 @@ -488,7 +488,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
50207
50208 set_fs(KERNEL_DS);
50209 /* The __user pointer cast is valid because of the set_fs() */
50210 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
50211 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
50212 set_fs(oldfs);
50213 /* truncating is ok because it's a user address */
50214 if (!ret)
50215 @@ -546,7 +546,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
50216 goto out;
50217
50218 ret = -EINVAL;
50219 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
50220 + if (nr_segs > UIO_MAXIOV)
50221 goto out;
50222 if (nr_segs > fast_segs) {
50223 ret = -ENOMEM;
50224 @@ -833,6 +833,7 @@ struct compat_old_linux_dirent {
50225
50226 struct compat_readdir_callback {
50227 struct compat_old_linux_dirent __user *dirent;
50228 + struct file * file;
50229 int result;
50230 };
50231
50232 @@ -850,6 +851,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
50233 buf->result = -EOVERFLOW;
50234 return -EOVERFLOW;
50235 }
50236 +
50237 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50238 + return 0;
50239 +
50240 buf->result++;
50241 dirent = buf->dirent;
50242 if (!access_ok(VERIFY_WRITE, dirent,
50243 @@ -880,6 +885,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
50244
50245 buf.result = 0;
50246 buf.dirent = dirent;
50247 + buf.file = f.file;
50248
50249 error = vfs_readdir(f.file, compat_fillonedir, &buf);
50250 if (buf.result)
50251 @@ -899,6 +905,7 @@ struct compat_linux_dirent {
50252 struct compat_getdents_callback {
50253 struct compat_linux_dirent __user *current_dir;
50254 struct compat_linux_dirent __user *previous;
50255 + struct file * file;
50256 int count;
50257 int error;
50258 };
50259 @@ -920,6 +927,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
50260 buf->error = -EOVERFLOW;
50261 return -EOVERFLOW;
50262 }
50263 +
50264 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50265 + return 0;
50266 +
50267 dirent = buf->previous;
50268 if (dirent) {
50269 if (__put_user(offset, &dirent->d_off))
50270 @@ -965,6 +976,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
50271 buf.previous = NULL;
50272 buf.count = count;
50273 buf.error = 0;
50274 + buf.file = f.file;
50275
50276 error = vfs_readdir(f.file, compat_filldir, &buf);
50277 if (error >= 0)
50278 @@ -985,6 +997,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
50279 struct compat_getdents_callback64 {
50280 struct linux_dirent64 __user *current_dir;
50281 struct linux_dirent64 __user *previous;
50282 + struct file * file;
50283 int count;
50284 int error;
50285 };
50286 @@ -1001,6 +1014,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
50287 buf->error = -EINVAL; /* only used if we fail.. */
50288 if (reclen > buf->count)
50289 return -EINVAL;
50290 +
50291 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
50292 + return 0;
50293 +
50294 dirent = buf->previous;
50295
50296 if (dirent) {
50297 @@ -1050,13 +1067,14 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
50298 buf.previous = NULL;
50299 buf.count = count;
50300 buf.error = 0;
50301 + buf.file = f.file;
50302
50303 error = vfs_readdir(f.file, compat_filldir64, &buf);
50304 if (error >= 0)
50305 error = buf.error;
50306 lastdirent = buf.previous;
50307 if (lastdirent) {
50308 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
50309 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
50310 if (__put_user_unaligned(d_off, &lastdirent->d_off))
50311 error = -EFAULT;
50312 else
50313 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
50314 index a81147e..20bf2b5 100644
50315 --- a/fs/compat_binfmt_elf.c
50316 +++ b/fs/compat_binfmt_elf.c
50317 @@ -30,11 +30,13 @@
50318 #undef elf_phdr
50319 #undef elf_shdr
50320 #undef elf_note
50321 +#undef elf_dyn
50322 #undef elf_addr_t
50323 #define elfhdr elf32_hdr
50324 #define elf_phdr elf32_phdr
50325 #define elf_shdr elf32_shdr
50326 #define elf_note elf32_note
50327 +#define elf_dyn Elf32_Dyn
50328 #define elf_addr_t Elf32_Addr
50329
50330 /*
50331 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
50332 index 996cdc5..15e2f33 100644
50333 --- a/fs/compat_ioctl.c
50334 +++ b/fs/compat_ioctl.c
50335 @@ -622,7 +622,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
50336 return -EFAULT;
50337 if (__get_user(udata, &ss32->iomem_base))
50338 return -EFAULT;
50339 - ss.iomem_base = compat_ptr(udata);
50340 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
50341 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
50342 __get_user(ss.port_high, &ss32->port_high))
50343 return -EFAULT;
50344 @@ -703,8 +703,8 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
50345 for (i = 0; i < nmsgs; i++) {
50346 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
50347 return -EFAULT;
50348 - if (get_user(datap, &umsgs[i].buf) ||
50349 - put_user(compat_ptr(datap), &tmsgs[i].buf))
50350 + if (get_user(datap, (u8 __user * __user *)&umsgs[i].buf) ||
50351 + put_user(compat_ptr(datap), (u8 __user * __user *)&tmsgs[i].buf))
50352 return -EFAULT;
50353 }
50354 return sys_ioctl(fd, cmd, (unsigned long)tdata);
50355 @@ -797,7 +797,7 @@ static int compat_ioctl_preallocate(struct file *file,
50356 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
50357 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
50358 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
50359 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
50360 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
50361 return -EFAULT;
50362
50363 return ioctl_preallocate(file, p);
50364 @@ -1619,8 +1619,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
50365 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
50366 {
50367 unsigned int a, b;
50368 - a = *(unsigned int *)p;
50369 - b = *(unsigned int *)q;
50370 + a = *(const unsigned int *)p;
50371 + b = *(const unsigned int *)q;
50372 if (a > b)
50373 return 1;
50374 if (a < b)
50375 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
50376 index 7aabc6a..34c1197 100644
50377 --- a/fs/configfs/dir.c
50378 +++ b/fs/configfs/dir.c
50379 @@ -1565,7 +1565,8 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
50380 }
50381 for (p=q->next; p!= &parent_sd->s_children; p=p->next) {
50382 struct configfs_dirent *next;
50383 - const char * name;
50384 + const unsigned char * name;
50385 + char d_name[sizeof(next->s_dentry->d_iname)];
50386 int len;
50387 struct inode *inode = NULL;
50388
50389 @@ -1575,7 +1576,12 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
50390 continue;
50391
50392 name = configfs_get_name(next);
50393 - len = strlen(name);
50394 + if (next->s_dentry && name == next->s_dentry->d_iname) {
50395 + len = next->s_dentry->d_name.len;
50396 + memcpy(d_name, name, len);
50397 + name = d_name;
50398 + } else
50399 + len = strlen(name);
50400
50401 /*
50402 * We'll have a dentry and an inode for
50403 diff --git a/fs/coredump.c b/fs/coredump.c
50404 index dafafba..10b3b27 100644
50405 --- a/fs/coredump.c
50406 +++ b/fs/coredump.c
50407 @@ -52,7 +52,7 @@ struct core_name {
50408 char *corename;
50409 int used, size;
50410 };
50411 -static atomic_t call_count = ATOMIC_INIT(1);
50412 +static atomic_unchecked_t call_count = ATOMIC_INIT(1);
50413
50414 /* The maximal length of core_pattern is also specified in sysctl.c */
50415
50416 @@ -60,7 +60,7 @@ static int expand_corename(struct core_name *cn)
50417 {
50418 char *old_corename = cn->corename;
50419
50420 - cn->size = CORENAME_MAX_SIZE * atomic_inc_return(&call_count);
50421 + cn->size = CORENAME_MAX_SIZE * atomic_inc_return_unchecked(&call_count);
50422 cn->corename = krealloc(old_corename, cn->size, GFP_KERNEL);
50423
50424 if (!cn->corename) {
50425 @@ -157,7 +157,7 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
50426 int pid_in_pattern = 0;
50427 int err = 0;
50428
50429 - cn->size = CORENAME_MAX_SIZE * atomic_read(&call_count);
50430 + cn->size = CORENAME_MAX_SIZE * atomic_read_unchecked(&call_count);
50431 cn->corename = kmalloc(cn->size, GFP_KERNEL);
50432 cn->used = 0;
50433
50434 @@ -435,8 +435,8 @@ static void wait_for_dump_helpers(struct file *file)
50435 struct pipe_inode_info *pipe = file->private_data;
50436
50437 pipe_lock(pipe);
50438 - pipe->readers++;
50439 - pipe->writers--;
50440 + atomic_inc(&pipe->readers);
50441 + atomic_dec(&pipe->writers);
50442 wake_up_interruptible_sync(&pipe->wait);
50443 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
50444 pipe_unlock(pipe);
50445 @@ -445,11 +445,11 @@ static void wait_for_dump_helpers(struct file *file)
50446 * We actually want wait_event_freezable() but then we need
50447 * to clear TIF_SIGPENDING and improve dump_interrupted().
50448 */
50449 - wait_event_interruptible(pipe->wait, pipe->readers == 1);
50450 + wait_event_interruptible(pipe->wait, atomic_read(&pipe->readers) == 1);
50451
50452 pipe_lock(pipe);
50453 - pipe->readers--;
50454 - pipe->writers++;
50455 + atomic_dec(&pipe->readers);
50456 + atomic_inc(&pipe->writers);
50457 pipe_unlock(pipe);
50458 }
50459
50460 @@ -496,7 +496,8 @@ void do_coredump(siginfo_t *siginfo)
50461 struct files_struct *displaced;
50462 bool need_nonrelative = false;
50463 bool core_dumped = false;
50464 - static atomic_t core_dump_count = ATOMIC_INIT(0);
50465 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
50466 + long signr = siginfo->si_signo;
50467 struct coredump_params cprm = {
50468 .siginfo = siginfo,
50469 .regs = signal_pt_regs(),
50470 @@ -509,7 +510,10 @@ void do_coredump(siginfo_t *siginfo)
50471 .mm_flags = mm->flags,
50472 };
50473
50474 - audit_core_dumps(siginfo->si_signo);
50475 + audit_core_dumps(signr);
50476 +
50477 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
50478 + gr_handle_brute_attach(cprm.mm_flags);
50479
50480 binfmt = mm->binfmt;
50481 if (!binfmt || !binfmt->core_dump)
50482 @@ -533,7 +537,7 @@ void do_coredump(siginfo_t *siginfo)
50483 need_nonrelative = true;
50484 }
50485
50486 - retval = coredump_wait(siginfo->si_signo, &core_state);
50487 + retval = coredump_wait(signr, &core_state);
50488 if (retval < 0)
50489 goto fail_creds;
50490
50491 @@ -576,7 +580,7 @@ void do_coredump(siginfo_t *siginfo)
50492 }
50493 cprm.limit = RLIM_INFINITY;
50494
50495 - dump_count = atomic_inc_return(&core_dump_count);
50496 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
50497 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
50498 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
50499 task_tgid_vnr(current), current->comm);
50500 @@ -608,6 +612,8 @@ void do_coredump(siginfo_t *siginfo)
50501 } else {
50502 struct inode *inode;
50503
50504 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
50505 +
50506 if (cprm.limit < binfmt->min_coredump)
50507 goto fail_unlock;
50508
50509 @@ -666,7 +672,7 @@ close_fail:
50510 filp_close(cprm.file, NULL);
50511 fail_dropcount:
50512 if (ispipe)
50513 - atomic_dec(&core_dump_count);
50514 + atomic_dec_unchecked(&core_dump_count);
50515 fail_unlock:
50516 kfree(cn.corename);
50517 fail_corename:
50518 @@ -687,7 +693,7 @@ int dump_write(struct file *file, const void *addr, int nr)
50519 {
50520 return !dump_interrupted() &&
50521 access_ok(VERIFY_READ, addr, nr) &&
50522 - file->f_op->write(file, addr, nr, &file->f_pos) == nr;
50523 + file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
50524 }
50525 EXPORT_SYMBOL(dump_write);
50526
50527 diff --git a/fs/dcache.c b/fs/dcache.c
50528 index f09b908..4dd10d8 100644
50529 --- a/fs/dcache.c
50530 +++ b/fs/dcache.c
50531 @@ -3086,7 +3086,7 @@ void __init vfs_caches_init(unsigned long mempages)
50532 mempages -= reserve;
50533
50534 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
50535 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
50536 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY, NULL);
50537
50538 dcache_init();
50539 inode_init();
50540 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
50541 index 4888cb3..e0f7cf8 100644
50542 --- a/fs/debugfs/inode.c
50543 +++ b/fs/debugfs/inode.c
50544 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
50545 */
50546 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
50547 {
50548 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
50549 + return __create_file(name, S_IFDIR | S_IRWXU,
50550 +#else
50551 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
50552 +#endif
50553 parent, NULL, NULL);
50554 }
50555 EXPORT_SYMBOL_GPL(debugfs_create_dir);
50556 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
50557 index 5eab400..810a3f5 100644
50558 --- a/fs/ecryptfs/inode.c
50559 +++ b/fs/ecryptfs/inode.c
50560 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
50561 old_fs = get_fs();
50562 set_fs(get_ds());
50563 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
50564 - (char __user *)lower_buf,
50565 + (char __force_user *)lower_buf,
50566 PATH_MAX);
50567 set_fs(old_fs);
50568 if (rc < 0)
50569 @@ -706,7 +706,7 @@ out:
50570 static void
50571 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
50572 {
50573 - char *buf = nd_get_link(nd);
50574 + const char *buf = nd_get_link(nd);
50575 if (!IS_ERR(buf)) {
50576 /* Free the char* */
50577 kfree(buf);
50578 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
50579 index e4141f2..d8263e8 100644
50580 --- a/fs/ecryptfs/miscdev.c
50581 +++ b/fs/ecryptfs/miscdev.c
50582 @@ -304,7 +304,7 @@ check_list:
50583 goto out_unlock_msg_ctx;
50584 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
50585 if (msg_ctx->msg) {
50586 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
50587 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
50588 goto out_unlock_msg_ctx;
50589 i += packet_length_size;
50590 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
50591 diff --git a/fs/exec.c b/fs/exec.c
50592 index ffd7a81..e38107f 100644
50593 --- a/fs/exec.c
50594 +++ b/fs/exec.c
50595 @@ -55,8 +55,20 @@
50596 #include <linux/pipe_fs_i.h>
50597 #include <linux/oom.h>
50598 #include <linux/compat.h>
50599 +#include <linux/random.h>
50600 +#include <linux/seq_file.h>
50601 +#include <linux/coredump.h>
50602 +#include <linux/mman.h>
50603 +
50604 +#ifdef CONFIG_PAX_REFCOUNT
50605 +#include <linux/kallsyms.h>
50606 +#include <linux/kdebug.h>
50607 +#endif
50608 +
50609 +#include <trace/events/fs.h>
50610
50611 #include <asm/uaccess.h>
50612 +#include <asm/sections.h>
50613 #include <asm/mmu_context.h>
50614 #include <asm/tlb.h>
50615
50616 @@ -66,17 +78,32 @@
50617
50618 #include <trace/events/sched.h>
50619
50620 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
50621 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
50622 +{
50623 + 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");
50624 +}
50625 +#endif
50626 +
50627 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
50628 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
50629 +EXPORT_SYMBOL(pax_set_initial_flags_func);
50630 +#endif
50631 +
50632 int suid_dumpable = 0;
50633
50634 static LIST_HEAD(formats);
50635 static DEFINE_RWLOCK(binfmt_lock);
50636
50637 +extern int gr_process_kernel_exec_ban(void);
50638 +extern int gr_process_suid_exec_ban(const struct linux_binprm *bprm);
50639 +
50640 void __register_binfmt(struct linux_binfmt * fmt, int insert)
50641 {
50642 BUG_ON(!fmt);
50643 write_lock(&binfmt_lock);
50644 - insert ? list_add(&fmt->lh, &formats) :
50645 - list_add_tail(&fmt->lh, &formats);
50646 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
50647 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
50648 write_unlock(&binfmt_lock);
50649 }
50650
50651 @@ -85,7 +112,7 @@ EXPORT_SYMBOL(__register_binfmt);
50652 void unregister_binfmt(struct linux_binfmt * fmt)
50653 {
50654 write_lock(&binfmt_lock);
50655 - list_del(&fmt->lh);
50656 + pax_list_del((struct list_head *)&fmt->lh);
50657 write_unlock(&binfmt_lock);
50658 }
50659
50660 @@ -180,18 +207,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50661 int write)
50662 {
50663 struct page *page;
50664 - int ret;
50665
50666 -#ifdef CONFIG_STACK_GROWSUP
50667 - if (write) {
50668 - ret = expand_downwards(bprm->vma, pos);
50669 - if (ret < 0)
50670 - return NULL;
50671 - }
50672 -#endif
50673 - ret = get_user_pages(current, bprm->mm, pos,
50674 - 1, write, 1, &page, NULL);
50675 - if (ret <= 0)
50676 + if (0 > expand_downwards(bprm->vma, pos))
50677 + return NULL;
50678 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
50679 return NULL;
50680
50681 if (write) {
50682 @@ -207,6 +226,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
50683 if (size <= ARG_MAX)
50684 return page;
50685
50686 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50687 + // only allow 512KB for argv+env on suid/sgid binaries
50688 + // to prevent easy ASLR exhaustion
50689 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
50690 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
50691 + (size > (512 * 1024))) {
50692 + put_page(page);
50693 + return NULL;
50694 + }
50695 +#endif
50696 +
50697 /*
50698 * Limit to 1/4-th the stack size for the argv+env strings.
50699 * This ensures that:
50700 @@ -266,6 +296,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50701 vma->vm_end = STACK_TOP_MAX;
50702 vma->vm_start = vma->vm_end - PAGE_SIZE;
50703 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
50704 +
50705 +#ifdef CONFIG_PAX_SEGMEXEC
50706 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
50707 +#endif
50708 +
50709 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
50710 INIT_LIST_HEAD(&vma->anon_vma_chain);
50711
50712 @@ -276,6 +311,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
50713 mm->stack_vm = mm->total_vm = 1;
50714 up_write(&mm->mmap_sem);
50715 bprm->p = vma->vm_end - sizeof(void *);
50716 +
50717 +#ifdef CONFIG_PAX_RANDUSTACK
50718 + if (randomize_va_space)
50719 + bprm->p ^= prandom_u32() & ~PAGE_MASK;
50720 +#endif
50721 +
50722 return 0;
50723 err:
50724 up_write(&mm->mmap_sem);
50725 @@ -396,7 +437,7 @@ struct user_arg_ptr {
50726 } ptr;
50727 };
50728
50729 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50730 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50731 {
50732 const char __user *native;
50733
50734 @@ -405,14 +446,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
50735 compat_uptr_t compat;
50736
50737 if (get_user(compat, argv.ptr.compat + nr))
50738 - return ERR_PTR(-EFAULT);
50739 + return (const char __force_user *)ERR_PTR(-EFAULT);
50740
50741 return compat_ptr(compat);
50742 }
50743 #endif
50744
50745 if (get_user(native, argv.ptr.native + nr))
50746 - return ERR_PTR(-EFAULT);
50747 + return (const char __force_user *)ERR_PTR(-EFAULT);
50748
50749 return native;
50750 }
50751 @@ -431,7 +472,7 @@ static int count(struct user_arg_ptr argv, int max)
50752 if (!p)
50753 break;
50754
50755 - if (IS_ERR(p))
50756 + if (IS_ERR((const char __force_kernel *)p))
50757 return -EFAULT;
50758
50759 if (i >= max)
50760 @@ -466,7 +507,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
50761
50762 ret = -EFAULT;
50763 str = get_user_arg_ptr(argv, argc);
50764 - if (IS_ERR(str))
50765 + if (IS_ERR((const char __force_kernel *)str))
50766 goto out;
50767
50768 len = strnlen_user(str, MAX_ARG_STRLEN);
50769 @@ -548,7 +589,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
50770 int r;
50771 mm_segment_t oldfs = get_fs();
50772 struct user_arg_ptr argv = {
50773 - .ptr.native = (const char __user *const __user *)__argv,
50774 + .ptr.native = (const char __force_user * const __force_user *)__argv,
50775 };
50776
50777 set_fs(KERNEL_DS);
50778 @@ -583,7 +624,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
50779 unsigned long new_end = old_end - shift;
50780 struct mmu_gather tlb;
50781
50782 - BUG_ON(new_start > new_end);
50783 + if (new_start >= new_end || new_start < mmap_min_addr)
50784 + return -ENOMEM;
50785
50786 /*
50787 * ensure there are no vmas between where we want to go
50788 @@ -592,6 +634,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
50789 if (vma != find_vma(mm, new_start))
50790 return -EFAULT;
50791
50792 +#ifdef CONFIG_PAX_SEGMEXEC
50793 + BUG_ON(pax_find_mirror_vma(vma));
50794 +#endif
50795 +
50796 /*
50797 * cover the whole range: [new_start, old_end)
50798 */
50799 @@ -672,10 +718,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
50800 stack_top = arch_align_stack(stack_top);
50801 stack_top = PAGE_ALIGN(stack_top);
50802
50803 - if (unlikely(stack_top < mmap_min_addr) ||
50804 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
50805 - return -ENOMEM;
50806 -
50807 stack_shift = vma->vm_end - stack_top;
50808
50809 bprm->p -= stack_shift;
50810 @@ -687,8 +729,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
50811 bprm->exec -= stack_shift;
50812
50813 down_write(&mm->mmap_sem);
50814 +
50815 + /* Move stack pages down in memory. */
50816 + if (stack_shift) {
50817 + ret = shift_arg_pages(vma, stack_shift);
50818 + if (ret)
50819 + goto out_unlock;
50820 + }
50821 +
50822 vm_flags = VM_STACK_FLAGS;
50823
50824 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
50825 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
50826 + vm_flags &= ~VM_EXEC;
50827 +
50828 +#ifdef CONFIG_PAX_MPROTECT
50829 + if (mm->pax_flags & MF_PAX_MPROTECT)
50830 + vm_flags &= ~VM_MAYEXEC;
50831 +#endif
50832 +
50833 + }
50834 +#endif
50835 +
50836 /*
50837 * Adjust stack execute permissions; explicitly enable for
50838 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
50839 @@ -707,13 +769,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
50840 goto out_unlock;
50841 BUG_ON(prev != vma);
50842
50843 - /* Move stack pages down in memory. */
50844 - if (stack_shift) {
50845 - ret = shift_arg_pages(vma, stack_shift);
50846 - if (ret)
50847 - goto out_unlock;
50848 - }
50849 -
50850 /* mprotect_fixup is overkill to remove the temporary stack flags */
50851 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
50852
50853 @@ -737,6 +792,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
50854 #endif
50855 current->mm->start_stack = bprm->p;
50856 ret = expand_stack(vma, stack_base);
50857 +
50858 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
50859 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
50860 + unsigned long size;
50861 + vm_flags_t vm_flags;
50862 +
50863 + size = STACK_TOP - vma->vm_end;
50864 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
50865 +
50866 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, vm_flags, 0);
50867 +
50868 +#ifdef CONFIG_X86
50869 + if (!ret) {
50870 + size = mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
50871 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), vm_flags, 0);
50872 + }
50873 +#endif
50874 +
50875 + }
50876 +#endif
50877 +
50878 if (ret)
50879 ret = -EFAULT;
50880
50881 @@ -772,6 +848,8 @@ struct file *open_exec(const char *name)
50882
50883 fsnotify_open(file);
50884
50885 + trace_open_exec(name);
50886 +
50887 err = deny_write_access(file);
50888 if (err)
50889 goto exit;
50890 @@ -795,7 +873,7 @@ int kernel_read(struct file *file, loff_t offset,
50891 old_fs = get_fs();
50892 set_fs(get_ds());
50893 /* The cast to a user pointer is valid due to the set_fs() */
50894 - result = vfs_read(file, (void __user *)addr, count, &pos);
50895 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
50896 set_fs(old_fs);
50897 return result;
50898 }
50899 @@ -1251,7 +1329,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
50900 }
50901 rcu_read_unlock();
50902
50903 - if (p->fs->users > n_fs) {
50904 + if (atomic_read(&p->fs->users) > n_fs) {
50905 bprm->unsafe |= LSM_UNSAFE_SHARE;
50906 } else {
50907 res = -EAGAIN;
50908 @@ -1451,6 +1529,31 @@ int search_binary_handler(struct linux_binprm *bprm)
50909
50910 EXPORT_SYMBOL(search_binary_handler);
50911
50912 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50913 +static DEFINE_PER_CPU(u64, exec_counter);
50914 +static int __init init_exec_counters(void)
50915 +{
50916 + unsigned int cpu;
50917 +
50918 + for_each_possible_cpu(cpu) {
50919 + per_cpu(exec_counter, cpu) = (u64)cpu;
50920 + }
50921 +
50922 + return 0;
50923 +}
50924 +early_initcall(init_exec_counters);
50925 +static inline void increment_exec_counter(void)
50926 +{
50927 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
50928 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
50929 +}
50930 +#else
50931 +static inline void increment_exec_counter(void) {}
50932 +#endif
50933 +
50934 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
50935 + struct user_arg_ptr argv);
50936 +
50937 /*
50938 * sys_execve() executes a new program.
50939 */
50940 @@ -1458,6 +1561,11 @@ static int do_execve_common(const char *filename,
50941 struct user_arg_ptr argv,
50942 struct user_arg_ptr envp)
50943 {
50944 +#ifdef CONFIG_GRKERNSEC
50945 + struct file *old_exec_file;
50946 + struct acl_subject_label *old_acl;
50947 + struct rlimit old_rlim[RLIM_NLIMITS];
50948 +#endif
50949 struct linux_binprm *bprm;
50950 struct file *file;
50951 struct files_struct *displaced;
50952 @@ -1465,6 +1573,8 @@ static int do_execve_common(const char *filename,
50953 int retval;
50954 const struct cred *cred = current_cred();
50955
50956 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&cred->user->processes), 1);
50957 +
50958 /*
50959 * We move the actual failure in case of RLIMIT_NPROC excess from
50960 * set*uid() to execve() because too many poorly written programs
50961 @@ -1505,12 +1615,22 @@ static int do_execve_common(const char *filename,
50962 if (IS_ERR(file))
50963 goto out_unmark;
50964
50965 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
50966 + retval = -EPERM;
50967 + goto out_file;
50968 + }
50969 +
50970 sched_exec();
50971
50972 bprm->file = file;
50973 bprm->filename = filename;
50974 bprm->interp = filename;
50975
50976 + if (!gr_acl_handle_execve(file->f_path.dentry, file->f_path.mnt)) {
50977 + retval = -EACCES;
50978 + goto out_file;
50979 + }
50980 +
50981 retval = bprm_mm_init(bprm);
50982 if (retval)
50983 goto out_file;
50984 @@ -1527,24 +1647,70 @@ static int do_execve_common(const char *filename,
50985 if (retval < 0)
50986 goto out;
50987
50988 +#ifdef CONFIG_GRKERNSEC
50989 + old_acl = current->acl;
50990 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
50991 + old_exec_file = current->exec_file;
50992 + get_file(file);
50993 + current->exec_file = file;
50994 +#endif
50995 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
50996 + /* limit suid stack to 8MB
50997 + * we saved the old limits above and will restore them if this exec fails
50998 + */
50999 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
51000 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
51001 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
51002 +#endif
51003 +
51004 + if (gr_process_kernel_exec_ban() || gr_process_suid_exec_ban(bprm)) {
51005 + retval = -EPERM;
51006 + goto out_fail;
51007 + }
51008 +
51009 + if (!gr_tpe_allow(file)) {
51010 + retval = -EACCES;
51011 + goto out_fail;
51012 + }
51013 +
51014 + if (gr_check_crash_exec(file)) {
51015 + retval = -EACCES;
51016 + goto out_fail;
51017 + }
51018 +
51019 + retval = gr_set_proc_label(file->f_path.dentry, file->f_path.mnt,
51020 + bprm->unsafe);
51021 + if (retval < 0)
51022 + goto out_fail;
51023 +
51024 retval = copy_strings_kernel(1, &bprm->filename, bprm);
51025 if (retval < 0)
51026 - goto out;
51027 + goto out_fail;
51028
51029 bprm->exec = bprm->p;
51030 retval = copy_strings(bprm->envc, envp, bprm);
51031 if (retval < 0)
51032 - goto out;
51033 + goto out_fail;
51034
51035 retval = copy_strings(bprm->argc, argv, bprm);
51036 if (retval < 0)
51037 - goto out;
51038 + goto out_fail;
51039 +
51040 + gr_log_chroot_exec(file->f_path.dentry, file->f_path.mnt);
51041 +
51042 + gr_handle_exec_args(bprm, argv);
51043
51044 retval = search_binary_handler(bprm);
51045 if (retval < 0)
51046 - goto out;
51047 + goto out_fail;
51048 +#ifdef CONFIG_GRKERNSEC
51049 + if (old_exec_file)
51050 + fput(old_exec_file);
51051 +#endif
51052
51053 /* execve succeeded */
51054 +
51055 + increment_exec_counter();
51056 current->fs->in_exec = 0;
51057 current->in_execve = 0;
51058 acct_update_integrals(current);
51059 @@ -1553,6 +1719,14 @@ static int do_execve_common(const char *filename,
51060 put_files_struct(displaced);
51061 return retval;
51062
51063 +out_fail:
51064 +#ifdef CONFIG_GRKERNSEC
51065 + current->acl = old_acl;
51066 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
51067 + fput(current->exec_file);
51068 + current->exec_file = old_exec_file;
51069 +#endif
51070 +
51071 out:
51072 if (bprm->mm) {
51073 acct_arg_size(bprm, 0);
51074 @@ -1701,3 +1875,283 @@ asmlinkage long compat_sys_execve(const char __user * filename,
51075 return error;
51076 }
51077 #endif
51078 +
51079 +int pax_check_flags(unsigned long *flags)
51080 +{
51081 + int retval = 0;
51082 +
51083 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
51084 + if (*flags & MF_PAX_SEGMEXEC)
51085 + {
51086 + *flags &= ~MF_PAX_SEGMEXEC;
51087 + retval = -EINVAL;
51088 + }
51089 +#endif
51090 +
51091 + if ((*flags & MF_PAX_PAGEEXEC)
51092 +
51093 +#ifdef CONFIG_PAX_PAGEEXEC
51094 + && (*flags & MF_PAX_SEGMEXEC)
51095 +#endif
51096 +
51097 + )
51098 + {
51099 + *flags &= ~MF_PAX_PAGEEXEC;
51100 + retval = -EINVAL;
51101 + }
51102 +
51103 + if ((*flags & MF_PAX_MPROTECT)
51104 +
51105 +#ifdef CONFIG_PAX_MPROTECT
51106 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
51107 +#endif
51108 +
51109 + )
51110 + {
51111 + *flags &= ~MF_PAX_MPROTECT;
51112 + retval = -EINVAL;
51113 + }
51114 +
51115 + if ((*flags & MF_PAX_EMUTRAMP)
51116 +
51117 +#ifdef CONFIG_PAX_EMUTRAMP
51118 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
51119 +#endif
51120 +
51121 + )
51122 + {
51123 + *flags &= ~MF_PAX_EMUTRAMP;
51124 + retval = -EINVAL;
51125 + }
51126 +
51127 + return retval;
51128 +}
51129 +
51130 +EXPORT_SYMBOL(pax_check_flags);
51131 +
51132 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
51133 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
51134 +{
51135 + struct task_struct *tsk = current;
51136 + struct mm_struct *mm = current->mm;
51137 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
51138 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
51139 + char *path_exec = NULL;
51140 + char *path_fault = NULL;
51141 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
51142 + siginfo_t info = { };
51143 +
51144 + if (buffer_exec && buffer_fault) {
51145 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
51146 +
51147 + down_read(&mm->mmap_sem);
51148 + vma = mm->mmap;
51149 + while (vma && (!vma_exec || !vma_fault)) {
51150 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
51151 + vma_exec = vma;
51152 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
51153 + vma_fault = vma;
51154 + vma = vma->vm_next;
51155 + }
51156 + if (vma_exec) {
51157 + path_exec = d_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
51158 + if (IS_ERR(path_exec))
51159 + path_exec = "<path too long>";
51160 + else {
51161 + path_exec = mangle_path(buffer_exec, path_exec, "\t\n\\");
51162 + if (path_exec) {
51163 + *path_exec = 0;
51164 + path_exec = buffer_exec;
51165 + } else
51166 + path_exec = "<path too long>";
51167 + }
51168 + }
51169 + if (vma_fault) {
51170 + start = vma_fault->vm_start;
51171 + end = vma_fault->vm_end;
51172 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
51173 + if (vma_fault->vm_file) {
51174 + path_fault = d_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
51175 + if (IS_ERR(path_fault))
51176 + path_fault = "<path too long>";
51177 + else {
51178 + path_fault = mangle_path(buffer_fault, path_fault, "\t\n\\");
51179 + if (path_fault) {
51180 + *path_fault = 0;
51181 + path_fault = buffer_fault;
51182 + } else
51183 + path_fault = "<path too long>";
51184 + }
51185 + } else
51186 + path_fault = "<anonymous mapping>";
51187 + }
51188 + up_read(&mm->mmap_sem);
51189 + }
51190 + if (tsk->signal->curr_ip)
51191 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
51192 + else
51193 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
51194 + 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),
51195 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
51196 + free_page((unsigned long)buffer_exec);
51197 + free_page((unsigned long)buffer_fault);
51198 + pax_report_insns(regs, pc, sp);
51199 + info.si_signo = SIGKILL;
51200 + info.si_errno = 0;
51201 + info.si_code = SI_KERNEL;
51202 + info.si_pid = 0;
51203 + info.si_uid = 0;
51204 + do_coredump(&info);
51205 +}
51206 +#endif
51207 +
51208 +#ifdef CONFIG_PAX_REFCOUNT
51209 +void pax_report_refcount_overflow(struct pt_regs *regs)
51210 +{
51211 + if (current->signal->curr_ip)
51212 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
51213 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
51214 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
51215 + else
51216 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
51217 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
51218 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
51219 + show_regs(regs);
51220 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
51221 +}
51222 +#endif
51223 +
51224 +#ifdef CONFIG_PAX_USERCOPY
51225 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
51226 +static noinline int check_stack_object(const void *obj, unsigned long len)
51227 +{
51228 + const void * const stack = task_stack_page(current);
51229 + const void * const stackend = stack + THREAD_SIZE;
51230 +
51231 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
51232 + const void *frame = NULL;
51233 + const void *oldframe;
51234 +#endif
51235 +
51236 + if (obj + len < obj)
51237 + return -1;
51238 +
51239 + if (obj + len <= stack || stackend <= obj)
51240 + return 0;
51241 +
51242 + if (obj < stack || stackend < obj + len)
51243 + return -1;
51244 +
51245 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
51246 + oldframe = __builtin_frame_address(1);
51247 + if (oldframe)
51248 + frame = __builtin_frame_address(2);
51249 + /*
51250 + low ----------------------------------------------> high
51251 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
51252 + ^----------------^
51253 + allow copies only within here
51254 + */
51255 + while (stack <= frame && frame < stackend) {
51256 + /* if obj + len extends past the last frame, this
51257 + check won't pass and the next frame will be 0,
51258 + causing us to bail out and correctly report
51259 + the copy as invalid
51260 + */
51261 + if (obj + len <= frame)
51262 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
51263 + oldframe = frame;
51264 + frame = *(const void * const *)frame;
51265 + }
51266 + return -1;
51267 +#else
51268 + return 1;
51269 +#endif
51270 +}
51271 +
51272 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
51273 +{
51274 + if (current->signal->curr_ip)
51275 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
51276 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
51277 + else
51278 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
51279 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
51280 + dump_stack();
51281 + gr_handle_kernel_exploit();
51282 + do_group_exit(SIGKILL);
51283 +}
51284 +#endif
51285 +
51286 +#ifdef CONFIG_PAX_USERCOPY
51287 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
51288 +{
51289 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
51290 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
51291 +#ifdef CONFIG_MODULES
51292 + unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
51293 +#else
51294 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
51295 +#endif
51296 +
51297 +#else
51298 + unsigned long textlow = (unsigned long)_stext;
51299 + unsigned long texthigh = (unsigned long)_etext;
51300 +#endif
51301 +
51302 + if (high <= textlow || low > texthigh)
51303 + return false;
51304 + else
51305 + return true;
51306 +}
51307 +#endif
51308 +
51309 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
51310 +{
51311 +
51312 +#ifdef CONFIG_PAX_USERCOPY
51313 + const char *type;
51314 +
51315 + if (!n)
51316 + return;
51317 +
51318 + type = check_heap_object(ptr, n);
51319 + if (!type) {
51320 + int ret = check_stack_object(ptr, n);
51321 + if (ret == 1 || ret == 2)
51322 + return;
51323 + if (ret == 0) {
51324 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
51325 + type = "<kernel text>";
51326 + else
51327 + return;
51328 + } else
51329 + type = "<process stack>";
51330 + }
51331 +
51332 + pax_report_usercopy(ptr, n, to_user, type);
51333 +#endif
51334 +
51335 +}
51336 +EXPORT_SYMBOL(__check_object_size);
51337 +
51338 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
51339 +void pax_track_stack(void)
51340 +{
51341 + unsigned long sp = (unsigned long)&sp;
51342 + if (sp < current_thread_info()->lowest_stack &&
51343 + sp > (unsigned long)task_stack_page(current))
51344 + current_thread_info()->lowest_stack = sp;
51345 +}
51346 +EXPORT_SYMBOL(pax_track_stack);
51347 +#endif
51348 +
51349 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
51350 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
51351 +{
51352 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
51353 + dump_stack();
51354 + do_group_exit(SIGKILL);
51355 +}
51356 +EXPORT_SYMBOL(report_size_overflow);
51357 +#endif
51358 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
51359 index 9f9992b..8b59411 100644
51360 --- a/fs/ext2/balloc.c
51361 +++ b/fs/ext2/balloc.c
51362 @@ -1184,10 +1184,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
51363
51364 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
51365 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
51366 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
51367 + if (free_blocks < root_blocks + 1 &&
51368 !uid_eq(sbi->s_resuid, current_fsuid()) &&
51369 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
51370 - !in_group_p (sbi->s_resgid))) {
51371 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
51372 return 0;
51373 }
51374 return 1;
51375 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
51376 index 22548f5..41521d8 100644
51377 --- a/fs/ext3/balloc.c
51378 +++ b/fs/ext3/balloc.c
51379 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
51380
51381 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
51382 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
51383 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
51384 + if (free_blocks < root_blocks + 1 &&
51385 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
51386 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
51387 - !in_group_p (sbi->s_resgid))) {
51388 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
51389 return 0;
51390 }
51391 return 1;
51392 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
51393 index d0f13ea..4b2dadd 100644
51394 --- a/fs/ext4/balloc.c
51395 +++ b/fs/ext4/balloc.c
51396 @@ -528,8 +528,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
51397 /* Hm, nope. Are (enough) root reserved clusters available? */
51398 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
51399 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
51400 - capable(CAP_SYS_RESOURCE) ||
51401 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
51402 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
51403 + capable_nolog(CAP_SYS_RESOURCE)) {
51404
51405 if (free_clusters >= (nclusters + dirty_clusters +
51406 resv_clusters))
51407 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
51408 index 5aae3d1..b5da7f8 100644
51409 --- a/fs/ext4/ext4.h
51410 +++ b/fs/ext4/ext4.h
51411 @@ -1252,19 +1252,19 @@ struct ext4_sb_info {
51412 unsigned long s_mb_last_start;
51413
51414 /* stats for buddy allocator */
51415 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
51416 - atomic_t s_bal_success; /* we found long enough chunks */
51417 - atomic_t s_bal_allocated; /* in blocks */
51418 - atomic_t s_bal_ex_scanned; /* total extents scanned */
51419 - atomic_t s_bal_goals; /* goal hits */
51420 - atomic_t s_bal_breaks; /* too long searches */
51421 - atomic_t s_bal_2orders; /* 2^order hits */
51422 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
51423 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
51424 + atomic_unchecked_t s_bal_allocated; /* in blocks */
51425 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
51426 + atomic_unchecked_t s_bal_goals; /* goal hits */
51427 + atomic_unchecked_t s_bal_breaks; /* too long searches */
51428 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
51429 spinlock_t s_bal_lock;
51430 unsigned long s_mb_buddies_generated;
51431 unsigned long long s_mb_generation_time;
51432 - atomic_t s_mb_lost_chunks;
51433 - atomic_t s_mb_preallocated;
51434 - atomic_t s_mb_discarded;
51435 + atomic_unchecked_t s_mb_lost_chunks;
51436 + atomic_unchecked_t s_mb_preallocated;
51437 + atomic_unchecked_t s_mb_discarded;
51438 atomic_t s_lock_busy;
51439
51440 /* locality groups */
51441 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
51442 index def8408..8253d11 100644
51443 --- a/fs/ext4/mballoc.c
51444 +++ b/fs/ext4/mballoc.c
51445 @@ -1865,7 +1865,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
51446 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
51447
51448 if (EXT4_SB(sb)->s_mb_stats)
51449 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
51450 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
51451
51452 break;
51453 }
51454 @@ -2170,7 +2170,7 @@ repeat:
51455 ac->ac_status = AC_STATUS_CONTINUE;
51456 ac->ac_flags |= EXT4_MB_HINT_FIRST;
51457 cr = 3;
51458 - atomic_inc(&sbi->s_mb_lost_chunks);
51459 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
51460 goto repeat;
51461 }
51462 }
51463 @@ -2678,25 +2678,25 @@ int ext4_mb_release(struct super_block *sb)
51464 if (sbi->s_mb_stats) {
51465 ext4_msg(sb, KERN_INFO,
51466 "mballoc: %u blocks %u reqs (%u success)",
51467 - atomic_read(&sbi->s_bal_allocated),
51468 - atomic_read(&sbi->s_bal_reqs),
51469 - atomic_read(&sbi->s_bal_success));
51470 + atomic_read_unchecked(&sbi->s_bal_allocated),
51471 + atomic_read_unchecked(&sbi->s_bal_reqs),
51472 + atomic_read_unchecked(&sbi->s_bal_success));
51473 ext4_msg(sb, KERN_INFO,
51474 "mballoc: %u extents scanned, %u goal hits, "
51475 "%u 2^N hits, %u breaks, %u lost",
51476 - atomic_read(&sbi->s_bal_ex_scanned),
51477 - atomic_read(&sbi->s_bal_goals),
51478 - atomic_read(&sbi->s_bal_2orders),
51479 - atomic_read(&sbi->s_bal_breaks),
51480 - atomic_read(&sbi->s_mb_lost_chunks));
51481 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
51482 + atomic_read_unchecked(&sbi->s_bal_goals),
51483 + atomic_read_unchecked(&sbi->s_bal_2orders),
51484 + atomic_read_unchecked(&sbi->s_bal_breaks),
51485 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
51486 ext4_msg(sb, KERN_INFO,
51487 "mballoc: %lu generated and it took %Lu",
51488 sbi->s_mb_buddies_generated,
51489 sbi->s_mb_generation_time);
51490 ext4_msg(sb, KERN_INFO,
51491 "mballoc: %u preallocated, %u discarded",
51492 - atomic_read(&sbi->s_mb_preallocated),
51493 - atomic_read(&sbi->s_mb_discarded));
51494 + atomic_read_unchecked(&sbi->s_mb_preallocated),
51495 + atomic_read_unchecked(&sbi->s_mb_discarded));
51496 }
51497
51498 free_percpu(sbi->s_locality_groups);
51499 @@ -3150,16 +3150,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
51500 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
51501
51502 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
51503 - atomic_inc(&sbi->s_bal_reqs);
51504 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
51505 + atomic_inc_unchecked(&sbi->s_bal_reqs);
51506 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
51507 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
51508 - atomic_inc(&sbi->s_bal_success);
51509 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
51510 + atomic_inc_unchecked(&sbi->s_bal_success);
51511 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
51512 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
51513 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
51514 - atomic_inc(&sbi->s_bal_goals);
51515 + atomic_inc_unchecked(&sbi->s_bal_goals);
51516 if (ac->ac_found > sbi->s_mb_max_to_scan)
51517 - atomic_inc(&sbi->s_bal_breaks);
51518 + atomic_inc_unchecked(&sbi->s_bal_breaks);
51519 }
51520
51521 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
51522 @@ -3559,7 +3559,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
51523 trace_ext4_mb_new_inode_pa(ac, pa);
51524
51525 ext4_mb_use_inode_pa(ac, pa);
51526 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
51527 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
51528
51529 ei = EXT4_I(ac->ac_inode);
51530 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
51531 @@ -3619,7 +3619,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
51532 trace_ext4_mb_new_group_pa(ac, pa);
51533
51534 ext4_mb_use_group_pa(ac, pa);
51535 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
51536 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
51537
51538 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
51539 lg = ac->ac_lg;
51540 @@ -3708,7 +3708,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
51541 * from the bitmap and continue.
51542 */
51543 }
51544 - atomic_add(free, &sbi->s_mb_discarded);
51545 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
51546
51547 return err;
51548 }
51549 @@ -3726,7 +3726,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
51550 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
51551 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
51552 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
51553 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
51554 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
51555 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
51556
51557 return 0;
51558 diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
51559 index 214461e..3614c89 100644
51560 --- a/fs/ext4/mmp.c
51561 +++ b/fs/ext4/mmp.c
51562 @@ -113,7 +113,7 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
51563 void __dump_mmp_msg(struct super_block *sb, struct mmp_struct *mmp,
51564 const char *function, unsigned int line, const char *msg)
51565 {
51566 - __ext4_warning(sb, function, line, msg);
51567 + __ext4_warning(sb, function, line, "%s", msg);
51568 __ext4_warning(sb, function, line,
51569 "MMP failure info: last update time: %llu, last update "
51570 "node: %s, last update device: %s\n",
51571 diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
51572 index b27c96d..6ed4df2 100644
51573 --- a/fs/ext4/resize.c
51574 +++ b/fs/ext4/resize.c
51575 @@ -79,12 +79,20 @@ static int verify_group_input(struct super_block *sb,
51576 ext4_fsblk_t end = start + input->blocks_count;
51577 ext4_group_t group = input->group;
51578 ext4_fsblk_t itend = input->inode_table + sbi->s_itb_per_group;
51579 - unsigned overhead = ext4_group_overhead_blocks(sb, group);
51580 - ext4_fsblk_t metaend = start + overhead;
51581 + unsigned overhead;
51582 + ext4_fsblk_t metaend;
51583 struct buffer_head *bh = NULL;
51584 ext4_grpblk_t free_blocks_count, offset;
51585 int err = -EINVAL;
51586
51587 + if (group != sbi->s_groups_count) {
51588 + ext4_warning(sb, "Cannot add at group %u (only %u groups)",
51589 + input->group, sbi->s_groups_count);
51590 + return -EINVAL;
51591 + }
51592 +
51593 + overhead = ext4_group_overhead_blocks(sb, group);
51594 + metaend = start + overhead;
51595 input->free_blocks_count = free_blocks_count =
51596 input->blocks_count - 2 - overhead - sbi->s_itb_per_group;
51597
51598 @@ -96,10 +104,7 @@ static int verify_group_input(struct super_block *sb,
51599 free_blocks_count, input->reserved_blocks);
51600
51601 ext4_get_group_no_and_offset(sb, start, NULL, &offset);
51602 - if (group != sbi->s_groups_count)
51603 - ext4_warning(sb, "Cannot add at group %u (only %u groups)",
51604 - input->group, sbi->s_groups_count);
51605 - else if (offset != 0)
51606 + if (offset != 0)
51607 ext4_warning(sb, "Last group not full");
51608 else if (input->reserved_blocks > input->blocks_count / 5)
51609 ext4_warning(sb, "Reserved blocks too high (%u)",
51610 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
51611 index 94cc84d..2490974 100644
51612 --- a/fs/ext4/super.c
51613 +++ b/fs/ext4/super.c
51614 @@ -1236,7 +1236,7 @@ static ext4_fsblk_t get_sb_block(void **data)
51615 }
51616
51617 #define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
51618 -static char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
51619 +static const char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
51620 "Contact linux-ext4@vger.kernel.org if you think we should keep it.\n";
51621
51622 #ifdef CONFIG_QUOTA
51623 @@ -2378,7 +2378,7 @@ struct ext4_attr {
51624 ssize_t (*store)(struct ext4_attr *, struct ext4_sb_info *,
51625 const char *, size_t);
51626 int offset;
51627 -};
51628 +} __do_const;
51629
51630 static int parse_strtoull(const char *buf,
51631 unsigned long long max, unsigned long long *value)
51632 diff --git a/fs/fcntl.c b/fs/fcntl.c
51633 index 6599222..e7bf0de 100644
51634 --- a/fs/fcntl.c
51635 +++ b/fs/fcntl.c
51636 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
51637 if (err)
51638 return err;
51639
51640 + if (gr_handle_chroot_fowner(pid, type))
51641 + return -ENOENT;
51642 + if (gr_check_protected_task_fowner(pid, type))
51643 + return -EACCES;
51644 +
51645 f_modown(filp, pid, type, force);
51646 return 0;
51647 }
51648 diff --git a/fs/fhandle.c b/fs/fhandle.c
51649 index 999ff5c..41f4109 100644
51650 --- a/fs/fhandle.c
51651 +++ b/fs/fhandle.c
51652 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
51653 } else
51654 retval = 0;
51655 /* copy the mount id */
51656 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
51657 - sizeof(*mnt_id)) ||
51658 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
51659 copy_to_user(ufh, handle,
51660 sizeof(struct file_handle) + handle_bytes))
51661 retval = -EFAULT;
51662 diff --git a/fs/file.c b/fs/file.c
51663 index 4a78f98..9447397 100644
51664 --- a/fs/file.c
51665 +++ b/fs/file.c
51666 @@ -16,6 +16,7 @@
51667 #include <linux/slab.h>
51668 #include <linux/vmalloc.h>
51669 #include <linux/file.h>
51670 +#include <linux/security.h>
51671 #include <linux/fdtable.h>
51672 #include <linux/bitops.h>
51673 #include <linux/interrupt.h>
51674 @@ -828,6 +829,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
51675 if (!file)
51676 return __close_fd(files, fd);
51677
51678 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
51679 if (fd >= rlimit(RLIMIT_NOFILE))
51680 return -EBADF;
51681
51682 @@ -854,6 +856,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
51683 if (unlikely(oldfd == newfd))
51684 return -EINVAL;
51685
51686 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
51687 if (newfd >= rlimit(RLIMIT_NOFILE))
51688 return -EBADF;
51689
51690 @@ -909,6 +912,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
51691 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
51692 {
51693 int err;
51694 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
51695 if (from >= rlimit(RLIMIT_NOFILE))
51696 return -EINVAL;
51697 err = alloc_fd(from, flags);
51698 diff --git a/fs/filesystems.c b/fs/filesystems.c
51699 index 92567d9..fcd8cbf 100644
51700 --- a/fs/filesystems.c
51701 +++ b/fs/filesystems.c
51702 @@ -273,7 +273,11 @@ struct file_system_type *get_fs_type(const char *name)
51703 int len = dot ? dot - name : strlen(name);
51704
51705 fs = __get_fs_type(name, len);
51706 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
51707 + if (!fs && (___request_module(true, "grsec_modharden_fs", "fs-%.*s", len, name) == 0))
51708 +#else
51709 if (!fs && (request_module("fs-%.*s", len, name) == 0))
51710 +#endif
51711 fs = __get_fs_type(name, len);
51712
51713 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
51714 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
51715 index d8ac61d..79a36f0 100644
51716 --- a/fs/fs_struct.c
51717 +++ b/fs/fs_struct.c
51718 @@ -4,6 +4,7 @@
51719 #include <linux/path.h>
51720 #include <linux/slab.h>
51721 #include <linux/fs_struct.h>
51722 +#include <linux/grsecurity.h>
51723 #include "internal.h"
51724
51725 /*
51726 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, const struct path *path)
51727 write_seqcount_begin(&fs->seq);
51728 old_root = fs->root;
51729 fs->root = *path;
51730 + gr_set_chroot_entries(current, path);
51731 write_seqcount_end(&fs->seq);
51732 spin_unlock(&fs->lock);
51733 if (old_root.dentry)
51734 @@ -67,6 +69,10 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
51735 int hits = 0;
51736 spin_lock(&fs->lock);
51737 write_seqcount_begin(&fs->seq);
51738 + /* this root replacement is only done by pivot_root,
51739 + leave grsec's chroot tagging alone for this task
51740 + so that a pivoted root isn't treated as a chroot
51741 + */
51742 hits += replace_path(&fs->root, old_root, new_root);
51743 hits += replace_path(&fs->pwd, old_root, new_root);
51744 write_seqcount_end(&fs->seq);
51745 @@ -99,7 +105,8 @@ void exit_fs(struct task_struct *tsk)
51746 task_lock(tsk);
51747 spin_lock(&fs->lock);
51748 tsk->fs = NULL;
51749 - kill = !--fs->users;
51750 + gr_clear_chroot_entries(tsk);
51751 + kill = !atomic_dec_return(&fs->users);
51752 spin_unlock(&fs->lock);
51753 task_unlock(tsk);
51754 if (kill)
51755 @@ -112,7 +119,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
51756 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
51757 /* We don't need to lock fs - think why ;-) */
51758 if (fs) {
51759 - fs->users = 1;
51760 + atomic_set(&fs->users, 1);
51761 fs->in_exec = 0;
51762 spin_lock_init(&fs->lock);
51763 seqcount_init(&fs->seq);
51764 @@ -121,6 +128,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
51765 spin_lock(&old->lock);
51766 fs->root = old->root;
51767 path_get(&fs->root);
51768 + /* instead of calling gr_set_chroot_entries here,
51769 + we call it from every caller of this function
51770 + */
51771 fs->pwd = old->pwd;
51772 path_get(&fs->pwd);
51773 spin_unlock(&old->lock);
51774 @@ -139,8 +149,9 @@ int unshare_fs_struct(void)
51775
51776 task_lock(current);
51777 spin_lock(&fs->lock);
51778 - kill = !--fs->users;
51779 + kill = !atomic_dec_return(&fs->users);
51780 current->fs = new_fs;
51781 + gr_set_chroot_entries(current, &new_fs->root);
51782 spin_unlock(&fs->lock);
51783 task_unlock(current);
51784
51785 @@ -153,13 +164,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
51786
51787 int current_umask(void)
51788 {
51789 - return current->fs->umask;
51790 + return current->fs->umask | gr_acl_umask();
51791 }
51792 EXPORT_SYMBOL(current_umask);
51793
51794 /* to be mentioned only in INIT_TASK */
51795 struct fs_struct init_fs = {
51796 - .users = 1,
51797 + .users = ATOMIC_INIT(1),
51798 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
51799 .seq = SEQCNT_ZERO,
51800 .umask = 0022,
51801 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
51802 index e2cba1f..17a25bb 100644
51803 --- a/fs/fscache/cookie.c
51804 +++ b/fs/fscache/cookie.c
51805 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
51806 parent ? (char *) parent->def->name : "<no-parent>",
51807 def->name, netfs_data);
51808
51809 - fscache_stat(&fscache_n_acquires);
51810 + fscache_stat_unchecked(&fscache_n_acquires);
51811
51812 /* if there's no parent cookie, then we don't create one here either */
51813 if (!parent) {
51814 - fscache_stat(&fscache_n_acquires_null);
51815 + fscache_stat_unchecked(&fscache_n_acquires_null);
51816 _leave(" [no parent]");
51817 return NULL;
51818 }
51819 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
51820 /* allocate and initialise a cookie */
51821 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
51822 if (!cookie) {
51823 - fscache_stat(&fscache_n_acquires_oom);
51824 + fscache_stat_unchecked(&fscache_n_acquires_oom);
51825 _leave(" [ENOMEM]");
51826 return NULL;
51827 }
51828 @@ -109,13 +109,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
51829
51830 switch (cookie->def->type) {
51831 case FSCACHE_COOKIE_TYPE_INDEX:
51832 - fscache_stat(&fscache_n_cookie_index);
51833 + fscache_stat_unchecked(&fscache_n_cookie_index);
51834 break;
51835 case FSCACHE_COOKIE_TYPE_DATAFILE:
51836 - fscache_stat(&fscache_n_cookie_data);
51837 + fscache_stat_unchecked(&fscache_n_cookie_data);
51838 break;
51839 default:
51840 - fscache_stat(&fscache_n_cookie_special);
51841 + fscache_stat_unchecked(&fscache_n_cookie_special);
51842 break;
51843 }
51844
51845 @@ -126,13 +126,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
51846 if (fscache_acquire_non_index_cookie(cookie) < 0) {
51847 atomic_dec(&parent->n_children);
51848 __fscache_cookie_put(cookie);
51849 - fscache_stat(&fscache_n_acquires_nobufs);
51850 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
51851 _leave(" = NULL");
51852 return NULL;
51853 }
51854 }
51855
51856 - fscache_stat(&fscache_n_acquires_ok);
51857 + fscache_stat_unchecked(&fscache_n_acquires_ok);
51858 _leave(" = %p", cookie);
51859 return cookie;
51860 }
51861 @@ -168,7 +168,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
51862 cache = fscache_select_cache_for_object(cookie->parent);
51863 if (!cache) {
51864 up_read(&fscache_addremove_sem);
51865 - fscache_stat(&fscache_n_acquires_no_cache);
51866 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
51867 _leave(" = -ENOMEDIUM [no cache]");
51868 return -ENOMEDIUM;
51869 }
51870 @@ -255,12 +255,12 @@ static int fscache_alloc_object(struct fscache_cache *cache,
51871 object = cache->ops->alloc_object(cache, cookie);
51872 fscache_stat_d(&fscache_n_cop_alloc_object);
51873 if (IS_ERR(object)) {
51874 - fscache_stat(&fscache_n_object_no_alloc);
51875 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
51876 ret = PTR_ERR(object);
51877 goto error;
51878 }
51879
51880 - fscache_stat(&fscache_n_object_alloc);
51881 + fscache_stat_unchecked(&fscache_n_object_alloc);
51882
51883 object->debug_id = atomic_inc_return(&fscache_object_debug_id);
51884
51885 @@ -376,7 +376,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
51886
51887 _enter("{%s}", cookie->def->name);
51888
51889 - fscache_stat(&fscache_n_invalidates);
51890 + fscache_stat_unchecked(&fscache_n_invalidates);
51891
51892 /* Only permit invalidation of data files. Invalidating an index will
51893 * require the caller to release all its attachments to the tree rooted
51894 @@ -434,10 +434,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
51895 {
51896 struct fscache_object *object;
51897
51898 - fscache_stat(&fscache_n_updates);
51899 + fscache_stat_unchecked(&fscache_n_updates);
51900
51901 if (!cookie) {
51902 - fscache_stat(&fscache_n_updates_null);
51903 + fscache_stat_unchecked(&fscache_n_updates_null);
51904 _leave(" [no cookie]");
51905 return;
51906 }
51907 @@ -471,12 +471,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
51908 struct fscache_object *object;
51909 unsigned long event;
51910
51911 - fscache_stat(&fscache_n_relinquishes);
51912 + fscache_stat_unchecked(&fscache_n_relinquishes);
51913 if (retire)
51914 - fscache_stat(&fscache_n_relinquishes_retire);
51915 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
51916
51917 if (!cookie) {
51918 - fscache_stat(&fscache_n_relinquishes_null);
51919 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
51920 _leave(" [no cookie]");
51921 return;
51922 }
51923 @@ -492,7 +492,7 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
51924
51925 /* wait for the cookie to finish being instantiated (or to fail) */
51926 if (test_bit(FSCACHE_COOKIE_CREATING, &cookie->flags)) {
51927 - fscache_stat(&fscache_n_relinquishes_waitcrt);
51928 + fscache_stat_unchecked(&fscache_n_relinquishes_waitcrt);
51929 wait_on_bit(&cookie->flags, FSCACHE_COOKIE_CREATING,
51930 fscache_wait_bit, TASK_UNINTERRUPTIBLE);
51931 }
51932 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
51933 index ee38fef..0a326d4 100644
51934 --- a/fs/fscache/internal.h
51935 +++ b/fs/fscache/internal.h
51936 @@ -148,101 +148,101 @@ extern void fscache_proc_cleanup(void);
51937 * stats.c
51938 */
51939 #ifdef CONFIG_FSCACHE_STATS
51940 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
51941 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
51942 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
51943 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
51944
51945 -extern atomic_t fscache_n_op_pend;
51946 -extern atomic_t fscache_n_op_run;
51947 -extern atomic_t fscache_n_op_enqueue;
51948 -extern atomic_t fscache_n_op_deferred_release;
51949 -extern atomic_t fscache_n_op_release;
51950 -extern atomic_t fscache_n_op_gc;
51951 -extern atomic_t fscache_n_op_cancelled;
51952 -extern atomic_t fscache_n_op_rejected;
51953 +extern atomic_unchecked_t fscache_n_op_pend;
51954 +extern atomic_unchecked_t fscache_n_op_run;
51955 +extern atomic_unchecked_t fscache_n_op_enqueue;
51956 +extern atomic_unchecked_t fscache_n_op_deferred_release;
51957 +extern atomic_unchecked_t fscache_n_op_release;
51958 +extern atomic_unchecked_t fscache_n_op_gc;
51959 +extern atomic_unchecked_t fscache_n_op_cancelled;
51960 +extern atomic_unchecked_t fscache_n_op_rejected;
51961
51962 -extern atomic_t fscache_n_attr_changed;
51963 -extern atomic_t fscache_n_attr_changed_ok;
51964 -extern atomic_t fscache_n_attr_changed_nobufs;
51965 -extern atomic_t fscache_n_attr_changed_nomem;
51966 -extern atomic_t fscache_n_attr_changed_calls;
51967 +extern atomic_unchecked_t fscache_n_attr_changed;
51968 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
51969 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
51970 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
51971 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
51972
51973 -extern atomic_t fscache_n_allocs;
51974 -extern atomic_t fscache_n_allocs_ok;
51975 -extern atomic_t fscache_n_allocs_wait;
51976 -extern atomic_t fscache_n_allocs_nobufs;
51977 -extern atomic_t fscache_n_allocs_intr;
51978 -extern atomic_t fscache_n_allocs_object_dead;
51979 -extern atomic_t fscache_n_alloc_ops;
51980 -extern atomic_t fscache_n_alloc_op_waits;
51981 +extern atomic_unchecked_t fscache_n_allocs;
51982 +extern atomic_unchecked_t fscache_n_allocs_ok;
51983 +extern atomic_unchecked_t fscache_n_allocs_wait;
51984 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
51985 +extern atomic_unchecked_t fscache_n_allocs_intr;
51986 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
51987 +extern atomic_unchecked_t fscache_n_alloc_ops;
51988 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
51989
51990 -extern atomic_t fscache_n_retrievals;
51991 -extern atomic_t fscache_n_retrievals_ok;
51992 -extern atomic_t fscache_n_retrievals_wait;
51993 -extern atomic_t fscache_n_retrievals_nodata;
51994 -extern atomic_t fscache_n_retrievals_nobufs;
51995 -extern atomic_t fscache_n_retrievals_intr;
51996 -extern atomic_t fscache_n_retrievals_nomem;
51997 -extern atomic_t fscache_n_retrievals_object_dead;
51998 -extern atomic_t fscache_n_retrieval_ops;
51999 -extern atomic_t fscache_n_retrieval_op_waits;
52000 +extern atomic_unchecked_t fscache_n_retrievals;
52001 +extern atomic_unchecked_t fscache_n_retrievals_ok;
52002 +extern atomic_unchecked_t fscache_n_retrievals_wait;
52003 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
52004 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
52005 +extern atomic_unchecked_t fscache_n_retrievals_intr;
52006 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
52007 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
52008 +extern atomic_unchecked_t fscache_n_retrieval_ops;
52009 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
52010
52011 -extern atomic_t fscache_n_stores;
52012 -extern atomic_t fscache_n_stores_ok;
52013 -extern atomic_t fscache_n_stores_again;
52014 -extern atomic_t fscache_n_stores_nobufs;
52015 -extern atomic_t fscache_n_stores_oom;
52016 -extern atomic_t fscache_n_store_ops;
52017 -extern atomic_t fscache_n_store_calls;
52018 -extern atomic_t fscache_n_store_pages;
52019 -extern atomic_t fscache_n_store_radix_deletes;
52020 -extern atomic_t fscache_n_store_pages_over_limit;
52021 +extern atomic_unchecked_t fscache_n_stores;
52022 +extern atomic_unchecked_t fscache_n_stores_ok;
52023 +extern atomic_unchecked_t fscache_n_stores_again;
52024 +extern atomic_unchecked_t fscache_n_stores_nobufs;
52025 +extern atomic_unchecked_t fscache_n_stores_oom;
52026 +extern atomic_unchecked_t fscache_n_store_ops;
52027 +extern atomic_unchecked_t fscache_n_store_calls;
52028 +extern atomic_unchecked_t fscache_n_store_pages;
52029 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
52030 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
52031
52032 -extern atomic_t fscache_n_store_vmscan_not_storing;
52033 -extern atomic_t fscache_n_store_vmscan_gone;
52034 -extern atomic_t fscache_n_store_vmscan_busy;
52035 -extern atomic_t fscache_n_store_vmscan_cancelled;
52036 -extern atomic_t fscache_n_store_vmscan_wait;
52037 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
52038 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
52039 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
52040 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
52041 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
52042
52043 -extern atomic_t fscache_n_marks;
52044 -extern atomic_t fscache_n_uncaches;
52045 +extern atomic_unchecked_t fscache_n_marks;
52046 +extern atomic_unchecked_t fscache_n_uncaches;
52047
52048 -extern atomic_t fscache_n_acquires;
52049 -extern atomic_t fscache_n_acquires_null;
52050 -extern atomic_t fscache_n_acquires_no_cache;
52051 -extern atomic_t fscache_n_acquires_ok;
52052 -extern atomic_t fscache_n_acquires_nobufs;
52053 -extern atomic_t fscache_n_acquires_oom;
52054 +extern atomic_unchecked_t fscache_n_acquires;
52055 +extern atomic_unchecked_t fscache_n_acquires_null;
52056 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
52057 +extern atomic_unchecked_t fscache_n_acquires_ok;
52058 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
52059 +extern atomic_unchecked_t fscache_n_acquires_oom;
52060
52061 -extern atomic_t fscache_n_invalidates;
52062 -extern atomic_t fscache_n_invalidates_run;
52063 +extern atomic_unchecked_t fscache_n_invalidates;
52064 +extern atomic_unchecked_t fscache_n_invalidates_run;
52065
52066 -extern atomic_t fscache_n_updates;
52067 -extern atomic_t fscache_n_updates_null;
52068 -extern atomic_t fscache_n_updates_run;
52069 +extern atomic_unchecked_t fscache_n_updates;
52070 +extern atomic_unchecked_t fscache_n_updates_null;
52071 +extern atomic_unchecked_t fscache_n_updates_run;
52072
52073 -extern atomic_t fscache_n_relinquishes;
52074 -extern atomic_t fscache_n_relinquishes_null;
52075 -extern atomic_t fscache_n_relinquishes_waitcrt;
52076 -extern atomic_t fscache_n_relinquishes_retire;
52077 +extern atomic_unchecked_t fscache_n_relinquishes;
52078 +extern atomic_unchecked_t fscache_n_relinquishes_null;
52079 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
52080 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
52081
52082 -extern atomic_t fscache_n_cookie_index;
52083 -extern atomic_t fscache_n_cookie_data;
52084 -extern atomic_t fscache_n_cookie_special;
52085 +extern atomic_unchecked_t fscache_n_cookie_index;
52086 +extern atomic_unchecked_t fscache_n_cookie_data;
52087 +extern atomic_unchecked_t fscache_n_cookie_special;
52088
52089 -extern atomic_t fscache_n_object_alloc;
52090 -extern atomic_t fscache_n_object_no_alloc;
52091 -extern atomic_t fscache_n_object_lookups;
52092 -extern atomic_t fscache_n_object_lookups_negative;
52093 -extern atomic_t fscache_n_object_lookups_positive;
52094 -extern atomic_t fscache_n_object_lookups_timed_out;
52095 -extern atomic_t fscache_n_object_created;
52096 -extern atomic_t fscache_n_object_avail;
52097 -extern atomic_t fscache_n_object_dead;
52098 +extern atomic_unchecked_t fscache_n_object_alloc;
52099 +extern atomic_unchecked_t fscache_n_object_no_alloc;
52100 +extern atomic_unchecked_t fscache_n_object_lookups;
52101 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
52102 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
52103 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
52104 +extern atomic_unchecked_t fscache_n_object_created;
52105 +extern atomic_unchecked_t fscache_n_object_avail;
52106 +extern atomic_unchecked_t fscache_n_object_dead;
52107
52108 -extern atomic_t fscache_n_checkaux_none;
52109 -extern atomic_t fscache_n_checkaux_okay;
52110 -extern atomic_t fscache_n_checkaux_update;
52111 -extern atomic_t fscache_n_checkaux_obsolete;
52112 +extern atomic_unchecked_t fscache_n_checkaux_none;
52113 +extern atomic_unchecked_t fscache_n_checkaux_okay;
52114 +extern atomic_unchecked_t fscache_n_checkaux_update;
52115 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
52116
52117 extern atomic_t fscache_n_cop_alloc_object;
52118 extern atomic_t fscache_n_cop_lookup_object;
52119 @@ -267,6 +267,11 @@ static inline void fscache_stat(atomic_t *stat)
52120 atomic_inc(stat);
52121 }
52122
52123 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
52124 +{
52125 + atomic_inc_unchecked(stat);
52126 +}
52127 +
52128 static inline void fscache_stat_d(atomic_t *stat)
52129 {
52130 atomic_dec(stat);
52131 @@ -279,6 +284,7 @@ extern const struct file_operations fscache_stats_fops;
52132
52133 #define __fscache_stat(stat) (NULL)
52134 #define fscache_stat(stat) do {} while (0)
52135 +#define fscache_stat_unchecked(stat) do {} while (0)
52136 #define fscache_stat_d(stat) do {} while (0)
52137 #endif
52138
52139 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
52140 index 50d41c1..10ee117 100644
52141 --- a/fs/fscache/object.c
52142 +++ b/fs/fscache/object.c
52143 @@ -143,7 +143,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52144 /* Invalidate an object on disk */
52145 case FSCACHE_OBJECT_INVALIDATING:
52146 clear_bit(FSCACHE_OBJECT_EV_INVALIDATE, &object->events);
52147 - fscache_stat(&fscache_n_invalidates_run);
52148 + fscache_stat_unchecked(&fscache_n_invalidates_run);
52149 fscache_stat(&fscache_n_cop_invalidate_object);
52150 fscache_invalidate_object(object);
52151 fscache_stat_d(&fscache_n_cop_invalidate_object);
52152 @@ -153,7 +153,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52153 /* update the object metadata on disk */
52154 case FSCACHE_OBJECT_UPDATING:
52155 clear_bit(FSCACHE_OBJECT_EV_UPDATE, &object->events);
52156 - fscache_stat(&fscache_n_updates_run);
52157 + fscache_stat_unchecked(&fscache_n_updates_run);
52158 fscache_stat(&fscache_n_cop_update_object);
52159 object->cache->ops->update_object(object);
52160 fscache_stat_d(&fscache_n_cop_update_object);
52161 @@ -242,7 +242,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52162 spin_lock(&object->lock);
52163 object->state = FSCACHE_OBJECT_DEAD;
52164 spin_unlock(&object->lock);
52165 - fscache_stat(&fscache_n_object_dead);
52166 + fscache_stat_unchecked(&fscache_n_object_dead);
52167 goto terminal_transit;
52168
52169 /* handle the parent cache of this object being withdrawn from
52170 @@ -257,7 +257,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
52171 spin_lock(&object->lock);
52172 object->state = FSCACHE_OBJECT_DEAD;
52173 spin_unlock(&object->lock);
52174 - fscache_stat(&fscache_n_object_dead);
52175 + fscache_stat_unchecked(&fscache_n_object_dead);
52176 goto terminal_transit;
52177
52178 /* complain about the object being woken up once it is
52179 @@ -495,7 +495,7 @@ static void fscache_lookup_object(struct fscache_object *object)
52180 parent->cookie->def->name, cookie->def->name,
52181 object->cache->tag->name);
52182
52183 - fscache_stat(&fscache_n_object_lookups);
52184 + fscache_stat_unchecked(&fscache_n_object_lookups);
52185 fscache_stat(&fscache_n_cop_lookup_object);
52186 ret = object->cache->ops->lookup_object(object);
52187 fscache_stat_d(&fscache_n_cop_lookup_object);
52188 @@ -506,7 +506,7 @@ static void fscache_lookup_object(struct fscache_object *object)
52189 if (ret == -ETIMEDOUT) {
52190 /* probably stuck behind another object, so move this one to
52191 * the back of the queue */
52192 - fscache_stat(&fscache_n_object_lookups_timed_out);
52193 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
52194 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
52195 }
52196
52197 @@ -529,7 +529,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
52198
52199 spin_lock(&object->lock);
52200 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
52201 - fscache_stat(&fscache_n_object_lookups_negative);
52202 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
52203
52204 /* transit here to allow write requests to begin stacking up
52205 * and read requests to begin returning ENODATA */
52206 @@ -575,7 +575,7 @@ void fscache_obtained_object(struct fscache_object *object)
52207 * result, in which case there may be data available */
52208 spin_lock(&object->lock);
52209 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
52210 - fscache_stat(&fscache_n_object_lookups_positive);
52211 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
52212
52213 clear_bit(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
52214
52215 @@ -589,7 +589,7 @@ void fscache_obtained_object(struct fscache_object *object)
52216 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
52217 } else {
52218 ASSERTCMP(object->state, ==, FSCACHE_OBJECT_CREATING);
52219 - fscache_stat(&fscache_n_object_created);
52220 + fscache_stat_unchecked(&fscache_n_object_created);
52221
52222 object->state = FSCACHE_OBJECT_AVAILABLE;
52223 spin_unlock(&object->lock);
52224 @@ -634,7 +634,7 @@ static void fscache_object_available(struct fscache_object *object)
52225 fscache_enqueue_dependents(object);
52226
52227 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
52228 - fscache_stat(&fscache_n_object_avail);
52229 + fscache_stat_unchecked(&fscache_n_object_avail);
52230
52231 _leave("");
52232 }
52233 @@ -894,7 +894,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
52234 enum fscache_checkaux result;
52235
52236 if (!object->cookie->def->check_aux) {
52237 - fscache_stat(&fscache_n_checkaux_none);
52238 + fscache_stat_unchecked(&fscache_n_checkaux_none);
52239 return FSCACHE_CHECKAUX_OKAY;
52240 }
52241
52242 @@ -903,17 +903,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
52243 switch (result) {
52244 /* entry okay as is */
52245 case FSCACHE_CHECKAUX_OKAY:
52246 - fscache_stat(&fscache_n_checkaux_okay);
52247 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
52248 break;
52249
52250 /* entry requires update */
52251 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
52252 - fscache_stat(&fscache_n_checkaux_update);
52253 + fscache_stat_unchecked(&fscache_n_checkaux_update);
52254 break;
52255
52256 /* entry requires deletion */
52257 case FSCACHE_CHECKAUX_OBSOLETE:
52258 - fscache_stat(&fscache_n_checkaux_obsolete);
52259 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
52260 break;
52261
52262 default:
52263 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
52264 index 762a9ec..2023284 100644
52265 --- a/fs/fscache/operation.c
52266 +++ b/fs/fscache/operation.c
52267 @@ -17,7 +17,7 @@
52268 #include <linux/slab.h>
52269 #include "internal.h"
52270
52271 -atomic_t fscache_op_debug_id;
52272 +atomic_unchecked_t fscache_op_debug_id;
52273 EXPORT_SYMBOL(fscache_op_debug_id);
52274
52275 /**
52276 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
52277 ASSERTCMP(atomic_read(&op->usage), >, 0);
52278 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
52279
52280 - fscache_stat(&fscache_n_op_enqueue);
52281 + fscache_stat_unchecked(&fscache_n_op_enqueue);
52282 switch (op->flags & FSCACHE_OP_TYPE) {
52283 case FSCACHE_OP_ASYNC:
52284 _debug("queue async");
52285 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
52286 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
52287 if (op->processor)
52288 fscache_enqueue_operation(op);
52289 - fscache_stat(&fscache_n_op_run);
52290 + fscache_stat_unchecked(&fscache_n_op_run);
52291 }
52292
52293 /*
52294 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
52295 if (object->n_in_progress > 0) {
52296 atomic_inc(&op->usage);
52297 list_add_tail(&op->pend_link, &object->pending_ops);
52298 - fscache_stat(&fscache_n_op_pend);
52299 + fscache_stat_unchecked(&fscache_n_op_pend);
52300 } else if (!list_empty(&object->pending_ops)) {
52301 atomic_inc(&op->usage);
52302 list_add_tail(&op->pend_link, &object->pending_ops);
52303 - fscache_stat(&fscache_n_op_pend);
52304 + fscache_stat_unchecked(&fscache_n_op_pend);
52305 fscache_start_operations(object);
52306 } else {
52307 ASSERTCMP(object->n_in_progress, ==, 0);
52308 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
52309 object->n_exclusive++; /* reads and writes must wait */
52310 atomic_inc(&op->usage);
52311 list_add_tail(&op->pend_link, &object->pending_ops);
52312 - fscache_stat(&fscache_n_op_pend);
52313 + fscache_stat_unchecked(&fscache_n_op_pend);
52314 ret = 0;
52315 } else {
52316 /* If we're in any other state, there must have been an I/O
52317 @@ -215,11 +215,11 @@ int fscache_submit_op(struct fscache_object *object,
52318 if (object->n_exclusive > 0) {
52319 atomic_inc(&op->usage);
52320 list_add_tail(&op->pend_link, &object->pending_ops);
52321 - fscache_stat(&fscache_n_op_pend);
52322 + fscache_stat_unchecked(&fscache_n_op_pend);
52323 } else if (!list_empty(&object->pending_ops)) {
52324 atomic_inc(&op->usage);
52325 list_add_tail(&op->pend_link, &object->pending_ops);
52326 - fscache_stat(&fscache_n_op_pend);
52327 + fscache_stat_unchecked(&fscache_n_op_pend);
52328 fscache_start_operations(object);
52329 } else {
52330 ASSERTCMP(object->n_exclusive, ==, 0);
52331 @@ -231,12 +231,12 @@ int fscache_submit_op(struct fscache_object *object,
52332 object->n_ops++;
52333 atomic_inc(&op->usage);
52334 list_add_tail(&op->pend_link, &object->pending_ops);
52335 - fscache_stat(&fscache_n_op_pend);
52336 + fscache_stat_unchecked(&fscache_n_op_pend);
52337 ret = 0;
52338 } else if (object->state == FSCACHE_OBJECT_DYING ||
52339 object->state == FSCACHE_OBJECT_LC_DYING ||
52340 object->state == FSCACHE_OBJECT_WITHDRAWING) {
52341 - fscache_stat(&fscache_n_op_rejected);
52342 + fscache_stat_unchecked(&fscache_n_op_rejected);
52343 op->state = FSCACHE_OP_ST_CANCELLED;
52344 ret = -ENOBUFS;
52345 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
52346 @@ -315,7 +315,7 @@ int fscache_cancel_op(struct fscache_operation *op,
52347 ret = -EBUSY;
52348 if (op->state == FSCACHE_OP_ST_PENDING) {
52349 ASSERT(!list_empty(&op->pend_link));
52350 - fscache_stat(&fscache_n_op_cancelled);
52351 + fscache_stat_unchecked(&fscache_n_op_cancelled);
52352 list_del_init(&op->pend_link);
52353 if (do_cancel)
52354 do_cancel(op);
52355 @@ -347,7 +347,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
52356 while (!list_empty(&object->pending_ops)) {
52357 op = list_entry(object->pending_ops.next,
52358 struct fscache_operation, pend_link);
52359 - fscache_stat(&fscache_n_op_cancelled);
52360 + fscache_stat_unchecked(&fscache_n_op_cancelled);
52361 list_del_init(&op->pend_link);
52362
52363 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
52364 @@ -419,7 +419,7 @@ void fscache_put_operation(struct fscache_operation *op)
52365 op->state, ==, FSCACHE_OP_ST_CANCELLED);
52366 op->state = FSCACHE_OP_ST_DEAD;
52367
52368 - fscache_stat(&fscache_n_op_release);
52369 + fscache_stat_unchecked(&fscache_n_op_release);
52370
52371 if (op->release) {
52372 op->release(op);
52373 @@ -442,7 +442,7 @@ void fscache_put_operation(struct fscache_operation *op)
52374 * lock, and defer it otherwise */
52375 if (!spin_trylock(&object->lock)) {
52376 _debug("defer put");
52377 - fscache_stat(&fscache_n_op_deferred_release);
52378 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
52379
52380 cache = object->cache;
52381 spin_lock(&cache->op_gc_list_lock);
52382 @@ -495,7 +495,7 @@ void fscache_operation_gc(struct work_struct *work)
52383
52384 _debug("GC DEFERRED REL OBJ%x OP%x",
52385 object->debug_id, op->debug_id);
52386 - fscache_stat(&fscache_n_op_gc);
52387 + fscache_stat_unchecked(&fscache_n_op_gc);
52388
52389 ASSERTCMP(atomic_read(&op->usage), ==, 0);
52390 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
52391 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
52392 index ff000e5..c44ec6d 100644
52393 --- a/fs/fscache/page.c
52394 +++ b/fs/fscache/page.c
52395 @@ -61,7 +61,7 @@ try_again:
52396 val = radix_tree_lookup(&cookie->stores, page->index);
52397 if (!val) {
52398 rcu_read_unlock();
52399 - fscache_stat(&fscache_n_store_vmscan_not_storing);
52400 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
52401 __fscache_uncache_page(cookie, page);
52402 return true;
52403 }
52404 @@ -91,11 +91,11 @@ try_again:
52405 spin_unlock(&cookie->stores_lock);
52406
52407 if (xpage) {
52408 - fscache_stat(&fscache_n_store_vmscan_cancelled);
52409 - fscache_stat(&fscache_n_store_radix_deletes);
52410 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
52411 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
52412 ASSERTCMP(xpage, ==, page);
52413 } else {
52414 - fscache_stat(&fscache_n_store_vmscan_gone);
52415 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
52416 }
52417
52418 wake_up_bit(&cookie->flags, 0);
52419 @@ -110,11 +110,11 @@ page_busy:
52420 * sleeping on memory allocation, so we may need to impose a timeout
52421 * too. */
52422 if (!(gfp & __GFP_WAIT)) {
52423 - fscache_stat(&fscache_n_store_vmscan_busy);
52424 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
52425 return false;
52426 }
52427
52428 - fscache_stat(&fscache_n_store_vmscan_wait);
52429 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
52430 __fscache_wait_on_page_write(cookie, page);
52431 gfp &= ~__GFP_WAIT;
52432 goto try_again;
52433 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
52434 FSCACHE_COOKIE_STORING_TAG);
52435 if (!radix_tree_tag_get(&cookie->stores, page->index,
52436 FSCACHE_COOKIE_PENDING_TAG)) {
52437 - fscache_stat(&fscache_n_store_radix_deletes);
52438 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
52439 xpage = radix_tree_delete(&cookie->stores, page->index);
52440 }
52441 spin_unlock(&cookie->stores_lock);
52442 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
52443
52444 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
52445
52446 - fscache_stat(&fscache_n_attr_changed_calls);
52447 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
52448
52449 if (fscache_object_is_active(object)) {
52450 fscache_stat(&fscache_n_cop_attr_changed);
52451 @@ -187,11 +187,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52452
52453 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52454
52455 - fscache_stat(&fscache_n_attr_changed);
52456 + fscache_stat_unchecked(&fscache_n_attr_changed);
52457
52458 op = kzalloc(sizeof(*op), GFP_KERNEL);
52459 if (!op) {
52460 - fscache_stat(&fscache_n_attr_changed_nomem);
52461 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
52462 _leave(" = -ENOMEM");
52463 return -ENOMEM;
52464 }
52465 @@ -209,7 +209,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52466 if (fscache_submit_exclusive_op(object, op) < 0)
52467 goto nobufs;
52468 spin_unlock(&cookie->lock);
52469 - fscache_stat(&fscache_n_attr_changed_ok);
52470 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
52471 fscache_put_operation(op);
52472 _leave(" = 0");
52473 return 0;
52474 @@ -217,7 +217,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
52475 nobufs:
52476 spin_unlock(&cookie->lock);
52477 kfree(op);
52478 - fscache_stat(&fscache_n_attr_changed_nobufs);
52479 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
52480 _leave(" = %d", -ENOBUFS);
52481 return -ENOBUFS;
52482 }
52483 @@ -255,7 +255,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
52484 /* allocate a retrieval operation and attempt to submit it */
52485 op = kzalloc(sizeof(*op), GFP_NOIO);
52486 if (!op) {
52487 - fscache_stat(&fscache_n_retrievals_nomem);
52488 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52489 return NULL;
52490 }
52491
52492 @@ -283,13 +283,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
52493 return 0;
52494 }
52495
52496 - fscache_stat(&fscache_n_retrievals_wait);
52497 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
52498
52499 jif = jiffies;
52500 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
52501 fscache_wait_bit_interruptible,
52502 TASK_INTERRUPTIBLE) != 0) {
52503 - fscache_stat(&fscache_n_retrievals_intr);
52504 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52505 _leave(" = -ERESTARTSYS");
52506 return -ERESTARTSYS;
52507 }
52508 @@ -318,8 +318,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
52509 */
52510 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52511 struct fscache_retrieval *op,
52512 - atomic_t *stat_op_waits,
52513 - atomic_t *stat_object_dead)
52514 + atomic_unchecked_t *stat_op_waits,
52515 + atomic_unchecked_t *stat_object_dead)
52516 {
52517 int ret;
52518
52519 @@ -327,7 +327,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52520 goto check_if_dead;
52521
52522 _debug(">>> WT");
52523 - fscache_stat(stat_op_waits);
52524 + fscache_stat_unchecked(stat_op_waits);
52525 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
52526 fscache_wait_bit_interruptible,
52527 TASK_INTERRUPTIBLE) != 0) {
52528 @@ -344,14 +344,14 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
52529
52530 check_if_dead:
52531 if (op->op.state == FSCACHE_OP_ST_CANCELLED) {
52532 - fscache_stat(stat_object_dead);
52533 + fscache_stat_unchecked(stat_object_dead);
52534 _leave(" = -ENOBUFS [cancelled]");
52535 return -ENOBUFS;
52536 }
52537 if (unlikely(fscache_object_is_dead(object))) {
52538 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->op.state);
52539 fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
52540 - fscache_stat(stat_object_dead);
52541 + fscache_stat_unchecked(stat_object_dead);
52542 return -ENOBUFS;
52543 }
52544 return 0;
52545 @@ -378,7 +378,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52546
52547 _enter("%p,%p,,,", cookie, page);
52548
52549 - fscache_stat(&fscache_n_retrievals);
52550 + fscache_stat_unchecked(&fscache_n_retrievals);
52551
52552 if (hlist_empty(&cookie->backing_objects))
52553 goto nobufs;
52554 @@ -417,7 +417,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52555 goto nobufs_unlock_dec;
52556 spin_unlock(&cookie->lock);
52557
52558 - fscache_stat(&fscache_n_retrieval_ops);
52559 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
52560
52561 /* pin the netfs read context in case we need to do the actual netfs
52562 * read because we've encountered a cache read failure */
52563 @@ -447,15 +447,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
52564
52565 error:
52566 if (ret == -ENOMEM)
52567 - fscache_stat(&fscache_n_retrievals_nomem);
52568 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52569 else if (ret == -ERESTARTSYS)
52570 - fscache_stat(&fscache_n_retrievals_intr);
52571 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52572 else if (ret == -ENODATA)
52573 - fscache_stat(&fscache_n_retrievals_nodata);
52574 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
52575 else if (ret < 0)
52576 - fscache_stat(&fscache_n_retrievals_nobufs);
52577 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52578 else
52579 - fscache_stat(&fscache_n_retrievals_ok);
52580 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52581
52582 fscache_put_retrieval(op);
52583 _leave(" = %d", ret);
52584 @@ -467,7 +467,7 @@ nobufs_unlock:
52585 spin_unlock(&cookie->lock);
52586 kfree(op);
52587 nobufs:
52588 - fscache_stat(&fscache_n_retrievals_nobufs);
52589 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52590 _leave(" = -ENOBUFS");
52591 return -ENOBUFS;
52592 }
52593 @@ -505,7 +505,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52594
52595 _enter("%p,,%d,,,", cookie, *nr_pages);
52596
52597 - fscache_stat(&fscache_n_retrievals);
52598 + fscache_stat_unchecked(&fscache_n_retrievals);
52599
52600 if (hlist_empty(&cookie->backing_objects))
52601 goto nobufs;
52602 @@ -541,7 +541,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52603 goto nobufs_unlock_dec;
52604 spin_unlock(&cookie->lock);
52605
52606 - fscache_stat(&fscache_n_retrieval_ops);
52607 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
52608
52609 /* pin the netfs read context in case we need to do the actual netfs
52610 * read because we've encountered a cache read failure */
52611 @@ -571,15 +571,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
52612
52613 error:
52614 if (ret == -ENOMEM)
52615 - fscache_stat(&fscache_n_retrievals_nomem);
52616 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
52617 else if (ret == -ERESTARTSYS)
52618 - fscache_stat(&fscache_n_retrievals_intr);
52619 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
52620 else if (ret == -ENODATA)
52621 - fscache_stat(&fscache_n_retrievals_nodata);
52622 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
52623 else if (ret < 0)
52624 - fscache_stat(&fscache_n_retrievals_nobufs);
52625 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52626 else
52627 - fscache_stat(&fscache_n_retrievals_ok);
52628 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
52629
52630 fscache_put_retrieval(op);
52631 _leave(" = %d", ret);
52632 @@ -591,7 +591,7 @@ nobufs_unlock:
52633 spin_unlock(&cookie->lock);
52634 kfree(op);
52635 nobufs:
52636 - fscache_stat(&fscache_n_retrievals_nobufs);
52637 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
52638 _leave(" = -ENOBUFS");
52639 return -ENOBUFS;
52640 }
52641 @@ -615,7 +615,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52642
52643 _enter("%p,%p,,,", cookie, page);
52644
52645 - fscache_stat(&fscache_n_allocs);
52646 + fscache_stat_unchecked(&fscache_n_allocs);
52647
52648 if (hlist_empty(&cookie->backing_objects))
52649 goto nobufs;
52650 @@ -647,7 +647,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52651 goto nobufs_unlock;
52652 spin_unlock(&cookie->lock);
52653
52654 - fscache_stat(&fscache_n_alloc_ops);
52655 + fscache_stat_unchecked(&fscache_n_alloc_ops);
52656
52657 ret = fscache_wait_for_retrieval_activation(
52658 object, op,
52659 @@ -663,11 +663,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
52660
52661 error:
52662 if (ret == -ERESTARTSYS)
52663 - fscache_stat(&fscache_n_allocs_intr);
52664 + fscache_stat_unchecked(&fscache_n_allocs_intr);
52665 else if (ret < 0)
52666 - fscache_stat(&fscache_n_allocs_nobufs);
52667 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52668 else
52669 - fscache_stat(&fscache_n_allocs_ok);
52670 + fscache_stat_unchecked(&fscache_n_allocs_ok);
52671
52672 fscache_put_retrieval(op);
52673 _leave(" = %d", ret);
52674 @@ -677,7 +677,7 @@ nobufs_unlock:
52675 spin_unlock(&cookie->lock);
52676 kfree(op);
52677 nobufs:
52678 - fscache_stat(&fscache_n_allocs_nobufs);
52679 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
52680 _leave(" = -ENOBUFS");
52681 return -ENOBUFS;
52682 }
52683 @@ -736,7 +736,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52684
52685 spin_lock(&cookie->stores_lock);
52686
52687 - fscache_stat(&fscache_n_store_calls);
52688 + fscache_stat_unchecked(&fscache_n_store_calls);
52689
52690 /* find a page to store */
52691 page = NULL;
52692 @@ -747,7 +747,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52693 page = results[0];
52694 _debug("gang %d [%lx]", n, page->index);
52695 if (page->index > op->store_limit) {
52696 - fscache_stat(&fscache_n_store_pages_over_limit);
52697 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
52698 goto superseded;
52699 }
52700
52701 @@ -759,7 +759,7 @@ static void fscache_write_op(struct fscache_operation *_op)
52702 spin_unlock(&cookie->stores_lock);
52703 spin_unlock(&object->lock);
52704
52705 - fscache_stat(&fscache_n_store_pages);
52706 + fscache_stat_unchecked(&fscache_n_store_pages);
52707 fscache_stat(&fscache_n_cop_write_page);
52708 ret = object->cache->ops->write_page(op, page);
52709 fscache_stat_d(&fscache_n_cop_write_page);
52710 @@ -860,7 +860,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52711 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52712 ASSERT(PageFsCache(page));
52713
52714 - fscache_stat(&fscache_n_stores);
52715 + fscache_stat_unchecked(&fscache_n_stores);
52716
52717 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
52718 _leave(" = -ENOBUFS [invalidating]");
52719 @@ -916,7 +916,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52720 spin_unlock(&cookie->stores_lock);
52721 spin_unlock(&object->lock);
52722
52723 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
52724 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
52725 op->store_limit = object->store_limit;
52726
52727 if (fscache_submit_op(object, &op->op) < 0)
52728 @@ -924,8 +924,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52729
52730 spin_unlock(&cookie->lock);
52731 radix_tree_preload_end();
52732 - fscache_stat(&fscache_n_store_ops);
52733 - fscache_stat(&fscache_n_stores_ok);
52734 + fscache_stat_unchecked(&fscache_n_store_ops);
52735 + fscache_stat_unchecked(&fscache_n_stores_ok);
52736
52737 /* the work queue now carries its own ref on the object */
52738 fscache_put_operation(&op->op);
52739 @@ -933,14 +933,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
52740 return 0;
52741
52742 already_queued:
52743 - fscache_stat(&fscache_n_stores_again);
52744 + fscache_stat_unchecked(&fscache_n_stores_again);
52745 already_pending:
52746 spin_unlock(&cookie->stores_lock);
52747 spin_unlock(&object->lock);
52748 spin_unlock(&cookie->lock);
52749 radix_tree_preload_end();
52750 kfree(op);
52751 - fscache_stat(&fscache_n_stores_ok);
52752 + fscache_stat_unchecked(&fscache_n_stores_ok);
52753 _leave(" = 0");
52754 return 0;
52755
52756 @@ -959,14 +959,14 @@ nobufs:
52757 spin_unlock(&cookie->lock);
52758 radix_tree_preload_end();
52759 kfree(op);
52760 - fscache_stat(&fscache_n_stores_nobufs);
52761 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
52762 _leave(" = -ENOBUFS");
52763 return -ENOBUFS;
52764
52765 nomem_free:
52766 kfree(op);
52767 nomem:
52768 - fscache_stat(&fscache_n_stores_oom);
52769 + fscache_stat_unchecked(&fscache_n_stores_oom);
52770 _leave(" = -ENOMEM");
52771 return -ENOMEM;
52772 }
52773 @@ -984,7 +984,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
52774 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
52775 ASSERTCMP(page, !=, NULL);
52776
52777 - fscache_stat(&fscache_n_uncaches);
52778 + fscache_stat_unchecked(&fscache_n_uncaches);
52779
52780 /* cache withdrawal may beat us to it */
52781 if (!PageFsCache(page))
52782 @@ -1035,7 +1035,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
52783 struct fscache_cookie *cookie = op->op.object->cookie;
52784
52785 #ifdef CONFIG_FSCACHE_STATS
52786 - atomic_inc(&fscache_n_marks);
52787 + atomic_inc_unchecked(&fscache_n_marks);
52788 #endif
52789
52790 _debug("- mark %p{%lx}", page, page->index);
52791 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
52792 index 40d13c7..ddf52b9 100644
52793 --- a/fs/fscache/stats.c
52794 +++ b/fs/fscache/stats.c
52795 @@ -18,99 +18,99 @@
52796 /*
52797 * operation counters
52798 */
52799 -atomic_t fscache_n_op_pend;
52800 -atomic_t fscache_n_op_run;
52801 -atomic_t fscache_n_op_enqueue;
52802 -atomic_t fscache_n_op_requeue;
52803 -atomic_t fscache_n_op_deferred_release;
52804 -atomic_t fscache_n_op_release;
52805 -atomic_t fscache_n_op_gc;
52806 -atomic_t fscache_n_op_cancelled;
52807 -atomic_t fscache_n_op_rejected;
52808 +atomic_unchecked_t fscache_n_op_pend;
52809 +atomic_unchecked_t fscache_n_op_run;
52810 +atomic_unchecked_t fscache_n_op_enqueue;
52811 +atomic_unchecked_t fscache_n_op_requeue;
52812 +atomic_unchecked_t fscache_n_op_deferred_release;
52813 +atomic_unchecked_t fscache_n_op_release;
52814 +atomic_unchecked_t fscache_n_op_gc;
52815 +atomic_unchecked_t fscache_n_op_cancelled;
52816 +atomic_unchecked_t fscache_n_op_rejected;
52817
52818 -atomic_t fscache_n_attr_changed;
52819 -atomic_t fscache_n_attr_changed_ok;
52820 -atomic_t fscache_n_attr_changed_nobufs;
52821 -atomic_t fscache_n_attr_changed_nomem;
52822 -atomic_t fscache_n_attr_changed_calls;
52823 +atomic_unchecked_t fscache_n_attr_changed;
52824 +atomic_unchecked_t fscache_n_attr_changed_ok;
52825 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
52826 +atomic_unchecked_t fscache_n_attr_changed_nomem;
52827 +atomic_unchecked_t fscache_n_attr_changed_calls;
52828
52829 -atomic_t fscache_n_allocs;
52830 -atomic_t fscache_n_allocs_ok;
52831 -atomic_t fscache_n_allocs_wait;
52832 -atomic_t fscache_n_allocs_nobufs;
52833 -atomic_t fscache_n_allocs_intr;
52834 -atomic_t fscache_n_allocs_object_dead;
52835 -atomic_t fscache_n_alloc_ops;
52836 -atomic_t fscache_n_alloc_op_waits;
52837 +atomic_unchecked_t fscache_n_allocs;
52838 +atomic_unchecked_t fscache_n_allocs_ok;
52839 +atomic_unchecked_t fscache_n_allocs_wait;
52840 +atomic_unchecked_t fscache_n_allocs_nobufs;
52841 +atomic_unchecked_t fscache_n_allocs_intr;
52842 +atomic_unchecked_t fscache_n_allocs_object_dead;
52843 +atomic_unchecked_t fscache_n_alloc_ops;
52844 +atomic_unchecked_t fscache_n_alloc_op_waits;
52845
52846 -atomic_t fscache_n_retrievals;
52847 -atomic_t fscache_n_retrievals_ok;
52848 -atomic_t fscache_n_retrievals_wait;
52849 -atomic_t fscache_n_retrievals_nodata;
52850 -atomic_t fscache_n_retrievals_nobufs;
52851 -atomic_t fscache_n_retrievals_intr;
52852 -atomic_t fscache_n_retrievals_nomem;
52853 -atomic_t fscache_n_retrievals_object_dead;
52854 -atomic_t fscache_n_retrieval_ops;
52855 -atomic_t fscache_n_retrieval_op_waits;
52856 +atomic_unchecked_t fscache_n_retrievals;
52857 +atomic_unchecked_t fscache_n_retrievals_ok;
52858 +atomic_unchecked_t fscache_n_retrievals_wait;
52859 +atomic_unchecked_t fscache_n_retrievals_nodata;
52860 +atomic_unchecked_t fscache_n_retrievals_nobufs;
52861 +atomic_unchecked_t fscache_n_retrievals_intr;
52862 +atomic_unchecked_t fscache_n_retrievals_nomem;
52863 +atomic_unchecked_t fscache_n_retrievals_object_dead;
52864 +atomic_unchecked_t fscache_n_retrieval_ops;
52865 +atomic_unchecked_t fscache_n_retrieval_op_waits;
52866
52867 -atomic_t fscache_n_stores;
52868 -atomic_t fscache_n_stores_ok;
52869 -atomic_t fscache_n_stores_again;
52870 -atomic_t fscache_n_stores_nobufs;
52871 -atomic_t fscache_n_stores_oom;
52872 -atomic_t fscache_n_store_ops;
52873 -atomic_t fscache_n_store_calls;
52874 -atomic_t fscache_n_store_pages;
52875 -atomic_t fscache_n_store_radix_deletes;
52876 -atomic_t fscache_n_store_pages_over_limit;
52877 +atomic_unchecked_t fscache_n_stores;
52878 +atomic_unchecked_t fscache_n_stores_ok;
52879 +atomic_unchecked_t fscache_n_stores_again;
52880 +atomic_unchecked_t fscache_n_stores_nobufs;
52881 +atomic_unchecked_t fscache_n_stores_oom;
52882 +atomic_unchecked_t fscache_n_store_ops;
52883 +atomic_unchecked_t fscache_n_store_calls;
52884 +atomic_unchecked_t fscache_n_store_pages;
52885 +atomic_unchecked_t fscache_n_store_radix_deletes;
52886 +atomic_unchecked_t fscache_n_store_pages_over_limit;
52887
52888 -atomic_t fscache_n_store_vmscan_not_storing;
52889 -atomic_t fscache_n_store_vmscan_gone;
52890 -atomic_t fscache_n_store_vmscan_busy;
52891 -atomic_t fscache_n_store_vmscan_cancelled;
52892 -atomic_t fscache_n_store_vmscan_wait;
52893 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
52894 +atomic_unchecked_t fscache_n_store_vmscan_gone;
52895 +atomic_unchecked_t fscache_n_store_vmscan_busy;
52896 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
52897 +atomic_unchecked_t fscache_n_store_vmscan_wait;
52898
52899 -atomic_t fscache_n_marks;
52900 -atomic_t fscache_n_uncaches;
52901 +atomic_unchecked_t fscache_n_marks;
52902 +atomic_unchecked_t fscache_n_uncaches;
52903
52904 -atomic_t fscache_n_acquires;
52905 -atomic_t fscache_n_acquires_null;
52906 -atomic_t fscache_n_acquires_no_cache;
52907 -atomic_t fscache_n_acquires_ok;
52908 -atomic_t fscache_n_acquires_nobufs;
52909 -atomic_t fscache_n_acquires_oom;
52910 +atomic_unchecked_t fscache_n_acquires;
52911 +atomic_unchecked_t fscache_n_acquires_null;
52912 +atomic_unchecked_t fscache_n_acquires_no_cache;
52913 +atomic_unchecked_t fscache_n_acquires_ok;
52914 +atomic_unchecked_t fscache_n_acquires_nobufs;
52915 +atomic_unchecked_t fscache_n_acquires_oom;
52916
52917 -atomic_t fscache_n_invalidates;
52918 -atomic_t fscache_n_invalidates_run;
52919 +atomic_unchecked_t fscache_n_invalidates;
52920 +atomic_unchecked_t fscache_n_invalidates_run;
52921
52922 -atomic_t fscache_n_updates;
52923 -atomic_t fscache_n_updates_null;
52924 -atomic_t fscache_n_updates_run;
52925 +atomic_unchecked_t fscache_n_updates;
52926 +atomic_unchecked_t fscache_n_updates_null;
52927 +atomic_unchecked_t fscache_n_updates_run;
52928
52929 -atomic_t fscache_n_relinquishes;
52930 -atomic_t fscache_n_relinquishes_null;
52931 -atomic_t fscache_n_relinquishes_waitcrt;
52932 -atomic_t fscache_n_relinquishes_retire;
52933 +atomic_unchecked_t fscache_n_relinquishes;
52934 +atomic_unchecked_t fscache_n_relinquishes_null;
52935 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
52936 +atomic_unchecked_t fscache_n_relinquishes_retire;
52937
52938 -atomic_t fscache_n_cookie_index;
52939 -atomic_t fscache_n_cookie_data;
52940 -atomic_t fscache_n_cookie_special;
52941 +atomic_unchecked_t fscache_n_cookie_index;
52942 +atomic_unchecked_t fscache_n_cookie_data;
52943 +atomic_unchecked_t fscache_n_cookie_special;
52944
52945 -atomic_t fscache_n_object_alloc;
52946 -atomic_t fscache_n_object_no_alloc;
52947 -atomic_t fscache_n_object_lookups;
52948 -atomic_t fscache_n_object_lookups_negative;
52949 -atomic_t fscache_n_object_lookups_positive;
52950 -atomic_t fscache_n_object_lookups_timed_out;
52951 -atomic_t fscache_n_object_created;
52952 -atomic_t fscache_n_object_avail;
52953 -atomic_t fscache_n_object_dead;
52954 +atomic_unchecked_t fscache_n_object_alloc;
52955 +atomic_unchecked_t fscache_n_object_no_alloc;
52956 +atomic_unchecked_t fscache_n_object_lookups;
52957 +atomic_unchecked_t fscache_n_object_lookups_negative;
52958 +atomic_unchecked_t fscache_n_object_lookups_positive;
52959 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
52960 +atomic_unchecked_t fscache_n_object_created;
52961 +atomic_unchecked_t fscache_n_object_avail;
52962 +atomic_unchecked_t fscache_n_object_dead;
52963
52964 -atomic_t fscache_n_checkaux_none;
52965 -atomic_t fscache_n_checkaux_okay;
52966 -atomic_t fscache_n_checkaux_update;
52967 -atomic_t fscache_n_checkaux_obsolete;
52968 +atomic_unchecked_t fscache_n_checkaux_none;
52969 +atomic_unchecked_t fscache_n_checkaux_okay;
52970 +atomic_unchecked_t fscache_n_checkaux_update;
52971 +atomic_unchecked_t fscache_n_checkaux_obsolete;
52972
52973 atomic_t fscache_n_cop_alloc_object;
52974 atomic_t fscache_n_cop_lookup_object;
52975 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
52976 seq_puts(m, "FS-Cache statistics\n");
52977
52978 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
52979 - atomic_read(&fscache_n_cookie_index),
52980 - atomic_read(&fscache_n_cookie_data),
52981 - atomic_read(&fscache_n_cookie_special));
52982 + atomic_read_unchecked(&fscache_n_cookie_index),
52983 + atomic_read_unchecked(&fscache_n_cookie_data),
52984 + atomic_read_unchecked(&fscache_n_cookie_special));
52985
52986 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
52987 - atomic_read(&fscache_n_object_alloc),
52988 - atomic_read(&fscache_n_object_no_alloc),
52989 - atomic_read(&fscache_n_object_avail),
52990 - atomic_read(&fscache_n_object_dead));
52991 + atomic_read_unchecked(&fscache_n_object_alloc),
52992 + atomic_read_unchecked(&fscache_n_object_no_alloc),
52993 + atomic_read_unchecked(&fscache_n_object_avail),
52994 + atomic_read_unchecked(&fscache_n_object_dead));
52995 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
52996 - atomic_read(&fscache_n_checkaux_none),
52997 - atomic_read(&fscache_n_checkaux_okay),
52998 - atomic_read(&fscache_n_checkaux_update),
52999 - atomic_read(&fscache_n_checkaux_obsolete));
53000 + atomic_read_unchecked(&fscache_n_checkaux_none),
53001 + atomic_read_unchecked(&fscache_n_checkaux_okay),
53002 + atomic_read_unchecked(&fscache_n_checkaux_update),
53003 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
53004
53005 seq_printf(m, "Pages : mrk=%u unc=%u\n",
53006 - atomic_read(&fscache_n_marks),
53007 - atomic_read(&fscache_n_uncaches));
53008 + atomic_read_unchecked(&fscache_n_marks),
53009 + atomic_read_unchecked(&fscache_n_uncaches));
53010
53011 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
53012 " oom=%u\n",
53013 - atomic_read(&fscache_n_acquires),
53014 - atomic_read(&fscache_n_acquires_null),
53015 - atomic_read(&fscache_n_acquires_no_cache),
53016 - atomic_read(&fscache_n_acquires_ok),
53017 - atomic_read(&fscache_n_acquires_nobufs),
53018 - atomic_read(&fscache_n_acquires_oom));
53019 + atomic_read_unchecked(&fscache_n_acquires),
53020 + atomic_read_unchecked(&fscache_n_acquires_null),
53021 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
53022 + atomic_read_unchecked(&fscache_n_acquires_ok),
53023 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
53024 + atomic_read_unchecked(&fscache_n_acquires_oom));
53025
53026 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
53027 - atomic_read(&fscache_n_object_lookups),
53028 - atomic_read(&fscache_n_object_lookups_negative),
53029 - atomic_read(&fscache_n_object_lookups_positive),
53030 - atomic_read(&fscache_n_object_created),
53031 - atomic_read(&fscache_n_object_lookups_timed_out));
53032 + atomic_read_unchecked(&fscache_n_object_lookups),
53033 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
53034 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
53035 + atomic_read_unchecked(&fscache_n_object_created),
53036 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
53037
53038 seq_printf(m, "Invals : n=%u run=%u\n",
53039 - atomic_read(&fscache_n_invalidates),
53040 - atomic_read(&fscache_n_invalidates_run));
53041 + atomic_read_unchecked(&fscache_n_invalidates),
53042 + atomic_read_unchecked(&fscache_n_invalidates_run));
53043
53044 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
53045 - atomic_read(&fscache_n_updates),
53046 - atomic_read(&fscache_n_updates_null),
53047 - atomic_read(&fscache_n_updates_run));
53048 + atomic_read_unchecked(&fscache_n_updates),
53049 + atomic_read_unchecked(&fscache_n_updates_null),
53050 + atomic_read_unchecked(&fscache_n_updates_run));
53051
53052 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
53053 - atomic_read(&fscache_n_relinquishes),
53054 - atomic_read(&fscache_n_relinquishes_null),
53055 - atomic_read(&fscache_n_relinquishes_waitcrt),
53056 - atomic_read(&fscache_n_relinquishes_retire));
53057 + atomic_read_unchecked(&fscache_n_relinquishes),
53058 + atomic_read_unchecked(&fscache_n_relinquishes_null),
53059 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
53060 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
53061
53062 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
53063 - atomic_read(&fscache_n_attr_changed),
53064 - atomic_read(&fscache_n_attr_changed_ok),
53065 - atomic_read(&fscache_n_attr_changed_nobufs),
53066 - atomic_read(&fscache_n_attr_changed_nomem),
53067 - atomic_read(&fscache_n_attr_changed_calls));
53068 + atomic_read_unchecked(&fscache_n_attr_changed),
53069 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
53070 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
53071 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
53072 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
53073
53074 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
53075 - atomic_read(&fscache_n_allocs),
53076 - atomic_read(&fscache_n_allocs_ok),
53077 - atomic_read(&fscache_n_allocs_wait),
53078 - atomic_read(&fscache_n_allocs_nobufs),
53079 - atomic_read(&fscache_n_allocs_intr));
53080 + atomic_read_unchecked(&fscache_n_allocs),
53081 + atomic_read_unchecked(&fscache_n_allocs_ok),
53082 + atomic_read_unchecked(&fscache_n_allocs_wait),
53083 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
53084 + atomic_read_unchecked(&fscache_n_allocs_intr));
53085 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
53086 - atomic_read(&fscache_n_alloc_ops),
53087 - atomic_read(&fscache_n_alloc_op_waits),
53088 - atomic_read(&fscache_n_allocs_object_dead));
53089 + atomic_read_unchecked(&fscache_n_alloc_ops),
53090 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
53091 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
53092
53093 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
53094 " int=%u oom=%u\n",
53095 - atomic_read(&fscache_n_retrievals),
53096 - atomic_read(&fscache_n_retrievals_ok),
53097 - atomic_read(&fscache_n_retrievals_wait),
53098 - atomic_read(&fscache_n_retrievals_nodata),
53099 - atomic_read(&fscache_n_retrievals_nobufs),
53100 - atomic_read(&fscache_n_retrievals_intr),
53101 - atomic_read(&fscache_n_retrievals_nomem));
53102 + atomic_read_unchecked(&fscache_n_retrievals),
53103 + atomic_read_unchecked(&fscache_n_retrievals_ok),
53104 + atomic_read_unchecked(&fscache_n_retrievals_wait),
53105 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
53106 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
53107 + atomic_read_unchecked(&fscache_n_retrievals_intr),
53108 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
53109 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
53110 - atomic_read(&fscache_n_retrieval_ops),
53111 - atomic_read(&fscache_n_retrieval_op_waits),
53112 - atomic_read(&fscache_n_retrievals_object_dead));
53113 + atomic_read_unchecked(&fscache_n_retrieval_ops),
53114 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
53115 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
53116
53117 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
53118 - atomic_read(&fscache_n_stores),
53119 - atomic_read(&fscache_n_stores_ok),
53120 - atomic_read(&fscache_n_stores_again),
53121 - atomic_read(&fscache_n_stores_nobufs),
53122 - atomic_read(&fscache_n_stores_oom));
53123 + atomic_read_unchecked(&fscache_n_stores),
53124 + atomic_read_unchecked(&fscache_n_stores_ok),
53125 + atomic_read_unchecked(&fscache_n_stores_again),
53126 + atomic_read_unchecked(&fscache_n_stores_nobufs),
53127 + atomic_read_unchecked(&fscache_n_stores_oom));
53128 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
53129 - atomic_read(&fscache_n_store_ops),
53130 - atomic_read(&fscache_n_store_calls),
53131 - atomic_read(&fscache_n_store_pages),
53132 - atomic_read(&fscache_n_store_radix_deletes),
53133 - atomic_read(&fscache_n_store_pages_over_limit));
53134 + atomic_read_unchecked(&fscache_n_store_ops),
53135 + atomic_read_unchecked(&fscache_n_store_calls),
53136 + atomic_read_unchecked(&fscache_n_store_pages),
53137 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
53138 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
53139
53140 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
53141 - atomic_read(&fscache_n_store_vmscan_not_storing),
53142 - atomic_read(&fscache_n_store_vmscan_gone),
53143 - atomic_read(&fscache_n_store_vmscan_busy),
53144 - atomic_read(&fscache_n_store_vmscan_cancelled),
53145 - atomic_read(&fscache_n_store_vmscan_wait));
53146 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
53147 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
53148 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
53149 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
53150 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
53151
53152 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
53153 - atomic_read(&fscache_n_op_pend),
53154 - atomic_read(&fscache_n_op_run),
53155 - atomic_read(&fscache_n_op_enqueue),
53156 - atomic_read(&fscache_n_op_cancelled),
53157 - atomic_read(&fscache_n_op_rejected));
53158 + atomic_read_unchecked(&fscache_n_op_pend),
53159 + atomic_read_unchecked(&fscache_n_op_run),
53160 + atomic_read_unchecked(&fscache_n_op_enqueue),
53161 + atomic_read_unchecked(&fscache_n_op_cancelled),
53162 + atomic_read_unchecked(&fscache_n_op_rejected));
53163 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
53164 - atomic_read(&fscache_n_op_deferred_release),
53165 - atomic_read(&fscache_n_op_release),
53166 - atomic_read(&fscache_n_op_gc));
53167 + atomic_read_unchecked(&fscache_n_op_deferred_release),
53168 + atomic_read_unchecked(&fscache_n_op_release),
53169 + atomic_read_unchecked(&fscache_n_op_gc));
53170
53171 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
53172 atomic_read(&fscache_n_cop_alloc_object),
53173 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
53174 index aef34b1..59bfd7b 100644
53175 --- a/fs/fuse/cuse.c
53176 +++ b/fs/fuse/cuse.c
53177 @@ -600,10 +600,12 @@ static int __init cuse_init(void)
53178 INIT_LIST_HEAD(&cuse_conntbl[i]);
53179
53180 /* inherit and extend fuse_dev_operations */
53181 - cuse_channel_fops = fuse_dev_operations;
53182 - cuse_channel_fops.owner = THIS_MODULE;
53183 - cuse_channel_fops.open = cuse_channel_open;
53184 - cuse_channel_fops.release = cuse_channel_release;
53185 + pax_open_kernel();
53186 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
53187 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
53188 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
53189 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
53190 + pax_close_kernel();
53191
53192 cuse_class = class_create(THIS_MODULE, "cuse");
53193 if (IS_ERR(cuse_class))
53194 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
53195 index 1d55f94..088da65 100644
53196 --- a/fs/fuse/dev.c
53197 +++ b/fs/fuse/dev.c
53198 @@ -1339,7 +1339,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
53199 ret = 0;
53200 pipe_lock(pipe);
53201
53202 - if (!pipe->readers) {
53203 + if (!atomic_read(&pipe->readers)) {
53204 send_sig(SIGPIPE, current, 0);
53205 if (!ret)
53206 ret = -EPIPE;
53207 @@ -1364,7 +1364,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
53208 page_nr++;
53209 ret += buf->len;
53210
53211 - if (pipe->files)
53212 + if (atomic_read(&pipe->files))
53213 do_wakeup = 1;
53214 }
53215
53216 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
53217 index f3f783d..bf11a8e 100644
53218 --- a/fs/fuse/dir.c
53219 +++ b/fs/fuse/dir.c
53220 @@ -1415,7 +1415,7 @@ static char *read_link(struct dentry *dentry)
53221 return link;
53222 }
53223
53224 -static void free_link(char *link)
53225 +static void free_link(const char *link)
53226 {
53227 if (!IS_ERR(link))
53228 free_page((unsigned long) link);
53229 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
53230 index 62b484e..0f9a140 100644
53231 --- a/fs/gfs2/inode.c
53232 +++ b/fs/gfs2/inode.c
53233 @@ -1441,7 +1441,7 @@ out:
53234
53235 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
53236 {
53237 - char *s = nd_get_link(nd);
53238 + const char *s = nd_get_link(nd);
53239 if (!IS_ERR(s))
53240 kfree(s);
53241 }
53242 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
53243 index a3f868a..bb308ae 100644
53244 --- a/fs/hugetlbfs/inode.c
53245 +++ b/fs/hugetlbfs/inode.c
53246 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
53247 struct mm_struct *mm = current->mm;
53248 struct vm_area_struct *vma;
53249 struct hstate *h = hstate_file(file);
53250 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
53251 struct vm_unmapped_area_info info;
53252
53253 if (len & ~huge_page_mask(h))
53254 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
53255 return addr;
53256 }
53257
53258 +#ifdef CONFIG_PAX_RANDMMAP
53259 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
53260 +#endif
53261 +
53262 if (addr) {
53263 addr = ALIGN(addr, huge_page_size(h));
53264 vma = find_vma(mm, addr);
53265 - if (TASK_SIZE - len >= addr &&
53266 - (!vma || addr + len <= vma->vm_start))
53267 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
53268 return addr;
53269 }
53270
53271 info.flags = 0;
53272 info.length = len;
53273 info.low_limit = TASK_UNMAPPED_BASE;
53274 +
53275 +#ifdef CONFIG_PAX_RANDMMAP
53276 + if (mm->pax_flags & MF_PAX_RANDMMAP)
53277 + info.low_limit += mm->delta_mmap;
53278 +#endif
53279 +
53280 info.high_limit = TASK_SIZE;
53281 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
53282 info.align_offset = 0;
53283 @@ -898,7 +908,7 @@ static struct file_system_type hugetlbfs_fs_type = {
53284 };
53285 MODULE_ALIAS_FS("hugetlbfs");
53286
53287 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
53288 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
53289
53290 static int can_do_hugetlb_shm(void)
53291 {
53292 diff --git a/fs/inode.c b/fs/inode.c
53293 index 00d5fc3..98ce7d7 100644
53294 --- a/fs/inode.c
53295 +++ b/fs/inode.c
53296 @@ -878,8 +878,8 @@ unsigned int get_next_ino(void)
53297
53298 #ifdef CONFIG_SMP
53299 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
53300 - static atomic_t shared_last_ino;
53301 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
53302 + static atomic_unchecked_t shared_last_ino;
53303 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
53304
53305 res = next - LAST_INO_BATCH;
53306 }
53307 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
53308 index 4a6cf28..d3a29d3 100644
53309 --- a/fs/jffs2/erase.c
53310 +++ b/fs/jffs2/erase.c
53311 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
53312 struct jffs2_unknown_node marker = {
53313 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
53314 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
53315 - .totlen = cpu_to_je32(c->cleanmarker_size)
53316 + .totlen = cpu_to_je32(c->cleanmarker_size),
53317 + .hdr_crc = cpu_to_je32(0)
53318 };
53319
53320 jffs2_prealloc_raw_node_refs(c, jeb, 1);
53321 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
53322 index a6597d6..41b30ec 100644
53323 --- a/fs/jffs2/wbuf.c
53324 +++ b/fs/jffs2/wbuf.c
53325 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
53326 {
53327 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
53328 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
53329 - .totlen = constant_cpu_to_je32(8)
53330 + .totlen = constant_cpu_to_je32(8),
53331 + .hdr_crc = constant_cpu_to_je32(0)
53332 };
53333
53334 /*
53335 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
53336 index 788e0a9..8433098 100644
53337 --- a/fs/jfs/super.c
53338 +++ b/fs/jfs/super.c
53339 @@ -878,7 +878,7 @@ static int __init init_jfs_fs(void)
53340
53341 jfs_inode_cachep =
53342 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
53343 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
53344 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
53345 init_once);
53346 if (jfs_inode_cachep == NULL)
53347 return -ENOMEM;
53348 diff --git a/fs/libfs.c b/fs/libfs.c
53349 index 916da8c..1588998 100644
53350 --- a/fs/libfs.c
53351 +++ b/fs/libfs.c
53352 @@ -165,6 +165,9 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
53353
53354 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
53355 struct dentry *next;
53356 + char d_name[sizeof(next->d_iname)];
53357 + const unsigned char *name;
53358 +
53359 next = list_entry(p, struct dentry, d_u.d_child);
53360 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
53361 if (!simple_positive(next)) {
53362 @@ -174,7 +177,12 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
53363
53364 spin_unlock(&next->d_lock);
53365 spin_unlock(&dentry->d_lock);
53366 - if (filldir(dirent, next->d_name.name,
53367 + name = next->d_name.name;
53368 + if (name == next->d_iname) {
53369 + memcpy(d_name, name, next->d_name.len);
53370 + name = d_name;
53371 + }
53372 + if (filldir(dirent, name,
53373 next->d_name.len, filp->f_pos,
53374 next->d_inode->i_ino,
53375 dt_type(next->d_inode)) < 0)
53376 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
53377 index 9760ecb..9b838ef 100644
53378 --- a/fs/lockd/clntproc.c
53379 +++ b/fs/lockd/clntproc.c
53380 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
53381 /*
53382 * Cookie counter for NLM requests
53383 */
53384 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
53385 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
53386
53387 void nlmclnt_next_cookie(struct nlm_cookie *c)
53388 {
53389 - u32 cookie = atomic_inc_return(&nlm_cookie);
53390 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
53391
53392 memcpy(c->data, &cookie, 4);
53393 c->len=4;
53394 diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
53395 index a2aa97d..10d6c41 100644
53396 --- a/fs/lockd/svc.c
53397 +++ b/fs/lockd/svc.c
53398 @@ -305,7 +305,7 @@ static int lockd_start_svc(struct svc_serv *serv)
53399 svc_sock_update_bufs(serv);
53400 serv->sv_maxconn = nlm_max_connections;
53401
53402 - nlmsvc_task = kthread_run(lockd, nlmsvc_rqst, serv->sv_name);
53403 + nlmsvc_task = kthread_run(lockd, nlmsvc_rqst, "%s", serv->sv_name);
53404 if (IS_ERR(nlmsvc_task)) {
53405 error = PTR_ERR(nlmsvc_task);
53406 printk(KERN_WARNING
53407 diff --git a/fs/locks.c b/fs/locks.c
53408 index cb424a4..850e4dd 100644
53409 --- a/fs/locks.c
53410 +++ b/fs/locks.c
53411 @@ -2064,16 +2064,16 @@ void locks_remove_flock(struct file *filp)
53412 return;
53413
53414 if (filp->f_op && filp->f_op->flock) {
53415 - struct file_lock fl = {
53416 + struct file_lock flock = {
53417 .fl_pid = current->tgid,
53418 .fl_file = filp,
53419 .fl_flags = FL_FLOCK,
53420 .fl_type = F_UNLCK,
53421 .fl_end = OFFSET_MAX,
53422 };
53423 - filp->f_op->flock(filp, F_SETLKW, &fl);
53424 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
53425 - fl.fl_ops->fl_release_private(&fl);
53426 + filp->f_op->flock(filp, F_SETLKW, &flock);
53427 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
53428 + flock.fl_ops->fl_release_private(&flock);
53429 }
53430
53431 lock_flocks();
53432 diff --git a/fs/namei.c b/fs/namei.c
53433 index 9ed9361..2b72db1 100644
53434 --- a/fs/namei.c
53435 +++ b/fs/namei.c
53436 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
53437 if (ret != -EACCES)
53438 return ret;
53439
53440 +#ifdef CONFIG_GRKERNSEC
53441 + /* we'll block if we have to log due to a denied capability use */
53442 + if (mask & MAY_NOT_BLOCK)
53443 + return -ECHILD;
53444 +#endif
53445 +
53446 if (S_ISDIR(inode->i_mode)) {
53447 /* DACs are overridable for directories */
53448 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
53449 - return 0;
53450 if (!(mask & MAY_WRITE))
53451 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
53452 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
53453 + inode_capable(inode, CAP_DAC_READ_SEARCH))
53454 return 0;
53455 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
53456 + return 0;
53457 return -EACCES;
53458 }
53459 /*
53460 + * Searching includes executable on directories, else just read.
53461 + */
53462 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
53463 + if (mask == MAY_READ)
53464 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
53465 + inode_capable(inode, CAP_DAC_READ_SEARCH))
53466 + return 0;
53467 +
53468 + /*
53469 * Read/write DACs are always overridable.
53470 * Executable DACs are overridable when there is
53471 * at least one exec bit set.
53472 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
53473 if (inode_capable(inode, CAP_DAC_OVERRIDE))
53474 return 0;
53475
53476 - /*
53477 - * Searching includes executable on directories, else just read.
53478 - */
53479 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
53480 - if (mask == MAY_READ)
53481 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
53482 - return 0;
53483 -
53484 return -EACCES;
53485 }
53486
53487 @@ -820,7 +828,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
53488 {
53489 struct dentry *dentry = link->dentry;
53490 int error;
53491 - char *s;
53492 + const char *s;
53493
53494 BUG_ON(nd->flags & LOOKUP_RCU);
53495
53496 @@ -841,6 +849,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
53497 if (error)
53498 goto out_put_nd_path;
53499
53500 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
53501 + dentry->d_inode, dentry, nd->path.mnt)) {
53502 + error = -EACCES;
53503 + goto out_put_nd_path;
53504 + }
53505 +
53506 nd->last_type = LAST_BIND;
53507 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
53508 error = PTR_ERR(*p);
53509 @@ -1588,6 +1602,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
53510 if (res)
53511 break;
53512 res = walk_component(nd, path, LOOKUP_FOLLOW);
53513 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
53514 + res = -EACCES;
53515 put_link(nd, &link, cookie);
53516 } while (res > 0);
53517
53518 @@ -1686,7 +1702,7 @@ EXPORT_SYMBOL(full_name_hash);
53519 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
53520 {
53521 unsigned long a, b, adata, bdata, mask, hash, len;
53522 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
53523 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
53524
53525 hash = a = 0;
53526 len = -sizeof(unsigned long);
53527 @@ -1968,6 +1984,8 @@ static int path_lookupat(int dfd, const char *name,
53528 if (err)
53529 break;
53530 err = lookup_last(nd, &path);
53531 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
53532 + err = -EACCES;
53533 put_link(nd, &link, cookie);
53534 }
53535 }
53536 @@ -1975,6 +1993,13 @@ static int path_lookupat(int dfd, const char *name,
53537 if (!err)
53538 err = complete_walk(nd);
53539
53540 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
53541 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53542 + path_put(&nd->path);
53543 + err = -ENOENT;
53544 + }
53545 + }
53546 +
53547 if (!err && nd->flags & LOOKUP_DIRECTORY) {
53548 if (!can_lookup(nd->inode)) {
53549 path_put(&nd->path);
53550 @@ -2002,8 +2027,15 @@ static int filename_lookup(int dfd, struct filename *name,
53551 retval = path_lookupat(dfd, name->name,
53552 flags | LOOKUP_REVAL, nd);
53553
53554 - if (likely(!retval))
53555 + if (likely(!retval)) {
53556 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
53557 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
53558 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
53559 + path_put(&nd->path);
53560 + return -ENOENT;
53561 + }
53562 + }
53563 + }
53564 return retval;
53565 }
53566
53567 @@ -2381,6 +2413,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
53568 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
53569 return -EPERM;
53570
53571 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
53572 + return -EPERM;
53573 + if (gr_handle_rawio(inode))
53574 + return -EPERM;
53575 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
53576 + return -EACCES;
53577 +
53578 return 0;
53579 }
53580
53581 @@ -2602,7 +2641,7 @@ looked_up:
53582 * cleared otherwise prior to returning.
53583 */
53584 static int lookup_open(struct nameidata *nd, struct path *path,
53585 - struct file *file,
53586 + struct path *link, struct file *file,
53587 const struct open_flags *op,
53588 bool got_write, int *opened)
53589 {
53590 @@ -2637,6 +2676,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
53591 /* Negative dentry, just create the file */
53592 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
53593 umode_t mode = op->mode;
53594 +
53595 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
53596 + error = -EACCES;
53597 + goto out_dput;
53598 + }
53599 +
53600 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
53601 + error = -EACCES;
53602 + goto out_dput;
53603 + }
53604 +
53605 if (!IS_POSIXACL(dir->d_inode))
53606 mode &= ~current_umask();
53607 /*
53608 @@ -2658,6 +2708,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
53609 nd->flags & LOOKUP_EXCL);
53610 if (error)
53611 goto out_dput;
53612 + else
53613 + gr_handle_create(dentry, nd->path.mnt);
53614 }
53615 out_no_open:
53616 path->dentry = dentry;
53617 @@ -2672,7 +2724,7 @@ out_dput:
53618 /*
53619 * Handle the last step of open()
53620 */
53621 -static int do_last(struct nameidata *nd, struct path *path,
53622 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
53623 struct file *file, const struct open_flags *op,
53624 int *opened, struct filename *name)
53625 {
53626 @@ -2701,16 +2753,32 @@ static int do_last(struct nameidata *nd, struct path *path,
53627 error = complete_walk(nd);
53628 if (error)
53629 return error;
53630 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53631 + error = -ENOENT;
53632 + goto out;
53633 + }
53634 audit_inode(name, nd->path.dentry, 0);
53635 if (open_flag & O_CREAT) {
53636 error = -EISDIR;
53637 goto out;
53638 }
53639 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53640 + error = -EACCES;
53641 + goto out;
53642 + }
53643 goto finish_open;
53644 case LAST_BIND:
53645 error = complete_walk(nd);
53646 if (error)
53647 return error;
53648 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
53649 + error = -ENOENT;
53650 + goto out;
53651 + }
53652 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53653 + error = -EACCES;
53654 + goto out;
53655 + }
53656 audit_inode(name, dir, 0);
53657 goto finish_open;
53658 }
53659 @@ -2759,7 +2827,7 @@ retry_lookup:
53660 */
53661 }
53662 mutex_lock(&dir->d_inode->i_mutex);
53663 - error = lookup_open(nd, path, file, op, got_write, opened);
53664 + error = lookup_open(nd, path, link, file, op, got_write, opened);
53665 mutex_unlock(&dir->d_inode->i_mutex);
53666
53667 if (error <= 0) {
53668 @@ -2783,11 +2851,28 @@ retry_lookup:
53669 goto finish_open_created;
53670 }
53671
53672 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
53673 + error = -ENOENT;
53674 + goto exit_dput;
53675 + }
53676 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
53677 + error = -EACCES;
53678 + goto exit_dput;
53679 + }
53680 +
53681 /*
53682 * create/update audit record if it already exists.
53683 */
53684 - if (path->dentry->d_inode)
53685 + if (path->dentry->d_inode) {
53686 + /* only check if O_CREAT is specified, all other checks need to go
53687 + into may_open */
53688 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
53689 + error = -EACCES;
53690 + goto exit_dput;
53691 + }
53692 +
53693 audit_inode(name, path->dentry, 0);
53694 + }
53695
53696 /*
53697 * If atomic_open() acquired write access it is dropped now due to
53698 @@ -2828,6 +2913,11 @@ finish_lookup:
53699 }
53700 }
53701 BUG_ON(inode != path->dentry->d_inode);
53702 + /* if we're resolving a symlink to another symlink */
53703 + if (link && gr_handle_symlink_owner(link, inode)) {
53704 + error = -EACCES;
53705 + goto out;
53706 + }
53707 return 1;
53708 }
53709
53710 @@ -2837,7 +2927,6 @@ finish_lookup:
53711 save_parent.dentry = nd->path.dentry;
53712 save_parent.mnt = mntget(path->mnt);
53713 nd->path.dentry = path->dentry;
53714 -
53715 }
53716 nd->inode = inode;
53717 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
53718 @@ -2846,6 +2935,16 @@ finish_lookup:
53719 path_put(&save_parent);
53720 return error;
53721 }
53722 +
53723 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
53724 + error = -ENOENT;
53725 + goto out;
53726 + }
53727 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
53728 + error = -EACCES;
53729 + goto out;
53730 + }
53731 +
53732 error = -EISDIR;
53733 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
53734 goto out;
53735 @@ -2944,7 +3043,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
53736 if (unlikely(error))
53737 goto out;
53738
53739 - error = do_last(nd, &path, file, op, &opened, pathname);
53740 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
53741 while (unlikely(error > 0)) { /* trailing symlink */
53742 struct path link = path;
53743 void *cookie;
53744 @@ -2962,7 +3061,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
53745 error = follow_link(&link, nd, &cookie);
53746 if (unlikely(error))
53747 break;
53748 - error = do_last(nd, &path, file, op, &opened, pathname);
53749 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
53750 put_link(nd, &link, cookie);
53751 }
53752 out:
53753 @@ -3062,8 +3161,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
53754 goto unlock;
53755
53756 error = -EEXIST;
53757 - if (dentry->d_inode)
53758 + if (dentry->d_inode) {
53759 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
53760 + error = -ENOENT;
53761 + }
53762 goto fail;
53763 + }
53764 /*
53765 * Special case - lookup gave negative, but... we had foo/bar/
53766 * From the vfs_mknod() POV we just have a negative dentry -
53767 @@ -3115,6 +3218,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
53768 }
53769 EXPORT_SYMBOL(user_path_create);
53770
53771 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
53772 +{
53773 + struct filename *tmp = getname(pathname);
53774 + struct dentry *res;
53775 + if (IS_ERR(tmp))
53776 + return ERR_CAST(tmp);
53777 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
53778 + if (IS_ERR(res))
53779 + putname(tmp);
53780 + else
53781 + *to = tmp;
53782 + return res;
53783 +}
53784 +
53785 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
53786 {
53787 int error = may_create(dir, dentry);
53788 @@ -3177,6 +3294,17 @@ retry:
53789
53790 if (!IS_POSIXACL(path.dentry->d_inode))
53791 mode &= ~current_umask();
53792 +
53793 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
53794 + error = -EPERM;
53795 + goto out;
53796 + }
53797 +
53798 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
53799 + error = -EACCES;
53800 + goto out;
53801 + }
53802 +
53803 error = security_path_mknod(&path, dentry, mode, dev);
53804 if (error)
53805 goto out;
53806 @@ -3193,6 +3321,8 @@ retry:
53807 break;
53808 }
53809 out:
53810 + if (!error)
53811 + gr_handle_create(dentry, path.mnt);
53812 done_path_create(&path, dentry);
53813 if (retry_estale(error, lookup_flags)) {
53814 lookup_flags |= LOOKUP_REVAL;
53815 @@ -3245,9 +3375,16 @@ retry:
53816
53817 if (!IS_POSIXACL(path.dentry->d_inode))
53818 mode &= ~current_umask();
53819 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
53820 + error = -EACCES;
53821 + goto out;
53822 + }
53823 error = security_path_mkdir(&path, dentry, mode);
53824 if (!error)
53825 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
53826 + if (!error)
53827 + gr_handle_create(dentry, path.mnt);
53828 +out:
53829 done_path_create(&path, dentry);
53830 if (retry_estale(error, lookup_flags)) {
53831 lookup_flags |= LOOKUP_REVAL;
53832 @@ -3328,6 +3465,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
53833 struct filename *name;
53834 struct dentry *dentry;
53835 struct nameidata nd;
53836 + ino_t saved_ino = 0;
53837 + dev_t saved_dev = 0;
53838 unsigned int lookup_flags = 0;
53839 retry:
53840 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
53841 @@ -3360,10 +3499,21 @@ retry:
53842 error = -ENOENT;
53843 goto exit3;
53844 }
53845 +
53846 + saved_ino = dentry->d_inode->i_ino;
53847 + saved_dev = gr_get_dev_from_dentry(dentry);
53848 +
53849 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
53850 + error = -EACCES;
53851 + goto exit3;
53852 + }
53853 +
53854 error = security_path_rmdir(&nd.path, dentry);
53855 if (error)
53856 goto exit3;
53857 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
53858 + if (!error && (saved_dev || saved_ino))
53859 + gr_handle_delete(saved_ino, saved_dev);
53860 exit3:
53861 dput(dentry);
53862 exit2:
53863 @@ -3429,6 +3579,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
53864 struct dentry *dentry;
53865 struct nameidata nd;
53866 struct inode *inode = NULL;
53867 + ino_t saved_ino = 0;
53868 + dev_t saved_dev = 0;
53869 unsigned int lookup_flags = 0;
53870 retry:
53871 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
53872 @@ -3455,10 +3607,22 @@ retry:
53873 if (!inode)
53874 goto slashes;
53875 ihold(inode);
53876 +
53877 + if (inode->i_nlink <= 1) {
53878 + saved_ino = inode->i_ino;
53879 + saved_dev = gr_get_dev_from_dentry(dentry);
53880 + }
53881 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
53882 + error = -EACCES;
53883 + goto exit2;
53884 + }
53885 +
53886 error = security_path_unlink(&nd.path, dentry);
53887 if (error)
53888 goto exit2;
53889 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
53890 + if (!error && (saved_ino || saved_dev))
53891 + gr_handle_delete(saved_ino, saved_dev);
53892 exit2:
53893 dput(dentry);
53894 }
53895 @@ -3536,9 +3700,17 @@ retry:
53896 if (IS_ERR(dentry))
53897 goto out_putname;
53898
53899 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
53900 + error = -EACCES;
53901 + goto out;
53902 + }
53903 +
53904 error = security_path_symlink(&path, dentry, from->name);
53905 if (!error)
53906 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
53907 + if (!error)
53908 + gr_handle_create(dentry, path.mnt);
53909 +out:
53910 done_path_create(&path, dentry);
53911 if (retry_estale(error, lookup_flags)) {
53912 lookup_flags |= LOOKUP_REVAL;
53913 @@ -3612,6 +3784,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
53914 {
53915 struct dentry *new_dentry;
53916 struct path old_path, new_path;
53917 + struct filename *to = NULL;
53918 int how = 0;
53919 int error;
53920
53921 @@ -3635,7 +3808,7 @@ retry:
53922 if (error)
53923 return error;
53924
53925 - new_dentry = user_path_create(newdfd, newname, &new_path,
53926 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
53927 (how & LOOKUP_REVAL));
53928 error = PTR_ERR(new_dentry);
53929 if (IS_ERR(new_dentry))
53930 @@ -3647,11 +3820,28 @@ retry:
53931 error = may_linkat(&old_path);
53932 if (unlikely(error))
53933 goto out_dput;
53934 +
53935 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
53936 + old_path.dentry->d_inode,
53937 + old_path.dentry->d_inode->i_mode, to)) {
53938 + error = -EACCES;
53939 + goto out_dput;
53940 + }
53941 +
53942 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
53943 + old_path.dentry, old_path.mnt, to)) {
53944 + error = -EACCES;
53945 + goto out_dput;
53946 + }
53947 +
53948 error = security_path_link(old_path.dentry, &new_path, new_dentry);
53949 if (error)
53950 goto out_dput;
53951 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
53952 + if (!error)
53953 + gr_handle_create(new_dentry, new_path.mnt);
53954 out_dput:
53955 + putname(to);
53956 done_path_create(&new_path, new_dentry);
53957 if (retry_estale(error, how)) {
53958 how |= LOOKUP_REVAL;
53959 @@ -3897,12 +4087,21 @@ retry:
53960 if (new_dentry == trap)
53961 goto exit5;
53962
53963 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
53964 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
53965 + to);
53966 + if (error)
53967 + goto exit5;
53968 +
53969 error = security_path_rename(&oldnd.path, old_dentry,
53970 &newnd.path, new_dentry);
53971 if (error)
53972 goto exit5;
53973 error = vfs_rename(old_dir->d_inode, old_dentry,
53974 new_dir->d_inode, new_dentry);
53975 + if (!error)
53976 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
53977 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
53978 exit5:
53979 dput(new_dentry);
53980 exit4:
53981 @@ -3934,6 +4133,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
53982
53983 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
53984 {
53985 + char tmpbuf[64];
53986 + const char *newlink;
53987 int len;
53988
53989 len = PTR_ERR(link);
53990 @@ -3943,7 +4144,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
53991 len = strlen(link);
53992 if (len > (unsigned) buflen)
53993 len = buflen;
53994 - if (copy_to_user(buffer, link, len))
53995 +
53996 + if (len < sizeof(tmpbuf)) {
53997 + memcpy(tmpbuf, link, len);
53998 + newlink = tmpbuf;
53999 + } else
54000 + newlink = link;
54001 +
54002 + if (copy_to_user(buffer, newlink, len))
54003 len = -EFAULT;
54004 out:
54005 return len;
54006 diff --git a/fs/namespace.c b/fs/namespace.c
54007 index 7b1ca9b..6faeccf 100644
54008 --- a/fs/namespace.c
54009 +++ b/fs/namespace.c
54010 @@ -1265,6 +1265,9 @@ static int do_umount(struct mount *mnt, int flags)
54011 if (!(sb->s_flags & MS_RDONLY))
54012 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
54013 up_write(&sb->s_umount);
54014 +
54015 + gr_log_remount(mnt->mnt_devname, retval);
54016 +
54017 return retval;
54018 }
54019
54020 @@ -1283,6 +1286,9 @@ static int do_umount(struct mount *mnt, int flags)
54021 }
54022 br_write_unlock(&vfsmount_lock);
54023 namespace_unlock();
54024 +
54025 + gr_log_unmount(mnt->mnt_devname, retval);
54026 +
54027 return retval;
54028 }
54029
54030 @@ -1302,7 +1308,7 @@ static inline bool may_mount(void)
54031 * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
54032 */
54033
54034 -SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
54035 +SYSCALL_DEFINE2(umount, const char __user *, name, int, flags)
54036 {
54037 struct path path;
54038 struct mount *mnt;
54039 @@ -1342,7 +1348,7 @@ out:
54040 /*
54041 * The 2.0 compatible umount. No flags.
54042 */
54043 -SYSCALL_DEFINE1(oldumount, char __user *, name)
54044 +SYSCALL_DEFINE1(oldumount, const char __user *, name)
54045 {
54046 return sys_umount(name, 0);
54047 }
54048 @@ -2313,6 +2319,16 @@ long do_mount(const char *dev_name, const char *dir_name,
54049 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
54050 MS_STRICTATIME);
54051
54052 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
54053 + retval = -EPERM;
54054 + goto dput_out;
54055 + }
54056 +
54057 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
54058 + retval = -EPERM;
54059 + goto dput_out;
54060 + }
54061 +
54062 if (flags & MS_REMOUNT)
54063 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
54064 data_page);
54065 @@ -2327,6 +2343,9 @@ long do_mount(const char *dev_name, const char *dir_name,
54066 dev_name, data_page);
54067 dput_out:
54068 path_put(&path);
54069 +
54070 + gr_log_mount(dev_name, dir_name, retval);
54071 +
54072 return retval;
54073 }
54074
54075 @@ -2500,8 +2519,8 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
54076 }
54077 EXPORT_SYMBOL(mount_subtree);
54078
54079 -SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
54080 - char __user *, type, unsigned long, flags, void __user *, data)
54081 +SYSCALL_DEFINE5(mount, const char __user *, dev_name, const char __user *, dir_name,
54082 + const char __user *, type, unsigned long, flags, void __user *, data)
54083 {
54084 int ret;
54085 char *kernel_type;
54086 @@ -2614,6 +2633,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
54087 if (error)
54088 goto out2;
54089
54090 + if (gr_handle_chroot_pivot()) {
54091 + error = -EPERM;
54092 + goto out2;
54093 + }
54094 +
54095 get_fs_root(current->fs, &root);
54096 old_mp = lock_mount(&old);
54097 error = PTR_ERR(old_mp);
54098 @@ -2864,7 +2888,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
54099 !nsown_capable(CAP_SYS_ADMIN))
54100 return -EPERM;
54101
54102 - if (fs->users != 1)
54103 + if (atomic_read(&fs->users) != 1)
54104 return -EINVAL;
54105
54106 get_mnt_ns(mnt_ns);
54107 diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
54108 index cff089a..4c3d57a 100644
54109 --- a/fs/nfs/callback.c
54110 +++ b/fs/nfs/callback.c
54111 @@ -211,7 +211,6 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt,
54112 struct svc_rqst *rqstp;
54113 int (*callback_svc)(void *vrqstp);
54114 struct nfs_callback_data *cb_info = &nfs_callback_info[minorversion];
54115 - char svc_name[12];
54116 int ret;
54117
54118 nfs_callback_bc_serv(minorversion, xprt, serv);
54119 @@ -235,10 +234,9 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt,
54120
54121 svc_sock_update_bufs(serv);
54122
54123 - sprintf(svc_name, "nfsv4.%u-svc", minorversion);
54124 cb_info->serv = serv;
54125 cb_info->rqst = rqstp;
54126 - cb_info->task = kthread_run(callback_svc, cb_info->rqst, svc_name);
54127 + cb_info->task = kthread_run(callback_svc, cb_info->rqst, "nfsv4.%u-svc", minorversion);
54128 if (IS_ERR(cb_info->task)) {
54129 ret = PTR_ERR(cb_info->task);
54130 svc_exit_thread(cb_info->rqst);
54131 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
54132 index a35582c..ebbdcd5 100644
54133 --- a/fs/nfs/callback_xdr.c
54134 +++ b/fs/nfs/callback_xdr.c
54135 @@ -51,7 +51,7 @@ struct callback_op {
54136 callback_decode_arg_t decode_args;
54137 callback_encode_res_t encode_res;
54138 long res_maxsize;
54139 -};
54140 +} __do_const;
54141
54142 static struct callback_op callback_ops[];
54143
54144 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
54145 index c1c7a9d..7afa0b8 100644
54146 --- a/fs/nfs/inode.c
54147 +++ b/fs/nfs/inode.c
54148 @@ -1043,16 +1043,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
54149 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
54150 }
54151
54152 -static atomic_long_t nfs_attr_generation_counter;
54153 +static atomic_long_unchecked_t nfs_attr_generation_counter;
54154
54155 static unsigned long nfs_read_attr_generation_counter(void)
54156 {
54157 - return atomic_long_read(&nfs_attr_generation_counter);
54158 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
54159 }
54160
54161 unsigned long nfs_inc_attr_generation_counter(void)
54162 {
54163 - return atomic_long_inc_return(&nfs_attr_generation_counter);
54164 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
54165 }
54166
54167 void nfs_fattr_init(struct nfs_fattr *fattr)
54168 diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
54169 index 1fab140..73d0f75 100644
54170 --- a/fs/nfs/nfs4state.c
54171 +++ b/fs/nfs/nfs4state.c
54172 @@ -1194,7 +1194,7 @@ void nfs4_schedule_state_manager(struct nfs_client *clp)
54173 snprintf(buf, sizeof(buf), "%s-manager",
54174 rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR));
54175 rcu_read_unlock();
54176 - task = kthread_run(nfs4_run_state_manager, clp, buf);
54177 + task = kthread_run(nfs4_run_state_manager, clp, "%s", buf);
54178 if (IS_ERR(task)) {
54179 printk(KERN_ERR "%s: kthread_run: %ld\n",
54180 __func__, PTR_ERR(task));
54181 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
54182 index 27d74a2..c4c2a73 100644
54183 --- a/fs/nfsd/nfs4proc.c
54184 +++ b/fs/nfsd/nfs4proc.c
54185 @@ -1126,7 +1126,7 @@ struct nfsd4_operation {
54186 nfsd4op_rsize op_rsize_bop;
54187 stateid_getter op_get_currentstateid;
54188 stateid_setter op_set_currentstateid;
54189 -};
54190 +} __do_const;
54191
54192 static struct nfsd4_operation nfsd4_ops[];
54193
54194 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
54195 index 6cd86e0..0369a36 100644
54196 --- a/fs/nfsd/nfs4xdr.c
54197 +++ b/fs/nfsd/nfs4xdr.c
54198 @@ -1458,7 +1458,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
54199
54200 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
54201
54202 -static nfsd4_dec nfsd4_dec_ops[] = {
54203 +static const nfsd4_dec nfsd4_dec_ops[] = {
54204 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
54205 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
54206 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
54207 @@ -1498,7 +1498,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
54208 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
54209 };
54210
54211 -static nfsd4_dec nfsd41_dec_ops[] = {
54212 +static const nfsd4_dec nfsd41_dec_ops[] = {
54213 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
54214 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
54215 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
54216 @@ -1560,7 +1560,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
54217 };
54218
54219 struct nfsd4_minorversion_ops {
54220 - nfsd4_dec *decoders;
54221 + const nfsd4_dec *decoders;
54222 int nops;
54223 };
54224
54225 diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
54226 index e76244e..9fe8f2f1 100644
54227 --- a/fs/nfsd/nfscache.c
54228 +++ b/fs/nfsd/nfscache.c
54229 @@ -526,14 +526,17 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
54230 {
54231 struct svc_cacherep *rp = rqstp->rq_cacherep;
54232 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
54233 - int len;
54234 + long len;
54235 size_t bufsize = 0;
54236
54237 if (!rp)
54238 return;
54239
54240 - len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
54241 - len >>= 2;
54242 + if (statp) {
54243 + len = (char*)statp - (char*)resv->iov_base;
54244 + len = resv->iov_len - len;
54245 + len >>= 2;
54246 + }
54247
54248 /* Don't cache excessive amounts of data and XDR failures */
54249 if (!statp || len > (256 >> 2)) {
54250 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
54251 index 84ce601..633d226 100644
54252 --- a/fs/nfsd/vfs.c
54253 +++ b/fs/nfsd/vfs.c
54254 @@ -939,7 +939,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
54255 } else {
54256 oldfs = get_fs();
54257 set_fs(KERNEL_DS);
54258 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
54259 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
54260 set_fs(oldfs);
54261 }
54262
54263 @@ -1026,7 +1026,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
54264
54265 /* Write the data. */
54266 oldfs = get_fs(); set_fs(KERNEL_DS);
54267 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
54268 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
54269 set_fs(oldfs);
54270 if (host_err < 0)
54271 goto out_nfserr;
54272 @@ -1572,7 +1572,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
54273 */
54274
54275 oldfs = get_fs(); set_fs(KERNEL_DS);
54276 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
54277 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
54278 set_fs(oldfs);
54279
54280 if (host_err < 0)
54281 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
54282 index fea6bd5..8ee9d81 100644
54283 --- a/fs/nls/nls_base.c
54284 +++ b/fs/nls/nls_base.c
54285 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
54286
54287 int register_nls(struct nls_table * nls)
54288 {
54289 - struct nls_table ** tmp = &tables;
54290 + struct nls_table *tmp = tables;
54291
54292 if (nls->next)
54293 return -EBUSY;
54294
54295 spin_lock(&nls_lock);
54296 - while (*tmp) {
54297 - if (nls == *tmp) {
54298 + while (tmp) {
54299 + if (nls == tmp) {
54300 spin_unlock(&nls_lock);
54301 return -EBUSY;
54302 }
54303 - tmp = &(*tmp)->next;
54304 + tmp = tmp->next;
54305 }
54306 - nls->next = tables;
54307 + pax_open_kernel();
54308 + *(struct nls_table **)&nls->next = tables;
54309 + pax_close_kernel();
54310 tables = nls;
54311 spin_unlock(&nls_lock);
54312 return 0;
54313 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
54314
54315 int unregister_nls(struct nls_table * nls)
54316 {
54317 - struct nls_table ** tmp = &tables;
54318 + struct nls_table * const * tmp = &tables;
54319
54320 spin_lock(&nls_lock);
54321 while (*tmp) {
54322 if (nls == *tmp) {
54323 - *tmp = nls->next;
54324 + pax_open_kernel();
54325 + *(struct nls_table **)tmp = nls->next;
54326 + pax_close_kernel();
54327 spin_unlock(&nls_lock);
54328 return 0;
54329 }
54330 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
54331 index 7424929..35f6be5 100644
54332 --- a/fs/nls/nls_euc-jp.c
54333 +++ b/fs/nls/nls_euc-jp.c
54334 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
54335 p_nls = load_nls("cp932");
54336
54337 if (p_nls) {
54338 - table.charset2upper = p_nls->charset2upper;
54339 - table.charset2lower = p_nls->charset2lower;
54340 + pax_open_kernel();
54341 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
54342 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
54343 + pax_close_kernel();
54344 return register_nls(&table);
54345 }
54346
54347 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
54348 index e7bc1d7..06bd4bb 100644
54349 --- a/fs/nls/nls_koi8-ru.c
54350 +++ b/fs/nls/nls_koi8-ru.c
54351 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
54352 p_nls = load_nls("koi8-u");
54353
54354 if (p_nls) {
54355 - table.charset2upper = p_nls->charset2upper;
54356 - table.charset2lower = p_nls->charset2lower;
54357 + pax_open_kernel();
54358 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
54359 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
54360 + pax_close_kernel();
54361 return register_nls(&table);
54362 }
54363
54364 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
54365 index 6c80083..a1e6299 100644
54366 --- a/fs/notify/fanotify/fanotify_user.c
54367 +++ b/fs/notify/fanotify/fanotify_user.c
54368 @@ -122,6 +122,7 @@ static int fill_event_metadata(struct fsnotify_group *group,
54369 metadata->event_len = FAN_EVENT_METADATA_LEN;
54370 metadata->metadata_len = FAN_EVENT_METADATA_LEN;
54371 metadata->vers = FANOTIFY_METADATA_VERSION;
54372 + metadata->reserved = 0;
54373 metadata->mask = event->mask & FAN_ALL_OUTGOING_EVENTS;
54374 metadata->pid = pid_vnr(event->tgid);
54375 if (unlikely(event->mask & FAN_Q_OVERFLOW))
54376 @@ -252,8 +253,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
54377
54378 fd = fanotify_event_metadata.fd;
54379 ret = -EFAULT;
54380 - if (copy_to_user(buf, &fanotify_event_metadata,
54381 - fanotify_event_metadata.event_len))
54382 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
54383 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
54384 goto out_close_fd;
54385
54386 ret = prepare_for_access_response(group, event, fd);
54387 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
54388 index 7b51b05..5ea5ef6 100644
54389 --- a/fs/notify/notification.c
54390 +++ b/fs/notify/notification.c
54391 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
54392 * get set to 0 so it will never get 'freed'
54393 */
54394 static struct fsnotify_event *q_overflow_event;
54395 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54396 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54397
54398 /**
54399 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
54400 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
54401 */
54402 u32 fsnotify_get_cookie(void)
54403 {
54404 - return atomic_inc_return(&fsnotify_sync_cookie);
54405 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
54406 }
54407 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
54408
54409 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
54410 index aa411c3..c260a84 100644
54411 --- a/fs/ntfs/dir.c
54412 +++ b/fs/ntfs/dir.c
54413 @@ -1329,7 +1329,7 @@ find_next_index_buffer:
54414 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
54415 ~(s64)(ndir->itype.index.block_size - 1)));
54416 /* Bounds checks. */
54417 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
54418 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
54419 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
54420 "inode 0x%lx or driver bug.", vdir->i_ino);
54421 goto err_out;
54422 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
54423 index c5670b8..01a3656 100644
54424 --- a/fs/ntfs/file.c
54425 +++ b/fs/ntfs/file.c
54426 @@ -2241,6 +2241,6 @@ const struct inode_operations ntfs_file_inode_ops = {
54427 #endif /* NTFS_RW */
54428 };
54429
54430 -const struct file_operations ntfs_empty_file_ops = {};
54431 +const struct file_operations ntfs_empty_file_ops __read_only;
54432
54433 -const struct inode_operations ntfs_empty_inode_ops = {};
54434 +const struct inode_operations ntfs_empty_inode_ops __read_only;
54435 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
54436 index aebeacd..0dcdd26 100644
54437 --- a/fs/ocfs2/localalloc.c
54438 +++ b/fs/ocfs2/localalloc.c
54439 @@ -1278,7 +1278,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
54440 goto bail;
54441 }
54442
54443 - atomic_inc(&osb->alloc_stats.moves);
54444 + atomic_inc_unchecked(&osb->alloc_stats.moves);
54445
54446 bail:
54447 if (handle)
54448 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
54449 index d355e6e..578d905 100644
54450 --- a/fs/ocfs2/ocfs2.h
54451 +++ b/fs/ocfs2/ocfs2.h
54452 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
54453
54454 struct ocfs2_alloc_stats
54455 {
54456 - atomic_t moves;
54457 - atomic_t local_data;
54458 - atomic_t bitmap_data;
54459 - atomic_t bg_allocs;
54460 - atomic_t bg_extends;
54461 + atomic_unchecked_t moves;
54462 + atomic_unchecked_t local_data;
54463 + atomic_unchecked_t bitmap_data;
54464 + atomic_unchecked_t bg_allocs;
54465 + atomic_unchecked_t bg_extends;
54466 };
54467
54468 enum ocfs2_local_alloc_state
54469 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
54470 index b7e74b5..19c6536 100644
54471 --- a/fs/ocfs2/suballoc.c
54472 +++ b/fs/ocfs2/suballoc.c
54473 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
54474 mlog_errno(status);
54475 goto bail;
54476 }
54477 - atomic_inc(&osb->alloc_stats.bg_extends);
54478 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
54479
54480 /* You should never ask for this much metadata */
54481 BUG_ON(bits_wanted >
54482 @@ -2007,7 +2007,7 @@ int ocfs2_claim_metadata(handle_t *handle,
54483 mlog_errno(status);
54484 goto bail;
54485 }
54486 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54487 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54488
54489 *suballoc_loc = res.sr_bg_blkno;
54490 *suballoc_bit_start = res.sr_bit_offset;
54491 @@ -2171,7 +2171,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
54492 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
54493 res->sr_bits);
54494
54495 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54496 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54497
54498 BUG_ON(res->sr_bits != 1);
54499
54500 @@ -2213,7 +2213,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
54501 mlog_errno(status);
54502 goto bail;
54503 }
54504 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54505 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
54506
54507 BUG_ON(res.sr_bits != 1);
54508
54509 @@ -2317,7 +2317,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
54510 cluster_start,
54511 num_clusters);
54512 if (!status)
54513 - atomic_inc(&osb->alloc_stats.local_data);
54514 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
54515 } else {
54516 if (min_clusters > (osb->bitmap_cpg - 1)) {
54517 /* The only paths asking for contiguousness
54518 @@ -2343,7 +2343,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
54519 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
54520 res.sr_bg_blkno,
54521 res.sr_bit_offset);
54522 - atomic_inc(&osb->alloc_stats.bitmap_data);
54523 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
54524 *num_clusters = res.sr_bits;
54525 }
54526 }
54527 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
54528 index 01b8516..579c4df 100644
54529 --- a/fs/ocfs2/super.c
54530 +++ b/fs/ocfs2/super.c
54531 @@ -301,11 +301,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
54532 "%10s => GlobalAllocs: %d LocalAllocs: %d "
54533 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
54534 "Stats",
54535 - atomic_read(&osb->alloc_stats.bitmap_data),
54536 - atomic_read(&osb->alloc_stats.local_data),
54537 - atomic_read(&osb->alloc_stats.bg_allocs),
54538 - atomic_read(&osb->alloc_stats.moves),
54539 - atomic_read(&osb->alloc_stats.bg_extends));
54540 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
54541 + atomic_read_unchecked(&osb->alloc_stats.local_data),
54542 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
54543 + atomic_read_unchecked(&osb->alloc_stats.moves),
54544 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
54545
54546 out += snprintf(buf + out, len - out,
54547 "%10s => State: %u Descriptor: %llu Size: %u bits "
54548 @@ -2122,11 +2122,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
54549 spin_lock_init(&osb->osb_xattr_lock);
54550 ocfs2_init_steal_slots(osb);
54551
54552 - atomic_set(&osb->alloc_stats.moves, 0);
54553 - atomic_set(&osb->alloc_stats.local_data, 0);
54554 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
54555 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
54556 - atomic_set(&osb->alloc_stats.bg_extends, 0);
54557 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
54558 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
54559 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
54560 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
54561 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
54562
54563 /* Copy the blockcheck stats from the superblock probe */
54564 osb->osb_ecc_stats = *stats;
54565 diff --git a/fs/open.c b/fs/open.c
54566 index 8c74100..4239c48 100644
54567 --- a/fs/open.c
54568 +++ b/fs/open.c
54569 @@ -32,6 +32,8 @@
54570 #include <linux/dnotify.h>
54571 #include <linux/compat.h>
54572
54573 +#define CREATE_TRACE_POINTS
54574 +#include <trace/events/fs.h>
54575 #include "internal.h"
54576
54577 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
54578 @@ -102,6 +104,8 @@ long vfs_truncate(struct path *path, loff_t length)
54579 error = locks_verify_truncate(inode, NULL, length);
54580 if (!error)
54581 error = security_path_truncate(path);
54582 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
54583 + error = -EACCES;
54584 if (!error)
54585 error = do_truncate(path->dentry, length, 0, NULL);
54586
54587 @@ -186,6 +190,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
54588 error = locks_verify_truncate(inode, f.file, length);
54589 if (!error)
54590 error = security_path_truncate(&f.file->f_path);
54591 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
54592 + error = -EACCES;
54593 if (!error)
54594 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
54595 sb_end_write(inode->i_sb);
54596 @@ -360,6 +366,9 @@ retry:
54597 if (__mnt_is_readonly(path.mnt))
54598 res = -EROFS;
54599
54600 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
54601 + res = -EACCES;
54602 +
54603 out_path_release:
54604 path_put(&path);
54605 if (retry_estale(res, lookup_flags)) {
54606 @@ -391,6 +400,8 @@ retry:
54607 if (error)
54608 goto dput_and_out;
54609
54610 + gr_log_chdir(path.dentry, path.mnt);
54611 +
54612 set_fs_pwd(current->fs, &path);
54613
54614 dput_and_out:
54615 @@ -420,6 +431,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
54616 goto out_putf;
54617
54618 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
54619 +
54620 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
54621 + error = -EPERM;
54622 +
54623 + if (!error)
54624 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
54625 +
54626 if (!error)
54627 set_fs_pwd(current->fs, &f.file->f_path);
54628 out_putf:
54629 @@ -449,7 +467,13 @@ retry:
54630 if (error)
54631 goto dput_and_out;
54632
54633 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
54634 + goto dput_and_out;
54635 +
54636 set_fs_root(current->fs, &path);
54637 +
54638 + gr_handle_chroot_chdir(&path);
54639 +
54640 error = 0;
54641 dput_and_out:
54642 path_put(&path);
54643 @@ -471,6 +495,16 @@ static int chmod_common(struct path *path, umode_t mode)
54644 if (error)
54645 return error;
54646 mutex_lock(&inode->i_mutex);
54647 +
54648 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
54649 + error = -EACCES;
54650 + goto out_unlock;
54651 + }
54652 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
54653 + error = -EACCES;
54654 + goto out_unlock;
54655 + }
54656 +
54657 error = security_path_chmod(path, mode);
54658 if (error)
54659 goto out_unlock;
54660 @@ -531,6 +565,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
54661 uid = make_kuid(current_user_ns(), user);
54662 gid = make_kgid(current_user_ns(), group);
54663
54664 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
54665 + return -EACCES;
54666 +
54667 newattrs.ia_valid = ATTR_CTIME;
54668 if (user != (uid_t) -1) {
54669 if (!uid_valid(uid))
54670 @@ -946,6 +983,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
54671 } else {
54672 fsnotify_open(f);
54673 fd_install(fd, f);
54674 + trace_do_sys_open(tmp->name, flags, mode);
54675 }
54676 }
54677 putname(tmp);
54678 diff --git a/fs/pipe.c b/fs/pipe.c
54679 index d2c45e1..009fe1c 100644
54680 --- a/fs/pipe.c
54681 +++ b/fs/pipe.c
54682 @@ -56,7 +56,7 @@ unsigned int pipe_min_size = PAGE_SIZE;
54683
54684 static void pipe_lock_nested(struct pipe_inode_info *pipe, int subclass)
54685 {
54686 - if (pipe->files)
54687 + if (atomic_read(&pipe->files))
54688 mutex_lock_nested(&pipe->mutex, subclass);
54689 }
54690
54691 @@ -71,7 +71,7 @@ EXPORT_SYMBOL(pipe_lock);
54692
54693 void pipe_unlock(struct pipe_inode_info *pipe)
54694 {
54695 - if (pipe->files)
54696 + if (atomic_read(&pipe->files))
54697 mutex_unlock(&pipe->mutex);
54698 }
54699 EXPORT_SYMBOL(pipe_unlock);
54700 @@ -449,9 +449,9 @@ redo:
54701 }
54702 if (bufs) /* More to do? */
54703 continue;
54704 - if (!pipe->writers)
54705 + if (!atomic_read(&pipe->writers))
54706 break;
54707 - if (!pipe->waiting_writers) {
54708 + if (!atomic_read(&pipe->waiting_writers)) {
54709 /* syscall merging: Usually we must not sleep
54710 * if O_NONBLOCK is set, or if we got some data.
54711 * But if a writer sleeps in kernel space, then
54712 @@ -513,7 +513,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
54713 ret = 0;
54714 __pipe_lock(pipe);
54715
54716 - if (!pipe->readers) {
54717 + if (!atomic_read(&pipe->readers)) {
54718 send_sig(SIGPIPE, current, 0);
54719 ret = -EPIPE;
54720 goto out;
54721 @@ -562,7 +562,7 @@ redo1:
54722 for (;;) {
54723 int bufs;
54724
54725 - if (!pipe->readers) {
54726 + if (!atomic_read(&pipe->readers)) {
54727 send_sig(SIGPIPE, current, 0);
54728 if (!ret)
54729 ret = -EPIPE;
54730 @@ -653,9 +653,9 @@ redo2:
54731 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
54732 do_wakeup = 0;
54733 }
54734 - pipe->waiting_writers++;
54735 + atomic_inc(&pipe->waiting_writers);
54736 pipe_wait(pipe);
54737 - pipe->waiting_writers--;
54738 + atomic_dec(&pipe->waiting_writers);
54739 }
54740 out:
54741 __pipe_unlock(pipe);
54742 @@ -709,7 +709,7 @@ pipe_poll(struct file *filp, poll_table *wait)
54743 mask = 0;
54744 if (filp->f_mode & FMODE_READ) {
54745 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
54746 - if (!pipe->writers && filp->f_version != pipe->w_counter)
54747 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
54748 mask |= POLLHUP;
54749 }
54750
54751 @@ -719,7 +719,7 @@ pipe_poll(struct file *filp, poll_table *wait)
54752 * Most Unices do not set POLLERR for FIFOs but on Linux they
54753 * behave exactly like pipes for poll().
54754 */
54755 - if (!pipe->readers)
54756 + if (!atomic_read(&pipe->readers))
54757 mask |= POLLERR;
54758 }
54759
54760 @@ -734,17 +734,17 @@ pipe_release(struct inode *inode, struct file *file)
54761
54762 __pipe_lock(pipe);
54763 if (file->f_mode & FMODE_READ)
54764 - pipe->readers--;
54765 + atomic_dec(&pipe->readers);
54766 if (file->f_mode & FMODE_WRITE)
54767 - pipe->writers--;
54768 + atomic_dec(&pipe->writers);
54769
54770 - if (pipe->readers || pipe->writers) {
54771 + if (atomic_read(&pipe->readers) || atomic_read(&pipe->writers)) {
54772 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
54773 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
54774 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
54775 }
54776 spin_lock(&inode->i_lock);
54777 - if (!--pipe->files) {
54778 + if (atomic_dec_and_test(&pipe->files)) {
54779 inode->i_pipe = NULL;
54780 kill = 1;
54781 }
54782 @@ -811,7 +811,7 @@ void free_pipe_info(struct pipe_inode_info *pipe)
54783 kfree(pipe);
54784 }
54785
54786 -static struct vfsmount *pipe_mnt __read_mostly;
54787 +struct vfsmount *pipe_mnt __read_mostly;
54788
54789 /*
54790 * pipefs_dname() is called from d_path().
54791 @@ -841,8 +841,9 @@ static struct inode * get_pipe_inode(void)
54792 goto fail_iput;
54793
54794 inode->i_pipe = pipe;
54795 - pipe->files = 2;
54796 - pipe->readers = pipe->writers = 1;
54797 + atomic_set(&pipe->files, 2);
54798 + atomic_set(&pipe->readers, 1);
54799 + atomic_set(&pipe->writers, 1);
54800 inode->i_fop = &pipefifo_fops;
54801
54802 /*
54803 @@ -1022,17 +1023,17 @@ static int fifo_open(struct inode *inode, struct file *filp)
54804 spin_lock(&inode->i_lock);
54805 if (inode->i_pipe) {
54806 pipe = inode->i_pipe;
54807 - pipe->files++;
54808 + atomic_inc(&pipe->files);
54809 spin_unlock(&inode->i_lock);
54810 } else {
54811 spin_unlock(&inode->i_lock);
54812 pipe = alloc_pipe_info();
54813 if (!pipe)
54814 return -ENOMEM;
54815 - pipe->files = 1;
54816 + atomic_set(&pipe->files, 1);
54817 spin_lock(&inode->i_lock);
54818 if (unlikely(inode->i_pipe)) {
54819 - inode->i_pipe->files++;
54820 + atomic_inc(&inode->i_pipe->files);
54821 spin_unlock(&inode->i_lock);
54822 free_pipe_info(pipe);
54823 pipe = inode->i_pipe;
54824 @@ -1057,10 +1058,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
54825 * opened, even when there is no process writing the FIFO.
54826 */
54827 pipe->r_counter++;
54828 - if (pipe->readers++ == 0)
54829 + if (atomic_inc_return(&pipe->readers) == 1)
54830 wake_up_partner(pipe);
54831
54832 - if (!is_pipe && !pipe->writers) {
54833 + if (!is_pipe && !atomic_read(&pipe->writers)) {
54834 if ((filp->f_flags & O_NONBLOCK)) {
54835 /* suppress POLLHUP until we have
54836 * seen a writer */
54837 @@ -1079,14 +1080,14 @@ static int fifo_open(struct inode *inode, struct file *filp)
54838 * errno=ENXIO when there is no process reading the FIFO.
54839 */
54840 ret = -ENXIO;
54841 - if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !pipe->readers)
54842 + if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
54843 goto err;
54844
54845 pipe->w_counter++;
54846 - if (!pipe->writers++)
54847 + if (atomic_inc_return(&pipe->writers) == 1)
54848 wake_up_partner(pipe);
54849
54850 - if (!is_pipe && !pipe->readers) {
54851 + if (!is_pipe && !atomic_read(&pipe->readers)) {
54852 if (wait_for_partner(pipe, &pipe->r_counter))
54853 goto err_wr;
54854 }
54855 @@ -1100,11 +1101,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
54856 * the process can at least talk to itself.
54857 */
54858
54859 - pipe->readers++;
54860 - pipe->writers++;
54861 + atomic_inc(&pipe->readers);
54862 + atomic_inc(&pipe->writers);
54863 pipe->r_counter++;
54864 pipe->w_counter++;
54865 - if (pipe->readers == 1 || pipe->writers == 1)
54866 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
54867 wake_up_partner(pipe);
54868 break;
54869
54870 @@ -1118,20 +1119,20 @@ static int fifo_open(struct inode *inode, struct file *filp)
54871 return 0;
54872
54873 err_rd:
54874 - if (!--pipe->readers)
54875 + if (atomic_dec_and_test(&pipe->readers))
54876 wake_up_interruptible(&pipe->wait);
54877 ret = -ERESTARTSYS;
54878 goto err;
54879
54880 err_wr:
54881 - if (!--pipe->writers)
54882 + if (atomic_dec_and_test(&pipe->writers))
54883 wake_up_interruptible(&pipe->wait);
54884 ret = -ERESTARTSYS;
54885 goto err;
54886
54887 err:
54888 spin_lock(&inode->i_lock);
54889 - if (!--pipe->files) {
54890 + if (atomic_dec_and_test(&pipe->files)) {
54891 inode->i_pipe = NULL;
54892 kill = 1;
54893 }
54894 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
54895 index 15af622..0e9f4467 100644
54896 --- a/fs/proc/Kconfig
54897 +++ b/fs/proc/Kconfig
54898 @@ -30,12 +30,12 @@ config PROC_FS
54899
54900 config PROC_KCORE
54901 bool "/proc/kcore support" if !ARM
54902 - depends on PROC_FS && MMU
54903 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
54904
54905 config PROC_VMCORE
54906 bool "/proc/vmcore support"
54907 - depends on PROC_FS && CRASH_DUMP
54908 - default y
54909 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
54910 + default n
54911 help
54912 Exports the dump image of crashed kernel in ELF format.
54913
54914 @@ -59,8 +59,8 @@ config PROC_SYSCTL
54915 limited in memory.
54916
54917 config PROC_PAGE_MONITOR
54918 - default y
54919 - depends on PROC_FS && MMU
54920 + default n
54921 + depends on PROC_FS && MMU && !GRKERNSEC
54922 bool "Enable /proc page monitoring" if EXPERT
54923 help
54924 Various /proc files exist to monitor process memory utilization:
54925 diff --git a/fs/proc/array.c b/fs/proc/array.c
54926 index cbd0f1b..adec3f0 100644
54927 --- a/fs/proc/array.c
54928 +++ b/fs/proc/array.c
54929 @@ -60,6 +60,7 @@
54930 #include <linux/tty.h>
54931 #include <linux/string.h>
54932 #include <linux/mman.h>
54933 +#include <linux/grsecurity.h>
54934 #include <linux/proc_fs.h>
54935 #include <linux/ioport.h>
54936 #include <linux/uaccess.h>
54937 @@ -363,6 +364,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
54938 seq_putc(m, '\n');
54939 }
54940
54941 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
54942 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
54943 +{
54944 + if (p->mm)
54945 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
54946 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
54947 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
54948 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
54949 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
54950 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
54951 + else
54952 + seq_printf(m, "PaX:\t-----\n");
54953 +}
54954 +#endif
54955 +
54956 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
54957 struct pid *pid, struct task_struct *task)
54958 {
54959 @@ -381,9 +397,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
54960 task_cpus_allowed(m, task);
54961 cpuset_task_status_allowed(m, task);
54962 task_context_switch_counts(m, task);
54963 +
54964 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
54965 + task_pax(m, task);
54966 +#endif
54967 +
54968 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
54969 + task_grsec_rbac(m, task);
54970 +#endif
54971 +
54972 return 0;
54973 }
54974
54975 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54976 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
54977 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
54978 + _mm->pax_flags & MF_PAX_SEGMEXEC))
54979 +#endif
54980 +
54981 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54982 struct pid *pid, struct task_struct *task, int whole)
54983 {
54984 @@ -405,6 +436,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54985 char tcomm[sizeof(task->comm)];
54986 unsigned long flags;
54987
54988 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
54989 + if (current->exec_id != m->exec_id) {
54990 + gr_log_badprocpid("stat");
54991 + return 0;
54992 + }
54993 +#endif
54994 +
54995 state = *get_task_state(task);
54996 vsize = eip = esp = 0;
54997 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
54998 @@ -476,6 +514,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
54999 gtime = task_gtime(task);
55000 }
55001
55002 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55003 + if (PAX_RAND_FLAGS(mm)) {
55004 + eip = 0;
55005 + esp = 0;
55006 + wchan = 0;
55007 + }
55008 +#endif
55009 +#ifdef CONFIG_GRKERNSEC_HIDESYM
55010 + wchan = 0;
55011 + eip =0;
55012 + esp =0;
55013 +#endif
55014 +
55015 /* scale priority and nice values from timeslices to -20..20 */
55016 /* to make it look like a "normal" Unix priority/nice value */
55017 priority = task_prio(task);
55018 @@ -512,9 +563,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55019 seq_put_decimal_ull(m, ' ', vsize);
55020 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
55021 seq_put_decimal_ull(m, ' ', rsslim);
55022 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55023 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
55024 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
55025 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
55026 +#else
55027 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
55028 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
55029 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
55030 +#endif
55031 seq_put_decimal_ull(m, ' ', esp);
55032 seq_put_decimal_ull(m, ' ', eip);
55033 /* The signal information here is obsolete.
55034 @@ -536,7 +593,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
55035 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
55036 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
55037
55038 - if (mm && permitted) {
55039 + if (mm && permitted
55040 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55041 + && !PAX_RAND_FLAGS(mm)
55042 +#endif
55043 + ) {
55044 seq_put_decimal_ull(m, ' ', mm->start_data);
55045 seq_put_decimal_ull(m, ' ', mm->end_data);
55046 seq_put_decimal_ull(m, ' ', mm->start_brk);
55047 @@ -574,8 +635,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55048 struct pid *pid, struct task_struct *task)
55049 {
55050 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
55051 - struct mm_struct *mm = get_task_mm(task);
55052 + struct mm_struct *mm;
55053
55054 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55055 + if (current->exec_id != m->exec_id) {
55056 + gr_log_badprocpid("statm");
55057 + return 0;
55058 + }
55059 +#endif
55060 + mm = get_task_mm(task);
55061 if (mm) {
55062 size = task_statm(mm, &shared, &text, &data, &resident);
55063 mmput(mm);
55064 @@ -598,6 +666,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
55065 return 0;
55066 }
55067
55068 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55069 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
55070 +{
55071 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
55072 +}
55073 +#endif
55074 +
55075 #ifdef CONFIG_CHECKPOINT_RESTORE
55076 static struct pid *
55077 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
55078 diff --git a/fs/proc/base.c b/fs/proc/base.c
55079 index c3834da..b402b2b 100644
55080 --- a/fs/proc/base.c
55081 +++ b/fs/proc/base.c
55082 @@ -113,6 +113,14 @@ struct pid_entry {
55083 union proc_op op;
55084 };
55085
55086 +struct getdents_callback {
55087 + struct linux_dirent __user * current_dir;
55088 + struct linux_dirent __user * previous;
55089 + struct file * file;
55090 + int count;
55091 + int error;
55092 +};
55093 +
55094 #define NOD(NAME, MODE, IOP, FOP, OP) { \
55095 .name = (NAME), \
55096 .len = sizeof(NAME) - 1, \
55097 @@ -210,6 +218,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
55098 if (!mm->arg_end)
55099 goto out_mm; /* Shh! No looking before we're done */
55100
55101 + if (gr_acl_handle_procpidmem(task))
55102 + goto out_mm;
55103 +
55104 len = mm->arg_end - mm->arg_start;
55105
55106 if (len > PAGE_SIZE)
55107 @@ -237,12 +248,28 @@ out:
55108 return res;
55109 }
55110
55111 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55112 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
55113 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
55114 + _mm->pax_flags & MF_PAX_SEGMEXEC))
55115 +#endif
55116 +
55117 static int proc_pid_auxv(struct task_struct *task, char *buffer)
55118 {
55119 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
55120 int res = PTR_ERR(mm);
55121 if (mm && !IS_ERR(mm)) {
55122 unsigned int nwords = 0;
55123 +
55124 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55125 + /* allow if we're currently ptracing this task */
55126 + if (PAX_RAND_FLAGS(mm) &&
55127 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
55128 + mmput(mm);
55129 + return 0;
55130 + }
55131 +#endif
55132 +
55133 do {
55134 nwords += 2;
55135 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
55136 @@ -256,7 +283,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
55137 }
55138
55139
55140 -#ifdef CONFIG_KALLSYMS
55141 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55142 /*
55143 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
55144 * Returns the resolved symbol. If that fails, simply return the address.
55145 @@ -295,7 +322,7 @@ static void unlock_trace(struct task_struct *task)
55146 mutex_unlock(&task->signal->cred_guard_mutex);
55147 }
55148
55149 -#ifdef CONFIG_STACKTRACE
55150 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55151
55152 #define MAX_STACK_TRACE_DEPTH 64
55153
55154 @@ -518,7 +545,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
55155 return count;
55156 }
55157
55158 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55159 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55160 static int proc_pid_syscall(struct task_struct *task, char *buffer)
55161 {
55162 long nr;
55163 @@ -547,7 +574,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
55164 /************************************************************************/
55165
55166 /* permission checks */
55167 -static int proc_fd_access_allowed(struct inode *inode)
55168 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
55169 {
55170 struct task_struct *task;
55171 int allowed = 0;
55172 @@ -557,7 +584,10 @@ static int proc_fd_access_allowed(struct inode *inode)
55173 */
55174 task = get_proc_task(inode);
55175 if (task) {
55176 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
55177 + if (log)
55178 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
55179 + else
55180 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
55181 put_task_struct(task);
55182 }
55183 return allowed;
55184 @@ -588,10 +618,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
55185 struct task_struct *task,
55186 int hide_pid_min)
55187 {
55188 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55189 + return false;
55190 +
55191 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55192 + rcu_read_lock();
55193 + {
55194 + const struct cred *tmpcred = current_cred();
55195 + const struct cred *cred = __task_cred(task);
55196 +
55197 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
55198 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55199 + || in_group_p(grsec_proc_gid)
55200 +#endif
55201 + ) {
55202 + rcu_read_unlock();
55203 + return true;
55204 + }
55205 + }
55206 + rcu_read_unlock();
55207 +
55208 + if (!pid->hide_pid)
55209 + return false;
55210 +#endif
55211 +
55212 if (pid->hide_pid < hide_pid_min)
55213 return true;
55214 if (in_group_p(pid->pid_gid))
55215 return true;
55216 +
55217 return ptrace_may_access(task, PTRACE_MODE_READ);
55218 }
55219
55220 @@ -609,7 +664,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
55221 put_task_struct(task);
55222
55223 if (!has_perms) {
55224 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55225 + {
55226 +#else
55227 if (pid->hide_pid == 2) {
55228 +#endif
55229 /*
55230 * Let's make getdents(), stat(), and open()
55231 * consistent with each other. If a process
55232 @@ -707,6 +766,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
55233 if (!task)
55234 return -ESRCH;
55235
55236 + if (gr_acl_handle_procpidmem(task)) {
55237 + put_task_struct(task);
55238 + return -EPERM;
55239 + }
55240 +
55241 mm = mm_access(task, mode);
55242 put_task_struct(task);
55243
55244 @@ -722,6 +786,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
55245
55246 file->private_data = mm;
55247
55248 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55249 + file->f_version = current->exec_id;
55250 +#endif
55251 +
55252 return 0;
55253 }
55254
55255 @@ -743,6 +811,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
55256 ssize_t copied;
55257 char *page;
55258
55259 +#ifdef CONFIG_GRKERNSEC
55260 + if (write)
55261 + return -EPERM;
55262 +#endif
55263 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55264 + if (file->f_version != current->exec_id) {
55265 + gr_log_badprocpid("mem");
55266 + return 0;
55267 + }
55268 +#endif
55269 +
55270 if (!mm)
55271 return 0;
55272
55273 @@ -755,7 +834,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
55274 goto free;
55275
55276 while (count > 0) {
55277 - int this_len = min_t(int, count, PAGE_SIZE);
55278 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
55279
55280 if (write && copy_from_user(page, buf, this_len)) {
55281 copied = -EFAULT;
55282 @@ -847,6 +926,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
55283 if (!mm)
55284 return 0;
55285
55286 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55287 + if (file->f_version != current->exec_id) {
55288 + gr_log_badprocpid("environ");
55289 + return 0;
55290 + }
55291 +#endif
55292 +
55293 page = (char *)__get_free_page(GFP_TEMPORARY);
55294 if (!page)
55295 return -ENOMEM;
55296 @@ -856,7 +942,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
55297 goto free;
55298 while (count > 0) {
55299 size_t this_len, max_len;
55300 - int retval;
55301 + ssize_t retval;
55302
55303 if (src >= (mm->env_end - mm->env_start))
55304 break;
55305 @@ -1461,7 +1547,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
55306 int error = -EACCES;
55307
55308 /* Are we allowed to snoop on the tasks file descriptors? */
55309 - if (!proc_fd_access_allowed(inode))
55310 + if (!proc_fd_access_allowed(inode, 0))
55311 goto out;
55312
55313 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
55314 @@ -1505,8 +1591,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
55315 struct path path;
55316
55317 /* Are we allowed to snoop on the tasks file descriptors? */
55318 - if (!proc_fd_access_allowed(inode))
55319 - goto out;
55320 + /* logging this is needed for learning on chromium to work properly,
55321 + but we don't want to flood the logs from 'ps' which does a readlink
55322 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
55323 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
55324 + */
55325 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
55326 + if (!proc_fd_access_allowed(inode,0))
55327 + goto out;
55328 + } else {
55329 + if (!proc_fd_access_allowed(inode,1))
55330 + goto out;
55331 + }
55332
55333 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
55334 if (error)
55335 @@ -1556,7 +1652,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
55336 rcu_read_lock();
55337 cred = __task_cred(task);
55338 inode->i_uid = cred->euid;
55339 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55340 + inode->i_gid = grsec_proc_gid;
55341 +#else
55342 inode->i_gid = cred->egid;
55343 +#endif
55344 rcu_read_unlock();
55345 }
55346 security_task_to_inode(task, inode);
55347 @@ -1592,10 +1692,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
55348 return -ENOENT;
55349 }
55350 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
55351 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55352 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
55353 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55354 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
55355 +#endif
55356 task_dumpable(task)) {
55357 cred = __task_cred(task);
55358 stat->uid = cred->euid;
55359 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55360 + stat->gid = grsec_proc_gid;
55361 +#else
55362 stat->gid = cred->egid;
55363 +#endif
55364 }
55365 }
55366 rcu_read_unlock();
55367 @@ -1633,11 +1742,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
55368
55369 if (task) {
55370 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
55371 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55372 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
55373 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55374 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
55375 +#endif
55376 task_dumpable(task)) {
55377 rcu_read_lock();
55378 cred = __task_cred(task);
55379 inode->i_uid = cred->euid;
55380 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55381 + inode->i_gid = grsec_proc_gid;
55382 +#else
55383 inode->i_gid = cred->egid;
55384 +#endif
55385 rcu_read_unlock();
55386 } else {
55387 inode->i_uid = GLOBAL_ROOT_UID;
55388 @@ -2196,6 +2314,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
55389 if (!task)
55390 goto out_no_task;
55391
55392 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55393 + goto out;
55394 +
55395 /*
55396 * Yes, it does not scale. And it should not. Don't add
55397 * new entries into /proc/<tgid>/ without very good reasons.
55398 @@ -2240,6 +2361,9 @@ static int proc_pident_readdir(struct file *filp,
55399 if (!task)
55400 goto out_no_task;
55401
55402 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55403 + goto out;
55404 +
55405 ret = 0;
55406 i = filp->f_pos;
55407 switch (i) {
55408 @@ -2653,7 +2777,7 @@ static const struct pid_entry tgid_base_stuff[] = {
55409 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
55410 #endif
55411 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
55412 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55413 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55414 INF("syscall", S_IRUGO, proc_pid_syscall),
55415 #endif
55416 INF("cmdline", S_IRUGO, proc_pid_cmdline),
55417 @@ -2678,10 +2802,10 @@ static const struct pid_entry tgid_base_stuff[] = {
55418 #ifdef CONFIG_SECURITY
55419 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
55420 #endif
55421 -#ifdef CONFIG_KALLSYMS
55422 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55423 INF("wchan", S_IRUGO, proc_pid_wchan),
55424 #endif
55425 -#ifdef CONFIG_STACKTRACE
55426 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55427 ONE("stack", S_IRUGO, proc_pid_stack),
55428 #endif
55429 #ifdef CONFIG_SCHEDSTATS
55430 @@ -2715,6 +2839,9 @@ static const struct pid_entry tgid_base_stuff[] = {
55431 #ifdef CONFIG_HARDWALL
55432 INF("hardwall", S_IRUGO, proc_pid_hardwall),
55433 #endif
55434 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55435 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
55436 +#endif
55437 #ifdef CONFIG_USER_NS
55438 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
55439 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
55440 @@ -2847,7 +2974,14 @@ static struct dentry *proc_pid_instantiate(struct inode *dir,
55441 if (!inode)
55442 goto out;
55443
55444 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55445 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
55446 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55447 + inode->i_gid = grsec_proc_gid;
55448 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
55449 +#else
55450 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
55451 +#endif
55452 inode->i_op = &proc_tgid_base_inode_operations;
55453 inode->i_fop = &proc_tgid_base_operations;
55454 inode->i_flags|=S_IMMUTABLE;
55455 @@ -2885,7 +3019,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
55456 if (!task)
55457 goto out;
55458
55459 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
55460 + goto out_put_task;
55461 +
55462 result = proc_pid_instantiate(dir, dentry, task, NULL);
55463 +out_put_task:
55464 put_task_struct(task);
55465 out:
55466 return result;
55467 @@ -2948,6 +3086,8 @@ static int proc_pid_fill_cache(struct file *filp, void *dirent, filldir_t filldi
55468 static int fake_filldir(void *buf, const char *name, int namelen,
55469 loff_t offset, u64 ino, unsigned d_type)
55470 {
55471 + struct getdents_callback * __buf = (struct getdents_callback *) buf;
55472 + __buf->error = -EINVAL;
55473 return 0;
55474 }
55475
55476 @@ -3007,7 +3147,7 @@ static const struct pid_entry tid_base_stuff[] = {
55477 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
55478 #endif
55479 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
55480 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
55481 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
55482 INF("syscall", S_IRUGO, proc_pid_syscall),
55483 #endif
55484 INF("cmdline", S_IRUGO, proc_pid_cmdline),
55485 @@ -3034,10 +3174,10 @@ static const struct pid_entry tid_base_stuff[] = {
55486 #ifdef CONFIG_SECURITY
55487 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
55488 #endif
55489 -#ifdef CONFIG_KALLSYMS
55490 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55491 INF("wchan", S_IRUGO, proc_pid_wchan),
55492 #endif
55493 -#ifdef CONFIG_STACKTRACE
55494 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
55495 ONE("stack", S_IRUGO, proc_pid_stack),
55496 #endif
55497 #ifdef CONFIG_SCHEDSTATS
55498 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
55499 index 82676e3..5f8518a 100644
55500 --- a/fs/proc/cmdline.c
55501 +++ b/fs/proc/cmdline.c
55502 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
55503
55504 static int __init proc_cmdline_init(void)
55505 {
55506 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55507 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
55508 +#else
55509 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
55510 +#endif
55511 return 0;
55512 }
55513 module_init(proc_cmdline_init);
55514 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
55515 index b143471..bb105e5 100644
55516 --- a/fs/proc/devices.c
55517 +++ b/fs/proc/devices.c
55518 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
55519
55520 static int __init proc_devices_init(void)
55521 {
55522 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55523 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
55524 +#else
55525 proc_create("devices", 0, NULL, &proc_devinfo_operations);
55526 +#endif
55527 return 0;
55528 }
55529 module_init(proc_devices_init);
55530 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
55531 index d7a4a28..0201742 100644
55532 --- a/fs/proc/fd.c
55533 +++ b/fs/proc/fd.c
55534 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
55535 if (!task)
55536 return -ENOENT;
55537
55538 - files = get_files_struct(task);
55539 + if (!gr_acl_handle_procpidmem(task))
55540 + files = get_files_struct(task);
55541 put_task_struct(task);
55542
55543 if (files) {
55544 @@ -302,11 +303,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
55545 */
55546 int proc_fd_permission(struct inode *inode, int mask)
55547 {
55548 + struct task_struct *task;
55549 int rv = generic_permission(inode, mask);
55550 - if (rv == 0)
55551 - return 0;
55552 +
55553 if (task_pid(current) == proc_pid(inode))
55554 rv = 0;
55555 +
55556 + task = get_proc_task(inode);
55557 + if (task == NULL)
55558 + return rv;
55559 +
55560 + if (gr_acl_handle_procpidmem(task))
55561 + rv = -EACCES;
55562 +
55563 + put_task_struct(task);
55564 +
55565 return rv;
55566 }
55567
55568 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
55569 index 073aea6..0630370 100644
55570 --- a/fs/proc/inode.c
55571 +++ b/fs/proc/inode.c
55572 @@ -23,11 +23,17 @@
55573 #include <linux/slab.h>
55574 #include <linux/mount.h>
55575 #include <linux/magic.h>
55576 +#include <linux/grsecurity.h>
55577
55578 #include <asm/uaccess.h>
55579
55580 #include "internal.h"
55581
55582 +#ifdef CONFIG_PROC_SYSCTL
55583 +extern const struct inode_operations proc_sys_inode_operations;
55584 +extern const struct inode_operations proc_sys_dir_operations;
55585 +#endif
55586 +
55587 static void proc_evict_inode(struct inode *inode)
55588 {
55589 struct proc_dir_entry *de;
55590 @@ -55,6 +61,13 @@ static void proc_evict_inode(struct inode *inode)
55591 ns = PROC_I(inode)->ns.ns;
55592 if (ns_ops && ns)
55593 ns_ops->put(ns);
55594 +
55595 +#ifdef CONFIG_PROC_SYSCTL
55596 + if (inode->i_op == &proc_sys_inode_operations ||
55597 + inode->i_op == &proc_sys_dir_operations)
55598 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
55599 +#endif
55600 +
55601 }
55602
55603 static struct kmem_cache * proc_inode_cachep;
55604 @@ -385,7 +398,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
55605 if (de->mode) {
55606 inode->i_mode = de->mode;
55607 inode->i_uid = de->uid;
55608 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
55609 + inode->i_gid = grsec_proc_gid;
55610 +#else
55611 inode->i_gid = de->gid;
55612 +#endif
55613 }
55614 if (de->size)
55615 inode->i_size = de->size;
55616 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
55617 index d600fb0..3b495fe 100644
55618 --- a/fs/proc/internal.h
55619 +++ b/fs/proc/internal.h
55620 @@ -155,6 +155,9 @@ extern int proc_pid_status(struct seq_file *, struct pid_namespace *,
55621 struct pid *, struct task_struct *);
55622 extern int proc_pid_statm(struct seq_file *, struct pid_namespace *,
55623 struct pid *, struct task_struct *);
55624 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
55625 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
55626 +#endif
55627
55628 /*
55629 * base.c
55630 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
55631 index 0a22194..a9fc8c1 100644
55632 --- a/fs/proc/kcore.c
55633 +++ b/fs/proc/kcore.c
55634 @@ -484,9 +484,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55635 * the addresses in the elf_phdr on our list.
55636 */
55637 start = kc_offset_to_vaddr(*fpos - elf_buflen);
55638 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
55639 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
55640 + if (tsz > buflen)
55641 tsz = buflen;
55642 -
55643 +
55644 while (buflen) {
55645 struct kcore_list *m;
55646
55647 @@ -515,20 +516,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55648 kfree(elf_buf);
55649 } else {
55650 if (kern_addr_valid(start)) {
55651 - unsigned long n;
55652 + char *elf_buf;
55653 + mm_segment_t oldfs;
55654
55655 - n = copy_to_user(buffer, (char *)start, tsz);
55656 - /*
55657 - * We cannot distinguish between fault on source
55658 - * and fault on destination. When this happens
55659 - * we clear too and hope it will trigger the
55660 - * EFAULT again.
55661 - */
55662 - if (n) {
55663 - if (clear_user(buffer + tsz - n,
55664 - n))
55665 + elf_buf = kmalloc(tsz, GFP_KERNEL);
55666 + if (!elf_buf)
55667 + return -ENOMEM;
55668 + oldfs = get_fs();
55669 + set_fs(KERNEL_DS);
55670 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
55671 + set_fs(oldfs);
55672 + if (copy_to_user(buffer, elf_buf, tsz)) {
55673 + kfree(elf_buf);
55674 return -EFAULT;
55675 + }
55676 }
55677 + set_fs(oldfs);
55678 + kfree(elf_buf);
55679 } else {
55680 if (clear_user(buffer, tsz))
55681 return -EFAULT;
55682 @@ -548,6 +552,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
55683
55684 static int open_kcore(struct inode *inode, struct file *filp)
55685 {
55686 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
55687 + return -EPERM;
55688 +#endif
55689 if (!capable(CAP_SYS_RAWIO))
55690 return -EPERM;
55691 if (kcore_need_update)
55692 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
55693 index 5aa847a..f77c8d4 100644
55694 --- a/fs/proc/meminfo.c
55695 +++ b/fs/proc/meminfo.c
55696 @@ -159,7 +159,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
55697 vmi.used >> 10,
55698 vmi.largest_chunk >> 10
55699 #ifdef CONFIG_MEMORY_FAILURE
55700 - ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
55701 + ,atomic_long_read_unchecked(&num_poisoned_pages) << (PAGE_SHIFT - 10)
55702 #endif
55703 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
55704 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
55705 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
55706 index ccfd99b..1b7e255 100644
55707 --- a/fs/proc/nommu.c
55708 +++ b/fs/proc/nommu.c
55709 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
55710 if (len < 1)
55711 len = 1;
55712 seq_printf(m, "%*c", len, ' ');
55713 - seq_path(m, &file->f_path, "");
55714 + seq_path(m, &file->f_path, "\n\\");
55715 }
55716
55717 seq_putc(m, '\n');
55718 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
55719 index 986e832..6e8e859 100644
55720 --- a/fs/proc/proc_net.c
55721 +++ b/fs/proc/proc_net.c
55722 @@ -23,6 +23,7 @@
55723 #include <linux/nsproxy.h>
55724 #include <net/net_namespace.h>
55725 #include <linux/seq_file.h>
55726 +#include <linux/grsecurity.h>
55727
55728 #include "internal.h"
55729
55730 @@ -109,6 +110,17 @@ static struct net *get_proc_task_net(struct inode *dir)
55731 struct task_struct *task;
55732 struct nsproxy *ns;
55733 struct net *net = NULL;
55734 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55735 + const struct cred *cred = current_cred();
55736 +#endif
55737 +
55738 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55739 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
55740 + return net;
55741 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55742 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
55743 + return net;
55744 +#endif
55745
55746 rcu_read_lock();
55747 task = pid_task(proc_pid(dir), PIDTYPE_PID);
55748 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
55749 index ac05f33..1e6dc7e 100644
55750 --- a/fs/proc/proc_sysctl.c
55751 +++ b/fs/proc/proc_sysctl.c
55752 @@ -13,11 +13,15 @@
55753 #include <linux/module.h>
55754 #include "internal.h"
55755
55756 +extern int gr_handle_chroot_sysctl(const int op);
55757 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
55758 + const int op);
55759 +
55760 static const struct dentry_operations proc_sys_dentry_operations;
55761 static const struct file_operations proc_sys_file_operations;
55762 -static const struct inode_operations proc_sys_inode_operations;
55763 +const struct inode_operations proc_sys_inode_operations;
55764 static const struct file_operations proc_sys_dir_file_operations;
55765 -static const struct inode_operations proc_sys_dir_operations;
55766 +const struct inode_operations proc_sys_dir_operations;
55767
55768 void proc_sys_poll_notify(struct ctl_table_poll *poll)
55769 {
55770 @@ -467,6 +471,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
55771
55772 err = NULL;
55773 d_set_d_op(dentry, &proc_sys_dentry_operations);
55774 +
55775 + gr_handle_proc_create(dentry, inode);
55776 +
55777 d_add(dentry, inode);
55778
55779 out:
55780 @@ -482,6 +489,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55781 struct inode *inode = file_inode(filp);
55782 struct ctl_table_header *head = grab_header(inode);
55783 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
55784 + int op = write ? MAY_WRITE : MAY_READ;
55785 ssize_t error;
55786 size_t res;
55787
55788 @@ -493,7 +501,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55789 * and won't be until we finish.
55790 */
55791 error = -EPERM;
55792 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
55793 + if (sysctl_perm(head, table, op))
55794 goto out;
55795
55796 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
55797 @@ -501,6 +509,22 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
55798 if (!table->proc_handler)
55799 goto out;
55800
55801 +#ifdef CONFIG_GRKERNSEC
55802 + error = -EPERM;
55803 + if (gr_handle_chroot_sysctl(op))
55804 + goto out;
55805 + dget(filp->f_path.dentry);
55806 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
55807 + dput(filp->f_path.dentry);
55808 + goto out;
55809 + }
55810 + dput(filp->f_path.dentry);
55811 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
55812 + goto out;
55813 + if (write && !capable(CAP_SYS_ADMIN))
55814 + goto out;
55815 +#endif
55816 +
55817 /* careful: calling conventions are nasty here */
55818 res = count;
55819 error = table->proc_handler(table, write, buf, &res, ppos);
55820 @@ -598,6 +622,9 @@ static int proc_sys_fill_cache(struct file *filp, void *dirent,
55821 return -ENOMEM;
55822 } else {
55823 d_set_d_op(child, &proc_sys_dentry_operations);
55824 +
55825 + gr_handle_proc_create(child, inode);
55826 +
55827 d_add(child, inode);
55828 }
55829 } else {
55830 @@ -641,6 +668,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
55831 if ((*pos)++ < file->f_pos)
55832 return 0;
55833
55834 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
55835 + return 0;
55836 +
55837 if (unlikely(S_ISLNK(table->mode)))
55838 res = proc_sys_link_fill_cache(file, dirent, filldir, head, table);
55839 else
55840 @@ -751,6 +781,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
55841 if (IS_ERR(head))
55842 return PTR_ERR(head);
55843
55844 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
55845 + return -ENOENT;
55846 +
55847 generic_fillattr(inode, stat);
55848 if (table)
55849 stat->mode = (stat->mode & S_IFMT) | table->mode;
55850 @@ -773,13 +806,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
55851 .llseek = generic_file_llseek,
55852 };
55853
55854 -static const struct inode_operations proc_sys_inode_operations = {
55855 +const struct inode_operations proc_sys_inode_operations = {
55856 .permission = proc_sys_permission,
55857 .setattr = proc_sys_setattr,
55858 .getattr = proc_sys_getattr,
55859 };
55860
55861 -static const struct inode_operations proc_sys_dir_operations = {
55862 +const struct inode_operations proc_sys_dir_operations = {
55863 .lookup = proc_sys_lookup,
55864 .permission = proc_sys_permission,
55865 .setattr = proc_sys_setattr,
55866 @@ -855,7 +888,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
55867 static struct ctl_dir *new_dir(struct ctl_table_set *set,
55868 const char *name, int namelen)
55869 {
55870 - struct ctl_table *table;
55871 + ctl_table_no_const *table;
55872 struct ctl_dir *new;
55873 struct ctl_node *node;
55874 char *new_name;
55875 @@ -867,7 +900,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
55876 return NULL;
55877
55878 node = (struct ctl_node *)(new + 1);
55879 - table = (struct ctl_table *)(node + 1);
55880 + table = (ctl_table_no_const *)(node + 1);
55881 new_name = (char *)(table + 2);
55882 memcpy(new_name, name, namelen);
55883 new_name[namelen] = '\0';
55884 @@ -1036,7 +1069,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
55885 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
55886 struct ctl_table_root *link_root)
55887 {
55888 - struct ctl_table *link_table, *entry, *link;
55889 + ctl_table_no_const *link_table, *link;
55890 + struct ctl_table *entry;
55891 struct ctl_table_header *links;
55892 struct ctl_node *node;
55893 char *link_name;
55894 @@ -1059,7 +1093,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
55895 return NULL;
55896
55897 node = (struct ctl_node *)(links + 1);
55898 - link_table = (struct ctl_table *)(node + nr_entries);
55899 + link_table = (ctl_table_no_const *)(node + nr_entries);
55900 link_name = (char *)&link_table[nr_entries + 1];
55901
55902 for (link = link_table, entry = table; entry->procname; link++, entry++) {
55903 @@ -1307,8 +1341,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55904 struct ctl_table_header ***subheader, struct ctl_table_set *set,
55905 struct ctl_table *table)
55906 {
55907 - struct ctl_table *ctl_table_arg = NULL;
55908 - struct ctl_table *entry, *files;
55909 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
55910 + struct ctl_table *entry;
55911 int nr_files = 0;
55912 int nr_dirs = 0;
55913 int err = -ENOMEM;
55914 @@ -1320,10 +1354,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55915 nr_files++;
55916 }
55917
55918 - files = table;
55919 /* If there are mixed files and directories we need a new table */
55920 if (nr_dirs && nr_files) {
55921 - struct ctl_table *new;
55922 + ctl_table_no_const *new;
55923 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
55924 GFP_KERNEL);
55925 if (!files)
55926 @@ -1341,7 +1374,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
55927 /* Register everything except a directory full of subdirectories */
55928 if (nr_files || !nr_dirs) {
55929 struct ctl_table_header *header;
55930 - header = __register_sysctl_table(set, path, files);
55931 + header = __register_sysctl_table(set, path, files ? files : table);
55932 if (!header) {
55933 kfree(ctl_table_arg);
55934 goto out;
55935 diff --git a/fs/proc/root.c b/fs/proc/root.c
55936 index 41a6ea9..23eaa92 100644
55937 --- a/fs/proc/root.c
55938 +++ b/fs/proc/root.c
55939 @@ -182,7 +182,15 @@ void __init proc_root_init(void)
55940 #ifdef CONFIG_PROC_DEVICETREE
55941 proc_device_tree_init();
55942 #endif
55943 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
55944 +#ifdef CONFIG_GRKERNSEC_PROC_USER
55945 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
55946 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
55947 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
55948 +#endif
55949 +#else
55950 proc_mkdir("bus", NULL);
55951 +#endif
55952 proc_sys_init();
55953 }
55954
55955 diff --git a/fs/proc/self.c b/fs/proc/self.c
55956 index 6b6a993..807cccc 100644
55957 --- a/fs/proc/self.c
55958 +++ b/fs/proc/self.c
55959 @@ -39,7 +39,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
55960 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
55961 void *cookie)
55962 {
55963 - char *s = nd_get_link(nd);
55964 + const char *s = nd_get_link(nd);
55965 if (!IS_ERR(s))
55966 kfree(s);
55967 }
55968 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
55969 index 3e636d8..83e3b71 100644
55970 --- a/fs/proc/task_mmu.c
55971 +++ b/fs/proc/task_mmu.c
55972 @@ -11,12 +11,19 @@
55973 #include <linux/rmap.h>
55974 #include <linux/swap.h>
55975 #include <linux/swapops.h>
55976 +#include <linux/grsecurity.h>
55977
55978 #include <asm/elf.h>
55979 #include <asm/uaccess.h>
55980 #include <asm/tlbflush.h>
55981 #include "internal.h"
55982
55983 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55984 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
55985 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
55986 + _mm->pax_flags & MF_PAX_SEGMEXEC))
55987 +#endif
55988 +
55989 void task_mem(struct seq_file *m, struct mm_struct *mm)
55990 {
55991 unsigned long data, text, lib, swap;
55992 @@ -52,8 +59,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
55993 "VmExe:\t%8lu kB\n"
55994 "VmLib:\t%8lu kB\n"
55995 "VmPTE:\t%8lu kB\n"
55996 - "VmSwap:\t%8lu kB\n",
55997 - hiwater_vm << (PAGE_SHIFT-10),
55998 + "VmSwap:\t%8lu kB\n"
55999 +
56000 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
56001 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
56002 +#endif
56003 +
56004 + ,hiwater_vm << (PAGE_SHIFT-10),
56005 total_vm << (PAGE_SHIFT-10),
56006 mm->locked_vm << (PAGE_SHIFT-10),
56007 mm->pinned_vm << (PAGE_SHIFT-10),
56008 @@ -62,7 +74,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
56009 data << (PAGE_SHIFT-10),
56010 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
56011 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
56012 - swap << (PAGE_SHIFT-10));
56013 + swap << (PAGE_SHIFT-10)
56014 +
56015 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
56016 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56017 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
56018 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
56019 +#else
56020 + , mm->context.user_cs_base
56021 + , mm->context.user_cs_limit
56022 +#endif
56023 +#endif
56024 +
56025 + );
56026 }
56027
56028 unsigned long task_vsize(struct mm_struct *mm)
56029 @@ -277,13 +301,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56030 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
56031 }
56032
56033 - /* We don't show the stack guard page in /proc/maps */
56034 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56035 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
56036 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
56037 +#else
56038 start = vma->vm_start;
56039 - if (stack_guard_page_start(vma, start))
56040 - start += PAGE_SIZE;
56041 end = vma->vm_end;
56042 - if (stack_guard_page_end(vma, end))
56043 - end -= PAGE_SIZE;
56044 +#endif
56045
56046 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
56047 start,
56048 @@ -292,7 +316,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56049 flags & VM_WRITE ? 'w' : '-',
56050 flags & VM_EXEC ? 'x' : '-',
56051 flags & VM_MAYSHARE ? 's' : 'p',
56052 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56053 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
56054 +#else
56055 pgoff,
56056 +#endif
56057 MAJOR(dev), MINOR(dev), ino, &len);
56058
56059 /*
56060 @@ -301,7 +329,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56061 */
56062 if (file) {
56063 pad_len_spaces(m, len);
56064 - seq_path(m, &file->f_path, "\n");
56065 + seq_path(m, &file->f_path, "\n\\");
56066 goto done;
56067 }
56068
56069 @@ -327,8 +355,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
56070 * Thread stack in /proc/PID/task/TID/maps or
56071 * the main process stack.
56072 */
56073 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
56074 - vma->vm_end >= mm->start_stack)) {
56075 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
56076 + (vma->vm_start <= mm->start_stack &&
56077 + vma->vm_end >= mm->start_stack)) {
56078 name = "[stack]";
56079 } else {
56080 /* Thread stack in /proc/PID/maps */
56081 @@ -352,6 +381,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
56082 struct proc_maps_private *priv = m->private;
56083 struct task_struct *task = priv->task;
56084
56085 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56086 + if (current->exec_id != m->exec_id) {
56087 + gr_log_badprocpid("maps");
56088 + return 0;
56089 + }
56090 +#endif
56091 +
56092 show_map_vma(m, vma, is_pid);
56093
56094 if (m->count < m->size) /* vma is copied successfully */
56095 @@ -589,12 +625,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
56096 .private = &mss,
56097 };
56098
56099 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56100 + if (current->exec_id != m->exec_id) {
56101 + gr_log_badprocpid("smaps");
56102 + return 0;
56103 + }
56104 +#endif
56105 memset(&mss, 0, sizeof mss);
56106 - mss.vma = vma;
56107 - /* mmap_sem is held in m_start */
56108 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
56109 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
56110 -
56111 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56112 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
56113 +#endif
56114 + mss.vma = vma;
56115 + /* mmap_sem is held in m_start */
56116 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
56117 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
56118 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56119 + }
56120 +#endif
56121 show_map_vma(m, vma, is_pid);
56122
56123 seq_printf(m,
56124 @@ -612,7 +659,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
56125 "KernelPageSize: %8lu kB\n"
56126 "MMUPageSize: %8lu kB\n"
56127 "Locked: %8lu kB\n",
56128 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56129 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
56130 +#else
56131 (vma->vm_end - vma->vm_start) >> 10,
56132 +#endif
56133 mss.resident >> 10,
56134 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
56135 mss.shared_clean >> 10,
56136 @@ -1264,6 +1315,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
56137 int n;
56138 char buffer[50];
56139
56140 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56141 + if (current->exec_id != m->exec_id) {
56142 + gr_log_badprocpid("numa_maps");
56143 + return 0;
56144 + }
56145 +#endif
56146 +
56147 if (!mm)
56148 return 0;
56149
56150 @@ -1281,11 +1339,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
56151 mpol_to_str(buffer, sizeof(buffer), pol);
56152 mpol_cond_put(pol);
56153
56154 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56155 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
56156 +#else
56157 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
56158 +#endif
56159
56160 if (file) {
56161 seq_printf(m, " file=");
56162 - seq_path(m, &file->f_path, "\n\t= ");
56163 + seq_path(m, &file->f_path, "\n\t\\= ");
56164 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
56165 seq_printf(m, " heap");
56166 } else {
56167 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
56168 index 56123a6..5a2f6ec 100644
56169 --- a/fs/proc/task_nommu.c
56170 +++ b/fs/proc/task_nommu.c
56171 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
56172 else
56173 bytes += kobjsize(mm);
56174
56175 - if (current->fs && current->fs->users > 1)
56176 + if (current->fs && atomic_read(&current->fs->users) > 1)
56177 sbytes += kobjsize(current->fs);
56178 else
56179 bytes += kobjsize(current->fs);
56180 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
56181
56182 if (file) {
56183 pad_len_spaces(m, len);
56184 - seq_path(m, &file->f_path, "");
56185 + seq_path(m, &file->f_path, "\n\\");
56186 } else if (mm) {
56187 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
56188
56189 diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
56190 index 17f7e08..e4b1529 100644
56191 --- a/fs/proc/vmcore.c
56192 +++ b/fs/proc/vmcore.c
56193 @@ -99,9 +99,13 @@ static ssize_t read_from_oldmem(char *buf, size_t count,
56194 nr_bytes = count;
56195
56196 /* If pfn is not ram, return zeros for sparse dump files */
56197 - if (pfn_is_ram(pfn) == 0)
56198 - memset(buf, 0, nr_bytes);
56199 - else {
56200 + if (pfn_is_ram(pfn) == 0) {
56201 + if (userbuf) {
56202 + if (clear_user((char __force_user *)buf, nr_bytes))
56203 + return -EFAULT;
56204 + } else
56205 + memset(buf, 0, nr_bytes);
56206 + } else {
56207 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
56208 offset, userbuf);
56209 if (tmp < 0)
56210 @@ -186,7 +190,7 @@ static ssize_t read_vmcore(struct file *file, char __user *buffer,
56211 if (tsz > nr_bytes)
56212 tsz = nr_bytes;
56213
56214 - tmp = read_from_oldmem(buffer, tsz, &start, 1);
56215 + tmp = read_from_oldmem((char __force_kernel *)buffer, tsz, &start, 1);
56216 if (tmp < 0)
56217 return tmp;
56218 buflen -= tsz;
56219 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
56220 index b00fcc9..e0c6381 100644
56221 --- a/fs/qnx6/qnx6.h
56222 +++ b/fs/qnx6/qnx6.h
56223 @@ -74,7 +74,7 @@ enum {
56224 BYTESEX_BE,
56225 };
56226
56227 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
56228 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
56229 {
56230 if (sbi->s_bytesex == BYTESEX_LE)
56231 return le64_to_cpu((__force __le64)n);
56232 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
56233 return (__force __fs64)cpu_to_be64(n);
56234 }
56235
56236 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
56237 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
56238 {
56239 if (sbi->s_bytesex == BYTESEX_LE)
56240 return le32_to_cpu((__force __le32)n);
56241 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
56242 index 16e8abb..2dcf914 100644
56243 --- a/fs/quota/netlink.c
56244 +++ b/fs/quota/netlink.c
56245 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
56246 void quota_send_warning(struct kqid qid, dev_t dev,
56247 const char warntype)
56248 {
56249 - static atomic_t seq;
56250 + static atomic_unchecked_t seq;
56251 struct sk_buff *skb;
56252 void *msg_head;
56253 int ret;
56254 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
56255 "VFS: Not enough memory to send quota warning.\n");
56256 return;
56257 }
56258 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
56259 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
56260 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
56261 if (!msg_head) {
56262 printk(KERN_ERR
56263 diff --git a/fs/read_write.c b/fs/read_write.c
56264 index 2cefa41..c7e2fe0 100644
56265 --- a/fs/read_write.c
56266 +++ b/fs/read_write.c
56267 @@ -411,7 +411,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
56268
56269 old_fs = get_fs();
56270 set_fs(get_ds());
56271 - p = (__force const char __user *)buf;
56272 + p = (const char __force_user *)buf;
56273 if (count > MAX_RW_COUNT)
56274 count = MAX_RW_COUNT;
56275 if (file->f_op->write)
56276 diff --git a/fs/readdir.c b/fs/readdir.c
56277 index fee38e0..12fdf47 100644
56278 --- a/fs/readdir.c
56279 +++ b/fs/readdir.c
56280 @@ -17,6 +17,7 @@
56281 #include <linux/security.h>
56282 #include <linux/syscalls.h>
56283 #include <linux/unistd.h>
56284 +#include <linux/namei.h>
56285
56286 #include <asm/uaccess.h>
56287
56288 @@ -67,6 +68,7 @@ struct old_linux_dirent {
56289
56290 struct readdir_callback {
56291 struct old_linux_dirent __user * dirent;
56292 + struct file * file;
56293 int result;
56294 };
56295
56296 @@ -84,6 +86,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
56297 buf->result = -EOVERFLOW;
56298 return -EOVERFLOW;
56299 }
56300 +
56301 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56302 + return 0;
56303 +
56304 buf->result++;
56305 dirent = buf->dirent;
56306 if (!access_ok(VERIFY_WRITE, dirent,
56307 @@ -114,6 +120,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
56308
56309 buf.result = 0;
56310 buf.dirent = dirent;
56311 + buf.file = f.file;
56312
56313 error = vfs_readdir(f.file, fillonedir, &buf);
56314 if (buf.result)
56315 @@ -139,6 +146,7 @@ struct linux_dirent {
56316 struct getdents_callback {
56317 struct linux_dirent __user * current_dir;
56318 struct linux_dirent __user * previous;
56319 + struct file * file;
56320 int count;
56321 int error;
56322 };
56323 @@ -160,6 +168,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
56324 buf->error = -EOVERFLOW;
56325 return -EOVERFLOW;
56326 }
56327 +
56328 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56329 + return 0;
56330 +
56331 dirent = buf->previous;
56332 if (dirent) {
56333 if (__put_user(offset, &dirent->d_off))
56334 @@ -205,6 +217,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
56335 buf.previous = NULL;
56336 buf.count = count;
56337 buf.error = 0;
56338 + buf.file = f.file;
56339
56340 error = vfs_readdir(f.file, filldir, &buf);
56341 if (error >= 0)
56342 @@ -223,6 +236,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
56343 struct getdents_callback64 {
56344 struct linux_dirent64 __user * current_dir;
56345 struct linux_dirent64 __user * previous;
56346 + struct file *file;
56347 int count;
56348 int error;
56349 };
56350 @@ -238,6 +252,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
56351 buf->error = -EINVAL; /* only used if we fail.. */
56352 if (reclen > buf->count)
56353 return -EINVAL;
56354 +
56355 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
56356 + return 0;
56357 +
56358 dirent = buf->previous;
56359 if (dirent) {
56360 if (__put_user(offset, &dirent->d_off))
56361 @@ -283,6 +301,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
56362
56363 buf.current_dir = dirent;
56364 buf.previous = NULL;
56365 + buf.file = f.file;
56366 buf.count = count;
56367 buf.error = 0;
56368
56369 @@ -291,7 +310,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
56370 error = buf.error;
56371 lastdirent = buf.previous;
56372 if (lastdirent) {
56373 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
56374 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
56375 if (__put_user(d_off, &lastdirent->d_off))
56376 error = -EFAULT;
56377 else
56378 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
56379 index 2b7882b..1c5ef48 100644
56380 --- a/fs/reiserfs/do_balan.c
56381 +++ b/fs/reiserfs/do_balan.c
56382 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
56383 return;
56384 }
56385
56386 - atomic_inc(&(fs_generation(tb->tb_sb)));
56387 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
56388 do_balance_starts(tb);
56389
56390 /* balance leaf returns 0 except if combining L R and S into
56391 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
56392 index 33532f7..4846ade 100644
56393 --- a/fs/reiserfs/procfs.c
56394 +++ b/fs/reiserfs/procfs.c
56395 @@ -112,7 +112,7 @@ static int show_super(struct seq_file *m, struct super_block *sb)
56396 "SMALL_TAILS " : "NO_TAILS ",
56397 replay_only(sb) ? "REPLAY_ONLY " : "",
56398 convert_reiserfs(sb) ? "CONV " : "",
56399 - atomic_read(&r->s_generation_counter),
56400 + atomic_read_unchecked(&r->s_generation_counter),
56401 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
56402 SF(s_do_balance), SF(s_unneeded_left_neighbor),
56403 SF(s_good_search_by_key_reada), SF(s_bmaps),
56404 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
56405 index 157e474..65a6114 100644
56406 --- a/fs/reiserfs/reiserfs.h
56407 +++ b/fs/reiserfs/reiserfs.h
56408 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
56409 /* Comment? -Hans */
56410 wait_queue_head_t s_wait;
56411 /* To be obsoleted soon by per buffer seals.. -Hans */
56412 - atomic_t s_generation_counter; // increased by one every time the
56413 + atomic_unchecked_t s_generation_counter; // increased by one every time the
56414 // tree gets re-balanced
56415 unsigned long s_properties; /* File system properties. Currently holds
56416 on-disk FS format */
56417 @@ -1978,7 +1978,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
56418 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
56419
56420 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
56421 -#define get_generation(s) atomic_read (&fs_generation(s))
56422 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
56423 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
56424 #define __fs_changed(gen,s) (gen != get_generation (s))
56425 #define fs_changed(gen,s) \
56426 diff --git a/fs/select.c b/fs/select.c
56427 index 8c1c96c..a0f9b6d 100644
56428 --- a/fs/select.c
56429 +++ b/fs/select.c
56430 @@ -20,6 +20,7 @@
56431 #include <linux/export.h>
56432 #include <linux/slab.h>
56433 #include <linux/poll.h>
56434 +#include <linux/security.h>
56435 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
56436 #include <linux/file.h>
56437 #include <linux/fdtable.h>
56438 @@ -827,6 +828,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
56439 struct poll_list *walk = head;
56440 unsigned long todo = nfds;
56441
56442 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
56443 if (nfds > rlimit(RLIMIT_NOFILE))
56444 return -EINVAL;
56445
56446 diff --git a/fs/seq_file.c b/fs/seq_file.c
56447 index 774c1eb..b67582a 100644
56448 --- a/fs/seq_file.c
56449 +++ b/fs/seq_file.c
56450 @@ -10,6 +10,7 @@
56451 #include <linux/seq_file.h>
56452 #include <linux/slab.h>
56453 #include <linux/cred.h>
56454 +#include <linux/sched.h>
56455
56456 #include <asm/uaccess.h>
56457 #include <asm/page.h>
56458 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
56459 #ifdef CONFIG_USER_NS
56460 p->user_ns = file->f_cred->user_ns;
56461 #endif
56462 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56463 + p->exec_id = current->exec_id;
56464 +#endif
56465
56466 /*
56467 * Wrappers around seq_open(e.g. swaps_open) need to be
56468 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
56469 return 0;
56470 }
56471 if (!m->buf) {
56472 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
56473 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
56474 if (!m->buf)
56475 return -ENOMEM;
56476 }
56477 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
56478 Eoverflow:
56479 m->op->stop(m, p);
56480 kfree(m->buf);
56481 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
56482 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
56483 return !m->buf ? -ENOMEM : -EAGAIN;
56484 }
56485
56486 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
56487
56488 /* grab buffer if we didn't have one */
56489 if (!m->buf) {
56490 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
56491 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
56492 if (!m->buf)
56493 goto Enomem;
56494 }
56495 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
56496 goto Fill;
56497 m->op->stop(m, p);
56498 kfree(m->buf);
56499 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
56500 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
56501 if (!m->buf)
56502 goto Enomem;
56503 m->count = 0;
56504 @@ -581,7 +585,7 @@ static void single_stop(struct seq_file *p, void *v)
56505 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
56506 void *data)
56507 {
56508 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
56509 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
56510 int res = -ENOMEM;
56511
56512 if (op) {
56513 diff --git a/fs/splice.c b/fs/splice.c
56514 index d37431d..81c3044 100644
56515 --- a/fs/splice.c
56516 +++ b/fs/splice.c
56517 @@ -196,7 +196,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
56518 pipe_lock(pipe);
56519
56520 for (;;) {
56521 - if (!pipe->readers) {
56522 + if (!atomic_read(&pipe->readers)) {
56523 send_sig(SIGPIPE, current, 0);
56524 if (!ret)
56525 ret = -EPIPE;
56526 @@ -219,7 +219,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
56527 page_nr++;
56528 ret += buf->len;
56529
56530 - if (pipe->files)
56531 + if (atomic_read(&pipe->files))
56532 do_wakeup = 1;
56533
56534 if (!--spd->nr_pages)
56535 @@ -250,9 +250,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
56536 do_wakeup = 0;
56537 }
56538
56539 - pipe->waiting_writers++;
56540 + atomic_inc(&pipe->waiting_writers);
56541 pipe_wait(pipe);
56542 - pipe->waiting_writers--;
56543 + atomic_dec(&pipe->waiting_writers);
56544 }
56545
56546 pipe_unlock(pipe);
56547 @@ -565,7 +565,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
56548 old_fs = get_fs();
56549 set_fs(get_ds());
56550 /* The cast to a user pointer is valid due to the set_fs() */
56551 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
56552 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
56553 set_fs(old_fs);
56554
56555 return res;
56556 @@ -580,7 +580,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
56557 old_fs = get_fs();
56558 set_fs(get_ds());
56559 /* The cast to a user pointer is valid due to the set_fs() */
56560 - res = vfs_write(file, (__force const char __user *)buf, count, &pos);
56561 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
56562 set_fs(old_fs);
56563
56564 return res;
56565 @@ -633,7 +633,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
56566 goto err;
56567
56568 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
56569 - vec[i].iov_base = (void __user *) page_address(page);
56570 + vec[i].iov_base = (void __force_user *) page_address(page);
56571 vec[i].iov_len = this_len;
56572 spd.pages[i] = page;
56573 spd.nr_pages++;
56574 @@ -829,7 +829,7 @@ int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_desc *sd,
56575 ops->release(pipe, buf);
56576 pipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1);
56577 pipe->nrbufs--;
56578 - if (pipe->files)
56579 + if (atomic_read(&pipe->files))
56580 sd->need_wakeup = true;
56581 }
56582
56583 @@ -854,10 +854,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
56584 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
56585 {
56586 while (!pipe->nrbufs) {
56587 - if (!pipe->writers)
56588 + if (!atomic_read(&pipe->writers))
56589 return 0;
56590
56591 - if (!pipe->waiting_writers && sd->num_spliced)
56592 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
56593 return 0;
56594
56595 if (sd->flags & SPLICE_F_NONBLOCK)
56596 @@ -1193,7 +1193,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
56597 * out of the pipe right after the splice_to_pipe(). So set
56598 * PIPE_READERS appropriately.
56599 */
56600 - pipe->readers = 1;
56601 + atomic_set(&pipe->readers, 1);
56602
56603 current->splice_pipe = pipe;
56604 }
56605 @@ -1769,9 +1769,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56606 ret = -ERESTARTSYS;
56607 break;
56608 }
56609 - if (!pipe->writers)
56610 + if (!atomic_read(&pipe->writers))
56611 break;
56612 - if (!pipe->waiting_writers) {
56613 + if (!atomic_read(&pipe->waiting_writers)) {
56614 if (flags & SPLICE_F_NONBLOCK) {
56615 ret = -EAGAIN;
56616 break;
56617 @@ -1803,7 +1803,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56618 pipe_lock(pipe);
56619
56620 while (pipe->nrbufs >= pipe->buffers) {
56621 - if (!pipe->readers) {
56622 + if (!atomic_read(&pipe->readers)) {
56623 send_sig(SIGPIPE, current, 0);
56624 ret = -EPIPE;
56625 break;
56626 @@ -1816,9 +1816,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
56627 ret = -ERESTARTSYS;
56628 break;
56629 }
56630 - pipe->waiting_writers++;
56631 + atomic_inc(&pipe->waiting_writers);
56632 pipe_wait(pipe);
56633 - pipe->waiting_writers--;
56634 + atomic_dec(&pipe->waiting_writers);
56635 }
56636
56637 pipe_unlock(pipe);
56638 @@ -1854,14 +1854,14 @@ retry:
56639 pipe_double_lock(ipipe, opipe);
56640
56641 do {
56642 - if (!opipe->readers) {
56643 + if (!atomic_read(&opipe->readers)) {
56644 send_sig(SIGPIPE, current, 0);
56645 if (!ret)
56646 ret = -EPIPE;
56647 break;
56648 }
56649
56650 - if (!ipipe->nrbufs && !ipipe->writers)
56651 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
56652 break;
56653
56654 /*
56655 @@ -1958,7 +1958,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
56656 pipe_double_lock(ipipe, opipe);
56657
56658 do {
56659 - if (!opipe->readers) {
56660 + if (!atomic_read(&opipe->readers)) {
56661 send_sig(SIGPIPE, current, 0);
56662 if (!ret)
56663 ret = -EPIPE;
56664 @@ -2003,7 +2003,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
56665 * return EAGAIN if we have the potential of some data in the
56666 * future, otherwise just return 0
56667 */
56668 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
56669 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
56670 ret = -EAGAIN;
56671
56672 pipe_unlock(ipipe);
56673 diff --git a/fs/stat.c b/fs/stat.c
56674 index 04ce1ac..a13dd1e 100644
56675 --- a/fs/stat.c
56676 +++ b/fs/stat.c
56677 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
56678 stat->gid = inode->i_gid;
56679 stat->rdev = inode->i_rdev;
56680 stat->size = i_size_read(inode);
56681 - stat->atime = inode->i_atime;
56682 - stat->mtime = inode->i_mtime;
56683 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
56684 + stat->atime = inode->i_ctime;
56685 + stat->mtime = inode->i_ctime;
56686 + } else {
56687 + stat->atime = inode->i_atime;
56688 + stat->mtime = inode->i_mtime;
56689 + }
56690 stat->ctime = inode->i_ctime;
56691 stat->blksize = (1 << inode->i_blkbits);
56692 stat->blocks = inode->i_blocks;
56693 @@ -46,8 +51,14 @@ int vfs_getattr(struct path *path, struct kstat *stat)
56694 if (retval)
56695 return retval;
56696
56697 - if (inode->i_op->getattr)
56698 - return inode->i_op->getattr(path->mnt, path->dentry, stat);
56699 + if (inode->i_op->getattr) {
56700 + retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
56701 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
56702 + stat->atime = stat->ctime;
56703 + stat->mtime = stat->ctime;
56704 + }
56705 + return retval;
56706 + }
56707
56708 generic_fillattr(inode, stat);
56709 return 0;
56710 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
56711 index 15c68f9..36a8b3e 100644
56712 --- a/fs/sysfs/bin.c
56713 +++ b/fs/sysfs/bin.c
56714 @@ -235,13 +235,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
56715 return ret;
56716 }
56717
56718 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
56719 - void *buf, int len, int write)
56720 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
56721 + void *buf, size_t len, int write)
56722 {
56723 struct file *file = vma->vm_file;
56724 struct bin_buffer *bb = file->private_data;
56725 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
56726 - int ret;
56727 + ssize_t ret;
56728
56729 if (!bb->vm_ops)
56730 return -EINVAL;
56731 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
56732 index e8e0e71..3ca455a 100644
56733 --- a/fs/sysfs/dir.c
56734 +++ b/fs/sysfs/dir.c
56735 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
56736 *
56737 * Returns 31 bit hash of ns + name (so it fits in an off_t )
56738 */
56739 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
56740 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
56741 {
56742 unsigned long hash = init_name_hash();
56743 unsigned int len = strlen(name);
56744 @@ -679,6 +679,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
56745 struct sysfs_dirent *sd;
56746 int rc;
56747
56748 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
56749 + const char *parent_name = parent_sd->s_name;
56750 +
56751 + mode = S_IFDIR | S_IRWXU;
56752 +
56753 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
56754 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
56755 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse"))) ||
56756 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
56757 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
56758 +#endif
56759 +
56760 /* allocate */
56761 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
56762 if (!sd)
56763 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
56764 index 602f56d..6853db8 100644
56765 --- a/fs/sysfs/file.c
56766 +++ b/fs/sysfs/file.c
56767 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
56768
56769 struct sysfs_open_dirent {
56770 atomic_t refcnt;
56771 - atomic_t event;
56772 + atomic_unchecked_t event;
56773 wait_queue_head_t poll;
56774 struct list_head buffers; /* goes through sysfs_buffer.list */
56775 };
56776 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
56777 if (!sysfs_get_active(attr_sd))
56778 return -ENODEV;
56779
56780 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
56781 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
56782 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
56783
56784 sysfs_put_active(attr_sd);
56785 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
56786 return -ENOMEM;
56787
56788 atomic_set(&new_od->refcnt, 0);
56789 - atomic_set(&new_od->event, 1);
56790 + atomic_set_unchecked(&new_od->event, 1);
56791 init_waitqueue_head(&new_od->poll);
56792 INIT_LIST_HEAD(&new_od->buffers);
56793 goto retry;
56794 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
56795
56796 sysfs_put_active(attr_sd);
56797
56798 - if (buffer->event != atomic_read(&od->event))
56799 + if (buffer->event != atomic_read_unchecked(&od->event))
56800 goto trigger;
56801
56802 return DEFAULT_POLLMASK;
56803 @@ -451,7 +451,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
56804
56805 od = sd->s_attr.open;
56806 if (od) {
56807 - atomic_inc(&od->event);
56808 + atomic_inc_unchecked(&od->event);
56809 wake_up_interruptible(&od->poll);
56810 }
56811
56812 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
56813 index 8c940df..25b733e 100644
56814 --- a/fs/sysfs/symlink.c
56815 +++ b/fs/sysfs/symlink.c
56816 @@ -305,7 +305,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
56817
56818 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
56819 {
56820 - char *page = nd_get_link(nd);
56821 + const char *page = nd_get_link(nd);
56822 if (!IS_ERR(page))
56823 free_page((unsigned long)page);
56824 }
56825 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
56826 index 69d4889..a810bd4 100644
56827 --- a/fs/sysv/sysv.h
56828 +++ b/fs/sysv/sysv.h
56829 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
56830 #endif
56831 }
56832
56833 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
56834 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
56835 {
56836 if (sbi->s_bytesex == BYTESEX_PDP)
56837 return PDP_swab((__force __u32)n);
56838 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
56839 index e18b988..f1d4ad0f 100644
56840 --- a/fs/ubifs/io.c
56841 +++ b/fs/ubifs/io.c
56842 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
56843 return err;
56844 }
56845
56846 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
56847 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
56848 {
56849 int err;
56850
56851 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
56852 index c175b4d..8f36a16 100644
56853 --- a/fs/udf/misc.c
56854 +++ b/fs/udf/misc.c
56855 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
56856
56857 u8 udf_tag_checksum(const struct tag *t)
56858 {
56859 - u8 *data = (u8 *)t;
56860 + const u8 *data = (const u8 *)t;
56861 u8 checksum = 0;
56862 int i;
56863 for (i = 0; i < sizeof(struct tag); ++i)
56864 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
56865 index 8d974c4..b82f6ec 100644
56866 --- a/fs/ufs/swab.h
56867 +++ b/fs/ufs/swab.h
56868 @@ -22,7 +22,7 @@ enum {
56869 BYTESEX_BE
56870 };
56871
56872 -static inline u64
56873 +static inline u64 __intentional_overflow(-1)
56874 fs64_to_cpu(struct super_block *sbp, __fs64 n)
56875 {
56876 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
56877 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
56878 return (__force __fs64)cpu_to_be64(n);
56879 }
56880
56881 -static inline u32
56882 +static inline u32 __intentional_overflow(-1)
56883 fs32_to_cpu(struct super_block *sbp, __fs32 n)
56884 {
56885 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
56886 diff --git a/fs/utimes.c b/fs/utimes.c
56887 index f4fb7ec..3fe03c0 100644
56888 --- a/fs/utimes.c
56889 +++ b/fs/utimes.c
56890 @@ -1,6 +1,7 @@
56891 #include <linux/compiler.h>
56892 #include <linux/file.h>
56893 #include <linux/fs.h>
56894 +#include <linux/security.h>
56895 #include <linux/linkage.h>
56896 #include <linux/mount.h>
56897 #include <linux/namei.h>
56898 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
56899 goto mnt_drop_write_and_out;
56900 }
56901 }
56902 +
56903 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
56904 + error = -EACCES;
56905 + goto mnt_drop_write_and_out;
56906 + }
56907 +
56908 mutex_lock(&inode->i_mutex);
56909 error = notify_change(path->dentry, &newattrs);
56910 mutex_unlock(&inode->i_mutex);
56911 diff --git a/fs/xattr.c b/fs/xattr.c
56912 index 3377dff..4d074d9 100644
56913 --- a/fs/xattr.c
56914 +++ b/fs/xattr.c
56915 @@ -227,6 +227,27 @@ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
56916 return rc;
56917 }
56918
56919 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
56920 +ssize_t
56921 +pax_getxattr(struct dentry *dentry, void *value, size_t size)
56922 +{
56923 + struct inode *inode = dentry->d_inode;
56924 + ssize_t error;
56925 +
56926 + error = inode_permission(inode, MAY_EXEC);
56927 + if (error)
56928 + return error;
56929 +
56930 + if (inode->i_op->getxattr)
56931 + error = inode->i_op->getxattr(dentry, XATTR_NAME_PAX_FLAGS, value, size);
56932 + else
56933 + error = -EOPNOTSUPP;
56934 +
56935 + return error;
56936 +}
56937 +EXPORT_SYMBOL(pax_getxattr);
56938 +#endif
56939 +
56940 ssize_t
56941 vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
56942 {
56943 @@ -319,7 +340,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
56944 * Extended attribute SET operations
56945 */
56946 static long
56947 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
56948 +setxattr(struct path *path, const char __user *name, const void __user *value,
56949 size_t size, int flags)
56950 {
56951 int error;
56952 @@ -355,7 +376,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
56953 posix_acl_fix_xattr_from_user(kvalue, size);
56954 }
56955
56956 - error = vfs_setxattr(d, kname, kvalue, size, flags);
56957 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
56958 + error = -EACCES;
56959 + goto out;
56960 + }
56961 +
56962 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
56963 out:
56964 if (vvalue)
56965 vfree(vvalue);
56966 @@ -377,7 +403,7 @@ retry:
56967 return error;
56968 error = mnt_want_write(path.mnt);
56969 if (!error) {
56970 - error = setxattr(path.dentry, name, value, size, flags);
56971 + error = setxattr(&path, name, value, size, flags);
56972 mnt_drop_write(path.mnt);
56973 }
56974 path_put(&path);
56975 @@ -401,7 +427,7 @@ retry:
56976 return error;
56977 error = mnt_want_write(path.mnt);
56978 if (!error) {
56979 - error = setxattr(path.dentry, name, value, size, flags);
56980 + error = setxattr(&path, name, value, size, flags);
56981 mnt_drop_write(path.mnt);
56982 }
56983 path_put(&path);
56984 @@ -416,16 +442,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
56985 const void __user *,value, size_t, size, int, flags)
56986 {
56987 struct fd f = fdget(fd);
56988 - struct dentry *dentry;
56989 int error = -EBADF;
56990
56991 if (!f.file)
56992 return error;
56993 - dentry = f.file->f_path.dentry;
56994 - audit_inode(NULL, dentry, 0);
56995 + audit_inode(NULL, f.file->f_path.dentry, 0);
56996 error = mnt_want_write_file(f.file);
56997 if (!error) {
56998 - error = setxattr(dentry, name, value, size, flags);
56999 + error = setxattr(&f.file->f_path, name, value, size, flags);
57000 mnt_drop_write_file(f.file);
57001 }
57002 fdput(f);
57003 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
57004 index 9fbea87..6b19972 100644
57005 --- a/fs/xattr_acl.c
57006 +++ b/fs/xattr_acl.c
57007 @@ -76,8 +76,8 @@ struct posix_acl *
57008 posix_acl_from_xattr(struct user_namespace *user_ns,
57009 const void *value, size_t size)
57010 {
57011 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
57012 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
57013 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
57014 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
57015 int count;
57016 struct posix_acl *acl;
57017 struct posix_acl_entry *acl_e;
57018 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
57019 index 8904284..ee0e14b 100644
57020 --- a/fs/xfs/xfs_bmap.c
57021 +++ b/fs/xfs/xfs_bmap.c
57022 @@ -765,7 +765,7 @@ xfs_bmap_validate_ret(
57023
57024 #else
57025 #define xfs_bmap_check_leaf_extents(cur, ip, whichfork) do { } while (0)
57026 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
57027 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do { } while (0)
57028 #endif /* DEBUG */
57029
57030 /*
57031 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
57032 index 6157424..ac98f6d 100644
57033 --- a/fs/xfs/xfs_dir2_sf.c
57034 +++ b/fs/xfs/xfs_dir2_sf.c
57035 @@ -851,7 +851,15 @@ xfs_dir2_sf_getdents(
57036 }
57037
57038 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
57039 - if (filldir(dirent, (char *)sfep->name, sfep->namelen,
57040 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
57041 + char name[sfep->namelen];
57042 + memcpy(name, sfep->name, sfep->namelen);
57043 + if (filldir(dirent, name, sfep->namelen,
57044 + off & 0x7fffffff, ino, DT_UNKNOWN)) {
57045 + *offset = off & 0x7fffffff;
57046 + return 0;
57047 + }
57048 + } else if (filldir(dirent, (char *)sfep->name, sfep->namelen,
57049 off & 0x7fffffff, ino, DT_UNKNOWN)) {
57050 *offset = off & 0x7fffffff;
57051 return 0;
57052 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
57053 index 5e99968..45bd327 100644
57054 --- a/fs/xfs/xfs_ioctl.c
57055 +++ b/fs/xfs/xfs_ioctl.c
57056 @@ -127,7 +127,7 @@ xfs_find_handle(
57057 }
57058
57059 error = -EFAULT;
57060 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
57061 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
57062 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
57063 goto out_put;
57064
57065 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
57066 index ca9ecaa..60100c7 100644
57067 --- a/fs/xfs/xfs_iops.c
57068 +++ b/fs/xfs/xfs_iops.c
57069 @@ -395,7 +395,7 @@ xfs_vn_put_link(
57070 struct nameidata *nd,
57071 void *p)
57072 {
57073 - char *s = nd_get_link(nd);
57074 + const char *s = nd_get_link(nd);
57075
57076 if (!IS_ERR(s))
57077 kfree(s);
57078 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
57079 new file mode 100644
57080 index 0000000..c9c4ac3
57081 --- /dev/null
57082 +++ b/grsecurity/Kconfig
57083 @@ -0,0 +1,1054 @@
57084 +#
57085 +# grecurity configuration
57086 +#
57087 +menu "Memory Protections"
57088 +depends on GRKERNSEC
57089 +
57090 +config GRKERNSEC_KMEM
57091 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
57092 + default y if GRKERNSEC_CONFIG_AUTO
57093 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
57094 + help
57095 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
57096 + be written to or read from to modify or leak the contents of the running
57097 + kernel. /dev/port will also not be allowed to be opened and support
57098 + for /dev/cpu/*/msr will be removed. If you have module
57099 + support disabled, enabling this will close up five ways that are
57100 + currently used to insert malicious code into the running kernel.
57101 +
57102 + Even with all these features enabled, we still highly recommend that
57103 + you use the RBAC system, as it is still possible for an attacker to
57104 + modify the running kernel through privileged I/O granted by ioperm/iopl.
57105 +
57106 + If you are not using XFree86, you may be able to stop this additional
57107 + case by enabling the 'Disable privileged I/O' option. Though nothing
57108 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
57109 + but only to video memory, which is the only writing we allow in this
57110 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
57111 + not be allowed to mprotect it with PROT_WRITE later.
57112 + Enabling this feature will prevent the "cpupower" and "powertop" tools
57113 + from working.
57114 +
57115 + It is highly recommended that you say Y here if you meet all the
57116 + conditions above.
57117 +
57118 +config GRKERNSEC_VM86
57119 + bool "Restrict VM86 mode"
57120 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57121 + depends on X86_32
57122 +
57123 + help
57124 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
57125 + make use of a special execution mode on 32bit x86 processors called
57126 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
57127 + video cards and will still work with this option enabled. The purpose
57128 + of the option is to prevent exploitation of emulation errors in
57129 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
57130 + Nearly all users should be able to enable this option.
57131 +
57132 +config GRKERNSEC_IO
57133 + bool "Disable privileged I/O"
57134 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57135 + depends on X86
57136 + select RTC_CLASS
57137 + select RTC_INTF_DEV
57138 + select RTC_DRV_CMOS
57139 +
57140 + help
57141 + If you say Y here, all ioperm and iopl calls will return an error.
57142 + Ioperm and iopl can be used to modify the running kernel.
57143 + Unfortunately, some programs need this access to operate properly,
57144 + the most notable of which are XFree86 and hwclock. hwclock can be
57145 + remedied by having RTC support in the kernel, so real-time
57146 + clock support is enabled if this option is enabled, to ensure
57147 + that hwclock operates correctly. XFree86 still will not
57148 + operate correctly with this option enabled, so DO NOT CHOOSE Y
57149 + IF YOU USE XFree86. If you use XFree86 and you still want to
57150 + protect your kernel against modification, use the RBAC system.
57151 +
57152 +config GRKERNSEC_JIT_HARDEN
57153 + bool "Harden BPF JIT against spray attacks"
57154 + default y if GRKERNSEC_CONFIG_AUTO
57155 + depends on BPF_JIT
57156 + help
57157 + If you say Y here, the native code generated by the kernel's Berkeley
57158 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
57159 + attacks that attempt to fit attacker-beneficial instructions in
57160 + 32bit immediate fields of JIT-generated native instructions. The
57161 + attacker will generally aim to cause an unintended instruction sequence
57162 + of JIT-generated native code to execute by jumping into the middle of
57163 + a generated instruction. This feature effectively randomizes the 32bit
57164 + immediate constants present in the generated code to thwart such attacks.
57165 +
57166 + If you're using KERNEXEC, it's recommended that you enable this option
57167 + to supplement the hardening of the kernel.
57168 +
57169 +config GRKERNSEC_PERF_HARDEN
57170 + bool "Disable unprivileged PERF_EVENTS usage by default"
57171 + default y if GRKERNSEC_CONFIG_AUTO
57172 + depends on PERF_EVENTS
57173 + help
57174 + If you say Y here, the range of acceptable values for the
57175 + /proc/sys/kernel/perf_event_paranoid sysctl will be expanded to allow and
57176 + default to a new value: 3. When the sysctl is set to this value, no
57177 + unprivileged use of the PERF_EVENTS syscall interface will be permitted.
57178 +
57179 + Though PERF_EVENTS can be used legitimately for performance monitoring
57180 + and low-level application profiling, it is forced on regardless of
57181 + configuration, has been at fault for several vulnerabilities, and
57182 + creates new opportunities for side channels and other information leaks.
57183 +
57184 + This feature puts PERF_EVENTS into a secure default state and permits
57185 + the administrator to change out of it temporarily if unprivileged
57186 + application profiling is needed.
57187 +
57188 +config GRKERNSEC_RAND_THREADSTACK
57189 + bool "Insert random gaps between thread stacks"
57190 + default y if GRKERNSEC_CONFIG_AUTO
57191 + depends on PAX_RANDMMAP && !PPC
57192 + help
57193 + If you say Y here, a random-sized gap will be enforced between allocated
57194 + thread stacks. Glibc's NPTL and other threading libraries that
57195 + pass MAP_STACK to the kernel for thread stack allocation are supported.
57196 + The implementation currently provides 8 bits of entropy for the gap.
57197 +
57198 + Many distributions do not compile threaded remote services with the
57199 + -fstack-check argument to GCC, causing the variable-sized stack-based
57200 + allocator, alloca(), to not probe the stack on allocation. This
57201 + permits an unbounded alloca() to skip over any guard page and potentially
57202 + modify another thread's stack reliably. An enforced random gap
57203 + reduces the reliability of such an attack and increases the chance
57204 + that such a read/write to another thread's stack instead lands in
57205 + an unmapped area, causing a crash and triggering grsecurity's
57206 + anti-bruteforcing logic.
57207 +
57208 +config GRKERNSEC_PROC_MEMMAP
57209 + bool "Harden ASLR against information leaks and entropy reduction"
57210 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
57211 + depends on PAX_NOEXEC || PAX_ASLR
57212 + help
57213 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
57214 + give no information about the addresses of its mappings if
57215 + PaX features that rely on random addresses are enabled on the task.
57216 + In addition to sanitizing this information and disabling other
57217 + dangerous sources of information, this option causes reads of sensitive
57218 + /proc/<pid> entries where the file descriptor was opened in a different
57219 + task than the one performing the read. Such attempts are logged.
57220 + This option also limits argv/env strings for suid/sgid binaries
57221 + to 512KB to prevent a complete exhaustion of the stack entropy provided
57222 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
57223 + binaries to prevent alternative mmap layouts from being abused.
57224 +
57225 + If you use PaX it is essential that you say Y here as it closes up
57226 + several holes that make full ASLR useless locally.
57227 +
57228 +config GRKERNSEC_BRUTE
57229 + bool "Deter exploit bruteforcing"
57230 + default y if GRKERNSEC_CONFIG_AUTO
57231 + help
57232 + If you say Y here, attempts to bruteforce exploits against forking
57233 + daemons such as apache or sshd, as well as against suid/sgid binaries
57234 + will be deterred. When a child of a forking daemon is killed by PaX
57235 + or crashes due to an illegal instruction or other suspicious signal,
57236 + the parent process will be delayed 30 seconds upon every subsequent
57237 + fork until the administrator is able to assess the situation and
57238 + restart the daemon.
57239 + In the suid/sgid case, the attempt is logged, the user has all their
57240 + existing instances of the suid/sgid binary terminated and will
57241 + be unable to execute any suid/sgid binaries for 15 minutes.
57242 +
57243 + It is recommended that you also enable signal logging in the auditing
57244 + section so that logs are generated when a process triggers a suspicious
57245 + signal.
57246 + If the sysctl option is enabled, a sysctl option with name
57247 + "deter_bruteforce" is created.
57248 +
57249 +
57250 +config GRKERNSEC_MODHARDEN
57251 + bool "Harden module auto-loading"
57252 + default y if GRKERNSEC_CONFIG_AUTO
57253 + depends on MODULES
57254 + help
57255 + If you say Y here, module auto-loading in response to use of some
57256 + feature implemented by an unloaded module will be restricted to
57257 + root users. Enabling this option helps defend against attacks
57258 + by unprivileged users who abuse the auto-loading behavior to
57259 + cause a vulnerable module to load that is then exploited.
57260 +
57261 + If this option prevents a legitimate use of auto-loading for a
57262 + non-root user, the administrator can execute modprobe manually
57263 + with the exact name of the module mentioned in the alert log.
57264 + Alternatively, the administrator can add the module to the list
57265 + of modules loaded at boot by modifying init scripts.
57266 +
57267 + Modification of init scripts will most likely be needed on
57268 + Ubuntu servers with encrypted home directory support enabled,
57269 + as the first non-root user logging in will cause the ecb(aes),
57270 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
57271 +
57272 +config GRKERNSEC_HIDESYM
57273 + bool "Hide kernel symbols"
57274 + default y if GRKERNSEC_CONFIG_AUTO
57275 + select PAX_USERCOPY_SLABS
57276 + help
57277 + If you say Y here, getting information on loaded modules, and
57278 + displaying all kernel symbols through a syscall will be restricted
57279 + to users with CAP_SYS_MODULE. For software compatibility reasons,
57280 + /proc/kallsyms will be restricted to the root user. The RBAC
57281 + system can hide that entry even from root.
57282 +
57283 + This option also prevents leaking of kernel addresses through
57284 + several /proc entries.
57285 +
57286 + Note that this option is only effective provided the following
57287 + conditions are met:
57288 + 1) The kernel using grsecurity is not precompiled by some distribution
57289 + 2) You have also enabled GRKERNSEC_DMESG
57290 + 3) You are using the RBAC system and hiding other files such as your
57291 + kernel image and System.map. Alternatively, enabling this option
57292 + causes the permissions on /boot, /lib/modules, and the kernel
57293 + source directory to change at compile time to prevent
57294 + reading by non-root users.
57295 + If the above conditions are met, this option will aid in providing a
57296 + useful protection against local kernel exploitation of overflows
57297 + and arbitrary read/write vulnerabilities.
57298 +
57299 + It is highly recommended that you enable GRKERNSEC_PERF_HARDEN
57300 + in addition to this feature.
57301 +
57302 +config GRKERNSEC_KERN_LOCKOUT
57303 + bool "Active kernel exploit response"
57304 + default y if GRKERNSEC_CONFIG_AUTO
57305 + depends on X86 || ARM || PPC || SPARC
57306 + help
57307 + If you say Y here, when a PaX alert is triggered due to suspicious
57308 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
57309 + or an OOPS occurs due to bad memory accesses, instead of just
57310 + terminating the offending process (and potentially allowing
57311 + a subsequent exploit from the same user), we will take one of two
57312 + actions:
57313 + If the user was root, we will panic the system
57314 + If the user was non-root, we will log the attempt, terminate
57315 + all processes owned by the user, then prevent them from creating
57316 + any new processes until the system is restarted
57317 + This deters repeated kernel exploitation/bruteforcing attempts
57318 + and is useful for later forensics.
57319 +
57320 +endmenu
57321 +menu "Role Based Access Control Options"
57322 +depends on GRKERNSEC
57323 +
57324 +config GRKERNSEC_RBAC_DEBUG
57325 + bool
57326 +
57327 +config GRKERNSEC_NO_RBAC
57328 + bool "Disable RBAC system"
57329 + help
57330 + If you say Y here, the /dev/grsec device will be removed from the kernel,
57331 + preventing the RBAC system from being enabled. You should only say Y
57332 + here if you have no intention of using the RBAC system, so as to prevent
57333 + an attacker with root access from misusing the RBAC system to hide files
57334 + and processes when loadable module support and /dev/[k]mem have been
57335 + locked down.
57336 +
57337 +config GRKERNSEC_ACL_HIDEKERN
57338 + bool "Hide kernel processes"
57339 + help
57340 + If you say Y here, all kernel threads will be hidden to all
57341 + processes but those whose subject has the "view hidden processes"
57342 + flag.
57343 +
57344 +config GRKERNSEC_ACL_MAXTRIES
57345 + int "Maximum tries before password lockout"
57346 + default 3
57347 + help
57348 + This option enforces the maximum number of times a user can attempt
57349 + to authorize themselves with the grsecurity RBAC system before being
57350 + denied the ability to attempt authorization again for a specified time.
57351 + The lower the number, the harder it will be to brute-force a password.
57352 +
57353 +config GRKERNSEC_ACL_TIMEOUT
57354 + int "Time to wait after max password tries, in seconds"
57355 + default 30
57356 + help
57357 + This option specifies the time the user must wait after attempting to
57358 + authorize to the RBAC system with the maximum number of invalid
57359 + passwords. The higher the number, the harder it will be to brute-force
57360 + a password.
57361 +
57362 +endmenu
57363 +menu "Filesystem Protections"
57364 +depends on GRKERNSEC
57365 +
57366 +config GRKERNSEC_PROC
57367 + bool "Proc restrictions"
57368 + default y if GRKERNSEC_CONFIG_AUTO
57369 + help
57370 + If you say Y here, the permissions of the /proc filesystem
57371 + will be altered to enhance system security and privacy. You MUST
57372 + choose either a user only restriction or a user and group restriction.
57373 + Depending upon the option you choose, you can either restrict users to
57374 + see only the processes they themselves run, or choose a group that can
57375 + view all processes and files normally restricted to root if you choose
57376 + the "restrict to user only" option. NOTE: If you're running identd or
57377 + ntpd as a non-root user, you will have to run it as the group you
57378 + specify here.
57379 +
57380 +config GRKERNSEC_PROC_USER
57381 + bool "Restrict /proc to user only"
57382 + depends on GRKERNSEC_PROC
57383 + help
57384 + If you say Y here, non-root users will only be able to view their own
57385 + processes, and restricts them from viewing network-related information,
57386 + and viewing kernel symbol and module information.
57387 +
57388 +config GRKERNSEC_PROC_USERGROUP
57389 + bool "Allow special group"
57390 + default y if GRKERNSEC_CONFIG_AUTO
57391 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
57392 + help
57393 + If you say Y here, you will be able to select a group that will be
57394 + able to view all processes and network-related information. If you've
57395 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
57396 + remain hidden. This option is useful if you want to run identd as
57397 + a non-root user. The group you select may also be chosen at boot time
57398 + via "grsec_proc_gid=" on the kernel commandline.
57399 +
57400 +config GRKERNSEC_PROC_GID
57401 + int "GID for special group"
57402 + depends on GRKERNSEC_PROC_USERGROUP
57403 + default 1001
57404 +
57405 +config GRKERNSEC_PROC_ADD
57406 + bool "Additional restrictions"
57407 + default y if GRKERNSEC_CONFIG_AUTO
57408 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
57409 + help
57410 + If you say Y here, additional restrictions will be placed on
57411 + /proc that keep normal users from viewing device information and
57412 + slabinfo information that could be useful for exploits.
57413 +
57414 +config GRKERNSEC_LINK
57415 + bool "Linking restrictions"
57416 + default y if GRKERNSEC_CONFIG_AUTO
57417 + help
57418 + If you say Y here, /tmp race exploits will be prevented, since users
57419 + will no longer be able to follow symlinks owned by other users in
57420 + world-writable +t directories (e.g. /tmp), unless the owner of the
57421 + symlink is the owner of the directory. users will also not be
57422 + able to hardlink to files they do not own. If the sysctl option is
57423 + enabled, a sysctl option with name "linking_restrictions" is created.
57424 +
57425 +config GRKERNSEC_SYMLINKOWN
57426 + bool "Kernel-enforced SymlinksIfOwnerMatch"
57427 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
57428 + help
57429 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
57430 + that prevents it from being used as a security feature. As Apache
57431 + verifies the symlink by performing a stat() against the target of
57432 + the symlink before it is followed, an attacker can setup a symlink
57433 + to point to a same-owned file, then replace the symlink with one
57434 + that targets another user's file just after Apache "validates" the
57435 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
57436 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
57437 + will be in place for the group you specify. If the sysctl option
57438 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
57439 + created.
57440 +
57441 +config GRKERNSEC_SYMLINKOWN_GID
57442 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
57443 + depends on GRKERNSEC_SYMLINKOWN
57444 + default 1006
57445 + help
57446 + Setting this GID determines what group kernel-enforced
57447 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
57448 + is enabled, a sysctl option with name "symlinkown_gid" is created.
57449 +
57450 +config GRKERNSEC_FIFO
57451 + bool "FIFO restrictions"
57452 + default y if GRKERNSEC_CONFIG_AUTO
57453 + help
57454 + If you say Y here, users will not be able to write to FIFOs they don't
57455 + own in world-writable +t directories (e.g. /tmp), unless the owner of
57456 + the FIFO is the same owner of the directory it's held in. If the sysctl
57457 + option is enabled, a sysctl option with name "fifo_restrictions" is
57458 + created.
57459 +
57460 +config GRKERNSEC_SYSFS_RESTRICT
57461 + bool "Sysfs/debugfs restriction"
57462 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
57463 + depends on SYSFS
57464 + help
57465 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
57466 + any filesystem normally mounted under it (e.g. debugfs) will be
57467 + mostly accessible only by root. These filesystems generally provide access
57468 + to hardware and debug information that isn't appropriate for unprivileged
57469 + users of the system. Sysfs and debugfs have also become a large source
57470 + of new vulnerabilities, ranging from infoleaks to local compromise.
57471 + There has been very little oversight with an eye toward security involved
57472 + in adding new exporters of information to these filesystems, so their
57473 + use is discouraged.
57474 + For reasons of compatibility, a few directories have been whitelisted
57475 + for access by non-root users:
57476 + /sys/fs/selinux
57477 + /sys/fs/fuse
57478 + /sys/devices/system/cpu
57479 +
57480 +config GRKERNSEC_ROFS
57481 + bool "Runtime read-only mount protection"
57482 + help
57483 + If you say Y here, a sysctl option with name "romount_protect" will
57484 + be created. By setting this option to 1 at runtime, filesystems
57485 + will be protected in the following ways:
57486 + * No new writable mounts will be allowed
57487 + * Existing read-only mounts won't be able to be remounted read/write
57488 + * Write operations will be denied on all block devices
57489 + This option acts independently of grsec_lock: once it is set to 1,
57490 + it cannot be turned off. Therefore, please be mindful of the resulting
57491 + behavior if this option is enabled in an init script on a read-only
57492 + filesystem. This feature is mainly intended for secure embedded systems.
57493 +
57494 +config GRKERNSEC_DEVICE_SIDECHANNEL
57495 + bool "Eliminate stat/notify-based device sidechannels"
57496 + default y if GRKERNSEC_CONFIG_AUTO
57497 + help
57498 + If you say Y here, timing analyses on block or character
57499 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
57500 + will be thwarted for unprivileged users. If a process without
57501 + CAP_MKNOD stats such a device, the last access and last modify times
57502 + will match the device's create time. No access or modify events
57503 + will be triggered through inotify/dnotify/fanotify for such devices.
57504 + This feature will prevent attacks that may at a minimum
57505 + allow an attacker to determine the administrator's password length.
57506 +
57507 +config GRKERNSEC_CHROOT
57508 + bool "Chroot jail restrictions"
57509 + default y if GRKERNSEC_CONFIG_AUTO
57510 + help
57511 + If you say Y here, you will be able to choose several options that will
57512 + make breaking out of a chrooted jail much more difficult. If you
57513 + encounter no software incompatibilities with the following options, it
57514 + is recommended that you enable each one.
57515 +
57516 +config GRKERNSEC_CHROOT_MOUNT
57517 + bool "Deny mounts"
57518 + default y if GRKERNSEC_CONFIG_AUTO
57519 + depends on GRKERNSEC_CHROOT
57520 + help
57521 + If you say Y here, processes inside a chroot will not be able to
57522 + mount or remount filesystems. If the sysctl option is enabled, a
57523 + sysctl option with name "chroot_deny_mount" is created.
57524 +
57525 +config GRKERNSEC_CHROOT_DOUBLE
57526 + bool "Deny double-chroots"
57527 + default y if GRKERNSEC_CONFIG_AUTO
57528 + depends on GRKERNSEC_CHROOT
57529 + help
57530 + If you say Y here, processes inside a chroot will not be able to chroot
57531 + again outside the chroot. This is a widely used method of breaking
57532 + out of a chroot jail and should not be allowed. If the sysctl
57533 + option is enabled, a sysctl option with name
57534 + "chroot_deny_chroot" is created.
57535 +
57536 +config GRKERNSEC_CHROOT_PIVOT
57537 + bool "Deny pivot_root in chroot"
57538 + default y if GRKERNSEC_CONFIG_AUTO
57539 + depends on GRKERNSEC_CHROOT
57540 + help
57541 + If you say Y here, processes inside a chroot will not be able to use
57542 + a function called pivot_root() that was introduced in Linux 2.3.41. It
57543 + works similar to chroot in that it changes the root filesystem. This
57544 + function could be misused in a chrooted process to attempt to break out
57545 + of the chroot, and therefore should not be allowed. If the sysctl
57546 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
57547 + created.
57548 +
57549 +config GRKERNSEC_CHROOT_CHDIR
57550 + bool "Enforce chdir(\"/\") on all chroots"
57551 + default y if GRKERNSEC_CONFIG_AUTO
57552 + depends on GRKERNSEC_CHROOT
57553 + help
57554 + If you say Y here, the current working directory of all newly-chrooted
57555 + applications will be set to the the root directory of the chroot.
57556 + The man page on chroot(2) states:
57557 + Note that this call does not change the current working
57558 + directory, so that `.' can be outside the tree rooted at
57559 + `/'. In particular, the super-user can escape from a
57560 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
57561 +
57562 + It is recommended that you say Y here, since it's not known to break
57563 + any software. If the sysctl option is enabled, a sysctl option with
57564 + name "chroot_enforce_chdir" is created.
57565 +
57566 +config GRKERNSEC_CHROOT_CHMOD
57567 + bool "Deny (f)chmod +s"
57568 + default y if GRKERNSEC_CONFIG_AUTO
57569 + depends on GRKERNSEC_CHROOT
57570 + help
57571 + If you say Y here, processes inside a chroot will not be able to chmod
57572 + or fchmod files to make them have suid or sgid bits. This protects
57573 + against another published method of breaking a chroot. If the sysctl
57574 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
57575 + created.
57576 +
57577 +config GRKERNSEC_CHROOT_FCHDIR
57578 + bool "Deny fchdir out of chroot"
57579 + default y if GRKERNSEC_CONFIG_AUTO
57580 + depends on GRKERNSEC_CHROOT
57581 + help
57582 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
57583 + to a file descriptor of the chrooting process that points to a directory
57584 + outside the filesystem will be stopped. If the sysctl option
57585 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
57586 +
57587 +config GRKERNSEC_CHROOT_MKNOD
57588 + bool "Deny mknod"
57589 + default y if GRKERNSEC_CONFIG_AUTO
57590 + depends on GRKERNSEC_CHROOT
57591 + help
57592 + If you say Y here, processes inside a chroot will not be allowed to
57593 + mknod. The problem with using mknod inside a chroot is that it
57594 + would allow an attacker to create a device entry that is the same
57595 + as one on the physical root of your system, which could range from
57596 + anything from the console device to a device for your harddrive (which
57597 + they could then use to wipe the drive or steal data). It is recommended
57598 + that you say Y here, unless you run into software incompatibilities.
57599 + If the sysctl option is enabled, a sysctl option with name
57600 + "chroot_deny_mknod" is created.
57601 +
57602 +config GRKERNSEC_CHROOT_SHMAT
57603 + bool "Deny shmat() out of chroot"
57604 + default y if GRKERNSEC_CONFIG_AUTO
57605 + depends on GRKERNSEC_CHROOT
57606 + help
57607 + If you say Y here, processes inside a chroot will not be able to attach
57608 + to shared memory segments that were created outside of the chroot jail.
57609 + It is recommended that you say Y here. If the sysctl option is enabled,
57610 + a sysctl option with name "chroot_deny_shmat" is created.
57611 +
57612 +config GRKERNSEC_CHROOT_UNIX
57613 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
57614 + default y if GRKERNSEC_CONFIG_AUTO
57615 + depends on GRKERNSEC_CHROOT
57616 + help
57617 + If you say Y here, processes inside a chroot will not be able to
57618 + connect to abstract (meaning not belonging to a filesystem) Unix
57619 + domain sockets that were bound outside of a chroot. It is recommended
57620 + that you say Y here. If the sysctl option is enabled, a sysctl option
57621 + with name "chroot_deny_unix" is created.
57622 +
57623 +config GRKERNSEC_CHROOT_FINDTASK
57624 + bool "Protect outside processes"
57625 + default y if GRKERNSEC_CONFIG_AUTO
57626 + depends on GRKERNSEC_CHROOT
57627 + help
57628 + If you say Y here, processes inside a chroot will not be able to
57629 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
57630 + getsid, or view any process outside of the chroot. If the sysctl
57631 + option is enabled, a sysctl option with name "chroot_findtask" is
57632 + created.
57633 +
57634 +config GRKERNSEC_CHROOT_NICE
57635 + bool "Restrict priority changes"
57636 + default y if GRKERNSEC_CONFIG_AUTO
57637 + depends on GRKERNSEC_CHROOT
57638 + help
57639 + If you say Y here, processes inside a chroot will not be able to raise
57640 + the priority of processes in the chroot, or alter the priority of
57641 + processes outside the chroot. This provides more security than simply
57642 + removing CAP_SYS_NICE from the process' capability set. If the
57643 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
57644 + is created.
57645 +
57646 +config GRKERNSEC_CHROOT_SYSCTL
57647 + bool "Deny sysctl writes"
57648 + default y if GRKERNSEC_CONFIG_AUTO
57649 + depends on GRKERNSEC_CHROOT
57650 + help
57651 + If you say Y here, an attacker in a chroot will not be able to
57652 + write to sysctl entries, either by sysctl(2) or through a /proc
57653 + interface. It is strongly recommended that you say Y here. If the
57654 + sysctl option is enabled, a sysctl option with name
57655 + "chroot_deny_sysctl" is created.
57656 +
57657 +config GRKERNSEC_CHROOT_CAPS
57658 + bool "Capability restrictions"
57659 + default y if GRKERNSEC_CONFIG_AUTO
57660 + depends on GRKERNSEC_CHROOT
57661 + help
57662 + If you say Y here, the capabilities on all processes within a
57663 + chroot jail will be lowered to stop module insertion, raw i/o,
57664 + system and net admin tasks, rebooting the system, modifying immutable
57665 + files, modifying IPC owned by another, and changing the system time.
57666 + This is left an option because it can break some apps. Disable this
57667 + if your chrooted apps are having problems performing those kinds of
57668 + tasks. If the sysctl option is enabled, a sysctl option with
57669 + name "chroot_caps" is created.
57670 +
57671 +config GRKERNSEC_CHROOT_INITRD
57672 + bool "Exempt initrd tasks from restrictions"
57673 + default y if GRKERNSEC_CONFIG_AUTO
57674 + depends on GRKERNSEC_CHROOT && BLK_DEV_RAM
57675 + help
57676 + If you say Y here, tasks started prior to init will be exempted from
57677 + grsecurity's chroot restrictions. This option is mainly meant to
57678 + resolve Plymouth's performing privileged operations unnecessarily
57679 + in a chroot.
57680 +
57681 +endmenu
57682 +menu "Kernel Auditing"
57683 +depends on GRKERNSEC
57684 +
57685 +config GRKERNSEC_AUDIT_GROUP
57686 + bool "Single group for auditing"
57687 + help
57688 + If you say Y here, the exec and chdir logging features will only operate
57689 + on a group you specify. This option is recommended if you only want to
57690 + watch certain users instead of having a large amount of logs from the
57691 + entire system. If the sysctl option is enabled, a sysctl option with
57692 + name "audit_group" is created.
57693 +
57694 +config GRKERNSEC_AUDIT_GID
57695 + int "GID for auditing"
57696 + depends on GRKERNSEC_AUDIT_GROUP
57697 + default 1007
57698 +
57699 +config GRKERNSEC_EXECLOG
57700 + bool "Exec logging"
57701 + help
57702 + If you say Y here, all execve() calls will be logged (since the
57703 + other exec*() calls are frontends to execve(), all execution
57704 + will be logged). Useful for shell-servers that like to keep track
57705 + of their users. If the sysctl option is enabled, a sysctl option with
57706 + name "exec_logging" is created.
57707 + WARNING: This option when enabled will produce a LOT of logs, especially
57708 + on an active system.
57709 +
57710 +config GRKERNSEC_RESLOG
57711 + bool "Resource logging"
57712 + default y if GRKERNSEC_CONFIG_AUTO
57713 + help
57714 + If you say Y here, all attempts to overstep resource limits will
57715 + be logged with the resource name, the requested size, and the current
57716 + limit. It is highly recommended that you say Y here. If the sysctl
57717 + option is enabled, a sysctl option with name "resource_logging" is
57718 + created. If the RBAC system is enabled, the sysctl value is ignored.
57719 +
57720 +config GRKERNSEC_CHROOT_EXECLOG
57721 + bool "Log execs within chroot"
57722 + help
57723 + If you say Y here, all executions inside a chroot jail will be logged
57724 + to syslog. This can cause a large amount of logs if certain
57725 + applications (eg. djb's daemontools) are installed on the system, and
57726 + is therefore left as an option. If the sysctl option is enabled, a
57727 + sysctl option with name "chroot_execlog" is created.
57728 +
57729 +config GRKERNSEC_AUDIT_PTRACE
57730 + bool "Ptrace logging"
57731 + help
57732 + If you say Y here, all attempts to attach to a process via ptrace
57733 + will be logged. If the sysctl option is enabled, a sysctl option
57734 + with name "audit_ptrace" is created.
57735 +
57736 +config GRKERNSEC_AUDIT_CHDIR
57737 + bool "Chdir logging"
57738 + help
57739 + If you say Y here, all chdir() calls will be logged. If the sysctl
57740 + option is enabled, a sysctl option with name "audit_chdir" is created.
57741 +
57742 +config GRKERNSEC_AUDIT_MOUNT
57743 + bool "(Un)Mount logging"
57744 + help
57745 + If you say Y here, all mounts and unmounts will be logged. If the
57746 + sysctl option is enabled, a sysctl option with name "audit_mount" is
57747 + created.
57748 +
57749 +config GRKERNSEC_SIGNAL
57750 + bool "Signal logging"
57751 + default y if GRKERNSEC_CONFIG_AUTO
57752 + help
57753 + If you say Y here, certain important signals will be logged, such as
57754 + SIGSEGV, which will as a result inform you of when a error in a program
57755 + occurred, which in some cases could mean a possible exploit attempt.
57756 + If the sysctl option is enabled, a sysctl option with name
57757 + "signal_logging" is created.
57758 +
57759 +config GRKERNSEC_FORKFAIL
57760 + bool "Fork failure logging"
57761 + help
57762 + If you say Y here, all failed fork() attempts will be logged.
57763 + This could suggest a fork bomb, or someone attempting to overstep
57764 + their process limit. If the sysctl option is enabled, a sysctl option
57765 + with name "forkfail_logging" is created.
57766 +
57767 +config GRKERNSEC_TIME
57768 + bool "Time change logging"
57769 + default y if GRKERNSEC_CONFIG_AUTO
57770 + help
57771 + If you say Y here, any changes of the system clock will be logged.
57772 + If the sysctl option is enabled, a sysctl option with name
57773 + "timechange_logging" is created.
57774 +
57775 +config GRKERNSEC_PROC_IPADDR
57776 + bool "/proc/<pid>/ipaddr support"
57777 + default y if GRKERNSEC_CONFIG_AUTO
57778 + help
57779 + If you say Y here, a new entry will be added to each /proc/<pid>
57780 + directory that contains the IP address of the person using the task.
57781 + The IP is carried across local TCP and AF_UNIX stream sockets.
57782 + This information can be useful for IDS/IPSes to perform remote response
57783 + to a local attack. The entry is readable by only the owner of the
57784 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
57785 + the RBAC system), and thus does not create privacy concerns.
57786 +
57787 +config GRKERNSEC_RWXMAP_LOG
57788 + bool 'Denied RWX mmap/mprotect logging'
57789 + default y if GRKERNSEC_CONFIG_AUTO
57790 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
57791 + help
57792 + If you say Y here, calls to mmap() and mprotect() with explicit
57793 + usage of PROT_WRITE and PROT_EXEC together will be logged when
57794 + denied by the PAX_MPROTECT feature. If the sysctl option is
57795 + enabled, a sysctl option with name "rwxmap_logging" is created.
57796 +
57797 +config GRKERNSEC_AUDIT_TEXTREL
57798 + bool 'ELF text relocations logging (READ HELP)'
57799 + depends on PAX_MPROTECT
57800 + help
57801 + If you say Y here, text relocations will be logged with the filename
57802 + of the offending library or binary. The purpose of the feature is
57803 + to help Linux distribution developers get rid of libraries and
57804 + binaries that need text relocations which hinder the future progress
57805 + of PaX. Only Linux distribution developers should say Y here, and
57806 + never on a production machine, as this option creates an information
57807 + leak that could aid an attacker in defeating the randomization of
57808 + a single memory region. If the sysctl option is enabled, a sysctl
57809 + option with name "audit_textrel" is created.
57810 +
57811 +endmenu
57812 +
57813 +menu "Executable Protections"
57814 +depends on GRKERNSEC
57815 +
57816 +config GRKERNSEC_DMESG
57817 + bool "Dmesg(8) restriction"
57818 + default y if GRKERNSEC_CONFIG_AUTO
57819 + help
57820 + If you say Y here, non-root users will not be able to use dmesg(8)
57821 + to view the contents of the kernel's circular log buffer.
57822 + The kernel's log buffer often contains kernel addresses and other
57823 + identifying information useful to an attacker in fingerprinting a
57824 + system for a targeted exploit.
57825 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
57826 + created.
57827 +
57828 +config GRKERNSEC_HARDEN_PTRACE
57829 + bool "Deter ptrace-based process snooping"
57830 + default y if GRKERNSEC_CONFIG_AUTO
57831 + help
57832 + If you say Y here, TTY sniffers and other malicious monitoring
57833 + programs implemented through ptrace will be defeated. If you
57834 + have been using the RBAC system, this option has already been
57835 + enabled for several years for all users, with the ability to make
57836 + fine-grained exceptions.
57837 +
57838 + This option only affects the ability of non-root users to ptrace
57839 + processes that are not a descendent of the ptracing process.
57840 + This means that strace ./binary and gdb ./binary will still work,
57841 + but attaching to arbitrary processes will not. If the sysctl
57842 + option is enabled, a sysctl option with name "harden_ptrace" is
57843 + created.
57844 +
57845 +config GRKERNSEC_PTRACE_READEXEC
57846 + bool "Require read access to ptrace sensitive binaries"
57847 + default y if GRKERNSEC_CONFIG_AUTO
57848 + help
57849 + If you say Y here, unprivileged users will not be able to ptrace unreadable
57850 + binaries. This option is useful in environments that
57851 + remove the read bits (e.g. file mode 4711) from suid binaries to
57852 + prevent infoleaking of their contents. This option adds
57853 + consistency to the use of that file mode, as the binary could normally
57854 + be read out when run without privileges while ptracing.
57855 +
57856 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
57857 + is created.
57858 +
57859 +config GRKERNSEC_SETXID
57860 + bool "Enforce consistent multithreaded privileges"
57861 + default y if GRKERNSEC_CONFIG_AUTO
57862 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
57863 + help
57864 + If you say Y here, a change from a root uid to a non-root uid
57865 + in a multithreaded application will cause the resulting uids,
57866 + gids, supplementary groups, and capabilities in that thread
57867 + to be propagated to the other threads of the process. In most
57868 + cases this is unnecessary, as glibc will emulate this behavior
57869 + on behalf of the application. Other libcs do not act in the
57870 + same way, allowing the other threads of the process to continue
57871 + running with root privileges. If the sysctl option is enabled,
57872 + a sysctl option with name "consistent_setxid" is created.
57873 +
57874 +config GRKERNSEC_TPE
57875 + bool "Trusted Path Execution (TPE)"
57876 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
57877 + help
57878 + If you say Y here, you will be able to choose a gid to add to the
57879 + supplementary groups of users you want to mark as "untrusted."
57880 + These users will not be able to execute any files that are not in
57881 + root-owned directories writable only by root. If the sysctl option
57882 + is enabled, a sysctl option with name "tpe" is created.
57883 +
57884 +config GRKERNSEC_TPE_ALL
57885 + bool "Partially restrict all non-root users"
57886 + depends on GRKERNSEC_TPE
57887 + help
57888 + If you say Y here, all non-root users will be covered under
57889 + a weaker TPE restriction. This is separate from, and in addition to,
57890 + the main TPE options that you have selected elsewhere. Thus, if a
57891 + "trusted" GID is chosen, this restriction applies to even that GID.
57892 + Under this restriction, all non-root users will only be allowed to
57893 + execute files in directories they own that are not group or
57894 + world-writable, or in directories owned by root and writable only by
57895 + root. If the sysctl option is enabled, a sysctl option with name
57896 + "tpe_restrict_all" is created.
57897 +
57898 +config GRKERNSEC_TPE_INVERT
57899 + bool "Invert GID option"
57900 + depends on GRKERNSEC_TPE
57901 + help
57902 + If you say Y here, the group you specify in the TPE configuration will
57903 + decide what group TPE restrictions will be *disabled* for. This
57904 + option is useful if you want TPE restrictions to be applied to most
57905 + users on the system. If the sysctl option is enabled, a sysctl option
57906 + with name "tpe_invert" is created. Unlike other sysctl options, this
57907 + entry will default to on for backward-compatibility.
57908 +
57909 +config GRKERNSEC_TPE_GID
57910 + int
57911 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
57912 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
57913 +
57914 +config GRKERNSEC_TPE_UNTRUSTED_GID
57915 + int "GID for TPE-untrusted users"
57916 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
57917 + default 1005
57918 + help
57919 + Setting this GID determines what group TPE restrictions will be
57920 + *enabled* for. If the sysctl option is enabled, a sysctl option
57921 + with name "tpe_gid" is created.
57922 +
57923 +config GRKERNSEC_TPE_TRUSTED_GID
57924 + int "GID for TPE-trusted users"
57925 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
57926 + default 1005
57927 + help
57928 + Setting this GID determines what group TPE restrictions will be
57929 + *disabled* for. If the sysctl option is enabled, a sysctl option
57930 + with name "tpe_gid" is created.
57931 +
57932 +endmenu
57933 +menu "Network Protections"
57934 +depends on GRKERNSEC
57935 +
57936 +config GRKERNSEC_RANDNET
57937 + bool "Larger entropy pools"
57938 + default y if GRKERNSEC_CONFIG_AUTO
57939 + help
57940 + If you say Y here, the entropy pools used for many features of Linux
57941 + and grsecurity will be doubled in size. Since several grsecurity
57942 + features use additional randomness, it is recommended that you say Y
57943 + here. Saying Y here has a similar effect as modifying
57944 + /proc/sys/kernel/random/poolsize.
57945 +
57946 +config GRKERNSEC_BLACKHOLE
57947 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
57948 + default y if GRKERNSEC_CONFIG_AUTO
57949 + depends on NET
57950 + help
57951 + If you say Y here, neither TCP resets nor ICMP
57952 + destination-unreachable packets will be sent in response to packets
57953 + sent to ports for which no associated listening process exists.
57954 + This feature supports both IPV4 and IPV6 and exempts the
57955 + loopback interface from blackholing. Enabling this feature
57956 + makes a host more resilient to DoS attacks and reduces network
57957 + visibility against scanners.
57958 +
57959 + The blackhole feature as-implemented is equivalent to the FreeBSD
57960 + blackhole feature, as it prevents RST responses to all packets, not
57961 + just SYNs. Under most application behavior this causes no
57962 + problems, but applications (like haproxy) may not close certain
57963 + connections in a way that cleanly terminates them on the remote
57964 + end, leaving the remote host in LAST_ACK state. Because of this
57965 + side-effect and to prevent intentional LAST_ACK DoSes, this
57966 + feature also adds automatic mitigation against such attacks.
57967 + The mitigation drastically reduces the amount of time a socket
57968 + can spend in LAST_ACK state. If you're using haproxy and not
57969 + all servers it connects to have this option enabled, consider
57970 + disabling this feature on the haproxy host.
57971 +
57972 + If the sysctl option is enabled, two sysctl options with names
57973 + "ip_blackhole" and "lastack_retries" will be created.
57974 + While "ip_blackhole" takes the standard zero/non-zero on/off
57975 + toggle, "lastack_retries" uses the same kinds of values as
57976 + "tcp_retries1" and "tcp_retries2". The default value of 4
57977 + prevents a socket from lasting more than 45 seconds in LAST_ACK
57978 + state.
57979 +
57980 +config GRKERNSEC_NO_SIMULT_CONNECT
57981 + bool "Disable TCP Simultaneous Connect"
57982 + default y if GRKERNSEC_CONFIG_AUTO
57983 + depends on NET
57984 + help
57985 + If you say Y here, a feature by Willy Tarreau will be enabled that
57986 + removes a weakness in Linux's strict implementation of TCP that
57987 + allows two clients to connect to each other without either entering
57988 + a listening state. The weakness allows an attacker to easily prevent
57989 + a client from connecting to a known server provided the source port
57990 + for the connection is guessed correctly.
57991 +
57992 + As the weakness could be used to prevent an antivirus or IPS from
57993 + fetching updates, or prevent an SSL gateway from fetching a CRL,
57994 + it should be eliminated by enabling this option. Though Linux is
57995 + one of few operating systems supporting simultaneous connect, it
57996 + has no legitimate use in practice and is rarely supported by firewalls.
57997 +
57998 +config GRKERNSEC_SOCKET
57999 + bool "Socket restrictions"
58000 + depends on NET
58001 + help
58002 + If you say Y here, you will be able to choose from several options.
58003 + If you assign a GID on your system and add it to the supplementary
58004 + groups of users you want to restrict socket access to, this patch
58005 + will perform up to three things, based on the option(s) you choose.
58006 +
58007 +config GRKERNSEC_SOCKET_ALL
58008 + bool "Deny any sockets to group"
58009 + depends on GRKERNSEC_SOCKET
58010 + help
58011 + If you say Y here, you will be able to choose a GID of whose users will
58012 + be unable to connect to other hosts from your machine or run server
58013 + applications from your machine. If the sysctl option is enabled, a
58014 + sysctl option with name "socket_all" is created.
58015 +
58016 +config GRKERNSEC_SOCKET_ALL_GID
58017 + int "GID to deny all sockets for"
58018 + depends on GRKERNSEC_SOCKET_ALL
58019 + default 1004
58020 + help
58021 + Here you can choose the GID to disable socket access for. Remember to
58022 + add the users you want socket access disabled for to the GID
58023 + specified here. If the sysctl option is enabled, a sysctl option
58024 + with name "socket_all_gid" is created.
58025 +
58026 +config GRKERNSEC_SOCKET_CLIENT
58027 + bool "Deny client sockets to group"
58028 + depends on GRKERNSEC_SOCKET
58029 + help
58030 + If you say Y here, you will be able to choose a GID of whose users will
58031 + be unable to connect to other hosts from your machine, but will be
58032 + able to run servers. If this option is enabled, all users in the group
58033 + you specify will have to use passive mode when initiating ftp transfers
58034 + from the shell on your machine. If the sysctl option is enabled, a
58035 + sysctl option with name "socket_client" is created.
58036 +
58037 +config GRKERNSEC_SOCKET_CLIENT_GID
58038 + int "GID to deny client sockets for"
58039 + depends on GRKERNSEC_SOCKET_CLIENT
58040 + default 1003
58041 + help
58042 + Here you can choose the GID to disable client socket access for.
58043 + Remember to add the users you want client socket access disabled for to
58044 + the GID specified here. If the sysctl option is enabled, a sysctl
58045 + option with name "socket_client_gid" is created.
58046 +
58047 +config GRKERNSEC_SOCKET_SERVER
58048 + bool "Deny server sockets to group"
58049 + depends on GRKERNSEC_SOCKET
58050 + help
58051 + If you say Y here, you will be able to choose a GID of whose users will
58052 + be unable to run server applications from your machine. If the sysctl
58053 + option is enabled, a sysctl option with name "socket_server" is created.
58054 +
58055 +config GRKERNSEC_SOCKET_SERVER_GID
58056 + int "GID to deny server sockets for"
58057 + depends on GRKERNSEC_SOCKET_SERVER
58058 + default 1002
58059 + help
58060 + Here you can choose the GID to disable server socket access for.
58061 + Remember to add the users you want server socket access disabled for to
58062 + the GID specified here. If the sysctl option is enabled, a sysctl
58063 + option with name "socket_server_gid" is created.
58064 +
58065 +endmenu
58066 +menu "Sysctl Support"
58067 +depends on GRKERNSEC && SYSCTL
58068 +
58069 +config GRKERNSEC_SYSCTL
58070 + bool "Sysctl support"
58071 + default y if GRKERNSEC_CONFIG_AUTO
58072 + help
58073 + If you say Y here, you will be able to change the options that
58074 + grsecurity runs with at bootup, without having to recompile your
58075 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
58076 + to enable (1) or disable (0) various features. All the sysctl entries
58077 + are mutable until the "grsec_lock" entry is set to a non-zero value.
58078 + All features enabled in the kernel configuration are disabled at boot
58079 + if you do not say Y to the "Turn on features by default" option.
58080 + All options should be set at startup, and the grsec_lock entry should
58081 + be set to a non-zero value after all the options are set.
58082 + *THIS IS EXTREMELY IMPORTANT*
58083 +
58084 +config GRKERNSEC_SYSCTL_DISTRO
58085 + bool "Extra sysctl support for distro makers (READ HELP)"
58086 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
58087 + help
58088 + If you say Y here, additional sysctl options will be created
58089 + for features that affect processes running as root. Therefore,
58090 + it is critical when using this option that the grsec_lock entry be
58091 + enabled after boot. Only distros with prebuilt kernel packages
58092 + with this option enabled that can ensure grsec_lock is enabled
58093 + after boot should use this option.
58094 + *Failure to set grsec_lock after boot makes all grsec features
58095 + this option covers useless*
58096 +
58097 + Currently this option creates the following sysctl entries:
58098 + "Disable Privileged I/O": "disable_priv_io"
58099 +
58100 +config GRKERNSEC_SYSCTL_ON
58101 + bool "Turn on features by default"
58102 + default y if GRKERNSEC_CONFIG_AUTO
58103 + depends on GRKERNSEC_SYSCTL
58104 + help
58105 + If you say Y here, instead of having all features enabled in the
58106 + kernel configuration disabled at boot time, the features will be
58107 + enabled at boot time. It is recommended you say Y here unless
58108 + there is some reason you would want all sysctl-tunable features to
58109 + be disabled by default. As mentioned elsewhere, it is important
58110 + to enable the grsec_lock entry once you have finished modifying
58111 + the sysctl entries.
58112 +
58113 +endmenu
58114 +menu "Logging Options"
58115 +depends on GRKERNSEC
58116 +
58117 +config GRKERNSEC_FLOODTIME
58118 + int "Seconds in between log messages (minimum)"
58119 + default 10
58120 + help
58121 + This option allows you to enforce the number of seconds between
58122 + grsecurity log messages. The default should be suitable for most
58123 + people, however, if you choose to change it, choose a value small enough
58124 + to allow informative logs to be produced, but large enough to
58125 + prevent flooding.
58126 +
58127 +config GRKERNSEC_FLOODBURST
58128 + int "Number of messages in a burst (maximum)"
58129 + default 6
58130 + help
58131 + This option allows you to choose the maximum number of messages allowed
58132 + within the flood time interval you chose in a separate option. The
58133 + default should be suitable for most people, however if you find that
58134 + many of your logs are being interpreted as flooding, you may want to
58135 + raise this value.
58136 +
58137 +endmenu
58138 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
58139 new file mode 100644
58140 index 0000000..1b9afa9
58141 --- /dev/null
58142 +++ b/grsecurity/Makefile
58143 @@ -0,0 +1,38 @@
58144 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
58145 +# during 2001-2009 it has been completely redesigned by Brad Spengler
58146 +# into an RBAC system
58147 +#
58148 +# All code in this directory and various hooks inserted throughout the kernel
58149 +# are copyright Brad Spengler - Open Source Security, Inc., and released
58150 +# under the GPL v2 or higher
58151 +
58152 +KBUILD_CFLAGS += -Werror
58153 +
58154 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
58155 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
58156 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o
58157 +
58158 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
58159 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
58160 + gracl_learn.o grsec_log.o
58161 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
58162 +
58163 +ifdef CONFIG_NET
58164 +obj-y += grsec_sock.o
58165 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
58166 +endif
58167 +
58168 +ifndef CONFIG_GRKERNSEC
58169 +obj-y += grsec_disabled.o
58170 +endif
58171 +
58172 +ifdef CONFIG_GRKERNSEC_HIDESYM
58173 +extra-y := grsec_hidesym.o
58174 +$(obj)/grsec_hidesym.o:
58175 + @-chmod -f 500 /boot
58176 + @-chmod -f 500 /lib/modules
58177 + @-chmod -f 500 /lib64/modules
58178 + @-chmod -f 500 /lib32/modules
58179 + @-chmod -f 700 .
58180 + @echo ' grsec: protected kernel image paths'
58181 +endif
58182 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
58183 new file mode 100644
58184 index 0000000..0d5c602
58185 --- /dev/null
58186 +++ b/grsecurity/gracl.c
58187 @@ -0,0 +1,4073 @@
58188 +#include <linux/kernel.h>
58189 +#include <linux/module.h>
58190 +#include <linux/sched.h>
58191 +#include <linux/mm.h>
58192 +#include <linux/file.h>
58193 +#include <linux/fs.h>
58194 +#include <linux/namei.h>
58195 +#include <linux/mount.h>
58196 +#include <linux/tty.h>
58197 +#include <linux/proc_fs.h>
58198 +#include <linux/lglock.h>
58199 +#include <linux/slab.h>
58200 +#include <linux/vmalloc.h>
58201 +#include <linux/types.h>
58202 +#include <linux/sysctl.h>
58203 +#include <linux/netdevice.h>
58204 +#include <linux/ptrace.h>
58205 +#include <linux/gracl.h>
58206 +#include <linux/gralloc.h>
58207 +#include <linux/security.h>
58208 +#include <linux/grinternal.h>
58209 +#include <linux/pid_namespace.h>
58210 +#include <linux/stop_machine.h>
58211 +#include <linux/fdtable.h>
58212 +#include <linux/percpu.h>
58213 +#include <linux/lglock.h>
58214 +#include <linux/hugetlb.h>
58215 +#include <linux/posix-timers.h>
58216 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
58217 +#include <linux/magic.h>
58218 +#include <linux/pagemap.h>
58219 +#include "../fs/btrfs/async-thread.h"
58220 +#include "../fs/btrfs/ctree.h"
58221 +#include "../fs/btrfs/btrfs_inode.h"
58222 +#endif
58223 +#include "../fs/mount.h"
58224 +
58225 +#include <asm/uaccess.h>
58226 +#include <asm/errno.h>
58227 +#include <asm/mman.h>
58228 +
58229 +extern struct lglock vfsmount_lock;
58230 +
58231 +static struct acl_role_db acl_role_set;
58232 +static struct name_db name_set;
58233 +static struct inodev_db inodev_set;
58234 +
58235 +/* for keeping track of userspace pointers used for subjects, so we
58236 + can share references in the kernel as well
58237 +*/
58238 +
58239 +static struct path real_root;
58240 +
58241 +static struct acl_subj_map_db subj_map_set;
58242 +
58243 +static struct acl_role_label *default_role;
58244 +
58245 +static struct acl_role_label *role_list;
58246 +
58247 +static u16 acl_sp_role_value;
58248 +
58249 +extern char *gr_shared_page[4];
58250 +static DEFINE_MUTEX(gr_dev_mutex);
58251 +DEFINE_RWLOCK(gr_inode_lock);
58252 +
58253 +struct gr_arg *gr_usermode;
58254 +
58255 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
58256 +
58257 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
58258 +extern void gr_clear_learn_entries(void);
58259 +
58260 +unsigned char *gr_system_salt;
58261 +unsigned char *gr_system_sum;
58262 +
58263 +static struct sprole_pw **acl_special_roles = NULL;
58264 +static __u16 num_sprole_pws = 0;
58265 +
58266 +static struct acl_role_label *kernel_role = NULL;
58267 +
58268 +static unsigned int gr_auth_attempts = 0;
58269 +static unsigned long gr_auth_expires = 0UL;
58270 +
58271 +#ifdef CONFIG_NET
58272 +extern struct vfsmount *sock_mnt;
58273 +#endif
58274 +
58275 +extern struct vfsmount *pipe_mnt;
58276 +extern struct vfsmount *shm_mnt;
58277 +
58278 +#ifdef CONFIG_HUGETLBFS
58279 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
58280 +#endif
58281 +
58282 +static struct acl_object_label *fakefs_obj_rw;
58283 +static struct acl_object_label *fakefs_obj_rwx;
58284 +
58285 +extern int gr_init_uidset(void);
58286 +extern void gr_free_uidset(void);
58287 +extern void gr_remove_uid(uid_t uid);
58288 +extern int gr_find_uid(uid_t uid);
58289 +
58290 +__inline__ int
58291 +gr_acl_is_enabled(void)
58292 +{
58293 + return (gr_status & GR_READY);
58294 +}
58295 +
58296 +static inline dev_t __get_dev(const struct dentry *dentry)
58297 +{
58298 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
58299 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
58300 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
58301 + else
58302 +#endif
58303 + return dentry->d_sb->s_dev;
58304 +}
58305 +
58306 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
58307 +{
58308 + return __get_dev(dentry);
58309 +}
58310 +
58311 +static char gr_task_roletype_to_char(struct task_struct *task)
58312 +{
58313 + switch (task->role->roletype &
58314 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
58315 + GR_ROLE_SPECIAL)) {
58316 + case GR_ROLE_DEFAULT:
58317 + return 'D';
58318 + case GR_ROLE_USER:
58319 + return 'U';
58320 + case GR_ROLE_GROUP:
58321 + return 'G';
58322 + case GR_ROLE_SPECIAL:
58323 + return 'S';
58324 + }
58325 +
58326 + return 'X';
58327 +}
58328 +
58329 +char gr_roletype_to_char(void)
58330 +{
58331 + return gr_task_roletype_to_char(current);
58332 +}
58333 +
58334 +__inline__ int
58335 +gr_acl_tpe_check(void)
58336 +{
58337 + if (unlikely(!(gr_status & GR_READY)))
58338 + return 0;
58339 + if (current->role->roletype & GR_ROLE_TPE)
58340 + return 1;
58341 + else
58342 + return 0;
58343 +}
58344 +
58345 +int
58346 +gr_handle_rawio(const struct inode *inode)
58347 +{
58348 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
58349 + if (inode && S_ISBLK(inode->i_mode) &&
58350 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
58351 + !capable(CAP_SYS_RAWIO))
58352 + return 1;
58353 +#endif
58354 + return 0;
58355 +}
58356 +
58357 +static int
58358 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
58359 +{
58360 + if (likely(lena != lenb))
58361 + return 0;
58362 +
58363 + return !memcmp(a, b, lena);
58364 +}
58365 +
58366 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
58367 +{
58368 + *buflen -= namelen;
58369 + if (*buflen < 0)
58370 + return -ENAMETOOLONG;
58371 + *buffer -= namelen;
58372 + memcpy(*buffer, str, namelen);
58373 + return 0;
58374 +}
58375 +
58376 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
58377 +{
58378 + return prepend(buffer, buflen, name->name, name->len);
58379 +}
58380 +
58381 +static int prepend_path(const struct path *path, struct path *root,
58382 + char **buffer, int *buflen)
58383 +{
58384 + struct dentry *dentry = path->dentry;
58385 + struct vfsmount *vfsmnt = path->mnt;
58386 + struct mount *mnt = real_mount(vfsmnt);
58387 + bool slash = false;
58388 + int error = 0;
58389 +
58390 + while (dentry != root->dentry || vfsmnt != root->mnt) {
58391 + struct dentry * parent;
58392 +
58393 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
58394 + /* Global root? */
58395 + if (!mnt_has_parent(mnt)) {
58396 + goto out;
58397 + }
58398 + dentry = mnt->mnt_mountpoint;
58399 + mnt = mnt->mnt_parent;
58400 + vfsmnt = &mnt->mnt;
58401 + continue;
58402 + }
58403 + parent = dentry->d_parent;
58404 + prefetch(parent);
58405 + spin_lock(&dentry->d_lock);
58406 + error = prepend_name(buffer, buflen, &dentry->d_name);
58407 + spin_unlock(&dentry->d_lock);
58408 + if (!error)
58409 + error = prepend(buffer, buflen, "/", 1);
58410 + if (error)
58411 + break;
58412 +
58413 + slash = true;
58414 + dentry = parent;
58415 + }
58416 +
58417 +out:
58418 + if (!error && !slash)
58419 + error = prepend(buffer, buflen, "/", 1);
58420 +
58421 + return error;
58422 +}
58423 +
58424 +/* this must be called with vfsmount_lock and rename_lock held */
58425 +
58426 +static char *__our_d_path(const struct path *path, struct path *root,
58427 + char *buf, int buflen)
58428 +{
58429 + char *res = buf + buflen;
58430 + int error;
58431 +
58432 + prepend(&res, &buflen, "\0", 1);
58433 + error = prepend_path(path, root, &res, &buflen);
58434 + if (error)
58435 + return ERR_PTR(error);
58436 +
58437 + return res;
58438 +}
58439 +
58440 +static char *
58441 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
58442 +{
58443 + char *retval;
58444 +
58445 + retval = __our_d_path(path, root, buf, buflen);
58446 + if (unlikely(IS_ERR(retval)))
58447 + retval = strcpy(buf, "<path too long>");
58448 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
58449 + retval[1] = '\0';
58450 +
58451 + return retval;
58452 +}
58453 +
58454 +static char *
58455 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
58456 + char *buf, int buflen)
58457 +{
58458 + struct path path;
58459 + char *res;
58460 +
58461 + path.dentry = (struct dentry *)dentry;
58462 + path.mnt = (struct vfsmount *)vfsmnt;
58463 +
58464 + /* we can use real_root.dentry, real_root.mnt, because this is only called
58465 + by the RBAC system */
58466 + res = gen_full_path(&path, &real_root, buf, buflen);
58467 +
58468 + return res;
58469 +}
58470 +
58471 +static char *
58472 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
58473 + char *buf, int buflen)
58474 +{
58475 + char *res;
58476 + struct path path;
58477 + struct path root;
58478 + struct task_struct *reaper = init_pid_ns.child_reaper;
58479 +
58480 + path.dentry = (struct dentry *)dentry;
58481 + path.mnt = (struct vfsmount *)vfsmnt;
58482 +
58483 + /* we can't use real_root.dentry, real_root.mnt, because they belong only to the RBAC system */
58484 + get_fs_root(reaper->fs, &root);
58485 +
58486 + br_read_lock(&vfsmount_lock);
58487 + write_seqlock(&rename_lock);
58488 + res = gen_full_path(&path, &root, buf, buflen);
58489 + write_sequnlock(&rename_lock);
58490 + br_read_unlock(&vfsmount_lock);
58491 +
58492 + path_put(&root);
58493 + return res;
58494 +}
58495 +
58496 +static char *
58497 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
58498 +{
58499 + char *ret;
58500 + br_read_lock(&vfsmount_lock);
58501 + write_seqlock(&rename_lock);
58502 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
58503 + PAGE_SIZE);
58504 + write_sequnlock(&rename_lock);
58505 + br_read_unlock(&vfsmount_lock);
58506 + return ret;
58507 +}
58508 +
58509 +static char *
58510 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
58511 +{
58512 + char *ret;
58513 + char *buf;
58514 + int buflen;
58515 +
58516 + br_read_lock(&vfsmount_lock);
58517 + write_seqlock(&rename_lock);
58518 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
58519 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
58520 + buflen = (int)(ret - buf);
58521 + if (buflen >= 5)
58522 + prepend(&ret, &buflen, "/proc", 5);
58523 + else
58524 + ret = strcpy(buf, "<path too long>");
58525 + write_sequnlock(&rename_lock);
58526 + br_read_unlock(&vfsmount_lock);
58527 + return ret;
58528 +}
58529 +
58530 +char *
58531 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
58532 +{
58533 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
58534 + PAGE_SIZE);
58535 +}
58536 +
58537 +char *
58538 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
58539 +{
58540 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
58541 + PAGE_SIZE);
58542 +}
58543 +
58544 +char *
58545 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
58546 +{
58547 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
58548 + PAGE_SIZE);
58549 +}
58550 +
58551 +char *
58552 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
58553 +{
58554 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
58555 + PAGE_SIZE);
58556 +}
58557 +
58558 +char *
58559 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
58560 +{
58561 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
58562 + PAGE_SIZE);
58563 +}
58564 +
58565 +__inline__ __u32
58566 +to_gr_audit(const __u32 reqmode)
58567 +{
58568 + /* masks off auditable permission flags, then shifts them to create
58569 + auditing flags, and adds the special case of append auditing if
58570 + we're requesting write */
58571 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
58572 +}
58573 +
58574 +struct acl_subject_label *
58575 +lookup_subject_map(const struct acl_subject_label *userp)
58576 +{
58577 + unsigned int index = gr_shash(userp, subj_map_set.s_size);
58578 + struct subject_map *match;
58579 +
58580 + match = subj_map_set.s_hash[index];
58581 +
58582 + while (match && match->user != userp)
58583 + match = match->next;
58584 +
58585 + if (match != NULL)
58586 + return match->kernel;
58587 + else
58588 + return NULL;
58589 +}
58590 +
58591 +static void
58592 +insert_subj_map_entry(struct subject_map *subjmap)
58593 +{
58594 + unsigned int index = gr_shash(subjmap->user, subj_map_set.s_size);
58595 + struct subject_map **curr;
58596 +
58597 + subjmap->prev = NULL;
58598 +
58599 + curr = &subj_map_set.s_hash[index];
58600 + if (*curr != NULL)
58601 + (*curr)->prev = subjmap;
58602 +
58603 + subjmap->next = *curr;
58604 + *curr = subjmap;
58605 +
58606 + return;
58607 +}
58608 +
58609 +static struct acl_role_label *
58610 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
58611 + const gid_t gid)
58612 +{
58613 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, acl_role_set.r_size);
58614 + struct acl_role_label *match;
58615 + struct role_allowed_ip *ipp;
58616 + unsigned int x;
58617 + u32 curr_ip = task->signal->curr_ip;
58618 +
58619 + task->signal->saved_ip = curr_ip;
58620 +
58621 + match = acl_role_set.r_hash[index];
58622 +
58623 + while (match) {
58624 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
58625 + for (x = 0; x < match->domain_child_num; x++) {
58626 + if (match->domain_children[x] == uid)
58627 + goto found;
58628 + }
58629 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
58630 + break;
58631 + match = match->next;
58632 + }
58633 +found:
58634 + if (match == NULL) {
58635 + try_group:
58636 + index = gr_rhash(gid, GR_ROLE_GROUP, acl_role_set.r_size);
58637 + match = acl_role_set.r_hash[index];
58638 +
58639 + while (match) {
58640 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
58641 + for (x = 0; x < match->domain_child_num; x++) {
58642 + if (match->domain_children[x] == gid)
58643 + goto found2;
58644 + }
58645 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
58646 + break;
58647 + match = match->next;
58648 + }
58649 +found2:
58650 + if (match == NULL)
58651 + match = default_role;
58652 + if (match->allowed_ips == NULL)
58653 + return match;
58654 + else {
58655 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
58656 + if (likely
58657 + ((ntohl(curr_ip) & ipp->netmask) ==
58658 + (ntohl(ipp->addr) & ipp->netmask)))
58659 + return match;
58660 + }
58661 + match = default_role;
58662 + }
58663 + } else if (match->allowed_ips == NULL) {
58664 + return match;
58665 + } else {
58666 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
58667 + if (likely
58668 + ((ntohl(curr_ip) & ipp->netmask) ==
58669 + (ntohl(ipp->addr) & ipp->netmask)))
58670 + return match;
58671 + }
58672 + goto try_group;
58673 + }
58674 +
58675 + return match;
58676 +}
58677 +
58678 +struct acl_subject_label *
58679 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
58680 + const struct acl_role_label *role)
58681 +{
58682 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
58683 + struct acl_subject_label *match;
58684 +
58685 + match = role->subj_hash[index];
58686 +
58687 + while (match && (match->inode != ino || match->device != dev ||
58688 + (match->mode & GR_DELETED))) {
58689 + match = match->next;
58690 + }
58691 +
58692 + if (match && !(match->mode & GR_DELETED))
58693 + return match;
58694 + else
58695 + return NULL;
58696 +}
58697 +
58698 +struct acl_subject_label *
58699 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
58700 + const struct acl_role_label *role)
58701 +{
58702 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
58703 + struct acl_subject_label *match;
58704 +
58705 + match = role->subj_hash[index];
58706 +
58707 + while (match && (match->inode != ino || match->device != dev ||
58708 + !(match->mode & GR_DELETED))) {
58709 + match = match->next;
58710 + }
58711 +
58712 + if (match && (match->mode & GR_DELETED))
58713 + return match;
58714 + else
58715 + return NULL;
58716 +}
58717 +
58718 +static struct acl_object_label *
58719 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
58720 + const struct acl_subject_label *subj)
58721 +{
58722 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
58723 + struct acl_object_label *match;
58724 +
58725 + match = subj->obj_hash[index];
58726 +
58727 + while (match && (match->inode != ino || match->device != dev ||
58728 + (match->mode & GR_DELETED))) {
58729 + match = match->next;
58730 + }
58731 +
58732 + if (match && !(match->mode & GR_DELETED))
58733 + return match;
58734 + else
58735 + return NULL;
58736 +}
58737 +
58738 +static struct acl_object_label *
58739 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
58740 + const struct acl_subject_label *subj)
58741 +{
58742 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
58743 + struct acl_object_label *match;
58744 +
58745 + match = subj->obj_hash[index];
58746 +
58747 + while (match && (match->inode != ino || match->device != dev ||
58748 + !(match->mode & GR_DELETED))) {
58749 + match = match->next;
58750 + }
58751 +
58752 + if (match && (match->mode & GR_DELETED))
58753 + return match;
58754 +
58755 + match = subj->obj_hash[index];
58756 +
58757 + while (match && (match->inode != ino || match->device != dev ||
58758 + (match->mode & GR_DELETED))) {
58759 + match = match->next;
58760 + }
58761 +
58762 + if (match && !(match->mode & GR_DELETED))
58763 + return match;
58764 + else
58765 + return NULL;
58766 +}
58767 +
58768 +static struct name_entry *
58769 +lookup_name_entry(const char *name)
58770 +{
58771 + unsigned int len = strlen(name);
58772 + unsigned int key = full_name_hash(name, len);
58773 + unsigned int index = key % name_set.n_size;
58774 + struct name_entry *match;
58775 +
58776 + match = name_set.n_hash[index];
58777 +
58778 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
58779 + match = match->next;
58780 +
58781 + return match;
58782 +}
58783 +
58784 +static struct name_entry *
58785 +lookup_name_entry_create(const char *name)
58786 +{
58787 + unsigned int len = strlen(name);
58788 + unsigned int key = full_name_hash(name, len);
58789 + unsigned int index = key % name_set.n_size;
58790 + struct name_entry *match;
58791 +
58792 + match = name_set.n_hash[index];
58793 +
58794 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
58795 + !match->deleted))
58796 + match = match->next;
58797 +
58798 + if (match && match->deleted)
58799 + return match;
58800 +
58801 + match = name_set.n_hash[index];
58802 +
58803 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
58804 + match->deleted))
58805 + match = match->next;
58806 +
58807 + if (match && !match->deleted)
58808 + return match;
58809 + else
58810 + return NULL;
58811 +}
58812 +
58813 +static struct inodev_entry *
58814 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
58815 +{
58816 + unsigned int index = gr_fhash(ino, dev, inodev_set.i_size);
58817 + struct inodev_entry *match;
58818 +
58819 + match = inodev_set.i_hash[index];
58820 +
58821 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
58822 + match = match->next;
58823 +
58824 + return match;
58825 +}
58826 +
58827 +static void
58828 +insert_inodev_entry(struct inodev_entry *entry)
58829 +{
58830 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
58831 + inodev_set.i_size);
58832 + struct inodev_entry **curr;
58833 +
58834 + entry->prev = NULL;
58835 +
58836 + curr = &inodev_set.i_hash[index];
58837 + if (*curr != NULL)
58838 + (*curr)->prev = entry;
58839 +
58840 + entry->next = *curr;
58841 + *curr = entry;
58842 +
58843 + return;
58844 +}
58845 +
58846 +static void
58847 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
58848 +{
58849 + unsigned int index =
58850 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), acl_role_set.r_size);
58851 + struct acl_role_label **curr;
58852 + struct acl_role_label *tmp, *tmp2;
58853 +
58854 + curr = &acl_role_set.r_hash[index];
58855 +
58856 + /* simple case, slot is empty, just set it to our role */
58857 + if (*curr == NULL) {
58858 + *curr = role;
58859 + } else {
58860 + /* example:
58861 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
58862 + 2 -> 3
58863 + */
58864 + /* first check to see if we can already be reached via this slot */
58865 + tmp = *curr;
58866 + while (tmp && tmp != role)
58867 + tmp = tmp->next;
58868 + if (tmp == role) {
58869 + /* we don't need to add ourselves to this slot's chain */
58870 + return;
58871 + }
58872 + /* we need to add ourselves to this chain, two cases */
58873 + if (role->next == NULL) {
58874 + /* simple case, append the current chain to our role */
58875 + role->next = *curr;
58876 + *curr = role;
58877 + } else {
58878 + /* 1 -> 2 -> 3 -> 4
58879 + 2 -> 3 -> 4
58880 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
58881 + */
58882 + /* trickier case: walk our role's chain until we find
58883 + the role for the start of the current slot's chain */
58884 + tmp = role;
58885 + tmp2 = *curr;
58886 + while (tmp->next && tmp->next != tmp2)
58887 + tmp = tmp->next;
58888 + if (tmp->next == tmp2) {
58889 + /* from example above, we found 3, so just
58890 + replace this slot's chain with ours */
58891 + *curr = role;
58892 + } else {
58893 + /* we didn't find a subset of our role's chain
58894 + in the current slot's chain, so append their
58895 + chain to ours, and set us as the first role in
58896 + the slot's chain
58897 +
58898 + we could fold this case with the case above,
58899 + but making it explicit for clarity
58900 + */
58901 + tmp->next = tmp2;
58902 + *curr = role;
58903 + }
58904 + }
58905 + }
58906 +
58907 + return;
58908 +}
58909 +
58910 +static void
58911 +insert_acl_role_label(struct acl_role_label *role)
58912 +{
58913 + int i;
58914 +
58915 + if (role_list == NULL) {
58916 + role_list = role;
58917 + role->prev = NULL;
58918 + } else {
58919 + role->prev = role_list;
58920 + role_list = role;
58921 + }
58922 +
58923 + /* used for hash chains */
58924 + role->next = NULL;
58925 +
58926 + if (role->roletype & GR_ROLE_DOMAIN) {
58927 + for (i = 0; i < role->domain_child_num; i++)
58928 + __insert_acl_role_label(role, role->domain_children[i]);
58929 + } else
58930 + __insert_acl_role_label(role, role->uidgid);
58931 +}
58932 +
58933 +static int
58934 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
58935 +{
58936 + struct name_entry **curr, *nentry;
58937 + struct inodev_entry *ientry;
58938 + unsigned int len = strlen(name);
58939 + unsigned int key = full_name_hash(name, len);
58940 + unsigned int index = key % name_set.n_size;
58941 +
58942 + curr = &name_set.n_hash[index];
58943 +
58944 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
58945 + curr = &((*curr)->next);
58946 +
58947 + if (*curr != NULL)
58948 + return 1;
58949 +
58950 + nentry = acl_alloc(sizeof (struct name_entry));
58951 + if (nentry == NULL)
58952 + return 0;
58953 + ientry = acl_alloc(sizeof (struct inodev_entry));
58954 + if (ientry == NULL)
58955 + return 0;
58956 + ientry->nentry = nentry;
58957 +
58958 + nentry->key = key;
58959 + nentry->name = name;
58960 + nentry->inode = inode;
58961 + nentry->device = device;
58962 + nentry->len = len;
58963 + nentry->deleted = deleted;
58964 +
58965 + nentry->prev = NULL;
58966 + curr = &name_set.n_hash[index];
58967 + if (*curr != NULL)
58968 + (*curr)->prev = nentry;
58969 + nentry->next = *curr;
58970 + *curr = nentry;
58971 +
58972 + /* insert us into the table searchable by inode/dev */
58973 + insert_inodev_entry(ientry);
58974 +
58975 + return 1;
58976 +}
58977 +
58978 +static void
58979 +insert_acl_obj_label(struct acl_object_label *obj,
58980 + struct acl_subject_label *subj)
58981 +{
58982 + unsigned int index =
58983 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
58984 + struct acl_object_label **curr;
58985 +
58986 +
58987 + obj->prev = NULL;
58988 +
58989 + curr = &subj->obj_hash[index];
58990 + if (*curr != NULL)
58991 + (*curr)->prev = obj;
58992 +
58993 + obj->next = *curr;
58994 + *curr = obj;
58995 +
58996 + return;
58997 +}
58998 +
58999 +static void
59000 +insert_acl_subj_label(struct acl_subject_label *obj,
59001 + struct acl_role_label *role)
59002 +{
59003 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
59004 + struct acl_subject_label **curr;
59005 +
59006 + obj->prev = NULL;
59007 +
59008 + curr = &role->subj_hash[index];
59009 + if (*curr != NULL)
59010 + (*curr)->prev = obj;
59011 +
59012 + obj->next = *curr;
59013 + *curr = obj;
59014 +
59015 + return;
59016 +}
59017 +
59018 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
59019 +
59020 +static void *
59021 +create_table(__u32 * len, int elementsize)
59022 +{
59023 + unsigned int table_sizes[] = {
59024 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
59025 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
59026 + 4194301, 8388593, 16777213, 33554393, 67108859
59027 + };
59028 + void *newtable = NULL;
59029 + unsigned int pwr = 0;
59030 +
59031 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
59032 + table_sizes[pwr] <= *len)
59033 + pwr++;
59034 +
59035 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
59036 + return newtable;
59037 +
59038 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
59039 + newtable =
59040 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
59041 + else
59042 + newtable = vmalloc(table_sizes[pwr] * elementsize);
59043 +
59044 + *len = table_sizes[pwr];
59045 +
59046 + return newtable;
59047 +}
59048 +
59049 +static int
59050 +init_variables(const struct gr_arg *arg)
59051 +{
59052 + struct task_struct *reaper = init_pid_ns.child_reaper;
59053 + unsigned int stacksize;
59054 +
59055 + subj_map_set.s_size = arg->role_db.num_subjects;
59056 + acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
59057 + name_set.n_size = arg->role_db.num_objects;
59058 + inodev_set.i_size = arg->role_db.num_objects;
59059 +
59060 + if (!subj_map_set.s_size || !acl_role_set.r_size ||
59061 + !name_set.n_size || !inodev_set.i_size)
59062 + return 1;
59063 +
59064 + if (!gr_init_uidset())
59065 + return 1;
59066 +
59067 + /* set up the stack that holds allocation info */
59068 +
59069 + stacksize = arg->role_db.num_pointers + 5;
59070 +
59071 + if (!acl_alloc_stack_init(stacksize))
59072 + return 1;
59073 +
59074 + /* grab reference for the real root dentry and vfsmount */
59075 + get_fs_root(reaper->fs, &real_root);
59076 +
59077 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
59078 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(real_root.dentry), real_root.dentry->d_inode->i_ino);
59079 +#endif
59080 +
59081 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
59082 + if (fakefs_obj_rw == NULL)
59083 + return 1;
59084 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
59085 +
59086 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
59087 + if (fakefs_obj_rwx == NULL)
59088 + return 1;
59089 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
59090 +
59091 + subj_map_set.s_hash =
59092 + (struct subject_map **) create_table(&subj_map_set.s_size, sizeof(void *));
59093 + acl_role_set.r_hash =
59094 + (struct acl_role_label **) create_table(&acl_role_set.r_size, sizeof(void *));
59095 + name_set.n_hash = (struct name_entry **) create_table(&name_set.n_size, sizeof(void *));
59096 + inodev_set.i_hash =
59097 + (struct inodev_entry **) create_table(&inodev_set.i_size, sizeof(void *));
59098 +
59099 + if (!subj_map_set.s_hash || !acl_role_set.r_hash ||
59100 + !name_set.n_hash || !inodev_set.i_hash)
59101 + return 1;
59102 +
59103 + memset(subj_map_set.s_hash, 0,
59104 + sizeof(struct subject_map *) * subj_map_set.s_size);
59105 + memset(acl_role_set.r_hash, 0,
59106 + sizeof (struct acl_role_label *) * acl_role_set.r_size);
59107 + memset(name_set.n_hash, 0,
59108 + sizeof (struct name_entry *) * name_set.n_size);
59109 + memset(inodev_set.i_hash, 0,
59110 + sizeof (struct inodev_entry *) * inodev_set.i_size);
59111 +
59112 + return 0;
59113 +}
59114 +
59115 +/* free information not needed after startup
59116 + currently contains user->kernel pointer mappings for subjects
59117 +*/
59118 +
59119 +static void
59120 +free_init_variables(void)
59121 +{
59122 + __u32 i;
59123 +
59124 + if (subj_map_set.s_hash) {
59125 + for (i = 0; i < subj_map_set.s_size; i++) {
59126 + if (subj_map_set.s_hash[i]) {
59127 + kfree(subj_map_set.s_hash[i]);
59128 + subj_map_set.s_hash[i] = NULL;
59129 + }
59130 + }
59131 +
59132 + if ((subj_map_set.s_size * sizeof (struct subject_map *)) <=
59133 + PAGE_SIZE)
59134 + kfree(subj_map_set.s_hash);
59135 + else
59136 + vfree(subj_map_set.s_hash);
59137 + }
59138 +
59139 + return;
59140 +}
59141 +
59142 +static void
59143 +free_variables(void)
59144 +{
59145 + struct acl_subject_label *s;
59146 + struct acl_role_label *r;
59147 + struct task_struct *task, *task2;
59148 + unsigned int x;
59149 +
59150 + gr_clear_learn_entries();
59151 +
59152 + read_lock(&tasklist_lock);
59153 + do_each_thread(task2, task) {
59154 + task->acl_sp_role = 0;
59155 + task->acl_role_id = 0;
59156 + task->acl = NULL;
59157 + task->role = NULL;
59158 + } while_each_thread(task2, task);
59159 + read_unlock(&tasklist_lock);
59160 +
59161 + /* release the reference to the real root dentry and vfsmount */
59162 + path_put(&real_root);
59163 + memset(&real_root, 0, sizeof(real_root));
59164 +
59165 + /* free all object hash tables */
59166 +
59167 + FOR_EACH_ROLE_START(r)
59168 + if (r->subj_hash == NULL)
59169 + goto next_role;
59170 + FOR_EACH_SUBJECT_START(r, s, x)
59171 + if (s->obj_hash == NULL)
59172 + break;
59173 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
59174 + kfree(s->obj_hash);
59175 + else
59176 + vfree(s->obj_hash);
59177 + FOR_EACH_SUBJECT_END(s, x)
59178 + FOR_EACH_NESTED_SUBJECT_START(r, s)
59179 + if (s->obj_hash == NULL)
59180 + break;
59181 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
59182 + kfree(s->obj_hash);
59183 + else
59184 + vfree(s->obj_hash);
59185 + FOR_EACH_NESTED_SUBJECT_END(s)
59186 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
59187 + kfree(r->subj_hash);
59188 + else
59189 + vfree(r->subj_hash);
59190 + r->subj_hash = NULL;
59191 +next_role:
59192 + FOR_EACH_ROLE_END(r)
59193 +
59194 + acl_free_all();
59195 +
59196 + if (acl_role_set.r_hash) {
59197 + if ((acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
59198 + PAGE_SIZE)
59199 + kfree(acl_role_set.r_hash);
59200 + else
59201 + vfree(acl_role_set.r_hash);
59202 + }
59203 + if (name_set.n_hash) {
59204 + if ((name_set.n_size * sizeof (struct name_entry *)) <=
59205 + PAGE_SIZE)
59206 + kfree(name_set.n_hash);
59207 + else
59208 + vfree(name_set.n_hash);
59209 + }
59210 +
59211 + if (inodev_set.i_hash) {
59212 + if ((inodev_set.i_size * sizeof (struct inodev_entry *)) <=
59213 + PAGE_SIZE)
59214 + kfree(inodev_set.i_hash);
59215 + else
59216 + vfree(inodev_set.i_hash);
59217 + }
59218 +
59219 + gr_free_uidset();
59220 +
59221 + memset(&name_set, 0, sizeof (struct name_db));
59222 + memset(&inodev_set, 0, sizeof (struct inodev_db));
59223 + memset(&acl_role_set, 0, sizeof (struct acl_role_db));
59224 + memset(&subj_map_set, 0, sizeof (struct acl_subj_map_db));
59225 +
59226 + default_role = NULL;
59227 + kernel_role = NULL;
59228 + role_list = NULL;
59229 +
59230 + return;
59231 +}
59232 +
59233 +static __u32
59234 +count_user_objs(struct acl_object_label *userp)
59235 +{
59236 + struct acl_object_label o_tmp;
59237 + __u32 num = 0;
59238 +
59239 + while (userp) {
59240 + if (copy_from_user(&o_tmp, userp,
59241 + sizeof (struct acl_object_label)))
59242 + break;
59243 +
59244 + userp = o_tmp.prev;
59245 + num++;
59246 + }
59247 +
59248 + return num;
59249 +}
59250 +
59251 +static struct acl_subject_label *
59252 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
59253 +
59254 +static int
59255 +copy_user_glob(struct acl_object_label *obj)
59256 +{
59257 + struct acl_object_label *g_tmp, **guser;
59258 + unsigned int len;
59259 + char *tmp;
59260 +
59261 + if (obj->globbed == NULL)
59262 + return 0;
59263 +
59264 + guser = &obj->globbed;
59265 + while (*guser) {
59266 + g_tmp = (struct acl_object_label *)
59267 + acl_alloc(sizeof (struct acl_object_label));
59268 + if (g_tmp == NULL)
59269 + return -ENOMEM;
59270 +
59271 + if (copy_from_user(g_tmp, *guser,
59272 + sizeof (struct acl_object_label)))
59273 + return -EFAULT;
59274 +
59275 + len = strnlen_user(g_tmp->filename, PATH_MAX);
59276 +
59277 + if (!len || len >= PATH_MAX)
59278 + return -EINVAL;
59279 +
59280 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59281 + return -ENOMEM;
59282 +
59283 + if (copy_from_user(tmp, g_tmp->filename, len))
59284 + return -EFAULT;
59285 + tmp[len-1] = '\0';
59286 + g_tmp->filename = tmp;
59287 +
59288 + *guser = g_tmp;
59289 + guser = &(g_tmp->next);
59290 + }
59291 +
59292 + return 0;
59293 +}
59294 +
59295 +static int
59296 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
59297 + struct acl_role_label *role)
59298 +{
59299 + struct acl_object_label *o_tmp;
59300 + unsigned int len;
59301 + int ret;
59302 + char *tmp;
59303 +
59304 + while (userp) {
59305 + if ((o_tmp = (struct acl_object_label *)
59306 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
59307 + return -ENOMEM;
59308 +
59309 + if (copy_from_user(o_tmp, userp,
59310 + sizeof (struct acl_object_label)))
59311 + return -EFAULT;
59312 +
59313 + userp = o_tmp->prev;
59314 +
59315 + len = strnlen_user(o_tmp->filename, PATH_MAX);
59316 +
59317 + if (!len || len >= PATH_MAX)
59318 + return -EINVAL;
59319 +
59320 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59321 + return -ENOMEM;
59322 +
59323 + if (copy_from_user(tmp, o_tmp->filename, len))
59324 + return -EFAULT;
59325 + tmp[len-1] = '\0';
59326 + o_tmp->filename = tmp;
59327 +
59328 + insert_acl_obj_label(o_tmp, subj);
59329 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
59330 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
59331 + return -ENOMEM;
59332 +
59333 + ret = copy_user_glob(o_tmp);
59334 + if (ret)
59335 + return ret;
59336 +
59337 + if (o_tmp->nested) {
59338 + int already_copied;
59339 +
59340 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
59341 + if (IS_ERR(o_tmp->nested))
59342 + return PTR_ERR(o_tmp->nested);
59343 +
59344 + /* insert into nested subject list if we haven't copied this one yet
59345 + to prevent duplicate entries */
59346 + if (!already_copied) {
59347 + o_tmp->nested->next = role->hash->first;
59348 + role->hash->first = o_tmp->nested;
59349 + }
59350 + }
59351 + }
59352 +
59353 + return 0;
59354 +}
59355 +
59356 +static __u32
59357 +count_user_subjs(struct acl_subject_label *userp)
59358 +{
59359 + struct acl_subject_label s_tmp;
59360 + __u32 num = 0;
59361 +
59362 + while (userp) {
59363 + if (copy_from_user(&s_tmp, userp,
59364 + sizeof (struct acl_subject_label)))
59365 + break;
59366 +
59367 + userp = s_tmp.prev;
59368 + }
59369 +
59370 + return num;
59371 +}
59372 +
59373 +static int
59374 +copy_user_allowedips(struct acl_role_label *rolep)
59375 +{
59376 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
59377 +
59378 + ruserip = rolep->allowed_ips;
59379 +
59380 + while (ruserip) {
59381 + rlast = rtmp;
59382 +
59383 + if ((rtmp = (struct role_allowed_ip *)
59384 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
59385 + return -ENOMEM;
59386 +
59387 + if (copy_from_user(rtmp, ruserip,
59388 + sizeof (struct role_allowed_ip)))
59389 + return -EFAULT;
59390 +
59391 + ruserip = rtmp->prev;
59392 +
59393 + if (!rlast) {
59394 + rtmp->prev = NULL;
59395 + rolep->allowed_ips = rtmp;
59396 + } else {
59397 + rlast->next = rtmp;
59398 + rtmp->prev = rlast;
59399 + }
59400 +
59401 + if (!ruserip)
59402 + rtmp->next = NULL;
59403 + }
59404 +
59405 + return 0;
59406 +}
59407 +
59408 +static int
59409 +copy_user_transitions(struct acl_role_label *rolep)
59410 +{
59411 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
59412 +
59413 + unsigned int len;
59414 + char *tmp;
59415 +
59416 + rusertp = rolep->transitions;
59417 +
59418 + while (rusertp) {
59419 + rlast = rtmp;
59420 +
59421 + if ((rtmp = (struct role_transition *)
59422 + acl_alloc(sizeof (struct role_transition))) == NULL)
59423 + return -ENOMEM;
59424 +
59425 + if (copy_from_user(rtmp, rusertp,
59426 + sizeof (struct role_transition)))
59427 + return -EFAULT;
59428 +
59429 + rusertp = rtmp->prev;
59430 +
59431 + len = strnlen_user(rtmp->rolename, GR_SPROLE_LEN);
59432 +
59433 + if (!len || len >= GR_SPROLE_LEN)
59434 + return -EINVAL;
59435 +
59436 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59437 + return -ENOMEM;
59438 +
59439 + if (copy_from_user(tmp, rtmp->rolename, len))
59440 + return -EFAULT;
59441 + tmp[len-1] = '\0';
59442 + rtmp->rolename = tmp;
59443 +
59444 + if (!rlast) {
59445 + rtmp->prev = NULL;
59446 + rolep->transitions = rtmp;
59447 + } else {
59448 + rlast->next = rtmp;
59449 + rtmp->prev = rlast;
59450 + }
59451 +
59452 + if (!rusertp)
59453 + rtmp->next = NULL;
59454 + }
59455 +
59456 + return 0;
59457 +}
59458 +
59459 +static struct acl_subject_label *
59460 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
59461 +{
59462 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
59463 + unsigned int len;
59464 + char *tmp;
59465 + __u32 num_objs;
59466 + struct acl_ip_label **i_tmp, *i_utmp2;
59467 + struct gr_hash_struct ghash;
59468 + struct subject_map *subjmap;
59469 + unsigned int i_num;
59470 + int err;
59471 +
59472 + if (already_copied != NULL)
59473 + *already_copied = 0;
59474 +
59475 + s_tmp = lookup_subject_map(userp);
59476 +
59477 + /* we've already copied this subject into the kernel, just return
59478 + the reference to it, and don't copy it over again
59479 + */
59480 + if (s_tmp) {
59481 + if (already_copied != NULL)
59482 + *already_copied = 1;
59483 + return(s_tmp);
59484 + }
59485 +
59486 + if ((s_tmp = (struct acl_subject_label *)
59487 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
59488 + return ERR_PTR(-ENOMEM);
59489 +
59490 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
59491 + if (subjmap == NULL)
59492 + return ERR_PTR(-ENOMEM);
59493 +
59494 + subjmap->user = userp;
59495 + subjmap->kernel = s_tmp;
59496 + insert_subj_map_entry(subjmap);
59497 +
59498 + if (copy_from_user(s_tmp, userp,
59499 + sizeof (struct acl_subject_label)))
59500 + return ERR_PTR(-EFAULT);
59501 +
59502 + len = strnlen_user(s_tmp->filename, PATH_MAX);
59503 +
59504 + if (!len || len >= PATH_MAX)
59505 + return ERR_PTR(-EINVAL);
59506 +
59507 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59508 + return ERR_PTR(-ENOMEM);
59509 +
59510 + if (copy_from_user(tmp, s_tmp->filename, len))
59511 + return ERR_PTR(-EFAULT);
59512 + tmp[len-1] = '\0';
59513 + s_tmp->filename = tmp;
59514 +
59515 + if (!strcmp(s_tmp->filename, "/"))
59516 + role->root_label = s_tmp;
59517 +
59518 + if (copy_from_user(&ghash, s_tmp->hash, sizeof(struct gr_hash_struct)))
59519 + return ERR_PTR(-EFAULT);
59520 +
59521 + /* copy user and group transition tables */
59522 +
59523 + if (s_tmp->user_trans_num) {
59524 + uid_t *uidlist;
59525 +
59526 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
59527 + if (uidlist == NULL)
59528 + return ERR_PTR(-ENOMEM);
59529 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
59530 + return ERR_PTR(-EFAULT);
59531 +
59532 + s_tmp->user_transitions = uidlist;
59533 + }
59534 +
59535 + if (s_tmp->group_trans_num) {
59536 + gid_t *gidlist;
59537 +
59538 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
59539 + if (gidlist == NULL)
59540 + return ERR_PTR(-ENOMEM);
59541 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
59542 + return ERR_PTR(-EFAULT);
59543 +
59544 + s_tmp->group_transitions = gidlist;
59545 + }
59546 +
59547 + /* set up object hash table */
59548 + num_objs = count_user_objs(ghash.first);
59549 +
59550 + s_tmp->obj_hash_size = num_objs;
59551 + s_tmp->obj_hash =
59552 + (struct acl_object_label **)
59553 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
59554 +
59555 + if (!s_tmp->obj_hash)
59556 + return ERR_PTR(-ENOMEM);
59557 +
59558 + memset(s_tmp->obj_hash, 0,
59559 + s_tmp->obj_hash_size *
59560 + sizeof (struct acl_object_label *));
59561 +
59562 + /* add in objects */
59563 + err = copy_user_objs(ghash.first, s_tmp, role);
59564 +
59565 + if (err)
59566 + return ERR_PTR(err);
59567 +
59568 + /* set pointer for parent subject */
59569 + if (s_tmp->parent_subject) {
59570 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
59571 +
59572 + if (IS_ERR(s_tmp2))
59573 + return s_tmp2;
59574 +
59575 + s_tmp->parent_subject = s_tmp2;
59576 + }
59577 +
59578 + /* add in ip acls */
59579 +
59580 + if (!s_tmp->ip_num) {
59581 + s_tmp->ips = NULL;
59582 + goto insert;
59583 + }
59584 +
59585 + i_tmp =
59586 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
59587 + sizeof (struct acl_ip_label *));
59588 +
59589 + if (!i_tmp)
59590 + return ERR_PTR(-ENOMEM);
59591 +
59592 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
59593 + *(i_tmp + i_num) =
59594 + (struct acl_ip_label *)
59595 + acl_alloc(sizeof (struct acl_ip_label));
59596 + if (!*(i_tmp + i_num))
59597 + return ERR_PTR(-ENOMEM);
59598 +
59599 + if (copy_from_user
59600 + (&i_utmp2, s_tmp->ips + i_num,
59601 + sizeof (struct acl_ip_label *)))
59602 + return ERR_PTR(-EFAULT);
59603 +
59604 + if (copy_from_user
59605 + (*(i_tmp + i_num), i_utmp2,
59606 + sizeof (struct acl_ip_label)))
59607 + return ERR_PTR(-EFAULT);
59608 +
59609 + if ((*(i_tmp + i_num))->iface == NULL)
59610 + continue;
59611 +
59612 + len = strnlen_user((*(i_tmp + i_num))->iface, IFNAMSIZ);
59613 + if (!len || len >= IFNAMSIZ)
59614 + return ERR_PTR(-EINVAL);
59615 + tmp = acl_alloc(len);
59616 + if (tmp == NULL)
59617 + return ERR_PTR(-ENOMEM);
59618 + if (copy_from_user(tmp, (*(i_tmp + i_num))->iface, len))
59619 + return ERR_PTR(-EFAULT);
59620 + (*(i_tmp + i_num))->iface = tmp;
59621 + }
59622 +
59623 + s_tmp->ips = i_tmp;
59624 +
59625 +insert:
59626 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
59627 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
59628 + return ERR_PTR(-ENOMEM);
59629 +
59630 + return s_tmp;
59631 +}
59632 +
59633 +static int
59634 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
59635 +{
59636 + struct acl_subject_label s_pre;
59637 + struct acl_subject_label * ret;
59638 + int err;
59639 +
59640 + while (userp) {
59641 + if (copy_from_user(&s_pre, userp,
59642 + sizeof (struct acl_subject_label)))
59643 + return -EFAULT;
59644 +
59645 + ret = do_copy_user_subj(userp, role, NULL);
59646 +
59647 + err = PTR_ERR(ret);
59648 + if (IS_ERR(ret))
59649 + return err;
59650 +
59651 + insert_acl_subj_label(ret, role);
59652 +
59653 + userp = s_pre.prev;
59654 + }
59655 +
59656 + return 0;
59657 +}
59658 +
59659 +static int
59660 +copy_user_acl(struct gr_arg *arg)
59661 +{
59662 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
59663 + struct acl_subject_label *subj_list;
59664 + struct sprole_pw *sptmp;
59665 + struct gr_hash_struct *ghash;
59666 + uid_t *domainlist;
59667 + unsigned int r_num;
59668 + unsigned int len;
59669 + char *tmp;
59670 + int err = 0;
59671 + __u16 i;
59672 + __u32 num_subjs;
59673 +
59674 + /* we need a default and kernel role */
59675 + if (arg->role_db.num_roles < 2)
59676 + return -EINVAL;
59677 +
59678 + /* copy special role authentication info from userspace */
59679 +
59680 + num_sprole_pws = arg->num_sprole_pws;
59681 + acl_special_roles = (struct sprole_pw **) acl_alloc_num(num_sprole_pws, sizeof(struct sprole_pw *));
59682 +
59683 + if (!acl_special_roles && num_sprole_pws)
59684 + return -ENOMEM;
59685 +
59686 + for (i = 0; i < num_sprole_pws; i++) {
59687 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
59688 + if (!sptmp)
59689 + return -ENOMEM;
59690 + if (copy_from_user(sptmp, arg->sprole_pws + i,
59691 + sizeof (struct sprole_pw)))
59692 + return -EFAULT;
59693 +
59694 + len = strnlen_user(sptmp->rolename, GR_SPROLE_LEN);
59695 +
59696 + if (!len || len >= GR_SPROLE_LEN)
59697 + return -EINVAL;
59698 +
59699 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59700 + return -ENOMEM;
59701 +
59702 + if (copy_from_user(tmp, sptmp->rolename, len))
59703 + return -EFAULT;
59704 +
59705 + tmp[len-1] = '\0';
59706 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
59707 + printk(KERN_ALERT "Copying special role %s\n", tmp);
59708 +#endif
59709 + sptmp->rolename = tmp;
59710 + acl_special_roles[i] = sptmp;
59711 + }
59712 +
59713 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
59714 +
59715 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
59716 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
59717 +
59718 + if (!r_tmp)
59719 + return -ENOMEM;
59720 +
59721 + if (copy_from_user(&r_utmp2, r_utmp + r_num,
59722 + sizeof (struct acl_role_label *)))
59723 + return -EFAULT;
59724 +
59725 + if (copy_from_user(r_tmp, r_utmp2,
59726 + sizeof (struct acl_role_label)))
59727 + return -EFAULT;
59728 +
59729 + len = strnlen_user(r_tmp->rolename, GR_SPROLE_LEN);
59730 +
59731 + if (!len || len >= PATH_MAX)
59732 + return -EINVAL;
59733 +
59734 + if ((tmp = (char *) acl_alloc(len)) == NULL)
59735 + return -ENOMEM;
59736 +
59737 + if (copy_from_user(tmp, r_tmp->rolename, len))
59738 + return -EFAULT;
59739 +
59740 + tmp[len-1] = '\0';
59741 + r_tmp->rolename = tmp;
59742 +
59743 + if (!strcmp(r_tmp->rolename, "default")
59744 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
59745 + default_role = r_tmp;
59746 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
59747 + kernel_role = r_tmp;
59748 + }
59749 +
59750 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
59751 + return -ENOMEM;
59752 +
59753 + if (copy_from_user(ghash, r_tmp->hash, sizeof(struct gr_hash_struct)))
59754 + return -EFAULT;
59755 +
59756 + r_tmp->hash = ghash;
59757 +
59758 + num_subjs = count_user_subjs(r_tmp->hash->first);
59759 +
59760 + r_tmp->subj_hash_size = num_subjs;
59761 + r_tmp->subj_hash =
59762 + (struct acl_subject_label **)
59763 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
59764 +
59765 + if (!r_tmp->subj_hash)
59766 + return -ENOMEM;
59767 +
59768 + err = copy_user_allowedips(r_tmp);
59769 + if (err)
59770 + return err;
59771 +
59772 + /* copy domain info */
59773 + if (r_tmp->domain_children != NULL) {
59774 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
59775 + if (domainlist == NULL)
59776 + return -ENOMEM;
59777 +
59778 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
59779 + return -EFAULT;
59780 +
59781 + r_tmp->domain_children = domainlist;
59782 + }
59783 +
59784 + err = copy_user_transitions(r_tmp);
59785 + if (err)
59786 + return err;
59787 +
59788 + memset(r_tmp->subj_hash, 0,
59789 + r_tmp->subj_hash_size *
59790 + sizeof (struct acl_subject_label *));
59791 +
59792 + /* acquire the list of subjects, then NULL out
59793 + the list prior to parsing the subjects for this role,
59794 + as during this parsing the list is replaced with a list
59795 + of *nested* subjects for the role
59796 + */
59797 + subj_list = r_tmp->hash->first;
59798 +
59799 + /* set nested subject list to null */
59800 + r_tmp->hash->first = NULL;
59801 +
59802 + err = copy_user_subjs(subj_list, r_tmp);
59803 +
59804 + if (err)
59805 + return err;
59806 +
59807 + insert_acl_role_label(r_tmp);
59808 + }
59809 +
59810 + if (default_role == NULL || kernel_role == NULL)
59811 + return -EINVAL;
59812 +
59813 + return err;
59814 +}
59815 +
59816 +static int
59817 +gracl_init(struct gr_arg *args)
59818 +{
59819 + int error = 0;
59820 +
59821 + memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
59822 + memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
59823 +
59824 + if (init_variables(args)) {
59825 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
59826 + error = -ENOMEM;
59827 + free_variables();
59828 + goto out;
59829 + }
59830 +
59831 + error = copy_user_acl(args);
59832 + free_init_variables();
59833 + if (error) {
59834 + free_variables();
59835 + goto out;
59836 + }
59837 +
59838 + if ((error = gr_set_acls(0))) {
59839 + free_variables();
59840 + goto out;
59841 + }
59842 +
59843 + pax_open_kernel();
59844 + gr_status |= GR_READY;
59845 + pax_close_kernel();
59846 +
59847 + out:
59848 + return error;
59849 +}
59850 +
59851 +/* derived from glibc fnmatch() 0: match, 1: no match*/
59852 +
59853 +static int
59854 +glob_match(const char *p, const char *n)
59855 +{
59856 + char c;
59857 +
59858 + while ((c = *p++) != '\0') {
59859 + switch (c) {
59860 + case '?':
59861 + if (*n == '\0')
59862 + return 1;
59863 + else if (*n == '/')
59864 + return 1;
59865 + break;
59866 + case '\\':
59867 + if (*n != c)
59868 + return 1;
59869 + break;
59870 + case '*':
59871 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
59872 + if (*n == '/')
59873 + return 1;
59874 + else if (c == '?') {
59875 + if (*n == '\0')
59876 + return 1;
59877 + else
59878 + ++n;
59879 + }
59880 + }
59881 + if (c == '\0') {
59882 + return 0;
59883 + } else {
59884 + const char *endp;
59885 +
59886 + if ((endp = strchr(n, '/')) == NULL)
59887 + endp = n + strlen(n);
59888 +
59889 + if (c == '[') {
59890 + for (--p; n < endp; ++n)
59891 + if (!glob_match(p, n))
59892 + return 0;
59893 + } else if (c == '/') {
59894 + while (*n != '\0' && *n != '/')
59895 + ++n;
59896 + if (*n == '/' && !glob_match(p, n + 1))
59897 + return 0;
59898 + } else {
59899 + for (--p; n < endp; ++n)
59900 + if (*n == c && !glob_match(p, n))
59901 + return 0;
59902 + }
59903 +
59904 + return 1;
59905 + }
59906 + case '[':
59907 + {
59908 + int not;
59909 + char cold;
59910 +
59911 + if (*n == '\0' || *n == '/')
59912 + return 1;
59913 +
59914 + not = (*p == '!' || *p == '^');
59915 + if (not)
59916 + ++p;
59917 +
59918 + c = *p++;
59919 + for (;;) {
59920 + unsigned char fn = (unsigned char)*n;
59921 +
59922 + if (c == '\0')
59923 + return 1;
59924 + else {
59925 + if (c == fn)
59926 + goto matched;
59927 + cold = c;
59928 + c = *p++;
59929 +
59930 + if (c == '-' && *p != ']') {
59931 + unsigned char cend = *p++;
59932 +
59933 + if (cend == '\0')
59934 + return 1;
59935 +
59936 + if (cold <= fn && fn <= cend)
59937 + goto matched;
59938 +
59939 + c = *p++;
59940 + }
59941 + }
59942 +
59943 + if (c == ']')
59944 + break;
59945 + }
59946 + if (!not)
59947 + return 1;
59948 + break;
59949 + matched:
59950 + while (c != ']') {
59951 + if (c == '\0')
59952 + return 1;
59953 +
59954 + c = *p++;
59955 + }
59956 + if (not)
59957 + return 1;
59958 + }
59959 + break;
59960 + default:
59961 + if (c != *n)
59962 + return 1;
59963 + }
59964 +
59965 + ++n;
59966 + }
59967 +
59968 + if (*n == '\0')
59969 + return 0;
59970 +
59971 + if (*n == '/')
59972 + return 0;
59973 +
59974 + return 1;
59975 +}
59976 +
59977 +static struct acl_object_label *
59978 +chk_glob_label(struct acl_object_label *globbed,
59979 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
59980 +{
59981 + struct acl_object_label *tmp;
59982 +
59983 + if (*path == NULL)
59984 + *path = gr_to_filename_nolock(dentry, mnt);
59985 +
59986 + tmp = globbed;
59987 +
59988 + while (tmp) {
59989 + if (!glob_match(tmp->filename, *path))
59990 + return tmp;
59991 + tmp = tmp->next;
59992 + }
59993 +
59994 + return NULL;
59995 +}
59996 +
59997 +static struct acl_object_label *
59998 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
59999 + const ino_t curr_ino, const dev_t curr_dev,
60000 + const struct acl_subject_label *subj, char **path, const int checkglob)
60001 +{
60002 + struct acl_subject_label *tmpsubj;
60003 + struct acl_object_label *retval;
60004 + struct acl_object_label *retval2;
60005 +
60006 + tmpsubj = (struct acl_subject_label *) subj;
60007 + read_lock(&gr_inode_lock);
60008 + do {
60009 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
60010 + if (retval) {
60011 + if (checkglob && retval->globbed) {
60012 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
60013 + if (retval2)
60014 + retval = retval2;
60015 + }
60016 + break;
60017 + }
60018 + } while ((tmpsubj = tmpsubj->parent_subject));
60019 + read_unlock(&gr_inode_lock);
60020 +
60021 + return retval;
60022 +}
60023 +
60024 +static __inline__ struct acl_object_label *
60025 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
60026 + struct dentry *curr_dentry,
60027 + const struct acl_subject_label *subj, char **path, const int checkglob)
60028 +{
60029 + int newglob = checkglob;
60030 + ino_t inode;
60031 + dev_t device;
60032 +
60033 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
60034 + as we don't want a / * rule to match instead of the / object
60035 + don't do this for create lookups that call this function though, since they're looking up
60036 + on the parent and thus need globbing checks on all paths
60037 + */
60038 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
60039 + newglob = GR_NO_GLOB;
60040 +
60041 + spin_lock(&curr_dentry->d_lock);
60042 + inode = curr_dentry->d_inode->i_ino;
60043 + device = __get_dev(curr_dentry);
60044 + spin_unlock(&curr_dentry->d_lock);
60045 +
60046 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
60047 +}
60048 +
60049 +#ifdef CONFIG_HUGETLBFS
60050 +static inline bool
60051 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
60052 +{
60053 + int i;
60054 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
60055 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
60056 + return true;
60057 + }
60058 +
60059 + return false;
60060 +}
60061 +#endif
60062 +
60063 +static struct acl_object_label *
60064 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60065 + const struct acl_subject_label *subj, char *path, const int checkglob)
60066 +{
60067 + struct dentry *dentry = (struct dentry *) l_dentry;
60068 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
60069 + struct mount *real_mnt = real_mount(mnt);
60070 + struct acl_object_label *retval;
60071 + struct dentry *parent;
60072 +
60073 + br_read_lock(&vfsmount_lock);
60074 + write_seqlock(&rename_lock);
60075 +
60076 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
60077 +#ifdef CONFIG_NET
60078 + mnt == sock_mnt ||
60079 +#endif
60080 +#ifdef CONFIG_HUGETLBFS
60081 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
60082 +#endif
60083 + /* ignore Eric Biederman */
60084 + IS_PRIVATE(l_dentry->d_inode))) {
60085 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
60086 + goto out;
60087 + }
60088 +
60089 + for (;;) {
60090 + if (dentry == real_root.dentry && mnt == real_root.mnt)
60091 + break;
60092 +
60093 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
60094 + if (!mnt_has_parent(real_mnt))
60095 + break;
60096 +
60097 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
60098 + if (retval != NULL)
60099 + goto out;
60100 +
60101 + dentry = real_mnt->mnt_mountpoint;
60102 + real_mnt = real_mnt->mnt_parent;
60103 + mnt = &real_mnt->mnt;
60104 + continue;
60105 + }
60106 +
60107 + parent = dentry->d_parent;
60108 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
60109 + if (retval != NULL)
60110 + goto out;
60111 +
60112 + dentry = parent;
60113 + }
60114 +
60115 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
60116 +
60117 + /* real_root is pinned so we don't have to hold a reference */
60118 + if (retval == NULL)
60119 + retval = full_lookup(l_dentry, l_mnt, real_root.dentry, subj, &path, checkglob);
60120 +out:
60121 + write_sequnlock(&rename_lock);
60122 + br_read_unlock(&vfsmount_lock);
60123 +
60124 + BUG_ON(retval == NULL);
60125 +
60126 + return retval;
60127 +}
60128 +
60129 +static __inline__ struct acl_object_label *
60130 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60131 + const struct acl_subject_label *subj)
60132 +{
60133 + char *path = NULL;
60134 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
60135 +}
60136 +
60137 +static __inline__ struct acl_object_label *
60138 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60139 + const struct acl_subject_label *subj)
60140 +{
60141 + char *path = NULL;
60142 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
60143 +}
60144 +
60145 +static __inline__ struct acl_object_label *
60146 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60147 + const struct acl_subject_label *subj, char *path)
60148 +{
60149 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
60150 +}
60151 +
60152 +static struct acl_subject_label *
60153 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
60154 + const struct acl_role_label *role)
60155 +{
60156 + struct dentry *dentry = (struct dentry *) l_dentry;
60157 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
60158 + struct mount *real_mnt = real_mount(mnt);
60159 + struct acl_subject_label *retval;
60160 + struct dentry *parent;
60161 +
60162 + br_read_lock(&vfsmount_lock);
60163 + write_seqlock(&rename_lock);
60164 +
60165 + for (;;) {
60166 + if (dentry == real_root.dentry && mnt == real_root.mnt)
60167 + break;
60168 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
60169 + if (!mnt_has_parent(real_mnt))
60170 + break;
60171 +
60172 + spin_lock(&dentry->d_lock);
60173 + read_lock(&gr_inode_lock);
60174 + retval =
60175 + lookup_acl_subj_label(dentry->d_inode->i_ino,
60176 + __get_dev(dentry), role);
60177 + read_unlock(&gr_inode_lock);
60178 + spin_unlock(&dentry->d_lock);
60179 + if (retval != NULL)
60180 + goto out;
60181 +
60182 + dentry = real_mnt->mnt_mountpoint;
60183 + real_mnt = real_mnt->mnt_parent;
60184 + mnt = &real_mnt->mnt;
60185 + continue;
60186 + }
60187 +
60188 + spin_lock(&dentry->d_lock);
60189 + read_lock(&gr_inode_lock);
60190 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
60191 + __get_dev(dentry), role);
60192 + read_unlock(&gr_inode_lock);
60193 + parent = dentry->d_parent;
60194 + spin_unlock(&dentry->d_lock);
60195 +
60196 + if (retval != NULL)
60197 + goto out;
60198 +
60199 + dentry = parent;
60200 + }
60201 +
60202 + spin_lock(&dentry->d_lock);
60203 + read_lock(&gr_inode_lock);
60204 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
60205 + __get_dev(dentry), role);
60206 + read_unlock(&gr_inode_lock);
60207 + spin_unlock(&dentry->d_lock);
60208 +
60209 + if (unlikely(retval == NULL)) {
60210 + /* real_root is pinned, we don't need to hold a reference */
60211 + read_lock(&gr_inode_lock);
60212 + retval = lookup_acl_subj_label(real_root.dentry->d_inode->i_ino,
60213 + __get_dev(real_root.dentry), role);
60214 + read_unlock(&gr_inode_lock);
60215 + }
60216 +out:
60217 + write_sequnlock(&rename_lock);
60218 + br_read_unlock(&vfsmount_lock);
60219 +
60220 + BUG_ON(retval == NULL);
60221 +
60222 + return retval;
60223 +}
60224 +
60225 +static void
60226 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
60227 +{
60228 + struct task_struct *task = current;
60229 + const struct cred *cred = current_cred();
60230 +
60231 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
60232 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60233 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60234 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
60235 +
60236 + return;
60237 +}
60238 +
60239 +static void
60240 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
60241 +{
60242 + struct task_struct *task = current;
60243 + const struct cred *cred = current_cred();
60244 +
60245 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
60246 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60247 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60248 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
60249 +
60250 + return;
60251 +}
60252 +
60253 +static void
60254 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
60255 +{
60256 + struct task_struct *task = current;
60257 + const struct cred *cred = current_cred();
60258 +
60259 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
60260 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
60261 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
60262 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
60263 +
60264 + return;
60265 +}
60266 +
60267 +__u32
60268 +gr_search_file(const struct dentry * dentry, const __u32 mode,
60269 + const struct vfsmount * mnt)
60270 +{
60271 + __u32 retval = mode;
60272 + struct acl_subject_label *curracl;
60273 + struct acl_object_label *currobj;
60274 +
60275 + if (unlikely(!(gr_status & GR_READY)))
60276 + return (mode & ~GR_AUDITS);
60277 +
60278 + curracl = current->acl;
60279 +
60280 + currobj = chk_obj_label(dentry, mnt, curracl);
60281 + retval = currobj->mode & mode;
60282 +
60283 + /* if we're opening a specified transfer file for writing
60284 + (e.g. /dev/initctl), then transfer our role to init
60285 + */
60286 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
60287 + current->role->roletype & GR_ROLE_PERSIST)) {
60288 + struct task_struct *task = init_pid_ns.child_reaper;
60289 +
60290 + if (task->role != current->role) {
60291 + task->acl_sp_role = 0;
60292 + task->acl_role_id = current->acl_role_id;
60293 + task->role = current->role;
60294 + rcu_read_lock();
60295 + read_lock(&grsec_exec_file_lock);
60296 + gr_apply_subject_to_task(task);
60297 + read_unlock(&grsec_exec_file_lock);
60298 + rcu_read_unlock();
60299 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
60300 + }
60301 + }
60302 +
60303 + if (unlikely
60304 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
60305 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
60306 + __u32 new_mode = mode;
60307 +
60308 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
60309 +
60310 + retval = new_mode;
60311 +
60312 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
60313 + new_mode |= GR_INHERIT;
60314 +
60315 + if (!(mode & GR_NOLEARN))
60316 + gr_log_learn(dentry, mnt, new_mode);
60317 + }
60318 +
60319 + return retval;
60320 +}
60321 +
60322 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
60323 + const struct dentry *parent,
60324 + const struct vfsmount *mnt)
60325 +{
60326 + struct name_entry *match;
60327 + struct acl_object_label *matchpo;
60328 + struct acl_subject_label *curracl;
60329 + char *path;
60330 +
60331 + if (unlikely(!(gr_status & GR_READY)))
60332 + return NULL;
60333 +
60334 + preempt_disable();
60335 + path = gr_to_filename_rbac(new_dentry, mnt);
60336 + match = lookup_name_entry_create(path);
60337 +
60338 + curracl = current->acl;
60339 +
60340 + if (match) {
60341 + read_lock(&gr_inode_lock);
60342 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
60343 + read_unlock(&gr_inode_lock);
60344 +
60345 + if (matchpo) {
60346 + preempt_enable();
60347 + return matchpo;
60348 + }
60349 + }
60350 +
60351 + // lookup parent
60352 +
60353 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
60354 +
60355 + preempt_enable();
60356 + return matchpo;
60357 +}
60358 +
60359 +__u32
60360 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
60361 + const struct vfsmount * mnt, const __u32 mode)
60362 +{
60363 + struct acl_object_label *matchpo;
60364 + __u32 retval;
60365 +
60366 + if (unlikely(!(gr_status & GR_READY)))
60367 + return (mode & ~GR_AUDITS);
60368 +
60369 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
60370 +
60371 + retval = matchpo->mode & mode;
60372 +
60373 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
60374 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
60375 + __u32 new_mode = mode;
60376 +
60377 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
60378 +
60379 + gr_log_learn(new_dentry, mnt, new_mode);
60380 + return new_mode;
60381 + }
60382 +
60383 + return retval;
60384 +}
60385 +
60386 +__u32
60387 +gr_check_link(const struct dentry * new_dentry,
60388 + const struct dentry * parent_dentry,
60389 + const struct vfsmount * parent_mnt,
60390 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
60391 +{
60392 + struct acl_object_label *obj;
60393 + __u32 oldmode, newmode;
60394 + __u32 needmode;
60395 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
60396 + GR_DELETE | GR_INHERIT;
60397 +
60398 + if (unlikely(!(gr_status & GR_READY)))
60399 + return (GR_CREATE | GR_LINK);
60400 +
60401 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
60402 + oldmode = obj->mode;
60403 +
60404 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
60405 + newmode = obj->mode;
60406 +
60407 + needmode = newmode & checkmodes;
60408 +
60409 + // old name for hardlink must have at least the permissions of the new name
60410 + if ((oldmode & needmode) != needmode)
60411 + goto bad;
60412 +
60413 + // if old name had restrictions/auditing, make sure the new name does as well
60414 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
60415 +
60416 + // don't allow hardlinking of suid/sgid/fcapped files without permission
60417 + if (is_privileged_binary(old_dentry))
60418 + needmode |= GR_SETID;
60419 +
60420 + if ((newmode & needmode) != needmode)
60421 + goto bad;
60422 +
60423 + // enforce minimum permissions
60424 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
60425 + return newmode;
60426 +bad:
60427 + needmode = oldmode;
60428 + if (is_privileged_binary(old_dentry))
60429 + needmode |= GR_SETID;
60430 +
60431 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
60432 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
60433 + return (GR_CREATE | GR_LINK);
60434 + } else if (newmode & GR_SUPPRESS)
60435 + return GR_SUPPRESS;
60436 + else
60437 + return 0;
60438 +}
60439 +
60440 +int
60441 +gr_check_hidden_task(const struct task_struct *task)
60442 +{
60443 + if (unlikely(!(gr_status & GR_READY)))
60444 + return 0;
60445 +
60446 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
60447 + return 1;
60448 +
60449 + return 0;
60450 +}
60451 +
60452 +int
60453 +gr_check_protected_task(const struct task_struct *task)
60454 +{
60455 + if (unlikely(!(gr_status & GR_READY) || !task))
60456 + return 0;
60457 +
60458 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
60459 + task->acl != current->acl)
60460 + return 1;
60461 +
60462 + return 0;
60463 +}
60464 +
60465 +int
60466 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
60467 +{
60468 + struct task_struct *p;
60469 + int ret = 0;
60470 +
60471 + if (unlikely(!(gr_status & GR_READY) || !pid))
60472 + return ret;
60473 +
60474 + read_lock(&tasklist_lock);
60475 + do_each_pid_task(pid, type, p) {
60476 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
60477 + p->acl != current->acl) {
60478 + ret = 1;
60479 + goto out;
60480 + }
60481 + } while_each_pid_task(pid, type, p);
60482 +out:
60483 + read_unlock(&tasklist_lock);
60484 +
60485 + return ret;
60486 +}
60487 +
60488 +void
60489 +gr_copy_label(struct task_struct *tsk)
60490 +{
60491 + tsk->signal->used_accept = 0;
60492 + tsk->acl_sp_role = 0;
60493 + tsk->acl_role_id = current->acl_role_id;
60494 + tsk->acl = current->acl;
60495 + tsk->role = current->role;
60496 + tsk->signal->curr_ip = current->signal->curr_ip;
60497 + tsk->signal->saved_ip = current->signal->saved_ip;
60498 + if (current->exec_file)
60499 + get_file(current->exec_file);
60500 + tsk->exec_file = current->exec_file;
60501 + tsk->is_writable = current->is_writable;
60502 + if (unlikely(current->signal->used_accept)) {
60503 + current->signal->curr_ip = 0;
60504 + current->signal->saved_ip = 0;
60505 + }
60506 +
60507 + return;
60508 +}
60509 +
60510 +static void
60511 +gr_set_proc_res(struct task_struct *task)
60512 +{
60513 + struct acl_subject_label *proc;
60514 + unsigned short i;
60515 +
60516 + proc = task->acl;
60517 +
60518 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
60519 + return;
60520 +
60521 + for (i = 0; i < RLIM_NLIMITS; i++) {
60522 + if (!(proc->resmask & (1U << i)))
60523 + continue;
60524 +
60525 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
60526 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
60527 +
60528 + if (i == RLIMIT_CPU)
60529 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
60530 + }
60531 +
60532 + return;
60533 +}
60534 +
60535 +extern int gr_process_kernel_setuid_ban(struct user_struct *user);
60536 +
60537 +int
60538 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
60539 +{
60540 + unsigned int i;
60541 + __u16 num;
60542 + uid_t *uidlist;
60543 + uid_t curuid;
60544 + int realok = 0;
60545 + int effectiveok = 0;
60546 + int fsok = 0;
60547 + uid_t globalreal, globaleffective, globalfs;
60548 +
60549 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT)
60550 + struct user_struct *user;
60551 +
60552 + if (!uid_valid(real))
60553 + goto skipit;
60554 +
60555 + /* find user based on global namespace */
60556 +
60557 + globalreal = GR_GLOBAL_UID(real);
60558 +
60559 + user = find_user(make_kuid(&init_user_ns, globalreal));
60560 + if (user == NULL)
60561 + goto skipit;
60562 +
60563 + if (gr_process_kernel_setuid_ban(user)) {
60564 + /* for find_user */
60565 + free_uid(user);
60566 + return 1;
60567 + }
60568 +
60569 + /* for find_user */
60570 + free_uid(user);
60571 +
60572 +skipit:
60573 +#endif
60574 +
60575 + if (unlikely(!(gr_status & GR_READY)))
60576 + return 0;
60577 +
60578 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
60579 + gr_log_learn_uid_change(real, effective, fs);
60580 +
60581 + num = current->acl->user_trans_num;
60582 + uidlist = current->acl->user_transitions;
60583 +
60584 + if (uidlist == NULL)
60585 + return 0;
60586 +
60587 + if (!uid_valid(real)) {
60588 + realok = 1;
60589 + globalreal = (uid_t)-1;
60590 + } else {
60591 + globalreal = GR_GLOBAL_UID(real);
60592 + }
60593 + if (!uid_valid(effective)) {
60594 + effectiveok = 1;
60595 + globaleffective = (uid_t)-1;
60596 + } else {
60597 + globaleffective = GR_GLOBAL_UID(effective);
60598 + }
60599 + if (!uid_valid(fs)) {
60600 + fsok = 1;
60601 + globalfs = (uid_t)-1;
60602 + } else {
60603 + globalfs = GR_GLOBAL_UID(fs);
60604 + }
60605 +
60606 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
60607 + for (i = 0; i < num; i++) {
60608 + curuid = uidlist[i];
60609 + if (globalreal == curuid)
60610 + realok = 1;
60611 + if (globaleffective == curuid)
60612 + effectiveok = 1;
60613 + if (globalfs == curuid)
60614 + fsok = 1;
60615 + }
60616 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
60617 + for (i = 0; i < num; i++) {
60618 + curuid = uidlist[i];
60619 + if (globalreal == curuid)
60620 + break;
60621 + if (globaleffective == curuid)
60622 + break;
60623 + if (globalfs == curuid)
60624 + break;
60625 + }
60626 + /* not in deny list */
60627 + if (i == num) {
60628 + realok = 1;
60629 + effectiveok = 1;
60630 + fsok = 1;
60631 + }
60632 + }
60633 +
60634 + if (realok && effectiveok && fsok)
60635 + return 0;
60636 + else {
60637 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
60638 + return 1;
60639 + }
60640 +}
60641 +
60642 +int
60643 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
60644 +{
60645 + unsigned int i;
60646 + __u16 num;
60647 + gid_t *gidlist;
60648 + gid_t curgid;
60649 + int realok = 0;
60650 + int effectiveok = 0;
60651 + int fsok = 0;
60652 + gid_t globalreal, globaleffective, globalfs;
60653 +
60654 + if (unlikely(!(gr_status & GR_READY)))
60655 + return 0;
60656 +
60657 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
60658 + gr_log_learn_gid_change(real, effective, fs);
60659 +
60660 + num = current->acl->group_trans_num;
60661 + gidlist = current->acl->group_transitions;
60662 +
60663 + if (gidlist == NULL)
60664 + return 0;
60665 +
60666 + if (!gid_valid(real)) {
60667 + realok = 1;
60668 + globalreal = (gid_t)-1;
60669 + } else {
60670 + globalreal = GR_GLOBAL_GID(real);
60671 + }
60672 + if (!gid_valid(effective)) {
60673 + effectiveok = 1;
60674 + globaleffective = (gid_t)-1;
60675 + } else {
60676 + globaleffective = GR_GLOBAL_GID(effective);
60677 + }
60678 + if (!gid_valid(fs)) {
60679 + fsok = 1;
60680 + globalfs = (gid_t)-1;
60681 + } else {
60682 + globalfs = GR_GLOBAL_GID(fs);
60683 + }
60684 +
60685 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
60686 + for (i = 0; i < num; i++) {
60687 + curgid = gidlist[i];
60688 + if (globalreal == curgid)
60689 + realok = 1;
60690 + if (globaleffective == curgid)
60691 + effectiveok = 1;
60692 + if (globalfs == curgid)
60693 + fsok = 1;
60694 + }
60695 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
60696 + for (i = 0; i < num; i++) {
60697 + curgid = gidlist[i];
60698 + if (globalreal == curgid)
60699 + break;
60700 + if (globaleffective == curgid)
60701 + break;
60702 + if (globalfs == curgid)
60703 + break;
60704 + }
60705 + /* not in deny list */
60706 + if (i == num) {
60707 + realok = 1;
60708 + effectiveok = 1;
60709 + fsok = 1;
60710 + }
60711 + }
60712 +
60713 + if (realok && effectiveok && fsok)
60714 + return 0;
60715 + else {
60716 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
60717 + return 1;
60718 + }
60719 +}
60720 +
60721 +extern int gr_acl_is_capable(const int cap);
60722 +
60723 +void
60724 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
60725 +{
60726 + struct acl_role_label *role = task->role;
60727 + struct acl_subject_label *subj = NULL;
60728 + struct acl_object_label *obj;
60729 + struct file *filp;
60730 + uid_t uid;
60731 + gid_t gid;
60732 +
60733 + if (unlikely(!(gr_status & GR_READY)))
60734 + return;
60735 +
60736 + uid = GR_GLOBAL_UID(kuid);
60737 + gid = GR_GLOBAL_GID(kgid);
60738 +
60739 + filp = task->exec_file;
60740 +
60741 + /* kernel process, we'll give them the kernel role */
60742 + if (unlikely(!filp)) {
60743 + task->role = kernel_role;
60744 + task->acl = kernel_role->root_label;
60745 + return;
60746 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL))
60747 + role = lookup_acl_role_label(task, uid, gid);
60748 +
60749 + /* don't change the role if we're not a privileged process */
60750 + if (role && task->role != role &&
60751 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
60752 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
60753 + return;
60754 +
60755 + /* perform subject lookup in possibly new role
60756 + we can use this result below in the case where role == task->role
60757 + */
60758 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
60759 +
60760 + /* if we changed uid/gid, but result in the same role
60761 + and are using inheritance, don't lose the inherited subject
60762 + if current subject is other than what normal lookup
60763 + would result in, we arrived via inheritance, don't
60764 + lose subject
60765 + */
60766 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
60767 + (subj == task->acl)))
60768 + task->acl = subj;
60769 +
60770 + task->role = role;
60771 +
60772 + task->is_writable = 0;
60773 +
60774 + /* ignore additional mmap checks for processes that are writable
60775 + by the default ACL */
60776 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
60777 + if (unlikely(obj->mode & GR_WRITE))
60778 + task->is_writable = 1;
60779 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
60780 + if (unlikely(obj->mode & GR_WRITE))
60781 + task->is_writable = 1;
60782 +
60783 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60784 + 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);
60785 +#endif
60786 +
60787 + gr_set_proc_res(task);
60788 +
60789 + return;
60790 +}
60791 +
60792 +int
60793 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
60794 + const int unsafe_flags)
60795 +{
60796 + struct task_struct *task = current;
60797 + struct acl_subject_label *newacl;
60798 + struct acl_object_label *obj;
60799 + __u32 retmode;
60800 +
60801 + if (unlikely(!(gr_status & GR_READY)))
60802 + return 0;
60803 +
60804 + newacl = chk_subj_label(dentry, mnt, task->role);
60805 +
60806 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
60807 + did an exec
60808 + */
60809 + rcu_read_lock();
60810 + read_lock(&tasklist_lock);
60811 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
60812 + (task->parent->acl->mode & GR_POVERRIDE))) {
60813 + read_unlock(&tasklist_lock);
60814 + rcu_read_unlock();
60815 + goto skip_check;
60816 + }
60817 + read_unlock(&tasklist_lock);
60818 + rcu_read_unlock();
60819 +
60820 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
60821 + !(task->role->roletype & GR_ROLE_GOD) &&
60822 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
60823 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
60824 + if (unsafe_flags & LSM_UNSAFE_SHARE)
60825 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
60826 + else
60827 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
60828 + return -EACCES;
60829 + }
60830 +
60831 +skip_check:
60832 +
60833 + obj = chk_obj_label(dentry, mnt, task->acl);
60834 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
60835 +
60836 + if (!(task->acl->mode & GR_INHERITLEARN) &&
60837 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
60838 + if (obj->nested)
60839 + task->acl = obj->nested;
60840 + else
60841 + task->acl = newacl;
60842 + } else if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
60843 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
60844 +
60845 + task->is_writable = 0;
60846 +
60847 + /* ignore additional mmap checks for processes that are writable
60848 + by the default ACL */
60849 + obj = chk_obj_label(dentry, mnt, default_role->root_label);
60850 + if (unlikely(obj->mode & GR_WRITE))
60851 + task->is_writable = 1;
60852 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
60853 + if (unlikely(obj->mode & GR_WRITE))
60854 + task->is_writable = 1;
60855 +
60856 + gr_set_proc_res(task);
60857 +
60858 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
60859 + 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);
60860 +#endif
60861 + return 0;
60862 +}
60863 +
60864 +/* always called with valid inodev ptr */
60865 +static void
60866 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
60867 +{
60868 + struct acl_object_label *matchpo;
60869 + struct acl_subject_label *matchps;
60870 + struct acl_subject_label *subj;
60871 + struct acl_role_label *role;
60872 + unsigned int x;
60873 +
60874 + FOR_EACH_ROLE_START(role)
60875 + FOR_EACH_SUBJECT_START(role, subj, x)
60876 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
60877 + matchpo->mode |= GR_DELETED;
60878 + FOR_EACH_SUBJECT_END(subj,x)
60879 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
60880 + /* nested subjects aren't in the role's subj_hash table */
60881 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
60882 + matchpo->mode |= GR_DELETED;
60883 + FOR_EACH_NESTED_SUBJECT_END(subj)
60884 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
60885 + matchps->mode |= GR_DELETED;
60886 + FOR_EACH_ROLE_END(role)
60887 +
60888 + inodev->nentry->deleted = 1;
60889 +
60890 + return;
60891 +}
60892 +
60893 +void
60894 +gr_handle_delete(const ino_t ino, const dev_t dev)
60895 +{
60896 + struct inodev_entry *inodev;
60897 +
60898 + if (unlikely(!(gr_status & GR_READY)))
60899 + return;
60900 +
60901 + write_lock(&gr_inode_lock);
60902 + inodev = lookup_inodev_entry(ino, dev);
60903 + if (inodev != NULL)
60904 + do_handle_delete(inodev, ino, dev);
60905 + write_unlock(&gr_inode_lock);
60906 +
60907 + return;
60908 +}
60909 +
60910 +static void
60911 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
60912 + const ino_t newinode, const dev_t newdevice,
60913 + struct acl_subject_label *subj)
60914 +{
60915 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
60916 + struct acl_object_label *match;
60917 +
60918 + match = subj->obj_hash[index];
60919 +
60920 + while (match && (match->inode != oldinode ||
60921 + match->device != olddevice ||
60922 + !(match->mode & GR_DELETED)))
60923 + match = match->next;
60924 +
60925 + if (match && (match->inode == oldinode)
60926 + && (match->device == olddevice)
60927 + && (match->mode & GR_DELETED)) {
60928 + if (match->prev == NULL) {
60929 + subj->obj_hash[index] = match->next;
60930 + if (match->next != NULL)
60931 + match->next->prev = NULL;
60932 + } else {
60933 + match->prev->next = match->next;
60934 + if (match->next != NULL)
60935 + match->next->prev = match->prev;
60936 + }
60937 + match->prev = NULL;
60938 + match->next = NULL;
60939 + match->inode = newinode;
60940 + match->device = newdevice;
60941 + match->mode &= ~GR_DELETED;
60942 +
60943 + insert_acl_obj_label(match, subj);
60944 + }
60945 +
60946 + return;
60947 +}
60948 +
60949 +static void
60950 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
60951 + const ino_t newinode, const dev_t newdevice,
60952 + struct acl_role_label *role)
60953 +{
60954 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
60955 + struct acl_subject_label *match;
60956 +
60957 + match = role->subj_hash[index];
60958 +
60959 + while (match && (match->inode != oldinode ||
60960 + match->device != olddevice ||
60961 + !(match->mode & GR_DELETED)))
60962 + match = match->next;
60963 +
60964 + if (match && (match->inode == oldinode)
60965 + && (match->device == olddevice)
60966 + && (match->mode & GR_DELETED)) {
60967 + if (match->prev == NULL) {
60968 + role->subj_hash[index] = match->next;
60969 + if (match->next != NULL)
60970 + match->next->prev = NULL;
60971 + } else {
60972 + match->prev->next = match->next;
60973 + if (match->next != NULL)
60974 + match->next->prev = match->prev;
60975 + }
60976 + match->prev = NULL;
60977 + match->next = NULL;
60978 + match->inode = newinode;
60979 + match->device = newdevice;
60980 + match->mode &= ~GR_DELETED;
60981 +
60982 + insert_acl_subj_label(match, role);
60983 + }
60984 +
60985 + return;
60986 +}
60987 +
60988 +static void
60989 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
60990 + const ino_t newinode, const dev_t newdevice)
60991 +{
60992 + unsigned int index = gr_fhash(oldinode, olddevice, inodev_set.i_size);
60993 + struct inodev_entry *match;
60994 +
60995 + match = inodev_set.i_hash[index];
60996 +
60997 + while (match && (match->nentry->inode != oldinode ||
60998 + match->nentry->device != olddevice || !match->nentry->deleted))
60999 + match = match->next;
61000 +
61001 + if (match && (match->nentry->inode == oldinode)
61002 + && (match->nentry->device == olddevice) &&
61003 + match->nentry->deleted) {
61004 + if (match->prev == NULL) {
61005 + inodev_set.i_hash[index] = match->next;
61006 + if (match->next != NULL)
61007 + match->next->prev = NULL;
61008 + } else {
61009 + match->prev->next = match->next;
61010 + if (match->next != NULL)
61011 + match->next->prev = match->prev;
61012 + }
61013 + match->prev = NULL;
61014 + match->next = NULL;
61015 + match->nentry->inode = newinode;
61016 + match->nentry->device = newdevice;
61017 + match->nentry->deleted = 0;
61018 +
61019 + insert_inodev_entry(match);
61020 + }
61021 +
61022 + return;
61023 +}
61024 +
61025 +static void
61026 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
61027 +{
61028 + struct acl_subject_label *subj;
61029 + struct acl_role_label *role;
61030 + unsigned int x;
61031 +
61032 + FOR_EACH_ROLE_START(role)
61033 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
61034 +
61035 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
61036 + if ((subj->inode == ino) && (subj->device == dev)) {
61037 + subj->inode = ino;
61038 + subj->device = dev;
61039 + }
61040 + /* nested subjects aren't in the role's subj_hash table */
61041 + update_acl_obj_label(matchn->inode, matchn->device,
61042 + ino, dev, subj);
61043 + FOR_EACH_NESTED_SUBJECT_END(subj)
61044 + FOR_EACH_SUBJECT_START(role, subj, x)
61045 + update_acl_obj_label(matchn->inode, matchn->device,
61046 + ino, dev, subj);
61047 + FOR_EACH_SUBJECT_END(subj,x)
61048 + FOR_EACH_ROLE_END(role)
61049 +
61050 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
61051 +
61052 + return;
61053 +}
61054 +
61055 +static void
61056 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
61057 + const struct vfsmount *mnt)
61058 +{
61059 + ino_t ino = dentry->d_inode->i_ino;
61060 + dev_t dev = __get_dev(dentry);
61061 +
61062 + __do_handle_create(matchn, ino, dev);
61063 +
61064 + return;
61065 +}
61066 +
61067 +void
61068 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
61069 +{
61070 + struct name_entry *matchn;
61071 +
61072 + if (unlikely(!(gr_status & GR_READY)))
61073 + return;
61074 +
61075 + preempt_disable();
61076 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
61077 +
61078 + if (unlikely((unsigned long)matchn)) {
61079 + write_lock(&gr_inode_lock);
61080 + do_handle_create(matchn, dentry, mnt);
61081 + write_unlock(&gr_inode_lock);
61082 + }
61083 + preempt_enable();
61084 +
61085 + return;
61086 +}
61087 +
61088 +void
61089 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
61090 +{
61091 + struct name_entry *matchn;
61092 +
61093 + if (unlikely(!(gr_status & GR_READY)))
61094 + return;
61095 +
61096 + preempt_disable();
61097 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
61098 +
61099 + if (unlikely((unsigned long)matchn)) {
61100 + write_lock(&gr_inode_lock);
61101 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
61102 + write_unlock(&gr_inode_lock);
61103 + }
61104 + preempt_enable();
61105 +
61106 + return;
61107 +}
61108 +
61109 +void
61110 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
61111 + struct dentry *old_dentry,
61112 + struct dentry *new_dentry,
61113 + struct vfsmount *mnt, const __u8 replace)
61114 +{
61115 + struct name_entry *matchn;
61116 + struct inodev_entry *inodev;
61117 + struct inode *inode = new_dentry->d_inode;
61118 + ino_t old_ino = old_dentry->d_inode->i_ino;
61119 + dev_t old_dev = __get_dev(old_dentry);
61120 +
61121 + /* vfs_rename swaps the name and parent link for old_dentry and
61122 + new_dentry
61123 + at this point, old_dentry has the new name, parent link, and inode
61124 + for the renamed file
61125 + if a file is being replaced by a rename, new_dentry has the inode
61126 + and name for the replaced file
61127 + */
61128 +
61129 + if (unlikely(!(gr_status & GR_READY)))
61130 + return;
61131 +
61132 + preempt_disable();
61133 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
61134 +
61135 + /* we wouldn't have to check d_inode if it weren't for
61136 + NFS silly-renaming
61137 + */
61138 +
61139 + write_lock(&gr_inode_lock);
61140 + if (unlikely(replace && inode)) {
61141 + ino_t new_ino = inode->i_ino;
61142 + dev_t new_dev = __get_dev(new_dentry);
61143 +
61144 + inodev = lookup_inodev_entry(new_ino, new_dev);
61145 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
61146 + do_handle_delete(inodev, new_ino, new_dev);
61147 + }
61148 +
61149 + inodev = lookup_inodev_entry(old_ino, old_dev);
61150 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
61151 + do_handle_delete(inodev, old_ino, old_dev);
61152 +
61153 + if (unlikely((unsigned long)matchn))
61154 + do_handle_create(matchn, old_dentry, mnt);
61155 +
61156 + write_unlock(&gr_inode_lock);
61157 + preempt_enable();
61158 +
61159 + return;
61160 +}
61161 +
61162 +static int
61163 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
61164 + unsigned char **sum)
61165 +{
61166 + struct acl_role_label *r;
61167 + struct role_allowed_ip *ipp;
61168 + struct role_transition *trans;
61169 + unsigned int i;
61170 + int found = 0;
61171 + u32 curr_ip = current->signal->curr_ip;
61172 +
61173 + current->signal->saved_ip = curr_ip;
61174 +
61175 + /* check transition table */
61176 +
61177 + for (trans = current->role->transitions; trans; trans = trans->next) {
61178 + if (!strcmp(rolename, trans->rolename)) {
61179 + found = 1;
61180 + break;
61181 + }
61182 + }
61183 +
61184 + if (!found)
61185 + return 0;
61186 +
61187 + /* handle special roles that do not require authentication
61188 + and check ip */
61189 +
61190 + FOR_EACH_ROLE_START(r)
61191 + if (!strcmp(rolename, r->rolename) &&
61192 + (r->roletype & GR_ROLE_SPECIAL)) {
61193 + found = 0;
61194 + if (r->allowed_ips != NULL) {
61195 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
61196 + if ((ntohl(curr_ip) & ipp->netmask) ==
61197 + (ntohl(ipp->addr) & ipp->netmask))
61198 + found = 1;
61199 + }
61200 + } else
61201 + found = 2;
61202 + if (!found)
61203 + return 0;
61204 +
61205 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
61206 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
61207 + *salt = NULL;
61208 + *sum = NULL;
61209 + return 1;
61210 + }
61211 + }
61212 + FOR_EACH_ROLE_END(r)
61213 +
61214 + for (i = 0; i < num_sprole_pws; i++) {
61215 + if (!strcmp(rolename, acl_special_roles[i]->rolename)) {
61216 + *salt = acl_special_roles[i]->salt;
61217 + *sum = acl_special_roles[i]->sum;
61218 + return 1;
61219 + }
61220 + }
61221 +
61222 + return 0;
61223 +}
61224 +
61225 +static void
61226 +assign_special_role(char *rolename)
61227 +{
61228 + struct acl_object_label *obj;
61229 + struct acl_role_label *r;
61230 + struct acl_role_label *assigned = NULL;
61231 + struct task_struct *tsk;
61232 + struct file *filp;
61233 +
61234 + FOR_EACH_ROLE_START(r)
61235 + if (!strcmp(rolename, r->rolename) &&
61236 + (r->roletype & GR_ROLE_SPECIAL)) {
61237 + assigned = r;
61238 + break;
61239 + }
61240 + FOR_EACH_ROLE_END(r)
61241 +
61242 + if (!assigned)
61243 + return;
61244 +
61245 + read_lock(&tasklist_lock);
61246 + read_lock(&grsec_exec_file_lock);
61247 +
61248 + tsk = current->real_parent;
61249 + if (tsk == NULL)
61250 + goto out_unlock;
61251 +
61252 + filp = tsk->exec_file;
61253 + if (filp == NULL)
61254 + goto out_unlock;
61255 +
61256 + tsk->is_writable = 0;
61257 +
61258 + tsk->acl_sp_role = 1;
61259 + tsk->acl_role_id = ++acl_sp_role_value;
61260 + tsk->role = assigned;
61261 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
61262 +
61263 + /* ignore additional mmap checks for processes that are writable
61264 + by the default ACL */
61265 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61266 + if (unlikely(obj->mode & GR_WRITE))
61267 + tsk->is_writable = 1;
61268 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
61269 + if (unlikely(obj->mode & GR_WRITE))
61270 + tsk->is_writable = 1;
61271 +
61272 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
61273 + 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));
61274 +#endif
61275 +
61276 +out_unlock:
61277 + read_unlock(&grsec_exec_file_lock);
61278 + read_unlock(&tasklist_lock);
61279 + return;
61280 +}
61281 +
61282 +int gr_check_secure_terminal(struct task_struct *task)
61283 +{
61284 + struct task_struct *p, *p2, *p3;
61285 + struct files_struct *files;
61286 + struct fdtable *fdt;
61287 + struct file *our_file = NULL, *file;
61288 + int i;
61289 +
61290 + if (task->signal->tty == NULL)
61291 + return 1;
61292 +
61293 + files = get_files_struct(task);
61294 + if (files != NULL) {
61295 + rcu_read_lock();
61296 + fdt = files_fdtable(files);
61297 + for (i=0; i < fdt->max_fds; i++) {
61298 + file = fcheck_files(files, i);
61299 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
61300 + get_file(file);
61301 + our_file = file;
61302 + }
61303 + }
61304 + rcu_read_unlock();
61305 + put_files_struct(files);
61306 + }
61307 +
61308 + if (our_file == NULL)
61309 + return 1;
61310 +
61311 + read_lock(&tasklist_lock);
61312 + do_each_thread(p2, p) {
61313 + files = get_files_struct(p);
61314 + if (files == NULL ||
61315 + (p->signal && p->signal->tty == task->signal->tty)) {
61316 + if (files != NULL)
61317 + put_files_struct(files);
61318 + continue;
61319 + }
61320 + rcu_read_lock();
61321 + fdt = files_fdtable(files);
61322 + for (i=0; i < fdt->max_fds; i++) {
61323 + file = fcheck_files(files, i);
61324 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
61325 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
61326 + p3 = task;
61327 + while (task_pid_nr(p3) > 0) {
61328 + if (p3 == p)
61329 + break;
61330 + p3 = p3->real_parent;
61331 + }
61332 + if (p3 == p)
61333 + break;
61334 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
61335 + gr_handle_alertkill(p);
61336 + rcu_read_unlock();
61337 + put_files_struct(files);
61338 + read_unlock(&tasklist_lock);
61339 + fput(our_file);
61340 + return 0;
61341 + }
61342 + }
61343 + rcu_read_unlock();
61344 + put_files_struct(files);
61345 + } while_each_thread(p2, p);
61346 + read_unlock(&tasklist_lock);
61347 +
61348 + fput(our_file);
61349 + return 1;
61350 +}
61351 +
61352 +static int gr_rbac_disable(void *unused)
61353 +{
61354 + pax_open_kernel();
61355 + gr_status &= ~GR_READY;
61356 + pax_close_kernel();
61357 +
61358 + return 0;
61359 +}
61360 +
61361 +ssize_t
61362 +write_grsec_handler(struct file *file, const char * buf, size_t count, loff_t *ppos)
61363 +{
61364 + struct gr_arg_wrapper uwrap;
61365 + unsigned char *sprole_salt = NULL;
61366 + unsigned char *sprole_sum = NULL;
61367 + int error = sizeof (struct gr_arg_wrapper);
61368 + int error2 = 0;
61369 +
61370 + mutex_lock(&gr_dev_mutex);
61371 +
61372 + if ((gr_status & GR_READY) && !(current->acl->mode & GR_KERNELAUTH)) {
61373 + error = -EPERM;
61374 + goto out;
61375 + }
61376 +
61377 + if (count != sizeof (struct gr_arg_wrapper)) {
61378 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)sizeof(struct gr_arg_wrapper));
61379 + error = -EINVAL;
61380 + goto out;
61381 + }
61382 +
61383 +
61384 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
61385 + gr_auth_expires = 0;
61386 + gr_auth_attempts = 0;
61387 + }
61388 +
61389 + if (copy_from_user(&uwrap, buf, sizeof (struct gr_arg_wrapper))) {
61390 + error = -EFAULT;
61391 + goto out;
61392 + }
61393 +
61394 + if ((uwrap.version != GRSECURITY_VERSION) || (uwrap.size != sizeof(struct gr_arg))) {
61395 + error = -EINVAL;
61396 + goto out;
61397 + }
61398 +
61399 + if (copy_from_user(gr_usermode, uwrap.arg, sizeof (struct gr_arg))) {
61400 + error = -EFAULT;
61401 + goto out;
61402 + }
61403 +
61404 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
61405 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
61406 + time_after(gr_auth_expires, get_seconds())) {
61407 + error = -EBUSY;
61408 + goto out;
61409 + }
61410 +
61411 + /* if non-root trying to do anything other than use a special role,
61412 + do not attempt authentication, do not count towards authentication
61413 + locking
61414 + */
61415 +
61416 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
61417 + gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
61418 + gr_is_global_nonroot(current_uid())) {
61419 + error = -EPERM;
61420 + goto out;
61421 + }
61422 +
61423 + /* ensure pw and special role name are null terminated */
61424 +
61425 + gr_usermode->pw[GR_PW_LEN - 1] = '\0';
61426 + gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
61427 +
61428 + /* Okay.
61429 + * We have our enough of the argument structure..(we have yet
61430 + * to copy_from_user the tables themselves) . Copy the tables
61431 + * only if we need them, i.e. for loading operations. */
61432 +
61433 + switch (gr_usermode->mode) {
61434 + case GR_STATUS:
61435 + if (gr_status & GR_READY) {
61436 + error = 1;
61437 + if (!gr_check_secure_terminal(current))
61438 + error = 3;
61439 + } else
61440 + error = 2;
61441 + goto out;
61442 + case GR_SHUTDOWN:
61443 + if ((gr_status & GR_READY)
61444 + && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61445 + stop_machine(gr_rbac_disable, NULL, NULL);
61446 + free_variables();
61447 + memset(gr_usermode, 0, sizeof (struct gr_arg));
61448 + memset(gr_system_salt, 0, GR_SALT_LEN);
61449 + memset(gr_system_sum, 0, GR_SHA_LEN);
61450 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
61451 + } else if (gr_status & GR_READY) {
61452 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
61453 + error = -EPERM;
61454 + } else {
61455 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
61456 + error = -EAGAIN;
61457 + }
61458 + break;
61459 + case GR_ENABLE:
61460 + if (!(gr_status & GR_READY) && !(error2 = gracl_init(gr_usermode)))
61461 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
61462 + else {
61463 + if (gr_status & GR_READY)
61464 + error = -EAGAIN;
61465 + else
61466 + error = error2;
61467 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
61468 + }
61469 + break;
61470 + case GR_RELOAD:
61471 + if (!(gr_status & GR_READY)) {
61472 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
61473 + error = -EAGAIN;
61474 + } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61475 + stop_machine(gr_rbac_disable, NULL, NULL);
61476 + free_variables();
61477 + error2 = gracl_init(gr_usermode);
61478 + if (!error2)
61479 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
61480 + else {
61481 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
61482 + error = error2;
61483 + }
61484 + } else {
61485 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
61486 + error = -EPERM;
61487 + }
61488 + break;
61489 + case GR_SEGVMOD:
61490 + if (unlikely(!(gr_status & GR_READY))) {
61491 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
61492 + error = -EAGAIN;
61493 + break;
61494 + }
61495 +
61496 + if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
61497 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
61498 + if (gr_usermode->segv_device && gr_usermode->segv_inode) {
61499 + struct acl_subject_label *segvacl;
61500 + segvacl =
61501 + lookup_acl_subj_label(gr_usermode->segv_inode,
61502 + gr_usermode->segv_device,
61503 + current->role);
61504 + if (segvacl) {
61505 + segvacl->crashes = 0;
61506 + segvacl->expires = 0;
61507 + }
61508 + } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
61509 + gr_remove_uid(gr_usermode->segv_uid);
61510 + }
61511 + } else {
61512 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
61513 + error = -EPERM;
61514 + }
61515 + break;
61516 + case GR_SPROLE:
61517 + case GR_SPROLEPAM:
61518 + if (unlikely(!(gr_status & GR_READY))) {
61519 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
61520 + error = -EAGAIN;
61521 + break;
61522 + }
61523 +
61524 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
61525 + current->role->expires = 0;
61526 + current->role->auth_attempts = 0;
61527 + }
61528 +
61529 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
61530 + time_after(current->role->expires, get_seconds())) {
61531 + error = -EBUSY;
61532 + goto out;
61533 + }
61534 +
61535 + if (lookup_special_role_auth
61536 + (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
61537 + && ((!sprole_salt && !sprole_sum)
61538 + || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
61539 + char *p = "";
61540 + assign_special_role(gr_usermode->sp_role);
61541 + read_lock(&tasklist_lock);
61542 + if (current->real_parent)
61543 + p = current->real_parent->role->rolename;
61544 + read_unlock(&tasklist_lock);
61545 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
61546 + p, acl_sp_role_value);
61547 + } else {
61548 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
61549 + error = -EPERM;
61550 + if(!(current->role->auth_attempts++))
61551 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
61552 +
61553 + goto out;
61554 + }
61555 + break;
61556 + case GR_UNSPROLE:
61557 + if (unlikely(!(gr_status & GR_READY))) {
61558 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
61559 + error = -EAGAIN;
61560 + break;
61561 + }
61562 +
61563 + if (current->role->roletype & GR_ROLE_SPECIAL) {
61564 + char *p = "";
61565 + int i = 0;
61566 +
61567 + read_lock(&tasklist_lock);
61568 + if (current->real_parent) {
61569 + p = current->real_parent->role->rolename;
61570 + i = current->real_parent->acl_role_id;
61571 + }
61572 + read_unlock(&tasklist_lock);
61573 +
61574 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
61575 + gr_set_acls(1);
61576 + } else {
61577 + error = -EPERM;
61578 + goto out;
61579 + }
61580 + break;
61581 + default:
61582 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
61583 + error = -EINVAL;
61584 + break;
61585 + }
61586 +
61587 + if (error != -EPERM)
61588 + goto out;
61589 +
61590 + if(!(gr_auth_attempts++))
61591 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
61592 +
61593 + out:
61594 + mutex_unlock(&gr_dev_mutex);
61595 + return error;
61596 +}
61597 +
61598 +/* must be called with
61599 + rcu_read_lock();
61600 + read_lock(&tasklist_lock);
61601 + read_lock(&grsec_exec_file_lock);
61602 +*/
61603 +int gr_apply_subject_to_task(struct task_struct *task)
61604 +{
61605 + struct acl_object_label *obj;
61606 + char *tmpname;
61607 + struct acl_subject_label *tmpsubj;
61608 + struct file *filp;
61609 + struct name_entry *nmatch;
61610 +
61611 + filp = task->exec_file;
61612 + if (filp == NULL)
61613 + return 0;
61614 +
61615 + /* the following is to apply the correct subject
61616 + on binaries running when the RBAC system
61617 + is enabled, when the binaries have been
61618 + replaced or deleted since their execution
61619 + -----
61620 + when the RBAC system starts, the inode/dev
61621 + from exec_file will be one the RBAC system
61622 + is unaware of. It only knows the inode/dev
61623 + of the present file on disk, or the absence
61624 + of it.
61625 + */
61626 + preempt_disable();
61627 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
61628 +
61629 + nmatch = lookup_name_entry(tmpname);
61630 + preempt_enable();
61631 + tmpsubj = NULL;
61632 + if (nmatch) {
61633 + if (nmatch->deleted)
61634 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
61635 + else
61636 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
61637 + if (tmpsubj != NULL)
61638 + task->acl = tmpsubj;
61639 + }
61640 + if (tmpsubj == NULL)
61641 + task->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
61642 + task->role);
61643 + if (task->acl) {
61644 + task->is_writable = 0;
61645 + /* ignore additional mmap checks for processes that are writable
61646 + by the default ACL */
61647 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61648 + if (unlikely(obj->mode & GR_WRITE))
61649 + task->is_writable = 1;
61650 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
61651 + if (unlikely(obj->mode & GR_WRITE))
61652 + task->is_writable = 1;
61653 +
61654 + gr_set_proc_res(task);
61655 +
61656 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
61657 + 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);
61658 +#endif
61659 + } else {
61660 + return 1;
61661 + }
61662 +
61663 + return 0;
61664 +}
61665 +
61666 +int
61667 +gr_set_acls(const int type)
61668 +{
61669 + struct task_struct *task, *task2;
61670 + struct acl_role_label *role = current->role;
61671 + __u16 acl_role_id = current->acl_role_id;
61672 + const struct cred *cred;
61673 + int ret;
61674 +
61675 + rcu_read_lock();
61676 + read_lock(&tasklist_lock);
61677 + read_lock(&grsec_exec_file_lock);
61678 + do_each_thread(task2, task) {
61679 + /* check to see if we're called from the exit handler,
61680 + if so, only replace ACLs that have inherited the admin
61681 + ACL */
61682 +
61683 + if (type && (task->role != role ||
61684 + task->acl_role_id != acl_role_id))
61685 + continue;
61686 +
61687 + task->acl_role_id = 0;
61688 + task->acl_sp_role = 0;
61689 +
61690 + if (task->exec_file) {
61691 + cred = __task_cred(task);
61692 + task->role = lookup_acl_role_label(task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
61693 + ret = gr_apply_subject_to_task(task);
61694 + if (ret) {
61695 + read_unlock(&grsec_exec_file_lock);
61696 + read_unlock(&tasklist_lock);
61697 + rcu_read_unlock();
61698 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
61699 + return ret;
61700 + }
61701 + } else {
61702 + // it's a kernel process
61703 + task->role = kernel_role;
61704 + task->acl = kernel_role->root_label;
61705 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
61706 + task->acl->mode &= ~GR_PROCFIND;
61707 +#endif
61708 + }
61709 + } while_each_thread(task2, task);
61710 + read_unlock(&grsec_exec_file_lock);
61711 + read_unlock(&tasklist_lock);
61712 + rcu_read_unlock();
61713 +
61714 + return 0;
61715 +}
61716 +
61717 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
61718 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
61719 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
61720 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
61721 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
61722 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
61723 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
61724 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
61725 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
61726 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
61727 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
61728 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
61729 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
61730 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
61731 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
61732 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
61733 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
61734 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
61735 +};
61736 +
61737 +void
61738 +gr_learn_resource(const struct task_struct *task,
61739 + const int res, const unsigned long wanted, const int gt)
61740 +{
61741 + struct acl_subject_label *acl;
61742 + const struct cred *cred;
61743 +
61744 + if (unlikely((gr_status & GR_READY) &&
61745 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
61746 + goto skip_reslog;
61747 +
61748 + gr_log_resource(task, res, wanted, gt);
61749 +skip_reslog:
61750 +
61751 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
61752 + return;
61753 +
61754 + acl = task->acl;
61755 +
61756 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
61757 + !(acl->resmask & (1U << (unsigned short) res))))
61758 + return;
61759 +
61760 + if (wanted >= acl->res[res].rlim_cur) {
61761 + unsigned long res_add;
61762 +
61763 + res_add = wanted + res_learn_bumps[res];
61764 +
61765 + acl->res[res].rlim_cur = res_add;
61766 +
61767 + if (wanted > acl->res[res].rlim_max)
61768 + acl->res[res].rlim_max = res_add;
61769 +
61770 + /* only log the subject filename, since resource logging is supported for
61771 + single-subject learning only */
61772 + rcu_read_lock();
61773 + cred = __task_cred(task);
61774 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
61775 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
61776 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
61777 + "", (unsigned long) res, &task->signal->saved_ip);
61778 + rcu_read_unlock();
61779 + }
61780 +
61781 + return;
61782 +}
61783 +EXPORT_SYMBOL(gr_learn_resource);
61784 +#endif
61785 +
61786 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
61787 +void
61788 +pax_set_initial_flags(struct linux_binprm *bprm)
61789 +{
61790 + struct task_struct *task = current;
61791 + struct acl_subject_label *proc;
61792 + unsigned long flags;
61793 +
61794 + if (unlikely(!(gr_status & GR_READY)))
61795 + return;
61796 +
61797 + flags = pax_get_flags(task);
61798 +
61799 + proc = task->acl;
61800 +
61801 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
61802 + flags &= ~MF_PAX_PAGEEXEC;
61803 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
61804 + flags &= ~MF_PAX_SEGMEXEC;
61805 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
61806 + flags &= ~MF_PAX_RANDMMAP;
61807 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
61808 + flags &= ~MF_PAX_EMUTRAMP;
61809 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
61810 + flags &= ~MF_PAX_MPROTECT;
61811 +
61812 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
61813 + flags |= MF_PAX_PAGEEXEC;
61814 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
61815 + flags |= MF_PAX_SEGMEXEC;
61816 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
61817 + flags |= MF_PAX_RANDMMAP;
61818 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
61819 + flags |= MF_PAX_EMUTRAMP;
61820 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
61821 + flags |= MF_PAX_MPROTECT;
61822 +
61823 + pax_set_flags(task, flags);
61824 +
61825 + return;
61826 +}
61827 +#endif
61828 +
61829 +int
61830 +gr_handle_proc_ptrace(struct task_struct *task)
61831 +{
61832 + struct file *filp;
61833 + struct task_struct *tmp = task;
61834 + struct task_struct *curtemp = current;
61835 + __u32 retmode;
61836 +
61837 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
61838 + if (unlikely(!(gr_status & GR_READY)))
61839 + return 0;
61840 +#endif
61841 +
61842 + read_lock(&tasklist_lock);
61843 + read_lock(&grsec_exec_file_lock);
61844 + filp = task->exec_file;
61845 +
61846 + while (task_pid_nr(tmp) > 0) {
61847 + if (tmp == curtemp)
61848 + break;
61849 + tmp = tmp->real_parent;
61850 + }
61851 +
61852 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
61853 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
61854 + read_unlock(&grsec_exec_file_lock);
61855 + read_unlock(&tasklist_lock);
61856 + return 1;
61857 + }
61858 +
61859 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
61860 + if (!(gr_status & GR_READY)) {
61861 + read_unlock(&grsec_exec_file_lock);
61862 + read_unlock(&tasklist_lock);
61863 + return 0;
61864 + }
61865 +#endif
61866 +
61867 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
61868 + read_unlock(&grsec_exec_file_lock);
61869 + read_unlock(&tasklist_lock);
61870 +
61871 + if (retmode & GR_NOPTRACE)
61872 + return 1;
61873 +
61874 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
61875 + && (current->acl != task->acl || (current->acl != current->role->root_label
61876 + && task_pid_nr(current) != task_pid_nr(task))))
61877 + return 1;
61878 +
61879 + return 0;
61880 +}
61881 +
61882 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
61883 +{
61884 + if (unlikely(!(gr_status & GR_READY)))
61885 + return;
61886 +
61887 + if (!(current->role->roletype & GR_ROLE_GOD))
61888 + return;
61889 +
61890 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
61891 + p->role->rolename, gr_task_roletype_to_char(p),
61892 + p->acl->filename);
61893 +}
61894 +
61895 +int
61896 +gr_handle_ptrace(struct task_struct *task, const long request)
61897 +{
61898 + struct task_struct *tmp = task;
61899 + struct task_struct *curtemp = current;
61900 + __u32 retmode;
61901 +
61902 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
61903 + if (unlikely(!(gr_status & GR_READY)))
61904 + return 0;
61905 +#endif
61906 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
61907 + read_lock(&tasklist_lock);
61908 + while (task_pid_nr(tmp) > 0) {
61909 + if (tmp == curtemp)
61910 + break;
61911 + tmp = tmp->real_parent;
61912 + }
61913 +
61914 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
61915 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
61916 + read_unlock(&tasklist_lock);
61917 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61918 + return 1;
61919 + }
61920 + read_unlock(&tasklist_lock);
61921 + }
61922 +
61923 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
61924 + if (!(gr_status & GR_READY))
61925 + return 0;
61926 +#endif
61927 +
61928 + read_lock(&grsec_exec_file_lock);
61929 + if (unlikely(!task->exec_file)) {
61930 + read_unlock(&grsec_exec_file_lock);
61931 + return 0;
61932 + }
61933 +
61934 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
61935 + read_unlock(&grsec_exec_file_lock);
61936 +
61937 + if (retmode & GR_NOPTRACE) {
61938 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61939 + return 1;
61940 + }
61941 +
61942 + if (retmode & GR_PTRACERD) {
61943 + switch (request) {
61944 + case PTRACE_SEIZE:
61945 + case PTRACE_POKETEXT:
61946 + case PTRACE_POKEDATA:
61947 + case PTRACE_POKEUSR:
61948 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
61949 + case PTRACE_SETREGS:
61950 + case PTRACE_SETFPREGS:
61951 +#endif
61952 +#ifdef CONFIG_X86
61953 + case PTRACE_SETFPXREGS:
61954 +#endif
61955 +#ifdef CONFIG_ALTIVEC
61956 + case PTRACE_SETVRREGS:
61957 +#endif
61958 + return 1;
61959 + default:
61960 + return 0;
61961 + }
61962 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
61963 + !(current->role->roletype & GR_ROLE_GOD) &&
61964 + (current->acl != task->acl)) {
61965 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
61966 + return 1;
61967 + }
61968 +
61969 + return 0;
61970 +}
61971 +
61972 +static int is_writable_mmap(const struct file *filp)
61973 +{
61974 + struct task_struct *task = current;
61975 + struct acl_object_label *obj, *obj2;
61976 +
61977 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
61978 + !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))) {
61979 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
61980 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
61981 + task->role->root_label);
61982 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
61983 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
61984 + return 1;
61985 + }
61986 + }
61987 + return 0;
61988 +}
61989 +
61990 +int
61991 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
61992 +{
61993 + __u32 mode;
61994 +
61995 + if (unlikely(!file || !(prot & PROT_EXEC)))
61996 + return 1;
61997 +
61998 + if (is_writable_mmap(file))
61999 + return 0;
62000 +
62001 + mode =
62002 + gr_search_file(file->f_path.dentry,
62003 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
62004 + file->f_path.mnt);
62005 +
62006 + if (!gr_tpe_allow(file))
62007 + return 0;
62008 +
62009 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
62010 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
62011 + return 0;
62012 + } else if (unlikely(!(mode & GR_EXEC))) {
62013 + return 0;
62014 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
62015 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
62016 + return 1;
62017 + }
62018 +
62019 + return 1;
62020 +}
62021 +
62022 +int
62023 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
62024 +{
62025 + __u32 mode;
62026 +
62027 + if (unlikely(!file || !(prot & PROT_EXEC)))
62028 + return 1;
62029 +
62030 + if (is_writable_mmap(file))
62031 + return 0;
62032 +
62033 + mode =
62034 + gr_search_file(file->f_path.dentry,
62035 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
62036 + file->f_path.mnt);
62037 +
62038 + if (!gr_tpe_allow(file))
62039 + return 0;
62040 +
62041 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
62042 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
62043 + return 0;
62044 + } else if (unlikely(!(mode & GR_EXEC))) {
62045 + return 0;
62046 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
62047 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
62048 + return 1;
62049 + }
62050 +
62051 + return 1;
62052 +}
62053 +
62054 +void
62055 +gr_acl_handle_psacct(struct task_struct *task, const long code)
62056 +{
62057 + unsigned long runtime;
62058 + unsigned long cputime;
62059 + unsigned int wday, cday;
62060 + __u8 whr, chr;
62061 + __u8 wmin, cmin;
62062 + __u8 wsec, csec;
62063 + struct timespec timeval;
62064 +
62065 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
62066 + !(task->acl->mode & GR_PROCACCT)))
62067 + return;
62068 +
62069 + do_posix_clock_monotonic_gettime(&timeval);
62070 + runtime = timeval.tv_sec - task->start_time.tv_sec;
62071 + wday = runtime / (3600 * 24);
62072 + runtime -= wday * (3600 * 24);
62073 + whr = runtime / 3600;
62074 + runtime -= whr * 3600;
62075 + wmin = runtime / 60;
62076 + runtime -= wmin * 60;
62077 + wsec = runtime;
62078 +
62079 + cputime = (task->utime + task->stime) / HZ;
62080 + cday = cputime / (3600 * 24);
62081 + cputime -= cday * (3600 * 24);
62082 + chr = cputime / 3600;
62083 + cputime -= chr * 3600;
62084 + cmin = cputime / 60;
62085 + cputime -= cmin * 60;
62086 + csec = cputime;
62087 +
62088 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
62089 +
62090 + return;
62091 +}
62092 +
62093 +void gr_set_kernel_label(struct task_struct *task)
62094 +{
62095 + if (gr_status & GR_READY) {
62096 + task->role = kernel_role;
62097 + task->acl = kernel_role->root_label;
62098 + }
62099 + return;
62100 +}
62101 +
62102 +#ifdef CONFIG_TASKSTATS
62103 +int gr_is_taskstats_denied(int pid)
62104 +{
62105 + struct task_struct *task;
62106 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62107 + const struct cred *cred;
62108 +#endif
62109 + int ret = 0;
62110 +
62111 + /* restrict taskstats viewing to un-chrooted root users
62112 + who have the 'view' subject flag if the RBAC system is enabled
62113 + */
62114 +
62115 + rcu_read_lock();
62116 + read_lock(&tasklist_lock);
62117 + task = find_task_by_vpid(pid);
62118 + if (task) {
62119 +#ifdef CONFIG_GRKERNSEC_CHROOT
62120 + if (proc_is_chrooted(task))
62121 + ret = -EACCES;
62122 +#endif
62123 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62124 + cred = __task_cred(task);
62125 +#ifdef CONFIG_GRKERNSEC_PROC_USER
62126 + if (gr_is_global_nonroot(cred->uid))
62127 + ret = -EACCES;
62128 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
62129 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
62130 + ret = -EACCES;
62131 +#endif
62132 +#endif
62133 + if (gr_status & GR_READY) {
62134 + if (!(task->acl->mode & GR_VIEW))
62135 + ret = -EACCES;
62136 + }
62137 + } else
62138 + ret = -ENOENT;
62139 +
62140 + read_unlock(&tasklist_lock);
62141 + rcu_read_unlock();
62142 +
62143 + return ret;
62144 +}
62145 +#endif
62146 +
62147 +/* AUXV entries are filled via a descendant of search_binary_handler
62148 + after we've already applied the subject for the target
62149 +*/
62150 +int gr_acl_enable_at_secure(void)
62151 +{
62152 + if (unlikely(!(gr_status & GR_READY)))
62153 + return 0;
62154 +
62155 + if (current->acl->mode & GR_ATSECURE)
62156 + return 1;
62157 +
62158 + return 0;
62159 +}
62160 +
62161 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
62162 +{
62163 + struct task_struct *task = current;
62164 + struct dentry *dentry = file->f_path.dentry;
62165 + struct vfsmount *mnt = file->f_path.mnt;
62166 + struct acl_object_label *obj, *tmp;
62167 + struct acl_subject_label *subj;
62168 + unsigned int bufsize;
62169 + int is_not_root;
62170 + char *path;
62171 + dev_t dev = __get_dev(dentry);
62172 +
62173 + if (unlikely(!(gr_status & GR_READY)))
62174 + return 1;
62175 +
62176 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
62177 + return 1;
62178 +
62179 + /* ignore Eric Biederman */
62180 + if (IS_PRIVATE(dentry->d_inode))
62181 + return 1;
62182 +
62183 + subj = task->acl;
62184 + read_lock(&gr_inode_lock);
62185 + do {
62186 + obj = lookup_acl_obj_label(ino, dev, subj);
62187 + if (obj != NULL) {
62188 + read_unlock(&gr_inode_lock);
62189 + return (obj->mode & GR_FIND) ? 1 : 0;
62190 + }
62191 + } while ((subj = subj->parent_subject));
62192 + read_unlock(&gr_inode_lock);
62193 +
62194 + /* this is purely an optimization since we're looking for an object
62195 + for the directory we're doing a readdir on
62196 + if it's possible for any globbed object to match the entry we're
62197 + filling into the directory, then the object we find here will be
62198 + an anchor point with attached globbed objects
62199 + */
62200 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
62201 + if (obj->globbed == NULL)
62202 + return (obj->mode & GR_FIND) ? 1 : 0;
62203 +
62204 + is_not_root = ((obj->filename[0] == '/') &&
62205 + (obj->filename[1] == '\0')) ? 0 : 1;
62206 + bufsize = PAGE_SIZE - namelen - is_not_root;
62207 +
62208 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
62209 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
62210 + return 1;
62211 +
62212 + preempt_disable();
62213 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
62214 + bufsize);
62215 +
62216 + bufsize = strlen(path);
62217 +
62218 + /* if base is "/", don't append an additional slash */
62219 + if (is_not_root)
62220 + *(path + bufsize) = '/';
62221 + memcpy(path + bufsize + is_not_root, name, namelen);
62222 + *(path + bufsize + namelen + is_not_root) = '\0';
62223 +
62224 + tmp = obj->globbed;
62225 + while (tmp) {
62226 + if (!glob_match(tmp->filename, path)) {
62227 + preempt_enable();
62228 + return (tmp->mode & GR_FIND) ? 1 : 0;
62229 + }
62230 + tmp = tmp->next;
62231 + }
62232 + preempt_enable();
62233 + return (obj->mode & GR_FIND) ? 1 : 0;
62234 +}
62235 +
62236 +void gr_put_exec_file(struct task_struct *task)
62237 +{
62238 + struct file *filp;
62239 +
62240 + write_lock(&grsec_exec_file_lock);
62241 + filp = task->exec_file;
62242 + task->exec_file = NULL;
62243 + write_unlock(&grsec_exec_file_lock);
62244 +
62245 + if (filp)
62246 + fput(filp);
62247 +
62248 + return;
62249 +}
62250 +
62251 +
62252 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
62253 +EXPORT_SYMBOL(gr_acl_is_enabled);
62254 +#endif
62255 +EXPORT_SYMBOL(gr_set_kernel_label);
62256 +#ifdef CONFIG_SECURITY
62257 +EXPORT_SYMBOL(gr_check_user_change);
62258 +EXPORT_SYMBOL(gr_check_group_change);
62259 +#endif
62260 +
62261 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
62262 new file mode 100644
62263 index 0000000..34fefda
62264 --- /dev/null
62265 +++ b/grsecurity/gracl_alloc.c
62266 @@ -0,0 +1,105 @@
62267 +#include <linux/kernel.h>
62268 +#include <linux/mm.h>
62269 +#include <linux/slab.h>
62270 +#include <linux/vmalloc.h>
62271 +#include <linux/gracl.h>
62272 +#include <linux/grsecurity.h>
62273 +
62274 +static unsigned long alloc_stack_next = 1;
62275 +static unsigned long alloc_stack_size = 1;
62276 +static void **alloc_stack;
62277 +
62278 +static __inline__ int
62279 +alloc_pop(void)
62280 +{
62281 + if (alloc_stack_next == 1)
62282 + return 0;
62283 +
62284 + kfree(alloc_stack[alloc_stack_next - 2]);
62285 +
62286 + alloc_stack_next--;
62287 +
62288 + return 1;
62289 +}
62290 +
62291 +static __inline__ int
62292 +alloc_push(void *buf)
62293 +{
62294 + if (alloc_stack_next >= alloc_stack_size)
62295 + return 1;
62296 +
62297 + alloc_stack[alloc_stack_next - 1] = buf;
62298 +
62299 + alloc_stack_next++;
62300 +
62301 + return 0;
62302 +}
62303 +
62304 +void *
62305 +acl_alloc(unsigned long len)
62306 +{
62307 + void *ret = NULL;
62308 +
62309 + if (!len || len > PAGE_SIZE)
62310 + goto out;
62311 +
62312 + ret = kmalloc(len, GFP_KERNEL);
62313 +
62314 + if (ret) {
62315 + if (alloc_push(ret)) {
62316 + kfree(ret);
62317 + ret = NULL;
62318 + }
62319 + }
62320 +
62321 +out:
62322 + return ret;
62323 +}
62324 +
62325 +void *
62326 +acl_alloc_num(unsigned long num, unsigned long len)
62327 +{
62328 + if (!len || (num > (PAGE_SIZE / len)))
62329 + return NULL;
62330 +
62331 + return acl_alloc(num * len);
62332 +}
62333 +
62334 +void
62335 +acl_free_all(void)
62336 +{
62337 + if (gr_acl_is_enabled() || !alloc_stack)
62338 + return;
62339 +
62340 + while (alloc_pop()) ;
62341 +
62342 + if (alloc_stack) {
62343 + if ((alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
62344 + kfree(alloc_stack);
62345 + else
62346 + vfree(alloc_stack);
62347 + }
62348 +
62349 + alloc_stack = NULL;
62350 + alloc_stack_size = 1;
62351 + alloc_stack_next = 1;
62352 +
62353 + return;
62354 +}
62355 +
62356 +int
62357 +acl_alloc_stack_init(unsigned long size)
62358 +{
62359 + if ((size * sizeof (void *)) <= PAGE_SIZE)
62360 + alloc_stack =
62361 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
62362 + else
62363 + alloc_stack = (void **) vmalloc(size * sizeof (void *));
62364 +
62365 + alloc_stack_size = size;
62366 +
62367 + if (!alloc_stack)
62368 + return 0;
62369 + else
62370 + return 1;
62371 +}
62372 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
62373 new file mode 100644
62374 index 0000000..bdd51ea
62375 --- /dev/null
62376 +++ b/grsecurity/gracl_cap.c
62377 @@ -0,0 +1,110 @@
62378 +#include <linux/kernel.h>
62379 +#include <linux/module.h>
62380 +#include <linux/sched.h>
62381 +#include <linux/gracl.h>
62382 +#include <linux/grsecurity.h>
62383 +#include <linux/grinternal.h>
62384 +
62385 +extern const char *captab_log[];
62386 +extern int captab_log_entries;
62387 +
62388 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
62389 +{
62390 + struct acl_subject_label *curracl;
62391 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
62392 + kernel_cap_t cap_audit = __cap_empty_set;
62393 +
62394 + if (!gr_acl_is_enabled())
62395 + return 1;
62396 +
62397 + curracl = task->acl;
62398 +
62399 + cap_drop = curracl->cap_lower;
62400 + cap_mask = curracl->cap_mask;
62401 + cap_audit = curracl->cap_invert_audit;
62402 +
62403 + while ((curracl = curracl->parent_subject)) {
62404 + /* if the cap isn't specified in the current computed mask but is specified in the
62405 + current level subject, and is lowered in the current level subject, then add
62406 + it to the set of dropped capabilities
62407 + otherwise, add the current level subject's mask to the current computed mask
62408 + */
62409 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
62410 + cap_raise(cap_mask, cap);
62411 + if (cap_raised(curracl->cap_lower, cap))
62412 + cap_raise(cap_drop, cap);
62413 + if (cap_raised(curracl->cap_invert_audit, cap))
62414 + cap_raise(cap_audit, cap);
62415 + }
62416 + }
62417 +
62418 + if (!cap_raised(cap_drop, cap)) {
62419 + if (cap_raised(cap_audit, cap))
62420 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
62421 + return 1;
62422 + }
62423 +
62424 + curracl = task->acl;
62425 +
62426 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
62427 + && cap_raised(cred->cap_effective, cap)) {
62428 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
62429 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
62430 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
62431 + gr_to_filename(task->exec_file->f_path.dentry,
62432 + task->exec_file->f_path.mnt) : curracl->filename,
62433 + curracl->filename, 0UL,
62434 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
62435 + return 1;
62436 + }
62437 +
62438 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
62439 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
62440 +
62441 + return 0;
62442 +}
62443 +
62444 +int
62445 +gr_acl_is_capable(const int cap)
62446 +{
62447 + return gr_task_acl_is_capable(current, current_cred(), cap);
62448 +}
62449 +
62450 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
62451 +{
62452 + struct acl_subject_label *curracl;
62453 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
62454 +
62455 + if (!gr_acl_is_enabled())
62456 + return 1;
62457 +
62458 + curracl = task->acl;
62459 +
62460 + cap_drop = curracl->cap_lower;
62461 + cap_mask = curracl->cap_mask;
62462 +
62463 + while ((curracl = curracl->parent_subject)) {
62464 + /* if the cap isn't specified in the current computed mask but is specified in the
62465 + current level subject, and is lowered in the current level subject, then add
62466 + it to the set of dropped capabilities
62467 + otherwise, add the current level subject's mask to the current computed mask
62468 + */
62469 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
62470 + cap_raise(cap_mask, cap);
62471 + if (cap_raised(curracl->cap_lower, cap))
62472 + cap_raise(cap_drop, cap);
62473 + }
62474 + }
62475 +
62476 + if (!cap_raised(cap_drop, cap))
62477 + return 1;
62478 +
62479 + return 0;
62480 +}
62481 +
62482 +int
62483 +gr_acl_is_capable_nolog(const int cap)
62484 +{
62485 + return gr_task_acl_is_capable_nolog(current, cap);
62486 +}
62487 +
62488 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
62489 new file mode 100644
62490 index 0000000..a340c17
62491 --- /dev/null
62492 +++ b/grsecurity/gracl_fs.c
62493 @@ -0,0 +1,431 @@
62494 +#include <linux/kernel.h>
62495 +#include <linux/sched.h>
62496 +#include <linux/types.h>
62497 +#include <linux/fs.h>
62498 +#include <linux/file.h>
62499 +#include <linux/stat.h>
62500 +#include <linux/grsecurity.h>
62501 +#include <linux/grinternal.h>
62502 +#include <linux/gracl.h>
62503 +
62504 +umode_t
62505 +gr_acl_umask(void)
62506 +{
62507 + if (unlikely(!gr_acl_is_enabled()))
62508 + return 0;
62509 +
62510 + return current->role->umask;
62511 +}
62512 +
62513 +__u32
62514 +gr_acl_handle_hidden_file(const struct dentry * dentry,
62515 + const struct vfsmount * mnt)
62516 +{
62517 + __u32 mode;
62518 +
62519 + if (unlikely(!dentry->d_inode))
62520 + return GR_FIND;
62521 +
62522 + mode =
62523 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
62524 +
62525 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
62526 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
62527 + return mode;
62528 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
62529 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
62530 + return 0;
62531 + } else if (unlikely(!(mode & GR_FIND)))
62532 + return 0;
62533 +
62534 + return GR_FIND;
62535 +}
62536 +
62537 +__u32
62538 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
62539 + int acc_mode)
62540 +{
62541 + __u32 reqmode = GR_FIND;
62542 + __u32 mode;
62543 +
62544 + if (unlikely(!dentry->d_inode))
62545 + return reqmode;
62546 +
62547 + if (acc_mode & MAY_APPEND)
62548 + reqmode |= GR_APPEND;
62549 + else if (acc_mode & MAY_WRITE)
62550 + reqmode |= GR_WRITE;
62551 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
62552 + reqmode |= GR_READ;
62553 +
62554 + mode =
62555 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
62556 + mnt);
62557 +
62558 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62559 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
62560 + reqmode & GR_READ ? " reading" : "",
62561 + reqmode & GR_WRITE ? " writing" : reqmode &
62562 + GR_APPEND ? " appending" : "");
62563 + return reqmode;
62564 + } else
62565 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62566 + {
62567 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
62568 + reqmode & GR_READ ? " reading" : "",
62569 + reqmode & GR_WRITE ? " writing" : reqmode &
62570 + GR_APPEND ? " appending" : "");
62571 + return 0;
62572 + } else if (unlikely((mode & reqmode) != reqmode))
62573 + return 0;
62574 +
62575 + return reqmode;
62576 +}
62577 +
62578 +__u32
62579 +gr_acl_handle_creat(const struct dentry * dentry,
62580 + const struct dentry * p_dentry,
62581 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
62582 + const int imode)
62583 +{
62584 + __u32 reqmode = GR_WRITE | GR_CREATE;
62585 + __u32 mode;
62586 +
62587 + if (acc_mode & MAY_APPEND)
62588 + reqmode |= GR_APPEND;
62589 + // if a directory was required or the directory already exists, then
62590 + // don't count this open as a read
62591 + if ((acc_mode & MAY_READ) &&
62592 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
62593 + reqmode |= GR_READ;
62594 + if ((open_flags & O_CREAT) &&
62595 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
62596 + reqmode |= GR_SETID;
62597 +
62598 + mode =
62599 + gr_check_create(dentry, p_dentry, p_mnt,
62600 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
62601 +
62602 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62603 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
62604 + reqmode & GR_READ ? " reading" : "",
62605 + reqmode & GR_WRITE ? " writing" : reqmode &
62606 + GR_APPEND ? " appending" : "");
62607 + return reqmode;
62608 + } else
62609 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62610 + {
62611 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
62612 + reqmode & GR_READ ? " reading" : "",
62613 + reqmode & GR_WRITE ? " writing" : reqmode &
62614 + GR_APPEND ? " appending" : "");
62615 + return 0;
62616 + } else if (unlikely((mode & reqmode) != reqmode))
62617 + return 0;
62618 +
62619 + return reqmode;
62620 +}
62621 +
62622 +__u32
62623 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
62624 + const int fmode)
62625 +{
62626 + __u32 mode, reqmode = GR_FIND;
62627 +
62628 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
62629 + reqmode |= GR_EXEC;
62630 + if (fmode & S_IWOTH)
62631 + reqmode |= GR_WRITE;
62632 + if (fmode & S_IROTH)
62633 + reqmode |= GR_READ;
62634 +
62635 + mode =
62636 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
62637 + mnt);
62638 +
62639 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
62640 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
62641 + reqmode & GR_READ ? " reading" : "",
62642 + reqmode & GR_WRITE ? " writing" : "",
62643 + reqmode & GR_EXEC ? " executing" : "");
62644 + return reqmode;
62645 + } else
62646 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
62647 + {
62648 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
62649 + reqmode & GR_READ ? " reading" : "",
62650 + reqmode & GR_WRITE ? " writing" : "",
62651 + reqmode & GR_EXEC ? " executing" : "");
62652 + return 0;
62653 + } else if (unlikely((mode & reqmode) != reqmode))
62654 + return 0;
62655 +
62656 + return reqmode;
62657 +}
62658 +
62659 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
62660 +{
62661 + __u32 mode;
62662 +
62663 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
62664 +
62665 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
62666 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
62667 + return mode;
62668 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
62669 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
62670 + return 0;
62671 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
62672 + return 0;
62673 +
62674 + return (reqmode);
62675 +}
62676 +
62677 +__u32
62678 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
62679 +{
62680 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
62681 +}
62682 +
62683 +__u32
62684 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
62685 +{
62686 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
62687 +}
62688 +
62689 +__u32
62690 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
62691 +{
62692 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
62693 +}
62694 +
62695 +__u32
62696 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
62697 +{
62698 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
62699 +}
62700 +
62701 +__u32
62702 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
62703 + umode_t *modeptr)
62704 +{
62705 + umode_t mode;
62706 +
62707 + *modeptr &= ~gr_acl_umask();
62708 + mode = *modeptr;
62709 +
62710 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
62711 + return 1;
62712 +
62713 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
62714 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
62715 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
62716 + GR_CHMOD_ACL_MSG);
62717 + } else {
62718 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
62719 + }
62720 +}
62721 +
62722 +__u32
62723 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
62724 +{
62725 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
62726 +}
62727 +
62728 +__u32
62729 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
62730 +{
62731 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
62732 +}
62733 +
62734 +__u32
62735 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
62736 +{
62737 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
62738 +}
62739 +
62740 +__u32
62741 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
62742 +{
62743 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
62744 + GR_UNIXCONNECT_ACL_MSG);
62745 +}
62746 +
62747 +/* hardlinks require at minimum create and link permission,
62748 + any additional privilege required is based on the
62749 + privilege of the file being linked to
62750 +*/
62751 +__u32
62752 +gr_acl_handle_link(const struct dentry * new_dentry,
62753 + const struct dentry * parent_dentry,
62754 + const struct vfsmount * parent_mnt,
62755 + const struct dentry * old_dentry,
62756 + const struct vfsmount * old_mnt, const struct filename *to)
62757 +{
62758 + __u32 mode;
62759 + __u32 needmode = GR_CREATE | GR_LINK;
62760 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
62761 +
62762 + mode =
62763 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
62764 + old_mnt);
62765 +
62766 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
62767 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
62768 + return mode;
62769 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
62770 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
62771 + return 0;
62772 + } else if (unlikely((mode & needmode) != needmode))
62773 + return 0;
62774 +
62775 + return 1;
62776 +}
62777 +
62778 +__u32
62779 +gr_acl_handle_symlink(const struct dentry * new_dentry,
62780 + const struct dentry * parent_dentry,
62781 + const struct vfsmount * parent_mnt, const struct filename *from)
62782 +{
62783 + __u32 needmode = GR_WRITE | GR_CREATE;
62784 + __u32 mode;
62785 +
62786 + mode =
62787 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
62788 + GR_CREATE | GR_AUDIT_CREATE |
62789 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
62790 +
62791 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
62792 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
62793 + return mode;
62794 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
62795 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
62796 + return 0;
62797 + } else if (unlikely((mode & needmode) != needmode))
62798 + return 0;
62799 +
62800 + return (GR_WRITE | GR_CREATE);
62801 +}
62802 +
62803 +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)
62804 +{
62805 + __u32 mode;
62806 +
62807 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
62808 +
62809 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
62810 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
62811 + return mode;
62812 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
62813 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
62814 + return 0;
62815 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
62816 + return 0;
62817 +
62818 + return (reqmode);
62819 +}
62820 +
62821 +__u32
62822 +gr_acl_handle_mknod(const struct dentry * new_dentry,
62823 + const struct dentry * parent_dentry,
62824 + const struct vfsmount * parent_mnt,
62825 + const int mode)
62826 +{
62827 + __u32 reqmode = GR_WRITE | GR_CREATE;
62828 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
62829 + reqmode |= GR_SETID;
62830 +
62831 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
62832 + reqmode, GR_MKNOD_ACL_MSG);
62833 +}
62834 +
62835 +__u32
62836 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
62837 + const struct dentry *parent_dentry,
62838 + const struct vfsmount *parent_mnt)
62839 +{
62840 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
62841 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
62842 +}
62843 +
62844 +#define RENAME_CHECK_SUCCESS(old, new) \
62845 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
62846 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
62847 +
62848 +int
62849 +gr_acl_handle_rename(struct dentry *new_dentry,
62850 + struct dentry *parent_dentry,
62851 + const struct vfsmount *parent_mnt,
62852 + struct dentry *old_dentry,
62853 + struct inode *old_parent_inode,
62854 + struct vfsmount *old_mnt, const struct filename *newname)
62855 +{
62856 + __u32 comp1, comp2;
62857 + int error = 0;
62858 +
62859 + if (unlikely(!gr_acl_is_enabled()))
62860 + return 0;
62861 +
62862 + if (!new_dentry->d_inode) {
62863 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
62864 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
62865 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
62866 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
62867 + GR_DELETE | GR_AUDIT_DELETE |
62868 + GR_AUDIT_READ | GR_AUDIT_WRITE |
62869 + GR_SUPPRESS, old_mnt);
62870 + } else {
62871 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
62872 + GR_CREATE | GR_DELETE |
62873 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
62874 + GR_AUDIT_READ | GR_AUDIT_WRITE |
62875 + GR_SUPPRESS, parent_mnt);
62876 + comp2 =
62877 + gr_search_file(old_dentry,
62878 + GR_READ | GR_WRITE | GR_AUDIT_READ |
62879 + GR_DELETE | GR_AUDIT_DELETE |
62880 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
62881 + }
62882 +
62883 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
62884 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
62885 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
62886 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
62887 + && !(comp2 & GR_SUPPRESS)) {
62888 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
62889 + error = -EACCES;
62890 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
62891 + error = -EACCES;
62892 +
62893 + return error;
62894 +}
62895 +
62896 +void
62897 +gr_acl_handle_exit(void)
62898 +{
62899 + u16 id;
62900 + char *rolename;
62901 +
62902 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
62903 + !(current->role->roletype & GR_ROLE_PERSIST))) {
62904 + id = current->acl_role_id;
62905 + rolename = current->role->rolename;
62906 + gr_set_acls(1);
62907 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
62908 + }
62909 +
62910 + gr_put_exec_file(current);
62911 + return;
62912 +}
62913 +
62914 +int
62915 +gr_acl_handle_procpidmem(const struct task_struct *task)
62916 +{
62917 + if (unlikely(!gr_acl_is_enabled()))
62918 + return 0;
62919 +
62920 + if (task != current && task->acl->mode & GR_PROTPROCFD)
62921 + return -EACCES;
62922 +
62923 + return 0;
62924 +}
62925 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
62926 new file mode 100644
62927 index 0000000..8132048
62928 --- /dev/null
62929 +++ b/grsecurity/gracl_ip.c
62930 @@ -0,0 +1,387 @@
62931 +#include <linux/kernel.h>
62932 +#include <asm/uaccess.h>
62933 +#include <asm/errno.h>
62934 +#include <net/sock.h>
62935 +#include <linux/file.h>
62936 +#include <linux/fs.h>
62937 +#include <linux/net.h>
62938 +#include <linux/in.h>
62939 +#include <linux/skbuff.h>
62940 +#include <linux/ip.h>
62941 +#include <linux/udp.h>
62942 +#include <linux/types.h>
62943 +#include <linux/sched.h>
62944 +#include <linux/netdevice.h>
62945 +#include <linux/inetdevice.h>
62946 +#include <linux/gracl.h>
62947 +#include <linux/grsecurity.h>
62948 +#include <linux/grinternal.h>
62949 +
62950 +#define GR_BIND 0x01
62951 +#define GR_CONNECT 0x02
62952 +#define GR_INVERT 0x04
62953 +#define GR_BINDOVERRIDE 0x08
62954 +#define GR_CONNECTOVERRIDE 0x10
62955 +#define GR_SOCK_FAMILY 0x20
62956 +
62957 +static const char * gr_protocols[IPPROTO_MAX] = {
62958 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
62959 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
62960 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
62961 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
62962 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
62963 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
62964 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
62965 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
62966 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
62967 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
62968 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
62969 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
62970 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
62971 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
62972 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
62973 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
62974 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
62975 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
62976 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
62977 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
62978 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
62979 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
62980 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
62981 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
62982 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
62983 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
62984 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
62985 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
62986 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
62987 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
62988 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
62989 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
62990 + };
62991 +
62992 +static const char * gr_socktypes[SOCK_MAX] = {
62993 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
62994 + "unknown:7", "unknown:8", "unknown:9", "packet"
62995 + };
62996 +
62997 +static const char * gr_sockfamilies[AF_MAX+1] = {
62998 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
62999 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
63000 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
63001 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
63002 + };
63003 +
63004 +const char *
63005 +gr_proto_to_name(unsigned char proto)
63006 +{
63007 + return gr_protocols[proto];
63008 +}
63009 +
63010 +const char *
63011 +gr_socktype_to_name(unsigned char type)
63012 +{
63013 + return gr_socktypes[type];
63014 +}
63015 +
63016 +const char *
63017 +gr_sockfamily_to_name(unsigned char family)
63018 +{
63019 + return gr_sockfamilies[family];
63020 +}
63021 +
63022 +int
63023 +gr_search_socket(const int domain, const int type, const int protocol)
63024 +{
63025 + struct acl_subject_label *curr;
63026 + const struct cred *cred = current_cred();
63027 +
63028 + if (unlikely(!gr_acl_is_enabled()))
63029 + goto exit;
63030 +
63031 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
63032 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
63033 + goto exit; // let the kernel handle it
63034 +
63035 + curr = current->acl;
63036 +
63037 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
63038 + /* the family is allowed, if this is PF_INET allow it only if
63039 + the extra sock type/protocol checks pass */
63040 + if (domain == PF_INET)
63041 + goto inet_check;
63042 + goto exit;
63043 + } else {
63044 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
63045 + __u32 fakeip = 0;
63046 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63047 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63048 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63049 + gr_to_filename(current->exec_file->f_path.dentry,
63050 + current->exec_file->f_path.mnt) :
63051 + curr->filename, curr->filename,
63052 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
63053 + &current->signal->saved_ip);
63054 + goto exit;
63055 + }
63056 + goto exit_fail;
63057 + }
63058 +
63059 +inet_check:
63060 + /* the rest of this checking is for IPv4 only */
63061 + if (!curr->ips)
63062 + goto exit;
63063 +
63064 + if ((curr->ip_type & (1U << type)) &&
63065 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
63066 + goto exit;
63067 +
63068 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
63069 + /* we don't place acls on raw sockets , and sometimes
63070 + dgram/ip sockets are opened for ioctl and not
63071 + bind/connect, so we'll fake a bind learn log */
63072 + if (type == SOCK_RAW || type == SOCK_PACKET) {
63073 + __u32 fakeip = 0;
63074 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63075 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63076 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63077 + gr_to_filename(current->exec_file->f_path.dentry,
63078 + current->exec_file->f_path.mnt) :
63079 + curr->filename, curr->filename,
63080 + &fakeip, 0, type,
63081 + protocol, GR_CONNECT, &current->signal->saved_ip);
63082 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
63083 + __u32 fakeip = 0;
63084 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63085 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63086 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63087 + gr_to_filename(current->exec_file->f_path.dentry,
63088 + current->exec_file->f_path.mnt) :
63089 + curr->filename, curr->filename,
63090 + &fakeip, 0, type,
63091 + protocol, GR_BIND, &current->signal->saved_ip);
63092 + }
63093 + /* we'll log when they use connect or bind */
63094 + goto exit;
63095 + }
63096 +
63097 +exit_fail:
63098 + if (domain == PF_INET)
63099 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
63100 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
63101 + else
63102 +#ifndef CONFIG_IPV6
63103 + if (domain != PF_INET6)
63104 +#endif
63105 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
63106 + gr_socktype_to_name(type), protocol);
63107 +
63108 + return 0;
63109 +exit:
63110 + return 1;
63111 +}
63112 +
63113 +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)
63114 +{
63115 + if ((ip->mode & mode) &&
63116 + (ip_port >= ip->low) &&
63117 + (ip_port <= ip->high) &&
63118 + ((ntohl(ip_addr) & our_netmask) ==
63119 + (ntohl(our_addr) & our_netmask))
63120 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
63121 + && (ip->type & (1U << type))) {
63122 + if (ip->mode & GR_INVERT)
63123 + return 2; // specifically denied
63124 + else
63125 + return 1; // allowed
63126 + }
63127 +
63128 + return 0; // not specifically allowed, may continue parsing
63129 +}
63130 +
63131 +static int
63132 +gr_search_connectbind(const int full_mode, struct sock *sk,
63133 + struct sockaddr_in *addr, const int type)
63134 +{
63135 + char iface[IFNAMSIZ] = {0};
63136 + struct acl_subject_label *curr;
63137 + struct acl_ip_label *ip;
63138 + struct inet_sock *isk;
63139 + struct net_device *dev;
63140 + struct in_device *idev;
63141 + unsigned long i;
63142 + int ret;
63143 + int mode = full_mode & (GR_BIND | GR_CONNECT);
63144 + __u32 ip_addr = 0;
63145 + __u32 our_addr;
63146 + __u32 our_netmask;
63147 + char *p;
63148 + __u16 ip_port = 0;
63149 + const struct cred *cred = current_cred();
63150 +
63151 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
63152 + return 0;
63153 +
63154 + curr = current->acl;
63155 + isk = inet_sk(sk);
63156 +
63157 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
63158 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
63159 + addr->sin_addr.s_addr = curr->inaddr_any_override;
63160 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
63161 + struct sockaddr_in saddr;
63162 + int err;
63163 +
63164 + saddr.sin_family = AF_INET;
63165 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
63166 + saddr.sin_port = isk->inet_sport;
63167 +
63168 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
63169 + if (err)
63170 + return err;
63171 +
63172 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
63173 + if (err)
63174 + return err;
63175 + }
63176 +
63177 + if (!curr->ips)
63178 + return 0;
63179 +
63180 + ip_addr = addr->sin_addr.s_addr;
63181 + ip_port = ntohs(addr->sin_port);
63182 +
63183 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
63184 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
63185 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
63186 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
63187 + gr_to_filename(current->exec_file->f_path.dentry,
63188 + current->exec_file->f_path.mnt) :
63189 + curr->filename, curr->filename,
63190 + &ip_addr, ip_port, type,
63191 + sk->sk_protocol, mode, &current->signal->saved_ip);
63192 + return 0;
63193 + }
63194 +
63195 + for (i = 0; i < curr->ip_num; i++) {
63196 + ip = *(curr->ips + i);
63197 + if (ip->iface != NULL) {
63198 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
63199 + p = strchr(iface, ':');
63200 + if (p != NULL)
63201 + *p = '\0';
63202 + dev = dev_get_by_name(sock_net(sk), iface);
63203 + if (dev == NULL)
63204 + continue;
63205 + idev = in_dev_get(dev);
63206 + if (idev == NULL) {
63207 + dev_put(dev);
63208 + continue;
63209 + }
63210 + rcu_read_lock();
63211 + for_ifa(idev) {
63212 + if (!strcmp(ip->iface, ifa->ifa_label)) {
63213 + our_addr = ifa->ifa_address;
63214 + our_netmask = 0xffffffff;
63215 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
63216 + if (ret == 1) {
63217 + rcu_read_unlock();
63218 + in_dev_put(idev);
63219 + dev_put(dev);
63220 + return 0;
63221 + } else if (ret == 2) {
63222 + rcu_read_unlock();
63223 + in_dev_put(idev);
63224 + dev_put(dev);
63225 + goto denied;
63226 + }
63227 + }
63228 + } endfor_ifa(idev);
63229 + rcu_read_unlock();
63230 + in_dev_put(idev);
63231 + dev_put(dev);
63232 + } else {
63233 + our_addr = ip->addr;
63234 + our_netmask = ip->netmask;
63235 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
63236 + if (ret == 1)
63237 + return 0;
63238 + else if (ret == 2)
63239 + goto denied;
63240 + }
63241 + }
63242 +
63243 +denied:
63244 + if (mode == GR_BIND)
63245 + 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));
63246 + else if (mode == GR_CONNECT)
63247 + 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));
63248 +
63249 + return -EACCES;
63250 +}
63251 +
63252 +int
63253 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
63254 +{
63255 + /* always allow disconnection of dgram sockets with connect */
63256 + if (addr->sin_family == AF_UNSPEC)
63257 + return 0;
63258 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
63259 +}
63260 +
63261 +int
63262 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
63263 +{
63264 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
63265 +}
63266 +
63267 +int gr_search_listen(struct socket *sock)
63268 +{
63269 + struct sock *sk = sock->sk;
63270 + struct sockaddr_in addr;
63271 +
63272 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
63273 + addr.sin_port = inet_sk(sk)->inet_sport;
63274 +
63275 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
63276 +}
63277 +
63278 +int gr_search_accept(struct socket *sock)
63279 +{
63280 + struct sock *sk = sock->sk;
63281 + struct sockaddr_in addr;
63282 +
63283 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
63284 + addr.sin_port = inet_sk(sk)->inet_sport;
63285 +
63286 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
63287 +}
63288 +
63289 +int
63290 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
63291 +{
63292 + if (addr)
63293 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
63294 + else {
63295 + struct sockaddr_in sin;
63296 + const struct inet_sock *inet = inet_sk(sk);
63297 +
63298 + sin.sin_addr.s_addr = inet->inet_daddr;
63299 + sin.sin_port = inet->inet_dport;
63300 +
63301 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
63302 + }
63303 +}
63304 +
63305 +int
63306 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
63307 +{
63308 + struct sockaddr_in sin;
63309 +
63310 + if (unlikely(skb->len < sizeof (struct udphdr)))
63311 + return 0; // skip this packet
63312 +
63313 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
63314 + sin.sin_port = udp_hdr(skb)->source;
63315 +
63316 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
63317 +}
63318 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
63319 new file mode 100644
63320 index 0000000..25f54ef
63321 --- /dev/null
63322 +++ b/grsecurity/gracl_learn.c
63323 @@ -0,0 +1,207 @@
63324 +#include <linux/kernel.h>
63325 +#include <linux/mm.h>
63326 +#include <linux/sched.h>
63327 +#include <linux/poll.h>
63328 +#include <linux/string.h>
63329 +#include <linux/file.h>
63330 +#include <linux/types.h>
63331 +#include <linux/vmalloc.h>
63332 +#include <linux/grinternal.h>
63333 +
63334 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
63335 + size_t count, loff_t *ppos);
63336 +extern int gr_acl_is_enabled(void);
63337 +
63338 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
63339 +static int gr_learn_attached;
63340 +
63341 +/* use a 512k buffer */
63342 +#define LEARN_BUFFER_SIZE (512 * 1024)
63343 +
63344 +static DEFINE_SPINLOCK(gr_learn_lock);
63345 +static DEFINE_MUTEX(gr_learn_user_mutex);
63346 +
63347 +/* we need to maintain two buffers, so that the kernel context of grlearn
63348 + uses a semaphore around the userspace copying, and the other kernel contexts
63349 + use a spinlock when copying into the buffer, since they cannot sleep
63350 +*/
63351 +static char *learn_buffer;
63352 +static char *learn_buffer_user;
63353 +static int learn_buffer_len;
63354 +static int learn_buffer_user_len;
63355 +
63356 +static ssize_t
63357 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
63358 +{
63359 + DECLARE_WAITQUEUE(wait, current);
63360 + ssize_t retval = 0;
63361 +
63362 + add_wait_queue(&learn_wait, &wait);
63363 + set_current_state(TASK_INTERRUPTIBLE);
63364 + do {
63365 + mutex_lock(&gr_learn_user_mutex);
63366 + spin_lock(&gr_learn_lock);
63367 + if (learn_buffer_len)
63368 + break;
63369 + spin_unlock(&gr_learn_lock);
63370 + mutex_unlock(&gr_learn_user_mutex);
63371 + if (file->f_flags & O_NONBLOCK) {
63372 + retval = -EAGAIN;
63373 + goto out;
63374 + }
63375 + if (signal_pending(current)) {
63376 + retval = -ERESTARTSYS;
63377 + goto out;
63378 + }
63379 +
63380 + schedule();
63381 + } while (1);
63382 +
63383 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
63384 + learn_buffer_user_len = learn_buffer_len;
63385 + retval = learn_buffer_len;
63386 + learn_buffer_len = 0;
63387 +
63388 + spin_unlock(&gr_learn_lock);
63389 +
63390 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
63391 + retval = -EFAULT;
63392 +
63393 + mutex_unlock(&gr_learn_user_mutex);
63394 +out:
63395 + set_current_state(TASK_RUNNING);
63396 + remove_wait_queue(&learn_wait, &wait);
63397 + return retval;
63398 +}
63399 +
63400 +static unsigned int
63401 +poll_learn(struct file * file, poll_table * wait)
63402 +{
63403 + poll_wait(file, &learn_wait, wait);
63404 +
63405 + if (learn_buffer_len)
63406 + return (POLLIN | POLLRDNORM);
63407 +
63408 + return 0;
63409 +}
63410 +
63411 +void
63412 +gr_clear_learn_entries(void)
63413 +{
63414 + char *tmp;
63415 +
63416 + mutex_lock(&gr_learn_user_mutex);
63417 + spin_lock(&gr_learn_lock);
63418 + tmp = learn_buffer;
63419 + learn_buffer = NULL;
63420 + spin_unlock(&gr_learn_lock);
63421 + if (tmp)
63422 + vfree(tmp);
63423 + if (learn_buffer_user != NULL) {
63424 + vfree(learn_buffer_user);
63425 + learn_buffer_user = NULL;
63426 + }
63427 + learn_buffer_len = 0;
63428 + mutex_unlock(&gr_learn_user_mutex);
63429 +
63430 + return;
63431 +}
63432 +
63433 +void
63434 +gr_add_learn_entry(const char *fmt, ...)
63435 +{
63436 + va_list args;
63437 + unsigned int len;
63438 +
63439 + if (!gr_learn_attached)
63440 + return;
63441 +
63442 + spin_lock(&gr_learn_lock);
63443 +
63444 + /* leave a gap at the end so we know when it's "full" but don't have to
63445 + compute the exact length of the string we're trying to append
63446 + */
63447 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
63448 + spin_unlock(&gr_learn_lock);
63449 + wake_up_interruptible(&learn_wait);
63450 + return;
63451 + }
63452 + if (learn_buffer == NULL) {
63453 + spin_unlock(&gr_learn_lock);
63454 + return;
63455 + }
63456 +
63457 + va_start(args, fmt);
63458 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
63459 + va_end(args);
63460 +
63461 + learn_buffer_len += len + 1;
63462 +
63463 + spin_unlock(&gr_learn_lock);
63464 + wake_up_interruptible(&learn_wait);
63465 +
63466 + return;
63467 +}
63468 +
63469 +static int
63470 +open_learn(struct inode *inode, struct file *file)
63471 +{
63472 + if (file->f_mode & FMODE_READ && gr_learn_attached)
63473 + return -EBUSY;
63474 + if (file->f_mode & FMODE_READ) {
63475 + int retval = 0;
63476 + mutex_lock(&gr_learn_user_mutex);
63477 + if (learn_buffer == NULL)
63478 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
63479 + if (learn_buffer_user == NULL)
63480 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
63481 + if (learn_buffer == NULL) {
63482 + retval = -ENOMEM;
63483 + goto out_error;
63484 + }
63485 + if (learn_buffer_user == NULL) {
63486 + retval = -ENOMEM;
63487 + goto out_error;
63488 + }
63489 + learn_buffer_len = 0;
63490 + learn_buffer_user_len = 0;
63491 + gr_learn_attached = 1;
63492 +out_error:
63493 + mutex_unlock(&gr_learn_user_mutex);
63494 + return retval;
63495 + }
63496 + return 0;
63497 +}
63498 +
63499 +static int
63500 +close_learn(struct inode *inode, struct file *file)
63501 +{
63502 + if (file->f_mode & FMODE_READ) {
63503 + char *tmp = NULL;
63504 + mutex_lock(&gr_learn_user_mutex);
63505 + spin_lock(&gr_learn_lock);
63506 + tmp = learn_buffer;
63507 + learn_buffer = NULL;
63508 + spin_unlock(&gr_learn_lock);
63509 + if (tmp)
63510 + vfree(tmp);
63511 + if (learn_buffer_user != NULL) {
63512 + vfree(learn_buffer_user);
63513 + learn_buffer_user = NULL;
63514 + }
63515 + learn_buffer_len = 0;
63516 + learn_buffer_user_len = 0;
63517 + gr_learn_attached = 0;
63518 + mutex_unlock(&gr_learn_user_mutex);
63519 + }
63520 +
63521 + return 0;
63522 +}
63523 +
63524 +const struct file_operations grsec_fops = {
63525 + .read = read_learn,
63526 + .write = write_grsec_handler,
63527 + .open = open_learn,
63528 + .release = close_learn,
63529 + .poll = poll_learn,
63530 +};
63531 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
63532 new file mode 100644
63533 index 0000000..39645c9
63534 --- /dev/null
63535 +++ b/grsecurity/gracl_res.c
63536 @@ -0,0 +1,68 @@
63537 +#include <linux/kernel.h>
63538 +#include <linux/sched.h>
63539 +#include <linux/gracl.h>
63540 +#include <linux/grinternal.h>
63541 +
63542 +static const char *restab_log[] = {
63543 + [RLIMIT_CPU] = "RLIMIT_CPU",
63544 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
63545 + [RLIMIT_DATA] = "RLIMIT_DATA",
63546 + [RLIMIT_STACK] = "RLIMIT_STACK",
63547 + [RLIMIT_CORE] = "RLIMIT_CORE",
63548 + [RLIMIT_RSS] = "RLIMIT_RSS",
63549 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
63550 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
63551 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
63552 + [RLIMIT_AS] = "RLIMIT_AS",
63553 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
63554 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
63555 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
63556 + [RLIMIT_NICE] = "RLIMIT_NICE",
63557 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
63558 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
63559 + [GR_CRASH_RES] = "RLIMIT_CRASH"
63560 +};
63561 +
63562 +void
63563 +gr_log_resource(const struct task_struct *task,
63564 + const int res, const unsigned long wanted, const int gt)
63565 +{
63566 + const struct cred *cred;
63567 + unsigned long rlim;
63568 +
63569 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
63570 + return;
63571 +
63572 + // not yet supported resource
63573 + if (unlikely(!restab_log[res]))
63574 + return;
63575 +
63576 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
63577 + rlim = task_rlimit_max(task, res);
63578 + else
63579 + rlim = task_rlimit(task, res);
63580 +
63581 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
63582 + return;
63583 +
63584 + rcu_read_lock();
63585 + cred = __task_cred(task);
63586 +
63587 + if (res == RLIMIT_NPROC &&
63588 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
63589 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
63590 + goto out_rcu_unlock;
63591 + else if (res == RLIMIT_MEMLOCK &&
63592 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
63593 + goto out_rcu_unlock;
63594 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
63595 + goto out_rcu_unlock;
63596 + rcu_read_unlock();
63597 +
63598 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
63599 +
63600 + return;
63601 +out_rcu_unlock:
63602 + rcu_read_unlock();
63603 + return;
63604 +}
63605 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
63606 new file mode 100644
63607 index 0000000..3c38bfe
63608 --- /dev/null
63609 +++ b/grsecurity/gracl_segv.c
63610 @@ -0,0 +1,305 @@
63611 +#include <linux/kernel.h>
63612 +#include <linux/mm.h>
63613 +#include <asm/uaccess.h>
63614 +#include <asm/errno.h>
63615 +#include <asm/mman.h>
63616 +#include <net/sock.h>
63617 +#include <linux/file.h>
63618 +#include <linux/fs.h>
63619 +#include <linux/net.h>
63620 +#include <linux/in.h>
63621 +#include <linux/slab.h>
63622 +#include <linux/types.h>
63623 +#include <linux/sched.h>
63624 +#include <linux/timer.h>
63625 +#include <linux/gracl.h>
63626 +#include <linux/grsecurity.h>
63627 +#include <linux/grinternal.h>
63628 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
63629 +#include <linux/magic.h>
63630 +#include <linux/pagemap.h>
63631 +#include "../fs/btrfs/async-thread.h"
63632 +#include "../fs/btrfs/ctree.h"
63633 +#include "../fs/btrfs/btrfs_inode.h"
63634 +#endif
63635 +
63636 +static struct crash_uid *uid_set;
63637 +static unsigned short uid_used;
63638 +static DEFINE_SPINLOCK(gr_uid_lock);
63639 +extern rwlock_t gr_inode_lock;
63640 +extern struct acl_subject_label *
63641 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
63642 + struct acl_role_label *role);
63643 +
63644 +static inline dev_t __get_dev(const struct dentry *dentry)
63645 +{
63646 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
63647 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
63648 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
63649 + else
63650 +#endif
63651 + return dentry->d_sb->s_dev;
63652 +}
63653 +
63654 +int
63655 +gr_init_uidset(void)
63656 +{
63657 + uid_set =
63658 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
63659 + uid_used = 0;
63660 +
63661 + return uid_set ? 1 : 0;
63662 +}
63663 +
63664 +void
63665 +gr_free_uidset(void)
63666 +{
63667 + if (uid_set)
63668 + kfree(uid_set);
63669 +
63670 + return;
63671 +}
63672 +
63673 +int
63674 +gr_find_uid(const uid_t uid)
63675 +{
63676 + struct crash_uid *tmp = uid_set;
63677 + uid_t buid;
63678 + int low = 0, high = uid_used - 1, mid;
63679 +
63680 + while (high >= low) {
63681 + mid = (low + high) >> 1;
63682 + buid = tmp[mid].uid;
63683 + if (buid == uid)
63684 + return mid;
63685 + if (buid > uid)
63686 + high = mid - 1;
63687 + if (buid < uid)
63688 + low = mid + 1;
63689 + }
63690 +
63691 + return -1;
63692 +}
63693 +
63694 +static __inline__ void
63695 +gr_insertsort(void)
63696 +{
63697 + unsigned short i, j;
63698 + struct crash_uid index;
63699 +
63700 + for (i = 1; i < uid_used; i++) {
63701 + index = uid_set[i];
63702 + j = i;
63703 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
63704 + uid_set[j] = uid_set[j - 1];
63705 + j--;
63706 + }
63707 + uid_set[j] = index;
63708 + }
63709 +
63710 + return;
63711 +}
63712 +
63713 +static __inline__ void
63714 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
63715 +{
63716 + int loc;
63717 + uid_t uid = GR_GLOBAL_UID(kuid);
63718 +
63719 + if (uid_used == GR_UIDTABLE_MAX)
63720 + return;
63721 +
63722 + loc = gr_find_uid(uid);
63723 +
63724 + if (loc >= 0) {
63725 + uid_set[loc].expires = expires;
63726 + return;
63727 + }
63728 +
63729 + uid_set[uid_used].uid = uid;
63730 + uid_set[uid_used].expires = expires;
63731 + uid_used++;
63732 +
63733 + gr_insertsort();
63734 +
63735 + return;
63736 +}
63737 +
63738 +void
63739 +gr_remove_uid(const unsigned short loc)
63740 +{
63741 + unsigned short i;
63742 +
63743 + for (i = loc + 1; i < uid_used; i++)
63744 + uid_set[i - 1] = uid_set[i];
63745 +
63746 + uid_used--;
63747 +
63748 + return;
63749 +}
63750 +
63751 +int
63752 +gr_check_crash_uid(const kuid_t kuid)
63753 +{
63754 + int loc;
63755 + int ret = 0;
63756 + uid_t uid;
63757 +
63758 + if (unlikely(!gr_acl_is_enabled()))
63759 + return 0;
63760 +
63761 + uid = GR_GLOBAL_UID(kuid);
63762 +
63763 + spin_lock(&gr_uid_lock);
63764 + loc = gr_find_uid(uid);
63765 +
63766 + if (loc < 0)
63767 + goto out_unlock;
63768 +
63769 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
63770 + gr_remove_uid(loc);
63771 + else
63772 + ret = 1;
63773 +
63774 +out_unlock:
63775 + spin_unlock(&gr_uid_lock);
63776 + return ret;
63777 +}
63778 +
63779 +static __inline__ int
63780 +proc_is_setxid(const struct cred *cred)
63781 +{
63782 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
63783 + !uid_eq(cred->uid, cred->fsuid))
63784 + return 1;
63785 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
63786 + !gid_eq(cred->gid, cred->fsgid))
63787 + return 1;
63788 +
63789 + return 0;
63790 +}
63791 +
63792 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
63793 +
63794 +void
63795 +gr_handle_crash(struct task_struct *task, const int sig)
63796 +{
63797 + struct acl_subject_label *curr;
63798 + struct task_struct *tsk, *tsk2;
63799 + const struct cred *cred;
63800 + const struct cred *cred2;
63801 +
63802 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
63803 + return;
63804 +
63805 + if (unlikely(!gr_acl_is_enabled()))
63806 + return;
63807 +
63808 + curr = task->acl;
63809 +
63810 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
63811 + return;
63812 +
63813 + if (time_before_eq(curr->expires, get_seconds())) {
63814 + curr->expires = 0;
63815 + curr->crashes = 0;
63816 + }
63817 +
63818 + curr->crashes++;
63819 +
63820 + if (!curr->expires)
63821 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
63822 +
63823 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
63824 + time_after(curr->expires, get_seconds())) {
63825 + rcu_read_lock();
63826 + cred = __task_cred(task);
63827 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
63828 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
63829 + spin_lock(&gr_uid_lock);
63830 + gr_insert_uid(cred->uid, curr->expires);
63831 + spin_unlock(&gr_uid_lock);
63832 + curr->expires = 0;
63833 + curr->crashes = 0;
63834 + read_lock(&tasklist_lock);
63835 + do_each_thread(tsk2, tsk) {
63836 + cred2 = __task_cred(tsk);
63837 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
63838 + gr_fake_force_sig(SIGKILL, tsk);
63839 + } while_each_thread(tsk2, tsk);
63840 + read_unlock(&tasklist_lock);
63841 + } else {
63842 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
63843 + read_lock(&tasklist_lock);
63844 + read_lock(&grsec_exec_file_lock);
63845 + do_each_thread(tsk2, tsk) {
63846 + if (likely(tsk != task)) {
63847 + // if this thread has the same subject as the one that triggered
63848 + // RES_CRASH and it's the same binary, kill it
63849 + if (tsk->acl == task->acl && gr_is_same_file(tsk->exec_file, task->exec_file))
63850 + gr_fake_force_sig(SIGKILL, tsk);
63851 + }
63852 + } while_each_thread(tsk2, tsk);
63853 + read_unlock(&grsec_exec_file_lock);
63854 + read_unlock(&tasklist_lock);
63855 + }
63856 + rcu_read_unlock();
63857 + }
63858 +
63859 + return;
63860 +}
63861 +
63862 +int
63863 +gr_check_crash_exec(const struct file *filp)
63864 +{
63865 + struct acl_subject_label *curr;
63866 +
63867 + if (unlikely(!gr_acl_is_enabled()))
63868 + return 0;
63869 +
63870 + read_lock(&gr_inode_lock);
63871 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
63872 + __get_dev(filp->f_path.dentry),
63873 + current->role);
63874 + read_unlock(&gr_inode_lock);
63875 +
63876 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
63877 + (!curr->crashes && !curr->expires))
63878 + return 0;
63879 +
63880 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
63881 + time_after(curr->expires, get_seconds()))
63882 + return 1;
63883 + else if (time_before_eq(curr->expires, get_seconds())) {
63884 + curr->crashes = 0;
63885 + curr->expires = 0;
63886 + }
63887 +
63888 + return 0;
63889 +}
63890 +
63891 +void
63892 +gr_handle_alertkill(struct task_struct *task)
63893 +{
63894 + struct acl_subject_label *curracl;
63895 + __u32 curr_ip;
63896 + struct task_struct *p, *p2;
63897 +
63898 + if (unlikely(!gr_acl_is_enabled()))
63899 + return;
63900 +
63901 + curracl = task->acl;
63902 + curr_ip = task->signal->curr_ip;
63903 +
63904 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
63905 + read_lock(&tasklist_lock);
63906 + do_each_thread(p2, p) {
63907 + if (p->signal->curr_ip == curr_ip)
63908 + gr_fake_force_sig(SIGKILL, p);
63909 + } while_each_thread(p2, p);
63910 + read_unlock(&tasklist_lock);
63911 + } else if (curracl->mode & GR_KILLPROC)
63912 + gr_fake_force_sig(SIGKILL, task);
63913 +
63914 + return;
63915 +}
63916 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
63917 new file mode 100644
63918 index 0000000..98011b0
63919 --- /dev/null
63920 +++ b/grsecurity/gracl_shm.c
63921 @@ -0,0 +1,40 @@
63922 +#include <linux/kernel.h>
63923 +#include <linux/mm.h>
63924 +#include <linux/sched.h>
63925 +#include <linux/file.h>
63926 +#include <linux/ipc.h>
63927 +#include <linux/gracl.h>
63928 +#include <linux/grsecurity.h>
63929 +#include <linux/grinternal.h>
63930 +
63931 +int
63932 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
63933 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
63934 +{
63935 + struct task_struct *task;
63936 +
63937 + if (!gr_acl_is_enabled())
63938 + return 1;
63939 +
63940 + rcu_read_lock();
63941 + read_lock(&tasklist_lock);
63942 +
63943 + task = find_task_by_vpid(shm_cprid);
63944 +
63945 + if (unlikely(!task))
63946 + task = find_task_by_vpid(shm_lapid);
63947 +
63948 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
63949 + (task_pid_nr(task) == shm_lapid)) &&
63950 + (task->acl->mode & GR_PROTSHM) &&
63951 + (task->acl != current->acl))) {
63952 + read_unlock(&tasklist_lock);
63953 + rcu_read_unlock();
63954 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
63955 + return 0;
63956 + }
63957 + read_unlock(&tasklist_lock);
63958 + rcu_read_unlock();
63959 +
63960 + return 1;
63961 +}
63962 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
63963 new file mode 100644
63964 index 0000000..bc0be01
63965 --- /dev/null
63966 +++ b/grsecurity/grsec_chdir.c
63967 @@ -0,0 +1,19 @@
63968 +#include <linux/kernel.h>
63969 +#include <linux/sched.h>
63970 +#include <linux/fs.h>
63971 +#include <linux/file.h>
63972 +#include <linux/grsecurity.h>
63973 +#include <linux/grinternal.h>
63974 +
63975 +void
63976 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
63977 +{
63978 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
63979 + if ((grsec_enable_chdir && grsec_enable_group &&
63980 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
63981 + !grsec_enable_group)) {
63982 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
63983 + }
63984 +#endif
63985 + return;
63986 +}
63987 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
63988 new file mode 100644
63989 index 0000000..bd6e105
63990 --- /dev/null
63991 +++ b/grsecurity/grsec_chroot.c
63992 @@ -0,0 +1,370 @@
63993 +#include <linux/kernel.h>
63994 +#include <linux/module.h>
63995 +#include <linux/sched.h>
63996 +#include <linux/file.h>
63997 +#include <linux/fs.h>
63998 +#include <linux/mount.h>
63999 +#include <linux/types.h>
64000 +#include "../fs/mount.h"
64001 +#include <linux/grsecurity.h>
64002 +#include <linux/grinternal.h>
64003 +
64004 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
64005 +static int gr_init_ran;
64006 +#endif
64007 +
64008 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path)
64009 +{
64010 +#ifdef CONFIG_GRKERNSEC
64011 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
64012 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
64013 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
64014 + && gr_init_ran
64015 +#endif
64016 + )
64017 + task->gr_is_chrooted = 1;
64018 + else {
64019 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
64020 + if (task_pid_nr(task) == 1 && !gr_init_ran)
64021 + gr_init_ran = 1;
64022 +#endif
64023 + task->gr_is_chrooted = 0;
64024 + }
64025 +
64026 + task->gr_chroot_dentry = path->dentry;
64027 +#endif
64028 + return;
64029 +}
64030 +
64031 +void gr_clear_chroot_entries(struct task_struct *task)
64032 +{
64033 +#ifdef CONFIG_GRKERNSEC
64034 + task->gr_is_chrooted = 0;
64035 + task->gr_chroot_dentry = NULL;
64036 +#endif
64037 + return;
64038 +}
64039 +
64040 +int
64041 +gr_handle_chroot_unix(const pid_t pid)
64042 +{
64043 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
64044 + struct task_struct *p;
64045 +
64046 + if (unlikely(!grsec_enable_chroot_unix))
64047 + return 1;
64048 +
64049 + if (likely(!proc_is_chrooted(current)))
64050 + return 1;
64051 +
64052 + rcu_read_lock();
64053 + read_lock(&tasklist_lock);
64054 + p = find_task_by_vpid_unrestricted(pid);
64055 + if (unlikely(p && !have_same_root(current, p))) {
64056 + read_unlock(&tasklist_lock);
64057 + rcu_read_unlock();
64058 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
64059 + return 0;
64060 + }
64061 + read_unlock(&tasklist_lock);
64062 + rcu_read_unlock();
64063 +#endif
64064 + return 1;
64065 +}
64066 +
64067 +int
64068 +gr_handle_chroot_nice(void)
64069 +{
64070 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
64071 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
64072 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
64073 + return -EPERM;
64074 + }
64075 +#endif
64076 + return 0;
64077 +}
64078 +
64079 +int
64080 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
64081 +{
64082 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
64083 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
64084 + && proc_is_chrooted(current)) {
64085 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
64086 + return -EACCES;
64087 + }
64088 +#endif
64089 + return 0;
64090 +}
64091 +
64092 +int
64093 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
64094 +{
64095 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
64096 + struct task_struct *p;
64097 + int ret = 0;
64098 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
64099 + return ret;
64100 +
64101 + read_lock(&tasklist_lock);
64102 + do_each_pid_task(pid, type, p) {
64103 + if (!have_same_root(current, p)) {
64104 + ret = 1;
64105 + goto out;
64106 + }
64107 + } while_each_pid_task(pid, type, p);
64108 +out:
64109 + read_unlock(&tasklist_lock);
64110 + return ret;
64111 +#endif
64112 + return 0;
64113 +}
64114 +
64115 +int
64116 +gr_pid_is_chrooted(struct task_struct *p)
64117 +{
64118 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
64119 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
64120 + return 0;
64121 +
64122 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
64123 + !have_same_root(current, p)) {
64124 + return 1;
64125 + }
64126 +#endif
64127 + return 0;
64128 +}
64129 +
64130 +EXPORT_SYMBOL(gr_pid_is_chrooted);
64131 +
64132 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
64133 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
64134 +{
64135 + struct path path, currentroot;
64136 + int ret = 0;
64137 +
64138 + path.dentry = (struct dentry *)u_dentry;
64139 + path.mnt = (struct vfsmount *)u_mnt;
64140 + get_fs_root(current->fs, &currentroot);
64141 + if (path_is_under(&path, &currentroot))
64142 + ret = 1;
64143 + path_put(&currentroot);
64144 +
64145 + return ret;
64146 +}
64147 +#endif
64148 +
64149 +int
64150 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
64151 +{
64152 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
64153 + if (!grsec_enable_chroot_fchdir)
64154 + return 1;
64155 +
64156 + if (!proc_is_chrooted(current))
64157 + return 1;
64158 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
64159 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
64160 + return 0;
64161 + }
64162 +#endif
64163 + return 1;
64164 +}
64165 +
64166 +int
64167 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
64168 + const time_t shm_createtime)
64169 +{
64170 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
64171 + struct task_struct *p;
64172 + time_t starttime;
64173 +
64174 + if (unlikely(!grsec_enable_chroot_shmat))
64175 + return 1;
64176 +
64177 + if (likely(!proc_is_chrooted(current)))
64178 + return 1;
64179 +
64180 + rcu_read_lock();
64181 + read_lock(&tasklist_lock);
64182 +
64183 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
64184 + starttime = p->start_time.tv_sec;
64185 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
64186 + if (have_same_root(current, p)) {
64187 + goto allow;
64188 + } else {
64189 + read_unlock(&tasklist_lock);
64190 + rcu_read_unlock();
64191 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
64192 + return 0;
64193 + }
64194 + }
64195 + /* creator exited, pid reuse, fall through to next check */
64196 + }
64197 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
64198 + if (unlikely(!have_same_root(current, p))) {
64199 + read_unlock(&tasklist_lock);
64200 + rcu_read_unlock();
64201 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
64202 + return 0;
64203 + }
64204 + }
64205 +
64206 +allow:
64207 + read_unlock(&tasklist_lock);
64208 + rcu_read_unlock();
64209 +#endif
64210 + return 1;
64211 +}
64212 +
64213 +void
64214 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
64215 +{
64216 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
64217 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
64218 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
64219 +#endif
64220 + return;
64221 +}
64222 +
64223 +int
64224 +gr_handle_chroot_mknod(const struct dentry *dentry,
64225 + const struct vfsmount *mnt, const int mode)
64226 +{
64227 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
64228 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
64229 + proc_is_chrooted(current)) {
64230 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
64231 + return -EPERM;
64232 + }
64233 +#endif
64234 + return 0;
64235 +}
64236 +
64237 +int
64238 +gr_handle_chroot_mount(const struct dentry *dentry,
64239 + const struct vfsmount *mnt, const char *dev_name)
64240 +{
64241 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
64242 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
64243 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
64244 + return -EPERM;
64245 + }
64246 +#endif
64247 + return 0;
64248 +}
64249 +
64250 +int
64251 +gr_handle_chroot_pivot(void)
64252 +{
64253 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
64254 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
64255 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
64256 + return -EPERM;
64257 + }
64258 +#endif
64259 + return 0;
64260 +}
64261 +
64262 +int
64263 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
64264 +{
64265 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
64266 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
64267 + !gr_is_outside_chroot(dentry, mnt)) {
64268 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
64269 + return -EPERM;
64270 + }
64271 +#endif
64272 + return 0;
64273 +}
64274 +
64275 +extern const char *captab_log[];
64276 +extern int captab_log_entries;
64277 +
64278 +int
64279 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
64280 +{
64281 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64282 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
64283 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
64284 + if (cap_raised(chroot_caps, cap)) {
64285 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
64286 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
64287 + }
64288 + return 0;
64289 + }
64290 + }
64291 +#endif
64292 + return 1;
64293 +}
64294 +
64295 +int
64296 +gr_chroot_is_capable(const int cap)
64297 +{
64298 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64299 + return gr_task_chroot_is_capable(current, current_cred(), cap);
64300 +#endif
64301 + return 1;
64302 +}
64303 +
64304 +int
64305 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
64306 +{
64307 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64308 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
64309 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
64310 + if (cap_raised(chroot_caps, cap)) {
64311 + return 0;
64312 + }
64313 + }
64314 +#endif
64315 + return 1;
64316 +}
64317 +
64318 +int
64319 +gr_chroot_is_capable_nolog(const int cap)
64320 +{
64321 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
64322 + return gr_task_chroot_is_capable_nolog(current, cap);
64323 +#endif
64324 + return 1;
64325 +}
64326 +
64327 +int
64328 +gr_handle_chroot_sysctl(const int op)
64329 +{
64330 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
64331 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
64332 + proc_is_chrooted(current))
64333 + return -EACCES;
64334 +#endif
64335 + return 0;
64336 +}
64337 +
64338 +void
64339 +gr_handle_chroot_chdir(const struct path *path)
64340 +{
64341 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
64342 + if (grsec_enable_chroot_chdir)
64343 + set_fs_pwd(current->fs, path);
64344 +#endif
64345 + return;
64346 +}
64347 +
64348 +int
64349 +gr_handle_chroot_chmod(const struct dentry *dentry,
64350 + const struct vfsmount *mnt, const int mode)
64351 +{
64352 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
64353 + /* allow chmod +s on directories, but not files */
64354 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
64355 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
64356 + proc_is_chrooted(current)) {
64357 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
64358 + return -EPERM;
64359 + }
64360 +#endif
64361 + return 0;
64362 +}
64363 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
64364 new file mode 100644
64365 index 0000000..ce65ceb
64366 --- /dev/null
64367 +++ b/grsecurity/grsec_disabled.c
64368 @@ -0,0 +1,434 @@
64369 +#include <linux/kernel.h>
64370 +#include <linux/module.h>
64371 +#include <linux/sched.h>
64372 +#include <linux/file.h>
64373 +#include <linux/fs.h>
64374 +#include <linux/kdev_t.h>
64375 +#include <linux/net.h>
64376 +#include <linux/in.h>
64377 +#include <linux/ip.h>
64378 +#include <linux/skbuff.h>
64379 +#include <linux/sysctl.h>
64380 +
64381 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
64382 +void
64383 +pax_set_initial_flags(struct linux_binprm *bprm)
64384 +{
64385 + return;
64386 +}
64387 +#endif
64388 +
64389 +#ifdef CONFIG_SYSCTL
64390 +__u32
64391 +gr_handle_sysctl(const struct ctl_table * table, const int op)
64392 +{
64393 + return 0;
64394 +}
64395 +#endif
64396 +
64397 +#ifdef CONFIG_TASKSTATS
64398 +int gr_is_taskstats_denied(int pid)
64399 +{
64400 + return 0;
64401 +}
64402 +#endif
64403 +
64404 +int
64405 +gr_acl_is_enabled(void)
64406 +{
64407 + return 0;
64408 +}
64409 +
64410 +void
64411 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
64412 +{
64413 + return;
64414 +}
64415 +
64416 +int
64417 +gr_handle_rawio(const struct inode *inode)
64418 +{
64419 + return 0;
64420 +}
64421 +
64422 +void
64423 +gr_acl_handle_psacct(struct task_struct *task, const long code)
64424 +{
64425 + return;
64426 +}
64427 +
64428 +int
64429 +gr_handle_ptrace(struct task_struct *task, const long request)
64430 +{
64431 + return 0;
64432 +}
64433 +
64434 +int
64435 +gr_handle_proc_ptrace(struct task_struct *task)
64436 +{
64437 + return 0;
64438 +}
64439 +
64440 +int
64441 +gr_set_acls(const int type)
64442 +{
64443 + return 0;
64444 +}
64445 +
64446 +int
64447 +gr_check_hidden_task(const struct task_struct *tsk)
64448 +{
64449 + return 0;
64450 +}
64451 +
64452 +int
64453 +gr_check_protected_task(const struct task_struct *task)
64454 +{
64455 + return 0;
64456 +}
64457 +
64458 +int
64459 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
64460 +{
64461 + return 0;
64462 +}
64463 +
64464 +void
64465 +gr_copy_label(struct task_struct *tsk)
64466 +{
64467 + return;
64468 +}
64469 +
64470 +void
64471 +gr_set_pax_flags(struct task_struct *task)
64472 +{
64473 + return;
64474 +}
64475 +
64476 +int
64477 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
64478 + const int unsafe_share)
64479 +{
64480 + return 0;
64481 +}
64482 +
64483 +void
64484 +gr_handle_delete(const ino_t ino, const dev_t dev)
64485 +{
64486 + return;
64487 +}
64488 +
64489 +void
64490 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
64491 +{
64492 + return;
64493 +}
64494 +
64495 +void
64496 +gr_handle_crash(struct task_struct *task, const int sig)
64497 +{
64498 + return;
64499 +}
64500 +
64501 +int
64502 +gr_check_crash_exec(const struct file *filp)
64503 +{
64504 + return 0;
64505 +}
64506 +
64507 +int
64508 +gr_check_crash_uid(const kuid_t uid)
64509 +{
64510 + return 0;
64511 +}
64512 +
64513 +void
64514 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
64515 + struct dentry *old_dentry,
64516 + struct dentry *new_dentry,
64517 + struct vfsmount *mnt, const __u8 replace)
64518 +{
64519 + return;
64520 +}
64521 +
64522 +int
64523 +gr_search_socket(const int family, const int type, const int protocol)
64524 +{
64525 + return 1;
64526 +}
64527 +
64528 +int
64529 +gr_search_connectbind(const int mode, const struct socket *sock,
64530 + const struct sockaddr_in *addr)
64531 +{
64532 + return 0;
64533 +}
64534 +
64535 +void
64536 +gr_handle_alertkill(struct task_struct *task)
64537 +{
64538 + return;
64539 +}
64540 +
64541 +__u32
64542 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
64543 +{
64544 + return 1;
64545 +}
64546 +
64547 +__u32
64548 +gr_acl_handle_hidden_file(const struct dentry * dentry,
64549 + const struct vfsmount * mnt)
64550 +{
64551 + return 1;
64552 +}
64553 +
64554 +__u32
64555 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
64556 + int acc_mode)
64557 +{
64558 + return 1;
64559 +}
64560 +
64561 +__u32
64562 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
64563 +{
64564 + return 1;
64565 +}
64566 +
64567 +__u32
64568 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
64569 +{
64570 + return 1;
64571 +}
64572 +
64573 +int
64574 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
64575 + unsigned int *vm_flags)
64576 +{
64577 + return 1;
64578 +}
64579 +
64580 +__u32
64581 +gr_acl_handle_truncate(const struct dentry * dentry,
64582 + const struct vfsmount * mnt)
64583 +{
64584 + return 1;
64585 +}
64586 +
64587 +__u32
64588 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
64589 +{
64590 + return 1;
64591 +}
64592 +
64593 +__u32
64594 +gr_acl_handle_access(const struct dentry * dentry,
64595 + const struct vfsmount * mnt, const int fmode)
64596 +{
64597 + return 1;
64598 +}
64599 +
64600 +__u32
64601 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
64602 + umode_t *mode)
64603 +{
64604 + return 1;
64605 +}
64606 +
64607 +__u32
64608 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
64609 +{
64610 + return 1;
64611 +}
64612 +
64613 +__u32
64614 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
64615 +{
64616 + return 1;
64617 +}
64618 +
64619 +void
64620 +grsecurity_init(void)
64621 +{
64622 + return;
64623 +}
64624 +
64625 +umode_t gr_acl_umask(void)
64626 +{
64627 + return 0;
64628 +}
64629 +
64630 +__u32
64631 +gr_acl_handle_mknod(const struct dentry * new_dentry,
64632 + const struct dentry * parent_dentry,
64633 + const struct vfsmount * parent_mnt,
64634 + const int mode)
64635 +{
64636 + return 1;
64637 +}
64638 +
64639 +__u32
64640 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
64641 + const struct dentry * parent_dentry,
64642 + const struct vfsmount * parent_mnt)
64643 +{
64644 + return 1;
64645 +}
64646 +
64647 +__u32
64648 +gr_acl_handle_symlink(const struct dentry * new_dentry,
64649 + const struct dentry * parent_dentry,
64650 + const struct vfsmount * parent_mnt, const struct filename *from)
64651 +{
64652 + return 1;
64653 +}
64654 +
64655 +__u32
64656 +gr_acl_handle_link(const struct dentry * new_dentry,
64657 + const struct dentry * parent_dentry,
64658 + const struct vfsmount * parent_mnt,
64659 + const struct dentry * old_dentry,
64660 + const struct vfsmount * old_mnt, const struct filename *to)
64661 +{
64662 + return 1;
64663 +}
64664 +
64665 +int
64666 +gr_acl_handle_rename(const struct dentry *new_dentry,
64667 + const struct dentry *parent_dentry,
64668 + const struct vfsmount *parent_mnt,
64669 + const struct dentry *old_dentry,
64670 + const struct inode *old_parent_inode,
64671 + const struct vfsmount *old_mnt, const struct filename *newname)
64672 +{
64673 + return 0;
64674 +}
64675 +
64676 +int
64677 +gr_acl_handle_filldir(const struct file *file, const char *name,
64678 + const int namelen, const ino_t ino)
64679 +{
64680 + return 1;
64681 +}
64682 +
64683 +int
64684 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
64685 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
64686 +{
64687 + return 1;
64688 +}
64689 +
64690 +int
64691 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
64692 +{
64693 + return 0;
64694 +}
64695 +
64696 +int
64697 +gr_search_accept(const struct socket *sock)
64698 +{
64699 + return 0;
64700 +}
64701 +
64702 +int
64703 +gr_search_listen(const struct socket *sock)
64704 +{
64705 + return 0;
64706 +}
64707 +
64708 +int
64709 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
64710 +{
64711 + return 0;
64712 +}
64713 +
64714 +__u32
64715 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
64716 +{
64717 + return 1;
64718 +}
64719 +
64720 +__u32
64721 +gr_acl_handle_creat(const struct dentry * dentry,
64722 + const struct dentry * p_dentry,
64723 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
64724 + const int imode)
64725 +{
64726 + return 1;
64727 +}
64728 +
64729 +void
64730 +gr_acl_handle_exit(void)
64731 +{
64732 + return;
64733 +}
64734 +
64735 +int
64736 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
64737 +{
64738 + return 1;
64739 +}
64740 +
64741 +void
64742 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
64743 +{
64744 + return;
64745 +}
64746 +
64747 +int
64748 +gr_acl_handle_procpidmem(const struct task_struct *task)
64749 +{
64750 + return 0;
64751 +}
64752 +
64753 +int
64754 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
64755 +{
64756 + return 0;
64757 +}
64758 +
64759 +int
64760 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
64761 +{
64762 + return 0;
64763 +}
64764 +
64765 +void
64766 +gr_set_kernel_label(struct task_struct *task)
64767 +{
64768 + return;
64769 +}
64770 +
64771 +int
64772 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
64773 +{
64774 + return 0;
64775 +}
64776 +
64777 +int
64778 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
64779 +{
64780 + return 0;
64781 +}
64782 +
64783 +int gr_acl_enable_at_secure(void)
64784 +{
64785 + return 0;
64786 +}
64787 +
64788 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
64789 +{
64790 + return dentry->d_sb->s_dev;
64791 +}
64792 +
64793 +void gr_put_exec_file(struct task_struct *task)
64794 +{
64795 + return;
64796 +}
64797 +
64798 +EXPORT_SYMBOL(gr_set_kernel_label);
64799 +#ifdef CONFIG_SECURITY
64800 +EXPORT_SYMBOL(gr_check_user_change);
64801 +EXPORT_SYMBOL(gr_check_group_change);
64802 +#endif
64803 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
64804 new file mode 100644
64805 index 0000000..387032b
64806 --- /dev/null
64807 +++ b/grsecurity/grsec_exec.c
64808 @@ -0,0 +1,187 @@
64809 +#include <linux/kernel.h>
64810 +#include <linux/sched.h>
64811 +#include <linux/file.h>
64812 +#include <linux/binfmts.h>
64813 +#include <linux/fs.h>
64814 +#include <linux/types.h>
64815 +#include <linux/grdefs.h>
64816 +#include <linux/grsecurity.h>
64817 +#include <linux/grinternal.h>
64818 +#include <linux/capability.h>
64819 +#include <linux/module.h>
64820 +#include <linux/compat.h>
64821 +
64822 +#include <asm/uaccess.h>
64823 +
64824 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64825 +static char gr_exec_arg_buf[132];
64826 +static DEFINE_MUTEX(gr_exec_arg_mutex);
64827 +#endif
64828 +
64829 +struct user_arg_ptr {
64830 +#ifdef CONFIG_COMPAT
64831 + bool is_compat;
64832 +#endif
64833 + union {
64834 + const char __user *const __user *native;
64835 +#ifdef CONFIG_COMPAT
64836 + const compat_uptr_t __user *compat;
64837 +#endif
64838 + } ptr;
64839 +};
64840 +
64841 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
64842 +
64843 +void
64844 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
64845 +{
64846 +#ifdef CONFIG_GRKERNSEC_EXECLOG
64847 + char *grarg = gr_exec_arg_buf;
64848 + unsigned int i, x, execlen = 0;
64849 + char c;
64850 +
64851 + if (!((grsec_enable_execlog && grsec_enable_group &&
64852 + in_group_p(grsec_audit_gid))
64853 + || (grsec_enable_execlog && !grsec_enable_group)))
64854 + return;
64855 +
64856 + mutex_lock(&gr_exec_arg_mutex);
64857 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
64858 +
64859 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
64860 + const char __user *p;
64861 + unsigned int len;
64862 +
64863 + p = get_user_arg_ptr(argv, i);
64864 + if (IS_ERR(p))
64865 + goto log;
64866 +
64867 + len = strnlen_user(p, 128 - execlen);
64868 + if (len > 128 - execlen)
64869 + len = 128 - execlen;
64870 + else if (len > 0)
64871 + len--;
64872 + if (copy_from_user(grarg + execlen, p, len))
64873 + goto log;
64874 +
64875 + /* rewrite unprintable characters */
64876 + for (x = 0; x < len; x++) {
64877 + c = *(grarg + execlen + x);
64878 + if (c < 32 || c > 126)
64879 + *(grarg + execlen + x) = ' ';
64880 + }
64881 +
64882 + execlen += len;
64883 + *(grarg + execlen) = ' ';
64884 + *(grarg + execlen + 1) = '\0';
64885 + execlen++;
64886 + }
64887 +
64888 + log:
64889 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
64890 + bprm->file->f_path.mnt, grarg);
64891 + mutex_unlock(&gr_exec_arg_mutex);
64892 +#endif
64893 + return;
64894 +}
64895 +
64896 +#ifdef CONFIG_GRKERNSEC
64897 +extern int gr_acl_is_capable(const int cap);
64898 +extern int gr_acl_is_capable_nolog(const int cap);
64899 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
64900 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
64901 +extern int gr_chroot_is_capable(const int cap);
64902 +extern int gr_chroot_is_capable_nolog(const int cap);
64903 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
64904 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
64905 +#endif
64906 +
64907 +const char *captab_log[] = {
64908 + "CAP_CHOWN",
64909 + "CAP_DAC_OVERRIDE",
64910 + "CAP_DAC_READ_SEARCH",
64911 + "CAP_FOWNER",
64912 + "CAP_FSETID",
64913 + "CAP_KILL",
64914 + "CAP_SETGID",
64915 + "CAP_SETUID",
64916 + "CAP_SETPCAP",
64917 + "CAP_LINUX_IMMUTABLE",
64918 + "CAP_NET_BIND_SERVICE",
64919 + "CAP_NET_BROADCAST",
64920 + "CAP_NET_ADMIN",
64921 + "CAP_NET_RAW",
64922 + "CAP_IPC_LOCK",
64923 + "CAP_IPC_OWNER",
64924 + "CAP_SYS_MODULE",
64925 + "CAP_SYS_RAWIO",
64926 + "CAP_SYS_CHROOT",
64927 + "CAP_SYS_PTRACE",
64928 + "CAP_SYS_PACCT",
64929 + "CAP_SYS_ADMIN",
64930 + "CAP_SYS_BOOT",
64931 + "CAP_SYS_NICE",
64932 + "CAP_SYS_RESOURCE",
64933 + "CAP_SYS_TIME",
64934 + "CAP_SYS_TTY_CONFIG",
64935 + "CAP_MKNOD",
64936 + "CAP_LEASE",
64937 + "CAP_AUDIT_WRITE",
64938 + "CAP_AUDIT_CONTROL",
64939 + "CAP_SETFCAP",
64940 + "CAP_MAC_OVERRIDE",
64941 + "CAP_MAC_ADMIN",
64942 + "CAP_SYSLOG",
64943 + "CAP_WAKE_ALARM"
64944 +};
64945 +
64946 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
64947 +
64948 +int gr_is_capable(const int cap)
64949 +{
64950 +#ifdef CONFIG_GRKERNSEC
64951 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
64952 + return 1;
64953 + return 0;
64954 +#else
64955 + return 1;
64956 +#endif
64957 +}
64958 +
64959 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
64960 +{
64961 +#ifdef CONFIG_GRKERNSEC
64962 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
64963 + return 1;
64964 + return 0;
64965 +#else
64966 + return 1;
64967 +#endif
64968 +}
64969 +
64970 +int gr_is_capable_nolog(const int cap)
64971 +{
64972 +#ifdef CONFIG_GRKERNSEC
64973 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
64974 + return 1;
64975 + return 0;
64976 +#else
64977 + return 1;
64978 +#endif
64979 +}
64980 +
64981 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
64982 +{
64983 +#ifdef CONFIG_GRKERNSEC
64984 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
64985 + return 1;
64986 + return 0;
64987 +#else
64988 + return 1;
64989 +#endif
64990 +}
64991 +
64992 +EXPORT_SYMBOL(gr_is_capable);
64993 +EXPORT_SYMBOL(gr_is_capable_nolog);
64994 +EXPORT_SYMBOL(gr_task_is_capable);
64995 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
64996 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
64997 new file mode 100644
64998 index 0000000..06cc6ea
64999 --- /dev/null
65000 +++ b/grsecurity/grsec_fifo.c
65001 @@ -0,0 +1,24 @@
65002 +#include <linux/kernel.h>
65003 +#include <linux/sched.h>
65004 +#include <linux/fs.h>
65005 +#include <linux/file.h>
65006 +#include <linux/grinternal.h>
65007 +
65008 +int
65009 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
65010 + const struct dentry *dir, const int flag, const int acc_mode)
65011 +{
65012 +#ifdef CONFIG_GRKERNSEC_FIFO
65013 + const struct cred *cred = current_cred();
65014 +
65015 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
65016 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
65017 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
65018 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
65019 + if (!inode_permission(dentry->d_inode, acc_mode))
65020 + 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));
65021 + return -EACCES;
65022 + }
65023 +#endif
65024 + return 0;
65025 +}
65026 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
65027 new file mode 100644
65028 index 0000000..8ca18bf
65029 --- /dev/null
65030 +++ b/grsecurity/grsec_fork.c
65031 @@ -0,0 +1,23 @@
65032 +#include <linux/kernel.h>
65033 +#include <linux/sched.h>
65034 +#include <linux/grsecurity.h>
65035 +#include <linux/grinternal.h>
65036 +#include <linux/errno.h>
65037 +
65038 +void
65039 +gr_log_forkfail(const int retval)
65040 +{
65041 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
65042 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
65043 + switch (retval) {
65044 + case -EAGAIN:
65045 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
65046 + break;
65047 + case -ENOMEM:
65048 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
65049 + break;
65050 + }
65051 + }
65052 +#endif
65053 + return;
65054 +}
65055 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
65056 new file mode 100644
65057 index 0000000..a862e9f
65058 --- /dev/null
65059 +++ b/grsecurity/grsec_init.c
65060 @@ -0,0 +1,283 @@
65061 +#include <linux/kernel.h>
65062 +#include <linux/sched.h>
65063 +#include <linux/mm.h>
65064 +#include <linux/gracl.h>
65065 +#include <linux/slab.h>
65066 +#include <linux/vmalloc.h>
65067 +#include <linux/percpu.h>
65068 +#include <linux/module.h>
65069 +
65070 +int grsec_enable_ptrace_readexec;
65071 +int grsec_enable_setxid;
65072 +int grsec_enable_symlinkown;
65073 +kgid_t grsec_symlinkown_gid;
65074 +int grsec_enable_brute;
65075 +int grsec_enable_link;
65076 +int grsec_enable_dmesg;
65077 +int grsec_enable_harden_ptrace;
65078 +int grsec_enable_fifo;
65079 +int grsec_enable_execlog;
65080 +int grsec_enable_signal;
65081 +int grsec_enable_forkfail;
65082 +int grsec_enable_audit_ptrace;
65083 +int grsec_enable_time;
65084 +int grsec_enable_audit_textrel;
65085 +int grsec_enable_group;
65086 +kgid_t grsec_audit_gid;
65087 +int grsec_enable_chdir;
65088 +int grsec_enable_mount;
65089 +int grsec_enable_rofs;
65090 +int grsec_enable_chroot_findtask;
65091 +int grsec_enable_chroot_mount;
65092 +int grsec_enable_chroot_shmat;
65093 +int grsec_enable_chroot_fchdir;
65094 +int grsec_enable_chroot_double;
65095 +int grsec_enable_chroot_pivot;
65096 +int grsec_enable_chroot_chdir;
65097 +int grsec_enable_chroot_chmod;
65098 +int grsec_enable_chroot_mknod;
65099 +int grsec_enable_chroot_nice;
65100 +int grsec_enable_chroot_execlog;
65101 +int grsec_enable_chroot_caps;
65102 +int grsec_enable_chroot_sysctl;
65103 +int grsec_enable_chroot_unix;
65104 +int grsec_enable_tpe;
65105 +kgid_t grsec_tpe_gid;
65106 +int grsec_enable_blackhole;
65107 +#ifdef CONFIG_IPV6_MODULE
65108 +EXPORT_SYMBOL(grsec_enable_blackhole);
65109 +#endif
65110 +int grsec_lastack_retries;
65111 +int grsec_enable_tpe_all;
65112 +int grsec_enable_tpe_invert;
65113 +int grsec_enable_socket_all;
65114 +kgid_t grsec_socket_all_gid;
65115 +int grsec_enable_socket_client;
65116 +kgid_t grsec_socket_client_gid;
65117 +int grsec_enable_socket_server;
65118 +kgid_t grsec_socket_server_gid;
65119 +int grsec_resource_logging;
65120 +int grsec_disable_privio;
65121 +int grsec_enable_log_rwxmaps;
65122 +int grsec_lock;
65123 +
65124 +DEFINE_SPINLOCK(grsec_alert_lock);
65125 +unsigned long grsec_alert_wtime = 0;
65126 +unsigned long grsec_alert_fyet = 0;
65127 +
65128 +DEFINE_SPINLOCK(grsec_audit_lock);
65129 +
65130 +DEFINE_RWLOCK(grsec_exec_file_lock);
65131 +
65132 +char *gr_shared_page[4];
65133 +
65134 +char *gr_alert_log_fmt;
65135 +char *gr_audit_log_fmt;
65136 +char *gr_alert_log_buf;
65137 +char *gr_audit_log_buf;
65138 +
65139 +extern struct gr_arg *gr_usermode;
65140 +extern unsigned char *gr_system_salt;
65141 +extern unsigned char *gr_system_sum;
65142 +
65143 +void __init
65144 +grsecurity_init(void)
65145 +{
65146 + int j;
65147 + /* create the per-cpu shared pages */
65148 +
65149 +#ifdef CONFIG_X86
65150 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
65151 +#endif
65152 +
65153 + for (j = 0; j < 4; j++) {
65154 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
65155 + if (gr_shared_page[j] == NULL) {
65156 + panic("Unable to allocate grsecurity shared page");
65157 + return;
65158 + }
65159 + }
65160 +
65161 + /* allocate log buffers */
65162 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
65163 + if (!gr_alert_log_fmt) {
65164 + panic("Unable to allocate grsecurity alert log format buffer");
65165 + return;
65166 + }
65167 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
65168 + if (!gr_audit_log_fmt) {
65169 + panic("Unable to allocate grsecurity audit log format buffer");
65170 + return;
65171 + }
65172 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
65173 + if (!gr_alert_log_buf) {
65174 + panic("Unable to allocate grsecurity alert log buffer");
65175 + return;
65176 + }
65177 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
65178 + if (!gr_audit_log_buf) {
65179 + panic("Unable to allocate grsecurity audit log buffer");
65180 + return;
65181 + }
65182 +
65183 + /* allocate memory for authentication structure */
65184 + gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
65185 + gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
65186 + gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
65187 +
65188 + if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
65189 + panic("Unable to allocate grsecurity authentication structure");
65190 + return;
65191 + }
65192 +
65193 +
65194 +#ifdef CONFIG_GRKERNSEC_IO
65195 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
65196 + grsec_disable_privio = 1;
65197 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
65198 + grsec_disable_privio = 1;
65199 +#else
65200 + grsec_disable_privio = 0;
65201 +#endif
65202 +#endif
65203 +
65204 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
65205 + /* for backward compatibility, tpe_invert always defaults to on if
65206 + enabled in the kernel
65207 + */
65208 + grsec_enable_tpe_invert = 1;
65209 +#endif
65210 +
65211 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
65212 +#ifndef CONFIG_GRKERNSEC_SYSCTL
65213 + grsec_lock = 1;
65214 +#endif
65215 +
65216 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
65217 + grsec_enable_audit_textrel = 1;
65218 +#endif
65219 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65220 + grsec_enable_log_rwxmaps = 1;
65221 +#endif
65222 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
65223 + grsec_enable_group = 1;
65224 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
65225 +#endif
65226 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
65227 + grsec_enable_ptrace_readexec = 1;
65228 +#endif
65229 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
65230 + grsec_enable_chdir = 1;
65231 +#endif
65232 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
65233 + grsec_enable_harden_ptrace = 1;
65234 +#endif
65235 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65236 + grsec_enable_mount = 1;
65237 +#endif
65238 +#ifdef CONFIG_GRKERNSEC_LINK
65239 + grsec_enable_link = 1;
65240 +#endif
65241 +#ifdef CONFIG_GRKERNSEC_BRUTE
65242 + grsec_enable_brute = 1;
65243 +#endif
65244 +#ifdef CONFIG_GRKERNSEC_DMESG
65245 + grsec_enable_dmesg = 1;
65246 +#endif
65247 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
65248 + grsec_enable_blackhole = 1;
65249 + grsec_lastack_retries = 4;
65250 +#endif
65251 +#ifdef CONFIG_GRKERNSEC_FIFO
65252 + grsec_enable_fifo = 1;
65253 +#endif
65254 +#ifdef CONFIG_GRKERNSEC_EXECLOG
65255 + grsec_enable_execlog = 1;
65256 +#endif
65257 +#ifdef CONFIG_GRKERNSEC_SETXID
65258 + grsec_enable_setxid = 1;
65259 +#endif
65260 +#ifdef CONFIG_GRKERNSEC_SIGNAL
65261 + grsec_enable_signal = 1;
65262 +#endif
65263 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
65264 + grsec_enable_forkfail = 1;
65265 +#endif
65266 +#ifdef CONFIG_GRKERNSEC_TIME
65267 + grsec_enable_time = 1;
65268 +#endif
65269 +#ifdef CONFIG_GRKERNSEC_RESLOG
65270 + grsec_resource_logging = 1;
65271 +#endif
65272 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
65273 + grsec_enable_chroot_findtask = 1;
65274 +#endif
65275 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
65276 + grsec_enable_chroot_unix = 1;
65277 +#endif
65278 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
65279 + grsec_enable_chroot_mount = 1;
65280 +#endif
65281 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
65282 + grsec_enable_chroot_fchdir = 1;
65283 +#endif
65284 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
65285 + grsec_enable_chroot_shmat = 1;
65286 +#endif
65287 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
65288 + grsec_enable_audit_ptrace = 1;
65289 +#endif
65290 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
65291 + grsec_enable_chroot_double = 1;
65292 +#endif
65293 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
65294 + grsec_enable_chroot_pivot = 1;
65295 +#endif
65296 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
65297 + grsec_enable_chroot_chdir = 1;
65298 +#endif
65299 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
65300 + grsec_enable_chroot_chmod = 1;
65301 +#endif
65302 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
65303 + grsec_enable_chroot_mknod = 1;
65304 +#endif
65305 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
65306 + grsec_enable_chroot_nice = 1;
65307 +#endif
65308 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
65309 + grsec_enable_chroot_execlog = 1;
65310 +#endif
65311 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
65312 + grsec_enable_chroot_caps = 1;
65313 +#endif
65314 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
65315 + grsec_enable_chroot_sysctl = 1;
65316 +#endif
65317 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
65318 + grsec_enable_symlinkown = 1;
65319 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
65320 +#endif
65321 +#ifdef CONFIG_GRKERNSEC_TPE
65322 + grsec_enable_tpe = 1;
65323 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
65324 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
65325 + grsec_enable_tpe_all = 1;
65326 +#endif
65327 +#endif
65328 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
65329 + grsec_enable_socket_all = 1;
65330 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
65331 +#endif
65332 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
65333 + grsec_enable_socket_client = 1;
65334 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
65335 +#endif
65336 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
65337 + grsec_enable_socket_server = 1;
65338 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
65339 +#endif
65340 +#endif
65341 +
65342 + return;
65343 +}
65344 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
65345 new file mode 100644
65346 index 0000000..5e05e20
65347 --- /dev/null
65348 +++ b/grsecurity/grsec_link.c
65349 @@ -0,0 +1,58 @@
65350 +#include <linux/kernel.h>
65351 +#include <linux/sched.h>
65352 +#include <linux/fs.h>
65353 +#include <linux/file.h>
65354 +#include <linux/grinternal.h>
65355 +
65356 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
65357 +{
65358 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
65359 + const struct inode *link_inode = link->dentry->d_inode;
65360 +
65361 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
65362 + /* ignore root-owned links, e.g. /proc/self */
65363 + gr_is_global_nonroot(link_inode->i_uid) && target &&
65364 + !uid_eq(link_inode->i_uid, target->i_uid)) {
65365 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
65366 + return 1;
65367 + }
65368 +#endif
65369 + return 0;
65370 +}
65371 +
65372 +int
65373 +gr_handle_follow_link(const struct inode *parent,
65374 + const struct inode *inode,
65375 + const struct dentry *dentry, const struct vfsmount *mnt)
65376 +{
65377 +#ifdef CONFIG_GRKERNSEC_LINK
65378 + const struct cred *cred = current_cred();
65379 +
65380 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
65381 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
65382 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
65383 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
65384 + return -EACCES;
65385 + }
65386 +#endif
65387 + return 0;
65388 +}
65389 +
65390 +int
65391 +gr_handle_hardlink(const struct dentry *dentry,
65392 + const struct vfsmount *mnt,
65393 + struct inode *inode, const int mode, const struct filename *to)
65394 +{
65395 +#ifdef CONFIG_GRKERNSEC_LINK
65396 + const struct cred *cred = current_cred();
65397 +
65398 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
65399 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
65400 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
65401 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
65402 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
65403 + return -EPERM;
65404 + }
65405 +#endif
65406 + return 0;
65407 +}
65408 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
65409 new file mode 100644
65410 index 0000000..7c06085
65411 --- /dev/null
65412 +++ b/grsecurity/grsec_log.c
65413 @@ -0,0 +1,326 @@
65414 +#include <linux/kernel.h>
65415 +#include <linux/sched.h>
65416 +#include <linux/file.h>
65417 +#include <linux/tty.h>
65418 +#include <linux/fs.h>
65419 +#include <linux/grinternal.h>
65420 +
65421 +#ifdef CONFIG_TREE_PREEMPT_RCU
65422 +#define DISABLE_PREEMPT() preempt_disable()
65423 +#define ENABLE_PREEMPT() preempt_enable()
65424 +#else
65425 +#define DISABLE_PREEMPT()
65426 +#define ENABLE_PREEMPT()
65427 +#endif
65428 +
65429 +#define BEGIN_LOCKS(x) \
65430 + DISABLE_PREEMPT(); \
65431 + rcu_read_lock(); \
65432 + read_lock(&tasklist_lock); \
65433 + read_lock(&grsec_exec_file_lock); \
65434 + if (x != GR_DO_AUDIT) \
65435 + spin_lock(&grsec_alert_lock); \
65436 + else \
65437 + spin_lock(&grsec_audit_lock)
65438 +
65439 +#define END_LOCKS(x) \
65440 + if (x != GR_DO_AUDIT) \
65441 + spin_unlock(&grsec_alert_lock); \
65442 + else \
65443 + spin_unlock(&grsec_audit_lock); \
65444 + read_unlock(&grsec_exec_file_lock); \
65445 + read_unlock(&tasklist_lock); \
65446 + rcu_read_unlock(); \
65447 + ENABLE_PREEMPT(); \
65448 + if (x == GR_DONT_AUDIT) \
65449 + gr_handle_alertkill(current)
65450 +
65451 +enum {
65452 + FLOODING,
65453 + NO_FLOODING
65454 +};
65455 +
65456 +extern char *gr_alert_log_fmt;
65457 +extern char *gr_audit_log_fmt;
65458 +extern char *gr_alert_log_buf;
65459 +extern char *gr_audit_log_buf;
65460 +
65461 +static int gr_log_start(int audit)
65462 +{
65463 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
65464 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
65465 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65466 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
65467 + unsigned long curr_secs = get_seconds();
65468 +
65469 + if (audit == GR_DO_AUDIT)
65470 + goto set_fmt;
65471 +
65472 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
65473 + grsec_alert_wtime = curr_secs;
65474 + grsec_alert_fyet = 0;
65475 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
65476 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
65477 + grsec_alert_fyet++;
65478 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
65479 + grsec_alert_wtime = curr_secs;
65480 + grsec_alert_fyet++;
65481 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
65482 + return FLOODING;
65483 + }
65484 + else return FLOODING;
65485 +
65486 +set_fmt:
65487 +#endif
65488 + memset(buf, 0, PAGE_SIZE);
65489 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
65490 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
65491 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
65492 + } else if (current->signal->curr_ip) {
65493 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
65494 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
65495 + } else if (gr_acl_is_enabled()) {
65496 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
65497 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
65498 + } else {
65499 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
65500 + strcpy(buf, fmt);
65501 + }
65502 +
65503 + return NO_FLOODING;
65504 +}
65505 +
65506 +static void gr_log_middle(int audit, const char *msg, va_list ap)
65507 + __attribute__ ((format (printf, 2, 0)));
65508 +
65509 +static void gr_log_middle(int audit, const char *msg, va_list ap)
65510 +{
65511 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65512 + unsigned int len = strlen(buf);
65513 +
65514 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
65515 +
65516 + return;
65517 +}
65518 +
65519 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
65520 + __attribute__ ((format (printf, 2, 3)));
65521 +
65522 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
65523 +{
65524 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65525 + unsigned int len = strlen(buf);
65526 + va_list ap;
65527 +
65528 + va_start(ap, msg);
65529 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
65530 + va_end(ap);
65531 +
65532 + return;
65533 +}
65534 +
65535 +static void gr_log_end(int audit, int append_default)
65536 +{
65537 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
65538 + if (append_default) {
65539 + struct task_struct *task = current;
65540 + struct task_struct *parent = task->real_parent;
65541 + const struct cred *cred = __task_cred(task);
65542 + const struct cred *pcred = __task_cred(parent);
65543 + unsigned int len = strlen(buf);
65544 +
65545 + 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));
65546 + }
65547 +
65548 + printk("%s\n", buf);
65549 +
65550 + return;
65551 +}
65552 +
65553 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
65554 +{
65555 + int logtype;
65556 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
65557 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
65558 + void *voidptr = NULL;
65559 + int num1 = 0, num2 = 0;
65560 + unsigned long ulong1 = 0, ulong2 = 0;
65561 + struct dentry *dentry = NULL;
65562 + struct vfsmount *mnt = NULL;
65563 + struct file *file = NULL;
65564 + struct task_struct *task = NULL;
65565 + const struct cred *cred, *pcred;
65566 + va_list ap;
65567 +
65568 + BEGIN_LOCKS(audit);
65569 + logtype = gr_log_start(audit);
65570 + if (logtype == FLOODING) {
65571 + END_LOCKS(audit);
65572 + return;
65573 + }
65574 + va_start(ap, argtypes);
65575 + switch (argtypes) {
65576 + case GR_TTYSNIFF:
65577 + task = va_arg(ap, struct task_struct *);
65578 + 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));
65579 + break;
65580 + case GR_SYSCTL_HIDDEN:
65581 + str1 = va_arg(ap, char *);
65582 + gr_log_middle_varargs(audit, msg, result, str1);
65583 + break;
65584 + case GR_RBAC:
65585 + dentry = va_arg(ap, struct dentry *);
65586 + mnt = va_arg(ap, struct vfsmount *);
65587 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
65588 + break;
65589 + case GR_RBAC_STR:
65590 + dentry = va_arg(ap, struct dentry *);
65591 + mnt = va_arg(ap, struct vfsmount *);
65592 + str1 = va_arg(ap, char *);
65593 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
65594 + break;
65595 + case GR_STR_RBAC:
65596 + str1 = va_arg(ap, char *);
65597 + dentry = va_arg(ap, struct dentry *);
65598 + mnt = va_arg(ap, struct vfsmount *);
65599 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
65600 + break;
65601 + case GR_RBAC_MODE2:
65602 + dentry = va_arg(ap, struct dentry *);
65603 + mnt = va_arg(ap, struct vfsmount *);
65604 + str1 = va_arg(ap, char *);
65605 + str2 = va_arg(ap, char *);
65606 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
65607 + break;
65608 + case GR_RBAC_MODE3:
65609 + dentry = va_arg(ap, struct dentry *);
65610 + mnt = va_arg(ap, struct vfsmount *);
65611 + str1 = va_arg(ap, char *);
65612 + str2 = va_arg(ap, char *);
65613 + str3 = va_arg(ap, char *);
65614 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
65615 + break;
65616 + case GR_FILENAME:
65617 + dentry = va_arg(ap, struct dentry *);
65618 + mnt = va_arg(ap, struct vfsmount *);
65619 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
65620 + break;
65621 + case GR_STR_FILENAME:
65622 + str1 = va_arg(ap, char *);
65623 + dentry = va_arg(ap, struct dentry *);
65624 + mnt = va_arg(ap, struct vfsmount *);
65625 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
65626 + break;
65627 + case GR_FILENAME_STR:
65628 + dentry = va_arg(ap, struct dentry *);
65629 + mnt = va_arg(ap, struct vfsmount *);
65630 + str1 = va_arg(ap, char *);
65631 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
65632 + break;
65633 + case GR_FILENAME_TWO_INT:
65634 + dentry = va_arg(ap, struct dentry *);
65635 + mnt = va_arg(ap, struct vfsmount *);
65636 + num1 = va_arg(ap, int);
65637 + num2 = va_arg(ap, int);
65638 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
65639 + break;
65640 + case GR_FILENAME_TWO_INT_STR:
65641 + dentry = va_arg(ap, struct dentry *);
65642 + mnt = va_arg(ap, struct vfsmount *);
65643 + num1 = va_arg(ap, int);
65644 + num2 = va_arg(ap, int);
65645 + str1 = va_arg(ap, char *);
65646 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
65647 + break;
65648 + case GR_TEXTREL:
65649 + file = va_arg(ap, struct file *);
65650 + ulong1 = va_arg(ap, unsigned long);
65651 + ulong2 = va_arg(ap, unsigned long);
65652 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
65653 + break;
65654 + case GR_PTRACE:
65655 + task = va_arg(ap, struct task_struct *);
65656 + 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));
65657 + break;
65658 + case GR_RESOURCE:
65659 + task = va_arg(ap, struct task_struct *);
65660 + cred = __task_cred(task);
65661 + pcred = __task_cred(task->real_parent);
65662 + ulong1 = va_arg(ap, unsigned long);
65663 + str1 = va_arg(ap, char *);
65664 + ulong2 = va_arg(ap, unsigned long);
65665 + 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));
65666 + break;
65667 + case GR_CAP:
65668 + task = va_arg(ap, struct task_struct *);
65669 + cred = __task_cred(task);
65670 + pcred = __task_cred(task->real_parent);
65671 + str1 = va_arg(ap, char *);
65672 + 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));
65673 + break;
65674 + case GR_SIG:
65675 + str1 = va_arg(ap, char *);
65676 + voidptr = va_arg(ap, void *);
65677 + gr_log_middle_varargs(audit, msg, str1, voidptr);
65678 + break;
65679 + case GR_SIG2:
65680 + task = va_arg(ap, struct task_struct *);
65681 + cred = __task_cred(task);
65682 + pcred = __task_cred(task->real_parent);
65683 + num1 = va_arg(ap, int);
65684 + 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));
65685 + break;
65686 + case GR_CRASH1:
65687 + task = va_arg(ap, struct task_struct *);
65688 + cred = __task_cred(task);
65689 + pcred = __task_cred(task->real_parent);
65690 + ulong1 = va_arg(ap, unsigned long);
65691 + 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);
65692 + break;
65693 + case GR_CRASH2:
65694 + task = va_arg(ap, struct task_struct *);
65695 + cred = __task_cred(task);
65696 + pcred = __task_cred(task->real_parent);
65697 + ulong1 = va_arg(ap, unsigned long);
65698 + 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);
65699 + break;
65700 + case GR_RWXMAP:
65701 + file = va_arg(ap, struct file *);
65702 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
65703 + break;
65704 + case GR_PSACCT:
65705 + {
65706 + unsigned int wday, cday;
65707 + __u8 whr, chr;
65708 + __u8 wmin, cmin;
65709 + __u8 wsec, csec;
65710 + char cur_tty[64] = { 0 };
65711 + char parent_tty[64] = { 0 };
65712 +
65713 + task = va_arg(ap, struct task_struct *);
65714 + wday = va_arg(ap, unsigned int);
65715 + cday = va_arg(ap, unsigned int);
65716 + whr = va_arg(ap, int);
65717 + chr = va_arg(ap, int);
65718 + wmin = va_arg(ap, int);
65719 + cmin = va_arg(ap, int);
65720 + wsec = va_arg(ap, int);
65721 + csec = va_arg(ap, int);
65722 + ulong1 = va_arg(ap, unsigned long);
65723 + cred = __task_cred(task);
65724 + pcred = __task_cred(task->real_parent);
65725 +
65726 + 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));
65727 + }
65728 + break;
65729 + default:
65730 + gr_log_middle(audit, msg, ap);
65731 + }
65732 + va_end(ap);
65733 + // these don't need DEFAULTSECARGS printed on the end
65734 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
65735 + gr_log_end(audit, 0);
65736 + else
65737 + gr_log_end(audit, 1);
65738 + END_LOCKS(audit);
65739 +}
65740 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
65741 new file mode 100644
65742 index 0000000..f536303
65743 --- /dev/null
65744 +++ b/grsecurity/grsec_mem.c
65745 @@ -0,0 +1,40 @@
65746 +#include <linux/kernel.h>
65747 +#include <linux/sched.h>
65748 +#include <linux/mm.h>
65749 +#include <linux/mman.h>
65750 +#include <linux/grinternal.h>
65751 +
65752 +void
65753 +gr_handle_ioperm(void)
65754 +{
65755 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
65756 + return;
65757 +}
65758 +
65759 +void
65760 +gr_handle_iopl(void)
65761 +{
65762 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
65763 + return;
65764 +}
65765 +
65766 +void
65767 +gr_handle_mem_readwrite(u64 from, u64 to)
65768 +{
65769 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
65770 + return;
65771 +}
65772 +
65773 +void
65774 +gr_handle_vm86(void)
65775 +{
65776 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
65777 + return;
65778 +}
65779 +
65780 +void
65781 +gr_log_badprocpid(const char *entry)
65782 +{
65783 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
65784 + return;
65785 +}
65786 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
65787 new file mode 100644
65788 index 0000000..2131422
65789 --- /dev/null
65790 +++ b/grsecurity/grsec_mount.c
65791 @@ -0,0 +1,62 @@
65792 +#include <linux/kernel.h>
65793 +#include <linux/sched.h>
65794 +#include <linux/mount.h>
65795 +#include <linux/grsecurity.h>
65796 +#include <linux/grinternal.h>
65797 +
65798 +void
65799 +gr_log_remount(const char *devname, const int retval)
65800 +{
65801 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65802 + if (grsec_enable_mount && (retval >= 0))
65803 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
65804 +#endif
65805 + return;
65806 +}
65807 +
65808 +void
65809 +gr_log_unmount(const char *devname, const int retval)
65810 +{
65811 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65812 + if (grsec_enable_mount && (retval >= 0))
65813 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
65814 +#endif
65815 + return;
65816 +}
65817 +
65818 +void
65819 +gr_log_mount(const char *from, const char *to, const int retval)
65820 +{
65821 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
65822 + if (grsec_enable_mount && (retval >= 0))
65823 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
65824 +#endif
65825 + return;
65826 +}
65827 +
65828 +int
65829 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
65830 +{
65831 +#ifdef CONFIG_GRKERNSEC_ROFS
65832 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
65833 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
65834 + return -EPERM;
65835 + } else
65836 + return 0;
65837 +#endif
65838 + return 0;
65839 +}
65840 +
65841 +int
65842 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
65843 +{
65844 +#ifdef CONFIG_GRKERNSEC_ROFS
65845 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
65846 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
65847 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
65848 + return -EPERM;
65849 + } else
65850 + return 0;
65851 +#endif
65852 + return 0;
65853 +}
65854 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
65855 new file mode 100644
65856 index 0000000..a3b12a0
65857 --- /dev/null
65858 +++ b/grsecurity/grsec_pax.c
65859 @@ -0,0 +1,36 @@
65860 +#include <linux/kernel.h>
65861 +#include <linux/sched.h>
65862 +#include <linux/mm.h>
65863 +#include <linux/file.h>
65864 +#include <linux/grinternal.h>
65865 +#include <linux/grsecurity.h>
65866 +
65867 +void
65868 +gr_log_textrel(struct vm_area_struct * vma)
65869 +{
65870 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
65871 + if (grsec_enable_audit_textrel)
65872 + gr_log_textrel_ulong_ulong(GR_DO_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
65873 +#endif
65874 + return;
65875 +}
65876 +
65877 +void
65878 +gr_log_rwxmmap(struct file *file)
65879 +{
65880 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65881 + if (grsec_enable_log_rwxmaps)
65882 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
65883 +#endif
65884 + return;
65885 +}
65886 +
65887 +void
65888 +gr_log_rwxmprotect(struct file *file)
65889 +{
65890 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
65891 + if (grsec_enable_log_rwxmaps)
65892 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, file);
65893 +#endif
65894 + return;
65895 +}
65896 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
65897 new file mode 100644
65898 index 0000000..f7f29aa
65899 --- /dev/null
65900 +++ b/grsecurity/grsec_ptrace.c
65901 @@ -0,0 +1,30 @@
65902 +#include <linux/kernel.h>
65903 +#include <linux/sched.h>
65904 +#include <linux/grinternal.h>
65905 +#include <linux/security.h>
65906 +
65907 +void
65908 +gr_audit_ptrace(struct task_struct *task)
65909 +{
65910 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
65911 + if (grsec_enable_audit_ptrace)
65912 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
65913 +#endif
65914 + return;
65915 +}
65916 +
65917 +int
65918 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
65919 +{
65920 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
65921 + const struct dentry *dentry = file->f_path.dentry;
65922 + const struct vfsmount *mnt = file->f_path.mnt;
65923 +
65924 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
65925 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
65926 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
65927 + return -EACCES;
65928 + }
65929 +#endif
65930 + return 0;
65931 +}
65932 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
65933 new file mode 100644
65934 index 0000000..4e29cc7
65935 --- /dev/null
65936 +++ b/grsecurity/grsec_sig.c
65937 @@ -0,0 +1,246 @@
65938 +#include <linux/kernel.h>
65939 +#include <linux/sched.h>
65940 +#include <linux/fs.h>
65941 +#include <linux/delay.h>
65942 +#include <linux/grsecurity.h>
65943 +#include <linux/grinternal.h>
65944 +#include <linux/hardirq.h>
65945 +
65946 +char *signames[] = {
65947 + [SIGSEGV] = "Segmentation fault",
65948 + [SIGILL] = "Illegal instruction",
65949 + [SIGABRT] = "Abort",
65950 + [SIGBUS] = "Invalid alignment/Bus error"
65951 +};
65952 +
65953 +void
65954 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
65955 +{
65956 +#ifdef CONFIG_GRKERNSEC_SIGNAL
65957 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
65958 + (sig == SIGABRT) || (sig == SIGBUS))) {
65959 + if (task_pid_nr(t) == task_pid_nr(current)) {
65960 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
65961 + } else {
65962 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
65963 + }
65964 + }
65965 +#endif
65966 + return;
65967 +}
65968 +
65969 +int
65970 +gr_handle_signal(const struct task_struct *p, const int sig)
65971 +{
65972 +#ifdef CONFIG_GRKERNSEC
65973 + /* ignore the 0 signal for protected task checks */
65974 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
65975 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
65976 + return -EPERM;
65977 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
65978 + return -EPERM;
65979 + }
65980 +#endif
65981 + return 0;
65982 +}
65983 +
65984 +#ifdef CONFIG_GRKERNSEC
65985 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
65986 +
65987 +int gr_fake_force_sig(int sig, struct task_struct *t)
65988 +{
65989 + unsigned long int flags;
65990 + int ret, blocked, ignored;
65991 + struct k_sigaction *action;
65992 +
65993 + spin_lock_irqsave(&t->sighand->siglock, flags);
65994 + action = &t->sighand->action[sig-1];
65995 + ignored = action->sa.sa_handler == SIG_IGN;
65996 + blocked = sigismember(&t->blocked, sig);
65997 + if (blocked || ignored) {
65998 + action->sa.sa_handler = SIG_DFL;
65999 + if (blocked) {
66000 + sigdelset(&t->blocked, sig);
66001 + recalc_sigpending_and_wake(t);
66002 + }
66003 + }
66004 + if (action->sa.sa_handler == SIG_DFL)
66005 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
66006 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
66007 +
66008 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
66009 +
66010 + return ret;
66011 +}
66012 +#endif
66013 +
66014 +#ifdef CONFIG_GRKERNSEC_BRUTE
66015 +#define GR_USER_BAN_TIME (15 * 60)
66016 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
66017 +
66018 +static int __get_dumpable(unsigned long mm_flags)
66019 +{
66020 + int ret;
66021 +
66022 + ret = mm_flags & MMF_DUMPABLE_MASK;
66023 + return (ret >= 2) ? 2 : ret;
66024 +}
66025 +#endif
66026 +
66027 +void gr_handle_brute_attach(unsigned long mm_flags)
66028 +{
66029 +#ifdef CONFIG_GRKERNSEC_BRUTE
66030 + struct task_struct *p = current;
66031 + kuid_t uid = GLOBAL_ROOT_UID;
66032 + int daemon = 0;
66033 +
66034 + if (!grsec_enable_brute)
66035 + return;
66036 +
66037 + rcu_read_lock();
66038 + read_lock(&tasklist_lock);
66039 + read_lock(&grsec_exec_file_lock);
66040 + if (p->real_parent && gr_is_same_file(p->real_parent->exec_file, p->exec_file)) {
66041 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
66042 + p->real_parent->brute = 1;
66043 + daemon = 1;
66044 + } else {
66045 + const struct cred *cred = __task_cred(p), *cred2;
66046 + struct task_struct *tsk, *tsk2;
66047 +
66048 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
66049 + struct user_struct *user;
66050 +
66051 + uid = cred->uid;
66052 +
66053 + /* this is put upon execution past expiration */
66054 + user = find_user(uid);
66055 + if (user == NULL)
66056 + goto unlock;
66057 + user->suid_banned = 1;
66058 + user->suid_ban_expires = get_seconds() + GR_USER_BAN_TIME;
66059 + if (user->suid_ban_expires == ~0UL)
66060 + user->suid_ban_expires--;
66061 +
66062 + /* only kill other threads of the same binary, from the same user */
66063 + do_each_thread(tsk2, tsk) {
66064 + cred2 = __task_cred(tsk);
66065 + if (tsk != p && uid_eq(cred2->uid, uid) && gr_is_same_file(tsk->exec_file, p->exec_file))
66066 + gr_fake_force_sig(SIGKILL, tsk);
66067 + } while_each_thread(tsk2, tsk);
66068 + }
66069 + }
66070 +unlock:
66071 + read_unlock(&grsec_exec_file_lock);
66072 + read_unlock(&tasklist_lock);
66073 + rcu_read_unlock();
66074 +
66075 + if (gr_is_global_nonroot(uid))
66076 + 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);
66077 + else if (daemon)
66078 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
66079 +
66080 +#endif
66081 + return;
66082 +}
66083 +
66084 +void gr_handle_brute_check(void)
66085 +{
66086 +#ifdef CONFIG_GRKERNSEC_BRUTE
66087 + struct task_struct *p = current;
66088 +
66089 + if (unlikely(p->brute)) {
66090 + if (!grsec_enable_brute)
66091 + p->brute = 0;
66092 + else if (time_before(get_seconds(), p->brute_expires))
66093 + msleep(30 * 1000);
66094 + }
66095 +#endif
66096 + return;
66097 +}
66098 +
66099 +void gr_handle_kernel_exploit(void)
66100 +{
66101 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
66102 + const struct cred *cred;
66103 + struct task_struct *tsk, *tsk2;
66104 + struct user_struct *user;
66105 + kuid_t uid;
66106 +
66107 + if (in_irq() || in_serving_softirq() || in_nmi())
66108 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
66109 +
66110 + uid = current_uid();
66111 +
66112 + if (gr_is_global_root(uid))
66113 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
66114 + else {
66115 + /* kill all the processes of this user, hold a reference
66116 + to their creds struct, and prevent them from creating
66117 + another process until system reset
66118 + */
66119 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
66120 + GR_GLOBAL_UID(uid));
66121 + /* we intentionally leak this ref */
66122 + user = get_uid(current->cred->user);
66123 + if (user)
66124 + user->kernel_banned = 1;
66125 +
66126 + /* kill all processes of this user */
66127 + read_lock(&tasklist_lock);
66128 + do_each_thread(tsk2, tsk) {
66129 + cred = __task_cred(tsk);
66130 + if (uid_eq(cred->uid, uid))
66131 + gr_fake_force_sig(SIGKILL, tsk);
66132 + } while_each_thread(tsk2, tsk);
66133 + read_unlock(&tasklist_lock);
66134 + }
66135 +#endif
66136 +}
66137 +
66138 +#ifdef CONFIG_GRKERNSEC_BRUTE
66139 +static bool suid_ban_expired(struct user_struct *user)
66140 +{
66141 + if (user->suid_ban_expires != ~0UL && time_after_eq(get_seconds(), user->suid_ban_expires)) {
66142 + user->suid_banned = 0;
66143 + user->suid_ban_expires = 0;
66144 + free_uid(user);
66145 + return true;
66146 + }
66147 +
66148 + return false;
66149 +}
66150 +#endif
66151 +
66152 +int gr_process_kernel_exec_ban(void)
66153 +{
66154 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
66155 + if (unlikely(current->cred->user->kernel_banned))
66156 + return -EPERM;
66157 +#endif
66158 + return 0;
66159 +}
66160 +
66161 +int gr_process_kernel_setuid_ban(struct user_struct *user)
66162 +{
66163 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
66164 + if (unlikely(user->kernel_banned))
66165 + gr_fake_force_sig(SIGKILL, current);
66166 +#endif
66167 + return 0;
66168 +}
66169 +
66170 +int gr_process_suid_exec_ban(const struct linux_binprm *bprm)
66171 +{
66172 +#ifdef CONFIG_GRKERNSEC_BRUTE
66173 + struct user_struct *user = current->cred->user;
66174 + if (unlikely(user->suid_banned)) {
66175 + if (suid_ban_expired(user))
66176 + return 0;
66177 + /* disallow execution of suid binaries only */
66178 + else if (!uid_eq(bprm->cred->euid, current->cred->uid))
66179 + return -EPERM;
66180 + }
66181 +#endif
66182 + return 0;
66183 +}
66184 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
66185 new file mode 100644
66186 index 0000000..4030d57
66187 --- /dev/null
66188 +++ b/grsecurity/grsec_sock.c
66189 @@ -0,0 +1,244 @@
66190 +#include <linux/kernel.h>
66191 +#include <linux/module.h>
66192 +#include <linux/sched.h>
66193 +#include <linux/file.h>
66194 +#include <linux/net.h>
66195 +#include <linux/in.h>
66196 +#include <linux/ip.h>
66197 +#include <net/sock.h>
66198 +#include <net/inet_sock.h>
66199 +#include <linux/grsecurity.h>
66200 +#include <linux/grinternal.h>
66201 +#include <linux/gracl.h>
66202 +
66203 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
66204 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
66205 +
66206 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
66207 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
66208 +
66209 +#ifdef CONFIG_UNIX_MODULE
66210 +EXPORT_SYMBOL(gr_acl_handle_unix);
66211 +EXPORT_SYMBOL(gr_acl_handle_mknod);
66212 +EXPORT_SYMBOL(gr_handle_chroot_unix);
66213 +EXPORT_SYMBOL(gr_handle_create);
66214 +#endif
66215 +
66216 +#ifdef CONFIG_GRKERNSEC
66217 +#define gr_conn_table_size 32749
66218 +struct conn_table_entry {
66219 + struct conn_table_entry *next;
66220 + struct signal_struct *sig;
66221 +};
66222 +
66223 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
66224 +DEFINE_SPINLOCK(gr_conn_table_lock);
66225 +
66226 +extern const char * gr_socktype_to_name(unsigned char type);
66227 +extern const char * gr_proto_to_name(unsigned char proto);
66228 +extern const char * gr_sockfamily_to_name(unsigned char family);
66229 +
66230 +static __inline__ int
66231 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
66232 +{
66233 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
66234 +}
66235 +
66236 +static __inline__ int
66237 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
66238 + __u16 sport, __u16 dport)
66239 +{
66240 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
66241 + sig->gr_sport == sport && sig->gr_dport == dport))
66242 + return 1;
66243 + else
66244 + return 0;
66245 +}
66246 +
66247 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
66248 +{
66249 + struct conn_table_entry **match;
66250 + unsigned int index;
66251 +
66252 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
66253 + sig->gr_sport, sig->gr_dport,
66254 + gr_conn_table_size);
66255 +
66256 + newent->sig = sig;
66257 +
66258 + match = &gr_conn_table[index];
66259 + newent->next = *match;
66260 + *match = newent;
66261 +
66262 + return;
66263 +}
66264 +
66265 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
66266 +{
66267 + struct conn_table_entry *match, *last = NULL;
66268 + unsigned int index;
66269 +
66270 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
66271 + sig->gr_sport, sig->gr_dport,
66272 + gr_conn_table_size);
66273 +
66274 + match = gr_conn_table[index];
66275 + while (match && !conn_match(match->sig,
66276 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
66277 + sig->gr_dport)) {
66278 + last = match;
66279 + match = match->next;
66280 + }
66281 +
66282 + if (match) {
66283 + if (last)
66284 + last->next = match->next;
66285 + else
66286 + gr_conn_table[index] = NULL;
66287 + kfree(match);
66288 + }
66289 +
66290 + return;
66291 +}
66292 +
66293 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
66294 + __u16 sport, __u16 dport)
66295 +{
66296 + struct conn_table_entry *match;
66297 + unsigned int index;
66298 +
66299 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
66300 +
66301 + match = gr_conn_table[index];
66302 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
66303 + match = match->next;
66304 +
66305 + if (match)
66306 + return match->sig;
66307 + else
66308 + return NULL;
66309 +}
66310 +
66311 +#endif
66312 +
66313 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
66314 +{
66315 +#ifdef CONFIG_GRKERNSEC
66316 + struct signal_struct *sig = task->signal;
66317 + struct conn_table_entry *newent;
66318 +
66319 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
66320 + if (newent == NULL)
66321 + return;
66322 + /* no bh lock needed since we are called with bh disabled */
66323 + spin_lock(&gr_conn_table_lock);
66324 + gr_del_task_from_ip_table_nolock(sig);
66325 + sig->gr_saddr = inet->inet_rcv_saddr;
66326 + sig->gr_daddr = inet->inet_daddr;
66327 + sig->gr_sport = inet->inet_sport;
66328 + sig->gr_dport = inet->inet_dport;
66329 + gr_add_to_task_ip_table_nolock(sig, newent);
66330 + spin_unlock(&gr_conn_table_lock);
66331 +#endif
66332 + return;
66333 +}
66334 +
66335 +void gr_del_task_from_ip_table(struct task_struct *task)
66336 +{
66337 +#ifdef CONFIG_GRKERNSEC
66338 + spin_lock_bh(&gr_conn_table_lock);
66339 + gr_del_task_from_ip_table_nolock(task->signal);
66340 + spin_unlock_bh(&gr_conn_table_lock);
66341 +#endif
66342 + return;
66343 +}
66344 +
66345 +void
66346 +gr_attach_curr_ip(const struct sock *sk)
66347 +{
66348 +#ifdef CONFIG_GRKERNSEC
66349 + struct signal_struct *p, *set;
66350 + const struct inet_sock *inet = inet_sk(sk);
66351 +
66352 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
66353 + return;
66354 +
66355 + set = current->signal;
66356 +
66357 + spin_lock_bh(&gr_conn_table_lock);
66358 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
66359 + inet->inet_dport, inet->inet_sport);
66360 + if (unlikely(p != NULL)) {
66361 + set->curr_ip = p->curr_ip;
66362 + set->used_accept = 1;
66363 + gr_del_task_from_ip_table_nolock(p);
66364 + spin_unlock_bh(&gr_conn_table_lock);
66365 + return;
66366 + }
66367 + spin_unlock_bh(&gr_conn_table_lock);
66368 +
66369 + set->curr_ip = inet->inet_daddr;
66370 + set->used_accept = 1;
66371 +#endif
66372 + return;
66373 +}
66374 +
66375 +int
66376 +gr_handle_sock_all(const int family, const int type, const int protocol)
66377 +{
66378 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
66379 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
66380 + (family != AF_UNIX)) {
66381 + if (family == AF_INET)
66382 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
66383 + else
66384 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
66385 + return -EACCES;
66386 + }
66387 +#endif
66388 + return 0;
66389 +}
66390 +
66391 +int
66392 +gr_handle_sock_server(const struct sockaddr *sck)
66393 +{
66394 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66395 + if (grsec_enable_socket_server &&
66396 + in_group_p(grsec_socket_server_gid) &&
66397 + sck && (sck->sa_family != AF_UNIX) &&
66398 + (sck->sa_family != AF_LOCAL)) {
66399 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
66400 + return -EACCES;
66401 + }
66402 +#endif
66403 + return 0;
66404 +}
66405 +
66406 +int
66407 +gr_handle_sock_server_other(const struct sock *sck)
66408 +{
66409 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66410 + if (grsec_enable_socket_server &&
66411 + in_group_p(grsec_socket_server_gid) &&
66412 + sck && (sck->sk_family != AF_UNIX) &&
66413 + (sck->sk_family != AF_LOCAL)) {
66414 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
66415 + return -EACCES;
66416 + }
66417 +#endif
66418 + return 0;
66419 +}
66420 +
66421 +int
66422 +gr_handle_sock_client(const struct sockaddr *sck)
66423 +{
66424 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
66425 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
66426 + sck && (sck->sa_family != AF_UNIX) &&
66427 + (sck->sa_family != AF_LOCAL)) {
66428 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
66429 + return -EACCES;
66430 + }
66431 +#endif
66432 + return 0;
66433 +}
66434 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
66435 new file mode 100644
66436 index 0000000..f55ef0f
66437 --- /dev/null
66438 +++ b/grsecurity/grsec_sysctl.c
66439 @@ -0,0 +1,469 @@
66440 +#include <linux/kernel.h>
66441 +#include <linux/sched.h>
66442 +#include <linux/sysctl.h>
66443 +#include <linux/grsecurity.h>
66444 +#include <linux/grinternal.h>
66445 +
66446 +int
66447 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
66448 +{
66449 +#ifdef CONFIG_GRKERNSEC_SYSCTL
66450 + if (dirname == NULL || name == NULL)
66451 + return 0;
66452 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
66453 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
66454 + return -EACCES;
66455 + }
66456 +#endif
66457 + return 0;
66458 +}
66459 +
66460 +#ifdef CONFIG_GRKERNSEC_ROFS
66461 +static int __maybe_unused one = 1;
66462 +#endif
66463 +
66464 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
66465 +struct ctl_table grsecurity_table[] = {
66466 +#ifdef CONFIG_GRKERNSEC_SYSCTL
66467 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
66468 +#ifdef CONFIG_GRKERNSEC_IO
66469 + {
66470 + .procname = "disable_priv_io",
66471 + .data = &grsec_disable_privio,
66472 + .maxlen = sizeof(int),
66473 + .mode = 0600,
66474 + .proc_handler = &proc_dointvec,
66475 + },
66476 +#endif
66477 +#endif
66478 +#ifdef CONFIG_GRKERNSEC_LINK
66479 + {
66480 + .procname = "linking_restrictions",
66481 + .data = &grsec_enable_link,
66482 + .maxlen = sizeof(int),
66483 + .mode = 0600,
66484 + .proc_handler = &proc_dointvec,
66485 + },
66486 +#endif
66487 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
66488 + {
66489 + .procname = "enforce_symlinksifowner",
66490 + .data = &grsec_enable_symlinkown,
66491 + .maxlen = sizeof(int),
66492 + .mode = 0600,
66493 + .proc_handler = &proc_dointvec,
66494 + },
66495 + {
66496 + .procname = "symlinkown_gid",
66497 + .data = &grsec_symlinkown_gid,
66498 + .maxlen = sizeof(int),
66499 + .mode = 0600,
66500 + .proc_handler = &proc_dointvec,
66501 + },
66502 +#endif
66503 +#ifdef CONFIG_GRKERNSEC_BRUTE
66504 + {
66505 + .procname = "deter_bruteforce",
66506 + .data = &grsec_enable_brute,
66507 + .maxlen = sizeof(int),
66508 + .mode = 0600,
66509 + .proc_handler = &proc_dointvec,
66510 + },
66511 +#endif
66512 +#ifdef CONFIG_GRKERNSEC_FIFO
66513 + {
66514 + .procname = "fifo_restrictions",
66515 + .data = &grsec_enable_fifo,
66516 + .maxlen = sizeof(int),
66517 + .mode = 0600,
66518 + .proc_handler = &proc_dointvec,
66519 + },
66520 +#endif
66521 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
66522 + {
66523 + .procname = "ptrace_readexec",
66524 + .data = &grsec_enable_ptrace_readexec,
66525 + .maxlen = sizeof(int),
66526 + .mode = 0600,
66527 + .proc_handler = &proc_dointvec,
66528 + },
66529 +#endif
66530 +#ifdef CONFIG_GRKERNSEC_SETXID
66531 + {
66532 + .procname = "consistent_setxid",
66533 + .data = &grsec_enable_setxid,
66534 + .maxlen = sizeof(int),
66535 + .mode = 0600,
66536 + .proc_handler = &proc_dointvec,
66537 + },
66538 +#endif
66539 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
66540 + {
66541 + .procname = "ip_blackhole",
66542 + .data = &grsec_enable_blackhole,
66543 + .maxlen = sizeof(int),
66544 + .mode = 0600,
66545 + .proc_handler = &proc_dointvec,
66546 + },
66547 + {
66548 + .procname = "lastack_retries",
66549 + .data = &grsec_lastack_retries,
66550 + .maxlen = sizeof(int),
66551 + .mode = 0600,
66552 + .proc_handler = &proc_dointvec,
66553 + },
66554 +#endif
66555 +#ifdef CONFIG_GRKERNSEC_EXECLOG
66556 + {
66557 + .procname = "exec_logging",
66558 + .data = &grsec_enable_execlog,
66559 + .maxlen = sizeof(int),
66560 + .mode = 0600,
66561 + .proc_handler = &proc_dointvec,
66562 + },
66563 +#endif
66564 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
66565 + {
66566 + .procname = "rwxmap_logging",
66567 + .data = &grsec_enable_log_rwxmaps,
66568 + .maxlen = sizeof(int),
66569 + .mode = 0600,
66570 + .proc_handler = &proc_dointvec,
66571 + },
66572 +#endif
66573 +#ifdef CONFIG_GRKERNSEC_SIGNAL
66574 + {
66575 + .procname = "signal_logging",
66576 + .data = &grsec_enable_signal,
66577 + .maxlen = sizeof(int),
66578 + .mode = 0600,
66579 + .proc_handler = &proc_dointvec,
66580 + },
66581 +#endif
66582 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
66583 + {
66584 + .procname = "forkfail_logging",
66585 + .data = &grsec_enable_forkfail,
66586 + .maxlen = sizeof(int),
66587 + .mode = 0600,
66588 + .proc_handler = &proc_dointvec,
66589 + },
66590 +#endif
66591 +#ifdef CONFIG_GRKERNSEC_TIME
66592 + {
66593 + .procname = "timechange_logging",
66594 + .data = &grsec_enable_time,
66595 + .maxlen = sizeof(int),
66596 + .mode = 0600,
66597 + .proc_handler = &proc_dointvec,
66598 + },
66599 +#endif
66600 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
66601 + {
66602 + .procname = "chroot_deny_shmat",
66603 + .data = &grsec_enable_chroot_shmat,
66604 + .maxlen = sizeof(int),
66605 + .mode = 0600,
66606 + .proc_handler = &proc_dointvec,
66607 + },
66608 +#endif
66609 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
66610 + {
66611 + .procname = "chroot_deny_unix",
66612 + .data = &grsec_enable_chroot_unix,
66613 + .maxlen = sizeof(int),
66614 + .mode = 0600,
66615 + .proc_handler = &proc_dointvec,
66616 + },
66617 +#endif
66618 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
66619 + {
66620 + .procname = "chroot_deny_mount",
66621 + .data = &grsec_enable_chroot_mount,
66622 + .maxlen = sizeof(int),
66623 + .mode = 0600,
66624 + .proc_handler = &proc_dointvec,
66625 + },
66626 +#endif
66627 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
66628 + {
66629 + .procname = "chroot_deny_fchdir",
66630 + .data = &grsec_enable_chroot_fchdir,
66631 + .maxlen = sizeof(int),
66632 + .mode = 0600,
66633 + .proc_handler = &proc_dointvec,
66634 + },
66635 +#endif
66636 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
66637 + {
66638 + .procname = "chroot_deny_chroot",
66639 + .data = &grsec_enable_chroot_double,
66640 + .maxlen = sizeof(int),
66641 + .mode = 0600,
66642 + .proc_handler = &proc_dointvec,
66643 + },
66644 +#endif
66645 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
66646 + {
66647 + .procname = "chroot_deny_pivot",
66648 + .data = &grsec_enable_chroot_pivot,
66649 + .maxlen = sizeof(int),
66650 + .mode = 0600,
66651 + .proc_handler = &proc_dointvec,
66652 + },
66653 +#endif
66654 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
66655 + {
66656 + .procname = "chroot_enforce_chdir",
66657 + .data = &grsec_enable_chroot_chdir,
66658 + .maxlen = sizeof(int),
66659 + .mode = 0600,
66660 + .proc_handler = &proc_dointvec,
66661 + },
66662 +#endif
66663 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
66664 + {
66665 + .procname = "chroot_deny_chmod",
66666 + .data = &grsec_enable_chroot_chmod,
66667 + .maxlen = sizeof(int),
66668 + .mode = 0600,
66669 + .proc_handler = &proc_dointvec,
66670 + },
66671 +#endif
66672 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
66673 + {
66674 + .procname = "chroot_deny_mknod",
66675 + .data = &grsec_enable_chroot_mknod,
66676 + .maxlen = sizeof(int),
66677 + .mode = 0600,
66678 + .proc_handler = &proc_dointvec,
66679 + },
66680 +#endif
66681 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
66682 + {
66683 + .procname = "chroot_restrict_nice",
66684 + .data = &grsec_enable_chroot_nice,
66685 + .maxlen = sizeof(int),
66686 + .mode = 0600,
66687 + .proc_handler = &proc_dointvec,
66688 + },
66689 +#endif
66690 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
66691 + {
66692 + .procname = "chroot_execlog",
66693 + .data = &grsec_enable_chroot_execlog,
66694 + .maxlen = sizeof(int),
66695 + .mode = 0600,
66696 + .proc_handler = &proc_dointvec,
66697 + },
66698 +#endif
66699 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
66700 + {
66701 + .procname = "chroot_caps",
66702 + .data = &grsec_enable_chroot_caps,
66703 + .maxlen = sizeof(int),
66704 + .mode = 0600,
66705 + .proc_handler = &proc_dointvec,
66706 + },
66707 +#endif
66708 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
66709 + {
66710 + .procname = "chroot_deny_sysctl",
66711 + .data = &grsec_enable_chroot_sysctl,
66712 + .maxlen = sizeof(int),
66713 + .mode = 0600,
66714 + .proc_handler = &proc_dointvec,
66715 + },
66716 +#endif
66717 +#ifdef CONFIG_GRKERNSEC_TPE
66718 + {
66719 + .procname = "tpe",
66720 + .data = &grsec_enable_tpe,
66721 + .maxlen = sizeof(int),
66722 + .mode = 0600,
66723 + .proc_handler = &proc_dointvec,
66724 + },
66725 + {
66726 + .procname = "tpe_gid",
66727 + .data = &grsec_tpe_gid,
66728 + .maxlen = sizeof(int),
66729 + .mode = 0600,
66730 + .proc_handler = &proc_dointvec,
66731 + },
66732 +#endif
66733 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
66734 + {
66735 + .procname = "tpe_invert",
66736 + .data = &grsec_enable_tpe_invert,
66737 + .maxlen = sizeof(int),
66738 + .mode = 0600,
66739 + .proc_handler = &proc_dointvec,
66740 + },
66741 +#endif
66742 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
66743 + {
66744 + .procname = "tpe_restrict_all",
66745 + .data = &grsec_enable_tpe_all,
66746 + .maxlen = sizeof(int),
66747 + .mode = 0600,
66748 + .proc_handler = &proc_dointvec,
66749 + },
66750 +#endif
66751 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
66752 + {
66753 + .procname = "socket_all",
66754 + .data = &grsec_enable_socket_all,
66755 + .maxlen = sizeof(int),
66756 + .mode = 0600,
66757 + .proc_handler = &proc_dointvec,
66758 + },
66759 + {
66760 + .procname = "socket_all_gid",
66761 + .data = &grsec_socket_all_gid,
66762 + .maxlen = sizeof(int),
66763 + .mode = 0600,
66764 + .proc_handler = &proc_dointvec,
66765 + },
66766 +#endif
66767 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
66768 + {
66769 + .procname = "socket_client",
66770 + .data = &grsec_enable_socket_client,
66771 + .maxlen = sizeof(int),
66772 + .mode = 0600,
66773 + .proc_handler = &proc_dointvec,
66774 + },
66775 + {
66776 + .procname = "socket_client_gid",
66777 + .data = &grsec_socket_client_gid,
66778 + .maxlen = sizeof(int),
66779 + .mode = 0600,
66780 + .proc_handler = &proc_dointvec,
66781 + },
66782 +#endif
66783 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
66784 + {
66785 + .procname = "socket_server",
66786 + .data = &grsec_enable_socket_server,
66787 + .maxlen = sizeof(int),
66788 + .mode = 0600,
66789 + .proc_handler = &proc_dointvec,
66790 + },
66791 + {
66792 + .procname = "socket_server_gid",
66793 + .data = &grsec_socket_server_gid,
66794 + .maxlen = sizeof(int),
66795 + .mode = 0600,
66796 + .proc_handler = &proc_dointvec,
66797 + },
66798 +#endif
66799 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
66800 + {
66801 + .procname = "audit_group",
66802 + .data = &grsec_enable_group,
66803 + .maxlen = sizeof(int),
66804 + .mode = 0600,
66805 + .proc_handler = &proc_dointvec,
66806 + },
66807 + {
66808 + .procname = "audit_gid",
66809 + .data = &grsec_audit_gid,
66810 + .maxlen = sizeof(int),
66811 + .mode = 0600,
66812 + .proc_handler = &proc_dointvec,
66813 + },
66814 +#endif
66815 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
66816 + {
66817 + .procname = "audit_chdir",
66818 + .data = &grsec_enable_chdir,
66819 + .maxlen = sizeof(int),
66820 + .mode = 0600,
66821 + .proc_handler = &proc_dointvec,
66822 + },
66823 +#endif
66824 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
66825 + {
66826 + .procname = "audit_mount",
66827 + .data = &grsec_enable_mount,
66828 + .maxlen = sizeof(int),
66829 + .mode = 0600,
66830 + .proc_handler = &proc_dointvec,
66831 + },
66832 +#endif
66833 +#ifdef CONFIG_GRKERNSEC_AUDIT_TEXTREL
66834 + {
66835 + .procname = "audit_textrel",
66836 + .data = &grsec_enable_audit_textrel,
66837 + .maxlen = sizeof(int),
66838 + .mode = 0600,
66839 + .proc_handler = &proc_dointvec,
66840 + },
66841 +#endif
66842 +#ifdef CONFIG_GRKERNSEC_DMESG
66843 + {
66844 + .procname = "dmesg",
66845 + .data = &grsec_enable_dmesg,
66846 + .maxlen = sizeof(int),
66847 + .mode = 0600,
66848 + .proc_handler = &proc_dointvec,
66849 + },
66850 +#endif
66851 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
66852 + {
66853 + .procname = "chroot_findtask",
66854 + .data = &grsec_enable_chroot_findtask,
66855 + .maxlen = sizeof(int),
66856 + .mode = 0600,
66857 + .proc_handler = &proc_dointvec,
66858 + },
66859 +#endif
66860 +#ifdef CONFIG_GRKERNSEC_RESLOG
66861 + {
66862 + .procname = "resource_logging",
66863 + .data = &grsec_resource_logging,
66864 + .maxlen = sizeof(int),
66865 + .mode = 0600,
66866 + .proc_handler = &proc_dointvec,
66867 + },
66868 +#endif
66869 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
66870 + {
66871 + .procname = "audit_ptrace",
66872 + .data = &grsec_enable_audit_ptrace,
66873 + .maxlen = sizeof(int),
66874 + .mode = 0600,
66875 + .proc_handler = &proc_dointvec,
66876 + },
66877 +#endif
66878 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
66879 + {
66880 + .procname = "harden_ptrace",
66881 + .data = &grsec_enable_harden_ptrace,
66882 + .maxlen = sizeof(int),
66883 + .mode = 0600,
66884 + .proc_handler = &proc_dointvec,
66885 + },
66886 +#endif
66887 + {
66888 + .procname = "grsec_lock",
66889 + .data = &grsec_lock,
66890 + .maxlen = sizeof(int),
66891 + .mode = 0600,
66892 + .proc_handler = &proc_dointvec,
66893 + },
66894 +#endif
66895 +#ifdef CONFIG_GRKERNSEC_ROFS
66896 + {
66897 + .procname = "romount_protect",
66898 + .data = &grsec_enable_rofs,
66899 + .maxlen = sizeof(int),
66900 + .mode = 0600,
66901 + .proc_handler = &proc_dointvec_minmax,
66902 + .extra1 = &one,
66903 + .extra2 = &one,
66904 + },
66905 +#endif
66906 + { }
66907 +};
66908 +#endif
66909 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
66910 new file mode 100644
66911 index 0000000..0dc13c3
66912 --- /dev/null
66913 +++ b/grsecurity/grsec_time.c
66914 @@ -0,0 +1,16 @@
66915 +#include <linux/kernel.h>
66916 +#include <linux/sched.h>
66917 +#include <linux/grinternal.h>
66918 +#include <linux/module.h>
66919 +
66920 +void
66921 +gr_log_timechange(void)
66922 +{
66923 +#ifdef CONFIG_GRKERNSEC_TIME
66924 + if (grsec_enable_time)
66925 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
66926 +#endif
66927 + return;
66928 +}
66929 +
66930 +EXPORT_SYMBOL(gr_log_timechange);
66931 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
66932 new file mode 100644
66933 index 0000000..ee57dcf
66934 --- /dev/null
66935 +++ b/grsecurity/grsec_tpe.c
66936 @@ -0,0 +1,73 @@
66937 +#include <linux/kernel.h>
66938 +#include <linux/sched.h>
66939 +#include <linux/file.h>
66940 +#include <linux/fs.h>
66941 +#include <linux/grinternal.h>
66942 +
66943 +extern int gr_acl_tpe_check(void);
66944 +
66945 +int
66946 +gr_tpe_allow(const struct file *file)
66947 +{
66948 +#ifdef CONFIG_GRKERNSEC
66949 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
66950 + const struct cred *cred = current_cred();
66951 + char *msg = NULL;
66952 + char *msg2 = NULL;
66953 +
66954 + // never restrict root
66955 + if (gr_is_global_root(cred->uid))
66956 + return 1;
66957 +
66958 + if (grsec_enable_tpe) {
66959 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
66960 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
66961 + msg = "not being in trusted group";
66962 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
66963 + msg = "being in untrusted group";
66964 +#else
66965 + if (in_group_p(grsec_tpe_gid))
66966 + msg = "being in untrusted group";
66967 +#endif
66968 + }
66969 + if (!msg && gr_acl_tpe_check())
66970 + msg = "being in untrusted role";
66971 +
66972 + // not in any affected group/role
66973 + if (!msg)
66974 + goto next_check;
66975 +
66976 + if (gr_is_global_nonroot(inode->i_uid))
66977 + msg2 = "file in non-root-owned directory";
66978 + else if (inode->i_mode & S_IWOTH)
66979 + msg2 = "file in world-writable directory";
66980 + else if (inode->i_mode & S_IWGRP)
66981 + msg2 = "file in group-writable directory";
66982 +
66983 + if (msg && msg2) {
66984 + char fullmsg[70] = {0};
66985 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
66986 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
66987 + return 0;
66988 + }
66989 + msg = NULL;
66990 +next_check:
66991 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
66992 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
66993 + return 1;
66994 +
66995 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
66996 + msg = "directory not owned by user";
66997 + else if (inode->i_mode & S_IWOTH)
66998 + msg = "file in world-writable directory";
66999 + else if (inode->i_mode & S_IWGRP)
67000 + msg = "file in group-writable directory";
67001 +
67002 + if (msg) {
67003 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
67004 + return 0;
67005 + }
67006 +#endif
67007 +#endif
67008 + return 1;
67009 +}
67010 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
67011 new file mode 100644
67012 index 0000000..9f7b1ac
67013 --- /dev/null
67014 +++ b/grsecurity/grsum.c
67015 @@ -0,0 +1,61 @@
67016 +#include <linux/err.h>
67017 +#include <linux/kernel.h>
67018 +#include <linux/sched.h>
67019 +#include <linux/mm.h>
67020 +#include <linux/scatterlist.h>
67021 +#include <linux/crypto.h>
67022 +#include <linux/gracl.h>
67023 +
67024 +
67025 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
67026 +#error "crypto and sha256 must be built into the kernel"
67027 +#endif
67028 +
67029 +int
67030 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
67031 +{
67032 + char *p;
67033 + struct crypto_hash *tfm;
67034 + struct hash_desc desc;
67035 + struct scatterlist sg;
67036 + unsigned char temp_sum[GR_SHA_LEN];
67037 + volatile int retval = 0;
67038 + volatile int dummy = 0;
67039 + unsigned int i;
67040 +
67041 + sg_init_table(&sg, 1);
67042 +
67043 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
67044 + if (IS_ERR(tfm)) {
67045 + /* should never happen, since sha256 should be built in */
67046 + return 1;
67047 + }
67048 +
67049 + desc.tfm = tfm;
67050 + desc.flags = 0;
67051 +
67052 + crypto_hash_init(&desc);
67053 +
67054 + p = salt;
67055 + sg_set_buf(&sg, p, GR_SALT_LEN);
67056 + crypto_hash_update(&desc, &sg, sg.length);
67057 +
67058 + p = entry->pw;
67059 + sg_set_buf(&sg, p, strlen(p));
67060 +
67061 + crypto_hash_update(&desc, &sg, sg.length);
67062 +
67063 + crypto_hash_final(&desc, temp_sum);
67064 +
67065 + memset(entry->pw, 0, GR_PW_LEN);
67066 +
67067 + for (i = 0; i < GR_SHA_LEN; i++)
67068 + if (sum[i] != temp_sum[i])
67069 + retval = 1;
67070 + else
67071 + dummy = 1; // waste a cycle
67072 +
67073 + crypto_free_hash(tfm);
67074 +
67075 + return retval;
67076 +}
67077 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
67078 index 77ff547..181834f 100644
67079 --- a/include/asm-generic/4level-fixup.h
67080 +++ b/include/asm-generic/4level-fixup.h
67081 @@ -13,8 +13,10 @@
67082 #define pmd_alloc(mm, pud, address) \
67083 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
67084 NULL: pmd_offset(pud, address))
67085 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
67086
67087 #define pud_alloc(mm, pgd, address) (pgd)
67088 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
67089 #define pud_offset(pgd, start) (pgd)
67090 #define pud_none(pud) 0
67091 #define pud_bad(pud) 0
67092 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
67093 index b7babf0..04ad282 100644
67094 --- a/include/asm-generic/atomic-long.h
67095 +++ b/include/asm-generic/atomic-long.h
67096 @@ -22,6 +22,12 @@
67097
67098 typedef atomic64_t atomic_long_t;
67099
67100 +#ifdef CONFIG_PAX_REFCOUNT
67101 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
67102 +#else
67103 +typedef atomic64_t atomic_long_unchecked_t;
67104 +#endif
67105 +
67106 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
67107
67108 static inline long atomic_long_read(atomic_long_t *l)
67109 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
67110 return (long)atomic64_read(v);
67111 }
67112
67113 +#ifdef CONFIG_PAX_REFCOUNT
67114 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
67115 +{
67116 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67117 +
67118 + return (long)atomic64_read_unchecked(v);
67119 +}
67120 +#endif
67121 +
67122 static inline void atomic_long_set(atomic_long_t *l, long i)
67123 {
67124 atomic64_t *v = (atomic64_t *)l;
67125 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
67126 atomic64_set(v, i);
67127 }
67128
67129 +#ifdef CONFIG_PAX_REFCOUNT
67130 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
67131 +{
67132 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67133 +
67134 + atomic64_set_unchecked(v, i);
67135 +}
67136 +#endif
67137 +
67138 static inline void atomic_long_inc(atomic_long_t *l)
67139 {
67140 atomic64_t *v = (atomic64_t *)l;
67141 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
67142 atomic64_inc(v);
67143 }
67144
67145 +#ifdef CONFIG_PAX_REFCOUNT
67146 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
67147 +{
67148 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67149 +
67150 + atomic64_inc_unchecked(v);
67151 +}
67152 +#endif
67153 +
67154 static inline void atomic_long_dec(atomic_long_t *l)
67155 {
67156 atomic64_t *v = (atomic64_t *)l;
67157 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
67158 atomic64_dec(v);
67159 }
67160
67161 +#ifdef CONFIG_PAX_REFCOUNT
67162 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
67163 +{
67164 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67165 +
67166 + atomic64_dec_unchecked(v);
67167 +}
67168 +#endif
67169 +
67170 static inline void atomic_long_add(long i, atomic_long_t *l)
67171 {
67172 atomic64_t *v = (atomic64_t *)l;
67173 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
67174 atomic64_add(i, v);
67175 }
67176
67177 +#ifdef CONFIG_PAX_REFCOUNT
67178 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
67179 +{
67180 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67181 +
67182 + atomic64_add_unchecked(i, v);
67183 +}
67184 +#endif
67185 +
67186 static inline void atomic_long_sub(long i, atomic_long_t *l)
67187 {
67188 atomic64_t *v = (atomic64_t *)l;
67189 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
67190 atomic64_sub(i, v);
67191 }
67192
67193 +#ifdef CONFIG_PAX_REFCOUNT
67194 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
67195 +{
67196 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67197 +
67198 + atomic64_sub_unchecked(i, v);
67199 +}
67200 +#endif
67201 +
67202 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
67203 {
67204 atomic64_t *v = (atomic64_t *)l;
67205 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
67206 return (long)atomic64_add_return(i, v);
67207 }
67208
67209 +#ifdef CONFIG_PAX_REFCOUNT
67210 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
67211 +{
67212 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67213 +
67214 + return (long)atomic64_add_return_unchecked(i, v);
67215 +}
67216 +#endif
67217 +
67218 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
67219 {
67220 atomic64_t *v = (atomic64_t *)l;
67221 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
67222 return (long)atomic64_inc_return(v);
67223 }
67224
67225 +#ifdef CONFIG_PAX_REFCOUNT
67226 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
67227 +{
67228 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
67229 +
67230 + return (long)atomic64_inc_return_unchecked(v);
67231 +}
67232 +#endif
67233 +
67234 static inline long atomic_long_dec_return(atomic_long_t *l)
67235 {
67236 atomic64_t *v = (atomic64_t *)l;
67237 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
67238
67239 typedef atomic_t atomic_long_t;
67240
67241 +#ifdef CONFIG_PAX_REFCOUNT
67242 +typedef atomic_unchecked_t atomic_long_unchecked_t;
67243 +#else
67244 +typedef atomic_t atomic_long_unchecked_t;
67245 +#endif
67246 +
67247 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
67248 static inline long atomic_long_read(atomic_long_t *l)
67249 {
67250 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
67251 return (long)atomic_read(v);
67252 }
67253
67254 +#ifdef CONFIG_PAX_REFCOUNT
67255 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
67256 +{
67257 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67258 +
67259 + return (long)atomic_read_unchecked(v);
67260 +}
67261 +#endif
67262 +
67263 static inline void atomic_long_set(atomic_long_t *l, long i)
67264 {
67265 atomic_t *v = (atomic_t *)l;
67266 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
67267 atomic_set(v, i);
67268 }
67269
67270 +#ifdef CONFIG_PAX_REFCOUNT
67271 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
67272 +{
67273 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67274 +
67275 + atomic_set_unchecked(v, i);
67276 +}
67277 +#endif
67278 +
67279 static inline void atomic_long_inc(atomic_long_t *l)
67280 {
67281 atomic_t *v = (atomic_t *)l;
67282 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
67283 atomic_inc(v);
67284 }
67285
67286 +#ifdef CONFIG_PAX_REFCOUNT
67287 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
67288 +{
67289 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67290 +
67291 + atomic_inc_unchecked(v);
67292 +}
67293 +#endif
67294 +
67295 static inline void atomic_long_dec(atomic_long_t *l)
67296 {
67297 atomic_t *v = (atomic_t *)l;
67298 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
67299 atomic_dec(v);
67300 }
67301
67302 +#ifdef CONFIG_PAX_REFCOUNT
67303 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
67304 +{
67305 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67306 +
67307 + atomic_dec_unchecked(v);
67308 +}
67309 +#endif
67310 +
67311 static inline void atomic_long_add(long i, atomic_long_t *l)
67312 {
67313 atomic_t *v = (atomic_t *)l;
67314 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
67315 atomic_add(i, v);
67316 }
67317
67318 +#ifdef CONFIG_PAX_REFCOUNT
67319 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
67320 +{
67321 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67322 +
67323 + atomic_add_unchecked(i, v);
67324 +}
67325 +#endif
67326 +
67327 static inline void atomic_long_sub(long i, atomic_long_t *l)
67328 {
67329 atomic_t *v = (atomic_t *)l;
67330 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
67331 atomic_sub(i, v);
67332 }
67333
67334 +#ifdef CONFIG_PAX_REFCOUNT
67335 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
67336 +{
67337 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67338 +
67339 + atomic_sub_unchecked(i, v);
67340 +}
67341 +#endif
67342 +
67343 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
67344 {
67345 atomic_t *v = (atomic_t *)l;
67346 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
67347 return (long)atomic_add_return(i, v);
67348 }
67349
67350 +#ifdef CONFIG_PAX_REFCOUNT
67351 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
67352 +{
67353 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67354 +
67355 + return (long)atomic_add_return_unchecked(i, v);
67356 +}
67357 +
67358 +#endif
67359 +
67360 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
67361 {
67362 atomic_t *v = (atomic_t *)l;
67363 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
67364 return (long)atomic_inc_return(v);
67365 }
67366
67367 +#ifdef CONFIG_PAX_REFCOUNT
67368 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
67369 +{
67370 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
67371 +
67372 + return (long)atomic_inc_return_unchecked(v);
67373 +}
67374 +#endif
67375 +
67376 static inline long atomic_long_dec_return(atomic_long_t *l)
67377 {
67378 atomic_t *v = (atomic_t *)l;
67379 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
67380
67381 #endif /* BITS_PER_LONG == 64 */
67382
67383 +#ifdef CONFIG_PAX_REFCOUNT
67384 +static inline void pax_refcount_needs_these_functions(void)
67385 +{
67386 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
67387 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
67388 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
67389 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
67390 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
67391 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
67392 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
67393 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
67394 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
67395 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
67396 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
67397 +#ifdef CONFIG_X86
67398 + atomic_clear_mask_unchecked(0, NULL);
67399 + atomic_set_mask_unchecked(0, NULL);
67400 +#endif
67401 +
67402 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
67403 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
67404 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
67405 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
67406 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
67407 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
67408 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
67409 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
67410 +}
67411 +#else
67412 +#define atomic_read_unchecked(v) atomic_read(v)
67413 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
67414 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
67415 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
67416 +#define atomic_inc_unchecked(v) atomic_inc(v)
67417 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
67418 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
67419 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
67420 +#define atomic_dec_unchecked(v) atomic_dec(v)
67421 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
67422 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
67423 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
67424 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
67425 +
67426 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
67427 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
67428 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
67429 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
67430 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
67431 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
67432 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
67433 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
67434 +#endif
67435 +
67436 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
67437 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
67438 index 33bd2de..f31bff97 100644
67439 --- a/include/asm-generic/atomic.h
67440 +++ b/include/asm-generic/atomic.h
67441 @@ -153,7 +153,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
67442 * Atomically clears the bits set in @mask from @v
67443 */
67444 #ifndef atomic_clear_mask
67445 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
67446 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
67447 {
67448 unsigned long flags;
67449
67450 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
67451 index b18ce4f..2ee2843 100644
67452 --- a/include/asm-generic/atomic64.h
67453 +++ b/include/asm-generic/atomic64.h
67454 @@ -16,6 +16,8 @@ typedef struct {
67455 long long counter;
67456 } atomic64_t;
67457
67458 +typedef atomic64_t atomic64_unchecked_t;
67459 +
67460 #define ATOMIC64_INIT(i) { (i) }
67461
67462 extern long long atomic64_read(const atomic64_t *v);
67463 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
67464 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
67465 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
67466
67467 +#define atomic64_read_unchecked(v) atomic64_read(v)
67468 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
67469 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
67470 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
67471 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
67472 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
67473 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
67474 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
67475 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
67476 +
67477 #endif /* _ASM_GENERIC_ATOMIC64_H */
67478 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
67479 index 1bfcfe5..e04c5c9 100644
67480 --- a/include/asm-generic/cache.h
67481 +++ b/include/asm-generic/cache.h
67482 @@ -6,7 +6,7 @@
67483 * cache lines need to provide their own cache.h.
67484 */
67485
67486 -#define L1_CACHE_SHIFT 5
67487 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
67488 +#define L1_CACHE_SHIFT 5UL
67489 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
67490
67491 #endif /* __ASM_GENERIC_CACHE_H */
67492 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
67493 index 0d68a1e..b74a761 100644
67494 --- a/include/asm-generic/emergency-restart.h
67495 +++ b/include/asm-generic/emergency-restart.h
67496 @@ -1,7 +1,7 @@
67497 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
67498 #define _ASM_GENERIC_EMERGENCY_RESTART_H
67499
67500 -static inline void machine_emergency_restart(void)
67501 +static inline __noreturn void machine_emergency_restart(void)
67502 {
67503 machine_restart(NULL);
67504 }
67505 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
67506 index 90f99c7..00ce236 100644
67507 --- a/include/asm-generic/kmap_types.h
67508 +++ b/include/asm-generic/kmap_types.h
67509 @@ -2,9 +2,9 @@
67510 #define _ASM_GENERIC_KMAP_TYPES_H
67511
67512 #ifdef __WITH_KM_FENCE
67513 -# define KM_TYPE_NR 41
67514 +# define KM_TYPE_NR 42
67515 #else
67516 -# define KM_TYPE_NR 20
67517 +# define KM_TYPE_NR 21
67518 #endif
67519
67520 #endif
67521 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
67522 index 9ceb03b..62b0b8f 100644
67523 --- a/include/asm-generic/local.h
67524 +++ b/include/asm-generic/local.h
67525 @@ -23,24 +23,37 @@ typedef struct
67526 atomic_long_t a;
67527 } local_t;
67528
67529 +typedef struct {
67530 + atomic_long_unchecked_t a;
67531 +} local_unchecked_t;
67532 +
67533 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
67534
67535 #define local_read(l) atomic_long_read(&(l)->a)
67536 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
67537 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
67538 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
67539 #define local_inc(l) atomic_long_inc(&(l)->a)
67540 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
67541 #define local_dec(l) atomic_long_dec(&(l)->a)
67542 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
67543 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
67544 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
67545 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
67546 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
67547
67548 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
67549 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
67550 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
67551 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
67552 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
67553 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
67554 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
67555 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
67556 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
67557
67558 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
67559 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
67560 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
67561 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
67562 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
67563 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
67564 index 725612b..9cc513a 100644
67565 --- a/include/asm-generic/pgtable-nopmd.h
67566 +++ b/include/asm-generic/pgtable-nopmd.h
67567 @@ -1,14 +1,19 @@
67568 #ifndef _PGTABLE_NOPMD_H
67569 #define _PGTABLE_NOPMD_H
67570
67571 -#ifndef __ASSEMBLY__
67572 -
67573 #include <asm-generic/pgtable-nopud.h>
67574
67575 -struct mm_struct;
67576 -
67577 #define __PAGETABLE_PMD_FOLDED
67578
67579 +#define PMD_SHIFT PUD_SHIFT
67580 +#define PTRS_PER_PMD 1
67581 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
67582 +#define PMD_MASK (~(PMD_SIZE-1))
67583 +
67584 +#ifndef __ASSEMBLY__
67585 +
67586 +struct mm_struct;
67587 +
67588 /*
67589 * Having the pmd type consist of a pud gets the size right, and allows
67590 * us to conceptually access the pud entry that this pmd is folded into
67591 @@ -16,11 +21,6 @@ struct mm_struct;
67592 */
67593 typedef struct { pud_t pud; } pmd_t;
67594
67595 -#define PMD_SHIFT PUD_SHIFT
67596 -#define PTRS_PER_PMD 1
67597 -#define PMD_SIZE (1UL << PMD_SHIFT)
67598 -#define PMD_MASK (~(PMD_SIZE-1))
67599 -
67600 /*
67601 * The "pud_xxx()" functions here are trivial for a folded two-level
67602 * setup: the pmd is never bad, and a pmd always exists (as it's folded
67603 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
67604 index 810431d..0ec4804f 100644
67605 --- a/include/asm-generic/pgtable-nopud.h
67606 +++ b/include/asm-generic/pgtable-nopud.h
67607 @@ -1,10 +1,15 @@
67608 #ifndef _PGTABLE_NOPUD_H
67609 #define _PGTABLE_NOPUD_H
67610
67611 -#ifndef __ASSEMBLY__
67612 -
67613 #define __PAGETABLE_PUD_FOLDED
67614
67615 +#define PUD_SHIFT PGDIR_SHIFT
67616 +#define PTRS_PER_PUD 1
67617 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
67618 +#define PUD_MASK (~(PUD_SIZE-1))
67619 +
67620 +#ifndef __ASSEMBLY__
67621 +
67622 /*
67623 * Having the pud type consist of a pgd gets the size right, and allows
67624 * us to conceptually access the pgd entry that this pud is folded into
67625 @@ -12,11 +17,6 @@
67626 */
67627 typedef struct { pgd_t pgd; } pud_t;
67628
67629 -#define PUD_SHIFT PGDIR_SHIFT
67630 -#define PTRS_PER_PUD 1
67631 -#define PUD_SIZE (1UL << PUD_SHIFT)
67632 -#define PUD_MASK (~(PUD_SIZE-1))
67633 -
67634 /*
67635 * The "pgd_xxx()" functions here are trivial for a folded two-level
67636 * setup: the pud is never bad, and a pud always exists (as it's folded
67637 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
67638 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
67639
67640 #define pgd_populate(mm, pgd, pud) do { } while (0)
67641 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
67642 /*
67643 * (puds are folded into pgds so this doesn't get actually called,
67644 * but the define is needed for a generic inline function.)
67645 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
67646 index a59ff51..2594a70 100644
67647 --- a/include/asm-generic/pgtable.h
67648 +++ b/include/asm-generic/pgtable.h
67649 @@ -688,6 +688,14 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
67650 }
67651 #endif /* CONFIG_NUMA_BALANCING */
67652
67653 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
67654 +static inline unsigned long pax_open_kernel(void) { return 0; }
67655 +#endif
67656 +
67657 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
67658 +static inline unsigned long pax_close_kernel(void) { return 0; }
67659 +#endif
67660 +
67661 #endif /* CONFIG_MMU */
67662
67663 #endif /* !__ASSEMBLY__ */
67664 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
67665 index eb58d2d..df131bf 100644
67666 --- a/include/asm-generic/vmlinux.lds.h
67667 +++ b/include/asm-generic/vmlinux.lds.h
67668 @@ -239,6 +239,7 @@
67669 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
67670 VMLINUX_SYMBOL(__start_rodata) = .; \
67671 *(.rodata) *(.rodata.*) \
67672 + *(.data..read_only) \
67673 *(__vermagic) /* Kernel version magic */ \
67674 . = ALIGN(8); \
67675 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
67676 @@ -749,17 +750,18 @@
67677 * section in the linker script will go there too. @phdr should have
67678 * a leading colon.
67679 *
67680 - * Note that this macros defines __per_cpu_load as an absolute symbol.
67681 + * Note that this macros defines per_cpu_load as an absolute symbol.
67682 * If there is no need to put the percpu section at a predetermined
67683 * address, use PERCPU_SECTION.
67684 */
67685 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
67686 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
67687 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
67688 + per_cpu_load = .; \
67689 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
67690 - LOAD_OFFSET) { \
67691 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
67692 PERCPU_INPUT(cacheline) \
67693 } phdr \
67694 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
67695 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
67696
67697 /**
67698 * PERCPU_SECTION - define output section for percpu area, simple version
67699 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
67700 index 418d270..bfd2794 100644
67701 --- a/include/crypto/algapi.h
67702 +++ b/include/crypto/algapi.h
67703 @@ -34,7 +34,7 @@ struct crypto_type {
67704 unsigned int maskclear;
67705 unsigned int maskset;
67706 unsigned int tfmsize;
67707 -};
67708 +} __do_const;
67709
67710 struct crypto_instance {
67711 struct crypto_alg alg;
67712 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
67713 index 63d17ee..716de2b 100644
67714 --- a/include/drm/drmP.h
67715 +++ b/include/drm/drmP.h
67716 @@ -72,6 +72,7 @@
67717 #include <linux/workqueue.h>
67718 #include <linux/poll.h>
67719 #include <asm/pgalloc.h>
67720 +#include <asm/local.h>
67721 #include <drm/drm.h>
67722 #include <drm/drm_sarea.h>
67723
67724 @@ -296,10 +297,12 @@ do { \
67725 * \param cmd command.
67726 * \param arg argument.
67727 */
67728 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
67729 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
67730 + struct drm_file *file_priv);
67731 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
67732 struct drm_file *file_priv);
67733
67734 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
67735 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
67736 unsigned long arg);
67737
67738 #define DRM_IOCTL_NR(n) _IOC_NR(n)
67739 @@ -314,10 +317,10 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
67740 struct drm_ioctl_desc {
67741 unsigned int cmd;
67742 int flags;
67743 - drm_ioctl_t *func;
67744 + drm_ioctl_t func;
67745 unsigned int cmd_drv;
67746 const char *name;
67747 -};
67748 +} __do_const;
67749
67750 /**
67751 * Creates a driver or general drm_ioctl_desc array entry for the given
67752 @@ -1015,7 +1018,7 @@ struct drm_info_list {
67753 int (*show)(struct seq_file*, void*); /** show callback */
67754 u32 driver_features; /**< Required driver features for this entry */
67755 void *data;
67756 -};
67757 +} __do_const;
67758
67759 /**
67760 * debugfs node structure. This structure represents a debugfs file.
67761 @@ -1088,7 +1091,7 @@ struct drm_device {
67762
67763 /** \name Usage Counters */
67764 /*@{ */
67765 - int open_count; /**< Outstanding files open */
67766 + local_t open_count; /**< Outstanding files open */
67767 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
67768 atomic_t vma_count; /**< Outstanding vma areas open */
67769 int buf_use; /**< Buffers in use -- cannot alloc */
67770 @@ -1099,7 +1102,7 @@ struct drm_device {
67771 /*@{ */
67772 unsigned long counters;
67773 enum drm_stat_type types[15];
67774 - atomic_t counts[15];
67775 + atomic_unchecked_t counts[15];
67776 /*@} */
67777
67778 struct list_head filelist;
67779 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
67780 index f43d556..94d9343 100644
67781 --- a/include/drm/drm_crtc_helper.h
67782 +++ b/include/drm/drm_crtc_helper.h
67783 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
67784 struct drm_connector *connector);
67785 /* disable encoder when not in use - more explicit than dpms off */
67786 void (*disable)(struct drm_encoder *encoder);
67787 -};
67788 +} __no_const;
67789
67790 /**
67791 * drm_connector_helper_funcs - helper operations for connectors
67792 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
67793 index 72dcbe8..8db58d7 100644
67794 --- a/include/drm/ttm/ttm_memory.h
67795 +++ b/include/drm/ttm/ttm_memory.h
67796 @@ -48,7 +48,7 @@
67797
67798 struct ttm_mem_shrink {
67799 int (*do_shrink) (struct ttm_mem_shrink *);
67800 -};
67801 +} __no_const;
67802
67803 /**
67804 * struct ttm_mem_global - Global memory accounting structure.
67805 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
67806 index 4b840e8..155d235 100644
67807 --- a/include/keys/asymmetric-subtype.h
67808 +++ b/include/keys/asymmetric-subtype.h
67809 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
67810 /* Verify the signature on a key of this subtype (optional) */
67811 int (*verify_signature)(const struct key *key,
67812 const struct public_key_signature *sig);
67813 -};
67814 +} __do_const;
67815
67816 /**
67817 * asymmetric_key_subtype - Get the subtype from an asymmetric key
67818 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
67819 index c1da539..1dcec55 100644
67820 --- a/include/linux/atmdev.h
67821 +++ b/include/linux/atmdev.h
67822 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
67823 #endif
67824
67825 struct k_atm_aal_stats {
67826 -#define __HANDLE_ITEM(i) atomic_t i
67827 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
67828 __AAL_STAT_ITEMS
67829 #undef __HANDLE_ITEM
67830 };
67831 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
67832 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
67833 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
67834 struct module *owner;
67835 -};
67836 +} __do_const ;
67837
67838 struct atmphy_ops {
67839 int (*start)(struct atm_dev *dev);
67840 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
67841 index 70cf138..cabb82e 100644
67842 --- a/include/linux/binfmts.h
67843 +++ b/include/linux/binfmts.h
67844 @@ -73,8 +73,9 @@ struct linux_binfmt {
67845 int (*load_binary)(struct linux_binprm *);
67846 int (*load_shlib)(struct file *);
67847 int (*core_dump)(struct coredump_params *cprm);
67848 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
67849 unsigned long min_coredump; /* minimal dump size */
67850 -};
67851 +} __do_const;
67852
67853 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
67854
67855 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
67856 index 2fdb4a4..54aad7e 100644
67857 --- a/include/linux/blkdev.h
67858 +++ b/include/linux/blkdev.h
67859 @@ -1526,7 +1526,7 @@ struct block_device_operations {
67860 /* this callback is with swap_lock and sometimes page table lock held */
67861 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
67862 struct module *owner;
67863 -};
67864 +} __do_const;
67865
67866 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
67867 unsigned long);
67868 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
67869 index 7c2e030..b72475d 100644
67870 --- a/include/linux/blktrace_api.h
67871 +++ b/include/linux/blktrace_api.h
67872 @@ -23,7 +23,7 @@ struct blk_trace {
67873 struct dentry *dir;
67874 struct dentry *dropped_file;
67875 struct dentry *msg_file;
67876 - atomic_t dropped;
67877 + atomic_unchecked_t dropped;
67878 };
67879
67880 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
67881 diff --git a/include/linux/cache.h b/include/linux/cache.h
67882 index 4c57065..4307975 100644
67883 --- a/include/linux/cache.h
67884 +++ b/include/linux/cache.h
67885 @@ -16,6 +16,10 @@
67886 #define __read_mostly
67887 #endif
67888
67889 +#ifndef __read_only
67890 +#define __read_only __read_mostly
67891 +#endif
67892 +
67893 #ifndef ____cacheline_aligned
67894 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
67895 #endif
67896 diff --git a/include/linux/capability.h b/include/linux/capability.h
67897 index d9a4f7f4..19f77d6 100644
67898 --- a/include/linux/capability.h
67899 +++ b/include/linux/capability.h
67900 @@ -213,8 +213,13 @@ extern bool ns_capable(struct user_namespace *ns, int cap);
67901 extern bool nsown_capable(int cap);
67902 extern bool inode_capable(const struct inode *inode, int cap);
67903 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
67904 +extern bool capable_nolog(int cap);
67905 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
67906 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
67907
67908 /* audit system wants to get cap info from files as well */
67909 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
67910
67911 +extern int is_privileged_binary(const struct dentry *dentry);
67912 +
67913 #endif /* !_LINUX_CAPABILITY_H */
67914 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
67915 index 8609d57..86e4d79 100644
67916 --- a/include/linux/cdrom.h
67917 +++ b/include/linux/cdrom.h
67918 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
67919
67920 /* driver specifications */
67921 const int capability; /* capability flags */
67922 - int n_minors; /* number of active minor devices */
67923 /* handle uniform packets for scsi type devices (scsi,atapi) */
67924 int (*generic_packet) (struct cdrom_device_info *,
67925 struct packet_command *);
67926 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
67927 index 4ce9056..86caac6 100644
67928 --- a/include/linux/cleancache.h
67929 +++ b/include/linux/cleancache.h
67930 @@ -31,7 +31,7 @@ struct cleancache_ops {
67931 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
67932 void (*invalidate_inode)(int, struct cleancache_filekey);
67933 void (*invalidate_fs)(int);
67934 -};
67935 +} __no_const;
67936
67937 extern struct cleancache_ops *
67938 cleancache_register_ops(struct cleancache_ops *ops);
67939 diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
67940 index 1186098..f87e53d 100644
67941 --- a/include/linux/clk-provider.h
67942 +++ b/include/linux/clk-provider.h
67943 @@ -132,6 +132,7 @@ struct clk_ops {
67944 unsigned long);
67945 void (*init)(struct clk_hw *hw);
67946 };
67947 +typedef struct clk_ops __no_const clk_ops_no_const;
67948
67949 /**
67950 * struct clk_init_data - holds init data that's common to all clocks and is
67951 diff --git a/include/linux/compat.h b/include/linux/compat.h
67952 index 7f0c1dd..b5729c6 100644
67953 --- a/include/linux/compat.h
67954 +++ b/include/linux/compat.h
67955 @@ -312,7 +312,7 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
67956 compat_size_t __user *len_ptr);
67957
67958 asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32);
67959 -asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
67960 +asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
67961 asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
67962 asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp,
67963 compat_ssize_t msgsz, int msgflg);
67964 @@ -419,7 +419,7 @@ extern int compat_ptrace_request(struct task_struct *child,
67965 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
67966 compat_ulong_t addr, compat_ulong_t data);
67967 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
67968 - compat_long_t addr, compat_long_t data);
67969 + compat_ulong_t addr, compat_ulong_t data);
67970
67971 asmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, size_t);
67972 /*
67973 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
67974 index 842de22..7f3a41f 100644
67975 --- a/include/linux/compiler-gcc4.h
67976 +++ b/include/linux/compiler-gcc4.h
67977 @@ -39,9 +39,29 @@
67978 # define __compiletime_warning(message) __attribute__((warning(message)))
67979 # define __compiletime_error(message) __attribute__((error(message)))
67980 #endif /* __CHECKER__ */
67981 +
67982 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
67983 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
67984 +#define __bos0(ptr) __bos((ptr), 0)
67985 +#define __bos1(ptr) __bos((ptr), 1)
67986 #endif /* GCC_VERSION >= 40300 */
67987
67988 #if GCC_VERSION >= 40500
67989 +
67990 +#ifdef CONSTIFY_PLUGIN
67991 +#define __no_const __attribute__((no_const))
67992 +#define __do_const __attribute__((do_const))
67993 +#endif
67994 +
67995 +#ifdef SIZE_OVERFLOW_PLUGIN
67996 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
67997 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
67998 +#endif
67999 +
68000 +#ifdef LATENT_ENTROPY_PLUGIN
68001 +#define __latent_entropy __attribute__((latent_entropy))
68002 +#endif
68003 +
68004 /*
68005 * Mark a position in code as unreachable. This can be used to
68006 * suppress control flow warnings after asm blocks that transfer
68007 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
68008 index 92669cd..1771a15 100644
68009 --- a/include/linux/compiler.h
68010 +++ b/include/linux/compiler.h
68011 @@ -5,11 +5,14 @@
68012
68013 #ifdef __CHECKER__
68014 # define __user __attribute__((noderef, address_space(1)))
68015 +# define __force_user __force __user
68016 # define __kernel __attribute__((address_space(0)))
68017 +# define __force_kernel __force __kernel
68018 # define __safe __attribute__((safe))
68019 # define __force __attribute__((force))
68020 # define __nocast __attribute__((nocast))
68021 # define __iomem __attribute__((noderef, address_space(2)))
68022 +# define __force_iomem __force __iomem
68023 # define __must_hold(x) __attribute__((context(x,1,1)))
68024 # define __acquires(x) __attribute__((context(x,0,1)))
68025 # define __releases(x) __attribute__((context(x,1,0)))
68026 @@ -17,20 +20,37 @@
68027 # define __release(x) __context__(x,-1)
68028 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
68029 # define __percpu __attribute__((noderef, address_space(3)))
68030 +# define __force_percpu __force __percpu
68031 #ifdef CONFIG_SPARSE_RCU_POINTER
68032 # define __rcu __attribute__((noderef, address_space(4)))
68033 +# define __force_rcu __force __rcu
68034 #else
68035 # define __rcu
68036 +# define __force_rcu
68037 #endif
68038 extern void __chk_user_ptr(const volatile void __user *);
68039 extern void __chk_io_ptr(const volatile void __iomem *);
68040 #else
68041 -# define __user
68042 -# define __kernel
68043 +# ifdef CHECKER_PLUGIN
68044 +//# define __user
68045 +//# define __force_user
68046 +//# define __kernel
68047 +//# define __force_kernel
68048 +# else
68049 +# ifdef STRUCTLEAK_PLUGIN
68050 +# define __user __attribute__((user))
68051 +# else
68052 +# define __user
68053 +# endif
68054 +# define __force_user
68055 +# define __kernel
68056 +# define __force_kernel
68057 +# endif
68058 # define __safe
68059 # define __force
68060 # define __nocast
68061 # define __iomem
68062 +# define __force_iomem
68063 # define __chk_user_ptr(x) (void)0
68064 # define __chk_io_ptr(x) (void)0
68065 # define __builtin_warning(x, y...) (1)
68066 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
68067 # define __release(x) (void)0
68068 # define __cond_lock(x,c) (c)
68069 # define __percpu
68070 +# define __force_percpu
68071 # define __rcu
68072 +# define __force_rcu
68073 #endif
68074
68075 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
68076 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
68077 # define __attribute_const__ /* unimplemented */
68078 #endif
68079
68080 +#ifndef __no_const
68081 +# define __no_const
68082 +#endif
68083 +
68084 +#ifndef __do_const
68085 +# define __do_const
68086 +#endif
68087 +
68088 +#ifndef __size_overflow
68089 +# define __size_overflow(...)
68090 +#endif
68091 +
68092 +#ifndef __intentional_overflow
68093 +# define __intentional_overflow(...)
68094 +#endif
68095 +
68096 +#ifndef __latent_entropy
68097 +# define __latent_entropy
68098 +#endif
68099 +
68100 /*
68101 * Tell gcc if a function is cold. The compiler will assume any path
68102 * directly leading to the call is unlikely.
68103 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
68104 #define __cold
68105 #endif
68106
68107 +#ifndef __alloc_size
68108 +#define __alloc_size(...)
68109 +#endif
68110 +
68111 +#ifndef __bos
68112 +#define __bos(ptr, arg)
68113 +#endif
68114 +
68115 +#ifndef __bos0
68116 +#define __bos0(ptr)
68117 +#endif
68118 +
68119 +#ifndef __bos1
68120 +#define __bos1(ptr)
68121 +#endif
68122 +
68123 /* Simple shorthand for a section definition */
68124 #ifndef __section
68125 # define __section(S) __attribute__ ((__section__(#S)))
68126 @@ -349,7 +407,8 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
68127 * use is to mediate communication between process-level code and irq/NMI
68128 * handlers, all running on the same CPU.
68129 */
68130 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
68131 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
68132 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
68133
68134 /* Ignore/forbid kprobes attach on very low level functions marked by this attribute: */
68135 #ifdef CONFIG_KPROBES
68136 diff --git a/include/linux/completion.h b/include/linux/completion.h
68137 index 33f0280..35c6568 100644
68138 --- a/include/linux/completion.h
68139 +++ b/include/linux/completion.h
68140 @@ -79,15 +79,15 @@ static inline void init_completion(struct completion *x)
68141 extern void wait_for_completion(struct completion *);
68142 extern void wait_for_completion_io(struct completion *);
68143 extern int wait_for_completion_interruptible(struct completion *x);
68144 -extern int wait_for_completion_killable(struct completion *x);
68145 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
68146 extern unsigned long wait_for_completion_timeout(struct completion *x,
68147 unsigned long timeout);
68148 extern unsigned long wait_for_completion_io_timeout(struct completion *x,
68149 unsigned long timeout);
68150 extern long wait_for_completion_interruptible_timeout(
68151 - struct completion *x, unsigned long timeout);
68152 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
68153 extern long wait_for_completion_killable_timeout(
68154 - struct completion *x, unsigned long timeout);
68155 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
68156 extern bool try_wait_for_completion(struct completion *x);
68157 extern bool completion_done(struct completion *x);
68158
68159 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
68160 index 34025df..d94bbbc 100644
68161 --- a/include/linux/configfs.h
68162 +++ b/include/linux/configfs.h
68163 @@ -125,7 +125,7 @@ struct configfs_attribute {
68164 const char *ca_name;
68165 struct module *ca_owner;
68166 umode_t ca_mode;
68167 -};
68168 +} __do_const;
68169
68170 /*
68171 * Users often need to create attribute structures for their configurable
68172 diff --git a/include/linux/cpu.h b/include/linux/cpu.h
68173 index 9f3c7e8..a18c7b6 100644
68174 --- a/include/linux/cpu.h
68175 +++ b/include/linux/cpu.h
68176 @@ -115,7 +115,7 @@ enum {
68177 /* Need to know about CPUs going up/down? */
68178 #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE)
68179 #define cpu_notifier(fn, pri) { \
68180 - static struct notifier_block fn##_nb __cpuinitdata = \
68181 + static struct notifier_block fn##_nb = \
68182 { .notifier_call = fn, .priority = pri }; \
68183 register_cpu_notifier(&fn##_nb); \
68184 }
68185 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
68186 index 037d36a..ca5fe6e 100644
68187 --- a/include/linux/cpufreq.h
68188 +++ b/include/linux/cpufreq.h
68189 @@ -262,7 +262,7 @@ struct cpufreq_driver {
68190 int (*suspend) (struct cpufreq_policy *policy);
68191 int (*resume) (struct cpufreq_policy *policy);
68192 struct freq_attr **attr;
68193 -};
68194 +} __do_const;
68195
68196 /* flags */
68197
68198 @@ -321,6 +321,7 @@ struct global_attr {
68199 ssize_t (*store)(struct kobject *a, struct attribute *b,
68200 const char *c, size_t count);
68201 };
68202 +typedef struct global_attr __no_const global_attr_no_const;
68203
68204 #define define_one_global_ro(_name) \
68205 static struct global_attr _name = \
68206 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
68207 index 8f04062..900239a 100644
68208 --- a/include/linux/cpuidle.h
68209 +++ b/include/linux/cpuidle.h
68210 @@ -52,7 +52,8 @@ struct cpuidle_state {
68211 int index);
68212
68213 int (*enter_dead) (struct cpuidle_device *dev, int index);
68214 -};
68215 +} __do_const;
68216 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
68217
68218 /* Idle State Flags */
68219 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
68220 @@ -191,7 +192,7 @@ struct cpuidle_governor {
68221 void (*reflect) (struct cpuidle_device *dev, int index);
68222
68223 struct module *owner;
68224 -};
68225 +} __do_const;
68226
68227 #ifdef CONFIG_CPU_IDLE
68228
68229 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
68230 index d08e4d2..95fad61 100644
68231 --- a/include/linux/cpumask.h
68232 +++ b/include/linux/cpumask.h
68233 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
68234 }
68235
68236 /* Valid inputs for n are -1 and 0. */
68237 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68238 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
68239 {
68240 return n+1;
68241 }
68242
68243 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68244 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
68245 {
68246 return n+1;
68247 }
68248
68249 -static inline unsigned int cpumask_next_and(int n,
68250 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
68251 const struct cpumask *srcp,
68252 const struct cpumask *andp)
68253 {
68254 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
68255 *
68256 * Returns >= nr_cpu_ids if no further cpus set.
68257 */
68258 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68259 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
68260 {
68261 /* -1 is a legal arg here. */
68262 if (n != -1)
68263 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
68264 *
68265 * Returns >= nr_cpu_ids if no further cpus unset.
68266 */
68267 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68268 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
68269 {
68270 /* -1 is a legal arg here. */
68271 if (n != -1)
68272 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
68273 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
68274 }
68275
68276 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
68277 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
68278 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
68279
68280 /**
68281 diff --git a/include/linux/cred.h b/include/linux/cred.h
68282 index 04421e8..6bce4ef 100644
68283 --- a/include/linux/cred.h
68284 +++ b/include/linux/cred.h
68285 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
68286 static inline void validate_process_creds(void)
68287 {
68288 }
68289 +static inline void validate_task_creds(struct task_struct *task)
68290 +{
68291 +}
68292 #endif
68293
68294 /**
68295 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
68296 index b92eadf..b4ecdc1 100644
68297 --- a/include/linux/crypto.h
68298 +++ b/include/linux/crypto.h
68299 @@ -373,7 +373,7 @@ struct cipher_tfm {
68300 const u8 *key, unsigned int keylen);
68301 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
68302 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
68303 -};
68304 +} __no_const;
68305
68306 struct hash_tfm {
68307 int (*init)(struct hash_desc *desc);
68308 @@ -394,13 +394,13 @@ struct compress_tfm {
68309 int (*cot_decompress)(struct crypto_tfm *tfm,
68310 const u8 *src, unsigned int slen,
68311 u8 *dst, unsigned int *dlen);
68312 -};
68313 +} __no_const;
68314
68315 struct rng_tfm {
68316 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
68317 unsigned int dlen);
68318 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
68319 -};
68320 +} __no_const;
68321
68322 #define crt_ablkcipher crt_u.ablkcipher
68323 #define crt_aead crt_u.aead
68324 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
68325 index 653589e..4ef254a 100644
68326 --- a/include/linux/ctype.h
68327 +++ b/include/linux/ctype.h
68328 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
68329 * Fast implementation of tolower() for internal usage. Do not use in your
68330 * code.
68331 */
68332 -static inline char _tolower(const char c)
68333 +static inline unsigned char _tolower(const unsigned char c)
68334 {
68335 return c | 0x20;
68336 }
68337 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
68338 index 7925bf0..d5143d2 100644
68339 --- a/include/linux/decompress/mm.h
68340 +++ b/include/linux/decompress/mm.h
68341 @@ -77,7 +77,7 @@ static void free(void *where)
68342 * warnings when not needed (indeed large_malloc / large_free are not
68343 * needed by inflate */
68344
68345 -#define malloc(a) kmalloc(a, GFP_KERNEL)
68346 +#define malloc(a) kmalloc((a), GFP_KERNEL)
68347 #define free(a) kfree(a)
68348
68349 #define large_malloc(a) vmalloc(a)
68350 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
68351 index fe8c447..bdc1f33 100644
68352 --- a/include/linux/devfreq.h
68353 +++ b/include/linux/devfreq.h
68354 @@ -114,7 +114,7 @@ struct devfreq_governor {
68355 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
68356 int (*event_handler)(struct devfreq *devfreq,
68357 unsigned int event, void *data);
68358 -};
68359 +} __do_const;
68360
68361 /**
68362 * struct devfreq - Device devfreq structure
68363 diff --git a/include/linux/device.h b/include/linux/device.h
68364 index c0a1261..dba7569 100644
68365 --- a/include/linux/device.h
68366 +++ b/include/linux/device.h
68367 @@ -290,7 +290,7 @@ struct subsys_interface {
68368 struct list_head node;
68369 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
68370 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
68371 -};
68372 +} __do_const;
68373
68374 int subsys_interface_register(struct subsys_interface *sif);
68375 void subsys_interface_unregister(struct subsys_interface *sif);
68376 @@ -473,7 +473,7 @@ struct device_type {
68377 void (*release)(struct device *dev);
68378
68379 const struct dev_pm_ops *pm;
68380 -};
68381 +} __do_const;
68382
68383 /* interface for exporting device attributes */
68384 struct device_attribute {
68385 @@ -483,11 +483,12 @@ struct device_attribute {
68386 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
68387 const char *buf, size_t count);
68388 };
68389 +typedef struct device_attribute __no_const device_attribute_no_const;
68390
68391 struct dev_ext_attribute {
68392 struct device_attribute attr;
68393 void *var;
68394 -};
68395 +} __do_const;
68396
68397 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
68398 char *buf);
68399 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
68400 index 94af418..b1ca7a2 100644
68401 --- a/include/linux/dma-mapping.h
68402 +++ b/include/linux/dma-mapping.h
68403 @@ -54,7 +54,7 @@ struct dma_map_ops {
68404 u64 (*get_required_mask)(struct device *dev);
68405 #endif
68406 int is_phys;
68407 -};
68408 +} __do_const;
68409
68410 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
68411
68412 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
68413 index 96d3e4a..dc36433 100644
68414 --- a/include/linux/dmaengine.h
68415 +++ b/include/linux/dmaengine.h
68416 @@ -1035,9 +1035,9 @@ struct dma_pinned_list {
68417 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
68418 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
68419
68420 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
68421 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
68422 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
68423 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
68424 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
68425 struct dma_pinned_list *pinned_list, struct page *page,
68426 unsigned int offset, size_t len);
68427
68428 diff --git a/include/linux/efi.h b/include/linux/efi.h
68429 index 2bc0ad7..3f7b006 100644
68430 --- a/include/linux/efi.h
68431 +++ b/include/linux/efi.h
68432 @@ -745,6 +745,7 @@ struct efivar_operations {
68433 efi_set_variable_t *set_variable;
68434 efi_query_variable_store_t *query_variable_store;
68435 };
68436 +typedef struct efivar_operations __no_const efivar_operations_no_const;
68437
68438 struct efivars {
68439 /*
68440 diff --git a/include/linux/elf.h b/include/linux/elf.h
68441 index 40a3c0e..4c45a38 100644
68442 --- a/include/linux/elf.h
68443 +++ b/include/linux/elf.h
68444 @@ -24,6 +24,7 @@ extern Elf32_Dyn _DYNAMIC [];
68445 #define elf_note elf32_note
68446 #define elf_addr_t Elf32_Off
68447 #define Elf_Half Elf32_Half
68448 +#define elf_dyn Elf32_Dyn
68449
68450 #else
68451
68452 @@ -34,6 +35,7 @@ extern Elf64_Dyn _DYNAMIC [];
68453 #define elf_note elf64_note
68454 #define elf_addr_t Elf64_Off
68455 #define Elf_Half Elf64_Half
68456 +#define elf_dyn Elf64_Dyn
68457
68458 #endif
68459
68460 diff --git a/include/linux/err.h b/include/linux/err.h
68461 index f2edce2..cc2082c 100644
68462 --- a/include/linux/err.h
68463 +++ b/include/linux/err.h
68464 @@ -19,12 +19,12 @@
68465
68466 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
68467
68468 -static inline void * __must_check ERR_PTR(long error)
68469 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
68470 {
68471 return (void *) error;
68472 }
68473
68474 -static inline long __must_check PTR_ERR(const void *ptr)
68475 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(const void *ptr)
68476 {
68477 return (long) ptr;
68478 }
68479 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
68480 index fcb51c8..bdafcf6 100644
68481 --- a/include/linux/extcon.h
68482 +++ b/include/linux/extcon.h
68483 @@ -134,7 +134,7 @@ struct extcon_dev {
68484 /* /sys/class/extcon/.../mutually_exclusive/... */
68485 struct attribute_group attr_g_muex;
68486 struct attribute **attrs_muex;
68487 - struct device_attribute *d_attrs_muex;
68488 + device_attribute_no_const *d_attrs_muex;
68489 };
68490
68491 /**
68492 diff --git a/include/linux/fb.h b/include/linux/fb.h
68493 index d49c60f..2834fbe 100644
68494 --- a/include/linux/fb.h
68495 +++ b/include/linux/fb.h
68496 @@ -304,7 +304,7 @@ struct fb_ops {
68497 /* called at KDB enter and leave time to prepare the console */
68498 int (*fb_debug_enter)(struct fb_info *info);
68499 int (*fb_debug_leave)(struct fb_info *info);
68500 -};
68501 +} __do_const;
68502
68503 #ifdef CONFIG_FB_TILEBLITTING
68504 #define FB_TILE_CURSOR_NONE 0
68505 diff --git a/include/linux/filter.h b/include/linux/filter.h
68506 index f65f5a6..2f4f93a 100644
68507 --- a/include/linux/filter.h
68508 +++ b/include/linux/filter.h
68509 @@ -20,6 +20,7 @@ struct compat_sock_fprog {
68510
68511 struct sk_buff;
68512 struct sock;
68513 +struct bpf_jit_work;
68514
68515 struct sk_filter
68516 {
68517 @@ -27,6 +28,9 @@ struct sk_filter
68518 unsigned int len; /* Number of filter blocks */
68519 unsigned int (*bpf_func)(const struct sk_buff *skb,
68520 const struct sock_filter *filter);
68521 +#ifdef CONFIG_BPF_JIT
68522 + struct bpf_jit_work *work;
68523 +#endif
68524 struct rcu_head rcu;
68525 struct sock_filter insns[0];
68526 };
68527 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
68528 index 8293262..2b3b8bd 100644
68529 --- a/include/linux/frontswap.h
68530 +++ b/include/linux/frontswap.h
68531 @@ -11,7 +11,7 @@ struct frontswap_ops {
68532 int (*load)(unsigned, pgoff_t, struct page *);
68533 void (*invalidate_page)(unsigned, pgoff_t);
68534 void (*invalidate_area)(unsigned);
68535 -};
68536 +} __no_const;
68537
68538 extern bool frontswap_enabled;
68539 extern struct frontswap_ops *
68540 diff --git a/include/linux/fs.h b/include/linux/fs.h
68541 index 65c2be2..4c53f6e 100644
68542 --- a/include/linux/fs.h
68543 +++ b/include/linux/fs.h
68544 @@ -1543,7 +1543,8 @@ struct file_operations {
68545 long (*fallocate)(struct file *file, int mode, loff_t offset,
68546 loff_t len);
68547 int (*show_fdinfo)(struct seq_file *m, struct file *f);
68548 -};
68549 +} __do_const;
68550 +typedef struct file_operations __no_const file_operations_no_const;
68551
68552 struct inode_operations {
68553 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
68554 @@ -2688,4 +2689,14 @@ static inline void inode_has_no_xattr(struct inode *inode)
68555 inode->i_flags |= S_NOSEC;
68556 }
68557
68558 +static inline bool is_sidechannel_device(const struct inode *inode)
68559 +{
68560 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
68561 + umode_t mode = inode->i_mode;
68562 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
68563 +#else
68564 + return false;
68565 +#endif
68566 +}
68567 +
68568 #endif /* _LINUX_FS_H */
68569 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
68570 index 2b93a9a..855d94a 100644
68571 --- a/include/linux/fs_struct.h
68572 +++ b/include/linux/fs_struct.h
68573 @@ -6,7 +6,7 @@
68574 #include <linux/seqlock.h>
68575
68576 struct fs_struct {
68577 - int users;
68578 + atomic_t users;
68579 spinlock_t lock;
68580 seqcount_t seq;
68581 int umask;
68582 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
68583 index 5dfa0aa..6acf322 100644
68584 --- a/include/linux/fscache-cache.h
68585 +++ b/include/linux/fscache-cache.h
68586 @@ -112,7 +112,7 @@ struct fscache_operation {
68587 fscache_operation_release_t release;
68588 };
68589
68590 -extern atomic_t fscache_op_debug_id;
68591 +extern atomic_unchecked_t fscache_op_debug_id;
68592 extern void fscache_op_work_func(struct work_struct *work);
68593
68594 extern void fscache_enqueue_operation(struct fscache_operation *);
68595 @@ -134,7 +134,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
68596 INIT_WORK(&op->work, fscache_op_work_func);
68597 atomic_set(&op->usage, 1);
68598 op->state = FSCACHE_OP_ST_INITIALISED;
68599 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
68600 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
68601 op->processor = processor;
68602 op->release = release;
68603 INIT_LIST_HEAD(&op->pend_link);
68604 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
68605 index 7a08623..4c07b0f 100644
68606 --- a/include/linux/fscache.h
68607 +++ b/include/linux/fscache.h
68608 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
68609 * - this is mandatory for any object that may have data
68610 */
68611 void (*now_uncached)(void *cookie_netfs_data);
68612 -};
68613 +} __do_const;
68614
68615 /*
68616 * fscache cached network filesystem type
68617 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
68618 index a78680a..87bd73e 100644
68619 --- a/include/linux/fsnotify.h
68620 +++ b/include/linux/fsnotify.h
68621 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
68622 struct inode *inode = path->dentry->d_inode;
68623 __u32 mask = FS_ACCESS;
68624
68625 + if (is_sidechannel_device(inode))
68626 + return;
68627 +
68628 if (S_ISDIR(inode->i_mode))
68629 mask |= FS_ISDIR;
68630
68631 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
68632 struct inode *inode = path->dentry->d_inode;
68633 __u32 mask = FS_MODIFY;
68634
68635 + if (is_sidechannel_device(inode))
68636 + return;
68637 +
68638 if (S_ISDIR(inode->i_mode))
68639 mask |= FS_ISDIR;
68640
68641 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
68642 */
68643 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
68644 {
68645 - return kstrdup(name, GFP_KERNEL);
68646 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
68647 }
68648
68649 /*
68650 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
68651 index 9f3c275..911b591 100644
68652 --- a/include/linux/genhd.h
68653 +++ b/include/linux/genhd.h
68654 @@ -194,7 +194,7 @@ struct gendisk {
68655 struct kobject *slave_dir;
68656
68657 struct timer_rand_state *random;
68658 - atomic_t sync_io; /* RAID */
68659 + atomic_unchecked_t sync_io; /* RAID */
68660 struct disk_events *ev;
68661 #ifdef CONFIG_BLK_DEV_INTEGRITY
68662 struct blk_integrity *integrity;
68663 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
68664 index 023bc34..b02b46a 100644
68665 --- a/include/linux/genl_magic_func.h
68666 +++ b/include/linux/genl_magic_func.h
68667 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
68668 },
68669
68670 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
68671 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
68672 +static struct genl_ops ZZZ_genl_ops[] = {
68673 #include GENL_MAGIC_INCLUDE_FILE
68674 };
68675
68676 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
68677 index 0f615eb..5c3832f 100644
68678 --- a/include/linux/gfp.h
68679 +++ b/include/linux/gfp.h
68680 @@ -35,6 +35,13 @@ struct vm_area_struct;
68681 #define ___GFP_NO_KSWAPD 0x400000u
68682 #define ___GFP_OTHER_NODE 0x800000u
68683 #define ___GFP_WRITE 0x1000000u
68684 +
68685 +#ifdef CONFIG_PAX_USERCOPY_SLABS
68686 +#define ___GFP_USERCOPY 0x2000000u
68687 +#else
68688 +#define ___GFP_USERCOPY 0
68689 +#endif
68690 +
68691 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
68692
68693 /*
68694 @@ -92,6 +99,7 @@ struct vm_area_struct;
68695 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
68696 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
68697 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
68698 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
68699
68700 /*
68701 * This may seem redundant, but it's a way of annotating false positives vs.
68702 @@ -99,7 +107,7 @@ struct vm_area_struct;
68703 */
68704 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
68705
68706 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
68707 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
68708 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
68709
68710 /* This equals 0, but use constants in case they ever change */
68711 @@ -153,6 +161,8 @@ struct vm_area_struct;
68712 /* 4GB DMA on some platforms */
68713 #define GFP_DMA32 __GFP_DMA32
68714
68715 +#define GFP_USERCOPY __GFP_USERCOPY
68716 +
68717 /* Convert GFP flags to their corresponding migrate type */
68718 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
68719 {
68720 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
68721 new file mode 100644
68722 index 0000000..ebe6d72
68723 --- /dev/null
68724 +++ b/include/linux/gracl.h
68725 @@ -0,0 +1,319 @@
68726 +#ifndef GR_ACL_H
68727 +#define GR_ACL_H
68728 +
68729 +#include <linux/grdefs.h>
68730 +#include <linux/resource.h>
68731 +#include <linux/capability.h>
68732 +#include <linux/dcache.h>
68733 +#include <asm/resource.h>
68734 +
68735 +/* Major status information */
68736 +
68737 +#define GR_VERSION "grsecurity 2.9.1"
68738 +#define GRSECURITY_VERSION 0x2901
68739 +
68740 +enum {
68741 + GR_SHUTDOWN = 0,
68742 + GR_ENABLE = 1,
68743 + GR_SPROLE = 2,
68744 + GR_RELOAD = 3,
68745 + GR_SEGVMOD = 4,
68746 + GR_STATUS = 5,
68747 + GR_UNSPROLE = 6,
68748 + GR_PASSSET = 7,
68749 + GR_SPROLEPAM = 8,
68750 +};
68751 +
68752 +/* Password setup definitions
68753 + * kernel/grhash.c */
68754 +enum {
68755 + GR_PW_LEN = 128,
68756 + GR_SALT_LEN = 16,
68757 + GR_SHA_LEN = 32,
68758 +};
68759 +
68760 +enum {
68761 + GR_SPROLE_LEN = 64,
68762 +};
68763 +
68764 +enum {
68765 + GR_NO_GLOB = 0,
68766 + GR_REG_GLOB,
68767 + GR_CREATE_GLOB
68768 +};
68769 +
68770 +#define GR_NLIMITS 32
68771 +
68772 +/* Begin Data Structures */
68773 +
68774 +struct sprole_pw {
68775 + unsigned char *rolename;
68776 + unsigned char salt[GR_SALT_LEN];
68777 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
68778 +};
68779 +
68780 +struct name_entry {
68781 + __u32 key;
68782 + ino_t inode;
68783 + dev_t device;
68784 + char *name;
68785 + __u16 len;
68786 + __u8 deleted;
68787 + struct name_entry *prev;
68788 + struct name_entry *next;
68789 +};
68790 +
68791 +struct inodev_entry {
68792 + struct name_entry *nentry;
68793 + struct inodev_entry *prev;
68794 + struct inodev_entry *next;
68795 +};
68796 +
68797 +struct acl_role_db {
68798 + struct acl_role_label **r_hash;
68799 + __u32 r_size;
68800 +};
68801 +
68802 +struct inodev_db {
68803 + struct inodev_entry **i_hash;
68804 + __u32 i_size;
68805 +};
68806 +
68807 +struct name_db {
68808 + struct name_entry **n_hash;
68809 + __u32 n_size;
68810 +};
68811 +
68812 +struct crash_uid {
68813 + uid_t uid;
68814 + unsigned long expires;
68815 +};
68816 +
68817 +struct gr_hash_struct {
68818 + void **table;
68819 + void **nametable;
68820 + void *first;
68821 + __u32 table_size;
68822 + __u32 used_size;
68823 + int type;
68824 +};
68825 +
68826 +/* Userspace Grsecurity ACL data structures */
68827 +
68828 +struct acl_subject_label {
68829 + char *filename;
68830 + ino_t inode;
68831 + dev_t device;
68832 + __u32 mode;
68833 + kernel_cap_t cap_mask;
68834 + kernel_cap_t cap_lower;
68835 + kernel_cap_t cap_invert_audit;
68836 +
68837 + struct rlimit res[GR_NLIMITS];
68838 + __u32 resmask;
68839 +
68840 + __u8 user_trans_type;
68841 + __u8 group_trans_type;
68842 + uid_t *user_transitions;
68843 + gid_t *group_transitions;
68844 + __u16 user_trans_num;
68845 + __u16 group_trans_num;
68846 +
68847 + __u32 sock_families[2];
68848 + __u32 ip_proto[8];
68849 + __u32 ip_type;
68850 + struct acl_ip_label **ips;
68851 + __u32 ip_num;
68852 + __u32 inaddr_any_override;
68853 +
68854 + __u32 crashes;
68855 + unsigned long expires;
68856 +
68857 + struct acl_subject_label *parent_subject;
68858 + struct gr_hash_struct *hash;
68859 + struct acl_subject_label *prev;
68860 + struct acl_subject_label *next;
68861 +
68862 + struct acl_object_label **obj_hash;
68863 + __u32 obj_hash_size;
68864 + __u16 pax_flags;
68865 +};
68866 +
68867 +struct role_allowed_ip {
68868 + __u32 addr;
68869 + __u32 netmask;
68870 +
68871 + struct role_allowed_ip *prev;
68872 + struct role_allowed_ip *next;
68873 +};
68874 +
68875 +struct role_transition {
68876 + char *rolename;
68877 +
68878 + struct role_transition *prev;
68879 + struct role_transition *next;
68880 +};
68881 +
68882 +struct acl_role_label {
68883 + char *rolename;
68884 + uid_t uidgid;
68885 + __u16 roletype;
68886 +
68887 + __u16 auth_attempts;
68888 + unsigned long expires;
68889 +
68890 + struct acl_subject_label *root_label;
68891 + struct gr_hash_struct *hash;
68892 +
68893 + struct acl_role_label *prev;
68894 + struct acl_role_label *next;
68895 +
68896 + struct role_transition *transitions;
68897 + struct role_allowed_ip *allowed_ips;
68898 + uid_t *domain_children;
68899 + __u16 domain_child_num;
68900 +
68901 + umode_t umask;
68902 +
68903 + struct acl_subject_label **subj_hash;
68904 + __u32 subj_hash_size;
68905 +};
68906 +
68907 +struct user_acl_role_db {
68908 + struct acl_role_label **r_table;
68909 + __u32 num_pointers; /* Number of allocations to track */
68910 + __u32 num_roles; /* Number of roles */
68911 + __u32 num_domain_children; /* Number of domain children */
68912 + __u32 num_subjects; /* Number of subjects */
68913 + __u32 num_objects; /* Number of objects */
68914 +};
68915 +
68916 +struct acl_object_label {
68917 + char *filename;
68918 + ino_t inode;
68919 + dev_t device;
68920 + __u32 mode;
68921 +
68922 + struct acl_subject_label *nested;
68923 + struct acl_object_label *globbed;
68924 +
68925 + /* next two structures not used */
68926 +
68927 + struct acl_object_label *prev;
68928 + struct acl_object_label *next;
68929 +};
68930 +
68931 +struct acl_ip_label {
68932 + char *iface;
68933 + __u32 addr;
68934 + __u32 netmask;
68935 + __u16 low, high;
68936 + __u8 mode;
68937 + __u32 type;
68938 + __u32 proto[8];
68939 +
68940 + /* next two structures not used */
68941 +
68942 + struct acl_ip_label *prev;
68943 + struct acl_ip_label *next;
68944 +};
68945 +
68946 +struct gr_arg {
68947 + struct user_acl_role_db role_db;
68948 + unsigned char pw[GR_PW_LEN];
68949 + unsigned char salt[GR_SALT_LEN];
68950 + unsigned char sum[GR_SHA_LEN];
68951 + unsigned char sp_role[GR_SPROLE_LEN];
68952 + struct sprole_pw *sprole_pws;
68953 + dev_t segv_device;
68954 + ino_t segv_inode;
68955 + uid_t segv_uid;
68956 + __u16 num_sprole_pws;
68957 + __u16 mode;
68958 +};
68959 +
68960 +struct gr_arg_wrapper {
68961 + struct gr_arg *arg;
68962 + __u32 version;
68963 + __u32 size;
68964 +};
68965 +
68966 +struct subject_map {
68967 + struct acl_subject_label *user;
68968 + struct acl_subject_label *kernel;
68969 + struct subject_map *prev;
68970 + struct subject_map *next;
68971 +};
68972 +
68973 +struct acl_subj_map_db {
68974 + struct subject_map **s_hash;
68975 + __u32 s_size;
68976 +};
68977 +
68978 +/* End Data Structures Section */
68979 +
68980 +/* Hash functions generated by empirical testing by Brad Spengler
68981 + Makes good use of the low bits of the inode. Generally 0-1 times
68982 + in loop for successful match. 0-3 for unsuccessful match.
68983 + Shift/add algorithm with modulus of table size and an XOR*/
68984 +
68985 +static __inline__ unsigned int
68986 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
68987 +{
68988 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
68989 +}
68990 +
68991 + static __inline__ unsigned int
68992 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
68993 +{
68994 + return ((const unsigned long)userp % sz);
68995 +}
68996 +
68997 +static __inline__ unsigned int
68998 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
68999 +{
69000 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
69001 +}
69002 +
69003 +static __inline__ unsigned int
69004 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
69005 +{
69006 + return full_name_hash((const unsigned char *)name, len) % sz;
69007 +}
69008 +
69009 +#define FOR_EACH_ROLE_START(role) \
69010 + role = role_list; \
69011 + while (role) {
69012 +
69013 +#define FOR_EACH_ROLE_END(role) \
69014 + role = role->prev; \
69015 + }
69016 +
69017 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
69018 + subj = NULL; \
69019 + iter = 0; \
69020 + while (iter < role->subj_hash_size) { \
69021 + if (subj == NULL) \
69022 + subj = role->subj_hash[iter]; \
69023 + if (subj == NULL) { \
69024 + iter++; \
69025 + continue; \
69026 + }
69027 +
69028 +#define FOR_EACH_SUBJECT_END(subj,iter) \
69029 + subj = subj->next; \
69030 + if (subj == NULL) \
69031 + iter++; \
69032 + }
69033 +
69034 +
69035 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
69036 + subj = role->hash->first; \
69037 + while (subj != NULL) {
69038 +
69039 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
69040 + subj = subj->next; \
69041 + }
69042 +
69043 +#endif
69044 +
69045 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
69046 new file mode 100644
69047 index 0000000..323ecf2
69048 --- /dev/null
69049 +++ b/include/linux/gralloc.h
69050 @@ -0,0 +1,9 @@
69051 +#ifndef __GRALLOC_H
69052 +#define __GRALLOC_H
69053 +
69054 +void acl_free_all(void);
69055 +int acl_alloc_stack_init(unsigned long size);
69056 +void *acl_alloc(unsigned long len);
69057 +void *acl_alloc_num(unsigned long num, unsigned long len);
69058 +
69059 +#endif
69060 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
69061 new file mode 100644
69062 index 0000000..be66033
69063 --- /dev/null
69064 +++ b/include/linux/grdefs.h
69065 @@ -0,0 +1,140 @@
69066 +#ifndef GRDEFS_H
69067 +#define GRDEFS_H
69068 +
69069 +/* Begin grsecurity status declarations */
69070 +
69071 +enum {
69072 + GR_READY = 0x01,
69073 + GR_STATUS_INIT = 0x00 // disabled state
69074 +};
69075 +
69076 +/* Begin ACL declarations */
69077 +
69078 +/* Role flags */
69079 +
69080 +enum {
69081 + GR_ROLE_USER = 0x0001,
69082 + GR_ROLE_GROUP = 0x0002,
69083 + GR_ROLE_DEFAULT = 0x0004,
69084 + GR_ROLE_SPECIAL = 0x0008,
69085 + GR_ROLE_AUTH = 0x0010,
69086 + GR_ROLE_NOPW = 0x0020,
69087 + GR_ROLE_GOD = 0x0040,
69088 + GR_ROLE_LEARN = 0x0080,
69089 + GR_ROLE_TPE = 0x0100,
69090 + GR_ROLE_DOMAIN = 0x0200,
69091 + GR_ROLE_PAM = 0x0400,
69092 + GR_ROLE_PERSIST = 0x0800
69093 +};
69094 +
69095 +/* ACL Subject and Object mode flags */
69096 +enum {
69097 + GR_DELETED = 0x80000000
69098 +};
69099 +
69100 +/* ACL Object-only mode flags */
69101 +enum {
69102 + GR_READ = 0x00000001,
69103 + GR_APPEND = 0x00000002,
69104 + GR_WRITE = 0x00000004,
69105 + GR_EXEC = 0x00000008,
69106 + GR_FIND = 0x00000010,
69107 + GR_INHERIT = 0x00000020,
69108 + GR_SETID = 0x00000040,
69109 + GR_CREATE = 0x00000080,
69110 + GR_DELETE = 0x00000100,
69111 + GR_LINK = 0x00000200,
69112 + GR_AUDIT_READ = 0x00000400,
69113 + GR_AUDIT_APPEND = 0x00000800,
69114 + GR_AUDIT_WRITE = 0x00001000,
69115 + GR_AUDIT_EXEC = 0x00002000,
69116 + GR_AUDIT_FIND = 0x00004000,
69117 + GR_AUDIT_INHERIT= 0x00008000,
69118 + GR_AUDIT_SETID = 0x00010000,
69119 + GR_AUDIT_CREATE = 0x00020000,
69120 + GR_AUDIT_DELETE = 0x00040000,
69121 + GR_AUDIT_LINK = 0x00080000,
69122 + GR_PTRACERD = 0x00100000,
69123 + GR_NOPTRACE = 0x00200000,
69124 + GR_SUPPRESS = 0x00400000,
69125 + GR_NOLEARN = 0x00800000,
69126 + GR_INIT_TRANSFER= 0x01000000
69127 +};
69128 +
69129 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
69130 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
69131 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
69132 +
69133 +/* ACL subject-only mode flags */
69134 +enum {
69135 + GR_KILL = 0x00000001,
69136 + GR_VIEW = 0x00000002,
69137 + GR_PROTECTED = 0x00000004,
69138 + GR_LEARN = 0x00000008,
69139 + GR_OVERRIDE = 0x00000010,
69140 + /* just a placeholder, this mode is only used in userspace */
69141 + GR_DUMMY = 0x00000020,
69142 + GR_PROTSHM = 0x00000040,
69143 + GR_KILLPROC = 0x00000080,
69144 + GR_KILLIPPROC = 0x00000100,
69145 + /* just a placeholder, this mode is only used in userspace */
69146 + GR_NOTROJAN = 0x00000200,
69147 + GR_PROTPROCFD = 0x00000400,
69148 + GR_PROCACCT = 0x00000800,
69149 + GR_RELAXPTRACE = 0x00001000,
69150 + //GR_NESTED = 0x00002000,
69151 + GR_INHERITLEARN = 0x00004000,
69152 + GR_PROCFIND = 0x00008000,
69153 + GR_POVERRIDE = 0x00010000,
69154 + GR_KERNELAUTH = 0x00020000,
69155 + GR_ATSECURE = 0x00040000,
69156 + GR_SHMEXEC = 0x00080000
69157 +};
69158 +
69159 +enum {
69160 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
69161 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
69162 + GR_PAX_ENABLE_MPROTECT = 0x0004,
69163 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
69164 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
69165 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
69166 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
69167 + GR_PAX_DISABLE_MPROTECT = 0x0400,
69168 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
69169 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
69170 +};
69171 +
69172 +enum {
69173 + GR_ID_USER = 0x01,
69174 + GR_ID_GROUP = 0x02,
69175 +};
69176 +
69177 +enum {
69178 + GR_ID_ALLOW = 0x01,
69179 + GR_ID_DENY = 0x02,
69180 +};
69181 +
69182 +#define GR_CRASH_RES 31
69183 +#define GR_UIDTABLE_MAX 500
69184 +
69185 +/* begin resource learning section */
69186 +enum {
69187 + GR_RLIM_CPU_BUMP = 60,
69188 + GR_RLIM_FSIZE_BUMP = 50000,
69189 + GR_RLIM_DATA_BUMP = 10000,
69190 + GR_RLIM_STACK_BUMP = 1000,
69191 + GR_RLIM_CORE_BUMP = 10000,
69192 + GR_RLIM_RSS_BUMP = 500000,
69193 + GR_RLIM_NPROC_BUMP = 1,
69194 + GR_RLIM_NOFILE_BUMP = 5,
69195 + GR_RLIM_MEMLOCK_BUMP = 50000,
69196 + GR_RLIM_AS_BUMP = 500000,
69197 + GR_RLIM_LOCKS_BUMP = 2,
69198 + GR_RLIM_SIGPENDING_BUMP = 5,
69199 + GR_RLIM_MSGQUEUE_BUMP = 10000,
69200 + GR_RLIM_NICE_BUMP = 1,
69201 + GR_RLIM_RTPRIO_BUMP = 1,
69202 + GR_RLIM_RTTIME_BUMP = 1000000
69203 +};
69204 +
69205 +#endif
69206 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
69207 new file mode 100644
69208 index 0000000..12994b5
69209 --- /dev/null
69210 +++ b/include/linux/grinternal.h
69211 @@ -0,0 +1,227 @@
69212 +#ifndef __GRINTERNAL_H
69213 +#define __GRINTERNAL_H
69214 +
69215 +#ifdef CONFIG_GRKERNSEC
69216 +
69217 +#include <linux/fs.h>
69218 +#include <linux/mnt_namespace.h>
69219 +#include <linux/nsproxy.h>
69220 +#include <linux/gracl.h>
69221 +#include <linux/grdefs.h>
69222 +#include <linux/grmsg.h>
69223 +
69224 +void gr_add_learn_entry(const char *fmt, ...)
69225 + __attribute__ ((format (printf, 1, 2)));
69226 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
69227 + const struct vfsmount *mnt);
69228 +__u32 gr_check_create(const struct dentry *new_dentry,
69229 + const struct dentry *parent,
69230 + const struct vfsmount *mnt, const __u32 mode);
69231 +int gr_check_protected_task(const struct task_struct *task);
69232 +__u32 to_gr_audit(const __u32 reqmode);
69233 +int gr_set_acls(const int type);
69234 +int gr_apply_subject_to_task(struct task_struct *task);
69235 +int gr_acl_is_enabled(void);
69236 +char gr_roletype_to_char(void);
69237 +
69238 +void gr_handle_alertkill(struct task_struct *task);
69239 +char *gr_to_filename(const struct dentry *dentry,
69240 + const struct vfsmount *mnt);
69241 +char *gr_to_filename1(const struct dentry *dentry,
69242 + const struct vfsmount *mnt);
69243 +char *gr_to_filename2(const struct dentry *dentry,
69244 + const struct vfsmount *mnt);
69245 +char *gr_to_filename3(const struct dentry *dentry,
69246 + const struct vfsmount *mnt);
69247 +
69248 +extern int grsec_enable_ptrace_readexec;
69249 +extern int grsec_enable_harden_ptrace;
69250 +extern int grsec_enable_link;
69251 +extern int grsec_enable_fifo;
69252 +extern int grsec_enable_execve;
69253 +extern int grsec_enable_shm;
69254 +extern int grsec_enable_execlog;
69255 +extern int grsec_enable_signal;
69256 +extern int grsec_enable_audit_ptrace;
69257 +extern int grsec_enable_forkfail;
69258 +extern int grsec_enable_time;
69259 +extern int grsec_enable_rofs;
69260 +extern int grsec_enable_chroot_shmat;
69261 +extern int grsec_enable_chroot_mount;
69262 +extern int grsec_enable_chroot_double;
69263 +extern int grsec_enable_chroot_pivot;
69264 +extern int grsec_enable_chroot_chdir;
69265 +extern int grsec_enable_chroot_chmod;
69266 +extern int grsec_enable_chroot_mknod;
69267 +extern int grsec_enable_chroot_fchdir;
69268 +extern int grsec_enable_chroot_nice;
69269 +extern int grsec_enable_chroot_execlog;
69270 +extern int grsec_enable_chroot_caps;
69271 +extern int grsec_enable_chroot_sysctl;
69272 +extern int grsec_enable_chroot_unix;
69273 +extern int grsec_enable_symlinkown;
69274 +extern kgid_t grsec_symlinkown_gid;
69275 +extern int grsec_enable_tpe;
69276 +extern kgid_t grsec_tpe_gid;
69277 +extern int grsec_enable_tpe_all;
69278 +extern int grsec_enable_tpe_invert;
69279 +extern int grsec_enable_socket_all;
69280 +extern kgid_t grsec_socket_all_gid;
69281 +extern int grsec_enable_socket_client;
69282 +extern kgid_t grsec_socket_client_gid;
69283 +extern int grsec_enable_socket_server;
69284 +extern kgid_t grsec_socket_server_gid;
69285 +extern kgid_t grsec_audit_gid;
69286 +extern int grsec_enable_group;
69287 +extern int grsec_enable_audit_textrel;
69288 +extern int grsec_enable_log_rwxmaps;
69289 +extern int grsec_enable_mount;
69290 +extern int grsec_enable_chdir;
69291 +extern int grsec_resource_logging;
69292 +extern int grsec_enable_blackhole;
69293 +extern int grsec_lastack_retries;
69294 +extern int grsec_enable_brute;
69295 +extern int grsec_lock;
69296 +
69297 +extern spinlock_t grsec_alert_lock;
69298 +extern unsigned long grsec_alert_wtime;
69299 +extern unsigned long grsec_alert_fyet;
69300 +
69301 +extern spinlock_t grsec_audit_lock;
69302 +
69303 +extern rwlock_t grsec_exec_file_lock;
69304 +
69305 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
69306 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
69307 + (tsk)->exec_file->f_path.mnt) : "/")
69308 +
69309 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
69310 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
69311 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
69312 +
69313 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
69314 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
69315 + (tsk)->exec_file->f_path.mnt) : "/")
69316 +
69317 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
69318 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
69319 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
69320 +
69321 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
69322 +
69323 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
69324 +
69325 +static inline bool gr_is_same_file(const struct file *file1, const struct file *file2)
69326 +{
69327 + if (file1 && file2) {
69328 + const struct inode *inode1 = file1->f_path.dentry->d_inode;
69329 + const struct inode *inode2 = file2->f_path.dentry->d_inode;
69330 + if (inode1->i_ino == inode2->i_ino && inode1->i_sb->s_dev == inode2->i_sb->s_dev)
69331 + return true;
69332 + }
69333 +
69334 + return false;
69335 +}
69336 +
69337 +#define GR_CHROOT_CAPS {{ \
69338 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
69339 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
69340 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
69341 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
69342 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
69343 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
69344 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
69345 +
69346 +#define security_learn(normal_msg,args...) \
69347 +({ \
69348 + read_lock(&grsec_exec_file_lock); \
69349 + gr_add_learn_entry(normal_msg "\n", ## args); \
69350 + read_unlock(&grsec_exec_file_lock); \
69351 +})
69352 +
69353 +enum {
69354 + GR_DO_AUDIT,
69355 + GR_DONT_AUDIT,
69356 + /* used for non-audit messages that we shouldn't kill the task on */
69357 + GR_DONT_AUDIT_GOOD
69358 +};
69359 +
69360 +enum {
69361 + GR_TTYSNIFF,
69362 + GR_RBAC,
69363 + GR_RBAC_STR,
69364 + GR_STR_RBAC,
69365 + GR_RBAC_MODE2,
69366 + GR_RBAC_MODE3,
69367 + GR_FILENAME,
69368 + GR_SYSCTL_HIDDEN,
69369 + GR_NOARGS,
69370 + GR_ONE_INT,
69371 + GR_ONE_INT_TWO_STR,
69372 + GR_ONE_STR,
69373 + GR_STR_INT,
69374 + GR_TWO_STR_INT,
69375 + GR_TWO_INT,
69376 + GR_TWO_U64,
69377 + GR_THREE_INT,
69378 + GR_FIVE_INT_TWO_STR,
69379 + GR_TWO_STR,
69380 + GR_THREE_STR,
69381 + GR_FOUR_STR,
69382 + GR_STR_FILENAME,
69383 + GR_FILENAME_STR,
69384 + GR_FILENAME_TWO_INT,
69385 + GR_FILENAME_TWO_INT_STR,
69386 + GR_TEXTREL,
69387 + GR_PTRACE,
69388 + GR_RESOURCE,
69389 + GR_CAP,
69390 + GR_SIG,
69391 + GR_SIG2,
69392 + GR_CRASH1,
69393 + GR_CRASH2,
69394 + GR_PSACCT,
69395 + GR_RWXMAP
69396 +};
69397 +
69398 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
69399 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
69400 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
69401 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
69402 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
69403 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
69404 +#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)
69405 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
69406 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
69407 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
69408 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
69409 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
69410 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
69411 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
69412 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
69413 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
69414 +#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)
69415 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
69416 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
69417 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
69418 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
69419 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
69420 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
69421 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
69422 +#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)
69423 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
69424 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
69425 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
69426 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
69427 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
69428 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
69429 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
69430 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
69431 +#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)
69432 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
69433 +
69434 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
69435 +
69436 +#endif
69437 +
69438 +#endif
69439 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
69440 new file mode 100644
69441 index 0000000..2f159b5
69442 --- /dev/null
69443 +++ b/include/linux/grmsg.h
69444 @@ -0,0 +1,112 @@
69445 +#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"
69446 +#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"
69447 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
69448 +#define GR_STOPMOD_MSG "denied modification of module state by "
69449 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
69450 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
69451 +#define GR_IOPERM_MSG "denied use of ioperm() by "
69452 +#define GR_IOPL_MSG "denied use of iopl() by "
69453 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
69454 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
69455 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
69456 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
69457 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
69458 +#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"
69459 +#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"
69460 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
69461 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
69462 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
69463 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
69464 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
69465 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
69466 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
69467 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
69468 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
69469 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
69470 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
69471 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
69472 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
69473 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
69474 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
69475 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
69476 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
69477 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
69478 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
69479 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
69480 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
69481 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
69482 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
69483 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
69484 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
69485 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
69486 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
69487 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
69488 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
69489 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
69490 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
69491 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
69492 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
69493 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
69494 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
69495 +#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"
69496 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
69497 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
69498 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
69499 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
69500 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
69501 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
69502 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
69503 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
69504 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
69505 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
69506 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
69507 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
69508 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
69509 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
69510 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
69511 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
69512 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
69513 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
69514 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
69515 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
69516 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
69517 +#define GR_NICE_CHROOT_MSG "denied priority change by "
69518 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
69519 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
69520 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
69521 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
69522 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
69523 +#define GR_TIME_MSG "time set by "
69524 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
69525 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
69526 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
69527 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
69528 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
69529 +#define GR_BIND_MSG "denied bind() by "
69530 +#define GR_CONNECT_MSG "denied connect() by "
69531 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
69532 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
69533 +#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"
69534 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
69535 +#define GR_CAP_ACL_MSG "use of %s denied for "
69536 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
69537 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
69538 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
69539 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
69540 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
69541 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
69542 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
69543 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
69544 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
69545 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
69546 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
69547 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
69548 +#define GR_TEXTREL_AUDIT_MSG "text relocation in %s, VMA:0x%08lx 0x%08lx by "
69549 +#define GR_VM86_MSG "denied use of vm86 by "
69550 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
69551 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
69552 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
69553 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
69554 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
69555 +#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 "
69556 +#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 "
69557 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
69558 new file mode 100644
69559 index 0000000..d957f6d
69560 --- /dev/null
69561 +++ b/include/linux/grsecurity.h
69562 @@ -0,0 +1,241 @@
69563 +#ifndef GR_SECURITY_H
69564 +#define GR_SECURITY_H
69565 +#include <linux/fs.h>
69566 +#include <linux/fs_struct.h>
69567 +#include <linux/binfmts.h>
69568 +#include <linux/gracl.h>
69569 +
69570 +/* notify of brain-dead configs */
69571 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
69572 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
69573 +#endif
69574 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
69575 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
69576 +#endif
69577 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
69578 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
69579 +#endif
69580 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
69581 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
69582 +#endif
69583 +
69584 +void gr_handle_brute_attach(unsigned long mm_flags);
69585 +void gr_handle_brute_check(void);
69586 +void gr_handle_kernel_exploit(void);
69587 +
69588 +char gr_roletype_to_char(void);
69589 +
69590 +int gr_acl_enable_at_secure(void);
69591 +
69592 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
69593 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
69594 +
69595 +void gr_del_task_from_ip_table(struct task_struct *p);
69596 +
69597 +int gr_pid_is_chrooted(struct task_struct *p);
69598 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
69599 +int gr_handle_chroot_nice(void);
69600 +int gr_handle_chroot_sysctl(const int op);
69601 +int gr_handle_chroot_setpriority(struct task_struct *p,
69602 + const int niceval);
69603 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
69604 +int gr_handle_chroot_chroot(const struct dentry *dentry,
69605 + const struct vfsmount *mnt);
69606 +void gr_handle_chroot_chdir(const struct path *path);
69607 +int gr_handle_chroot_chmod(const struct dentry *dentry,
69608 + const struct vfsmount *mnt, const int mode);
69609 +int gr_handle_chroot_mknod(const struct dentry *dentry,
69610 + const struct vfsmount *mnt, const int mode);
69611 +int gr_handle_chroot_mount(const struct dentry *dentry,
69612 + const struct vfsmount *mnt,
69613 + const char *dev_name);
69614 +int gr_handle_chroot_pivot(void);
69615 +int gr_handle_chroot_unix(const pid_t pid);
69616 +
69617 +int gr_handle_rawio(const struct inode *inode);
69618 +
69619 +void gr_handle_ioperm(void);
69620 +void gr_handle_iopl(void);
69621 +
69622 +umode_t gr_acl_umask(void);
69623 +
69624 +int gr_tpe_allow(const struct file *file);
69625 +
69626 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path);
69627 +void gr_clear_chroot_entries(struct task_struct *task);
69628 +
69629 +void gr_log_forkfail(const int retval);
69630 +void gr_log_timechange(void);
69631 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
69632 +void gr_log_chdir(const struct dentry *dentry,
69633 + const struct vfsmount *mnt);
69634 +void gr_log_chroot_exec(const struct dentry *dentry,
69635 + const struct vfsmount *mnt);
69636 +void gr_log_remount(const char *devname, const int retval);
69637 +void gr_log_unmount(const char *devname, const int retval);
69638 +void gr_log_mount(const char *from, const char *to, const int retval);
69639 +void gr_log_textrel(struct vm_area_struct *vma);
69640 +void gr_log_rwxmmap(struct file *file);
69641 +void gr_log_rwxmprotect(struct file *file);
69642 +
69643 +int gr_handle_follow_link(const struct inode *parent,
69644 + const struct inode *inode,
69645 + const struct dentry *dentry,
69646 + const struct vfsmount *mnt);
69647 +int gr_handle_fifo(const struct dentry *dentry,
69648 + const struct vfsmount *mnt,
69649 + const struct dentry *dir, const int flag,
69650 + const int acc_mode);
69651 +int gr_handle_hardlink(const struct dentry *dentry,
69652 + const struct vfsmount *mnt,
69653 + struct inode *inode,
69654 + const int mode, const struct filename *to);
69655 +
69656 +int gr_is_capable(const int cap);
69657 +int gr_is_capable_nolog(const int cap);
69658 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
69659 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
69660 +
69661 +void gr_copy_label(struct task_struct *tsk);
69662 +void gr_handle_crash(struct task_struct *task, const int sig);
69663 +int gr_handle_signal(const struct task_struct *p, const int sig);
69664 +int gr_check_crash_uid(const kuid_t uid);
69665 +int gr_check_protected_task(const struct task_struct *task);
69666 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
69667 +int gr_acl_handle_mmap(const struct file *file,
69668 + const unsigned long prot);
69669 +int gr_acl_handle_mprotect(const struct file *file,
69670 + const unsigned long prot);
69671 +int gr_check_hidden_task(const struct task_struct *tsk);
69672 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
69673 + const struct vfsmount *mnt);
69674 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
69675 + const struct vfsmount *mnt);
69676 +__u32 gr_acl_handle_access(const struct dentry *dentry,
69677 + const struct vfsmount *mnt, const int fmode);
69678 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
69679 + const struct vfsmount *mnt, umode_t *mode);
69680 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
69681 + const struct vfsmount *mnt);
69682 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
69683 + const struct vfsmount *mnt);
69684 +int gr_handle_ptrace(struct task_struct *task, const long request);
69685 +int gr_handle_proc_ptrace(struct task_struct *task);
69686 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
69687 + const struct vfsmount *mnt);
69688 +int gr_check_crash_exec(const struct file *filp);
69689 +int gr_acl_is_enabled(void);
69690 +void gr_set_kernel_label(struct task_struct *task);
69691 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
69692 + const kgid_t gid);
69693 +int gr_set_proc_label(const struct dentry *dentry,
69694 + const struct vfsmount *mnt,
69695 + const int unsafe_flags);
69696 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
69697 + const struct vfsmount *mnt);
69698 +__u32 gr_acl_handle_open(const struct dentry *dentry,
69699 + const struct vfsmount *mnt, int acc_mode);
69700 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
69701 + const struct dentry *p_dentry,
69702 + const struct vfsmount *p_mnt,
69703 + int open_flags, int acc_mode, const int imode);
69704 +void gr_handle_create(const struct dentry *dentry,
69705 + const struct vfsmount *mnt);
69706 +void gr_handle_proc_create(const struct dentry *dentry,
69707 + const struct inode *inode);
69708 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
69709 + const struct dentry *parent_dentry,
69710 + const struct vfsmount *parent_mnt,
69711 + const int mode);
69712 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
69713 + const struct dentry *parent_dentry,
69714 + const struct vfsmount *parent_mnt);
69715 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
69716 + const struct vfsmount *mnt);
69717 +void gr_handle_delete(const ino_t ino, const dev_t dev);
69718 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
69719 + const struct vfsmount *mnt);
69720 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
69721 + const struct dentry *parent_dentry,
69722 + const struct vfsmount *parent_mnt,
69723 + const struct filename *from);
69724 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
69725 + const struct dentry *parent_dentry,
69726 + const struct vfsmount *parent_mnt,
69727 + const struct dentry *old_dentry,
69728 + const struct vfsmount *old_mnt, const struct filename *to);
69729 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
69730 +int gr_acl_handle_rename(struct dentry *new_dentry,
69731 + struct dentry *parent_dentry,
69732 + const struct vfsmount *parent_mnt,
69733 + struct dentry *old_dentry,
69734 + struct inode *old_parent_inode,
69735 + struct vfsmount *old_mnt, const struct filename *newname);
69736 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
69737 + struct dentry *old_dentry,
69738 + struct dentry *new_dentry,
69739 + struct vfsmount *mnt, const __u8 replace);
69740 +__u32 gr_check_link(const struct dentry *new_dentry,
69741 + const struct dentry *parent_dentry,
69742 + const struct vfsmount *parent_mnt,
69743 + const struct dentry *old_dentry,
69744 + const struct vfsmount *old_mnt);
69745 +int gr_acl_handle_filldir(const struct file *file, const char *name,
69746 + const unsigned int namelen, const ino_t ino);
69747 +
69748 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
69749 + const struct vfsmount *mnt);
69750 +void gr_acl_handle_exit(void);
69751 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
69752 +int gr_acl_handle_procpidmem(const struct task_struct *task);
69753 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
69754 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
69755 +void gr_audit_ptrace(struct task_struct *task);
69756 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
69757 +void gr_put_exec_file(struct task_struct *task);
69758 +
69759 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
69760 +
69761 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
69762 +extern void gr_learn_resource(const struct task_struct *task, const int res,
69763 + const unsigned long wanted, const int gt);
69764 +#else
69765 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
69766 + const unsigned long wanted, const int gt)
69767 +{
69768 +}
69769 +#endif
69770 +
69771 +#ifdef CONFIG_GRKERNSEC_RESLOG
69772 +extern void gr_log_resource(const struct task_struct *task, const int res,
69773 + const unsigned long wanted, const int gt);
69774 +#else
69775 +static inline void gr_log_resource(const struct task_struct *task, const int res,
69776 + const unsigned long wanted, const int gt)
69777 +{
69778 +}
69779 +#endif
69780 +
69781 +#ifdef CONFIG_GRKERNSEC
69782 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
69783 +void gr_handle_vm86(void);
69784 +void gr_handle_mem_readwrite(u64 from, u64 to);
69785 +
69786 +void gr_log_badprocpid(const char *entry);
69787 +
69788 +extern int grsec_enable_dmesg;
69789 +extern int grsec_disable_privio;
69790 +
69791 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
69792 +extern kgid_t grsec_proc_gid;
69793 +#endif
69794 +
69795 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69796 +extern int grsec_enable_chroot_findtask;
69797 +#endif
69798 +#ifdef CONFIG_GRKERNSEC_SETXID
69799 +extern int grsec_enable_setxid;
69800 +#endif
69801 +#endif
69802 +
69803 +#endif
69804 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
69805 new file mode 100644
69806 index 0000000..e7ffaaf
69807 --- /dev/null
69808 +++ b/include/linux/grsock.h
69809 @@ -0,0 +1,19 @@
69810 +#ifndef __GRSOCK_H
69811 +#define __GRSOCK_H
69812 +
69813 +extern void gr_attach_curr_ip(const struct sock *sk);
69814 +extern int gr_handle_sock_all(const int family, const int type,
69815 + const int protocol);
69816 +extern int gr_handle_sock_server(const struct sockaddr *sck);
69817 +extern int gr_handle_sock_server_other(const struct sock *sck);
69818 +extern int gr_handle_sock_client(const struct sockaddr *sck);
69819 +extern int gr_search_connect(struct socket * sock,
69820 + struct sockaddr_in * addr);
69821 +extern int gr_search_bind(struct socket * sock,
69822 + struct sockaddr_in * addr);
69823 +extern int gr_search_listen(struct socket * sock);
69824 +extern int gr_search_accept(struct socket * sock);
69825 +extern int gr_search_socket(const int domain, const int type,
69826 + const int protocol);
69827 +
69828 +#endif
69829 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
69830 index 7fb31da..08b5114 100644
69831 --- a/include/linux/highmem.h
69832 +++ b/include/linux/highmem.h
69833 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
69834 kunmap_atomic(kaddr);
69835 }
69836
69837 +static inline void sanitize_highpage(struct page *page)
69838 +{
69839 + void *kaddr;
69840 + unsigned long flags;
69841 +
69842 + local_irq_save(flags);
69843 + kaddr = kmap_atomic(page);
69844 + clear_page(kaddr);
69845 + kunmap_atomic(kaddr);
69846 + local_irq_restore(flags);
69847 +}
69848 +
69849 static inline void zero_user_segments(struct page *page,
69850 unsigned start1, unsigned end1,
69851 unsigned start2, unsigned end2)
69852 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
69853 index 1c7b89a..7f52502 100644
69854 --- a/include/linux/hwmon-sysfs.h
69855 +++ b/include/linux/hwmon-sysfs.h
69856 @@ -25,7 +25,8 @@
69857 struct sensor_device_attribute{
69858 struct device_attribute dev_attr;
69859 int index;
69860 -};
69861 +} __do_const;
69862 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
69863 #define to_sensor_dev_attr(_dev_attr) \
69864 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
69865
69866 @@ -41,7 +42,7 @@ struct sensor_device_attribute_2 {
69867 struct device_attribute dev_attr;
69868 u8 index;
69869 u8 nr;
69870 -};
69871 +} __do_const;
69872 #define to_sensor_dev_attr_2(_dev_attr) \
69873 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
69874
69875 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
69876 index e988fa9..ff9f17e 100644
69877 --- a/include/linux/i2c.h
69878 +++ b/include/linux/i2c.h
69879 @@ -366,6 +366,7 @@ struct i2c_algorithm {
69880 /* To determine what the adapter supports */
69881 u32 (*functionality) (struct i2c_adapter *);
69882 };
69883 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
69884
69885 /**
69886 * struct i2c_bus_recovery_info - I2C bus recovery information
69887 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
69888 index d23c3c2..eb63c81 100644
69889 --- a/include/linux/i2o.h
69890 +++ b/include/linux/i2o.h
69891 @@ -565,7 +565,7 @@ struct i2o_controller {
69892 struct i2o_device *exec; /* Executive */
69893 #if BITS_PER_LONG == 64
69894 spinlock_t context_list_lock; /* lock for context_list */
69895 - atomic_t context_list_counter; /* needed for unique contexts */
69896 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
69897 struct list_head context_list; /* list of context id's
69898 and pointers */
69899 #endif
69900 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
69901 index aff7ad8..3942bbd 100644
69902 --- a/include/linux/if_pppox.h
69903 +++ b/include/linux/if_pppox.h
69904 @@ -76,7 +76,7 @@ struct pppox_proto {
69905 int (*ioctl)(struct socket *sock, unsigned int cmd,
69906 unsigned long arg);
69907 struct module *owner;
69908 -};
69909 +} __do_const;
69910
69911 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
69912 extern void unregister_pppox_proto(int proto_num);
69913 diff --git a/include/linux/init.h b/include/linux/init.h
69914 index 8618147..0821126 100644
69915 --- a/include/linux/init.h
69916 +++ b/include/linux/init.h
69917 @@ -39,9 +39,36 @@
69918 * Also note, that this data cannot be "const".
69919 */
69920
69921 +#ifdef MODULE
69922 +#define add_init_latent_entropy
69923 +#define add_devinit_latent_entropy
69924 +#define add_cpuinit_latent_entropy
69925 +#define add_meminit_latent_entropy
69926 +#else
69927 +#define add_init_latent_entropy __latent_entropy
69928 +
69929 +#ifdef CONFIG_HOTPLUG
69930 +#define add_devinit_latent_entropy
69931 +#else
69932 +#define add_devinit_latent_entropy __latent_entropy
69933 +#endif
69934 +
69935 +#ifdef CONFIG_HOTPLUG_CPU
69936 +#define add_cpuinit_latent_entropy
69937 +#else
69938 +#define add_cpuinit_latent_entropy __latent_entropy
69939 +#endif
69940 +
69941 +#ifdef CONFIG_MEMORY_HOTPLUG
69942 +#define add_meminit_latent_entropy
69943 +#else
69944 +#define add_meminit_latent_entropy __latent_entropy
69945 +#endif
69946 +#endif
69947 +
69948 /* These are for everybody (although not all archs will actually
69949 discard it in modules) */
69950 -#define __init __section(.init.text) __cold notrace
69951 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
69952 #define __initdata __section(.init.data)
69953 #define __initconst __constsection(.init.rodata)
69954 #define __exitdata __section(.exit.data)
69955 @@ -94,7 +121,7 @@
69956 #define __exit __section(.exit.text) __exitused __cold notrace
69957
69958 /* Used for HOTPLUG_CPU */
69959 -#define __cpuinit __section(.cpuinit.text) __cold notrace
69960 +#define __cpuinit __section(.cpuinit.text) __cold notrace add_cpuinit_latent_entropy
69961 #define __cpuinitdata __section(.cpuinit.data)
69962 #define __cpuinitconst __constsection(.cpuinit.rodata)
69963 #define __cpuexit __section(.cpuexit.text) __exitused __cold notrace
69964 @@ -102,7 +129,7 @@
69965 #define __cpuexitconst __constsection(.cpuexit.rodata)
69966
69967 /* Used for MEMORY_HOTPLUG */
69968 -#define __meminit __section(.meminit.text) __cold notrace
69969 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
69970 #define __meminitdata __section(.meminit.data)
69971 #define __meminitconst __constsection(.meminit.rodata)
69972 #define __memexit __section(.memexit.text) __exitused __cold notrace
69973 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
69974 index 5cd0f09..c9f67cc 100644
69975 --- a/include/linux/init_task.h
69976 +++ b/include/linux/init_task.h
69977 @@ -154,6 +154,12 @@ extern struct task_group root_task_group;
69978
69979 #define INIT_TASK_COMM "swapper"
69980
69981 +#ifdef CONFIG_X86
69982 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
69983 +#else
69984 +#define INIT_TASK_THREAD_INFO
69985 +#endif
69986 +
69987 /*
69988 * INIT_TASK is used to set up the first task table, touch at
69989 * your own risk!. Base=0, limit=0x1fffff (=2MB)
69990 @@ -193,6 +199,7 @@ extern struct task_group root_task_group;
69991 RCU_POINTER_INITIALIZER(cred, &init_cred), \
69992 .comm = INIT_TASK_COMM, \
69993 .thread = INIT_THREAD, \
69994 + INIT_TASK_THREAD_INFO \
69995 .fs = &init_fs, \
69996 .files = &init_files, \
69997 .signal = &init_signals, \
69998 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
69999 index 5fa5afe..ac55b25 100644
70000 --- a/include/linux/interrupt.h
70001 +++ b/include/linux/interrupt.h
70002 @@ -430,7 +430,7 @@ enum
70003 /* map softirq index to softirq name. update 'softirq_to_name' in
70004 * kernel/softirq.c when adding a new softirq.
70005 */
70006 -extern char *softirq_to_name[NR_SOFTIRQS];
70007 +extern const char * const softirq_to_name[NR_SOFTIRQS];
70008
70009 /* softirq mask and active fields moved to irq_cpustat_t in
70010 * asm/hardirq.h to get better cache usage. KAO
70011 @@ -438,12 +438,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
70012
70013 struct softirq_action
70014 {
70015 - void (*action)(struct softirq_action *);
70016 -};
70017 + void (*action)(void);
70018 +} __no_const;
70019
70020 asmlinkage void do_softirq(void);
70021 asmlinkage void __do_softirq(void);
70022 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
70023 +extern void open_softirq(int nr, void (*action)(void));
70024 extern void softirq_init(void);
70025 extern void __raise_softirq_irqoff(unsigned int nr);
70026
70027 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
70028 index 3aeb730..2177f39 100644
70029 --- a/include/linux/iommu.h
70030 +++ b/include/linux/iommu.h
70031 @@ -113,7 +113,7 @@ struct iommu_ops {
70032 u32 (*domain_get_windows)(struct iommu_domain *domain);
70033
70034 unsigned long pgsize_bitmap;
70035 -};
70036 +} __do_const;
70037
70038 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
70039 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
70040 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
70041 index 89b7c24..382af74 100644
70042 --- a/include/linux/ioport.h
70043 +++ b/include/linux/ioport.h
70044 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
70045 int adjust_resource(struct resource *res, resource_size_t start,
70046 resource_size_t size);
70047 resource_size_t resource_alignment(struct resource *res);
70048 -static inline resource_size_t resource_size(const struct resource *res)
70049 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
70050 {
70051 return res->end - res->start + 1;
70052 }
70053 diff --git a/include/linux/irq.h b/include/linux/irq.h
70054 index bc4e066..50468a9 100644
70055 --- a/include/linux/irq.h
70056 +++ b/include/linux/irq.h
70057 @@ -328,7 +328,8 @@ struct irq_chip {
70058 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
70059
70060 unsigned long flags;
70061 -};
70062 +} __do_const;
70063 +typedef struct irq_chip __no_const irq_chip_no_const;
70064
70065 /*
70066 * irq_chip specific flags
70067 diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
70068 index 3e203eb..3fe68d0 100644
70069 --- a/include/linux/irqchip/arm-gic.h
70070 +++ b/include/linux/irqchip/arm-gic.h
70071 @@ -59,9 +59,11 @@
70072
70073 #ifndef __ASSEMBLY__
70074
70075 +#include <linux/irq.h>
70076 +
70077 struct device_node;
70078
70079 -extern struct irq_chip gic_arch_extn;
70080 +extern irq_chip_no_const gic_arch_extn;
70081
70082 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
70083 u32 offset, struct device_node *);
70084 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
70085 index 6883e19..06992b1 100644
70086 --- a/include/linux/kallsyms.h
70087 +++ b/include/linux/kallsyms.h
70088 @@ -15,7 +15,8 @@
70089
70090 struct module;
70091
70092 -#ifdef CONFIG_KALLSYMS
70093 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
70094 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
70095 /* Lookup the address for a symbol. Returns 0 if not found. */
70096 unsigned long kallsyms_lookup_name(const char *name);
70097
70098 @@ -106,6 +107,17 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
70099 /* Stupid that this does nothing, but I didn't create this mess. */
70100 #define __print_symbol(fmt, addr)
70101 #endif /*CONFIG_KALLSYMS*/
70102 +#else /* when included by kallsyms.c, vsnprintf.c, or
70103 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
70104 +extern void __print_symbol(const char *fmt, unsigned long address);
70105 +extern int sprint_backtrace(char *buffer, unsigned long address);
70106 +extern int sprint_symbol(char *buffer, unsigned long address);
70107 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
70108 +const char *kallsyms_lookup(unsigned long addr,
70109 + unsigned long *symbolsize,
70110 + unsigned long *offset,
70111 + char **modname, char *namebuf);
70112 +#endif
70113
70114 /* This macro allows us to keep printk typechecking */
70115 static __printf(1, 2)
70116 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
70117 index 518a53a..5e28358 100644
70118 --- a/include/linux/key-type.h
70119 +++ b/include/linux/key-type.h
70120 @@ -125,7 +125,7 @@ struct key_type {
70121 /* internal fields */
70122 struct list_head link; /* link in types list */
70123 struct lock_class_key lock_class; /* key->sem lock class */
70124 -};
70125 +} __do_const;
70126
70127 extern struct key_type key_type_keyring;
70128
70129 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
70130 index c6e091b..a940adf 100644
70131 --- a/include/linux/kgdb.h
70132 +++ b/include/linux/kgdb.h
70133 @@ -52,7 +52,7 @@ extern int kgdb_connected;
70134 extern int kgdb_io_module_registered;
70135
70136 extern atomic_t kgdb_setting_breakpoint;
70137 -extern atomic_t kgdb_cpu_doing_single_step;
70138 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
70139
70140 extern struct task_struct *kgdb_usethread;
70141 extern struct task_struct *kgdb_contthread;
70142 @@ -254,7 +254,7 @@ struct kgdb_arch {
70143 void (*correct_hw_break)(void);
70144
70145 void (*enable_nmi)(bool on);
70146 -};
70147 +} __do_const;
70148
70149 /**
70150 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
70151 @@ -279,7 +279,7 @@ struct kgdb_io {
70152 void (*pre_exception) (void);
70153 void (*post_exception) (void);
70154 int is_console;
70155 -};
70156 +} __do_const;
70157
70158 extern struct kgdb_arch arch_kgdb_ops;
70159
70160 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
70161 index 0555cc6..b16a7a4 100644
70162 --- a/include/linux/kmod.h
70163 +++ b/include/linux/kmod.h
70164 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
70165 * usually useless though. */
70166 extern __printf(2, 3)
70167 int __request_module(bool wait, const char *name, ...);
70168 +extern __printf(3, 4)
70169 +int ___request_module(bool wait, char *param_name, const char *name, ...);
70170 #define request_module(mod...) __request_module(true, mod)
70171 #define request_module_nowait(mod...) __request_module(false, mod)
70172 #define try_then_request_module(x, mod...) \
70173 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
70174 index 939b112..ed6ed51 100644
70175 --- a/include/linux/kobject.h
70176 +++ b/include/linux/kobject.h
70177 @@ -111,7 +111,7 @@ struct kobj_type {
70178 struct attribute **default_attrs;
70179 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
70180 const void *(*namespace)(struct kobject *kobj);
70181 -};
70182 +} __do_const;
70183
70184 struct kobj_uevent_env {
70185 char *envp[UEVENT_NUM_ENVP];
70186 @@ -134,6 +134,7 @@ struct kobj_attribute {
70187 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
70188 const char *buf, size_t count);
70189 };
70190 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
70191
70192 extern const struct sysfs_ops kobj_sysfs_ops;
70193
70194 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
70195 index f66b065..c2c29b4 100644
70196 --- a/include/linux/kobject_ns.h
70197 +++ b/include/linux/kobject_ns.h
70198 @@ -43,7 +43,7 @@ struct kobj_ns_type_operations {
70199 const void *(*netlink_ns)(struct sock *sk);
70200 const void *(*initial_ns)(void);
70201 void (*drop_ns)(void *);
70202 -};
70203 +} __do_const;
70204
70205 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
70206 int kobj_ns_type_registered(enum kobj_ns_type type);
70207 diff --git a/include/linux/kref.h b/include/linux/kref.h
70208 index 484604d..0f6c5b6 100644
70209 --- a/include/linux/kref.h
70210 +++ b/include/linux/kref.h
70211 @@ -68,7 +68,7 @@ static inline void kref_get(struct kref *kref)
70212 static inline int kref_sub(struct kref *kref, unsigned int count,
70213 void (*release)(struct kref *kref))
70214 {
70215 - WARN_ON(release == NULL);
70216 + BUG_ON(release == NULL);
70217
70218 if (atomic_sub_and_test((int) count, &kref->refcount)) {
70219 release(kref);
70220 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
70221 index 8db53cf..c21121d 100644
70222 --- a/include/linux/kvm_host.h
70223 +++ b/include/linux/kvm_host.h
70224 @@ -444,7 +444,7 @@ static inline void kvm_irqfd_exit(void)
70225 {
70226 }
70227 #endif
70228 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
70229 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
70230 struct module *module);
70231 void kvm_exit(void);
70232
70233 @@ -616,7 +616,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
70234 struct kvm_guest_debug *dbg);
70235 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
70236
70237 -int kvm_arch_init(void *opaque);
70238 +int kvm_arch_init(const void *opaque);
70239 void kvm_arch_exit(void);
70240
70241 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
70242 diff --git a/include/linux/libata.h b/include/linux/libata.h
70243 index eae7a05..2cdd875 100644
70244 --- a/include/linux/libata.h
70245 +++ b/include/linux/libata.h
70246 @@ -919,7 +919,7 @@ struct ata_port_operations {
70247 * fields must be pointers.
70248 */
70249 const struct ata_port_operations *inherits;
70250 -};
70251 +} __do_const;
70252
70253 struct ata_port_info {
70254 unsigned long flags;
70255 diff --git a/include/linux/list.h b/include/linux/list.h
70256 index b83e565..baa6c1d 100644
70257 --- a/include/linux/list.h
70258 +++ b/include/linux/list.h
70259 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
70260 extern void list_del(struct list_head *entry);
70261 #endif
70262
70263 +extern void __pax_list_add(struct list_head *new,
70264 + struct list_head *prev,
70265 + struct list_head *next);
70266 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
70267 +{
70268 + __pax_list_add(new, head, head->next);
70269 +}
70270 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
70271 +{
70272 + __pax_list_add(new, head->prev, head);
70273 +}
70274 +extern void pax_list_del(struct list_head *entry);
70275 +
70276 /**
70277 * list_replace - replace old entry by new one
70278 * @old : the element to be replaced
70279 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
70280 INIT_LIST_HEAD(entry);
70281 }
70282
70283 +extern void pax_list_del_init(struct list_head *entry);
70284 +
70285 /**
70286 * list_move - delete from one list and add as another's head
70287 * @list: the entry to move
70288 diff --git a/include/linux/math64.h b/include/linux/math64.h
70289 index 2913b86..4209244 100644
70290 --- a/include/linux/math64.h
70291 +++ b/include/linux/math64.h
70292 @@ -15,7 +15,7 @@
70293 * This is commonly provided by 32bit archs to provide an optimized 64bit
70294 * divide.
70295 */
70296 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70297 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70298 {
70299 *remainder = dividend % divisor;
70300 return dividend / divisor;
70301 @@ -52,7 +52,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
70302 #define div64_ul(x, y) div_u64((x), (y))
70303
70304 #ifndef div_u64_rem
70305 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70306 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
70307 {
70308 *remainder = do_div(dividend, divisor);
70309 return dividend;
70310 @@ -81,7 +81,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
70311 * divide.
70312 */
70313 #ifndef div_u64
70314 -static inline u64 div_u64(u64 dividend, u32 divisor)
70315 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
70316 {
70317 u32 remainder;
70318 return div_u64_rem(dividend, divisor, &remainder);
70319 diff --git a/include/linux/mm.h b/include/linux/mm.h
70320 index e0c8528..bcf0c29 100644
70321 --- a/include/linux/mm.h
70322 +++ b/include/linux/mm.h
70323 @@ -104,6 +104,11 @@ extern unsigned int kobjsize(const void *objp);
70324 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
70325 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
70326 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
70327 +
70328 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
70329 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
70330 +#endif
70331 +
70332 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
70333
70334 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
70335 @@ -205,8 +210,8 @@ struct vm_operations_struct {
70336 /* called by access_process_vm when get_user_pages() fails, typically
70337 * for use by special VMAs that can switch between memory and hardware
70338 */
70339 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
70340 - void *buf, int len, int write);
70341 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
70342 + void *buf, size_t len, int write);
70343 #ifdef CONFIG_NUMA
70344 /*
70345 * set_policy() op must add a reference to any non-NULL @new mempolicy
70346 @@ -236,6 +241,7 @@ struct vm_operations_struct {
70347 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
70348 unsigned long size, pgoff_t pgoff);
70349 };
70350 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
70351
70352 struct mmu_gather;
70353 struct inode;
70354 @@ -980,8 +986,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
70355 unsigned long *pfn);
70356 int follow_phys(struct vm_area_struct *vma, unsigned long address,
70357 unsigned int flags, unsigned long *prot, resource_size_t *phys);
70358 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
70359 - void *buf, int len, int write);
70360 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
70361 + void *buf, size_t len, int write);
70362
70363 static inline void unmap_shared_mapping_range(struct address_space *mapping,
70364 loff_t const holebegin, loff_t const holelen)
70365 @@ -1020,9 +1026,9 @@ static inline int fixup_user_fault(struct task_struct *tsk,
70366 }
70367 #endif
70368
70369 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
70370 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
70371 - void *buf, int len, int write);
70372 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
70373 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
70374 + void *buf, size_t len, int write);
70375
70376 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
70377 unsigned long start, unsigned long nr_pages,
70378 @@ -1053,34 +1059,6 @@ int set_page_dirty(struct page *page);
70379 int set_page_dirty_lock(struct page *page);
70380 int clear_page_dirty_for_io(struct page *page);
70381
70382 -/* Is the vma a continuation of the stack vma above it? */
70383 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
70384 -{
70385 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
70386 -}
70387 -
70388 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
70389 - unsigned long addr)
70390 -{
70391 - return (vma->vm_flags & VM_GROWSDOWN) &&
70392 - (vma->vm_start == addr) &&
70393 - !vma_growsdown(vma->vm_prev, addr);
70394 -}
70395 -
70396 -/* Is the vma a continuation of the stack vma below it? */
70397 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
70398 -{
70399 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
70400 -}
70401 -
70402 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
70403 - unsigned long addr)
70404 -{
70405 - return (vma->vm_flags & VM_GROWSUP) &&
70406 - (vma->vm_end == addr) &&
70407 - !vma_growsup(vma->vm_next, addr);
70408 -}
70409 -
70410 extern pid_t
70411 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
70412
70413 @@ -1180,6 +1158,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
70414 }
70415 #endif
70416
70417 +#ifdef CONFIG_MMU
70418 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
70419 +#else
70420 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
70421 +{
70422 + return __pgprot(0);
70423 +}
70424 +#endif
70425 +
70426 int vma_wants_writenotify(struct vm_area_struct *vma);
70427
70428 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
70429 @@ -1198,8 +1185,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
70430 {
70431 return 0;
70432 }
70433 +
70434 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
70435 + unsigned long address)
70436 +{
70437 + return 0;
70438 +}
70439 #else
70440 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
70441 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
70442 #endif
70443
70444 #ifdef __PAGETABLE_PMD_FOLDED
70445 @@ -1208,8 +1202,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
70446 {
70447 return 0;
70448 }
70449 +
70450 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
70451 + unsigned long address)
70452 +{
70453 + return 0;
70454 +}
70455 #else
70456 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
70457 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
70458 #endif
70459
70460 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
70461 @@ -1227,11 +1228,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
70462 NULL: pud_offset(pgd, address);
70463 }
70464
70465 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
70466 +{
70467 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
70468 + NULL: pud_offset(pgd, address);
70469 +}
70470 +
70471 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
70472 {
70473 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
70474 NULL: pmd_offset(pud, address);
70475 }
70476 +
70477 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
70478 +{
70479 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
70480 + NULL: pmd_offset(pud, address);
70481 +}
70482 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
70483
70484 #if USE_SPLIT_PTLOCKS
70485 @@ -1517,6 +1530,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
70486 unsigned long len, unsigned long prot, unsigned long flags,
70487 unsigned long pgoff, unsigned long *populate);
70488 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
70489 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
70490
70491 #ifdef CONFIG_MMU
70492 extern int __mm_populate(unsigned long addr, unsigned long len,
70493 @@ -1545,10 +1559,11 @@ struct vm_unmapped_area_info {
70494 unsigned long high_limit;
70495 unsigned long align_mask;
70496 unsigned long align_offset;
70497 + unsigned long threadstack_offset;
70498 };
70499
70500 -extern unsigned long unmapped_area(struct vm_unmapped_area_info *info);
70501 -extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
70502 +extern unsigned long unmapped_area(const struct vm_unmapped_area_info *info);
70503 +extern unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info);
70504
70505 /*
70506 * Search for an unmapped address range.
70507 @@ -1560,7 +1575,7 @@ extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
70508 * - satisfies (begin_addr & align_mask) == (align_offset & align_mask)
70509 */
70510 static inline unsigned long
70511 -vm_unmapped_area(struct vm_unmapped_area_info *info)
70512 +vm_unmapped_area(const struct vm_unmapped_area_info *info)
70513 {
70514 if (!(info->flags & VM_UNMAPPED_AREA_TOPDOWN))
70515 return unmapped_area(info);
70516 @@ -1623,6 +1638,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
70517 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
70518 struct vm_area_struct **pprev);
70519
70520 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
70521 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
70522 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
70523 +
70524 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
70525 NULL if none. Assume start_addr < end_addr. */
70526 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
70527 @@ -1651,15 +1670,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
70528 return vma;
70529 }
70530
70531 -#ifdef CONFIG_MMU
70532 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
70533 -#else
70534 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
70535 -{
70536 - return __pgprot(0);
70537 -}
70538 -#endif
70539 -
70540 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
70541 unsigned long change_prot_numa(struct vm_area_struct *vma,
70542 unsigned long start, unsigned long end);
70543 @@ -1711,6 +1721,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
70544 static inline void vm_stat_account(struct mm_struct *mm,
70545 unsigned long flags, struct file *file, long pages)
70546 {
70547 +
70548 +#ifdef CONFIG_PAX_RANDMMAP
70549 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
70550 +#endif
70551 +
70552 mm->total_vm += pages;
70553 }
70554 #endif /* CONFIG_PROC_FS */
70555 @@ -1791,7 +1806,7 @@ extern int unpoison_memory(unsigned long pfn);
70556 extern int sysctl_memory_failure_early_kill;
70557 extern int sysctl_memory_failure_recovery;
70558 extern void shake_page(struct page *p, int access);
70559 -extern atomic_long_t num_poisoned_pages;
70560 +extern atomic_long_unchecked_t num_poisoned_pages;
70561 extern int soft_offline_page(struct page *page, int flags);
70562
70563 extern void dump_page(struct page *page);
70564 @@ -1828,5 +1843,11 @@ void __init setup_nr_node_ids(void);
70565 static inline void setup_nr_node_ids(void) {}
70566 #endif
70567
70568 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
70569 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
70570 +#else
70571 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
70572 +#endif
70573 +
70574 #endif /* __KERNEL__ */
70575 #endif /* _LINUX_MM_H */
70576 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
70577 index ace9a5f..81bdb59 100644
70578 --- a/include/linux/mm_types.h
70579 +++ b/include/linux/mm_types.h
70580 @@ -289,6 +289,8 @@ struct vm_area_struct {
70581 #ifdef CONFIG_NUMA
70582 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
70583 #endif
70584 +
70585 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
70586 };
70587
70588 struct core_thread {
70589 @@ -437,6 +439,24 @@ struct mm_struct {
70590 int first_nid;
70591 #endif
70592 struct uprobes_state uprobes_state;
70593 +
70594 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
70595 + unsigned long pax_flags;
70596 +#endif
70597 +
70598 +#ifdef CONFIG_PAX_DLRESOLVE
70599 + unsigned long call_dl_resolve;
70600 +#endif
70601 +
70602 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
70603 + unsigned long call_syscall;
70604 +#endif
70605 +
70606 +#ifdef CONFIG_PAX_ASLR
70607 + unsigned long delta_mmap; /* randomized offset */
70608 + unsigned long delta_stack; /* randomized offset */
70609 +#endif
70610 +
70611 };
70612
70613 /* first nid will either be a valid NID or one of these values */
70614 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
70615 index c5d5278..f0b68c8 100644
70616 --- a/include/linux/mmiotrace.h
70617 +++ b/include/linux/mmiotrace.h
70618 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
70619 /* Called from ioremap.c */
70620 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
70621 void __iomem *addr);
70622 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
70623 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
70624
70625 /* For anyone to insert markers. Remember trailing newline. */
70626 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
70627 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
70628 {
70629 }
70630
70631 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
70632 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
70633 {
70634 }
70635
70636 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
70637 index 5c76737..61f518e 100644
70638 --- a/include/linux/mmzone.h
70639 +++ b/include/linux/mmzone.h
70640 @@ -396,7 +396,7 @@ struct zone {
70641 unsigned long flags; /* zone flags, see below */
70642
70643 /* Zone statistics */
70644 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
70645 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
70646
70647 /*
70648 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
70649 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
70650 index b508016..237cfe5 100644
70651 --- a/include/linux/mod_devicetable.h
70652 +++ b/include/linux/mod_devicetable.h
70653 @@ -13,7 +13,7 @@
70654 typedef unsigned long kernel_ulong_t;
70655 #endif
70656
70657 -#define PCI_ANY_ID (~0)
70658 +#define PCI_ANY_ID ((__u16)~0)
70659
70660 struct pci_device_id {
70661 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
70662 @@ -139,7 +139,7 @@ struct usb_device_id {
70663 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
70664 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
70665
70666 -#define HID_ANY_ID (~0)
70667 +#define HID_ANY_ID (~0U)
70668 #define HID_BUS_ANY 0xffff
70669 #define HID_GROUP_ANY 0x0000
70670
70671 @@ -465,7 +465,7 @@ struct dmi_system_id {
70672 const char *ident;
70673 struct dmi_strmatch matches[4];
70674 void *driver_data;
70675 -};
70676 +} __do_const;
70677 /*
70678 * struct dmi_device_id appears during expansion of
70679 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
70680 diff --git a/include/linux/module.h b/include/linux/module.h
70681 index 46f1ea0..a34ca37 100644
70682 --- a/include/linux/module.h
70683 +++ b/include/linux/module.h
70684 @@ -17,9 +17,11 @@
70685 #include <linux/moduleparam.h>
70686 #include <linux/tracepoint.h>
70687 #include <linux/export.h>
70688 +#include <linux/fs.h>
70689
70690 #include <linux/percpu.h>
70691 #include <asm/module.h>
70692 +#include <asm/pgtable.h>
70693
70694 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
70695 #define MODULE_SIG_STRING "~Module signature appended~\n"
70696 @@ -54,12 +56,13 @@ struct module_attribute {
70697 int (*test)(struct module *);
70698 void (*free)(struct module *);
70699 };
70700 +typedef struct module_attribute __no_const module_attribute_no_const;
70701
70702 struct module_version_attribute {
70703 struct module_attribute mattr;
70704 const char *module_name;
70705 const char *version;
70706 -} __attribute__ ((__aligned__(sizeof(void *))));
70707 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
70708
70709 extern ssize_t __modver_version_show(struct module_attribute *,
70710 struct module_kobject *, char *);
70711 @@ -232,7 +235,7 @@ struct module
70712
70713 /* Sysfs stuff. */
70714 struct module_kobject mkobj;
70715 - struct module_attribute *modinfo_attrs;
70716 + module_attribute_no_const *modinfo_attrs;
70717 const char *version;
70718 const char *srcversion;
70719 struct kobject *holders_dir;
70720 @@ -281,19 +284,16 @@ struct module
70721 int (*init)(void);
70722
70723 /* If this is non-NULL, vfree after init() returns */
70724 - void *module_init;
70725 + void *module_init_rx, *module_init_rw;
70726
70727 /* Here is the actual code + data, vfree'd on unload. */
70728 - void *module_core;
70729 + void *module_core_rx, *module_core_rw;
70730
70731 /* Here are the sizes of the init and core sections */
70732 - unsigned int init_size, core_size;
70733 + unsigned int init_size_rw, core_size_rw;
70734
70735 /* The size of the executable code in each section. */
70736 - unsigned int init_text_size, core_text_size;
70737 -
70738 - /* Size of RO sections of the module (text+rodata) */
70739 - unsigned int init_ro_size, core_ro_size;
70740 + unsigned int init_size_rx, core_size_rx;
70741
70742 /* Arch-specific module values */
70743 struct mod_arch_specific arch;
70744 @@ -349,6 +349,10 @@ struct module
70745 #ifdef CONFIG_EVENT_TRACING
70746 struct ftrace_event_call **trace_events;
70747 unsigned int num_trace_events;
70748 + struct file_operations trace_id;
70749 + struct file_operations trace_enable;
70750 + struct file_operations trace_format;
70751 + struct file_operations trace_filter;
70752 #endif
70753 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
70754 unsigned int num_ftrace_callsites;
70755 @@ -396,16 +400,46 @@ bool is_module_address(unsigned long addr);
70756 bool is_module_percpu_address(unsigned long addr);
70757 bool is_module_text_address(unsigned long addr);
70758
70759 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
70760 +{
70761 +
70762 +#ifdef CONFIG_PAX_KERNEXEC
70763 + if (ktla_ktva(addr) >= (unsigned long)start &&
70764 + ktla_ktva(addr) < (unsigned long)start + size)
70765 + return 1;
70766 +#endif
70767 +
70768 + return ((void *)addr >= start && (void *)addr < start + size);
70769 +}
70770 +
70771 +static inline int within_module_core_rx(unsigned long addr, const struct module *mod)
70772 +{
70773 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
70774 +}
70775 +
70776 +static inline int within_module_core_rw(unsigned long addr, const struct module *mod)
70777 +{
70778 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
70779 +}
70780 +
70781 +static inline int within_module_init_rx(unsigned long addr, const struct module *mod)
70782 +{
70783 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
70784 +}
70785 +
70786 +static inline int within_module_init_rw(unsigned long addr, const struct module *mod)
70787 +{
70788 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
70789 +}
70790 +
70791 static inline int within_module_core(unsigned long addr, const struct module *mod)
70792 {
70793 - return (unsigned long)mod->module_core <= addr &&
70794 - addr < (unsigned long)mod->module_core + mod->core_size;
70795 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
70796 }
70797
70798 static inline int within_module_init(unsigned long addr, const struct module *mod)
70799 {
70800 - return (unsigned long)mod->module_init <= addr &&
70801 - addr < (unsigned long)mod->module_init + mod->init_size;
70802 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
70803 }
70804
70805 /* Search for module by name: must hold module_mutex. */
70806 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
70807 index 560ca53..ef621ef 100644
70808 --- a/include/linux/moduleloader.h
70809 +++ b/include/linux/moduleloader.h
70810 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
70811 sections. Returns NULL on failure. */
70812 void *module_alloc(unsigned long size);
70813
70814 +#ifdef CONFIG_PAX_KERNEXEC
70815 +void *module_alloc_exec(unsigned long size);
70816 +#else
70817 +#define module_alloc_exec(x) module_alloc(x)
70818 +#endif
70819 +
70820 /* Free memory returned from module_alloc. */
70821 void module_free(struct module *mod, void *module_region);
70822
70823 +#ifdef CONFIG_PAX_KERNEXEC
70824 +void module_free_exec(struct module *mod, void *module_region);
70825 +#else
70826 +#define module_free_exec(x, y) module_free((x), (y))
70827 +#endif
70828 +
70829 /*
70830 * Apply the given relocation to the (simplified) ELF. Return -error
70831 * or 0.
70832 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
70833 unsigned int relsec,
70834 struct module *me)
70835 {
70836 +#ifdef CONFIG_MODULES
70837 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
70838 +#endif
70839 return -ENOEXEC;
70840 }
70841 #endif
70842 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
70843 unsigned int relsec,
70844 struct module *me)
70845 {
70846 +#ifdef CONFIG_MODULES
70847 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
70848 +#endif
70849 return -ENOEXEC;
70850 }
70851 #endif
70852 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
70853 index 137b419..fe663ec 100644
70854 --- a/include/linux/moduleparam.h
70855 +++ b/include/linux/moduleparam.h
70856 @@ -284,7 +284,7 @@ static inline void __kernel_param_unlock(void)
70857 * @len is usually just sizeof(string).
70858 */
70859 #define module_param_string(name, string, len, perm) \
70860 - static const struct kparam_string __param_string_##name \
70861 + static const struct kparam_string __param_string_##name __used \
70862 = { len, string }; \
70863 __module_param_call(MODULE_PARAM_PREFIX, name, \
70864 &param_ops_string, \
70865 @@ -423,7 +423,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
70866 */
70867 #define module_param_array_named(name, array, type, nump, perm) \
70868 param_check_##type(name, &(array)[0]); \
70869 - static const struct kparam_array __param_arr_##name \
70870 + static const struct kparam_array __param_arr_##name __used \
70871 = { .max = ARRAY_SIZE(array), .num = nump, \
70872 .ops = &param_ops_##type, \
70873 .elemsize = sizeof(array[0]), .elem = array }; \
70874 diff --git a/include/linux/namei.h b/include/linux/namei.h
70875 index 5a5ff57..5ae5070 100644
70876 --- a/include/linux/namei.h
70877 +++ b/include/linux/namei.h
70878 @@ -19,7 +19,7 @@ struct nameidata {
70879 unsigned seq;
70880 int last_type;
70881 unsigned depth;
70882 - char *saved_names[MAX_NESTED_LINKS + 1];
70883 + const char *saved_names[MAX_NESTED_LINKS + 1];
70884 };
70885
70886 /*
70887 @@ -84,12 +84,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
70888
70889 extern void nd_jump_link(struct nameidata *nd, struct path *path);
70890
70891 -static inline void nd_set_link(struct nameidata *nd, char *path)
70892 +static inline void nd_set_link(struct nameidata *nd, const char *path)
70893 {
70894 nd->saved_names[nd->depth] = path;
70895 }
70896
70897 -static inline char *nd_get_link(struct nameidata *nd)
70898 +static inline const char *nd_get_link(const struct nameidata *nd)
70899 {
70900 return nd->saved_names[nd->depth];
70901 }
70902 diff --git a/include/linux/net.h b/include/linux/net.h
70903 index 99c9f0c..e1cf296 100644
70904 --- a/include/linux/net.h
70905 +++ b/include/linux/net.h
70906 @@ -183,7 +183,7 @@ struct net_proto_family {
70907 int (*create)(struct net *net, struct socket *sock,
70908 int protocol, int kern);
70909 struct module *owner;
70910 -};
70911 +} __do_const;
70912
70913 struct iovec;
70914 struct kvec;
70915 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
70916 index 96e4c21..9cc8278 100644
70917 --- a/include/linux/netdevice.h
70918 +++ b/include/linux/netdevice.h
70919 @@ -1026,6 +1026,7 @@ struct net_device_ops {
70920 int (*ndo_change_carrier)(struct net_device *dev,
70921 bool new_carrier);
70922 };
70923 +typedef struct net_device_ops __no_const net_device_ops_no_const;
70924
70925 /*
70926 * The DEVICE structure.
70927 @@ -1094,7 +1095,7 @@ struct net_device {
70928 int iflink;
70929
70930 struct net_device_stats stats;
70931 - atomic_long_t rx_dropped; /* dropped packets by core network
70932 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
70933 * Do not use this in drivers.
70934 */
70935
70936 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
70937 index 0060fde..481c6ae 100644
70938 --- a/include/linux/netfilter.h
70939 +++ b/include/linux/netfilter.h
70940 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
70941 #endif
70942 /* Use the module struct to lock set/get code in place */
70943 struct module *owner;
70944 -};
70945 +} __do_const;
70946
70947 /* Function to register/unregister hook points. */
70948 int nf_register_hook(struct nf_hook_ops *reg);
70949 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
70950 index d80e275..c3510b8 100644
70951 --- a/include/linux/netfilter/ipset/ip_set.h
70952 +++ b/include/linux/netfilter/ipset/ip_set.h
70953 @@ -124,7 +124,7 @@ struct ip_set_type_variant {
70954 /* Return true if "b" set is the same as "a"
70955 * according to the create set parameters */
70956 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
70957 -};
70958 +} __do_const;
70959
70960 /* The core set type structure */
70961 struct ip_set_type {
70962 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
70963 index cadb740..d7c37c0 100644
70964 --- a/include/linux/netfilter/nfnetlink.h
70965 +++ b/include/linux/netfilter/nfnetlink.h
70966 @@ -16,7 +16,7 @@ struct nfnl_callback {
70967 const struct nlattr * const cda[]);
70968 const struct nla_policy *policy; /* netlink attribute policy */
70969 const u_int16_t attr_count; /* number of nlattr's */
70970 -};
70971 +} __do_const;
70972
70973 struct nfnetlink_subsystem {
70974 const char *name;
70975 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
70976 new file mode 100644
70977 index 0000000..33f4af8
70978 --- /dev/null
70979 +++ b/include/linux/netfilter/xt_gradm.h
70980 @@ -0,0 +1,9 @@
70981 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
70982 +#define _LINUX_NETFILTER_XT_GRADM_H 1
70983 +
70984 +struct xt_gradm_mtinfo {
70985 + __u16 flags;
70986 + __u16 invflags;
70987 +};
70988 +
70989 +#endif
70990 diff --git a/include/linux/nls.h b/include/linux/nls.h
70991 index 5dc635f..35f5e11 100644
70992 --- a/include/linux/nls.h
70993 +++ b/include/linux/nls.h
70994 @@ -31,7 +31,7 @@ struct nls_table {
70995 const unsigned char *charset2upper;
70996 struct module *owner;
70997 struct nls_table *next;
70998 -};
70999 +} __do_const;
71000
71001 /* this value hold the maximum octet of charset */
71002 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
71003 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
71004 index d14a4c3..a078786 100644
71005 --- a/include/linux/notifier.h
71006 +++ b/include/linux/notifier.h
71007 @@ -54,7 +54,8 @@ struct notifier_block {
71008 notifier_fn_t notifier_call;
71009 struct notifier_block __rcu *next;
71010 int priority;
71011 -};
71012 +} __do_const;
71013 +typedef struct notifier_block __no_const notifier_block_no_const;
71014
71015 struct atomic_notifier_head {
71016 spinlock_t lock;
71017 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
71018 index a4c5624..79d6d88 100644
71019 --- a/include/linux/oprofile.h
71020 +++ b/include/linux/oprofile.h
71021 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
71022 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
71023 char const * name, ulong * val);
71024
71025 -/** Create a file for read-only access to an atomic_t. */
71026 +/** Create a file for read-only access to an atomic_unchecked_t. */
71027 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
71028 - char const * name, atomic_t * val);
71029 + char const * name, atomic_unchecked_t * val);
71030
71031 /** create a directory */
71032 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
71033 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
71034 index 8db71dc..a76bf2c 100644
71035 --- a/include/linux/pci_hotplug.h
71036 +++ b/include/linux/pci_hotplug.h
71037 @@ -80,7 +80,8 @@ struct hotplug_slot_ops {
71038 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
71039 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
71040 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
71041 -};
71042 +} __do_const;
71043 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
71044
71045 /**
71046 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
71047 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
71048 index c5b6dbf..b124155 100644
71049 --- a/include/linux/perf_event.h
71050 +++ b/include/linux/perf_event.h
71051 @@ -318,8 +318,8 @@ struct perf_event {
71052
71053 enum perf_event_active_state state;
71054 unsigned int attach_state;
71055 - local64_t count;
71056 - atomic64_t child_count;
71057 + local64_t count; /* PaX: fix it one day */
71058 + atomic64_unchecked_t child_count;
71059
71060 /*
71061 * These are the total time in nanoseconds that the event
71062 @@ -370,8 +370,8 @@ struct perf_event {
71063 * These accumulate total time (in nanoseconds) that children
71064 * events have been enabled and running, respectively.
71065 */
71066 - atomic64_t child_total_time_enabled;
71067 - atomic64_t child_total_time_running;
71068 + atomic64_unchecked_t child_total_time_enabled;
71069 + atomic64_unchecked_t child_total_time_running;
71070
71071 /*
71072 * Protect attach/detach and child_list:
71073 @@ -692,7 +692,7 @@ static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64
71074 entry->ip[entry->nr++] = ip;
71075 }
71076
71077 -extern int sysctl_perf_event_paranoid;
71078 +extern int sysctl_perf_event_legitimately_concerned;
71079 extern int sysctl_perf_event_mlock;
71080 extern int sysctl_perf_event_sample_rate;
71081
71082 @@ -700,19 +700,24 @@ extern int perf_proc_update_handler(struct ctl_table *table, int write,
71083 void __user *buffer, size_t *lenp,
71084 loff_t *ppos);
71085
71086 +static inline bool perf_paranoid_any(void)
71087 +{
71088 + return sysctl_perf_event_legitimately_concerned > 2;
71089 +}
71090 +
71091 static inline bool perf_paranoid_tracepoint_raw(void)
71092 {
71093 - return sysctl_perf_event_paranoid > -1;
71094 + return sysctl_perf_event_legitimately_concerned > -1;
71095 }
71096
71097 static inline bool perf_paranoid_cpu(void)
71098 {
71099 - return sysctl_perf_event_paranoid > 0;
71100 + return sysctl_perf_event_legitimately_concerned > 0;
71101 }
71102
71103 static inline bool perf_paranoid_kernel(void)
71104 {
71105 - return sysctl_perf_event_paranoid > 1;
71106 + return sysctl_perf_event_legitimately_concerned > 1;
71107 }
71108
71109 extern void perf_event_init(void);
71110 @@ -806,7 +811,7 @@ static inline void perf_restore_debug_store(void) { }
71111 */
71112 #define perf_cpu_notifier(fn) \
71113 do { \
71114 - static struct notifier_block fn##_nb __cpuinitdata = \
71115 + static struct notifier_block fn##_nb = \
71116 { .notifier_call = fn, .priority = CPU_PRI_PERF }; \
71117 unsigned long cpu = smp_processor_id(); \
71118 unsigned long flags; \
71119 @@ -826,7 +831,7 @@ struct perf_pmu_events_attr {
71120 struct device_attribute attr;
71121 u64 id;
71122 const char *event_str;
71123 -};
71124 +} __do_const;
71125
71126 #define PMU_EVENT_ATTR(_name, _var, _id, _show) \
71127 static struct perf_pmu_events_attr _var = { \
71128 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
71129 index b8809fe..ae4ccd0 100644
71130 --- a/include/linux/pipe_fs_i.h
71131 +++ b/include/linux/pipe_fs_i.h
71132 @@ -47,10 +47,10 @@ struct pipe_inode_info {
71133 struct mutex mutex;
71134 wait_queue_head_t wait;
71135 unsigned int nrbufs, curbuf, buffers;
71136 - unsigned int readers;
71137 - unsigned int writers;
71138 - unsigned int files;
71139 - unsigned int waiting_writers;
71140 + atomic_t readers;
71141 + atomic_t writers;
71142 + atomic_t files;
71143 + atomic_t waiting_writers;
71144 unsigned int r_counter;
71145 unsigned int w_counter;
71146 struct page *tmp_page;
71147 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
71148 index 5f28cae..3d23723 100644
71149 --- a/include/linux/platform_data/usb-ehci-s5p.h
71150 +++ b/include/linux/platform_data/usb-ehci-s5p.h
71151 @@ -14,7 +14,7 @@
71152 struct s5p_ehci_platdata {
71153 int (*phy_init)(struct platform_device *pdev, int type);
71154 int (*phy_exit)(struct platform_device *pdev, int type);
71155 -};
71156 +} __no_const;
71157
71158 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
71159
71160 diff --git a/include/linux/platform_data/usb-ohci-exynos.h b/include/linux/platform_data/usb-ohci-exynos.h
71161 index c256c59..8ea94c7 100644
71162 --- a/include/linux/platform_data/usb-ohci-exynos.h
71163 +++ b/include/linux/platform_data/usb-ohci-exynos.h
71164 @@ -14,7 +14,7 @@
71165 struct exynos4_ohci_platdata {
71166 int (*phy_init)(struct platform_device *pdev, int type);
71167 int (*phy_exit)(struct platform_device *pdev, int type);
71168 -};
71169 +} __no_const;
71170
71171 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
71172
71173 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
71174 index 7c1d252..c5c773e 100644
71175 --- a/include/linux/pm_domain.h
71176 +++ b/include/linux/pm_domain.h
71177 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
71178
71179 struct gpd_cpu_data {
71180 unsigned int saved_exit_latency;
71181 - struct cpuidle_state *idle_state;
71182 + cpuidle_state_no_const *idle_state;
71183 };
71184
71185 struct generic_pm_domain {
71186 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
71187 index 7d7e09e..8671ef8 100644
71188 --- a/include/linux/pm_runtime.h
71189 +++ b/include/linux/pm_runtime.h
71190 @@ -104,7 +104,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
71191
71192 static inline void pm_runtime_mark_last_busy(struct device *dev)
71193 {
71194 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
71195 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
71196 }
71197
71198 #else /* !CONFIG_PM_RUNTIME */
71199 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
71200 index 195aafc..49a7bc2 100644
71201 --- a/include/linux/pnp.h
71202 +++ b/include/linux/pnp.h
71203 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
71204 struct pnp_fixup {
71205 char id[7];
71206 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
71207 -};
71208 +} __do_const;
71209
71210 /* config parameters */
71211 #define PNP_CONFIG_NORMAL 0x0001
71212 diff --git a/include/linux/poison.h b/include/linux/poison.h
71213 index 2110a81..13a11bb 100644
71214 --- a/include/linux/poison.h
71215 +++ b/include/linux/poison.h
71216 @@ -19,8 +19,8 @@
71217 * under normal circumstances, used to verify that nobody uses
71218 * non-initialized list entries.
71219 */
71220 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
71221 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
71222 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
71223 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
71224
71225 /********** include/linux/timer.h **********/
71226 /*
71227 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
71228 index c0f44c2..1572583 100644
71229 --- a/include/linux/power/smartreflex.h
71230 +++ b/include/linux/power/smartreflex.h
71231 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
71232 int (*notify)(struct omap_sr *sr, u32 status);
71233 u8 notify_flags;
71234 u8 class_type;
71235 -};
71236 +} __do_const;
71237
71238 /**
71239 * struct omap_sr_nvalue_table - Smartreflex n-target value info
71240 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
71241 index 4ea1d37..80f4b33 100644
71242 --- a/include/linux/ppp-comp.h
71243 +++ b/include/linux/ppp-comp.h
71244 @@ -84,7 +84,7 @@ struct compressor {
71245 struct module *owner;
71246 /* Extra skb space needed by the compressor algorithm */
71247 unsigned int comp_extra;
71248 -};
71249 +} __do_const;
71250
71251 /*
71252 * The return value from decompress routine is the length of the
71253 diff --git a/include/linux/printk.h b/include/linux/printk.h
71254 index 22c7052..ad3fa0a 100644
71255 --- a/include/linux/printk.h
71256 +++ b/include/linux/printk.h
71257 @@ -106,6 +106,8 @@ static inline __printf(1, 2) __cold
71258 void early_printk(const char *s, ...) { }
71259 #endif
71260
71261 +extern int kptr_restrict;
71262 +
71263 #ifdef CONFIG_PRINTK
71264 asmlinkage __printf(5, 0)
71265 int vprintk_emit(int facility, int level,
71266 @@ -140,7 +142,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
71267
71268 extern int printk_delay_msec;
71269 extern int dmesg_restrict;
71270 -extern int kptr_restrict;
71271
71272 extern void wake_up_klogd(void);
71273
71274 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
71275 index 608e60a..c26f864 100644
71276 --- a/include/linux/proc_fs.h
71277 +++ b/include/linux/proc_fs.h
71278 @@ -34,6 +34,19 @@ static inline struct proc_dir_entry *proc_create(
71279 return proc_create_data(name, mode, parent, proc_fops, NULL);
71280 }
71281
71282 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
71283 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
71284 +{
71285 +#ifdef CONFIG_GRKERNSEC_PROC_USER
71286 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
71287 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
71288 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
71289 +#else
71290 + return proc_create_data(name, mode, parent, proc_fops, NULL);
71291 +#endif
71292 +}
71293 +
71294 +
71295 extern void proc_set_size(struct proc_dir_entry *, loff_t);
71296 extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
71297 extern void *PDE_DATA(const struct inode *);
71298 diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
71299 index 34a1e10..03a6d03 100644
71300 --- a/include/linux/proc_ns.h
71301 +++ b/include/linux/proc_ns.h
71302 @@ -14,7 +14,7 @@ struct proc_ns_operations {
71303 void (*put)(void *ns);
71304 int (*install)(struct nsproxy *nsproxy, void *ns);
71305 unsigned int (*inum)(void *ns);
71306 -};
71307 +} __do_const;
71308
71309 struct proc_ns {
71310 void *ns;
71311 diff --git a/include/linux/random.h b/include/linux/random.h
71312 index 3b9377d..61b506a 100644
71313 --- a/include/linux/random.h
71314 +++ b/include/linux/random.h
71315 @@ -32,6 +32,11 @@ void prandom_seed(u32 seed);
71316 u32 prandom_u32_state(struct rnd_state *);
71317 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
71318
71319 +static inline unsigned long pax_get_random_long(void)
71320 +{
71321 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
71322 +}
71323 +
71324 /*
71325 * Handle minimum values for seeds
71326 */
71327 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
71328 index f4b1001..8ddb2b6 100644
71329 --- a/include/linux/rculist.h
71330 +++ b/include/linux/rculist.h
71331 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
71332 struct list_head *prev, struct list_head *next);
71333 #endif
71334
71335 +extern void __pax_list_add_rcu(struct list_head *new,
71336 + struct list_head *prev, struct list_head *next);
71337 +
71338 /**
71339 * list_add_rcu - add a new entry to rcu-protected list
71340 * @new: new entry to be added
71341 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
71342 __list_add_rcu(new, head, head->next);
71343 }
71344
71345 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
71346 +{
71347 + __pax_list_add_rcu(new, head, head->next);
71348 +}
71349 +
71350 /**
71351 * list_add_tail_rcu - add a new entry to rcu-protected list
71352 * @new: new entry to be added
71353 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
71354 __list_add_rcu(new, head->prev, head);
71355 }
71356
71357 +static inline void pax_list_add_tail_rcu(struct list_head *new,
71358 + struct list_head *head)
71359 +{
71360 + __pax_list_add_rcu(new, head->prev, head);
71361 +}
71362 +
71363 /**
71364 * list_del_rcu - deletes entry from list without re-initialization
71365 * @entry: the element to delete from the list.
71366 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
71367 entry->prev = LIST_POISON2;
71368 }
71369
71370 +extern void pax_list_del_rcu(struct list_head *entry);
71371 +
71372 /**
71373 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
71374 * @n: the element to delete from the hash list.
71375 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
71376 index 23b3630..e1bc12b 100644
71377 --- a/include/linux/reboot.h
71378 +++ b/include/linux/reboot.h
71379 @@ -18,9 +18,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
71380 * Architecture-specific implementations of sys_reboot commands.
71381 */
71382
71383 -extern void machine_restart(char *cmd);
71384 -extern void machine_halt(void);
71385 -extern void machine_power_off(void);
71386 +extern void machine_restart(char *cmd) __noreturn;
71387 +extern void machine_halt(void) __noreturn;
71388 +extern void machine_power_off(void) __noreturn;
71389
71390 extern void machine_shutdown(void);
71391 struct pt_regs;
71392 @@ -31,9 +31,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
71393 */
71394
71395 extern void kernel_restart_prepare(char *cmd);
71396 -extern void kernel_restart(char *cmd);
71397 -extern void kernel_halt(void);
71398 -extern void kernel_power_off(void);
71399 +extern void kernel_restart(char *cmd) __noreturn;
71400 +extern void kernel_halt(void) __noreturn;
71401 +extern void kernel_power_off(void) __noreturn;
71402
71403 extern int C_A_D; /* for sysctl */
71404 void ctrl_alt_del(void);
71405 @@ -47,7 +47,7 @@ extern int orderly_poweroff(bool force);
71406 * Emergency restart, callable from an interrupt handler.
71407 */
71408
71409 -extern void emergency_restart(void);
71410 +extern void emergency_restart(void) __noreturn;
71411 #include <asm/emergency-restart.h>
71412
71413 #endif /* _LINUX_REBOOT_H */
71414 diff --git a/include/linux/regset.h b/include/linux/regset.h
71415 index 8e0c9fe..ac4d221 100644
71416 --- a/include/linux/regset.h
71417 +++ b/include/linux/regset.h
71418 @@ -161,7 +161,8 @@ struct user_regset {
71419 unsigned int align;
71420 unsigned int bias;
71421 unsigned int core_note_type;
71422 -};
71423 +} __do_const;
71424 +typedef struct user_regset __no_const user_regset_no_const;
71425
71426 /**
71427 * struct user_regset_view - available regsets
71428 diff --git a/include/linux/relay.h b/include/linux/relay.h
71429 index d7c8359..818daf5 100644
71430 --- a/include/linux/relay.h
71431 +++ b/include/linux/relay.h
71432 @@ -157,7 +157,7 @@ struct rchan_callbacks
71433 * The callback should return 0 if successful, negative if not.
71434 */
71435 int (*remove_buf_file)(struct dentry *dentry);
71436 -};
71437 +} __no_const;
71438
71439 /*
71440 * CONFIG_RELAY kernel API, kernel/relay.c
71441 diff --git a/include/linux/rio.h b/include/linux/rio.h
71442 index 18e0993..8ab5b21 100644
71443 --- a/include/linux/rio.h
71444 +++ b/include/linux/rio.h
71445 @@ -345,7 +345,7 @@ struct rio_ops {
71446 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
71447 u64 rstart, u32 size, u32 flags);
71448 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
71449 -};
71450 +} __no_const;
71451
71452 #define RIO_RESOURCE_MEM 0x00000100
71453 #define RIO_RESOURCE_DOORBELL 0x00000200
71454 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
71455 index 6dacb93..6174423 100644
71456 --- a/include/linux/rmap.h
71457 +++ b/include/linux/rmap.h
71458 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
71459 void anon_vma_init(void); /* create anon_vma_cachep */
71460 int anon_vma_prepare(struct vm_area_struct *);
71461 void unlink_anon_vmas(struct vm_area_struct *);
71462 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
71463 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
71464 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
71465 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
71466
71467 static inline void anon_vma_merge(struct vm_area_struct *vma,
71468 struct vm_area_struct *next)
71469 diff --git a/include/linux/sched.h b/include/linux/sched.h
71470 index 178a8d9..52e71a3 100644
71471 --- a/include/linux/sched.h
71472 +++ b/include/linux/sched.h
71473 @@ -62,6 +62,7 @@ struct bio_list;
71474 struct fs_struct;
71475 struct perf_event_context;
71476 struct blk_plug;
71477 +struct linux_binprm;
71478
71479 /*
71480 * List of flags we want to share for kernel threads,
71481 @@ -303,7 +304,7 @@ extern char __sched_text_start[], __sched_text_end[];
71482 extern int in_sched_functions(unsigned long addr);
71483
71484 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
71485 -extern signed long schedule_timeout(signed long timeout);
71486 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
71487 extern signed long schedule_timeout_interruptible(signed long timeout);
71488 extern signed long schedule_timeout_killable(signed long timeout);
71489 extern signed long schedule_timeout_uninterruptible(signed long timeout);
71490 @@ -314,6 +315,19 @@ struct nsproxy;
71491 struct user_namespace;
71492
71493 #ifdef CONFIG_MMU
71494 +
71495 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
71496 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
71497 +#else
71498 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
71499 +{
71500 + return 0;
71501 +}
71502 +#endif
71503 +
71504 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
71505 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
71506 +
71507 extern void arch_pick_mmap_layout(struct mm_struct *mm);
71508 extern unsigned long
71509 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
71510 @@ -591,6 +605,17 @@ struct signal_struct {
71511 #ifdef CONFIG_TASKSTATS
71512 struct taskstats *stats;
71513 #endif
71514 +
71515 +#ifdef CONFIG_GRKERNSEC
71516 + u32 curr_ip;
71517 + u32 saved_ip;
71518 + u32 gr_saddr;
71519 + u32 gr_daddr;
71520 + u16 gr_sport;
71521 + u16 gr_dport;
71522 + u8 used_accept:1;
71523 +#endif
71524 +
71525 #ifdef CONFIG_AUDIT
71526 unsigned audit_tty;
71527 unsigned audit_tty_log_passwd;
71528 @@ -671,6 +696,14 @@ struct user_struct {
71529 struct key *session_keyring; /* UID's default session keyring */
71530 #endif
71531
71532 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
71533 + unsigned char kernel_banned;
71534 +#endif
71535 +#ifdef CONFIG_GRKERNSEC_BRUTE
71536 + unsigned char suid_banned;
71537 + unsigned long suid_ban_expires;
71538 +#endif
71539 +
71540 /* Hash table maintenance information */
71541 struct hlist_node uidhash_node;
71542 kuid_t uid;
71543 @@ -1158,8 +1191,8 @@ struct task_struct {
71544 struct list_head thread_group;
71545
71546 struct completion *vfork_done; /* for vfork() */
71547 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
71548 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
71549 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
71550 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
71551
71552 cputime_t utime, stime, utimescaled, stimescaled;
71553 cputime_t gtime;
71554 @@ -1184,11 +1217,6 @@ struct task_struct {
71555 struct task_cputime cputime_expires;
71556 struct list_head cpu_timers[3];
71557
71558 -/* process credentials */
71559 - const struct cred __rcu *real_cred; /* objective and real subjective task
71560 - * credentials (COW) */
71561 - const struct cred __rcu *cred; /* effective (overridable) subjective task
71562 - * credentials (COW) */
71563 char comm[TASK_COMM_LEN]; /* executable name excluding path
71564 - access with [gs]et_task_comm (which lock
71565 it with task_lock())
71566 @@ -1205,6 +1233,10 @@ struct task_struct {
71567 #endif
71568 /* CPU-specific state of this task */
71569 struct thread_struct thread;
71570 +/* thread_info moved to task_struct */
71571 +#ifdef CONFIG_X86
71572 + struct thread_info tinfo;
71573 +#endif
71574 /* filesystem information */
71575 struct fs_struct *fs;
71576 /* open file information */
71577 @@ -1278,6 +1310,10 @@ struct task_struct {
71578 gfp_t lockdep_reclaim_gfp;
71579 #endif
71580
71581 +/* process credentials */
71582 + const struct cred __rcu *real_cred; /* objective and real subjective task
71583 + * credentials (COW) */
71584 +
71585 /* journalling filesystem info */
71586 void *journal_info;
71587
71588 @@ -1316,6 +1352,10 @@ struct task_struct {
71589 /* cg_list protected by css_set_lock and tsk->alloc_lock */
71590 struct list_head cg_list;
71591 #endif
71592 +
71593 + const struct cred __rcu *cred; /* effective (overridable) subjective task
71594 + * credentials (COW) */
71595 +
71596 #ifdef CONFIG_FUTEX
71597 struct robust_list_head __user *robust_list;
71598 #ifdef CONFIG_COMPAT
71599 @@ -1416,8 +1456,74 @@ struct task_struct {
71600 unsigned int sequential_io;
71601 unsigned int sequential_io_avg;
71602 #endif
71603 +
71604 +#ifdef CONFIG_GRKERNSEC
71605 + /* grsecurity */
71606 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
71607 + u64 exec_id;
71608 +#endif
71609 +#ifdef CONFIG_GRKERNSEC_SETXID
71610 + const struct cred *delayed_cred;
71611 +#endif
71612 + struct dentry *gr_chroot_dentry;
71613 + struct acl_subject_label *acl;
71614 + struct acl_role_label *role;
71615 + struct file *exec_file;
71616 + unsigned long brute_expires;
71617 + u16 acl_role_id;
71618 + /* is this the task that authenticated to the special role */
71619 + u8 acl_sp_role;
71620 + u8 is_writable;
71621 + u8 brute;
71622 + u8 gr_is_chrooted;
71623 +#endif
71624 +
71625 };
71626
71627 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
71628 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
71629 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
71630 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
71631 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
71632 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
71633 +
71634 +#ifdef CONFIG_PAX_SOFTMODE
71635 +extern int pax_softmode;
71636 +#endif
71637 +
71638 +extern int pax_check_flags(unsigned long *);
71639 +
71640 +/* if tsk != current then task_lock must be held on it */
71641 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
71642 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
71643 +{
71644 + if (likely(tsk->mm))
71645 + return tsk->mm->pax_flags;
71646 + else
71647 + return 0UL;
71648 +}
71649 +
71650 +/* if tsk != current then task_lock must be held on it */
71651 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
71652 +{
71653 + if (likely(tsk->mm)) {
71654 + tsk->mm->pax_flags = flags;
71655 + return 0;
71656 + }
71657 + return -EINVAL;
71658 +}
71659 +#endif
71660 +
71661 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
71662 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
71663 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
71664 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
71665 +#endif
71666 +
71667 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
71668 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
71669 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
71670 +
71671 /* Future-safe accessor for struct task_struct's cpus_allowed. */
71672 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
71673
71674 @@ -1476,7 +1582,7 @@ struct pid_namespace;
71675 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
71676 struct pid_namespace *ns);
71677
71678 -static inline pid_t task_pid_nr(struct task_struct *tsk)
71679 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
71680 {
71681 return tsk->pid;
71682 }
71683 @@ -1919,7 +2025,9 @@ void yield(void);
71684 extern struct exec_domain default_exec_domain;
71685
71686 union thread_union {
71687 +#ifndef CONFIG_X86
71688 struct thread_info thread_info;
71689 +#endif
71690 unsigned long stack[THREAD_SIZE/sizeof(long)];
71691 };
71692
71693 @@ -1952,6 +2060,7 @@ extern struct pid_namespace init_pid_ns;
71694 */
71695
71696 extern struct task_struct *find_task_by_vpid(pid_t nr);
71697 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
71698 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
71699 struct pid_namespace *ns);
71700
71701 @@ -2118,7 +2227,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
71702 extern void exit_itimers(struct signal_struct *);
71703 extern void flush_itimer_signals(void);
71704
71705 -extern void do_group_exit(int);
71706 +extern __noreturn void do_group_exit(int);
71707
71708 extern int allow_signal(int);
71709 extern int disallow_signal(int);
71710 @@ -2309,9 +2418,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
71711
71712 #endif
71713
71714 -static inline int object_is_on_stack(void *obj)
71715 +static inline int object_starts_on_stack(void *obj)
71716 {
71717 - void *stack = task_stack_page(current);
71718 + const void *stack = task_stack_page(current);
71719
71720 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
71721 }
71722 diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
71723 index bf8086b..962b035 100644
71724 --- a/include/linux/sched/sysctl.h
71725 +++ b/include/linux/sched/sysctl.h
71726 @@ -30,6 +30,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };
71727 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
71728
71729 extern int sysctl_max_map_count;
71730 +extern unsigned long sysctl_heap_stack_gap;
71731
71732 extern unsigned int sysctl_sched_latency;
71733 extern unsigned int sysctl_sched_min_granularity;
71734 diff --git a/include/linux/security.h b/include/linux/security.h
71735 index 4686491..2bd210e 100644
71736 --- a/include/linux/security.h
71737 +++ b/include/linux/security.h
71738 @@ -26,6 +26,7 @@
71739 #include <linux/capability.h>
71740 #include <linux/slab.h>
71741 #include <linux/err.h>
71742 +#include <linux/grsecurity.h>
71743
71744 struct linux_binprm;
71745 struct cred;
71746 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
71747 index 2da29ac..aac448ec 100644
71748 --- a/include/linux/seq_file.h
71749 +++ b/include/linux/seq_file.h
71750 @@ -26,6 +26,9 @@ struct seq_file {
71751 struct mutex lock;
71752 const struct seq_operations *op;
71753 int poll_event;
71754 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
71755 + u64 exec_id;
71756 +#endif
71757 #ifdef CONFIG_USER_NS
71758 struct user_namespace *user_ns;
71759 #endif
71760 @@ -38,6 +41,7 @@ struct seq_operations {
71761 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
71762 int (*show) (struct seq_file *m, void *v);
71763 };
71764 +typedef struct seq_operations __no_const seq_operations_no_const;
71765
71766 #define SEQ_SKIP 1
71767
71768 diff --git a/include/linux/shm.h b/include/linux/shm.h
71769 index 429c199..4d42e38 100644
71770 --- a/include/linux/shm.h
71771 +++ b/include/linux/shm.h
71772 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
71773
71774 /* The task created the shm object. NULL if the task is dead. */
71775 struct task_struct *shm_creator;
71776 +#ifdef CONFIG_GRKERNSEC
71777 + time_t shm_createtime;
71778 + pid_t shm_lapid;
71779 +#endif
71780 };
71781
71782 /* shm_mode upper byte flags */
71783 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
71784 index dec1748..112c1f9 100644
71785 --- a/include/linux/skbuff.h
71786 +++ b/include/linux/skbuff.h
71787 @@ -640,7 +640,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
71788 extern struct sk_buff *__alloc_skb(unsigned int size,
71789 gfp_t priority, int flags, int node);
71790 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
71791 -static inline struct sk_buff *alloc_skb(unsigned int size,
71792 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
71793 gfp_t priority)
71794 {
71795 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
71796 @@ -756,7 +756,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
71797 */
71798 static inline int skb_queue_empty(const struct sk_buff_head *list)
71799 {
71800 - return list->next == (struct sk_buff *)list;
71801 + return list->next == (const struct sk_buff *)list;
71802 }
71803
71804 /**
71805 @@ -769,7 +769,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
71806 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
71807 const struct sk_buff *skb)
71808 {
71809 - return skb->next == (struct sk_buff *)list;
71810 + return skb->next == (const struct sk_buff *)list;
71811 }
71812
71813 /**
71814 @@ -782,7 +782,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
71815 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
71816 const struct sk_buff *skb)
71817 {
71818 - return skb->prev == (struct sk_buff *)list;
71819 + return skb->prev == (const struct sk_buff *)list;
71820 }
71821
71822 /**
71823 @@ -1848,7 +1848,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
71824 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
71825 */
71826 #ifndef NET_SKB_PAD
71827 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
71828 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
71829 #endif
71830
71831 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
71832 @@ -2443,7 +2443,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
71833 int noblock, int *err);
71834 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
71835 struct poll_table_struct *wait);
71836 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
71837 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
71838 int offset, struct iovec *to,
71839 int size);
71840 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
71841 @@ -2733,6 +2733,9 @@ static inline void nf_reset(struct sk_buff *skb)
71842 nf_bridge_put(skb->nf_bridge);
71843 skb->nf_bridge = NULL;
71844 #endif
71845 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
71846 + skb->nf_trace = 0;
71847 +#endif
71848 }
71849
71850 static inline void nf_reset_trace(struct sk_buff *skb)
71851 diff --git a/include/linux/slab.h b/include/linux/slab.h
71852 index 0c62175..9ece3d8 100644
71853 --- a/include/linux/slab.h
71854 +++ b/include/linux/slab.h
71855 @@ -12,13 +12,20 @@
71856 #include <linux/gfp.h>
71857 #include <linux/types.h>
71858 #include <linux/workqueue.h>
71859 -
71860 +#include <linux/err.h>
71861
71862 /*
71863 * Flags to pass to kmem_cache_create().
71864 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
71865 */
71866 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
71867 +
71868 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71869 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
71870 +#else
71871 +#define SLAB_USERCOPY 0x00000000UL
71872 +#endif
71873 +
71874 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
71875 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
71876 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
71877 @@ -89,10 +96,13 @@
71878 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
71879 * Both make kfree a no-op.
71880 */
71881 -#define ZERO_SIZE_PTR ((void *)16)
71882 +#define ZERO_SIZE_PTR \
71883 +({ \
71884 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
71885 + (void *)(-MAX_ERRNO-1L); \
71886 +})
71887
71888 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
71889 - (unsigned long)ZERO_SIZE_PTR)
71890 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
71891
71892
71893 struct mem_cgroup;
71894 @@ -132,6 +142,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
71895 void kfree(const void *);
71896 void kzfree(const void *);
71897 size_t ksize(const void *);
71898 +const char *check_heap_object(const void *ptr, unsigned long n);
71899 +bool is_usercopy_object(const void *ptr);
71900
71901 /*
71902 * Some archs want to perform DMA into kmalloc caches and need a guaranteed
71903 @@ -164,7 +176,7 @@ struct kmem_cache {
71904 unsigned int align; /* Alignment as calculated */
71905 unsigned long flags; /* Active flags on the slab */
71906 const char *name; /* Slab name for sysfs */
71907 - int refcount; /* Use counter */
71908 + atomic_t refcount; /* Use counter */
71909 void (*ctor)(void *); /* Called on object slot creation */
71910 struct list_head list; /* List of all slab caches on the system */
71911 };
71912 @@ -226,6 +238,10 @@ extern struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];
71913 extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
71914 #endif
71915
71916 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71917 +extern struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
71918 +#endif
71919 +
71920 /*
71921 * Figure out which kmalloc slab an allocation of a certain size
71922 * belongs to.
71923 @@ -234,7 +250,7 @@ extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
71924 * 2 = 120 .. 192 bytes
71925 * n = 2^(n-1) .. 2^n -1
71926 */
71927 -static __always_inline int kmalloc_index(size_t size)
71928 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
71929 {
71930 if (!size)
71931 return 0;
71932 @@ -406,6 +422,7 @@ void print_slabinfo_header(struct seq_file *m);
71933 * for general use, and so are not documented here. For a full list of
71934 * potential flags, always refer to linux/gfp.h.
71935 */
71936 +
71937 static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
71938 {
71939 if (size != 0 && n > SIZE_MAX / size)
71940 @@ -465,7 +482,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
71941 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
71942 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
71943 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
71944 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
71945 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
71946 #define kmalloc_track_caller(size, flags) \
71947 __kmalloc_track_caller(size, flags, _RET_IP_)
71948 #else
71949 @@ -485,7 +502,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
71950 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
71951 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
71952 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
71953 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
71954 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
71955 #define kmalloc_node_track_caller(size, flags, node) \
71956 __kmalloc_node_track_caller(size, flags, node, \
71957 _RET_IP_)
71958 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
71959 index cd40158..d9dc02c 100644
71960 --- a/include/linux/slab_def.h
71961 +++ b/include/linux/slab_def.h
71962 @@ -50,7 +50,7 @@ struct kmem_cache {
71963 /* 4) cache creation/removal */
71964 const char *name;
71965 struct list_head list;
71966 - int refcount;
71967 + atomic_t refcount;
71968 int object_size;
71969 int align;
71970
71971 @@ -66,10 +66,10 @@ struct kmem_cache {
71972 unsigned long node_allocs;
71973 unsigned long node_frees;
71974 unsigned long node_overflow;
71975 - atomic_t allochit;
71976 - atomic_t allocmiss;
71977 - atomic_t freehit;
71978 - atomic_t freemiss;
71979 + atomic_unchecked_t allochit;
71980 + atomic_unchecked_t allocmiss;
71981 + atomic_unchecked_t freehit;
71982 + atomic_unchecked_t freemiss;
71983
71984 /*
71985 * If debugging is enabled, then the allocator can add additional
71986 @@ -103,7 +103,7 @@ struct kmem_cache {
71987 };
71988
71989 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
71990 -void *__kmalloc(size_t size, gfp_t flags);
71991 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
71992
71993 #ifdef CONFIG_TRACING
71994 extern void *kmem_cache_alloc_trace(struct kmem_cache *, gfp_t, size_t);
71995 @@ -136,6 +136,13 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
71996 cachep = kmalloc_dma_caches[i];
71997 else
71998 #endif
71999 +
72000 +#ifdef CONFIG_PAX_USERCOPY_SLABS
72001 + if (flags & GFP_USERCOPY)
72002 + cachep = kmalloc_usercopy_caches[i];
72003 + else
72004 +#endif
72005 +
72006 cachep = kmalloc_caches[i];
72007
72008 ret = kmem_cache_alloc_trace(cachep, flags, size);
72009 @@ -146,7 +153,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
72010 }
72011
72012 #ifdef CONFIG_NUMA
72013 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
72014 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
72015 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
72016
72017 #ifdef CONFIG_TRACING
72018 @@ -185,6 +192,13 @@ static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
72019 cachep = kmalloc_dma_caches[i];
72020 else
72021 #endif
72022 +
72023 +#ifdef CONFIG_PAX_USERCOPY_SLABS
72024 + if (flags & GFP_USERCOPY)
72025 + cachep = kmalloc_usercopy_caches[i];
72026 + else
72027 +#endif
72028 +
72029 cachep = kmalloc_caches[i];
72030
72031 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
72032 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
72033 index f28e14a..7831211 100644
72034 --- a/include/linux/slob_def.h
72035 +++ b/include/linux/slob_def.h
72036 @@ -11,7 +11,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
72037 return kmem_cache_alloc_node(cachep, flags, NUMA_NO_NODE);
72038 }
72039
72040 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
72041 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
72042
72043 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
72044 {
72045 @@ -31,7 +31,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
72046 return __kmalloc_node(size, flags, NUMA_NO_NODE);
72047 }
72048
72049 -static __always_inline void *__kmalloc(size_t size, gfp_t flags)
72050 +static __always_inline __size_overflow(1) void *__kmalloc(size_t size, gfp_t flags)
72051 {
72052 return kmalloc(size, flags);
72053 }
72054 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
72055 index 027276f..092bfe8 100644
72056 --- a/include/linux/slub_def.h
72057 +++ b/include/linux/slub_def.h
72058 @@ -80,7 +80,7 @@ struct kmem_cache {
72059 struct kmem_cache_order_objects max;
72060 struct kmem_cache_order_objects min;
72061 gfp_t allocflags; /* gfp flags to use on each alloc */
72062 - int refcount; /* Refcount for slab cache destroy */
72063 + atomic_t refcount; /* Refcount for slab cache destroy */
72064 void (*ctor)(void *);
72065 int inuse; /* Offset to metadata */
72066 int align; /* Alignment */
72067 @@ -105,7 +105,7 @@ struct kmem_cache {
72068 };
72069
72070 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
72071 -void *__kmalloc(size_t size, gfp_t flags);
72072 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
72073
72074 static __always_inline void *
72075 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
72076 @@ -149,7 +149,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
72077 }
72078 #endif
72079
72080 -static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
72081 +static __always_inline __size_overflow(1) void *kmalloc_large(size_t size, gfp_t flags)
72082 {
72083 unsigned int order = get_order(size);
72084 return kmalloc_order_trace(size, flags, order);
72085 @@ -175,7 +175,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
72086 }
72087
72088 #ifdef CONFIG_NUMA
72089 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
72090 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
72091 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
72092
72093 #ifdef CONFIG_TRACING
72094 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
72095 index 54f91d3..be2c379 100644
72096 --- a/include/linux/sock_diag.h
72097 +++ b/include/linux/sock_diag.h
72098 @@ -11,7 +11,7 @@ struct sock;
72099 struct sock_diag_handler {
72100 __u8 family;
72101 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
72102 -};
72103 +} __do_const;
72104
72105 int sock_diag_register(const struct sock_diag_handler *h);
72106 void sock_diag_unregister(const struct sock_diag_handler *h);
72107 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
72108 index 680f9a3..f13aeb0 100644
72109 --- a/include/linux/sonet.h
72110 +++ b/include/linux/sonet.h
72111 @@ -7,7 +7,7 @@
72112 #include <uapi/linux/sonet.h>
72113
72114 struct k_sonet_stats {
72115 -#define __HANDLE_ITEM(i) atomic_t i
72116 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
72117 __SONET_ITEMS
72118 #undef __HANDLE_ITEM
72119 };
72120 diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
72121 index 07d8e53..dc934c9 100644
72122 --- a/include/linux/sunrpc/addr.h
72123 +++ b/include/linux/sunrpc/addr.h
72124 @@ -23,9 +23,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
72125 {
72126 switch (sap->sa_family) {
72127 case AF_INET:
72128 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
72129 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
72130 case AF_INET6:
72131 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
72132 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
72133 }
72134 return 0;
72135 }
72136 @@ -58,7 +58,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
72137 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
72138 const struct sockaddr *src)
72139 {
72140 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
72141 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
72142 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
72143
72144 dsin->sin_family = ssin->sin_family;
72145 @@ -164,7 +164,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
72146 if (sa->sa_family != AF_INET6)
72147 return 0;
72148
72149 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
72150 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
72151 }
72152
72153 #endif /* _LINUX_SUNRPC_ADDR_H */
72154 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
72155 index bfe11be..12bc8c4 100644
72156 --- a/include/linux/sunrpc/clnt.h
72157 +++ b/include/linux/sunrpc/clnt.h
72158 @@ -96,7 +96,7 @@ struct rpc_procinfo {
72159 unsigned int p_timer; /* Which RTT timer to use */
72160 u32 p_statidx; /* Which procedure to account */
72161 const char * p_name; /* name of procedure */
72162 -};
72163 +} __do_const;
72164
72165 #ifdef __KERNEL__
72166
72167 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
72168 index 1f0216b..6a4fa50 100644
72169 --- a/include/linux/sunrpc/svc.h
72170 +++ b/include/linux/sunrpc/svc.h
72171 @@ -411,7 +411,7 @@ struct svc_procedure {
72172 unsigned int pc_count; /* call count */
72173 unsigned int pc_cachetype; /* cache info (NFS) */
72174 unsigned int pc_xdrressize; /* maximum size of XDR reply */
72175 -};
72176 +} __do_const;
72177
72178 /*
72179 * Function prototypes.
72180 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
72181 index 0b8e3e6..33e0a01 100644
72182 --- a/include/linux/sunrpc/svc_rdma.h
72183 +++ b/include/linux/sunrpc/svc_rdma.h
72184 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
72185 extern unsigned int svcrdma_max_requests;
72186 extern unsigned int svcrdma_max_req_size;
72187
72188 -extern atomic_t rdma_stat_recv;
72189 -extern atomic_t rdma_stat_read;
72190 -extern atomic_t rdma_stat_write;
72191 -extern atomic_t rdma_stat_sq_starve;
72192 -extern atomic_t rdma_stat_rq_starve;
72193 -extern atomic_t rdma_stat_rq_poll;
72194 -extern atomic_t rdma_stat_rq_prod;
72195 -extern atomic_t rdma_stat_sq_poll;
72196 -extern atomic_t rdma_stat_sq_prod;
72197 +extern atomic_unchecked_t rdma_stat_recv;
72198 +extern atomic_unchecked_t rdma_stat_read;
72199 +extern atomic_unchecked_t rdma_stat_write;
72200 +extern atomic_unchecked_t rdma_stat_sq_starve;
72201 +extern atomic_unchecked_t rdma_stat_rq_starve;
72202 +extern atomic_unchecked_t rdma_stat_rq_poll;
72203 +extern atomic_unchecked_t rdma_stat_rq_prod;
72204 +extern atomic_unchecked_t rdma_stat_sq_poll;
72205 +extern atomic_unchecked_t rdma_stat_sq_prod;
72206
72207 #define RPCRDMA_VERSION 1
72208
72209 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
72210 index ff374ab..7fd2ecb 100644
72211 --- a/include/linux/sunrpc/svcauth.h
72212 +++ b/include/linux/sunrpc/svcauth.h
72213 @@ -109,7 +109,7 @@ struct auth_ops {
72214 int (*release)(struct svc_rqst *rq);
72215 void (*domain_release)(struct auth_domain *);
72216 int (*set_client)(struct svc_rqst *rq);
72217 -};
72218 +} __do_const;
72219
72220 #define SVC_GARBAGE 1
72221 #define SVC_SYSERR 2
72222 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
72223 index a5ffd32..0935dea 100644
72224 --- a/include/linux/swiotlb.h
72225 +++ b/include/linux/swiotlb.h
72226 @@ -60,7 +60,8 @@ extern void
72227
72228 extern void
72229 swiotlb_free_coherent(struct device *hwdev, size_t size,
72230 - void *vaddr, dma_addr_t dma_handle);
72231 + void *vaddr, dma_addr_t dma_handle,
72232 + struct dma_attrs *attrs);
72233
72234 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
72235 unsigned long offset, size_t size,
72236 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
72237 index 4147d70..31a1791 100644
72238 --- a/include/linux/syscalls.h
72239 +++ b/include/linux/syscalls.h
72240 @@ -362,11 +362,11 @@ asmlinkage long sys_sync(void);
72241 asmlinkage long sys_fsync(unsigned int fd);
72242 asmlinkage long sys_fdatasync(unsigned int fd);
72243 asmlinkage long sys_bdflush(int func, long data);
72244 -asmlinkage long sys_mount(char __user *dev_name, char __user *dir_name,
72245 - char __user *type, unsigned long flags,
72246 +asmlinkage long sys_mount(const char __user *dev_name, const char __user *dir_name,
72247 + const char __user *type, unsigned long flags,
72248 void __user *data);
72249 -asmlinkage long sys_umount(char __user *name, int flags);
72250 -asmlinkage long sys_oldumount(char __user *name);
72251 +asmlinkage long sys_umount(const char __user *name, int flags);
72252 +asmlinkage long sys_oldumount(const char __user *name);
72253 asmlinkage long sys_truncate(const char __user *path, long length);
72254 asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
72255 asmlinkage long sys_stat(const char __user *filename,
72256 @@ -578,7 +578,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
72257 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
72258 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
72259 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
72260 - struct sockaddr __user *, int);
72261 + struct sockaddr __user *, int) __intentional_overflow(0);
72262 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
72263 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
72264 unsigned int vlen, unsigned flags);
72265 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
72266 index 27b3b0b..e093dd9 100644
72267 --- a/include/linux/syscore_ops.h
72268 +++ b/include/linux/syscore_ops.h
72269 @@ -16,7 +16,7 @@ struct syscore_ops {
72270 int (*suspend)(void);
72271 void (*resume)(void);
72272 void (*shutdown)(void);
72273 -};
72274 +} __do_const;
72275
72276 extern void register_syscore_ops(struct syscore_ops *ops);
72277 extern void unregister_syscore_ops(struct syscore_ops *ops);
72278 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
72279 index 14a8ff2..af52bad 100644
72280 --- a/include/linux/sysctl.h
72281 +++ b/include/linux/sysctl.h
72282 @@ -34,13 +34,13 @@ struct ctl_table_root;
72283 struct ctl_table_header;
72284 struct ctl_dir;
72285
72286 -typedef struct ctl_table ctl_table;
72287 -
72288 typedef int proc_handler (struct ctl_table *ctl, int write,
72289 void __user *buffer, size_t *lenp, loff_t *ppos);
72290
72291 extern int proc_dostring(struct ctl_table *, int,
72292 void __user *, size_t *, loff_t *);
72293 +extern int proc_dostring_modpriv(struct ctl_table *, int,
72294 + void __user *, size_t *, loff_t *);
72295 extern int proc_dointvec(struct ctl_table *, int,
72296 void __user *, size_t *, loff_t *);
72297 extern int proc_dointvec_minmax(struct ctl_table *, int,
72298 @@ -115,7 +115,9 @@ struct ctl_table
72299 struct ctl_table_poll *poll;
72300 void *extra1;
72301 void *extra2;
72302 -};
72303 +} __do_const;
72304 +typedef struct ctl_table __no_const ctl_table_no_const;
72305 +typedef struct ctl_table ctl_table;
72306
72307 struct ctl_node {
72308 struct rb_node node;
72309 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
72310 index e2cee22..3ddb921 100644
72311 --- a/include/linux/sysfs.h
72312 +++ b/include/linux/sysfs.h
72313 @@ -31,7 +31,8 @@ struct attribute {
72314 struct lock_class_key *key;
72315 struct lock_class_key skey;
72316 #endif
72317 -};
72318 +} __do_const;
72319 +typedef struct attribute __no_const attribute_no_const;
72320
72321 /**
72322 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
72323 @@ -59,8 +60,8 @@ struct attribute_group {
72324 umode_t (*is_visible)(struct kobject *,
72325 struct attribute *, int);
72326 struct attribute **attrs;
72327 -};
72328 -
72329 +} __do_const;
72330 +typedef struct attribute_group __no_const attribute_group_no_const;
72331
72332
72333 /**
72334 @@ -107,7 +108,8 @@ struct bin_attribute {
72335 char *, loff_t, size_t);
72336 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
72337 struct vm_area_struct *vma);
72338 -};
72339 +} __do_const;
72340 +typedef struct bin_attribute __no_const bin_attribute_no_const;
72341
72342 /**
72343 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
72344 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
72345 index 7faf933..9b85a0c 100644
72346 --- a/include/linux/sysrq.h
72347 +++ b/include/linux/sysrq.h
72348 @@ -16,6 +16,7 @@
72349
72350 #include <linux/errno.h>
72351 #include <linux/types.h>
72352 +#include <linux/compiler.h>
72353
72354 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
72355 #define SYSRQ_DEFAULT_ENABLE 1
72356 @@ -36,7 +37,7 @@ struct sysrq_key_op {
72357 char *help_msg;
72358 char *action_msg;
72359 int enable_mask;
72360 -};
72361 +} __do_const;
72362
72363 #ifdef CONFIG_MAGIC_SYSRQ
72364
72365 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
72366 index e7e0473..7989295 100644
72367 --- a/include/linux/thread_info.h
72368 +++ b/include/linux/thread_info.h
72369 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
72370 #error "no set_restore_sigmask() provided and default one won't work"
72371 #endif
72372
72373 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
72374 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
72375 +{
72376 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
72377 + if (!__builtin_constant_p(n))
72378 +#endif
72379 + __check_object_size(ptr, n, to_user);
72380 +}
72381 +
72382 #endif /* __KERNEL__ */
72383
72384 #endif /* _LINUX_THREAD_INFO_H */
72385 diff --git a/include/linux/tty.h b/include/linux/tty.h
72386 index 8780bd2..d1ae08b 100644
72387 --- a/include/linux/tty.h
72388 +++ b/include/linux/tty.h
72389 @@ -194,7 +194,7 @@ struct tty_port {
72390 const struct tty_port_operations *ops; /* Port operations */
72391 spinlock_t lock; /* Lock protecting tty field */
72392 int blocked_open; /* Waiting to open */
72393 - int count; /* Usage count */
72394 + atomic_t count; /* Usage count */
72395 wait_queue_head_t open_wait; /* Open waiters */
72396 wait_queue_head_t close_wait; /* Close waiters */
72397 wait_queue_head_t delta_msr_wait; /* Modem status change */
72398 @@ -550,7 +550,7 @@ extern int tty_port_open(struct tty_port *port,
72399 struct tty_struct *tty, struct file *filp);
72400 static inline int tty_port_users(struct tty_port *port)
72401 {
72402 - return port->count + port->blocked_open;
72403 + return atomic_read(&port->count) + port->blocked_open;
72404 }
72405
72406 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
72407 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
72408 index 756a609..b302dd6 100644
72409 --- a/include/linux/tty_driver.h
72410 +++ b/include/linux/tty_driver.h
72411 @@ -285,7 +285,7 @@ struct tty_operations {
72412 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
72413 #endif
72414 const struct file_operations *proc_fops;
72415 -};
72416 +} __do_const;
72417
72418 struct tty_driver {
72419 int magic; /* magic number for this structure */
72420 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
72421 index 58390c7..95e214c 100644
72422 --- a/include/linux/tty_ldisc.h
72423 +++ b/include/linux/tty_ldisc.h
72424 @@ -146,7 +146,7 @@ struct tty_ldisc_ops {
72425
72426 struct module *owner;
72427
72428 - int refcount;
72429 + atomic_t refcount;
72430 };
72431
72432 struct tty_ldisc {
72433 diff --git a/include/linux/types.h b/include/linux/types.h
72434 index 4d118ba..c3ee9bf 100644
72435 --- a/include/linux/types.h
72436 +++ b/include/linux/types.h
72437 @@ -176,10 +176,26 @@ typedef struct {
72438 int counter;
72439 } atomic_t;
72440
72441 +#ifdef CONFIG_PAX_REFCOUNT
72442 +typedef struct {
72443 + int counter;
72444 +} atomic_unchecked_t;
72445 +#else
72446 +typedef atomic_t atomic_unchecked_t;
72447 +#endif
72448 +
72449 #ifdef CONFIG_64BIT
72450 typedef struct {
72451 long counter;
72452 } atomic64_t;
72453 +
72454 +#ifdef CONFIG_PAX_REFCOUNT
72455 +typedef struct {
72456 + long counter;
72457 +} atomic64_unchecked_t;
72458 +#else
72459 +typedef atomic64_t atomic64_unchecked_t;
72460 +#endif
72461 #endif
72462
72463 struct list_head {
72464 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
72465 index 5ca0951..ab496a5 100644
72466 --- a/include/linux/uaccess.h
72467 +++ b/include/linux/uaccess.h
72468 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
72469 long ret; \
72470 mm_segment_t old_fs = get_fs(); \
72471 \
72472 - set_fs(KERNEL_DS); \
72473 pagefault_disable(); \
72474 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
72475 - pagefault_enable(); \
72476 + set_fs(KERNEL_DS); \
72477 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
72478 set_fs(old_fs); \
72479 + pagefault_enable(); \
72480 ret; \
72481 })
72482
72483 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
72484 index 8e522cbc..aa8572d 100644
72485 --- a/include/linux/uidgid.h
72486 +++ b/include/linux/uidgid.h
72487 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
72488
72489 #endif /* CONFIG_USER_NS */
72490
72491 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
72492 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
72493 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
72494 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
72495 +
72496 #endif /* _LINUX_UIDGID_H */
72497 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
72498 index 99c1b4d..562e6f3 100644
72499 --- a/include/linux/unaligned/access_ok.h
72500 +++ b/include/linux/unaligned/access_ok.h
72501 @@ -4,34 +4,34 @@
72502 #include <linux/kernel.h>
72503 #include <asm/byteorder.h>
72504
72505 -static inline u16 get_unaligned_le16(const void *p)
72506 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
72507 {
72508 - return le16_to_cpup((__le16 *)p);
72509 + return le16_to_cpup((const __le16 *)p);
72510 }
72511
72512 -static inline u32 get_unaligned_le32(const void *p)
72513 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
72514 {
72515 - return le32_to_cpup((__le32 *)p);
72516 + return le32_to_cpup((const __le32 *)p);
72517 }
72518
72519 -static inline u64 get_unaligned_le64(const void *p)
72520 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
72521 {
72522 - return le64_to_cpup((__le64 *)p);
72523 + return le64_to_cpup((const __le64 *)p);
72524 }
72525
72526 -static inline u16 get_unaligned_be16(const void *p)
72527 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
72528 {
72529 - return be16_to_cpup((__be16 *)p);
72530 + return be16_to_cpup((const __be16 *)p);
72531 }
72532
72533 -static inline u32 get_unaligned_be32(const void *p)
72534 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
72535 {
72536 - return be32_to_cpup((__be32 *)p);
72537 + return be32_to_cpup((const __be32 *)p);
72538 }
72539
72540 -static inline u64 get_unaligned_be64(const void *p)
72541 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
72542 {
72543 - return be64_to_cpup((__be64 *)p);
72544 + return be64_to_cpup((const __be64 *)p);
72545 }
72546
72547 static inline void put_unaligned_le16(u16 val, void *p)
72548 diff --git a/include/linux/usb.h b/include/linux/usb.h
72549 index a0bee5a..5533a52 100644
72550 --- a/include/linux/usb.h
72551 +++ b/include/linux/usb.h
72552 @@ -552,7 +552,7 @@ struct usb_device {
72553 int maxchild;
72554
72555 u32 quirks;
72556 - atomic_t urbnum;
72557 + atomic_unchecked_t urbnum;
72558
72559 unsigned long active_duration;
72560
72561 @@ -1607,7 +1607,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
72562
72563 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
72564 __u8 request, __u8 requesttype, __u16 value, __u16 index,
72565 - void *data, __u16 size, int timeout);
72566 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
72567 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
72568 void *data, int len, int *actual_length, int timeout);
72569 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
72570 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
72571 index e452ba6..78f8e80 100644
72572 --- a/include/linux/usb/renesas_usbhs.h
72573 +++ b/include/linux/usb/renesas_usbhs.h
72574 @@ -39,7 +39,7 @@ enum {
72575 */
72576 struct renesas_usbhs_driver_callback {
72577 int (*notify_hotplug)(struct platform_device *pdev);
72578 -};
72579 +} __no_const;
72580
72581 /*
72582 * callback functions for platform
72583 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
72584 index 6f8fbcf..8259001 100644
72585 --- a/include/linux/vermagic.h
72586 +++ b/include/linux/vermagic.h
72587 @@ -25,9 +25,35 @@
72588 #define MODULE_ARCH_VERMAGIC ""
72589 #endif
72590
72591 +#ifdef CONFIG_PAX_REFCOUNT
72592 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
72593 +#else
72594 +#define MODULE_PAX_REFCOUNT ""
72595 +#endif
72596 +
72597 +#ifdef CONSTIFY_PLUGIN
72598 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
72599 +#else
72600 +#define MODULE_CONSTIFY_PLUGIN ""
72601 +#endif
72602 +
72603 +#ifdef STACKLEAK_PLUGIN
72604 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
72605 +#else
72606 +#define MODULE_STACKLEAK_PLUGIN ""
72607 +#endif
72608 +
72609 +#ifdef CONFIG_GRKERNSEC
72610 +#define MODULE_GRSEC "GRSEC "
72611 +#else
72612 +#define MODULE_GRSEC ""
72613 +#endif
72614 +
72615 #define VERMAGIC_STRING \
72616 UTS_RELEASE " " \
72617 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
72618 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
72619 - MODULE_ARCH_VERMAGIC
72620 + MODULE_ARCH_VERMAGIC \
72621 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
72622 + MODULE_GRSEC
72623
72624 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
72625 index 7d5773a..541c01c 100644
72626 --- a/include/linux/vmalloc.h
72627 +++ b/include/linux/vmalloc.h
72628 @@ -16,6 +16,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
72629 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
72630 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
72631 #define VM_UNLIST 0x00000020 /* vm_struct is not listed in vmlist */
72632 +
72633 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
72634 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
72635 +#endif
72636 +
72637 /* bits [20..32] reserved for arch specific ioremap internals */
72638
72639 /*
72640 @@ -75,7 +80,7 @@ extern void *vmalloc_32_user(unsigned long size);
72641 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
72642 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
72643 unsigned long start, unsigned long end, gfp_t gfp_mask,
72644 - pgprot_t prot, int node, const void *caller);
72645 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
72646 extern void vfree(const void *addr);
72647
72648 extern void *vmap(struct page **pages, unsigned int count,
72649 @@ -137,8 +142,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
72650 extern void free_vm_area(struct vm_struct *area);
72651
72652 /* for /dev/kmem */
72653 -extern long vread(char *buf, char *addr, unsigned long count);
72654 -extern long vwrite(char *buf, char *addr, unsigned long count);
72655 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
72656 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
72657
72658 /*
72659 * Internals. Dont't use..
72660 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
72661 index c586679..f06b389 100644
72662 --- a/include/linux/vmstat.h
72663 +++ b/include/linux/vmstat.h
72664 @@ -90,18 +90,18 @@ static inline void vm_events_fold_cpu(int cpu)
72665 /*
72666 * Zone based page accounting with per cpu differentials.
72667 */
72668 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
72669 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
72670
72671 static inline void zone_page_state_add(long x, struct zone *zone,
72672 enum zone_stat_item item)
72673 {
72674 - atomic_long_add(x, &zone->vm_stat[item]);
72675 - atomic_long_add(x, &vm_stat[item]);
72676 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
72677 + atomic_long_add_unchecked(x, &vm_stat[item]);
72678 }
72679
72680 static inline unsigned long global_page_state(enum zone_stat_item item)
72681 {
72682 - long x = atomic_long_read(&vm_stat[item]);
72683 + long x = atomic_long_read_unchecked(&vm_stat[item]);
72684 #ifdef CONFIG_SMP
72685 if (x < 0)
72686 x = 0;
72687 @@ -112,7 +112,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
72688 static inline unsigned long zone_page_state(struct zone *zone,
72689 enum zone_stat_item item)
72690 {
72691 - long x = atomic_long_read(&zone->vm_stat[item]);
72692 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
72693 #ifdef CONFIG_SMP
72694 if (x < 0)
72695 x = 0;
72696 @@ -129,7 +129,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
72697 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
72698 enum zone_stat_item item)
72699 {
72700 - long x = atomic_long_read(&zone->vm_stat[item]);
72701 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
72702
72703 #ifdef CONFIG_SMP
72704 int cpu;
72705 @@ -221,8 +221,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
72706
72707 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
72708 {
72709 - atomic_long_inc(&zone->vm_stat[item]);
72710 - atomic_long_inc(&vm_stat[item]);
72711 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
72712 + atomic_long_inc_unchecked(&vm_stat[item]);
72713 }
72714
72715 static inline void __inc_zone_page_state(struct page *page,
72716 @@ -233,8 +233,8 @@ static inline void __inc_zone_page_state(struct page *page,
72717
72718 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
72719 {
72720 - atomic_long_dec(&zone->vm_stat[item]);
72721 - atomic_long_dec(&vm_stat[item]);
72722 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
72723 + atomic_long_dec_unchecked(&vm_stat[item]);
72724 }
72725
72726 static inline void __dec_zone_page_state(struct page *page,
72727 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
72728 index fdbafc6..49dfe4f 100644
72729 --- a/include/linux/xattr.h
72730 +++ b/include/linux/xattr.h
72731 @@ -28,7 +28,7 @@ struct xattr_handler {
72732 size_t size, int handler_flags);
72733 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
72734 size_t size, int flags, int handler_flags);
72735 -};
72736 +} __do_const;
72737
72738 struct xattr {
72739 char *name;
72740 @@ -37,6 +37,9 @@ struct xattr {
72741 };
72742
72743 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
72744 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
72745 +ssize_t pax_getxattr(struct dentry *, void *, size_t);
72746 +#endif
72747 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
72748 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
72749 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
72750 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
72751 index 9c5a6b4..09c9438 100644
72752 --- a/include/linux/zlib.h
72753 +++ b/include/linux/zlib.h
72754 @@ -31,6 +31,7 @@
72755 #define _ZLIB_H
72756
72757 #include <linux/zconf.h>
72758 +#include <linux/compiler.h>
72759
72760 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
72761 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
72762 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
72763
72764 /* basic functions */
72765
72766 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
72767 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
72768 /*
72769 Returns the number of bytes that needs to be allocated for a per-
72770 stream workspace with the specified parameters. A pointer to this
72771 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
72772 index 95d1c91..6798cca 100644
72773 --- a/include/media/v4l2-dev.h
72774 +++ b/include/media/v4l2-dev.h
72775 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
72776 int (*mmap) (struct file *, struct vm_area_struct *);
72777 int (*open) (struct file *);
72778 int (*release) (struct file *);
72779 -};
72780 +} __do_const;
72781
72782 /*
72783 * Newer version of video_device, handled by videodev2.c
72784 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
72785 index adcbb20..62c2559 100644
72786 --- a/include/net/9p/transport.h
72787 +++ b/include/net/9p/transport.h
72788 @@ -57,7 +57,7 @@ struct p9_trans_module {
72789 int (*cancel) (struct p9_client *, struct p9_req_t *req);
72790 int (*zc_request)(struct p9_client *, struct p9_req_t *,
72791 char *, char *, int , int, int, int);
72792 -};
72793 +} __do_const;
72794
72795 void v9fs_register_trans(struct p9_trans_module *m);
72796 void v9fs_unregister_trans(struct p9_trans_module *m);
72797 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
72798 index fb94cf1..7c0c987 100644
72799 --- a/include/net/bluetooth/l2cap.h
72800 +++ b/include/net/bluetooth/l2cap.h
72801 @@ -551,7 +551,7 @@ struct l2cap_ops {
72802 void (*defer) (struct l2cap_chan *chan);
72803 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
72804 unsigned long len, int nb);
72805 -};
72806 +} __do_const;
72807
72808 struct l2cap_conn {
72809 struct hci_conn *hcon;
72810 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
72811 index f2ae33d..c457cf0 100644
72812 --- a/include/net/caif/cfctrl.h
72813 +++ b/include/net/caif/cfctrl.h
72814 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
72815 void (*radioset_rsp)(void);
72816 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
72817 struct cflayer *client_layer);
72818 -};
72819 +} __no_const;
72820
72821 /* Link Setup Parameters for CAIF-Links. */
72822 struct cfctrl_link_param {
72823 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
72824 struct cfctrl {
72825 struct cfsrvl serv;
72826 struct cfctrl_rsp res;
72827 - atomic_t req_seq_no;
72828 - atomic_t rsp_seq_no;
72829 + atomic_unchecked_t req_seq_no;
72830 + atomic_unchecked_t rsp_seq_no;
72831 struct list_head list;
72832 /* Protects from simultaneous access to first_req list */
72833 spinlock_t info_list_lock;
72834 diff --git a/include/net/flow.h b/include/net/flow.h
72835 index 628e11b..4c475df 100644
72836 --- a/include/net/flow.h
72837 +++ b/include/net/flow.h
72838 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
72839
72840 extern void flow_cache_flush(void);
72841 extern void flow_cache_flush_deferred(void);
72842 -extern atomic_t flow_cache_genid;
72843 +extern atomic_unchecked_t flow_cache_genid;
72844
72845 #endif
72846 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
72847 index 93024a4..eeb6b6e 100644
72848 --- a/include/net/genetlink.h
72849 +++ b/include/net/genetlink.h
72850 @@ -119,7 +119,7 @@ struct genl_ops {
72851 struct netlink_callback *cb);
72852 int (*done)(struct netlink_callback *cb);
72853 struct list_head ops_list;
72854 -};
72855 +} __do_const;
72856
72857 extern int genl_register_family(struct genl_family *family);
72858 extern int genl_register_family_with_ops(struct genl_family *family,
72859 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
72860 index 734d9b5..48a9a4b 100644
72861 --- a/include/net/gro_cells.h
72862 +++ b/include/net/gro_cells.h
72863 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
72864 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
72865
72866 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
72867 - atomic_long_inc(&dev->rx_dropped);
72868 + atomic_long_inc_unchecked(&dev->rx_dropped);
72869 kfree_skb(skb);
72870 return;
72871 }
72872 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
72873 index de2c785..0588a6b 100644
72874 --- a/include/net/inet_connection_sock.h
72875 +++ b/include/net/inet_connection_sock.h
72876 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
72877 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
72878 int (*bind_conflict)(const struct sock *sk,
72879 const struct inet_bind_bucket *tb, bool relax);
72880 -};
72881 +} __do_const;
72882
72883 /** inet_connection_sock - INET connection oriented sock
72884 *
72885 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
72886 index 53f464d..ba76aaa 100644
72887 --- a/include/net/inetpeer.h
72888 +++ b/include/net/inetpeer.h
72889 @@ -47,8 +47,8 @@ struct inet_peer {
72890 */
72891 union {
72892 struct {
72893 - atomic_t rid; /* Frag reception counter */
72894 - atomic_t ip_id_count; /* IP ID for the next packet */
72895 + atomic_unchecked_t rid; /* Frag reception counter */
72896 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
72897 };
72898 struct rcu_head rcu;
72899 struct inet_peer *gc_next;
72900 @@ -182,11 +182,11 @@ static inline int inet_getid(struct inet_peer *p, int more)
72901 more++;
72902 inet_peer_refcheck(p);
72903 do {
72904 - old = atomic_read(&p->ip_id_count);
72905 + old = atomic_read_unchecked(&p->ip_id_count);
72906 new = old + more;
72907 if (!new)
72908 new = 1;
72909 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
72910 + } while (atomic_cmpxchg_unchecked(&p->ip_id_count, old, new) != old);
72911 return new;
72912 }
72913
72914 diff --git a/include/net/ip.h b/include/net/ip.h
72915 index a68f838..74518ab 100644
72916 --- a/include/net/ip.h
72917 +++ b/include/net/ip.h
72918 @@ -202,7 +202,7 @@ extern struct local_ports {
72919 } sysctl_local_ports;
72920 extern void inet_get_local_port_range(int *low, int *high);
72921
72922 -extern unsigned long *sysctl_local_reserved_ports;
72923 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
72924 static inline int inet_is_reserved_local_port(int port)
72925 {
72926 return test_bit(port, sysctl_local_reserved_ports);
72927 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
72928 index e49db91..76a81de 100644
72929 --- a/include/net/ip_fib.h
72930 +++ b/include/net/ip_fib.h
72931 @@ -167,7 +167,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
72932
72933 #define FIB_RES_SADDR(net, res) \
72934 ((FIB_RES_NH(res).nh_saddr_genid == \
72935 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
72936 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
72937 FIB_RES_NH(res).nh_saddr : \
72938 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
72939 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
72940 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
72941 index 4c062cc..3562c31 100644
72942 --- a/include/net/ip_vs.h
72943 +++ b/include/net/ip_vs.h
72944 @@ -612,7 +612,7 @@ struct ip_vs_conn {
72945 struct ip_vs_conn *control; /* Master control connection */
72946 atomic_t n_control; /* Number of controlled ones */
72947 struct ip_vs_dest *dest; /* real server */
72948 - atomic_t in_pkts; /* incoming packet counter */
72949 + atomic_unchecked_t in_pkts; /* incoming packet counter */
72950
72951 /* packet transmitter for different forwarding methods. If it
72952 mangles the packet, it must return NF_DROP or better NF_STOLEN,
72953 @@ -761,7 +761,7 @@ struct ip_vs_dest {
72954 __be16 port; /* port number of the server */
72955 union nf_inet_addr addr; /* IP address of the server */
72956 volatile unsigned int flags; /* dest status flags */
72957 - atomic_t conn_flags; /* flags to copy to conn */
72958 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
72959 atomic_t weight; /* server weight */
72960
72961 atomic_t refcnt; /* reference counter */
72962 @@ -1013,11 +1013,11 @@ struct netns_ipvs {
72963 /* ip_vs_lblc */
72964 int sysctl_lblc_expiration;
72965 struct ctl_table_header *lblc_ctl_header;
72966 - struct ctl_table *lblc_ctl_table;
72967 + ctl_table_no_const *lblc_ctl_table;
72968 /* ip_vs_lblcr */
72969 int sysctl_lblcr_expiration;
72970 struct ctl_table_header *lblcr_ctl_header;
72971 - struct ctl_table *lblcr_ctl_table;
72972 + ctl_table_no_const *lblcr_ctl_table;
72973 /* ip_vs_est */
72974 struct list_head est_list; /* estimator list */
72975 spinlock_t est_lock;
72976 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
72977 index 80ffde3..968b0f4 100644
72978 --- a/include/net/irda/ircomm_tty.h
72979 +++ b/include/net/irda/ircomm_tty.h
72980 @@ -35,6 +35,7 @@
72981 #include <linux/termios.h>
72982 #include <linux/timer.h>
72983 #include <linux/tty.h> /* struct tty_struct */
72984 +#include <asm/local.h>
72985
72986 #include <net/irda/irias_object.h>
72987 #include <net/irda/ircomm_core.h>
72988 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
72989 index 714cc9a..ea05f3e 100644
72990 --- a/include/net/iucv/af_iucv.h
72991 +++ b/include/net/iucv/af_iucv.h
72992 @@ -149,7 +149,7 @@ struct iucv_skb_cb {
72993 struct iucv_sock_list {
72994 struct hlist_head head;
72995 rwlock_t lock;
72996 - atomic_t autobind_name;
72997 + atomic_unchecked_t autobind_name;
72998 };
72999
73000 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
73001 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
73002 index df83f69..9b640b8 100644
73003 --- a/include/net/llc_c_ac.h
73004 +++ b/include/net/llc_c_ac.h
73005 @@ -87,7 +87,7 @@
73006 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
73007 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
73008
73009 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
73010 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
73011
73012 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
73013 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
73014 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
73015 index 6ca3113..f8026dd 100644
73016 --- a/include/net/llc_c_ev.h
73017 +++ b/include/net/llc_c_ev.h
73018 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
73019 return (struct llc_conn_state_ev *)skb->cb;
73020 }
73021
73022 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
73023 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
73024 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
73025 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
73026
73027 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
73028 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
73029 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
73030 index 0e79cfb..f46db31 100644
73031 --- a/include/net/llc_c_st.h
73032 +++ b/include/net/llc_c_st.h
73033 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
73034 u8 next_state;
73035 llc_conn_ev_qfyr_t *ev_qualifiers;
73036 llc_conn_action_t *ev_actions;
73037 -};
73038 +} __do_const;
73039
73040 struct llc_conn_state {
73041 u8 current_state;
73042 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
73043 index 37a3bbd..55a4241 100644
73044 --- a/include/net/llc_s_ac.h
73045 +++ b/include/net/llc_s_ac.h
73046 @@ -23,7 +23,7 @@
73047 #define SAP_ACT_TEST_IND 9
73048
73049 /* All action functions must look like this */
73050 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
73051 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
73052
73053 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
73054 struct sk_buff *skb);
73055 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
73056 index 567c681..cd73ac0 100644
73057 --- a/include/net/llc_s_st.h
73058 +++ b/include/net/llc_s_st.h
73059 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
73060 llc_sap_ev_t ev;
73061 u8 next_state;
73062 llc_sap_action_t *ev_actions;
73063 -};
73064 +} __do_const;
73065
73066 struct llc_sap_state {
73067 u8 curr_state;
73068 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
73069 index 885898a..cdace34 100644
73070 --- a/include/net/mac80211.h
73071 +++ b/include/net/mac80211.h
73072 @@ -4205,7 +4205,7 @@ struct rate_control_ops {
73073 void (*add_sta_debugfs)(void *priv, void *priv_sta,
73074 struct dentry *dir);
73075 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
73076 -};
73077 +} __do_const;
73078
73079 static inline int rate_supported(struct ieee80211_sta *sta,
73080 enum ieee80211_band band,
73081 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
73082 index 7e748ad..5c6229b 100644
73083 --- a/include/net/neighbour.h
73084 +++ b/include/net/neighbour.h
73085 @@ -123,7 +123,7 @@ struct neigh_ops {
73086 void (*error_report)(struct neighbour *, struct sk_buff *);
73087 int (*output)(struct neighbour *, struct sk_buff *);
73088 int (*connected_output)(struct neighbour *, struct sk_buff *);
73089 -};
73090 +} __do_const;
73091
73092 struct pneigh_entry {
73093 struct pneigh_entry *next;
73094 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
73095 index b176978..ea169f4 100644
73096 --- a/include/net/net_namespace.h
73097 +++ b/include/net/net_namespace.h
73098 @@ -117,7 +117,7 @@ struct net {
73099 #endif
73100 struct netns_ipvs *ipvs;
73101 struct sock *diag_nlsk;
73102 - atomic_t rt_genid;
73103 + atomic_unchecked_t rt_genid;
73104 };
73105
73106 /*
73107 @@ -274,7 +274,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
73108 #define __net_init __init
73109 #define __net_exit __exit_refok
73110 #define __net_initdata __initdata
73111 +#ifdef CONSTIFY_PLUGIN
73112 #define __net_initconst __initconst
73113 +#else
73114 +#define __net_initconst __initdata
73115 +#endif
73116 #endif
73117
73118 struct pernet_operations {
73119 @@ -284,7 +288,7 @@ struct pernet_operations {
73120 void (*exit_batch)(struct list_head *net_exit_list);
73121 int *id;
73122 size_t size;
73123 -};
73124 +} __do_const;
73125
73126 /*
73127 * Use these carefully. If you implement a network device and it
73128 @@ -332,12 +336,12 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
73129
73130 static inline int rt_genid(struct net *net)
73131 {
73132 - return atomic_read(&net->rt_genid);
73133 + return atomic_read_unchecked(&net->rt_genid);
73134 }
73135
73136 static inline void rt_genid_bump(struct net *net)
73137 {
73138 - atomic_inc(&net->rt_genid);
73139 + atomic_inc_unchecked(&net->rt_genid);
73140 }
73141
73142 #endif /* __NET_NET_NAMESPACE_H */
73143 diff --git a/include/net/netdma.h b/include/net/netdma.h
73144 index 8ba8ce2..99b7fff 100644
73145 --- a/include/net/netdma.h
73146 +++ b/include/net/netdma.h
73147 @@ -24,7 +24,7 @@
73148 #include <linux/dmaengine.h>
73149 #include <linux/skbuff.h>
73150
73151 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
73152 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
73153 struct sk_buff *skb, int offset, struct iovec *to,
73154 size_t len, struct dma_pinned_list *pinned_list);
73155
73156 diff --git a/include/net/netlink.h b/include/net/netlink.h
73157 index 9690b0f..87aded7 100644
73158 --- a/include/net/netlink.h
73159 +++ b/include/net/netlink.h
73160 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
73161 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
73162 {
73163 if (mark)
73164 - skb_trim(skb, (unsigned char *) mark - skb->data);
73165 + skb_trim(skb, (const unsigned char *) mark - skb->data);
73166 }
73167
73168 /**
73169 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
73170 index c9c0c53..53f24c3 100644
73171 --- a/include/net/netns/conntrack.h
73172 +++ b/include/net/netns/conntrack.h
73173 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
73174 struct nf_proto_net {
73175 #ifdef CONFIG_SYSCTL
73176 struct ctl_table_header *ctl_table_header;
73177 - struct ctl_table *ctl_table;
73178 + ctl_table_no_const *ctl_table;
73179 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
73180 struct ctl_table_header *ctl_compat_header;
73181 - struct ctl_table *ctl_compat_table;
73182 + ctl_table_no_const *ctl_compat_table;
73183 #endif
73184 #endif
73185 unsigned int users;
73186 @@ -58,7 +58,7 @@ struct nf_ip_net {
73187 struct nf_icmp_net icmpv6;
73188 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
73189 struct ctl_table_header *ctl_table_header;
73190 - struct ctl_table *ctl_table;
73191 + ctl_table_no_const *ctl_table;
73192 #endif
73193 };
73194
73195 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
73196 index 2ba9de8..47bd6c7 100644
73197 --- a/include/net/netns/ipv4.h
73198 +++ b/include/net/netns/ipv4.h
73199 @@ -67,7 +67,7 @@ struct netns_ipv4 {
73200 kgid_t sysctl_ping_group_range[2];
73201 long sysctl_tcp_mem[3];
73202
73203 - atomic_t dev_addr_genid;
73204 + atomic_unchecked_t dev_addr_genid;
73205
73206 #ifdef CONFIG_IP_MROUTE
73207 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
73208 diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
73209 index 005e2c2..023d340 100644
73210 --- a/include/net/netns/ipv6.h
73211 +++ b/include/net/netns/ipv6.h
73212 @@ -71,7 +71,7 @@ struct netns_ipv6 {
73213 struct fib_rules_ops *mr6_rules_ops;
73214 #endif
73215 #endif
73216 - atomic_t dev_addr_genid;
73217 + atomic_unchecked_t dev_addr_genid;
73218 };
73219
73220 #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
73221 diff --git a/include/net/protocol.h b/include/net/protocol.h
73222 index 047c047..b9dad15 100644
73223 --- a/include/net/protocol.h
73224 +++ b/include/net/protocol.h
73225 @@ -44,7 +44,7 @@ struct net_protocol {
73226 void (*err_handler)(struct sk_buff *skb, u32 info);
73227 unsigned int no_policy:1,
73228 netns_ok:1;
73229 -};
73230 +} __do_const;
73231
73232 #if IS_ENABLED(CONFIG_IPV6)
73233 struct inet6_protocol {
73234 @@ -57,7 +57,7 @@ struct inet6_protocol {
73235 u8 type, u8 code, int offset,
73236 __be32 info);
73237 unsigned int flags; /* INET6_PROTO_xxx */
73238 -};
73239 +} __do_const;
73240
73241 #define INET6_PROTO_NOPOLICY 0x1
73242 #define INET6_PROTO_FINAL 0x2
73243 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
73244 index 7026648..584cc8c 100644
73245 --- a/include/net/rtnetlink.h
73246 +++ b/include/net/rtnetlink.h
73247 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
73248 const struct net_device *dev);
73249 unsigned int (*get_num_tx_queues)(void);
73250 unsigned int (*get_num_rx_queues)(void);
73251 -};
73252 +} __do_const;
73253
73254 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
73255 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
73256 diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
73257 index cd89510..d67810f 100644
73258 --- a/include/net/sctp/sctp.h
73259 +++ b/include/net/sctp/sctp.h
73260 @@ -330,9 +330,9 @@ do { \
73261
73262 #else /* SCTP_DEBUG */
73263
73264 -#define SCTP_DEBUG_PRINTK(whatever...)
73265 -#define SCTP_DEBUG_PRINTK_CONT(fmt, args...)
73266 -#define SCTP_DEBUG_PRINTK_IPADDR(whatever...)
73267 +#define SCTP_DEBUG_PRINTK(whatever...) do {} while (0)
73268 +#define SCTP_DEBUG_PRINTK_CONT(fmt, args...) do {} while (0)
73269 +#define SCTP_DEBUG_PRINTK_IPADDR(whatever...) do {} while (0)
73270 #define SCTP_ENABLE_DEBUG
73271 #define SCTP_DISABLE_DEBUG
73272 #define SCTP_ASSERT(expr, str, func)
73273 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
73274 index 2a82d13..62a31c2 100644
73275 --- a/include/net/sctp/sm.h
73276 +++ b/include/net/sctp/sm.h
73277 @@ -87,7 +87,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
73278 typedef struct {
73279 sctp_state_fn_t *fn;
73280 const char *name;
73281 -} sctp_sm_table_entry_t;
73282 +} __do_const sctp_sm_table_entry_t;
73283
73284 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
73285 * currently in use.
73286 @@ -299,7 +299,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
73287 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
73288
73289 /* Extern declarations for major data structures. */
73290 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
73291 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
73292
73293
73294 /* Get the size of a DATA chunk payload. */
73295 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
73296 index 1bd4c41..9250b5b 100644
73297 --- a/include/net/sctp/structs.h
73298 +++ b/include/net/sctp/structs.h
73299 @@ -516,7 +516,7 @@ struct sctp_pf {
73300 struct sctp_association *asoc);
73301 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
73302 struct sctp_af *af;
73303 -};
73304 +} __do_const;
73305
73306
73307 /* Structure to track chunk fragments that have been acked, but peer
73308 diff --git a/include/net/sock.h b/include/net/sock.h
73309 index 66772cf..25bc45b 100644
73310 --- a/include/net/sock.h
73311 +++ b/include/net/sock.h
73312 @@ -325,7 +325,7 @@ struct sock {
73313 #ifdef CONFIG_RPS
73314 __u32 sk_rxhash;
73315 #endif
73316 - atomic_t sk_drops;
73317 + atomic_unchecked_t sk_drops;
73318 int sk_rcvbuf;
73319
73320 struct sk_filter __rcu *sk_filter;
73321 @@ -1797,7 +1797,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
73322 }
73323
73324 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
73325 - char __user *from, char *to,
73326 + char __user *from, unsigned char *to,
73327 int copy, int offset)
73328 {
73329 if (skb->ip_summed == CHECKSUM_NONE) {
73330 @@ -2056,7 +2056,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
73331 }
73332 }
73333
73334 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
73335 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
73336
73337 /**
73338 * sk_page_frag - return an appropriate page_frag
73339 diff --git a/include/net/tcp.h b/include/net/tcp.h
73340 index 5bba80f..8520a82 100644
73341 --- a/include/net/tcp.h
73342 +++ b/include/net/tcp.h
73343 @@ -524,7 +524,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
73344 extern void tcp_xmit_retransmit_queue(struct sock *);
73345 extern void tcp_simple_retransmit(struct sock *);
73346 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
73347 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
73348 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
73349
73350 extern void tcp_send_probe0(struct sock *);
73351 extern void tcp_send_partial(struct sock *);
73352 @@ -697,8 +697,8 @@ struct tcp_skb_cb {
73353 struct inet6_skb_parm h6;
73354 #endif
73355 } header; /* For incoming frames */
73356 - __u32 seq; /* Starting sequence number */
73357 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
73358 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
73359 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
73360 __u32 when; /* used to compute rtt's */
73361 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
73362
73363 @@ -712,7 +712,7 @@ struct tcp_skb_cb {
73364
73365 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
73366 /* 1 byte hole */
73367 - __u32 ack_seq; /* Sequence number ACK'd */
73368 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
73369 };
73370
73371 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
73372 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
73373 index 94ce082..62b278d 100644
73374 --- a/include/net/xfrm.h
73375 +++ b/include/net/xfrm.h
73376 @@ -305,7 +305,7 @@ struct xfrm_policy_afinfo {
73377 struct net_device *dev,
73378 const struct flowi *fl);
73379 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
73380 -};
73381 +} __do_const;
73382
73383 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
73384 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
73385 @@ -341,7 +341,7 @@ struct xfrm_state_afinfo {
73386 struct sk_buff *skb);
73387 int (*transport_finish)(struct sk_buff *skb,
73388 int async);
73389 -};
73390 +} __do_const;
73391
73392 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
73393 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
73394 @@ -424,7 +424,7 @@ struct xfrm_mode {
73395 struct module *owner;
73396 unsigned int encap;
73397 int flags;
73398 -};
73399 +} __do_const;
73400
73401 /* Flags for xfrm_mode. */
73402 enum {
73403 @@ -521,7 +521,7 @@ struct xfrm_policy {
73404 struct timer_list timer;
73405
73406 struct flow_cache_object flo;
73407 - atomic_t genid;
73408 + atomic_unchecked_t genid;
73409 u32 priority;
73410 u32 index;
73411 struct xfrm_mark mark;
73412 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
73413 index 1a046b1..ee0bef0 100644
73414 --- a/include/rdma/iw_cm.h
73415 +++ b/include/rdma/iw_cm.h
73416 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
73417 int backlog);
73418
73419 int (*destroy_listen)(struct iw_cm_id *cm_id);
73420 -};
73421 +} __no_const;
73422
73423 /**
73424 * iw_create_cm_id - Create an IW CM identifier.
73425 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
73426 index e1379b4..67eafbe 100644
73427 --- a/include/scsi/libfc.h
73428 +++ b/include/scsi/libfc.h
73429 @@ -762,6 +762,7 @@ struct libfc_function_template {
73430 */
73431 void (*disc_stop_final) (struct fc_lport *);
73432 };
73433 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
73434
73435 /**
73436 * struct fc_disc - Discovery context
73437 @@ -866,7 +867,7 @@ struct fc_lport {
73438 struct fc_vport *vport;
73439
73440 /* Operational Information */
73441 - struct libfc_function_template tt;
73442 + libfc_function_template_no_const tt;
73443 u8 link_up;
73444 u8 qfull;
73445 enum fc_lport_state state;
73446 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
73447 index cc64587..608f523 100644
73448 --- a/include/scsi/scsi_device.h
73449 +++ b/include/scsi/scsi_device.h
73450 @@ -171,9 +171,9 @@ struct scsi_device {
73451 unsigned int max_device_blocked; /* what device_blocked counts down from */
73452 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
73453
73454 - atomic_t iorequest_cnt;
73455 - atomic_t iodone_cnt;
73456 - atomic_t ioerr_cnt;
73457 + atomic_unchecked_t iorequest_cnt;
73458 + atomic_unchecked_t iodone_cnt;
73459 + atomic_unchecked_t ioerr_cnt;
73460
73461 struct device sdev_gendev,
73462 sdev_dev;
73463 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
73464 index b797e8f..8e2c3aa 100644
73465 --- a/include/scsi/scsi_transport_fc.h
73466 +++ b/include/scsi/scsi_transport_fc.h
73467 @@ -751,7 +751,8 @@ struct fc_function_template {
73468 unsigned long show_host_system_hostname:1;
73469
73470 unsigned long disable_target_scan:1;
73471 -};
73472 +} __do_const;
73473 +typedef struct fc_function_template __no_const fc_function_template_no_const;
73474
73475
73476 /**
73477 diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
73478 index 9031a26..750d592 100644
73479 --- a/include/sound/compress_driver.h
73480 +++ b/include/sound/compress_driver.h
73481 @@ -128,7 +128,7 @@ struct snd_compr_ops {
73482 struct snd_compr_caps *caps);
73483 int (*get_codec_caps) (struct snd_compr_stream *stream,
73484 struct snd_compr_codec_caps *codec);
73485 -};
73486 +} __no_const;
73487
73488 /**
73489 * struct snd_compr: Compressed device
73490 diff --git a/include/sound/soc.h b/include/sound/soc.h
73491 index 85c1522..f44bad1 100644
73492 --- a/include/sound/soc.h
73493 +++ b/include/sound/soc.h
73494 @@ -781,7 +781,7 @@ struct snd_soc_codec_driver {
73495 /* probe ordering - for components with runtime dependencies */
73496 int probe_order;
73497 int remove_order;
73498 -};
73499 +} __do_const;
73500
73501 /* SoC platform interface */
73502 struct snd_soc_platform_driver {
73503 @@ -827,7 +827,7 @@ struct snd_soc_platform_driver {
73504 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
73505 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
73506 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
73507 -};
73508 +} __do_const;
73509
73510 struct snd_soc_platform {
73511 const char *name;
73512 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
73513 index 4ea4f98..a63629b 100644
73514 --- a/include/target/target_core_base.h
73515 +++ b/include/target/target_core_base.h
73516 @@ -653,7 +653,7 @@ struct se_device {
73517 spinlock_t stats_lock;
73518 /* Active commands on this virtual SE device */
73519 atomic_t simple_cmds;
73520 - atomic_t dev_ordered_id;
73521 + atomic_unchecked_t dev_ordered_id;
73522 atomic_t dev_ordered_sync;
73523 atomic_t dev_qf_count;
73524 int export_count;
73525 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
73526 new file mode 100644
73527 index 0000000..fb634b7
73528 --- /dev/null
73529 +++ b/include/trace/events/fs.h
73530 @@ -0,0 +1,53 @@
73531 +#undef TRACE_SYSTEM
73532 +#define TRACE_SYSTEM fs
73533 +
73534 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
73535 +#define _TRACE_FS_H
73536 +
73537 +#include <linux/fs.h>
73538 +#include <linux/tracepoint.h>
73539 +
73540 +TRACE_EVENT(do_sys_open,
73541 +
73542 + TP_PROTO(const char *filename, int flags, int mode),
73543 +
73544 + TP_ARGS(filename, flags, mode),
73545 +
73546 + TP_STRUCT__entry(
73547 + __string( filename, filename )
73548 + __field( int, flags )
73549 + __field( int, mode )
73550 + ),
73551 +
73552 + TP_fast_assign(
73553 + __assign_str(filename, filename);
73554 + __entry->flags = flags;
73555 + __entry->mode = mode;
73556 + ),
73557 +
73558 + TP_printk("\"%s\" %x %o",
73559 + __get_str(filename), __entry->flags, __entry->mode)
73560 +);
73561 +
73562 +TRACE_EVENT(open_exec,
73563 +
73564 + TP_PROTO(const char *filename),
73565 +
73566 + TP_ARGS(filename),
73567 +
73568 + TP_STRUCT__entry(
73569 + __string( filename, filename )
73570 + ),
73571 +
73572 + TP_fast_assign(
73573 + __assign_str(filename, filename);
73574 + ),
73575 +
73576 + TP_printk("\"%s\"",
73577 + __get_str(filename))
73578 +);
73579 +
73580 +#endif /* _TRACE_FS_H */
73581 +
73582 +/* This part must be outside protection */
73583 +#include <trace/define_trace.h>
73584 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
73585 index 1c09820..7f5ec79 100644
73586 --- a/include/trace/events/irq.h
73587 +++ b/include/trace/events/irq.h
73588 @@ -36,7 +36,7 @@ struct softirq_action;
73589 */
73590 TRACE_EVENT(irq_handler_entry,
73591
73592 - TP_PROTO(int irq, struct irqaction *action),
73593 + TP_PROTO(int irq, const struct irqaction *action),
73594
73595 TP_ARGS(irq, action),
73596
73597 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
73598 */
73599 TRACE_EVENT(irq_handler_exit,
73600
73601 - TP_PROTO(int irq, struct irqaction *action, int ret),
73602 + TP_PROTO(int irq, const struct irqaction *action, int ret),
73603
73604 TP_ARGS(irq, action, ret),
73605
73606 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
73607 index 7caf44c..23c6f27 100644
73608 --- a/include/uapi/linux/a.out.h
73609 +++ b/include/uapi/linux/a.out.h
73610 @@ -39,6 +39,14 @@ enum machine_type {
73611 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
73612 };
73613
73614 +/* Constants for the N_FLAGS field */
73615 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
73616 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
73617 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
73618 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
73619 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
73620 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
73621 +
73622 #if !defined (N_MAGIC)
73623 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
73624 #endif
73625 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
73626 index d876736..ccce5c0 100644
73627 --- a/include/uapi/linux/byteorder/little_endian.h
73628 +++ b/include/uapi/linux/byteorder/little_endian.h
73629 @@ -42,51 +42,51 @@
73630
73631 static inline __le64 __cpu_to_le64p(const __u64 *p)
73632 {
73633 - return (__force __le64)*p;
73634 + return (__force const __le64)*p;
73635 }
73636 -static inline __u64 __le64_to_cpup(const __le64 *p)
73637 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
73638 {
73639 - return (__force __u64)*p;
73640 + return (__force const __u64)*p;
73641 }
73642 static inline __le32 __cpu_to_le32p(const __u32 *p)
73643 {
73644 - return (__force __le32)*p;
73645 + return (__force const __le32)*p;
73646 }
73647 static inline __u32 __le32_to_cpup(const __le32 *p)
73648 {
73649 - return (__force __u32)*p;
73650 + return (__force const __u32)*p;
73651 }
73652 static inline __le16 __cpu_to_le16p(const __u16 *p)
73653 {
73654 - return (__force __le16)*p;
73655 + return (__force const __le16)*p;
73656 }
73657 static inline __u16 __le16_to_cpup(const __le16 *p)
73658 {
73659 - return (__force __u16)*p;
73660 + return (__force const __u16)*p;
73661 }
73662 static inline __be64 __cpu_to_be64p(const __u64 *p)
73663 {
73664 - return (__force __be64)__swab64p(p);
73665 + return (__force const __be64)__swab64p(p);
73666 }
73667 static inline __u64 __be64_to_cpup(const __be64 *p)
73668 {
73669 - return __swab64p((__u64 *)p);
73670 + return __swab64p((const __u64 *)p);
73671 }
73672 static inline __be32 __cpu_to_be32p(const __u32 *p)
73673 {
73674 - return (__force __be32)__swab32p(p);
73675 + return (__force const __be32)__swab32p(p);
73676 }
73677 -static inline __u32 __be32_to_cpup(const __be32 *p)
73678 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
73679 {
73680 - return __swab32p((__u32 *)p);
73681 + return __swab32p((const __u32 *)p);
73682 }
73683 static inline __be16 __cpu_to_be16p(const __u16 *p)
73684 {
73685 - return (__force __be16)__swab16p(p);
73686 + return (__force const __be16)__swab16p(p);
73687 }
73688 static inline __u16 __be16_to_cpup(const __be16 *p)
73689 {
73690 - return __swab16p((__u16 *)p);
73691 + return __swab16p((const __u16 *)p);
73692 }
73693 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
73694 #define __le64_to_cpus(x) do { (void)(x); } while (0)
73695 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
73696 index ef6103b..d4e65dd 100644
73697 --- a/include/uapi/linux/elf.h
73698 +++ b/include/uapi/linux/elf.h
73699 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
73700 #define PT_GNU_EH_FRAME 0x6474e550
73701
73702 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
73703 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
73704 +
73705 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
73706 +
73707 +/* Constants for the e_flags field */
73708 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
73709 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
73710 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
73711 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
73712 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
73713 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
73714
73715 /*
73716 * Extended Numbering
73717 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
73718 #define DT_DEBUG 21
73719 #define DT_TEXTREL 22
73720 #define DT_JMPREL 23
73721 +#define DT_FLAGS 30
73722 + #define DF_TEXTREL 0x00000004
73723 #define DT_ENCODING 32
73724 #define OLD_DT_LOOS 0x60000000
73725 #define DT_LOOS 0x6000000d
73726 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
73727 #define PF_W 0x2
73728 #define PF_X 0x1
73729
73730 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
73731 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
73732 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
73733 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
73734 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
73735 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
73736 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
73737 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
73738 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
73739 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
73740 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
73741 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
73742 +
73743 typedef struct elf32_phdr{
73744 Elf32_Word p_type;
73745 Elf32_Off p_offset;
73746 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
73747 #define EI_OSABI 7
73748 #define EI_PAD 8
73749
73750 +#define EI_PAX 14
73751 +
73752 #define ELFMAG0 0x7f /* EI_MAG */
73753 #define ELFMAG1 'E'
73754 #define ELFMAG2 'L'
73755 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
73756 index aa169c4..6a2771d 100644
73757 --- a/include/uapi/linux/personality.h
73758 +++ b/include/uapi/linux/personality.h
73759 @@ -30,6 +30,7 @@ enum {
73760 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
73761 ADDR_NO_RANDOMIZE | \
73762 ADDR_COMPAT_LAYOUT | \
73763 + ADDR_LIMIT_3GB | \
73764 MMAP_PAGE_ZERO)
73765
73766 /*
73767 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
73768 index 7530e74..e714828 100644
73769 --- a/include/uapi/linux/screen_info.h
73770 +++ b/include/uapi/linux/screen_info.h
73771 @@ -43,7 +43,8 @@ struct screen_info {
73772 __u16 pages; /* 0x32 */
73773 __u16 vesa_attributes; /* 0x34 */
73774 __u32 capabilities; /* 0x36 */
73775 - __u8 _reserved[6]; /* 0x3a */
73776 + __u16 vesapm_size; /* 0x3a */
73777 + __u8 _reserved[4]; /* 0x3c */
73778 } __attribute__((packed));
73779
73780 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
73781 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
73782 index 0e011eb..82681b1 100644
73783 --- a/include/uapi/linux/swab.h
73784 +++ b/include/uapi/linux/swab.h
73785 @@ -43,7 +43,7 @@
73786 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
73787 */
73788
73789 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
73790 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
73791 {
73792 #ifdef __HAVE_BUILTIN_BSWAP16__
73793 return __builtin_bswap16(val);
73794 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
73795 #endif
73796 }
73797
73798 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
73799 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
73800 {
73801 #ifdef __HAVE_BUILTIN_BSWAP32__
73802 return __builtin_bswap32(val);
73803 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
73804 #endif
73805 }
73806
73807 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
73808 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
73809 {
73810 #ifdef __HAVE_BUILTIN_BSWAP64__
73811 return __builtin_bswap64(val);
73812 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
73813 index 6d67213..8dab561 100644
73814 --- a/include/uapi/linux/sysctl.h
73815 +++ b/include/uapi/linux/sysctl.h
73816 @@ -155,7 +155,11 @@ enum
73817 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
73818 };
73819
73820 -
73821 +#ifdef CONFIG_PAX_SOFTMODE
73822 +enum {
73823 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
73824 +};
73825 +#endif
73826
73827 /* CTL_VM names: */
73828 enum
73829 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
73830 index e4629b9..6958086 100644
73831 --- a/include/uapi/linux/xattr.h
73832 +++ b/include/uapi/linux/xattr.h
73833 @@ -63,5 +63,9 @@
73834 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
73835 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
73836
73837 +/* User namespace */
73838 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
73839 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
73840 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
73841
73842 #endif /* _UAPI_LINUX_XATTR_H */
73843 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
73844 index f9466fa..f4e2b81 100644
73845 --- a/include/video/udlfb.h
73846 +++ b/include/video/udlfb.h
73847 @@ -53,10 +53,10 @@ struct dlfb_data {
73848 u32 pseudo_palette[256];
73849 int blank_mode; /*one of FB_BLANK_ */
73850 /* blit-only rendering path metrics, exposed through sysfs */
73851 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
73852 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
73853 - atomic_t bytes_sent; /* to usb, after compression including overhead */
73854 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
73855 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
73856 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
73857 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
73858 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
73859 };
73860
73861 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
73862 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
73863 index 1a91850..28573f8 100644
73864 --- a/include/video/uvesafb.h
73865 +++ b/include/video/uvesafb.h
73866 @@ -122,6 +122,7 @@ struct uvesafb_par {
73867 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
73868 u8 pmi_setpal; /* PMI for palette changes */
73869 u16 *pmi_base; /* protected mode interface location */
73870 + u8 *pmi_code; /* protected mode code location */
73871 void *pmi_start;
73872 void *pmi_pal;
73873 u8 *vbe_state_orig; /*
73874 diff --git a/init/Kconfig b/init/Kconfig
73875 index 2d9b831..ae4c8ac 100644
73876 --- a/init/Kconfig
73877 +++ b/init/Kconfig
73878 @@ -1029,6 +1029,7 @@ endif # CGROUPS
73879
73880 config CHECKPOINT_RESTORE
73881 bool "Checkpoint/restore support" if EXPERT
73882 + depends on !GRKERNSEC
73883 default n
73884 help
73885 Enables additional kernel features in a sake of checkpoint/restore.
73886 @@ -1516,7 +1517,7 @@ config SLUB_DEBUG
73887
73888 config COMPAT_BRK
73889 bool "Disable heap randomization"
73890 - default y
73891 + default n
73892 help
73893 Randomizing heap placement makes heap exploits harder, but it
73894 also breaks ancient binaries (including anything libc5 based).
73895 @@ -1779,7 +1780,7 @@ config INIT_ALL_POSSIBLE
73896 config STOP_MACHINE
73897 bool
73898 default y
73899 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
73900 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
73901 help
73902 Need stop_machine() primitive.
73903
73904 diff --git a/init/Makefile b/init/Makefile
73905 index 7bc47ee..6da2dc7 100644
73906 --- a/init/Makefile
73907 +++ b/init/Makefile
73908 @@ -2,6 +2,9 @@
73909 # Makefile for the linux kernel.
73910 #
73911
73912 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
73913 +asflags-y := $(GCC_PLUGINS_AFLAGS)
73914 +
73915 obj-y := main.o version.o mounts.o
73916 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
73917 obj-y += noinitramfs.o
73918 diff --git a/init/do_mounts.c b/init/do_mounts.c
73919 index a2b49f2..03a0e17c 100644
73920 --- a/init/do_mounts.c
73921 +++ b/init/do_mounts.c
73922 @@ -355,11 +355,11 @@ static void __init get_fs_names(char *page)
73923 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
73924 {
73925 struct super_block *s;
73926 - int err = sys_mount(name, "/root", fs, flags, data);
73927 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
73928 if (err)
73929 return err;
73930
73931 - sys_chdir("/root");
73932 + sys_chdir((const char __force_user *)"/root");
73933 s = current->fs->pwd.dentry->d_sb;
73934 ROOT_DEV = s->s_dev;
73935 printk(KERN_INFO
73936 @@ -480,18 +480,18 @@ void __init change_floppy(char *fmt, ...)
73937 va_start(args, fmt);
73938 vsprintf(buf, fmt, args);
73939 va_end(args);
73940 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
73941 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
73942 if (fd >= 0) {
73943 sys_ioctl(fd, FDEJECT, 0);
73944 sys_close(fd);
73945 }
73946 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
73947 - fd = sys_open("/dev/console", O_RDWR, 0);
73948 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
73949 if (fd >= 0) {
73950 sys_ioctl(fd, TCGETS, (long)&termios);
73951 termios.c_lflag &= ~ICANON;
73952 sys_ioctl(fd, TCSETSF, (long)&termios);
73953 - sys_read(fd, &c, 1);
73954 + sys_read(fd, (char __user *)&c, 1);
73955 termios.c_lflag |= ICANON;
73956 sys_ioctl(fd, TCSETSF, (long)&termios);
73957 sys_close(fd);
73958 @@ -585,6 +585,6 @@ void __init prepare_namespace(void)
73959 mount_root();
73960 out:
73961 devtmpfs_mount("dev");
73962 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
73963 - sys_chroot(".");
73964 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
73965 + sys_chroot((const char __force_user *)".");
73966 }
73967 diff --git a/init/do_mounts.h b/init/do_mounts.h
73968 index f5b978a..69dbfe8 100644
73969 --- a/init/do_mounts.h
73970 +++ b/init/do_mounts.h
73971 @@ -15,15 +15,15 @@ extern int root_mountflags;
73972
73973 static inline int create_dev(char *name, dev_t dev)
73974 {
73975 - sys_unlink(name);
73976 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
73977 + sys_unlink((char __force_user *)name);
73978 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
73979 }
73980
73981 #if BITS_PER_LONG == 32
73982 static inline u32 bstat(char *name)
73983 {
73984 struct stat64 stat;
73985 - if (sys_stat64(name, &stat) != 0)
73986 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
73987 return 0;
73988 if (!S_ISBLK(stat.st_mode))
73989 return 0;
73990 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
73991 static inline u32 bstat(char *name)
73992 {
73993 struct stat stat;
73994 - if (sys_newstat(name, &stat) != 0)
73995 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
73996 return 0;
73997 if (!S_ISBLK(stat.st_mode))
73998 return 0;
73999 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
74000 index 3e0878e..8a9d7a0 100644
74001 --- a/init/do_mounts_initrd.c
74002 +++ b/init/do_mounts_initrd.c
74003 @@ -37,13 +37,13 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)
74004 {
74005 sys_unshare(CLONE_FS | CLONE_FILES);
74006 /* stdin/stdout/stderr for /linuxrc */
74007 - sys_open("/dev/console", O_RDWR, 0);
74008 + sys_open((const char __force_user *)"/dev/console", O_RDWR, 0);
74009 sys_dup(0);
74010 sys_dup(0);
74011 /* move initrd over / and chdir/chroot in initrd root */
74012 - sys_chdir("/root");
74013 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
74014 - sys_chroot(".");
74015 + sys_chdir((const char __force_user *)"/root");
74016 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
74017 + sys_chroot((const char __force_user *)".");
74018 sys_setsid();
74019 return 0;
74020 }
74021 @@ -59,8 +59,8 @@ static void __init handle_initrd(void)
74022 create_dev("/dev/root.old", Root_RAM0);
74023 /* mount initrd on rootfs' /root */
74024 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
74025 - sys_mkdir("/old", 0700);
74026 - sys_chdir("/old");
74027 + sys_mkdir((const char __force_user *)"/old", 0700);
74028 + sys_chdir((const char __force_user *)"/old");
74029
74030 /* try loading default modules from initrd */
74031 load_default_modules();
74032 @@ -80,31 +80,31 @@ static void __init handle_initrd(void)
74033 current->flags &= ~PF_FREEZER_SKIP;
74034
74035 /* move initrd to rootfs' /old */
74036 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
74037 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
74038 /* switch root and cwd back to / of rootfs */
74039 - sys_chroot("..");
74040 + sys_chroot((const char __force_user *)"..");
74041
74042 if (new_decode_dev(real_root_dev) == Root_RAM0) {
74043 - sys_chdir("/old");
74044 + sys_chdir((const char __force_user *)"/old");
74045 return;
74046 }
74047
74048 - sys_chdir("/");
74049 + sys_chdir((const char __force_user *)"/");
74050 ROOT_DEV = new_decode_dev(real_root_dev);
74051 mount_root();
74052
74053 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
74054 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
74055 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
74056 if (!error)
74057 printk("okay\n");
74058 else {
74059 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
74060 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
74061 if (error == -ENOENT)
74062 printk("/initrd does not exist. Ignored.\n");
74063 else
74064 printk("failed\n");
74065 printk(KERN_NOTICE "Unmounting old root\n");
74066 - sys_umount("/old", MNT_DETACH);
74067 + sys_umount((char __force_user *)"/old", MNT_DETACH);
74068 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
74069 if (fd < 0) {
74070 error = fd;
74071 @@ -127,11 +127,11 @@ int __init initrd_load(void)
74072 * mounted in the normal path.
74073 */
74074 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
74075 - sys_unlink("/initrd.image");
74076 + sys_unlink((const char __force_user *)"/initrd.image");
74077 handle_initrd();
74078 return 1;
74079 }
74080 }
74081 - sys_unlink("/initrd.image");
74082 + sys_unlink((const char __force_user *)"/initrd.image");
74083 return 0;
74084 }
74085 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
74086 index 8cb6db5..d729f50 100644
74087 --- a/init/do_mounts_md.c
74088 +++ b/init/do_mounts_md.c
74089 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
74090 partitioned ? "_d" : "", minor,
74091 md_setup_args[ent].device_names);
74092
74093 - fd = sys_open(name, 0, 0);
74094 + fd = sys_open((char __force_user *)name, 0, 0);
74095 if (fd < 0) {
74096 printk(KERN_ERR "md: open failed - cannot start "
74097 "array %s\n", name);
74098 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
74099 * array without it
74100 */
74101 sys_close(fd);
74102 - fd = sys_open(name, 0, 0);
74103 + fd = sys_open((char __force_user *)name, 0, 0);
74104 sys_ioctl(fd, BLKRRPART, 0);
74105 }
74106 sys_close(fd);
74107 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
74108
74109 wait_for_device_probe();
74110
74111 - fd = sys_open("/dev/md0", 0, 0);
74112 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
74113 if (fd >= 0) {
74114 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
74115 sys_close(fd);
74116 diff --git a/init/init_task.c b/init/init_task.c
74117 index ba0a7f36..2bcf1d5 100644
74118 --- a/init/init_task.c
74119 +++ b/init/init_task.c
74120 @@ -22,5 +22,9 @@ EXPORT_SYMBOL(init_task);
74121 * Initial thread structure. Alignment of this is handled by a special
74122 * linker map entry.
74123 */
74124 +#ifdef CONFIG_X86
74125 +union thread_union init_thread_union __init_task_data;
74126 +#else
74127 union thread_union init_thread_union __init_task_data =
74128 { INIT_THREAD_INFO(init_task) };
74129 +#endif
74130 diff --git a/init/initramfs.c b/init/initramfs.c
74131 index a67ef9d..2d17ed9 100644
74132 --- a/init/initramfs.c
74133 +++ b/init/initramfs.c
74134 @@ -84,7 +84,7 @@ static void __init free_hash(void)
74135 }
74136 }
74137
74138 -static long __init do_utime(char *filename, time_t mtime)
74139 +static long __init do_utime(char __force_user *filename, time_t mtime)
74140 {
74141 struct timespec t[2];
74142
74143 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
74144 struct dir_entry *de, *tmp;
74145 list_for_each_entry_safe(de, tmp, &dir_list, list) {
74146 list_del(&de->list);
74147 - do_utime(de->name, de->mtime);
74148 + do_utime((char __force_user *)de->name, de->mtime);
74149 kfree(de->name);
74150 kfree(de);
74151 }
74152 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
74153 if (nlink >= 2) {
74154 char *old = find_link(major, minor, ino, mode, collected);
74155 if (old)
74156 - return (sys_link(old, collected) < 0) ? -1 : 1;
74157 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
74158 }
74159 return 0;
74160 }
74161 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
74162 {
74163 struct stat st;
74164
74165 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
74166 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
74167 if (S_ISDIR(st.st_mode))
74168 - sys_rmdir(path);
74169 + sys_rmdir((char __force_user *)path);
74170 else
74171 - sys_unlink(path);
74172 + sys_unlink((char __force_user *)path);
74173 }
74174 }
74175
74176 @@ -315,7 +315,7 @@ static int __init do_name(void)
74177 int openflags = O_WRONLY|O_CREAT;
74178 if (ml != 1)
74179 openflags |= O_TRUNC;
74180 - wfd = sys_open(collected, openflags, mode);
74181 + wfd = sys_open((char __force_user *)collected, openflags, mode);
74182
74183 if (wfd >= 0) {
74184 sys_fchown(wfd, uid, gid);
74185 @@ -327,17 +327,17 @@ static int __init do_name(void)
74186 }
74187 }
74188 } else if (S_ISDIR(mode)) {
74189 - sys_mkdir(collected, mode);
74190 - sys_chown(collected, uid, gid);
74191 - sys_chmod(collected, mode);
74192 + sys_mkdir((char __force_user *)collected, mode);
74193 + sys_chown((char __force_user *)collected, uid, gid);
74194 + sys_chmod((char __force_user *)collected, mode);
74195 dir_add(collected, mtime);
74196 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
74197 S_ISFIFO(mode) || S_ISSOCK(mode)) {
74198 if (maybe_link() == 0) {
74199 - sys_mknod(collected, mode, rdev);
74200 - sys_chown(collected, uid, gid);
74201 - sys_chmod(collected, mode);
74202 - do_utime(collected, mtime);
74203 + sys_mknod((char __force_user *)collected, mode, rdev);
74204 + sys_chown((char __force_user *)collected, uid, gid);
74205 + sys_chmod((char __force_user *)collected, mode);
74206 + do_utime((char __force_user *)collected, mtime);
74207 }
74208 }
74209 return 0;
74210 @@ -346,15 +346,15 @@ static int __init do_name(void)
74211 static int __init do_copy(void)
74212 {
74213 if (count >= body_len) {
74214 - sys_write(wfd, victim, body_len);
74215 + sys_write(wfd, (char __force_user *)victim, body_len);
74216 sys_close(wfd);
74217 - do_utime(vcollected, mtime);
74218 + do_utime((char __force_user *)vcollected, mtime);
74219 kfree(vcollected);
74220 eat(body_len);
74221 state = SkipIt;
74222 return 0;
74223 } else {
74224 - sys_write(wfd, victim, count);
74225 + sys_write(wfd, (char __force_user *)victim, count);
74226 body_len -= count;
74227 eat(count);
74228 return 1;
74229 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
74230 {
74231 collected[N_ALIGN(name_len) + body_len] = '\0';
74232 clean_path(collected, 0);
74233 - sys_symlink(collected + N_ALIGN(name_len), collected);
74234 - sys_lchown(collected, uid, gid);
74235 - do_utime(collected, mtime);
74236 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
74237 + sys_lchown((char __force_user *)collected, uid, gid);
74238 + do_utime((char __force_user *)collected, mtime);
74239 state = SkipIt;
74240 next_state = Reset;
74241 return 0;
74242 @@ -583,7 +583,7 @@ static int __init populate_rootfs(void)
74243 {
74244 char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
74245 if (err)
74246 - panic(err); /* Failed to decompress INTERNAL initramfs */
74247 + panic("%s", err); /* Failed to decompress INTERNAL initramfs */
74248 if (initrd_start) {
74249 #ifdef CONFIG_BLK_DEV_RAM
74250 int fd;
74251 diff --git a/init/main.c b/init/main.c
74252 index 9484f4b..4c01430 100644
74253 --- a/init/main.c
74254 +++ b/init/main.c
74255 @@ -100,6 +100,8 @@ static inline void mark_rodata_ro(void) { }
74256 extern void tc_init(void);
74257 #endif
74258
74259 +extern void grsecurity_init(void);
74260 +
74261 /*
74262 * Debug helper: via this flag we know that we are in 'early bootup code'
74263 * where only the boot processor is running with IRQ disabled. This means
74264 @@ -153,6 +155,64 @@ static int __init set_reset_devices(char *str)
74265
74266 __setup("reset_devices", set_reset_devices);
74267
74268 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
74269 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
74270 +static int __init setup_grsec_proc_gid(char *str)
74271 +{
74272 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
74273 + return 1;
74274 +}
74275 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
74276 +#endif
74277 +
74278 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
74279 +unsigned long pax_user_shadow_base __read_only = 1UL << TASK_SIZE_MAX_SHIFT;
74280 +EXPORT_SYMBOL(pax_user_shadow_base);
74281 +extern char pax_enter_kernel_user[];
74282 +extern char pax_exit_kernel_user[];
74283 +extern pgdval_t clone_pgd_mask;
74284 +#endif
74285 +
74286 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
74287 +static int __init setup_pax_nouderef(char *str)
74288 +{
74289 +#ifdef CONFIG_X86_32
74290 + unsigned int cpu;
74291 + struct desc_struct *gdt;
74292 +
74293 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
74294 + gdt = get_cpu_gdt_table(cpu);
74295 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
74296 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
74297 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
74298 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
74299 + }
74300 + loadsegment(ds, __KERNEL_DS);
74301 + loadsegment(es, __KERNEL_DS);
74302 + loadsegment(ss, __KERNEL_DS);
74303 +#else
74304 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
74305 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
74306 + clone_pgd_mask = ~(pgdval_t)0UL;
74307 + pax_user_shadow_base = 0UL;
74308 +#endif
74309 +
74310 + return 0;
74311 +}
74312 +early_param("pax_nouderef", setup_pax_nouderef);
74313 +#endif
74314 +
74315 +#ifdef CONFIG_PAX_SOFTMODE
74316 +int pax_softmode;
74317 +
74318 +static int __init setup_pax_softmode(char *str)
74319 +{
74320 + get_option(&str, &pax_softmode);
74321 + return 1;
74322 +}
74323 +__setup("pax_softmode=", setup_pax_softmode);
74324 +#endif
74325 +
74326 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
74327 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
74328 static const char *panic_later, *panic_param;
74329 @@ -655,8 +715,6 @@ static void __init do_ctors(void)
74330 bool initcall_debug;
74331 core_param(initcall_debug, initcall_debug, bool, 0644);
74332
74333 -static char msgbuf[64];
74334 -
74335 static int __init_or_module do_one_initcall_debug(initcall_t fn)
74336 {
74337 ktime_t calltime, delta, rettime;
74338 @@ -679,23 +737,22 @@ int __init_or_module do_one_initcall(initcall_t fn)
74339 {
74340 int count = preempt_count();
74341 int ret;
74342 + const char *msg1 = "", *msg2 = "";
74343
74344 if (initcall_debug)
74345 ret = do_one_initcall_debug(fn);
74346 else
74347 ret = fn();
74348
74349 - msgbuf[0] = 0;
74350 -
74351 if (preempt_count() != count) {
74352 - sprintf(msgbuf, "preemption imbalance ");
74353 + msg1 = " preemption imbalance";
74354 preempt_count() = count;
74355 }
74356 if (irqs_disabled()) {
74357 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
74358 + msg2 = " disabled interrupts";
74359 local_irq_enable();
74360 }
74361 - WARN(msgbuf[0], "initcall %pF returned with %s\n", fn, msgbuf);
74362 + WARN(*msg1 || *msg2, "initcall %pF returned with%s%s\n", fn, msg1, msg2);
74363
74364 return ret;
74365 }
74366 @@ -748,8 +805,14 @@ static void __init do_initcall_level(int level)
74367 level, level,
74368 &repair_env_string);
74369
74370 - for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
74371 + for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++) {
74372 do_one_initcall(*fn);
74373 +
74374 +#ifdef LATENT_ENTROPY_PLUGIN
74375 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
74376 +#endif
74377 +
74378 + }
74379 }
74380
74381 static void __init do_initcalls(void)
74382 @@ -783,8 +846,14 @@ static void __init do_pre_smp_initcalls(void)
74383 {
74384 initcall_t *fn;
74385
74386 - for (fn = __initcall_start; fn < __initcall0_start; fn++)
74387 + for (fn = __initcall_start; fn < __initcall0_start; fn++) {
74388 do_one_initcall(*fn);
74389 +
74390 +#ifdef LATENT_ENTROPY_PLUGIN
74391 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
74392 +#endif
74393 +
74394 + }
74395 }
74396
74397 /*
74398 @@ -802,8 +871,8 @@ static int run_init_process(const char *init_filename)
74399 {
74400 argv_init[0] = init_filename;
74401 return do_execve(init_filename,
74402 - (const char __user *const __user *)argv_init,
74403 - (const char __user *const __user *)envp_init);
74404 + (const char __user *const __force_user *)argv_init,
74405 + (const char __user *const __force_user *)envp_init);
74406 }
74407
74408 static noinline void __init kernel_init_freeable(void);
74409 @@ -880,7 +949,7 @@ static noinline void __init kernel_init_freeable(void)
74410 do_basic_setup();
74411
74412 /* Open the /dev/console on the rootfs, this should never fail */
74413 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
74414 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
74415 pr_err("Warning: unable to open an initial console.\n");
74416
74417 (void) sys_dup(0);
74418 @@ -893,11 +962,13 @@ static noinline void __init kernel_init_freeable(void)
74419 if (!ramdisk_execute_command)
74420 ramdisk_execute_command = "/init";
74421
74422 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
74423 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
74424 ramdisk_execute_command = NULL;
74425 prepare_namespace();
74426 }
74427
74428 + grsecurity_init();
74429 +
74430 /*
74431 * Ok, we have completed the initial bootup, and
74432 * we're essentially up and running. Get rid of the
74433 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
74434 index 130dfec..cc88451 100644
74435 --- a/ipc/ipc_sysctl.c
74436 +++ b/ipc/ipc_sysctl.c
74437 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
74438 static int proc_ipc_dointvec(ctl_table *table, int write,
74439 void __user *buffer, size_t *lenp, loff_t *ppos)
74440 {
74441 - struct ctl_table ipc_table;
74442 + ctl_table_no_const ipc_table;
74443
74444 memcpy(&ipc_table, table, sizeof(ipc_table));
74445 ipc_table.data = get_ipc(table);
74446 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
74447 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
74448 void __user *buffer, size_t *lenp, loff_t *ppos)
74449 {
74450 - struct ctl_table ipc_table;
74451 + ctl_table_no_const ipc_table;
74452
74453 memcpy(&ipc_table, table, sizeof(ipc_table));
74454 ipc_table.data = get_ipc(table);
74455 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
74456 static int proc_ipc_callback_dointvec(ctl_table *table, int write,
74457 void __user *buffer, size_t *lenp, loff_t *ppos)
74458 {
74459 - struct ctl_table ipc_table;
74460 + ctl_table_no_const ipc_table;
74461 size_t lenp_bef = *lenp;
74462 int rc;
74463
74464 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
74465 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
74466 void __user *buffer, size_t *lenp, loff_t *ppos)
74467 {
74468 - struct ctl_table ipc_table;
74469 + ctl_table_no_const ipc_table;
74470 memcpy(&ipc_table, table, sizeof(ipc_table));
74471 ipc_table.data = get_ipc(table);
74472
74473 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
74474 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
74475 void __user *buffer, size_t *lenp, loff_t *ppos)
74476 {
74477 - struct ctl_table ipc_table;
74478 + ctl_table_no_const ipc_table;
74479 size_t lenp_bef = *lenp;
74480 int oldval;
74481 int rc;
74482 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
74483 index 383d638..943fdbb 100644
74484 --- a/ipc/mq_sysctl.c
74485 +++ b/ipc/mq_sysctl.c
74486 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
74487 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
74488 void __user *buffer, size_t *lenp, loff_t *ppos)
74489 {
74490 - struct ctl_table mq_table;
74491 + ctl_table_no_const mq_table;
74492 memcpy(&mq_table, table, sizeof(mq_table));
74493 mq_table.data = get_mq(table);
74494
74495 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
74496 index e4e47f6..a85e0ad 100644
74497 --- a/ipc/mqueue.c
74498 +++ b/ipc/mqueue.c
74499 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
74500 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
74501 info->attr.mq_msgsize);
74502
74503 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
74504 spin_lock(&mq_lock);
74505 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
74506 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
74507 diff --git a/ipc/msg.c b/ipc/msg.c
74508 index d0c6d96..69a893c 100644
74509 --- a/ipc/msg.c
74510 +++ b/ipc/msg.c
74511 @@ -296,18 +296,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
74512 return security_msg_queue_associate(msq, msgflg);
74513 }
74514
74515 +static struct ipc_ops msg_ops = {
74516 + .getnew = newque,
74517 + .associate = msg_security,
74518 + .more_checks = NULL
74519 +};
74520 +
74521 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
74522 {
74523 struct ipc_namespace *ns;
74524 - struct ipc_ops msg_ops;
74525 struct ipc_params msg_params;
74526
74527 ns = current->nsproxy->ipc_ns;
74528
74529 - msg_ops.getnew = newque;
74530 - msg_ops.associate = msg_security;
74531 - msg_ops.more_checks = NULL;
74532 -
74533 msg_params.key = key;
74534 msg_params.flg = msgflg;
74535
74536 diff --git a/ipc/sem.c b/ipc/sem.c
74537 index 70480a3..f4e8262 100644
74538 --- a/ipc/sem.c
74539 +++ b/ipc/sem.c
74540 @@ -460,10 +460,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
74541 return 0;
74542 }
74543
74544 +static struct ipc_ops sem_ops = {
74545 + .getnew = newary,
74546 + .associate = sem_security,
74547 + .more_checks = sem_more_checks
74548 +};
74549 +
74550 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
74551 {
74552 struct ipc_namespace *ns;
74553 - struct ipc_ops sem_ops;
74554 struct ipc_params sem_params;
74555
74556 ns = current->nsproxy->ipc_ns;
74557 @@ -471,10 +476,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
74558 if (nsems < 0 || nsems > ns->sc_semmsl)
74559 return -EINVAL;
74560
74561 - sem_ops.getnew = newary;
74562 - sem_ops.associate = sem_security;
74563 - sem_ops.more_checks = sem_more_checks;
74564 -
74565 sem_params.key = key;
74566 sem_params.flg = semflg;
74567 sem_params.u.nsems = nsems;
74568 diff --git a/ipc/shm.c b/ipc/shm.c
74569 index 7e199fa..180a1ca 100644
74570 --- a/ipc/shm.c
74571 +++ b/ipc/shm.c
74572 @@ -69,6 +69,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
74573 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
74574 #endif
74575
74576 +#ifdef CONFIG_GRKERNSEC
74577 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
74578 + const time_t shm_createtime, const kuid_t cuid,
74579 + const int shmid);
74580 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
74581 + const time_t shm_createtime);
74582 +#endif
74583 +
74584 void shm_init_ns(struct ipc_namespace *ns)
74585 {
74586 ns->shm_ctlmax = SHMMAX;
74587 @@ -531,6 +539,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
74588 shp->shm_lprid = 0;
74589 shp->shm_atim = shp->shm_dtim = 0;
74590 shp->shm_ctim = get_seconds();
74591 +#ifdef CONFIG_GRKERNSEC
74592 + {
74593 + struct timespec timeval;
74594 + do_posix_clock_monotonic_gettime(&timeval);
74595 +
74596 + shp->shm_createtime = timeval.tv_sec;
74597 + }
74598 +#endif
74599 shp->shm_segsz = size;
74600 shp->shm_nattch = 0;
74601 shp->shm_file = file;
74602 @@ -582,18 +598,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
74603 return 0;
74604 }
74605
74606 +static struct ipc_ops shm_ops = {
74607 + .getnew = newseg,
74608 + .associate = shm_security,
74609 + .more_checks = shm_more_checks
74610 +};
74611 +
74612 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
74613 {
74614 struct ipc_namespace *ns;
74615 - struct ipc_ops shm_ops;
74616 struct ipc_params shm_params;
74617
74618 ns = current->nsproxy->ipc_ns;
74619
74620 - shm_ops.getnew = newseg;
74621 - shm_ops.associate = shm_security;
74622 - shm_ops.more_checks = shm_more_checks;
74623 -
74624 shm_params.key = key;
74625 shm_params.flg = shmflg;
74626 shm_params.u.size = size;
74627 @@ -1014,6 +1031,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
74628 f_mode = FMODE_READ | FMODE_WRITE;
74629 }
74630 if (shmflg & SHM_EXEC) {
74631 +
74632 +#ifdef CONFIG_PAX_MPROTECT
74633 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
74634 + goto out;
74635 +#endif
74636 +
74637 prot |= PROT_EXEC;
74638 acc_mode |= S_IXUGO;
74639 }
74640 @@ -1037,9 +1060,21 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
74641 if (err)
74642 goto out_unlock;
74643
74644 +#ifdef CONFIG_GRKERNSEC
74645 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
74646 + shp->shm_perm.cuid, shmid) ||
74647 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
74648 + err = -EACCES;
74649 + goto out_unlock;
74650 + }
74651 +#endif
74652 +
74653 path = shp->shm_file->f_path;
74654 path_get(&path);
74655 shp->shm_nattch++;
74656 +#ifdef CONFIG_GRKERNSEC
74657 + shp->shm_lapid = current->pid;
74658 +#endif
74659 size = i_size_read(path.dentry->d_inode);
74660 shm_unlock(shp);
74661
74662 diff --git a/kernel/acct.c b/kernel/acct.c
74663 index 8d6e145..33e0b1e 100644
74664 --- a/kernel/acct.c
74665 +++ b/kernel/acct.c
74666 @@ -556,7 +556,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
74667 */
74668 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
74669 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
74670 - file->f_op->write(file, (char *)&ac,
74671 + file->f_op->write(file, (char __force_user *)&ac,
74672 sizeof(acct_t), &file->f_pos);
74673 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
74674 set_fs(fs);
74675 diff --git a/kernel/audit.c b/kernel/audit.c
74676 index 91e53d0..d9e3ec4 100644
74677 --- a/kernel/audit.c
74678 +++ b/kernel/audit.c
74679 @@ -118,7 +118,7 @@ u32 audit_sig_sid = 0;
74680 3) suppressed due to audit_rate_limit
74681 4) suppressed due to audit_backlog_limit
74682 */
74683 -static atomic_t audit_lost = ATOMIC_INIT(0);
74684 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
74685
74686 /* The netlink socket. */
74687 static struct sock *audit_sock;
74688 @@ -240,7 +240,7 @@ void audit_log_lost(const char *message)
74689 unsigned long now;
74690 int print;
74691
74692 - atomic_inc(&audit_lost);
74693 + atomic_inc_unchecked(&audit_lost);
74694
74695 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
74696
74697 @@ -259,7 +259,7 @@ void audit_log_lost(const char *message)
74698 printk(KERN_WARNING
74699 "audit: audit_lost=%d audit_rate_limit=%d "
74700 "audit_backlog_limit=%d\n",
74701 - atomic_read(&audit_lost),
74702 + atomic_read_unchecked(&audit_lost),
74703 audit_rate_limit,
74704 audit_backlog_limit);
74705 audit_panic(message);
74706 @@ -664,7 +664,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
74707 status_set.pid = audit_pid;
74708 status_set.rate_limit = audit_rate_limit;
74709 status_set.backlog_limit = audit_backlog_limit;
74710 - status_set.lost = atomic_read(&audit_lost);
74711 + status_set.lost = atomic_read_unchecked(&audit_lost);
74712 status_set.backlog = skb_queue_len(&audit_skb_queue);
74713 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
74714 &status_set, sizeof(status_set));
74715 diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
74716 index 6bd4a90..0ee9eff 100644
74717 --- a/kernel/auditfilter.c
74718 +++ b/kernel/auditfilter.c
74719 @@ -423,7 +423,7 @@ static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data,
74720 f->lsm_rule = NULL;
74721
74722 /* Support legacy tests for a valid loginuid */
74723 - if ((f->type == AUDIT_LOGINUID) && (f->val == 4294967295)) {
74724 + if ((f->type == AUDIT_LOGINUID) && (f->val == 4294967295U)) {
74725 f->type = AUDIT_LOGINUID_SET;
74726 f->val = 0;
74727 }
74728 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
74729 index 3c8a601..3a416f6 100644
74730 --- a/kernel/auditsc.c
74731 +++ b/kernel/auditsc.c
74732 @@ -1956,7 +1956,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
74733 }
74734
74735 /* global counter which is incremented every time something logs in */
74736 -static atomic_t session_id = ATOMIC_INIT(0);
74737 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
74738
74739 /**
74740 * audit_set_loginuid - set current task's audit_context loginuid
74741 @@ -1980,7 +1980,7 @@ int audit_set_loginuid(kuid_t loginuid)
74742 return -EPERM;
74743 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
74744
74745 - sessionid = atomic_inc_return(&session_id);
74746 + sessionid = atomic_inc_return_unchecked(&session_id);
74747 if (context && context->in_syscall) {
74748 struct audit_buffer *ab;
74749
74750 diff --git a/kernel/capability.c b/kernel/capability.c
74751 index f6c2ce5..982c0f9 100644
74752 --- a/kernel/capability.c
74753 +++ b/kernel/capability.c
74754 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
74755 * before modification is attempted and the application
74756 * fails.
74757 */
74758 + if (tocopy > ARRAY_SIZE(kdata))
74759 + return -EFAULT;
74760 +
74761 if (copy_to_user(dataptr, kdata, tocopy
74762 * sizeof(struct __user_cap_data_struct))) {
74763 return -EFAULT;
74764 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
74765 int ret;
74766
74767 rcu_read_lock();
74768 - ret = security_capable(__task_cred(t), ns, cap);
74769 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
74770 + gr_task_is_capable(t, __task_cred(t), cap);
74771 rcu_read_unlock();
74772
74773 - return (ret == 0);
74774 + return ret;
74775 }
74776
74777 /**
74778 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
74779 int ret;
74780
74781 rcu_read_lock();
74782 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
74783 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
74784 rcu_read_unlock();
74785
74786 - return (ret == 0);
74787 + return ret;
74788 }
74789
74790 /**
74791 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
74792 BUG();
74793 }
74794
74795 - if (security_capable(current_cred(), ns, cap) == 0) {
74796 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
74797 current->flags |= PF_SUPERPRIV;
74798 return true;
74799 }
74800 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
74801 }
74802 EXPORT_SYMBOL(ns_capable);
74803
74804 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
74805 +{
74806 + if (unlikely(!cap_valid(cap))) {
74807 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
74808 + BUG();
74809 + }
74810 +
74811 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
74812 + current->flags |= PF_SUPERPRIV;
74813 + return true;
74814 + }
74815 + return false;
74816 +}
74817 +EXPORT_SYMBOL(ns_capable_nolog);
74818 +
74819 /**
74820 * file_ns_capable - Determine if the file's opener had a capability in effect
74821 * @file: The file we want to check
74822 @@ -432,6 +451,12 @@ bool capable(int cap)
74823 }
74824 EXPORT_SYMBOL(capable);
74825
74826 +bool capable_nolog(int cap)
74827 +{
74828 + return ns_capable_nolog(&init_user_ns, cap);
74829 +}
74830 +EXPORT_SYMBOL(capable_nolog);
74831 +
74832 /**
74833 * nsown_capable - Check superior capability to one's own user_ns
74834 * @cap: The capability in question
74835 @@ -464,3 +489,10 @@ bool inode_capable(const struct inode *inode, int cap)
74836
74837 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
74838 }
74839 +
74840 +bool inode_capable_nolog(const struct inode *inode, int cap)
74841 +{
74842 + struct user_namespace *ns = current_user_ns();
74843 +
74844 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
74845 +}
74846 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
74847 index a7c9e6d..a16aa75 100644
74848 --- a/kernel/cgroup.c
74849 +++ b/kernel/cgroup.c
74850 @@ -5378,7 +5378,7 @@ static int cgroup_css_links_read(struct cgroup *cont,
74851 struct css_set *cg = link->cg;
74852 struct task_struct *task;
74853 int count = 0;
74854 - seq_printf(seq, "css_set %p\n", cg);
74855 + seq_printf(seq, "css_set %pK\n", cg);
74856 list_for_each_entry(task, &cg->tasks, cg_list) {
74857 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
74858 seq_puts(seq, " ...\n");
74859 diff --git a/kernel/compat.c b/kernel/compat.c
74860 index 0a09e48..f44f3f0 100644
74861 --- a/kernel/compat.c
74862 +++ b/kernel/compat.c
74863 @@ -13,6 +13,7 @@
74864
74865 #include <linux/linkage.h>
74866 #include <linux/compat.h>
74867 +#include <linux/module.h>
74868 #include <linux/errno.h>
74869 #include <linux/time.h>
74870 #include <linux/signal.h>
74871 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
74872 mm_segment_t oldfs;
74873 long ret;
74874
74875 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
74876 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
74877 oldfs = get_fs();
74878 set_fs(KERNEL_DS);
74879 ret = hrtimer_nanosleep_restart(restart);
74880 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
74881 oldfs = get_fs();
74882 set_fs(KERNEL_DS);
74883 ret = hrtimer_nanosleep(&tu,
74884 - rmtp ? (struct timespec __user *)&rmt : NULL,
74885 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
74886 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
74887 set_fs(oldfs);
74888
74889 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
74890 mm_segment_t old_fs = get_fs();
74891
74892 set_fs(KERNEL_DS);
74893 - ret = sys_sigpending((old_sigset_t __user *) &s);
74894 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
74895 set_fs(old_fs);
74896 if (ret == 0)
74897 ret = put_user(s, set);
74898 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
74899 mm_segment_t old_fs = get_fs();
74900
74901 set_fs(KERNEL_DS);
74902 - ret = sys_old_getrlimit(resource, &r);
74903 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
74904 set_fs(old_fs);
74905
74906 if (!ret) {
74907 @@ -533,8 +534,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
74908 set_fs (KERNEL_DS);
74909 ret = sys_wait4(pid,
74910 (stat_addr ?
74911 - (unsigned int __user *) &status : NULL),
74912 - options, (struct rusage __user *) &r);
74913 + (unsigned int __force_user *) &status : NULL),
74914 + options, (struct rusage __force_user *) &r);
74915 set_fs (old_fs);
74916
74917 if (ret > 0) {
74918 @@ -560,8 +561,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
74919 memset(&info, 0, sizeof(info));
74920
74921 set_fs(KERNEL_DS);
74922 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
74923 - uru ? (struct rusage __user *)&ru : NULL);
74924 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
74925 + uru ? (struct rusage __force_user *)&ru : NULL);
74926 set_fs(old_fs);
74927
74928 if ((ret < 0) || (info.si_signo == 0))
74929 @@ -695,8 +696,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
74930 oldfs = get_fs();
74931 set_fs(KERNEL_DS);
74932 err = sys_timer_settime(timer_id, flags,
74933 - (struct itimerspec __user *) &newts,
74934 - (struct itimerspec __user *) &oldts);
74935 + (struct itimerspec __force_user *) &newts,
74936 + (struct itimerspec __force_user *) &oldts);
74937 set_fs(oldfs);
74938 if (!err && old && put_compat_itimerspec(old, &oldts))
74939 return -EFAULT;
74940 @@ -713,7 +714,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
74941 oldfs = get_fs();
74942 set_fs(KERNEL_DS);
74943 err = sys_timer_gettime(timer_id,
74944 - (struct itimerspec __user *) &ts);
74945 + (struct itimerspec __force_user *) &ts);
74946 set_fs(oldfs);
74947 if (!err && put_compat_itimerspec(setting, &ts))
74948 return -EFAULT;
74949 @@ -732,7 +733,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
74950 oldfs = get_fs();
74951 set_fs(KERNEL_DS);
74952 err = sys_clock_settime(which_clock,
74953 - (struct timespec __user *) &ts);
74954 + (struct timespec __force_user *) &ts);
74955 set_fs(oldfs);
74956 return err;
74957 }
74958 @@ -747,7 +748,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
74959 oldfs = get_fs();
74960 set_fs(KERNEL_DS);
74961 err = sys_clock_gettime(which_clock,
74962 - (struct timespec __user *) &ts);
74963 + (struct timespec __force_user *) &ts);
74964 set_fs(oldfs);
74965 if (!err && put_compat_timespec(&ts, tp))
74966 return -EFAULT;
74967 @@ -767,7 +768,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
74968
74969 oldfs = get_fs();
74970 set_fs(KERNEL_DS);
74971 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
74972 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
74973 set_fs(oldfs);
74974
74975 err = compat_put_timex(utp, &txc);
74976 @@ -787,7 +788,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
74977 oldfs = get_fs();
74978 set_fs(KERNEL_DS);
74979 err = sys_clock_getres(which_clock,
74980 - (struct timespec __user *) &ts);
74981 + (struct timespec __force_user *) &ts);
74982 set_fs(oldfs);
74983 if (!err && tp && put_compat_timespec(&ts, tp))
74984 return -EFAULT;
74985 @@ -799,9 +800,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
74986 long err;
74987 mm_segment_t oldfs;
74988 struct timespec tu;
74989 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
74990 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
74991
74992 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
74993 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
74994 oldfs = get_fs();
74995 set_fs(KERNEL_DS);
74996 err = clock_nanosleep_restart(restart);
74997 @@ -833,8 +834,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
74998 oldfs = get_fs();
74999 set_fs(KERNEL_DS);
75000 err = sys_clock_nanosleep(which_clock, flags,
75001 - (struct timespec __user *) &in,
75002 - (struct timespec __user *) &out);
75003 + (struct timespec __force_user *) &in,
75004 + (struct timespec __force_user *) &out);
75005 set_fs(oldfs);
75006
75007 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
75008 diff --git a/kernel/configs.c b/kernel/configs.c
75009 index c18b1f1..b9a0132 100644
75010 --- a/kernel/configs.c
75011 +++ b/kernel/configs.c
75012 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
75013 struct proc_dir_entry *entry;
75014
75015 /* create the current config file */
75016 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
75017 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
75018 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
75019 + &ikconfig_file_ops);
75020 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
75021 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
75022 + &ikconfig_file_ops);
75023 +#endif
75024 +#else
75025 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
75026 &ikconfig_file_ops);
75027 +#endif
75028 +
75029 if (!entry)
75030 return -ENOMEM;
75031
75032 diff --git a/kernel/cred.c b/kernel/cred.c
75033 index e0573a4..3874e41 100644
75034 --- a/kernel/cred.c
75035 +++ b/kernel/cred.c
75036 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
75037 validate_creds(cred);
75038 alter_cred_subscribers(cred, -1);
75039 put_cred(cred);
75040 +
75041 +#ifdef CONFIG_GRKERNSEC_SETXID
75042 + cred = (struct cred *) tsk->delayed_cred;
75043 + if (cred != NULL) {
75044 + tsk->delayed_cred = NULL;
75045 + validate_creds(cred);
75046 + alter_cred_subscribers(cred, -1);
75047 + put_cred(cred);
75048 + }
75049 +#endif
75050 }
75051
75052 /**
75053 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
75054 * Always returns 0 thus allowing this function to be tail-called at the end
75055 * of, say, sys_setgid().
75056 */
75057 -int commit_creds(struct cred *new)
75058 +static int __commit_creds(struct cred *new)
75059 {
75060 struct task_struct *task = current;
75061 const struct cred *old = task->real_cred;
75062 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
75063
75064 get_cred(new); /* we will require a ref for the subj creds too */
75065
75066 + gr_set_role_label(task, new->uid, new->gid);
75067 +
75068 /* dumpability changes */
75069 if (!uid_eq(old->euid, new->euid) ||
75070 !gid_eq(old->egid, new->egid) ||
75071 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
75072 put_cred(old);
75073 return 0;
75074 }
75075 +#ifdef CONFIG_GRKERNSEC_SETXID
75076 +extern int set_user(struct cred *new);
75077 +
75078 +void gr_delayed_cred_worker(void)
75079 +{
75080 + const struct cred *new = current->delayed_cred;
75081 + struct cred *ncred;
75082 +
75083 + current->delayed_cred = NULL;
75084 +
75085 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
75086 + // from doing get_cred on it when queueing this
75087 + put_cred(new);
75088 + return;
75089 + } else if (new == NULL)
75090 + return;
75091 +
75092 + ncred = prepare_creds();
75093 + if (!ncred)
75094 + goto die;
75095 + // uids
75096 + ncred->uid = new->uid;
75097 + ncred->euid = new->euid;
75098 + ncred->suid = new->suid;
75099 + ncred->fsuid = new->fsuid;
75100 + // gids
75101 + ncred->gid = new->gid;
75102 + ncred->egid = new->egid;
75103 + ncred->sgid = new->sgid;
75104 + ncred->fsgid = new->fsgid;
75105 + // groups
75106 + if (set_groups(ncred, new->group_info) < 0) {
75107 + abort_creds(ncred);
75108 + goto die;
75109 + }
75110 + // caps
75111 + ncred->securebits = new->securebits;
75112 + ncred->cap_inheritable = new->cap_inheritable;
75113 + ncred->cap_permitted = new->cap_permitted;
75114 + ncred->cap_effective = new->cap_effective;
75115 + ncred->cap_bset = new->cap_bset;
75116 +
75117 + if (set_user(ncred)) {
75118 + abort_creds(ncred);
75119 + goto die;
75120 + }
75121 +
75122 + // from doing get_cred on it when queueing this
75123 + put_cred(new);
75124 +
75125 + __commit_creds(ncred);
75126 + return;
75127 +die:
75128 + // from doing get_cred on it when queueing this
75129 + put_cred(new);
75130 + do_group_exit(SIGKILL);
75131 +}
75132 +#endif
75133 +
75134 +int commit_creds(struct cred *new)
75135 +{
75136 +#ifdef CONFIG_GRKERNSEC_SETXID
75137 + int ret;
75138 + int schedule_it = 0;
75139 + struct task_struct *t;
75140 +
75141 + /* we won't get called with tasklist_lock held for writing
75142 + and interrupts disabled as the cred struct in that case is
75143 + init_cred
75144 + */
75145 + if (grsec_enable_setxid && !current_is_single_threaded() &&
75146 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
75147 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
75148 + schedule_it = 1;
75149 + }
75150 + ret = __commit_creds(new);
75151 + if (schedule_it) {
75152 + rcu_read_lock();
75153 + read_lock(&tasklist_lock);
75154 + for (t = next_thread(current); t != current;
75155 + t = next_thread(t)) {
75156 + if (t->delayed_cred == NULL) {
75157 + t->delayed_cred = get_cred(new);
75158 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
75159 + set_tsk_need_resched(t);
75160 + }
75161 + }
75162 + read_unlock(&tasklist_lock);
75163 + rcu_read_unlock();
75164 + }
75165 + return ret;
75166 +#else
75167 + return __commit_creds(new);
75168 +#endif
75169 +}
75170 +
75171 EXPORT_SYMBOL(commit_creds);
75172
75173 /**
75174 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
75175 index 0506d44..2c20034 100644
75176 --- a/kernel/debug/debug_core.c
75177 +++ b/kernel/debug/debug_core.c
75178 @@ -123,7 +123,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
75179 */
75180 static atomic_t masters_in_kgdb;
75181 static atomic_t slaves_in_kgdb;
75182 -static atomic_t kgdb_break_tasklet_var;
75183 +static atomic_unchecked_t kgdb_break_tasklet_var;
75184 atomic_t kgdb_setting_breakpoint;
75185
75186 struct task_struct *kgdb_usethread;
75187 @@ -133,7 +133,7 @@ int kgdb_single_step;
75188 static pid_t kgdb_sstep_pid;
75189
75190 /* to keep track of the CPU which is doing the single stepping*/
75191 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
75192 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
75193
75194 /*
75195 * If you are debugging a problem where roundup (the collection of
75196 @@ -541,7 +541,7 @@ return_normal:
75197 * kernel will only try for the value of sstep_tries before
75198 * giving up and continuing on.
75199 */
75200 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
75201 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
75202 (kgdb_info[cpu].task &&
75203 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
75204 atomic_set(&kgdb_active, -1);
75205 @@ -635,8 +635,8 @@ cpu_master_loop:
75206 }
75207
75208 kgdb_restore:
75209 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
75210 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
75211 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
75212 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
75213 if (kgdb_info[sstep_cpu].task)
75214 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
75215 else
75216 @@ -888,18 +888,18 @@ static void kgdb_unregister_callbacks(void)
75217 static void kgdb_tasklet_bpt(unsigned long ing)
75218 {
75219 kgdb_breakpoint();
75220 - atomic_set(&kgdb_break_tasklet_var, 0);
75221 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
75222 }
75223
75224 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
75225
75226 void kgdb_schedule_breakpoint(void)
75227 {
75228 - if (atomic_read(&kgdb_break_tasklet_var) ||
75229 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
75230 atomic_read(&kgdb_active) != -1 ||
75231 atomic_read(&kgdb_setting_breakpoint))
75232 return;
75233 - atomic_inc(&kgdb_break_tasklet_var);
75234 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
75235 tasklet_schedule(&kgdb_tasklet_breakpoint);
75236 }
75237 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
75238 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
75239 index 00eb8f7..d7e3244 100644
75240 --- a/kernel/debug/kdb/kdb_main.c
75241 +++ b/kernel/debug/kdb/kdb_main.c
75242 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
75243 continue;
75244
75245 kdb_printf("%-20s%8u 0x%p ", mod->name,
75246 - mod->core_size, (void *)mod);
75247 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
75248 #ifdef CONFIG_MODULE_UNLOAD
75249 kdb_printf("%4ld ", module_refcount(mod));
75250 #endif
75251 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
75252 kdb_printf(" (Loading)");
75253 else
75254 kdb_printf(" (Live)");
75255 - kdb_printf(" 0x%p", mod->module_core);
75256 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
75257
75258 #ifdef CONFIG_MODULE_UNLOAD
75259 {
75260 diff --git a/kernel/events/core.c b/kernel/events/core.c
75261 index b391907..a0e2372 100644
75262 --- a/kernel/events/core.c
75263 +++ b/kernel/events/core.c
75264 @@ -156,8 +156,15 @@ static struct srcu_struct pmus_srcu;
75265 * 0 - disallow raw tracepoint access for unpriv
75266 * 1 - disallow cpu events for unpriv
75267 * 2 - disallow kernel profiling for unpriv
75268 + * 3 - disallow all unpriv perf event use
75269 */
75270 -int sysctl_perf_event_paranoid __read_mostly = 1;
75271 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
75272 +int sysctl_perf_event_legitimately_concerned __read_mostly = 3;
75273 +#elif defined(CONFIG_GRKERNSEC_HIDESYM)
75274 +int sysctl_perf_event_legitimately_concerned __read_mostly = 2;
75275 +#else
75276 +int sysctl_perf_event_legitimately_concerned __read_mostly = 1;
75277 +#endif
75278
75279 /* Minimum for 512 kiB + 1 user control page */
75280 int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
75281 @@ -184,7 +191,7 @@ int perf_proc_update_handler(struct ctl_table *table, int write,
75282 return 0;
75283 }
75284
75285 -static atomic64_t perf_event_id;
75286 +static atomic64_unchecked_t perf_event_id;
75287
75288 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
75289 enum event_type_t event_type);
75290 @@ -2725,7 +2732,7 @@ static void __perf_event_read(void *info)
75291
75292 static inline u64 perf_event_count(struct perf_event *event)
75293 {
75294 - return local64_read(&event->count) + atomic64_read(&event->child_count);
75295 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
75296 }
75297
75298 static u64 perf_event_read(struct perf_event *event)
75299 @@ -3071,9 +3078,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
75300 mutex_lock(&event->child_mutex);
75301 total += perf_event_read(event);
75302 *enabled += event->total_time_enabled +
75303 - atomic64_read(&event->child_total_time_enabled);
75304 + atomic64_read_unchecked(&event->child_total_time_enabled);
75305 *running += event->total_time_running +
75306 - atomic64_read(&event->child_total_time_running);
75307 + atomic64_read_unchecked(&event->child_total_time_running);
75308
75309 list_for_each_entry(child, &event->child_list, child_list) {
75310 total += perf_event_read(child);
75311 @@ -3459,10 +3466,10 @@ void perf_event_update_userpage(struct perf_event *event)
75312 userpg->offset -= local64_read(&event->hw.prev_count);
75313
75314 userpg->time_enabled = enabled +
75315 - atomic64_read(&event->child_total_time_enabled);
75316 + atomic64_read_unchecked(&event->child_total_time_enabled);
75317
75318 userpg->time_running = running +
75319 - atomic64_read(&event->child_total_time_running);
75320 + atomic64_read_unchecked(&event->child_total_time_running);
75321
75322 arch_perf_update_userpage(userpg, now);
75323
75324 @@ -4012,7 +4019,7 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size,
75325
75326 /* Data. */
75327 sp = perf_user_stack_pointer(regs);
75328 - rem = __output_copy_user(handle, (void *) sp, dump_size);
75329 + rem = __output_copy_user(handle, (void __user *) sp, dump_size);
75330 dyn_size = dump_size - rem;
75331
75332 perf_output_skip(handle, rem);
75333 @@ -4100,11 +4107,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
75334 values[n++] = perf_event_count(event);
75335 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
75336 values[n++] = enabled +
75337 - atomic64_read(&event->child_total_time_enabled);
75338 + atomic64_read_unchecked(&event->child_total_time_enabled);
75339 }
75340 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
75341 values[n++] = running +
75342 - atomic64_read(&event->child_total_time_running);
75343 + atomic64_read_unchecked(&event->child_total_time_running);
75344 }
75345 if (read_format & PERF_FORMAT_ID)
75346 values[n++] = primary_event_id(event);
75347 @@ -4813,12 +4820,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
75348 * need to add enough zero bytes after the string to handle
75349 * the 64bit alignment we do later.
75350 */
75351 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
75352 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
75353 if (!buf) {
75354 name = strncpy(tmp, "//enomem", sizeof(tmp));
75355 goto got_name;
75356 }
75357 - name = d_path(&file->f_path, buf, PATH_MAX);
75358 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
75359 if (IS_ERR(name)) {
75360 name = strncpy(tmp, "//toolong", sizeof(tmp));
75361 goto got_name;
75362 @@ -6240,7 +6247,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
75363 event->parent = parent_event;
75364
75365 event->ns = get_pid_ns(task_active_pid_ns(current));
75366 - event->id = atomic64_inc_return(&perf_event_id);
75367 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
75368
75369 event->state = PERF_EVENT_STATE_INACTIVE;
75370
75371 @@ -6550,6 +6557,11 @@ SYSCALL_DEFINE5(perf_event_open,
75372 if (flags & ~PERF_FLAG_ALL)
75373 return -EINVAL;
75374
75375 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
75376 + if (perf_paranoid_any() && !capable(CAP_SYS_ADMIN))
75377 + return -EACCES;
75378 +#endif
75379 +
75380 err = perf_copy_attr(attr_uptr, &attr);
75381 if (err)
75382 return err;
75383 @@ -6882,10 +6894,10 @@ static void sync_child_event(struct perf_event *child_event,
75384 /*
75385 * Add back the child's count to the parent's count:
75386 */
75387 - atomic64_add(child_val, &parent_event->child_count);
75388 - atomic64_add(child_event->total_time_enabled,
75389 + atomic64_add_unchecked(child_val, &parent_event->child_count);
75390 + atomic64_add_unchecked(child_event->total_time_enabled,
75391 &parent_event->child_total_time_enabled);
75392 - atomic64_add(child_event->total_time_running,
75393 + atomic64_add_unchecked(child_event->total_time_running,
75394 &parent_event->child_total_time_running);
75395
75396 /*
75397 diff --git a/kernel/events/internal.h b/kernel/events/internal.h
75398 index ca65997..cc8cee4 100644
75399 --- a/kernel/events/internal.h
75400 +++ b/kernel/events/internal.h
75401 @@ -81,10 +81,10 @@ static inline unsigned long perf_data_size(struct ring_buffer *rb)
75402 return rb->nr_pages << (PAGE_SHIFT + page_order(rb));
75403 }
75404
75405 -#define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \
75406 +#define DEFINE_OUTPUT_COPY(func_name, memcpy_func, user) \
75407 static inline unsigned int \
75408 func_name(struct perf_output_handle *handle, \
75409 - const void *buf, unsigned int len) \
75410 + const void user *buf, unsigned int len) \
75411 { \
75412 unsigned long size, written; \
75413 \
75414 @@ -116,17 +116,17 @@ static inline int memcpy_common(void *dst, const void *src, size_t n)
75415 return n;
75416 }
75417
75418 -DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
75419 +DEFINE_OUTPUT_COPY(__output_copy, memcpy_common, )
75420
75421 #define MEMCPY_SKIP(dst, src, n) (n)
75422
75423 -DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP)
75424 +DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP, )
75425
75426 #ifndef arch_perf_out_copy_user
75427 #define arch_perf_out_copy_user __copy_from_user_inatomic
75428 #endif
75429
75430 -DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
75431 +DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user, __user)
75432
75433 /* Callchain handling */
75434 extern struct perf_callchain_entry *
75435 diff --git a/kernel/exit.c b/kernel/exit.c
75436 index 7bb73f9..d7978ed 100644
75437 --- a/kernel/exit.c
75438 +++ b/kernel/exit.c
75439 @@ -172,6 +172,10 @@ void release_task(struct task_struct * p)
75440 struct task_struct *leader;
75441 int zap_leader;
75442 repeat:
75443 +#ifdef CONFIG_NET
75444 + gr_del_task_from_ip_table(p);
75445 +#endif
75446 +
75447 /* don't need to get the RCU readlock here - the process is dead and
75448 * can't be modifying its own credentials. But shut RCU-lockdep up */
75449 rcu_read_lock();
75450 @@ -340,7 +344,7 @@ int allow_signal(int sig)
75451 * know it'll be handled, so that they don't get converted to
75452 * SIGKILL or just silently dropped.
75453 */
75454 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
75455 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
75456 recalc_sigpending();
75457 spin_unlock_irq(&current->sighand->siglock);
75458 return 0;
75459 @@ -709,6 +713,8 @@ void do_exit(long code)
75460 struct task_struct *tsk = current;
75461 int group_dead;
75462
75463 + set_fs(USER_DS);
75464 +
75465 profile_task_exit(tsk);
75466
75467 WARN_ON(blk_needs_flush_plug(tsk));
75468 @@ -725,7 +731,6 @@ void do_exit(long code)
75469 * mm_release()->clear_child_tid() from writing to a user-controlled
75470 * kernel address.
75471 */
75472 - set_fs(USER_DS);
75473
75474 ptrace_event(PTRACE_EVENT_EXIT, code);
75475
75476 @@ -784,6 +789,9 @@ void do_exit(long code)
75477 tsk->exit_code = code;
75478 taskstats_exit(tsk, group_dead);
75479
75480 + gr_acl_handle_psacct(tsk, code);
75481 + gr_acl_handle_exit();
75482 +
75483 exit_mm(tsk);
75484
75485 if (group_dead)
75486 @@ -905,7 +913,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
75487 * Take down every thread in the group. This is called by fatal signals
75488 * as well as by sys_exit_group (below).
75489 */
75490 -void
75491 +__noreturn void
75492 do_group_exit(int exit_code)
75493 {
75494 struct signal_struct *sig = current->signal;
75495 diff --git a/kernel/fork.c b/kernel/fork.c
75496 index 987b28a..60e5ad2 100644
75497 --- a/kernel/fork.c
75498 +++ b/kernel/fork.c
75499 @@ -319,7 +319,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
75500 *stackend = STACK_END_MAGIC; /* for overflow detection */
75501
75502 #ifdef CONFIG_CC_STACKPROTECTOR
75503 - tsk->stack_canary = get_random_int();
75504 + tsk->stack_canary = pax_get_random_long();
75505 #endif
75506
75507 /*
75508 @@ -345,13 +345,81 @@ free_tsk:
75509 }
75510
75511 #ifdef CONFIG_MMU
75512 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
75513 +{
75514 + struct vm_area_struct *tmp;
75515 + unsigned long charge;
75516 + struct mempolicy *pol;
75517 + struct file *file;
75518 +
75519 + charge = 0;
75520 + if (mpnt->vm_flags & VM_ACCOUNT) {
75521 + unsigned long len = vma_pages(mpnt);
75522 +
75523 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
75524 + goto fail_nomem;
75525 + charge = len;
75526 + }
75527 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
75528 + if (!tmp)
75529 + goto fail_nomem;
75530 + *tmp = *mpnt;
75531 + tmp->vm_mm = mm;
75532 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
75533 + pol = mpol_dup(vma_policy(mpnt));
75534 + if (IS_ERR(pol))
75535 + goto fail_nomem_policy;
75536 + vma_set_policy(tmp, pol);
75537 + if (anon_vma_fork(tmp, mpnt))
75538 + goto fail_nomem_anon_vma_fork;
75539 + tmp->vm_flags &= ~VM_LOCKED;
75540 + tmp->vm_next = tmp->vm_prev = NULL;
75541 + tmp->vm_mirror = NULL;
75542 + file = tmp->vm_file;
75543 + if (file) {
75544 + struct inode *inode = file_inode(file);
75545 + struct address_space *mapping = file->f_mapping;
75546 +
75547 + get_file(file);
75548 + if (tmp->vm_flags & VM_DENYWRITE)
75549 + atomic_dec(&inode->i_writecount);
75550 + mutex_lock(&mapping->i_mmap_mutex);
75551 + if (tmp->vm_flags & VM_SHARED)
75552 + mapping->i_mmap_writable++;
75553 + flush_dcache_mmap_lock(mapping);
75554 + /* insert tmp into the share list, just after mpnt */
75555 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
75556 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
75557 + else
75558 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
75559 + flush_dcache_mmap_unlock(mapping);
75560 + mutex_unlock(&mapping->i_mmap_mutex);
75561 + }
75562 +
75563 + /*
75564 + * Clear hugetlb-related page reserves for children. This only
75565 + * affects MAP_PRIVATE mappings. Faults generated by the child
75566 + * are not guaranteed to succeed, even if read-only
75567 + */
75568 + if (is_vm_hugetlb_page(tmp))
75569 + reset_vma_resv_huge_pages(tmp);
75570 +
75571 + return tmp;
75572 +
75573 +fail_nomem_anon_vma_fork:
75574 + mpol_put(pol);
75575 +fail_nomem_policy:
75576 + kmem_cache_free(vm_area_cachep, tmp);
75577 +fail_nomem:
75578 + vm_unacct_memory(charge);
75579 + return NULL;
75580 +}
75581 +
75582 static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75583 {
75584 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
75585 struct rb_node **rb_link, *rb_parent;
75586 int retval;
75587 - unsigned long charge;
75588 - struct mempolicy *pol;
75589
75590 uprobe_start_dup_mmap();
75591 down_write(&oldmm->mmap_sem);
75592 @@ -365,8 +433,8 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75593 mm->locked_vm = 0;
75594 mm->mmap = NULL;
75595 mm->mmap_cache = NULL;
75596 - mm->free_area_cache = oldmm->mmap_base;
75597 - mm->cached_hole_size = ~0UL;
75598 + mm->free_area_cache = oldmm->free_area_cache;
75599 + mm->cached_hole_size = oldmm->cached_hole_size;
75600 mm->map_count = 0;
75601 cpumask_clear(mm_cpumask(mm));
75602 mm->mm_rb = RB_ROOT;
75603 @@ -382,57 +450,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75604
75605 prev = NULL;
75606 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
75607 - struct file *file;
75608 -
75609 if (mpnt->vm_flags & VM_DONTCOPY) {
75610 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
75611 -vma_pages(mpnt));
75612 continue;
75613 }
75614 - charge = 0;
75615 - if (mpnt->vm_flags & VM_ACCOUNT) {
75616 - unsigned long len = vma_pages(mpnt);
75617 -
75618 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
75619 - goto fail_nomem;
75620 - charge = len;
75621 - }
75622 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
75623 - if (!tmp)
75624 - goto fail_nomem;
75625 - *tmp = *mpnt;
75626 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
75627 - pol = mpol_dup(vma_policy(mpnt));
75628 - retval = PTR_ERR(pol);
75629 - if (IS_ERR(pol))
75630 - goto fail_nomem_policy;
75631 - vma_set_policy(tmp, pol);
75632 - tmp->vm_mm = mm;
75633 - if (anon_vma_fork(tmp, mpnt))
75634 - goto fail_nomem_anon_vma_fork;
75635 - tmp->vm_flags &= ~VM_LOCKED;
75636 - tmp->vm_next = tmp->vm_prev = NULL;
75637 - file = tmp->vm_file;
75638 - if (file) {
75639 - struct inode *inode = file_inode(file);
75640 - struct address_space *mapping = file->f_mapping;
75641 -
75642 - get_file(file);
75643 - if (tmp->vm_flags & VM_DENYWRITE)
75644 - atomic_dec(&inode->i_writecount);
75645 - mutex_lock(&mapping->i_mmap_mutex);
75646 - if (tmp->vm_flags & VM_SHARED)
75647 - mapping->i_mmap_writable++;
75648 - flush_dcache_mmap_lock(mapping);
75649 - /* insert tmp into the share list, just after mpnt */
75650 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
75651 - vma_nonlinear_insert(tmp,
75652 - &mapping->i_mmap_nonlinear);
75653 - else
75654 - vma_interval_tree_insert_after(tmp, mpnt,
75655 - &mapping->i_mmap);
75656 - flush_dcache_mmap_unlock(mapping);
75657 - mutex_unlock(&mapping->i_mmap_mutex);
75658 + tmp = dup_vma(mm, oldmm, mpnt);
75659 + if (!tmp) {
75660 + retval = -ENOMEM;
75661 + goto out;
75662 }
75663
75664 /*
75665 @@ -464,6 +490,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
75666 if (retval)
75667 goto out;
75668 }
75669 +
75670 +#ifdef CONFIG_PAX_SEGMEXEC
75671 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
75672 + struct vm_area_struct *mpnt_m;
75673 +
75674 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
75675 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
75676 +
75677 + if (!mpnt->vm_mirror)
75678 + continue;
75679 +
75680 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
75681 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
75682 + mpnt->vm_mirror = mpnt_m;
75683 + } else {
75684 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
75685 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
75686 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
75687 + mpnt->vm_mirror->vm_mirror = mpnt;
75688 + }
75689 + }
75690 + BUG_ON(mpnt_m);
75691 + }
75692 +#endif
75693 +
75694 /* a new mm has just been created */
75695 arch_dup_mmap(oldmm, mm);
75696 retval = 0;
75697 @@ -473,14 +524,6 @@ out:
75698 up_write(&oldmm->mmap_sem);
75699 uprobe_end_dup_mmap();
75700 return retval;
75701 -fail_nomem_anon_vma_fork:
75702 - mpol_put(pol);
75703 -fail_nomem_policy:
75704 - kmem_cache_free(vm_area_cachep, tmp);
75705 -fail_nomem:
75706 - retval = -ENOMEM;
75707 - vm_unacct_memory(charge);
75708 - goto out;
75709 }
75710
75711 static inline int mm_alloc_pgd(struct mm_struct *mm)
75712 @@ -695,8 +738,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
75713 return ERR_PTR(err);
75714
75715 mm = get_task_mm(task);
75716 - if (mm && mm != current->mm &&
75717 - !ptrace_may_access(task, mode)) {
75718 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
75719 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
75720 mmput(mm);
75721 mm = ERR_PTR(-EACCES);
75722 }
75723 @@ -918,13 +961,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
75724 spin_unlock(&fs->lock);
75725 return -EAGAIN;
75726 }
75727 - fs->users++;
75728 + atomic_inc(&fs->users);
75729 spin_unlock(&fs->lock);
75730 return 0;
75731 }
75732 tsk->fs = copy_fs_struct(fs);
75733 if (!tsk->fs)
75734 return -ENOMEM;
75735 + /* Carry through gr_chroot_dentry and is_chrooted instead
75736 + of recomputing it here. Already copied when the task struct
75737 + is duplicated. This allows pivot_root to not be treated as
75738 + a chroot
75739 + */
75740 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
75741 +
75742 return 0;
75743 }
75744
75745 @@ -1197,6 +1247,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
75746 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
75747 #endif
75748 retval = -EAGAIN;
75749 +
75750 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
75751 +
75752 if (atomic_read(&p->real_cred->user->processes) >=
75753 task_rlimit(p, RLIMIT_NPROC)) {
75754 if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
75755 @@ -1446,6 +1499,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
75756 goto bad_fork_free_pid;
75757 }
75758
75759 + /* synchronizes with gr_set_acls()
75760 + we need to call this past the point of no return for fork()
75761 + */
75762 + gr_copy_label(p);
75763 +
75764 if (clone_flags & CLONE_THREAD) {
75765 current->signal->nr_threads++;
75766 atomic_inc(&current->signal->live);
75767 @@ -1529,6 +1587,8 @@ bad_fork_cleanup_count:
75768 bad_fork_free:
75769 free_task(p);
75770 fork_out:
75771 + gr_log_forkfail(retval);
75772 +
75773 return ERR_PTR(retval);
75774 }
75775
75776 @@ -1579,6 +1639,23 @@ long do_fork(unsigned long clone_flags,
75777 return -EINVAL;
75778 }
75779
75780 +#ifdef CONFIG_GRKERNSEC
75781 + if (clone_flags & CLONE_NEWUSER) {
75782 + /*
75783 + * This doesn't really inspire confidence:
75784 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
75785 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
75786 + * Increases kernel attack surface in areas developers
75787 + * previously cared little about ("low importance due
75788 + * to requiring "root" capability")
75789 + * To be removed when this code receives *proper* review
75790 + */
75791 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
75792 + !capable(CAP_SETGID))
75793 + return -EPERM;
75794 + }
75795 +#endif
75796 +
75797 /*
75798 * Determine whether and which event to report to ptracer. When
75799 * called from kernel_thread or CLONE_UNTRACED is explicitly
75800 @@ -1613,6 +1690,8 @@ long do_fork(unsigned long clone_flags,
75801 if (clone_flags & CLONE_PARENT_SETTID)
75802 put_user(nr, parent_tidptr);
75803
75804 + gr_handle_brute_check();
75805 +
75806 if (clone_flags & CLONE_VFORK) {
75807 p->vfork_done = &vfork;
75808 init_completion(&vfork);
75809 @@ -1763,7 +1842,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
75810 return 0;
75811
75812 /* don't need lock here; in the worst case we'll do useless copy */
75813 - if (fs->users == 1)
75814 + if (atomic_read(&fs->users) == 1)
75815 return 0;
75816
75817 *new_fsp = copy_fs_struct(fs);
75818 @@ -1875,7 +1954,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
75819 fs = current->fs;
75820 spin_lock(&fs->lock);
75821 current->fs = new_fs;
75822 - if (--fs->users)
75823 + gr_set_chroot_entries(current, &current->fs->root);
75824 + if (atomic_dec_return(&fs->users))
75825 new_fs = NULL;
75826 else
75827 new_fs = fs;
75828 diff --git a/kernel/futex.c b/kernel/futex.c
75829 index b26dcfc..39e266a 100644
75830 --- a/kernel/futex.c
75831 +++ b/kernel/futex.c
75832 @@ -54,6 +54,7 @@
75833 #include <linux/mount.h>
75834 #include <linux/pagemap.h>
75835 #include <linux/syscalls.h>
75836 +#include <linux/ptrace.h>
75837 #include <linux/signal.h>
75838 #include <linux/export.h>
75839 #include <linux/magic.h>
75840 @@ -241,6 +242,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
75841 struct page *page, *page_head;
75842 int err, ro = 0;
75843
75844 +#ifdef CONFIG_PAX_SEGMEXEC
75845 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
75846 + return -EFAULT;
75847 +#endif
75848 +
75849 /*
75850 * The futex address must be "naturally" aligned.
75851 */
75852 @@ -2732,6 +2738,7 @@ static int __init futex_init(void)
75853 {
75854 u32 curval;
75855 int i;
75856 + mm_segment_t oldfs;
75857
75858 /*
75859 * This will fail and we want it. Some arch implementations do
75860 @@ -2743,8 +2750,11 @@ static int __init futex_init(void)
75861 * implementation, the non-functional ones will return
75862 * -ENOSYS.
75863 */
75864 + oldfs = get_fs();
75865 + set_fs(USER_DS);
75866 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
75867 futex_cmpxchg_enabled = 1;
75868 + set_fs(oldfs);
75869
75870 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
75871 plist_head_init(&futex_queues[i].chain);
75872 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
75873 index f9f44fd..29885e4 100644
75874 --- a/kernel/futex_compat.c
75875 +++ b/kernel/futex_compat.c
75876 @@ -32,7 +32,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
75877 return 0;
75878 }
75879
75880 -static void __user *futex_uaddr(struct robust_list __user *entry,
75881 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
75882 compat_long_t futex_offset)
75883 {
75884 compat_uptr_t base = ptr_to_compat(entry);
75885 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
75886 index 9b22d03..6295b62 100644
75887 --- a/kernel/gcov/base.c
75888 +++ b/kernel/gcov/base.c
75889 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
75890 }
75891
75892 #ifdef CONFIG_MODULES
75893 -static inline int within(void *addr, void *start, unsigned long size)
75894 -{
75895 - return ((addr >= start) && (addr < start + size));
75896 -}
75897 -
75898 /* Update list and generate events when modules are unloaded. */
75899 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
75900 void *data)
75901 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
75902 prev = NULL;
75903 /* Remove entries located in module from linked list. */
75904 for (info = gcov_info_head; info; info = info->next) {
75905 - if (within(info, mod->module_core, mod->core_size)) {
75906 + if (within_module_core_rw((unsigned long)info, mod)) {
75907 if (prev)
75908 prev->next = info->next;
75909 else
75910 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
75911 index fd4b13b..09a5ccb 100644
75912 --- a/kernel/hrtimer.c
75913 +++ b/kernel/hrtimer.c
75914 @@ -1430,7 +1430,7 @@ void hrtimer_peek_ahead_timers(void)
75915 local_irq_restore(flags);
75916 }
75917
75918 -static void run_hrtimer_softirq(struct softirq_action *h)
75919 +static void run_hrtimer_softirq(void)
75920 {
75921 struct hrtimer_cpu_base *cpu_base = &__get_cpu_var(hrtimer_bases);
75922
75923 @@ -1772,7 +1772,7 @@ static int __cpuinit hrtimer_cpu_notify(struct notifier_block *self,
75924 return NOTIFY_OK;
75925 }
75926
75927 -static struct notifier_block __cpuinitdata hrtimers_nb = {
75928 +static struct notifier_block hrtimers_nb = {
75929 .notifier_call = hrtimer_cpu_notify,
75930 };
75931
75932 diff --git a/kernel/irq_work.c b/kernel/irq_work.c
75933 index 55fcce6..0e4cf34 100644
75934 --- a/kernel/irq_work.c
75935 +++ b/kernel/irq_work.c
75936 @@ -189,12 +189,13 @@ static int irq_work_cpu_notify(struct notifier_block *self,
75937 return NOTIFY_OK;
75938 }
75939
75940 -static struct notifier_block cpu_notify;
75941 +static struct notifier_block cpu_notify = {
75942 + .notifier_call = irq_work_cpu_notify,
75943 + .priority = 0,
75944 +};
75945
75946 static __init int irq_work_init_cpu_notifier(void)
75947 {
75948 - cpu_notify.notifier_call = irq_work_cpu_notify;
75949 - cpu_notify.priority = 0;
75950 register_cpu_notifier(&cpu_notify);
75951 return 0;
75952 }
75953 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
75954 index 60f48fa..7f3a770 100644
75955 --- a/kernel/jump_label.c
75956 +++ b/kernel/jump_label.c
75957 @@ -13,6 +13,7 @@
75958 #include <linux/sort.h>
75959 #include <linux/err.h>
75960 #include <linux/static_key.h>
75961 +#include <linux/mm.h>
75962
75963 #ifdef HAVE_JUMP_LABEL
75964
75965 @@ -50,7 +51,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
75966
75967 size = (((unsigned long)stop - (unsigned long)start)
75968 / sizeof(struct jump_entry));
75969 + pax_open_kernel();
75970 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
75971 + pax_close_kernel();
75972 }
75973
75974 static void jump_label_update(struct static_key *key, int enable);
75975 @@ -357,10 +360,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
75976 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
75977 struct jump_entry *iter;
75978
75979 + pax_open_kernel();
75980 for (iter = iter_start; iter < iter_stop; iter++) {
75981 if (within_module_init(iter->code, mod))
75982 iter->code = 0;
75983 }
75984 + pax_close_kernel();
75985 }
75986
75987 static int
75988 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
75989 index 3127ad5..159d880 100644
75990 --- a/kernel/kallsyms.c
75991 +++ b/kernel/kallsyms.c
75992 @@ -11,6 +11,9 @@
75993 * Changed the compression method from stem compression to "table lookup"
75994 * compression (see scripts/kallsyms.c for a more complete description)
75995 */
75996 +#ifdef CONFIG_GRKERNSEC_HIDESYM
75997 +#define __INCLUDED_BY_HIDESYM 1
75998 +#endif
75999 #include <linux/kallsyms.h>
76000 #include <linux/module.h>
76001 #include <linux/init.h>
76002 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
76003
76004 static inline int is_kernel_inittext(unsigned long addr)
76005 {
76006 + if (system_state != SYSTEM_BOOTING)
76007 + return 0;
76008 +
76009 if (addr >= (unsigned long)_sinittext
76010 && addr <= (unsigned long)_einittext)
76011 return 1;
76012 return 0;
76013 }
76014
76015 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
76016 +#ifdef CONFIG_MODULES
76017 +static inline int is_module_text(unsigned long addr)
76018 +{
76019 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
76020 + return 1;
76021 +
76022 + addr = ktla_ktva(addr);
76023 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
76024 +}
76025 +#else
76026 +static inline int is_module_text(unsigned long addr)
76027 +{
76028 + return 0;
76029 +}
76030 +#endif
76031 +#endif
76032 +
76033 static inline int is_kernel_text(unsigned long addr)
76034 {
76035 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
76036 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
76037
76038 static inline int is_kernel(unsigned long addr)
76039 {
76040 +
76041 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
76042 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
76043 + return 1;
76044 +
76045 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
76046 +#else
76047 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
76048 +#endif
76049 +
76050 return 1;
76051 return in_gate_area_no_mm(addr);
76052 }
76053
76054 static int is_ksym_addr(unsigned long addr)
76055 {
76056 +
76057 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
76058 + if (is_module_text(addr))
76059 + return 0;
76060 +#endif
76061 +
76062 if (all_var)
76063 return is_kernel(addr);
76064
76065 @@ -480,7 +519,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
76066
76067 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
76068 {
76069 - iter->name[0] = '\0';
76070 iter->nameoff = get_symbol_offset(new_pos);
76071 iter->pos = new_pos;
76072 }
76073 @@ -528,6 +566,11 @@ static int s_show(struct seq_file *m, void *p)
76074 {
76075 struct kallsym_iter *iter = m->private;
76076
76077 +#ifdef CONFIG_GRKERNSEC_HIDESYM
76078 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
76079 + return 0;
76080 +#endif
76081 +
76082 /* Some debugging symbols have no name. Ignore them. */
76083 if (!iter->name[0])
76084 return 0;
76085 @@ -541,6 +584,7 @@ static int s_show(struct seq_file *m, void *p)
76086 */
76087 type = iter->exported ? toupper(iter->type) :
76088 tolower(iter->type);
76089 +
76090 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
76091 type, iter->name, iter->module_name);
76092 } else
76093 @@ -566,7 +610,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
76094 struct kallsym_iter *iter;
76095 int ret;
76096
76097 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
76098 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
76099 if (!iter)
76100 return -ENOMEM;
76101 reset_iter(iter, 0);
76102 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
76103 index e30ac0f..3528cac 100644
76104 --- a/kernel/kcmp.c
76105 +++ b/kernel/kcmp.c
76106 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
76107 struct task_struct *task1, *task2;
76108 int ret;
76109
76110 +#ifdef CONFIG_GRKERNSEC
76111 + return -ENOSYS;
76112 +#endif
76113 +
76114 rcu_read_lock();
76115
76116 /*
76117 diff --git a/kernel/kexec.c b/kernel/kexec.c
76118 index 59f7b55..4022f65 100644
76119 --- a/kernel/kexec.c
76120 +++ b/kernel/kexec.c
76121 @@ -1041,7 +1041,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
76122 unsigned long flags)
76123 {
76124 struct compat_kexec_segment in;
76125 - struct kexec_segment out, __user *ksegments;
76126 + struct kexec_segment out;
76127 + struct kexec_segment __user *ksegments;
76128 unsigned long i, result;
76129
76130 /* Don't allow clients that don't understand the native
76131 diff --git a/kernel/kmod.c b/kernel/kmod.c
76132 index 8241906..d625f2c 100644
76133 --- a/kernel/kmod.c
76134 +++ b/kernel/kmod.c
76135 @@ -75,7 +75,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
76136 kfree(info->argv);
76137 }
76138
76139 -static int call_modprobe(char *module_name, int wait)
76140 +static int call_modprobe(char *module_name, char *module_param, int wait)
76141 {
76142 struct subprocess_info *info;
76143 static char *envp[] = {
76144 @@ -85,7 +85,7 @@ static int call_modprobe(char *module_name, int wait)
76145 NULL
76146 };
76147
76148 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
76149 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
76150 if (!argv)
76151 goto out;
76152
76153 @@ -97,7 +97,8 @@ static int call_modprobe(char *module_name, int wait)
76154 argv[1] = "-q";
76155 argv[2] = "--";
76156 argv[3] = module_name; /* check free_modprobe_argv() */
76157 - argv[4] = NULL;
76158 + argv[4] = module_param;
76159 + argv[5] = NULL;
76160
76161 info = call_usermodehelper_setup(modprobe_path, argv, envp, GFP_KERNEL,
76162 NULL, free_modprobe_argv, NULL);
76163 @@ -129,9 +130,8 @@ out:
76164 * If module auto-loading support is disabled then this function
76165 * becomes a no-operation.
76166 */
76167 -int __request_module(bool wait, const char *fmt, ...)
76168 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
76169 {
76170 - va_list args;
76171 char module_name[MODULE_NAME_LEN];
76172 unsigned int max_modprobes;
76173 int ret;
76174 @@ -147,9 +147,7 @@ int __request_module(bool wait, const char *fmt, ...)
76175 */
76176 WARN_ON_ONCE(wait && current_is_async());
76177
76178 - va_start(args, fmt);
76179 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
76180 - va_end(args);
76181 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
76182 if (ret >= MODULE_NAME_LEN)
76183 return -ENAMETOOLONG;
76184
76185 @@ -157,6 +155,20 @@ int __request_module(bool wait, const char *fmt, ...)
76186 if (ret)
76187 return ret;
76188
76189 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76190 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
76191 + /* hack to workaround consolekit/udisks stupidity */
76192 + read_lock(&tasklist_lock);
76193 + if (!strcmp(current->comm, "mount") &&
76194 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
76195 + read_unlock(&tasklist_lock);
76196 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
76197 + return -EPERM;
76198 + }
76199 + read_unlock(&tasklist_lock);
76200 + }
76201 +#endif
76202 +
76203 /* If modprobe needs a service that is in a module, we get a recursive
76204 * loop. Limit the number of running kmod threads to max_threads/2 or
76205 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
76206 @@ -185,11 +197,52 @@ int __request_module(bool wait, const char *fmt, ...)
76207
76208 trace_module_request(module_name, wait, _RET_IP_);
76209
76210 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
76211 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
76212
76213 atomic_dec(&kmod_concurrent);
76214 return ret;
76215 }
76216 +
76217 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
76218 +{
76219 + va_list args;
76220 + int ret;
76221 +
76222 + va_start(args, fmt);
76223 + ret = ____request_module(wait, module_param, fmt, args);
76224 + va_end(args);
76225 +
76226 + return ret;
76227 +}
76228 +
76229 +int __request_module(bool wait, const char *fmt, ...)
76230 +{
76231 + va_list args;
76232 + int ret;
76233 +
76234 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76235 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
76236 + char module_param[MODULE_NAME_LEN];
76237 +
76238 + memset(module_param, 0, sizeof(module_param));
76239 +
76240 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
76241 +
76242 + va_start(args, fmt);
76243 + ret = ____request_module(wait, module_param, fmt, args);
76244 + va_end(args);
76245 +
76246 + return ret;
76247 + }
76248 +#endif
76249 +
76250 + va_start(args, fmt);
76251 + ret = ____request_module(wait, NULL, fmt, args);
76252 + va_end(args);
76253 +
76254 + return ret;
76255 +}
76256 +
76257 EXPORT_SYMBOL(__request_module);
76258 #endif /* CONFIG_MODULES */
76259
76260 @@ -300,7 +353,7 @@ static int wait_for_helper(void *data)
76261 *
76262 * Thus the __user pointer cast is valid here.
76263 */
76264 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
76265 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
76266
76267 /*
76268 * If ret is 0, either ____call_usermodehelper failed and the
76269 @@ -651,7 +704,7 @@ EXPORT_SYMBOL(call_usermodehelper);
76270 static int proc_cap_handler(struct ctl_table *table, int write,
76271 void __user *buffer, size_t *lenp, loff_t *ppos)
76272 {
76273 - struct ctl_table t;
76274 + ctl_table_no_const t;
76275 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
76276 kernel_cap_t new_cap;
76277 int err, i;
76278 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
76279 index bddf3b2..07b90dd 100644
76280 --- a/kernel/kprobes.c
76281 +++ b/kernel/kprobes.c
76282 @@ -185,7 +185,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
76283 * kernel image and loaded module images reside. This is required
76284 * so x86_64 can correctly handle the %rip-relative fixups.
76285 */
76286 - kip->insns = module_alloc(PAGE_SIZE);
76287 + kip->insns = module_alloc_exec(PAGE_SIZE);
76288 if (!kip->insns) {
76289 kfree(kip);
76290 return NULL;
76291 @@ -225,7 +225,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
76292 */
76293 if (!list_is_singular(&kip->list)) {
76294 list_del(&kip->list);
76295 - module_free(NULL, kip->insns);
76296 + module_free_exec(NULL, kip->insns);
76297 kfree(kip);
76298 }
76299 return 1;
76300 @@ -2083,7 +2083,7 @@ static int __init init_kprobes(void)
76301 {
76302 int i, err = 0;
76303 unsigned long offset = 0, size = 0;
76304 - char *modname, namebuf[128];
76305 + char *modname, namebuf[KSYM_NAME_LEN];
76306 const char *symbol_name;
76307 void *addr;
76308 struct kprobe_blackpoint *kb;
76309 @@ -2168,11 +2168,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
76310 kprobe_type = "k";
76311
76312 if (sym)
76313 - seq_printf(pi, "%p %s %s+0x%x %s ",
76314 + seq_printf(pi, "%pK %s %s+0x%x %s ",
76315 p->addr, kprobe_type, sym, offset,
76316 (modname ? modname : " "));
76317 else
76318 - seq_printf(pi, "%p %s %p ",
76319 + seq_printf(pi, "%pK %s %pK ",
76320 p->addr, kprobe_type, p->addr);
76321
76322 if (!pp)
76323 @@ -2209,7 +2209,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
76324 const char *sym = NULL;
76325 unsigned int i = *(loff_t *) v;
76326 unsigned long offset = 0;
76327 - char *modname, namebuf[128];
76328 + char *modname, namebuf[KSYM_NAME_LEN];
76329
76330 head = &kprobe_table[i];
76331 preempt_disable();
76332 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
76333 index 6ada93c..dce7d5d 100644
76334 --- a/kernel/ksysfs.c
76335 +++ b/kernel/ksysfs.c
76336 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
76337 {
76338 if (count+1 > UEVENT_HELPER_PATH_LEN)
76339 return -ENOENT;
76340 + if (!capable(CAP_SYS_ADMIN))
76341 + return -EPERM;
76342 memcpy(uevent_helper, buf, count);
76343 uevent_helper[count] = '\0';
76344 if (count && uevent_helper[count-1] == '\n')
76345 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
76346 return count;
76347 }
76348
76349 -static struct bin_attribute notes_attr = {
76350 +static bin_attribute_no_const notes_attr __read_only = {
76351 .attr = {
76352 .name = "notes",
76353 .mode = S_IRUGO,
76354 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
76355 index 1f3186b..bb7dbc6 100644
76356 --- a/kernel/lockdep.c
76357 +++ b/kernel/lockdep.c
76358 @@ -596,6 +596,10 @@ static int static_obj(void *obj)
76359 end = (unsigned long) &_end,
76360 addr = (unsigned long) obj;
76361
76362 +#ifdef CONFIG_PAX_KERNEXEC
76363 + start = ktla_ktva(start);
76364 +#endif
76365 +
76366 /*
76367 * static variable?
76368 */
76369 @@ -736,6 +740,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
76370 if (!static_obj(lock->key)) {
76371 debug_locks_off();
76372 printk("INFO: trying to register non-static key.\n");
76373 + printk("lock:%pS key:%pS.\n", lock, lock->key);
76374 printk("the code is fine but needs lockdep annotation.\n");
76375 printk("turning off the locking correctness validator.\n");
76376 dump_stack();
76377 @@ -3080,7 +3085,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
76378 if (!class)
76379 return 0;
76380 }
76381 - atomic_inc((atomic_t *)&class->ops);
76382 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
76383 if (very_verbose(class)) {
76384 printk("\nacquire class [%p] %s", class->key, class->name);
76385 if (class->name_version > 1)
76386 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
76387 index b2c71c5..7b88d63 100644
76388 --- a/kernel/lockdep_proc.c
76389 +++ b/kernel/lockdep_proc.c
76390 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
76391 return 0;
76392 }
76393
76394 - seq_printf(m, "%p", class->key);
76395 + seq_printf(m, "%pK", class->key);
76396 #ifdef CONFIG_DEBUG_LOCKDEP
76397 seq_printf(m, " OPS:%8ld", class->ops);
76398 #endif
76399 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
76400
76401 list_for_each_entry(entry, &class->locks_after, entry) {
76402 if (entry->distance == 1) {
76403 - seq_printf(m, " -> [%p] ", entry->class->key);
76404 + seq_printf(m, " -> [%pK] ", entry->class->key);
76405 print_name(m, entry->class);
76406 seq_puts(m, "\n");
76407 }
76408 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
76409 if (!class->key)
76410 continue;
76411
76412 - seq_printf(m, "[%p] ", class->key);
76413 + seq_printf(m, "[%pK] ", class->key);
76414 print_name(m, class);
76415 seq_puts(m, "\n");
76416 }
76417 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
76418 if (!i)
76419 seq_line(m, '-', 40-namelen, namelen);
76420
76421 - snprintf(ip, sizeof(ip), "[<%p>]",
76422 + snprintf(ip, sizeof(ip), "[<%pK>]",
76423 (void *)class->contention_point[i]);
76424 seq_printf(m, "%40s %14lu %29s %pS\n",
76425 name, stats->contention_point[i],
76426 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
76427 if (!i)
76428 seq_line(m, '-', 40-namelen, namelen);
76429
76430 - snprintf(ip, sizeof(ip), "[<%p>]",
76431 + snprintf(ip, sizeof(ip), "[<%pK>]",
76432 (void *)class->contending_point[i]);
76433 seq_printf(m, "%40s %14lu %29s %pS\n",
76434 name, stats->contending_point[i],
76435 diff --git a/kernel/module.c b/kernel/module.c
76436 index cab4bce..2025a6e 100644
76437 --- a/kernel/module.c
76438 +++ b/kernel/module.c
76439 @@ -61,6 +61,7 @@
76440 #include <linux/pfn.h>
76441 #include <linux/bsearch.h>
76442 #include <linux/fips.h>
76443 +#include <linux/grsecurity.h>
76444 #include <uapi/linux/module.h>
76445 #include "module-internal.h"
76446
76447 @@ -156,7 +157,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
76448
76449 /* Bounds of module allocation, for speeding __module_address.
76450 * Protected by module_mutex. */
76451 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
76452 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
76453 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
76454
76455 int register_module_notifier(struct notifier_block * nb)
76456 {
76457 @@ -323,7 +325,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
76458 return true;
76459
76460 list_for_each_entry_rcu(mod, &modules, list) {
76461 - struct symsearch arr[] = {
76462 + struct symsearch modarr[] = {
76463 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
76464 NOT_GPL_ONLY, false },
76465 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
76466 @@ -348,7 +350,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
76467 if (mod->state == MODULE_STATE_UNFORMED)
76468 continue;
76469
76470 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
76471 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
76472 return true;
76473 }
76474 return false;
76475 @@ -485,7 +487,7 @@ static inline void __percpu *mod_percpu(struct module *mod)
76476 static int percpu_modalloc(struct module *mod,
76477 unsigned long size, unsigned long align)
76478 {
76479 - if (align > PAGE_SIZE) {
76480 + if (align-1 >= PAGE_SIZE) {
76481 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
76482 mod->name, align, PAGE_SIZE);
76483 align = PAGE_SIZE;
76484 @@ -1089,7 +1091,7 @@ struct module_attribute module_uevent =
76485 static ssize_t show_coresize(struct module_attribute *mattr,
76486 struct module_kobject *mk, char *buffer)
76487 {
76488 - return sprintf(buffer, "%u\n", mk->mod->core_size);
76489 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
76490 }
76491
76492 static struct module_attribute modinfo_coresize =
76493 @@ -1098,7 +1100,7 @@ static struct module_attribute modinfo_coresize =
76494 static ssize_t show_initsize(struct module_attribute *mattr,
76495 struct module_kobject *mk, char *buffer)
76496 {
76497 - return sprintf(buffer, "%u\n", mk->mod->init_size);
76498 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
76499 }
76500
76501 static struct module_attribute modinfo_initsize =
76502 @@ -1313,7 +1315,7 @@ resolve_symbol_wait(struct module *mod,
76503 */
76504 #ifdef CONFIG_SYSFS
76505
76506 -#ifdef CONFIG_KALLSYMS
76507 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
76508 static inline bool sect_empty(const Elf_Shdr *sect)
76509 {
76510 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
76511 @@ -1453,7 +1455,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
76512 {
76513 unsigned int notes, loaded, i;
76514 struct module_notes_attrs *notes_attrs;
76515 - struct bin_attribute *nattr;
76516 + bin_attribute_no_const *nattr;
76517
76518 /* failed to create section attributes, so can't create notes */
76519 if (!mod->sect_attrs)
76520 @@ -1565,7 +1567,7 @@ static void del_usage_links(struct module *mod)
76521 static int module_add_modinfo_attrs(struct module *mod)
76522 {
76523 struct module_attribute *attr;
76524 - struct module_attribute *temp_attr;
76525 + module_attribute_no_const *temp_attr;
76526 int error = 0;
76527 int i;
76528
76529 @@ -1779,21 +1781,21 @@ static void set_section_ro_nx(void *base,
76530
76531 static void unset_module_core_ro_nx(struct module *mod)
76532 {
76533 - set_page_attributes(mod->module_core + mod->core_text_size,
76534 - mod->module_core + mod->core_size,
76535 + set_page_attributes(mod->module_core_rw,
76536 + mod->module_core_rw + mod->core_size_rw,
76537 set_memory_x);
76538 - set_page_attributes(mod->module_core,
76539 - mod->module_core + mod->core_ro_size,
76540 + set_page_attributes(mod->module_core_rx,
76541 + mod->module_core_rx + mod->core_size_rx,
76542 set_memory_rw);
76543 }
76544
76545 static void unset_module_init_ro_nx(struct module *mod)
76546 {
76547 - set_page_attributes(mod->module_init + mod->init_text_size,
76548 - mod->module_init + mod->init_size,
76549 + set_page_attributes(mod->module_init_rw,
76550 + mod->module_init_rw + mod->init_size_rw,
76551 set_memory_x);
76552 - set_page_attributes(mod->module_init,
76553 - mod->module_init + mod->init_ro_size,
76554 + set_page_attributes(mod->module_init_rx,
76555 + mod->module_init_rx + mod->init_size_rx,
76556 set_memory_rw);
76557 }
76558
76559 @@ -1806,14 +1808,14 @@ void set_all_modules_text_rw(void)
76560 list_for_each_entry_rcu(mod, &modules, list) {
76561 if (mod->state == MODULE_STATE_UNFORMED)
76562 continue;
76563 - if ((mod->module_core) && (mod->core_text_size)) {
76564 - set_page_attributes(mod->module_core,
76565 - mod->module_core + mod->core_text_size,
76566 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
76567 + set_page_attributes(mod->module_core_rx,
76568 + mod->module_core_rx + mod->core_size_rx,
76569 set_memory_rw);
76570 }
76571 - if ((mod->module_init) && (mod->init_text_size)) {
76572 - set_page_attributes(mod->module_init,
76573 - mod->module_init + mod->init_text_size,
76574 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
76575 + set_page_attributes(mod->module_init_rx,
76576 + mod->module_init_rx + mod->init_size_rx,
76577 set_memory_rw);
76578 }
76579 }
76580 @@ -1829,14 +1831,14 @@ void set_all_modules_text_ro(void)
76581 list_for_each_entry_rcu(mod, &modules, list) {
76582 if (mod->state == MODULE_STATE_UNFORMED)
76583 continue;
76584 - if ((mod->module_core) && (mod->core_text_size)) {
76585 - set_page_attributes(mod->module_core,
76586 - mod->module_core + mod->core_text_size,
76587 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
76588 + set_page_attributes(mod->module_core_rx,
76589 + mod->module_core_rx + mod->core_size_rx,
76590 set_memory_ro);
76591 }
76592 - if ((mod->module_init) && (mod->init_text_size)) {
76593 - set_page_attributes(mod->module_init,
76594 - mod->module_init + mod->init_text_size,
76595 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
76596 + set_page_attributes(mod->module_init_rx,
76597 + mod->module_init_rx + mod->init_size_rx,
76598 set_memory_ro);
76599 }
76600 }
76601 @@ -1887,16 +1889,19 @@ static void free_module(struct module *mod)
76602
76603 /* This may be NULL, but that's OK */
76604 unset_module_init_ro_nx(mod);
76605 - module_free(mod, mod->module_init);
76606 + module_free(mod, mod->module_init_rw);
76607 + module_free_exec(mod, mod->module_init_rx);
76608 kfree(mod->args);
76609 percpu_modfree(mod);
76610
76611 /* Free lock-classes: */
76612 - lockdep_free_key_range(mod->module_core, mod->core_size);
76613 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
76614 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
76615
76616 /* Finally, free the core (containing the module structure) */
76617 unset_module_core_ro_nx(mod);
76618 - module_free(mod, mod->module_core);
76619 + module_free_exec(mod, mod->module_core_rx);
76620 + module_free(mod, mod->module_core_rw);
76621
76622 #ifdef CONFIG_MPU
76623 update_protections(current->mm);
76624 @@ -1966,9 +1971,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76625 int ret = 0;
76626 const struct kernel_symbol *ksym;
76627
76628 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76629 + int is_fs_load = 0;
76630 + int register_filesystem_found = 0;
76631 + char *p;
76632 +
76633 + p = strstr(mod->args, "grsec_modharden_fs");
76634 + if (p) {
76635 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
76636 + /* copy \0 as well */
76637 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
76638 + is_fs_load = 1;
76639 + }
76640 +#endif
76641 +
76642 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
76643 const char *name = info->strtab + sym[i].st_name;
76644
76645 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76646 + /* it's a real shame this will never get ripped and copied
76647 + upstream! ;(
76648 + */
76649 + if (is_fs_load && !strcmp(name, "register_filesystem"))
76650 + register_filesystem_found = 1;
76651 +#endif
76652 +
76653 switch (sym[i].st_shndx) {
76654 case SHN_COMMON:
76655 /* We compiled with -fno-common. These are not
76656 @@ -1989,7 +2016,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76657 ksym = resolve_symbol_wait(mod, info, name);
76658 /* Ok if resolved. */
76659 if (ksym && !IS_ERR(ksym)) {
76660 + pax_open_kernel();
76661 sym[i].st_value = ksym->value;
76662 + pax_close_kernel();
76663 break;
76664 }
76665
76666 @@ -2008,11 +2037,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
76667 secbase = (unsigned long)mod_percpu(mod);
76668 else
76669 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
76670 + pax_open_kernel();
76671 sym[i].st_value += secbase;
76672 + pax_close_kernel();
76673 break;
76674 }
76675 }
76676
76677 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
76678 + if (is_fs_load && !register_filesystem_found) {
76679 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
76680 + ret = -EPERM;
76681 + }
76682 +#endif
76683 +
76684 return ret;
76685 }
76686
76687 @@ -2096,22 +2134,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
76688 || s->sh_entsize != ~0UL
76689 || strstarts(sname, ".init"))
76690 continue;
76691 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
76692 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
76693 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
76694 + else
76695 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
76696 pr_debug("\t%s\n", sname);
76697 }
76698 - switch (m) {
76699 - case 0: /* executable */
76700 - mod->core_size = debug_align(mod->core_size);
76701 - mod->core_text_size = mod->core_size;
76702 - break;
76703 - case 1: /* RO: text and ro-data */
76704 - mod->core_size = debug_align(mod->core_size);
76705 - mod->core_ro_size = mod->core_size;
76706 - break;
76707 - case 3: /* whole core */
76708 - mod->core_size = debug_align(mod->core_size);
76709 - break;
76710 - }
76711 }
76712
76713 pr_debug("Init section allocation order:\n");
76714 @@ -2125,23 +2153,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
76715 || s->sh_entsize != ~0UL
76716 || !strstarts(sname, ".init"))
76717 continue;
76718 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
76719 - | INIT_OFFSET_MASK);
76720 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
76721 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
76722 + else
76723 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
76724 + s->sh_entsize |= INIT_OFFSET_MASK;
76725 pr_debug("\t%s\n", sname);
76726 }
76727 - switch (m) {
76728 - case 0: /* executable */
76729 - mod->init_size = debug_align(mod->init_size);
76730 - mod->init_text_size = mod->init_size;
76731 - break;
76732 - case 1: /* RO: text and ro-data */
76733 - mod->init_size = debug_align(mod->init_size);
76734 - mod->init_ro_size = mod->init_size;
76735 - break;
76736 - case 3: /* whole init */
76737 - mod->init_size = debug_align(mod->init_size);
76738 - break;
76739 - }
76740 }
76741 }
76742
76743 @@ -2314,7 +2332,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
76744
76745 /* Put symbol section at end of init part of module. */
76746 symsect->sh_flags |= SHF_ALLOC;
76747 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
76748 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
76749 info->index.sym) | INIT_OFFSET_MASK;
76750 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
76751
76752 @@ -2331,13 +2349,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
76753 }
76754
76755 /* Append room for core symbols at end of core part. */
76756 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
76757 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
76758 - mod->core_size += strtab_size;
76759 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
76760 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
76761 + mod->core_size_rx += strtab_size;
76762
76763 /* Put string table section at end of init part of module. */
76764 strsect->sh_flags |= SHF_ALLOC;
76765 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
76766 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
76767 info->index.str) | INIT_OFFSET_MASK;
76768 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
76769 }
76770 @@ -2355,12 +2373,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
76771 /* Make sure we get permanent strtab: don't use info->strtab. */
76772 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
76773
76774 + pax_open_kernel();
76775 +
76776 /* Set types up while we still have access to sections. */
76777 for (i = 0; i < mod->num_symtab; i++)
76778 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
76779
76780 - mod->core_symtab = dst = mod->module_core + info->symoffs;
76781 - mod->core_strtab = s = mod->module_core + info->stroffs;
76782 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
76783 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
76784 src = mod->symtab;
76785 for (ndst = i = 0; i < mod->num_symtab; i++) {
76786 if (i == 0 ||
76787 @@ -2372,6 +2392,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
76788 }
76789 }
76790 mod->core_num_syms = ndst;
76791 +
76792 + pax_close_kernel();
76793 }
76794 #else
76795 static inline void layout_symtab(struct module *mod, struct load_info *info)
76796 @@ -2405,17 +2427,33 @@ void * __weak module_alloc(unsigned long size)
76797 return vmalloc_exec(size);
76798 }
76799
76800 -static void *module_alloc_update_bounds(unsigned long size)
76801 +static void *module_alloc_update_bounds_rw(unsigned long size)
76802 {
76803 void *ret = module_alloc(size);
76804
76805 if (ret) {
76806 mutex_lock(&module_mutex);
76807 /* Update module bounds. */
76808 - if ((unsigned long)ret < module_addr_min)
76809 - module_addr_min = (unsigned long)ret;
76810 - if ((unsigned long)ret + size > module_addr_max)
76811 - module_addr_max = (unsigned long)ret + size;
76812 + if ((unsigned long)ret < module_addr_min_rw)
76813 + module_addr_min_rw = (unsigned long)ret;
76814 + if ((unsigned long)ret + size > module_addr_max_rw)
76815 + module_addr_max_rw = (unsigned long)ret + size;
76816 + mutex_unlock(&module_mutex);
76817 + }
76818 + return ret;
76819 +}
76820 +
76821 +static void *module_alloc_update_bounds_rx(unsigned long size)
76822 +{
76823 + void *ret = module_alloc_exec(size);
76824 +
76825 + if (ret) {
76826 + mutex_lock(&module_mutex);
76827 + /* Update module bounds. */
76828 + if ((unsigned long)ret < module_addr_min_rx)
76829 + module_addr_min_rx = (unsigned long)ret;
76830 + if ((unsigned long)ret + size > module_addr_max_rx)
76831 + module_addr_max_rx = (unsigned long)ret + size;
76832 mutex_unlock(&module_mutex);
76833 }
76834 return ret;
76835 @@ -2691,8 +2729,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
76836 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
76837 {
76838 const char *modmagic = get_modinfo(info, "vermagic");
76839 + const char *license = get_modinfo(info, "license");
76840 int err;
76841
76842 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
76843 + if (!license || !license_is_gpl_compatible(license))
76844 + return -ENOEXEC;
76845 +#endif
76846 +
76847 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
76848 modmagic = NULL;
76849
76850 @@ -2718,7 +2762,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
76851 }
76852
76853 /* Set up license info based on the info section */
76854 - set_license(mod, get_modinfo(info, "license"));
76855 + set_license(mod, license);
76856
76857 return 0;
76858 }
76859 @@ -2799,7 +2843,7 @@ static int move_module(struct module *mod, struct load_info *info)
76860 void *ptr;
76861
76862 /* Do the allocs. */
76863 - ptr = module_alloc_update_bounds(mod->core_size);
76864 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
76865 /*
76866 * The pointer to this block is stored in the module structure
76867 * which is inside the block. Just mark it as not being a
76868 @@ -2809,11 +2853,11 @@ static int move_module(struct module *mod, struct load_info *info)
76869 if (!ptr)
76870 return -ENOMEM;
76871
76872 - memset(ptr, 0, mod->core_size);
76873 - mod->module_core = ptr;
76874 + memset(ptr, 0, mod->core_size_rw);
76875 + mod->module_core_rw = ptr;
76876
76877 - if (mod->init_size) {
76878 - ptr = module_alloc_update_bounds(mod->init_size);
76879 + if (mod->init_size_rw) {
76880 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
76881 /*
76882 * The pointer to this block is stored in the module structure
76883 * which is inside the block. This block doesn't need to be
76884 @@ -2822,13 +2866,45 @@ static int move_module(struct module *mod, struct load_info *info)
76885 */
76886 kmemleak_ignore(ptr);
76887 if (!ptr) {
76888 - module_free(mod, mod->module_core);
76889 + module_free(mod, mod->module_core_rw);
76890 return -ENOMEM;
76891 }
76892 - memset(ptr, 0, mod->init_size);
76893 - mod->module_init = ptr;
76894 + memset(ptr, 0, mod->init_size_rw);
76895 + mod->module_init_rw = ptr;
76896 } else
76897 - mod->module_init = NULL;
76898 + mod->module_init_rw = NULL;
76899 +
76900 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
76901 + kmemleak_not_leak(ptr);
76902 + if (!ptr) {
76903 + if (mod->module_init_rw)
76904 + module_free(mod, mod->module_init_rw);
76905 + module_free(mod, mod->module_core_rw);
76906 + return -ENOMEM;
76907 + }
76908 +
76909 + pax_open_kernel();
76910 + memset(ptr, 0, mod->core_size_rx);
76911 + pax_close_kernel();
76912 + mod->module_core_rx = ptr;
76913 +
76914 + if (mod->init_size_rx) {
76915 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
76916 + kmemleak_ignore(ptr);
76917 + if (!ptr && mod->init_size_rx) {
76918 + module_free_exec(mod, mod->module_core_rx);
76919 + if (mod->module_init_rw)
76920 + module_free(mod, mod->module_init_rw);
76921 + module_free(mod, mod->module_core_rw);
76922 + return -ENOMEM;
76923 + }
76924 +
76925 + pax_open_kernel();
76926 + memset(ptr, 0, mod->init_size_rx);
76927 + pax_close_kernel();
76928 + mod->module_init_rx = ptr;
76929 + } else
76930 + mod->module_init_rx = NULL;
76931
76932 /* Transfer each section which specifies SHF_ALLOC */
76933 pr_debug("final section addresses:\n");
76934 @@ -2839,16 +2915,45 @@ static int move_module(struct module *mod, struct load_info *info)
76935 if (!(shdr->sh_flags & SHF_ALLOC))
76936 continue;
76937
76938 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
76939 - dest = mod->module_init
76940 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76941 - else
76942 - dest = mod->module_core + shdr->sh_entsize;
76943 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
76944 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
76945 + dest = mod->module_init_rw
76946 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76947 + else
76948 + dest = mod->module_init_rx
76949 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
76950 + } else {
76951 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
76952 + dest = mod->module_core_rw + shdr->sh_entsize;
76953 + else
76954 + dest = mod->module_core_rx + shdr->sh_entsize;
76955 + }
76956 +
76957 + if (shdr->sh_type != SHT_NOBITS) {
76958 +
76959 +#ifdef CONFIG_PAX_KERNEXEC
76960 +#ifdef CONFIG_X86_64
76961 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
76962 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
76963 +#endif
76964 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
76965 + pax_open_kernel();
76966 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
76967 + pax_close_kernel();
76968 + } else
76969 +#endif
76970
76971 - if (shdr->sh_type != SHT_NOBITS)
76972 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
76973 + }
76974 /* Update sh_addr to point to copy in image. */
76975 - shdr->sh_addr = (unsigned long)dest;
76976 +
76977 +#ifdef CONFIG_PAX_KERNEXEC
76978 + if (shdr->sh_flags & SHF_EXECINSTR)
76979 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
76980 + else
76981 +#endif
76982 +
76983 + shdr->sh_addr = (unsigned long)dest;
76984 pr_debug("\t0x%lx %s\n",
76985 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
76986 }
76987 @@ -2905,12 +3010,12 @@ static void flush_module_icache(const struct module *mod)
76988 * Do it before processing of module parameters, so the module
76989 * can provide parameter accessor functions of its own.
76990 */
76991 - if (mod->module_init)
76992 - flush_icache_range((unsigned long)mod->module_init,
76993 - (unsigned long)mod->module_init
76994 - + mod->init_size);
76995 - flush_icache_range((unsigned long)mod->module_core,
76996 - (unsigned long)mod->module_core + mod->core_size);
76997 + if (mod->module_init_rx)
76998 + flush_icache_range((unsigned long)mod->module_init_rx,
76999 + (unsigned long)mod->module_init_rx
77000 + + mod->init_size_rx);
77001 + flush_icache_range((unsigned long)mod->module_core_rx,
77002 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
77003
77004 set_fs(old_fs);
77005 }
77006 @@ -2980,8 +3085,10 @@ out:
77007 static void module_deallocate(struct module *mod, struct load_info *info)
77008 {
77009 percpu_modfree(mod);
77010 - module_free(mod, mod->module_init);
77011 - module_free(mod, mod->module_core);
77012 + module_free_exec(mod, mod->module_init_rx);
77013 + module_free_exec(mod, mod->module_core_rx);
77014 + module_free(mod, mod->module_init_rw);
77015 + module_free(mod, mod->module_core_rw);
77016 }
77017
77018 int __weak module_finalize(const Elf_Ehdr *hdr,
77019 @@ -2994,7 +3101,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
77020 static int post_relocation(struct module *mod, const struct load_info *info)
77021 {
77022 /* Sort exception table now relocations are done. */
77023 + pax_open_kernel();
77024 sort_extable(mod->extable, mod->extable + mod->num_exentries);
77025 + pax_close_kernel();
77026
77027 /* Copy relocated percpu area over. */
77028 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
77029 @@ -3048,16 +3157,16 @@ static int do_init_module(struct module *mod)
77030 MODULE_STATE_COMING, mod);
77031
77032 /* Set RO and NX regions for core */
77033 - set_section_ro_nx(mod->module_core,
77034 - mod->core_text_size,
77035 - mod->core_ro_size,
77036 - mod->core_size);
77037 + set_section_ro_nx(mod->module_core_rx,
77038 + mod->core_size_rx,
77039 + mod->core_size_rx,
77040 + mod->core_size_rx);
77041
77042 /* Set RO and NX regions for init */
77043 - set_section_ro_nx(mod->module_init,
77044 - mod->init_text_size,
77045 - mod->init_ro_size,
77046 - mod->init_size);
77047 + set_section_ro_nx(mod->module_init_rx,
77048 + mod->init_size_rx,
77049 + mod->init_size_rx,
77050 + mod->init_size_rx);
77051
77052 do_mod_ctors(mod);
77053 /* Start the module */
77054 @@ -3119,11 +3228,12 @@ static int do_init_module(struct module *mod)
77055 mod->strtab = mod->core_strtab;
77056 #endif
77057 unset_module_init_ro_nx(mod);
77058 - module_free(mod, mod->module_init);
77059 - mod->module_init = NULL;
77060 - mod->init_size = 0;
77061 - mod->init_ro_size = 0;
77062 - mod->init_text_size = 0;
77063 + module_free(mod, mod->module_init_rw);
77064 + module_free_exec(mod, mod->module_init_rx);
77065 + mod->module_init_rw = NULL;
77066 + mod->module_init_rx = NULL;
77067 + mod->init_size_rw = 0;
77068 + mod->init_size_rx = 0;
77069 mutex_unlock(&module_mutex);
77070 wake_up_all(&module_wq);
77071
77072 @@ -3250,9 +3360,38 @@ static int load_module(struct load_info *info, const char __user *uargs,
77073 if (err)
77074 goto free_unload;
77075
77076 + /* Now copy in args */
77077 + mod->args = strndup_user(uargs, ~0UL >> 1);
77078 + if (IS_ERR(mod->args)) {
77079 + err = PTR_ERR(mod->args);
77080 + goto free_unload;
77081 + }
77082 +
77083 /* Set up MODINFO_ATTR fields */
77084 setup_modinfo(mod, info);
77085
77086 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
77087 + {
77088 + char *p, *p2;
77089 +
77090 + if (strstr(mod->args, "grsec_modharden_netdev")) {
77091 + 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);
77092 + err = -EPERM;
77093 + goto free_modinfo;
77094 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
77095 + p += sizeof("grsec_modharden_normal") - 1;
77096 + p2 = strstr(p, "_");
77097 + if (p2) {
77098 + *p2 = '\0';
77099 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
77100 + *p2 = '_';
77101 + }
77102 + err = -EPERM;
77103 + goto free_modinfo;
77104 + }
77105 + }
77106 +#endif
77107 +
77108 /* Fix up syms, so that st_value is a pointer to location. */
77109 err = simplify_symbols(mod, info);
77110 if (err < 0)
77111 @@ -3268,13 +3407,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
77112
77113 flush_module_icache(mod);
77114
77115 - /* Now copy in args */
77116 - mod->args = strndup_user(uargs, ~0UL >> 1);
77117 - if (IS_ERR(mod->args)) {
77118 - err = PTR_ERR(mod->args);
77119 - goto free_arch_cleanup;
77120 - }
77121 -
77122 dynamic_debug_setup(info->debug, info->num_debug);
77123
77124 /* Finally it's fully formed, ready to start executing. */
77125 @@ -3309,11 +3441,10 @@ static int load_module(struct load_info *info, const char __user *uargs,
77126 ddebug_cleanup:
77127 dynamic_debug_remove(info->debug);
77128 synchronize_sched();
77129 - kfree(mod->args);
77130 - free_arch_cleanup:
77131 module_arch_cleanup(mod);
77132 free_modinfo:
77133 free_modinfo(mod);
77134 + kfree(mod->args);
77135 free_unload:
77136 module_unload_free(mod);
77137 unlink_mod:
77138 @@ -3396,10 +3527,16 @@ static const char *get_ksymbol(struct module *mod,
77139 unsigned long nextval;
77140
77141 /* At worse, next value is at end of module */
77142 - if (within_module_init(addr, mod))
77143 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
77144 + if (within_module_init_rx(addr, mod))
77145 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
77146 + else if (within_module_init_rw(addr, mod))
77147 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
77148 + else if (within_module_core_rx(addr, mod))
77149 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
77150 + else if (within_module_core_rw(addr, mod))
77151 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
77152 else
77153 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
77154 + return NULL;
77155
77156 /* Scan for closest preceding symbol, and next symbol. (ELF
77157 starts real symbols at 1). */
77158 @@ -3652,7 +3789,7 @@ static int m_show(struct seq_file *m, void *p)
77159 return 0;
77160
77161 seq_printf(m, "%s %u",
77162 - mod->name, mod->init_size + mod->core_size);
77163 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
77164 print_unload_info(m, mod);
77165
77166 /* Informative for users. */
77167 @@ -3661,7 +3798,7 @@ static int m_show(struct seq_file *m, void *p)
77168 mod->state == MODULE_STATE_COMING ? "Loading":
77169 "Live");
77170 /* Used by oprofile and other similar tools. */
77171 - seq_printf(m, " 0x%pK", mod->module_core);
77172 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
77173
77174 /* Taints info */
77175 if (mod->taints)
77176 @@ -3697,7 +3834,17 @@ static const struct file_operations proc_modules_operations = {
77177
77178 static int __init proc_modules_init(void)
77179 {
77180 +#ifndef CONFIG_GRKERNSEC_HIDESYM
77181 +#ifdef CONFIG_GRKERNSEC_PROC_USER
77182 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
77183 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
77184 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
77185 +#else
77186 proc_create("modules", 0, NULL, &proc_modules_operations);
77187 +#endif
77188 +#else
77189 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
77190 +#endif
77191 return 0;
77192 }
77193 module_init(proc_modules_init);
77194 @@ -3758,14 +3905,14 @@ struct module *__module_address(unsigned long addr)
77195 {
77196 struct module *mod;
77197
77198 - if (addr < module_addr_min || addr > module_addr_max)
77199 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
77200 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
77201 return NULL;
77202
77203 list_for_each_entry_rcu(mod, &modules, list) {
77204 if (mod->state == MODULE_STATE_UNFORMED)
77205 continue;
77206 - if (within_module_core(addr, mod)
77207 - || within_module_init(addr, mod))
77208 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
77209 return mod;
77210 }
77211 return NULL;
77212 @@ -3800,11 +3947,20 @@ bool is_module_text_address(unsigned long addr)
77213 */
77214 struct module *__module_text_address(unsigned long addr)
77215 {
77216 - struct module *mod = __module_address(addr);
77217 + struct module *mod;
77218 +
77219 +#ifdef CONFIG_X86_32
77220 + addr = ktla_ktva(addr);
77221 +#endif
77222 +
77223 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
77224 + return NULL;
77225 +
77226 + mod = __module_address(addr);
77227 +
77228 if (mod) {
77229 /* Make sure it's within the text section. */
77230 - if (!within(addr, mod->module_init, mod->init_text_size)
77231 - && !within(addr, mod->module_core, mod->core_text_size))
77232 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
77233 mod = NULL;
77234 }
77235 return mod;
77236 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
77237 index 7e3443f..b2a1e6b 100644
77238 --- a/kernel/mutex-debug.c
77239 +++ b/kernel/mutex-debug.c
77240 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
77241 }
77242
77243 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
77244 - struct thread_info *ti)
77245 + struct task_struct *task)
77246 {
77247 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
77248
77249 /* Mark the current thread as blocked on the lock: */
77250 - ti->task->blocked_on = waiter;
77251 + task->blocked_on = waiter;
77252 }
77253
77254 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
77255 - struct thread_info *ti)
77256 + struct task_struct *task)
77257 {
77258 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
77259 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
77260 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
77261 - ti->task->blocked_on = NULL;
77262 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
77263 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
77264 + task->blocked_on = NULL;
77265
77266 list_del_init(&waiter->list);
77267 waiter->task = NULL;
77268 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
77269 index 0799fd3..d06ae3b 100644
77270 --- a/kernel/mutex-debug.h
77271 +++ b/kernel/mutex-debug.h
77272 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
77273 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
77274 extern void debug_mutex_add_waiter(struct mutex *lock,
77275 struct mutex_waiter *waiter,
77276 - struct thread_info *ti);
77277 + struct task_struct *task);
77278 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
77279 - struct thread_info *ti);
77280 + struct task_struct *task);
77281 extern void debug_mutex_unlock(struct mutex *lock);
77282 extern void debug_mutex_init(struct mutex *lock, const char *name,
77283 struct lock_class_key *key);
77284 diff --git a/kernel/mutex.c b/kernel/mutex.c
77285 index ad53a66..f1bf8bc 100644
77286 --- a/kernel/mutex.c
77287 +++ b/kernel/mutex.c
77288 @@ -134,7 +134,7 @@ void mspin_lock(struct mspin_node **lock, struct mspin_node *node)
77289 node->locked = 1;
77290 return;
77291 }
77292 - ACCESS_ONCE(prev->next) = node;
77293 + ACCESS_ONCE_RW(prev->next) = node;
77294 smp_wmb();
77295 /* Wait until the lock holder passes the lock down */
77296 while (!ACCESS_ONCE(node->locked))
77297 @@ -155,7 +155,7 @@ static void mspin_unlock(struct mspin_node **lock, struct mspin_node *node)
77298 while (!(next = ACCESS_ONCE(node->next)))
77299 arch_mutex_cpu_relax();
77300 }
77301 - ACCESS_ONCE(next->locked) = 1;
77302 + ACCESS_ONCE_RW(next->locked) = 1;
77303 smp_wmb();
77304 }
77305
77306 @@ -341,7 +341,7 @@ slowpath:
77307 spin_lock_mutex(&lock->wait_lock, flags);
77308
77309 debug_mutex_lock_common(lock, &waiter);
77310 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
77311 + debug_mutex_add_waiter(lock, &waiter, task);
77312
77313 /* add waiting tasks to the end of the waitqueue (FIFO): */
77314 list_add_tail(&waiter.list, &lock->wait_list);
77315 @@ -371,8 +371,7 @@ slowpath:
77316 * TASK_UNINTERRUPTIBLE case.)
77317 */
77318 if (unlikely(signal_pending_state(state, task))) {
77319 - mutex_remove_waiter(lock, &waiter,
77320 - task_thread_info(task));
77321 + mutex_remove_waiter(lock, &waiter, task);
77322 mutex_release(&lock->dep_map, 1, ip);
77323 spin_unlock_mutex(&lock->wait_lock, flags);
77324
77325 @@ -391,7 +390,7 @@ slowpath:
77326 done:
77327 lock_acquired(&lock->dep_map, ip);
77328 /* got the lock - rejoice! */
77329 - mutex_remove_waiter(lock, &waiter, current_thread_info());
77330 + mutex_remove_waiter(lock, &waiter, task);
77331 mutex_set_owner(lock);
77332
77333 /* set it to 0 if there are no waiters left: */
77334 diff --git a/kernel/notifier.c b/kernel/notifier.c
77335 index 2d5cc4c..d9ea600 100644
77336 --- a/kernel/notifier.c
77337 +++ b/kernel/notifier.c
77338 @@ -5,6 +5,7 @@
77339 #include <linux/rcupdate.h>
77340 #include <linux/vmalloc.h>
77341 #include <linux/reboot.h>
77342 +#include <linux/mm.h>
77343
77344 /*
77345 * Notifier list for kernel code which wants to be called
77346 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
77347 while ((*nl) != NULL) {
77348 if (n->priority > (*nl)->priority)
77349 break;
77350 - nl = &((*nl)->next);
77351 + nl = (struct notifier_block **)&((*nl)->next);
77352 }
77353 - n->next = *nl;
77354 + pax_open_kernel();
77355 + *(const void **)&n->next = *nl;
77356 rcu_assign_pointer(*nl, n);
77357 + pax_close_kernel();
77358 return 0;
77359 }
77360
77361 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
77362 return 0;
77363 if (n->priority > (*nl)->priority)
77364 break;
77365 - nl = &((*nl)->next);
77366 + nl = (struct notifier_block **)&((*nl)->next);
77367 }
77368 - n->next = *nl;
77369 + pax_open_kernel();
77370 + *(const void **)&n->next = *nl;
77371 rcu_assign_pointer(*nl, n);
77372 + pax_close_kernel();
77373 return 0;
77374 }
77375
77376 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
77377 {
77378 while ((*nl) != NULL) {
77379 if ((*nl) == n) {
77380 + pax_open_kernel();
77381 rcu_assign_pointer(*nl, n->next);
77382 + pax_close_kernel();
77383 return 0;
77384 }
77385 - nl = &((*nl)->next);
77386 + nl = (struct notifier_block **)&((*nl)->next);
77387 }
77388 return -ENOENT;
77389 }
77390 diff --git a/kernel/panic.c b/kernel/panic.c
77391 index 167ec09..0dda5f9 100644
77392 --- a/kernel/panic.c
77393 +++ b/kernel/panic.c
77394 @@ -400,7 +400,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
77395 unsigned taint, struct slowpath_args *args)
77396 {
77397 printk(KERN_WARNING "------------[ cut here ]------------\n");
77398 - printk(KERN_WARNING "WARNING: at %s:%d %pS()\n", file, line, caller);
77399 + printk(KERN_WARNING "WARNING: at %s:%d %pA()\n", file, line, caller);
77400
77401 if (args)
77402 vprintk(args->fmt, args->args);
77403 @@ -453,7 +453,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
77404 */
77405 void __stack_chk_fail(void)
77406 {
77407 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
77408 + dump_stack();
77409 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
77410 __builtin_return_address(0));
77411 }
77412 EXPORT_SYMBOL(__stack_chk_fail);
77413 diff --git a/kernel/pid.c b/kernel/pid.c
77414 index 0db3e79..95b9dc2 100644
77415 --- a/kernel/pid.c
77416 +++ b/kernel/pid.c
77417 @@ -33,6 +33,7 @@
77418 #include <linux/rculist.h>
77419 #include <linux/bootmem.h>
77420 #include <linux/hash.h>
77421 +#include <linux/security.h>
77422 #include <linux/pid_namespace.h>
77423 #include <linux/init_task.h>
77424 #include <linux/syscalls.h>
77425 @@ -47,7 +48,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
77426
77427 int pid_max = PID_MAX_DEFAULT;
77428
77429 -#define RESERVED_PIDS 300
77430 +#define RESERVED_PIDS 500
77431
77432 int pid_max_min = RESERVED_PIDS + 1;
77433 int pid_max_max = PID_MAX_LIMIT;
77434 @@ -442,10 +443,18 @@ EXPORT_SYMBOL(pid_task);
77435 */
77436 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
77437 {
77438 + struct task_struct *task;
77439 +
77440 rcu_lockdep_assert(rcu_read_lock_held(),
77441 "find_task_by_pid_ns() needs rcu_read_lock()"
77442 " protection");
77443 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
77444 +
77445 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
77446 +
77447 + if (gr_pid_is_chrooted(task))
77448 + return NULL;
77449 +
77450 + return task;
77451 }
77452
77453 struct task_struct *find_task_by_vpid(pid_t vnr)
77454 @@ -453,6 +462,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
77455 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
77456 }
77457
77458 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
77459 +{
77460 + rcu_lockdep_assert(rcu_read_lock_held(),
77461 + "find_task_by_pid_ns() needs rcu_read_lock()"
77462 + " protection");
77463 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
77464 +}
77465 +
77466 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
77467 {
77468 struct pid *pid;
77469 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
77470 index 6917e8e..9909aeb 100644
77471 --- a/kernel/pid_namespace.c
77472 +++ b/kernel/pid_namespace.c
77473 @@ -247,7 +247,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
77474 void __user *buffer, size_t *lenp, loff_t *ppos)
77475 {
77476 struct pid_namespace *pid_ns = task_active_pid_ns(current);
77477 - struct ctl_table tmp = *table;
77478 + ctl_table_no_const tmp = *table;
77479
77480 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
77481 return -EPERM;
77482 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
77483 index 42670e9..8719c2f 100644
77484 --- a/kernel/posix-cpu-timers.c
77485 +++ b/kernel/posix-cpu-timers.c
77486 @@ -1636,14 +1636,14 @@ struct k_clock clock_posix_cpu = {
77487
77488 static __init int init_posix_cpu_timers(void)
77489 {
77490 - struct k_clock process = {
77491 + static struct k_clock process = {
77492 .clock_getres = process_cpu_clock_getres,
77493 .clock_get = process_cpu_clock_get,
77494 .timer_create = process_cpu_timer_create,
77495 .nsleep = process_cpu_nsleep,
77496 .nsleep_restart = process_cpu_nsleep_restart,
77497 };
77498 - struct k_clock thread = {
77499 + static struct k_clock thread = {
77500 .clock_getres = thread_cpu_clock_getres,
77501 .clock_get = thread_cpu_clock_get,
77502 .timer_create = thread_cpu_timer_create,
77503 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
77504 index 424c2d4..a9194f7 100644
77505 --- a/kernel/posix-timers.c
77506 +++ b/kernel/posix-timers.c
77507 @@ -43,6 +43,7 @@
77508 #include <linux/hash.h>
77509 #include <linux/posix-clock.h>
77510 #include <linux/posix-timers.h>
77511 +#include <linux/grsecurity.h>
77512 #include <linux/syscalls.h>
77513 #include <linux/wait.h>
77514 #include <linux/workqueue.h>
77515 @@ -122,7 +123,7 @@ static DEFINE_SPINLOCK(hash_lock);
77516 * which we beg off on and pass to do_sys_settimeofday().
77517 */
77518
77519 -static struct k_clock posix_clocks[MAX_CLOCKS];
77520 +static struct k_clock *posix_clocks[MAX_CLOCKS];
77521
77522 /*
77523 * These ones are defined below.
77524 @@ -275,7 +276,7 @@ static int posix_get_tai(clockid_t which_clock, struct timespec *tp)
77525 */
77526 static __init int init_posix_timers(void)
77527 {
77528 - struct k_clock clock_realtime = {
77529 + static struct k_clock clock_realtime = {
77530 .clock_getres = hrtimer_get_res,
77531 .clock_get = posix_clock_realtime_get,
77532 .clock_set = posix_clock_realtime_set,
77533 @@ -287,7 +288,7 @@ static __init int init_posix_timers(void)
77534 .timer_get = common_timer_get,
77535 .timer_del = common_timer_del,
77536 };
77537 - struct k_clock clock_monotonic = {
77538 + static struct k_clock clock_monotonic = {
77539 .clock_getres = hrtimer_get_res,
77540 .clock_get = posix_ktime_get_ts,
77541 .nsleep = common_nsleep,
77542 @@ -297,19 +298,19 @@ static __init int init_posix_timers(void)
77543 .timer_get = common_timer_get,
77544 .timer_del = common_timer_del,
77545 };
77546 - struct k_clock clock_monotonic_raw = {
77547 + static struct k_clock clock_monotonic_raw = {
77548 .clock_getres = hrtimer_get_res,
77549 .clock_get = posix_get_monotonic_raw,
77550 };
77551 - struct k_clock clock_realtime_coarse = {
77552 + static struct k_clock clock_realtime_coarse = {
77553 .clock_getres = posix_get_coarse_res,
77554 .clock_get = posix_get_realtime_coarse,
77555 };
77556 - struct k_clock clock_monotonic_coarse = {
77557 + static struct k_clock clock_monotonic_coarse = {
77558 .clock_getres = posix_get_coarse_res,
77559 .clock_get = posix_get_monotonic_coarse,
77560 };
77561 - struct k_clock clock_tai = {
77562 + static struct k_clock clock_tai = {
77563 .clock_getres = hrtimer_get_res,
77564 .clock_get = posix_get_tai,
77565 .nsleep = common_nsleep,
77566 @@ -319,7 +320,7 @@ static __init int init_posix_timers(void)
77567 .timer_get = common_timer_get,
77568 .timer_del = common_timer_del,
77569 };
77570 - struct k_clock clock_boottime = {
77571 + static struct k_clock clock_boottime = {
77572 .clock_getres = hrtimer_get_res,
77573 .clock_get = posix_get_boottime,
77574 .nsleep = common_nsleep,
77575 @@ -531,7 +532,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
77576 return;
77577 }
77578
77579 - posix_clocks[clock_id] = *new_clock;
77580 + posix_clocks[clock_id] = new_clock;
77581 }
77582 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
77583
77584 @@ -577,9 +578,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
77585 return (id & CLOCKFD_MASK) == CLOCKFD ?
77586 &clock_posix_dynamic : &clock_posix_cpu;
77587
77588 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
77589 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
77590 return NULL;
77591 - return &posix_clocks[id];
77592 + return posix_clocks[id];
77593 }
77594
77595 static int common_timer_create(struct k_itimer *new_timer)
77596 @@ -1011,6 +1012,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
77597 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
77598 return -EFAULT;
77599
77600 + /* only the CLOCK_REALTIME clock can be set, all other clocks
77601 + have their clock_set fptr set to a nosettime dummy function
77602 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
77603 + call common_clock_set, which calls do_sys_settimeofday, which
77604 + we hook
77605 + */
77606 +
77607 return kc->clock_set(which_clock, &new_tp);
77608 }
77609
77610 diff --git a/kernel/power/process.c b/kernel/power/process.c
77611 index 98088e0..aaf95c0 100644
77612 --- a/kernel/power/process.c
77613 +++ b/kernel/power/process.c
77614 @@ -33,6 +33,7 @@ static int try_to_freeze_tasks(bool user_only)
77615 u64 elapsed_csecs64;
77616 unsigned int elapsed_csecs;
77617 bool wakeup = false;
77618 + bool timedout = false;
77619
77620 do_gettimeofday(&start);
77621
77622 @@ -43,13 +44,20 @@ static int try_to_freeze_tasks(bool user_only)
77623
77624 while (true) {
77625 todo = 0;
77626 + if (time_after(jiffies, end_time))
77627 + timedout = true;
77628 read_lock(&tasklist_lock);
77629 do_each_thread(g, p) {
77630 if (p == current || !freeze_task(p))
77631 continue;
77632
77633 - if (!freezer_should_skip(p))
77634 + if (!freezer_should_skip(p)) {
77635 todo++;
77636 + if (timedout) {
77637 + printk(KERN_ERR "Task refusing to freeze:\n");
77638 + sched_show_task(p);
77639 + }
77640 + }
77641 } while_each_thread(g, p);
77642 read_unlock(&tasklist_lock);
77643
77644 @@ -58,7 +66,7 @@ static int try_to_freeze_tasks(bool user_only)
77645 todo += wq_busy;
77646 }
77647
77648 - if (!todo || time_after(jiffies, end_time))
77649 + if (!todo || timedout)
77650 break;
77651
77652 if (pm_wakeup_pending()) {
77653 diff --git a/kernel/printk.c b/kernel/printk.c
77654 index 8212c1a..eb61021 100644
77655 --- a/kernel/printk.c
77656 +++ b/kernel/printk.c
77657 @@ -390,6 +390,11 @@ static int check_syslog_permissions(int type, bool from_file)
77658 if (from_file && type != SYSLOG_ACTION_OPEN)
77659 return 0;
77660
77661 +#ifdef CONFIG_GRKERNSEC_DMESG
77662 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
77663 + return -EPERM;
77664 +#endif
77665 +
77666 if (syslog_action_restricted(type)) {
77667 if (capable(CAP_SYSLOG))
77668 return 0;
77669 diff --git a/kernel/profile.c b/kernel/profile.c
77670 index 0bf4007..6234708 100644
77671 --- a/kernel/profile.c
77672 +++ b/kernel/profile.c
77673 @@ -37,7 +37,7 @@ struct profile_hit {
77674 #define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
77675 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
77676
77677 -static atomic_t *prof_buffer;
77678 +static atomic_unchecked_t *prof_buffer;
77679 static unsigned long prof_len, prof_shift;
77680
77681 int prof_on __read_mostly;
77682 @@ -260,7 +260,7 @@ static void profile_flip_buffers(void)
77683 hits[i].pc = 0;
77684 continue;
77685 }
77686 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
77687 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
77688 hits[i].hits = hits[i].pc = 0;
77689 }
77690 }
77691 @@ -321,9 +321,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
77692 * Add the current hit(s) and flush the write-queue out
77693 * to the global buffer:
77694 */
77695 - atomic_add(nr_hits, &prof_buffer[pc]);
77696 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
77697 for (i = 0; i < NR_PROFILE_HIT; ++i) {
77698 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
77699 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
77700 hits[i].pc = hits[i].hits = 0;
77701 }
77702 out:
77703 @@ -398,7 +398,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
77704 {
77705 unsigned long pc;
77706 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
77707 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
77708 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
77709 }
77710 #endif /* !CONFIG_SMP */
77711
77712 @@ -494,7 +494,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
77713 return -EFAULT;
77714 buf++; p++; count--; read++;
77715 }
77716 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
77717 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
77718 if (copy_to_user(buf, (void *)pnt, count))
77719 return -EFAULT;
77720 read += count;
77721 @@ -525,7 +525,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
77722 }
77723 #endif
77724 profile_discard_flip_buffers();
77725 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
77726 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
77727 return count;
77728 }
77729
77730 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
77731 index 335a7ae..3bbbceb 100644
77732 --- a/kernel/ptrace.c
77733 +++ b/kernel/ptrace.c
77734 @@ -326,7 +326,7 @@ static int ptrace_attach(struct task_struct *task, long request,
77735 if (seize)
77736 flags |= PT_SEIZED;
77737 rcu_read_lock();
77738 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
77739 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
77740 flags |= PT_PTRACE_CAP;
77741 rcu_read_unlock();
77742 task->ptrace = flags;
77743 @@ -537,7 +537,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
77744 break;
77745 return -EIO;
77746 }
77747 - if (copy_to_user(dst, buf, retval))
77748 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
77749 return -EFAULT;
77750 copied += retval;
77751 src += retval;
77752 @@ -805,7 +805,7 @@ int ptrace_request(struct task_struct *child, long request,
77753 bool seized = child->ptrace & PT_SEIZED;
77754 int ret = -EIO;
77755 siginfo_t siginfo, *si;
77756 - void __user *datavp = (void __user *) data;
77757 + void __user *datavp = (__force void __user *) data;
77758 unsigned long __user *datalp = datavp;
77759 unsigned long flags;
77760
77761 @@ -1011,14 +1011,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
77762 goto out;
77763 }
77764
77765 + if (gr_handle_ptrace(child, request)) {
77766 + ret = -EPERM;
77767 + goto out_put_task_struct;
77768 + }
77769 +
77770 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
77771 ret = ptrace_attach(child, request, addr, data);
77772 /*
77773 * Some architectures need to do book-keeping after
77774 * a ptrace attach.
77775 */
77776 - if (!ret)
77777 + if (!ret) {
77778 arch_ptrace_attach(child);
77779 + gr_audit_ptrace(child);
77780 + }
77781 goto out_put_task_struct;
77782 }
77783
77784 @@ -1046,7 +1053,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
77785 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
77786 if (copied != sizeof(tmp))
77787 return -EIO;
77788 - return put_user(tmp, (unsigned long __user *)data);
77789 + return put_user(tmp, (__force unsigned long __user *)data);
77790 }
77791
77792 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
77793 @@ -1140,7 +1147,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
77794 }
77795
77796 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
77797 - compat_long_t addr, compat_long_t data)
77798 + compat_ulong_t addr, compat_ulong_t data)
77799 {
77800 struct task_struct *child;
77801 long ret;
77802 @@ -1156,14 +1163,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
77803 goto out;
77804 }
77805
77806 + if (gr_handle_ptrace(child, request)) {
77807 + ret = -EPERM;
77808 + goto out_put_task_struct;
77809 + }
77810 +
77811 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
77812 ret = ptrace_attach(child, request, addr, data);
77813 /*
77814 * Some architectures need to do book-keeping after
77815 * a ptrace attach.
77816 */
77817 - if (!ret)
77818 + if (!ret) {
77819 arch_ptrace_attach(child);
77820 + gr_audit_ptrace(child);
77821 + }
77822 goto out_put_task_struct;
77823 }
77824
77825 diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
77826 index 48ab703..07561d4 100644
77827 --- a/kernel/rcupdate.c
77828 +++ b/kernel/rcupdate.c
77829 @@ -439,10 +439,10 @@ int rcu_jiffies_till_stall_check(void)
77830 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
77831 */
77832 if (till_stall_check < 3) {
77833 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
77834 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
77835 till_stall_check = 3;
77836 } else if (till_stall_check > 300) {
77837 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
77838 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
77839 till_stall_check = 300;
77840 }
77841 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
77842 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
77843 index a0714a5..2ab5e34 100644
77844 --- a/kernel/rcutiny.c
77845 +++ b/kernel/rcutiny.c
77846 @@ -46,7 +46,7 @@
77847 struct rcu_ctrlblk;
77848 static void invoke_rcu_callbacks(void);
77849 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
77850 -static void rcu_process_callbacks(struct softirq_action *unused);
77851 +static void rcu_process_callbacks(void);
77852 static void __call_rcu(struct rcu_head *head,
77853 void (*func)(struct rcu_head *rcu),
77854 struct rcu_ctrlblk *rcp);
77855 @@ -312,7 +312,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
77856 rcu_is_callbacks_kthread()));
77857 }
77858
77859 -static void rcu_process_callbacks(struct softirq_action *unused)
77860 +static void rcu_process_callbacks(void)
77861 {
77862 __rcu_process_callbacks(&rcu_sched_ctrlblk);
77863 __rcu_process_callbacks(&rcu_bh_ctrlblk);
77864 diff --git a/kernel/rcutiny_plugin.h b/kernel/rcutiny_plugin.h
77865 index 8a23300..4255818 100644
77866 --- a/kernel/rcutiny_plugin.h
77867 +++ b/kernel/rcutiny_plugin.h
77868 @@ -945,7 +945,7 @@ static int rcu_kthread(void *arg)
77869 have_rcu_kthread_work = morework;
77870 local_irq_restore(flags);
77871 if (work)
77872 - rcu_process_callbacks(NULL);
77873 + rcu_process_callbacks();
77874 schedule_timeout_interruptible(1); /* Leave CPU for others. */
77875 }
77876
77877 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
77878 index e1f3a8c..42c94a2 100644
77879 --- a/kernel/rcutorture.c
77880 +++ b/kernel/rcutorture.c
77881 @@ -164,12 +164,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
77882 { 0 };
77883 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
77884 { 0 };
77885 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
77886 -static atomic_t n_rcu_torture_alloc;
77887 -static atomic_t n_rcu_torture_alloc_fail;
77888 -static atomic_t n_rcu_torture_free;
77889 -static atomic_t n_rcu_torture_mberror;
77890 -static atomic_t n_rcu_torture_error;
77891 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
77892 +static atomic_unchecked_t n_rcu_torture_alloc;
77893 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
77894 +static atomic_unchecked_t n_rcu_torture_free;
77895 +static atomic_unchecked_t n_rcu_torture_mberror;
77896 +static atomic_unchecked_t n_rcu_torture_error;
77897 static long n_rcu_torture_barrier_error;
77898 static long n_rcu_torture_boost_ktrerror;
77899 static long n_rcu_torture_boost_rterror;
77900 @@ -287,11 +287,11 @@ rcu_torture_alloc(void)
77901
77902 spin_lock_bh(&rcu_torture_lock);
77903 if (list_empty(&rcu_torture_freelist)) {
77904 - atomic_inc(&n_rcu_torture_alloc_fail);
77905 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
77906 spin_unlock_bh(&rcu_torture_lock);
77907 return NULL;
77908 }
77909 - atomic_inc(&n_rcu_torture_alloc);
77910 + atomic_inc_unchecked(&n_rcu_torture_alloc);
77911 p = rcu_torture_freelist.next;
77912 list_del_init(p);
77913 spin_unlock_bh(&rcu_torture_lock);
77914 @@ -304,7 +304,7 @@ rcu_torture_alloc(void)
77915 static void
77916 rcu_torture_free(struct rcu_torture *p)
77917 {
77918 - atomic_inc(&n_rcu_torture_free);
77919 + atomic_inc_unchecked(&n_rcu_torture_free);
77920 spin_lock_bh(&rcu_torture_lock);
77921 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
77922 spin_unlock_bh(&rcu_torture_lock);
77923 @@ -424,7 +424,7 @@ rcu_torture_cb(struct rcu_head *p)
77924 i = rp->rtort_pipe_count;
77925 if (i > RCU_TORTURE_PIPE_LEN)
77926 i = RCU_TORTURE_PIPE_LEN;
77927 - atomic_inc(&rcu_torture_wcount[i]);
77928 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77929 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
77930 rp->rtort_mbtest = 0;
77931 rcu_torture_free(rp);
77932 @@ -472,7 +472,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
77933 i = rp->rtort_pipe_count;
77934 if (i > RCU_TORTURE_PIPE_LEN)
77935 i = RCU_TORTURE_PIPE_LEN;
77936 - atomic_inc(&rcu_torture_wcount[i]);
77937 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77938 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
77939 rp->rtort_mbtest = 0;
77940 list_del(&rp->rtort_free);
77941 @@ -990,7 +990,7 @@ rcu_torture_writer(void *arg)
77942 i = old_rp->rtort_pipe_count;
77943 if (i > RCU_TORTURE_PIPE_LEN)
77944 i = RCU_TORTURE_PIPE_LEN;
77945 - atomic_inc(&rcu_torture_wcount[i]);
77946 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
77947 old_rp->rtort_pipe_count++;
77948 cur_ops->deferred_free(old_rp);
77949 }
77950 @@ -1076,7 +1076,7 @@ static void rcu_torture_timer(unsigned long unused)
77951 return;
77952 }
77953 if (p->rtort_mbtest == 0)
77954 - atomic_inc(&n_rcu_torture_mberror);
77955 + atomic_inc_unchecked(&n_rcu_torture_mberror);
77956 spin_lock(&rand_lock);
77957 cur_ops->read_delay(&rand);
77958 n_rcu_torture_timers++;
77959 @@ -1146,7 +1146,7 @@ rcu_torture_reader(void *arg)
77960 continue;
77961 }
77962 if (p->rtort_mbtest == 0)
77963 - atomic_inc(&n_rcu_torture_mberror);
77964 + atomic_inc_unchecked(&n_rcu_torture_mberror);
77965 cur_ops->read_delay(&rand);
77966 preempt_disable();
77967 pipe_count = p->rtort_pipe_count;
77968 @@ -1209,11 +1209,11 @@ rcu_torture_printk(char *page)
77969 rcu_torture_current,
77970 rcu_torture_current_version,
77971 list_empty(&rcu_torture_freelist),
77972 - atomic_read(&n_rcu_torture_alloc),
77973 - atomic_read(&n_rcu_torture_alloc_fail),
77974 - atomic_read(&n_rcu_torture_free));
77975 + atomic_read_unchecked(&n_rcu_torture_alloc),
77976 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
77977 + atomic_read_unchecked(&n_rcu_torture_free));
77978 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
77979 - atomic_read(&n_rcu_torture_mberror),
77980 + atomic_read_unchecked(&n_rcu_torture_mberror),
77981 n_rcu_torture_boost_ktrerror,
77982 n_rcu_torture_boost_rterror);
77983 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
77984 @@ -1232,14 +1232,14 @@ rcu_torture_printk(char *page)
77985 n_barrier_attempts,
77986 n_rcu_torture_barrier_error);
77987 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
77988 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
77989 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
77990 n_rcu_torture_barrier_error != 0 ||
77991 n_rcu_torture_boost_ktrerror != 0 ||
77992 n_rcu_torture_boost_rterror != 0 ||
77993 n_rcu_torture_boost_failure != 0 ||
77994 i > 1) {
77995 cnt += sprintf(&page[cnt], "!!! ");
77996 - atomic_inc(&n_rcu_torture_error);
77997 + atomic_inc_unchecked(&n_rcu_torture_error);
77998 WARN_ON_ONCE(1);
77999 }
78000 cnt += sprintf(&page[cnt], "Reader Pipe: ");
78001 @@ -1253,7 +1253,7 @@ rcu_torture_printk(char *page)
78002 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
78003 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
78004 cnt += sprintf(&page[cnt], " %d",
78005 - atomic_read(&rcu_torture_wcount[i]));
78006 + atomic_read_unchecked(&rcu_torture_wcount[i]));
78007 }
78008 cnt += sprintf(&page[cnt], "\n");
78009 if (cur_ops->stats)
78010 @@ -1962,7 +1962,7 @@ rcu_torture_cleanup(void)
78011
78012 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
78013
78014 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
78015 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
78016 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
78017 else if (n_online_successes != n_online_attempts ||
78018 n_offline_successes != n_offline_attempts)
78019 @@ -2031,18 +2031,18 @@ rcu_torture_init(void)
78020
78021 rcu_torture_current = NULL;
78022 rcu_torture_current_version = 0;
78023 - atomic_set(&n_rcu_torture_alloc, 0);
78024 - atomic_set(&n_rcu_torture_alloc_fail, 0);
78025 - atomic_set(&n_rcu_torture_free, 0);
78026 - atomic_set(&n_rcu_torture_mberror, 0);
78027 - atomic_set(&n_rcu_torture_error, 0);
78028 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
78029 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
78030 + atomic_set_unchecked(&n_rcu_torture_free, 0);
78031 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
78032 + atomic_set_unchecked(&n_rcu_torture_error, 0);
78033 n_rcu_torture_barrier_error = 0;
78034 n_rcu_torture_boost_ktrerror = 0;
78035 n_rcu_torture_boost_rterror = 0;
78036 n_rcu_torture_boost_failure = 0;
78037 n_rcu_torture_boosts = 0;
78038 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
78039 - atomic_set(&rcu_torture_wcount[i], 0);
78040 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
78041 for_each_possible_cpu(cpu) {
78042 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
78043 per_cpu(rcu_torture_count, cpu)[i] = 0;
78044 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
78045 index 3538001..e379e0b 100644
78046 --- a/kernel/rcutree.c
78047 +++ b/kernel/rcutree.c
78048 @@ -358,9 +358,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
78049 rcu_prepare_for_idle(smp_processor_id());
78050 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
78051 smp_mb__before_atomic_inc(); /* See above. */
78052 - atomic_inc(&rdtp->dynticks);
78053 + atomic_inc_unchecked(&rdtp->dynticks);
78054 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
78055 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
78056 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
78057
78058 /*
78059 * It is illegal to enter an extended quiescent state while
78060 @@ -496,10 +496,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
78061 int user)
78062 {
78063 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
78064 - atomic_inc(&rdtp->dynticks);
78065 + atomic_inc_unchecked(&rdtp->dynticks);
78066 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
78067 smp_mb__after_atomic_inc(); /* See above. */
78068 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
78069 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
78070 rcu_cleanup_after_idle(smp_processor_id());
78071 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
78072 if (!user && !is_idle_task(current)) {
78073 @@ -638,14 +638,14 @@ void rcu_nmi_enter(void)
78074 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
78075
78076 if (rdtp->dynticks_nmi_nesting == 0 &&
78077 - (atomic_read(&rdtp->dynticks) & 0x1))
78078 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
78079 return;
78080 rdtp->dynticks_nmi_nesting++;
78081 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
78082 - atomic_inc(&rdtp->dynticks);
78083 + atomic_inc_unchecked(&rdtp->dynticks);
78084 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
78085 smp_mb__after_atomic_inc(); /* See above. */
78086 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
78087 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
78088 }
78089
78090 /**
78091 @@ -664,9 +664,9 @@ void rcu_nmi_exit(void)
78092 return;
78093 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
78094 smp_mb__before_atomic_inc(); /* See above. */
78095 - atomic_inc(&rdtp->dynticks);
78096 + atomic_inc_unchecked(&rdtp->dynticks);
78097 smp_mb__after_atomic_inc(); /* Force delay to next write. */
78098 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
78099 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
78100 }
78101
78102 /**
78103 @@ -680,7 +680,7 @@ int rcu_is_cpu_idle(void)
78104 int ret;
78105
78106 preempt_disable();
78107 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
78108 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
78109 preempt_enable();
78110 return ret;
78111 }
78112 @@ -748,7 +748,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
78113 */
78114 static int dyntick_save_progress_counter(struct rcu_data *rdp)
78115 {
78116 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
78117 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
78118 return (rdp->dynticks_snap & 0x1) == 0;
78119 }
78120
78121 @@ -763,7 +763,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
78122 unsigned int curr;
78123 unsigned int snap;
78124
78125 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
78126 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
78127 snap = (unsigned int)rdp->dynticks_snap;
78128
78129 /*
78130 @@ -1440,9 +1440,9 @@ static int rcu_gp_init(struct rcu_state *rsp)
78131 rdp = this_cpu_ptr(rsp->rda);
78132 rcu_preempt_check_blocked_tasks(rnp);
78133 rnp->qsmask = rnp->qsmaskinit;
78134 - ACCESS_ONCE(rnp->gpnum) = rsp->gpnum;
78135 + ACCESS_ONCE_RW(rnp->gpnum) = rsp->gpnum;
78136 WARN_ON_ONCE(rnp->completed != rsp->completed);
78137 - ACCESS_ONCE(rnp->completed) = rsp->completed;
78138 + ACCESS_ONCE_RW(rnp->completed) = rsp->completed;
78139 if (rnp == rdp->mynode)
78140 rcu_start_gp_per_cpu(rsp, rnp, rdp);
78141 rcu_preempt_boost_start_gp(rnp);
78142 @@ -1524,7 +1524,7 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
78143 */
78144 rcu_for_each_node_breadth_first(rsp, rnp) {
78145 raw_spin_lock_irq(&rnp->lock);
78146 - ACCESS_ONCE(rnp->completed) = rsp->gpnum;
78147 + ACCESS_ONCE_RW(rnp->completed) = rsp->gpnum;
78148 rdp = this_cpu_ptr(rsp->rda);
78149 if (rnp == rdp->mynode)
78150 __rcu_process_gp_end(rsp, rnp, rdp);
78151 @@ -1855,7 +1855,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
78152 rsp->qlen += rdp->qlen;
78153 rdp->n_cbs_orphaned += rdp->qlen;
78154 rdp->qlen_lazy = 0;
78155 - ACCESS_ONCE(rdp->qlen) = 0;
78156 + ACCESS_ONCE_RW(rdp->qlen) = 0;
78157 }
78158
78159 /*
78160 @@ -2101,7 +2101,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
78161 }
78162 smp_mb(); /* List handling before counting for rcu_barrier(). */
78163 rdp->qlen_lazy -= count_lazy;
78164 - ACCESS_ONCE(rdp->qlen) -= count;
78165 + ACCESS_ONCE_RW(rdp->qlen) -= count;
78166 rdp->n_cbs_invoked += count;
78167
78168 /* Reinstate batch limit if we have worked down the excess. */
78169 @@ -2295,7 +2295,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
78170 /*
78171 * Do RCU core processing for the current CPU.
78172 */
78173 -static void rcu_process_callbacks(struct softirq_action *unused)
78174 +static void rcu_process_callbacks(void)
78175 {
78176 struct rcu_state *rsp;
78177
78178 @@ -2419,7 +2419,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
78179 local_irq_restore(flags);
78180 return;
78181 }
78182 - ACCESS_ONCE(rdp->qlen)++;
78183 + ACCESS_ONCE_RW(rdp->qlen)++;
78184 if (lazy)
78185 rdp->qlen_lazy++;
78186 else
78187 @@ -2628,11 +2628,11 @@ void synchronize_sched_expedited(void)
78188 * counter wrap on a 32-bit system. Quite a few more CPUs would of
78189 * course be required on a 64-bit system.
78190 */
78191 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
78192 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
78193 (ulong)atomic_long_read(&rsp->expedited_done) +
78194 ULONG_MAX / 8)) {
78195 synchronize_sched();
78196 - atomic_long_inc(&rsp->expedited_wrap);
78197 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
78198 return;
78199 }
78200
78201 @@ -2640,7 +2640,7 @@ void synchronize_sched_expedited(void)
78202 * Take a ticket. Note that atomic_inc_return() implies a
78203 * full memory barrier.
78204 */
78205 - snap = atomic_long_inc_return(&rsp->expedited_start);
78206 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
78207 firstsnap = snap;
78208 get_online_cpus();
78209 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
78210 @@ -2653,14 +2653,14 @@ void synchronize_sched_expedited(void)
78211 synchronize_sched_expedited_cpu_stop,
78212 NULL) == -EAGAIN) {
78213 put_online_cpus();
78214 - atomic_long_inc(&rsp->expedited_tryfail);
78215 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
78216
78217 /* Check to see if someone else did our work for us. */
78218 s = atomic_long_read(&rsp->expedited_done);
78219 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
78220 /* ensure test happens before caller kfree */
78221 smp_mb__before_atomic_inc(); /* ^^^ */
78222 - atomic_long_inc(&rsp->expedited_workdone1);
78223 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
78224 return;
78225 }
78226
78227 @@ -2669,7 +2669,7 @@ void synchronize_sched_expedited(void)
78228 udelay(trycount * num_online_cpus());
78229 } else {
78230 wait_rcu_gp(call_rcu_sched);
78231 - atomic_long_inc(&rsp->expedited_normal);
78232 + atomic_long_inc_unchecked(&rsp->expedited_normal);
78233 return;
78234 }
78235
78236 @@ -2678,7 +2678,7 @@ void synchronize_sched_expedited(void)
78237 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
78238 /* ensure test happens before caller kfree */
78239 smp_mb__before_atomic_inc(); /* ^^^ */
78240 - atomic_long_inc(&rsp->expedited_workdone2);
78241 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
78242 return;
78243 }
78244
78245 @@ -2690,10 +2690,10 @@ void synchronize_sched_expedited(void)
78246 * period works for us.
78247 */
78248 get_online_cpus();
78249 - snap = atomic_long_read(&rsp->expedited_start);
78250 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
78251 smp_mb(); /* ensure read is before try_stop_cpus(). */
78252 }
78253 - atomic_long_inc(&rsp->expedited_stoppedcpus);
78254 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
78255
78256 /*
78257 * Everyone up to our most recent fetch is covered by our grace
78258 @@ -2702,16 +2702,16 @@ void synchronize_sched_expedited(void)
78259 * than we did already did their update.
78260 */
78261 do {
78262 - atomic_long_inc(&rsp->expedited_done_tries);
78263 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
78264 s = atomic_long_read(&rsp->expedited_done);
78265 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
78266 /* ensure test happens before caller kfree */
78267 smp_mb__before_atomic_inc(); /* ^^^ */
78268 - atomic_long_inc(&rsp->expedited_done_lost);
78269 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
78270 break;
78271 }
78272 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
78273 - atomic_long_inc(&rsp->expedited_done_exit);
78274 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
78275
78276 put_online_cpus();
78277 }
78278 @@ -2893,7 +2893,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
78279 * ACCESS_ONCE() to prevent the compiler from speculating
78280 * the increment to precede the early-exit check.
78281 */
78282 - ACCESS_ONCE(rsp->n_barrier_done)++;
78283 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
78284 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
78285 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
78286 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
78287 @@ -2943,7 +2943,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
78288
78289 /* Increment ->n_barrier_done to prevent duplicate work. */
78290 smp_mb(); /* Keep increment after above mechanism. */
78291 - ACCESS_ONCE(rsp->n_barrier_done)++;
78292 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
78293 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
78294 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
78295 smp_mb(); /* Keep increment before caller's subsequent code. */
78296 @@ -2988,10 +2988,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
78297 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
78298 init_callback_list(rdp);
78299 rdp->qlen_lazy = 0;
78300 - ACCESS_ONCE(rdp->qlen) = 0;
78301 + ACCESS_ONCE_RW(rdp->qlen) = 0;
78302 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
78303 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
78304 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
78305 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
78306 rdp->cpu = cpu;
78307 rdp->rsp = rsp;
78308 rcu_boot_init_nocb_percpu_data(rdp);
78309 @@ -3024,8 +3024,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
78310 rdp->blimit = blimit;
78311 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
78312 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
78313 - atomic_set(&rdp->dynticks->dynticks,
78314 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
78315 + atomic_set_unchecked(&rdp->dynticks->dynticks,
78316 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
78317 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
78318
78319 /* Add CPU to rcu_node bitmasks. */
78320 @@ -3120,7 +3120,7 @@ static int __init rcu_spawn_gp_kthread(void)
78321 struct task_struct *t;
78322
78323 for_each_rcu_flavor(rsp) {
78324 - t = kthread_run(rcu_gp_kthread, rsp, rsp->name);
78325 + t = kthread_run(rcu_gp_kthread, rsp, "%s", rsp->name);
78326 BUG_ON(IS_ERR(t));
78327 rnp = rcu_get_root(rsp);
78328 raw_spin_lock_irqsave(&rnp->lock, flags);
78329 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
78330 index 4df5034..5ee93f2 100644
78331 --- a/kernel/rcutree.h
78332 +++ b/kernel/rcutree.h
78333 @@ -87,7 +87,7 @@ struct rcu_dynticks {
78334 long long dynticks_nesting; /* Track irq/process nesting level. */
78335 /* Process level is worth LLONG_MAX/2. */
78336 int dynticks_nmi_nesting; /* Track NMI nesting level. */
78337 - atomic_t dynticks; /* Even value for idle, else odd. */
78338 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
78339 #ifdef CONFIG_RCU_FAST_NO_HZ
78340 bool all_lazy; /* Are all CPU's CBs lazy? */
78341 unsigned long nonlazy_posted;
78342 @@ -414,17 +414,17 @@ struct rcu_state {
78343 /* _rcu_barrier(). */
78344 /* End of fields guarded by barrier_mutex. */
78345
78346 - atomic_long_t expedited_start; /* Starting ticket. */
78347 - atomic_long_t expedited_done; /* Done ticket. */
78348 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
78349 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
78350 - atomic_long_t expedited_workdone1; /* # done by others #1. */
78351 - atomic_long_t expedited_workdone2; /* # done by others #2. */
78352 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
78353 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
78354 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
78355 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
78356 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
78357 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
78358 + atomic_long_t expedited_done; /* Done ticket. */
78359 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
78360 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
78361 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
78362 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
78363 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
78364 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
78365 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
78366 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
78367 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
78368
78369 unsigned long jiffies_force_qs; /* Time at which to invoke */
78370 /* force_quiescent_state(). */
78371 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
78372 index 3db5a37..b395fb35 100644
78373 --- a/kernel/rcutree_plugin.h
78374 +++ b/kernel/rcutree_plugin.h
78375 @@ -903,7 +903,7 @@ void synchronize_rcu_expedited(void)
78376
78377 /* Clean up and exit. */
78378 smp_mb(); /* ensure expedited GP seen before counter increment. */
78379 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
78380 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
78381 unlock_mb_ret:
78382 mutex_unlock(&sync_rcu_preempt_exp_mutex);
78383 mb_ret:
78384 @@ -1451,7 +1451,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
78385 free_cpumask_var(cm);
78386 }
78387
78388 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
78389 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
78390 .store = &rcu_cpu_kthread_task,
78391 .thread_should_run = rcu_cpu_kthread_should_run,
78392 .thread_fn = rcu_cpu_kthread,
78393 @@ -1916,7 +1916,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
78394 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
78395 printk(KERN_ERR "\t%d: (%lu %s) idle=%03x/%llx/%d softirq=%u/%u %s\n",
78396 cpu, ticks_value, ticks_title,
78397 - atomic_read(&rdtp->dynticks) & 0xfff,
78398 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
78399 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
78400 rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu),
78401 fast_no_hz);
78402 @@ -2079,7 +2079,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
78403
78404 /* Enqueue the callback on the nocb list and update counts. */
78405 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
78406 - ACCESS_ONCE(*old_rhpp) = rhp;
78407 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
78408 atomic_long_add(rhcount, &rdp->nocb_q_count);
78409 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
78410
78411 @@ -2219,12 +2219,12 @@ static int rcu_nocb_kthread(void *arg)
78412 * Extract queued callbacks, update counts, and wait
78413 * for a grace period to elapse.
78414 */
78415 - ACCESS_ONCE(rdp->nocb_head) = NULL;
78416 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
78417 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
78418 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
78419 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
78420 - ACCESS_ONCE(rdp->nocb_p_count) += c;
78421 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
78422 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
78423 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
78424 rcu_nocb_wait_gp(rdp);
78425
78426 /* Each pass through the following loop invokes a callback. */
78427 @@ -2246,8 +2246,8 @@ static int rcu_nocb_kthread(void *arg)
78428 list = next;
78429 }
78430 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
78431 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
78432 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
78433 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
78434 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
78435 rdp->n_nocbs_invoked += c;
78436 }
78437 return 0;
78438 @@ -2274,7 +2274,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
78439 t = kthread_run(rcu_nocb_kthread, rdp,
78440 "rcuo%c/%d", rsp->abbr, cpu);
78441 BUG_ON(IS_ERR(t));
78442 - ACCESS_ONCE(rdp->nocb_kthread) = t;
78443 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
78444 }
78445 }
78446
78447 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
78448 index cf6c174..a8f4b50 100644
78449 --- a/kernel/rcutree_trace.c
78450 +++ b/kernel/rcutree_trace.c
78451 @@ -121,7 +121,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
78452 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
78453 rdp->passed_quiesce, rdp->qs_pending);
78454 seq_printf(m, " dt=%d/%llx/%d df=%lu",
78455 - atomic_read(&rdp->dynticks->dynticks),
78456 + atomic_read_unchecked(&rdp->dynticks->dynticks),
78457 rdp->dynticks->dynticks_nesting,
78458 rdp->dynticks->dynticks_nmi_nesting,
78459 rdp->dynticks_fqs);
78460 @@ -182,17 +182,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
78461 struct rcu_state *rsp = (struct rcu_state *)m->private;
78462
78463 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",
78464 - atomic_long_read(&rsp->expedited_start),
78465 + atomic_long_read_unchecked(&rsp->expedited_start),
78466 atomic_long_read(&rsp->expedited_done),
78467 - atomic_long_read(&rsp->expedited_wrap),
78468 - atomic_long_read(&rsp->expedited_tryfail),
78469 - atomic_long_read(&rsp->expedited_workdone1),
78470 - atomic_long_read(&rsp->expedited_workdone2),
78471 - atomic_long_read(&rsp->expedited_normal),
78472 - atomic_long_read(&rsp->expedited_stoppedcpus),
78473 - atomic_long_read(&rsp->expedited_done_tries),
78474 - atomic_long_read(&rsp->expedited_done_lost),
78475 - atomic_long_read(&rsp->expedited_done_exit));
78476 + atomic_long_read_unchecked(&rsp->expedited_wrap),
78477 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
78478 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
78479 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
78480 + atomic_long_read_unchecked(&rsp->expedited_normal),
78481 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
78482 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
78483 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
78484 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
78485 return 0;
78486 }
78487
78488 diff --git a/kernel/resource.c b/kernel/resource.c
78489 index d738698..5f8e60a 100644
78490 --- a/kernel/resource.c
78491 +++ b/kernel/resource.c
78492 @@ -152,8 +152,18 @@ static const struct file_operations proc_iomem_operations = {
78493
78494 static int __init ioresources_init(void)
78495 {
78496 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
78497 +#ifdef CONFIG_GRKERNSEC_PROC_USER
78498 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
78499 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
78500 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
78501 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
78502 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
78503 +#endif
78504 +#else
78505 proc_create("ioports", 0, NULL, &proc_ioports_operations);
78506 proc_create("iomem", 0, NULL, &proc_iomem_operations);
78507 +#endif
78508 return 0;
78509 }
78510 __initcall(ioresources_init);
78511 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
78512 index 1d96dd0..994ff19 100644
78513 --- a/kernel/rtmutex-tester.c
78514 +++ b/kernel/rtmutex-tester.c
78515 @@ -22,7 +22,7 @@
78516 #define MAX_RT_TEST_MUTEXES 8
78517
78518 static spinlock_t rttest_lock;
78519 -static atomic_t rttest_event;
78520 +static atomic_unchecked_t rttest_event;
78521
78522 struct test_thread_data {
78523 int opcode;
78524 @@ -63,7 +63,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78525
78526 case RTTEST_LOCKCONT:
78527 td->mutexes[td->opdata] = 1;
78528 - td->event = atomic_add_return(1, &rttest_event);
78529 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78530 return 0;
78531
78532 case RTTEST_RESET:
78533 @@ -76,7 +76,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78534 return 0;
78535
78536 case RTTEST_RESETEVENT:
78537 - atomic_set(&rttest_event, 0);
78538 + atomic_set_unchecked(&rttest_event, 0);
78539 return 0;
78540
78541 default:
78542 @@ -93,9 +93,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78543 return ret;
78544
78545 td->mutexes[id] = 1;
78546 - td->event = atomic_add_return(1, &rttest_event);
78547 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78548 rt_mutex_lock(&mutexes[id]);
78549 - td->event = atomic_add_return(1, &rttest_event);
78550 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78551 td->mutexes[id] = 4;
78552 return 0;
78553
78554 @@ -106,9 +106,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78555 return ret;
78556
78557 td->mutexes[id] = 1;
78558 - td->event = atomic_add_return(1, &rttest_event);
78559 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78560 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
78561 - td->event = atomic_add_return(1, &rttest_event);
78562 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78563 td->mutexes[id] = ret ? 0 : 4;
78564 return ret ? -EINTR : 0;
78565
78566 @@ -117,9 +117,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
78567 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
78568 return ret;
78569
78570 - td->event = atomic_add_return(1, &rttest_event);
78571 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78572 rt_mutex_unlock(&mutexes[id]);
78573 - td->event = atomic_add_return(1, &rttest_event);
78574 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78575 td->mutexes[id] = 0;
78576 return 0;
78577
78578 @@ -166,7 +166,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78579 break;
78580
78581 td->mutexes[dat] = 2;
78582 - td->event = atomic_add_return(1, &rttest_event);
78583 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78584 break;
78585
78586 default:
78587 @@ -186,7 +186,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78588 return;
78589
78590 td->mutexes[dat] = 3;
78591 - td->event = atomic_add_return(1, &rttest_event);
78592 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78593 break;
78594
78595 case RTTEST_LOCKNOWAIT:
78596 @@ -198,7 +198,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
78597 return;
78598
78599 td->mutexes[dat] = 1;
78600 - td->event = atomic_add_return(1, &rttest_event);
78601 + td->event = atomic_add_return_unchecked(1, &rttest_event);
78602 return;
78603
78604 default:
78605 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
78606 index 64de5f8..7735e12 100644
78607 --- a/kernel/sched/auto_group.c
78608 +++ b/kernel/sched/auto_group.c
78609 @@ -11,7 +11,7 @@
78610
78611 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
78612 static struct autogroup autogroup_default;
78613 -static atomic_t autogroup_seq_nr;
78614 +static atomic_unchecked_t autogroup_seq_nr;
78615
78616 void __init autogroup_init(struct task_struct *init_task)
78617 {
78618 @@ -81,7 +81,7 @@ static inline struct autogroup *autogroup_create(void)
78619
78620 kref_init(&ag->kref);
78621 init_rwsem(&ag->lock);
78622 - ag->id = atomic_inc_return(&autogroup_seq_nr);
78623 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
78624 ag->tg = tg;
78625 #ifdef CONFIG_RT_GROUP_SCHED
78626 /*
78627 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
78628 index e8b3350..d83d44e 100644
78629 --- a/kernel/sched/core.c
78630 +++ b/kernel/sched/core.c
78631 @@ -3440,7 +3440,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
78632 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
78633 * positive (at least 1, or number of jiffies left till timeout) if completed.
78634 */
78635 -long __sched
78636 +long __sched __intentional_overflow(-1)
78637 wait_for_completion_interruptible_timeout(struct completion *x,
78638 unsigned long timeout)
78639 {
78640 @@ -3457,7 +3457,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
78641 *
78642 * The return value is -ERESTARTSYS if interrupted, 0 if completed.
78643 */
78644 -int __sched wait_for_completion_killable(struct completion *x)
78645 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
78646 {
78647 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
78648 if (t == -ERESTARTSYS)
78649 @@ -3478,7 +3478,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
78650 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
78651 * positive (at least 1, or number of jiffies left till timeout) if completed.
78652 */
78653 -long __sched
78654 +long __sched __intentional_overflow(-1)
78655 wait_for_completion_killable_timeout(struct completion *x,
78656 unsigned long timeout)
78657 {
78658 @@ -3704,6 +3704,8 @@ int can_nice(const struct task_struct *p, const int nice)
78659 /* convert nice value [19,-20] to rlimit style value [1,40] */
78660 int nice_rlim = 20 - nice;
78661
78662 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
78663 +
78664 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
78665 capable(CAP_SYS_NICE));
78666 }
78667 @@ -3737,7 +3739,8 @@ SYSCALL_DEFINE1(nice, int, increment)
78668 if (nice > 19)
78669 nice = 19;
78670
78671 - if (increment < 0 && !can_nice(current, nice))
78672 + if (increment < 0 && (!can_nice(current, nice) ||
78673 + gr_handle_chroot_nice()))
78674 return -EPERM;
78675
78676 retval = security_task_setnice(current, nice);
78677 @@ -3891,6 +3894,7 @@ recheck:
78678 unsigned long rlim_rtprio =
78679 task_rlimit(p, RLIMIT_RTPRIO);
78680
78681 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
78682 /* can't set/change the rt policy */
78683 if (policy != p->policy && !rlim_rtprio)
78684 return -EPERM;
78685 @@ -4988,7 +4992,7 @@ static void migrate_tasks(unsigned int dead_cpu)
78686
78687 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
78688
78689 -static struct ctl_table sd_ctl_dir[] = {
78690 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
78691 {
78692 .procname = "sched_domain",
78693 .mode = 0555,
78694 @@ -5005,17 +5009,17 @@ static struct ctl_table sd_ctl_root[] = {
78695 {}
78696 };
78697
78698 -static struct ctl_table *sd_alloc_ctl_entry(int n)
78699 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
78700 {
78701 - struct ctl_table *entry =
78702 + ctl_table_no_const *entry =
78703 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
78704
78705 return entry;
78706 }
78707
78708 -static void sd_free_ctl_entry(struct ctl_table **tablep)
78709 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
78710 {
78711 - struct ctl_table *entry;
78712 + ctl_table_no_const *entry;
78713
78714 /*
78715 * In the intermediate directories, both the child directory and
78716 @@ -5023,22 +5027,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
78717 * will always be set. In the lowest directory the names are
78718 * static strings and all have proc handlers.
78719 */
78720 - for (entry = *tablep; entry->mode; entry++) {
78721 - if (entry->child)
78722 - sd_free_ctl_entry(&entry->child);
78723 + for (entry = tablep; entry->mode; entry++) {
78724 + if (entry->child) {
78725 + sd_free_ctl_entry(entry->child);
78726 + pax_open_kernel();
78727 + entry->child = NULL;
78728 + pax_close_kernel();
78729 + }
78730 if (entry->proc_handler == NULL)
78731 kfree(entry->procname);
78732 }
78733
78734 - kfree(*tablep);
78735 - *tablep = NULL;
78736 + kfree(tablep);
78737 }
78738
78739 static int min_load_idx = 0;
78740 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
78741
78742 static void
78743 -set_table_entry(struct ctl_table *entry,
78744 +set_table_entry(ctl_table_no_const *entry,
78745 const char *procname, void *data, int maxlen,
78746 umode_t mode, proc_handler *proc_handler,
78747 bool load_idx)
78748 @@ -5058,7 +5065,7 @@ set_table_entry(struct ctl_table *entry,
78749 static struct ctl_table *
78750 sd_alloc_ctl_domain_table(struct sched_domain *sd)
78751 {
78752 - struct ctl_table *table = sd_alloc_ctl_entry(13);
78753 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
78754
78755 if (table == NULL)
78756 return NULL;
78757 @@ -5093,9 +5100,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
78758 return table;
78759 }
78760
78761 -static ctl_table *sd_alloc_ctl_cpu_table(int cpu)
78762 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
78763 {
78764 - struct ctl_table *entry, *table;
78765 + ctl_table_no_const *entry, *table;
78766 struct sched_domain *sd;
78767 int domain_num = 0, i;
78768 char buf[32];
78769 @@ -5122,11 +5129,13 @@ static struct ctl_table_header *sd_sysctl_header;
78770 static void register_sched_domain_sysctl(void)
78771 {
78772 int i, cpu_num = num_possible_cpus();
78773 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
78774 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
78775 char buf[32];
78776
78777 WARN_ON(sd_ctl_dir[0].child);
78778 + pax_open_kernel();
78779 sd_ctl_dir[0].child = entry;
78780 + pax_close_kernel();
78781
78782 if (entry == NULL)
78783 return;
78784 @@ -5149,8 +5158,12 @@ static void unregister_sched_domain_sysctl(void)
78785 if (sd_sysctl_header)
78786 unregister_sysctl_table(sd_sysctl_header);
78787 sd_sysctl_header = NULL;
78788 - if (sd_ctl_dir[0].child)
78789 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
78790 + if (sd_ctl_dir[0].child) {
78791 + sd_free_ctl_entry(sd_ctl_dir[0].child);
78792 + pax_open_kernel();
78793 + sd_ctl_dir[0].child = NULL;
78794 + pax_close_kernel();
78795 + }
78796 }
78797 #else
78798 static void register_sched_domain_sysctl(void)
78799 @@ -5249,7 +5262,7 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
78800 * happens before everything else. This has to be lower priority than
78801 * the notifier in the perf_event subsystem, though.
78802 */
78803 -static struct notifier_block __cpuinitdata migration_notifier = {
78804 +static struct notifier_block migration_notifier = {
78805 .notifier_call = migration_call,
78806 .priority = CPU_PRI_MIGRATION,
78807 };
78808 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
78809 index c61a614..d7f3d7e 100644
78810 --- a/kernel/sched/fair.c
78811 +++ b/kernel/sched/fair.c
78812 @@ -831,7 +831,7 @@ void task_numa_fault(int node, int pages, bool migrated)
78813
78814 static void reset_ptenuma_scan(struct task_struct *p)
78815 {
78816 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
78817 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
78818 p->mm->numa_scan_offset = 0;
78819 }
78820
78821 @@ -5686,7 +5686,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
78822 * run_rebalance_domains is triggered when needed from the scheduler tick.
78823 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
78824 */
78825 -static void run_rebalance_domains(struct softirq_action *h)
78826 +static void run_rebalance_domains(void)
78827 {
78828 int this_cpu = smp_processor_id();
78829 struct rq *this_rq = cpu_rq(this_cpu);
78830 diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
78831 index ce39224..0e09343 100644
78832 --- a/kernel/sched/sched.h
78833 +++ b/kernel/sched/sched.h
78834 @@ -1009,7 +1009,7 @@ struct sched_class {
78835 #ifdef CONFIG_FAIR_GROUP_SCHED
78836 void (*task_move_group) (struct task_struct *p, int on_rq);
78837 #endif
78838 -};
78839 +} __do_const;
78840
78841 #define sched_class_highest (&stop_sched_class)
78842 #define for_each_class(class) \
78843 diff --git a/kernel/signal.c b/kernel/signal.c
78844 index 113411b..17190e2 100644
78845 --- a/kernel/signal.c
78846 +++ b/kernel/signal.c
78847 @@ -51,12 +51,12 @@ static struct kmem_cache *sigqueue_cachep;
78848
78849 int print_fatal_signals __read_mostly;
78850
78851 -static void __user *sig_handler(struct task_struct *t, int sig)
78852 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
78853 {
78854 return t->sighand->action[sig - 1].sa.sa_handler;
78855 }
78856
78857 -static int sig_handler_ignored(void __user *handler, int sig)
78858 +static int sig_handler_ignored(__sighandler_t handler, int sig)
78859 {
78860 /* Is it explicitly or implicitly ignored? */
78861 return handler == SIG_IGN ||
78862 @@ -65,7 +65,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
78863
78864 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
78865 {
78866 - void __user *handler;
78867 + __sighandler_t handler;
78868
78869 handler = sig_handler(t, sig);
78870
78871 @@ -369,6 +369,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
78872 atomic_inc(&user->sigpending);
78873 rcu_read_unlock();
78874
78875 + if (!override_rlimit)
78876 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
78877 +
78878 if (override_rlimit ||
78879 atomic_read(&user->sigpending) <=
78880 task_rlimit(t, RLIMIT_SIGPENDING)) {
78881 @@ -496,7 +499,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
78882
78883 int unhandled_signal(struct task_struct *tsk, int sig)
78884 {
78885 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
78886 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
78887 if (is_global_init(tsk))
78888 return 1;
78889 if (handler != SIG_IGN && handler != SIG_DFL)
78890 @@ -816,6 +819,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
78891 }
78892 }
78893
78894 + /* allow glibc communication via tgkill to other threads in our
78895 + thread group */
78896 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
78897 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
78898 + && gr_handle_signal(t, sig))
78899 + return -EPERM;
78900 +
78901 return security_task_kill(t, info, sig, 0);
78902 }
78903
78904 @@ -1199,7 +1209,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
78905 return send_signal(sig, info, p, 1);
78906 }
78907
78908 -static int
78909 +int
78910 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78911 {
78912 return send_signal(sig, info, t, 0);
78913 @@ -1236,6 +1246,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78914 unsigned long int flags;
78915 int ret, blocked, ignored;
78916 struct k_sigaction *action;
78917 + int is_unhandled = 0;
78918
78919 spin_lock_irqsave(&t->sighand->siglock, flags);
78920 action = &t->sighand->action[sig-1];
78921 @@ -1250,9 +1261,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
78922 }
78923 if (action->sa.sa_handler == SIG_DFL)
78924 t->signal->flags &= ~SIGNAL_UNKILLABLE;
78925 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
78926 + is_unhandled = 1;
78927 ret = specific_send_sig_info(sig, info, t);
78928 spin_unlock_irqrestore(&t->sighand->siglock, flags);
78929
78930 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
78931 + normal operation */
78932 + if (is_unhandled) {
78933 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
78934 + gr_handle_crash(t, sig);
78935 + }
78936 +
78937 return ret;
78938 }
78939
78940 @@ -1319,8 +1339,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
78941 ret = check_kill_permission(sig, info, p);
78942 rcu_read_unlock();
78943
78944 - if (!ret && sig)
78945 + if (!ret && sig) {
78946 ret = do_send_sig_info(sig, info, p, true);
78947 + if (!ret)
78948 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
78949 + }
78950
78951 return ret;
78952 }
78953 @@ -2926,7 +2949,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
78954 int error = -ESRCH;
78955
78956 rcu_read_lock();
78957 - p = find_task_by_vpid(pid);
78958 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
78959 + /* allow glibc communication via tgkill to other threads in our
78960 + thread group */
78961 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
78962 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
78963 + p = find_task_by_vpid_unrestricted(pid);
78964 + else
78965 +#endif
78966 + p = find_task_by_vpid(pid);
78967 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
78968 error = check_kill_permission(sig, info, p);
78969 /*
78970 @@ -3240,8 +3271,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
78971 }
78972 seg = get_fs();
78973 set_fs(KERNEL_DS);
78974 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
78975 - (stack_t __force __user *) &uoss,
78976 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
78977 + (stack_t __force_user *) &uoss,
78978 compat_user_stack_pointer());
78979 set_fs(seg);
78980 if (ret >= 0 && uoss_ptr) {
78981 diff --git a/kernel/smp.c b/kernel/smp.c
78982 index 4dba0f7..fe9f773 100644
78983 --- a/kernel/smp.c
78984 +++ b/kernel/smp.c
78985 @@ -73,7 +73,7 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu)
78986 return NOTIFY_OK;
78987 }
78988
78989 -static struct notifier_block __cpuinitdata hotplug_cfd_notifier = {
78990 +static struct notifier_block hotplug_cfd_notifier = {
78991 .notifier_call = hotplug_cfd,
78992 };
78993
78994 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
78995 index 02fc5c9..e54c335 100644
78996 --- a/kernel/smpboot.c
78997 +++ b/kernel/smpboot.c
78998 @@ -288,7 +288,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
78999 }
79000 smpboot_unpark_thread(plug_thread, cpu);
79001 }
79002 - list_add(&plug_thread->list, &hotplug_threads);
79003 + pax_list_add(&plug_thread->list, &hotplug_threads);
79004 out:
79005 mutex_unlock(&smpboot_threads_lock);
79006 return ret;
79007 @@ -305,7 +305,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
79008 {
79009 get_online_cpus();
79010 mutex_lock(&smpboot_threads_lock);
79011 - list_del(&plug_thread->list);
79012 + pax_list_del(&plug_thread->list);
79013 smpboot_destroy_threads(plug_thread);
79014 mutex_unlock(&smpboot_threads_lock);
79015 put_online_cpus();
79016 diff --git a/kernel/softirq.c b/kernel/softirq.c
79017 index 3d6833f..da6d93d 100644
79018 --- a/kernel/softirq.c
79019 +++ b/kernel/softirq.c
79020 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
79021 EXPORT_SYMBOL(irq_stat);
79022 #endif
79023
79024 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
79025 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
79026
79027 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
79028
79029 -char *softirq_to_name[NR_SOFTIRQS] = {
79030 +const char * const softirq_to_name[NR_SOFTIRQS] = {
79031 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
79032 "TASKLET", "SCHED", "HRTIMER", "RCU"
79033 };
79034 @@ -250,7 +250,7 @@ restart:
79035 kstat_incr_softirqs_this_cpu(vec_nr);
79036
79037 trace_softirq_entry(vec_nr);
79038 - h->action(h);
79039 + h->action();
79040 trace_softirq_exit(vec_nr);
79041 if (unlikely(prev_count != preempt_count())) {
79042 printk(KERN_ERR "huh, entered softirq %u %s %p"
79043 @@ -405,7 +405,7 @@ void __raise_softirq_irqoff(unsigned int nr)
79044 or_softirq_pending(1UL << nr);
79045 }
79046
79047 -void open_softirq(int nr, void (*action)(struct softirq_action *))
79048 +void __init open_softirq(int nr, void (*action)(void))
79049 {
79050 softirq_vec[nr].action = action;
79051 }
79052 @@ -461,7 +461,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
79053
79054 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
79055
79056 -static void tasklet_action(struct softirq_action *a)
79057 +static void tasklet_action(void)
79058 {
79059 struct tasklet_struct *list;
79060
79061 @@ -496,7 +496,7 @@ static void tasklet_action(struct softirq_action *a)
79062 }
79063 }
79064
79065 -static void tasklet_hi_action(struct softirq_action *a)
79066 +static void tasklet_hi_action(void)
79067 {
79068 struct tasklet_struct *list;
79069
79070 @@ -730,7 +730,7 @@ static int __cpuinit remote_softirq_cpu_notify(struct notifier_block *self,
79071 return NOTIFY_OK;
79072 }
79073
79074 -static struct notifier_block __cpuinitdata remote_softirq_cpu_notifier = {
79075 +static struct notifier_block remote_softirq_cpu_notifier = {
79076 .notifier_call = remote_softirq_cpu_notify,
79077 };
79078
79079 @@ -847,11 +847,11 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
79080 return NOTIFY_OK;
79081 }
79082
79083 -static struct notifier_block __cpuinitdata cpu_nfb = {
79084 +static struct notifier_block cpu_nfb = {
79085 .notifier_call = cpu_callback
79086 };
79087
79088 -static struct smp_hotplug_thread softirq_threads = {
79089 +static struct smp_hotplug_thread softirq_threads __read_only = {
79090 .store = &ksoftirqd,
79091 .thread_should_run = ksoftirqd_should_run,
79092 .thread_fn = run_ksoftirqd,
79093 diff --git a/kernel/srcu.c b/kernel/srcu.c
79094 index 01d5ccb..cdcbee6 100644
79095 --- a/kernel/srcu.c
79096 +++ b/kernel/srcu.c
79097 @@ -300,9 +300,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
79098
79099 idx = ACCESS_ONCE(sp->completed) & 0x1;
79100 preempt_disable();
79101 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
79102 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
79103 smp_mb(); /* B */ /* Avoid leaking the critical section. */
79104 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
79105 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
79106 preempt_enable();
79107 return idx;
79108 }
79109 diff --git a/kernel/sys.c b/kernel/sys.c
79110 index 2bbd9a7..0875671 100644
79111 --- a/kernel/sys.c
79112 +++ b/kernel/sys.c
79113 @@ -163,6 +163,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
79114 error = -EACCES;
79115 goto out;
79116 }
79117 +
79118 + if (gr_handle_chroot_setpriority(p, niceval)) {
79119 + error = -EACCES;
79120 + goto out;
79121 + }
79122 +
79123 no_nice = security_task_setnice(p, niceval);
79124 if (no_nice) {
79125 error = no_nice;
79126 @@ -626,6 +632,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
79127 goto error;
79128 }
79129
79130 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
79131 + goto error;
79132 +
79133 if (rgid != (gid_t) -1 ||
79134 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
79135 new->sgid = new->egid;
79136 @@ -661,6 +670,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
79137 old = current_cred();
79138
79139 retval = -EPERM;
79140 +
79141 + if (gr_check_group_change(kgid, kgid, kgid))
79142 + goto error;
79143 +
79144 if (nsown_capable(CAP_SETGID))
79145 new->gid = new->egid = new->sgid = new->fsgid = kgid;
79146 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
79147 @@ -678,7 +691,7 @@ error:
79148 /*
79149 * change the user struct in a credentials set to match the new UID
79150 */
79151 -static int set_user(struct cred *new)
79152 +int set_user(struct cred *new)
79153 {
79154 struct user_struct *new_user;
79155
79156 @@ -758,6 +771,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
79157 goto error;
79158 }
79159
79160 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
79161 + goto error;
79162 +
79163 if (!uid_eq(new->uid, old->uid)) {
79164 retval = set_user(new);
79165 if (retval < 0)
79166 @@ -808,6 +824,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
79167 old = current_cred();
79168
79169 retval = -EPERM;
79170 +
79171 + if (gr_check_crash_uid(kuid))
79172 + goto error;
79173 + if (gr_check_user_change(kuid, kuid, kuid))
79174 + goto error;
79175 +
79176 if (nsown_capable(CAP_SETUID)) {
79177 new->suid = new->uid = kuid;
79178 if (!uid_eq(kuid, old->uid)) {
79179 @@ -877,6 +899,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
79180 goto error;
79181 }
79182
79183 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
79184 + goto error;
79185 +
79186 if (ruid != (uid_t) -1) {
79187 new->uid = kruid;
79188 if (!uid_eq(kruid, old->uid)) {
79189 @@ -959,6 +984,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
79190 goto error;
79191 }
79192
79193 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
79194 + goto error;
79195 +
79196 if (rgid != (gid_t) -1)
79197 new->gid = krgid;
79198 if (egid != (gid_t) -1)
79199 @@ -1020,12 +1048,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
79200 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
79201 nsown_capable(CAP_SETUID)) {
79202 if (!uid_eq(kuid, old->fsuid)) {
79203 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
79204 + goto error;
79205 +
79206 new->fsuid = kuid;
79207 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
79208 goto change_okay;
79209 }
79210 }
79211
79212 +error:
79213 abort_creds(new);
79214 return old_fsuid;
79215
79216 @@ -1058,12 +1090,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
79217 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
79218 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
79219 nsown_capable(CAP_SETGID)) {
79220 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
79221 + goto error;
79222 +
79223 if (!gid_eq(kgid, old->fsgid)) {
79224 new->fsgid = kgid;
79225 goto change_okay;
79226 }
79227 }
79228
79229 +error:
79230 abort_creds(new);
79231 return old_fsgid;
79232
79233 @@ -1432,19 +1468,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
79234 return -EFAULT;
79235
79236 down_read(&uts_sem);
79237 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
79238 + error = __copy_to_user(name->sysname, &utsname()->sysname,
79239 __OLD_UTS_LEN);
79240 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
79241 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
79242 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
79243 __OLD_UTS_LEN);
79244 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
79245 - error |= __copy_to_user(&name->release, &utsname()->release,
79246 + error |= __copy_to_user(name->release, &utsname()->release,
79247 __OLD_UTS_LEN);
79248 error |= __put_user(0, name->release + __OLD_UTS_LEN);
79249 - error |= __copy_to_user(&name->version, &utsname()->version,
79250 + error |= __copy_to_user(name->version, &utsname()->version,
79251 __OLD_UTS_LEN);
79252 error |= __put_user(0, name->version + __OLD_UTS_LEN);
79253 - error |= __copy_to_user(&name->machine, &utsname()->machine,
79254 + error |= __copy_to_user(name->machine, &utsname()->machine,
79255 __OLD_UTS_LEN);
79256 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
79257 up_read(&uts_sem);
79258 @@ -1646,6 +1682,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
79259 */
79260 new_rlim->rlim_cur = 1;
79261 }
79262 + /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
79263 + is changed to a lower value. Since tasks can be created by the same
79264 + user in between this limit change and an execve by this task, force
79265 + a recheck only for this task by setting PF_NPROC_EXCEEDED
79266 + */
79267 + if (resource == RLIMIT_NPROC && tsk->real_cred->user != INIT_USER)
79268 + tsk->flags |= PF_NPROC_EXCEEDED;
79269 }
79270 if (!retval) {
79271 if (old_rlim)
79272 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
79273 index 9edcf45..713c960 100644
79274 --- a/kernel/sysctl.c
79275 +++ b/kernel/sysctl.c
79276 @@ -93,7 +93,6 @@
79277
79278
79279 #if defined(CONFIG_SYSCTL)
79280 -
79281 /* External variables not in a header file. */
79282 extern int sysctl_overcommit_memory;
79283 extern int sysctl_overcommit_ratio;
79284 @@ -119,18 +118,18 @@ extern int blk_iopoll_enabled;
79285
79286 /* Constants used for minimum and maximum */
79287 #ifdef CONFIG_LOCKUP_DETECTOR
79288 -static int sixty = 60;
79289 -static int neg_one = -1;
79290 +static int sixty __read_only = 60;
79291 #endif
79292
79293 -static int zero;
79294 -static int __maybe_unused one = 1;
79295 -static int __maybe_unused two = 2;
79296 -static int __maybe_unused three = 3;
79297 -static unsigned long one_ul = 1;
79298 -static int one_hundred = 100;
79299 +static int neg_one __read_only = -1;
79300 +static int zero __read_only = 0;
79301 +static int __maybe_unused one __read_only = 1;
79302 +static int __maybe_unused two __read_only = 2;
79303 +static int __maybe_unused three __read_only = 3;
79304 +static unsigned long one_ul __read_only = 1;
79305 +static int one_hundred __read_only = 100;
79306 #ifdef CONFIG_PRINTK
79307 -static int ten_thousand = 10000;
79308 +static int ten_thousand __read_only = 10000;
79309 #endif
79310
79311 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
79312 @@ -177,10 +176,8 @@ static int proc_taint(struct ctl_table *table, int write,
79313 void __user *buffer, size_t *lenp, loff_t *ppos);
79314 #endif
79315
79316 -#ifdef CONFIG_PRINTK
79317 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
79318 void __user *buffer, size_t *lenp, loff_t *ppos);
79319 -#endif
79320
79321 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
79322 void __user *buffer, size_t *lenp, loff_t *ppos);
79323 @@ -211,6 +208,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
79324
79325 #endif
79326
79327 +extern struct ctl_table grsecurity_table[];
79328 +
79329 static struct ctl_table kern_table[];
79330 static struct ctl_table vm_table[];
79331 static struct ctl_table fs_table[];
79332 @@ -225,6 +224,20 @@ extern struct ctl_table epoll_table[];
79333 int sysctl_legacy_va_layout;
79334 #endif
79335
79336 +#ifdef CONFIG_PAX_SOFTMODE
79337 +static ctl_table pax_table[] = {
79338 + {
79339 + .procname = "softmode",
79340 + .data = &pax_softmode,
79341 + .maxlen = sizeof(unsigned int),
79342 + .mode = 0600,
79343 + .proc_handler = &proc_dointvec,
79344 + },
79345 +
79346 + { }
79347 +};
79348 +#endif
79349 +
79350 /* The default sysctl tables: */
79351
79352 static struct ctl_table sysctl_base_table[] = {
79353 @@ -273,6 +286,22 @@ static int max_extfrag_threshold = 1000;
79354 #endif
79355
79356 static struct ctl_table kern_table[] = {
79357 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
79358 + {
79359 + .procname = "grsecurity",
79360 + .mode = 0500,
79361 + .child = grsecurity_table,
79362 + },
79363 +#endif
79364 +
79365 +#ifdef CONFIG_PAX_SOFTMODE
79366 + {
79367 + .procname = "pax",
79368 + .mode = 0500,
79369 + .child = pax_table,
79370 + },
79371 +#endif
79372 +
79373 {
79374 .procname = "sched_child_runs_first",
79375 .data = &sysctl_sched_child_runs_first,
79376 @@ -607,7 +636,7 @@ static struct ctl_table kern_table[] = {
79377 .data = &modprobe_path,
79378 .maxlen = KMOD_PATH_LEN,
79379 .mode = 0644,
79380 - .proc_handler = proc_dostring,
79381 + .proc_handler = proc_dostring_modpriv,
79382 },
79383 {
79384 .procname = "modules_disabled",
79385 @@ -774,16 +803,20 @@ static struct ctl_table kern_table[] = {
79386 .extra1 = &zero,
79387 .extra2 = &one,
79388 },
79389 +#endif
79390 {
79391 .procname = "kptr_restrict",
79392 .data = &kptr_restrict,
79393 .maxlen = sizeof(int),
79394 .mode = 0644,
79395 .proc_handler = proc_dointvec_minmax_sysadmin,
79396 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79397 + .extra1 = &two,
79398 +#else
79399 .extra1 = &zero,
79400 +#endif
79401 .extra2 = &two,
79402 },
79403 -#endif
79404 {
79405 .procname = "ngroups_max",
79406 .data = &ngroups_max,
79407 @@ -1025,10 +1058,17 @@ static struct ctl_table kern_table[] = {
79408 */
79409 {
79410 .procname = "perf_event_paranoid",
79411 - .data = &sysctl_perf_event_paranoid,
79412 - .maxlen = sizeof(sysctl_perf_event_paranoid),
79413 + .data = &sysctl_perf_event_legitimately_concerned,
79414 + .maxlen = sizeof(sysctl_perf_event_legitimately_concerned),
79415 .mode = 0644,
79416 - .proc_handler = proc_dointvec,
79417 + /* go ahead, be a hero */
79418 + .proc_handler = proc_dointvec_minmax_sysadmin,
79419 + .extra1 = &neg_one,
79420 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
79421 + .extra2 = &three,
79422 +#else
79423 + .extra2 = &two,
79424 +#endif
79425 },
79426 {
79427 .procname = "perf_event_mlock_kb",
79428 @@ -1282,6 +1322,13 @@ static struct ctl_table vm_table[] = {
79429 .proc_handler = proc_dointvec_minmax,
79430 .extra1 = &zero,
79431 },
79432 + {
79433 + .procname = "heap_stack_gap",
79434 + .data = &sysctl_heap_stack_gap,
79435 + .maxlen = sizeof(sysctl_heap_stack_gap),
79436 + .mode = 0644,
79437 + .proc_handler = proc_doulongvec_minmax,
79438 + },
79439 #else
79440 {
79441 .procname = "nr_trim_pages",
79442 @@ -1746,6 +1793,16 @@ int proc_dostring(struct ctl_table *table, int write,
79443 buffer, lenp, ppos);
79444 }
79445
79446 +int proc_dostring_modpriv(struct ctl_table *table, int write,
79447 + void __user *buffer, size_t *lenp, loff_t *ppos)
79448 +{
79449 + if (write && !capable(CAP_SYS_MODULE))
79450 + return -EPERM;
79451 +
79452 + return _proc_do_string(table->data, table->maxlen, write,
79453 + buffer, lenp, ppos);
79454 +}
79455 +
79456 static size_t proc_skip_spaces(char **buf)
79457 {
79458 size_t ret;
79459 @@ -1851,6 +1908,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
79460 len = strlen(tmp);
79461 if (len > *size)
79462 len = *size;
79463 + if (len > sizeof(tmp))
79464 + len = sizeof(tmp);
79465 if (copy_to_user(*buf, tmp, len))
79466 return -EFAULT;
79467 *size -= len;
79468 @@ -2015,7 +2074,7 @@ int proc_dointvec(struct ctl_table *table, int write,
79469 static int proc_taint(struct ctl_table *table, int write,
79470 void __user *buffer, size_t *lenp, loff_t *ppos)
79471 {
79472 - struct ctl_table t;
79473 + ctl_table_no_const t;
79474 unsigned long tmptaint = get_taint();
79475 int err;
79476
79477 @@ -2043,7 +2102,6 @@ static int proc_taint(struct ctl_table *table, int write,
79478 return err;
79479 }
79480
79481 -#ifdef CONFIG_PRINTK
79482 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
79483 void __user *buffer, size_t *lenp, loff_t *ppos)
79484 {
79485 @@ -2052,7 +2110,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
79486
79487 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
79488 }
79489 -#endif
79490
79491 struct do_proc_dointvec_minmax_conv_param {
79492 int *min;
79493 @@ -2199,8 +2256,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
79494 *i = val;
79495 } else {
79496 val = convdiv * (*i) / convmul;
79497 - if (!first)
79498 + if (!first) {
79499 err = proc_put_char(&buffer, &left, '\t');
79500 + if (err)
79501 + break;
79502 + }
79503 err = proc_put_long(&buffer, &left, val, false);
79504 if (err)
79505 break;
79506 @@ -2592,6 +2652,12 @@ int proc_dostring(struct ctl_table *table, int write,
79507 return -ENOSYS;
79508 }
79509
79510 +int proc_dostring_modpriv(struct ctl_table *table, int write,
79511 + void __user *buffer, size_t *lenp, loff_t *ppos)
79512 +{
79513 + return -ENOSYS;
79514 +}
79515 +
79516 int proc_dointvec(struct ctl_table *table, int write,
79517 void __user *buffer, size_t *lenp, loff_t *ppos)
79518 {
79519 @@ -2648,5 +2714,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
79520 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
79521 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
79522 EXPORT_SYMBOL(proc_dostring);
79523 +EXPORT_SYMBOL(proc_dostring_modpriv);
79524 EXPORT_SYMBOL(proc_doulongvec_minmax);
79525 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
79526 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
79527 index 145bb4d..b2aa969 100644
79528 --- a/kernel/taskstats.c
79529 +++ b/kernel/taskstats.c
79530 @@ -28,9 +28,12 @@
79531 #include <linux/fs.h>
79532 #include <linux/file.h>
79533 #include <linux/pid_namespace.h>
79534 +#include <linux/grsecurity.h>
79535 #include <net/genetlink.h>
79536 #include <linux/atomic.h>
79537
79538 +extern int gr_is_taskstats_denied(int pid);
79539 +
79540 /*
79541 * Maximum length of a cpumask that can be specified in
79542 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
79543 @@ -570,6 +573,9 @@ err:
79544
79545 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
79546 {
79547 + if (gr_is_taskstats_denied(current->pid))
79548 + return -EACCES;
79549 +
79550 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
79551 return cmd_attr_register_cpumask(info);
79552 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
79553 diff --git a/kernel/time.c b/kernel/time.c
79554 index d3617db..c98bbe9 100644
79555 --- a/kernel/time.c
79556 +++ b/kernel/time.c
79557 @@ -172,6 +172,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
79558 return error;
79559
79560 if (tz) {
79561 + /* we log in do_settimeofday called below, so don't log twice
79562 + */
79563 + if (!tv)
79564 + gr_log_timechange();
79565 +
79566 sys_tz = *tz;
79567 update_vsyscall_tz();
79568 if (firsttime) {
79569 @@ -502,7 +507,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
79570 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
79571 * value to a scaled second value.
79572 */
79573 -unsigned long
79574 +unsigned long __intentional_overflow(-1)
79575 timespec_to_jiffies(const struct timespec *value)
79576 {
79577 unsigned long sec = value->tv_sec;
79578 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
79579 index f11d83b..d016d91 100644
79580 --- a/kernel/time/alarmtimer.c
79581 +++ b/kernel/time/alarmtimer.c
79582 @@ -750,7 +750,7 @@ static int __init alarmtimer_init(void)
79583 struct platform_device *pdev;
79584 int error = 0;
79585 int i;
79586 - struct k_clock alarm_clock = {
79587 + static struct k_clock alarm_clock = {
79588 .clock_getres = alarm_clock_getres,
79589 .clock_get = alarm_clock_get,
79590 .timer_create = alarm_timer_create,
79591 diff --git a/kernel/time/tick-broadcast.c b/kernel/time/tick-broadcast.c
79592 index 20d6fba..09e103a 100644
79593 --- a/kernel/time/tick-broadcast.c
79594 +++ b/kernel/time/tick-broadcast.c
79595 @@ -147,7 +147,7 @@ int tick_device_uses_broadcast(struct clock_event_device *dev, int cpu)
79596 * then clear the broadcast bit.
79597 */
79598 if (!(dev->features & CLOCK_EVT_FEAT_C3STOP)) {
79599 - int cpu = smp_processor_id();
79600 + cpu = smp_processor_id();
79601 cpumask_clear_cpu(cpu, tick_broadcast_mask);
79602 tick_broadcast_clear_oneshot(cpu);
79603 } else {
79604 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
79605 index baeeb5c..c22704a 100644
79606 --- a/kernel/time/timekeeping.c
79607 +++ b/kernel/time/timekeeping.c
79608 @@ -15,6 +15,7 @@
79609 #include <linux/init.h>
79610 #include <linux/mm.h>
79611 #include <linux/sched.h>
79612 +#include <linux/grsecurity.h>
79613 #include <linux/syscore_ops.h>
79614 #include <linux/clocksource.h>
79615 #include <linux/jiffies.h>
79616 @@ -495,6 +496,8 @@ int do_settimeofday(const struct timespec *tv)
79617 if (!timespec_valid_strict(tv))
79618 return -EINVAL;
79619
79620 + gr_log_timechange();
79621 +
79622 raw_spin_lock_irqsave(&timekeeper_lock, flags);
79623 write_seqcount_begin(&timekeeper_seq);
79624
79625 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
79626 index 3bdf283..cc68d83 100644
79627 --- a/kernel/time/timer_list.c
79628 +++ b/kernel/time/timer_list.c
79629 @@ -45,12 +45,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
79630
79631 static void print_name_offset(struct seq_file *m, void *sym)
79632 {
79633 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79634 + SEQ_printf(m, "<%p>", NULL);
79635 +#else
79636 char symname[KSYM_NAME_LEN];
79637
79638 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
79639 SEQ_printf(m, "<%pK>", sym);
79640 else
79641 SEQ_printf(m, "%s", symname);
79642 +#endif
79643 }
79644
79645 static void
79646 @@ -119,7 +123,11 @@ next_one:
79647 static void
79648 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
79649 {
79650 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79651 + SEQ_printf(m, " .base: %p\n", NULL);
79652 +#else
79653 SEQ_printf(m, " .base: %pK\n", base);
79654 +#endif
79655 SEQ_printf(m, " .index: %d\n",
79656 base->index);
79657 SEQ_printf(m, " .resolution: %Lu nsecs\n",
79658 @@ -355,7 +363,11 @@ static int __init init_timer_list_procfs(void)
79659 {
79660 struct proc_dir_entry *pe;
79661
79662 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
79663 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
79664 +#else
79665 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
79666 +#endif
79667 if (!pe)
79668 return -ENOMEM;
79669 return 0;
79670 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
79671 index 0b537f2..40d6c20 100644
79672 --- a/kernel/time/timer_stats.c
79673 +++ b/kernel/time/timer_stats.c
79674 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
79675 static unsigned long nr_entries;
79676 static struct entry entries[MAX_ENTRIES];
79677
79678 -static atomic_t overflow_count;
79679 +static atomic_unchecked_t overflow_count;
79680
79681 /*
79682 * The entries are in a hash-table, for fast lookup:
79683 @@ -140,7 +140,7 @@ static void reset_entries(void)
79684 nr_entries = 0;
79685 memset(entries, 0, sizeof(entries));
79686 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
79687 - atomic_set(&overflow_count, 0);
79688 + atomic_set_unchecked(&overflow_count, 0);
79689 }
79690
79691 static struct entry *alloc_entry(void)
79692 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
79693 if (likely(entry))
79694 entry->count++;
79695 else
79696 - atomic_inc(&overflow_count);
79697 + atomic_inc_unchecked(&overflow_count);
79698
79699 out_unlock:
79700 raw_spin_unlock_irqrestore(lock, flags);
79701 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
79702
79703 static void print_name_offset(struct seq_file *m, unsigned long addr)
79704 {
79705 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79706 + seq_printf(m, "<%p>", NULL);
79707 +#else
79708 char symname[KSYM_NAME_LEN];
79709
79710 if (lookup_symbol_name(addr, symname) < 0)
79711 - seq_printf(m, "<%p>", (void *)addr);
79712 + seq_printf(m, "<%pK>", (void *)addr);
79713 else
79714 seq_printf(m, "%s", symname);
79715 +#endif
79716 }
79717
79718 static int tstats_show(struct seq_file *m, void *v)
79719 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
79720
79721 seq_puts(m, "Timer Stats Version: v0.2\n");
79722 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
79723 - if (atomic_read(&overflow_count))
79724 + if (atomic_read_unchecked(&overflow_count))
79725 seq_printf(m, "Overflow: %d entries\n",
79726 - atomic_read(&overflow_count));
79727 + atomic_read_unchecked(&overflow_count));
79728
79729 for (i = 0; i < nr_entries; i++) {
79730 entry = entries + i;
79731 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
79732 {
79733 struct proc_dir_entry *pe;
79734
79735 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
79736 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
79737 +#else
79738 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
79739 +#endif
79740 if (!pe)
79741 return -ENOMEM;
79742 return 0;
79743 diff --git a/kernel/timer.c b/kernel/timer.c
79744 index 15ffdb3..62d885c 100644
79745 --- a/kernel/timer.c
79746 +++ b/kernel/timer.c
79747 @@ -1364,7 +1364,7 @@ void update_process_times(int user_tick)
79748 /*
79749 * This function runs timers and the timer-tq in bottom half context.
79750 */
79751 -static void run_timer_softirq(struct softirq_action *h)
79752 +static void run_timer_softirq(void)
79753 {
79754 struct tvec_base *base = __this_cpu_read(tvec_bases);
79755
79756 @@ -1427,7 +1427,7 @@ static void process_timeout(unsigned long __data)
79757 *
79758 * In all cases the return value is guaranteed to be non-negative.
79759 */
79760 -signed long __sched schedule_timeout(signed long timeout)
79761 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
79762 {
79763 struct timer_list timer;
79764 unsigned long expire;
79765 @@ -1633,7 +1633,7 @@ static int __cpuinit timer_cpu_notify(struct notifier_block *self,
79766 return NOTIFY_OK;
79767 }
79768
79769 -static struct notifier_block __cpuinitdata timers_nb = {
79770 +static struct notifier_block timers_nb = {
79771 .notifier_call = timer_cpu_notify,
79772 };
79773
79774 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
79775 index b8b8560..75b1a09 100644
79776 --- a/kernel/trace/blktrace.c
79777 +++ b/kernel/trace/blktrace.c
79778 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
79779 struct blk_trace *bt = filp->private_data;
79780 char buf[16];
79781
79782 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
79783 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
79784
79785 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
79786 }
79787 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
79788 return 1;
79789
79790 bt = buf->chan->private_data;
79791 - atomic_inc(&bt->dropped);
79792 + atomic_inc_unchecked(&bt->dropped);
79793 return 0;
79794 }
79795
79796 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
79797
79798 bt->dir = dir;
79799 bt->dev = dev;
79800 - atomic_set(&bt->dropped, 0);
79801 + atomic_set_unchecked(&bt->dropped, 0);
79802
79803 ret = -EIO;
79804 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
79805 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
79806 index 6c508ff..ee55a13 100644
79807 --- a/kernel/trace/ftrace.c
79808 +++ b/kernel/trace/ftrace.c
79809 @@ -1915,12 +1915,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
79810 if (unlikely(ftrace_disabled))
79811 return 0;
79812
79813 + ret = ftrace_arch_code_modify_prepare();
79814 + FTRACE_WARN_ON(ret);
79815 + if (ret)
79816 + return 0;
79817 +
79818 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
79819 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
79820 if (ret) {
79821 ftrace_bug(ret, ip);
79822 - return 0;
79823 }
79824 - return 1;
79825 + return ret ? 0 : 1;
79826 }
79827
79828 /*
79829 @@ -3931,8 +3936,10 @@ static int ftrace_process_locs(struct module *mod,
79830 if (!count)
79831 return 0;
79832
79833 + pax_open_kernel();
79834 sort(start, count, sizeof(*start),
79835 ftrace_cmp_ips, ftrace_swap_ips);
79836 + pax_close_kernel();
79837
79838 start_pg = ftrace_allocate_pages(count);
79839 if (!start_pg)
79840 @@ -4655,8 +4662,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
79841 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
79842
79843 static int ftrace_graph_active;
79844 -static struct notifier_block ftrace_suspend_notifier;
79845 -
79846 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
79847 {
79848 return 0;
79849 @@ -4800,6 +4805,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
79850 return NOTIFY_DONE;
79851 }
79852
79853 +static struct notifier_block ftrace_suspend_notifier = {
79854 + .notifier_call = ftrace_suspend_notifier_call
79855 +};
79856 +
79857 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
79858 trace_func_graph_ent_t entryfunc)
79859 {
79860 @@ -4813,7 +4822,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
79861 goto out;
79862 }
79863
79864 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
79865 register_pm_notifier(&ftrace_suspend_notifier);
79866
79867 ftrace_graph_active++;
79868 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
79869 index e444ff8..438b8f4 100644
79870 --- a/kernel/trace/ring_buffer.c
79871 +++ b/kernel/trace/ring_buffer.c
79872 @@ -352,9 +352,9 @@ struct buffer_data_page {
79873 */
79874 struct buffer_page {
79875 struct list_head list; /* list of buffer pages */
79876 - local_t write; /* index for next write */
79877 + local_unchecked_t write; /* index for next write */
79878 unsigned read; /* index for next read */
79879 - local_t entries; /* entries on this page */
79880 + local_unchecked_t entries; /* entries on this page */
79881 unsigned long real_end; /* real end of data */
79882 struct buffer_data_page *page; /* Actual data page */
79883 };
79884 @@ -473,8 +473,8 @@ struct ring_buffer_per_cpu {
79885 unsigned long last_overrun;
79886 local_t entries_bytes;
79887 local_t entries;
79888 - local_t overrun;
79889 - local_t commit_overrun;
79890 + local_unchecked_t overrun;
79891 + local_unchecked_t commit_overrun;
79892 local_t dropped_events;
79893 local_t committing;
79894 local_t commits;
79895 @@ -992,8 +992,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
79896 *
79897 * We add a counter to the write field to denote this.
79898 */
79899 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
79900 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
79901 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
79902 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
79903
79904 /*
79905 * Just make sure we have seen our old_write and synchronize
79906 @@ -1021,8 +1021,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
79907 * cmpxchg to only update if an interrupt did not already
79908 * do it for us. If the cmpxchg fails, we don't care.
79909 */
79910 - (void)local_cmpxchg(&next_page->write, old_write, val);
79911 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
79912 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
79913 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
79914
79915 /*
79916 * No need to worry about races with clearing out the commit.
79917 @@ -1386,12 +1386,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
79918
79919 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
79920 {
79921 - return local_read(&bpage->entries) & RB_WRITE_MASK;
79922 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
79923 }
79924
79925 static inline unsigned long rb_page_write(struct buffer_page *bpage)
79926 {
79927 - return local_read(&bpage->write) & RB_WRITE_MASK;
79928 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
79929 }
79930
79931 static int
79932 @@ -1486,7 +1486,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
79933 * bytes consumed in ring buffer from here.
79934 * Increment overrun to account for the lost events.
79935 */
79936 - local_add(page_entries, &cpu_buffer->overrun);
79937 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
79938 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
79939 }
79940
79941 @@ -2063,7 +2063,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
79942 * it is our responsibility to update
79943 * the counters.
79944 */
79945 - local_add(entries, &cpu_buffer->overrun);
79946 + local_add_unchecked(entries, &cpu_buffer->overrun);
79947 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
79948
79949 /*
79950 @@ -2213,7 +2213,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79951 if (tail == BUF_PAGE_SIZE)
79952 tail_page->real_end = 0;
79953
79954 - local_sub(length, &tail_page->write);
79955 + local_sub_unchecked(length, &tail_page->write);
79956 return;
79957 }
79958
79959 @@ -2248,7 +2248,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79960 rb_event_set_padding(event);
79961
79962 /* Set the write back to the previous setting */
79963 - local_sub(length, &tail_page->write);
79964 + local_sub_unchecked(length, &tail_page->write);
79965 return;
79966 }
79967
79968 @@ -2260,7 +2260,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
79969
79970 /* Set write to end of buffer */
79971 length = (tail + length) - BUF_PAGE_SIZE;
79972 - local_sub(length, &tail_page->write);
79973 + local_sub_unchecked(length, &tail_page->write);
79974 }
79975
79976 /*
79977 @@ -2286,7 +2286,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
79978 * about it.
79979 */
79980 if (unlikely(next_page == commit_page)) {
79981 - local_inc(&cpu_buffer->commit_overrun);
79982 + local_inc_unchecked(&cpu_buffer->commit_overrun);
79983 goto out_reset;
79984 }
79985
79986 @@ -2342,7 +2342,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
79987 cpu_buffer->tail_page) &&
79988 (cpu_buffer->commit_page ==
79989 cpu_buffer->reader_page))) {
79990 - local_inc(&cpu_buffer->commit_overrun);
79991 + local_inc_unchecked(&cpu_buffer->commit_overrun);
79992 goto out_reset;
79993 }
79994 }
79995 @@ -2390,7 +2390,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
79996 length += RB_LEN_TIME_EXTEND;
79997
79998 tail_page = cpu_buffer->tail_page;
79999 - write = local_add_return(length, &tail_page->write);
80000 + write = local_add_return_unchecked(length, &tail_page->write);
80001
80002 /* set write to only the index of the write */
80003 write &= RB_WRITE_MASK;
80004 @@ -2407,7 +2407,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
80005 kmemcheck_annotate_bitfield(event, bitfield);
80006 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
80007
80008 - local_inc(&tail_page->entries);
80009 + local_inc_unchecked(&tail_page->entries);
80010
80011 /*
80012 * If this is the first commit on the page, then update
80013 @@ -2440,7 +2440,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
80014
80015 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
80016 unsigned long write_mask =
80017 - local_read(&bpage->write) & ~RB_WRITE_MASK;
80018 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
80019 unsigned long event_length = rb_event_length(event);
80020 /*
80021 * This is on the tail page. It is possible that
80022 @@ -2450,7 +2450,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
80023 */
80024 old_index += write_mask;
80025 new_index += write_mask;
80026 - index = local_cmpxchg(&bpage->write, old_index, new_index);
80027 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
80028 if (index == old_index) {
80029 /* update counters */
80030 local_sub(event_length, &cpu_buffer->entries_bytes);
80031 @@ -2842,7 +2842,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
80032
80033 /* Do the likely case first */
80034 if (likely(bpage->page == (void *)addr)) {
80035 - local_dec(&bpage->entries);
80036 + local_dec_unchecked(&bpage->entries);
80037 return;
80038 }
80039
80040 @@ -2854,7 +2854,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
80041 start = bpage;
80042 do {
80043 if (bpage->page == (void *)addr) {
80044 - local_dec(&bpage->entries);
80045 + local_dec_unchecked(&bpage->entries);
80046 return;
80047 }
80048 rb_inc_page(cpu_buffer, &bpage);
80049 @@ -3138,7 +3138,7 @@ static inline unsigned long
80050 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
80051 {
80052 return local_read(&cpu_buffer->entries) -
80053 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
80054 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
80055 }
80056
80057 /**
80058 @@ -3227,7 +3227,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
80059 return 0;
80060
80061 cpu_buffer = buffer->buffers[cpu];
80062 - ret = local_read(&cpu_buffer->overrun);
80063 + ret = local_read_unchecked(&cpu_buffer->overrun);
80064
80065 return ret;
80066 }
80067 @@ -3250,7 +3250,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
80068 return 0;
80069
80070 cpu_buffer = buffer->buffers[cpu];
80071 - ret = local_read(&cpu_buffer->commit_overrun);
80072 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
80073
80074 return ret;
80075 }
80076 @@ -3335,7 +3335,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
80077 /* if you care about this being correct, lock the buffer */
80078 for_each_buffer_cpu(buffer, cpu) {
80079 cpu_buffer = buffer->buffers[cpu];
80080 - overruns += local_read(&cpu_buffer->overrun);
80081 + overruns += local_read_unchecked(&cpu_buffer->overrun);
80082 }
80083
80084 return overruns;
80085 @@ -3511,8 +3511,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
80086 /*
80087 * Reset the reader page to size zero.
80088 */
80089 - local_set(&cpu_buffer->reader_page->write, 0);
80090 - local_set(&cpu_buffer->reader_page->entries, 0);
80091 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
80092 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
80093 local_set(&cpu_buffer->reader_page->page->commit, 0);
80094 cpu_buffer->reader_page->real_end = 0;
80095
80096 @@ -3546,7 +3546,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
80097 * want to compare with the last_overrun.
80098 */
80099 smp_mb();
80100 - overwrite = local_read(&(cpu_buffer->overrun));
80101 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
80102
80103 /*
80104 * Here's the tricky part.
80105 @@ -4116,8 +4116,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
80106
80107 cpu_buffer->head_page
80108 = list_entry(cpu_buffer->pages, struct buffer_page, list);
80109 - local_set(&cpu_buffer->head_page->write, 0);
80110 - local_set(&cpu_buffer->head_page->entries, 0);
80111 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
80112 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
80113 local_set(&cpu_buffer->head_page->page->commit, 0);
80114
80115 cpu_buffer->head_page->read = 0;
80116 @@ -4127,14 +4127,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
80117
80118 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
80119 INIT_LIST_HEAD(&cpu_buffer->new_pages);
80120 - local_set(&cpu_buffer->reader_page->write, 0);
80121 - local_set(&cpu_buffer->reader_page->entries, 0);
80122 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
80123 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
80124 local_set(&cpu_buffer->reader_page->page->commit, 0);
80125 cpu_buffer->reader_page->read = 0;
80126
80127 local_set(&cpu_buffer->entries_bytes, 0);
80128 - local_set(&cpu_buffer->overrun, 0);
80129 - local_set(&cpu_buffer->commit_overrun, 0);
80130 + local_set_unchecked(&cpu_buffer->overrun, 0);
80131 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
80132 local_set(&cpu_buffer->dropped_events, 0);
80133 local_set(&cpu_buffer->entries, 0);
80134 local_set(&cpu_buffer->committing, 0);
80135 @@ -4538,8 +4538,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
80136 rb_init_page(bpage);
80137 bpage = reader->page;
80138 reader->page = *data_page;
80139 - local_set(&reader->write, 0);
80140 - local_set(&reader->entries, 0);
80141 + local_set_unchecked(&reader->write, 0);
80142 + local_set_unchecked(&reader->entries, 0);
80143 reader->read = 0;
80144 *data_page = bpage;
80145
80146 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
80147 index e71a8be..948710a 100644
80148 --- a/kernel/trace/trace.c
80149 +++ b/kernel/trace/trace.c
80150 @@ -3201,7 +3201,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
80151 return 0;
80152 }
80153
80154 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)
80155 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled)
80156 {
80157 /* do nothing if flag is already set */
80158 if (!!(trace_flags & mask) == !!enabled)
80159 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
80160 index 20572ed..fe55cf3 100644
80161 --- a/kernel/trace/trace.h
80162 +++ b/kernel/trace/trace.h
80163 @@ -1030,7 +1030,7 @@ extern const char *__stop___trace_bprintk_fmt[];
80164 void trace_printk_init_buffers(void);
80165 void trace_printk_start_comm(void);
80166 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
80167 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled);
80168 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled);
80169
80170 /*
80171 * Normal trace_printk() and friends allocates special buffers
80172 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
80173 index 27963e2..5a6936f 100644
80174 --- a/kernel/trace/trace_events.c
80175 +++ b/kernel/trace/trace_events.c
80176 @@ -1637,10 +1637,6 @@ static LIST_HEAD(ftrace_module_file_list);
80177 struct ftrace_module_file_ops {
80178 struct list_head list;
80179 struct module *mod;
80180 - struct file_operations id;
80181 - struct file_operations enable;
80182 - struct file_operations format;
80183 - struct file_operations filter;
80184 };
80185
80186 static struct ftrace_module_file_ops *
80187 @@ -1681,17 +1677,12 @@ trace_create_file_ops(struct module *mod)
80188
80189 file_ops->mod = mod;
80190
80191 - file_ops->id = ftrace_event_id_fops;
80192 - file_ops->id.owner = mod;
80193 -
80194 - file_ops->enable = ftrace_enable_fops;
80195 - file_ops->enable.owner = mod;
80196 -
80197 - file_ops->filter = ftrace_event_filter_fops;
80198 - file_ops->filter.owner = mod;
80199 -
80200 - file_ops->format = ftrace_event_format_fops;
80201 - file_ops->format.owner = mod;
80202 + pax_open_kernel();
80203 + mod->trace_id.owner = mod;
80204 + mod->trace_enable.owner = mod;
80205 + mod->trace_filter.owner = mod;
80206 + mod->trace_format.owner = mod;
80207 + pax_close_kernel();
80208
80209 list_add(&file_ops->list, &ftrace_module_file_list);
80210
80211 @@ -1782,8 +1773,8 @@ __trace_add_new_mod_event(struct ftrace_event_call *call,
80212 struct ftrace_module_file_ops *file_ops)
80213 {
80214 return __trace_add_new_event(call, tr,
80215 - &file_ops->id, &file_ops->enable,
80216 - &file_ops->filter, &file_ops->format);
80217 + &file_ops->mod->trace_id, &file_ops->mod->trace_enable,
80218 + &file_ops->mod->trace_filter, &file_ops->mod->trace_format);
80219 }
80220
80221 #else
80222 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
80223 index a5e8f48..a9690d2 100644
80224 --- a/kernel/trace/trace_mmiotrace.c
80225 +++ b/kernel/trace/trace_mmiotrace.c
80226 @@ -24,7 +24,7 @@ struct header_iter {
80227 static struct trace_array *mmio_trace_array;
80228 static bool overrun_detected;
80229 static unsigned long prev_overruns;
80230 -static atomic_t dropped_count;
80231 +static atomic_unchecked_t dropped_count;
80232
80233 static void mmio_reset_data(struct trace_array *tr)
80234 {
80235 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
80236
80237 static unsigned long count_overruns(struct trace_iterator *iter)
80238 {
80239 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
80240 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
80241 unsigned long over = ring_buffer_overruns(iter->trace_buffer->buffer);
80242
80243 if (over > prev_overruns)
80244 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
80245 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
80246 sizeof(*entry), 0, pc);
80247 if (!event) {
80248 - atomic_inc(&dropped_count);
80249 + atomic_inc_unchecked(&dropped_count);
80250 return;
80251 }
80252 entry = ring_buffer_event_data(event);
80253 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
80254 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
80255 sizeof(*entry), 0, pc);
80256 if (!event) {
80257 - atomic_inc(&dropped_count);
80258 + atomic_inc_unchecked(&dropped_count);
80259 return;
80260 }
80261 entry = ring_buffer_event_data(event);
80262 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
80263 index bb922d9..2a54a257 100644
80264 --- a/kernel/trace/trace_output.c
80265 +++ b/kernel/trace/trace_output.c
80266 @@ -294,7 +294,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
80267
80268 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
80269 if (!IS_ERR(p)) {
80270 - p = mangle_path(s->buffer + s->len, p, "\n");
80271 + p = mangle_path(s->buffer + s->len, p, "\n\\");
80272 if (p) {
80273 s->len = p - s->buffer;
80274 return 1;
80275 @@ -893,14 +893,16 @@ int register_ftrace_event(struct trace_event *event)
80276 goto out;
80277 }
80278
80279 + pax_open_kernel();
80280 if (event->funcs->trace == NULL)
80281 - event->funcs->trace = trace_nop_print;
80282 + *(void **)&event->funcs->trace = trace_nop_print;
80283 if (event->funcs->raw == NULL)
80284 - event->funcs->raw = trace_nop_print;
80285 + *(void **)&event->funcs->raw = trace_nop_print;
80286 if (event->funcs->hex == NULL)
80287 - event->funcs->hex = trace_nop_print;
80288 + *(void **)&event->funcs->hex = trace_nop_print;
80289 if (event->funcs->binary == NULL)
80290 - event->funcs->binary = trace_nop_print;
80291 + *(void **)&event->funcs->binary = trace_nop_print;
80292 + pax_close_kernel();
80293
80294 key = event->type & (EVENT_HASHSIZE - 1);
80295
80296 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
80297 index b20428c..4845a10 100644
80298 --- a/kernel/trace/trace_stack.c
80299 +++ b/kernel/trace/trace_stack.c
80300 @@ -68,7 +68,7 @@ check_stack(unsigned long ip, unsigned long *stack)
80301 return;
80302
80303 /* we do not handle interrupt stacks yet */
80304 - if (!object_is_on_stack(stack))
80305 + if (!object_starts_on_stack(stack))
80306 return;
80307
80308 local_irq_save(flags);
80309 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
80310 index d8c30db..e065e89 100644
80311 --- a/kernel/user_namespace.c
80312 +++ b/kernel/user_namespace.c
80313 @@ -853,7 +853,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
80314 if (atomic_read(&current->mm->mm_users) > 1)
80315 return -EINVAL;
80316
80317 - if (current->fs->users != 1)
80318 + if (atomic_read(&current->fs->users) != 1)
80319 return -EINVAL;
80320
80321 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
80322 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
80323 index 4f69f9a..7c6f8f8 100644
80324 --- a/kernel/utsname_sysctl.c
80325 +++ b/kernel/utsname_sysctl.c
80326 @@ -47,7 +47,7 @@ static void put_uts(ctl_table *table, int write, void *which)
80327 static int proc_do_uts_string(ctl_table *table, int write,
80328 void __user *buffer, size_t *lenp, loff_t *ppos)
80329 {
80330 - struct ctl_table uts_table;
80331 + ctl_table_no_const uts_table;
80332 int r;
80333 memcpy(&uts_table, table, sizeof(uts_table));
80334 uts_table.data = get_uts(table, write);
80335 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
80336 index 05039e3..17490c7 100644
80337 --- a/kernel/watchdog.c
80338 +++ b/kernel/watchdog.c
80339 @@ -531,7 +531,7 @@ int proc_dowatchdog(struct ctl_table *table, int write,
80340 }
80341 #endif /* CONFIG_SYSCTL */
80342
80343 -static struct smp_hotplug_thread watchdog_threads = {
80344 +static struct smp_hotplug_thread watchdog_threads __read_only = {
80345 .store = &softlockup_watchdog,
80346 .thread_should_run = watchdog_should_run,
80347 .thread_fn = watchdog,
80348 diff --git a/kernel/workqueue.c b/kernel/workqueue.c
80349 index ee8e29a..410568e 100644
80350 --- a/kernel/workqueue.c
80351 +++ b/kernel/workqueue.c
80352 @@ -4584,7 +4584,7 @@ static void rebind_workers(struct worker_pool *pool)
80353 WARN_ON_ONCE(!(worker_flags & WORKER_UNBOUND));
80354 worker_flags |= WORKER_REBOUND;
80355 worker_flags &= ~WORKER_UNBOUND;
80356 - ACCESS_ONCE(worker->flags) = worker_flags;
80357 + ACCESS_ONCE_RW(worker->flags) = worker_flags;
80358 }
80359
80360 spin_unlock_irq(&pool->lock);
80361 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
80362 index 566cf2b..fdaa52c 100644
80363 --- a/lib/Kconfig.debug
80364 +++ b/lib/Kconfig.debug
80365 @@ -549,7 +549,7 @@ config DEBUG_MUTEXES
80366
80367 config DEBUG_LOCK_ALLOC
80368 bool "Lock debugging: detect incorrect freeing of live locks"
80369 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
80370 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
80371 select DEBUG_SPINLOCK
80372 select DEBUG_MUTEXES
80373 select LOCKDEP
80374 @@ -563,7 +563,7 @@ config DEBUG_LOCK_ALLOC
80375
80376 config PROVE_LOCKING
80377 bool "Lock debugging: prove locking correctness"
80378 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
80379 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
80380 select LOCKDEP
80381 select DEBUG_SPINLOCK
80382 select DEBUG_MUTEXES
80383 @@ -614,7 +614,7 @@ config LOCKDEP
80384
80385 config LOCK_STAT
80386 bool "Lock usage statistics"
80387 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
80388 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
80389 select LOCKDEP
80390 select DEBUG_SPINLOCK
80391 select DEBUG_MUTEXES
80392 @@ -1282,6 +1282,7 @@ config LATENCYTOP
80393 depends on DEBUG_KERNEL
80394 depends on STACKTRACE_SUPPORT
80395 depends on PROC_FS
80396 + depends on !GRKERNSEC_HIDESYM
80397 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
80398 select KALLSYMS
80399 select KALLSYMS_ALL
80400 @@ -1298,7 +1299,7 @@ config ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
80401 config DEBUG_STRICT_USER_COPY_CHECKS
80402 bool "Strict user copy size checks"
80403 depends on ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
80404 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
80405 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
80406 help
80407 Enabling this option turns a certain set of sanity checks for user
80408 copy operations into compile time failures.
80409 @@ -1328,7 +1329,7 @@ config INTERVAL_TREE_TEST
80410
80411 config PROVIDE_OHCI1394_DMA_INIT
80412 bool "Remote debugging over FireWire early on boot"
80413 - depends on PCI && X86
80414 + depends on PCI && X86 && !GRKERNSEC
80415 help
80416 If you want to debug problems which hang or crash the kernel early
80417 on boot and the crashing machine has a FireWire port, you can use
80418 @@ -1357,7 +1358,7 @@ config PROVIDE_OHCI1394_DMA_INIT
80419
80420 config FIREWIRE_OHCI_REMOTE_DMA
80421 bool "Remote debugging over FireWire with firewire-ohci"
80422 - depends on FIREWIRE_OHCI
80423 + depends on FIREWIRE_OHCI && !GRKERNSEC
80424 help
80425 This option lets you use the FireWire bus for remote debugging
80426 with help of the firewire-ohci driver. It enables unfiltered
80427 diff --git a/lib/Makefile b/lib/Makefile
80428 index c55a037..fb46e3b 100644
80429 --- a/lib/Makefile
80430 +++ b/lib/Makefile
80431 @@ -50,7 +50,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
80432
80433 obj-$(CONFIG_BTREE) += btree.o
80434 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
80435 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
80436 +obj-y += list_debug.o
80437 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
80438
80439 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
80440 diff --git a/lib/bitmap.c b/lib/bitmap.c
80441 index 06f7e4f..f3cf2b0 100644
80442 --- a/lib/bitmap.c
80443 +++ b/lib/bitmap.c
80444 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
80445 {
80446 int c, old_c, totaldigits, ndigits, nchunks, nbits;
80447 u32 chunk;
80448 - const char __user __force *ubuf = (const char __user __force *)buf;
80449 + const char __user *ubuf = (const char __force_user *)buf;
80450
80451 bitmap_zero(maskp, nmaskbits);
80452
80453 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
80454 {
80455 if (!access_ok(VERIFY_READ, ubuf, ulen))
80456 return -EFAULT;
80457 - return __bitmap_parse((const char __force *)ubuf,
80458 + return __bitmap_parse((const char __force_kernel *)ubuf,
80459 ulen, 1, maskp, nmaskbits);
80460
80461 }
80462 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
80463 {
80464 unsigned a, b;
80465 int c, old_c, totaldigits;
80466 - const char __user __force *ubuf = (const char __user __force *)buf;
80467 + const char __user *ubuf = (const char __force_user *)buf;
80468 int exp_digit, in_range;
80469
80470 totaldigits = c = 0;
80471 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
80472 {
80473 if (!access_ok(VERIFY_READ, ubuf, ulen))
80474 return -EFAULT;
80475 - return __bitmap_parselist((const char __force *)ubuf,
80476 + return __bitmap_parselist((const char __force_kernel *)ubuf,
80477 ulen, 1, maskp, nmaskbits);
80478 }
80479 EXPORT_SYMBOL(bitmap_parselist_user);
80480 diff --git a/lib/bug.c b/lib/bug.c
80481 index 1686034..a9c00c8 100644
80482 --- a/lib/bug.c
80483 +++ b/lib/bug.c
80484 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
80485 return BUG_TRAP_TYPE_NONE;
80486
80487 bug = find_bug(bugaddr);
80488 + if (!bug)
80489 + return BUG_TRAP_TYPE_NONE;
80490
80491 file = NULL;
80492 line = 0;
80493 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
80494 index 37061ed..da83f48 100644
80495 --- a/lib/debugobjects.c
80496 +++ b/lib/debugobjects.c
80497 @@ -286,7 +286,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
80498 if (limit > 4)
80499 return;
80500
80501 - is_on_stack = object_is_on_stack(addr);
80502 + is_on_stack = object_starts_on_stack(addr);
80503 if (is_on_stack == onstack)
80504 return;
80505
80506 diff --git a/lib/devres.c b/lib/devres.c
80507 index 8235331..5881053 100644
80508 --- a/lib/devres.c
80509 +++ b/lib/devres.c
80510 @@ -81,7 +81,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
80511 void devm_iounmap(struct device *dev, void __iomem *addr)
80512 {
80513 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
80514 - (void *)addr));
80515 + (void __force *)addr));
80516 iounmap(addr);
80517 }
80518 EXPORT_SYMBOL(devm_iounmap);
80519 @@ -224,7 +224,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
80520 {
80521 ioport_unmap(addr);
80522 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
80523 - devm_ioport_map_match, (void *)addr));
80524 + devm_ioport_map_match, (void __force *)addr));
80525 }
80526 EXPORT_SYMBOL(devm_ioport_unmap);
80527 #endif /* CONFIG_HAS_IOPORT */
80528 diff --git a/lib/div64.c b/lib/div64.c
80529 index a163b6c..9618fa5 100644
80530 --- a/lib/div64.c
80531 +++ b/lib/div64.c
80532 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
80533 EXPORT_SYMBOL(__div64_32);
80534
80535 #ifndef div_s64_rem
80536 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
80537 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
80538 {
80539 u64 quotient;
80540
80541 @@ -90,7 +90,7 @@ EXPORT_SYMBOL(div_s64_rem);
80542 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
80543 */
80544 #ifndef div64_u64
80545 -u64 div64_u64(u64 dividend, u64 divisor)
80546 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
80547 {
80548 u32 high = divisor >> 32;
80549 u64 quot;
80550 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
80551 index d87a17a..ac0d79a 100644
80552 --- a/lib/dma-debug.c
80553 +++ b/lib/dma-debug.c
80554 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
80555
80556 void dma_debug_add_bus(struct bus_type *bus)
80557 {
80558 - struct notifier_block *nb;
80559 + notifier_block_no_const *nb;
80560
80561 if (global_disable)
80562 return;
80563 @@ -945,7 +945,7 @@ static void check_unmap(struct dma_debug_entry *ref)
80564
80565 static void check_for_stack(struct device *dev, void *addr)
80566 {
80567 - if (object_is_on_stack(addr))
80568 + if (object_starts_on_stack(addr))
80569 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
80570 "stack [addr=%p]\n", addr);
80571 }
80572 diff --git a/lib/inflate.c b/lib/inflate.c
80573 index 013a761..c28f3fc 100644
80574 --- a/lib/inflate.c
80575 +++ b/lib/inflate.c
80576 @@ -269,7 +269,7 @@ static void free(void *where)
80577 malloc_ptr = free_mem_ptr;
80578 }
80579 #else
80580 -#define malloc(a) kmalloc(a, GFP_KERNEL)
80581 +#define malloc(a) kmalloc((a), GFP_KERNEL)
80582 #define free(a) kfree(a)
80583 #endif
80584
80585 diff --git a/lib/ioremap.c b/lib/ioremap.c
80586 index 0c9216c..863bd89 100644
80587 --- a/lib/ioremap.c
80588 +++ b/lib/ioremap.c
80589 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
80590 unsigned long next;
80591
80592 phys_addr -= addr;
80593 - pmd = pmd_alloc(&init_mm, pud, addr);
80594 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
80595 if (!pmd)
80596 return -ENOMEM;
80597 do {
80598 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
80599 unsigned long next;
80600
80601 phys_addr -= addr;
80602 - pud = pud_alloc(&init_mm, pgd, addr);
80603 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
80604 if (!pud)
80605 return -ENOMEM;
80606 do {
80607 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
80608 index bd2bea9..6b3c95e 100644
80609 --- a/lib/is_single_threaded.c
80610 +++ b/lib/is_single_threaded.c
80611 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
80612 struct task_struct *p, *t;
80613 bool ret;
80614
80615 + if (!mm)
80616 + return true;
80617 +
80618 if (atomic_read(&task->signal->live) != 1)
80619 return false;
80620
80621 diff --git a/lib/kobject.c b/lib/kobject.c
80622 index b7e29a6..2f3ca75 100644
80623 --- a/lib/kobject.c
80624 +++ b/lib/kobject.c
80625 @@ -805,7 +805,7 @@ static struct kset *kset_create(const char *name,
80626 kset = kzalloc(sizeof(*kset), GFP_KERNEL);
80627 if (!kset)
80628 return NULL;
80629 - retval = kobject_set_name(&kset->kobj, name);
80630 + retval = kobject_set_name(&kset->kobj, "%s", name);
80631 if (retval) {
80632 kfree(kset);
80633 return NULL;
80634 @@ -859,9 +859,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
80635
80636
80637 static DEFINE_SPINLOCK(kobj_ns_type_lock);
80638 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
80639 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
80640
80641 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
80642 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
80643 {
80644 enum kobj_ns_type type = ops->type;
80645 int error;
80646 diff --git a/lib/list_debug.c b/lib/list_debug.c
80647 index c24c2f7..06e070b 100644
80648 --- a/lib/list_debug.c
80649 +++ b/lib/list_debug.c
80650 @@ -11,7 +11,9 @@
80651 #include <linux/bug.h>
80652 #include <linux/kernel.h>
80653 #include <linux/rculist.h>
80654 +#include <linux/mm.h>
80655
80656 +#ifdef CONFIG_DEBUG_LIST
80657 /*
80658 * Insert a new entry between two known consecutive entries.
80659 *
80660 @@ -19,21 +21,32 @@
80661 * the prev/next entries already!
80662 */
80663
80664 -void __list_add(struct list_head *new,
80665 - struct list_head *prev,
80666 - struct list_head *next)
80667 +static bool __list_add_debug(struct list_head *new,
80668 + struct list_head *prev,
80669 + struct list_head *next)
80670 {
80671 - WARN(next->prev != prev,
80672 + if (WARN(next->prev != prev,
80673 "list_add corruption. next->prev should be "
80674 "prev (%p), but was %p. (next=%p).\n",
80675 - prev, next->prev, next);
80676 - WARN(prev->next != next,
80677 + prev, next->prev, next) ||
80678 + WARN(prev->next != next,
80679 "list_add corruption. prev->next should be "
80680 "next (%p), but was %p. (prev=%p).\n",
80681 - next, prev->next, prev);
80682 - WARN(new == prev || new == next,
80683 - "list_add double add: new=%p, prev=%p, next=%p.\n",
80684 - new, prev, next);
80685 + next, prev->next, prev) ||
80686 + WARN(new == prev || new == next,
80687 + "list_add double add: new=%p, prev=%p, next=%p.\n",
80688 + new, prev, next))
80689 + return false;
80690 + return true;
80691 +}
80692 +
80693 +void __list_add(struct list_head *new,
80694 + struct list_head *prev,
80695 + struct list_head *next)
80696 +{
80697 + if (!__list_add_debug(new, prev, next))
80698 + return;
80699 +
80700 next->prev = new;
80701 new->next = next;
80702 new->prev = prev;
80703 @@ -41,7 +54,7 @@ void __list_add(struct list_head *new,
80704 }
80705 EXPORT_SYMBOL(__list_add);
80706
80707 -void __list_del_entry(struct list_head *entry)
80708 +static bool __list_del_entry_debug(struct list_head *entry)
80709 {
80710 struct list_head *prev, *next;
80711
80712 @@ -60,9 +73,16 @@ void __list_del_entry(struct list_head *entry)
80713 WARN(next->prev != entry,
80714 "list_del corruption. next->prev should be %p, "
80715 "but was %p\n", entry, next->prev))
80716 + return false;
80717 + return true;
80718 +}
80719 +
80720 +void __list_del_entry(struct list_head *entry)
80721 +{
80722 + if (!__list_del_entry_debug(entry))
80723 return;
80724
80725 - __list_del(prev, next);
80726 + __list_del(entry->prev, entry->next);
80727 }
80728 EXPORT_SYMBOL(__list_del_entry);
80729
80730 @@ -86,15 +106,85 @@ EXPORT_SYMBOL(list_del);
80731 void __list_add_rcu(struct list_head *new,
80732 struct list_head *prev, struct list_head *next)
80733 {
80734 - WARN(next->prev != prev,
80735 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
80736 - prev, next->prev, next);
80737 - WARN(prev->next != next,
80738 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
80739 - next, prev->next, prev);
80740 + if (!__list_add_debug(new, prev, next))
80741 + return;
80742 +
80743 new->next = next;
80744 new->prev = prev;
80745 rcu_assign_pointer(list_next_rcu(prev), new);
80746 next->prev = new;
80747 }
80748 EXPORT_SYMBOL(__list_add_rcu);
80749 +#endif
80750 +
80751 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
80752 +{
80753 +#ifdef CONFIG_DEBUG_LIST
80754 + if (!__list_add_debug(new, prev, next))
80755 + return;
80756 +#endif
80757 +
80758 + pax_open_kernel();
80759 + next->prev = new;
80760 + new->next = next;
80761 + new->prev = prev;
80762 + prev->next = new;
80763 + pax_close_kernel();
80764 +}
80765 +EXPORT_SYMBOL(__pax_list_add);
80766 +
80767 +void pax_list_del(struct list_head *entry)
80768 +{
80769 +#ifdef CONFIG_DEBUG_LIST
80770 + if (!__list_del_entry_debug(entry))
80771 + return;
80772 +#endif
80773 +
80774 + pax_open_kernel();
80775 + __list_del(entry->prev, entry->next);
80776 + entry->next = LIST_POISON1;
80777 + entry->prev = LIST_POISON2;
80778 + pax_close_kernel();
80779 +}
80780 +EXPORT_SYMBOL(pax_list_del);
80781 +
80782 +void pax_list_del_init(struct list_head *entry)
80783 +{
80784 + pax_open_kernel();
80785 + __list_del(entry->prev, entry->next);
80786 + INIT_LIST_HEAD(entry);
80787 + pax_close_kernel();
80788 +}
80789 +EXPORT_SYMBOL(pax_list_del_init);
80790 +
80791 +void __pax_list_add_rcu(struct list_head *new,
80792 + struct list_head *prev, struct list_head *next)
80793 +{
80794 +#ifdef CONFIG_DEBUG_LIST
80795 + if (!__list_add_debug(new, prev, next))
80796 + return;
80797 +#endif
80798 +
80799 + pax_open_kernel();
80800 + new->next = next;
80801 + new->prev = prev;
80802 + rcu_assign_pointer(list_next_rcu(prev), new);
80803 + next->prev = new;
80804 + pax_close_kernel();
80805 +}
80806 +EXPORT_SYMBOL(__pax_list_add_rcu);
80807 +
80808 +void pax_list_del_rcu(struct list_head *entry)
80809 +{
80810 +#ifdef CONFIG_DEBUG_LIST
80811 + if (!__list_del_entry_debug(entry))
80812 + return;
80813 +#endif
80814 +
80815 + pax_open_kernel();
80816 + __list_del(entry->prev, entry->next);
80817 + entry->next = LIST_POISON1;
80818 + entry->prev = LIST_POISON2;
80819 + pax_close_kernel();
80820 +}
80821 +EXPORT_SYMBOL(pax_list_del_rcu);
80822 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
80823 index e796429..6e38f9f 100644
80824 --- a/lib/radix-tree.c
80825 +++ b/lib/radix-tree.c
80826 @@ -92,7 +92,7 @@ struct radix_tree_preload {
80827 int nr;
80828 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
80829 };
80830 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
80831 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
80832
80833 static inline void *ptr_to_indirect(void *ptr)
80834 {
80835 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
80836 index bb2b201..46abaf9 100644
80837 --- a/lib/strncpy_from_user.c
80838 +++ b/lib/strncpy_from_user.c
80839 @@ -21,7 +21,7 @@
80840 */
80841 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
80842 {
80843 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80844 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80845 long res = 0;
80846
80847 /*
80848 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
80849 index a28df52..3d55877 100644
80850 --- a/lib/strnlen_user.c
80851 +++ b/lib/strnlen_user.c
80852 @@ -26,7 +26,7 @@
80853 */
80854 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
80855 {
80856 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80857 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
80858 long align, res = 0;
80859 unsigned long c;
80860
80861 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
80862 index d23762e..e21eab2 100644
80863 --- a/lib/swiotlb.c
80864 +++ b/lib/swiotlb.c
80865 @@ -664,7 +664,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
80866
80867 void
80868 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
80869 - dma_addr_t dev_addr)
80870 + dma_addr_t dev_addr, struct dma_attrs *attrs)
80871 {
80872 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
80873
80874 diff --git a/lib/usercopy.c b/lib/usercopy.c
80875 index 4f5b1dd..7cab418 100644
80876 --- a/lib/usercopy.c
80877 +++ b/lib/usercopy.c
80878 @@ -7,3 +7,9 @@ void copy_from_user_overflow(void)
80879 WARN(1, "Buffer overflow detected!\n");
80880 }
80881 EXPORT_SYMBOL(copy_from_user_overflow);
80882 +
80883 +void copy_to_user_overflow(void)
80884 +{
80885 + WARN(1, "Buffer overflow detected!\n");
80886 +}
80887 +EXPORT_SYMBOL(copy_to_user_overflow);
80888 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
80889 index e149c64..24aa71a 100644
80890 --- a/lib/vsprintf.c
80891 +++ b/lib/vsprintf.c
80892 @@ -16,6 +16,9 @@
80893 * - scnprintf and vscnprintf
80894 */
80895
80896 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80897 +#define __INCLUDED_BY_HIDESYM 1
80898 +#endif
80899 #include <stdarg.h>
80900 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
80901 #include <linux/types.h>
80902 @@ -981,7 +984,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
80903 return number(buf, end, *(const netdev_features_t *)addr, spec);
80904 }
80905
80906 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80907 +int kptr_restrict __read_mostly = 2;
80908 +#else
80909 int kptr_restrict __read_mostly;
80910 +#endif
80911
80912 /*
80913 * Show a '%p' thing. A kernel extension is that the '%p' is followed
80914 @@ -994,6 +1001,7 @@ int kptr_restrict __read_mostly;
80915 * - 'f' For simple symbolic function names without offset
80916 * - 'S' For symbolic direct pointers with offset
80917 * - 's' For symbolic direct pointers without offset
80918 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
80919 * - '[FfSs]R' as above with __builtin_extract_return_addr() translation
80920 * - 'B' For backtraced symbolic direct pointers with offset
80921 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
80922 @@ -1052,12 +1060,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80923
80924 if (!ptr && *fmt != 'K') {
80925 /*
80926 - * Print (null) with the same width as a pointer so it makes
80927 + * Print (nil) with the same width as a pointer so it makes
80928 * tabular output look nice.
80929 */
80930 if (spec.field_width == -1)
80931 spec.field_width = default_width;
80932 - return string(buf, end, "(null)", spec);
80933 + return string(buf, end, "(nil)", spec);
80934 }
80935
80936 switch (*fmt) {
80937 @@ -1067,6 +1075,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80938 /* Fallthrough */
80939 case 'S':
80940 case 's':
80941 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80942 + break;
80943 +#else
80944 + return symbol_string(buf, end, ptr, spec, fmt);
80945 +#endif
80946 + case 'A':
80947 case 'B':
80948 return symbol_string(buf, end, ptr, spec, fmt);
80949 case 'R':
80950 @@ -1107,6 +1121,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80951 va_end(va);
80952 return buf;
80953 }
80954 + case 'P':
80955 + break;
80956 case 'K':
80957 /*
80958 * %pK cannot be used in IRQ context because its test
80959 @@ -1136,6 +1152,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
80960 return number(buf, end,
80961 (unsigned long long) *((phys_addr_t *)ptr), spec);
80962 }
80963 +
80964 +#ifdef CONFIG_GRKERNSEC_HIDESYM
80965 + /* 'P' = approved pointers to copy to userland,
80966 + as in the /proc/kallsyms case, as we make it display nothing
80967 + for non-root users, and the real contents for root users
80968 + Also ignore 'K' pointers, since we force their NULLing for non-root users
80969 + above
80970 + */
80971 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
80972 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
80973 + dump_stack();
80974 + ptr = NULL;
80975 + }
80976 +#endif
80977 +
80978 spec.flags |= SMALL;
80979 if (spec.field_width == -1) {
80980 spec.field_width = default_width;
80981 @@ -1857,11 +1888,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
80982 typeof(type) value; \
80983 if (sizeof(type) == 8) { \
80984 args = PTR_ALIGN(args, sizeof(u32)); \
80985 - *(u32 *)&value = *(u32 *)args; \
80986 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
80987 + *(u32 *)&value = *(const u32 *)args; \
80988 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
80989 } else { \
80990 args = PTR_ALIGN(args, sizeof(type)); \
80991 - value = *(typeof(type) *)args; \
80992 + value = *(const typeof(type) *)args; \
80993 } \
80994 args += sizeof(type); \
80995 value; \
80996 @@ -1924,7 +1955,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
80997 case FORMAT_TYPE_STR: {
80998 const char *str_arg = args;
80999 args += strlen(str_arg) + 1;
81000 - str = string(str, end, (char *)str_arg, spec);
81001 + str = string(str, end, str_arg, spec);
81002 break;
81003 }
81004
81005 diff --git a/localversion-grsec b/localversion-grsec
81006 new file mode 100644
81007 index 0000000..7cd6065
81008 --- /dev/null
81009 +++ b/localversion-grsec
81010 @@ -0,0 +1 @@
81011 +-grsec
81012 diff --git a/mm/Kconfig b/mm/Kconfig
81013 index e742d06..c56fdd8 100644
81014 --- a/mm/Kconfig
81015 +++ b/mm/Kconfig
81016 @@ -317,10 +317,10 @@ config KSM
81017 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
81018
81019 config DEFAULT_MMAP_MIN_ADDR
81020 - int "Low address space to protect from user allocation"
81021 + int "Low address space to protect from user allocation"
81022 depends on MMU
81023 - default 4096
81024 - help
81025 + default 65536
81026 + help
81027 This is the portion of low virtual memory which should be protected
81028 from userspace allocation. Keeping a user from writing to low pages
81029 can help reduce the impact of kernel NULL pointer bugs.
81030 @@ -351,7 +351,7 @@ config MEMORY_FAILURE
81031
81032 config HWPOISON_INJECT
81033 tristate "HWPoison pages injector"
81034 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
81035 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
81036 select PROC_PAGE_MONITOR
81037
81038 config NOMMU_INITIAL_TRIM_EXCESS
81039 diff --git a/mm/backing-dev.c b/mm/backing-dev.c
81040 index 5025174..9fc1c5c 100644
81041 --- a/mm/backing-dev.c
81042 +++ b/mm/backing-dev.c
81043 @@ -515,7 +515,6 @@ EXPORT_SYMBOL(bdi_destroy);
81044 int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
81045 unsigned int cap)
81046 {
81047 - char tmp[32];
81048 int err;
81049
81050 bdi->name = name;
81051 @@ -524,8 +523,7 @@ int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
81052 if (err)
81053 return err;
81054
81055 - sprintf(tmp, "%.28s%s", name, "-%d");
81056 - err = bdi_register(bdi, NULL, tmp, atomic_long_inc_return(&bdi_seq));
81057 + err = bdi_register(bdi, NULL, "%.28s-%ld", name, atomic_long_inc_return(&bdi_seq));
81058 if (err) {
81059 bdi_destroy(bdi);
81060 return err;
81061 diff --git a/mm/filemap.c b/mm/filemap.c
81062 index 7905fe7..e60faa8 100644
81063 --- a/mm/filemap.c
81064 +++ b/mm/filemap.c
81065 @@ -1766,7 +1766,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
81066 struct address_space *mapping = file->f_mapping;
81067
81068 if (!mapping->a_ops->readpage)
81069 - return -ENOEXEC;
81070 + return -ENODEV;
81071 file_accessed(file);
81072 vma->vm_ops = &generic_file_vm_ops;
81073 return 0;
81074 @@ -2106,6 +2106,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
81075 *pos = i_size_read(inode);
81076
81077 if (limit != RLIM_INFINITY) {
81078 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
81079 if (*pos >= limit) {
81080 send_sig(SIGXFSZ, current, 0);
81081 return -EFBIG;
81082 diff --git a/mm/fremap.c b/mm/fremap.c
81083 index 87da359..3f41cb1 100644
81084 --- a/mm/fremap.c
81085 +++ b/mm/fremap.c
81086 @@ -158,6 +158,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
81087 retry:
81088 vma = find_vma(mm, start);
81089
81090 +#ifdef CONFIG_PAX_SEGMEXEC
81091 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
81092 + goto out;
81093 +#endif
81094 +
81095 /*
81096 * Make sure the vma is shared, that it supports prefaulting,
81097 * and that the remapped range is valid and fully within
81098 diff --git a/mm/highmem.c b/mm/highmem.c
81099 index b32b70c..e512eb0 100644
81100 --- a/mm/highmem.c
81101 +++ b/mm/highmem.c
81102 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
81103 * So no dangers, even with speculative execution.
81104 */
81105 page = pte_page(pkmap_page_table[i]);
81106 + pax_open_kernel();
81107 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
81108 -
81109 + pax_close_kernel();
81110 set_page_address(page, NULL);
81111 need_flush = 1;
81112 }
81113 @@ -198,9 +199,11 @@ start:
81114 }
81115 }
81116 vaddr = PKMAP_ADDR(last_pkmap_nr);
81117 +
81118 + pax_open_kernel();
81119 set_pte_at(&init_mm, vaddr,
81120 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
81121 -
81122 + pax_close_kernel();
81123 pkmap_count[last_pkmap_nr] = 1;
81124 set_page_address(page, (void *)vaddr);
81125
81126 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
81127 index e2bfbf7..aa59ead 100644
81128 --- a/mm/hugetlb.c
81129 +++ b/mm/hugetlb.c
81130 @@ -2005,15 +2005,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
81131 struct hstate *h = &default_hstate;
81132 unsigned long tmp;
81133 int ret;
81134 + ctl_table_no_const hugetlb_table;
81135
81136 tmp = h->max_huge_pages;
81137
81138 if (write && h->order >= MAX_ORDER)
81139 return -EINVAL;
81140
81141 - table->data = &tmp;
81142 - table->maxlen = sizeof(unsigned long);
81143 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
81144 + hugetlb_table = *table;
81145 + hugetlb_table.data = &tmp;
81146 + hugetlb_table.maxlen = sizeof(unsigned long);
81147 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
81148 if (ret)
81149 goto out;
81150
81151 @@ -2070,15 +2072,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
81152 struct hstate *h = &default_hstate;
81153 unsigned long tmp;
81154 int ret;
81155 + ctl_table_no_const hugetlb_table;
81156
81157 tmp = h->nr_overcommit_huge_pages;
81158
81159 if (write && h->order >= MAX_ORDER)
81160 return -EINVAL;
81161
81162 - table->data = &tmp;
81163 - table->maxlen = sizeof(unsigned long);
81164 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
81165 + hugetlb_table = *table;
81166 + hugetlb_table.data = &tmp;
81167 + hugetlb_table.maxlen = sizeof(unsigned long);
81168 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
81169 if (ret)
81170 goto out;
81171
81172 @@ -2528,6 +2532,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
81173 return 1;
81174 }
81175
81176 +#ifdef CONFIG_PAX_SEGMEXEC
81177 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
81178 +{
81179 + struct mm_struct *mm = vma->vm_mm;
81180 + struct vm_area_struct *vma_m;
81181 + unsigned long address_m;
81182 + pte_t *ptep_m;
81183 +
81184 + vma_m = pax_find_mirror_vma(vma);
81185 + if (!vma_m)
81186 + return;
81187 +
81188 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81189 + address_m = address + SEGMEXEC_TASK_SIZE;
81190 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
81191 + get_page(page_m);
81192 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
81193 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
81194 +}
81195 +#endif
81196 +
81197 /*
81198 * Hugetlb_cow() should be called with page lock of the original hugepage held.
81199 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
81200 @@ -2646,6 +2671,11 @@ retry_avoidcopy:
81201 make_huge_pte(vma, new_page, 1));
81202 page_remove_rmap(old_page);
81203 hugepage_add_new_anon_rmap(new_page, vma, address);
81204 +
81205 +#ifdef CONFIG_PAX_SEGMEXEC
81206 + pax_mirror_huge_pte(vma, address, new_page);
81207 +#endif
81208 +
81209 /* Make the old page be freed below */
81210 new_page = old_page;
81211 }
81212 @@ -2804,6 +2834,10 @@ retry:
81213 && (vma->vm_flags & VM_SHARED)));
81214 set_huge_pte_at(mm, address, ptep, new_pte);
81215
81216 +#ifdef CONFIG_PAX_SEGMEXEC
81217 + pax_mirror_huge_pte(vma, address, page);
81218 +#endif
81219 +
81220 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
81221 /* Optimization, do the COW without a second fault */
81222 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
81223 @@ -2833,6 +2867,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81224 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
81225 struct hstate *h = hstate_vma(vma);
81226
81227 +#ifdef CONFIG_PAX_SEGMEXEC
81228 + struct vm_area_struct *vma_m;
81229 +#endif
81230 +
81231 address &= huge_page_mask(h);
81232
81233 ptep = huge_pte_offset(mm, address);
81234 @@ -2846,6 +2884,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
81235 VM_FAULT_SET_HINDEX(hstate_index(h));
81236 }
81237
81238 +#ifdef CONFIG_PAX_SEGMEXEC
81239 + vma_m = pax_find_mirror_vma(vma);
81240 + if (vma_m) {
81241 + unsigned long address_m;
81242 +
81243 + if (vma->vm_start > vma_m->vm_start) {
81244 + address_m = address;
81245 + address -= SEGMEXEC_TASK_SIZE;
81246 + vma = vma_m;
81247 + h = hstate_vma(vma);
81248 + } else
81249 + address_m = address + SEGMEXEC_TASK_SIZE;
81250 +
81251 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
81252 + return VM_FAULT_OOM;
81253 + address_m &= HPAGE_MASK;
81254 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
81255 + }
81256 +#endif
81257 +
81258 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
81259 if (!ptep)
81260 return VM_FAULT_OOM;
81261 diff --git a/mm/internal.h b/mm/internal.h
81262 index 8562de0..7fdfe92 100644
81263 --- a/mm/internal.h
81264 +++ b/mm/internal.h
81265 @@ -100,6 +100,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
81266 * in mm/page_alloc.c
81267 */
81268 extern void __free_pages_bootmem(struct page *page, unsigned int order);
81269 +extern void free_compound_page(struct page *page);
81270 extern void prep_compound_page(struct page *page, unsigned long order);
81271 #ifdef CONFIG_MEMORY_FAILURE
81272 extern bool is_free_buddy_page(struct page *page);
81273 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
81274 index c8d7f31..2dbeffd 100644
81275 --- a/mm/kmemleak.c
81276 +++ b/mm/kmemleak.c
81277 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
81278
81279 for (i = 0; i < object->trace_len; i++) {
81280 void *ptr = (void *)object->trace[i];
81281 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
81282 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
81283 }
81284 }
81285
81286 @@ -1851,7 +1851,7 @@ static int __init kmemleak_late_init(void)
81287 return -ENOMEM;
81288 }
81289
81290 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
81291 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
81292 &kmemleak_fops);
81293 if (!dentry)
81294 pr_warning("Failed to create the debugfs kmemleak file\n");
81295 diff --git a/mm/maccess.c b/mm/maccess.c
81296 index d53adf9..03a24bf 100644
81297 --- a/mm/maccess.c
81298 +++ b/mm/maccess.c
81299 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
81300 set_fs(KERNEL_DS);
81301 pagefault_disable();
81302 ret = __copy_from_user_inatomic(dst,
81303 - (__force const void __user *)src, size);
81304 + (const void __force_user *)src, size);
81305 pagefault_enable();
81306 set_fs(old_fs);
81307
81308 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
81309
81310 set_fs(KERNEL_DS);
81311 pagefault_disable();
81312 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
81313 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
81314 pagefault_enable();
81315 set_fs(old_fs);
81316
81317 diff --git a/mm/madvise.c b/mm/madvise.c
81318 index 7055883..4e8c835 100644
81319 --- a/mm/madvise.c
81320 +++ b/mm/madvise.c
81321 @@ -51,6 +51,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
81322 pgoff_t pgoff;
81323 unsigned long new_flags = vma->vm_flags;
81324
81325 +#ifdef CONFIG_PAX_SEGMEXEC
81326 + struct vm_area_struct *vma_m;
81327 +#endif
81328 +
81329 switch (behavior) {
81330 case MADV_NORMAL:
81331 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
81332 @@ -126,6 +130,13 @@ success:
81333 /*
81334 * vm_flags is protected by the mmap_sem held in write mode.
81335 */
81336 +
81337 +#ifdef CONFIG_PAX_SEGMEXEC
81338 + vma_m = pax_find_mirror_vma(vma);
81339 + if (vma_m)
81340 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
81341 +#endif
81342 +
81343 vma->vm_flags = new_flags;
81344
81345 out:
81346 @@ -274,6 +285,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
81347 struct vm_area_struct ** prev,
81348 unsigned long start, unsigned long end)
81349 {
81350 +
81351 +#ifdef CONFIG_PAX_SEGMEXEC
81352 + struct vm_area_struct *vma_m;
81353 +#endif
81354 +
81355 *prev = vma;
81356 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
81357 return -EINVAL;
81358 @@ -286,6 +302,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
81359 zap_page_range(vma, start, end - start, &details);
81360 } else
81361 zap_page_range(vma, start, end - start, NULL);
81362 +
81363 +#ifdef CONFIG_PAX_SEGMEXEC
81364 + vma_m = pax_find_mirror_vma(vma);
81365 + if (vma_m) {
81366 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
81367 + struct zap_details details = {
81368 + .nonlinear_vma = vma_m,
81369 + .last_index = ULONG_MAX,
81370 + };
81371 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
81372 + } else
81373 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
81374 + }
81375 +#endif
81376 +
81377 return 0;
81378 }
81379
81380 @@ -485,6 +516,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
81381 if (end < start)
81382 return error;
81383
81384 +#ifdef CONFIG_PAX_SEGMEXEC
81385 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
81386 + if (end > SEGMEXEC_TASK_SIZE)
81387 + goto out;
81388 + } else
81389 +#endif
81390 +
81391 + if (end > TASK_SIZE)
81392 + goto out;
81393 +
81394 error = 0;
81395 if (end == start)
81396 return error;
81397 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
81398 index ceb0c7f..b2b8e94 100644
81399 --- a/mm/memory-failure.c
81400 +++ b/mm/memory-failure.c
81401 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
81402
81403 int sysctl_memory_failure_recovery __read_mostly = 1;
81404
81405 -atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
81406 +atomic_long_unchecked_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
81407
81408 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
81409
81410 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
81411 pfn, t->comm, t->pid);
81412 si.si_signo = SIGBUS;
81413 si.si_errno = 0;
81414 - si.si_addr = (void *)addr;
81415 + si.si_addr = (void __user *)addr;
81416 #ifdef __ARCH_SI_TRAPNO
81417 si.si_trapno = trapno;
81418 #endif
81419 @@ -760,7 +760,7 @@ static struct page_state {
81420 unsigned long res;
81421 char *msg;
81422 int (*action)(struct page *p, unsigned long pfn);
81423 -} error_states[] = {
81424 +} __do_const error_states[] = {
81425 { reserved, reserved, "reserved kernel", me_kernel },
81426 /*
81427 * free pages are specially detected outside this table:
81428 @@ -1051,7 +1051,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
81429 nr_pages = 1 << compound_order(hpage);
81430 else /* normal page or thp */
81431 nr_pages = 1;
81432 - atomic_long_add(nr_pages, &num_poisoned_pages);
81433 + atomic_long_add_unchecked(nr_pages, &num_poisoned_pages);
81434
81435 /*
81436 * We need/can do nothing about count=0 pages.
81437 @@ -1081,7 +1081,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
81438 if (!PageHWPoison(hpage)
81439 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
81440 || (p != hpage && TestSetPageHWPoison(hpage))) {
81441 - atomic_long_sub(nr_pages, &num_poisoned_pages);
81442 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
81443 return 0;
81444 }
81445 set_page_hwpoison_huge_page(hpage);
81446 @@ -1148,7 +1148,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
81447 }
81448 if (hwpoison_filter(p)) {
81449 if (TestClearPageHWPoison(p))
81450 - atomic_long_sub(nr_pages, &num_poisoned_pages);
81451 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
81452 unlock_page(hpage);
81453 put_page(hpage);
81454 return 0;
81455 @@ -1350,7 +1350,7 @@ int unpoison_memory(unsigned long pfn)
81456 return 0;
81457 }
81458 if (TestClearPageHWPoison(p))
81459 - atomic_long_sub(nr_pages, &num_poisoned_pages);
81460 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
81461 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
81462 return 0;
81463 }
81464 @@ -1364,7 +1364,7 @@ int unpoison_memory(unsigned long pfn)
81465 */
81466 if (TestClearPageHWPoison(page)) {
81467 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
81468 - atomic_long_sub(nr_pages, &num_poisoned_pages);
81469 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
81470 freeit = 1;
81471 if (PageHuge(page))
81472 clear_page_hwpoison_huge_page(page);
81473 @@ -1491,7 +1491,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
81474 } else {
81475 set_page_hwpoison_huge_page(hpage);
81476 dequeue_hwpoisoned_huge_page(hpage);
81477 - atomic_long_add(1 << compound_trans_order(hpage),
81478 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
81479 &num_poisoned_pages);
81480 }
81481 /* keep elevated page count for bad page */
81482 @@ -1552,11 +1552,11 @@ int soft_offline_page(struct page *page, int flags)
81483 if (PageHuge(page)) {
81484 set_page_hwpoison_huge_page(hpage);
81485 dequeue_hwpoisoned_huge_page(hpage);
81486 - atomic_long_add(1 << compound_trans_order(hpage),
81487 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
81488 &num_poisoned_pages);
81489 } else {
81490 SetPageHWPoison(page);
81491 - atomic_long_inc(&num_poisoned_pages);
81492 + atomic_long_inc_unchecked(&num_poisoned_pages);
81493 }
81494 }
81495 /* keep elevated page count for bad page */
81496 @@ -1596,7 +1596,7 @@ static int __soft_offline_page(struct page *page, int flags)
81497 put_page(page);
81498 pr_info("soft_offline: %#lx: invalidated\n", pfn);
81499 SetPageHWPoison(page);
81500 - atomic_long_inc(&num_poisoned_pages);
81501 + atomic_long_inc_unchecked(&num_poisoned_pages);
81502 return 0;
81503 }
81504
81505 @@ -1626,7 +1626,7 @@ static int __soft_offline_page(struct page *page, int flags)
81506 ret = -EIO;
81507 } else {
81508 SetPageHWPoison(page);
81509 - atomic_long_inc(&num_poisoned_pages);
81510 + atomic_long_inc_unchecked(&num_poisoned_pages);
81511 }
81512 } else {
81513 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
81514 diff --git a/mm/memory.c b/mm/memory.c
81515 index 61a262b..77a94d1 100644
81516 --- a/mm/memory.c
81517 +++ b/mm/memory.c
81518 @@ -429,6 +429,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
81519 free_pte_range(tlb, pmd, addr);
81520 } while (pmd++, addr = next, addr != end);
81521
81522 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
81523 start &= PUD_MASK;
81524 if (start < floor)
81525 return;
81526 @@ -443,6 +444,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
81527 pmd = pmd_offset(pud, start);
81528 pud_clear(pud);
81529 pmd_free_tlb(tlb, pmd, start);
81530 +#endif
81531 +
81532 }
81533
81534 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81535 @@ -462,6 +465,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81536 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
81537 } while (pud++, addr = next, addr != end);
81538
81539 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
81540 start &= PGDIR_MASK;
81541 if (start < floor)
81542 return;
81543 @@ -476,6 +480,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
81544 pud = pud_offset(pgd, start);
81545 pgd_clear(pgd);
81546 pud_free_tlb(tlb, pud, start);
81547 +#endif
81548 +
81549 }
81550
81551 /*
81552 @@ -1635,12 +1641,6 @@ no_page_table:
81553 return page;
81554 }
81555
81556 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
81557 -{
81558 - return stack_guard_page_start(vma, addr) ||
81559 - stack_guard_page_end(vma, addr+PAGE_SIZE);
81560 -}
81561 -
81562 /**
81563 * __get_user_pages() - pin user pages in memory
81564 * @tsk: task_struct of target task
81565 @@ -1727,10 +1727,10 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81566
81567 i = 0;
81568
81569 - do {
81570 + while (nr_pages) {
81571 struct vm_area_struct *vma;
81572
81573 - vma = find_extend_vma(mm, start);
81574 + vma = find_vma(mm, start);
81575 if (!vma && in_gate_area(mm, start)) {
81576 unsigned long pg = start & PAGE_MASK;
81577 pgd_t *pgd;
81578 @@ -1779,7 +1779,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81579 goto next_page;
81580 }
81581
81582 - if (!vma ||
81583 + if (!vma || start < vma->vm_start ||
81584 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
81585 !(vm_flags & vma->vm_flags))
81586 return i ? : -EFAULT;
81587 @@ -1808,11 +1808,6 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
81588 int ret;
81589 unsigned int fault_flags = 0;
81590
81591 - /* For mlock, just skip the stack guard page. */
81592 - if (foll_flags & FOLL_MLOCK) {
81593 - if (stack_guard_page(vma, start))
81594 - goto next_page;
81595 - }
81596 if (foll_flags & FOLL_WRITE)
81597 fault_flags |= FAULT_FLAG_WRITE;
81598 if (nonblocking)
81599 @@ -1892,7 +1887,7 @@ next_page:
81600 start += page_increm * PAGE_SIZE;
81601 nr_pages -= page_increm;
81602 } while (nr_pages && start < vma->vm_end);
81603 - } while (nr_pages);
81604 + }
81605 return i;
81606 }
81607 EXPORT_SYMBOL(__get_user_pages);
81608 @@ -2099,6 +2094,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
81609 page_add_file_rmap(page);
81610 set_pte_at(mm, addr, pte, mk_pte(page, prot));
81611
81612 +#ifdef CONFIG_PAX_SEGMEXEC
81613 + pax_mirror_file_pte(vma, addr, page, ptl);
81614 +#endif
81615 +
81616 retval = 0;
81617 pte_unmap_unlock(pte, ptl);
81618 return retval;
81619 @@ -2143,9 +2142,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
81620 if (!page_count(page))
81621 return -EINVAL;
81622 if (!(vma->vm_flags & VM_MIXEDMAP)) {
81623 +
81624 +#ifdef CONFIG_PAX_SEGMEXEC
81625 + struct vm_area_struct *vma_m;
81626 +#endif
81627 +
81628 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
81629 BUG_ON(vma->vm_flags & VM_PFNMAP);
81630 vma->vm_flags |= VM_MIXEDMAP;
81631 +
81632 +#ifdef CONFIG_PAX_SEGMEXEC
81633 + vma_m = pax_find_mirror_vma(vma);
81634 + if (vma_m)
81635 + vma_m->vm_flags |= VM_MIXEDMAP;
81636 +#endif
81637 +
81638 }
81639 return insert_page(vma, addr, page, vma->vm_page_prot);
81640 }
81641 @@ -2228,6 +2239,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
81642 unsigned long pfn)
81643 {
81644 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
81645 + BUG_ON(vma->vm_mirror);
81646
81647 if (addr < vma->vm_start || addr >= vma->vm_end)
81648 return -EFAULT;
81649 @@ -2475,7 +2487,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
81650
81651 BUG_ON(pud_huge(*pud));
81652
81653 - pmd = pmd_alloc(mm, pud, addr);
81654 + pmd = (mm == &init_mm) ?
81655 + pmd_alloc_kernel(mm, pud, addr) :
81656 + pmd_alloc(mm, pud, addr);
81657 if (!pmd)
81658 return -ENOMEM;
81659 do {
81660 @@ -2495,7 +2509,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
81661 unsigned long next;
81662 int err;
81663
81664 - pud = pud_alloc(mm, pgd, addr);
81665 + pud = (mm == &init_mm) ?
81666 + pud_alloc_kernel(mm, pgd, addr) :
81667 + pud_alloc(mm, pgd, addr);
81668 if (!pud)
81669 return -ENOMEM;
81670 do {
81671 @@ -2583,6 +2599,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
81672 copy_user_highpage(dst, src, va, vma);
81673 }
81674
81675 +#ifdef CONFIG_PAX_SEGMEXEC
81676 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
81677 +{
81678 + struct mm_struct *mm = vma->vm_mm;
81679 + spinlock_t *ptl;
81680 + pte_t *pte, entry;
81681 +
81682 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
81683 + entry = *pte;
81684 + if (!pte_present(entry)) {
81685 + if (!pte_none(entry)) {
81686 + BUG_ON(pte_file(entry));
81687 + free_swap_and_cache(pte_to_swp_entry(entry));
81688 + pte_clear_not_present_full(mm, address, pte, 0);
81689 + }
81690 + } else {
81691 + struct page *page;
81692 +
81693 + flush_cache_page(vma, address, pte_pfn(entry));
81694 + entry = ptep_clear_flush(vma, address, pte);
81695 + BUG_ON(pte_dirty(entry));
81696 + page = vm_normal_page(vma, address, entry);
81697 + if (page) {
81698 + update_hiwater_rss(mm);
81699 + if (PageAnon(page))
81700 + dec_mm_counter_fast(mm, MM_ANONPAGES);
81701 + else
81702 + dec_mm_counter_fast(mm, MM_FILEPAGES);
81703 + page_remove_rmap(page);
81704 + page_cache_release(page);
81705 + }
81706 + }
81707 + pte_unmap_unlock(pte, ptl);
81708 +}
81709 +
81710 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
81711 + *
81712 + * the ptl of the lower mapped page is held on entry and is not released on exit
81713 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
81714 + */
81715 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
81716 +{
81717 + struct mm_struct *mm = vma->vm_mm;
81718 + unsigned long address_m;
81719 + spinlock_t *ptl_m;
81720 + struct vm_area_struct *vma_m;
81721 + pmd_t *pmd_m;
81722 + pte_t *pte_m, entry_m;
81723 +
81724 + BUG_ON(!page_m || !PageAnon(page_m));
81725 +
81726 + vma_m = pax_find_mirror_vma(vma);
81727 + if (!vma_m)
81728 + return;
81729 +
81730 + BUG_ON(!PageLocked(page_m));
81731 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81732 + address_m = address + SEGMEXEC_TASK_SIZE;
81733 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81734 + pte_m = pte_offset_map(pmd_m, address_m);
81735 + ptl_m = pte_lockptr(mm, pmd_m);
81736 + if (ptl != ptl_m) {
81737 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81738 + if (!pte_none(*pte_m))
81739 + goto out;
81740 + }
81741 +
81742 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
81743 + page_cache_get(page_m);
81744 + page_add_anon_rmap(page_m, vma_m, address_m);
81745 + inc_mm_counter_fast(mm, MM_ANONPAGES);
81746 + set_pte_at(mm, address_m, pte_m, entry_m);
81747 + update_mmu_cache(vma_m, address_m, pte_m);
81748 +out:
81749 + if (ptl != ptl_m)
81750 + spin_unlock(ptl_m);
81751 + pte_unmap(pte_m);
81752 + unlock_page(page_m);
81753 +}
81754 +
81755 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
81756 +{
81757 + struct mm_struct *mm = vma->vm_mm;
81758 + unsigned long address_m;
81759 + spinlock_t *ptl_m;
81760 + struct vm_area_struct *vma_m;
81761 + pmd_t *pmd_m;
81762 + pte_t *pte_m, entry_m;
81763 +
81764 + BUG_ON(!page_m || PageAnon(page_m));
81765 +
81766 + vma_m = pax_find_mirror_vma(vma);
81767 + if (!vma_m)
81768 + return;
81769 +
81770 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81771 + address_m = address + SEGMEXEC_TASK_SIZE;
81772 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81773 + pte_m = pte_offset_map(pmd_m, address_m);
81774 + ptl_m = pte_lockptr(mm, pmd_m);
81775 + if (ptl != ptl_m) {
81776 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81777 + if (!pte_none(*pte_m))
81778 + goto out;
81779 + }
81780 +
81781 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
81782 + page_cache_get(page_m);
81783 + page_add_file_rmap(page_m);
81784 + inc_mm_counter_fast(mm, MM_FILEPAGES);
81785 + set_pte_at(mm, address_m, pte_m, entry_m);
81786 + update_mmu_cache(vma_m, address_m, pte_m);
81787 +out:
81788 + if (ptl != ptl_m)
81789 + spin_unlock(ptl_m);
81790 + pte_unmap(pte_m);
81791 +}
81792 +
81793 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
81794 +{
81795 + struct mm_struct *mm = vma->vm_mm;
81796 + unsigned long address_m;
81797 + spinlock_t *ptl_m;
81798 + struct vm_area_struct *vma_m;
81799 + pmd_t *pmd_m;
81800 + pte_t *pte_m, entry_m;
81801 +
81802 + vma_m = pax_find_mirror_vma(vma);
81803 + if (!vma_m)
81804 + return;
81805 +
81806 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
81807 + address_m = address + SEGMEXEC_TASK_SIZE;
81808 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
81809 + pte_m = pte_offset_map(pmd_m, address_m);
81810 + ptl_m = pte_lockptr(mm, pmd_m);
81811 + if (ptl != ptl_m) {
81812 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
81813 + if (!pte_none(*pte_m))
81814 + goto out;
81815 + }
81816 +
81817 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
81818 + set_pte_at(mm, address_m, pte_m, entry_m);
81819 +out:
81820 + if (ptl != ptl_m)
81821 + spin_unlock(ptl_m);
81822 + pte_unmap(pte_m);
81823 +}
81824 +
81825 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
81826 +{
81827 + struct page *page_m;
81828 + pte_t entry;
81829 +
81830 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
81831 + goto out;
81832 +
81833 + entry = *pte;
81834 + page_m = vm_normal_page(vma, address, entry);
81835 + if (!page_m)
81836 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
81837 + else if (PageAnon(page_m)) {
81838 + if (pax_find_mirror_vma(vma)) {
81839 + pte_unmap_unlock(pte, ptl);
81840 + lock_page(page_m);
81841 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
81842 + if (pte_same(entry, *pte))
81843 + pax_mirror_anon_pte(vma, address, page_m, ptl);
81844 + else
81845 + unlock_page(page_m);
81846 + }
81847 + } else
81848 + pax_mirror_file_pte(vma, address, page_m, ptl);
81849 +
81850 +out:
81851 + pte_unmap_unlock(pte, ptl);
81852 +}
81853 +#endif
81854 +
81855 /*
81856 * This routine handles present pages, when users try to write
81857 * to a shared page. It is done by copying the page to a new address
81858 @@ -2799,6 +2995,12 @@ gotten:
81859 */
81860 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
81861 if (likely(pte_same(*page_table, orig_pte))) {
81862 +
81863 +#ifdef CONFIG_PAX_SEGMEXEC
81864 + if (pax_find_mirror_vma(vma))
81865 + BUG_ON(!trylock_page(new_page));
81866 +#endif
81867 +
81868 if (old_page) {
81869 if (!PageAnon(old_page)) {
81870 dec_mm_counter_fast(mm, MM_FILEPAGES);
81871 @@ -2850,6 +3052,10 @@ gotten:
81872 page_remove_rmap(old_page);
81873 }
81874
81875 +#ifdef CONFIG_PAX_SEGMEXEC
81876 + pax_mirror_anon_pte(vma, address, new_page, ptl);
81877 +#endif
81878 +
81879 /* Free the old page.. */
81880 new_page = old_page;
81881 ret |= VM_FAULT_WRITE;
81882 @@ -3125,6 +3331,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
81883 swap_free(entry);
81884 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
81885 try_to_free_swap(page);
81886 +
81887 +#ifdef CONFIG_PAX_SEGMEXEC
81888 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
81889 +#endif
81890 +
81891 unlock_page(page);
81892 if (page != swapcache) {
81893 /*
81894 @@ -3148,6 +3359,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
81895
81896 /* No need to invalidate - it was non-present before */
81897 update_mmu_cache(vma, address, page_table);
81898 +
81899 +#ifdef CONFIG_PAX_SEGMEXEC
81900 + pax_mirror_anon_pte(vma, address, page, ptl);
81901 +#endif
81902 +
81903 unlock:
81904 pte_unmap_unlock(page_table, ptl);
81905 out:
81906 @@ -3167,40 +3383,6 @@ out_release:
81907 }
81908
81909 /*
81910 - * This is like a special single-page "expand_{down|up}wards()",
81911 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
81912 - * doesn't hit another vma.
81913 - */
81914 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
81915 -{
81916 - address &= PAGE_MASK;
81917 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
81918 - struct vm_area_struct *prev = vma->vm_prev;
81919 -
81920 - /*
81921 - * Is there a mapping abutting this one below?
81922 - *
81923 - * That's only ok if it's the same stack mapping
81924 - * that has gotten split..
81925 - */
81926 - if (prev && prev->vm_end == address)
81927 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
81928 -
81929 - expand_downwards(vma, address - PAGE_SIZE);
81930 - }
81931 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
81932 - struct vm_area_struct *next = vma->vm_next;
81933 -
81934 - /* As VM_GROWSDOWN but s/below/above/ */
81935 - if (next && next->vm_start == address + PAGE_SIZE)
81936 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
81937 -
81938 - expand_upwards(vma, address + PAGE_SIZE);
81939 - }
81940 - return 0;
81941 -}
81942 -
81943 -/*
81944 * We enter with non-exclusive mmap_sem (to exclude vma changes,
81945 * but allow concurrent faults), and pte mapped but not yet locked.
81946 * We return with mmap_sem still held, but pte unmapped and unlocked.
81947 @@ -3209,27 +3391,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
81948 unsigned long address, pte_t *page_table, pmd_t *pmd,
81949 unsigned int flags)
81950 {
81951 - struct page *page;
81952 + struct page *page = NULL;
81953 spinlock_t *ptl;
81954 pte_t entry;
81955
81956 - pte_unmap(page_table);
81957 -
81958 - /* Check if we need to add a guard page to the stack */
81959 - if (check_stack_guard_page(vma, address) < 0)
81960 - return VM_FAULT_SIGBUS;
81961 -
81962 - /* Use the zero-page for reads */
81963 if (!(flags & FAULT_FLAG_WRITE)) {
81964 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
81965 vma->vm_page_prot));
81966 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
81967 + ptl = pte_lockptr(mm, pmd);
81968 + spin_lock(ptl);
81969 if (!pte_none(*page_table))
81970 goto unlock;
81971 goto setpte;
81972 }
81973
81974 /* Allocate our own private page. */
81975 + pte_unmap(page_table);
81976 +
81977 if (unlikely(anon_vma_prepare(vma)))
81978 goto oom;
81979 page = alloc_zeroed_user_highpage_movable(vma, address);
81980 @@ -3253,6 +3431,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
81981 if (!pte_none(*page_table))
81982 goto release;
81983
81984 +#ifdef CONFIG_PAX_SEGMEXEC
81985 + if (pax_find_mirror_vma(vma))
81986 + BUG_ON(!trylock_page(page));
81987 +#endif
81988 +
81989 inc_mm_counter_fast(mm, MM_ANONPAGES);
81990 page_add_new_anon_rmap(page, vma, address);
81991 setpte:
81992 @@ -3260,6 +3443,12 @@ setpte:
81993
81994 /* No need to invalidate - it was non-present before */
81995 update_mmu_cache(vma, address, page_table);
81996 +
81997 +#ifdef CONFIG_PAX_SEGMEXEC
81998 + if (page)
81999 + pax_mirror_anon_pte(vma, address, page, ptl);
82000 +#endif
82001 +
82002 unlock:
82003 pte_unmap_unlock(page_table, ptl);
82004 return 0;
82005 @@ -3403,6 +3592,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
82006 */
82007 /* Only go through if we didn't race with anybody else... */
82008 if (likely(pte_same(*page_table, orig_pte))) {
82009 +
82010 +#ifdef CONFIG_PAX_SEGMEXEC
82011 + if (anon && pax_find_mirror_vma(vma))
82012 + BUG_ON(!trylock_page(page));
82013 +#endif
82014 +
82015 flush_icache_page(vma, page);
82016 entry = mk_pte(page, vma->vm_page_prot);
82017 if (flags & FAULT_FLAG_WRITE)
82018 @@ -3422,6 +3617,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
82019
82020 /* no need to invalidate: a not-present page won't be cached */
82021 update_mmu_cache(vma, address, page_table);
82022 +
82023 +#ifdef CONFIG_PAX_SEGMEXEC
82024 + if (anon)
82025 + pax_mirror_anon_pte(vma, address, page, ptl);
82026 + else
82027 + pax_mirror_file_pte(vma, address, page, ptl);
82028 +#endif
82029 +
82030 } else {
82031 if (cow_page)
82032 mem_cgroup_uncharge_page(cow_page);
82033 @@ -3743,6 +3946,12 @@ int handle_pte_fault(struct mm_struct *mm,
82034 if (flags & FAULT_FLAG_WRITE)
82035 flush_tlb_fix_spurious_fault(vma, address);
82036 }
82037 +
82038 +#ifdef CONFIG_PAX_SEGMEXEC
82039 + pax_mirror_pte(vma, address, pte, pmd, ptl);
82040 + return 0;
82041 +#endif
82042 +
82043 unlock:
82044 pte_unmap_unlock(pte, ptl);
82045 return 0;
82046 @@ -3759,6 +3968,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
82047 pmd_t *pmd;
82048 pte_t *pte;
82049
82050 +#ifdef CONFIG_PAX_SEGMEXEC
82051 + struct vm_area_struct *vma_m;
82052 +#endif
82053 +
82054 __set_current_state(TASK_RUNNING);
82055
82056 count_vm_event(PGFAULT);
82057 @@ -3770,6 +3983,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
82058 if (unlikely(is_vm_hugetlb_page(vma)))
82059 return hugetlb_fault(mm, vma, address, flags);
82060
82061 +#ifdef CONFIG_PAX_SEGMEXEC
82062 + vma_m = pax_find_mirror_vma(vma);
82063 + if (vma_m) {
82064 + unsigned long address_m;
82065 + pgd_t *pgd_m;
82066 + pud_t *pud_m;
82067 + pmd_t *pmd_m;
82068 +
82069 + if (vma->vm_start > vma_m->vm_start) {
82070 + address_m = address;
82071 + address -= SEGMEXEC_TASK_SIZE;
82072 + vma = vma_m;
82073 + } else
82074 + address_m = address + SEGMEXEC_TASK_SIZE;
82075 +
82076 + pgd_m = pgd_offset(mm, address_m);
82077 + pud_m = pud_alloc(mm, pgd_m, address_m);
82078 + if (!pud_m)
82079 + return VM_FAULT_OOM;
82080 + pmd_m = pmd_alloc(mm, pud_m, address_m);
82081 + if (!pmd_m)
82082 + return VM_FAULT_OOM;
82083 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
82084 + return VM_FAULT_OOM;
82085 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
82086 + }
82087 +#endif
82088 +
82089 retry:
82090 pgd = pgd_offset(mm, address);
82091 pud = pud_alloc(mm, pgd, address);
82092 @@ -3868,6 +4109,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
82093 spin_unlock(&mm->page_table_lock);
82094 return 0;
82095 }
82096 +
82097 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
82098 +{
82099 + pud_t *new = pud_alloc_one(mm, address);
82100 + if (!new)
82101 + return -ENOMEM;
82102 +
82103 + smp_wmb(); /* See comment in __pte_alloc */
82104 +
82105 + spin_lock(&mm->page_table_lock);
82106 + if (pgd_present(*pgd)) /* Another has populated it */
82107 + pud_free(mm, new);
82108 + else
82109 + pgd_populate_kernel(mm, pgd, new);
82110 + spin_unlock(&mm->page_table_lock);
82111 + return 0;
82112 +}
82113 #endif /* __PAGETABLE_PUD_FOLDED */
82114
82115 #ifndef __PAGETABLE_PMD_FOLDED
82116 @@ -3898,6 +4156,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
82117 spin_unlock(&mm->page_table_lock);
82118 return 0;
82119 }
82120 +
82121 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
82122 +{
82123 + pmd_t *new = pmd_alloc_one(mm, address);
82124 + if (!new)
82125 + return -ENOMEM;
82126 +
82127 + smp_wmb(); /* See comment in __pte_alloc */
82128 +
82129 + spin_lock(&mm->page_table_lock);
82130 +#ifndef __ARCH_HAS_4LEVEL_HACK
82131 + if (pud_present(*pud)) /* Another has populated it */
82132 + pmd_free(mm, new);
82133 + else
82134 + pud_populate_kernel(mm, pud, new);
82135 +#else
82136 + if (pgd_present(*pud)) /* Another has populated it */
82137 + pmd_free(mm, new);
82138 + else
82139 + pgd_populate_kernel(mm, pud, new);
82140 +#endif /* __ARCH_HAS_4LEVEL_HACK */
82141 + spin_unlock(&mm->page_table_lock);
82142 + return 0;
82143 +}
82144 #endif /* __PAGETABLE_PMD_FOLDED */
82145
82146 #if !defined(__HAVE_ARCH_GATE_AREA)
82147 @@ -3911,7 +4193,7 @@ static int __init gate_vma_init(void)
82148 gate_vma.vm_start = FIXADDR_USER_START;
82149 gate_vma.vm_end = FIXADDR_USER_END;
82150 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
82151 - gate_vma.vm_page_prot = __P101;
82152 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
82153
82154 return 0;
82155 }
82156 @@ -4045,8 +4327,8 @@ out:
82157 return ret;
82158 }
82159
82160 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
82161 - void *buf, int len, int write)
82162 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
82163 + void *buf, size_t len, int write)
82164 {
82165 resource_size_t phys_addr;
82166 unsigned long prot = 0;
82167 @@ -4071,8 +4353,8 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
82168 * Access another process' address space as given in mm. If non-NULL, use the
82169 * given task for page fault accounting.
82170 */
82171 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
82172 - unsigned long addr, void *buf, int len, int write)
82173 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
82174 + unsigned long addr, void *buf, size_t len, int write)
82175 {
82176 struct vm_area_struct *vma;
82177 void *old_buf = buf;
82178 @@ -4080,7 +4362,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
82179 down_read(&mm->mmap_sem);
82180 /* ignore errors, just check how much was successfully transferred */
82181 while (len) {
82182 - int bytes, ret, offset;
82183 + ssize_t bytes, ret, offset;
82184 void *maddr;
82185 struct page *page = NULL;
82186
82187 @@ -4139,8 +4421,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
82188 *
82189 * The caller must hold a reference on @mm.
82190 */
82191 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
82192 - void *buf, int len, int write)
82193 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
82194 + void *buf, size_t len, int write)
82195 {
82196 return __access_remote_vm(NULL, mm, addr, buf, len, write);
82197 }
82198 @@ -4150,11 +4432,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
82199 * Source/target buffer must be kernel space,
82200 * Do not walk the page table directly, use get_user_pages
82201 */
82202 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
82203 - void *buf, int len, int write)
82204 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
82205 + void *buf, size_t len, int write)
82206 {
82207 struct mm_struct *mm;
82208 - int ret;
82209 + ssize_t ret;
82210
82211 mm = get_task_mm(tsk);
82212 if (!mm)
82213 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
82214 index 7431001..0f8344e 100644
82215 --- a/mm/mempolicy.c
82216 +++ b/mm/mempolicy.c
82217 @@ -708,6 +708,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
82218 unsigned long vmstart;
82219 unsigned long vmend;
82220
82221 +#ifdef CONFIG_PAX_SEGMEXEC
82222 + struct vm_area_struct *vma_m;
82223 +#endif
82224 +
82225 vma = find_vma(mm, start);
82226 if (!vma || vma->vm_start > start)
82227 return -EFAULT;
82228 @@ -744,9 +748,20 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
82229 if (err)
82230 goto out;
82231 }
82232 +
82233 err = vma_replace_policy(vma, new_pol);
82234 if (err)
82235 goto out;
82236 +
82237 +#ifdef CONFIG_PAX_SEGMEXEC
82238 + vma_m = pax_find_mirror_vma(vma);
82239 + if (vma_m) {
82240 + err = vma_replace_policy(vma_m, new_pol);
82241 + if (err)
82242 + goto out;
82243 + }
82244 +#endif
82245 +
82246 }
82247
82248 out:
82249 @@ -1202,6 +1217,17 @@ static long do_mbind(unsigned long start, unsigned long len,
82250
82251 if (end < start)
82252 return -EINVAL;
82253 +
82254 +#ifdef CONFIG_PAX_SEGMEXEC
82255 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
82256 + if (end > SEGMEXEC_TASK_SIZE)
82257 + return -EINVAL;
82258 + } else
82259 +#endif
82260 +
82261 + if (end > TASK_SIZE)
82262 + return -EINVAL;
82263 +
82264 if (end == start)
82265 return 0;
82266
82267 @@ -1430,8 +1456,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
82268 */
82269 tcred = __task_cred(task);
82270 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
82271 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
82272 - !capable(CAP_SYS_NICE)) {
82273 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
82274 rcu_read_unlock();
82275 err = -EPERM;
82276 goto out_put;
82277 @@ -1462,6 +1487,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
82278 goto out;
82279 }
82280
82281 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
82282 + if (mm != current->mm &&
82283 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
82284 + mmput(mm);
82285 + err = -EPERM;
82286 + goto out;
82287 + }
82288 +#endif
82289 +
82290 err = do_migrate_pages(mm, old, new,
82291 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
82292
82293 diff --git a/mm/migrate.c b/mm/migrate.c
82294 index 6f0c244..6d1ae32 100644
82295 --- a/mm/migrate.c
82296 +++ b/mm/migrate.c
82297 @@ -1399,8 +1399,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
82298 */
82299 tcred = __task_cred(task);
82300 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
82301 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
82302 - !capable(CAP_SYS_NICE)) {
82303 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
82304 rcu_read_unlock();
82305 err = -EPERM;
82306 goto out;
82307 diff --git a/mm/mlock.c b/mm/mlock.c
82308 index 79b7cf7..9944291 100644
82309 --- a/mm/mlock.c
82310 +++ b/mm/mlock.c
82311 @@ -13,6 +13,7 @@
82312 #include <linux/pagemap.h>
82313 #include <linux/mempolicy.h>
82314 #include <linux/syscalls.h>
82315 +#include <linux/security.h>
82316 #include <linux/sched.h>
82317 #include <linux/export.h>
82318 #include <linux/rmap.h>
82319 @@ -334,7 +335,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
82320 {
82321 unsigned long nstart, end, tmp;
82322 struct vm_area_struct * vma, * prev;
82323 - int error;
82324 + int error = 0;
82325
82326 VM_BUG_ON(start & ~PAGE_MASK);
82327 VM_BUG_ON(len != PAGE_ALIGN(len));
82328 @@ -343,6 +344,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
82329 return -EINVAL;
82330 if (end == start)
82331 return 0;
82332 + if (end > TASK_SIZE)
82333 + return -EINVAL;
82334 +
82335 vma = find_vma(current->mm, start);
82336 if (!vma || vma->vm_start > start)
82337 return -ENOMEM;
82338 @@ -354,6 +358,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
82339 for (nstart = start ; ; ) {
82340 vm_flags_t newflags;
82341
82342 +#ifdef CONFIG_PAX_SEGMEXEC
82343 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
82344 + break;
82345 +#endif
82346 +
82347 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
82348
82349 newflags = vma->vm_flags & ~VM_LOCKED;
82350 @@ -466,6 +475,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
82351 lock_limit >>= PAGE_SHIFT;
82352
82353 /* check against resource limits */
82354 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
82355 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
82356 error = do_mlock(start, len, 1);
82357 up_write(&current->mm->mmap_sem);
82358 @@ -500,6 +510,11 @@ static int do_mlockall(int flags)
82359 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
82360 vm_flags_t newflags;
82361
82362 +#ifdef CONFIG_PAX_SEGMEXEC
82363 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
82364 + break;
82365 +#endif
82366 +
82367 newflags = vma->vm_flags & ~VM_LOCKED;
82368 if (flags & MCL_CURRENT)
82369 newflags |= VM_LOCKED;
82370 @@ -532,6 +547,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
82371 lock_limit >>= PAGE_SHIFT;
82372
82373 ret = -ENOMEM;
82374 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
82375 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
82376 capable(CAP_IPC_LOCK))
82377 ret = do_mlockall(flags);
82378 diff --git a/mm/mmap.c b/mm/mmap.c
82379 index f681e18..4c2577f 100644
82380 --- a/mm/mmap.c
82381 +++ b/mm/mmap.c
82382 @@ -36,6 +36,7 @@
82383 #include <linux/sched/sysctl.h>
82384 #include <linux/notifier.h>
82385 #include <linux/memory.h>
82386 +#include <linux/random.h>
82387
82388 #include <asm/uaccess.h>
82389 #include <asm/cacheflush.h>
82390 @@ -52,6 +53,16 @@
82391 #define arch_rebalance_pgtables(addr, len) (addr)
82392 #endif
82393
82394 +static inline void verify_mm_writelocked(struct mm_struct *mm)
82395 +{
82396 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
82397 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
82398 + up_read(&mm->mmap_sem);
82399 + BUG();
82400 + }
82401 +#endif
82402 +}
82403 +
82404 static void unmap_region(struct mm_struct *mm,
82405 struct vm_area_struct *vma, struct vm_area_struct *prev,
82406 unsigned long start, unsigned long end);
82407 @@ -71,16 +82,25 @@ static void unmap_region(struct mm_struct *mm,
82408 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
82409 *
82410 */
82411 -pgprot_t protection_map[16] = {
82412 +pgprot_t protection_map[16] __read_only = {
82413 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
82414 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
82415 };
82416
82417 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
82418 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
82419 {
82420 - return __pgprot(pgprot_val(protection_map[vm_flags &
82421 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
82422 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
82423 pgprot_val(arch_vm_get_page_prot(vm_flags)));
82424 +
82425 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82426 + if (!(__supported_pte_mask & _PAGE_NX) &&
82427 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
82428 + (vm_flags & (VM_READ | VM_WRITE)))
82429 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
82430 +#endif
82431 +
82432 + return prot;
82433 }
82434 EXPORT_SYMBOL(vm_get_page_prot);
82435
82436 @@ -89,6 +109,7 @@ int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
82437 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
82438 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
82439 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
82440 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
82441 /*
82442 * Make sure vm_committed_as in one cacheline and not cacheline shared with
82443 * other variables. It can be updated by several CPUs frequently.
82444 @@ -247,6 +268,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
82445 struct vm_area_struct *next = vma->vm_next;
82446
82447 might_sleep();
82448 + BUG_ON(vma->vm_mirror);
82449 if (vma->vm_ops && vma->vm_ops->close)
82450 vma->vm_ops->close(vma);
82451 if (vma->vm_file)
82452 @@ -291,6 +313,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
82453 * not page aligned -Ram Gupta
82454 */
82455 rlim = rlimit(RLIMIT_DATA);
82456 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
82457 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
82458 (mm->end_data - mm->start_data) > rlim)
82459 goto out;
82460 @@ -933,6 +956,12 @@ static int
82461 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
82462 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
82463 {
82464 +
82465 +#ifdef CONFIG_PAX_SEGMEXEC
82466 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
82467 + return 0;
82468 +#endif
82469 +
82470 if (is_mergeable_vma(vma, file, vm_flags) &&
82471 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
82472 if (vma->vm_pgoff == vm_pgoff)
82473 @@ -952,6 +981,12 @@ static int
82474 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
82475 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
82476 {
82477 +
82478 +#ifdef CONFIG_PAX_SEGMEXEC
82479 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
82480 + return 0;
82481 +#endif
82482 +
82483 if (is_mergeable_vma(vma, file, vm_flags) &&
82484 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
82485 pgoff_t vm_pglen;
82486 @@ -994,13 +1029,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
82487 struct vm_area_struct *vma_merge(struct mm_struct *mm,
82488 struct vm_area_struct *prev, unsigned long addr,
82489 unsigned long end, unsigned long vm_flags,
82490 - struct anon_vma *anon_vma, struct file *file,
82491 + struct anon_vma *anon_vma, struct file *file,
82492 pgoff_t pgoff, struct mempolicy *policy)
82493 {
82494 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
82495 struct vm_area_struct *area, *next;
82496 int err;
82497
82498 +#ifdef CONFIG_PAX_SEGMEXEC
82499 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
82500 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
82501 +
82502 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
82503 +#endif
82504 +
82505 /*
82506 * We later require that vma->vm_flags == vm_flags,
82507 * so this tests vma->vm_flags & VM_SPECIAL, too.
82508 @@ -1016,6 +1058,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82509 if (next && next->vm_end == end) /* cases 6, 7, 8 */
82510 next = next->vm_next;
82511
82512 +#ifdef CONFIG_PAX_SEGMEXEC
82513 + if (prev)
82514 + prev_m = pax_find_mirror_vma(prev);
82515 + if (area)
82516 + area_m = pax_find_mirror_vma(area);
82517 + if (next)
82518 + next_m = pax_find_mirror_vma(next);
82519 +#endif
82520 +
82521 /*
82522 * Can it merge with the predecessor?
82523 */
82524 @@ -1035,9 +1086,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82525 /* cases 1, 6 */
82526 err = vma_adjust(prev, prev->vm_start,
82527 next->vm_end, prev->vm_pgoff, NULL);
82528 - } else /* cases 2, 5, 7 */
82529 +
82530 +#ifdef CONFIG_PAX_SEGMEXEC
82531 + if (!err && prev_m)
82532 + err = vma_adjust(prev_m, prev_m->vm_start,
82533 + next_m->vm_end, prev_m->vm_pgoff, NULL);
82534 +#endif
82535 +
82536 + } else { /* cases 2, 5, 7 */
82537 err = vma_adjust(prev, prev->vm_start,
82538 end, prev->vm_pgoff, NULL);
82539 +
82540 +#ifdef CONFIG_PAX_SEGMEXEC
82541 + if (!err && prev_m)
82542 + err = vma_adjust(prev_m, prev_m->vm_start,
82543 + end_m, prev_m->vm_pgoff, NULL);
82544 +#endif
82545 +
82546 + }
82547 if (err)
82548 return NULL;
82549 khugepaged_enter_vma_merge(prev);
82550 @@ -1051,12 +1117,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
82551 mpol_equal(policy, vma_policy(next)) &&
82552 can_vma_merge_before(next, vm_flags,
82553 anon_vma, file, pgoff+pglen)) {
82554 - if (prev && addr < prev->vm_end) /* case 4 */
82555 + if (prev && addr < prev->vm_end) { /* case 4 */
82556 err = vma_adjust(prev, prev->vm_start,
82557 addr, prev->vm_pgoff, NULL);
82558 - else /* cases 3, 8 */
82559 +
82560 +#ifdef CONFIG_PAX_SEGMEXEC
82561 + if (!err && prev_m)
82562 + err = vma_adjust(prev_m, prev_m->vm_start,
82563 + addr_m, prev_m->vm_pgoff, NULL);
82564 +#endif
82565 +
82566 + } else { /* cases 3, 8 */
82567 err = vma_adjust(area, addr, next->vm_end,
82568 next->vm_pgoff - pglen, NULL);
82569 +
82570 +#ifdef CONFIG_PAX_SEGMEXEC
82571 + if (!err && area_m)
82572 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
82573 + next_m->vm_pgoff - pglen, NULL);
82574 +#endif
82575 +
82576 + }
82577 if (err)
82578 return NULL;
82579 khugepaged_enter_vma_merge(area);
82580 @@ -1165,8 +1246,10 @@ none:
82581 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
82582 struct file *file, long pages)
82583 {
82584 - const unsigned long stack_flags
82585 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
82586 +
82587 +#ifdef CONFIG_PAX_RANDMMAP
82588 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
82589 +#endif
82590
82591 mm->total_vm += pages;
82592
82593 @@ -1174,7 +1257,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
82594 mm->shared_vm += pages;
82595 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
82596 mm->exec_vm += pages;
82597 - } else if (flags & stack_flags)
82598 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
82599 mm->stack_vm += pages;
82600 }
82601 #endif /* CONFIG_PROC_FS */
82602 @@ -1213,7 +1296,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82603 * (the exception is when the underlying filesystem is noexec
82604 * mounted, in which case we dont add PROT_EXEC.)
82605 */
82606 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
82607 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
82608 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
82609 prot |= PROT_EXEC;
82610
82611 @@ -1239,7 +1322,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82612 /* Obtain the address to map to. we verify (or select) it and ensure
82613 * that it represents a valid section of the address space.
82614 */
82615 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
82616 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
82617 if (addr & ~PAGE_MASK)
82618 return addr;
82619
82620 @@ -1250,6 +1333,36 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82621 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
82622 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
82623
82624 +#ifdef CONFIG_PAX_MPROTECT
82625 + if (mm->pax_flags & MF_PAX_MPROTECT) {
82626 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
82627 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
82628 + gr_log_rwxmmap(file);
82629 +
82630 +#ifdef CONFIG_PAX_EMUPLT
82631 + vm_flags &= ~VM_EXEC;
82632 +#else
82633 + return -EPERM;
82634 +#endif
82635 +
82636 + }
82637 +
82638 + if (!(vm_flags & VM_EXEC))
82639 + vm_flags &= ~VM_MAYEXEC;
82640 +#else
82641 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
82642 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
82643 +#endif
82644 + else
82645 + vm_flags &= ~VM_MAYWRITE;
82646 + }
82647 +#endif
82648 +
82649 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82650 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
82651 + vm_flags &= ~VM_PAGEEXEC;
82652 +#endif
82653 +
82654 if (flags & MAP_LOCKED)
82655 if (!can_do_mlock())
82656 return -EPERM;
82657 @@ -1261,6 +1374,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82658 locked += mm->locked_vm;
82659 lock_limit = rlimit(RLIMIT_MEMLOCK);
82660 lock_limit >>= PAGE_SHIFT;
82661 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
82662 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
82663 return -EAGAIN;
82664 }
82665 @@ -1341,6 +1455,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
82666 vm_flags |= VM_NORESERVE;
82667 }
82668
82669 + if (!gr_acl_handle_mmap(file, prot))
82670 + return -EACCES;
82671 +
82672 addr = mmap_region(file, addr, len, vm_flags, pgoff);
82673 if (!IS_ERR_VALUE(addr) &&
82674 ((vm_flags & VM_LOCKED) ||
82675 @@ -1432,7 +1549,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
82676 vm_flags_t vm_flags = vma->vm_flags;
82677
82678 /* If it was private or non-writable, the write bit is already clear */
82679 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
82680 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
82681 return 0;
82682
82683 /* The backer wishes to know when pages are first written to? */
82684 @@ -1480,7 +1597,22 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
82685 unsigned long charged = 0;
82686 struct inode *inode = file ? file_inode(file) : NULL;
82687
82688 +#ifdef CONFIG_PAX_SEGMEXEC
82689 + struct vm_area_struct *vma_m = NULL;
82690 +#endif
82691 +
82692 + /*
82693 + * mm->mmap_sem is required to protect against another thread
82694 + * changing the mappings in case we sleep.
82695 + */
82696 + verify_mm_writelocked(mm);
82697 +
82698 /* Check against address space limit. */
82699 +
82700 +#ifdef CONFIG_PAX_RANDMMAP
82701 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
82702 +#endif
82703 +
82704 if (!may_expand_vm(mm, len >> PAGE_SHIFT)) {
82705 unsigned long nr_pages;
82706
82707 @@ -1499,11 +1631,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
82708
82709 /* Clear old maps */
82710 error = -ENOMEM;
82711 -munmap_back:
82712 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
82713 if (do_munmap(mm, addr, len))
82714 return -ENOMEM;
82715 - goto munmap_back;
82716 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
82717 }
82718
82719 /*
82720 @@ -1534,6 +1665,16 @@ munmap_back:
82721 goto unacct_error;
82722 }
82723
82724 +#ifdef CONFIG_PAX_SEGMEXEC
82725 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
82726 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
82727 + if (!vma_m) {
82728 + error = -ENOMEM;
82729 + goto free_vma;
82730 + }
82731 + }
82732 +#endif
82733 +
82734 vma->vm_mm = mm;
82735 vma->vm_start = addr;
82736 vma->vm_end = addr + len;
82737 @@ -1558,6 +1699,13 @@ munmap_back:
82738 if (error)
82739 goto unmap_and_free_vma;
82740
82741 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
82742 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
82743 + vma->vm_flags |= VM_PAGEEXEC;
82744 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
82745 + }
82746 +#endif
82747 +
82748 /* Can addr have changed??
82749 *
82750 * Answer: Yes, several device drivers can do it in their
82751 @@ -1596,6 +1744,11 @@ munmap_back:
82752 vma_link(mm, vma, prev, rb_link, rb_parent);
82753 file = vma->vm_file;
82754
82755 +#ifdef CONFIG_PAX_SEGMEXEC
82756 + if (vma_m)
82757 + BUG_ON(pax_mirror_vma(vma_m, vma));
82758 +#endif
82759 +
82760 /* Once vma denies write, undo our temporary denial count */
82761 if (correct_wcount)
82762 atomic_inc(&inode->i_writecount);
82763 @@ -1603,6 +1756,7 @@ out:
82764 perf_event_mmap(vma);
82765
82766 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
82767 + track_exec_limit(mm, addr, addr + len, vm_flags);
82768 if (vm_flags & VM_LOCKED) {
82769 if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) ||
82770 vma == get_gate_vma(current->mm)))
82771 @@ -1626,6 +1780,12 @@ unmap_and_free_vma:
82772 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
82773 charged = 0;
82774 free_vma:
82775 +
82776 +#ifdef CONFIG_PAX_SEGMEXEC
82777 + if (vma_m)
82778 + kmem_cache_free(vm_area_cachep, vma_m);
82779 +#endif
82780 +
82781 kmem_cache_free(vm_area_cachep, vma);
82782 unacct_error:
82783 if (charged)
82784 @@ -1633,7 +1793,63 @@ unacct_error:
82785 return error;
82786 }
82787
82788 -unsigned long unmapped_area(struct vm_unmapped_area_info *info)
82789 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
82790 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
82791 +{
82792 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
82793 + return ((prandom_u32() & 0xFF) + 1) << PAGE_SHIFT;
82794 +
82795 + return 0;
82796 +}
82797 +#endif
82798 +
82799 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
82800 +{
82801 + if (!vma) {
82802 +#ifdef CONFIG_STACK_GROWSUP
82803 + if (addr > sysctl_heap_stack_gap)
82804 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
82805 + else
82806 + vma = find_vma(current->mm, 0);
82807 + if (vma && (vma->vm_flags & VM_GROWSUP))
82808 + return false;
82809 +#endif
82810 + return true;
82811 + }
82812 +
82813 + if (addr + len > vma->vm_start)
82814 + return false;
82815 +
82816 + if (vma->vm_flags & VM_GROWSDOWN)
82817 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
82818 +#ifdef CONFIG_STACK_GROWSUP
82819 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
82820 + return addr - vma->vm_prev->vm_end >= sysctl_heap_stack_gap;
82821 +#endif
82822 + else if (offset)
82823 + return offset <= vma->vm_start - addr - len;
82824 +
82825 + return true;
82826 +}
82827 +
82828 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
82829 +{
82830 + if (vma->vm_start < len)
82831 + return -ENOMEM;
82832 +
82833 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
82834 + if (offset <= vma->vm_start - len)
82835 + return vma->vm_start - len - offset;
82836 + else
82837 + return -ENOMEM;
82838 + }
82839 +
82840 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
82841 + return vma->vm_start - len - sysctl_heap_stack_gap;
82842 + return -ENOMEM;
82843 +}
82844 +
82845 +unsigned long unmapped_area(const struct vm_unmapped_area_info *info)
82846 {
82847 /*
82848 * We implement the search by looking for an rbtree node that
82849 @@ -1681,11 +1897,29 @@ unsigned long unmapped_area(struct vm_unmapped_area_info *info)
82850 }
82851 }
82852
82853 - gap_start = vma->vm_prev ? vma->vm_prev->vm_end : 0;
82854 + gap_start = vma->vm_prev ? vma->vm_prev->vm_end: 0;
82855 check_current:
82856 /* Check if current node has a suitable gap */
82857 if (gap_start > high_limit)
82858 return -ENOMEM;
82859 +
82860 + if (gap_end - gap_start > info->threadstack_offset)
82861 + gap_start += info->threadstack_offset;
82862 + else
82863 + gap_start = gap_end;
82864 +
82865 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
82866 + if (gap_end - gap_start > sysctl_heap_stack_gap)
82867 + gap_start += sysctl_heap_stack_gap;
82868 + else
82869 + gap_start = gap_end;
82870 + }
82871 + if (vma->vm_flags & VM_GROWSDOWN) {
82872 + if (gap_end - gap_start > sysctl_heap_stack_gap)
82873 + gap_end -= sysctl_heap_stack_gap;
82874 + else
82875 + gap_end = gap_start;
82876 + }
82877 if (gap_end >= low_limit && gap_end - gap_start >= length)
82878 goto found;
82879
82880 @@ -1735,7 +1969,7 @@ found:
82881 return gap_start;
82882 }
82883
82884 -unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
82885 +unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info)
82886 {
82887 struct mm_struct *mm = current->mm;
82888 struct vm_area_struct *vma;
82889 @@ -1789,6 +2023,24 @@ check_current:
82890 gap_end = vma->vm_start;
82891 if (gap_end < low_limit)
82892 return -ENOMEM;
82893 +
82894 + if (gap_end - gap_start > info->threadstack_offset)
82895 + gap_end -= info->threadstack_offset;
82896 + else
82897 + gap_end = gap_start;
82898 +
82899 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
82900 + if (gap_end - gap_start > sysctl_heap_stack_gap)
82901 + gap_start += sysctl_heap_stack_gap;
82902 + else
82903 + gap_start = gap_end;
82904 + }
82905 + if (vma->vm_flags & VM_GROWSDOWN) {
82906 + if (gap_end - gap_start > sysctl_heap_stack_gap)
82907 + gap_end -= sysctl_heap_stack_gap;
82908 + else
82909 + gap_end = gap_start;
82910 + }
82911 if (gap_start <= high_limit && gap_end - gap_start >= length)
82912 goto found;
82913
82914 @@ -1852,6 +2104,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
82915 struct mm_struct *mm = current->mm;
82916 struct vm_area_struct *vma;
82917 struct vm_unmapped_area_info info;
82918 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
82919
82920 if (len > TASK_SIZE)
82921 return -ENOMEM;
82922 @@ -1859,29 +2112,45 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
82923 if (flags & MAP_FIXED)
82924 return addr;
82925
82926 +#ifdef CONFIG_PAX_RANDMMAP
82927 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
82928 +#endif
82929 +
82930 if (addr) {
82931 addr = PAGE_ALIGN(addr);
82932 vma = find_vma(mm, addr);
82933 - if (TASK_SIZE - len >= addr &&
82934 - (!vma || addr + len <= vma->vm_start))
82935 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
82936 return addr;
82937 }
82938
82939 info.flags = 0;
82940 info.length = len;
82941 info.low_limit = TASK_UNMAPPED_BASE;
82942 +
82943 +#ifdef CONFIG_PAX_RANDMMAP
82944 + if (mm->pax_flags & MF_PAX_RANDMMAP)
82945 + info.low_limit += mm->delta_mmap;
82946 +#endif
82947 +
82948 info.high_limit = TASK_SIZE;
82949 info.align_mask = 0;
82950 + info.threadstack_offset = offset;
82951 return vm_unmapped_area(&info);
82952 }
82953 #endif
82954
82955 void arch_unmap_area(struct mm_struct *mm, unsigned long addr)
82956 {
82957 +
82958 +#ifdef CONFIG_PAX_SEGMEXEC
82959 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
82960 + return;
82961 +#endif
82962 +
82963 /*
82964 * Is this a new hole at the lowest possible address?
82965 */
82966 - if (addr >= TASK_UNMAPPED_BASE && addr < mm->free_area_cache)
82967 + if (addr >= mm->mmap_base && addr < mm->free_area_cache)
82968 mm->free_area_cache = addr;
82969 }
82970
82971 @@ -1899,6 +2168,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82972 struct mm_struct *mm = current->mm;
82973 unsigned long addr = addr0;
82974 struct vm_unmapped_area_info info;
82975 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
82976
82977 /* requested length too big for entire address space */
82978 if (len > TASK_SIZE)
82979 @@ -1907,12 +2177,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82980 if (flags & MAP_FIXED)
82981 return addr;
82982
82983 +#ifdef CONFIG_PAX_RANDMMAP
82984 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
82985 +#endif
82986 +
82987 /* requesting a specific address */
82988 if (addr) {
82989 addr = PAGE_ALIGN(addr);
82990 vma = find_vma(mm, addr);
82991 - if (TASK_SIZE - len >= addr &&
82992 - (!vma || addr + len <= vma->vm_start))
82993 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
82994 return addr;
82995 }
82996
82997 @@ -1921,6 +2194,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
82998 info.low_limit = PAGE_SIZE;
82999 info.high_limit = mm->mmap_base;
83000 info.align_mask = 0;
83001 + info.threadstack_offset = offset;
83002 addr = vm_unmapped_area(&info);
83003
83004 /*
83005 @@ -1933,6 +2207,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
83006 VM_BUG_ON(addr != -ENOMEM);
83007 info.flags = 0;
83008 info.low_limit = TASK_UNMAPPED_BASE;
83009 +
83010 +#ifdef CONFIG_PAX_RANDMMAP
83011 + if (mm->pax_flags & MF_PAX_RANDMMAP)
83012 + info.low_limit += mm->delta_mmap;
83013 +#endif
83014 +
83015 info.high_limit = TASK_SIZE;
83016 addr = vm_unmapped_area(&info);
83017 }
83018 @@ -1943,6 +2223,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
83019
83020 void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
83021 {
83022 +
83023 +#ifdef CONFIG_PAX_SEGMEXEC
83024 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
83025 + return;
83026 +#endif
83027 +
83028 /*
83029 * Is this a new hole at the highest possible address?
83030 */
83031 @@ -1950,8 +2236,10 @@ void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
83032 mm->free_area_cache = addr;
83033
83034 /* dont allow allocations above current base */
83035 - if (mm->free_area_cache > mm->mmap_base)
83036 + if (mm->free_area_cache > mm->mmap_base) {
83037 mm->free_area_cache = mm->mmap_base;
83038 + mm->cached_hole_size = ~0UL;
83039 + }
83040 }
83041
83042 unsigned long
83043 @@ -2047,6 +2335,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
83044 return vma;
83045 }
83046
83047 +#ifdef CONFIG_PAX_SEGMEXEC
83048 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
83049 +{
83050 + struct vm_area_struct *vma_m;
83051 +
83052 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
83053 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
83054 + BUG_ON(vma->vm_mirror);
83055 + return NULL;
83056 + }
83057 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
83058 + vma_m = vma->vm_mirror;
83059 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
83060 + BUG_ON(vma->vm_file != vma_m->vm_file);
83061 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
83062 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
83063 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
83064 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
83065 + return vma_m;
83066 +}
83067 +#endif
83068 +
83069 /*
83070 * Verify that the stack growth is acceptable and
83071 * update accounting. This is shared with both the
83072 @@ -2063,6 +2373,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
83073 return -ENOMEM;
83074
83075 /* Stack limit test */
83076 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
83077 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
83078 return -ENOMEM;
83079
83080 @@ -2073,6 +2384,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
83081 locked = mm->locked_vm + grow;
83082 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
83083 limit >>= PAGE_SHIFT;
83084 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
83085 if (locked > limit && !capable(CAP_IPC_LOCK))
83086 return -ENOMEM;
83087 }
83088 @@ -2102,37 +2414,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
83089 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
83090 * vma is the last one with address > vma->vm_end. Have to extend vma.
83091 */
83092 +#ifndef CONFIG_IA64
83093 +static
83094 +#endif
83095 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
83096 {
83097 int error;
83098 + bool locknext;
83099
83100 if (!(vma->vm_flags & VM_GROWSUP))
83101 return -EFAULT;
83102
83103 + /* Also guard against wrapping around to address 0. */
83104 + if (address < PAGE_ALIGN(address+1))
83105 + address = PAGE_ALIGN(address+1);
83106 + else
83107 + return -ENOMEM;
83108 +
83109 /*
83110 * We must make sure the anon_vma is allocated
83111 * so that the anon_vma locking is not a noop.
83112 */
83113 if (unlikely(anon_vma_prepare(vma)))
83114 return -ENOMEM;
83115 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
83116 + if (locknext && anon_vma_prepare(vma->vm_next))
83117 + return -ENOMEM;
83118 vma_lock_anon_vma(vma);
83119 + if (locknext)
83120 + vma_lock_anon_vma(vma->vm_next);
83121
83122 /*
83123 * vma->vm_start/vm_end cannot change under us because the caller
83124 * is required to hold the mmap_sem in read mode. We need the
83125 - * anon_vma lock to serialize against concurrent expand_stacks.
83126 - * Also guard against wrapping around to address 0.
83127 + * anon_vma locks to serialize against concurrent expand_stacks
83128 + * and expand_upwards.
83129 */
83130 - if (address < PAGE_ALIGN(address+4))
83131 - address = PAGE_ALIGN(address+4);
83132 - else {
83133 - vma_unlock_anon_vma(vma);
83134 - return -ENOMEM;
83135 - }
83136 error = 0;
83137
83138 /* Somebody else might have raced and expanded it already */
83139 - if (address > vma->vm_end) {
83140 + 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)
83141 + error = -ENOMEM;
83142 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
83143 unsigned long size, grow;
83144
83145 size = address - vma->vm_start;
83146 @@ -2167,6 +2490,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
83147 }
83148 }
83149 }
83150 + if (locknext)
83151 + vma_unlock_anon_vma(vma->vm_next);
83152 vma_unlock_anon_vma(vma);
83153 khugepaged_enter_vma_merge(vma);
83154 validate_mm(vma->vm_mm);
83155 @@ -2181,6 +2506,8 @@ int expand_downwards(struct vm_area_struct *vma,
83156 unsigned long address)
83157 {
83158 int error;
83159 + bool lockprev = false;
83160 + struct vm_area_struct *prev;
83161
83162 /*
83163 * We must make sure the anon_vma is allocated
83164 @@ -2194,6 +2521,15 @@ int expand_downwards(struct vm_area_struct *vma,
83165 if (error)
83166 return error;
83167
83168 + prev = vma->vm_prev;
83169 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
83170 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
83171 +#endif
83172 + if (lockprev && anon_vma_prepare(prev))
83173 + return -ENOMEM;
83174 + if (lockprev)
83175 + vma_lock_anon_vma(prev);
83176 +
83177 vma_lock_anon_vma(vma);
83178
83179 /*
83180 @@ -2203,9 +2539,17 @@ int expand_downwards(struct vm_area_struct *vma,
83181 */
83182
83183 /* Somebody else might have raced and expanded it already */
83184 - if (address < vma->vm_start) {
83185 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
83186 + error = -ENOMEM;
83187 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
83188 unsigned long size, grow;
83189
83190 +#ifdef CONFIG_PAX_SEGMEXEC
83191 + struct vm_area_struct *vma_m;
83192 +
83193 + vma_m = pax_find_mirror_vma(vma);
83194 +#endif
83195 +
83196 size = vma->vm_end - address;
83197 grow = (vma->vm_start - address) >> PAGE_SHIFT;
83198
83199 @@ -2230,13 +2574,27 @@ int expand_downwards(struct vm_area_struct *vma,
83200 vma->vm_pgoff -= grow;
83201 anon_vma_interval_tree_post_update_vma(vma);
83202 vma_gap_update(vma);
83203 +
83204 +#ifdef CONFIG_PAX_SEGMEXEC
83205 + if (vma_m) {
83206 + anon_vma_interval_tree_pre_update_vma(vma_m);
83207 + vma_m->vm_start -= grow << PAGE_SHIFT;
83208 + vma_m->vm_pgoff -= grow;
83209 + anon_vma_interval_tree_post_update_vma(vma_m);
83210 + vma_gap_update(vma_m);
83211 + }
83212 +#endif
83213 +
83214 spin_unlock(&vma->vm_mm->page_table_lock);
83215
83216 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
83217 perf_event_mmap(vma);
83218 }
83219 }
83220 }
83221 vma_unlock_anon_vma(vma);
83222 + if (lockprev)
83223 + vma_unlock_anon_vma(prev);
83224 khugepaged_enter_vma_merge(vma);
83225 validate_mm(vma->vm_mm);
83226 return error;
83227 @@ -2334,6 +2692,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
83228 do {
83229 long nrpages = vma_pages(vma);
83230
83231 +#ifdef CONFIG_PAX_SEGMEXEC
83232 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
83233 + vma = remove_vma(vma);
83234 + continue;
83235 + }
83236 +#endif
83237 +
83238 if (vma->vm_flags & VM_ACCOUNT)
83239 nr_accounted += nrpages;
83240 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
83241 @@ -2379,6 +2744,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
83242 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
83243 vma->vm_prev = NULL;
83244 do {
83245 +
83246 +#ifdef CONFIG_PAX_SEGMEXEC
83247 + if (vma->vm_mirror) {
83248 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
83249 + vma->vm_mirror->vm_mirror = NULL;
83250 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
83251 + vma->vm_mirror = NULL;
83252 + }
83253 +#endif
83254 +
83255 vma_rb_erase(vma, &mm->mm_rb);
83256 mm->map_count--;
83257 tail_vma = vma;
83258 @@ -2410,14 +2785,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
83259 struct vm_area_struct *new;
83260 int err = -ENOMEM;
83261
83262 +#ifdef CONFIG_PAX_SEGMEXEC
83263 + struct vm_area_struct *vma_m, *new_m = NULL;
83264 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
83265 +#endif
83266 +
83267 if (is_vm_hugetlb_page(vma) && (addr &
83268 ~(huge_page_mask(hstate_vma(vma)))))
83269 return -EINVAL;
83270
83271 +#ifdef CONFIG_PAX_SEGMEXEC
83272 + vma_m = pax_find_mirror_vma(vma);
83273 +#endif
83274 +
83275 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
83276 if (!new)
83277 goto out_err;
83278
83279 +#ifdef CONFIG_PAX_SEGMEXEC
83280 + if (vma_m) {
83281 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
83282 + if (!new_m) {
83283 + kmem_cache_free(vm_area_cachep, new);
83284 + goto out_err;
83285 + }
83286 + }
83287 +#endif
83288 +
83289 /* most fields are the same, copy all, and then fixup */
83290 *new = *vma;
83291
83292 @@ -2430,6 +2824,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
83293 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
83294 }
83295
83296 +#ifdef CONFIG_PAX_SEGMEXEC
83297 + if (vma_m) {
83298 + *new_m = *vma_m;
83299 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
83300 + new_m->vm_mirror = new;
83301 + new->vm_mirror = new_m;
83302 +
83303 + if (new_below)
83304 + new_m->vm_end = addr_m;
83305 + else {
83306 + new_m->vm_start = addr_m;
83307 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
83308 + }
83309 + }
83310 +#endif
83311 +
83312 pol = mpol_dup(vma_policy(vma));
83313 if (IS_ERR(pol)) {
83314 err = PTR_ERR(pol);
83315 @@ -2452,6 +2862,36 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
83316 else
83317 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
83318
83319 +#ifdef CONFIG_PAX_SEGMEXEC
83320 + if (!err && vma_m) {
83321 + if (anon_vma_clone(new_m, vma_m))
83322 + goto out_free_mpol;
83323 +
83324 + mpol_get(pol);
83325 + vma_set_policy(new_m, pol);
83326 +
83327 + if (new_m->vm_file)
83328 + get_file(new_m->vm_file);
83329 +
83330 + if (new_m->vm_ops && new_m->vm_ops->open)
83331 + new_m->vm_ops->open(new_m);
83332 +
83333 + if (new_below)
83334 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
83335 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
83336 + else
83337 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
83338 +
83339 + if (err) {
83340 + if (new_m->vm_ops && new_m->vm_ops->close)
83341 + new_m->vm_ops->close(new_m);
83342 + if (new_m->vm_file)
83343 + fput(new_m->vm_file);
83344 + mpol_put(pol);
83345 + }
83346 + }
83347 +#endif
83348 +
83349 /* Success. */
83350 if (!err)
83351 return 0;
83352 @@ -2461,10 +2901,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
83353 new->vm_ops->close(new);
83354 if (new->vm_file)
83355 fput(new->vm_file);
83356 - unlink_anon_vmas(new);
83357 out_free_mpol:
83358 mpol_put(pol);
83359 out_free_vma:
83360 +
83361 +#ifdef CONFIG_PAX_SEGMEXEC
83362 + if (new_m) {
83363 + unlink_anon_vmas(new_m);
83364 + kmem_cache_free(vm_area_cachep, new_m);
83365 + }
83366 +#endif
83367 +
83368 + unlink_anon_vmas(new);
83369 kmem_cache_free(vm_area_cachep, new);
83370 out_err:
83371 return err;
83372 @@ -2477,6 +2925,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
83373 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
83374 unsigned long addr, int new_below)
83375 {
83376 +
83377 +#ifdef CONFIG_PAX_SEGMEXEC
83378 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
83379 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
83380 + if (mm->map_count >= sysctl_max_map_count-1)
83381 + return -ENOMEM;
83382 + } else
83383 +#endif
83384 +
83385 if (mm->map_count >= sysctl_max_map_count)
83386 return -ENOMEM;
83387
83388 @@ -2488,11 +2945,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
83389 * work. This now handles partial unmappings.
83390 * Jeremy Fitzhardinge <jeremy@goop.org>
83391 */
83392 +#ifdef CONFIG_PAX_SEGMEXEC
83393 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
83394 {
83395 + int ret = __do_munmap(mm, start, len);
83396 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
83397 + return ret;
83398 +
83399 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
83400 +}
83401 +
83402 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
83403 +#else
83404 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
83405 +#endif
83406 +{
83407 unsigned long end;
83408 struct vm_area_struct *vma, *prev, *last;
83409
83410 + /*
83411 + * mm->mmap_sem is required to protect against another thread
83412 + * changing the mappings in case we sleep.
83413 + */
83414 + verify_mm_writelocked(mm);
83415 +
83416 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
83417 return -EINVAL;
83418
83419 @@ -2567,6 +3043,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
83420 /* Fix up all other VM information */
83421 remove_vma_list(mm, vma);
83422
83423 + track_exec_limit(mm, start, end, 0UL);
83424 +
83425 return 0;
83426 }
83427
83428 @@ -2575,6 +3053,13 @@ int vm_munmap(unsigned long start, size_t len)
83429 int ret;
83430 struct mm_struct *mm = current->mm;
83431
83432 +
83433 +#ifdef CONFIG_PAX_SEGMEXEC
83434 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
83435 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
83436 + return -EINVAL;
83437 +#endif
83438 +
83439 down_write(&mm->mmap_sem);
83440 ret = do_munmap(mm, start, len);
83441 up_write(&mm->mmap_sem);
83442 @@ -2588,16 +3073,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
83443 return vm_munmap(addr, len);
83444 }
83445
83446 -static inline void verify_mm_writelocked(struct mm_struct *mm)
83447 -{
83448 -#ifdef CONFIG_DEBUG_VM
83449 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
83450 - WARN_ON(1);
83451 - up_read(&mm->mmap_sem);
83452 - }
83453 -#endif
83454 -}
83455 -
83456 /*
83457 * this is really a simplified "do_mmap". it only handles
83458 * anonymous maps. eventually we may be able to do some
83459 @@ -2611,6 +3086,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83460 struct rb_node ** rb_link, * rb_parent;
83461 pgoff_t pgoff = addr >> PAGE_SHIFT;
83462 int error;
83463 + unsigned long charged;
83464
83465 len = PAGE_ALIGN(len);
83466 if (!len)
83467 @@ -2618,16 +3094,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83468
83469 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
83470
83471 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
83472 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
83473 + flags &= ~VM_EXEC;
83474 +
83475 +#ifdef CONFIG_PAX_MPROTECT
83476 + if (mm->pax_flags & MF_PAX_MPROTECT)
83477 + flags &= ~VM_MAYEXEC;
83478 +#endif
83479 +
83480 + }
83481 +#endif
83482 +
83483 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
83484 if (error & ~PAGE_MASK)
83485 return error;
83486
83487 + charged = len >> PAGE_SHIFT;
83488 +
83489 /*
83490 * mlock MCL_FUTURE?
83491 */
83492 if (mm->def_flags & VM_LOCKED) {
83493 unsigned long locked, lock_limit;
83494 - locked = len >> PAGE_SHIFT;
83495 + locked = charged;
83496 locked += mm->locked_vm;
83497 lock_limit = rlimit(RLIMIT_MEMLOCK);
83498 lock_limit >>= PAGE_SHIFT;
83499 @@ -2644,21 +3134,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83500 /*
83501 * Clear old maps. this also does some error checking for us
83502 */
83503 - munmap_back:
83504 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
83505 if (do_munmap(mm, addr, len))
83506 return -ENOMEM;
83507 - goto munmap_back;
83508 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
83509 }
83510
83511 /* Check against address space limits *after* clearing old maps... */
83512 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
83513 + if (!may_expand_vm(mm, charged))
83514 return -ENOMEM;
83515
83516 if (mm->map_count > sysctl_max_map_count)
83517 return -ENOMEM;
83518
83519 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
83520 + if (security_vm_enough_memory_mm(mm, charged))
83521 return -ENOMEM;
83522
83523 /* Can we just expand an old private anonymous mapping? */
83524 @@ -2672,7 +3161,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83525 */
83526 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83527 if (!vma) {
83528 - vm_unacct_memory(len >> PAGE_SHIFT);
83529 + vm_unacct_memory(charged);
83530 return -ENOMEM;
83531 }
83532
83533 @@ -2686,9 +3175,10 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
83534 vma_link(mm, vma, prev, rb_link, rb_parent);
83535 out:
83536 perf_event_mmap(vma);
83537 - mm->total_vm += len >> PAGE_SHIFT;
83538 + mm->total_vm += charged;
83539 if (flags & VM_LOCKED)
83540 - mm->locked_vm += (len >> PAGE_SHIFT);
83541 + mm->locked_vm += charged;
83542 + track_exec_limit(mm, addr, addr + len, flags);
83543 return addr;
83544 }
83545
83546 @@ -2750,6 +3240,7 @@ void exit_mmap(struct mm_struct *mm)
83547 while (vma) {
83548 if (vma->vm_flags & VM_ACCOUNT)
83549 nr_accounted += vma_pages(vma);
83550 + vma->vm_mirror = NULL;
83551 vma = remove_vma(vma);
83552 }
83553 vm_unacct_memory(nr_accounted);
83554 @@ -2766,6 +3257,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
83555 struct vm_area_struct *prev;
83556 struct rb_node **rb_link, *rb_parent;
83557
83558 +#ifdef CONFIG_PAX_SEGMEXEC
83559 + struct vm_area_struct *vma_m = NULL;
83560 +#endif
83561 +
83562 + if (security_mmap_addr(vma->vm_start))
83563 + return -EPERM;
83564 +
83565 /*
83566 * The vm_pgoff of a purely anonymous vma should be irrelevant
83567 * until its first write fault, when page's anon_vma and index
83568 @@ -2789,7 +3287,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
83569 security_vm_enough_memory_mm(mm, vma_pages(vma)))
83570 return -ENOMEM;
83571
83572 +#ifdef CONFIG_PAX_SEGMEXEC
83573 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
83574 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83575 + if (!vma_m)
83576 + return -ENOMEM;
83577 + }
83578 +#endif
83579 +
83580 vma_link(mm, vma, prev, rb_link, rb_parent);
83581 +
83582 +#ifdef CONFIG_PAX_SEGMEXEC
83583 + if (vma_m)
83584 + BUG_ON(pax_mirror_vma(vma_m, vma));
83585 +#endif
83586 +
83587 return 0;
83588 }
83589
83590 @@ -2809,6 +3321,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
83591 struct mempolicy *pol;
83592 bool faulted_in_anon_vma = true;
83593
83594 + BUG_ON(vma->vm_mirror);
83595 +
83596 /*
83597 * If anonymous vma has not yet been faulted, update new pgoff
83598 * to match new location, to increase its chance of merging.
83599 @@ -2875,6 +3389,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
83600 return NULL;
83601 }
83602
83603 +#ifdef CONFIG_PAX_SEGMEXEC
83604 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
83605 +{
83606 + struct vm_area_struct *prev_m;
83607 + struct rb_node **rb_link_m, *rb_parent_m;
83608 + struct mempolicy *pol_m;
83609 +
83610 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
83611 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
83612 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
83613 + *vma_m = *vma;
83614 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
83615 + if (anon_vma_clone(vma_m, vma))
83616 + return -ENOMEM;
83617 + pol_m = vma_policy(vma_m);
83618 + mpol_get(pol_m);
83619 + vma_set_policy(vma_m, pol_m);
83620 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
83621 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
83622 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
83623 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
83624 + if (vma_m->vm_file)
83625 + get_file(vma_m->vm_file);
83626 + if (vma_m->vm_ops && vma_m->vm_ops->open)
83627 + vma_m->vm_ops->open(vma_m);
83628 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
83629 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
83630 + vma_m->vm_mirror = vma;
83631 + vma->vm_mirror = vma_m;
83632 + return 0;
83633 +}
83634 +#endif
83635 +
83636 /*
83637 * Return true if the calling process may expand its vm space by the passed
83638 * number of pages
83639 @@ -2886,6 +3433,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
83640
83641 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
83642
83643 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
83644 if (cur + npages > lim)
83645 return 0;
83646 return 1;
83647 @@ -2956,6 +3504,22 @@ int install_special_mapping(struct mm_struct *mm,
83648 vma->vm_start = addr;
83649 vma->vm_end = addr + len;
83650
83651 +#ifdef CONFIG_PAX_MPROTECT
83652 + if (mm->pax_flags & MF_PAX_MPROTECT) {
83653 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
83654 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
83655 + return -EPERM;
83656 + if (!(vm_flags & VM_EXEC))
83657 + vm_flags &= ~VM_MAYEXEC;
83658 +#else
83659 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
83660 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
83661 +#endif
83662 + else
83663 + vm_flags &= ~VM_MAYWRITE;
83664 + }
83665 +#endif
83666 +
83667 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
83668 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
83669
83670 diff --git a/mm/mprotect.c b/mm/mprotect.c
83671 index 94722a4..07d9926 100644
83672 --- a/mm/mprotect.c
83673 +++ b/mm/mprotect.c
83674 @@ -23,10 +23,18 @@
83675 #include <linux/mmu_notifier.h>
83676 #include <linux/migrate.h>
83677 #include <linux/perf_event.h>
83678 +#include <linux/sched/sysctl.h>
83679 +
83680 +#ifdef CONFIG_PAX_MPROTECT
83681 +#include <linux/elf.h>
83682 +#include <linux/binfmts.h>
83683 +#endif
83684 +
83685 #include <asm/uaccess.h>
83686 #include <asm/pgtable.h>
83687 #include <asm/cacheflush.h>
83688 #include <asm/tlbflush.h>
83689 +#include <asm/mmu_context.h>
83690
83691 #ifndef pgprot_modify
83692 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
83693 @@ -233,6 +241,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
83694 return pages;
83695 }
83696
83697 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
83698 +/* called while holding the mmap semaphor for writing except stack expansion */
83699 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
83700 +{
83701 + unsigned long oldlimit, newlimit = 0UL;
83702 +
83703 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
83704 + return;
83705 +
83706 + spin_lock(&mm->page_table_lock);
83707 + oldlimit = mm->context.user_cs_limit;
83708 + if ((prot & VM_EXEC) && oldlimit < end)
83709 + /* USER_CS limit moved up */
83710 + newlimit = end;
83711 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
83712 + /* USER_CS limit moved down */
83713 + newlimit = start;
83714 +
83715 + if (newlimit) {
83716 + mm->context.user_cs_limit = newlimit;
83717 +
83718 +#ifdef CONFIG_SMP
83719 + wmb();
83720 + cpus_clear(mm->context.cpu_user_cs_mask);
83721 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
83722 +#endif
83723 +
83724 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
83725 + }
83726 + spin_unlock(&mm->page_table_lock);
83727 + if (newlimit == end) {
83728 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
83729 +
83730 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
83731 + if (is_vm_hugetlb_page(vma))
83732 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
83733 + else
83734 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
83735 + }
83736 +}
83737 +#endif
83738 +
83739 int
83740 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83741 unsigned long start, unsigned long end, unsigned long newflags)
83742 @@ -245,11 +295,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83743 int error;
83744 int dirty_accountable = 0;
83745
83746 +#ifdef CONFIG_PAX_SEGMEXEC
83747 + struct vm_area_struct *vma_m = NULL;
83748 + unsigned long start_m, end_m;
83749 +
83750 + start_m = start + SEGMEXEC_TASK_SIZE;
83751 + end_m = end + SEGMEXEC_TASK_SIZE;
83752 +#endif
83753 +
83754 if (newflags == oldflags) {
83755 *pprev = vma;
83756 return 0;
83757 }
83758
83759 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
83760 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
83761 +
83762 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
83763 + return -ENOMEM;
83764 +
83765 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
83766 + return -ENOMEM;
83767 + }
83768 +
83769 /*
83770 * If we make a private mapping writable we increase our commit;
83771 * but (without finer accounting) cannot reduce our commit if we
83772 @@ -266,6 +334,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
83773 }
83774 }
83775
83776 +#ifdef CONFIG_PAX_SEGMEXEC
83777 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
83778 + if (start != vma->vm_start) {
83779 + error = split_vma(mm, vma, start, 1);
83780 + if (error)
83781 + goto fail;
83782 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
83783 + *pprev = (*pprev)->vm_next;
83784 + }
83785 +
83786 + if (end != vma->vm_end) {
83787 + error = split_vma(mm, vma, end, 0);
83788 + if (error)
83789 + goto fail;
83790 + }
83791 +
83792 + if (pax_find_mirror_vma(vma)) {
83793 + error = __do_munmap(mm, start_m, end_m - start_m);
83794 + if (error)
83795 + goto fail;
83796 + } else {
83797 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
83798 + if (!vma_m) {
83799 + error = -ENOMEM;
83800 + goto fail;
83801 + }
83802 + vma->vm_flags = newflags;
83803 + error = pax_mirror_vma(vma_m, vma);
83804 + if (error) {
83805 + vma->vm_flags = oldflags;
83806 + goto fail;
83807 + }
83808 + }
83809 + }
83810 +#endif
83811 +
83812 /*
83813 * First try to merge with previous and/or next vma.
83814 */
83815 @@ -296,9 +400,21 @@ success:
83816 * vm_flags and vm_page_prot are protected by the mmap_sem
83817 * held in write mode.
83818 */
83819 +
83820 +#ifdef CONFIG_PAX_SEGMEXEC
83821 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
83822 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
83823 +#endif
83824 +
83825 vma->vm_flags = newflags;
83826 +
83827 +#ifdef CONFIG_PAX_MPROTECT
83828 + if (mm->binfmt && mm->binfmt->handle_mprotect)
83829 + mm->binfmt->handle_mprotect(vma, newflags);
83830 +#endif
83831 +
83832 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
83833 - vm_get_page_prot(newflags));
83834 + vm_get_page_prot(vma->vm_flags));
83835
83836 if (vma_wants_writenotify(vma)) {
83837 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
83838 @@ -337,6 +453,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83839 end = start + len;
83840 if (end <= start)
83841 return -ENOMEM;
83842 +
83843 +#ifdef CONFIG_PAX_SEGMEXEC
83844 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
83845 + if (end > SEGMEXEC_TASK_SIZE)
83846 + return -EINVAL;
83847 + } else
83848 +#endif
83849 +
83850 + if (end > TASK_SIZE)
83851 + return -EINVAL;
83852 +
83853 if (!arch_validate_prot(prot))
83854 return -EINVAL;
83855
83856 @@ -344,7 +471,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83857 /*
83858 * Does the application expect PROT_READ to imply PROT_EXEC:
83859 */
83860 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
83861 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
83862 prot |= PROT_EXEC;
83863
83864 vm_flags = calc_vm_prot_bits(prot);
83865 @@ -376,6 +503,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83866 if (start > vma->vm_start)
83867 prev = vma;
83868
83869 +#ifdef CONFIG_PAX_MPROTECT
83870 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
83871 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
83872 +#endif
83873 +
83874 for (nstart = start ; ; ) {
83875 unsigned long newflags;
83876
83877 @@ -386,6 +518,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83878
83879 /* newflags >> 4 shift VM_MAY% in place of VM_% */
83880 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
83881 + if (prot & (PROT_WRITE | PROT_EXEC))
83882 + gr_log_rwxmprotect(vma->vm_file);
83883 +
83884 + error = -EACCES;
83885 + goto out;
83886 + }
83887 +
83888 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
83889 error = -EACCES;
83890 goto out;
83891 }
83892 @@ -400,6 +540,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
83893 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
83894 if (error)
83895 goto out;
83896 +
83897 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
83898 +
83899 nstart = tmp;
83900
83901 if (nstart < prev->vm_end)
83902 diff --git a/mm/mremap.c b/mm/mremap.c
83903 index 463a257..c0c7a92 100644
83904 --- a/mm/mremap.c
83905 +++ b/mm/mremap.c
83906 @@ -126,6 +126,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
83907 continue;
83908 pte = ptep_get_and_clear(mm, old_addr, old_pte);
83909 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
83910 +
83911 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
83912 + if (!(__supported_pte_mask & _PAGE_NX) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
83913 + pte = pte_exprotect(pte);
83914 +#endif
83915 +
83916 set_pte_at(mm, new_addr, new_pte, pte);
83917 }
83918
83919 @@ -318,6 +324,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
83920 if (is_vm_hugetlb_page(vma))
83921 goto Einval;
83922
83923 +#ifdef CONFIG_PAX_SEGMEXEC
83924 + if (pax_find_mirror_vma(vma))
83925 + goto Einval;
83926 +#endif
83927 +
83928 /* We can't remap across vm area boundaries */
83929 if (old_len > vma->vm_end - addr)
83930 goto Efault;
83931 @@ -373,20 +384,25 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
83932 unsigned long ret = -EINVAL;
83933 unsigned long charged = 0;
83934 unsigned long map_flags;
83935 + unsigned long pax_task_size = TASK_SIZE;
83936
83937 if (new_addr & ~PAGE_MASK)
83938 goto out;
83939
83940 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
83941 +#ifdef CONFIG_PAX_SEGMEXEC
83942 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
83943 + pax_task_size = SEGMEXEC_TASK_SIZE;
83944 +#endif
83945 +
83946 + pax_task_size -= PAGE_SIZE;
83947 +
83948 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
83949 goto out;
83950
83951 /* Check if the location we're moving into overlaps the
83952 * old location at all, and fail if it does.
83953 */
83954 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
83955 - goto out;
83956 -
83957 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
83958 + if (addr + old_len > new_addr && new_addr + new_len > addr)
83959 goto out;
83960
83961 ret = do_munmap(mm, new_addr, new_len);
83962 @@ -455,6 +471,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83963 unsigned long ret = -EINVAL;
83964 unsigned long charged = 0;
83965 bool locked = false;
83966 + unsigned long pax_task_size = TASK_SIZE;
83967
83968 down_write(&current->mm->mmap_sem);
83969
83970 @@ -475,6 +492,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83971 if (!new_len)
83972 goto out;
83973
83974 +#ifdef CONFIG_PAX_SEGMEXEC
83975 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
83976 + pax_task_size = SEGMEXEC_TASK_SIZE;
83977 +#endif
83978 +
83979 + pax_task_size -= PAGE_SIZE;
83980 +
83981 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
83982 + old_len > pax_task_size || addr > pax_task_size-old_len)
83983 + goto out;
83984 +
83985 if (flags & MREMAP_FIXED) {
83986 if (flags & MREMAP_MAYMOVE)
83987 ret = mremap_to(addr, old_len, new_addr, new_len,
83988 @@ -524,6 +552,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83989 new_addr = addr;
83990 }
83991 ret = addr;
83992 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
83993 goto out;
83994 }
83995 }
83996 @@ -547,7 +576,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
83997 goto out;
83998 }
83999
84000 + map_flags = vma->vm_flags;
84001 ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
84002 + if (!(ret & ~PAGE_MASK)) {
84003 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
84004 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
84005 + }
84006 }
84007 out:
84008 if (ret & ~PAGE_MASK)
84009 diff --git a/mm/nommu.c b/mm/nommu.c
84010 index 298884d..5f74980 100644
84011 --- a/mm/nommu.c
84012 +++ b/mm/nommu.c
84013 @@ -65,7 +65,6 @@ int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
84014 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
84015 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
84016 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
84017 -int heap_stack_gap = 0;
84018
84019 atomic_long_t mmap_pages_allocated;
84020
84021 @@ -842,15 +841,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
84022 EXPORT_SYMBOL(find_vma);
84023
84024 /*
84025 - * find a VMA
84026 - * - we don't extend stack VMAs under NOMMU conditions
84027 - */
84028 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
84029 -{
84030 - return find_vma(mm, addr);
84031 -}
84032 -
84033 -/*
84034 * expand a stack to a given address
84035 * - not supported under NOMMU conditions
84036 */
84037 @@ -1561,6 +1551,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
84038
84039 /* most fields are the same, copy all, and then fixup */
84040 *new = *vma;
84041 + INIT_LIST_HEAD(&new->anon_vma_chain);
84042 *region = *vma->vm_region;
84043 new->vm_region = region;
84044
84045 @@ -1995,8 +1986,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
84046 }
84047 EXPORT_SYMBOL(generic_file_remap_pages);
84048
84049 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
84050 - unsigned long addr, void *buf, int len, int write)
84051 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
84052 + unsigned long addr, void *buf, size_t len, int write)
84053 {
84054 struct vm_area_struct *vma;
84055
84056 @@ -2037,8 +2028,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
84057 *
84058 * The caller must hold a reference on @mm.
84059 */
84060 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
84061 - void *buf, int len, int write)
84062 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
84063 + void *buf, size_t len, int write)
84064 {
84065 return __access_remote_vm(NULL, mm, addr, buf, len, write);
84066 }
84067 @@ -2047,7 +2038,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
84068 * Access another process' address space.
84069 * - source/target buffer must be kernel space
84070 */
84071 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
84072 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
84073 {
84074 struct mm_struct *mm;
84075
84076 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
84077 index 4514ad7..92eaa1c 100644
84078 --- a/mm/page-writeback.c
84079 +++ b/mm/page-writeback.c
84080 @@ -659,7 +659,7 @@ unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty)
84081 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
84082 * - the bdi dirty thresh drops quickly due to change of JBOD workload
84083 */
84084 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
84085 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
84086 unsigned long thresh,
84087 unsigned long bg_thresh,
84088 unsigned long dirty,
84089 @@ -1634,7 +1634,7 @@ ratelimit_handler(struct notifier_block *self, unsigned long action,
84090 }
84091 }
84092
84093 -static struct notifier_block __cpuinitdata ratelimit_nb = {
84094 +static struct notifier_block ratelimit_nb = {
84095 .notifier_call = ratelimit_handler,
84096 .next = NULL,
84097 };
84098 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
84099 index c3edb62..2d60097 100644
84100 --- a/mm/page_alloc.c
84101 +++ b/mm/page_alloc.c
84102 @@ -60,6 +60,7 @@
84103 #include <linux/page-debug-flags.h>
84104 #include <linux/hugetlb.h>
84105 #include <linux/sched/rt.h>
84106 +#include <linux/random.h>
84107
84108 #include <asm/tlbflush.h>
84109 #include <asm/div64.h>
84110 @@ -345,7 +346,7 @@ out:
84111 * This usage means that zero-order pages may not be compound.
84112 */
84113
84114 -static void free_compound_page(struct page *page)
84115 +void free_compound_page(struct page *page)
84116 {
84117 __free_pages_ok(page, compound_order(page));
84118 }
84119 @@ -702,6 +703,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
84120 int i;
84121 int bad = 0;
84122
84123 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
84124 + unsigned long index = 1UL << order;
84125 +#endif
84126 +
84127 trace_mm_page_free(page, order);
84128 kmemcheck_free_shadow(page, order);
84129
84130 @@ -717,6 +722,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
84131 debug_check_no_obj_freed(page_address(page),
84132 PAGE_SIZE << order);
84133 }
84134 +
84135 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
84136 + for (; index; --index)
84137 + sanitize_highpage(page + index - 1);
84138 +#endif
84139 +
84140 arch_free_page(page, order);
84141 kernel_map_pages(page, 1 << order, 0);
84142
84143 @@ -739,6 +750,19 @@ static void __free_pages_ok(struct page *page, unsigned int order)
84144 local_irq_restore(flags);
84145 }
84146
84147 +#ifdef CONFIG_PAX_LATENT_ENTROPY
84148 +bool __meminitdata extra_latent_entropy;
84149 +
84150 +static int __init setup_pax_extra_latent_entropy(char *str)
84151 +{
84152 + extra_latent_entropy = true;
84153 + return 0;
84154 +}
84155 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
84156 +
84157 +volatile u64 latent_entropy;
84158 +#endif
84159 +
84160 /*
84161 * Read access to zone->managed_pages is safe because it's unsigned long,
84162 * but we still need to serialize writers. Currently all callers of
84163 @@ -761,6 +785,19 @@ void __meminit __free_pages_bootmem(struct page *page, unsigned int order)
84164 set_page_count(p, 0);
84165 }
84166
84167 +#ifdef CONFIG_PAX_LATENT_ENTROPY
84168 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
84169 + u64 hash = 0;
84170 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
84171 + const u64 *data = lowmem_page_address(page);
84172 +
84173 + for (index = 0; index < end; index++)
84174 + hash ^= hash + data[index];
84175 + latent_entropy ^= hash;
84176 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
84177 + }
84178 +#endif
84179 +
84180 page_zone(page)->managed_pages += 1 << order;
84181 set_page_refcounted(page);
84182 __free_pages(page, order);
84183 @@ -870,8 +907,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
84184 arch_alloc_page(page, order);
84185 kernel_map_pages(page, 1 << order, 1);
84186
84187 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
84188 if (gfp_flags & __GFP_ZERO)
84189 prep_zero_page(page, order, gfp_flags);
84190 +#endif
84191
84192 if (order && (gfp_flags & __GFP_COMP))
84193 prep_compound_page(page, order);
84194 diff --git a/mm/page_io.c b/mm/page_io.c
84195 index a8a3ef4..7260a60 100644
84196 --- a/mm/page_io.c
84197 +++ b/mm/page_io.c
84198 @@ -214,7 +214,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
84199 struct file *swap_file = sis->swap_file;
84200 struct address_space *mapping = swap_file->f_mapping;
84201 struct iovec iov = {
84202 - .iov_base = kmap(page),
84203 + .iov_base = (void __force_user *)kmap(page),
84204 .iov_len = PAGE_SIZE,
84205 };
84206
84207 diff --git a/mm/percpu.c b/mm/percpu.c
84208 index 8c8e08f..73a5cda 100644
84209 --- a/mm/percpu.c
84210 +++ b/mm/percpu.c
84211 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
84212 static unsigned int pcpu_high_unit_cpu __read_mostly;
84213
84214 /* the address of the first chunk which starts with the kernel static area */
84215 -void *pcpu_base_addr __read_mostly;
84216 +void *pcpu_base_addr __read_only;
84217 EXPORT_SYMBOL_GPL(pcpu_base_addr);
84218
84219 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
84220 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
84221 index fd26d04..0cea1b0 100644
84222 --- a/mm/process_vm_access.c
84223 +++ b/mm/process_vm_access.c
84224 @@ -13,6 +13,7 @@
84225 #include <linux/uio.h>
84226 #include <linux/sched.h>
84227 #include <linux/highmem.h>
84228 +#include <linux/security.h>
84229 #include <linux/ptrace.h>
84230 #include <linux/slab.h>
84231 #include <linux/syscalls.h>
84232 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
84233 size_t iov_l_curr_offset = 0;
84234 ssize_t iov_len;
84235
84236 + return -ENOSYS; // PaX: until properly audited
84237 +
84238 /*
84239 * Work out how many pages of struct pages we're going to need
84240 * when eventually calling get_user_pages
84241 */
84242 for (i = 0; i < riovcnt; i++) {
84243 iov_len = rvec[i].iov_len;
84244 - if (iov_len > 0) {
84245 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
84246 - + iov_len)
84247 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
84248 - / PAGE_SIZE + 1;
84249 - nr_pages = max(nr_pages, nr_pages_iov);
84250 - }
84251 + if (iov_len <= 0)
84252 + continue;
84253 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
84254 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
84255 + nr_pages = max(nr_pages, nr_pages_iov);
84256 }
84257
84258 if (nr_pages == 0)
84259 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
84260 goto free_proc_pages;
84261 }
84262
84263 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
84264 + rc = -EPERM;
84265 + goto put_task_struct;
84266 + }
84267 +
84268 mm = mm_access(task, PTRACE_MODE_ATTACH);
84269 if (!mm || IS_ERR(mm)) {
84270 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
84271 diff --git a/mm/rmap.c b/mm/rmap.c
84272 index 6280da8..ecce194 100644
84273 --- a/mm/rmap.c
84274 +++ b/mm/rmap.c
84275 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
84276 struct anon_vma *anon_vma = vma->anon_vma;
84277 struct anon_vma_chain *avc;
84278
84279 +#ifdef CONFIG_PAX_SEGMEXEC
84280 + struct anon_vma_chain *avc_m = NULL;
84281 +#endif
84282 +
84283 might_sleep();
84284 if (unlikely(!anon_vma)) {
84285 struct mm_struct *mm = vma->vm_mm;
84286 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
84287 if (!avc)
84288 goto out_enomem;
84289
84290 +#ifdef CONFIG_PAX_SEGMEXEC
84291 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
84292 + if (!avc_m)
84293 + goto out_enomem_free_avc;
84294 +#endif
84295 +
84296 anon_vma = find_mergeable_anon_vma(vma);
84297 allocated = NULL;
84298 if (!anon_vma) {
84299 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
84300 /* page_table_lock to protect against threads */
84301 spin_lock(&mm->page_table_lock);
84302 if (likely(!vma->anon_vma)) {
84303 +
84304 +#ifdef CONFIG_PAX_SEGMEXEC
84305 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
84306 +
84307 + if (vma_m) {
84308 + BUG_ON(vma_m->anon_vma);
84309 + vma_m->anon_vma = anon_vma;
84310 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
84311 + avc_m = NULL;
84312 + }
84313 +#endif
84314 +
84315 vma->anon_vma = anon_vma;
84316 anon_vma_chain_link(vma, avc, anon_vma);
84317 allocated = NULL;
84318 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
84319
84320 if (unlikely(allocated))
84321 put_anon_vma(allocated);
84322 +
84323 +#ifdef CONFIG_PAX_SEGMEXEC
84324 + if (unlikely(avc_m))
84325 + anon_vma_chain_free(avc_m);
84326 +#endif
84327 +
84328 if (unlikely(avc))
84329 anon_vma_chain_free(avc);
84330 }
84331 return 0;
84332
84333 out_enomem_free_avc:
84334 +
84335 +#ifdef CONFIG_PAX_SEGMEXEC
84336 + if (avc_m)
84337 + anon_vma_chain_free(avc_m);
84338 +#endif
84339 +
84340 anon_vma_chain_free(avc);
84341 out_enomem:
84342 return -ENOMEM;
84343 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
84344 * Attach the anon_vmas from src to dst.
84345 * Returns 0 on success, -ENOMEM on failure.
84346 */
84347 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
84348 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
84349 {
84350 struct anon_vma_chain *avc, *pavc;
84351 struct anon_vma *root = NULL;
84352 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
84353 * the corresponding VMA in the parent process is attached to.
84354 * Returns 0 on success, non-zero on failure.
84355 */
84356 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
84357 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
84358 {
84359 struct anon_vma_chain *avc;
84360 struct anon_vma *anon_vma;
84361 diff --git a/mm/shmem.c b/mm/shmem.c
84362 index 5e6a842..b41916e 100644
84363 --- a/mm/shmem.c
84364 +++ b/mm/shmem.c
84365 @@ -33,7 +33,7 @@
84366 #include <linux/swap.h>
84367 #include <linux/aio.h>
84368
84369 -static struct vfsmount *shm_mnt;
84370 +struct vfsmount *shm_mnt;
84371
84372 #ifdef CONFIG_SHMEM
84373 /*
84374 @@ -77,7 +77,7 @@ static struct vfsmount *shm_mnt;
84375 #define BOGO_DIRENT_SIZE 20
84376
84377 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
84378 -#define SHORT_SYMLINK_LEN 128
84379 +#define SHORT_SYMLINK_LEN 64
84380
84381 /*
84382 * shmem_fallocate and shmem_writepage communicate via inode->i_private
84383 @@ -2203,6 +2203,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
84384 static int shmem_xattr_validate(const char *name)
84385 {
84386 struct { const char *prefix; size_t len; } arr[] = {
84387 +
84388 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
84389 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
84390 +#endif
84391 +
84392 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
84393 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
84394 };
84395 @@ -2258,6 +2263,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
84396 if (err)
84397 return err;
84398
84399 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
84400 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
84401 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
84402 + return -EOPNOTSUPP;
84403 + if (size > 8)
84404 + return -EINVAL;
84405 + }
84406 +#endif
84407 +
84408 return simple_xattr_set(&info->xattrs, name, value, size, flags);
84409 }
84410
84411 @@ -2570,8 +2584,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
84412 int err = -ENOMEM;
84413
84414 /* Round up to L1_CACHE_BYTES to resist false sharing */
84415 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
84416 - L1_CACHE_BYTES), GFP_KERNEL);
84417 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
84418 if (!sbinfo)
84419 return -ENOMEM;
84420
84421 diff --git a/mm/slab.c b/mm/slab.c
84422 index 8ccd296..9645f16 100644
84423 --- a/mm/slab.c
84424 +++ b/mm/slab.c
84425 @@ -366,10 +366,10 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
84426 if ((x)->max_freeable < i) \
84427 (x)->max_freeable = i; \
84428 } while (0)
84429 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
84430 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
84431 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
84432 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
84433 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
84434 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
84435 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
84436 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
84437 #else
84438 #define STATS_INC_ACTIVE(x) do { } while (0)
84439 #define STATS_DEC_ACTIVE(x) do { } while (0)
84440 @@ -477,7 +477,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
84441 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
84442 */
84443 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
84444 - const struct slab *slab, void *obj)
84445 + const struct slab *slab, const void *obj)
84446 {
84447 u32 offset = (obj - slab->s_mem);
84448 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
84449 @@ -1384,7 +1384,7 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
84450 return notifier_from_errno(err);
84451 }
84452
84453 -static struct notifier_block __cpuinitdata cpucache_notifier = {
84454 +static struct notifier_block cpucache_notifier = {
84455 &cpuup_callback, NULL, 0
84456 };
84457
84458 @@ -3800,6 +3800,7 @@ void kfree(const void *objp)
84459
84460 if (unlikely(ZERO_OR_NULL_PTR(objp)))
84461 return;
84462 + VM_BUG_ON(!virt_addr_valid(objp));
84463 local_irq_save(flags);
84464 kfree_debugcheck(objp);
84465 c = virt_to_cache(objp);
84466 @@ -4241,10 +4242,10 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
84467 }
84468 /* cpu stats */
84469 {
84470 - unsigned long allochit = atomic_read(&cachep->allochit);
84471 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
84472 - unsigned long freehit = atomic_read(&cachep->freehit);
84473 - unsigned long freemiss = atomic_read(&cachep->freemiss);
84474 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
84475 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
84476 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
84477 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
84478
84479 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
84480 allochit, allocmiss, freehit, freemiss);
84481 @@ -4476,13 +4477,71 @@ static const struct file_operations proc_slabstats_operations = {
84482 static int __init slab_proc_init(void)
84483 {
84484 #ifdef CONFIG_DEBUG_SLAB_LEAK
84485 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
84486 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
84487 #endif
84488 return 0;
84489 }
84490 module_init(slab_proc_init);
84491 #endif
84492
84493 +bool is_usercopy_object(const void *ptr)
84494 +{
84495 + struct page *page;
84496 + struct kmem_cache *cachep;
84497 +
84498 + if (ZERO_OR_NULL_PTR(ptr))
84499 + return false;
84500 +
84501 + if (!slab_is_available())
84502 + return false;
84503 +
84504 + if (!virt_addr_valid(ptr))
84505 + return false;
84506 +
84507 + page = virt_to_head_page(ptr);
84508 +
84509 + if (!PageSlab(page))
84510 + return false;
84511 +
84512 + cachep = page->slab_cache;
84513 + return cachep->flags & SLAB_USERCOPY;
84514 +}
84515 +
84516 +#ifdef CONFIG_PAX_USERCOPY
84517 +const char *check_heap_object(const void *ptr, unsigned long n)
84518 +{
84519 + struct page *page;
84520 + struct kmem_cache *cachep;
84521 + struct slab *slabp;
84522 + unsigned int objnr;
84523 + unsigned long offset;
84524 +
84525 + if (ZERO_OR_NULL_PTR(ptr))
84526 + return "<null>";
84527 +
84528 + if (!virt_addr_valid(ptr))
84529 + return NULL;
84530 +
84531 + page = virt_to_head_page(ptr);
84532 +
84533 + if (!PageSlab(page))
84534 + return NULL;
84535 +
84536 + cachep = page->slab_cache;
84537 + if (!(cachep->flags & SLAB_USERCOPY))
84538 + return cachep->name;
84539 +
84540 + slabp = page->slab_page;
84541 + objnr = obj_to_index(cachep, slabp, ptr);
84542 + BUG_ON(objnr >= cachep->num);
84543 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
84544 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
84545 + return NULL;
84546 +
84547 + return cachep->name;
84548 +}
84549 +#endif
84550 +
84551 /**
84552 * ksize - get the actual amount of memory allocated for a given object
84553 * @objp: Pointer to the object
84554 diff --git a/mm/slab.h b/mm/slab.h
84555 index f96b49e..5634e90 100644
84556 --- a/mm/slab.h
84557 +++ b/mm/slab.h
84558 @@ -67,7 +67,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
84559
84560 /* Legal flag mask for kmem_cache_create(), for various configurations */
84561 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
84562 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
84563 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | SLAB_USERCOPY)
84564
84565 #if defined(CONFIG_DEBUG_SLAB)
84566 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
84567 @@ -229,6 +229,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
84568 return s;
84569
84570 page = virt_to_head_page(x);
84571 +
84572 + BUG_ON(!PageSlab(page));
84573 +
84574 cachep = page->slab_cache;
84575 if (slab_equal_or_root(cachep, s))
84576 return cachep;
84577 diff --git a/mm/slab_common.c b/mm/slab_common.c
84578 index 2d41450..e22088e 100644
84579 --- a/mm/slab_common.c
84580 +++ b/mm/slab_common.c
84581 @@ -22,7 +22,7 @@
84582
84583 #include "slab.h"
84584
84585 -enum slab_state slab_state;
84586 +enum slab_state slab_state __read_only;
84587 LIST_HEAD(slab_caches);
84588 DEFINE_MUTEX(slab_mutex);
84589 struct kmem_cache *kmem_cache;
84590 @@ -209,7 +209,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
84591
84592 err = __kmem_cache_create(s, flags);
84593 if (!err) {
84594 - s->refcount = 1;
84595 + atomic_set(&s->refcount, 1);
84596 list_add(&s->list, &slab_caches);
84597 memcg_cache_list_add(memcg, s);
84598 } else {
84599 @@ -255,8 +255,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
84600
84601 get_online_cpus();
84602 mutex_lock(&slab_mutex);
84603 - s->refcount--;
84604 - if (!s->refcount) {
84605 + if (atomic_dec_and_test(&s->refcount)) {
84606 list_del(&s->list);
84607
84608 if (!__kmem_cache_shutdown(s)) {
84609 @@ -302,7 +301,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
84610 panic("Creation of kmalloc slab %s size=%zu failed. Reason %d\n",
84611 name, size, err);
84612
84613 - s->refcount = -1; /* Exempt from merging for now */
84614 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
84615 }
84616
84617 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
84618 @@ -315,7 +314,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
84619
84620 create_boot_cache(s, name, size, flags);
84621 list_add(&s->list, &slab_caches);
84622 - s->refcount = 1;
84623 + atomic_set(&s->refcount, 1);
84624 return s;
84625 }
84626
84627 @@ -327,6 +326,11 @@ struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
84628 EXPORT_SYMBOL(kmalloc_dma_caches);
84629 #endif
84630
84631 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84632 +struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
84633 +EXPORT_SYMBOL(kmalloc_usercopy_caches);
84634 +#endif
84635 +
84636 /*
84637 * Conversion table for small slabs sizes / 8 to the index in the
84638 * kmalloc array. This is necessary for slabs < 192 since we have non power
84639 @@ -391,6 +395,13 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags)
84640 return kmalloc_dma_caches[index];
84641
84642 #endif
84643 +
84644 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84645 + if (unlikely((flags & GFP_USERCOPY)))
84646 + return kmalloc_usercopy_caches[index];
84647 +
84648 +#endif
84649 +
84650 return kmalloc_caches[index];
84651 }
84652
84653 @@ -447,7 +458,7 @@ void __init create_kmalloc_caches(unsigned long flags)
84654 for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
84655 if (!kmalloc_caches[i]) {
84656 kmalloc_caches[i] = create_kmalloc_cache(NULL,
84657 - 1 << i, flags);
84658 + 1 << i, SLAB_USERCOPY | flags);
84659 }
84660
84661 /*
84662 @@ -456,10 +467,10 @@ void __init create_kmalloc_caches(unsigned long flags)
84663 * earlier power of two caches
84664 */
84665 if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[1] && i == 6)
84666 - kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, flags);
84667 + kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, SLAB_USERCOPY | flags);
84668
84669 if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[2] && i == 7)
84670 - kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, flags);
84671 + kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, SLAB_USERCOPY | flags);
84672 }
84673
84674 /* Kmalloc array is now usable */
84675 @@ -492,6 +503,23 @@ void __init create_kmalloc_caches(unsigned long flags)
84676 }
84677 }
84678 #endif
84679 +
84680 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84681 + for (i = 0; i <= KMALLOC_SHIFT_HIGH; i++) {
84682 + struct kmem_cache *s = kmalloc_caches[i];
84683 +
84684 + if (s) {
84685 + int size = kmalloc_size(i);
84686 + char *n = kasprintf(GFP_NOWAIT,
84687 + "usercopy-kmalloc-%d", size);
84688 +
84689 + BUG_ON(!n);
84690 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(n,
84691 + size, SLAB_USERCOPY | flags);
84692 + }
84693 + }
84694 +#endif
84695 +
84696 }
84697 #endif /* !CONFIG_SLOB */
84698
84699 diff --git a/mm/slob.c b/mm/slob.c
84700 index eeed4a0..6ee34ec 100644
84701 --- a/mm/slob.c
84702 +++ b/mm/slob.c
84703 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
84704 /*
84705 * Return the size of a slob block.
84706 */
84707 -static slobidx_t slob_units(slob_t *s)
84708 +static slobidx_t slob_units(const slob_t *s)
84709 {
84710 if (s->units > 0)
84711 return s->units;
84712 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
84713 /*
84714 * Return the next free slob block pointer after this one.
84715 */
84716 -static slob_t *slob_next(slob_t *s)
84717 +static slob_t *slob_next(const slob_t *s)
84718 {
84719 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
84720 slobidx_t next;
84721 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
84722 /*
84723 * Returns true if s is the last free block in its page.
84724 */
84725 -static int slob_last(slob_t *s)
84726 +static int slob_last(const slob_t *s)
84727 {
84728 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
84729 }
84730
84731 -static void *slob_new_pages(gfp_t gfp, int order, int node)
84732 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
84733 {
84734 - void *page;
84735 + struct page *page;
84736
84737 #ifdef CONFIG_NUMA
84738 if (node != NUMA_NO_NODE)
84739 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
84740 if (!page)
84741 return NULL;
84742
84743 - return page_address(page);
84744 + __SetPageSlab(page);
84745 + return page;
84746 }
84747
84748 -static void slob_free_pages(void *b, int order)
84749 +static void slob_free_pages(struct page *sp, int order)
84750 {
84751 if (current->reclaim_state)
84752 current->reclaim_state->reclaimed_slab += 1 << order;
84753 - free_pages((unsigned long)b, order);
84754 + __ClearPageSlab(sp);
84755 + reset_page_mapcount(sp);
84756 + sp->private = 0;
84757 + __free_pages(sp, order);
84758 }
84759
84760 /*
84761 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
84762
84763 /* Not enough space: must allocate a new page */
84764 if (!b) {
84765 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
84766 - if (!b)
84767 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
84768 + if (!sp)
84769 return NULL;
84770 - sp = virt_to_page(b);
84771 - __SetPageSlab(sp);
84772 + b = page_address(sp);
84773
84774 spin_lock_irqsave(&slob_lock, flags);
84775 sp->units = SLOB_UNITS(PAGE_SIZE);
84776 sp->freelist = b;
84777 + sp->private = 0;
84778 INIT_LIST_HEAD(&sp->list);
84779 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
84780 set_slob_page_free(sp, slob_list);
84781 @@ -359,9 +363,7 @@ static void slob_free(void *block, int size)
84782 if (slob_page_free(sp))
84783 clear_slob_page_free(sp);
84784 spin_unlock_irqrestore(&slob_lock, flags);
84785 - __ClearPageSlab(sp);
84786 - page_mapcount_reset(sp);
84787 - slob_free_pages(b, 0);
84788 + slob_free_pages(sp, 0);
84789 return;
84790 }
84791
84792 @@ -424,11 +426,10 @@ out:
84793 */
84794
84795 static __always_inline void *
84796 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84797 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
84798 {
84799 - unsigned int *m;
84800 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84801 - void *ret;
84802 + slob_t *m;
84803 + void *ret = NULL;
84804
84805 gfp &= gfp_allowed_mask;
84806
84807 @@ -442,23 +443,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84808
84809 if (!m)
84810 return NULL;
84811 - *m = size;
84812 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
84813 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
84814 + m[0].units = size;
84815 + m[1].units = align;
84816 ret = (void *)m + align;
84817
84818 trace_kmalloc_node(caller, ret,
84819 size, size + align, gfp, node);
84820 } else {
84821 unsigned int order = get_order(size);
84822 + struct page *page;
84823
84824 if (likely(order))
84825 gfp |= __GFP_COMP;
84826 - ret = slob_new_pages(gfp, order, node);
84827 + page = slob_new_pages(gfp, order, node);
84828 + if (page) {
84829 + ret = page_address(page);
84830 + page->private = size;
84831 + }
84832
84833 trace_kmalloc_node(caller, ret,
84834 size, PAGE_SIZE << order, gfp, node);
84835 }
84836
84837 - kmemleak_alloc(ret, size, 1, gfp);
84838 + return ret;
84839 +}
84840 +
84841 +static __always_inline void *
84842 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
84843 +{
84844 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84845 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
84846 +
84847 + if (!ZERO_OR_NULL_PTR(ret))
84848 + kmemleak_alloc(ret, size, 1, gfp);
84849 return ret;
84850 }
84851
84852 @@ -493,34 +512,112 @@ void kfree(const void *block)
84853 return;
84854 kmemleak_free(block);
84855
84856 + VM_BUG_ON(!virt_addr_valid(block));
84857 sp = virt_to_page(block);
84858 - if (PageSlab(sp)) {
84859 + VM_BUG_ON(!PageSlab(sp));
84860 + if (!sp->private) {
84861 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84862 - unsigned int *m = (unsigned int *)(block - align);
84863 - slob_free(m, *m + align);
84864 - } else
84865 + slob_t *m = (slob_t *)(block - align);
84866 + slob_free(m, m[0].units + align);
84867 + } else {
84868 + __ClearPageSlab(sp);
84869 + reset_page_mapcount(sp);
84870 + sp->private = 0;
84871 __free_pages(sp, compound_order(sp));
84872 + }
84873 }
84874 EXPORT_SYMBOL(kfree);
84875
84876 +bool is_usercopy_object(const void *ptr)
84877 +{
84878 + if (!slab_is_available())
84879 + return false;
84880 +
84881 + // PAX: TODO
84882 +
84883 + return false;
84884 +}
84885 +
84886 +#ifdef CONFIG_PAX_USERCOPY
84887 +const char *check_heap_object(const void *ptr, unsigned long n)
84888 +{
84889 + struct page *page;
84890 + const slob_t *free;
84891 + const void *base;
84892 + unsigned long flags;
84893 +
84894 + if (ZERO_OR_NULL_PTR(ptr))
84895 + return "<null>";
84896 +
84897 + if (!virt_addr_valid(ptr))
84898 + return NULL;
84899 +
84900 + page = virt_to_head_page(ptr);
84901 + if (!PageSlab(page))
84902 + return NULL;
84903 +
84904 + if (page->private) {
84905 + base = page;
84906 + if (base <= ptr && n <= page->private - (ptr - base))
84907 + return NULL;
84908 + return "<slob>";
84909 + }
84910 +
84911 + /* some tricky double walking to find the chunk */
84912 + spin_lock_irqsave(&slob_lock, flags);
84913 + base = (void *)((unsigned long)ptr & PAGE_MASK);
84914 + free = page->freelist;
84915 +
84916 + while (!slob_last(free) && (void *)free <= ptr) {
84917 + base = free + slob_units(free);
84918 + free = slob_next(free);
84919 + }
84920 +
84921 + while (base < (void *)free) {
84922 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
84923 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
84924 + int offset;
84925 +
84926 + if (ptr < base + align)
84927 + break;
84928 +
84929 + offset = ptr - base - align;
84930 + if (offset >= m) {
84931 + base += size;
84932 + continue;
84933 + }
84934 +
84935 + if (n > m - offset)
84936 + break;
84937 +
84938 + spin_unlock_irqrestore(&slob_lock, flags);
84939 + return NULL;
84940 + }
84941 +
84942 + spin_unlock_irqrestore(&slob_lock, flags);
84943 + return "<slob>";
84944 +}
84945 +#endif
84946 +
84947 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
84948 size_t ksize(const void *block)
84949 {
84950 struct page *sp;
84951 int align;
84952 - unsigned int *m;
84953 + slob_t *m;
84954
84955 BUG_ON(!block);
84956 if (unlikely(block == ZERO_SIZE_PTR))
84957 return 0;
84958
84959 sp = virt_to_page(block);
84960 - if (unlikely(!PageSlab(sp)))
84961 - return PAGE_SIZE << compound_order(sp);
84962 + VM_BUG_ON(!PageSlab(sp));
84963 + if (sp->private)
84964 + return sp->private;
84965
84966 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
84967 - m = (unsigned int *)(block - align);
84968 - return SLOB_UNITS(*m) * SLOB_UNIT;
84969 + m = (slob_t *)(block - align);
84970 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
84971 }
84972 EXPORT_SYMBOL(ksize);
84973
84974 @@ -536,23 +633,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
84975
84976 void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
84977 {
84978 - void *b;
84979 + void *b = NULL;
84980
84981 flags &= gfp_allowed_mask;
84982
84983 lockdep_trace_alloc(flags);
84984
84985 +#ifdef CONFIG_PAX_USERCOPY_SLABS
84986 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
84987 +#else
84988 if (c->size < PAGE_SIZE) {
84989 b = slob_alloc(c->size, flags, c->align, node);
84990 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
84991 SLOB_UNITS(c->size) * SLOB_UNIT,
84992 flags, node);
84993 } else {
84994 - b = slob_new_pages(flags, get_order(c->size), node);
84995 + struct page *sp;
84996 +
84997 + sp = slob_new_pages(flags, get_order(c->size), node);
84998 + if (sp) {
84999 + b = page_address(sp);
85000 + sp->private = c->size;
85001 + }
85002 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
85003 PAGE_SIZE << get_order(c->size),
85004 flags, node);
85005 }
85006 +#endif
85007
85008 if (c->ctor)
85009 c->ctor(b);
85010 @@ -564,10 +671,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
85011
85012 static void __kmem_cache_free(void *b, int size)
85013 {
85014 - if (size < PAGE_SIZE)
85015 + struct page *sp;
85016 +
85017 + sp = virt_to_page(b);
85018 + BUG_ON(!PageSlab(sp));
85019 + if (!sp->private)
85020 slob_free(b, size);
85021 else
85022 - slob_free_pages(b, get_order(size));
85023 + slob_free_pages(sp, get_order(size));
85024 }
85025
85026 static void kmem_rcu_free(struct rcu_head *head)
85027 @@ -580,17 +691,31 @@ static void kmem_rcu_free(struct rcu_head *head)
85028
85029 void kmem_cache_free(struct kmem_cache *c, void *b)
85030 {
85031 + int size = c->size;
85032 +
85033 +#ifdef CONFIG_PAX_USERCOPY_SLABS
85034 + if (size + c->align < PAGE_SIZE) {
85035 + size += c->align;
85036 + b -= c->align;
85037 + }
85038 +#endif
85039 +
85040 kmemleak_free_recursive(b, c->flags);
85041 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
85042 struct slob_rcu *slob_rcu;
85043 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
85044 - slob_rcu->size = c->size;
85045 + slob_rcu = b + (size - sizeof(struct slob_rcu));
85046 + slob_rcu->size = size;
85047 call_rcu(&slob_rcu->head, kmem_rcu_free);
85048 } else {
85049 - __kmem_cache_free(b, c->size);
85050 + __kmem_cache_free(b, size);
85051 }
85052
85053 +#ifdef CONFIG_PAX_USERCOPY_SLABS
85054 + trace_kfree(_RET_IP_, b);
85055 +#else
85056 trace_kmem_cache_free(_RET_IP_, b);
85057 +#endif
85058 +
85059 }
85060 EXPORT_SYMBOL(kmem_cache_free);
85061
85062 diff --git a/mm/slub.c b/mm/slub.c
85063 index 57707f0..c28619b 100644
85064 --- a/mm/slub.c
85065 +++ b/mm/slub.c
85066 @@ -198,7 +198,7 @@ struct track {
85067
85068 enum track_item { TRACK_ALLOC, TRACK_FREE };
85069
85070 -#ifdef CONFIG_SYSFS
85071 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
85072 static int sysfs_slab_add(struct kmem_cache *);
85073 static int sysfs_slab_alias(struct kmem_cache *, const char *);
85074 static void sysfs_slab_remove(struct kmem_cache *);
85075 @@ -519,7 +519,7 @@ static void print_track(const char *s, struct track *t)
85076 if (!t->addr)
85077 return;
85078
85079 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
85080 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
85081 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
85082 #ifdef CONFIG_STACKTRACE
85083 {
85084 @@ -2661,7 +2661,7 @@ static int slub_min_objects;
85085 * Merge control. If this is set then no merging of slab caches will occur.
85086 * (Could be removed. This was introduced to pacify the merge skeptics.)
85087 */
85088 -static int slub_nomerge;
85089 +static int slub_nomerge = 1;
85090
85091 /*
85092 * Calculate the order of allocation given an slab object size.
85093 @@ -3283,6 +3283,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
85094 EXPORT_SYMBOL(__kmalloc_node);
85095 #endif
85096
85097 +bool is_usercopy_object(const void *ptr)
85098 +{
85099 + struct page *page;
85100 + struct kmem_cache *s;
85101 +
85102 + if (ZERO_OR_NULL_PTR(ptr))
85103 + return false;
85104 +
85105 + if (!slab_is_available())
85106 + return false;
85107 +
85108 + if (!virt_addr_valid(ptr))
85109 + return false;
85110 +
85111 + page = virt_to_head_page(ptr);
85112 +
85113 + if (!PageSlab(page))
85114 + return false;
85115 +
85116 + s = page->slab_cache;
85117 + return s->flags & SLAB_USERCOPY;
85118 +}
85119 +
85120 +#ifdef CONFIG_PAX_USERCOPY
85121 +const char *check_heap_object(const void *ptr, unsigned long n)
85122 +{
85123 + struct page *page;
85124 + struct kmem_cache *s;
85125 + unsigned long offset;
85126 +
85127 + if (ZERO_OR_NULL_PTR(ptr))
85128 + return "<null>";
85129 +
85130 + if (!virt_addr_valid(ptr))
85131 + return NULL;
85132 +
85133 + page = virt_to_head_page(ptr);
85134 +
85135 + if (!PageSlab(page))
85136 + return NULL;
85137 +
85138 + s = page->slab_cache;
85139 + if (!(s->flags & SLAB_USERCOPY))
85140 + return s->name;
85141 +
85142 + offset = (ptr - page_address(page)) % s->size;
85143 + if (offset <= s->object_size && n <= s->object_size - offset)
85144 + return NULL;
85145 +
85146 + return s->name;
85147 +}
85148 +#endif
85149 +
85150 size_t ksize(const void *object)
85151 {
85152 struct page *page;
85153 @@ -3347,6 +3400,7 @@ void kfree(const void *x)
85154 if (unlikely(ZERO_OR_NULL_PTR(x)))
85155 return;
85156
85157 + VM_BUG_ON(!virt_addr_valid(x));
85158 page = virt_to_head_page(x);
85159 if (unlikely(!PageSlab(page))) {
85160 BUG_ON(!PageCompound(page));
85161 @@ -3652,7 +3706,7 @@ static int slab_unmergeable(struct kmem_cache *s)
85162 /*
85163 * We may have set a slab to be unmergeable during bootstrap.
85164 */
85165 - if (s->refcount < 0)
85166 + if (atomic_read(&s->refcount) < 0)
85167 return 1;
85168
85169 return 0;
85170 @@ -3710,7 +3764,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
85171
85172 s = find_mergeable(memcg, size, align, flags, name, ctor);
85173 if (s) {
85174 - s->refcount++;
85175 + atomic_inc(&s->refcount);
85176 /*
85177 * Adjust the object sizes so that we clear
85178 * the complete object on kzalloc.
85179 @@ -3719,7 +3773,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
85180 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
85181
85182 if (sysfs_slab_alias(s, name)) {
85183 - s->refcount--;
85184 + atomic_dec(&s->refcount);
85185 s = NULL;
85186 }
85187 }
85188 @@ -3781,7 +3835,7 @@ static int __cpuinit slab_cpuup_callback(struct notifier_block *nfb,
85189 return NOTIFY_OK;
85190 }
85191
85192 -static struct notifier_block __cpuinitdata slab_notifier = {
85193 +static struct notifier_block slab_notifier = {
85194 .notifier_call = slab_cpuup_callback
85195 };
85196
85197 @@ -3839,7 +3893,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
85198 }
85199 #endif
85200
85201 -#ifdef CONFIG_SYSFS
85202 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
85203 static int count_inuse(struct page *page)
85204 {
85205 return page->inuse;
85206 @@ -4226,12 +4280,12 @@ static void resiliency_test(void)
85207 validate_slab_cache(kmalloc_caches[9]);
85208 }
85209 #else
85210 -#ifdef CONFIG_SYSFS
85211 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
85212 static void resiliency_test(void) {};
85213 #endif
85214 #endif
85215
85216 -#ifdef CONFIG_SYSFS
85217 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
85218 enum slab_stat_type {
85219 SL_ALL, /* All slabs */
85220 SL_PARTIAL, /* Only partially allocated slabs */
85221 @@ -4475,7 +4529,7 @@ SLAB_ATTR_RO(ctor);
85222
85223 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
85224 {
85225 - return sprintf(buf, "%d\n", s->refcount - 1);
85226 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
85227 }
85228 SLAB_ATTR_RO(aliases);
85229
85230 @@ -4563,6 +4617,14 @@ static ssize_t cache_dma_show(struct kmem_cache *s, char *buf)
85231 SLAB_ATTR_RO(cache_dma);
85232 #endif
85233
85234 +#ifdef CONFIG_PAX_USERCOPY_SLABS
85235 +static ssize_t usercopy_show(struct kmem_cache *s, char *buf)
85236 +{
85237 + return sprintf(buf, "%d\n", !!(s->flags & SLAB_USERCOPY));
85238 +}
85239 +SLAB_ATTR_RO(usercopy);
85240 +#endif
85241 +
85242 static ssize_t destroy_by_rcu_show(struct kmem_cache *s, char *buf)
85243 {
85244 return sprintf(buf, "%d\n", !!(s->flags & SLAB_DESTROY_BY_RCU));
85245 @@ -4897,6 +4959,9 @@ static struct attribute *slab_attrs[] = {
85246 #ifdef CONFIG_ZONE_DMA
85247 &cache_dma_attr.attr,
85248 #endif
85249 +#ifdef CONFIG_PAX_USERCOPY_SLABS
85250 + &usercopy_attr.attr,
85251 +#endif
85252 #ifdef CONFIG_NUMA
85253 &remote_node_defrag_ratio_attr.attr,
85254 #endif
85255 @@ -5128,6 +5193,7 @@ static char *create_unique_id(struct kmem_cache *s)
85256 return name;
85257 }
85258
85259 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
85260 static int sysfs_slab_add(struct kmem_cache *s)
85261 {
85262 int err;
85263 @@ -5151,7 +5217,7 @@ static int sysfs_slab_add(struct kmem_cache *s)
85264 }
85265
85266 s->kobj.kset = slab_kset;
85267 - err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, name);
85268 + err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, "%s", name);
85269 if (err) {
85270 kobject_put(&s->kobj);
85271 return err;
85272 @@ -5185,6 +5251,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
85273 kobject_del(&s->kobj);
85274 kobject_put(&s->kobj);
85275 }
85276 +#endif
85277
85278 /*
85279 * Need to buffer aliases during bootup until sysfs becomes
85280 @@ -5198,6 +5265,7 @@ struct saved_alias {
85281
85282 static struct saved_alias *alias_list;
85283
85284 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
85285 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
85286 {
85287 struct saved_alias *al;
85288 @@ -5220,6 +5288,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
85289 alias_list = al;
85290 return 0;
85291 }
85292 +#endif
85293
85294 static int __init slab_sysfs_init(void)
85295 {
85296 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
85297 index 27eeab3..7c3f7f2 100644
85298 --- a/mm/sparse-vmemmap.c
85299 +++ b/mm/sparse-vmemmap.c
85300 @@ -130,7 +130,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
85301 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
85302 if (!p)
85303 return NULL;
85304 - pud_populate(&init_mm, pud, p);
85305 + pud_populate_kernel(&init_mm, pud, p);
85306 }
85307 return pud;
85308 }
85309 @@ -142,7 +142,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
85310 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
85311 if (!p)
85312 return NULL;
85313 - pgd_populate(&init_mm, pgd, p);
85314 + pgd_populate_kernel(&init_mm, pgd, p);
85315 }
85316 return pgd;
85317 }
85318 diff --git a/mm/sparse.c b/mm/sparse.c
85319 index 1c91f0d3..485470a 100644
85320 --- a/mm/sparse.c
85321 +++ b/mm/sparse.c
85322 @@ -761,7 +761,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
85323
85324 for (i = 0; i < PAGES_PER_SECTION; i++) {
85325 if (PageHWPoison(&memmap[i])) {
85326 - atomic_long_sub(1, &num_poisoned_pages);
85327 + atomic_long_sub_unchecked(1, &num_poisoned_pages);
85328 ClearPageHWPoison(&memmap[i]);
85329 }
85330 }
85331 diff --git a/mm/swap.c b/mm/swap.c
85332 index dfd7d71..ccdf688 100644
85333 --- a/mm/swap.c
85334 +++ b/mm/swap.c
85335 @@ -31,6 +31,7 @@
85336 #include <linux/memcontrol.h>
85337 #include <linux/gfp.h>
85338 #include <linux/uio.h>
85339 +#include <linux/hugetlb.h>
85340
85341 #include "internal.h"
85342
85343 @@ -73,6 +74,8 @@ static void __put_compound_page(struct page *page)
85344
85345 __page_cache_release(page);
85346 dtor = get_compound_page_dtor(page);
85347 + if (!PageHuge(page))
85348 + BUG_ON(dtor != free_compound_page);
85349 (*dtor)(page);
85350 }
85351
85352 diff --git a/mm/swapfile.c b/mm/swapfile.c
85353 index 746af55b..7ac94ae 100644
85354 --- a/mm/swapfile.c
85355 +++ b/mm/swapfile.c
85356 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(swapon_mutex);
85357
85358 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
85359 /* Activity counter to indicate that a swapon or swapoff has occurred */
85360 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
85361 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
85362
85363 static inline unsigned char swap_count(unsigned char ent)
85364 {
85365 @@ -1684,7 +1684,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
85366 }
85367 filp_close(swap_file, NULL);
85368 err = 0;
85369 - atomic_inc(&proc_poll_event);
85370 + atomic_inc_unchecked(&proc_poll_event);
85371 wake_up_interruptible(&proc_poll_wait);
85372
85373 out_dput:
85374 @@ -1701,8 +1701,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
85375
85376 poll_wait(file, &proc_poll_wait, wait);
85377
85378 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
85379 - seq->poll_event = atomic_read(&proc_poll_event);
85380 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
85381 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
85382 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
85383 }
85384
85385 @@ -1800,7 +1800,7 @@ static int swaps_open(struct inode *inode, struct file *file)
85386 return ret;
85387
85388 seq = file->private_data;
85389 - seq->poll_event = atomic_read(&proc_poll_event);
85390 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
85391 return 0;
85392 }
85393
85394 @@ -2143,7 +2143,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
85395 (frontswap_map) ? "FS" : "");
85396
85397 mutex_unlock(&swapon_mutex);
85398 - atomic_inc(&proc_poll_event);
85399 + atomic_inc_unchecked(&proc_poll_event);
85400 wake_up_interruptible(&proc_poll_wait);
85401
85402 if (S_ISREG(inode->i_mode))
85403 diff --git a/mm/util.c b/mm/util.c
85404 index ab1424d..7c5bd5a 100644
85405 --- a/mm/util.c
85406 +++ b/mm/util.c
85407 @@ -294,6 +294,12 @@ done:
85408 void arch_pick_mmap_layout(struct mm_struct *mm)
85409 {
85410 mm->mmap_base = TASK_UNMAPPED_BASE;
85411 +
85412 +#ifdef CONFIG_PAX_RANDMMAP
85413 + if (mm->pax_flags & MF_PAX_RANDMMAP)
85414 + mm->mmap_base += mm->delta_mmap;
85415 +#endif
85416 +
85417 mm->get_unmapped_area = arch_get_unmapped_area;
85418 mm->unmap_area = arch_unmap_area;
85419 }
85420 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
85421 index d365724..6cae7c2 100644
85422 --- a/mm/vmalloc.c
85423 +++ b/mm/vmalloc.c
85424 @@ -59,8 +59,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
85425
85426 pte = pte_offset_kernel(pmd, addr);
85427 do {
85428 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
85429 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
85430 +
85431 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
85432 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
85433 + BUG_ON(!pte_exec(*pte));
85434 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
85435 + continue;
85436 + }
85437 +#endif
85438 +
85439 + {
85440 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
85441 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
85442 + }
85443 } while (pte++, addr += PAGE_SIZE, addr != end);
85444 }
85445
85446 @@ -120,16 +131,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
85447 pte = pte_alloc_kernel(pmd, addr);
85448 if (!pte)
85449 return -ENOMEM;
85450 +
85451 + pax_open_kernel();
85452 do {
85453 struct page *page = pages[*nr];
85454
85455 - if (WARN_ON(!pte_none(*pte)))
85456 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
85457 + if (pgprot_val(prot) & _PAGE_NX)
85458 +#endif
85459 +
85460 + if (!pte_none(*pte)) {
85461 + pax_close_kernel();
85462 + WARN_ON(1);
85463 return -EBUSY;
85464 - if (WARN_ON(!page))
85465 + }
85466 + if (!page) {
85467 + pax_close_kernel();
85468 + WARN_ON(1);
85469 return -ENOMEM;
85470 + }
85471 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
85472 (*nr)++;
85473 } while (pte++, addr += PAGE_SIZE, addr != end);
85474 + pax_close_kernel();
85475 return 0;
85476 }
85477
85478 @@ -139,7 +163,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
85479 pmd_t *pmd;
85480 unsigned long next;
85481
85482 - pmd = pmd_alloc(&init_mm, pud, addr);
85483 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
85484 if (!pmd)
85485 return -ENOMEM;
85486 do {
85487 @@ -156,7 +180,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
85488 pud_t *pud;
85489 unsigned long next;
85490
85491 - pud = pud_alloc(&init_mm, pgd, addr);
85492 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
85493 if (!pud)
85494 return -ENOMEM;
85495 do {
85496 @@ -216,6 +240,12 @@ int is_vmalloc_or_module_addr(const void *x)
85497 if (addr >= MODULES_VADDR && addr < MODULES_END)
85498 return 1;
85499 #endif
85500 +
85501 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
85502 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
85503 + return 1;
85504 +#endif
85505 +
85506 return is_vmalloc_addr(x);
85507 }
85508
85509 @@ -236,8 +266,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
85510
85511 if (!pgd_none(*pgd)) {
85512 pud_t *pud = pud_offset(pgd, addr);
85513 +#ifdef CONFIG_X86
85514 + if (!pud_large(*pud))
85515 +#endif
85516 if (!pud_none(*pud)) {
85517 pmd_t *pmd = pmd_offset(pud, addr);
85518 +#ifdef CONFIG_X86
85519 + if (!pmd_large(*pmd))
85520 +#endif
85521 if (!pmd_none(*pmd)) {
85522 pte_t *ptep, pte;
85523
85524 @@ -339,7 +375,7 @@ static void purge_vmap_area_lazy(void);
85525 * Allocate a region of KVA of the specified size and alignment, within the
85526 * vstart and vend.
85527 */
85528 -static struct vmap_area *alloc_vmap_area(unsigned long size,
85529 +static __size_overflow(1) struct vmap_area *alloc_vmap_area(unsigned long size,
85530 unsigned long align,
85531 unsigned long vstart, unsigned long vend,
85532 int node, gfp_t gfp_mask)
85533 @@ -1337,6 +1373,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
85534 struct vm_struct *area;
85535
85536 BUG_ON(in_interrupt());
85537 +
85538 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85539 + if (flags & VM_KERNEXEC) {
85540 + if (start != VMALLOC_START || end != VMALLOC_END)
85541 + return NULL;
85542 + start = (unsigned long)MODULES_EXEC_VADDR;
85543 + end = (unsigned long)MODULES_EXEC_END;
85544 + }
85545 +#endif
85546 +
85547 if (flags & VM_IOREMAP) {
85548 int bit = fls(size);
85549
85550 @@ -1581,6 +1627,11 @@ void *vmap(struct page **pages, unsigned int count,
85551 if (count > totalram_pages)
85552 return NULL;
85553
85554 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85555 + if (!(pgprot_val(prot) & _PAGE_NX))
85556 + flags |= VM_KERNEXEC;
85557 +#endif
85558 +
85559 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
85560 __builtin_return_address(0));
85561 if (!area)
85562 @@ -1682,6 +1733,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
85563 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
85564 goto fail;
85565
85566 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
85567 + if (!(pgprot_val(prot) & _PAGE_NX))
85568 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST | VM_KERNEXEC,
85569 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
85570 + else
85571 +#endif
85572 +
85573 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST,
85574 start, end, node, gfp_mask, caller);
85575 if (!area)
85576 @@ -1858,10 +1916,9 @@ EXPORT_SYMBOL(vzalloc_node);
85577 * For tight control over page level allocator and protection flags
85578 * use __vmalloc() instead.
85579 */
85580 -
85581 void *vmalloc_exec(unsigned long size)
85582 {
85583 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
85584 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
85585 NUMA_NO_NODE, __builtin_return_address(0));
85586 }
85587
85588 @@ -2168,6 +2225,8 @@ int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
85589 unsigned long uaddr = vma->vm_start;
85590 unsigned long usize = vma->vm_end - vma->vm_start;
85591
85592 + BUG_ON(vma->vm_mirror);
85593 +
85594 if ((PAGE_SIZE-1) & (unsigned long)addr)
85595 return -EINVAL;
85596
85597 @@ -2629,7 +2688,11 @@ static int s_show(struct seq_file *m, void *p)
85598 v->addr, v->addr + v->size, v->size);
85599
85600 if (v->caller)
85601 +#ifdef CONFIG_GRKERNSEC_HIDESYM
85602 + seq_printf(m, " %pK", v->caller);
85603 +#else
85604 seq_printf(m, " %pS", v->caller);
85605 +#endif
85606
85607 if (v->nr_pages)
85608 seq_printf(m, " pages=%d", v->nr_pages);
85609 diff --git a/mm/vmstat.c b/mm/vmstat.c
85610 index f42745e..62f8346 100644
85611 --- a/mm/vmstat.c
85612 +++ b/mm/vmstat.c
85613 @@ -76,7 +76,7 @@ void vm_events_fold_cpu(int cpu)
85614 *
85615 * vm_stat contains the global counters
85616 */
85617 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
85618 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
85619 EXPORT_SYMBOL(vm_stat);
85620
85621 #ifdef CONFIG_SMP
85622 @@ -452,7 +452,7 @@ void refresh_cpu_vm_stats(int cpu)
85623 v = p->vm_stat_diff[i];
85624 p->vm_stat_diff[i] = 0;
85625 local_irq_restore(flags);
85626 - atomic_long_add(v, &zone->vm_stat[i]);
85627 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
85628 global_diff[i] += v;
85629 #ifdef CONFIG_NUMA
85630 /* 3 seconds idle till flush */
85631 @@ -490,7 +490,7 @@ void refresh_cpu_vm_stats(int cpu)
85632
85633 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
85634 if (global_diff[i])
85635 - atomic_long_add(global_diff[i], &vm_stat[i]);
85636 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
85637 }
85638
85639 /*
85640 @@ -505,8 +505,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
85641 if (pset->vm_stat_diff[i]) {
85642 int v = pset->vm_stat_diff[i];
85643 pset->vm_stat_diff[i] = 0;
85644 - atomic_long_add(v, &zone->vm_stat[i]);
85645 - atomic_long_add(v, &vm_stat[i]);
85646 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
85647 + atomic_long_add_unchecked(v, &vm_stat[i]);
85648 }
85649 }
85650 #endif
85651 @@ -1226,7 +1226,7 @@ static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb,
85652 return NOTIFY_OK;
85653 }
85654
85655 -static struct notifier_block __cpuinitdata vmstat_notifier =
85656 +static struct notifier_block vmstat_notifier =
85657 { &vmstat_cpuup_callback, NULL, 0 };
85658 #endif
85659
85660 @@ -1241,10 +1241,20 @@ static int __init setup_vmstat(void)
85661 start_cpu_timer(cpu);
85662 #endif
85663 #ifdef CONFIG_PROC_FS
85664 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
85665 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
85666 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
85667 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
85668 + {
85669 + mode_t gr_mode = S_IRUGO;
85670 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
85671 + gr_mode = S_IRUSR;
85672 +#endif
85673 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
85674 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
85675 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
85676 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
85677 +#else
85678 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
85679 +#endif
85680 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
85681 + }
85682 #endif
85683 return 0;
85684 }
85685 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
85686 index 9424f37..6aabf19 100644
85687 --- a/net/8021q/vlan.c
85688 +++ b/net/8021q/vlan.c
85689 @@ -469,7 +469,7 @@ out:
85690 return NOTIFY_DONE;
85691 }
85692
85693 -static struct notifier_block vlan_notifier_block __read_mostly = {
85694 +static struct notifier_block vlan_notifier_block = {
85695 .notifier_call = vlan_device_event,
85696 };
85697
85698 @@ -544,8 +544,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
85699 err = -EPERM;
85700 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
85701 break;
85702 - if ((args.u.name_type >= 0) &&
85703 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
85704 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
85705 struct vlan_net *vn;
85706
85707 vn = net_generic(net, vlan_net_id);
85708 diff --git a/net/9p/mod.c b/net/9p/mod.c
85709 index 6ab36ae..6f1841b 100644
85710 --- a/net/9p/mod.c
85711 +++ b/net/9p/mod.c
85712 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
85713 void v9fs_register_trans(struct p9_trans_module *m)
85714 {
85715 spin_lock(&v9fs_trans_lock);
85716 - list_add_tail(&m->list, &v9fs_trans_list);
85717 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
85718 spin_unlock(&v9fs_trans_lock);
85719 }
85720 EXPORT_SYMBOL(v9fs_register_trans);
85721 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
85722 void v9fs_unregister_trans(struct p9_trans_module *m)
85723 {
85724 spin_lock(&v9fs_trans_lock);
85725 - list_del_init(&m->list);
85726 + pax_list_del_init((struct list_head *)&m->list);
85727 spin_unlock(&v9fs_trans_lock);
85728 }
85729 EXPORT_SYMBOL(v9fs_unregister_trans);
85730 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
85731 index 02efb25..41541a9 100644
85732 --- a/net/9p/trans_fd.c
85733 +++ b/net/9p/trans_fd.c
85734 @@ -425,7 +425,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
85735 oldfs = get_fs();
85736 set_fs(get_ds());
85737 /* The cast to a user pointer is valid due to the set_fs() */
85738 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
85739 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
85740 set_fs(oldfs);
85741
85742 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
85743 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
85744 index 876fbe8..8bbea9f 100644
85745 --- a/net/atm/atm_misc.c
85746 +++ b/net/atm/atm_misc.c
85747 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
85748 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
85749 return 1;
85750 atm_return(vcc, truesize);
85751 - atomic_inc(&vcc->stats->rx_drop);
85752 + atomic_inc_unchecked(&vcc->stats->rx_drop);
85753 return 0;
85754 }
85755 EXPORT_SYMBOL(atm_charge);
85756 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
85757 }
85758 }
85759 atm_return(vcc, guess);
85760 - atomic_inc(&vcc->stats->rx_drop);
85761 + atomic_inc_unchecked(&vcc->stats->rx_drop);
85762 return NULL;
85763 }
85764 EXPORT_SYMBOL(atm_alloc_charge);
85765 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
85766
85767 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
85768 {
85769 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
85770 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
85771 __SONET_ITEMS
85772 #undef __HANDLE_ITEM
85773 }
85774 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
85775
85776 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
85777 {
85778 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
85779 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
85780 __SONET_ITEMS
85781 #undef __HANDLE_ITEM
85782 }
85783 diff --git a/net/atm/lec.h b/net/atm/lec.h
85784 index 4149db1..f2ab682 100644
85785 --- a/net/atm/lec.h
85786 +++ b/net/atm/lec.h
85787 @@ -48,7 +48,7 @@ struct lane2_ops {
85788 const u8 *tlvs, u32 sizeoftlvs);
85789 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
85790 const u8 *tlvs, u32 sizeoftlvs);
85791 -};
85792 +} __no_const;
85793
85794 /*
85795 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
85796 diff --git a/net/atm/proc.c b/net/atm/proc.c
85797 index bbb6461..cf04016 100644
85798 --- a/net/atm/proc.c
85799 +++ b/net/atm/proc.c
85800 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
85801 const struct k_atm_aal_stats *stats)
85802 {
85803 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
85804 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
85805 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
85806 - atomic_read(&stats->rx_drop));
85807 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
85808 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
85809 + atomic_read_unchecked(&stats->rx_drop));
85810 }
85811
85812 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
85813 diff --git a/net/atm/resources.c b/net/atm/resources.c
85814 index 0447d5d..3cf4728 100644
85815 --- a/net/atm/resources.c
85816 +++ b/net/atm/resources.c
85817 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
85818 static void copy_aal_stats(struct k_atm_aal_stats *from,
85819 struct atm_aal_stats *to)
85820 {
85821 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
85822 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
85823 __AAL_STAT_ITEMS
85824 #undef __HANDLE_ITEM
85825 }
85826 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
85827 static void subtract_aal_stats(struct k_atm_aal_stats *from,
85828 struct atm_aal_stats *to)
85829 {
85830 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
85831 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
85832 __AAL_STAT_ITEMS
85833 #undef __HANDLE_ITEM
85834 }
85835 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
85836 index d5744b7..506bae3 100644
85837 --- a/net/ax25/sysctl_net_ax25.c
85838 +++ b/net/ax25/sysctl_net_ax25.c
85839 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
85840 {
85841 char path[sizeof("net/ax25/") + IFNAMSIZ];
85842 int k;
85843 - struct ctl_table *table;
85844 + ctl_table_no_const *table;
85845
85846 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
85847 if (!table)
85848 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
85849 index f680ee1..97e3542 100644
85850 --- a/net/batman-adv/bat_iv_ogm.c
85851 +++ b/net/batman-adv/bat_iv_ogm.c
85852 @@ -79,7 +79,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
85853
85854 /* randomize initial seqno to avoid collision */
85855 get_random_bytes(&random_seqno, sizeof(random_seqno));
85856 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
85857 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
85858
85859 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
85860 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
85861 @@ -627,9 +627,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
85862 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
85863
85864 /* change sequence number to network order */
85865 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
85866 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
85867 batadv_ogm_packet->seqno = htonl(seqno);
85868 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
85869 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
85870
85871 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
85872 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
85873 @@ -1037,7 +1037,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
85874 return;
85875
85876 /* could be changed by schedule_own_packet() */
85877 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
85878 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
85879
85880 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
85881 has_directlink_flag = 1;
85882 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
85883 index 522243a..b48c0ef 100644
85884 --- a/net/batman-adv/hard-interface.c
85885 +++ b/net/batman-adv/hard-interface.c
85886 @@ -401,7 +401,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
85887 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
85888 dev_add_pack(&hard_iface->batman_adv_ptype);
85889
85890 - atomic_set(&hard_iface->frag_seqno, 1);
85891 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
85892 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
85893 hard_iface->net_dev->name);
85894
85895 @@ -550,7 +550,7 @@ batadv_hardif_add_interface(struct net_device *net_dev)
85896 /* This can't be called via a bat_priv callback because
85897 * we have no bat_priv yet.
85898 */
85899 - atomic_set(&hard_iface->bat_iv.ogm_seqno, 1);
85900 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, 1);
85901 hard_iface->bat_iv.ogm_buff = NULL;
85902
85903 return hard_iface;
85904 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
85905 index 819dfb0..9a672d1 100644
85906 --- a/net/batman-adv/soft-interface.c
85907 +++ b/net/batman-adv/soft-interface.c
85908 @@ -253,7 +253,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
85909 primary_if->net_dev->dev_addr, ETH_ALEN);
85910
85911 /* set broadcast sequence number */
85912 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
85913 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
85914 bcast_packet->seqno = htonl(seqno);
85915
85916 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
85917 @@ -472,7 +472,7 @@ static int batadv_softif_init_late(struct net_device *dev)
85918 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
85919
85920 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
85921 - atomic_set(&bat_priv->bcast_seqno, 1);
85922 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
85923 atomic_set(&bat_priv->tt.vn, 0);
85924 atomic_set(&bat_priv->tt.local_changes, 0);
85925 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
85926 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
85927 index aba8364..50fcbb8 100644
85928 --- a/net/batman-adv/types.h
85929 +++ b/net/batman-adv/types.h
85930 @@ -51,7 +51,7 @@
85931 struct batadv_hard_iface_bat_iv {
85932 unsigned char *ogm_buff;
85933 int ogm_buff_len;
85934 - atomic_t ogm_seqno;
85935 + atomic_unchecked_t ogm_seqno;
85936 };
85937
85938 /**
85939 @@ -75,7 +75,7 @@ struct batadv_hard_iface {
85940 int16_t if_num;
85941 char if_status;
85942 struct net_device *net_dev;
85943 - atomic_t frag_seqno;
85944 + atomic_unchecked_t frag_seqno;
85945 struct kobject *hardif_obj;
85946 atomic_t refcount;
85947 struct packet_type batman_adv_ptype;
85948 @@ -558,7 +558,7 @@ struct batadv_priv {
85949 #ifdef CONFIG_BATMAN_ADV_DEBUG
85950 atomic_t log_level;
85951 #endif
85952 - atomic_t bcast_seqno;
85953 + atomic_unchecked_t bcast_seqno;
85954 atomic_t bcast_queue_left;
85955 atomic_t batman_queue_left;
85956 char num_ifaces;
85957 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
85958 index 0bb3b59..ffcbf2f 100644
85959 --- a/net/batman-adv/unicast.c
85960 +++ b/net/batman-adv/unicast.c
85961 @@ -270,7 +270,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
85962 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
85963 frag2->flags = large_tail;
85964
85965 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
85966 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
85967 frag1->seqno = htons(seqno - 1);
85968 frag2->seqno = htons(seqno);
85969
85970 diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
85971 index ace5e55..a65a1c0 100644
85972 --- a/net/bluetooth/hci_core.c
85973 +++ b/net/bluetooth/hci_core.c
85974 @@ -2211,16 +2211,16 @@ int hci_register_dev(struct hci_dev *hdev)
85975 list_add(&hdev->list, &hci_dev_list);
85976 write_unlock(&hci_dev_list_lock);
85977
85978 - hdev->workqueue = alloc_workqueue(hdev->name, WQ_HIGHPRI | WQ_UNBOUND |
85979 - WQ_MEM_RECLAIM, 1);
85980 + hdev->workqueue = alloc_workqueue("%s", WQ_HIGHPRI | WQ_UNBOUND |
85981 + WQ_MEM_RECLAIM, 1, hdev->name);
85982 if (!hdev->workqueue) {
85983 error = -ENOMEM;
85984 goto err;
85985 }
85986
85987 - hdev->req_workqueue = alloc_workqueue(hdev->name,
85988 + hdev->req_workqueue = alloc_workqueue("%s",
85989 WQ_HIGHPRI | WQ_UNBOUND |
85990 - WQ_MEM_RECLAIM, 1);
85991 + WQ_MEM_RECLAIM, 1, hdev->name);
85992 if (!hdev->req_workqueue) {
85993 destroy_workqueue(hdev->workqueue);
85994 error = -ENOMEM;
85995 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
85996 index 9bd7d95..6c4884f 100644
85997 --- a/net/bluetooth/hci_sock.c
85998 +++ b/net/bluetooth/hci_sock.c
85999 @@ -934,7 +934,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
86000 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
86001 }
86002
86003 - len = min_t(unsigned int, len, sizeof(uf));
86004 + len = min((size_t)len, sizeof(uf));
86005 if (copy_from_user(&uf, optval, len)) {
86006 err = -EFAULT;
86007 break;
86008 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
86009 index 68843a2..30e9342 100644
86010 --- a/net/bluetooth/l2cap_core.c
86011 +++ b/net/bluetooth/l2cap_core.c
86012 @@ -3507,8 +3507,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
86013 break;
86014
86015 case L2CAP_CONF_RFC:
86016 - if (olen == sizeof(rfc))
86017 - memcpy(&rfc, (void *)val, olen);
86018 + if (olen != sizeof(rfc))
86019 + break;
86020 +
86021 + memcpy(&rfc, (void *)val, olen);
86022
86023 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
86024 rfc.mode != chan->mode)
86025 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
86026 index 36fed40..be2eeb2 100644
86027 --- a/net/bluetooth/l2cap_sock.c
86028 +++ b/net/bluetooth/l2cap_sock.c
86029 @@ -485,7 +485,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
86030 struct sock *sk = sock->sk;
86031 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
86032 struct l2cap_options opts;
86033 - int len, err = 0;
86034 + int err = 0;
86035 + size_t len = optlen;
86036 u32 opt;
86037
86038 BT_DBG("sk %p", sk);
86039 @@ -507,7 +508,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
86040 opts.max_tx = chan->max_tx;
86041 opts.txwin_size = chan->tx_win;
86042
86043 - len = min_t(unsigned int, sizeof(opts), optlen);
86044 + len = min(sizeof(opts), len);
86045 if (copy_from_user((char *) &opts, optval, len)) {
86046 err = -EFAULT;
86047 break;
86048 @@ -587,7 +588,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
86049 struct bt_security sec;
86050 struct bt_power pwr;
86051 struct l2cap_conn *conn;
86052 - int len, err = 0;
86053 + int err = 0;
86054 + size_t len = optlen;
86055 u32 opt;
86056
86057 BT_DBG("sk %p", sk);
86058 @@ -610,7 +612,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
86059
86060 sec.level = BT_SECURITY_LOW;
86061
86062 - len = min_t(unsigned int, sizeof(sec), optlen);
86063 + len = min(sizeof(sec), len);
86064 if (copy_from_user((char *) &sec, optval, len)) {
86065 err = -EFAULT;
86066 break;
86067 @@ -707,7 +709,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
86068
86069 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
86070
86071 - len = min_t(unsigned int, sizeof(pwr), optlen);
86072 + len = min(sizeof(pwr), len);
86073 if (copy_from_user((char *) &pwr, optval, len)) {
86074 err = -EFAULT;
86075 break;
86076 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
86077 index 30b3721..c1bd0a0 100644
86078 --- a/net/bluetooth/rfcomm/sock.c
86079 +++ b/net/bluetooth/rfcomm/sock.c
86080 @@ -666,7 +666,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
86081 struct sock *sk = sock->sk;
86082 struct bt_security sec;
86083 int err = 0;
86084 - size_t len;
86085 + size_t len = optlen;
86086 u32 opt;
86087
86088 BT_DBG("sk %p", sk);
86089 @@ -688,7 +688,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
86090
86091 sec.level = BT_SECURITY_LOW;
86092
86093 - len = min_t(unsigned int, sizeof(sec), optlen);
86094 + len = min(sizeof(sec), len);
86095 if (copy_from_user((char *) &sec, optval, len)) {
86096 err = -EFAULT;
86097 break;
86098 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
86099 index b6e44ad..5b0d514 100644
86100 --- a/net/bluetooth/rfcomm/tty.c
86101 +++ b/net/bluetooth/rfcomm/tty.c
86102 @@ -309,7 +309,7 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
86103 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
86104
86105 spin_lock_irqsave(&dev->port.lock, flags);
86106 - if (dev->port.count > 0) {
86107 + if (atomic_read(&dev->port.count) > 0) {
86108 spin_unlock_irqrestore(&dev->port.lock, flags);
86109 return;
86110 }
86111 @@ -659,10 +659,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
86112 return -ENODEV;
86113
86114 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
86115 - dev->channel, dev->port.count);
86116 + dev->channel, atomic_read(&dev->port.count));
86117
86118 spin_lock_irqsave(&dev->port.lock, flags);
86119 - if (++dev->port.count > 1) {
86120 + if (atomic_inc_return(&dev->port.count) > 1) {
86121 spin_unlock_irqrestore(&dev->port.lock, flags);
86122 return 0;
86123 }
86124 @@ -727,10 +727,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
86125 return;
86126
86127 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
86128 - dev->port.count);
86129 + atomic_read(&dev->port.count));
86130
86131 spin_lock_irqsave(&dev->port.lock, flags);
86132 - if (!--dev->port.count) {
86133 + if (!atomic_dec_return(&dev->port.count)) {
86134 spin_unlock_irqrestore(&dev->port.lock, flags);
86135 if (dev->tty_dev->parent)
86136 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
86137 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
86138 index 3d110c4..4e1b2eb 100644
86139 --- a/net/bridge/netfilter/ebtables.c
86140 +++ b/net/bridge/netfilter/ebtables.c
86141 @@ -1525,7 +1525,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
86142 tmp.valid_hooks = t->table->valid_hooks;
86143 }
86144 mutex_unlock(&ebt_mutex);
86145 - if (copy_to_user(user, &tmp, *len) != 0){
86146 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
86147 BUGPRINT("c2u Didn't work\n");
86148 ret = -EFAULT;
86149 break;
86150 @@ -2331,7 +2331,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
86151 goto out;
86152 tmp.valid_hooks = t->valid_hooks;
86153
86154 - if (copy_to_user(user, &tmp, *len) != 0) {
86155 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
86156 ret = -EFAULT;
86157 break;
86158 }
86159 @@ -2342,7 +2342,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
86160 tmp.entries_size = t->table->entries_size;
86161 tmp.valid_hooks = t->table->valid_hooks;
86162
86163 - if (copy_to_user(user, &tmp, *len) != 0) {
86164 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
86165 ret = -EFAULT;
86166 break;
86167 }
86168 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
86169 index 2bd4b58..0dc30a1 100644
86170 --- a/net/caif/cfctrl.c
86171 +++ b/net/caif/cfctrl.c
86172 @@ -10,6 +10,7 @@
86173 #include <linux/spinlock.h>
86174 #include <linux/slab.h>
86175 #include <linux/pkt_sched.h>
86176 +#include <linux/sched.h>
86177 #include <net/caif/caif_layer.h>
86178 #include <net/caif/cfpkt.h>
86179 #include <net/caif/cfctrl.h>
86180 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
86181 memset(&dev_info, 0, sizeof(dev_info));
86182 dev_info.id = 0xff;
86183 cfsrvl_init(&this->serv, 0, &dev_info, false);
86184 - atomic_set(&this->req_seq_no, 1);
86185 - atomic_set(&this->rsp_seq_no, 1);
86186 + atomic_set_unchecked(&this->req_seq_no, 1);
86187 + atomic_set_unchecked(&this->rsp_seq_no, 1);
86188 this->serv.layer.receive = cfctrl_recv;
86189 sprintf(this->serv.layer.name, "ctrl");
86190 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
86191 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
86192 struct cfctrl_request_info *req)
86193 {
86194 spin_lock_bh(&ctrl->info_list_lock);
86195 - atomic_inc(&ctrl->req_seq_no);
86196 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
86197 + atomic_inc_unchecked(&ctrl->req_seq_no);
86198 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
86199 list_add_tail(&req->list, &ctrl->list);
86200 spin_unlock_bh(&ctrl->info_list_lock);
86201 }
86202 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
86203 if (p != first)
86204 pr_warn("Requests are not received in order\n");
86205
86206 - atomic_set(&ctrl->rsp_seq_no,
86207 + atomic_set_unchecked(&ctrl->rsp_seq_no,
86208 p->sequence_no);
86209 list_del(&p->list);
86210 goto out;
86211 diff --git a/net/can/af_can.c b/net/can/af_can.c
86212 index c4e5085..aa9efdf 100644
86213 --- a/net/can/af_can.c
86214 +++ b/net/can/af_can.c
86215 @@ -862,7 +862,7 @@ static const struct net_proto_family can_family_ops = {
86216 };
86217
86218 /* notifier block for netdevice event */
86219 -static struct notifier_block can_netdev_notifier __read_mostly = {
86220 +static struct notifier_block can_netdev_notifier = {
86221 .notifier_call = can_notifier,
86222 };
86223
86224 diff --git a/net/can/gw.c b/net/can/gw.c
86225 index 3ee690e..00d581b 100644
86226 --- a/net/can/gw.c
86227 +++ b/net/can/gw.c
86228 @@ -80,7 +80,6 @@ MODULE_PARM_DESC(max_hops,
86229 "default: " __stringify(CGW_DEFAULT_HOPS) ")");
86230
86231 static HLIST_HEAD(cgw_list);
86232 -static struct notifier_block notifier;
86233
86234 static struct kmem_cache *cgw_cache __read_mostly;
86235
86236 @@ -927,6 +926,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh)
86237 return err;
86238 }
86239
86240 +static struct notifier_block notifier = {
86241 + .notifier_call = cgw_notifier
86242 +};
86243 +
86244 static __init int cgw_module_init(void)
86245 {
86246 /* sanitize given module parameter */
86247 @@ -942,7 +945,6 @@ static __init int cgw_module_init(void)
86248 return -ENOMEM;
86249
86250 /* set notifier */
86251 - notifier.notifier_call = cgw_notifier;
86252 register_netdevice_notifier(&notifier);
86253
86254 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
86255 diff --git a/net/compat.c b/net/compat.c
86256 index f0a1ba6..0541331 100644
86257 --- a/net/compat.c
86258 +++ b/net/compat.c
86259 @@ -71,9 +71,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
86260 __get_user(kmsg->msg_controllen, &umsg->msg_controllen) ||
86261 __get_user(kmsg->msg_flags, &umsg->msg_flags))
86262 return -EFAULT;
86263 - kmsg->msg_name = compat_ptr(tmp1);
86264 - kmsg->msg_iov = compat_ptr(tmp2);
86265 - kmsg->msg_control = compat_ptr(tmp3);
86266 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
86267 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
86268 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
86269 return 0;
86270 }
86271
86272 @@ -85,7 +85,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
86273
86274 if (kern_msg->msg_namelen) {
86275 if (mode == VERIFY_READ) {
86276 - int err = move_addr_to_kernel(kern_msg->msg_name,
86277 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
86278 kern_msg->msg_namelen,
86279 kern_address);
86280 if (err < 0)
86281 @@ -96,7 +96,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
86282 kern_msg->msg_name = NULL;
86283
86284 tot_len = iov_from_user_compat_to_kern(kern_iov,
86285 - (struct compat_iovec __user *)kern_msg->msg_iov,
86286 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
86287 kern_msg->msg_iovlen);
86288 if (tot_len >= 0)
86289 kern_msg->msg_iov = kern_iov;
86290 @@ -116,20 +116,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
86291
86292 #define CMSG_COMPAT_FIRSTHDR(msg) \
86293 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
86294 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
86295 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
86296 (struct compat_cmsghdr __user *)NULL)
86297
86298 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
86299 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
86300 (ucmlen) <= (unsigned long) \
86301 ((mhdr)->msg_controllen - \
86302 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
86303 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
86304
86305 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
86306 struct compat_cmsghdr __user *cmsg, int cmsg_len)
86307 {
86308 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
86309 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
86310 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
86311 msg->msg_controllen)
86312 return NULL;
86313 return (struct compat_cmsghdr __user *)ptr;
86314 @@ -219,7 +219,7 @@ Efault:
86315
86316 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
86317 {
86318 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
86319 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
86320 struct compat_cmsghdr cmhdr;
86321 struct compat_timeval ctv;
86322 struct compat_timespec cts[3];
86323 @@ -275,7 +275,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
86324
86325 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
86326 {
86327 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
86328 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
86329 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
86330 int fdnum = scm->fp->count;
86331 struct file **fp = scm->fp->fp;
86332 @@ -363,7 +363,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
86333 return -EFAULT;
86334 old_fs = get_fs();
86335 set_fs(KERNEL_DS);
86336 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
86337 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
86338 set_fs(old_fs);
86339
86340 return err;
86341 @@ -424,7 +424,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
86342 len = sizeof(ktime);
86343 old_fs = get_fs();
86344 set_fs(KERNEL_DS);
86345 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
86346 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
86347 set_fs(old_fs);
86348
86349 if (!err) {
86350 @@ -567,7 +567,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
86351 case MCAST_JOIN_GROUP:
86352 case MCAST_LEAVE_GROUP:
86353 {
86354 - struct compat_group_req __user *gr32 = (void *)optval;
86355 + struct compat_group_req __user *gr32 = (void __user *)optval;
86356 struct group_req __user *kgr =
86357 compat_alloc_user_space(sizeof(struct group_req));
86358 u32 interface;
86359 @@ -588,7 +588,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
86360 case MCAST_BLOCK_SOURCE:
86361 case MCAST_UNBLOCK_SOURCE:
86362 {
86363 - struct compat_group_source_req __user *gsr32 = (void *)optval;
86364 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
86365 struct group_source_req __user *kgsr = compat_alloc_user_space(
86366 sizeof(struct group_source_req));
86367 u32 interface;
86368 @@ -609,7 +609,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
86369 }
86370 case MCAST_MSFILTER:
86371 {
86372 - struct compat_group_filter __user *gf32 = (void *)optval;
86373 + struct compat_group_filter __user *gf32 = (void __user *)optval;
86374 struct group_filter __user *kgf;
86375 u32 interface, fmode, numsrc;
86376
86377 @@ -647,7 +647,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
86378 char __user *optval, int __user *optlen,
86379 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
86380 {
86381 - struct compat_group_filter __user *gf32 = (void *)optval;
86382 + struct compat_group_filter __user *gf32 = (void __user *)optval;
86383 struct group_filter __user *kgf;
86384 int __user *koptlen;
86385 u32 interface, fmode, numsrc;
86386 @@ -805,7 +805,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
86387
86388 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
86389 return -EINVAL;
86390 - if (copy_from_user(a, args, nas[call]))
86391 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
86392 return -EFAULT;
86393 a0 = a[0];
86394 a1 = a[1];
86395 diff --git a/net/core/datagram.c b/net/core/datagram.c
86396 index b71423d..0360434 100644
86397 --- a/net/core/datagram.c
86398 +++ b/net/core/datagram.c
86399 @@ -295,7 +295,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
86400 }
86401
86402 kfree_skb(skb);
86403 - atomic_inc(&sk->sk_drops);
86404 + atomic_inc_unchecked(&sk->sk_drops);
86405 sk_mem_reclaim_partial(sk);
86406
86407 return err;
86408 diff --git a/net/core/dev.c b/net/core/dev.c
86409 index faebb39..a38fb42 100644
86410 --- a/net/core/dev.c
86411 +++ b/net/core/dev.c
86412 @@ -1649,7 +1649,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
86413 {
86414 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
86415 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
86416 - atomic_long_inc(&dev->rx_dropped);
86417 + atomic_long_inc_unchecked(&dev->rx_dropped);
86418 kfree_skb(skb);
86419 return NET_RX_DROP;
86420 }
86421 @@ -1658,7 +1658,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
86422 skb_orphan(skb);
86423
86424 if (unlikely(!is_skb_forwardable(dev, skb))) {
86425 - atomic_long_inc(&dev->rx_dropped);
86426 + atomic_long_inc_unchecked(&dev->rx_dropped);
86427 kfree_skb(skb);
86428 return NET_RX_DROP;
86429 }
86430 @@ -2404,7 +2404,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
86431
86432 struct dev_gso_cb {
86433 void (*destructor)(struct sk_buff *skb);
86434 -};
86435 +} __no_const;
86436
86437 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
86438
86439 @@ -3139,7 +3139,7 @@ enqueue:
86440
86441 local_irq_restore(flags);
86442
86443 - atomic_long_inc(&skb->dev->rx_dropped);
86444 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
86445 kfree_skb(skb);
86446 return NET_RX_DROP;
86447 }
86448 @@ -3211,7 +3211,7 @@ int netif_rx_ni(struct sk_buff *skb)
86449 }
86450 EXPORT_SYMBOL(netif_rx_ni);
86451
86452 -static void net_tx_action(struct softirq_action *h)
86453 +static void net_tx_action(void)
86454 {
86455 struct softnet_data *sd = &__get_cpu_var(softnet_data);
86456
86457 @@ -3538,7 +3538,7 @@ ncls:
86458 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
86459 } else {
86460 drop:
86461 - atomic_long_inc(&skb->dev->rx_dropped);
86462 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
86463 kfree_skb(skb);
86464 /* Jamal, now you will not able to escape explaining
86465 * me how you were going to use this. :-)
86466 @@ -4146,7 +4146,7 @@ void netif_napi_del(struct napi_struct *napi)
86467 }
86468 EXPORT_SYMBOL(netif_napi_del);
86469
86470 -static void net_rx_action(struct softirq_action *h)
86471 +static void net_rx_action(void)
86472 {
86473 struct softnet_data *sd = &__get_cpu_var(softnet_data);
86474 unsigned long time_limit = jiffies + 2;
86475 @@ -5583,7 +5583,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
86476 } else {
86477 netdev_stats_to_stats64(storage, &dev->stats);
86478 }
86479 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
86480 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
86481 return storage;
86482 }
86483 EXPORT_SYMBOL(dev_get_stats);
86484 diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
86485 index 5b7d0e1..cb960fc 100644
86486 --- a/net/core/dev_ioctl.c
86487 +++ b/net/core/dev_ioctl.c
86488 @@ -365,9 +365,13 @@ void dev_load(struct net *net, const char *name)
86489 if (no_module && capable(CAP_NET_ADMIN))
86490 no_module = request_module("netdev-%s", name);
86491 if (no_module && capable(CAP_SYS_MODULE)) {
86492 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
86493 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
86494 +#else
86495 if (!request_module("%s", name))
86496 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
86497 name);
86498 +#endif
86499 }
86500 }
86501 EXPORT_SYMBOL(dev_load);
86502 diff --git a/net/core/flow.c b/net/core/flow.c
86503 index 7102f16..146b4bd 100644
86504 --- a/net/core/flow.c
86505 +++ b/net/core/flow.c
86506 @@ -61,7 +61,7 @@ struct flow_cache {
86507 struct timer_list rnd_timer;
86508 };
86509
86510 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
86511 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
86512 EXPORT_SYMBOL(flow_cache_genid);
86513 static struct flow_cache flow_cache_global;
86514 static struct kmem_cache *flow_cachep __read_mostly;
86515 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
86516
86517 static int flow_entry_valid(struct flow_cache_entry *fle)
86518 {
86519 - if (atomic_read(&flow_cache_genid) != fle->genid)
86520 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
86521 return 0;
86522 if (fle->object && !fle->object->ops->check(fle->object))
86523 return 0;
86524 @@ -258,7 +258,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
86525 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
86526 fcp->hash_count++;
86527 }
86528 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
86529 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
86530 flo = fle->object;
86531 if (!flo)
86532 goto ret_object;
86533 @@ -279,7 +279,7 @@ nocache:
86534 }
86535 flo = resolver(net, key, family, dir, flo, ctx);
86536 if (fle) {
86537 - fle->genid = atomic_read(&flow_cache_genid);
86538 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
86539 if (!IS_ERR(flo))
86540 fle->object = flo;
86541 else
86542 diff --git a/net/core/iovec.c b/net/core/iovec.c
86543 index de178e4..1dabd8b 100644
86544 --- a/net/core/iovec.c
86545 +++ b/net/core/iovec.c
86546 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
86547 if (m->msg_namelen) {
86548 if (mode == VERIFY_READ) {
86549 void __user *namep;
86550 - namep = (void __user __force *) m->msg_name;
86551 + namep = (void __force_user *) m->msg_name;
86552 err = move_addr_to_kernel(namep, m->msg_namelen,
86553 address);
86554 if (err < 0)
86555 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
86556 }
86557
86558 size = m->msg_iovlen * sizeof(struct iovec);
86559 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
86560 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
86561 return -EFAULT;
86562
86563 m->msg_iov = iov;
86564 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
86565 index 5c56b21..8766fbf 100644
86566 --- a/net/core/neighbour.c
86567 +++ b/net/core/neighbour.c
86568 @@ -2769,7 +2769,7 @@ static int proc_unres_qlen(ctl_table *ctl, int write, void __user *buffer,
86569 size_t *lenp, loff_t *ppos)
86570 {
86571 int size, ret;
86572 - ctl_table tmp = *ctl;
86573 + ctl_table_no_const tmp = *ctl;
86574
86575 tmp.extra1 = &zero;
86576 tmp.extra2 = &unres_qlen_max;
86577 diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
86578 index 569d355..79cf2d0 100644
86579 --- a/net/core/net-procfs.c
86580 +++ b/net/core/net-procfs.c
86581 @@ -271,8 +271,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
86582 else
86583 seq_printf(seq, "%04x", ntohs(pt->type));
86584
86585 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86586 + seq_printf(seq, " %-8s %pf\n",
86587 + pt->dev ? pt->dev->name : "", NULL);
86588 +#else
86589 seq_printf(seq, " %-8s %pf\n",
86590 pt->dev ? pt->dev->name : "", pt->func);
86591 +#endif
86592 }
86593
86594 return 0;
86595 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
86596 index 981fed3..536af34 100644
86597 --- a/net/core/net-sysfs.c
86598 +++ b/net/core/net-sysfs.c
86599 @@ -1311,7 +1311,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
86600 }
86601 EXPORT_SYMBOL(netdev_class_remove_file);
86602
86603 -int netdev_kobject_init(void)
86604 +int __init netdev_kobject_init(void)
86605 {
86606 kobj_ns_type_register(&net_ns_type_operations);
86607 return class_register(&net_class);
86608 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
86609 index f9765203..9feaef8 100644
86610 --- a/net/core/net_namespace.c
86611 +++ b/net/core/net_namespace.c
86612 @@ -443,7 +443,7 @@ static int __register_pernet_operations(struct list_head *list,
86613 int error;
86614 LIST_HEAD(net_exit_list);
86615
86616 - list_add_tail(&ops->list, list);
86617 + pax_list_add_tail((struct list_head *)&ops->list, list);
86618 if (ops->init || (ops->id && ops->size)) {
86619 for_each_net(net) {
86620 error = ops_init(ops, net);
86621 @@ -456,7 +456,7 @@ static int __register_pernet_operations(struct list_head *list,
86622
86623 out_undo:
86624 /* If I have an error cleanup all namespaces I initialized */
86625 - list_del(&ops->list);
86626 + pax_list_del((struct list_head *)&ops->list);
86627 ops_exit_list(ops, &net_exit_list);
86628 ops_free_list(ops, &net_exit_list);
86629 return error;
86630 @@ -467,7 +467,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
86631 struct net *net;
86632 LIST_HEAD(net_exit_list);
86633
86634 - list_del(&ops->list);
86635 + pax_list_del((struct list_head *)&ops->list);
86636 for_each_net(net)
86637 list_add_tail(&net->exit_list, &net_exit_list);
86638 ops_exit_list(ops, &net_exit_list);
86639 @@ -601,7 +601,7 @@ int register_pernet_device(struct pernet_operations *ops)
86640 mutex_lock(&net_mutex);
86641 error = register_pernet_operations(&pernet_list, ops);
86642 if (!error && (first_device == &pernet_list))
86643 - first_device = &ops->list;
86644 + first_device = (struct list_head *)&ops->list;
86645 mutex_unlock(&net_mutex);
86646 return error;
86647 }
86648 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
86649 index a08bd2b..4e8f43c 100644
86650 --- a/net/core/rtnetlink.c
86651 +++ b/net/core/rtnetlink.c
86652 @@ -58,7 +58,7 @@ struct rtnl_link {
86653 rtnl_doit_func doit;
86654 rtnl_dumpit_func dumpit;
86655 rtnl_calcit_func calcit;
86656 -};
86657 +} __no_const;
86658
86659 static DEFINE_MUTEX(rtnl_mutex);
86660
86661 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
86662 if (rtnl_link_ops_get(ops->kind))
86663 return -EEXIST;
86664
86665 - if (!ops->dellink)
86666 - ops->dellink = unregister_netdevice_queue;
86667 + if (!ops->dellink) {
86668 + pax_open_kernel();
86669 + *(void **)&ops->dellink = unregister_netdevice_queue;
86670 + pax_close_kernel();
86671 + }
86672
86673 - list_add_tail(&ops->list, &link_ops);
86674 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
86675 return 0;
86676 }
86677 EXPORT_SYMBOL_GPL(__rtnl_link_register);
86678 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
86679 for_each_net(net) {
86680 __rtnl_kill_links(net, ops);
86681 }
86682 - list_del(&ops->list);
86683 + pax_list_del((struct list_head *)&ops->list);
86684 }
86685 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
86686
86687 diff --git a/net/core/scm.c b/net/core/scm.c
86688 index 03795d0..eaf7368 100644
86689 --- a/net/core/scm.c
86690 +++ b/net/core/scm.c
86691 @@ -210,7 +210,7 @@ EXPORT_SYMBOL(__scm_send);
86692 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
86693 {
86694 struct cmsghdr __user *cm
86695 - = (__force struct cmsghdr __user *)msg->msg_control;
86696 + = (struct cmsghdr __force_user *)msg->msg_control;
86697 struct cmsghdr cmhdr;
86698 int cmlen = CMSG_LEN(len);
86699 int err;
86700 @@ -233,7 +233,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
86701 err = -EFAULT;
86702 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
86703 goto out;
86704 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
86705 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
86706 goto out;
86707 cmlen = CMSG_SPACE(len);
86708 if (msg->msg_controllen < cmlen)
86709 @@ -249,7 +249,7 @@ EXPORT_SYMBOL(put_cmsg);
86710 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
86711 {
86712 struct cmsghdr __user *cm
86713 - = (__force struct cmsghdr __user*)msg->msg_control;
86714 + = (struct cmsghdr __force_user *)msg->msg_control;
86715
86716 int fdmax = 0;
86717 int fdnum = scm->fp->count;
86718 @@ -269,7 +269,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
86719 if (fdnum < fdmax)
86720 fdmax = fdnum;
86721
86722 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
86723 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
86724 i++, cmfptr++)
86725 {
86726 struct socket *sock;
86727 diff --git a/net/core/sock.c b/net/core/sock.c
86728 index d6d024c..6ea7ab4 100644
86729 --- a/net/core/sock.c
86730 +++ b/net/core/sock.c
86731 @@ -390,7 +390,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86732 struct sk_buff_head *list = &sk->sk_receive_queue;
86733
86734 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
86735 - atomic_inc(&sk->sk_drops);
86736 + atomic_inc_unchecked(&sk->sk_drops);
86737 trace_sock_rcvqueue_full(sk, skb);
86738 return -ENOMEM;
86739 }
86740 @@ -400,7 +400,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86741 return err;
86742
86743 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
86744 - atomic_inc(&sk->sk_drops);
86745 + atomic_inc_unchecked(&sk->sk_drops);
86746 return -ENOBUFS;
86747 }
86748
86749 @@ -420,7 +420,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
86750 skb_dst_force(skb);
86751
86752 spin_lock_irqsave(&list->lock, flags);
86753 - skb->dropcount = atomic_read(&sk->sk_drops);
86754 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
86755 __skb_queue_tail(list, skb);
86756 spin_unlock_irqrestore(&list->lock, flags);
86757
86758 @@ -440,7 +440,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
86759 skb->dev = NULL;
86760
86761 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
86762 - atomic_inc(&sk->sk_drops);
86763 + atomic_inc_unchecked(&sk->sk_drops);
86764 goto discard_and_relse;
86765 }
86766 if (nested)
86767 @@ -458,7 +458,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
86768 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
86769 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
86770 bh_unlock_sock(sk);
86771 - atomic_inc(&sk->sk_drops);
86772 + atomic_inc_unchecked(&sk->sk_drops);
86773 goto discard_and_relse;
86774 }
86775
86776 @@ -933,12 +933,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86777 struct timeval tm;
86778 } v;
86779
86780 - int lv = sizeof(int);
86781 - int len;
86782 + unsigned int lv = sizeof(int);
86783 + unsigned int len;
86784
86785 if (get_user(len, optlen))
86786 return -EFAULT;
86787 - if (len < 0)
86788 + if (len > INT_MAX)
86789 return -EINVAL;
86790
86791 memset(&v, 0, sizeof(v));
86792 @@ -1090,11 +1090,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86793
86794 case SO_PEERNAME:
86795 {
86796 - char address[128];
86797 + char address[_K_SS_MAXSIZE];
86798
86799 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
86800 return -ENOTCONN;
86801 - if (lv < len)
86802 + if (lv < len || sizeof address < len)
86803 return -EINVAL;
86804 if (copy_to_user(optval, address, len))
86805 return -EFAULT;
86806 @@ -1161,7 +1161,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
86807
86808 if (len > lv)
86809 len = lv;
86810 - if (copy_to_user(optval, &v, len))
86811 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
86812 return -EFAULT;
86813 lenout:
86814 if (put_user(len, optlen))
86815 @@ -2277,7 +2277,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
86816 */
86817 smp_wmb();
86818 atomic_set(&sk->sk_refcnt, 1);
86819 - atomic_set(&sk->sk_drops, 0);
86820 + atomic_set_unchecked(&sk->sk_drops, 0);
86821 }
86822 EXPORT_SYMBOL(sock_init_data);
86823
86824 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
86825 index a0e9cf6..ef7f9ed 100644
86826 --- a/net/core/sock_diag.c
86827 +++ b/net/core/sock_diag.c
86828 @@ -9,26 +9,33 @@
86829 #include <linux/inet_diag.h>
86830 #include <linux/sock_diag.h>
86831
86832 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
86833 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
86834 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
86835 static DEFINE_MUTEX(sock_diag_table_mutex);
86836
86837 int sock_diag_check_cookie(void *sk, __u32 *cookie)
86838 {
86839 +#ifndef CONFIG_GRKERNSEC_HIDESYM
86840 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
86841 cookie[1] != INET_DIAG_NOCOOKIE) &&
86842 ((u32)(unsigned long)sk != cookie[0] ||
86843 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
86844 return -ESTALE;
86845 else
86846 +#endif
86847 return 0;
86848 }
86849 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
86850
86851 void sock_diag_save_cookie(void *sk, __u32 *cookie)
86852 {
86853 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86854 + cookie[0] = 0;
86855 + cookie[1] = 0;
86856 +#else
86857 cookie[0] = (u32)(unsigned long)sk;
86858 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
86859 +#endif
86860 }
86861 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
86862
86863 @@ -113,8 +120,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
86864 mutex_lock(&sock_diag_table_mutex);
86865 if (sock_diag_handlers[hndl->family])
86866 err = -EBUSY;
86867 - else
86868 + else {
86869 + pax_open_kernel();
86870 sock_diag_handlers[hndl->family] = hndl;
86871 + pax_close_kernel();
86872 + }
86873 mutex_unlock(&sock_diag_table_mutex);
86874
86875 return err;
86876 @@ -130,7 +140,9 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
86877
86878 mutex_lock(&sock_diag_table_mutex);
86879 BUG_ON(sock_diag_handlers[family] != hnld);
86880 + pax_open_kernel();
86881 sock_diag_handlers[family] = NULL;
86882 + pax_close_kernel();
86883 mutex_unlock(&sock_diag_table_mutex);
86884 }
86885 EXPORT_SYMBOL_GPL(sock_diag_unregister);
86886 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
86887 index cfdb46a..cef55e1 100644
86888 --- a/net/core/sysctl_net_core.c
86889 +++ b/net/core/sysctl_net_core.c
86890 @@ -28,7 +28,7 @@ static int rps_sock_flow_sysctl(ctl_table *table, int write,
86891 {
86892 unsigned int orig_size, size;
86893 int ret, i;
86894 - ctl_table tmp = {
86895 + ctl_table_no_const tmp = {
86896 .data = &size,
86897 .maxlen = sizeof(size),
86898 .mode = table->mode
86899 @@ -211,13 +211,12 @@ static struct ctl_table netns_core_table[] = {
86900
86901 static __net_init int sysctl_core_net_init(struct net *net)
86902 {
86903 - struct ctl_table *tbl;
86904 + ctl_table_no_const *tbl = NULL;
86905
86906 net->core.sysctl_somaxconn = SOMAXCONN;
86907
86908 - tbl = netns_core_table;
86909 if (!net_eq(net, &init_net)) {
86910 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
86911 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
86912 if (tbl == NULL)
86913 goto err_dup;
86914
86915 @@ -227,17 +226,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
86916 if (net->user_ns != &init_user_ns) {
86917 tbl[0].procname = NULL;
86918 }
86919 - }
86920 -
86921 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
86922 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
86923 + } else
86924 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
86925 if (net->core.sysctl_hdr == NULL)
86926 goto err_reg;
86927
86928 return 0;
86929
86930 err_reg:
86931 - if (tbl != netns_core_table)
86932 - kfree(tbl);
86933 + kfree(tbl);
86934 err_dup:
86935 return -ENOMEM;
86936 }
86937 @@ -252,7 +250,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
86938 kfree(tbl);
86939 }
86940
86941 -static __net_initdata struct pernet_operations sysctl_core_ops = {
86942 +static __net_initconst struct pernet_operations sysctl_core_ops = {
86943 .init = sysctl_core_net_init,
86944 .exit = sysctl_core_net_exit,
86945 };
86946 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
86947 index c21f200..bc4565b 100644
86948 --- a/net/decnet/af_decnet.c
86949 +++ b/net/decnet/af_decnet.c
86950 @@ -465,6 +465,7 @@ static struct proto dn_proto = {
86951 .sysctl_rmem = sysctl_decnet_rmem,
86952 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
86953 .obj_size = sizeof(struct dn_sock),
86954 + .slab_flags = SLAB_USERCOPY,
86955 };
86956
86957 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
86958 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
86959 index a55eecc..dd8428c 100644
86960 --- a/net/decnet/sysctl_net_decnet.c
86961 +++ b/net/decnet/sysctl_net_decnet.c
86962 @@ -174,7 +174,7 @@ static int dn_node_address_handler(ctl_table *table, int write,
86963
86964 if (len > *lenp) len = *lenp;
86965
86966 - if (copy_to_user(buffer, addr, len))
86967 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
86968 return -EFAULT;
86969
86970 *lenp = len;
86971 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(ctl_table *table, int write,
86972
86973 if (len > *lenp) len = *lenp;
86974
86975 - if (copy_to_user(buffer, devname, len))
86976 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
86977 return -EFAULT;
86978
86979 *lenp = len;
86980 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
86981 index d01be2a..8976537 100644
86982 --- a/net/ipv4/af_inet.c
86983 +++ b/net/ipv4/af_inet.c
86984 @@ -1703,13 +1703,9 @@ static int __init inet_init(void)
86985
86986 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > FIELD_SIZEOF(struct sk_buff, cb));
86987
86988 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
86989 - if (!sysctl_local_reserved_ports)
86990 - goto out;
86991 -
86992 rc = proto_register(&tcp_prot, 1);
86993 if (rc)
86994 - goto out_free_reserved_ports;
86995 + goto out;
86996
86997 rc = proto_register(&udp_prot, 1);
86998 if (rc)
86999 @@ -1818,8 +1814,6 @@ out_unregister_udp_proto:
87000 proto_unregister(&udp_prot);
87001 out_unregister_tcp_proto:
87002 proto_unregister(&tcp_prot);
87003 -out_free_reserved_ports:
87004 - kfree(sysctl_local_reserved_ports);
87005 goto out;
87006 }
87007
87008 diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
87009 index 2e7f194..0fa4d6d 100644
87010 --- a/net/ipv4/ah4.c
87011 +++ b/net/ipv4/ah4.c
87012 @@ -420,7 +420,7 @@ static void ah4_err(struct sk_buff *skb, u32 info)
87013 return;
87014
87015 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
87016 - atomic_inc(&flow_cache_genid);
87017 + atomic_inc_unchecked(&flow_cache_genid);
87018 rt_genid_bump(net);
87019
87020 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_AH, 0);
87021 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
87022 index dfc39d4..0b82c4d 100644
87023 --- a/net/ipv4/devinet.c
87024 +++ b/net/ipv4/devinet.c
87025 @@ -1529,7 +1529,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
87026 idx = 0;
87027 head = &net->dev_index_head[h];
87028 rcu_read_lock();
87029 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
87030 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
87031 net->dev_base_seq;
87032 hlist_for_each_entry_rcu(dev, head, index_hlist) {
87033 if (idx < s_idx)
87034 @@ -1840,7 +1840,7 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb,
87035 idx = 0;
87036 head = &net->dev_index_head[h];
87037 rcu_read_lock();
87038 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
87039 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
87040 net->dev_base_seq;
87041 hlist_for_each_entry_rcu(dev, head, index_hlist) {
87042 if (idx < s_idx)
87043 @@ -2065,7 +2065,7 @@ static int ipv4_doint_and_flush(ctl_table *ctl, int write,
87044 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
87045 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
87046
87047 -static struct devinet_sysctl_table {
87048 +static const struct devinet_sysctl_table {
87049 struct ctl_table_header *sysctl_header;
87050 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
87051 } devinet_sysctl = {
87052 @@ -2183,7 +2183,7 @@ static __net_init int devinet_init_net(struct net *net)
87053 int err;
87054 struct ipv4_devconf *all, *dflt;
87055 #ifdef CONFIG_SYSCTL
87056 - struct ctl_table *tbl = ctl_forward_entry;
87057 + ctl_table_no_const *tbl = NULL;
87058 struct ctl_table_header *forw_hdr;
87059 #endif
87060
87061 @@ -2201,7 +2201,7 @@ static __net_init int devinet_init_net(struct net *net)
87062 goto err_alloc_dflt;
87063
87064 #ifdef CONFIG_SYSCTL
87065 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
87066 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
87067 if (tbl == NULL)
87068 goto err_alloc_ctl;
87069
87070 @@ -2221,7 +2221,10 @@ static __net_init int devinet_init_net(struct net *net)
87071 goto err_reg_dflt;
87072
87073 err = -ENOMEM;
87074 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
87075 + if (!net_eq(net, &init_net))
87076 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
87077 + else
87078 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
87079 if (forw_hdr == NULL)
87080 goto err_reg_ctl;
87081 net->ipv4.forw_hdr = forw_hdr;
87082 @@ -2237,8 +2240,7 @@ err_reg_ctl:
87083 err_reg_dflt:
87084 __devinet_sysctl_unregister(all);
87085 err_reg_all:
87086 - if (tbl != ctl_forward_entry)
87087 - kfree(tbl);
87088 + kfree(tbl);
87089 err_alloc_ctl:
87090 #endif
87091 if (dflt != &ipv4_devconf_dflt)
87092 diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
87093 index 4cfe34d..a6ba66e 100644
87094 --- a/net/ipv4/esp4.c
87095 +++ b/net/ipv4/esp4.c
87096 @@ -503,7 +503,7 @@ static void esp4_err(struct sk_buff *skb, u32 info)
87097 return;
87098
87099 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
87100 - atomic_inc(&flow_cache_genid);
87101 + atomic_inc_unchecked(&flow_cache_genid);
87102 rt_genid_bump(net);
87103
87104 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_ESP, 0);
87105 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
87106 index c7629a2..b62d139 100644
87107 --- a/net/ipv4/fib_frontend.c
87108 +++ b/net/ipv4/fib_frontend.c
87109 @@ -1017,12 +1017,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
87110 #ifdef CONFIG_IP_ROUTE_MULTIPATH
87111 fib_sync_up(dev);
87112 #endif
87113 - atomic_inc(&net->ipv4.dev_addr_genid);
87114 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
87115 rt_cache_flush(dev_net(dev));
87116 break;
87117 case NETDEV_DOWN:
87118 fib_del_ifaddr(ifa, NULL);
87119 - atomic_inc(&net->ipv4.dev_addr_genid);
87120 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
87121 if (ifa->ifa_dev->ifa_list == NULL) {
87122 /* Last address was deleted from this interface.
87123 * Disable IP.
87124 @@ -1058,7 +1058,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
87125 #ifdef CONFIG_IP_ROUTE_MULTIPATH
87126 fib_sync_up(dev);
87127 #endif
87128 - atomic_inc(&net->ipv4.dev_addr_genid);
87129 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
87130 rt_cache_flush(net);
87131 break;
87132 case NETDEV_DOWN:
87133 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
87134 index 8f6cb7a..34507f9 100644
87135 --- a/net/ipv4/fib_semantics.c
87136 +++ b/net/ipv4/fib_semantics.c
87137 @@ -765,7 +765,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
87138 nh->nh_saddr = inet_select_addr(nh->nh_dev,
87139 nh->nh_gw,
87140 nh->nh_parent->fib_scope);
87141 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
87142 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
87143
87144 return nh->nh_saddr;
87145 }
87146 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
87147 index 6acb541..9ea617d 100644
87148 --- a/net/ipv4/inet_connection_sock.c
87149 +++ b/net/ipv4/inet_connection_sock.c
87150 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
87151 .range = { 32768, 61000 },
87152 };
87153
87154 -unsigned long *sysctl_local_reserved_ports;
87155 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
87156 EXPORT_SYMBOL(sysctl_local_reserved_ports);
87157
87158 void inet_get_local_port_range(int *low, int *high)
87159 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
87160 index 6af375a..c493c74 100644
87161 --- a/net/ipv4/inet_hashtables.c
87162 +++ b/net/ipv4/inet_hashtables.c
87163 @@ -18,12 +18,15 @@
87164 #include <linux/sched.h>
87165 #include <linux/slab.h>
87166 #include <linux/wait.h>
87167 +#include <linux/security.h>
87168
87169 #include <net/inet_connection_sock.h>
87170 #include <net/inet_hashtables.h>
87171 #include <net/secure_seq.h>
87172 #include <net/ip.h>
87173
87174 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
87175 +
87176 /*
87177 * Allocate and initialize a new local port bind bucket.
87178 * The bindhash mutex for snum's hash chain must be held here.
87179 @@ -554,6 +557,8 @@ ok:
87180 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
87181 spin_unlock(&head->lock);
87182
87183 + gr_update_task_in_ip_table(current, inet_sk(sk));
87184 +
87185 if (tw) {
87186 inet_twsk_deschedule(tw, death_row);
87187 while (twrefcnt) {
87188 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
87189 index 000e3d2..5472da3 100644
87190 --- a/net/ipv4/inetpeer.c
87191 +++ b/net/ipv4/inetpeer.c
87192 @@ -503,8 +503,8 @@ relookup:
87193 if (p) {
87194 p->daddr = *daddr;
87195 atomic_set(&p->refcnt, 1);
87196 - atomic_set(&p->rid, 0);
87197 - atomic_set(&p->ip_id_count,
87198 + atomic_set_unchecked(&p->rid, 0);
87199 + atomic_set_unchecked(&p->ip_id_count,
87200 (daddr->family == AF_INET) ?
87201 secure_ip_id(daddr->addr.a4) :
87202 secure_ipv6_id(daddr->addr.a6));
87203 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
87204 index b66910a..cfe416e 100644
87205 --- a/net/ipv4/ip_fragment.c
87206 +++ b/net/ipv4/ip_fragment.c
87207 @@ -282,7 +282,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
87208 return 0;
87209
87210 start = qp->rid;
87211 - end = atomic_inc_return(&peer->rid);
87212 + end = atomic_inc_return_unchecked(&peer->rid);
87213 qp->rid = end;
87214
87215 rc = qp->q.fragments && (end - start) > max;
87216 @@ -759,12 +759,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
87217
87218 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
87219 {
87220 - struct ctl_table *table;
87221 + ctl_table_no_const *table = NULL;
87222 struct ctl_table_header *hdr;
87223
87224 - table = ip4_frags_ns_ctl_table;
87225 if (!net_eq(net, &init_net)) {
87226 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
87227 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
87228 if (table == NULL)
87229 goto err_alloc;
87230
87231 @@ -775,9 +774,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
87232 /* Don't export sysctls to unprivileged users */
87233 if (net->user_ns != &init_user_ns)
87234 table[0].procname = NULL;
87235 - }
87236 + hdr = register_net_sysctl(net, "net/ipv4", table);
87237 + } else
87238 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
87239
87240 - hdr = register_net_sysctl(net, "net/ipv4", table);
87241 if (hdr == NULL)
87242 goto err_reg;
87243
87244 @@ -785,8 +785,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
87245 return 0;
87246
87247 err_reg:
87248 - if (!net_eq(net, &init_net))
87249 - kfree(table);
87250 + kfree(table);
87251 err_alloc:
87252 return -ENOMEM;
87253 }
87254 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
87255 index 2a83591..0064080 100644
87256 --- a/net/ipv4/ip_gre.c
87257 +++ b/net/ipv4/ip_gre.c
87258 @@ -115,7 +115,7 @@ static bool log_ecn_error = true;
87259 module_param(log_ecn_error, bool, 0644);
87260 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
87261
87262 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
87263 +static struct rtnl_link_ops ipgre_link_ops;
87264 static int ipgre_tunnel_init(struct net_device *dev);
87265
87266 static int ipgre_net_id __read_mostly;
87267 @@ -918,7 +918,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
87268 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
87269 };
87270
87271 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
87272 +static struct rtnl_link_ops ipgre_link_ops = {
87273 .kind = "gre",
87274 .maxtype = IFLA_GRE_MAX,
87275 .policy = ipgre_policy,
87276 @@ -932,7 +932,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
87277 .fill_info = ipgre_fill_info,
87278 };
87279
87280 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
87281 +static struct rtnl_link_ops ipgre_tap_ops = {
87282 .kind = "gretap",
87283 .maxtype = IFLA_GRE_MAX,
87284 .policy = ipgre_policy,
87285 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
87286 index d9c4f11..02b82dbc 100644
87287 --- a/net/ipv4/ip_sockglue.c
87288 +++ b/net/ipv4/ip_sockglue.c
87289 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
87290 len = min_t(unsigned int, len, opt->optlen);
87291 if (put_user(len, optlen))
87292 return -EFAULT;
87293 - if (copy_to_user(optval, opt->__data, len))
87294 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
87295 + copy_to_user(optval, opt->__data, len))
87296 return -EFAULT;
87297 return 0;
87298 }
87299 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
87300 if (sk->sk_type != SOCK_STREAM)
87301 return -ENOPROTOOPT;
87302
87303 - msg.msg_control = optval;
87304 + msg.msg_control = (void __force_kernel *)optval;
87305 msg.msg_controllen = len;
87306 msg.msg_flags = flags;
87307
87308 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
87309 index c118f6b..3ad0680 100644
87310 --- a/net/ipv4/ip_vti.c
87311 +++ b/net/ipv4/ip_vti.c
87312 @@ -47,7 +47,7 @@
87313 #define HASH_SIZE 16
87314 #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&(HASH_SIZE-1))
87315
87316 -static struct rtnl_link_ops vti_link_ops __read_mostly;
87317 +static struct rtnl_link_ops vti_link_ops;
87318
87319 static int vti_net_id __read_mostly;
87320 struct vti_net {
87321 @@ -847,7 +847,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
87322 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
87323 };
87324
87325 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
87326 +static struct rtnl_link_ops vti_link_ops = {
87327 .kind = "vti",
87328 .maxtype = IFLA_VTI_MAX,
87329 .policy = vti_policy,
87330 diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
87331 index 59cb8c7..a72160c 100644
87332 --- a/net/ipv4/ipcomp.c
87333 +++ b/net/ipv4/ipcomp.c
87334 @@ -48,7 +48,7 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info)
87335 return;
87336
87337 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
87338 - atomic_inc(&flow_cache_genid);
87339 + atomic_inc_unchecked(&flow_cache_genid);
87340 rt_genid_bump(net);
87341
87342 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_COMP, 0);
87343 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
87344 index efa1138..20dbba0 100644
87345 --- a/net/ipv4/ipconfig.c
87346 +++ b/net/ipv4/ipconfig.c
87347 @@ -334,7 +334,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
87348
87349 mm_segment_t oldfs = get_fs();
87350 set_fs(get_ds());
87351 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
87352 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
87353 set_fs(oldfs);
87354 return res;
87355 }
87356 @@ -345,7 +345,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
87357
87358 mm_segment_t oldfs = get_fs();
87359 set_fs(get_ds());
87360 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
87361 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
87362 set_fs(oldfs);
87363 return res;
87364 }
87365 @@ -356,7 +356,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
87366
87367 mm_segment_t oldfs = get_fs();
87368 set_fs(get_ds());
87369 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
87370 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
87371 set_fs(oldfs);
87372 return res;
87373 }
87374 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
87375 index 77bfcce..64a55d4 100644
87376 --- a/net/ipv4/ipip.c
87377 +++ b/net/ipv4/ipip.c
87378 @@ -124,7 +124,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
87379 static int ipip_net_id __read_mostly;
87380
87381 static int ipip_tunnel_init(struct net_device *dev);
87382 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
87383 +static struct rtnl_link_ops ipip_link_ops;
87384
87385 static int ipip_err(struct sk_buff *skb, u32 info)
87386 {
87387 @@ -404,7 +404,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
87388 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
87389 };
87390
87391 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
87392 +static struct rtnl_link_ops ipip_link_ops = {
87393 .kind = "ipip",
87394 .maxtype = IFLA_IPTUN_MAX,
87395 .policy = ipip_policy,
87396 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
87397 index 85a4f21..1beb1f5 100644
87398 --- a/net/ipv4/netfilter/arp_tables.c
87399 +++ b/net/ipv4/netfilter/arp_tables.c
87400 @@ -880,14 +880,14 @@ static int compat_table_info(const struct xt_table_info *info,
87401 #endif
87402
87403 static int get_info(struct net *net, void __user *user,
87404 - const int *len, int compat)
87405 + int len, int compat)
87406 {
87407 char name[XT_TABLE_MAXNAMELEN];
87408 struct xt_table *t;
87409 int ret;
87410
87411 - if (*len != sizeof(struct arpt_getinfo)) {
87412 - duprintf("length %u != %Zu\n", *len,
87413 + if (len != sizeof(struct arpt_getinfo)) {
87414 + duprintf("length %u != %Zu\n", len,
87415 sizeof(struct arpt_getinfo));
87416 return -EINVAL;
87417 }
87418 @@ -924,7 +924,7 @@ static int get_info(struct net *net, void __user *user,
87419 info.size = private->size;
87420 strcpy(info.name, name);
87421
87422 - if (copy_to_user(user, &info, *len) != 0)
87423 + if (copy_to_user(user, &info, len) != 0)
87424 ret = -EFAULT;
87425 else
87426 ret = 0;
87427 @@ -1683,7 +1683,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
87428
87429 switch (cmd) {
87430 case ARPT_SO_GET_INFO:
87431 - ret = get_info(sock_net(sk), user, len, 1);
87432 + ret = get_info(sock_net(sk), user, *len, 1);
87433 break;
87434 case ARPT_SO_GET_ENTRIES:
87435 ret = compat_get_entries(sock_net(sk), user, len);
87436 @@ -1728,7 +1728,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
87437
87438 switch (cmd) {
87439 case ARPT_SO_GET_INFO:
87440 - ret = get_info(sock_net(sk), user, len, 0);
87441 + ret = get_info(sock_net(sk), user, *len, 0);
87442 break;
87443
87444 case ARPT_SO_GET_ENTRIES:
87445 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
87446 index d23118d..6ad7277 100644
87447 --- a/net/ipv4/netfilter/ip_tables.c
87448 +++ b/net/ipv4/netfilter/ip_tables.c
87449 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
87450 #endif
87451
87452 static int get_info(struct net *net, void __user *user,
87453 - const int *len, int compat)
87454 + int len, int compat)
87455 {
87456 char name[XT_TABLE_MAXNAMELEN];
87457 struct xt_table *t;
87458 int ret;
87459
87460 - if (*len != sizeof(struct ipt_getinfo)) {
87461 - duprintf("length %u != %zu\n", *len,
87462 + if (len != sizeof(struct ipt_getinfo)) {
87463 + duprintf("length %u != %zu\n", len,
87464 sizeof(struct ipt_getinfo));
87465 return -EINVAL;
87466 }
87467 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
87468 info.size = private->size;
87469 strcpy(info.name, name);
87470
87471 - if (copy_to_user(user, &info, *len) != 0)
87472 + if (copy_to_user(user, &info, len) != 0)
87473 ret = -EFAULT;
87474 else
87475 ret = 0;
87476 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87477
87478 switch (cmd) {
87479 case IPT_SO_GET_INFO:
87480 - ret = get_info(sock_net(sk), user, len, 1);
87481 + ret = get_info(sock_net(sk), user, *len, 1);
87482 break;
87483 case IPT_SO_GET_ENTRIES:
87484 ret = compat_get_entries(sock_net(sk), user, len);
87485 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
87486
87487 switch (cmd) {
87488 case IPT_SO_GET_INFO:
87489 - ret = get_info(sock_net(sk), user, len, 0);
87490 + ret = get_info(sock_net(sk), user, *len, 0);
87491 break;
87492
87493 case IPT_SO_GET_ENTRIES:
87494 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
87495 index 7d93d62..cbbf2a3 100644
87496 --- a/net/ipv4/ping.c
87497 +++ b/net/ipv4/ping.c
87498 @@ -843,7 +843,7 @@ static void ping_format_sock(struct sock *sp, struct seq_file *f,
87499 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
87500 0, sock_i_ino(sp),
87501 atomic_read(&sp->sk_refcnt), sp,
87502 - atomic_read(&sp->sk_drops), len);
87503 + atomic_read_unchecked(&sp->sk_drops), len);
87504 }
87505
87506 static int ping_seq_show(struct seq_file *seq, void *v)
87507 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
87508 index dd44e0a..06dcca4 100644
87509 --- a/net/ipv4/raw.c
87510 +++ b/net/ipv4/raw.c
87511 @@ -309,7 +309,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
87512 int raw_rcv(struct sock *sk, struct sk_buff *skb)
87513 {
87514 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
87515 - atomic_inc(&sk->sk_drops);
87516 + atomic_inc_unchecked(&sk->sk_drops);
87517 kfree_skb(skb);
87518 return NET_RX_DROP;
87519 }
87520 @@ -745,16 +745,20 @@ static int raw_init(struct sock *sk)
87521
87522 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
87523 {
87524 + struct icmp_filter filter;
87525 +
87526 if (optlen > sizeof(struct icmp_filter))
87527 optlen = sizeof(struct icmp_filter);
87528 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
87529 + if (copy_from_user(&filter, optval, optlen))
87530 return -EFAULT;
87531 + raw_sk(sk)->filter = filter;
87532 return 0;
87533 }
87534
87535 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
87536 {
87537 int len, ret = -EFAULT;
87538 + struct icmp_filter filter;
87539
87540 if (get_user(len, optlen))
87541 goto out;
87542 @@ -764,8 +768,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
87543 if (len > sizeof(struct icmp_filter))
87544 len = sizeof(struct icmp_filter);
87545 ret = -EFAULT;
87546 - if (put_user(len, optlen) ||
87547 - copy_to_user(optval, &raw_sk(sk)->filter, len))
87548 + filter = raw_sk(sk)->filter;
87549 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
87550 goto out;
87551 ret = 0;
87552 out: return ret;
87553 @@ -994,7 +998,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
87554 0, 0L, 0,
87555 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
87556 0, sock_i_ino(sp),
87557 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
87558 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
87559 }
87560
87561 static int raw_seq_show(struct seq_file *seq, void *v)
87562 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
87563 index d35bbf0..faa3ab8 100644
87564 --- a/net/ipv4/route.c
87565 +++ b/net/ipv4/route.c
87566 @@ -2558,34 +2558,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
87567 .maxlen = sizeof(int),
87568 .mode = 0200,
87569 .proc_handler = ipv4_sysctl_rtcache_flush,
87570 + .extra1 = &init_net,
87571 },
87572 { },
87573 };
87574
87575 static __net_init int sysctl_route_net_init(struct net *net)
87576 {
87577 - struct ctl_table *tbl;
87578 + ctl_table_no_const *tbl = NULL;
87579
87580 - tbl = ipv4_route_flush_table;
87581 if (!net_eq(net, &init_net)) {
87582 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
87583 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
87584 if (tbl == NULL)
87585 goto err_dup;
87586
87587 /* Don't export sysctls to unprivileged users */
87588 if (net->user_ns != &init_user_ns)
87589 tbl[0].procname = NULL;
87590 - }
87591 - tbl[0].extra1 = net;
87592 + tbl[0].extra1 = net;
87593 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
87594 + } else
87595 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
87596
87597 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
87598 if (net->ipv4.route_hdr == NULL)
87599 goto err_reg;
87600 return 0;
87601
87602 err_reg:
87603 - if (tbl != ipv4_route_flush_table)
87604 - kfree(tbl);
87605 + kfree(tbl);
87606 err_dup:
87607 return -ENOMEM;
87608 }
87609 @@ -2608,7 +2608,7 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
87610
87611 static __net_init int rt_genid_init(struct net *net)
87612 {
87613 - atomic_set(&net->rt_genid, 0);
87614 + atomic_set_unchecked(&net->rt_genid, 0);
87615 get_random_bytes(&net->ipv4.dev_addr_genid,
87616 sizeof(net->ipv4.dev_addr_genid));
87617 return 0;
87618 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
87619 index fa2f63f..6554815 100644
87620 --- a/net/ipv4/sysctl_net_ipv4.c
87621 +++ b/net/ipv4/sysctl_net_ipv4.c
87622 @@ -55,7 +55,7 @@ static int ipv4_local_port_range(ctl_table *table, int write,
87623 {
87624 int ret;
87625 int range[2];
87626 - ctl_table tmp = {
87627 + ctl_table_no_const tmp = {
87628 .data = &range,
87629 .maxlen = sizeof(range),
87630 .mode = table->mode,
87631 @@ -108,7 +108,7 @@ static int ipv4_ping_group_range(ctl_table *table, int write,
87632 int ret;
87633 gid_t urange[2];
87634 kgid_t low, high;
87635 - ctl_table tmp = {
87636 + ctl_table_no_const tmp = {
87637 .data = &urange,
87638 .maxlen = sizeof(urange),
87639 .mode = table->mode,
87640 @@ -139,7 +139,7 @@ static int proc_tcp_congestion_control(ctl_table *ctl, int write,
87641 void __user *buffer, size_t *lenp, loff_t *ppos)
87642 {
87643 char val[TCP_CA_NAME_MAX];
87644 - ctl_table tbl = {
87645 + ctl_table_no_const tbl = {
87646 .data = val,
87647 .maxlen = TCP_CA_NAME_MAX,
87648 };
87649 @@ -158,7 +158,7 @@ static int proc_tcp_available_congestion_control(ctl_table *ctl,
87650 void __user *buffer, size_t *lenp,
87651 loff_t *ppos)
87652 {
87653 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
87654 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
87655 int ret;
87656
87657 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
87658 @@ -175,7 +175,7 @@ static int proc_allowed_congestion_control(ctl_table *ctl,
87659 void __user *buffer, size_t *lenp,
87660 loff_t *ppos)
87661 {
87662 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
87663 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
87664 int ret;
87665
87666 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
87667 @@ -201,15 +201,17 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
87668 struct mem_cgroup *memcg;
87669 #endif
87670
87671 - ctl_table tmp = {
87672 + ctl_table_no_const tmp = {
87673 .data = &vec,
87674 .maxlen = sizeof(vec),
87675 .mode = ctl->mode,
87676 };
87677
87678 if (!write) {
87679 - ctl->data = &net->ipv4.sysctl_tcp_mem;
87680 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
87681 + ctl_table_no_const tcp_mem = *ctl;
87682 +
87683 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
87684 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
87685 }
87686
87687 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
87688 @@ -236,7 +238,7 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
87689 static int proc_tcp_fastopen_key(ctl_table *ctl, int write, void __user *buffer,
87690 size_t *lenp, loff_t *ppos)
87691 {
87692 - ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
87693 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
87694 struct tcp_fastopen_context *ctxt;
87695 int ret;
87696 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
87697 @@ -477,7 +479,7 @@ static struct ctl_table ipv4_table[] = {
87698 },
87699 {
87700 .procname = "ip_local_reserved_ports",
87701 - .data = NULL, /* initialized in sysctl_ipv4_init */
87702 + .data = sysctl_local_reserved_ports,
87703 .maxlen = 65536,
87704 .mode = 0644,
87705 .proc_handler = proc_do_large_bitmap,
87706 @@ -842,11 +844,10 @@ static struct ctl_table ipv4_net_table[] = {
87707
87708 static __net_init int ipv4_sysctl_init_net(struct net *net)
87709 {
87710 - struct ctl_table *table;
87711 + ctl_table_no_const *table = NULL;
87712
87713 - table = ipv4_net_table;
87714 if (!net_eq(net, &init_net)) {
87715 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
87716 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
87717 if (table == NULL)
87718 goto err_alloc;
87719
87720 @@ -881,15 +882,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
87721
87722 tcp_init_mem(net);
87723
87724 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
87725 + if (!net_eq(net, &init_net))
87726 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
87727 + else
87728 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
87729 if (net->ipv4.ipv4_hdr == NULL)
87730 goto err_reg;
87731
87732 return 0;
87733
87734 err_reg:
87735 - if (!net_eq(net, &init_net))
87736 - kfree(table);
87737 + kfree(table);
87738 err_alloc:
87739 return -ENOMEM;
87740 }
87741 @@ -911,16 +914,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
87742 static __init int sysctl_ipv4_init(void)
87743 {
87744 struct ctl_table_header *hdr;
87745 - struct ctl_table *i;
87746 -
87747 - for (i = ipv4_table; i->procname; i++) {
87748 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
87749 - i->data = sysctl_local_reserved_ports;
87750 - break;
87751 - }
87752 - }
87753 - if (!i->procname)
87754 - return -EINVAL;
87755
87756 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
87757 if (hdr == NULL)
87758 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
87759 index 9c62257..651cc27 100644
87760 --- a/net/ipv4/tcp_input.c
87761 +++ b/net/ipv4/tcp_input.c
87762 @@ -4436,7 +4436,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
87763 * simplifies code)
87764 */
87765 static void
87766 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
87767 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
87768 struct sk_buff *head, struct sk_buff *tail,
87769 u32 start, u32 end)
87770 {
87771 @@ -5522,6 +5522,7 @@ discard:
87772 tcp_paws_reject(&tp->rx_opt, 0))
87773 goto discard_and_undo;
87774
87775 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
87776 if (th->syn) {
87777 /* We see SYN without ACK. It is attempt of
87778 * simultaneous connect with crossed SYNs.
87779 @@ -5572,6 +5573,7 @@ discard:
87780 goto discard;
87781 #endif
87782 }
87783 +#endif
87784 /* "fifth, if neither of the SYN or RST bits is set then
87785 * drop the segment and return."
87786 */
87787 @@ -5616,7 +5618,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
87788 goto discard;
87789
87790 if (th->syn) {
87791 - if (th->fin)
87792 + if (th->fin || th->urg || th->psh)
87793 goto discard;
87794 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
87795 return 1;
87796 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
87797 index 7999fc5..c812f42 100644
87798 --- a/net/ipv4/tcp_ipv4.c
87799 +++ b/net/ipv4/tcp_ipv4.c
87800 @@ -90,6 +90,10 @@ int sysctl_tcp_low_latency __read_mostly;
87801 EXPORT_SYMBOL(sysctl_tcp_low_latency);
87802
87803
87804 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87805 +extern int grsec_enable_blackhole;
87806 +#endif
87807 +
87808 #ifdef CONFIG_TCP_MD5SIG
87809 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
87810 __be32 daddr, __be32 saddr, const struct tcphdr *th);
87811 @@ -1855,6 +1859,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
87812 return 0;
87813
87814 reset:
87815 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87816 + if (!grsec_enable_blackhole)
87817 +#endif
87818 tcp_v4_send_reset(rsk, skb);
87819 discard:
87820 kfree_skb(skb);
87821 @@ -2000,12 +2007,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
87822 TCP_SKB_CB(skb)->sacked = 0;
87823
87824 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
87825 - if (!sk)
87826 + if (!sk) {
87827 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87828 + ret = 1;
87829 +#endif
87830 goto no_tcp_socket;
87831 -
87832 + }
87833 process:
87834 - if (sk->sk_state == TCP_TIME_WAIT)
87835 + if (sk->sk_state == TCP_TIME_WAIT) {
87836 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87837 + ret = 2;
87838 +#endif
87839 goto do_time_wait;
87840 + }
87841
87842 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
87843 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
87844 @@ -2058,6 +2072,10 @@ csum_error:
87845 bad_packet:
87846 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
87847 } else {
87848 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87849 + if (!grsec_enable_blackhole || (ret == 1 &&
87850 + (skb->dev->flags & IFF_LOOPBACK)))
87851 +#endif
87852 tcp_v4_send_reset(NULL, skb);
87853 }
87854
87855 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
87856 index 0f01788..d52a859 100644
87857 --- a/net/ipv4/tcp_minisocks.c
87858 +++ b/net/ipv4/tcp_minisocks.c
87859 @@ -27,6 +27,10 @@
87860 #include <net/inet_common.h>
87861 #include <net/xfrm.h>
87862
87863 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87864 +extern int grsec_enable_blackhole;
87865 +#endif
87866 +
87867 int sysctl_tcp_syncookies __read_mostly = 1;
87868 EXPORT_SYMBOL(sysctl_tcp_syncookies);
87869
87870 @@ -717,7 +721,10 @@ embryonic_reset:
87871 * avoid becoming vulnerable to outside attack aiming at
87872 * resetting legit local connections.
87873 */
87874 - req->rsk_ops->send_reset(sk, skb);
87875 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87876 + if (!grsec_enable_blackhole)
87877 +#endif
87878 + req->rsk_ops->send_reset(sk, skb);
87879 } else if (fastopen) { /* received a valid RST pkt */
87880 reqsk_fastopen_remove(sk, req, true);
87881 tcp_reset(sk);
87882 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
87883 index d4943f6..e7a74a5 100644
87884 --- a/net/ipv4/tcp_probe.c
87885 +++ b/net/ipv4/tcp_probe.c
87886 @@ -204,7 +204,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
87887 if (cnt + width >= len)
87888 break;
87889
87890 - if (copy_to_user(buf + cnt, tbuf, width))
87891 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
87892 return -EFAULT;
87893 cnt += width;
87894 }
87895 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
87896 index 4b85e6f..22f9ac9 100644
87897 --- a/net/ipv4/tcp_timer.c
87898 +++ b/net/ipv4/tcp_timer.c
87899 @@ -22,6 +22,10 @@
87900 #include <linux/gfp.h>
87901 #include <net/tcp.h>
87902
87903 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87904 +extern int grsec_lastack_retries;
87905 +#endif
87906 +
87907 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
87908 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
87909 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
87910 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
87911 }
87912 }
87913
87914 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87915 + if ((sk->sk_state == TCP_LAST_ACK) &&
87916 + (grsec_lastack_retries > 0) &&
87917 + (grsec_lastack_retries < retry_until))
87918 + retry_until = grsec_lastack_retries;
87919 +#endif
87920 +
87921 if (retransmits_timed_out(sk, retry_until,
87922 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
87923 /* Has it gone just too far? */
87924 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
87925 index 0bf5d399..79a725f 100644
87926 --- a/net/ipv4/udp.c
87927 +++ b/net/ipv4/udp.c
87928 @@ -87,6 +87,7 @@
87929 #include <linux/types.h>
87930 #include <linux/fcntl.h>
87931 #include <linux/module.h>
87932 +#include <linux/security.h>
87933 #include <linux/socket.h>
87934 #include <linux/sockios.h>
87935 #include <linux/igmp.h>
87936 @@ -111,6 +112,10 @@
87937 #include <trace/events/skb.h>
87938 #include "udp_impl.h"
87939
87940 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
87941 +extern int grsec_enable_blackhole;
87942 +#endif
87943 +
87944 struct udp_table udp_table __read_mostly;
87945 EXPORT_SYMBOL(udp_table);
87946
87947 @@ -594,6 +599,9 @@ found:
87948 return s;
87949 }
87950
87951 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
87952 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
87953 +
87954 /*
87955 * This routine is called by the ICMP module when it gets some
87956 * sort of error condition. If err < 0 then the socket should
87957 @@ -889,9 +897,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
87958 dport = usin->sin_port;
87959 if (dport == 0)
87960 return -EINVAL;
87961 +
87962 + err = gr_search_udp_sendmsg(sk, usin);
87963 + if (err)
87964 + return err;
87965 } else {
87966 if (sk->sk_state != TCP_ESTABLISHED)
87967 return -EDESTADDRREQ;
87968 +
87969 + err = gr_search_udp_sendmsg(sk, NULL);
87970 + if (err)
87971 + return err;
87972 +
87973 daddr = inet->inet_daddr;
87974 dport = inet->inet_dport;
87975 /* Open fast path for connected socket.
87976 @@ -1135,7 +1152,7 @@ static unsigned int first_packet_length(struct sock *sk)
87977 IS_UDPLITE(sk));
87978 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
87979 IS_UDPLITE(sk));
87980 - atomic_inc(&sk->sk_drops);
87981 + atomic_inc_unchecked(&sk->sk_drops);
87982 __skb_unlink(skb, rcvq);
87983 __skb_queue_tail(&list_kill, skb);
87984 }
87985 @@ -1221,6 +1238,10 @@ try_again:
87986 if (!skb)
87987 goto out;
87988
87989 + err = gr_search_udp_recvmsg(sk, skb);
87990 + if (err)
87991 + goto out_free;
87992 +
87993 ulen = skb->len - sizeof(struct udphdr);
87994 copied = len;
87995 if (copied > ulen)
87996 @@ -1254,7 +1275,7 @@ try_again:
87997 if (unlikely(err)) {
87998 trace_kfree_skb(skb, udp_recvmsg);
87999 if (!peeked) {
88000 - atomic_inc(&sk->sk_drops);
88001 + atomic_inc_unchecked(&sk->sk_drops);
88002 UDP_INC_STATS_USER(sock_net(sk),
88003 UDP_MIB_INERRORS, is_udplite);
88004 }
88005 @@ -1541,7 +1562,7 @@ csum_error:
88006 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
88007 drop:
88008 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
88009 - atomic_inc(&sk->sk_drops);
88010 + atomic_inc_unchecked(&sk->sk_drops);
88011 kfree_skb(skb);
88012 return -1;
88013 }
88014 @@ -1560,7 +1581,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
88015 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
88016
88017 if (!skb1) {
88018 - atomic_inc(&sk->sk_drops);
88019 + atomic_inc_unchecked(&sk->sk_drops);
88020 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
88021 IS_UDPLITE(sk));
88022 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
88023 @@ -1729,6 +1750,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
88024 goto csum_error;
88025
88026 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
88027 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88028 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
88029 +#endif
88030 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
88031
88032 /*
88033 @@ -2159,7 +2183,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
88034 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
88035 0, sock_i_ino(sp),
88036 atomic_read(&sp->sk_refcnt), sp,
88037 - atomic_read(&sp->sk_drops), len);
88038 + atomic_read_unchecked(&sp->sk_drops), len);
88039 }
88040
88041 int udp4_seq_show(struct seq_file *seq, void *v)
88042 diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
88043 index 9a459be..086b866 100644
88044 --- a/net/ipv4/xfrm4_policy.c
88045 +++ b/net/ipv4/xfrm4_policy.c
88046 @@ -264,19 +264,18 @@ static struct ctl_table xfrm4_policy_table[] = {
88047
88048 static int __net_init xfrm4_net_init(struct net *net)
88049 {
88050 - struct ctl_table *table;
88051 + ctl_table_no_const *table = NULL;
88052 struct ctl_table_header *hdr;
88053
88054 - table = xfrm4_policy_table;
88055 if (!net_eq(net, &init_net)) {
88056 - table = kmemdup(table, sizeof(xfrm4_policy_table), GFP_KERNEL);
88057 + table = kmemdup(xfrm4_policy_table, sizeof(xfrm4_policy_table), GFP_KERNEL);
88058 if (!table)
88059 goto err_alloc;
88060
88061 table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh;
88062 - }
88063 -
88064 - hdr = register_net_sysctl(net, "net/ipv4", table);
88065 + hdr = register_net_sysctl(net, "net/ipv4", table);
88066 + } else
88067 + hdr = register_net_sysctl(net, "net/ipv4", xfrm4_policy_table);
88068 if (!hdr)
88069 goto err_reg;
88070
88071 @@ -284,8 +283,7 @@ static int __net_init xfrm4_net_init(struct net *net)
88072 return 0;
88073
88074 err_reg:
88075 - if (!net_eq(net, &init_net))
88076 - kfree(table);
88077 + kfree(table);
88078 err_alloc:
88079 return -ENOMEM;
88080 }
88081 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
88082 index 4ab4c38..1533b2d 100644
88083 --- a/net/ipv6/addrconf.c
88084 +++ b/net/ipv6/addrconf.c
88085 @@ -621,7 +621,7 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb,
88086 idx = 0;
88087 head = &net->dev_index_head[h];
88088 rcu_read_lock();
88089 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^
88090 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^
88091 net->dev_base_seq;
88092 hlist_for_each_entry_rcu(dev, head, index_hlist) {
88093 if (idx < s_idx)
88094 @@ -2372,7 +2372,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
88095 p.iph.ihl = 5;
88096 p.iph.protocol = IPPROTO_IPV6;
88097 p.iph.ttl = 64;
88098 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
88099 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
88100
88101 if (ops->ndo_do_ioctl) {
88102 mm_segment_t oldfs = get_fs();
88103 @@ -3994,7 +3994,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
88104 s_ip_idx = ip_idx = cb->args[2];
88105
88106 rcu_read_lock();
88107 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
88108 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
88109 for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
88110 idx = 0;
88111 head = &net->dev_index_head[h];
88112 @@ -4579,7 +4579,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
88113 dst_free(&ifp->rt->dst);
88114 break;
88115 }
88116 - atomic_inc(&net->ipv6.dev_addr_genid);
88117 + atomic_inc_unchecked(&net->ipv6.dev_addr_genid);
88118 }
88119
88120 static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
88121 @@ -4599,7 +4599,7 @@ int addrconf_sysctl_forward(ctl_table *ctl, int write,
88122 int *valp = ctl->data;
88123 int val = *valp;
88124 loff_t pos = *ppos;
88125 - ctl_table lctl;
88126 + ctl_table_no_const lctl;
88127 int ret;
88128
88129 /*
88130 @@ -4681,7 +4681,7 @@ int addrconf_sysctl_disable(ctl_table *ctl, int write,
88131 int *valp = ctl->data;
88132 int val = *valp;
88133 loff_t pos = *ppos;
88134 - ctl_table lctl;
88135 + ctl_table_no_const lctl;
88136 int ret;
88137
88138 /*
88139 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
88140 index b4ff0a4..db9b764 100644
88141 --- a/net/ipv6/icmp.c
88142 +++ b/net/ipv6/icmp.c
88143 @@ -980,7 +980,7 @@ ctl_table ipv6_icmp_table_template[] = {
88144
88145 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
88146 {
88147 - struct ctl_table *table;
88148 + ctl_table_no_const *table;
88149
88150 table = kmemdup(ipv6_icmp_table_template,
88151 sizeof(ipv6_icmp_table_template),
88152 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
88153 index ecd6073..58162ae 100644
88154 --- a/net/ipv6/ip6_gre.c
88155 +++ b/net/ipv6/ip6_gre.c
88156 @@ -74,7 +74,7 @@ struct ip6gre_net {
88157 struct net_device *fb_tunnel_dev;
88158 };
88159
88160 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
88161 +static struct rtnl_link_ops ip6gre_link_ops;
88162 static int ip6gre_tunnel_init(struct net_device *dev);
88163 static void ip6gre_tunnel_setup(struct net_device *dev);
88164 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
88165 @@ -1283,7 +1283,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
88166 }
88167
88168
88169 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
88170 +static struct inet6_protocol ip6gre_protocol = {
88171 .handler = ip6gre_rcv,
88172 .err_handler = ip6gre_err,
88173 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
88174 @@ -1617,7 +1617,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
88175 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
88176 };
88177
88178 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
88179 +static struct rtnl_link_ops ip6gre_link_ops = {
88180 .kind = "ip6gre",
88181 .maxtype = IFLA_GRE_MAX,
88182 .policy = ip6gre_policy,
88183 @@ -1630,7 +1630,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
88184 .fill_info = ip6gre_fill_info,
88185 };
88186
88187 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
88188 +static struct rtnl_link_ops ip6gre_tap_ops = {
88189 .kind = "ip6gretap",
88190 .maxtype = IFLA_GRE_MAX,
88191 .policy = ip6gre_policy,
88192 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
88193 index 1e55866..b398dab 100644
88194 --- a/net/ipv6/ip6_tunnel.c
88195 +++ b/net/ipv6/ip6_tunnel.c
88196 @@ -88,7 +88,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
88197
88198 static int ip6_tnl_dev_init(struct net_device *dev);
88199 static void ip6_tnl_dev_setup(struct net_device *dev);
88200 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
88201 +static struct rtnl_link_ops ip6_link_ops;
88202
88203 static int ip6_tnl_net_id __read_mostly;
88204 struct ip6_tnl_net {
88205 @@ -1672,7 +1672,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
88206 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
88207 };
88208
88209 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
88210 +static struct rtnl_link_ops ip6_link_ops = {
88211 .kind = "ip6tnl",
88212 .maxtype = IFLA_IPTUN_MAX,
88213 .policy = ip6_tnl_policy,
88214 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
88215 index d1e2e8e..51c19ae 100644
88216 --- a/net/ipv6/ipv6_sockglue.c
88217 +++ b/net/ipv6/ipv6_sockglue.c
88218 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
88219 if (sk->sk_type != SOCK_STREAM)
88220 return -ENOPROTOOPT;
88221
88222 - msg.msg_control = optval;
88223 + msg.msg_control = (void __force_kernel *)optval;
88224 msg.msg_controllen = len;
88225 msg.msg_flags = flags;
88226
88227 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
88228 index 44400c2..8e11f52 100644
88229 --- a/net/ipv6/netfilter/ip6_tables.c
88230 +++ b/net/ipv6/netfilter/ip6_tables.c
88231 @@ -1078,14 +1078,14 @@ static int compat_table_info(const struct xt_table_info *info,
88232 #endif
88233
88234 static int get_info(struct net *net, void __user *user,
88235 - const int *len, int compat)
88236 + int len, int compat)
88237 {
88238 char name[XT_TABLE_MAXNAMELEN];
88239 struct xt_table *t;
88240 int ret;
88241
88242 - if (*len != sizeof(struct ip6t_getinfo)) {
88243 - duprintf("length %u != %zu\n", *len,
88244 + if (len != sizeof(struct ip6t_getinfo)) {
88245 + duprintf("length %u != %zu\n", len,
88246 sizeof(struct ip6t_getinfo));
88247 return -EINVAL;
88248 }
88249 @@ -1122,7 +1122,7 @@ static int get_info(struct net *net, void __user *user,
88250 info.size = private->size;
88251 strcpy(info.name, name);
88252
88253 - if (copy_to_user(user, &info, *len) != 0)
88254 + if (copy_to_user(user, &info, len) != 0)
88255 ret = -EFAULT;
88256 else
88257 ret = 0;
88258 @@ -1976,7 +1976,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
88259
88260 switch (cmd) {
88261 case IP6T_SO_GET_INFO:
88262 - ret = get_info(sock_net(sk), user, len, 1);
88263 + ret = get_info(sock_net(sk), user, *len, 1);
88264 break;
88265 case IP6T_SO_GET_ENTRIES:
88266 ret = compat_get_entries(sock_net(sk), user, len);
88267 @@ -2023,7 +2023,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
88268
88269 switch (cmd) {
88270 case IP6T_SO_GET_INFO:
88271 - ret = get_info(sock_net(sk), user, len, 0);
88272 + ret = get_info(sock_net(sk), user, *len, 0);
88273 break;
88274
88275 case IP6T_SO_GET_ENTRIES:
88276 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
88277 index dffdc1a..ccc6678 100644
88278 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
88279 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
88280 @@ -90,12 +90,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
88281
88282 static int nf_ct_frag6_sysctl_register(struct net *net)
88283 {
88284 - struct ctl_table *table;
88285 + ctl_table_no_const *table = NULL;
88286 struct ctl_table_header *hdr;
88287
88288 - table = nf_ct_frag6_sysctl_table;
88289 if (!net_eq(net, &init_net)) {
88290 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
88291 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
88292 GFP_KERNEL);
88293 if (table == NULL)
88294 goto err_alloc;
88295 @@ -103,9 +102,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
88296 table[0].data = &net->nf_frag.frags.timeout;
88297 table[1].data = &net->nf_frag.frags.low_thresh;
88298 table[2].data = &net->nf_frag.frags.high_thresh;
88299 - }
88300 -
88301 - hdr = register_net_sysctl(net, "net/netfilter", table);
88302 + hdr = register_net_sysctl(net, "net/netfilter", table);
88303 + } else
88304 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
88305 if (hdr == NULL)
88306 goto err_reg;
88307
88308 @@ -113,8 +112,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
88309 return 0;
88310
88311 err_reg:
88312 - if (!net_eq(net, &init_net))
88313 - kfree(table);
88314 + kfree(table);
88315 err_alloc:
88316 return -ENOMEM;
88317 }
88318 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
88319 index eedff8c..6e13a47 100644
88320 --- a/net/ipv6/raw.c
88321 +++ b/net/ipv6/raw.c
88322 @@ -378,7 +378,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
88323 {
88324 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
88325 skb_checksum_complete(skb)) {
88326 - atomic_inc(&sk->sk_drops);
88327 + atomic_inc_unchecked(&sk->sk_drops);
88328 kfree_skb(skb);
88329 return NET_RX_DROP;
88330 }
88331 @@ -406,7 +406,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
88332 struct raw6_sock *rp = raw6_sk(sk);
88333
88334 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
88335 - atomic_inc(&sk->sk_drops);
88336 + atomic_inc_unchecked(&sk->sk_drops);
88337 kfree_skb(skb);
88338 return NET_RX_DROP;
88339 }
88340 @@ -430,7 +430,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
88341
88342 if (inet->hdrincl) {
88343 if (skb_checksum_complete(skb)) {
88344 - atomic_inc(&sk->sk_drops);
88345 + atomic_inc_unchecked(&sk->sk_drops);
88346 kfree_skb(skb);
88347 return NET_RX_DROP;
88348 }
88349 @@ -602,7 +602,7 @@ out:
88350 return err;
88351 }
88352
88353 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
88354 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
88355 struct flowi6 *fl6, struct dst_entry **dstp,
88356 unsigned int flags)
88357 {
88358 @@ -914,12 +914,15 @@ do_confirm:
88359 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
88360 char __user *optval, int optlen)
88361 {
88362 + struct icmp6_filter filter;
88363 +
88364 switch (optname) {
88365 case ICMPV6_FILTER:
88366 if (optlen > sizeof(struct icmp6_filter))
88367 optlen = sizeof(struct icmp6_filter);
88368 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
88369 + if (copy_from_user(&filter, optval, optlen))
88370 return -EFAULT;
88371 + raw6_sk(sk)->filter = filter;
88372 return 0;
88373 default:
88374 return -ENOPROTOOPT;
88375 @@ -932,6 +935,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
88376 char __user *optval, int __user *optlen)
88377 {
88378 int len;
88379 + struct icmp6_filter filter;
88380
88381 switch (optname) {
88382 case ICMPV6_FILTER:
88383 @@ -943,7 +947,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
88384 len = sizeof(struct icmp6_filter);
88385 if (put_user(len, optlen))
88386 return -EFAULT;
88387 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
88388 + filter = raw6_sk(sk)->filter;
88389 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
88390 return -EFAULT;
88391 return 0;
88392 default:
88393 @@ -1251,7 +1256,7 @@ static void raw6_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
88394 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
88395 0,
88396 sock_i_ino(sp),
88397 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
88398 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
88399 }
88400
88401 static int raw6_seq_show(struct seq_file *seq, void *v)
88402 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
88403 index 790d9f4..68ae078 100644
88404 --- a/net/ipv6/reassembly.c
88405 +++ b/net/ipv6/reassembly.c
88406 @@ -621,12 +621,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
88407
88408 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
88409 {
88410 - struct ctl_table *table;
88411 + ctl_table_no_const *table = NULL;
88412 struct ctl_table_header *hdr;
88413
88414 - table = ip6_frags_ns_ctl_table;
88415 if (!net_eq(net, &init_net)) {
88416 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
88417 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
88418 if (table == NULL)
88419 goto err_alloc;
88420
88421 @@ -637,9 +636,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
88422 /* Don't export sysctls to unprivileged users */
88423 if (net->user_ns != &init_user_ns)
88424 table[0].procname = NULL;
88425 - }
88426 + hdr = register_net_sysctl(net, "net/ipv6", table);
88427 + } else
88428 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
88429
88430 - hdr = register_net_sysctl(net, "net/ipv6", table);
88431 if (hdr == NULL)
88432 goto err_reg;
88433
88434 @@ -647,8 +647,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
88435 return 0;
88436
88437 err_reg:
88438 - if (!net_eq(net, &init_net))
88439 - kfree(table);
88440 + kfree(table);
88441 err_alloc:
88442 return -ENOMEM;
88443 }
88444 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
88445 index ad0aa6b..beaef03 100644
88446 --- a/net/ipv6/route.c
88447 +++ b/net/ipv6/route.c
88448 @@ -2881,7 +2881,7 @@ ctl_table ipv6_route_table_template[] = {
88449
88450 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
88451 {
88452 - struct ctl_table *table;
88453 + ctl_table_no_const *table;
88454
88455 table = kmemdup(ipv6_route_table_template,
88456 sizeof(ipv6_route_table_template),
88457 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
88458 index 3353634..3d5084a 100644
88459 --- a/net/ipv6/sit.c
88460 +++ b/net/ipv6/sit.c
88461 @@ -74,7 +74,7 @@ static void ipip6_tunnel_setup(struct net_device *dev);
88462 static void ipip6_dev_free(struct net_device *dev);
88463 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
88464 __be32 *v4dst);
88465 -static struct rtnl_link_ops sit_link_ops __read_mostly;
88466 +static struct rtnl_link_ops sit_link_ops;
88467
88468 static int sit_net_id __read_mostly;
88469 struct sit_net {
88470 @@ -1453,7 +1453,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
88471 #endif
88472 };
88473
88474 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
88475 +static struct rtnl_link_ops sit_link_ops = {
88476 .kind = "sit",
88477 .maxtype = IFLA_IPTUN_MAX,
88478 .policy = ipip6_policy,
88479 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
88480 index e85c48b..b8268d3 100644
88481 --- a/net/ipv6/sysctl_net_ipv6.c
88482 +++ b/net/ipv6/sysctl_net_ipv6.c
88483 @@ -40,7 +40,7 @@ static ctl_table ipv6_rotable[] = {
88484
88485 static int __net_init ipv6_sysctl_net_init(struct net *net)
88486 {
88487 - struct ctl_table *ipv6_table;
88488 + ctl_table_no_const *ipv6_table;
88489 struct ctl_table *ipv6_route_table;
88490 struct ctl_table *ipv6_icmp_table;
88491 int err;
88492 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
88493 index 0a17ed9..2526cc3 100644
88494 --- a/net/ipv6/tcp_ipv6.c
88495 +++ b/net/ipv6/tcp_ipv6.c
88496 @@ -103,6 +103,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
88497 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
88498 }
88499
88500 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88501 +extern int grsec_enable_blackhole;
88502 +#endif
88503 +
88504 static void tcp_v6_hash(struct sock *sk)
88505 {
88506 if (sk->sk_state != TCP_CLOSE) {
88507 @@ -1398,6 +1402,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
88508 return 0;
88509
88510 reset:
88511 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88512 + if (!grsec_enable_blackhole)
88513 +#endif
88514 tcp_v6_send_reset(sk, skb);
88515 discard:
88516 if (opt_skb)
88517 @@ -1480,12 +1487,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
88518 TCP_SKB_CB(skb)->sacked = 0;
88519
88520 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
88521 - if (!sk)
88522 + if (!sk) {
88523 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88524 + ret = 1;
88525 +#endif
88526 goto no_tcp_socket;
88527 + }
88528
88529 process:
88530 - if (sk->sk_state == TCP_TIME_WAIT)
88531 + if (sk->sk_state == TCP_TIME_WAIT) {
88532 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88533 + ret = 2;
88534 +#endif
88535 goto do_time_wait;
88536 + }
88537
88538 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
88539 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
88540 @@ -1536,6 +1551,10 @@ csum_error:
88541 bad_packet:
88542 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
88543 } else {
88544 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88545 + if (!grsec_enable_blackhole || (ret == 1 &&
88546 + (skb->dev->flags & IFF_LOOPBACK)))
88547 +#endif
88548 tcp_v6_send_reset(NULL, skb);
88549 }
88550
88551 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
88552 index 42923b1..8ca3d6e 100644
88553 --- a/net/ipv6/udp.c
88554 +++ b/net/ipv6/udp.c
88555 @@ -52,6 +52,10 @@
88556 #include <trace/events/skb.h>
88557 #include "udp_impl.h"
88558
88559 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88560 +extern int grsec_enable_blackhole;
88561 +#endif
88562 +
88563 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
88564 {
88565 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
88566 @@ -419,7 +423,7 @@ try_again:
88567 if (unlikely(err)) {
88568 trace_kfree_skb(skb, udpv6_recvmsg);
88569 if (!peeked) {
88570 - atomic_inc(&sk->sk_drops);
88571 + atomic_inc_unchecked(&sk->sk_drops);
88572 if (is_udp4)
88573 UDP_INC_STATS_USER(sock_net(sk),
88574 UDP_MIB_INERRORS,
88575 @@ -665,7 +669,7 @@ csum_error:
88576 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
88577 drop:
88578 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
88579 - atomic_inc(&sk->sk_drops);
88580 + atomic_inc_unchecked(&sk->sk_drops);
88581 kfree_skb(skb);
88582 return -1;
88583 }
88584 @@ -723,7 +727,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
88585 if (likely(skb1 == NULL))
88586 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
88587 if (!skb1) {
88588 - atomic_inc(&sk->sk_drops);
88589 + atomic_inc_unchecked(&sk->sk_drops);
88590 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
88591 IS_UDPLITE(sk));
88592 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
88593 @@ -860,6 +864,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
88594 goto csum_error;
88595
88596 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
88597 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
88598 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
88599 +#endif
88600 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
88601
88602 kfree_skb(skb);
88603 @@ -1387,7 +1394,7 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket
88604 0,
88605 sock_i_ino(sp),
88606 atomic_read(&sp->sk_refcnt), sp,
88607 - atomic_read(&sp->sk_drops));
88608 + atomic_read_unchecked(&sp->sk_drops));
88609 }
88610
88611 int udp6_seq_show(struct seq_file *seq, void *v)
88612 diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
88613 index 23ed03d..465a71d 100644
88614 --- a/net/ipv6/xfrm6_policy.c
88615 +++ b/net/ipv6/xfrm6_policy.c
88616 @@ -324,19 +324,19 @@ static struct ctl_table xfrm6_policy_table[] = {
88617
88618 static int __net_init xfrm6_net_init(struct net *net)
88619 {
88620 - struct ctl_table *table;
88621 + ctl_table_no_const *table = NULL;
88622 struct ctl_table_header *hdr;
88623
88624 - table = xfrm6_policy_table;
88625 if (!net_eq(net, &init_net)) {
88626 - table = kmemdup(table, sizeof(xfrm6_policy_table), GFP_KERNEL);
88627 + table = kmemdup(xfrm6_policy_table, sizeof(xfrm6_policy_table), GFP_KERNEL);
88628 if (!table)
88629 goto err_alloc;
88630
88631 table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh;
88632 - }
88633 + hdr = register_net_sysctl(net, "net/ipv6", table);
88634 + } else
88635 + hdr = register_net_sysctl(net, "net/ipv6", xfrm6_policy_table);
88636
88637 - hdr = register_net_sysctl(net, "net/ipv6", table);
88638 if (!hdr)
88639 goto err_reg;
88640
88641 @@ -344,8 +344,7 @@ static int __net_init xfrm6_net_init(struct net *net)
88642 return 0;
88643
88644 err_reg:
88645 - if (!net_eq(net, &init_net))
88646 - kfree(table);
88647 + kfree(table);
88648 err_alloc:
88649 return -ENOMEM;
88650 }
88651 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
88652 index 41ac7938..75e3bb1 100644
88653 --- a/net/irda/ircomm/ircomm_tty.c
88654 +++ b/net/irda/ircomm/ircomm_tty.c
88655 @@ -319,11 +319,11 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
88656 add_wait_queue(&port->open_wait, &wait);
88657
88658 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
88659 - __FILE__, __LINE__, tty->driver->name, port->count);
88660 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
88661
88662 spin_lock_irqsave(&port->lock, flags);
88663 if (!tty_hung_up_p(filp))
88664 - port->count--;
88665 + atomic_dec(&port->count);
88666 port->blocked_open++;
88667 spin_unlock_irqrestore(&port->lock, flags);
88668
88669 @@ -358,7 +358,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
88670 }
88671
88672 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
88673 - __FILE__, __LINE__, tty->driver->name, port->count);
88674 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
88675
88676 schedule();
88677 }
88678 @@ -368,12 +368,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
88679
88680 spin_lock_irqsave(&port->lock, flags);
88681 if (!tty_hung_up_p(filp))
88682 - port->count++;
88683 + atomic_inc(&port->count);
88684 port->blocked_open--;
88685 spin_unlock_irqrestore(&port->lock, flags);
88686
88687 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
88688 - __FILE__, __LINE__, tty->driver->name, port->count);
88689 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
88690
88691 if (!retval)
88692 port->flags |= ASYNC_NORMAL_ACTIVE;
88693 @@ -447,12 +447,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
88694
88695 /* ++ is not atomic, so this should be protected - Jean II */
88696 spin_lock_irqsave(&self->port.lock, flags);
88697 - self->port.count++;
88698 + atomic_inc(&self->port.count);
88699 spin_unlock_irqrestore(&self->port.lock, flags);
88700 tty_port_tty_set(&self->port, tty);
88701
88702 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
88703 - self->line, self->port.count);
88704 + self->line, atomic_read(&self->port.count));
88705
88706 /* Not really used by us, but lets do it anyway */
88707 self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
88708 @@ -989,7 +989,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
88709 tty_kref_put(port->tty);
88710 }
88711 port->tty = NULL;
88712 - port->count = 0;
88713 + atomic_set(&port->count, 0);
88714 spin_unlock_irqrestore(&port->lock, flags);
88715
88716 wake_up_interruptible(&port->open_wait);
88717 @@ -1346,7 +1346,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
88718 seq_putc(m, '\n');
88719
88720 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
88721 - seq_printf(m, "Open count: %d\n", self->port.count);
88722 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
88723 seq_printf(m, "Max data size: %d\n", self->max_data_size);
88724 seq_printf(m, "Max header size: %d\n", self->max_header_size);
88725
88726 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
88727 index ae69165..c8b82d8 100644
88728 --- a/net/iucv/af_iucv.c
88729 +++ b/net/iucv/af_iucv.c
88730 @@ -773,10 +773,10 @@ static int iucv_sock_autobind(struct sock *sk)
88731
88732 write_lock_bh(&iucv_sk_list.lock);
88733
88734 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
88735 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
88736 while (__iucv_get_sock_by_name(name)) {
88737 sprintf(name, "%08x",
88738 - atomic_inc_return(&iucv_sk_list.autobind_name));
88739 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
88740 }
88741
88742 write_unlock_bh(&iucv_sk_list.lock);
88743 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
88744 index 4fe76ff..426a904 100644
88745 --- a/net/iucv/iucv.c
88746 +++ b/net/iucv/iucv.c
88747 @@ -690,7 +690,7 @@ static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
88748 return NOTIFY_OK;
88749 }
88750
88751 -static struct notifier_block __refdata iucv_cpu_notifier = {
88752 +static struct notifier_block iucv_cpu_notifier = {
88753 .notifier_call = iucv_cpu_notify,
88754 };
88755
88756 diff --git a/net/key/af_key.c b/net/key/af_key.c
88757 index 9da8620..97070ad 100644
88758 --- a/net/key/af_key.c
88759 +++ b/net/key/af_key.c
88760 @@ -3047,10 +3047,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
88761 static u32 get_acqseq(void)
88762 {
88763 u32 res;
88764 - static atomic_t acqseq;
88765 + static atomic_unchecked_t acqseq;
88766
88767 do {
88768 - res = atomic_inc_return(&acqseq);
88769 + res = atomic_inc_return_unchecked(&acqseq);
88770 } while (!res);
88771 return res;
88772 }
88773 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
88774 index 4fdb306e..920086a 100644
88775 --- a/net/mac80211/cfg.c
88776 +++ b/net/mac80211/cfg.c
88777 @@ -804,7 +804,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
88778 ret = ieee80211_vif_use_channel(sdata, chandef,
88779 IEEE80211_CHANCTX_EXCLUSIVE);
88780 }
88781 - } else if (local->open_count == local->monitors) {
88782 + } else if (local_read(&local->open_count) == local->monitors) {
88783 local->_oper_chandef = *chandef;
88784 ieee80211_hw_config(local, 0);
88785 }
88786 @@ -2920,7 +2920,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
88787 else
88788 local->probe_req_reg--;
88789
88790 - if (!local->open_count)
88791 + if (!local_read(&local->open_count))
88792 break;
88793
88794 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
88795 @@ -3383,8 +3383,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
88796 if (chanctx_conf) {
88797 *chandef = chanctx_conf->def;
88798 ret = 0;
88799 - } else if (local->open_count > 0 &&
88800 - local->open_count == local->monitors &&
88801 + } else if (local_read(&local->open_count) > 0 &&
88802 + local_read(&local->open_count) == local->monitors &&
88803 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
88804 if (local->use_chanctx)
88805 *chandef = local->monitor_chandef;
88806 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
88807 index 9ca8e32..48e4a9b 100644
88808 --- a/net/mac80211/ieee80211_i.h
88809 +++ b/net/mac80211/ieee80211_i.h
88810 @@ -28,6 +28,7 @@
88811 #include <net/ieee80211_radiotap.h>
88812 #include <net/cfg80211.h>
88813 #include <net/mac80211.h>
88814 +#include <asm/local.h>
88815 #include "key.h"
88816 #include "sta_info.h"
88817 #include "debug.h"
88818 @@ -891,7 +892,7 @@ struct ieee80211_local {
88819 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
88820 spinlock_t queue_stop_reason_lock;
88821
88822 - int open_count;
88823 + local_t open_count;
88824 int monitors, cooked_mntrs;
88825 /* number of interfaces with corresponding FIF_ flags */
88826 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
88827 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
88828 index 98d20c0..586675b 100644
88829 --- a/net/mac80211/iface.c
88830 +++ b/net/mac80211/iface.c
88831 @@ -502,7 +502,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88832 break;
88833 }
88834
88835 - if (local->open_count == 0) {
88836 + if (local_read(&local->open_count) == 0) {
88837 res = drv_start(local);
88838 if (res)
88839 goto err_del_bss;
88840 @@ -545,7 +545,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88841 break;
88842 }
88843
88844 - if (local->monitors == 0 && local->open_count == 0) {
88845 + if (local->monitors == 0 && local_read(&local->open_count) == 0) {
88846 res = ieee80211_add_virtual_monitor(local);
88847 if (res)
88848 goto err_stop;
88849 @@ -653,7 +653,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88850 atomic_inc(&local->iff_promiscs);
88851
88852 if (coming_up)
88853 - local->open_count++;
88854 + local_inc(&local->open_count);
88855
88856 if (hw_reconf_flags)
88857 ieee80211_hw_config(local, hw_reconf_flags);
88858 @@ -691,7 +691,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
88859 err_del_interface:
88860 drv_remove_interface(local, sdata);
88861 err_stop:
88862 - if (!local->open_count)
88863 + if (!local_read(&local->open_count))
88864 drv_stop(local);
88865 err_del_bss:
88866 sdata->bss = NULL;
88867 @@ -828,7 +828,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88868 }
88869
88870 if (going_down)
88871 - local->open_count--;
88872 + local_dec(&local->open_count);
88873
88874 switch (sdata->vif.type) {
88875 case NL80211_IFTYPE_AP_VLAN:
88876 @@ -895,7 +895,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88877 }
88878 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
88879
88880 - if (local->open_count == 0)
88881 + if (local_read(&local->open_count) == 0)
88882 ieee80211_clear_tx_pending(local);
88883
88884 /*
88885 @@ -931,7 +931,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88886
88887 ieee80211_recalc_ps(local, -1);
88888
88889 - if (local->open_count == 0) {
88890 + if (local_read(&local->open_count) == 0) {
88891 ieee80211_stop_device(local);
88892
88893 /* no reconfiguring after stop! */
88894 @@ -942,7 +942,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
88895 ieee80211_configure_filter(local);
88896 ieee80211_hw_config(local, hw_reconf_flags);
88897
88898 - if (local->monitors == local->open_count)
88899 + if (local->monitors == local_read(&local->open_count))
88900 ieee80211_add_virtual_monitor(local);
88901 }
88902
88903 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
88904 index 8a7bfc4..4407cd0 100644
88905 --- a/net/mac80211/main.c
88906 +++ b/net/mac80211/main.c
88907 @@ -181,7 +181,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
88908 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
88909 IEEE80211_CONF_CHANGE_POWER);
88910
88911 - if (changed && local->open_count) {
88912 + if (changed && local_read(&local->open_count)) {
88913 ret = drv_config(local, changed);
88914 /*
88915 * Goal:
88916 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
88917 index 7fc5d0d..07ea536 100644
88918 --- a/net/mac80211/pm.c
88919 +++ b/net/mac80211/pm.c
88920 @@ -12,7 +12,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88921 struct ieee80211_sub_if_data *sdata;
88922 struct sta_info *sta;
88923
88924 - if (!local->open_count)
88925 + if (!local_read(&local->open_count))
88926 goto suspend;
88927
88928 ieee80211_scan_cancel(local);
88929 @@ -59,7 +59,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88930 cancel_work_sync(&local->dynamic_ps_enable_work);
88931 del_timer_sync(&local->dynamic_ps_timer);
88932
88933 - local->wowlan = wowlan && local->open_count;
88934 + local->wowlan = wowlan && local_read(&local->open_count);
88935 if (local->wowlan) {
88936 int err = drv_suspend(local, wowlan);
88937 if (err < 0) {
88938 @@ -113,7 +113,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
88939 WARN_ON(!list_empty(&local->chanctx_list));
88940
88941 /* stop hardware - this must stop RX */
88942 - if (local->open_count)
88943 + if (local_read(&local->open_count))
88944 ieee80211_stop_device(local);
88945
88946 suspend:
88947 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
88948 index a02bef3..f2f38dd 100644
88949 --- a/net/mac80211/rate.c
88950 +++ b/net/mac80211/rate.c
88951 @@ -712,7 +712,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
88952
88953 ASSERT_RTNL();
88954
88955 - if (local->open_count)
88956 + if (local_read(&local->open_count))
88957 return -EBUSY;
88958
88959 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
88960 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
88961 index c97a065..ff61928 100644
88962 --- a/net/mac80211/rc80211_pid_debugfs.c
88963 +++ b/net/mac80211/rc80211_pid_debugfs.c
88964 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
88965
88966 spin_unlock_irqrestore(&events->lock, status);
88967
88968 - if (copy_to_user(buf, pb, p))
88969 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
88970 return -EFAULT;
88971
88972 return p;
88973 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
88974 index 72e6292..e6319eb 100644
88975 --- a/net/mac80211/util.c
88976 +++ b/net/mac80211/util.c
88977 @@ -1472,7 +1472,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
88978 }
88979 #endif
88980 /* everything else happens only if HW was up & running */
88981 - if (!local->open_count)
88982 + if (!local_read(&local->open_count))
88983 goto wake_up;
88984
88985 /*
88986 @@ -1696,7 +1696,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
88987 local->in_reconfig = false;
88988 barrier();
88989
88990 - if (local->monitors == local->open_count && local->monitors > 0)
88991 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
88992 ieee80211_add_virtual_monitor(local);
88993
88994 /*
88995 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
88996 index 56d22ca..87c778f 100644
88997 --- a/net/netfilter/Kconfig
88998 +++ b/net/netfilter/Kconfig
88999 @@ -958,6 +958,16 @@ config NETFILTER_XT_MATCH_ESP
89000
89001 To compile it as a module, choose M here. If unsure, say N.
89002
89003 +config NETFILTER_XT_MATCH_GRADM
89004 + tristate '"gradm" match support'
89005 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
89006 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
89007 + ---help---
89008 + The gradm match allows to match on grsecurity RBAC being enabled.
89009 + It is useful when iptables rules are applied early on bootup to
89010 + prevent connections to the machine (except from a trusted host)
89011 + while the RBAC system is disabled.
89012 +
89013 config NETFILTER_XT_MATCH_HASHLIMIT
89014 tristate '"hashlimit" match support'
89015 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
89016 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
89017 index a1abf87..dbcb7ee 100644
89018 --- a/net/netfilter/Makefile
89019 +++ b/net/netfilter/Makefile
89020 @@ -112,6 +112,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
89021 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
89022 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
89023 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
89024 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
89025 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
89026 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
89027 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
89028 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
89029 index f771390..145b765 100644
89030 --- a/net/netfilter/ipset/ip_set_core.c
89031 +++ b/net/netfilter/ipset/ip_set_core.c
89032 @@ -1820,7 +1820,7 @@ done:
89033 return ret;
89034 }
89035
89036 -static struct nf_sockopt_ops so_set __read_mostly = {
89037 +static struct nf_sockopt_ops so_set = {
89038 .pf = PF_INET,
89039 .get_optmin = SO_IP_SET,
89040 .get_optmax = SO_IP_SET + 1,
89041 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
89042 index a083bda..da661c3 100644
89043 --- a/net/netfilter/ipvs/ip_vs_conn.c
89044 +++ b/net/netfilter/ipvs/ip_vs_conn.c
89045 @@ -556,7 +556,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
89046 /* Increase the refcnt counter of the dest */
89047 ip_vs_dest_hold(dest);
89048
89049 - conn_flags = atomic_read(&dest->conn_flags);
89050 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
89051 if (cp->protocol != IPPROTO_UDP)
89052 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
89053 flags = cp->flags;
89054 @@ -900,7 +900,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
89055
89056 cp->control = NULL;
89057 atomic_set(&cp->n_control, 0);
89058 - atomic_set(&cp->in_pkts, 0);
89059 + atomic_set_unchecked(&cp->in_pkts, 0);
89060
89061 cp->packet_xmit = NULL;
89062 cp->app = NULL;
89063 @@ -1190,7 +1190,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
89064
89065 /* Don't drop the entry if its number of incoming packets is not
89066 located in [0, 8] */
89067 - i = atomic_read(&cp->in_pkts);
89068 + i = atomic_read_unchecked(&cp->in_pkts);
89069 if (i > 8 || i < 0) return 0;
89070
89071 if (!todrop_rate[i]) return 0;
89072 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
89073 index 23b8eb5..48a8959 100644
89074 --- a/net/netfilter/ipvs/ip_vs_core.c
89075 +++ b/net/netfilter/ipvs/ip_vs_core.c
89076 @@ -559,7 +559,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
89077 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
89078 /* do not touch skb anymore */
89079
89080 - atomic_inc(&cp->in_pkts);
89081 + atomic_inc_unchecked(&cp->in_pkts);
89082 ip_vs_conn_put(cp);
89083 return ret;
89084 }
89085 @@ -1711,7 +1711,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
89086 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
89087 pkts = sysctl_sync_threshold(ipvs);
89088 else
89089 - pkts = atomic_add_return(1, &cp->in_pkts);
89090 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
89091
89092 if (ipvs->sync_state & IP_VS_STATE_MASTER)
89093 ip_vs_sync_conn(net, cp, pkts);
89094 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
89095 index 9e6c2a0..28552e2 100644
89096 --- a/net/netfilter/ipvs/ip_vs_ctl.c
89097 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
89098 @@ -789,7 +789,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
89099 */
89100 ip_vs_rs_hash(ipvs, dest);
89101 }
89102 - atomic_set(&dest->conn_flags, conn_flags);
89103 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
89104
89105 /* bind the service */
89106 if (!dest->svc) {
89107 @@ -1657,7 +1657,7 @@ proc_do_sync_ports(ctl_table *table, int write,
89108 * align with netns init in ip_vs_control_net_init()
89109 */
89110
89111 -static struct ctl_table vs_vars[] = {
89112 +static ctl_table_no_const vs_vars[] __read_only = {
89113 {
89114 .procname = "amemthresh",
89115 .maxlen = sizeof(int),
89116 @@ -2060,7 +2060,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
89117 " %-7s %-6d %-10d %-10d\n",
89118 &dest->addr.in6,
89119 ntohs(dest->port),
89120 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
89121 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
89122 atomic_read(&dest->weight),
89123 atomic_read(&dest->activeconns),
89124 atomic_read(&dest->inactconns));
89125 @@ -2071,7 +2071,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
89126 "%-7s %-6d %-10d %-10d\n",
89127 ntohl(dest->addr.ip),
89128 ntohs(dest->port),
89129 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
89130 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
89131 atomic_read(&dest->weight),
89132 atomic_read(&dest->activeconns),
89133 atomic_read(&dest->inactconns));
89134 @@ -2549,7 +2549,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
89135
89136 entry.addr = dest->addr.ip;
89137 entry.port = dest->port;
89138 - entry.conn_flags = atomic_read(&dest->conn_flags);
89139 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
89140 entry.weight = atomic_read(&dest->weight);
89141 entry.u_threshold = dest->u_threshold;
89142 entry.l_threshold = dest->l_threshold;
89143 @@ -3092,7 +3092,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
89144 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
89145 nla_put_be16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
89146 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
89147 - (atomic_read(&dest->conn_flags) &
89148 + (atomic_read_unchecked(&dest->conn_flags) &
89149 IP_VS_CONN_F_FWD_MASK)) ||
89150 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
89151 atomic_read(&dest->weight)) ||
89152 @@ -3682,7 +3682,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
89153 {
89154 int idx;
89155 struct netns_ipvs *ipvs = net_ipvs(net);
89156 - struct ctl_table *tbl;
89157 + ctl_table_no_const *tbl;
89158
89159 atomic_set(&ipvs->dropentry, 0);
89160 spin_lock_init(&ipvs->dropentry_lock);
89161 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
89162 index 5ea26bd..c9bc65f 100644
89163 --- a/net/netfilter/ipvs/ip_vs_lblc.c
89164 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
89165 @@ -118,7 +118,7 @@ struct ip_vs_lblc_table {
89166 * IPVS LBLC sysctl table
89167 */
89168 #ifdef CONFIG_SYSCTL
89169 -static ctl_table vs_vars_table[] = {
89170 +static ctl_table_no_const vs_vars_table[] __read_only = {
89171 {
89172 .procname = "lblc_expiration",
89173 .data = NULL,
89174 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
89175 index 50123c2..067c773 100644
89176 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
89177 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
89178 @@ -299,7 +299,7 @@ struct ip_vs_lblcr_table {
89179 * IPVS LBLCR sysctl table
89180 */
89181
89182 -static ctl_table vs_vars_table[] = {
89183 +static ctl_table_no_const vs_vars_table[] __read_only = {
89184 {
89185 .procname = "lblcr_expiration",
89186 .data = NULL,
89187 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
89188 index f6046d9..4f10cfd 100644
89189 --- a/net/netfilter/ipvs/ip_vs_sync.c
89190 +++ b/net/netfilter/ipvs/ip_vs_sync.c
89191 @@ -596,7 +596,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
89192 cp = cp->control;
89193 if (cp) {
89194 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
89195 - pkts = atomic_add_return(1, &cp->in_pkts);
89196 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
89197 else
89198 pkts = sysctl_sync_threshold(ipvs);
89199 ip_vs_sync_conn(net, cp->control, pkts);
89200 @@ -758,7 +758,7 @@ control:
89201 if (!cp)
89202 return;
89203 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
89204 - pkts = atomic_add_return(1, &cp->in_pkts);
89205 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
89206 else
89207 pkts = sysctl_sync_threshold(ipvs);
89208 goto sloop;
89209 @@ -882,7 +882,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
89210
89211 if (opt)
89212 memcpy(&cp->in_seq, opt, sizeof(*opt));
89213 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
89214 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
89215 cp->state = state;
89216 cp->old_state = cp->state;
89217 /*
89218 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
89219 index b75ff64..0c51bbe 100644
89220 --- a/net/netfilter/ipvs/ip_vs_xmit.c
89221 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
89222 @@ -1102,7 +1102,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
89223 else
89224 rc = NF_ACCEPT;
89225 /* do not touch skb anymore */
89226 - atomic_inc(&cp->in_pkts);
89227 + atomic_inc_unchecked(&cp->in_pkts);
89228 goto out;
89229 }
89230
89231 @@ -1194,7 +1194,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
89232 else
89233 rc = NF_ACCEPT;
89234 /* do not touch skb anymore */
89235 - atomic_inc(&cp->in_pkts);
89236 + atomic_inc_unchecked(&cp->in_pkts);
89237 goto out;
89238 }
89239
89240 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
89241 index 2d3030a..7ba1c0a 100644
89242 --- a/net/netfilter/nf_conntrack_acct.c
89243 +++ b/net/netfilter/nf_conntrack_acct.c
89244 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
89245 #ifdef CONFIG_SYSCTL
89246 static int nf_conntrack_acct_init_sysctl(struct net *net)
89247 {
89248 - struct ctl_table *table;
89249 + ctl_table_no_const *table;
89250
89251 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
89252 GFP_KERNEL);
89253 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
89254 index 0283bae..5febcb0 100644
89255 --- a/net/netfilter/nf_conntrack_core.c
89256 +++ b/net/netfilter/nf_conntrack_core.c
89257 @@ -1614,6 +1614,10 @@ void nf_conntrack_init_end(void)
89258 #define DYING_NULLS_VAL ((1<<30)+1)
89259 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
89260
89261 +#ifdef CONFIG_GRKERNSEC_HIDESYM
89262 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
89263 +#endif
89264 +
89265 int nf_conntrack_init_net(struct net *net)
89266 {
89267 int ret;
89268 @@ -1628,7 +1632,11 @@ int nf_conntrack_init_net(struct net *net)
89269 goto err_stat;
89270 }
89271
89272 +#ifdef CONFIG_GRKERNSEC_HIDESYM
89273 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
89274 +#else
89275 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
89276 +#endif
89277 if (!net->ct.slabname) {
89278 ret = -ENOMEM;
89279 goto err_slabname;
89280 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
89281 index 1df1761..ce8b88a 100644
89282 --- a/net/netfilter/nf_conntrack_ecache.c
89283 +++ b/net/netfilter/nf_conntrack_ecache.c
89284 @@ -188,7 +188,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
89285 #ifdef CONFIG_SYSCTL
89286 static int nf_conntrack_event_init_sysctl(struct net *net)
89287 {
89288 - struct ctl_table *table;
89289 + ctl_table_no_const *table;
89290
89291 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
89292 GFP_KERNEL);
89293 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
89294 index 974a2a4..52cc6ff 100644
89295 --- a/net/netfilter/nf_conntrack_helper.c
89296 +++ b/net/netfilter/nf_conntrack_helper.c
89297 @@ -57,7 +57,7 @@ static struct ctl_table helper_sysctl_table[] = {
89298
89299 static int nf_conntrack_helper_init_sysctl(struct net *net)
89300 {
89301 - struct ctl_table *table;
89302 + ctl_table_no_const *table;
89303
89304 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
89305 GFP_KERNEL);
89306 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
89307 index 0ab9636..cea3c6a 100644
89308 --- a/net/netfilter/nf_conntrack_proto.c
89309 +++ b/net/netfilter/nf_conntrack_proto.c
89310 @@ -52,7 +52,7 @@ nf_ct_register_sysctl(struct net *net,
89311
89312 static void
89313 nf_ct_unregister_sysctl(struct ctl_table_header **header,
89314 - struct ctl_table **table,
89315 + ctl_table_no_const **table,
89316 unsigned int users)
89317 {
89318 if (users > 0)
89319 diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
89320 index a99b6c3..3841268 100644
89321 --- a/net/netfilter/nf_conntrack_proto_dccp.c
89322 +++ b/net/netfilter/nf_conntrack_proto_dccp.c
89323 @@ -457,7 +457,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
89324 out_invalid:
89325 if (LOG_INVALID(net, IPPROTO_DCCP))
89326 nf_log_packet(net, nf_ct_l3num(ct), 0, skb, NULL, NULL,
89327 - NULL, msg);
89328 + NULL, "%s", msg);
89329 return false;
89330 }
89331
89332 @@ -614,7 +614,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
89333
89334 out_invalid:
89335 if (LOG_INVALID(net, IPPROTO_DCCP))
89336 - nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, msg);
89337 + nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, "%s", msg);
89338 return -NF_ACCEPT;
89339 }
89340
89341 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
89342 index bd700b4..4a3dc61 100644
89343 --- a/net/netfilter/nf_conntrack_standalone.c
89344 +++ b/net/netfilter/nf_conntrack_standalone.c
89345 @@ -471,7 +471,7 @@ static ctl_table nf_ct_netfilter_table[] = {
89346
89347 static int nf_conntrack_standalone_init_sysctl(struct net *net)
89348 {
89349 - struct ctl_table *table;
89350 + ctl_table_no_const *table;
89351
89352 table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),
89353 GFP_KERNEL);
89354 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
89355 index 902fb0a..87f7fdb 100644
89356 --- a/net/netfilter/nf_conntrack_timestamp.c
89357 +++ b/net/netfilter/nf_conntrack_timestamp.c
89358 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
89359 #ifdef CONFIG_SYSCTL
89360 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
89361 {
89362 - struct ctl_table *table;
89363 + ctl_table_no_const *table;
89364
89365 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
89366 GFP_KERNEL);
89367 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
89368 index 3b18dd1..f79e0ca 100644
89369 --- a/net/netfilter/nf_log.c
89370 +++ b/net/netfilter/nf_log.c
89371 @@ -243,7 +243,7 @@ static const struct file_operations nflog_file_ops = {
89372
89373 #ifdef CONFIG_SYSCTL
89374 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
89375 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
89376 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
89377
89378 static int nf_log_proc_dostring(ctl_table *table, int write,
89379 void __user *buffer, size_t *lenp, loff_t *ppos)
89380 @@ -274,14 +274,16 @@ static int nf_log_proc_dostring(ctl_table *table, int write,
89381 rcu_assign_pointer(net->nf.nf_loggers[tindex], logger);
89382 mutex_unlock(&nf_log_mutex);
89383 } else {
89384 + ctl_table_no_const nf_log_table = *table;
89385 +
89386 mutex_lock(&nf_log_mutex);
89387 logger = rcu_dereference_protected(net->nf.nf_loggers[tindex],
89388 lockdep_is_held(&nf_log_mutex));
89389 if (!logger)
89390 - table->data = "NONE";
89391 + nf_log_table.data = "NONE";
89392 else
89393 - table->data = logger->name;
89394 - r = proc_dostring(table, write, buffer, lenp, ppos);
89395 + nf_log_table.data = logger->name;
89396 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
89397 mutex_unlock(&nf_log_mutex);
89398 }
89399
89400 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
89401 index f042ae5..30ea486 100644
89402 --- a/net/netfilter/nf_sockopt.c
89403 +++ b/net/netfilter/nf_sockopt.c
89404 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
89405 }
89406 }
89407
89408 - list_add(&reg->list, &nf_sockopts);
89409 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
89410 out:
89411 mutex_unlock(&nf_sockopt_mutex);
89412 return ret;
89413 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
89414 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
89415 {
89416 mutex_lock(&nf_sockopt_mutex);
89417 - list_del(&reg->list);
89418 + pax_list_del((struct list_head *)&reg->list);
89419 mutex_unlock(&nf_sockopt_mutex);
89420 }
89421 EXPORT_SYMBOL(nf_unregister_sockopt);
89422 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
89423 index 962e979..d4ae2e9 100644
89424 --- a/net/netfilter/nfnetlink_log.c
89425 +++ b/net/netfilter/nfnetlink_log.c
89426 @@ -82,7 +82,7 @@ static int nfnl_log_net_id __read_mostly;
89427 struct nfnl_log_net {
89428 spinlock_t instances_lock;
89429 struct hlist_head instance_table[INSTANCE_BUCKETS];
89430 - atomic_t global_seq;
89431 + atomic_unchecked_t global_seq;
89432 };
89433
89434 static struct nfnl_log_net *nfnl_log_pernet(struct net *net)
89435 @@ -559,7 +559,7 @@ __build_packet_message(struct nfnl_log_net *log,
89436 /* global sequence number */
89437 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
89438 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
89439 - htonl(atomic_inc_return(&log->global_seq))))
89440 + htonl(atomic_inc_return_unchecked(&log->global_seq))))
89441 goto nla_put_failure;
89442
89443 if (data_len) {
89444 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
89445 new file mode 100644
89446 index 0000000..c566332
89447 --- /dev/null
89448 +++ b/net/netfilter/xt_gradm.c
89449 @@ -0,0 +1,51 @@
89450 +/*
89451 + * gradm match for netfilter
89452 + * Copyright © Zbigniew Krzystolik, 2010
89453 + *
89454 + * This program is free software; you can redistribute it and/or modify
89455 + * it under the terms of the GNU General Public License; either version
89456 + * 2 or 3 as published by the Free Software Foundation.
89457 + */
89458 +#include <linux/module.h>
89459 +#include <linux/moduleparam.h>
89460 +#include <linux/skbuff.h>
89461 +#include <linux/netfilter/x_tables.h>
89462 +#include <linux/grsecurity.h>
89463 +#include <linux/netfilter/xt_gradm.h>
89464 +
89465 +static bool
89466 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
89467 +{
89468 + const struct xt_gradm_mtinfo *info = par->matchinfo;
89469 + bool retval = false;
89470 + if (gr_acl_is_enabled())
89471 + retval = true;
89472 + return retval ^ info->invflags;
89473 +}
89474 +
89475 +static struct xt_match gradm_mt_reg __read_mostly = {
89476 + .name = "gradm",
89477 + .revision = 0,
89478 + .family = NFPROTO_UNSPEC,
89479 + .match = gradm_mt,
89480 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
89481 + .me = THIS_MODULE,
89482 +};
89483 +
89484 +static int __init gradm_mt_init(void)
89485 +{
89486 + return xt_register_match(&gradm_mt_reg);
89487 +}
89488 +
89489 +static void __exit gradm_mt_exit(void)
89490 +{
89491 + xt_unregister_match(&gradm_mt_reg);
89492 +}
89493 +
89494 +module_init(gradm_mt_init);
89495 +module_exit(gradm_mt_exit);
89496 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
89497 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
89498 +MODULE_LICENSE("GPL");
89499 +MODULE_ALIAS("ipt_gradm");
89500 +MODULE_ALIAS("ip6t_gradm");
89501 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
89502 index 4fe4fb4..87a89e5 100644
89503 --- a/net/netfilter/xt_statistic.c
89504 +++ b/net/netfilter/xt_statistic.c
89505 @@ -19,7 +19,7 @@
89506 #include <linux/module.h>
89507
89508 struct xt_statistic_priv {
89509 - atomic_t count;
89510 + atomic_unchecked_t count;
89511 } ____cacheline_aligned_in_smp;
89512
89513 MODULE_LICENSE("GPL");
89514 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
89515 break;
89516 case XT_STATISTIC_MODE_NTH:
89517 do {
89518 - oval = atomic_read(&info->master->count);
89519 + oval = atomic_read_unchecked(&info->master->count);
89520 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
89521 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
89522 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
89523 if (nval == 0)
89524 ret = !ret;
89525 break;
89526 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
89527 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
89528 if (info->master == NULL)
89529 return -ENOMEM;
89530 - atomic_set(&info->master->count, info->u.nth.count);
89531 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
89532
89533 return 0;
89534 }
89535 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
89536 index 57ee84d..8b99cf5 100644
89537 --- a/net/netlink/af_netlink.c
89538 +++ b/net/netlink/af_netlink.c
89539 @@ -121,7 +121,7 @@ static void netlink_overrun(struct sock *sk)
89540 sk->sk_error_report(sk);
89541 }
89542 }
89543 - atomic_inc(&sk->sk_drops);
89544 + atomic_inc_unchecked(&sk->sk_drops);
89545 }
89546
89547 static void netlink_rcv_wake(struct sock *sk)
89548 @@ -2771,7 +2771,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
89549 sk_wmem_alloc_get(s),
89550 nlk->cb,
89551 atomic_read(&s->sk_refcnt),
89552 - atomic_read(&s->sk_drops),
89553 + atomic_read_unchecked(&s->sk_drops),
89554 sock_i_ino(s)
89555 );
89556
89557 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
89558 index 2fd6dbe..1032269 100644
89559 --- a/net/netlink/genetlink.c
89560 +++ b/net/netlink/genetlink.c
89561 @@ -310,18 +310,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
89562 goto errout;
89563 }
89564
89565 + pax_open_kernel();
89566 if (ops->dumpit)
89567 - ops->flags |= GENL_CMD_CAP_DUMP;
89568 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
89569 if (ops->doit)
89570 - ops->flags |= GENL_CMD_CAP_DO;
89571 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
89572 if (ops->policy)
89573 - ops->flags |= GENL_CMD_CAP_HASPOL;
89574 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
89575 + pax_close_kernel();
89576
89577 genl_lock_all();
89578 - list_add_tail(&ops->ops_list, &family->ops_list);
89579 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
89580 genl_unlock_all();
89581
89582 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
89583 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
89584 err = 0;
89585 errout:
89586 return err;
89587 @@ -351,9 +353,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
89588 genl_lock_all();
89589 list_for_each_entry(rc, &family->ops_list, ops_list) {
89590 if (rc == ops) {
89591 - list_del(&ops->ops_list);
89592 + pax_list_del((struct list_head *)&ops->ops_list);
89593 genl_unlock_all();
89594 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
89595 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
89596 return 0;
89597 }
89598 }
89599 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
89600 index ec0c80f..41e1830 100644
89601 --- a/net/netrom/af_netrom.c
89602 +++ b/net/netrom/af_netrom.c
89603 @@ -850,7 +850,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
89604 *uaddr_len = sizeof(struct full_sockaddr_ax25);
89605 } else {
89606 sax->fsa_ax25.sax25_family = AF_NETROM;
89607 - sax->fsa_ax25.sax25_ndigis = 0;
89608 sax->fsa_ax25.sax25_call = nr->source_addr;
89609 *uaddr_len = sizeof(struct sockaddr_ax25);
89610 }
89611 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
89612 index 20a1bd0..bb8f1c1 100644
89613 --- a/net/packet/af_packet.c
89614 +++ b/net/packet/af_packet.c
89615 @@ -1681,7 +1681,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
89616
89617 spin_lock(&sk->sk_receive_queue.lock);
89618 po->stats.stats1.tp_packets++;
89619 - skb->dropcount = atomic_read(&sk->sk_drops);
89620 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
89621 __skb_queue_tail(&sk->sk_receive_queue, skb);
89622 spin_unlock(&sk->sk_receive_queue.lock);
89623 sk->sk_data_ready(sk, skb->len);
89624 @@ -1690,7 +1690,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
89625 drop_n_acct:
89626 spin_lock(&sk->sk_receive_queue.lock);
89627 po->stats.stats1.tp_drops++;
89628 - atomic_inc(&sk->sk_drops);
89629 + atomic_inc_unchecked(&sk->sk_drops);
89630 spin_unlock(&sk->sk_receive_queue.lock);
89631
89632 drop_n_restore:
89633 @@ -2640,6 +2640,7 @@ out:
89634
89635 static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
89636 {
89637 + struct sock_extended_err ee;
89638 struct sock_exterr_skb *serr;
89639 struct sk_buff *skb, *skb2;
89640 int copied, err;
89641 @@ -2661,8 +2662,9 @@ static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
89642 sock_recv_timestamp(msg, sk, skb);
89643
89644 serr = SKB_EXT_ERR(skb);
89645 + ee = serr->ee;
89646 put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
89647 - sizeof(serr->ee), &serr->ee);
89648 + sizeof ee, &ee);
89649
89650 msg->msg_flags |= MSG_ERRQUEUE;
89651 err = copied;
89652 @@ -3281,7 +3283,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
89653 case PACKET_HDRLEN:
89654 if (len > sizeof(int))
89655 len = sizeof(int);
89656 - if (copy_from_user(&val, optval, len))
89657 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
89658 return -EFAULT;
89659 switch (val) {
89660 case TPACKET_V1:
89661 @@ -3324,7 +3326,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
89662 len = lv;
89663 if (put_user(len, optlen))
89664 return -EFAULT;
89665 - if (copy_to_user(optval, data, len))
89666 + if (len > sizeof(st) || copy_to_user(optval, data, len))
89667 return -EFAULT;
89668 return 0;
89669 }
89670 diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
89671 index 5a940db..d6a502d 100644
89672 --- a/net/phonet/af_phonet.c
89673 +++ b/net/phonet/af_phonet.c
89674 @@ -469,7 +469,7 @@ int __init_or_module phonet_proto_register(unsigned int protocol,
89675 {
89676 int err = 0;
89677
89678 - if (protocol >= PHONET_NPROTO)
89679 + if (protocol < 0 || protocol >= PHONET_NPROTO)
89680 return -EINVAL;
89681
89682 err = proto_register(pp->prot, 1);
89683 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
89684 index e774117..900b8b7 100644
89685 --- a/net/phonet/pep.c
89686 +++ b/net/phonet/pep.c
89687 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
89688
89689 case PNS_PEP_CTRL_REQ:
89690 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
89691 - atomic_inc(&sk->sk_drops);
89692 + atomic_inc_unchecked(&sk->sk_drops);
89693 break;
89694 }
89695 __skb_pull(skb, 4);
89696 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
89697 }
89698
89699 if (pn->rx_credits == 0) {
89700 - atomic_inc(&sk->sk_drops);
89701 + atomic_inc_unchecked(&sk->sk_drops);
89702 err = -ENOBUFS;
89703 break;
89704 }
89705 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
89706 }
89707
89708 if (pn->rx_credits == 0) {
89709 - atomic_inc(&sk->sk_drops);
89710 + atomic_inc_unchecked(&sk->sk_drops);
89711 err = NET_RX_DROP;
89712 break;
89713 }
89714 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
89715 index 1afd138..0b42453 100644
89716 --- a/net/phonet/socket.c
89717 +++ b/net/phonet/socket.c
89718 @@ -612,7 +612,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
89719 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
89720 sock_i_ino(sk),
89721 atomic_read(&sk->sk_refcnt), sk,
89722 - atomic_read(&sk->sk_drops), &len);
89723 + atomic_read_unchecked(&sk->sk_drops), &len);
89724 }
89725 seq_printf(seq, "%*s\n", 127 - len, "");
89726 return 0;
89727 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
89728 index d6bbbbd..61561e4 100644
89729 --- a/net/phonet/sysctl.c
89730 +++ b/net/phonet/sysctl.c
89731 @@ -67,7 +67,7 @@ static int proc_local_port_range(ctl_table *table, int write,
89732 {
89733 int ret;
89734 int range[2] = {local_port_range[0], local_port_range[1]};
89735 - ctl_table tmp = {
89736 + ctl_table_no_const tmp = {
89737 .data = &range,
89738 .maxlen = sizeof(range),
89739 .mode = table->mode,
89740 diff --git a/net/rds/cong.c b/net/rds/cong.c
89741 index e5b65ac..f3b6fb7 100644
89742 --- a/net/rds/cong.c
89743 +++ b/net/rds/cong.c
89744 @@ -78,7 +78,7 @@
89745 * finds that the saved generation number is smaller than the global generation
89746 * number, it wakes up the process.
89747 */
89748 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
89749 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
89750
89751 /*
89752 * Congestion monitoring
89753 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
89754 rdsdebug("waking map %p for %pI4\n",
89755 map, &map->m_addr);
89756 rds_stats_inc(s_cong_update_received);
89757 - atomic_inc(&rds_cong_generation);
89758 + atomic_inc_unchecked(&rds_cong_generation);
89759 if (waitqueue_active(&map->m_waitq))
89760 wake_up(&map->m_waitq);
89761 if (waitqueue_active(&rds_poll_waitq))
89762 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
89763
89764 int rds_cong_updated_since(unsigned long *recent)
89765 {
89766 - unsigned long gen = atomic_read(&rds_cong_generation);
89767 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
89768
89769 if (likely(*recent == gen))
89770 return 0;
89771 diff --git a/net/rds/ib.h b/net/rds/ib.h
89772 index 7280ab8..e04f4ea 100644
89773 --- a/net/rds/ib.h
89774 +++ b/net/rds/ib.h
89775 @@ -128,7 +128,7 @@ struct rds_ib_connection {
89776 /* sending acks */
89777 unsigned long i_ack_flags;
89778 #ifdef KERNEL_HAS_ATOMIC64
89779 - atomic64_t i_ack_next; /* next ACK to send */
89780 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
89781 #else
89782 spinlock_t i_ack_lock; /* protect i_ack_next */
89783 u64 i_ack_next; /* next ACK to send */
89784 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
89785 index 31b74f5..dc1fbfa 100644
89786 --- a/net/rds/ib_cm.c
89787 +++ b/net/rds/ib_cm.c
89788 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
89789 /* Clear the ACK state */
89790 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
89791 #ifdef KERNEL_HAS_ATOMIC64
89792 - atomic64_set(&ic->i_ack_next, 0);
89793 + atomic64_set_unchecked(&ic->i_ack_next, 0);
89794 #else
89795 ic->i_ack_next = 0;
89796 #endif
89797 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
89798 index 8eb9501..0c386ff 100644
89799 --- a/net/rds/ib_recv.c
89800 +++ b/net/rds/ib_recv.c
89801 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
89802 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
89803 int ack_required)
89804 {
89805 - atomic64_set(&ic->i_ack_next, seq);
89806 + atomic64_set_unchecked(&ic->i_ack_next, seq);
89807 if (ack_required) {
89808 smp_mb__before_clear_bit();
89809 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89810 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
89811 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89812 smp_mb__after_clear_bit();
89813
89814 - return atomic64_read(&ic->i_ack_next);
89815 + return atomic64_read_unchecked(&ic->i_ack_next);
89816 }
89817 #endif
89818
89819 diff --git a/net/rds/iw.h b/net/rds/iw.h
89820 index 04ce3b1..48119a6 100644
89821 --- a/net/rds/iw.h
89822 +++ b/net/rds/iw.h
89823 @@ -134,7 +134,7 @@ struct rds_iw_connection {
89824 /* sending acks */
89825 unsigned long i_ack_flags;
89826 #ifdef KERNEL_HAS_ATOMIC64
89827 - atomic64_t i_ack_next; /* next ACK to send */
89828 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
89829 #else
89830 spinlock_t i_ack_lock; /* protect i_ack_next */
89831 u64 i_ack_next; /* next ACK to send */
89832 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
89833 index a91e1db..cf3053f 100644
89834 --- a/net/rds/iw_cm.c
89835 +++ b/net/rds/iw_cm.c
89836 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
89837 /* Clear the ACK state */
89838 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
89839 #ifdef KERNEL_HAS_ATOMIC64
89840 - atomic64_set(&ic->i_ack_next, 0);
89841 + atomic64_set_unchecked(&ic->i_ack_next, 0);
89842 #else
89843 ic->i_ack_next = 0;
89844 #endif
89845 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
89846 index 4503335..db566b4 100644
89847 --- a/net/rds/iw_recv.c
89848 +++ b/net/rds/iw_recv.c
89849 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
89850 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
89851 int ack_required)
89852 {
89853 - atomic64_set(&ic->i_ack_next, seq);
89854 + atomic64_set_unchecked(&ic->i_ack_next, seq);
89855 if (ack_required) {
89856 smp_mb__before_clear_bit();
89857 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89858 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
89859 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
89860 smp_mb__after_clear_bit();
89861
89862 - return atomic64_read(&ic->i_ack_next);
89863 + return atomic64_read_unchecked(&ic->i_ack_next);
89864 }
89865 #endif
89866
89867 diff --git a/net/rds/rds.h b/net/rds/rds.h
89868 index ec1d731..90a3a8d 100644
89869 --- a/net/rds/rds.h
89870 +++ b/net/rds/rds.h
89871 @@ -449,7 +449,7 @@ struct rds_transport {
89872 void (*sync_mr)(void *trans_private, int direction);
89873 void (*free_mr)(void *trans_private, int invalidate);
89874 void (*flush_mrs)(void);
89875 -};
89876 +} __do_const;
89877
89878 struct rds_sock {
89879 struct sock rs_sk;
89880 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
89881 index edac9ef..16bcb98 100644
89882 --- a/net/rds/tcp.c
89883 +++ b/net/rds/tcp.c
89884 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
89885 int val = 1;
89886
89887 set_fs(KERNEL_DS);
89888 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
89889 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
89890 sizeof(val));
89891 set_fs(oldfs);
89892 }
89893 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
89894 index 81cf5a4..b5826ff 100644
89895 --- a/net/rds/tcp_send.c
89896 +++ b/net/rds/tcp_send.c
89897 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
89898
89899 oldfs = get_fs();
89900 set_fs(KERNEL_DS);
89901 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
89902 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
89903 sizeof(val));
89904 set_fs(oldfs);
89905 }
89906 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
89907 index e61aa60..f07cc89 100644
89908 --- a/net/rxrpc/af_rxrpc.c
89909 +++ b/net/rxrpc/af_rxrpc.c
89910 @@ -40,7 +40,7 @@ static const struct proto_ops rxrpc_rpc_ops;
89911 __be32 rxrpc_epoch;
89912
89913 /* current debugging ID */
89914 -atomic_t rxrpc_debug_id;
89915 +atomic_unchecked_t rxrpc_debug_id;
89916
89917 /* count of skbs currently in use */
89918 atomic_t rxrpc_n_skbs;
89919 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
89920 index e4d9cbc..b229649 100644
89921 --- a/net/rxrpc/ar-ack.c
89922 +++ b/net/rxrpc/ar-ack.c
89923 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
89924
89925 _enter("{%d,%d,%d,%d},",
89926 call->acks_hard, call->acks_unacked,
89927 - atomic_read(&call->sequence),
89928 + atomic_read_unchecked(&call->sequence),
89929 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
89930
89931 stop = 0;
89932 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
89933
89934 /* each Tx packet has a new serial number */
89935 sp->hdr.serial =
89936 - htonl(atomic_inc_return(&call->conn->serial));
89937 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
89938
89939 hdr = (struct rxrpc_header *) txb->head;
89940 hdr->serial = sp->hdr.serial;
89941 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
89942 */
89943 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
89944 {
89945 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
89946 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
89947 }
89948
89949 /*
89950 @@ -629,7 +629,7 @@ process_further:
89951
89952 latest = ntohl(sp->hdr.serial);
89953 hard = ntohl(ack.firstPacket);
89954 - tx = atomic_read(&call->sequence);
89955 + tx = atomic_read_unchecked(&call->sequence);
89956
89957 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
89958 latest,
89959 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
89960 goto maybe_reschedule;
89961
89962 send_ACK_with_skew:
89963 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
89964 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
89965 ntohl(ack.serial));
89966 send_ACK:
89967 mtu = call->conn->trans->peer->if_mtu;
89968 @@ -1173,7 +1173,7 @@ send_ACK:
89969 ackinfo.rxMTU = htonl(5692);
89970 ackinfo.jumbo_max = htonl(4);
89971
89972 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
89973 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
89974 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
89975 ntohl(hdr.serial),
89976 ntohs(ack.maxSkew),
89977 @@ -1191,7 +1191,7 @@ send_ACK:
89978 send_message:
89979 _debug("send message");
89980
89981 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
89982 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
89983 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
89984 send_message_2:
89985
89986 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
89987 index a3bbb36..3341fb9 100644
89988 --- a/net/rxrpc/ar-call.c
89989 +++ b/net/rxrpc/ar-call.c
89990 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
89991 spin_lock_init(&call->lock);
89992 rwlock_init(&call->state_lock);
89993 atomic_set(&call->usage, 1);
89994 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
89995 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
89996 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
89997
89998 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
89999 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
90000 index 4106ca9..a338d7a 100644
90001 --- a/net/rxrpc/ar-connection.c
90002 +++ b/net/rxrpc/ar-connection.c
90003 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
90004 rwlock_init(&conn->lock);
90005 spin_lock_init(&conn->state_lock);
90006 atomic_set(&conn->usage, 1);
90007 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
90008 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
90009 conn->avail_calls = RXRPC_MAXCALLS;
90010 conn->size_align = 4;
90011 conn->header_size = sizeof(struct rxrpc_header);
90012 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
90013 index e7ed43a..6afa140 100644
90014 --- a/net/rxrpc/ar-connevent.c
90015 +++ b/net/rxrpc/ar-connevent.c
90016 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
90017
90018 len = iov[0].iov_len + iov[1].iov_len;
90019
90020 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
90021 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
90022 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
90023
90024 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
90025 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
90026 index 529572f..c758ca7 100644
90027 --- a/net/rxrpc/ar-input.c
90028 +++ b/net/rxrpc/ar-input.c
90029 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
90030 /* track the latest serial number on this connection for ACK packet
90031 * information */
90032 serial = ntohl(sp->hdr.serial);
90033 - hi_serial = atomic_read(&call->conn->hi_serial);
90034 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
90035 while (serial > hi_serial)
90036 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
90037 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
90038 serial);
90039
90040 /* request ACK generation for any ACK or DATA packet that requests
90041 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
90042 index a693aca..81e7293 100644
90043 --- a/net/rxrpc/ar-internal.h
90044 +++ b/net/rxrpc/ar-internal.h
90045 @@ -272,8 +272,8 @@ struct rxrpc_connection {
90046 int error; /* error code for local abort */
90047 int debug_id; /* debug ID for printks */
90048 unsigned int call_counter; /* call ID counter */
90049 - atomic_t serial; /* packet serial number counter */
90050 - atomic_t hi_serial; /* highest serial number received */
90051 + atomic_unchecked_t serial; /* packet serial number counter */
90052 + atomic_unchecked_t hi_serial; /* highest serial number received */
90053 u8 avail_calls; /* number of calls available */
90054 u8 size_align; /* data size alignment (for security) */
90055 u8 header_size; /* rxrpc + security header size */
90056 @@ -346,7 +346,7 @@ struct rxrpc_call {
90057 spinlock_t lock;
90058 rwlock_t state_lock; /* lock for state transition */
90059 atomic_t usage;
90060 - atomic_t sequence; /* Tx data packet sequence counter */
90061 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
90062 u32 abort_code; /* local/remote abort code */
90063 enum { /* current state of call */
90064 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
90065 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
90066 */
90067 extern atomic_t rxrpc_n_skbs;
90068 extern __be32 rxrpc_epoch;
90069 -extern atomic_t rxrpc_debug_id;
90070 +extern atomic_unchecked_t rxrpc_debug_id;
90071 extern struct workqueue_struct *rxrpc_workqueue;
90072
90073 /*
90074 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
90075 index 87f7135..74d3703 100644
90076 --- a/net/rxrpc/ar-local.c
90077 +++ b/net/rxrpc/ar-local.c
90078 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
90079 spin_lock_init(&local->lock);
90080 rwlock_init(&local->services_lock);
90081 atomic_set(&local->usage, 1);
90082 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
90083 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
90084 memcpy(&local->srx, srx, sizeof(*srx));
90085 }
90086
90087 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
90088 index e1ac183..b43e10e 100644
90089 --- a/net/rxrpc/ar-output.c
90090 +++ b/net/rxrpc/ar-output.c
90091 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
90092 sp->hdr.cid = call->cid;
90093 sp->hdr.callNumber = call->call_id;
90094 sp->hdr.seq =
90095 - htonl(atomic_inc_return(&call->sequence));
90096 + htonl(atomic_inc_return_unchecked(&call->sequence));
90097 sp->hdr.serial =
90098 - htonl(atomic_inc_return(&conn->serial));
90099 + htonl(atomic_inc_return_unchecked(&conn->serial));
90100 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
90101 sp->hdr.userStatus = 0;
90102 sp->hdr.securityIndex = conn->security_ix;
90103 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
90104 index bebaa43..2644591 100644
90105 --- a/net/rxrpc/ar-peer.c
90106 +++ b/net/rxrpc/ar-peer.c
90107 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
90108 INIT_LIST_HEAD(&peer->error_targets);
90109 spin_lock_init(&peer->lock);
90110 atomic_set(&peer->usage, 1);
90111 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
90112 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
90113 memcpy(&peer->srx, srx, sizeof(*srx));
90114
90115 rxrpc_assess_MTU_size(peer);
90116 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
90117 index 38047f7..9f48511 100644
90118 --- a/net/rxrpc/ar-proc.c
90119 +++ b/net/rxrpc/ar-proc.c
90120 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
90121 atomic_read(&conn->usage),
90122 rxrpc_conn_states[conn->state],
90123 key_serial(conn->key),
90124 - atomic_read(&conn->serial),
90125 - atomic_read(&conn->hi_serial));
90126 + atomic_read_unchecked(&conn->serial),
90127 + atomic_read_unchecked(&conn->hi_serial));
90128
90129 return 0;
90130 }
90131 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
90132 index 92df566..87ec1bf 100644
90133 --- a/net/rxrpc/ar-transport.c
90134 +++ b/net/rxrpc/ar-transport.c
90135 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
90136 spin_lock_init(&trans->client_lock);
90137 rwlock_init(&trans->conn_lock);
90138 atomic_set(&trans->usage, 1);
90139 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
90140 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
90141
90142 if (peer->srx.transport.family == AF_INET) {
90143 switch (peer->srx.transport_type) {
90144 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
90145 index f226709..0e735a8 100644
90146 --- a/net/rxrpc/rxkad.c
90147 +++ b/net/rxrpc/rxkad.c
90148 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
90149
90150 len = iov[0].iov_len + iov[1].iov_len;
90151
90152 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
90153 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
90154 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
90155
90156 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
90157 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
90158
90159 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
90160
90161 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
90162 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
90163 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
90164
90165 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
90166 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
90167 index 391a245..296b3d7 100644
90168 --- a/net/sctp/ipv6.c
90169 +++ b/net/sctp/ipv6.c
90170 @@ -981,7 +981,7 @@ static const struct inet6_protocol sctpv6_protocol = {
90171 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
90172 };
90173
90174 -static struct sctp_af sctp_af_inet6 = {
90175 +static struct sctp_af sctp_af_inet6 __read_only = {
90176 .sa_family = AF_INET6,
90177 .sctp_xmit = sctp_v6_xmit,
90178 .setsockopt = ipv6_setsockopt,
90179 @@ -1013,7 +1013,7 @@ static struct sctp_af sctp_af_inet6 = {
90180 #endif
90181 };
90182
90183 -static struct sctp_pf sctp_pf_inet6 = {
90184 +static struct sctp_pf sctp_pf_inet6 __read_only = {
90185 .event_msgname = sctp_inet6_event_msgname,
90186 .skb_msgname = sctp_inet6_skb_msgname,
90187 .af_supported = sctp_inet6_af_supported,
90188 @@ -1038,7 +1038,7 @@ void sctp_v6_pf_init(void)
90189
90190 void sctp_v6_pf_exit(void)
90191 {
90192 - list_del(&sctp_af_inet6.list);
90193 + pax_list_del(&sctp_af_inet6.list);
90194 }
90195
90196 /* Initialize IPv6 support and register with socket layer. */
90197 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
90198 index 4e45ee3..e66a031 100644
90199 --- a/net/sctp/proc.c
90200 +++ b/net/sctp/proc.c
90201 @@ -337,7 +337,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
90202 seq_printf(seq,
90203 "%8pK %8pK %-3d %-3d %-2d %-4d "
90204 "%4d %8d %8d %7d %5lu %-5d %5d ",
90205 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
90206 + assoc, sk,
90207 + sctp_sk(sk)->type, sk->sk_state,
90208 assoc->state, hash,
90209 assoc->assoc_id,
90210 assoc->sndbuf_used,
90211 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
90212 index eaee00c..97c0afd 100644
90213 --- a/net/sctp/protocol.c
90214 +++ b/net/sctp/protocol.c
90215 @@ -834,8 +834,10 @@ int sctp_register_af(struct sctp_af *af)
90216 return 0;
90217 }
90218
90219 + pax_open_kernel();
90220 INIT_LIST_HEAD(&af->list);
90221 - list_add_tail(&af->list, &sctp_address_families);
90222 + pax_close_kernel();
90223 + pax_list_add_tail(&af->list, &sctp_address_families);
90224 return 1;
90225 }
90226
90227 @@ -966,7 +968,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
90228
90229 static struct sctp_af sctp_af_inet;
90230
90231 -static struct sctp_pf sctp_pf_inet = {
90232 +static struct sctp_pf sctp_pf_inet __read_only = {
90233 .event_msgname = sctp_inet_event_msgname,
90234 .skb_msgname = sctp_inet_skb_msgname,
90235 .af_supported = sctp_inet_af_supported,
90236 @@ -1037,7 +1039,7 @@ static const struct net_protocol sctp_protocol = {
90237 };
90238
90239 /* IPv4 address related functions. */
90240 -static struct sctp_af sctp_af_inet = {
90241 +static struct sctp_af sctp_af_inet __read_only = {
90242 .sa_family = AF_INET,
90243 .sctp_xmit = sctp_v4_xmit,
90244 .setsockopt = ip_setsockopt,
90245 @@ -1122,7 +1124,7 @@ static void sctp_v4_pf_init(void)
90246
90247 static void sctp_v4_pf_exit(void)
90248 {
90249 - list_del(&sctp_af_inet.list);
90250 + pax_list_del(&sctp_af_inet.list);
90251 }
90252
90253 static int sctp_v4_protosw_init(void)
90254 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
90255 index 8aab894..f6b7e7d 100644
90256 --- a/net/sctp/sm_sideeffect.c
90257 +++ b/net/sctp/sm_sideeffect.c
90258 @@ -447,7 +447,7 @@ static void sctp_generate_sack_event(unsigned long data)
90259 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
90260 }
90261
90262 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
90263 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
90264 NULL,
90265 sctp_generate_t1_cookie_event,
90266 sctp_generate_t1_init_event,
90267 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
90268 index 6abb1ca..1678f8b 100644
90269 --- a/net/sctp/socket.c
90270 +++ b/net/sctp/socket.c
90271 @@ -2167,11 +2167,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
90272 {
90273 struct sctp_association *asoc;
90274 struct sctp_ulpevent *event;
90275 + struct sctp_event_subscribe subscribe;
90276
90277 if (optlen > sizeof(struct sctp_event_subscribe))
90278 return -EINVAL;
90279 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
90280 + if (copy_from_user(&subscribe, optval, optlen))
90281 return -EFAULT;
90282 + sctp_sk(sk)->subscribe = subscribe;
90283
90284 /*
90285 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
90286 @@ -4222,13 +4224,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
90287 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
90288 int __user *optlen)
90289 {
90290 + struct sctp_event_subscribe subscribe;
90291 +
90292 if (len <= 0)
90293 return -EINVAL;
90294 if (len > sizeof(struct sctp_event_subscribe))
90295 len = sizeof(struct sctp_event_subscribe);
90296 if (put_user(len, optlen))
90297 return -EFAULT;
90298 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
90299 + subscribe = sctp_sk(sk)->subscribe;
90300 + if (copy_to_user(optval, &subscribe, len))
90301 return -EFAULT;
90302 return 0;
90303 }
90304 @@ -4246,6 +4251,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
90305 */
90306 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
90307 {
90308 + __u32 autoclose;
90309 +
90310 /* Applicable to UDP-style socket only */
90311 if (sctp_style(sk, TCP))
90312 return -EOPNOTSUPP;
90313 @@ -4254,7 +4261,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
90314 len = sizeof(int);
90315 if (put_user(len, optlen))
90316 return -EFAULT;
90317 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
90318 + autoclose = sctp_sk(sk)->autoclose;
90319 + if (copy_to_user(optval, &autoclose, sizeof(int)))
90320 return -EFAULT;
90321 return 0;
90322 }
90323 @@ -4626,12 +4634,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
90324 */
90325 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
90326 {
90327 + struct sctp_initmsg initmsg;
90328 +
90329 if (len < sizeof(struct sctp_initmsg))
90330 return -EINVAL;
90331 len = sizeof(struct sctp_initmsg);
90332 if (put_user(len, optlen))
90333 return -EFAULT;
90334 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
90335 + initmsg = sctp_sk(sk)->initmsg;
90336 + if (copy_to_user(optval, &initmsg, len))
90337 return -EFAULT;
90338 return 0;
90339 }
90340 @@ -4672,6 +4683,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
90341 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
90342 if (space_left < addrlen)
90343 return -ENOMEM;
90344 + if (addrlen > sizeof(temp) || addrlen < 0)
90345 + return -EFAULT;
90346 if (copy_to_user(to, &temp, addrlen))
90347 return -EFAULT;
90348 to += addrlen;
90349 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
90350 index bf3c6e8..376d8d0 100644
90351 --- a/net/sctp/sysctl.c
90352 +++ b/net/sctp/sysctl.c
90353 @@ -307,7 +307,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
90354 {
90355 struct net *net = current->nsproxy->net_ns;
90356 char tmp[8];
90357 - ctl_table tbl;
90358 + ctl_table_no_const tbl;
90359 int ret;
90360 int changed = 0;
90361 char *none = "none";
90362 @@ -350,7 +350,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
90363
90364 int sctp_sysctl_net_register(struct net *net)
90365 {
90366 - struct ctl_table *table;
90367 + ctl_table_no_const *table;
90368 int i;
90369
90370 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
90371 diff --git a/net/socket.c b/net/socket.c
90372 index 4ca1526..df83e47 100644
90373 --- a/net/socket.c
90374 +++ b/net/socket.c
90375 @@ -88,6 +88,7 @@
90376 #include <linux/magic.h>
90377 #include <linux/slab.h>
90378 #include <linux/xattr.h>
90379 +#include <linux/in.h>
90380
90381 #include <asm/uaccess.h>
90382 #include <asm/unistd.h>
90383 @@ -105,6 +106,8 @@
90384 #include <linux/sockios.h>
90385 #include <linux/atalk.h>
90386
90387 +#include <linux/grsock.h>
90388 +
90389 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
90390 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
90391 unsigned long nr_segs, loff_t pos);
90392 @@ -321,7 +324,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
90393 &sockfs_dentry_operations, SOCKFS_MAGIC);
90394 }
90395
90396 -static struct vfsmount *sock_mnt __read_mostly;
90397 +struct vfsmount *sock_mnt __read_mostly;
90398
90399 static struct file_system_type sock_fs_type = {
90400 .name = "sockfs",
90401 @@ -1246,6 +1249,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
90402 return -EAFNOSUPPORT;
90403 if (type < 0 || type >= SOCK_MAX)
90404 return -EINVAL;
90405 + if (protocol < 0)
90406 + return -EINVAL;
90407
90408 /* Compatibility.
90409
90410 @@ -1377,6 +1382,16 @@ SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)
90411 if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
90412 flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
90413
90414 + if(!gr_search_socket(family, type, protocol)) {
90415 + retval = -EACCES;
90416 + goto out;
90417 + }
90418 +
90419 + if (gr_handle_sock_all(family, type, protocol)) {
90420 + retval = -EACCES;
90421 + goto out;
90422 + }
90423 +
90424 retval = sock_create(family, type, protocol, &sock);
90425 if (retval < 0)
90426 goto out;
90427 @@ -1504,6 +1519,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
90428 if (sock) {
90429 err = move_addr_to_kernel(umyaddr, addrlen, &address);
90430 if (err >= 0) {
90431 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
90432 + err = -EACCES;
90433 + goto error;
90434 + }
90435 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
90436 + if (err)
90437 + goto error;
90438 +
90439 err = security_socket_bind(sock,
90440 (struct sockaddr *)&address,
90441 addrlen);
90442 @@ -1512,6 +1535,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
90443 (struct sockaddr *)
90444 &address, addrlen);
90445 }
90446 +error:
90447 fput_light(sock->file, fput_needed);
90448 }
90449 return err;
90450 @@ -1535,10 +1559,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
90451 if ((unsigned int)backlog > somaxconn)
90452 backlog = somaxconn;
90453
90454 + if (gr_handle_sock_server_other(sock->sk)) {
90455 + err = -EPERM;
90456 + goto error;
90457 + }
90458 +
90459 + err = gr_search_listen(sock);
90460 + if (err)
90461 + goto error;
90462 +
90463 err = security_socket_listen(sock, backlog);
90464 if (!err)
90465 err = sock->ops->listen(sock, backlog);
90466
90467 +error:
90468 fput_light(sock->file, fput_needed);
90469 }
90470 return err;
90471 @@ -1582,6 +1616,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
90472 newsock->type = sock->type;
90473 newsock->ops = sock->ops;
90474
90475 + if (gr_handle_sock_server_other(sock->sk)) {
90476 + err = -EPERM;
90477 + sock_release(newsock);
90478 + goto out_put;
90479 + }
90480 +
90481 + err = gr_search_accept(sock);
90482 + if (err) {
90483 + sock_release(newsock);
90484 + goto out_put;
90485 + }
90486 +
90487 /*
90488 * We don't need try_module_get here, as the listening socket (sock)
90489 * has the protocol module (sock->ops->owner) held.
90490 @@ -1627,6 +1673,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
90491 fd_install(newfd, newfile);
90492 err = newfd;
90493
90494 + gr_attach_curr_ip(newsock->sk);
90495 +
90496 out_put:
90497 fput_light(sock->file, fput_needed);
90498 out:
90499 @@ -1659,6 +1707,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
90500 int, addrlen)
90501 {
90502 struct socket *sock;
90503 + struct sockaddr *sck;
90504 struct sockaddr_storage address;
90505 int err, fput_needed;
90506
90507 @@ -1669,6 +1718,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
90508 if (err < 0)
90509 goto out_put;
90510
90511 + sck = (struct sockaddr *)&address;
90512 +
90513 + if (gr_handle_sock_client(sck)) {
90514 + err = -EACCES;
90515 + goto out_put;
90516 + }
90517 +
90518 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
90519 + if (err)
90520 + goto out_put;
90521 +
90522 err =
90523 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
90524 if (err)
90525 @@ -1750,6 +1810,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
90526 * the protocol.
90527 */
90528
90529 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
90530 +
90531 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
90532 unsigned int, flags, struct sockaddr __user *, addr,
90533 int, addr_len)
90534 @@ -1816,7 +1878,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
90535 struct socket *sock;
90536 struct iovec iov;
90537 struct msghdr msg;
90538 - struct sockaddr_storage address;
90539 + struct sockaddr_storage address = { };
90540 int err, err2;
90541 int fput_needed;
90542
90543 @@ -2023,7 +2085,7 @@ static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
90544 * checking falls down on this.
90545 */
90546 if (copy_from_user(ctl_buf,
90547 - (void __user __force *)msg_sys->msg_control,
90548 + (void __force_user *)msg_sys->msg_control,
90549 ctl_len))
90550 goto out_freectl;
90551 msg_sys->msg_control = ctl_buf;
90552 @@ -2174,7 +2236,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
90553 int err, total_len, len;
90554
90555 /* kernel mode address */
90556 - struct sockaddr_storage addr;
90557 + struct sockaddr_storage addr = { };
90558
90559 /* user mode address pointers */
90560 struct sockaddr __user *uaddr;
90561 @@ -2202,7 +2264,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
90562 * kernel msghdr to use the kernel address space)
90563 */
90564
90565 - uaddr = (__force void __user *)msg_sys->msg_name;
90566 + uaddr = (void __force_user *)msg_sys->msg_name;
90567 uaddr_len = COMPAT_NAMELEN(msg);
90568 if (MSG_CMSG_COMPAT & flags) {
90569 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
90570 @@ -2955,7 +3017,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
90571 old_fs = get_fs();
90572 set_fs(KERNEL_DS);
90573 err = dev_ioctl(net, cmd,
90574 - (struct ifreq __user __force *) &kifr);
90575 + (struct ifreq __force_user *) &kifr);
90576 set_fs(old_fs);
90577
90578 return err;
90579 @@ -3064,7 +3126,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
90580
90581 old_fs = get_fs();
90582 set_fs(KERNEL_DS);
90583 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
90584 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
90585 set_fs(old_fs);
90586
90587 if (cmd == SIOCGIFMAP && !err) {
90588 @@ -3169,7 +3231,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
90589 ret |= __get_user(rtdev, &(ur4->rt_dev));
90590 if (rtdev) {
90591 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
90592 - r4.rt_dev = (char __user __force *)devname;
90593 + r4.rt_dev = (char __force_user *)devname;
90594 devname[15] = 0;
90595 } else
90596 r4.rt_dev = NULL;
90597 @@ -3395,8 +3457,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
90598 int __user *uoptlen;
90599 int err;
90600
90601 - uoptval = (char __user __force *) optval;
90602 - uoptlen = (int __user __force *) optlen;
90603 + uoptval = (char __force_user *) optval;
90604 + uoptlen = (int __force_user *) optlen;
90605
90606 set_fs(KERNEL_DS);
90607 if (level == SOL_SOCKET)
90608 @@ -3416,7 +3478,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
90609 char __user *uoptval;
90610 int err;
90611
90612 - uoptval = (char __user __force *) optval;
90613 + uoptval = (char __force_user *) optval;
90614
90615 set_fs(KERNEL_DS);
90616 if (level == SOL_SOCKET)
90617 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
90618 index 5a750b9..ca5d7af 100644
90619 --- a/net/sunrpc/clnt.c
90620 +++ b/net/sunrpc/clnt.c
90621 @@ -1288,7 +1288,9 @@ call_start(struct rpc_task *task)
90622 (RPC_IS_ASYNC(task) ? "async" : "sync"));
90623
90624 /* Increment call count */
90625 - task->tk_msg.rpc_proc->p_count++;
90626 + pax_open_kernel();
90627 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
90628 + pax_close_kernel();
90629 clnt->cl_stats->rpccnt++;
90630 task->tk_action = call_reserve;
90631 }
90632 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
90633 index 5356b12..c0f4c29 100644
90634 --- a/net/sunrpc/sched.c
90635 +++ b/net/sunrpc/sched.c
90636 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
90637 #ifdef RPC_DEBUG
90638 static void rpc_task_set_debuginfo(struct rpc_task *task)
90639 {
90640 - static atomic_t rpc_pid;
90641 + static atomic_unchecked_t rpc_pid;
90642
90643 - task->tk_pid = atomic_inc_return(&rpc_pid);
90644 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
90645 }
90646 #else
90647 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
90648 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
90649 index 89a588b..678ed90 100644
90650 --- a/net/sunrpc/svc.c
90651 +++ b/net/sunrpc/svc.c
90652 @@ -740,7 +740,7 @@ svc_set_num_threads(struct svc_serv *serv, struct svc_pool *pool, int nrservs)
90653
90654 __module_get(serv->sv_module);
90655 task = kthread_create_on_node(serv->sv_function, rqstp,
90656 - node, serv->sv_name);
90657 + node, "%s", serv->sv_name);
90658 if (IS_ERR(task)) {
90659 error = PTR_ERR(task);
90660 module_put(serv->sv_module);
90661 @@ -1160,7 +1160,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
90662 svc_putnl(resv, RPC_SUCCESS);
90663
90664 /* Bump per-procedure stats counter */
90665 - procp->pc_count++;
90666 + pax_open_kernel();
90667 + (*(unsigned int *)&procp->pc_count)++;
90668 + pax_close_kernel();
90669
90670 /* Initialize storage for argp and resp */
90671 memset(rqstp->rq_argp, 0, procp->pc_argsize);
90672 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
90673 index 8343737..677025e 100644
90674 --- a/net/sunrpc/xprtrdma/svc_rdma.c
90675 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
90676 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
90677 static unsigned int min_max_inline = 4096;
90678 static unsigned int max_max_inline = 65536;
90679
90680 -atomic_t rdma_stat_recv;
90681 -atomic_t rdma_stat_read;
90682 -atomic_t rdma_stat_write;
90683 -atomic_t rdma_stat_sq_starve;
90684 -atomic_t rdma_stat_rq_starve;
90685 -atomic_t rdma_stat_rq_poll;
90686 -atomic_t rdma_stat_rq_prod;
90687 -atomic_t rdma_stat_sq_poll;
90688 -atomic_t rdma_stat_sq_prod;
90689 +atomic_unchecked_t rdma_stat_recv;
90690 +atomic_unchecked_t rdma_stat_read;
90691 +atomic_unchecked_t rdma_stat_write;
90692 +atomic_unchecked_t rdma_stat_sq_starve;
90693 +atomic_unchecked_t rdma_stat_rq_starve;
90694 +atomic_unchecked_t rdma_stat_rq_poll;
90695 +atomic_unchecked_t rdma_stat_rq_prod;
90696 +atomic_unchecked_t rdma_stat_sq_poll;
90697 +atomic_unchecked_t rdma_stat_sq_prod;
90698
90699 /* Temporary NFS request map and context caches */
90700 struct kmem_cache *svc_rdma_map_cachep;
90701 @@ -110,7 +110,7 @@ static int read_reset_stat(ctl_table *table, int write,
90702 len -= *ppos;
90703 if (len > *lenp)
90704 len = *lenp;
90705 - if (len && copy_to_user(buffer, str_buf, len))
90706 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
90707 return -EFAULT;
90708 *lenp = len;
90709 *ppos += len;
90710 @@ -151,63 +151,63 @@ static ctl_table svcrdma_parm_table[] = {
90711 {
90712 .procname = "rdma_stat_read",
90713 .data = &rdma_stat_read,
90714 - .maxlen = sizeof(atomic_t),
90715 + .maxlen = sizeof(atomic_unchecked_t),
90716 .mode = 0644,
90717 .proc_handler = read_reset_stat,
90718 },
90719 {
90720 .procname = "rdma_stat_recv",
90721 .data = &rdma_stat_recv,
90722 - .maxlen = sizeof(atomic_t),
90723 + .maxlen = sizeof(atomic_unchecked_t),
90724 .mode = 0644,
90725 .proc_handler = read_reset_stat,
90726 },
90727 {
90728 .procname = "rdma_stat_write",
90729 .data = &rdma_stat_write,
90730 - .maxlen = sizeof(atomic_t),
90731 + .maxlen = sizeof(atomic_unchecked_t),
90732 .mode = 0644,
90733 .proc_handler = read_reset_stat,
90734 },
90735 {
90736 .procname = "rdma_stat_sq_starve",
90737 .data = &rdma_stat_sq_starve,
90738 - .maxlen = sizeof(atomic_t),
90739 + .maxlen = sizeof(atomic_unchecked_t),
90740 .mode = 0644,
90741 .proc_handler = read_reset_stat,
90742 },
90743 {
90744 .procname = "rdma_stat_rq_starve",
90745 .data = &rdma_stat_rq_starve,
90746 - .maxlen = sizeof(atomic_t),
90747 + .maxlen = sizeof(atomic_unchecked_t),
90748 .mode = 0644,
90749 .proc_handler = read_reset_stat,
90750 },
90751 {
90752 .procname = "rdma_stat_rq_poll",
90753 .data = &rdma_stat_rq_poll,
90754 - .maxlen = sizeof(atomic_t),
90755 + .maxlen = sizeof(atomic_unchecked_t),
90756 .mode = 0644,
90757 .proc_handler = read_reset_stat,
90758 },
90759 {
90760 .procname = "rdma_stat_rq_prod",
90761 .data = &rdma_stat_rq_prod,
90762 - .maxlen = sizeof(atomic_t),
90763 + .maxlen = sizeof(atomic_unchecked_t),
90764 .mode = 0644,
90765 .proc_handler = read_reset_stat,
90766 },
90767 {
90768 .procname = "rdma_stat_sq_poll",
90769 .data = &rdma_stat_sq_poll,
90770 - .maxlen = sizeof(atomic_t),
90771 + .maxlen = sizeof(atomic_unchecked_t),
90772 .mode = 0644,
90773 .proc_handler = read_reset_stat,
90774 },
90775 {
90776 .procname = "rdma_stat_sq_prod",
90777 .data = &rdma_stat_sq_prod,
90778 - .maxlen = sizeof(atomic_t),
90779 + .maxlen = sizeof(atomic_unchecked_t),
90780 .mode = 0644,
90781 .proc_handler = read_reset_stat,
90782 },
90783 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90784 index 0ce7552..d074459 100644
90785 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90786 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
90787 @@ -501,7 +501,7 @@ next_sge:
90788 svc_rdma_put_context(ctxt, 0);
90789 goto out;
90790 }
90791 - atomic_inc(&rdma_stat_read);
90792 + atomic_inc_unchecked(&rdma_stat_read);
90793
90794 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
90795 chl_map->ch[ch_no].count -= read_wr.num_sge;
90796 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
90797 dto_q);
90798 list_del_init(&ctxt->dto_q);
90799 } else {
90800 - atomic_inc(&rdma_stat_rq_starve);
90801 + atomic_inc_unchecked(&rdma_stat_rq_starve);
90802 clear_bit(XPT_DATA, &xprt->xpt_flags);
90803 ctxt = NULL;
90804 }
90805 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
90806 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
90807 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
90808 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
90809 - atomic_inc(&rdma_stat_recv);
90810 + atomic_inc_unchecked(&rdma_stat_recv);
90811
90812 /* Build up the XDR from the receive buffers. */
90813 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
90814 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90815 index c1d124d..acfc59e 100644
90816 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90817 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
90818 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
90819 write_wr.wr.rdma.remote_addr = to;
90820
90821 /* Post It */
90822 - atomic_inc(&rdma_stat_write);
90823 + atomic_inc_unchecked(&rdma_stat_write);
90824 if (svc_rdma_send(xprt, &write_wr))
90825 goto err;
90826 return 0;
90827 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
90828 index 62e4f9b..dd3f2d7 100644
90829 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
90830 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
90831 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
90832 return;
90833
90834 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
90835 - atomic_inc(&rdma_stat_rq_poll);
90836 + atomic_inc_unchecked(&rdma_stat_rq_poll);
90837
90838 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
90839 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
90840 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
90841 }
90842
90843 if (ctxt)
90844 - atomic_inc(&rdma_stat_rq_prod);
90845 + atomic_inc_unchecked(&rdma_stat_rq_prod);
90846
90847 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
90848 /*
90849 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
90850 return;
90851
90852 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
90853 - atomic_inc(&rdma_stat_sq_poll);
90854 + atomic_inc_unchecked(&rdma_stat_sq_poll);
90855 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
90856 if (wc.status != IB_WC_SUCCESS)
90857 /* Close the transport */
90858 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
90859 }
90860
90861 if (ctxt)
90862 - atomic_inc(&rdma_stat_sq_prod);
90863 + atomic_inc_unchecked(&rdma_stat_sq_prod);
90864 }
90865
90866 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
90867 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
90868 spin_lock_bh(&xprt->sc_lock);
90869 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
90870 spin_unlock_bh(&xprt->sc_lock);
90871 - atomic_inc(&rdma_stat_sq_starve);
90872 + atomic_inc_unchecked(&rdma_stat_sq_starve);
90873
90874 /* See if we can opportunistically reap SQ WR to make room */
90875 sq_cq_reap(xprt);
90876 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
90877 index 9bc6db0..47ac8c0 100644
90878 --- a/net/sysctl_net.c
90879 +++ b/net/sysctl_net.c
90880 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
90881 kgid_t root_gid = make_kgid(net->user_ns, 0);
90882
90883 /* Allow network administrator to have same access as root. */
90884 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
90885 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
90886 uid_eq(root_uid, current_uid())) {
90887 int mode = (table->mode >> 6) & 7;
90888 return (mode << 6) | (mode << 3) | mode;
90889 diff --git a/net/tipc/link.c b/net/tipc/link.c
90890 index a80feee..2bbbe70 100644
90891 --- a/net/tipc/link.c
90892 +++ b/net/tipc/link.c
90893 @@ -1201,7 +1201,7 @@ static int link_send_sections_long(struct tipc_port *sender,
90894 struct tipc_msg fragm_hdr;
90895 struct sk_buff *buf, *buf_chain, *prev;
90896 u32 fragm_crs, fragm_rest, hsz, sect_rest;
90897 - const unchar *sect_crs;
90898 + const unchar __user *sect_crs;
90899 int curr_sect;
90900 u32 fragm_no;
90901
90902 @@ -1242,7 +1242,7 @@ again:
90903
90904 if (!sect_rest) {
90905 sect_rest = msg_sect[++curr_sect].iov_len;
90906 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
90907 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
90908 }
90909
90910 if (sect_rest < fragm_rest)
90911 @@ -1261,7 +1261,7 @@ error:
90912 }
90913 } else
90914 skb_copy_to_linear_data_offset(buf, fragm_crs,
90915 - sect_crs, sz);
90916 + (const void __force_kernel *)sect_crs, sz);
90917 sect_crs += sz;
90918 sect_rest -= sz;
90919 fragm_crs += sz;
90920 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
90921 index f2db8a8..9245aa4 100644
90922 --- a/net/tipc/msg.c
90923 +++ b/net/tipc/msg.c
90924 @@ -98,7 +98,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
90925 msg_sect[cnt].iov_len);
90926 else
90927 skb_copy_to_linear_data_offset(*buf, pos,
90928 - msg_sect[cnt].iov_base,
90929 + (const void __force_kernel *)msg_sect[cnt].iov_base,
90930 msg_sect[cnt].iov_len);
90931 pos += msg_sect[cnt].iov_len;
90932 }
90933 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
90934 index 6b42d47..2ac24d5 100644
90935 --- a/net/tipc/subscr.c
90936 +++ b/net/tipc/subscr.c
90937 @@ -96,7 +96,7 @@ static void subscr_send_event(struct tipc_subscription *sub,
90938 {
90939 struct iovec msg_sect;
90940
90941 - msg_sect.iov_base = (void *)&sub->evt;
90942 + msg_sect.iov_base = (void __force_user *)&sub->evt;
90943 msg_sect.iov_len = sizeof(struct tipc_event);
90944
90945 sub->evt.event = htohl(event, sub->swap);
90946 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
90947 index 826e099..4fa8c93 100644
90948 --- a/net/unix/af_unix.c
90949 +++ b/net/unix/af_unix.c
90950 @@ -783,6 +783,12 @@ static struct sock *unix_find_other(struct net *net,
90951 err = -ECONNREFUSED;
90952 if (!S_ISSOCK(inode->i_mode))
90953 goto put_fail;
90954 +
90955 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
90956 + err = -EACCES;
90957 + goto put_fail;
90958 + }
90959 +
90960 u = unix_find_socket_byinode(inode);
90961 if (!u)
90962 goto put_fail;
90963 @@ -803,6 +809,13 @@ static struct sock *unix_find_other(struct net *net,
90964 if (u) {
90965 struct dentry *dentry;
90966 dentry = unix_sk(u)->path.dentry;
90967 +
90968 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
90969 + err = -EPERM;
90970 + sock_put(u);
90971 + goto fail;
90972 + }
90973 +
90974 if (dentry)
90975 touch_atime(&unix_sk(u)->path);
90976 } else
90977 @@ -836,12 +849,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
90978 */
90979 err = security_path_mknod(&path, dentry, mode, 0);
90980 if (!err) {
90981 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
90982 + err = -EACCES;
90983 + goto out;
90984 + }
90985 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
90986 if (!err) {
90987 res->mnt = mntget(path.mnt);
90988 res->dentry = dget(dentry);
90989 + gr_handle_create(dentry, path.mnt);
90990 }
90991 }
90992 +out:
90993 done_path_create(&path, dentry);
90994 return err;
90995 }
90996 @@ -2324,9 +2343,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
90997 seq_puts(seq, "Num RefCount Protocol Flags Type St "
90998 "Inode Path\n");
90999 else {
91000 - struct sock *s = v;
91001 + struct sock *s = v, *peer;
91002 struct unix_sock *u = unix_sk(s);
91003 unix_state_lock(s);
91004 + peer = unix_peer(s);
91005 + unix_state_unlock(s);
91006 +
91007 + unix_state_double_lock(s, peer);
91008
91009 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
91010 s,
91011 @@ -2353,8 +2376,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
91012 }
91013 for ( ; i < len; i++)
91014 seq_putc(seq, u->addr->name->sun_path[i]);
91015 - }
91016 - unix_state_unlock(s);
91017 + } else if (peer)
91018 + seq_printf(seq, " P%lu", sock_i_ino(peer));
91019 +
91020 + unix_state_double_unlock(s, peer);
91021 seq_putc(seq, '\n');
91022 }
91023
91024 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
91025 index 8800604..0526440 100644
91026 --- a/net/unix/sysctl_net_unix.c
91027 +++ b/net/unix/sysctl_net_unix.c
91028 @@ -28,7 +28,7 @@ static ctl_table unix_table[] = {
91029
91030 int __net_init unix_sysctl_register(struct net *net)
91031 {
91032 - struct ctl_table *table;
91033 + ctl_table_no_const *table;
91034
91035 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
91036 if (table == NULL)
91037 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
91038 index c8717c1..08539f5 100644
91039 --- a/net/wireless/wext-core.c
91040 +++ b/net/wireless/wext-core.c
91041 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
91042 */
91043
91044 /* Support for very large requests */
91045 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
91046 - (user_length > descr->max_tokens)) {
91047 + if (user_length > descr->max_tokens) {
91048 /* Allow userspace to GET more than max so
91049 * we can support any size GET requests.
91050 * There is still a limit : -ENOMEM.
91051 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
91052 }
91053 }
91054
91055 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
91056 - /*
91057 - * If this is a GET, but not NOMAX, it means that the extra
91058 - * data is not bounded by userspace, but by max_tokens. Thus
91059 - * set the length to max_tokens. This matches the extra data
91060 - * allocation.
91061 - * The driver should fill it with the number of tokens it
91062 - * provided, and it may check iwp->length rather than having
91063 - * knowledge of max_tokens. If the driver doesn't change the
91064 - * iwp->length, this ioctl just copies back max_token tokens
91065 - * filled with zeroes. Hopefully the driver isn't claiming
91066 - * them to be valid data.
91067 - */
91068 - iwp->length = descr->max_tokens;
91069 - }
91070 -
91071 err = handler(dev, info, (union iwreq_data *) iwp, extra);
91072
91073 iwp->length += essid_compat;
91074 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
91075 index ea970b8..c68edb9f 100644
91076 --- a/net/xfrm/xfrm_policy.c
91077 +++ b/net/xfrm/xfrm_policy.c
91078 @@ -334,7 +334,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
91079 {
91080 policy->walk.dead = 1;
91081
91082 - atomic_inc(&policy->genid);
91083 + atomic_inc_unchecked(&policy->genid);
91084
91085 del_timer(&policy->polq.hold_timer);
91086 xfrm_queue_purge(&policy->polq.hold_queue);
91087 @@ -659,7 +659,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
91088 hlist_add_head(&policy->bydst, chain);
91089 xfrm_pol_hold(policy);
91090 net->xfrm.policy_count[dir]++;
91091 - atomic_inc(&flow_cache_genid);
91092 + atomic_inc_unchecked(&flow_cache_genid);
91093 rt_genid_bump(net);
91094 if (delpol) {
91095 xfrm_policy_requeue(delpol, policy);
91096 @@ -1629,7 +1629,7 @@ free_dst:
91097 goto out;
91098 }
91099
91100 -static int inline
91101 +static inline int
91102 xfrm_dst_alloc_copy(void **target, const void *src, int size)
91103 {
91104 if (!*target) {
91105 @@ -1641,7 +1641,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
91106 return 0;
91107 }
91108
91109 -static int inline
91110 +static inline int
91111 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
91112 {
91113 #ifdef CONFIG_XFRM_SUB_POLICY
91114 @@ -1653,7 +1653,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
91115 #endif
91116 }
91117
91118 -static int inline
91119 +static inline int
91120 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
91121 {
91122 #ifdef CONFIG_XFRM_SUB_POLICY
91123 @@ -1747,7 +1747,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
91124
91125 xdst->num_pols = num_pols;
91126 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
91127 - xdst->policy_genid = atomic_read(&pols[0]->genid);
91128 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
91129
91130 return xdst;
91131 }
91132 @@ -2618,7 +2618,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
91133 if (xdst->xfrm_genid != dst->xfrm->genid)
91134 return 0;
91135 if (xdst->num_pols > 0 &&
91136 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
91137 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
91138 return 0;
91139
91140 mtu = dst_mtu(dst->child);
91141 @@ -2706,8 +2706,11 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
91142 dst_ops->link_failure = xfrm_link_failure;
91143 if (likely(dst_ops->neigh_lookup == NULL))
91144 dst_ops->neigh_lookup = xfrm_neigh_lookup;
91145 - if (likely(afinfo->garbage_collect == NULL))
91146 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
91147 + if (likely(afinfo->garbage_collect == NULL)) {
91148 + pax_open_kernel();
91149 + *(void **)&afinfo->garbage_collect = xfrm_garbage_collect_deferred;
91150 + pax_close_kernel();
91151 + }
91152 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
91153 }
91154 spin_unlock(&xfrm_policy_afinfo_lock);
91155 @@ -2761,7 +2764,9 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
91156 dst_ops->check = NULL;
91157 dst_ops->negative_advice = NULL;
91158 dst_ops->link_failure = NULL;
91159 - afinfo->garbage_collect = NULL;
91160 + pax_open_kernel();
91161 + *(void **)&afinfo->garbage_collect = NULL;
91162 + pax_close_kernel();
91163 }
91164 return err;
91165 }
91166 @@ -3144,7 +3149,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
91167 sizeof(pol->xfrm_vec[i].saddr));
91168 pol->xfrm_vec[i].encap_family = mp->new_family;
91169 /* flush bundles */
91170 - atomic_inc(&pol->genid);
91171 + atomic_inc_unchecked(&pol->genid);
91172 }
91173 }
91174
91175 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
91176 index 78f66fa..9286768 100644
91177 --- a/net/xfrm/xfrm_state.c
91178 +++ b/net/xfrm/xfrm_state.c
91179 @@ -177,12 +177,14 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
91180
91181 if (unlikely(afinfo == NULL))
91182 return -EAFNOSUPPORT;
91183 - typemap = afinfo->type_map;
91184 + typemap = (const struct xfrm_type **)afinfo->type_map;
91185 spin_lock_bh(&xfrm_type_lock);
91186
91187 - if (likely(typemap[type->proto] == NULL))
91188 + if (likely(typemap[type->proto] == NULL)) {
91189 + pax_open_kernel();
91190 typemap[type->proto] = type;
91191 - else
91192 + pax_close_kernel();
91193 + } else
91194 err = -EEXIST;
91195 spin_unlock_bh(&xfrm_type_lock);
91196 xfrm_state_put_afinfo(afinfo);
91197 @@ -198,13 +200,16 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
91198
91199 if (unlikely(afinfo == NULL))
91200 return -EAFNOSUPPORT;
91201 - typemap = afinfo->type_map;
91202 + typemap = (const struct xfrm_type **)afinfo->type_map;
91203 spin_lock_bh(&xfrm_type_lock);
91204
91205 if (unlikely(typemap[type->proto] != type))
91206 err = -ENOENT;
91207 - else
91208 + else {
91209 + pax_open_kernel();
91210 typemap[type->proto] = NULL;
91211 + pax_close_kernel();
91212 + }
91213 spin_unlock_bh(&xfrm_type_lock);
91214 xfrm_state_put_afinfo(afinfo);
91215 return err;
91216 @@ -214,7 +219,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
91217 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
91218 {
91219 struct xfrm_state_afinfo *afinfo;
91220 - const struct xfrm_type **typemap;
91221 const struct xfrm_type *type;
91222 int modload_attempted = 0;
91223
91224 @@ -222,9 +226,8 @@ retry:
91225 afinfo = xfrm_state_get_afinfo(family);
91226 if (unlikely(afinfo == NULL))
91227 return NULL;
91228 - typemap = afinfo->type_map;
91229
91230 - type = typemap[proto];
91231 + type = afinfo->type_map[proto];
91232 if (unlikely(type && !try_module_get(type->owner)))
91233 type = NULL;
91234 if (!type && !modload_attempted) {
91235 @@ -258,7 +261,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
91236 return -EAFNOSUPPORT;
91237
91238 err = -EEXIST;
91239 - modemap = afinfo->mode_map;
91240 + modemap = (struct xfrm_mode **)afinfo->mode_map;
91241 spin_lock_bh(&xfrm_mode_lock);
91242 if (modemap[mode->encap])
91243 goto out;
91244 @@ -267,8 +270,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
91245 if (!try_module_get(afinfo->owner))
91246 goto out;
91247
91248 - mode->afinfo = afinfo;
91249 + pax_open_kernel();
91250 + *(const void **)&mode->afinfo = afinfo;
91251 modemap[mode->encap] = mode;
91252 + pax_close_kernel();
91253 err = 0;
91254
91255 out:
91256 @@ -292,10 +297,12 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
91257 return -EAFNOSUPPORT;
91258
91259 err = -ENOENT;
91260 - modemap = afinfo->mode_map;
91261 + modemap = (struct xfrm_mode **)afinfo->mode_map;
91262 spin_lock_bh(&xfrm_mode_lock);
91263 if (likely(modemap[mode->encap] == mode)) {
91264 + pax_open_kernel();
91265 modemap[mode->encap] = NULL;
91266 + pax_close_kernel();
91267 module_put(mode->afinfo->owner);
91268 err = 0;
91269 }
91270 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
91271 index 05a6e3d..6716ec9 100644
91272 --- a/net/xfrm/xfrm_sysctl.c
91273 +++ b/net/xfrm/xfrm_sysctl.c
91274 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
91275
91276 int __net_init xfrm_sysctl_init(struct net *net)
91277 {
91278 - struct ctl_table *table;
91279 + ctl_table_no_const *table;
91280
91281 __xfrm_sysctl_init(net);
91282
91283 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
91284 index d5d859c..781cbcb 100644
91285 --- a/scripts/Makefile.build
91286 +++ b/scripts/Makefile.build
91287 @@ -111,7 +111,7 @@ endif
91288 endif
91289
91290 # Do not include host rules unless needed
91291 -ifneq ($(hostprogs-y)$(hostprogs-m),)
91292 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
91293 include scripts/Makefile.host
91294 endif
91295
91296 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
91297 index 686cb0d..9d653bf 100644
91298 --- a/scripts/Makefile.clean
91299 +++ b/scripts/Makefile.clean
91300 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
91301 __clean-files := $(extra-y) $(always) \
91302 $(targets) $(clean-files) \
91303 $(host-progs) \
91304 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
91305 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
91306 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
91307
91308 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
91309
91310 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
91311 index 1ac414f..38575f7 100644
91312 --- a/scripts/Makefile.host
91313 +++ b/scripts/Makefile.host
91314 @@ -31,6 +31,8 @@
91315 # Note: Shared libraries consisting of C++ files are not supported
91316
91317 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
91318 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
91319 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
91320
91321 # C code
91322 # Executables compiled from a single .c file
91323 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
91324 # Shared libaries (only .c supported)
91325 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
91326 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
91327 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
91328 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
91329 # Remove .so files from "xxx-objs"
91330 host-cobjs := $(filter-out %.so,$(host-cobjs))
91331 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
91332
91333 -#Object (.o) files used by the shared libaries
91334 +# Object (.o) files used by the shared libaries
91335 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
91336 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
91337
91338 # output directory for programs/.o files
91339 # hostprogs-y := tools/build may have been specified. Retrieve directory
91340 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
91341 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
91342 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
91343 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
91344 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
91345 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
91346 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
91347 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
91348
91349 obj-dirs += $(host-objdirs)
91350 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
91351 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
91352 $(call if_changed_dep,host-cshobjs)
91353
91354 +# Compile .c file, create position independent .o file
91355 +# host-cxxshobjs -> .o
91356 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
91357 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
91358 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
91359 + $(call if_changed_dep,host-cxxshobjs)
91360 +
91361 # Link a shared library, based on position independent .o files
91362 # *.o -> .so shared library (host-cshlib)
91363 quiet_cmd_host-cshlib = HOSTLLD -shared $@
91364 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
91365 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
91366 $(call if_changed,host-cshlib)
91367
91368 +# Link a shared library, based on position independent .o files
91369 +# *.o -> .so shared library (host-cxxshlib)
91370 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
91371 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
91372 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
91373 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
91374 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
91375 + $(call if_changed,host-cxxshlib)
91376 +
91377 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
91378 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
91379 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
91380
91381 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
91382 index 078fe1d..fbdb363 100644
91383 --- a/scripts/basic/fixdep.c
91384 +++ b/scripts/basic/fixdep.c
91385 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
91386 /*
91387 * Lookup a value in the configuration string.
91388 */
91389 -static int is_defined_config(const char *name, int len, unsigned int hash)
91390 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
91391 {
91392 struct item *aux;
91393
91394 @@ -211,10 +211,10 @@ static void clear_config(void)
91395 /*
91396 * Record the use of a CONFIG_* word.
91397 */
91398 -static void use_config(const char *m, int slen)
91399 +static void use_config(const char *m, unsigned int slen)
91400 {
91401 unsigned int hash = strhash(m, slen);
91402 - int c, i;
91403 + unsigned int c, i;
91404
91405 if (is_defined_config(m, slen, hash))
91406 return;
91407 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
91408
91409 static void parse_config_file(const char *map, size_t len)
91410 {
91411 - const int *end = (const int *) (map + len);
91412 + const unsigned int *end = (const unsigned int *) (map + len);
91413 /* start at +1, so that p can never be < map */
91414 - const int *m = (const int *) map + 1;
91415 + const unsigned int *m = (const unsigned int *) map + 1;
91416 const char *p, *q;
91417
91418 for (; m < end; m++) {
91419 @@ -435,7 +435,7 @@ static void print_deps(void)
91420 static void traps(void)
91421 {
91422 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
91423 - int *p = (int *)test;
91424 + unsigned int *p = (unsigned int *)test;
91425
91426 if (*p != INT_CONF) {
91427 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianness? %#x\n",
91428 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
91429 new file mode 100644
91430 index 0000000..5e0222d
91431 --- /dev/null
91432 +++ b/scripts/gcc-plugin.sh
91433 @@ -0,0 +1,17 @@
91434 +#!/bin/bash
91435 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
91436 +#include "gcc-plugin.h"
91437 +#include "tree.h"
91438 +#include "tm.h"
91439 +#include "rtl.h"
91440 +#ifdef ENABLE_BUILD_WITH_CXX
91441 +#warning $2
91442 +#else
91443 +#warning $1
91444 +#endif
91445 +EOF`
91446 +if [ $? -eq 0 ]
91447 +then
91448 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
91449 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
91450 +fi
91451 diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
91452 index 643764f..c437ded 100644
91453 --- a/scripts/headers_install.sh
91454 +++ b/scripts/headers_install.sh
91455 @@ -29,6 +29,7 @@ do
91456 FILE="$(basename "$i")"
91457 sed -r \
91458 -e 's/([ \t(])(__user|__force|__iomem)[ \t]/\1/g' \
91459 + -e 's/__intentional_overflow\([ \t,0-9]*\)//g' \
91460 -e 's/__attribute_const__([ \t]|$)/\1/g' \
91461 -e 's@^#include <linux/compiler.h>@@' \
91462 -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
91463 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
91464 index 0149949..d482a0d 100644
91465 --- a/scripts/link-vmlinux.sh
91466 +++ b/scripts/link-vmlinux.sh
91467 @@ -158,7 +158,7 @@ else
91468 fi;
91469
91470 # final build of init/
91471 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
91472 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
91473
91474 kallsymso=""
91475 kallsyms_vmlinux=""
91476 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
91477 index 45f9a33..e4194b3 100644
91478 --- a/scripts/mod/file2alias.c
91479 +++ b/scripts/mod/file2alias.c
91480 @@ -140,7 +140,7 @@ static void device_id_check(const char *modname, const char *device_id,
91481 unsigned long size, unsigned long id_size,
91482 void *symval)
91483 {
91484 - int i;
91485 + unsigned int i;
91486
91487 if (size % id_size || size < id_size) {
91488 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
91489 @@ -168,7 +168,7 @@ static void device_id_check(const char *modname, const char *device_id,
91490 /* USB is special because the bcdDevice can be matched against a numeric range */
91491 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
91492 static void do_usb_entry(void *symval,
91493 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
91494 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
91495 unsigned char range_lo, unsigned char range_hi,
91496 unsigned char max, struct module *mod)
91497 {
91498 @@ -278,7 +278,7 @@ static void do_usb_entry_multi(void *symval, struct module *mod)
91499 {
91500 unsigned int devlo, devhi;
91501 unsigned char chi, clo, max;
91502 - int ndigits;
91503 + unsigned int ndigits;
91504
91505 DEF_FIELD(symval, usb_device_id, match_flags);
91506 DEF_FIELD(symval, usb_device_id, idVendor);
91507 @@ -531,7 +531,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
91508 for (i = 0; i < count; i++) {
91509 DEF_FIELD_ADDR(symval + i*id_size, pnp_device_id, id);
91510 char acpi_id[sizeof(*id)];
91511 - int j;
91512 + unsigned int j;
91513
91514 buf_printf(&mod->dev_table_buf,
91515 "MODULE_ALIAS(\"pnp:d%s*\");\n", *id);
91516 @@ -560,7 +560,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
91517
91518 for (j = 0; j < PNP_MAX_DEVICES; j++) {
91519 const char *id = (char *)(*devs)[j].id;
91520 - int i2, j2;
91521 + unsigned int i2, j2;
91522 int dup = 0;
91523
91524 if (!id[0])
91525 @@ -586,7 +586,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
91526 /* add an individual alias for every device entry */
91527 if (!dup) {
91528 char acpi_id[PNP_ID_LEN];
91529 - int k;
91530 + unsigned int k;
91531
91532 buf_printf(&mod->dev_table_buf,
91533 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
91534 @@ -938,7 +938,7 @@ static void dmi_ascii_filter(char *d, const char *s)
91535 static int do_dmi_entry(const char *filename, void *symval,
91536 char *alias)
91537 {
91538 - int i, j;
91539 + unsigned int i, j;
91540 DEF_FIELD_ADDR(symval, dmi_system_id, matches);
91541 sprintf(alias, "dmi*");
91542
91543 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
91544 index a4be8e1..6e8a5fb 100644
91545 --- a/scripts/mod/modpost.c
91546 +++ b/scripts/mod/modpost.c
91547 @@ -933,6 +933,7 @@ enum mismatch {
91548 ANY_INIT_TO_ANY_EXIT,
91549 ANY_EXIT_TO_ANY_INIT,
91550 EXPORT_TO_INIT_EXIT,
91551 + DATA_TO_TEXT
91552 };
91553
91554 struct sectioncheck {
91555 @@ -1047,6 +1048,12 @@ const struct sectioncheck sectioncheck[] = {
91556 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
91557 .mismatch = EXPORT_TO_INIT_EXIT,
91558 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
91559 +},
91560 +/* Do not reference code from writable data */
91561 +{
91562 + .fromsec = { DATA_SECTIONS, NULL },
91563 + .tosec = { TEXT_SECTIONS, NULL },
91564 + .mismatch = DATA_TO_TEXT
91565 }
91566 };
91567
91568 @@ -1169,10 +1176,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
91569 continue;
91570 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
91571 continue;
91572 - if (sym->st_value == addr)
91573 - return sym;
91574 /* Find a symbol nearby - addr are maybe negative */
91575 d = sym->st_value - addr;
91576 + if (d == 0)
91577 + return sym;
91578 if (d < 0)
91579 d = addr - sym->st_value;
91580 if (d < distance) {
91581 @@ -1451,6 +1458,14 @@ static void report_sec_mismatch(const char *modname,
91582 tosym, prl_to, prl_to, tosym);
91583 free(prl_to);
91584 break;
91585 + case DATA_TO_TEXT:
91586 +#if 0
91587 + fprintf(stderr,
91588 + "The %s %s:%s references\n"
91589 + "the %s %s:%s%s\n",
91590 + from, fromsec, fromsym, to, tosec, tosym, to_p);
91591 +#endif
91592 + break;
91593 }
91594 fprintf(stderr, "\n");
91595 }
91596 @@ -1685,7 +1700,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
91597 static void check_sec_ref(struct module *mod, const char *modname,
91598 struct elf_info *elf)
91599 {
91600 - int i;
91601 + unsigned int i;
91602 Elf_Shdr *sechdrs = elf->sechdrs;
91603
91604 /* Walk through all sections */
91605 @@ -1804,7 +1819,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
91606 va_end(ap);
91607 }
91608
91609 -void buf_write(struct buffer *buf, const char *s, int len)
91610 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
91611 {
91612 if (buf->size - buf->pos < len) {
91613 buf->size += len + SZ;
91614 @@ -2023,7 +2038,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
91615 if (fstat(fileno(file), &st) < 0)
91616 goto close_write;
91617
91618 - if (st.st_size != b->pos)
91619 + if (st.st_size != (off_t)b->pos)
91620 goto close_write;
91621
91622 tmp = NOFAIL(malloc(b->pos));
91623 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
91624 index 51207e4..f7d603d 100644
91625 --- a/scripts/mod/modpost.h
91626 +++ b/scripts/mod/modpost.h
91627 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
91628
91629 struct buffer {
91630 char *p;
91631 - int pos;
91632 - int size;
91633 + unsigned int pos;
91634 + unsigned int size;
91635 };
91636
91637 void __attribute__((format(printf, 2, 3)))
91638 buf_printf(struct buffer *buf, const char *fmt, ...);
91639
91640 void
91641 -buf_write(struct buffer *buf, const char *s, int len);
91642 +buf_write(struct buffer *buf, const char *s, unsigned int len);
91643
91644 struct module {
91645 struct module *next;
91646 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
91647 index 9dfcd6d..099068e 100644
91648 --- a/scripts/mod/sumversion.c
91649 +++ b/scripts/mod/sumversion.c
91650 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
91651 goto out;
91652 }
91653
91654 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
91655 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
91656 warn("writing sum in %s failed: %s\n",
91657 filename, strerror(errno));
91658 goto out;
91659 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
91660 index acb8650..b8c5f02 100644
91661 --- a/scripts/package/builddeb
91662 +++ b/scripts/package/builddeb
91663 @@ -246,6 +246,7 @@ fi
91664 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
91665 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
91666 (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
91667 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
91668 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
91669 mkdir -p "$destdir"
91670 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
91671 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
91672 index 68bb4ef..2f419e1 100644
91673 --- a/scripts/pnmtologo.c
91674 +++ b/scripts/pnmtologo.c
91675 @@ -244,14 +244,14 @@ static void write_header(void)
91676 fprintf(out, " * Linux logo %s\n", logoname);
91677 fputs(" */\n\n", out);
91678 fputs("#include <linux/linux_logo.h>\n\n", out);
91679 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
91680 + fprintf(out, "static unsigned char %s_data[] = {\n",
91681 logoname);
91682 }
91683
91684 static void write_footer(void)
91685 {
91686 fputs("\n};\n\n", out);
91687 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
91688 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
91689 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
91690 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
91691 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
91692 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
91693 fputs("\n};\n\n", out);
91694
91695 /* write logo clut */
91696 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
91697 + fprintf(out, "static unsigned char %s_clut[] = {\n",
91698 logoname);
91699 write_hex_cnt = 0;
91700 for (i = 0; i < logo_clutsize; i++) {
91701 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
91702 index f5eb43d..1814de8 100644
91703 --- a/scripts/sortextable.h
91704 +++ b/scripts/sortextable.h
91705 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
91706 const char *secstrtab;
91707 const char *strtab;
91708 char *extab_image;
91709 - int extab_index = 0;
91710 - int i;
91711 - int idx;
91712 + unsigned int extab_index = 0;
91713 + unsigned int i;
91714 + unsigned int idx;
91715
91716 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
91717 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
91718 diff --git a/security/Kconfig b/security/Kconfig
91719 index e9c6ac7..66bf8e9 100644
91720 --- a/security/Kconfig
91721 +++ b/security/Kconfig
91722 @@ -4,6 +4,945 @@
91723
91724 menu "Security options"
91725
91726 +menu "Grsecurity"
91727 +
91728 + config ARCH_TRACK_EXEC_LIMIT
91729 + bool
91730 +
91731 + config PAX_KERNEXEC_PLUGIN
91732 + bool
91733 +
91734 + config PAX_PER_CPU_PGD
91735 + bool
91736 +
91737 + config TASK_SIZE_MAX_SHIFT
91738 + int
91739 + depends on X86_64
91740 + default 47 if !PAX_PER_CPU_PGD
91741 + default 42 if PAX_PER_CPU_PGD
91742 +
91743 + config PAX_ENABLE_PAE
91744 + bool
91745 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
91746 +
91747 + config PAX_USERCOPY_SLABS
91748 + bool
91749 +
91750 +config GRKERNSEC
91751 + bool "Grsecurity"
91752 + select CRYPTO
91753 + select CRYPTO_SHA256
91754 + select PROC_FS
91755 + select STOP_MACHINE
91756 + select TTY
91757 + help
91758 + If you say Y here, you will be able to configure many features
91759 + that will enhance the security of your system. It is highly
91760 + recommended that you say Y here and read through the help
91761 + for each option so that you fully understand the features and
91762 + can evaluate their usefulness for your machine.
91763 +
91764 +choice
91765 + prompt "Configuration Method"
91766 + depends on GRKERNSEC
91767 + default GRKERNSEC_CONFIG_CUSTOM
91768 + help
91769 +
91770 +config GRKERNSEC_CONFIG_AUTO
91771 + bool "Automatic"
91772 + help
91773 + If you choose this configuration method, you'll be able to answer a small
91774 + number of simple questions about how you plan to use this kernel.
91775 + The settings of grsecurity and PaX will be automatically configured for
91776 + the highest commonly-used settings within the provided constraints.
91777 +
91778 + If you require additional configuration, custom changes can still be made
91779 + from the "custom configuration" menu.
91780 +
91781 +config GRKERNSEC_CONFIG_CUSTOM
91782 + bool "Custom"
91783 + help
91784 + If you choose this configuration method, you'll be able to configure all
91785 + grsecurity and PaX settings manually. Via this method, no options are
91786 + automatically enabled.
91787 +
91788 +endchoice
91789 +
91790 +choice
91791 + prompt "Usage Type"
91792 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91793 + default GRKERNSEC_CONFIG_SERVER
91794 + help
91795 +
91796 +config GRKERNSEC_CONFIG_SERVER
91797 + bool "Server"
91798 + help
91799 + Choose this option if you plan to use this kernel on a server.
91800 +
91801 +config GRKERNSEC_CONFIG_DESKTOP
91802 + bool "Desktop"
91803 + help
91804 + Choose this option if you plan to use this kernel on a desktop.
91805 +
91806 +endchoice
91807 +
91808 +choice
91809 + prompt "Virtualization Type"
91810 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
91811 + default GRKERNSEC_CONFIG_VIRT_NONE
91812 + help
91813 +
91814 +config GRKERNSEC_CONFIG_VIRT_NONE
91815 + bool "None"
91816 + help
91817 + Choose this option if this kernel will be run on bare metal.
91818 +
91819 +config GRKERNSEC_CONFIG_VIRT_GUEST
91820 + bool "Guest"
91821 + help
91822 + Choose this option if this kernel will be run as a VM guest.
91823 +
91824 +config GRKERNSEC_CONFIG_VIRT_HOST
91825 + bool "Host"
91826 + help
91827 + Choose this option if this kernel will be run as a VM host.
91828 +
91829 +endchoice
91830 +
91831 +choice
91832 + prompt "Virtualization Hardware"
91833 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
91834 + help
91835 +
91836 +config GRKERNSEC_CONFIG_VIRT_EPT
91837 + bool "EPT/RVI Processor Support"
91838 + depends on X86
91839 + help
91840 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
91841 + hardware virtualization. This allows for additional kernel hardening protections
91842 + to operate without additional performance impact.
91843 +
91844 + To see if your Intel processor supports EPT, see:
91845 + http://ark.intel.com/Products/VirtualizationTechnology
91846 + (Most Core i3/5/7 support EPT)
91847 +
91848 + To see if your AMD processor supports RVI, see:
91849 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
91850 +
91851 +config GRKERNSEC_CONFIG_VIRT_SOFT
91852 + bool "First-gen/No Hardware Virtualization"
91853 + help
91854 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
91855 + support hardware virtualization or doesn't support the EPT/RVI extensions.
91856 +
91857 +endchoice
91858 +
91859 +choice
91860 + prompt "Virtualization Software"
91861 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
91862 + help
91863 +
91864 +config GRKERNSEC_CONFIG_VIRT_XEN
91865 + bool "Xen"
91866 + help
91867 + Choose this option if this kernel is running as a Xen guest or host.
91868 +
91869 +config GRKERNSEC_CONFIG_VIRT_VMWARE
91870 + bool "VMWare"
91871 + help
91872 + Choose this option if this kernel is running as a VMWare guest or host.
91873 +
91874 +config GRKERNSEC_CONFIG_VIRT_KVM
91875 + bool "KVM"
91876 + help
91877 + Choose this option if this kernel is running as a KVM guest or host.
91878 +
91879 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
91880 + bool "VirtualBox"
91881 + help
91882 + Choose this option if this kernel is running as a VirtualBox guest or host.
91883 +
91884 +endchoice
91885 +
91886 +choice
91887 + prompt "Required Priorities"
91888 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91889 + default GRKERNSEC_CONFIG_PRIORITY_PERF
91890 + help
91891 +
91892 +config GRKERNSEC_CONFIG_PRIORITY_PERF
91893 + bool "Performance"
91894 + help
91895 + Choose this option if performance is of highest priority for this deployment
91896 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
91897 + clearing of structures intended for userland, and freed memory sanitizing will
91898 + be disabled.
91899 +
91900 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
91901 + bool "Security"
91902 + help
91903 + Choose this option if security is of highest priority for this deployment of
91904 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
91905 + for userland, and freed memory sanitizing will be enabled for this kernel.
91906 + In a worst-case scenario, these features can introduce a 20% performance hit
91907 + (UDEREF on x64 contributing half of this hit).
91908 +
91909 +endchoice
91910 +
91911 +menu "Default Special Groups"
91912 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
91913 +
91914 +config GRKERNSEC_PROC_GID
91915 + int "GID exempted from /proc restrictions"
91916 + default 1001
91917 + help
91918 + Setting this GID determines which group will be exempted from
91919 + grsecurity's /proc restrictions, allowing users of the specified
91920 + group to view network statistics and the existence of other users'
91921 + processes on the system. This GID may also be chosen at boot time
91922 + via "grsec_proc_gid=" on the kernel commandline.
91923 +
91924 +config GRKERNSEC_TPE_UNTRUSTED_GID
91925 + int "GID for TPE-untrusted users"
91926 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
91927 + default 1005
91928 + help
91929 + Setting this GID determines which group untrusted users should
91930 + be added to. These users will be placed under grsecurity's Trusted Path
91931 + Execution mechanism, preventing them from executing their own binaries.
91932 + The users will only be able to execute binaries in directories owned and
91933 + writable only by the root user. If the sysctl option is enabled, a sysctl
91934 + option with name "tpe_gid" is created.
91935 +
91936 +config GRKERNSEC_TPE_TRUSTED_GID
91937 + int "GID for TPE-trusted users"
91938 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
91939 + default 1005
91940 + help
91941 + Setting this GID determines what group TPE restrictions will be
91942 + *disabled* for. If the sysctl option is enabled, a sysctl option
91943 + with name "tpe_gid" is created.
91944 +
91945 +config GRKERNSEC_SYMLINKOWN_GID
91946 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
91947 + depends on GRKERNSEC_CONFIG_SERVER
91948 + default 1006
91949 + help
91950 + Setting this GID determines what group kernel-enforced
91951 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
91952 + is enabled, a sysctl option with name "symlinkown_gid" is created.
91953 +
91954 +
91955 +endmenu
91956 +
91957 +menu "Customize Configuration"
91958 +depends on GRKERNSEC
91959 +
91960 +menu "PaX"
91961 +
91962 +config PAX
91963 + bool "Enable various PaX features"
91964 + default y if GRKERNSEC_CONFIG_AUTO
91965 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
91966 + help
91967 + This allows you to enable various PaX features. PaX adds
91968 + intrusion prevention mechanisms to the kernel that reduce
91969 + the risks posed by exploitable memory corruption bugs.
91970 +
91971 +menu "PaX Control"
91972 + depends on PAX
91973 +
91974 +config PAX_SOFTMODE
91975 + bool 'Support soft mode'
91976 + help
91977 + Enabling this option will allow you to run PaX in soft mode, that
91978 + is, PaX features will not be enforced by default, only on executables
91979 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
91980 + support as they are the only way to mark executables for soft mode use.
91981 +
91982 + Soft mode can be activated by using the "pax_softmode=1" kernel command
91983 + line option on boot. Furthermore you can control various PaX features
91984 + at runtime via the entries in /proc/sys/kernel/pax.
91985 +
91986 +config PAX_EI_PAX
91987 + bool 'Use legacy ELF header marking'
91988 + default y if GRKERNSEC_CONFIG_AUTO
91989 + help
91990 + Enabling this option will allow you to control PaX features on
91991 + a per executable basis via the 'chpax' utility available at
91992 + http://pax.grsecurity.net/. The control flags will be read from
91993 + an otherwise reserved part of the ELF header. This marking has
91994 + numerous drawbacks (no support for soft-mode, toolchain does not
91995 + know about the non-standard use of the ELF header) therefore it
91996 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
91997 + support.
91998 +
91999 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
92000 + support as well, they will override the legacy EI_PAX marks.
92001 +
92002 + If you enable none of the marking options then all applications
92003 + will run with PaX enabled on them by default.
92004 +
92005 +config PAX_PT_PAX_FLAGS
92006 + bool 'Use ELF program header marking'
92007 + default y if GRKERNSEC_CONFIG_AUTO
92008 + help
92009 + Enabling this option will allow you to control PaX features on
92010 + a per executable basis via the 'paxctl' utility available at
92011 + http://pax.grsecurity.net/. The control flags will be read from
92012 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
92013 + has the benefits of supporting both soft mode and being fully
92014 + integrated into the toolchain (the binutils patch is available
92015 + from http://pax.grsecurity.net).
92016 +
92017 + Note that if you enable the legacy EI_PAX marking support as well,
92018 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
92019 +
92020 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
92021 + must make sure that the marks are the same if a binary has both marks.
92022 +
92023 + If you enable none of the marking options then all applications
92024 + will run with PaX enabled on them by default.
92025 +
92026 +config PAX_XATTR_PAX_FLAGS
92027 + bool 'Use filesystem extended attributes marking'
92028 + default y if GRKERNSEC_CONFIG_AUTO
92029 + select CIFS_XATTR if CIFS
92030 + select EXT2_FS_XATTR if EXT2_FS
92031 + select EXT3_FS_XATTR if EXT3_FS
92032 + select EXT4_FS_XATTR if EXT4_FS
92033 + select JFFS2_FS_XATTR if JFFS2_FS
92034 + select REISERFS_FS_XATTR if REISERFS_FS
92035 + select SQUASHFS_XATTR if SQUASHFS
92036 + select TMPFS_XATTR if TMPFS
92037 + select UBIFS_FS_XATTR if UBIFS_FS
92038 + help
92039 + Enabling this option will allow you to control PaX features on
92040 + a per executable basis via the 'setfattr' utility. The control
92041 + flags will be read from the user.pax.flags extended attribute of
92042 + the file. This marking has the benefit of supporting binary-only
92043 + applications that self-check themselves (e.g., skype) and would
92044 + not tolerate chpax/paxctl changes. The main drawback is that
92045 + extended attributes are not supported by some filesystems (e.g.,
92046 + isofs, udf, vfat) so copying files through such filesystems will
92047 + lose the extended attributes and these PaX markings.
92048 +
92049 + Note that if you enable the legacy EI_PAX marking support as well,
92050 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
92051 +
92052 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
92053 + must make sure that the marks are the same if a binary has both marks.
92054 +
92055 + If you enable none of the marking options then all applications
92056 + will run with PaX enabled on them by default.
92057 +
92058 +choice
92059 + prompt 'MAC system integration'
92060 + default PAX_HAVE_ACL_FLAGS
92061 + help
92062 + Mandatory Access Control systems have the option of controlling
92063 + PaX flags on a per executable basis, choose the method supported
92064 + by your particular system.
92065 +
92066 + - "none": if your MAC system does not interact with PaX,
92067 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
92068 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
92069 +
92070 + NOTE: this option is for developers/integrators only.
92071 +
92072 + config PAX_NO_ACL_FLAGS
92073 + bool 'none'
92074 +
92075 + config PAX_HAVE_ACL_FLAGS
92076 + bool 'direct'
92077 +
92078 + config PAX_HOOK_ACL_FLAGS
92079 + bool 'hook'
92080 +endchoice
92081 +
92082 +endmenu
92083 +
92084 +menu "Non-executable pages"
92085 + depends on PAX
92086 +
92087 +config PAX_NOEXEC
92088 + bool "Enforce non-executable pages"
92089 + default y if GRKERNSEC_CONFIG_AUTO
92090 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
92091 + help
92092 + By design some architectures do not allow for protecting memory
92093 + pages against execution or even if they do, Linux does not make
92094 + use of this feature. In practice this means that if a page is
92095 + readable (such as the stack or heap) it is also executable.
92096 +
92097 + There is a well known exploit technique that makes use of this
92098 + fact and a common programming mistake where an attacker can
92099 + introduce code of his choice somewhere in the attacked program's
92100 + memory (typically the stack or the heap) and then execute it.
92101 +
92102 + If the attacked program was running with different (typically
92103 + higher) privileges than that of the attacker, then he can elevate
92104 + his own privilege level (e.g. get a root shell, write to files for
92105 + which he does not have write access to, etc).
92106 +
92107 + Enabling this option will let you choose from various features
92108 + that prevent the injection and execution of 'foreign' code in
92109 + a program.
92110 +
92111 + This will also break programs that rely on the old behaviour and
92112 + expect that dynamically allocated memory via the malloc() family
92113 + of functions is executable (which it is not). Notable examples
92114 + are the XFree86 4.x server, the java runtime and wine.
92115 +
92116 +config PAX_PAGEEXEC
92117 + bool "Paging based non-executable pages"
92118 + default y if GRKERNSEC_CONFIG_AUTO
92119 + 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)
92120 + select S390_SWITCH_AMODE if S390
92121 + select S390_EXEC_PROTECT if S390
92122 + select ARCH_TRACK_EXEC_LIMIT if X86_32
92123 + help
92124 + This implementation is based on the paging feature of the CPU.
92125 + On i386 without hardware non-executable bit support there is a
92126 + variable but usually low performance impact, however on Intel's
92127 + P4 core based CPUs it is very high so you should not enable this
92128 + for kernels meant to be used on such CPUs.
92129 +
92130 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
92131 + with hardware non-executable bit support there is no performance
92132 + impact, on ppc the impact is negligible.
92133 +
92134 + Note that several architectures require various emulations due to
92135 + badly designed userland ABIs, this will cause a performance impact
92136 + but will disappear as soon as userland is fixed. For example, ppc
92137 + userland MUST have been built with secure-plt by a recent toolchain.
92138 +
92139 +config PAX_SEGMEXEC
92140 + bool "Segmentation based non-executable pages"
92141 + default y if GRKERNSEC_CONFIG_AUTO
92142 + depends on PAX_NOEXEC && X86_32
92143 + help
92144 + This implementation is based on the segmentation feature of the
92145 + CPU and has a very small performance impact, however applications
92146 + will be limited to a 1.5 GB address space instead of the normal
92147 + 3 GB.
92148 +
92149 +config PAX_EMUTRAMP
92150 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
92151 + default y if PARISC
92152 + help
92153 + There are some programs and libraries that for one reason or
92154 + another attempt to execute special small code snippets from
92155 + non-executable memory pages. Most notable examples are the
92156 + signal handler return code generated by the kernel itself and
92157 + the GCC trampolines.
92158 +
92159 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
92160 + such programs will no longer work under your kernel.
92161 +
92162 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
92163 + utilities to enable trampoline emulation for the affected programs
92164 + yet still have the protection provided by the non-executable pages.
92165 +
92166 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
92167 + your system will not even boot.
92168 +
92169 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
92170 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
92171 + for the affected files.
92172 +
92173 + NOTE: enabling this feature *may* open up a loophole in the
92174 + protection provided by non-executable pages that an attacker
92175 + could abuse. Therefore the best solution is to not have any
92176 + files on your system that would require this option. This can
92177 + be achieved by not using libc5 (which relies on the kernel
92178 + signal handler return code) and not using or rewriting programs
92179 + that make use of the nested function implementation of GCC.
92180 + Skilled users can just fix GCC itself so that it implements
92181 + nested function calls in a way that does not interfere with PaX.
92182 +
92183 +config PAX_EMUSIGRT
92184 + bool "Automatically emulate sigreturn trampolines"
92185 + depends on PAX_EMUTRAMP && PARISC
92186 + default y
92187 + help
92188 + Enabling this option will have the kernel automatically detect
92189 + and emulate signal return trampolines executing on the stack
92190 + that would otherwise lead to task termination.
92191 +
92192 + This solution is intended as a temporary one for users with
92193 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
92194 + Modula-3 runtime, etc) or executables linked to such, basically
92195 + everything that does not specify its own SA_RESTORER function in
92196 + normal executable memory like glibc 2.1+ does.
92197 +
92198 + On parisc you MUST enable this option, otherwise your system will
92199 + not even boot.
92200 +
92201 + NOTE: this feature cannot be disabled on a per executable basis
92202 + and since it *does* open up a loophole in the protection provided
92203 + by non-executable pages, the best solution is to not have any
92204 + files on your system that would require this option.
92205 +
92206 +config PAX_MPROTECT
92207 + bool "Restrict mprotect()"
92208 + default y if GRKERNSEC_CONFIG_AUTO
92209 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
92210 + help
92211 + Enabling this option will prevent programs from
92212 + - changing the executable status of memory pages that were
92213 + not originally created as executable,
92214 + - making read-only executable pages writable again,
92215 + - creating executable pages from anonymous memory,
92216 + - making read-only-after-relocations (RELRO) data pages writable again.
92217 +
92218 + You should say Y here to complete the protection provided by
92219 + the enforcement of non-executable pages.
92220 +
92221 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
92222 + this feature on a per file basis.
92223 +
92224 +config PAX_MPROTECT_COMPAT
92225 + bool "Use legacy/compat protection demoting (read help)"
92226 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
92227 + depends on PAX_MPROTECT
92228 + help
92229 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
92230 + by sending the proper error code to the application. For some broken
92231 + userland, this can cause problems with Python or other applications. The
92232 + current implementation however allows for applications like clamav to
92233 + detect if JIT compilation/execution is allowed and to fall back gracefully
92234 + to an interpreter-based mode if it does not. While we encourage everyone
92235 + to use the current implementation as-is and push upstream to fix broken
92236 + userland (note that the RWX logging option can assist with this), in some
92237 + environments this may not be possible. Having to disable MPROTECT
92238 + completely on certain binaries reduces the security benefit of PaX,
92239 + so this option is provided for those environments to revert to the old
92240 + behavior.
92241 +
92242 +config PAX_ELFRELOCS
92243 + bool "Allow ELF text relocations (read help)"
92244 + depends on PAX_MPROTECT
92245 + default n
92246 + help
92247 + Non-executable pages and mprotect() restrictions are effective
92248 + in preventing the introduction of new executable code into an
92249 + attacked task's address space. There remain only two venues
92250 + for this kind of attack: if the attacker can execute already
92251 + existing code in the attacked task then he can either have it
92252 + create and mmap() a file containing his code or have it mmap()
92253 + an already existing ELF library that does not have position
92254 + independent code in it and use mprotect() on it to make it
92255 + writable and copy his code there. While protecting against
92256 + the former approach is beyond PaX, the latter can be prevented
92257 + by having only PIC ELF libraries on one's system (which do not
92258 + need to relocate their code). If you are sure this is your case,
92259 + as is the case with all modern Linux distributions, then leave
92260 + this option disabled. You should say 'n' here.
92261 +
92262 +config PAX_ETEXECRELOCS
92263 + bool "Allow ELF ET_EXEC text relocations"
92264 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
92265 + select PAX_ELFRELOCS
92266 + default y
92267 + help
92268 + On some architectures there are incorrectly created applications
92269 + that require text relocations and would not work without enabling
92270 + this option. If you are an alpha, ia64 or parisc user, you should
92271 + enable this option and disable it once you have made sure that
92272 + none of your applications need it.
92273 +
92274 +config PAX_EMUPLT
92275 + bool "Automatically emulate ELF PLT"
92276 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
92277 + default y
92278 + help
92279 + Enabling this option will have the kernel automatically detect
92280 + and emulate the Procedure Linkage Table entries in ELF files.
92281 + On some architectures such entries are in writable memory, and
92282 + become non-executable leading to task termination. Therefore
92283 + it is mandatory that you enable this option on alpha, parisc,
92284 + sparc and sparc64, otherwise your system would not even boot.
92285 +
92286 + NOTE: this feature *does* open up a loophole in the protection
92287 + provided by the non-executable pages, therefore the proper
92288 + solution is to modify the toolchain to produce a PLT that does
92289 + not need to be writable.
92290 +
92291 +config PAX_DLRESOLVE
92292 + bool 'Emulate old glibc resolver stub'
92293 + depends on PAX_EMUPLT && SPARC
92294 + default n
92295 + help
92296 + This option is needed if userland has an old glibc (before 2.4)
92297 + that puts a 'save' instruction into the runtime generated resolver
92298 + stub that needs special emulation.
92299 +
92300 +config PAX_KERNEXEC
92301 + bool "Enforce non-executable kernel pages"
92302 + 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))
92303 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
92304 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
92305 + select PAX_KERNEXEC_PLUGIN if X86_64
92306 + help
92307 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
92308 + that is, enabling this option will make it harder to inject
92309 + and execute 'foreign' code in kernel memory itself.
92310 +
92311 +choice
92312 + prompt "Return Address Instrumentation Method"
92313 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
92314 + depends on PAX_KERNEXEC_PLUGIN
92315 + help
92316 + Select the method used to instrument function pointer dereferences.
92317 + Note that binary modules cannot be instrumented by this approach.
92318 +
92319 + Note that the implementation requires a gcc with plugin support,
92320 + i.e., gcc 4.5 or newer. You may need to install the supporting
92321 + headers explicitly in addition to the normal gcc package.
92322 +
92323 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
92324 + bool "bts"
92325 + help
92326 + This method is compatible with binary only modules but has
92327 + a higher runtime overhead.
92328 +
92329 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
92330 + bool "or"
92331 + depends on !PARAVIRT
92332 + help
92333 + This method is incompatible with binary only modules but has
92334 + a lower runtime overhead.
92335 +endchoice
92336 +
92337 +config PAX_KERNEXEC_PLUGIN_METHOD
92338 + string
92339 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
92340 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
92341 + default ""
92342 +
92343 +config PAX_KERNEXEC_MODULE_TEXT
92344 + int "Minimum amount of memory reserved for module code"
92345 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
92346 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
92347 + depends on PAX_KERNEXEC && X86_32
92348 + help
92349 + Due to implementation details the kernel must reserve a fixed
92350 + amount of memory for runtime allocated code (such as modules)
92351 + at compile time that cannot be changed at runtime. Here you
92352 + can specify the minimum amount in MB that will be reserved.
92353 + Due to the same implementation details this size will always
92354 + be rounded up to the next 2/4 MB boundary (depends on PAE) so
92355 + the actually available memory for runtime allocated code will
92356 + usually be more than this minimum.
92357 +
92358 + The default 4 MB should be enough for most users but if you have
92359 + an excessive number of modules (e.g., most distribution configs
92360 + compile many drivers as modules) or use huge modules such as
92361 + nvidia's kernel driver, you will need to adjust this amount.
92362 + A good rule of thumb is to look at your currently loaded kernel
92363 + modules and add up their sizes.
92364 +
92365 +endmenu
92366 +
92367 +menu "Address Space Layout Randomization"
92368 + depends on PAX
92369 +
92370 +config PAX_ASLR
92371 + bool "Address Space Layout Randomization"
92372 + default y if GRKERNSEC_CONFIG_AUTO
92373 + help
92374 + Many if not most exploit techniques rely on the knowledge of
92375 + certain addresses in the attacked program. The following options
92376 + will allow the kernel to apply a certain amount of randomization
92377 + to specific parts of the program thereby forcing an attacker to
92378 + guess them in most cases. Any failed guess will most likely crash
92379 + the attacked program which allows the kernel to detect such attempts
92380 + and react on them. PaX itself provides no reaction mechanisms,
92381 + instead it is strongly encouraged that you make use of Nergal's
92382 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
92383 + (http://www.grsecurity.net/) built-in crash detection features or
92384 + develop one yourself.
92385 +
92386 + By saying Y here you can choose to randomize the following areas:
92387 + - top of the task's kernel stack
92388 + - top of the task's userland stack
92389 + - base address for mmap() requests that do not specify one
92390 + (this includes all libraries)
92391 + - base address of the main executable
92392 +
92393 + It is strongly recommended to say Y here as address space layout
92394 + randomization has negligible impact on performance yet it provides
92395 + a very effective protection.
92396 +
92397 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
92398 + this feature on a per file basis.
92399 +
92400 +config PAX_RANDKSTACK
92401 + bool "Randomize kernel stack base"
92402 + default y if GRKERNSEC_CONFIG_AUTO
92403 + depends on X86_TSC && X86
92404 + help
92405 + By saying Y here the kernel will randomize every task's kernel
92406 + stack on every system call. This will not only force an attacker
92407 + to guess it but also prevent him from making use of possible
92408 + leaked information about it.
92409 +
92410 + Since the kernel stack is a rather scarce resource, randomization
92411 + may cause unexpected stack overflows, therefore you should very
92412 + carefully test your system. Note that once enabled in the kernel
92413 + configuration, this feature cannot be disabled on a per file basis.
92414 +
92415 +config PAX_RANDUSTACK
92416 + bool "Randomize user stack base"
92417 + default y if GRKERNSEC_CONFIG_AUTO
92418 + depends on PAX_ASLR
92419 + help
92420 + By saying Y here the kernel will randomize every task's userland
92421 + stack. The randomization is done in two steps where the second
92422 + one may apply a big amount of shift to the top of the stack and
92423 + cause problems for programs that want to use lots of memory (more
92424 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
92425 + For this reason the second step can be controlled by 'chpax' or
92426 + 'paxctl' on a per file basis.
92427 +
92428 +config PAX_RANDMMAP
92429 + bool "Randomize mmap() base"
92430 + default y if GRKERNSEC_CONFIG_AUTO
92431 + depends on PAX_ASLR
92432 + help
92433 + By saying Y here the kernel will use a randomized base address for
92434 + mmap() requests that do not specify one themselves. As a result
92435 + all dynamically loaded libraries will appear at random addresses
92436 + and therefore be harder to exploit by a technique where an attacker
92437 + attempts to execute library code for his purposes (e.g. spawn a
92438 + shell from an exploited program that is running at an elevated
92439 + privilege level).
92440 +
92441 + Furthermore, if a program is relinked as a dynamic ELF file, its
92442 + base address will be randomized as well, completing the full
92443 + randomization of the address space layout. Attacking such programs
92444 + becomes a guess game. You can find an example of doing this at
92445 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
92446 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
92447 +
92448 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
92449 + feature on a per file basis.
92450 +
92451 +endmenu
92452 +
92453 +menu "Miscellaneous hardening features"
92454 +
92455 +config PAX_MEMORY_SANITIZE
92456 + bool "Sanitize all freed memory"
92457 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92458 + depends on !HIBERNATION
92459 + help
92460 + By saying Y here the kernel will erase memory pages as soon as they
92461 + are freed. This in turn reduces the lifetime of data stored in the
92462 + pages, making it less likely that sensitive information such as
92463 + passwords, cryptographic secrets, etc stay in memory for too long.
92464 +
92465 + This is especially useful for programs whose runtime is short, long
92466 + lived processes and the kernel itself benefit from this as long as
92467 + they operate on whole memory pages and ensure timely freeing of pages
92468 + that may hold sensitive information.
92469 +
92470 + The tradeoff is performance impact, on a single CPU system kernel
92471 + compilation sees a 3% slowdown, other systems and workloads may vary
92472 + and you are advised to test this feature on your expected workload
92473 + before deploying it.
92474 +
92475 + Note that this feature does not protect data stored in live pages,
92476 + e.g., process memory swapped to disk may stay there for a long time.
92477 +
92478 +config PAX_MEMORY_STACKLEAK
92479 + bool "Sanitize kernel stack"
92480 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92481 + depends on X86
92482 + help
92483 + By saying Y here the kernel will erase the kernel stack before it
92484 + returns from a system call. This in turn reduces the information
92485 + that a kernel stack leak bug can reveal.
92486 +
92487 + Note that such a bug can still leak information that was put on
92488 + the stack by the current system call (the one eventually triggering
92489 + the bug) but traces of earlier system calls on the kernel stack
92490 + cannot leak anymore.
92491 +
92492 + The tradeoff is performance impact: on a single CPU system kernel
92493 + compilation sees a 1% slowdown, other systems and workloads may vary
92494 + and you are advised to test this feature on your expected workload
92495 + before deploying it.
92496 +
92497 + Note that the full feature requires a gcc with plugin support,
92498 + i.e., gcc 4.5 or newer. You may need to install the supporting
92499 + headers explicitly in addition to the normal gcc package. Using
92500 + older gcc versions means that functions with large enough stack
92501 + frames may leave uninitialized memory behind that may be exposed
92502 + to a later syscall leaking the stack.
92503 +
92504 +config PAX_MEMORY_STRUCTLEAK
92505 + bool "Forcibly initialize local variables copied to userland"
92506 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
92507 + help
92508 + By saying Y here the kernel will zero initialize some local
92509 + variables that are going to be copied to userland. This in
92510 + turn prevents unintended information leakage from the kernel
92511 + stack should later code forget to explicitly set all parts of
92512 + the copied variable.
92513 +
92514 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
92515 + at a much smaller coverage.
92516 +
92517 + Note that the implementation requires a gcc with plugin support,
92518 + i.e., gcc 4.5 or newer. You may need to install the supporting
92519 + headers explicitly in addition to the normal gcc package.
92520 +
92521 +config PAX_MEMORY_UDEREF
92522 + bool "Prevent invalid userland pointer dereference"
92523 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
92524 + depends on (X86 || (ARM && (CPU_V6 || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
92525 + select PAX_PER_CPU_PGD if X86_64
92526 + help
92527 + By saying Y here the kernel will be prevented from dereferencing
92528 + userland pointers in contexts where the kernel expects only kernel
92529 + pointers. This is both a useful runtime debugging feature and a
92530 + security measure that prevents exploiting a class of kernel bugs.
92531 +
92532 + The tradeoff is that some virtualization solutions may experience
92533 + a huge slowdown and therefore you should not enable this feature
92534 + for kernels meant to run in such environments. Whether a given VM
92535 + solution is affected or not is best determined by simply trying it
92536 + out, the performance impact will be obvious right on boot as this
92537 + mechanism engages from very early on. A good rule of thumb is that
92538 + VMs running on CPUs without hardware virtualization support (i.e.,
92539 + the majority of IA-32 CPUs) will likely experience the slowdown.
92540 +
92541 +config PAX_REFCOUNT
92542 + bool "Prevent various kernel object reference counter overflows"
92543 + default y if GRKERNSEC_CONFIG_AUTO
92544 + depends on GRKERNSEC && ((ARM && (CPU_32v6 || CPU_32v6K || CPU_32v7)) || SPARC64 || X86)
92545 + help
92546 + By saying Y here the kernel will detect and prevent overflowing
92547 + various (but not all) kinds of object reference counters. Such
92548 + overflows can normally occur due to bugs only and are often, if
92549 + not always, exploitable.
92550 +
92551 + The tradeoff is that data structures protected by an overflowed
92552 + refcount will never be freed and therefore will leak memory. Note
92553 + that this leak also happens even without this protection but in
92554 + that case the overflow can eventually trigger the freeing of the
92555 + data structure while it is still being used elsewhere, resulting
92556 + in the exploitable situation that this feature prevents.
92557 +
92558 + Since this has a negligible performance impact, you should enable
92559 + this feature.
92560 +
92561 +config PAX_CONSTIFY_PLUGIN
92562 + bool "Automatically constify eligible structures"
92563 + default y
92564 + depends on !UML && PAX_KERNEXEC
92565 + help
92566 + By saying Y here the compiler will automatically constify a class
92567 + of types that contain only function pointers. This reduces the
92568 + kernel's attack surface and also produces a better memory layout.
92569 +
92570 + Note that the implementation requires a gcc with plugin support,
92571 + i.e., gcc 4.5 or newer. You may need to install the supporting
92572 + headers explicitly in addition to the normal gcc package.
92573 +
92574 + Note that if some code really has to modify constified variables
92575 + then the source code will have to be patched to allow it. Examples
92576 + can be found in PaX itself (the no_const attribute) and for some
92577 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
92578 +
92579 +config PAX_USERCOPY
92580 + bool "Harden heap object copies between kernel and userland"
92581 + default y if GRKERNSEC_CONFIG_AUTO
92582 + depends on ARM || IA64 || PPC || SPARC || X86
92583 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
92584 + select PAX_USERCOPY_SLABS
92585 + help
92586 + By saying Y here the kernel will enforce the size of heap objects
92587 + when they are copied in either direction between the kernel and
92588 + userland, even if only a part of the heap object is copied.
92589 +
92590 + Specifically, this checking prevents information leaking from the
92591 + kernel heap during kernel to userland copies (if the kernel heap
92592 + object is otherwise fully initialized) and prevents kernel heap
92593 + overflows during userland to kernel copies.
92594 +
92595 + Note that the current implementation provides the strictest bounds
92596 + checks for the SLUB allocator.
92597 +
92598 + Enabling this option also enables per-slab cache protection against
92599 + data in a given cache being copied into/out of via userland
92600 + accessors. Though the whitelist of regions will be reduced over
92601 + time, it notably protects important data structures like task structs.
92602 +
92603 + If frame pointers are enabled on x86, this option will also restrict
92604 + copies into and out of the kernel stack to local variables within a
92605 + single frame.
92606 +
92607 + Since this has a negligible performance impact, you should enable
92608 + this feature.
92609 +
92610 +config PAX_USERCOPY_DEBUG
92611 + bool
92612 + depends on X86 && PAX_USERCOPY
92613 + default n
92614 +
92615 +config PAX_SIZE_OVERFLOW
92616 + bool "Prevent various integer overflows in function size parameters"
92617 + default y if GRKERNSEC_CONFIG_AUTO
92618 + depends on X86
92619 + help
92620 + By saying Y here the kernel recomputes expressions of function
92621 + arguments marked by a size_overflow attribute with double integer
92622 + precision (DImode/TImode for 32/64 bit integer types).
92623 +
92624 + The recomputed argument is checked against TYPE_MAX and an event
92625 + is logged on overflow and the triggering process is killed.
92626 +
92627 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
92628 +
92629 + Note that the implementation requires a gcc with plugin support,
92630 + i.e., gcc 4.5 or newer. You may need to install the supporting
92631 + headers explicitly in addition to the normal gcc package.
92632 +
92633 +config PAX_LATENT_ENTROPY
92634 + bool "Generate some entropy during boot"
92635 + default y if GRKERNSEC_CONFIG_AUTO
92636 + help
92637 + By saying Y here the kernel will instrument early boot code to
92638 + extract some entropy from both original and artificially created
92639 + program state. This will help especially embedded systems where
92640 + there is little 'natural' source of entropy normally. The cost
92641 + is some slowdown of the boot process.
92642 +
92643 + When pax_extra_latent_entropy is passed on the kernel command line,
92644 + entropy will be extracted from up to the first 4GB of RAM while the
92645 + runtime memory allocator is being initialized. This costs even more
92646 + slowdown of the boot process.
92647 +
92648 + Note that the implementation requires a gcc with plugin support,
92649 + i.e., gcc 4.5 or newer. You may need to install the supporting
92650 + headers explicitly in addition to the normal gcc package.
92651 +
92652 + Note that entropy extracted this way is not cryptographically
92653 + secure!
92654 +
92655 +endmenu
92656 +
92657 +endmenu
92658 +
92659 +source grsecurity/Kconfig
92660 +
92661 +endmenu
92662 +
92663 +endmenu
92664 +
92665 source security/keys/Kconfig
92666
92667 config SECURITY_DMESG_RESTRICT
92668 @@ -103,7 +1042,7 @@ config INTEL_TXT
92669 config LSM_MMAP_MIN_ADDR
92670 int "Low address space for LSM to protect from user allocation"
92671 depends on SECURITY && SECURITY_SELINUX
92672 - default 32768 if ARM
92673 + default 32768 if ALPHA || ARM || PARISC || SPARC32
92674 default 65536
92675 help
92676 This is the portion of low virtual memory which should be protected
92677 diff --git a/security/apparmor/Kconfig b/security/apparmor/Kconfig
92678 index 9b9013b..51ebf96 100644
92679 --- a/security/apparmor/Kconfig
92680 +++ b/security/apparmor/Kconfig
92681 @@ -29,3 +29,12 @@ config SECURITY_APPARMOR_BOOTPARAM_VALUE
92682 boot.
92683
92684 If you are unsure how to answer this question, answer 1.
92685 +
92686 +config SECURITY_APPARMOR_COMPAT_24
92687 + bool "Enable AppArmor 2.4 compatability"
92688 + depends on SECURITY_APPARMOR
92689 + default y
92690 + help
92691 + This option enables compatability with AppArmor 2.4. It is
92692 + recommended if compatability with older versions of AppArmor
92693 + is desired.
92694 diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
92695 index 16c15ec..42b7c9f 100644
92696 --- a/security/apparmor/apparmorfs.c
92697 +++ b/security/apparmor/apparmorfs.c
92698 @@ -182,6 +182,234 @@ const struct file_operations aa_fs_seq_file_ops = {
92699 .release = single_release,
92700 };
92701
92702 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
92703 +/**
92704 + * __next_namespace - find the next namespace to list
92705 + * @root: root namespace to stop search at (NOT NULL)
92706 + * @ns: current ns position (NOT NULL)
92707 + *
92708 + * Find the next namespace from @ns under @root and handle all locking needed
92709 + * while switching current namespace.
92710 + *
92711 + * Returns: next namespace or NULL if at last namespace under @root
92712 + * NOTE: will not unlock root->lock
92713 + */
92714 +static struct aa_namespace *__next_namespace(struct aa_namespace *root,
92715 + struct aa_namespace *ns)
92716 +{
92717 + struct aa_namespace *parent;
92718 +
92719 + /* is next namespace a child */
92720 + if (!list_empty(&ns->sub_ns)) {
92721 + struct aa_namespace *next;
92722 + next = list_first_entry(&ns->sub_ns, typeof(*ns), base.list);
92723 + read_lock(&next->lock);
92724 + return next;
92725 + }
92726 +
92727 + /* check if the next ns is a sibling, parent, gp, .. */
92728 + parent = ns->parent;
92729 + while (parent) {
92730 + read_unlock(&ns->lock);
92731 + list_for_each_entry_continue(ns, &parent->sub_ns, base.list) {
92732 + read_lock(&ns->lock);
92733 + return ns;
92734 + }
92735 + if (parent == root)
92736 + return NULL;
92737 + ns = parent;
92738 + parent = parent->parent;
92739 + }
92740 +
92741 + return NULL;
92742 +}
92743 +
92744 +/**
92745 + * __first_profile - find the first profile in a namespace
92746 + * @root: namespace that is root of profiles being displayed (NOT NULL)
92747 + * @ns: namespace to start in (NOT NULL)
92748 + *
92749 + * Returns: unrefcounted profile or NULL if no profile
92750 + */
92751 +static struct aa_profile *__first_profile(struct aa_namespace *root,
92752 + struct aa_namespace *ns)
92753 +{
92754 + for ( ; ns; ns = __next_namespace(root, ns)) {
92755 + if (!list_empty(&ns->base.profiles))
92756 + return list_first_entry(&ns->base.profiles,
92757 + struct aa_profile, base.list);
92758 + }
92759 + return NULL;
92760 +}
92761 +
92762 +/**
92763 + * __next_profile - step to the next profile in a profile tree
92764 + * @profile: current profile in tree (NOT NULL)
92765 + *
92766 + * Perform a depth first taversal on the profile tree in a namespace
92767 + *
92768 + * Returns: next profile or NULL if done
92769 + * Requires: profile->ns.lock to be held
92770 + */
92771 +static struct aa_profile *__next_profile(struct aa_profile *p)
92772 +{
92773 + struct aa_profile *parent;
92774 + struct aa_namespace *ns = p->ns;
92775 +
92776 + /* is next profile a child */
92777 + if (!list_empty(&p->base.profiles))
92778 + return list_first_entry(&p->base.profiles, typeof(*p),
92779 + base.list);
92780 +
92781 + /* is next profile a sibling, parent sibling, gp, subling, .. */
92782 + parent = p->parent;
92783 + while (parent) {
92784 + list_for_each_entry_continue(p, &parent->base.profiles,
92785 + base.list)
92786 + return p;
92787 + p = parent;
92788 + parent = parent->parent;
92789 + }
92790 +
92791 + /* is next another profile in the namespace */
92792 + list_for_each_entry_continue(p, &ns->base.profiles, base.list)
92793 + return p;
92794 +
92795 + return NULL;
92796 +}
92797 +
92798 +/**
92799 + * next_profile - step to the next profile in where ever it may be
92800 + * @root: root namespace (NOT NULL)
92801 + * @profile: current profile (NOT NULL)
92802 + *
92803 + * Returns: next profile or NULL if there isn't one
92804 + */
92805 +static struct aa_profile *next_profile(struct aa_namespace *root,
92806 + struct aa_profile *profile)
92807 +{
92808 + struct aa_profile *next = __next_profile(profile);
92809 + if (next)
92810 + return next;
92811 +
92812 + /* finished all profiles in namespace move to next namespace */
92813 + return __first_profile(root, __next_namespace(root, profile->ns));
92814 +}
92815 +
92816 +/**
92817 + * p_start - start a depth first traversal of profile tree
92818 + * @f: seq_file to fill
92819 + * @pos: current position
92820 + *
92821 + * Returns: first profile under current namespace or NULL if none found
92822 + *
92823 + * acquires first ns->lock
92824 + */
92825 +static void *p_start(struct seq_file *f, loff_t *pos)
92826 + __acquires(root->lock)
92827 +{
92828 + struct aa_profile *profile = NULL;
92829 + struct aa_namespace *root = aa_current_profile()->ns;
92830 + loff_t l = *pos;
92831 + f->private = aa_get_namespace(root);
92832 +
92833 +
92834 + /* find the first profile */
92835 + read_lock(&root->lock);
92836 + profile = __first_profile(root, root);
92837 +
92838 + /* skip to position */
92839 + for (; profile && l > 0; l--)
92840 + profile = next_profile(root, profile);
92841 +
92842 + return profile;
92843 +}
92844 +
92845 +/**
92846 + * p_next - read the next profile entry
92847 + * @f: seq_file to fill
92848 + * @p: profile previously returned
92849 + * @pos: current position
92850 + *
92851 + * Returns: next profile after @p or NULL if none
92852 + *
92853 + * may acquire/release locks in namespace tree as necessary
92854 + */
92855 +static void *p_next(struct seq_file *f, void *p, loff_t *pos)
92856 +{
92857 + struct aa_profile *profile = p;
92858 + struct aa_namespace *root = f->private;
92859 + (*pos)++;
92860 +
92861 + return next_profile(root, profile);
92862 +}
92863 +
92864 +/**
92865 + * p_stop - stop depth first traversal
92866 + * @f: seq_file we are filling
92867 + * @p: the last profile writen
92868 + *
92869 + * Release all locking done by p_start/p_next on namespace tree
92870 + */
92871 +static void p_stop(struct seq_file *f, void *p)
92872 + __releases(root->lock)
92873 +{
92874 + struct aa_profile *profile = p;
92875 + struct aa_namespace *root = f->private, *ns;
92876 +
92877 + if (profile) {
92878 + for (ns = profile->ns; ns && ns != root; ns = ns->parent)
92879 + read_unlock(&ns->lock);
92880 + }
92881 + read_unlock(&root->lock);
92882 + aa_put_namespace(root);
92883 +}
92884 +
92885 +/**
92886 + * seq_show_profile - show a profile entry
92887 + * @f: seq_file to file
92888 + * @p: current position (profile) (NOT NULL)
92889 + *
92890 + * Returns: error on failure
92891 + */
92892 +static int seq_show_profile(struct seq_file *f, void *p)
92893 +{
92894 + struct aa_profile *profile = (struct aa_profile *)p;
92895 + struct aa_namespace *root = f->private;
92896 +
92897 + if (profile->ns != root)
92898 + seq_printf(f, ":%s://", aa_ns_name(root, profile->ns));
92899 + seq_printf(f, "%s (%s)\n", profile->base.hname,
92900 + COMPLAIN_MODE(profile) ? "complain" : "enforce");
92901 +
92902 + return 0;
92903 +}
92904 +
92905 +static const struct seq_operations aa_fs_profiles_op = {
92906 + .start = p_start,
92907 + .next = p_next,
92908 + .stop = p_stop,
92909 + .show = seq_show_profile,
92910 +};
92911 +
92912 +static int profiles_open(struct inode *inode, struct file *file)
92913 +{
92914 + return seq_open(file, &aa_fs_profiles_op);
92915 +}
92916 +
92917 +static int profiles_release(struct inode *inode, struct file *file)
92918 +{
92919 + return seq_release(inode, file);
92920 +}
92921 +
92922 +const struct file_operations aa_fs_profiles_fops = {
92923 + .open = profiles_open,
92924 + .read = seq_read,
92925 + .llseek = seq_lseek,
92926 + .release = profiles_release,
92927 +};
92928 +#endif /* CONFIG_SECURITY_APPARMOR_COMPAT_24 */
92929 +
92930 /** Base file system setup **/
92931
92932 static struct aa_fs_entry aa_fs_entry_file[] = {
92933 @@ -210,6 +438,9 @@ static struct aa_fs_entry aa_fs_entry_apparmor[] = {
92934 AA_FS_FILE_FOPS(".load", 0640, &aa_fs_profile_load),
92935 AA_FS_FILE_FOPS(".replace", 0640, &aa_fs_profile_replace),
92936 AA_FS_FILE_FOPS(".remove", 0640, &aa_fs_profile_remove),
92937 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
92938 + AA_FS_FILE_FOPS("profiles", 0640, &aa_fs_profiles_fops),
92939 +#endif
92940 AA_FS_DIR("features", aa_fs_entry_features),
92941 { }
92942 };
92943 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
92944 index b21830e..a7d1a17 100644
92945 --- a/security/apparmor/lsm.c
92946 +++ b/security/apparmor/lsm.c
92947 @@ -614,7 +614,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
92948 return error;
92949 }
92950
92951 -static struct security_operations apparmor_ops = {
92952 +static struct security_operations apparmor_ops __read_only = {
92953 .name = "apparmor",
92954
92955 .ptrace_access_check = apparmor_ptrace_access_check,
92956 diff --git a/security/commoncap.c b/security/commoncap.c
92957 index c44b6fe..932df30 100644
92958 --- a/security/commoncap.c
92959 +++ b/security/commoncap.c
92960 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
92961 return 0;
92962 }
92963
92964 +/* returns:
92965 + 1 for suid privilege
92966 + 2 for sgid privilege
92967 + 3 for fscap privilege
92968 +*/
92969 +int is_privileged_binary(const struct dentry *dentry)
92970 +{
92971 + struct cpu_vfs_cap_data capdata;
92972 + struct inode *inode = dentry->d_inode;
92973 +
92974 + if (!inode || S_ISDIR(inode->i_mode))
92975 + return 0;
92976 +
92977 + if (inode->i_mode & S_ISUID)
92978 + return 1;
92979 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
92980 + return 2;
92981 +
92982 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
92983 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
92984 + return 3;
92985 + }
92986 +
92987 + return 0;
92988 +}
92989 +
92990 /*
92991 * Attempt to get the on-exec apply capability sets for an executable file from
92992 * its xattrs and, if present, apply them to the proposed credentials being
92993 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
92994 const struct cred *cred = current_cred();
92995 kuid_t root_uid = make_kuid(cred->user_ns, 0);
92996
92997 + if (gr_acl_enable_at_secure())
92998 + return 1;
92999 +
93000 if (!uid_eq(cred->uid, root_uid)) {
93001 if (bprm->cap_effective)
93002 return 1;
93003 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
93004 index a41c9c1..83da6dd 100644
93005 --- a/security/integrity/ima/ima.h
93006 +++ b/security/integrity/ima/ima.h
93007 @@ -97,8 +97,8 @@ int ima_init_crypto(void);
93008 extern spinlock_t ima_queue_lock;
93009
93010 struct ima_h_table {
93011 - atomic_long_t len; /* number of stored measurements in the list */
93012 - atomic_long_t violations;
93013 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
93014 + atomic_long_unchecked_t violations;
93015 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
93016 };
93017 extern struct ima_h_table ima_htable;
93018 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
93019 index 1c03e8f1..398a941 100644
93020 --- a/security/integrity/ima/ima_api.c
93021 +++ b/security/integrity/ima/ima_api.c
93022 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
93023 int result;
93024
93025 /* can overflow, only indicator */
93026 - atomic_long_inc(&ima_htable.violations);
93027 + atomic_long_inc_unchecked(&ima_htable.violations);
93028
93029 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
93030 if (!entry) {
93031 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
93032 index 38477c9..87a60c7 100644
93033 --- a/security/integrity/ima/ima_fs.c
93034 +++ b/security/integrity/ima/ima_fs.c
93035 @@ -28,12 +28,12 @@
93036 static int valid_policy = 1;
93037 #define TMPBUFLEN 12
93038 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
93039 - loff_t *ppos, atomic_long_t *val)
93040 + loff_t *ppos, atomic_long_unchecked_t *val)
93041 {
93042 char tmpbuf[TMPBUFLEN];
93043 ssize_t len;
93044
93045 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
93046 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
93047 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
93048 }
93049
93050 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
93051 index ff63fe0..809cd96 100644
93052 --- a/security/integrity/ima/ima_queue.c
93053 +++ b/security/integrity/ima/ima_queue.c
93054 @@ -80,7 +80,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
93055 INIT_LIST_HEAD(&qe->later);
93056 list_add_tail_rcu(&qe->later, &ima_measurements);
93057
93058 - atomic_long_inc(&ima_htable.len);
93059 + atomic_long_inc_unchecked(&ima_htable.len);
93060 key = ima_hash_key(entry->digest);
93061 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
93062 return 0;
93063 diff --git a/security/keys/compat.c b/security/keys/compat.c
93064 index d65fa7f..cbfe366 100644
93065 --- a/security/keys/compat.c
93066 +++ b/security/keys/compat.c
93067 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
93068 if (ret == 0)
93069 goto no_payload_free;
93070
93071 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
93072 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
93073 err:
93074 if (iov != iovstack)
93075 kfree(iov);
93076 diff --git a/security/keys/internal.h b/security/keys/internal.h
93077 index d4f1468..cc52f92 100644
93078 --- a/security/keys/internal.h
93079 +++ b/security/keys/internal.h
93080 @@ -242,7 +242,7 @@ extern long keyctl_instantiate_key_iov(key_serial_t,
93081 extern long keyctl_invalidate_key(key_serial_t);
93082
93083 extern long keyctl_instantiate_key_common(key_serial_t,
93084 - const struct iovec *,
93085 + const struct iovec __user *,
93086 unsigned, size_t, key_serial_t);
93087
93088 /*
93089 diff --git a/security/keys/key.c b/security/keys/key.c
93090 index 8fb7c7b..ba3610d 100644
93091 --- a/security/keys/key.c
93092 +++ b/security/keys/key.c
93093 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
93094
93095 atomic_set(&key->usage, 1);
93096 init_rwsem(&key->sem);
93097 - lockdep_set_class(&key->sem, &type->lock_class);
93098 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
93099 key->type = type;
93100 key->user = user;
93101 key->quotalen = quotalen;
93102 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
93103 struct key_type *p;
93104 int ret;
93105
93106 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
93107 + pax_open_kernel();
93108 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
93109 + pax_close_kernel();
93110
93111 ret = -EEXIST;
93112 down_write(&key_types_sem);
93113 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
93114 }
93115
93116 /* store the type */
93117 - list_add(&ktype->link, &key_types_list);
93118 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
93119
93120 pr_notice("Key type %s registered\n", ktype->name);
93121 ret = 0;
93122 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
93123 void unregister_key_type(struct key_type *ktype)
93124 {
93125 down_write(&key_types_sem);
93126 - list_del_init(&ktype->link);
93127 + pax_list_del_init((struct list_head *)&ktype->link);
93128 downgrade_write(&key_types_sem);
93129 key_gc_keytype(ktype);
93130 pr_notice("Key type %s unregistered\n", ktype->name);
93131 @@ -1084,10 +1086,10 @@ void __init key_init(void)
93132 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
93133
93134 /* add the special key types */
93135 - list_add_tail(&key_type_keyring.link, &key_types_list);
93136 - list_add_tail(&key_type_dead.link, &key_types_list);
93137 - list_add_tail(&key_type_user.link, &key_types_list);
93138 - list_add_tail(&key_type_logon.link, &key_types_list);
93139 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
93140 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
93141 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
93142 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
93143
93144 /* record the root user tracking */
93145 rb_link_node(&root_key_user.node,
93146 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
93147 index 33cfd27..842fc5a 100644
93148 --- a/security/keys/keyctl.c
93149 +++ b/security/keys/keyctl.c
93150 @@ -987,7 +987,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
93151 /*
93152 * Copy the iovec data from userspace
93153 */
93154 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
93155 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
93156 unsigned ioc)
93157 {
93158 for (; ioc > 0; ioc--) {
93159 @@ -1009,7 +1009,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
93160 * If successful, 0 will be returned.
93161 */
93162 long keyctl_instantiate_key_common(key_serial_t id,
93163 - const struct iovec *payload_iov,
93164 + const struct iovec __user *payload_iov,
93165 unsigned ioc,
93166 size_t plen,
93167 key_serial_t ringid)
93168 @@ -1104,7 +1104,7 @@ long keyctl_instantiate_key(key_serial_t id,
93169 [0].iov_len = plen
93170 };
93171
93172 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
93173 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
93174 }
93175
93176 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
93177 @@ -1137,7 +1137,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
93178 if (ret == 0)
93179 goto no_payload_free;
93180
93181 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
93182 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
93183 err:
93184 if (iov != iovstack)
93185 kfree(iov);
93186 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
93187 index 6ece7f2..ecdb55c 100644
93188 --- a/security/keys/keyring.c
93189 +++ b/security/keys/keyring.c
93190 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
93191 ret = -EFAULT;
93192
93193 for (loop = 0; loop < klist->nkeys; loop++) {
93194 + key_serial_t serial;
93195 key = rcu_deref_link_locked(klist, loop,
93196 keyring);
93197 + serial = key->serial;
93198
93199 tmp = sizeof(key_serial_t);
93200 if (tmp > buflen)
93201 tmp = buflen;
93202
93203 - if (copy_to_user(buffer,
93204 - &key->serial,
93205 - tmp) != 0)
93206 + if (copy_to_user(buffer, &serial, tmp))
93207 goto error;
93208
93209 buflen -= tmp;
93210 diff --git a/security/min_addr.c b/security/min_addr.c
93211 index f728728..6457a0c 100644
93212 --- a/security/min_addr.c
93213 +++ b/security/min_addr.c
93214 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
93215 */
93216 static void update_mmap_min_addr(void)
93217 {
93218 +#ifndef SPARC
93219 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
93220 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
93221 mmap_min_addr = dac_mmap_min_addr;
93222 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
93223 #else
93224 mmap_min_addr = dac_mmap_min_addr;
93225 #endif
93226 +#endif
93227 }
93228
93229 /*
93230 diff --git a/security/security.c b/security/security.c
93231 index a3dce87..9ca1435 100644
93232 --- a/security/security.c
93233 +++ b/security/security.c
93234 @@ -20,6 +20,7 @@
93235 #include <linux/ima.h>
93236 #include <linux/evm.h>
93237 #include <linux/fsnotify.h>
93238 +#include <linux/mm.h>
93239 #include <linux/mman.h>
93240 #include <linux/mount.h>
93241 #include <linux/personality.h>
93242 @@ -32,8 +33,8 @@
93243 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
93244 CONFIG_DEFAULT_SECURITY;
93245
93246 -static struct security_operations *security_ops;
93247 -static struct security_operations default_security_ops = {
93248 +static struct security_operations *security_ops __read_only;
93249 +static struct security_operations default_security_ops __read_only = {
93250 .name = "default",
93251 };
93252
93253 @@ -74,7 +75,9 @@ int __init security_init(void)
93254
93255 void reset_security_ops(void)
93256 {
93257 + pax_open_kernel();
93258 security_ops = &default_security_ops;
93259 + pax_close_kernel();
93260 }
93261
93262 /* Save user chosen LSM */
93263 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
93264 index 5c6f2cd..b4f945c 100644
93265 --- a/security/selinux/hooks.c
93266 +++ b/security/selinux/hooks.c
93267 @@ -96,8 +96,6 @@
93268
93269 #define NUM_SEL_MNT_OPTS 5
93270
93271 -extern struct security_operations *security_ops;
93272 -
93273 /* SECMARK reference count */
93274 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
93275
93276 @@ -5529,7 +5527,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
93277
93278 #endif
93279
93280 -static struct security_operations selinux_ops = {
93281 +static struct security_operations selinux_ops __read_only = {
93282 .name = "selinux",
93283
93284 .ptrace_access_check = selinux_ptrace_access_check,
93285 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
93286 index 65f67cb..3f141ef 100644
93287 --- a/security/selinux/include/xfrm.h
93288 +++ b/security/selinux/include/xfrm.h
93289 @@ -50,7 +50,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
93290
93291 static inline void selinux_xfrm_notify_policyload(void)
93292 {
93293 - atomic_inc(&flow_cache_genid);
93294 + atomic_inc_unchecked(&flow_cache_genid);
93295 rt_genid_bump(&init_net);
93296 }
93297 #else
93298 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
93299 index d52c780..6431349 100644
93300 --- a/security/smack/smack_lsm.c
93301 +++ b/security/smack/smack_lsm.c
93302 @@ -3392,7 +3392,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
93303 return 0;
93304 }
93305
93306 -struct security_operations smack_ops = {
93307 +struct security_operations smack_ops __read_only = {
93308 .name = "smack",
93309
93310 .ptrace_access_check = smack_ptrace_access_check,
93311 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
93312 index 390c646..f2f8db3 100644
93313 --- a/security/tomoyo/mount.c
93314 +++ b/security/tomoyo/mount.c
93315 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
93316 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
93317 need_dev = -1; /* dev_name is a directory */
93318 } else {
93319 + if (!capable(CAP_SYS_ADMIN)) {
93320 + error = -EPERM;
93321 + goto out;
93322 + }
93323 fstype = get_fs_type(type);
93324 if (!fstype) {
93325 error = -ENODEV;
93326 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
93327 index f0b756e..b129202 100644
93328 --- a/security/tomoyo/tomoyo.c
93329 +++ b/security/tomoyo/tomoyo.c
93330 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
93331 * tomoyo_security_ops is a "struct security_operations" which is used for
93332 * registering TOMOYO.
93333 */
93334 -static struct security_operations tomoyo_security_ops = {
93335 +static struct security_operations tomoyo_security_ops __read_only = {
93336 .name = "tomoyo",
93337 .cred_alloc_blank = tomoyo_cred_alloc_blank,
93338 .cred_prepare = tomoyo_cred_prepare,
93339 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
93340 index 20ef514..4182bed 100644
93341 --- a/security/yama/Kconfig
93342 +++ b/security/yama/Kconfig
93343 @@ -1,6 +1,6 @@
93344 config SECURITY_YAMA
93345 bool "Yama support"
93346 - depends on SECURITY
93347 + depends on SECURITY && !GRKERNSEC
93348 select SECURITYFS
93349 select SECURITY_PATH
93350 default n
93351 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
93352 index 13c88fbc..f8c115e 100644
93353 --- a/security/yama/yama_lsm.c
93354 +++ b/security/yama/yama_lsm.c
93355 @@ -365,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
93356 }
93357
93358 #ifndef CONFIG_SECURITY_YAMA_STACKED
93359 -static struct security_operations yama_ops = {
93360 +static struct security_operations yama_ops __read_only = {
93361 .name = "yama",
93362
93363 .ptrace_access_check = yama_ptrace_access_check,
93364 @@ -376,28 +376,24 @@ static struct security_operations yama_ops = {
93365 #endif
93366
93367 #ifdef CONFIG_SYSCTL
93368 +static int zero __read_only;
93369 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
93370 +
93371 static int yama_dointvec_minmax(struct ctl_table *table, int write,
93372 void __user *buffer, size_t *lenp, loff_t *ppos)
93373 {
93374 - int rc;
93375 + ctl_table_no_const yama_table;
93376
93377 if (write && !capable(CAP_SYS_PTRACE))
93378 return -EPERM;
93379
93380 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
93381 - if (rc)
93382 - return rc;
93383 -
93384 + yama_table = *table;
93385 /* Lock the max value if it ever gets set. */
93386 - if (write && *(int *)table->data == *(int *)table->extra2)
93387 - table->extra1 = table->extra2;
93388 -
93389 - return rc;
93390 + if (ptrace_scope == max_scope)
93391 + yama_table.extra1 = &max_scope;
93392 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
93393 }
93394
93395 -static int zero;
93396 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
93397 -
93398 struct ctl_path yama_sysctl_path[] = {
93399 { .procname = "kernel", },
93400 { .procname = "yama", },
93401 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
93402 index 4cedc69..e59d8a3 100644
93403 --- a/sound/aoa/codecs/onyx.c
93404 +++ b/sound/aoa/codecs/onyx.c
93405 @@ -54,7 +54,7 @@ struct onyx {
93406 spdif_locked:1,
93407 analog_locked:1,
93408 original_mute:2;
93409 - int open_count;
93410 + local_t open_count;
93411 struct codec_info *codec_info;
93412
93413 /* mutex serializes concurrent access to the device
93414 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
93415 struct onyx *onyx = cii->codec_data;
93416
93417 mutex_lock(&onyx->mutex);
93418 - onyx->open_count++;
93419 + local_inc(&onyx->open_count);
93420 mutex_unlock(&onyx->mutex);
93421
93422 return 0;
93423 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
93424 struct onyx *onyx = cii->codec_data;
93425
93426 mutex_lock(&onyx->mutex);
93427 - onyx->open_count--;
93428 - if (!onyx->open_count)
93429 + if (local_dec_and_test(&onyx->open_count))
93430 onyx->spdif_locked = onyx->analog_locked = 0;
93431 mutex_unlock(&onyx->mutex);
93432
93433 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
93434 index ffd2025..df062c9 100644
93435 --- a/sound/aoa/codecs/onyx.h
93436 +++ b/sound/aoa/codecs/onyx.h
93437 @@ -11,6 +11,7 @@
93438 #include <linux/i2c.h>
93439 #include <asm/pmac_low_i2c.h>
93440 #include <asm/prom.h>
93441 +#include <asm/local.h>
93442
93443 /* PCM3052 register definitions */
93444
93445 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
93446 index 4c1cc51..16040040 100644
93447 --- a/sound/core/oss/pcm_oss.c
93448 +++ b/sound/core/oss/pcm_oss.c
93449 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
93450 if (in_kernel) {
93451 mm_segment_t fs;
93452 fs = snd_enter_user();
93453 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
93454 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
93455 snd_leave_user(fs);
93456 } else {
93457 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
93458 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
93459 }
93460 if (ret != -EPIPE && ret != -ESTRPIPE)
93461 break;
93462 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
93463 if (in_kernel) {
93464 mm_segment_t fs;
93465 fs = snd_enter_user();
93466 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
93467 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
93468 snd_leave_user(fs);
93469 } else {
93470 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
93471 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
93472 }
93473 if (ret == -EPIPE) {
93474 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
93475 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
93476 struct snd_pcm_plugin_channel *channels;
93477 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
93478 if (!in_kernel) {
93479 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
93480 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
93481 return -EFAULT;
93482 buf = runtime->oss.buffer;
93483 }
93484 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
93485 }
93486 } else {
93487 tmp = snd_pcm_oss_write2(substream,
93488 - (const char __force *)buf,
93489 + (const char __force_kernel *)buf,
93490 runtime->oss.period_bytes, 0);
93491 if (tmp <= 0)
93492 goto err;
93493 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
93494 struct snd_pcm_runtime *runtime = substream->runtime;
93495 snd_pcm_sframes_t frames, frames1;
93496 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
93497 - char __user *final_dst = (char __force __user *)buf;
93498 + char __user *final_dst = (char __force_user *)buf;
93499 if (runtime->oss.plugin_first) {
93500 struct snd_pcm_plugin_channel *channels;
93501 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
93502 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
93503 xfer += tmp;
93504 runtime->oss.buffer_used -= tmp;
93505 } else {
93506 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
93507 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
93508 runtime->oss.period_bytes, 0);
93509 if (tmp <= 0)
93510 goto err;
93511 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
93512 size1);
93513 size1 /= runtime->channels; /* frames */
93514 fs = snd_enter_user();
93515 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
93516 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
93517 snd_leave_user(fs);
93518 }
93519 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
93520 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
93521 index af49721..e85058e 100644
93522 --- a/sound/core/pcm_compat.c
93523 +++ b/sound/core/pcm_compat.c
93524 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
93525 int err;
93526
93527 fs = snd_enter_user();
93528 - err = snd_pcm_delay(substream, &delay);
93529 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
93530 snd_leave_user(fs);
93531 if (err < 0)
93532 return err;
93533 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
93534 index f928181..33fb83d 100644
93535 --- a/sound/core/pcm_native.c
93536 +++ b/sound/core/pcm_native.c
93537 @@ -2819,11 +2819,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
93538 switch (substream->stream) {
93539 case SNDRV_PCM_STREAM_PLAYBACK:
93540 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
93541 - (void __user *)arg);
93542 + (void __force_user *)arg);
93543 break;
93544 case SNDRV_PCM_STREAM_CAPTURE:
93545 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
93546 - (void __user *)arg);
93547 + (void __force_user *)arg);
93548 break;
93549 default:
93550 result = -EINVAL;
93551 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
93552 index 040c60e..989a19a 100644
93553 --- a/sound/core/seq/seq_device.c
93554 +++ b/sound/core/seq/seq_device.c
93555 @@ -64,7 +64,7 @@ struct ops_list {
93556 int argsize; /* argument size */
93557
93558 /* operators */
93559 - struct snd_seq_dev_ops ops;
93560 + struct snd_seq_dev_ops *ops;
93561
93562 /* registered devices */
93563 struct list_head dev_list; /* list of devices */
93564 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
93565
93566 mutex_lock(&ops->reg_mutex);
93567 /* copy driver operators */
93568 - ops->ops = *entry;
93569 + ops->ops = entry;
93570 ops->driver |= DRIVER_LOADED;
93571 ops->argsize = argsize;
93572
93573 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
93574 dev->name, ops->id, ops->argsize, dev->argsize);
93575 return -EINVAL;
93576 }
93577 - if (ops->ops.init_device(dev) >= 0) {
93578 + if (ops->ops->init_device(dev) >= 0) {
93579 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
93580 ops->num_init_devices++;
93581 } else {
93582 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
93583 dev->name, ops->id, ops->argsize, dev->argsize);
93584 return -EINVAL;
93585 }
93586 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
93587 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
93588 dev->status = SNDRV_SEQ_DEVICE_FREE;
93589 dev->driver_data = NULL;
93590 ops->num_init_devices--;
93591 diff --git a/sound/core/sound.c b/sound/core/sound.c
93592 index f002bd9..c462985 100644
93593 --- a/sound/core/sound.c
93594 +++ b/sound/core/sound.c
93595 @@ -86,7 +86,7 @@ static void snd_request_other(int minor)
93596 case SNDRV_MINOR_TIMER: str = "snd-timer"; break;
93597 default: return;
93598 }
93599 - request_module(str);
93600 + request_module("%s", str);
93601 }
93602
93603 #endif /* modular kernel */
93604 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
93605 index 4e0dd22..7a1f32c 100644
93606 --- a/sound/drivers/mts64.c
93607 +++ b/sound/drivers/mts64.c
93608 @@ -29,6 +29,7 @@
93609 #include <sound/initval.h>
93610 #include <sound/rawmidi.h>
93611 #include <sound/control.h>
93612 +#include <asm/local.h>
93613
93614 #define CARD_NAME "Miditerminal 4140"
93615 #define DRIVER_NAME "MTS64"
93616 @@ -67,7 +68,7 @@ struct mts64 {
93617 struct pardevice *pardev;
93618 int pardev_claimed;
93619
93620 - int open_count;
93621 + local_t open_count;
93622 int current_midi_output_port;
93623 int current_midi_input_port;
93624 u8 mode[MTS64_NUM_INPUT_PORTS];
93625 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
93626 {
93627 struct mts64 *mts = substream->rmidi->private_data;
93628
93629 - if (mts->open_count == 0) {
93630 + if (local_read(&mts->open_count) == 0) {
93631 /* We don't need a spinlock here, because this is just called
93632 if the device has not been opened before.
93633 So there aren't any IRQs from the device */
93634 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
93635
93636 msleep(50);
93637 }
93638 - ++(mts->open_count);
93639 + local_inc(&mts->open_count);
93640
93641 return 0;
93642 }
93643 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
93644 struct mts64 *mts = substream->rmidi->private_data;
93645 unsigned long flags;
93646
93647 - --(mts->open_count);
93648 - if (mts->open_count == 0) {
93649 + if (local_dec_return(&mts->open_count) == 0) {
93650 /* We need the spinlock_irqsave here because we can still
93651 have IRQs at this point */
93652 spin_lock_irqsave(&mts->lock, flags);
93653 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
93654
93655 msleep(500);
93656
93657 - } else if (mts->open_count < 0)
93658 - mts->open_count = 0;
93659 + } else if (local_read(&mts->open_count) < 0)
93660 + local_set(&mts->open_count, 0);
93661
93662 return 0;
93663 }
93664 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
93665 index b953fb4..1999c01 100644
93666 --- a/sound/drivers/opl4/opl4_lib.c
93667 +++ b/sound/drivers/opl4/opl4_lib.c
93668 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
93669 MODULE_DESCRIPTION("OPL4 driver");
93670 MODULE_LICENSE("GPL");
93671
93672 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
93673 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
93674 {
93675 int timeout = 10;
93676 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
93677 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
93678 index 991018d..8984740 100644
93679 --- a/sound/drivers/portman2x4.c
93680 +++ b/sound/drivers/portman2x4.c
93681 @@ -48,6 +48,7 @@
93682 #include <sound/initval.h>
93683 #include <sound/rawmidi.h>
93684 #include <sound/control.h>
93685 +#include <asm/local.h>
93686
93687 #define CARD_NAME "Portman 2x4"
93688 #define DRIVER_NAME "portman"
93689 @@ -85,7 +86,7 @@ struct portman {
93690 struct pardevice *pardev;
93691 int pardev_claimed;
93692
93693 - int open_count;
93694 + local_t open_count;
93695 int mode[PORTMAN_NUM_INPUT_PORTS];
93696 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
93697 };
93698 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
93699 index ea995af..f1bfa37 100644
93700 --- a/sound/firewire/amdtp.c
93701 +++ b/sound/firewire/amdtp.c
93702 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
93703 ptr = s->pcm_buffer_pointer + data_blocks;
93704 if (ptr >= pcm->runtime->buffer_size)
93705 ptr -= pcm->runtime->buffer_size;
93706 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
93707 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
93708
93709 s->pcm_period_pointer += data_blocks;
93710 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
93711 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
93712 */
93713 void amdtp_out_stream_update(struct amdtp_out_stream *s)
93714 {
93715 - ACCESS_ONCE(s->source_node_id_field) =
93716 + ACCESS_ONCE_RW(s->source_node_id_field) =
93717 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
93718 }
93719 EXPORT_SYMBOL(amdtp_out_stream_update);
93720 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
93721 index b680c5e..061b7a0 100644
93722 --- a/sound/firewire/amdtp.h
93723 +++ b/sound/firewire/amdtp.h
93724 @@ -139,7 +139,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
93725 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
93726 struct snd_pcm_substream *pcm)
93727 {
93728 - ACCESS_ONCE(s->pcm) = pcm;
93729 + ACCESS_ONCE_RW(s->pcm) = pcm;
93730 }
93731
93732 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
93733 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
93734 index d428ffe..751ef78 100644
93735 --- a/sound/firewire/isight.c
93736 +++ b/sound/firewire/isight.c
93737 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
93738 ptr += count;
93739 if (ptr >= runtime->buffer_size)
93740 ptr -= runtime->buffer_size;
93741 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
93742 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
93743
93744 isight->period_counter += count;
93745 if (isight->period_counter >= runtime->period_size) {
93746 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
93747 if (err < 0)
93748 return err;
93749
93750 - ACCESS_ONCE(isight->pcm_active) = true;
93751 + ACCESS_ONCE_RW(isight->pcm_active) = true;
93752
93753 return 0;
93754 }
93755 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
93756 {
93757 struct isight *isight = substream->private_data;
93758
93759 - ACCESS_ONCE(isight->pcm_active) = false;
93760 + ACCESS_ONCE_RW(isight->pcm_active) = false;
93761
93762 mutex_lock(&isight->mutex);
93763 isight_stop_streaming(isight);
93764 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
93765
93766 switch (cmd) {
93767 case SNDRV_PCM_TRIGGER_START:
93768 - ACCESS_ONCE(isight->pcm_running) = true;
93769 + ACCESS_ONCE_RW(isight->pcm_running) = true;
93770 break;
93771 case SNDRV_PCM_TRIGGER_STOP:
93772 - ACCESS_ONCE(isight->pcm_running) = false;
93773 + ACCESS_ONCE_RW(isight->pcm_running) = false;
93774 break;
93775 default:
93776 return -EINVAL;
93777 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
93778 index 844a555..985ab83 100644
93779 --- a/sound/firewire/scs1x.c
93780 +++ b/sound/firewire/scs1x.c
93781 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
93782 {
93783 struct scs *scs = stream->rmidi->private_data;
93784
93785 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
93786 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
93787 if (up) {
93788 scs->output_idle = false;
93789 tasklet_schedule(&scs->tasklet);
93790 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
93791 {
93792 struct scs *scs = stream->rmidi->private_data;
93793
93794 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
93795 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
93796 }
93797
93798 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
93799 @@ -457,8 +457,8 @@ static int scs_remove(struct device *dev)
93800
93801 snd_card_disconnect(scs->card);
93802
93803 - ACCESS_ONCE(scs->output) = NULL;
93804 - ACCESS_ONCE(scs->input) = NULL;
93805 + ACCESS_ONCE_RW(scs->output) = NULL;
93806 + ACCESS_ONCE_RW(scs->input) = NULL;
93807
93808 wait_event(scs->idle_wait, scs->output_idle);
93809
93810 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
93811 index 048439a..3be9f6f 100644
93812 --- a/sound/oss/sb_audio.c
93813 +++ b/sound/oss/sb_audio.c
93814 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
93815 buf16 = (signed short *)(localbuf + localoffs);
93816 while (c)
93817 {
93818 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
93819 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
93820 if (copy_from_user(lbuf8,
93821 userbuf+useroffs + p,
93822 locallen))
93823 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
93824 index 7d8803a..559f8d0 100644
93825 --- a/sound/oss/swarm_cs4297a.c
93826 +++ b/sound/oss/swarm_cs4297a.c
93827 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
93828 {
93829 struct cs4297a_state *s;
93830 u32 pwr, id;
93831 - mm_segment_t fs;
93832 int rval;
93833 #ifndef CONFIG_BCM_CS4297A_CSWARM
93834 u64 cfg;
93835 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
93836 if (!rval) {
93837 char *sb1250_duart_present;
93838
93839 +#if 0
93840 + mm_segment_t fs;
93841 fs = get_fs();
93842 set_fs(KERNEL_DS);
93843 -#if 0
93844 val = SOUND_MASK_LINE;
93845 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
93846 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
93847 val = initvol[i].vol;
93848 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
93849 }
93850 + set_fs(fs);
93851 // cs4297a_write_ac97(s, 0x18, 0x0808);
93852 #else
93853 // cs4297a_write_ac97(s, 0x5e, 0x180);
93854 cs4297a_write_ac97(s, 0x02, 0x0808);
93855 cs4297a_write_ac97(s, 0x18, 0x0808);
93856 #endif
93857 - set_fs(fs);
93858
93859 list_add(&s->list, &cs4297a_devs);
93860
93861 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
93862 index 4631a23..001ae57 100644
93863 --- a/sound/pci/ymfpci/ymfpci.h
93864 +++ b/sound/pci/ymfpci/ymfpci.h
93865 @@ -358,7 +358,7 @@ struct snd_ymfpci {
93866 spinlock_t reg_lock;
93867 spinlock_t voice_lock;
93868 wait_queue_head_t interrupt_sleep;
93869 - atomic_t interrupt_sleep_count;
93870 + atomic_unchecked_t interrupt_sleep_count;
93871 struct snd_info_entry *proc_entry;
93872 const struct firmware *dsp_microcode;
93873 const struct firmware *controller_microcode;
93874 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
93875 index 22056c5..25d3244 100644
93876 --- a/sound/pci/ymfpci/ymfpci_main.c
93877 +++ b/sound/pci/ymfpci/ymfpci_main.c
93878 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
93879 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
93880 break;
93881 }
93882 - if (atomic_read(&chip->interrupt_sleep_count)) {
93883 - atomic_set(&chip->interrupt_sleep_count, 0);
93884 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
93885 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
93886 wake_up(&chip->interrupt_sleep);
93887 }
93888 __end:
93889 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
93890 continue;
93891 init_waitqueue_entry(&wait, current);
93892 add_wait_queue(&chip->interrupt_sleep, &wait);
93893 - atomic_inc(&chip->interrupt_sleep_count);
93894 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
93895 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
93896 remove_wait_queue(&chip->interrupt_sleep, &wait);
93897 }
93898 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
93899 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
93900 spin_unlock(&chip->reg_lock);
93901
93902 - if (atomic_read(&chip->interrupt_sleep_count)) {
93903 - atomic_set(&chip->interrupt_sleep_count, 0);
93904 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
93905 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
93906 wake_up(&chip->interrupt_sleep);
93907 }
93908 }
93909 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
93910 spin_lock_init(&chip->reg_lock);
93911 spin_lock_init(&chip->voice_lock);
93912 init_waitqueue_head(&chip->interrupt_sleep);
93913 - atomic_set(&chip->interrupt_sleep_count, 0);
93914 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
93915 chip->card = card;
93916 chip->pci = pci;
93917 chip->irq = -1;
93918 diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
93919 index 0f0bed6..c161e28 100644
93920 --- a/sound/soc/fsl/fsl_ssi.c
93921 +++ b/sound/soc/fsl/fsl_ssi.c
93922 @@ -657,7 +657,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
93923 {
93924 struct fsl_ssi_private *ssi_private;
93925 int ret = 0;
93926 - struct device_attribute *dev_attr = NULL;
93927 + device_attribute_no_const *dev_attr = NULL;
93928 struct device_node *np = pdev->dev.of_node;
93929 const char *p, *sprop;
93930 const uint32_t *iprop;
93931 diff --git a/sound/sound_core.c b/sound/sound_core.c
93932 index 359753f..45759f4 100644
93933 --- a/sound/sound_core.c
93934 +++ b/sound/sound_core.c
93935 @@ -292,7 +292,7 @@ retry:
93936 }
93937
93938 device_create(sound_class, dev, MKDEV(SOUND_MAJOR, s->unit_minor),
93939 - NULL, s->name+6);
93940 + NULL, "%s", s->name+6);
93941 return s->unit_minor;
93942
93943 fail:
93944 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
93945 new file mode 100644
93946 index 0000000..50f2f2f
93947 --- /dev/null
93948 +++ b/tools/gcc/.gitignore
93949 @@ -0,0 +1 @@
93950 +size_overflow_hash.h
93951 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
93952 new file mode 100644
93953 index 0000000..144dbee
93954 --- /dev/null
93955 +++ b/tools/gcc/Makefile
93956 @@ -0,0 +1,45 @@
93957 +#CC := gcc
93958 +#PLUGIN_SOURCE_FILES := pax_plugin.c
93959 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
93960 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
93961 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
93962 +
93963 +ifeq ($(PLUGINCC),$(HOSTCC))
93964 +HOSTLIBS := hostlibs
93965 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
93966 +else
93967 +HOSTLIBS := hostcxxlibs
93968 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
93969 +endif
93970 +
93971 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
93972 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
93973 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
93974 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
93975 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
93976 +$(HOSTLIBS)-y += colorize_plugin.so
93977 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
93978 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
93979 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
93980 +
93981 +always := $($(HOSTLIBS)-y)
93982 +
93983 +constify_plugin-objs := constify_plugin.o
93984 +stackleak_plugin-objs := stackleak_plugin.o
93985 +kallocstat_plugin-objs := kallocstat_plugin.o
93986 +kernexec_plugin-objs := kernexec_plugin.o
93987 +checker_plugin-objs := checker_plugin.o
93988 +colorize_plugin-objs := colorize_plugin.o
93989 +size_overflow_plugin-objs := size_overflow_plugin.o
93990 +latent_entropy_plugin-objs := latent_entropy_plugin.o
93991 +structleak_plugin-objs := structleak_plugin.o
93992 +
93993 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
93994 +
93995 +quiet_cmd_build_size_overflow_hash = GENHASH $@
93996 + cmd_build_size_overflow_hash = \
93997 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
93998 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
93999 + $(call if_changed,build_size_overflow_hash)
94000 +
94001 +targets += size_overflow_hash.h
94002 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
94003 new file mode 100644
94004 index 0000000..22f03c0
94005 --- /dev/null
94006 +++ b/tools/gcc/checker_plugin.c
94007 @@ -0,0 +1,172 @@
94008 +/*
94009 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
94010 + * Licensed under the GPL v2
94011 + *
94012 + * Note: the choice of the license means that the compilation process is
94013 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94014 + * but for the kernel it doesn't matter since it doesn't link against
94015 + * any of the gcc libraries
94016 + *
94017 + * gcc plugin to implement various sparse (source code checker) features
94018 + *
94019 + * TODO:
94020 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
94021 + *
94022 + * BUGS:
94023 + * - none known
94024 + */
94025 +#include "gcc-plugin.h"
94026 +#include "config.h"
94027 +#include "system.h"
94028 +#include "coretypes.h"
94029 +#include "tree.h"
94030 +#include "tree-pass.h"
94031 +#include "flags.h"
94032 +#include "intl.h"
94033 +#include "toplev.h"
94034 +#include "plugin.h"
94035 +//#include "expr.h" where are you...
94036 +#include "diagnostic.h"
94037 +#include "plugin-version.h"
94038 +#include "tm.h"
94039 +#include "function.h"
94040 +#include "basic-block.h"
94041 +#include "gimple.h"
94042 +#include "rtl.h"
94043 +#include "emit-rtl.h"
94044 +#include "tree-flow.h"
94045 +#include "target.h"
94046 +
94047 +extern void c_register_addr_space (const char *str, addr_space_t as);
94048 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
94049 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
94050 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
94051 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
94052 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
94053 +
94054 +extern void print_gimple_stmt(FILE *, gimple, int, int);
94055 +extern rtx emit_move_insn(rtx x, rtx y);
94056 +
94057 +int plugin_is_GPL_compatible;
94058 +
94059 +static struct plugin_info checker_plugin_info = {
94060 + .version = "201111150100",
94061 + .help = NULL,
94062 +};
94063 +
94064 +#define ADDR_SPACE_KERNEL 0
94065 +#define ADDR_SPACE_FORCE_KERNEL 1
94066 +#define ADDR_SPACE_USER 2
94067 +#define ADDR_SPACE_FORCE_USER 3
94068 +#define ADDR_SPACE_IOMEM 0
94069 +#define ADDR_SPACE_FORCE_IOMEM 0
94070 +#define ADDR_SPACE_PERCPU 0
94071 +#define ADDR_SPACE_FORCE_PERCPU 0
94072 +#define ADDR_SPACE_RCU 0
94073 +#define ADDR_SPACE_FORCE_RCU 0
94074 +
94075 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
94076 +{
94077 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
94078 +}
94079 +
94080 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
94081 +{
94082 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
94083 +}
94084 +
94085 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
94086 +{
94087 + return default_addr_space_valid_pointer_mode(mode, as);
94088 +}
94089 +
94090 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
94091 +{
94092 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
94093 +}
94094 +
94095 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
94096 +{
94097 + return default_addr_space_legitimize_address(x, oldx, mode, as);
94098 +}
94099 +
94100 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
94101 +{
94102 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
94103 + return true;
94104 +
94105 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
94106 + return true;
94107 +
94108 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
94109 + return true;
94110 +
94111 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
94112 + return true;
94113 +
94114 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
94115 + return true;
94116 +
94117 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
94118 + return true;
94119 +
94120 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
94121 + return true;
94122 +
94123 + return subset == superset;
94124 +}
94125 +
94126 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
94127 +{
94128 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
94129 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
94130 +
94131 + return op;
94132 +}
94133 +
94134 +static void register_checker_address_spaces(void *event_data, void *data)
94135 +{
94136 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
94137 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
94138 + c_register_addr_space("__user", ADDR_SPACE_USER);
94139 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
94140 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
94141 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
94142 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
94143 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
94144 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
94145 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
94146 +
94147 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
94148 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
94149 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
94150 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
94151 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
94152 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
94153 + targetm.addr_space.convert = checker_addr_space_convert;
94154 +}
94155 +
94156 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94157 +{
94158 + const char * const plugin_name = plugin_info->base_name;
94159 + const int argc = plugin_info->argc;
94160 + const struct plugin_argument * const argv = plugin_info->argv;
94161 + int i;
94162 +
94163 + if (!plugin_default_version_check(version, &gcc_version)) {
94164 + error(G_("incompatible gcc/plugin versions"));
94165 + return 1;
94166 + }
94167 +
94168 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
94169 +
94170 + for (i = 0; i < argc; ++i)
94171 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
94172 +
94173 + if (TARGET_64BIT == 0)
94174 + return 0;
94175 +
94176 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
94177 +
94178 + return 0;
94179 +}
94180 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
94181 new file mode 100644
94182 index 0000000..414fe5e
94183 --- /dev/null
94184 +++ b/tools/gcc/colorize_plugin.c
94185 @@ -0,0 +1,151 @@
94186 +/*
94187 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
94188 + * Licensed under the GPL v2
94189 + *
94190 + * Note: the choice of the license means that the compilation process is
94191 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
94192 + * but for the kernel it doesn't matter since it doesn't link against
94193 + * any of the gcc libraries
94194 + *
94195 + * gcc plugin to colorize diagnostic output
94196 + *
94197 + */
94198 +
94199 +#include "gcc-plugin.h"
94200 +#include "config.h"
94201 +#include "system.h"
94202 +#include "coretypes.h"
94203 +#include "tree.h"
94204 +#include "tree-pass.h"
94205 +#include "flags.h"
94206 +#include "intl.h"
94207 +#include "toplev.h"
94208 +#include "plugin.h"
94209 +#include "diagnostic.h"
94210 +#include "plugin-version.h"
94211 +#include "tm.h"
94212 +
94213 +int plugin_is_GPL_compatible;
94214 +
94215 +static struct plugin_info colorize_plugin_info = {
94216 + .version = "201302112000",
94217 + .help = NULL,
94218 +};
94219 +
94220 +#define GREEN "\033[32m\033[2m"
94221 +#define LIGHTGREEN "\033[32m\033[1m"
94222 +#define YELLOW "\033[33m\033[2m"
94223 +#define LIGHTYELLOW "\033[33m\033[1m"
94224 +#define RED "\033[31m\033[2m"
94225 +#define LIGHTRED "\033[31m\033[1m"
94226 +#define BLUE "\033[34m\033[2m"
94227 +#define LIGHTBLUE "\033[34m\033[1m"
94228 +#define BRIGHT "\033[m\033[1m"
94229 +#define NORMAL "\033[m"
94230 +
94231 +static diagnostic_starter_fn old_starter;
94232 +static diagnostic_finalizer_fn old_finalizer;
94233 +
94234 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
94235 +{
94236 + const char *color;
94237 + char *newprefix;
94238 +
94239 + switch (diagnostic->kind) {
94240 + case DK_NOTE:
94241 + color = LIGHTBLUE;
94242 + break;
94243 +
94244 + case DK_PEDWARN:
94245 + case DK_WARNING:
94246 + color = LIGHTYELLOW;
94247 + break;
94248 +
94249 + case DK_ERROR:
94250 + case DK_FATAL:
94251 + case DK_ICE:
94252 + case DK_PERMERROR:
94253 + case DK_SORRY:
94254 + color = LIGHTRED;
94255 + break;
94256 +
94257 + default:
94258 + color = NORMAL;
94259 + }
94260 +
94261 + old_starter(context, diagnostic);
94262 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
94263 + return;
94264 + pp_destroy_prefix(context->printer);
94265 + pp_set_prefix(context->printer, newprefix);
94266 +}
94267 +
94268 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
94269 +{
94270 + old_finalizer(context, diagnostic);
94271 +}
94272 +
94273 +static void colorize_arm(void)
94274 +{
94275 + old_starter = diagnostic_starter(global_dc);
94276 + old_finalizer = diagnostic_finalizer(global_dc);
94277 +
94278 + diagnostic_starter(global_dc) = start_colorize;
94279 + diagnostic_finalizer(global_dc) = finalize_colorize;
94280 +}
94281 +
94282 +static unsigned int execute_colorize_rearm(void)
94283 +{
94284 + if (diagnostic_starter(global_dc) == start_colorize)
94285 + return 0;
94286 +
94287 + colorize_arm();
94288 + return 0;
94289 +}
94290 +
94291 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
94292 + .pass = {
94293 + .type = SIMPLE_IPA_PASS,
94294 + .name = "colorize_rearm",
94295 +#if BUILDING_GCC_VERSION >= 4008
94296 + .optinfo_flags = OPTGROUP_NONE,
94297 +#endif
94298 + .gate = NULL,
94299 + .execute = execute_colorize_rearm,
94300 + .sub = NULL,
94301 + .next = NULL,
94302 + .static_pass_number = 0,
94303 + .tv_id = TV_NONE,
94304 + .properties_required = 0,
94305 + .properties_provided = 0,
94306 + .properties_destroyed = 0,
94307 + .todo_flags_start = 0,
94308 + .todo_flags_finish = 0
94309 + }
94310 +};
94311 +
94312 +static void colorize_start_unit(void *gcc_data, void *user_data)
94313 +{
94314 + colorize_arm();
94315 +}
94316 +
94317 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94318 +{
94319 + const char * const plugin_name = plugin_info->base_name;
94320 + struct register_pass_info colorize_rearm_pass_info = {
94321 + .pass = &pass_ipa_colorize_rearm.pass,
94322 + .reference_pass_name = "*free_lang_data",
94323 + .ref_pass_instance_number = 1,
94324 + .pos_op = PASS_POS_INSERT_AFTER
94325 + };
94326 +
94327 + if (!plugin_default_version_check(version, &gcc_version)) {
94328 + error(G_("incompatible gcc/plugin versions"));
94329 + return 1;
94330 + }
94331 +
94332 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
94333 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
94334 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
94335 + return 0;
94336 +}
94337 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
94338 new file mode 100644
94339 index 0000000..c17312d
94340 --- /dev/null
94341 +++ b/tools/gcc/constify_plugin.c
94342 @@ -0,0 +1,560 @@
94343 +/*
94344 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
94345 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
94346 + * Licensed under the GPL v2, or (at your option) v3
94347 + *
94348 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
94349 + *
94350 + * Homepage:
94351 + * http://www.grsecurity.net/~ephox/const_plugin/
94352 + *
94353 + * Usage:
94354 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
94355 + * $ gcc -fplugin=constify_plugin.so test.c -O2
94356 + */
94357 +
94358 +#include "gcc-plugin.h"
94359 +#include "config.h"
94360 +#include "system.h"
94361 +#include "coretypes.h"
94362 +#include "tree.h"
94363 +#include "tree-pass.h"
94364 +#include "flags.h"
94365 +#include "intl.h"
94366 +#include "toplev.h"
94367 +#include "plugin.h"
94368 +#include "diagnostic.h"
94369 +#include "plugin-version.h"
94370 +#include "tm.h"
94371 +#include "function.h"
94372 +#include "basic-block.h"
94373 +#include "gimple.h"
94374 +#include "rtl.h"
94375 +#include "emit-rtl.h"
94376 +#include "tree-flow.h"
94377 +#include "target.h"
94378 +#include "langhooks.h"
94379 +
94380 +// should come from c-tree.h if only it were installed for gcc 4.5...
94381 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
94382 +
94383 +// unused type flag in all versions 4.5-4.8
94384 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
94385 +
94386 +int plugin_is_GPL_compatible;
94387 +
94388 +static struct plugin_info const_plugin_info = {
94389 + .version = "201305231310",
94390 + .help = "no-constify\tturn off constification\n",
94391 +};
94392 +
94393 +typedef struct {
94394 + bool has_fptr_field;
94395 + bool has_writable_field;
94396 + bool has_do_const_field;
94397 + bool has_no_const_field;
94398 +} constify_info;
94399 +
94400 +static const_tree get_field_type(const_tree field)
94401 +{
94402 + return strip_array_types(TREE_TYPE(field));
94403 +}
94404 +
94405 +static bool is_fptr(const_tree field)
94406 +{
94407 + const_tree ptr = get_field_type(field);
94408 +
94409 + if (TREE_CODE(ptr) != POINTER_TYPE)
94410 + return false;
94411 +
94412 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
94413 +}
94414 +
94415 +/*
94416 + * determine whether the given structure type meets the requirements for automatic constification,
94417 + * including the constification attributes on nested structure types
94418 + */
94419 +static void constifiable(const_tree node, constify_info *cinfo)
94420 +{
94421 + const_tree field;
94422 +
94423 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
94424 +
94425 + // e.g., pointer to structure fields while still constructing the structure type
94426 + if (TYPE_FIELDS(node) == NULL_TREE)
94427 + return;
94428 +
94429 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
94430 + const_tree type = get_field_type(field);
94431 + enum tree_code code = TREE_CODE(type);
94432 +
94433 + if (node == type)
94434 + continue;
94435 +
94436 + if (is_fptr(field))
94437 + cinfo->has_fptr_field = true;
94438 + else if (!TREE_READONLY(field))
94439 + cinfo->has_writable_field = true;
94440 +
94441 + if (code == RECORD_TYPE || code == UNION_TYPE) {
94442 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
94443 + cinfo->has_do_const_field = true;
94444 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
94445 + cinfo->has_no_const_field = true;
94446 + else
94447 + constifiable(type, cinfo);
94448 + }
94449 + }
94450 +}
94451 +
94452 +static bool constified(const_tree node)
94453 +{
94454 + constify_info cinfo = {
94455 + .has_fptr_field = false,
94456 + .has_writable_field = false,
94457 + .has_do_const_field = false,
94458 + .has_no_const_field = false
94459 + };
94460 +
94461 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
94462 +
94463 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
94464 + gcc_assert(!TYPE_READONLY(node));
94465 + return false;
94466 + }
94467 +
94468 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
94469 + gcc_assert(TYPE_READONLY(node));
94470 + return true;
94471 + }
94472 +
94473 + constifiable(node, &cinfo);
94474 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
94475 + return false;
94476 +
94477 + return TYPE_READONLY(node);
94478 +}
94479 +
94480 +static void deconstify_tree(tree node);
94481 +
94482 +static void deconstify_type(tree type)
94483 +{
94484 + tree field;
94485 +
94486 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
94487 +
94488 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
94489 + const_tree fieldtype = get_field_type(field);
94490 +
94491 + // special case handling of simple ptr-to-same-array-type members
94492 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
94493 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
94494 +
94495 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
94496 + continue;
94497 + if (TREE_TYPE(TREE_TYPE(field)) == type)
94498 + continue;
94499 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
94500 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
94501 + TREE_TYPE(TREE_TYPE(field)) = type;
94502 + }
94503 + continue;
94504 + }
94505 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
94506 + continue;
94507 + if (!constified(fieldtype))
94508 + continue;
94509 +
94510 + deconstify_tree(field);
94511 + TREE_READONLY(field) = 0;
94512 + }
94513 + TYPE_READONLY(type) = 0;
94514 + C_TYPE_FIELDS_READONLY(type) = 0;
94515 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
94516 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
94517 +}
94518 +
94519 +static void deconstify_tree(tree node)
94520 +{
94521 + tree old_type, new_type, field;
94522 +
94523 + old_type = TREE_TYPE(node);
94524 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
94525 + node = TREE_TYPE(node) = copy_node(old_type);
94526 + old_type = TREE_TYPE(old_type);
94527 + }
94528 +
94529 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
94530 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
94531 +
94532 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
94533 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
94534 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
94535 + DECL_FIELD_CONTEXT(field) = new_type;
94536 +
94537 + deconstify_type(new_type);
94538 +
94539 + TREE_TYPE(node) = new_type;
94540 +}
94541 +
94542 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
94543 +{
94544 + tree type;
94545 + constify_info cinfo = {
94546 + .has_fptr_field = false,
94547 + .has_writable_field = false,
94548 + .has_do_const_field = false,
94549 + .has_no_const_field = false
94550 + };
94551 +
94552 + *no_add_attrs = true;
94553 + if (TREE_CODE(*node) == FUNCTION_DECL) {
94554 + error("%qE attribute does not apply to functions", name);
94555 + return NULL_TREE;
94556 + }
94557 +
94558 + if (TREE_CODE(*node) == PARM_DECL) {
94559 + error("%qE attribute does not apply to function parameters", name);
94560 + return NULL_TREE;
94561 + }
94562 +
94563 + if (TREE_CODE(*node) == VAR_DECL) {
94564 + error("%qE attribute does not apply to variables", name);
94565 + return NULL_TREE;
94566 + }
94567 +
94568 + if (TYPE_P(*node)) {
94569 + *no_add_attrs = false;
94570 + type = *node;
94571 + } else {
94572 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
94573 + type = TREE_TYPE(*node);
94574 + }
94575 +
94576 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
94577 + error("%qE attribute applies to struct and union types only", name);
94578 + return NULL_TREE;
94579 + }
94580 +
94581 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
94582 + error("%qE attribute is already applied to the type", name);
94583 + return NULL_TREE;
94584 + }
94585 +
94586 + if (TYPE_P(*node)) {
94587 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
94588 + error("%qE attribute is incompatible with 'do_const'", name);
94589 + return NULL_TREE;
94590 + }
94591 +
94592 + constifiable(type, &cinfo);
94593 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
94594 + deconstify_tree(*node);
94595 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
94596 + return NULL_TREE;
94597 + }
94598 +
94599 + error("%qE attribute used on type that is not constified", name);
94600 + return NULL_TREE;
94601 +}
94602 +
94603 +static void constify_type(tree type)
94604 +{
94605 + TYPE_READONLY(type) = 1;
94606 + C_TYPE_FIELDS_READONLY(type) = 1;
94607 + TYPE_CONSTIFY_VISITED(type) = 1;
94608 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
94609 +}
94610 +
94611 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
94612 +{
94613 + *no_add_attrs = true;
94614 + if (!TYPE_P(*node)) {
94615 + error("%qE attribute applies to types only", name);
94616 + return NULL_TREE;
94617 + }
94618 +
94619 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
94620 + error("%qE attribute applies to struct and union types only", name);
94621 + return NULL_TREE;
94622 + }
94623 +
94624 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
94625 + error("%qE attribute is already applied to the type", name);
94626 + return NULL_TREE;
94627 + }
94628 +
94629 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
94630 + error("%qE attribute is incompatible with 'no_const'", name);
94631 + return NULL_TREE;
94632 + }
94633 +
94634 + *no_add_attrs = false;
94635 + return NULL_TREE;
94636 +}
94637 +
94638 +static struct attribute_spec no_const_attr = {
94639 + .name = "no_const",
94640 + .min_length = 0,
94641 + .max_length = 0,
94642 + .decl_required = false,
94643 + .type_required = false,
94644 + .function_type_required = false,
94645 + .handler = handle_no_const_attribute,
94646 +#if BUILDING_GCC_VERSION >= 4007
94647 + .affects_type_identity = true
94648 +#endif
94649 +};
94650 +
94651 +static struct attribute_spec do_const_attr = {
94652 + .name = "do_const",
94653 + .min_length = 0,
94654 + .max_length = 0,
94655 + .decl_required = false,
94656 + .type_required = false,
94657 + .function_type_required = false,
94658 + .handler = handle_do_const_attribute,
94659 +#if BUILDING_GCC_VERSION >= 4007
94660 + .affects_type_identity = true
94661 +#endif
94662 +};
94663 +
94664 +static void register_attributes(void *event_data, void *data)
94665 +{
94666 + register_attribute(&no_const_attr);
94667 + register_attribute(&do_const_attr);
94668 +}
94669 +
94670 +static void finish_type(void *event_data, void *data)
94671 +{
94672 + tree type = (tree)event_data;
94673 + constify_info cinfo = {
94674 + .has_fptr_field = false,
94675 + .has_writable_field = false,
94676 + .has_do_const_field = false,
94677 + .has_no_const_field = false
94678 + };
94679 +
94680 + if (type == NULL_TREE || type == error_mark_node)
94681 + return;
94682 +
94683 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
94684 + return;
94685 +
94686 + constifiable(type, &cinfo);
94687 +
94688 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
94689 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
94690 + return;
94691 + if (cinfo.has_writable_field)
94692 + return;
94693 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
94694 + return;
94695 + }
94696 +
94697 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
94698 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
94699 + deconstify_type(type);
94700 + TYPE_CONSTIFY_VISITED(type) = 1;
94701 + } else
94702 + error("'no_const' attribute used on type that is not constified");
94703 + return;
94704 + }
94705 +
94706 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
94707 + constify_type(type);
94708 + return;
94709 + }
94710 +
94711 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
94712 + constify_type(type);
94713 + return;
94714 + }
94715 +
94716 + deconstify_type(type);
94717 + TYPE_CONSTIFY_VISITED(type) = 1;
94718 +}
94719 +
94720 +static void check_global_variables(void)
94721 +{
94722 + struct varpool_node *node;
94723 +
94724 +#if BUILDING_GCC_VERSION <= 4007
94725 + for (node = varpool_nodes; node; node = node->next) {
94726 + tree var = node->decl;
94727 +#else
94728 + FOR_EACH_VARIABLE(node) {
94729 + tree var = node->symbol.decl;
94730 +#endif
94731 + tree type = TREE_TYPE(var);
94732 +
94733 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
94734 + continue;
94735 +
94736 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
94737 + continue;
94738 +
94739 + if (!TYPE_CONSTIFY_VISITED(type))
94740 + continue;
94741 +
94742 + if (DECL_EXTERNAL(var))
94743 + continue;
94744 +
94745 + if (DECL_INITIAL(var))
94746 + continue;
94747 +
94748 + // this works around a gcc bug/feature where uninitialized globals
94749 + // are moved into the .bss section regardless of any constification
94750 + DECL_INITIAL(var) = build_constructor(type, NULL);
94751 +// inform(DECL_SOURCE_LOCATION(var), "constified variable %qE moved into .rodata", var);
94752 + }
94753 +}
94754 +
94755 +static unsigned int check_local_variables(void)
94756 +{
94757 + unsigned int ret = 0;
94758 + tree var;
94759 +
94760 +#if BUILDING_GCC_VERSION == 4005
94761 + tree vars;
94762 +#else
94763 + unsigned int i;
94764 +#endif
94765 +
94766 +#if BUILDING_GCC_VERSION == 4005
94767 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
94768 + var = TREE_VALUE(vars);
94769 +#else
94770 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
94771 +#endif
94772 + tree type = TREE_TYPE(var);
94773 +
94774 + gcc_assert(DECL_P(var));
94775 + if (is_global_var(var))
94776 + continue;
94777 +
94778 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
94779 + continue;
94780 +
94781 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
94782 + continue;
94783 +
94784 + if (!TYPE_CONSTIFY_VISITED(type))
94785 + continue;
94786 +
94787 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
94788 + ret = 1;
94789 + }
94790 + return ret;
94791 +}
94792 +
94793 +static unsigned int check_variables(void)
94794 +{
94795 + check_global_variables();
94796 + return check_local_variables();
94797 +}
94798 +
94799 + unsigned int ret = 0;
94800 +static struct gimple_opt_pass pass_local_variable = {
94801 + {
94802 + .type = GIMPLE_PASS,
94803 + .name = "check_variables",
94804 +#if BUILDING_GCC_VERSION >= 4008
94805 + .optinfo_flags = OPTGROUP_NONE,
94806 +#endif
94807 + .gate = NULL,
94808 + .execute = check_variables,
94809 + .sub = NULL,
94810 + .next = NULL,
94811 + .static_pass_number = 0,
94812 + .tv_id = TV_NONE,
94813 + .properties_required = 0,
94814 + .properties_provided = 0,
94815 + .properties_destroyed = 0,
94816 + .todo_flags_start = 0,
94817 + .todo_flags_finish = 0
94818 + }
94819 +};
94820 +
94821 +static struct {
94822 + const char *name;
94823 + const char *asm_op;
94824 +} sections[] = {
94825 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
94826 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
94827 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
94828 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
94829 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
94830 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
94831 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
94832 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
94833 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
94834 +};
94835 +
94836 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
94837 +
94838 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
94839 +{
94840 + size_t i;
94841 +
94842 + for (i = 0; i < ARRAY_SIZE(sections); i++)
94843 + if (!strcmp(sections[i].name, name))
94844 + return 0;
94845 + return old_section_type_flags(decl, name, reloc);
94846 +}
94847 +
94848 +static void constify_start_unit(void *gcc_data, void *user_data)
94849 +{
94850 +// size_t i;
94851 +
94852 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
94853 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
94854 +// sections[i].section = get_section(sections[i].name, 0, NULL);
94855 +
94856 + old_section_type_flags = targetm.section_type_flags;
94857 + targetm.section_type_flags = constify_section_type_flags;
94858 +}
94859 +
94860 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
94861 +{
94862 + const char * const plugin_name = plugin_info->base_name;
94863 + const int argc = plugin_info->argc;
94864 + const struct plugin_argument * const argv = plugin_info->argv;
94865 + int i;
94866 + bool constify = true;
94867 +
94868 + struct register_pass_info local_variable_pass_info = {
94869 + .pass = &pass_local_variable.pass,
94870 + .reference_pass_name = "ssa",
94871 + .ref_pass_instance_number = 1,
94872 + .pos_op = PASS_POS_INSERT_BEFORE
94873 + };
94874 +
94875 + if (!plugin_default_version_check(version, &gcc_version)) {
94876 + error(G_("incompatible gcc/plugin versions"));
94877 + return 1;
94878 + }
94879 +
94880 + for (i = 0; i < argc; ++i) {
94881 + if (!(strcmp(argv[i].key, "no-constify"))) {
94882 + constify = false;
94883 + continue;
94884 + }
94885 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
94886 + }
94887 +
94888 + if (strcmp(lang_hooks.name, "GNU C")) {
94889 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
94890 + constify = false;
94891 + }
94892 +
94893 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
94894 + if (constify) {
94895 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
94896 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
94897 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
94898 + }
94899 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
94900 +
94901 + return 0;
94902 +}
94903 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
94904 new file mode 100644
94905 index 0000000..e518932
94906 --- /dev/null
94907 +++ b/tools/gcc/generate_size_overflow_hash.sh
94908 @@ -0,0 +1,94 @@
94909 +#!/bin/bash
94910 +
94911 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
94912 +
94913 +header1="size_overflow_hash.h"
94914 +database="size_overflow_hash.data"
94915 +n=65536
94916 +
94917 +usage() {
94918 +cat <<EOF
94919 +usage: $0 options
94920 +OPTIONS:
94921 + -h|--help help
94922 + -o header file
94923 + -d database file
94924 + -n hash array size
94925 +EOF
94926 + return 0
94927 +}
94928 +
94929 +while true
94930 +do
94931 + case "$1" in
94932 + -h|--help) usage && exit 0;;
94933 + -n) n=$2; shift 2;;
94934 + -o) header1="$2"; shift 2;;
94935 + -d) database="$2"; shift 2;;
94936 + --) shift 1; break ;;
94937 + *) break ;;
94938 + esac
94939 +done
94940 +
94941 +create_defines() {
94942 + for i in `seq 0 31`
94943 + do
94944 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
94945 + done
94946 + echo >> "$header1"
94947 +}
94948 +
94949 +create_structs() {
94950 + rm -f "$header1"
94951 +
94952 + create_defines
94953 +
94954 + cat "$database" | while read data
94955 + do
94956 + data_array=($data)
94957 + struct_hash_name="${data_array[0]}"
94958 + funcn="${data_array[1]}"
94959 + params="${data_array[2]}"
94960 + next="${data_array[4]}"
94961 +
94962 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
94963 +
94964 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
94965 + echo -en "\t.param\t= " >> "$header1"
94966 + line=
94967 + for param_num in ${params//-/ };
94968 + do
94969 + line="${line}PARAM"$param_num"|"
94970 + done
94971 +
94972 + echo -e "${line%?},\n};\n" >> "$header1"
94973 + done
94974 +}
94975 +
94976 +create_headers() {
94977 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
94978 +}
94979 +
94980 +create_array_elements() {
94981 + index=0
94982 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
94983 + do
94984 + data_array=($data)
94985 + i="${data_array[3]}"
94986 + hash="${data_array[0]}"
94987 + while [[ $index -lt $i ]]
94988 + do
94989 + echo -e "\t["$index"]\t= NULL," >> "$header1"
94990 + index=$(($index + 1))
94991 + done
94992 + index=$(($index + 1))
94993 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
94994 + done
94995 + echo '};' >> $header1
94996 +}
94997 +
94998 +create_structs
94999 +create_headers
95000 +create_array_elements
95001 +
95002 +exit 0
95003 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
95004 new file mode 100644
95005 index 0000000..568b360
95006 --- /dev/null
95007 +++ b/tools/gcc/kallocstat_plugin.c
95008 @@ -0,0 +1,170 @@
95009 +/*
95010 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
95011 + * Licensed under the GPL v2
95012 + *
95013 + * Note: the choice of the license means that the compilation process is
95014 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
95015 + * but for the kernel it doesn't matter since it doesn't link against
95016 + * any of the gcc libraries
95017 + *
95018 + * gcc plugin to find the distribution of k*alloc sizes
95019 + *
95020 + * TODO:
95021 + *
95022 + * BUGS:
95023 + * - none known
95024 + */
95025 +#include "gcc-plugin.h"
95026 +#include "config.h"
95027 +#include "system.h"
95028 +#include "coretypes.h"
95029 +#include "tree.h"
95030 +#include "tree-pass.h"
95031 +#include "flags.h"
95032 +#include "intl.h"
95033 +#include "toplev.h"
95034 +#include "plugin.h"
95035 +//#include "expr.h" where are you...
95036 +#include "diagnostic.h"
95037 +#include "plugin-version.h"
95038 +#include "tm.h"
95039 +#include "function.h"
95040 +#include "basic-block.h"
95041 +#include "gimple.h"
95042 +#include "rtl.h"
95043 +#include "emit-rtl.h"
95044 +
95045 +extern void print_gimple_stmt(FILE *, gimple, int, int);
95046 +
95047 +int plugin_is_GPL_compatible;
95048 +
95049 +static const char * const kalloc_functions[] = {
95050 + "__kmalloc",
95051 + "kmalloc",
95052 + "kmalloc_large",
95053 + "kmalloc_node",
95054 + "kmalloc_order",
95055 + "kmalloc_order_trace",
95056 + "kmalloc_slab",
95057 + "kzalloc",
95058 + "kzalloc_node",
95059 +};
95060 +
95061 +static struct plugin_info kallocstat_plugin_info = {
95062 + .version = "201302112000",
95063 +};
95064 +
95065 +static unsigned int execute_kallocstat(void);
95066 +
95067 +static struct gimple_opt_pass kallocstat_pass = {
95068 + .pass = {
95069 + .type = GIMPLE_PASS,
95070 + .name = "kallocstat",
95071 +#if BUILDING_GCC_VERSION >= 4008
95072 + .optinfo_flags = OPTGROUP_NONE,
95073 +#endif
95074 + .gate = NULL,
95075 + .execute = execute_kallocstat,
95076 + .sub = NULL,
95077 + .next = NULL,
95078 + .static_pass_number = 0,
95079 + .tv_id = TV_NONE,
95080 + .properties_required = 0,
95081 + .properties_provided = 0,
95082 + .properties_destroyed = 0,
95083 + .todo_flags_start = 0,
95084 + .todo_flags_finish = 0
95085 + }
95086 +};
95087 +
95088 +static bool is_kalloc(const char *fnname)
95089 +{
95090 + size_t i;
95091 +
95092 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
95093 + if (!strcmp(fnname, kalloc_functions[i]))
95094 + return true;
95095 + return false;
95096 +}
95097 +
95098 +static unsigned int execute_kallocstat(void)
95099 +{
95100 + basic_block bb;
95101 +
95102 + // 1. loop through BBs and GIMPLE statements
95103 + FOR_EACH_BB(bb) {
95104 + gimple_stmt_iterator gsi;
95105 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
95106 + // gimple match:
95107 + tree fndecl, size;
95108 + gimple call_stmt;
95109 + const char *fnname;
95110 +
95111 + // is it a call
95112 + call_stmt = gsi_stmt(gsi);
95113 + if (!is_gimple_call(call_stmt))
95114 + continue;
95115 + fndecl = gimple_call_fndecl(call_stmt);
95116 + if (fndecl == NULL_TREE)
95117 + continue;
95118 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
95119 + continue;
95120 +
95121 + // is it a call to k*alloc
95122 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
95123 + if (!is_kalloc(fnname))
95124 + continue;
95125 +
95126 + // is the size arg the result of a simple const assignment
95127 + size = gimple_call_arg(call_stmt, 0);
95128 + while (true) {
95129 + gimple def_stmt;
95130 + expanded_location xloc;
95131 + size_t size_val;
95132 +
95133 + if (TREE_CODE(size) != SSA_NAME)
95134 + break;
95135 + def_stmt = SSA_NAME_DEF_STMT(size);
95136 + if (!def_stmt || !is_gimple_assign(def_stmt))
95137 + break;
95138 + if (gimple_num_ops(def_stmt) != 2)
95139 + break;
95140 + size = gimple_assign_rhs1(def_stmt);
95141 + if (!TREE_CONSTANT(size))
95142 + continue;
95143 + xloc = expand_location(gimple_location(def_stmt));
95144 + if (!xloc.file)
95145 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
95146 + size_val = TREE_INT_CST_LOW(size);
95147 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
95148 + break;
95149 + }
95150 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
95151 +//debug_tree(gimple_call_fn(call_stmt));
95152 +//print_node(stderr, "pax", fndecl, 4);
95153 + }
95154 + }
95155 +
95156 + return 0;
95157 +}
95158 +
95159 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
95160 +{
95161 + const char * const plugin_name = plugin_info->base_name;
95162 + struct register_pass_info kallocstat_pass_info = {
95163 + .pass = &kallocstat_pass.pass,
95164 + .reference_pass_name = "ssa",
95165 + .ref_pass_instance_number = 1,
95166 + .pos_op = PASS_POS_INSERT_AFTER
95167 + };
95168 +
95169 + if (!plugin_default_version_check(version, &gcc_version)) {
95170 + error(G_("incompatible gcc/plugin versions"));
95171 + return 1;
95172 + }
95173 +
95174 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
95175 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
95176 +
95177 + return 0;
95178 +}
95179 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
95180 new file mode 100644
95181 index 0000000..0408e06
95182 --- /dev/null
95183 +++ b/tools/gcc/kernexec_plugin.c
95184 @@ -0,0 +1,465 @@
95185 +/*
95186 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
95187 + * Licensed under the GPL v2
95188 + *
95189 + * Note: the choice of the license means that the compilation process is
95190 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
95191 + * but for the kernel it doesn't matter since it doesn't link against
95192 + * any of the gcc libraries
95193 + *
95194 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
95195 + *
95196 + * TODO:
95197 + *
95198 + * BUGS:
95199 + * - none known
95200 + */
95201 +#include "gcc-plugin.h"
95202 +#include "config.h"
95203 +#include "system.h"
95204 +#include "coretypes.h"
95205 +#include "tree.h"
95206 +#include "tree-pass.h"
95207 +#include "flags.h"
95208 +#include "intl.h"
95209 +#include "toplev.h"
95210 +#include "plugin.h"
95211 +//#include "expr.h" where are you...
95212 +#include "diagnostic.h"
95213 +#include "plugin-version.h"
95214 +#include "tm.h"
95215 +#include "function.h"
95216 +#include "basic-block.h"
95217 +#include "gimple.h"
95218 +#include "rtl.h"
95219 +#include "emit-rtl.h"
95220 +#include "tree-flow.h"
95221 +
95222 +extern void print_gimple_stmt(FILE *, gimple, int, int);
95223 +extern rtx emit_move_insn(rtx x, rtx y);
95224 +
95225 +#if BUILDING_GCC_VERSION <= 4006
95226 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
95227 +#endif
95228 +
95229 +#if BUILDING_GCC_VERSION >= 4008
95230 +#define TODO_dump_func 0
95231 +#endif
95232 +
95233 +int plugin_is_GPL_compatible;
95234 +
95235 +static struct plugin_info kernexec_plugin_info = {
95236 + .version = "201302112000",
95237 + .help = "method=[bts|or]\tinstrumentation method\n"
95238 +};
95239 +
95240 +static unsigned int execute_kernexec_reload(void);
95241 +static unsigned int execute_kernexec_fptr(void);
95242 +static unsigned int execute_kernexec_retaddr(void);
95243 +static bool kernexec_cmodel_check(void);
95244 +
95245 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
95246 +static void (*kernexec_instrument_retaddr)(rtx);
95247 +
95248 +static struct gimple_opt_pass kernexec_reload_pass = {
95249 + .pass = {
95250 + .type = GIMPLE_PASS,
95251 + .name = "kernexec_reload",
95252 +#if BUILDING_GCC_VERSION >= 4008
95253 + .optinfo_flags = OPTGROUP_NONE,
95254 +#endif
95255 + .gate = kernexec_cmodel_check,
95256 + .execute = execute_kernexec_reload,
95257 + .sub = NULL,
95258 + .next = NULL,
95259 + .static_pass_number = 0,
95260 + .tv_id = TV_NONE,
95261 + .properties_required = 0,
95262 + .properties_provided = 0,
95263 + .properties_destroyed = 0,
95264 + .todo_flags_start = 0,
95265 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
95266 + }
95267 +};
95268 +
95269 +static struct gimple_opt_pass kernexec_fptr_pass = {
95270 + .pass = {
95271 + .type = GIMPLE_PASS,
95272 + .name = "kernexec_fptr",
95273 +#if BUILDING_GCC_VERSION >= 4008
95274 + .optinfo_flags = OPTGROUP_NONE,
95275 +#endif
95276 + .gate = kernexec_cmodel_check,
95277 + .execute = execute_kernexec_fptr,
95278 + .sub = NULL,
95279 + .next = NULL,
95280 + .static_pass_number = 0,
95281 + .tv_id = TV_NONE,
95282 + .properties_required = 0,
95283 + .properties_provided = 0,
95284 + .properties_destroyed = 0,
95285 + .todo_flags_start = 0,
95286 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
95287 + }
95288 +};
95289 +
95290 +static struct rtl_opt_pass kernexec_retaddr_pass = {
95291 + .pass = {
95292 + .type = RTL_PASS,
95293 + .name = "kernexec_retaddr",
95294 +#if BUILDING_GCC_VERSION >= 4008
95295 + .optinfo_flags = OPTGROUP_NONE,
95296 +#endif
95297 + .gate = kernexec_cmodel_check,
95298 + .execute = execute_kernexec_retaddr,
95299 + .sub = NULL,
95300 + .next = NULL,
95301 + .static_pass_number = 0,
95302 + .tv_id = TV_NONE,
95303 + .properties_required = 0,
95304 + .properties_provided = 0,
95305 + .properties_destroyed = 0,
95306 + .todo_flags_start = 0,
95307 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
95308 + }
95309 +};
95310 +
95311 +static bool kernexec_cmodel_check(void)
95312 +{
95313 + tree section;
95314 +
95315 + if (ix86_cmodel != CM_KERNEL)
95316 + return false;
95317 +
95318 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
95319 + if (!section || !TREE_VALUE(section))
95320 + return true;
95321 +
95322 + section = TREE_VALUE(TREE_VALUE(section));
95323 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
95324 + return true;
95325 +
95326 + return false;
95327 +}
95328 +
95329 +/*
95330 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
95331 + */
95332 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
95333 +{
95334 + gimple asm_movabs_stmt;
95335 +
95336 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
95337 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
95338 + gimple_asm_set_volatile(asm_movabs_stmt, true);
95339 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
95340 + update_stmt(asm_movabs_stmt);
95341 +}
95342 +
95343 +/*
95344 + * find all asm() stmts that clobber r10 and add a reload of r10
95345 + */
95346 +static unsigned int execute_kernexec_reload(void)
95347 +{
95348 + basic_block bb;
95349 +
95350 + // 1. loop through BBs and GIMPLE statements
95351 + FOR_EACH_BB(bb) {
95352 + gimple_stmt_iterator gsi;
95353 +
95354 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
95355 + // gimple match: __asm__ ("" : : : "r10");
95356 + gimple asm_stmt;
95357 + size_t nclobbers;
95358 +
95359 + // is it an asm ...
95360 + asm_stmt = gsi_stmt(gsi);
95361 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
95362 + continue;
95363 +
95364 + // ... clobbering r10
95365 + nclobbers = gimple_asm_nclobbers(asm_stmt);
95366 + while (nclobbers--) {
95367 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
95368 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
95369 + continue;
95370 + kernexec_reload_fptr_mask(&gsi);
95371 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
95372 + break;
95373 + }
95374 + }
95375 + }
95376 +
95377 + return 0;
95378 +}
95379 +
95380 +/*
95381 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
95382 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
95383 + */
95384 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
95385 +{
95386 + gimple assign_intptr, assign_new_fptr, call_stmt;
95387 + tree intptr, old_fptr, new_fptr, kernexec_mask;
95388 +
95389 + call_stmt = gsi_stmt(*gsi);
95390 + old_fptr = gimple_call_fn(call_stmt);
95391 +
95392 + // create temporary unsigned long variable used for bitops and cast fptr to it
95393 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
95394 +#if BUILDING_GCC_VERSION <= 4007
95395 + add_referenced_var(intptr);
95396 + mark_sym_for_renaming(intptr);
95397 +#endif
95398 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
95399 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
95400 + update_stmt(assign_intptr);
95401 +
95402 + // apply logical or to temporary unsigned long and bitmask
95403 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
95404 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
95405 + assign_intptr = gimple_build_assign(intptr, fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask));
95406 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
95407 + update_stmt(assign_intptr);
95408 +
95409 + // cast temporary unsigned long back to a temporary fptr variable
95410 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
95411 +#if BUILDING_GCC_VERSION <= 4007
95412 + add_referenced_var(new_fptr);
95413 + mark_sym_for_renaming(new_fptr);
95414 +#endif
95415 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
95416 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
95417 + update_stmt(assign_new_fptr);
95418 +
95419 + // replace call stmt fn with the new fptr
95420 + gimple_call_set_fn(call_stmt, new_fptr);
95421 + update_stmt(call_stmt);
95422 +}
95423 +
95424 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
95425 +{
95426 + gimple asm_or_stmt, call_stmt;
95427 + tree old_fptr, new_fptr, input, output;
95428 +#if BUILDING_GCC_VERSION <= 4007
95429 + VEC(tree, gc) *inputs = NULL;
95430 + VEC(tree, gc) *outputs = NULL;
95431 +#else
95432 + vec<tree, va_gc> *inputs = NULL;
95433 + vec<tree, va_gc> *outputs = NULL;
95434 +#endif
95435 +
95436 + call_stmt = gsi_stmt(*gsi);
95437 + old_fptr = gimple_call_fn(call_stmt);
95438 +
95439 + // create temporary fptr variable
95440 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
95441 +#if BUILDING_GCC_VERSION <= 4007
95442 + add_referenced_var(new_fptr);
95443 + mark_sym_for_renaming(new_fptr);
95444 +#endif
95445 +
95446 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
95447 + input = build_tree_list(NULL_TREE, build_string(2, "0"));
95448 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
95449 + output = build_tree_list(NULL_TREE, build_string(3, "=r"));
95450 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
95451 +#if BUILDING_GCC_VERSION <= 4007
95452 + VEC_safe_push(tree, gc, inputs, input);
95453 + VEC_safe_push(tree, gc, outputs, output);
95454 +#else
95455 + vec_safe_push(inputs, input);
95456 + vec_safe_push(outputs, output);
95457 +#endif
95458 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
95459 + gimple_asm_set_volatile(asm_or_stmt, true);
95460 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
95461 + update_stmt(asm_or_stmt);
95462 +
95463 + // replace call stmt fn with the new fptr
95464 + gimple_call_set_fn(call_stmt, new_fptr);
95465 + update_stmt(call_stmt);
95466 +}
95467 +
95468 +/*
95469 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
95470 + */
95471 +static unsigned int execute_kernexec_fptr(void)
95472 +{
95473 + basic_block bb;
95474 +
95475 + // 1. loop through BBs and GIMPLE statements
95476 + FOR_EACH_BB(bb) {
95477 + gimple_stmt_iterator gsi;
95478 +
95479 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
95480 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
95481 + tree fn;
95482 + gimple call_stmt;
95483 +
95484 + // is it a call ...
95485 + call_stmt = gsi_stmt(gsi);
95486 + if (!is_gimple_call(call_stmt))
95487 + continue;
95488 + fn = gimple_call_fn(call_stmt);
95489 + if (TREE_CODE(fn) == ADDR_EXPR)
95490 + continue;
95491 + if (TREE_CODE(fn) != SSA_NAME)
95492 + gcc_unreachable();
95493 +
95494 + // ... through a function pointer
95495 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
95496 + fn = SSA_NAME_VAR(fn);
95497 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
95498 + debug_tree(fn);
95499 + gcc_unreachable();
95500 + }
95501 + }
95502 + fn = TREE_TYPE(fn);
95503 + if (TREE_CODE(fn) != POINTER_TYPE)
95504 + continue;
95505 + fn = TREE_TYPE(fn);
95506 + if (TREE_CODE(fn) != FUNCTION_TYPE)
95507 + continue;
95508 +
95509 + kernexec_instrument_fptr(&gsi);
95510 +
95511 +//debug_tree(gimple_call_fn(call_stmt));
95512 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
95513 + }
95514 + }
95515 +
95516 + return 0;
95517 +}
95518 +
95519 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
95520 +static void kernexec_instrument_retaddr_bts(rtx insn)
95521 +{
95522 + rtx btsq;
95523 + rtvec argvec, constraintvec, labelvec;
95524 + int line;
95525 +
95526 + // create asm volatile("btsq $63,(%%rsp)":::)
95527 + argvec = rtvec_alloc(0);
95528 + constraintvec = rtvec_alloc(0);
95529 + labelvec = rtvec_alloc(0);
95530 + line = expand_location(RTL_LOCATION(insn)).line;
95531 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
95532 + MEM_VOLATILE_P(btsq) = 1;
95533 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
95534 + emit_insn_before(btsq, insn);
95535 +}
95536 +
95537 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
95538 +static void kernexec_instrument_retaddr_or(rtx insn)
95539 +{
95540 + rtx orq;
95541 + rtvec argvec, constraintvec, labelvec;
95542 + int line;
95543 +
95544 + // create asm volatile("orq %%r10,(%%rsp)":::)
95545 + argvec = rtvec_alloc(0);
95546 + constraintvec = rtvec_alloc(0);
95547 + labelvec = rtvec_alloc(0);
95548 + line = expand_location(RTL_LOCATION(insn)).line;
95549 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
95550 + MEM_VOLATILE_P(orq) = 1;
95551 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
95552 + emit_insn_before(orq, insn);
95553 +}
95554 +
95555 +/*
95556 + * find all asm level function returns and forcibly set the highest bit of the return address
95557 + */
95558 +static unsigned int execute_kernexec_retaddr(void)
95559 +{
95560 + rtx insn;
95561 +
95562 + // 1. find function returns
95563 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
95564 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
95565 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
95566 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
95567 + rtx body;
95568 +
95569 + // is it a retn
95570 + if (!JUMP_P(insn))
95571 + continue;
95572 + body = PATTERN(insn);
95573 + if (GET_CODE(body) == PARALLEL)
95574 + body = XVECEXP(body, 0, 0);
95575 + if (!ANY_RETURN_P(body))
95576 + continue;
95577 + kernexec_instrument_retaddr(insn);
95578 + }
95579 +
95580 +// print_simple_rtl(stderr, get_insns());
95581 +// print_rtl(stderr, get_insns());
95582 +
95583 + return 0;
95584 +}
95585 +
95586 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
95587 +{
95588 + const char * const plugin_name = plugin_info->base_name;
95589 + const int argc = plugin_info->argc;
95590 + const struct plugin_argument * const argv = plugin_info->argv;
95591 + int i;
95592 + struct register_pass_info kernexec_reload_pass_info = {
95593 + .pass = &kernexec_reload_pass.pass,
95594 + .reference_pass_name = "ssa",
95595 + .ref_pass_instance_number = 1,
95596 + .pos_op = PASS_POS_INSERT_AFTER
95597 + };
95598 + struct register_pass_info kernexec_fptr_pass_info = {
95599 + .pass = &kernexec_fptr_pass.pass,
95600 + .reference_pass_name = "ssa",
95601 + .ref_pass_instance_number = 1,
95602 + .pos_op = PASS_POS_INSERT_AFTER
95603 + };
95604 + struct register_pass_info kernexec_retaddr_pass_info = {
95605 + .pass = &kernexec_retaddr_pass.pass,
95606 + .reference_pass_name = "pro_and_epilogue",
95607 + .ref_pass_instance_number = 1,
95608 + .pos_op = PASS_POS_INSERT_AFTER
95609 + };
95610 +
95611 + if (!plugin_default_version_check(version, &gcc_version)) {
95612 + error(G_("incompatible gcc/plugin versions"));
95613 + return 1;
95614 + }
95615 +
95616 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
95617 +
95618 + if (TARGET_64BIT == 0)
95619 + return 0;
95620 +
95621 + for (i = 0; i < argc; ++i) {
95622 + if (!strcmp(argv[i].key, "method")) {
95623 + if (!argv[i].value) {
95624 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
95625 + continue;
95626 + }
95627 + if (!strcmp(argv[i].value, "bts")) {
95628 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
95629 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
95630 + } else if (!strcmp(argv[i].value, "or")) {
95631 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
95632 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
95633 + fix_register("r10", 1, 1);
95634 + } else
95635 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
95636 + continue;
95637 + }
95638 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
95639 + }
95640 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
95641 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
95642 +
95643 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
95644 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
95645 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
95646 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
95647 +
95648 + return 0;
95649 +}
95650 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
95651 new file mode 100644
95652 index 0000000..b5395ba
95653 --- /dev/null
95654 +++ b/tools/gcc/latent_entropy_plugin.c
95655 @@ -0,0 +1,327 @@
95656 +/*
95657 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
95658 + * Licensed under the GPL v2
95659 + *
95660 + * Note: the choice of the license means that the compilation process is
95661 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
95662 + * but for the kernel it doesn't matter since it doesn't link against
95663 + * any of the gcc libraries
95664 + *
95665 + * gcc plugin to help generate a little bit of entropy from program state,
95666 + * used during boot in the kernel
95667 + *
95668 + * TODO:
95669 + * - add ipa pass to identify not explicitly marked candidate functions
95670 + * - mix in more program state (function arguments/return values, loop variables, etc)
95671 + * - more instrumentation control via attribute parameters
95672 + *
95673 + * BUGS:
95674 + * - LTO needs -flto-partition=none for now
95675 + */
95676 +#include "gcc-plugin.h"
95677 +#include "config.h"
95678 +#include "system.h"
95679 +#include "coretypes.h"
95680 +#include "tree.h"
95681 +#include "tree-pass.h"
95682 +#include "flags.h"
95683 +#include "intl.h"
95684 +#include "toplev.h"
95685 +#include "plugin.h"
95686 +//#include "expr.h" where are you...
95687 +#include "diagnostic.h"
95688 +#include "plugin-version.h"
95689 +#include "tm.h"
95690 +#include "function.h"
95691 +#include "basic-block.h"
95692 +#include "gimple.h"
95693 +#include "rtl.h"
95694 +#include "emit-rtl.h"
95695 +#include "tree-flow.h"
95696 +#include "langhooks.h"
95697 +
95698 +#if BUILDING_GCC_VERSION >= 4008
95699 +#define TODO_dump_func 0
95700 +#endif
95701 +
95702 +int plugin_is_GPL_compatible;
95703 +
95704 +static tree latent_entropy_decl;
95705 +
95706 +static struct plugin_info latent_entropy_plugin_info = {
95707 + .version = "201303102320",
95708 + .help = NULL
95709 +};
95710 +
95711 +static unsigned int execute_latent_entropy(void);
95712 +static bool gate_latent_entropy(void);
95713 +
95714 +static struct gimple_opt_pass latent_entropy_pass = {
95715 + .pass = {
95716 + .type = GIMPLE_PASS,
95717 + .name = "latent_entropy",
95718 +#if BUILDING_GCC_VERSION >= 4008
95719 + .optinfo_flags = OPTGROUP_NONE,
95720 +#endif
95721 + .gate = gate_latent_entropy,
95722 + .execute = execute_latent_entropy,
95723 + .sub = NULL,
95724 + .next = NULL,
95725 + .static_pass_number = 0,
95726 + .tv_id = TV_NONE,
95727 + .properties_required = PROP_gimple_leh | PROP_cfg,
95728 + .properties_provided = 0,
95729 + .properties_destroyed = 0,
95730 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
95731 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
95732 + }
95733 +};
95734 +
95735 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
95736 +{
95737 + if (TREE_CODE(*node) != FUNCTION_DECL) {
95738 + *no_add_attrs = true;
95739 + error("%qE attribute only applies to functions", name);
95740 + }
95741 + return NULL_TREE;
95742 +}
95743 +
95744 +static struct attribute_spec latent_entropy_attr = {
95745 + .name = "latent_entropy",
95746 + .min_length = 0,
95747 + .max_length = 0,
95748 + .decl_required = true,
95749 + .type_required = false,
95750 + .function_type_required = false,
95751 + .handler = handle_latent_entropy_attribute,
95752 +#if BUILDING_GCC_VERSION >= 4007
95753 + .affects_type_identity = false
95754 +#endif
95755 +};
95756 +
95757 +static void register_attributes(void *event_data, void *data)
95758 +{
95759 + register_attribute(&latent_entropy_attr);
95760 +}
95761 +
95762 +static bool gate_latent_entropy(void)
95763 +{
95764 + tree latent_entropy_attr;
95765 +
95766 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
95767 + return latent_entropy_attr != NULL_TREE;
95768 +}
95769 +
95770 +static unsigned HOST_WIDE_INT seed;
95771 +static unsigned HOST_WIDE_INT get_random_const(void)
95772 +{
95773 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
95774 + return seed;
95775 +}
95776 +
95777 +static enum tree_code get_op(tree *rhs)
95778 +{
95779 + static enum tree_code op;
95780 + unsigned HOST_WIDE_INT random_const;
95781 +
95782 + random_const = get_random_const();
95783 +
95784 + switch (op) {
95785 + case BIT_XOR_EXPR:
95786 + op = PLUS_EXPR;
95787 + break;
95788 +
95789 + case PLUS_EXPR:
95790 + if (rhs) {
95791 + op = LROTATE_EXPR;
95792 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
95793 + break;
95794 + }
95795 +
95796 + case LROTATE_EXPR:
95797 + default:
95798 + op = BIT_XOR_EXPR;
95799 + break;
95800 + }
95801 + if (rhs)
95802 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
95803 + return op;
95804 +}
95805 +
95806 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
95807 +{
95808 + gimple_stmt_iterator gsi;
95809 + gimple assign;
95810 + tree addxorrol, rhs;
95811 + enum tree_code op;
95812 +
95813 + op = get_op(&rhs);
95814 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
95815 + assign = gimple_build_assign(local_entropy, addxorrol);
95816 +#if BUILDING_GCC_VERSION <= 4007
95817 + find_referenced_vars_in(assign);
95818 +#endif
95819 +//debug_bb(bb);
95820 + gsi = gsi_after_labels(bb);
95821 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
95822 + update_stmt(assign);
95823 +}
95824 +
95825 +static void perturb_latent_entropy(basic_block bb, tree rhs)
95826 +{
95827 + gimple_stmt_iterator gsi;
95828 + gimple assign;
95829 + tree addxorrol, temp;
95830 +
95831 + // 1. create temporary copy of latent_entropy
95832 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
95833 +#if BUILDING_GCC_VERSION <= 4007
95834 + add_referenced_var(temp);
95835 + mark_sym_for_renaming(temp);
95836 +#endif
95837 +
95838 + // 2. read...
95839 + assign = gimple_build_assign(temp, latent_entropy_decl);
95840 +#if BUILDING_GCC_VERSION <= 4007
95841 + find_referenced_vars_in(assign);
95842 +#endif
95843 + gsi = gsi_after_labels(bb);
95844 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95845 + update_stmt(assign);
95846 +
95847 + // 3. ...modify...
95848 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
95849 + assign = gimple_build_assign(temp, addxorrol);
95850 +#if BUILDING_GCC_VERSION <= 4007
95851 + find_referenced_vars_in(assign);
95852 +#endif
95853 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95854 + update_stmt(assign);
95855 +
95856 + // 4. ...write latent_entropy
95857 + assign = gimple_build_assign(latent_entropy_decl, temp);
95858 +#if BUILDING_GCC_VERSION <= 4007
95859 + find_referenced_vars_in(assign);
95860 +#endif
95861 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95862 + update_stmt(assign);
95863 +}
95864 +
95865 +static unsigned int execute_latent_entropy(void)
95866 +{
95867 + basic_block bb;
95868 + gimple assign;
95869 + gimple_stmt_iterator gsi;
95870 + tree local_entropy;
95871 +
95872 + if (!latent_entropy_decl) {
95873 + struct varpool_node *node;
95874 +
95875 +#if BUILDING_GCC_VERSION <= 4007
95876 + for (node = varpool_nodes; node; node = node->next) {
95877 + tree var = node->decl;
95878 +#else
95879 + FOR_EACH_VARIABLE(node) {
95880 + tree var = node->symbol.decl;
95881 +#endif
95882 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
95883 + continue;
95884 + latent_entropy_decl = var;
95885 +// debug_tree(var);
95886 + break;
95887 + }
95888 + if (!latent_entropy_decl) {
95889 +// debug_tree(current_function_decl);
95890 + return 0;
95891 + }
95892 + }
95893 +
95894 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
95895 +
95896 + // 1. create local entropy variable
95897 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
95898 +#if BUILDING_GCC_VERSION <= 4007
95899 + add_referenced_var(local_entropy);
95900 + mark_sym_for_renaming(local_entropy);
95901 +#endif
95902 +
95903 + // 2. initialize local entropy variable
95904 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
95905 + if (dom_info_available_p(CDI_DOMINATORS))
95906 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
95907 + gsi = gsi_start_bb(bb);
95908 +
95909 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
95910 +// gimple_set_location(assign, loc);
95911 +#if BUILDING_GCC_VERSION <= 4007
95912 + find_referenced_vars_in(assign);
95913 +#endif
95914 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
95915 + update_stmt(assign);
95916 + bb = bb->next_bb;
95917 +
95918 + // 3. instrument each BB with an operation on the local entropy variable
95919 + while (bb != EXIT_BLOCK_PTR) {
95920 + perturb_local_entropy(bb, local_entropy);
95921 + bb = bb->next_bb;
95922 + };
95923 +
95924 + // 4. mix local entropy into the global entropy variable
95925 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
95926 + return 0;
95927 +}
95928 +
95929 +static void start_unit_callback(void *gcc_data, void *user_data)
95930 +{
95931 + tree latent_entropy_type;
95932 +
95933 +#if BUILDING_GCC_VERSION >= 4007
95934 + seed = get_random_seed(false);
95935 +#else
95936 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
95937 + seed *= seed;
95938 +#endif
95939 +
95940 + if (in_lto_p)
95941 + return;
95942 +
95943 + // extern volatile u64 latent_entropy
95944 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
95945 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
95946 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
95947 +
95948 + TREE_STATIC(latent_entropy_decl) = 1;
95949 + TREE_PUBLIC(latent_entropy_decl) = 1;
95950 + TREE_USED(latent_entropy_decl) = 1;
95951 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
95952 + DECL_EXTERNAL(latent_entropy_decl) = 1;
95953 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
95954 + DECL_INITIAL(latent_entropy_decl) = NULL;
95955 + lang_hooks.decls.pushdecl(latent_entropy_decl);
95956 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
95957 +// varpool_finalize_decl(latent_entropy_decl);
95958 +// varpool_mark_needed_node(latent_entropy_decl);
95959 +}
95960 +
95961 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
95962 +{
95963 + const char * const plugin_name = plugin_info->base_name;
95964 + struct register_pass_info latent_entropy_pass_info = {
95965 + .pass = &latent_entropy_pass.pass,
95966 + .reference_pass_name = "optimized",
95967 + .ref_pass_instance_number = 1,
95968 + .pos_op = PASS_POS_INSERT_BEFORE
95969 + };
95970 +
95971 + if (!plugin_default_version_check(version, &gcc_version)) {
95972 + error(G_("incompatible gcc/plugin versions"));
95973 + return 1;
95974 + }
95975 +
95976 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
95977 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
95978 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
95979 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
95980 +
95981 + return 0;
95982 +}
95983 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
95984 new file mode 100644
95985 index 0000000..7982a0c
95986 --- /dev/null
95987 +++ b/tools/gcc/size_overflow_hash.data
95988 @@ -0,0 +1,5893 @@
95989 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
95990 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
95991 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
95992 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
95993 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
95994 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
95995 +padzero_55 padzero 1 55 &sel_read_policyvers_55
95996 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
95997 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
95998 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 NULL
95999 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
96000 +load_msg_95 load_msg 2 95 NULL
96001 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
96002 +init_q_132 init_q 4 132 NULL
96003 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
96004 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
96005 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 NULL
96006 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
96007 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
96008 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
96009 +virtblk_add_req_197 virtblk_add_req 2-3 197 NULL
96010 +proc_scsi_write_proc_267 proc_scsi_write_proc 3 267 NULL
96011 +br_port_info_size_268 br_port_info_size 0 268 NULL
96012 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
96013 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
96014 +syslog_print_307 syslog_print 2 307 NULL
96015 +platform_device_add_data_310 platform_device_add_data 3 310 NULL
96016 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
96017 +next_node_allowed_318 next_node_allowed 1 318 NULL
96018 +compat_sys_ioctl_333 compat_sys_ioctl 3 333 NULL
96019 +btmrvl_txdnldready_read_413 btmrvl_txdnldready_read 3 413 NULL
96020 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
96021 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
96022 +_alloc_get_attr_desc_470 _alloc_get_attr_desc 2 470 NULL
96023 +dccp_manip_pkt_476 dccp_manip_pkt 4 476 NULL
96024 +pidlist_resize_496 pidlist_resize 2 496 NULL
96025 +read_vbt_r0_503 read_vbt_r0 1 503 NULL
96026 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
96027 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
96028 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0 537 NULL
96029 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
96030 +dle_count_543 dle_count 0 543 NULL
96031 +devres_alloc_551 devres_alloc 2 551 NULL
96032 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
96033 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
96034 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
96035 +compat_sys_preadv_583 compat_sys_preadv 3 583 NULL
96036 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
96037 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
96038 +fuse_request_alloc_nofs_617 fuse_request_alloc_nofs 1 617 NULL
96039 +compat_sys_shmat_620 compat_sys_shmat 3 620 NULL
96040 +isp1760_register_628 isp1760_register 1-2 628 NULL
96041 +clone_split_bio_633 clone_split_bio 6 633 NULL
96042 +remap_to_cache_640 remap_to_cache 3 640 NULL
96043 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 NULL
96044 +unlink_queued_645 unlink_queued 3-4 645 NULL
96045 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
96046 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
96047 +rtl8169_try_rx_copy_705 rtl8169_try_rx_copy 3 705 NULL
96048 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
96049 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
96050 +disk_max_parts_719 disk_max_parts 0 719 NULL
96051 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
96052 +dvb_video_write_754 dvb_video_write 3 754 NULL
96053 +if_writecmd_815 if_writecmd 2 815 NULL
96054 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
96055 +read_fifo_826 read_fifo 3 826 NULL
96056 +um_idi_read_850 um_idi_read 3 850 NULL
96057 +ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz_856 ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz 3 856 NULL
96058 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
96059 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
96060 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
96061 +btmrvl_hsstate_read_920 btmrvl_hsstate_read 3 920 NULL
96062 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
96063 +get_ramdisk_size_954 get_ramdisk_size 0 954 NULL
96064 +__nodes_weight_956 __nodes_weight 2-0 956 NULL
96065 +sys_msgrcv_959 sys_msgrcv 3 959 NULL
96066 +pte_prefetch_gfn_to_pfn_997 pte_prefetch_gfn_to_pfn 2 997 NULL nohasharray
96067 +hdlcdev_rx_997 hdlcdev_rx 3 997 &pte_prefetch_gfn_to_pfn_997
96068 +dm_cache_set_dirty_1016 dm_cache_set_dirty 2 1016 NULL
96069 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
96070 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
96071 +Read_hfc16_1070 Read_hfc16 0 1070 NULL
96072 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
96073 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
96074 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
96075 +nfs_pgarray_set_1085 nfs_pgarray_set 2 1085 NULL
96076 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
96077 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
96078 +sys_mremap_1107 sys_mremap 5-1-2 1107 NULL
96079 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
96080 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
96081 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
96082 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
96083 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
96084 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
96085 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
96086 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
96087 +ipw_packet_received_skb_1230 ipw_packet_received_skb 2 1230 NULL
96088 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
96089 +nested_get_page_1252 nested_get_page 2 1252 NULL
96090 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
96091 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
96092 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
96093 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
96094 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
96095 +wm_adsp_buf_alloc_1317 wm_adsp_buf_alloc 2 1317 NULL
96096 +compat_put_u64_1319 compat_put_u64 1 1319 NULL
96097 +ffs_1322 ffs 0 1322 NULL
96098 +carl9170_rx_stream_1334 carl9170_rx_stream 3 1334 NULL
96099 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
96100 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
96101 +io_mapping_create_wc_1354 io_mapping_create_wc 1-2 1354 NULL
96102 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
96103 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
96104 +iov_num_pages_1364 iov_num_pages 0 1364 NULL
96105 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
96106 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
96107 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
96108 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
96109 +zone_page_state_1393 zone_page_state 0 1393 NULL
96110 +file_read_actor_1401 file_read_actor 4 1401 NULL
96111 +vb2_dc_get_user_pages_1442 vb2_dc_get_user_pages 1-3 1442 NULL
96112 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
96113 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
96114 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
96115 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
96116 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
96117 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
96118 +__vfio_dma_map_1523 __vfio_dma_map 3 1523 NULL
96119 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
96120 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
96121 +fc_frame_alloc_1596 fc_frame_alloc 2 1596 NULL
96122 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
96123 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
96124 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
96125 +btmrvl_hsmode_read_1647 btmrvl_hsmode_read 3 1647 NULL
96126 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
96127 +netdev_feature_string_1667 netdev_feature_string 0 1667 NULL
96128 +compat_x25_ioctl_1674 compat_x25_ioctl 3 1674 NULL
96129 +rmap_add_1677 rmap_add 3 1677 NULL
96130 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
96131 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL
96132 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
96133 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
96134 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
96135 +compat_cdrom_generic_command_1756 compat_cdrom_generic_command 4 1756 NULL
96136 +ieee80211_new_mesh_header_1761 ieee80211_new_mesh_header 0 1761 NULL
96137 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
96138 +cosa_write_1774 cosa_write 3 1774 NULL
96139 +update_macheader_1775 update_macheader 7 1775 NULL
96140 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
96141 +__nodelist_scnprintf_1815 __nodelist_scnprintf 0-2-4 1815 NULL
96142 +alloc_pages_exact_1892 alloc_pages_exact 1 1892 NULL
96143 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
96144 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
96145 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
96146 +memblock_alloc_base_1938 memblock_alloc_base 1-2 1938 NULL
96147 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
96148 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
96149 +read_swap_header_1957 read_swap_header 0 1957 NULL
96150 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
96151 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
96152 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2-3 1992 NULL
96153 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
96154 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
96155 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
96156 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
96157 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
96158 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
96159 +BcmCopySection_2035 BcmCopySection 5 2035 NULL
96160 +devm_ioremap_nocache_2036 devm_ioremap_nocache 2-3 2036 NULL
96161 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
96162 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
96163 +subbuf_read_actor_2071 subbuf_read_actor 3 2071 NULL
96164 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
96165 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
96166 +audit_expand_2098 audit_expand 2 2098 NULL
96167 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
96168 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
96169 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
96170 +__find_xattr_2117 __find_xattr 6 2117 NULL nohasharray
96171 +enable_read_2117 enable_read 3 2117 &__find_xattr_2117
96172 +pcf50633_write_block_2124 pcf50633_write_block 2-3 2124 NULL
96173 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
96174 +lp_gpio_irq_map_2149 lp_gpio_irq_map 2 2149 NULL
96175 +mlx4_init_icm_table_2151 mlx4_init_icm_table 5-4 2151 NULL
96176 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
96177 +_ore_get_io_state_2166 _ore_get_io_state 3-4-5 2166 NULL
96178 +ssb_bus_ssbbus_register_2217 ssb_bus_ssbbus_register 2 2217 NULL
96179 +u32_array_read_2219 u32_array_read 3 2219 NULL
96180 +vhci_write_2224 vhci_write 3 2224 NULL
96181 +efx_tsoh_page_count_2225 efx_tsoh_page_count 0 2225 NULL
96182 +lowpan_get_mac_header_length_2231 lowpan_get_mac_header_length 0 2231 NULL
96183 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
96184 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
96185 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
96186 +do_update_counters_2259 do_update_counters 4 2259 NULL
96187 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
96188 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
96189 +kvm_clear_guest_page_2308 kvm_clear_guest_page 4-2 2308 NULL
96190 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
96191 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL
96192 +gart_map_page_2325 gart_map_page 3-4 2325 NULL
96193 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
96194 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
96195 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
96196 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL
96197 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
96198 +rtl_port_map_2385 rtl_port_map 1-2 2385 NULL
96199 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
96200 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
96201 +raid1_size_2419 raid1_size 0-2 2419 NULL
96202 +roccat_common2_send_2422 roccat_common2_send 4 2422 NULL
96203 +hfcpci_empty_fifo_2427 hfcpci_empty_fifo 4 2427 NULL
96204 +ioremap_nocache_2439 ioremap_nocache 1-2 2439 NULL
96205 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
96206 +ath6kl_usb_bmi_write_2454 ath6kl_usb_bmi_write 3 2454 NULL
96207 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
96208 +update_pmkid_2481 update_pmkid 4 2481 NULL
96209 +wiphy_new_2482 wiphy_new 2 2482 NULL
96210 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
96211 +lookup_cache_entry_2494 lookup_cache_entry 2 2494 NULL
96212 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
96213 +dm_write_2513 dm_write 3 2513 NULL
96214 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
96215 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
96216 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
96217 +i915_next_seqno_write_2572 i915_next_seqno_write 3 2572 NULL
96218 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
96219 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
96220 +kvm_gfn_to_hva_cache_init_2636 kvm_gfn_to_hva_cache_init 3 2636 NULL
96221 +lro_gen_skb_2644 lro_gen_skb 6 2644 NULL
96222 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
96223 +memcpy_fromiovecend_2707 memcpy_fromiovecend 3-4 2707 NULL
96224 +__xip_file_write_2733 __xip_file_write 4-3 2733 NULL
96225 +hid_report_raw_event_2762 hid_report_raw_event 4 2762 NULL
96226 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL
96227 +__next_cpu_2782 __next_cpu 1 2782 NULL
96228 +set_msr_hyperv_pw_2785 set_msr_hyperv_pw 3 2785 NULL
96229 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
96230 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL
96231 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
96232 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
96233 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
96234 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
96235 +mq_map_2871 mq_map 2 2871 NULL
96236 +nla_padlen_2883 nla_padlen 1 2883 NULL
96237 +cmm_write_2896 cmm_write 3 2896 NULL
96238 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
96239 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
96240 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
96241 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
96242 +ppp_cp_event_2965 ppp_cp_event 6 2965 NULL
96243 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
96244 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
96245 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
96246 +depth_write_3021 depth_write 3 3021 NULL
96247 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
96248 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
96249 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 NULL
96250 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
96251 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
96252 +qp_alloc_ppn_set_3068 qp_alloc_ppn_set 2-4 3068 NULL
96253 +__blk_end_bidi_request_3070 __blk_end_bidi_request 3-4 3070 NULL
96254 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
96255 +free_coherent_3082 free_coherent 4-2 3082 NULL
96256 +clone_bio_3100 clone_bio 6 3100 NULL nohasharray
96257 +ttusb2_msg_3100 ttusb2_msg 4 3100 &clone_bio_3100
96258 +rb_alloc_3102 rb_alloc 1 3102 NULL
96259 +simple_write_to_buffer_3122 simple_write_to_buffer 5-2 3122 NULL
96260 +print_time_3132 print_time 0 3132 NULL
96261 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
96262 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
96263 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
96264 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
96265 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
96266 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
96267 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
96268 +alloc_context_3194 alloc_context 1 3194 NULL
96269 +shmem_pread_slow_3198 shmem_pread_slow 3 3198 NULL
96270 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
96271 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
96272 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
96273 +key_key_read_3241 key_key_read 3 3241 NULL
96274 +number_3243 number 0 3243 NULL
96275 +check_vendor_extension_3254 check_vendor_extension 1 3254 NULL
96276 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
96277 +arvo_sysfs_write_3311 arvo_sysfs_write 6 3311 NULL
96278 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
96279 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
96280 +aac_rkt_ioremap_3333 aac_rkt_ioremap 2 3333 NULL
96281 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
96282 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
96283 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
96284 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
96285 +scnprintf_3360 scnprintf 0-2 3360 NULL
96286 +x86_emulate_instruction_3389 x86_emulate_instruction 2 3389 NULL
96287 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
96288 +send_stream_3397 send_stream 4 3397 NULL
96289 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
96290 +msix_map_region_3411 msix_map_region 3 3411 NULL
96291 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
96292 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
96293 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
96294 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
96295 +percpu_modalloc_3448 percpu_modalloc 2-3 3448 NULL
96296 +map_single_3449 map_single 0-2 3449 NULL
96297 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
96298 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 4-2-5 3464 &jffs2_acl_setxattr_3464
96299 +alloc_skb_fclone_3467 alloc_skb_fclone 1 3467 NULL
96300 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
96301 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
96302 +kvm_handle_bad_page_3503 kvm_handle_bad_page 2 3503 NULL
96303 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL nohasharray
96304 +ieee80211_wx_set_gen_ie_rsl_3521 ieee80211_wx_set_gen_ie_rsl 3 3521 &mem_tx_free_mem_blks_read_3521
96305 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
96306 +b43legacy_read16_3561 b43legacy_read16 0 3561 NULL
96307 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
96308 +evtchn_read_3569 evtchn_read 3 3569 NULL
96309 +vc_resize_3585 vc_resize 2-3 3585 NULL
96310 +compat_sys_semtimedop_3606 compat_sys_semtimedop 3 3606 NULL
96311 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
96312 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
96313 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
96314 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
96315 +cm_copy_private_data_3649 cm_copy_private_data 2 3649 NULL
96316 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
96317 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
96318 +create_irq_3703 create_irq 0 3703 NULL nohasharray
96319 +btmrvl_psmode_write_3703 btmrvl_psmode_write 3 3703 &create_irq_3703 nohasharray
96320 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 &btmrvl_psmode_write_3703
96321 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
96322 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
96323 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
96324 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
96325 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
96326 +read_file_tx_chainmask_3829 read_file_tx_chainmask 3 3829 NULL
96327 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
96328 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
96329 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
96330 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
96331 +get_fd_set_3866 get_fd_set 1 3866 NULL
96332 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
96333 +uea_send_modem_cmd_3888 uea_send_modem_cmd 3 3888 NULL
96334 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
96335 +nvram_write_3894 nvram_write 3 3894 NULL
96336 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
96337 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
96338 +vcs_write_3910 vcs_write 3 3910 NULL
96339 +atalk_compat_ioctl_3991 atalk_compat_ioctl 3 3991 NULL
96340 +do_add_counters_3992 do_add_counters 3 3992 NULL
96341 +userspace_status_4004 userspace_status 4 4004 NULL
96342 +mei_write_4005 mei_write 3 4005 NULL nohasharray
96343 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
96344 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
96345 +mm_populate_4016 mm_populate 1 4016 NULL
96346 +blk_end_request_4024 blk_end_request 3 4024 NULL
96347 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
96348 +usbnet_write_cmd_async_4035 usbnet_write_cmd_async 7 4035 NULL
96349 +read_file_queues_4078 read_file_queues 3 4078 NULL
96350 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
96351 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
96352 +ntb_netdev_change_mtu_4147 ntb_netdev_change_mtu 2 4147 NULL
96353 +tm6000_read_4151 tm6000_read 3 4151 NULL
96354 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
96355 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
96356 +get_alua_req_4166 get_alua_req 3 4166 NULL
96357 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
96358 +read_file_bool_4180 read_file_bool 3 4180 NULL
96359 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
96360 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
96361 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
96362 +goldfish_audio_write_4284 goldfish_audio_write 3 4284 NULL
96363 +paging32_page_fault_4288 paging32_page_fault 2 4288 NULL
96364 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
96365 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
96366 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 3-2-5 4303 NULL
96367 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
96368 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
96369 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 3 4365 NULL
96370 +sys_setdomainname_4373 sys_setdomainname 2 4373 NULL
96371 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
96372 +access_process_vm_4412 access_process_vm 0-2-4 4412 NULL nohasharray
96373 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
96374 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
96375 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
96376 +memparse_4444 memparse 0 4444 NULL
96377 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
96378 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 0-5 4481 NULL
96379 +sys_semtimedop_4486 sys_semtimedop 3 4486 NULL
96380 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
96381 +set_link_security_4502 set_link_security 4 4502 NULL
96382 +dm_cache_remove_mapping_4513 dm_cache_remove_mapping 2 4513 NULL
96383 +__gfn_to_pfn_memslot_4530 __gfn_to_pfn_memslot 2 4530 NULL
96384 +sys_llistxattr_4532 sys_llistxattr 3 4532 NULL
96385 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
96386 +tty_register_device_4544 tty_register_device 2 4544 NULL
96387 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
96388 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
96389 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
96390 +bch_alloc_4593 bch_alloc 1 4593 NULL
96391 +__wb_force_remove_mapping_4622 __wb_force_remove_mapping 2 4622 NULL
96392 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
96393 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
96394 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
96395 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
96396 +kone_receive_4690 kone_receive 4 4690 NULL
96397 +round_pipe_size_4701 round_pipe_size 0 4701 NULL
96398 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
96399 +btmrvl_gpiogap_read_4718 btmrvl_gpiogap_read 3 4718 NULL
96400 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
96401 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
96402 +__find_free_cblock_4741 __find_free_cblock 2 4741 NULL
96403 +memblock_find_in_range_4759 memblock_find_in_range 3-4 4759 NULL
96404 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 NULL
96405 +create_subvol_4791 create_subvol 4 4791 NULL
96406 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
96407 +repair_io_failure_4815 repair_io_failure 4 4815 NULL
96408 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
96409 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
96410 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3 4873 NULL
96411 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
96412 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
96413 +sys_ipc_4889 sys_ipc 3 4889 NULL
96414 +sys_process_vm_writev_4928 sys_process_vm_writev 3-5 4928 NULL
96415 +ntfs_rl_insert_4931 ntfs_rl_insert 2-4 4931 NULL
96416 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
96417 +devm_kzalloc_4966 devm_kzalloc 2 4966 NULL
96418 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
96419 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
96420 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
96421 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
96422 +qla82xx_pci_mem_write_direct_5008 qla82xx_pci_mem_write_direct 2 5008 NULL
96423 +do_mincore_5018 do_mincore 0-1 5018 NULL
96424 +mtd_device_parse_register_5024 mtd_device_parse_register 5 5024 NULL
96425 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 2-3 5066 NULL
96426 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
96427 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
96428 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
96429 +kfifo_copy_from_user_5091 kfifo_copy_from_user 3 5091 &get_random_bytes_5091 nohasharray
96430 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
96431 +mpol_to_str_5093 mpol_to_str 2 5093 NULL
96432 +sound_write_5102 sound_write 3 5102 NULL
96433 +clear_dirty_5105 clear_dirty 3 5105 NULL
96434 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
96435 +compat_ptr_5159 compat_ptr 0-1 5159 NULL
96436 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
96437 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
96438 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
96439 +sfi_map_memory_5183 sfi_map_memory 1-2 5183 NULL
96440 +skb_network_header_5203 skb_network_header 0 5203 NULL
96441 +pipe_set_size_5204 pipe_set_size 2 5204 NULL
96442 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL
96443 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
96444 +ssb_ioremap_5228 ssb_ioremap 2 5228 NULL
96445 +isdn_ppp_skb_push_5236 isdn_ppp_skb_push 2 5236 NULL
96446 +do_atmif_sioc_5247 do_atmif_sioc 3 5247 NULL
96447 +gfn_to_hva_memslot_5265 gfn_to_hva_memslot 2 5265 NULL
96448 +alloc_cache_blocks_with_hash_5285 alloc_cache_blocks_with_hash 2 5285 NULL
96449 +__gfn_to_hva_memslot_5304 __gfn_to_hva_memslot 0-2 5304 NULL
96450 +sbc_get_write_same_sectors_5317 sbc_get_write_same_sectors 0 5317 NULL
96451 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
96452 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
96453 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
96454 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 3-2 5368 NULL
96455 +kvm_pin_pages_5369 kvm_pin_pages 2 5369 NULL
96456 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
96457 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
96458 +sfi_map_table_5462 sfi_map_table 1 5462 NULL
96459 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
96460 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
96461 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
96462 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
96463 +tty_write_5494 tty_write 3 5494 NULL
96464 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
96465 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
96466 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
96467 +spidev_message_5518 spidev_message 3 5518 NULL
96468 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
96469 +brcmu_pkt_buf_get_skb_5556 brcmu_pkt_buf_get_skb 1 5556 NULL
96470 +le_readq_5557 le_readq 0 5557 NULL
96471 +inw_5558 inw 0 5558 NULL
96472 +fir16_create_5574 fir16_create 3 5574 NULL
96473 +bioset_create_5580 bioset_create 1 5580 NULL
96474 +oz_ep_alloc_5587 oz_ep_alloc 2 5587 NULL
96475 +usb_dump_device_descriptor_5599 usb_dump_device_descriptor 0 5599 NULL
96476 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
96477 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
96478 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
96479 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
96480 +mthca_map_reg_5664 mthca_map_reg 2-3 5664 NULL
96481 +__videobuf_alloc_vb_5665 __videobuf_alloc_vb 1 5665 NULL
96482 +wb_clear_dirty_5684 wb_clear_dirty 2 5684 NULL
96483 +get_arg_5694 get_arg 3 5694 NULL
96484 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
96485 +reexecute_instruction_5733 reexecute_instruction 2 5733 NULL
96486 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
96487 +ubi_cdev_compat_ioctl_5746 ubi_cdev_compat_ioctl 3 5746 NULL
96488 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL
96489 +compat_sys_writev_5784 compat_sys_writev 3 5784 NULL
96490 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
96491 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
96492 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
96493 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
96494 +autofs4_root_compat_ioctl_5838 autofs4_root_compat_ioctl 3 5838 NULL
96495 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
96496 +ixgb_check_copybreak_5847 ixgb_check_copybreak 3 5847 NULL
96497 +setup_req_5848 setup_req 3 5848 NULL
96498 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
96499 +compat_sys_move_pages_5861 compat_sys_move_pages 2 5861 NULL nohasharray
96500 +uinput_compat_ioctl_5861 uinput_compat_ioctl 3 5861 &compat_sys_move_pages_5861
96501 +paging64_walk_addr_5887 paging64_walk_addr 3 5887 NULL
96502 +port_show_regs_5904 port_show_regs 3 5904 NULL
96503 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
96504 +qla82xx_pci_mem_read_2M_5912 qla82xx_pci_mem_read_2M 2 5912 NULL
96505 +ttm_bo_kmap_ttm_5922 ttm_bo_kmap_ttm 3 5922 NULL
96506 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
96507 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
96508 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
96509 +tipc_subseq_alloc_5957 tipc_subseq_alloc 1 5957 NULL
96510 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
96511 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
96512 +native_pte_val_5978 native_pte_val 0 5978 NULL
96513 +ntfs_rl_append_6037 ntfs_rl_append 2-4 6037 NULL
96514 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL
96515 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
96516 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
96517 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
96518 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
96519 +matrix_keypad_build_keymap_6129 matrix_keypad_build_keymap 3 6129 NULL
96520 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
96521 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
96522 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
96523 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
96524 +paging64_walk_addr_generic_6180 paging64_walk_addr_generic 4 6180 NULL
96525 +qp_host_get_user_memory_6189 qp_host_get_user_memory 1-2 6189 NULL
96526 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
96527 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
96528 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
96529 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
96530 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
96531 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
96532 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
96533 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 3 6282 NULL nohasharray
96534 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
96535 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
96536 +paging64_gva_to_gpa_nested_6287 paging64_gva_to_gpa_nested 2 6287 NULL
96537 +nf_nat_ipv6_manip_pkt_6289 nf_nat_ipv6_manip_pkt 2 6289 NULL
96538 +nf_nat_sack_adjust_6297 nf_nat_sack_adjust 2 6297 NULL
96539 +mid_get_vbt_data_r10_6308 mid_get_vbt_data_r10 2 6308 NULL
96540 +ucs2_strnlen_6342 ucs2_strnlen 0 6342 NULL
96541 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
96542 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
96543 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
96544 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
96545 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2-3 6432 NULL
96546 +paging32_gva_to_gpa_nested_6442 paging32_gva_to_gpa_nested 2 6442 NULL
96547 +mlx4_ib_reg_user_mr_6471 mlx4_ib_reg_user_mr 2-3 6471 NULL nohasharray
96548 +ext4_compat_ioctl_6471 ext4_compat_ioctl 3 6471 &mlx4_ib_reg_user_mr_6471
96549 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
96550 +qp_memcpy_from_queue_6479 qp_memcpy_from_queue 4-5 6479 NULL
96551 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
96552 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
96553 +mei_read_6507 mei_read 3 6507 NULL
96554 +read_file_disable_ani_6536 read_file_disable_ani 3 6536 NULL
96555 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
96556 +wdm_read_6549 wdm_read 3 6549 NULL
96557 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
96558 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
96559 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
96560 +virtscsi_alloc_tgt_6643 virtscsi_alloc_tgt 2 6643 NULL
96561 +aac_srcv_ioremap_6659 aac_srcv_ioremap 2 6659 NULL
96562 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
96563 +ql_process_mac_rx_skb_6689 ql_process_mac_rx_skb 4 6689 NULL
96564 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2 6696 NULL
96565 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
96566 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
96567 +mpeg_read_6708 mpeg_read 3 6708 NULL
96568 +set_orig_insn_6712 set_orig_insn 3 6712 NULL
96569 +video_proc_write_6724 video_proc_write 3 6724 NULL
96570 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
96571 +rds_rdma_pages_6735 rds_rdma_pages 0 6735 NULL
96572 +sfi_check_table_6772 sfi_check_table 1 6772 NULL
96573 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
96574 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
96575 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
96576 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
96577 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
96578 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
96579 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
96580 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
96581 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
96582 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
96583 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
96584 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
96585 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
96586 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
96587 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
96588 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
96589 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
96590 +qsfp_cks_6945 qsfp_cks 0-2 6945 NULL
96591 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
96592 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
96593 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 NULL
96594 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
96595 +request_key_async_6990 request_key_async 4 6990 NULL
96596 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
96597 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
96598 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
96599 +wimax_msg_7030 wimax_msg 4 7030 NULL
96600 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
96601 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
96602 +event_enable_read_7074 event_enable_read 3 7074 NULL
96603 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
96604 +lp_compat_ioctl_7098 lp_compat_ioctl 3 7098 NULL
96605 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
96606 +check_header_7108 check_header 0 7108 NULL
96607 +qlcnic_enable_msix_7144 qlcnic_enable_msix 2 7144 NULL
96608 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 NULL
96609 +sys32_ipc_7238 sys32_ipc 3-5-6 7238 NULL
96610 +get_param_h_7247 get_param_h 0 7247 NULL
96611 +af_alg_make_sg_7254 af_alg_make_sg 3 7254 NULL
96612 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
96613 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5 7272 NULL
96614 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
96615 +wb_remove_mapping_7307 wb_remove_mapping 2 7307 NULL
96616 +mgmt_control_7349 mgmt_control 3 7349 NULL
96617 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 NULL
96618 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
96619 +hweight_long_7388 hweight_long 0-1 7388 NULL
96620 +vhost_scsi_compat_ioctl_7393 vhost_scsi_compat_ioctl 3 7393 NULL
96621 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
96622 +readb_7401 readb 0 7401 NULL
96623 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
96624 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
96625 +numa_emulation_7466 numa_emulation 2 7466 NULL
96626 +__mutex_lock_common_7469 __mutex_lock_common 0 7469 NULL
96627 +garp_request_join_7471 garp_request_join 4 7471 NULL
96628 +compat_sys_msgrcv_7482 compat_sys_msgrcv 2 7482 NULL
96629 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
96630 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
96631 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
96632 +array_zalloc_7519 array_zalloc 1-2 7519 NULL
96633 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
96634 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
96635 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3 7590 NULL
96636 +groups_alloc_7614 groups_alloc 1 7614 NULL
96637 +sg_virt_7616 sg_virt 0 7616 NULL
96638 +skb_copy_expand_7685 skb_copy_expand 2-3 7685 NULL nohasharray
96639 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 2-1 7685 &skb_copy_expand_7685
96640 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
96641 +dev_write_7708 dev_write 3 7708 NULL
96642 +brcmf_sdcard_send_buf_7713 brcmf_sdcard_send_buf 6 7713 NULL
96643 +set_bypass_pwup_pfs_7742 set_bypass_pwup_pfs 3 7742 NULL
96644 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
96645 +osdv2_attr_list_elem_size_7763 osdv2_attr_list_elem_size 0-1 7763 NULL
96646 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
96647 +ioread32be_7773 ioread32be 0 7773 NULL
96648 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
96649 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
96650 +bnx2_nvram_write_7790 bnx2_nvram_write 4-2 7790 NULL
96651 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL
96652 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
96653 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
96654 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
96655 +gfs2_tune_get_i_7903 gfs2_tune_get_i 0 7903 NULL
96656 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
96657 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
96658 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
96659 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
96660 +integrity_digsig_verify_7956 integrity_digsig_verify 3 7956 NULL
96661 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
96662 +sys_mbind_7990 sys_mbind 5 7990 NULL
96663 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
96664 +vcs_read_8017 vcs_read 3 8017 NULL
96665 +normalize_up_8037 normalize_up 0-1-2 8037 NULL
96666 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
96667 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
96668 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
96669 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
96670 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
96671 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
96672 +venus_lookup_8121 venus_lookup 4 8121 NULL
96673 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
96674 +dma_map_area_8178 dma_map_area 5-2-3 8178 NULL
96675 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
96676 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
96677 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
96678 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
96679 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
96680 +play_iframe_8219 play_iframe 3 8219 NULL
96681 +create_log_8225 create_log 2 8225 NULL nohasharray
96682 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
96683 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
96684 +bnx2x_iov_get_max_queue_count_8235 bnx2x_iov_get_max_queue_count 0 8235 NULL
96685 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
96686 +add_rx_skb_8257 add_rx_skb 3 8257 NULL
96687 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
96688 +init_cdev_8274 init_cdev 1 8274 NULL
96689 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
96690 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
96691 +construct_key_and_link_8321 construct_key_and_link 4 8321 NULL
96692 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
96693 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
96694 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
96695 +ping_getfrag_8360 ping_getfrag 4-3 8360 NULL
96696 +uvc_v4l2_compat_ioctl32_8375 uvc_v4l2_compat_ioctl32 3 8375 NULL
96697 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
96698 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
96699 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 NULL
96700 +pca953x_gpio_to_irq_8424 pca953x_gpio_to_irq 2 8424 NULL
96701 +snd_usb_ctl_msg_8436 snd_usb_ctl_msg 8 8436 NULL
96702 +irq_create_mapping_8437 irq_create_mapping 2 8437 NULL
96703 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
96704 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
96705 +dev_config_8506 dev_config 3 8506 NULL
96706 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
96707 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
96708 +pnp_resource_len_8532 pnp_resource_len 0 8532 NULL
96709 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
96710 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
96711 +profile_remove_8556 profile_remove 3 8556 NULL
96712 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
96713 +mga_ioremap_8571 mga_ioremap 1-2 8571 NULL
96714 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
96715 +tower_write_8580 tower_write 3 8580 NULL
96716 +rtllib_MFIE_rate_len_8606 rtllib_MFIE_rate_len 0 8606 NULL
96717 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
96718 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
96719 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
96720 +fuse_send_write_pages_8636 fuse_send_write_pages 0 8636 NULL
96721 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
96722 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
96723 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
96724 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
96725 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
96726 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
96727 +arcfb_write_8702 arcfb_write 3 8702 NULL
96728 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
96729 +init_header_8703 init_header 0 8703 &i_size_read_8703
96730 +ctrl_out_8712 ctrl_out 3-5 8712 NULL
96731 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL
96732 +f_dupfd_8730 f_dupfd 1 8730 NULL
96733 +__create_irqs_8733 __create_irqs 2-1 8733 NULL
96734 +pca953x_gpio_irq_map_8737 pca953x_gpio_irq_map 2 8737 NULL
96735 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
96736 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
96737 +sys_prctl_8766 sys_prctl 4 8766 NULL
96738 +x32_arch_ptrace_8767 x32_arch_ptrace 3-4 8767 NULL
96739 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
96740 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
96741 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
96742 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
96743 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
96744 +icmpv6_manip_pkt_8833 icmpv6_manip_pkt 4 8833 NULL nohasharray
96745 +get_queue_depth_8833 get_queue_depth 0 8833 &icmpv6_manip_pkt_8833
96746 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
96747 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
96748 +clear_bitset_8840 clear_bitset 2 8840 NULL
96749 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
96750 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
96751 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
96752 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 NULL
96753 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
96754 +layout_commit_8926 layout_commit 3 8926 NULL
96755 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
96756 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
96757 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
96758 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
96759 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
96760 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
96761 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
96762 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
96763 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
96764 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
96765 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
96766 +__pskb_copy_9038 __pskb_copy 2 9038 NULL
96767 +nla_put_9042 nla_put 3 9042 NULL
96768 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 3-5 9061 NULL
96769 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
96770 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
96771 +string_9080 string 0 9080 NULL
96772 +create_queues_9088 create_queues 2-3 9088 NULL
96773 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
96774 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
96775 +gfn_to_rmap_9110 gfn_to_rmap 2-3 9110 &caif_stream_sendmsg_9110
96776 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
96777 +mq_remove_mapping_9124 mq_remove_mapping 2 9124 NULL
96778 +mlx4_alloc_resize_umem_9132 mlx4_alloc_resize_umem 3 9132 NULL
96779 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
96780 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
96781 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
96782 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
96783 +alloc_group_attrs_9194 alloc_group_attrs 2 9194 NULL nohasharray
96784 +altera_swap_ir_9194 altera_swap_ir 2 9194 &alloc_group_attrs_9194
96785 +gx1_gx_base_9198 gx1_gx_base 0 9198 NULL
96786 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
96787 +get_pfn_9207 get_pfn 1 9207 NULL
96788 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
96789 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
96790 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4 9256 NULL
96791 +tcf_csum_ipv4_icmp_9258 tcf_csum_ipv4_icmp 3 9258 NULL
96792 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
96793 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
96794 +flakey_status_9274 flakey_status 5 9274 NULL
96795 +qla82xx_pci_set_window_9303 qla82xx_pci_set_window 0-2 9303 NULL
96796 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
96797 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
96798 +memblock_find_in_range_node_9328 memblock_find_in_range_node 0-3-4 9328 NULL
96799 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
96800 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
96801 +read_9397 read 3 9397 NULL
96802 +nf_nat_sip_expect_9418 nf_nat_sip_expect 8 9418 NULL
96803 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
96804 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
96805 +kmalloc_array_9444 kmalloc_array 1-2 9444 NULL
96806 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
96807 +mcs_unwrap_mir_9455 mcs_unwrap_mir 3 9455 NULL
96808 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
96809 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL
96810 +__alloc_preds_9492 __alloc_preds 2 9492 NULL nohasharray
96811 +crypt_status_9492 crypt_status 5 9492 &__alloc_preds_9492
96812 +lp_write_9511 lp_write 3 9511 NULL
96813 +xen_remap_exchanged_ptes_9513 xen_remap_exchanged_ptes 1 9513 NULL
96814 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
96815 +read_file_dma_9530 read_file_dma 3 9530 NULL
96816 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
96817 +audit_log_n_untrustedstring_9548 audit_log_n_untrustedstring 3 9548 NULL
96818 +fw_node_create_9559 fw_node_create 2 9559 NULL
96819 +ipath_get_user_pages_9561 ipath_get_user_pages 1-2 9561 NULL
96820 +kobj_map_9566 kobj_map 2-3 9566 NULL
96821 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
96822 +biovec_create_pools_9575 biovec_create_pools 2 9575 NULL
96823 +ieee80211_tdls_mgmt_9581 ieee80211_tdls_mgmt 8 9581 NULL
96824 +do_sync_9604 do_sync 1 9604 NULL
96825 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
96826 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
96827 +ceph_copy_user_to_page_vector_9635 ceph_copy_user_to_page_vector 4-3 9635 NULL
96828 +compat_sys_keyctl_9639 compat_sys_keyctl 4-2-3 9639 NULL
96829 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
96830 +uvc_alloc_buffers_9656 uvc_alloc_buffers 2-3 9656 NULL
96831 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
96832 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
96833 +ks8842_read16_9676 ks8842_read16 0 9676 NULL nohasharray
96834 +dns_query_9676 dns_query 3 9676 &ks8842_read16_9676
96835 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
96836 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
96837 +is_hole_9694 is_hole 2 9694 NULL nohasharray
96838 +x25_asy_compat_ioctl_9694 x25_asy_compat_ioctl 4 9694 &is_hole_9694
96839 +fnb_9703 fnb 2-3 9703 NULL
96840 +fuse_iter_npages_9705 fuse_iter_npages 0 9705 NULL nohasharray
96841 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 &fuse_iter_npages_9705
96842 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
96843 +ddb_input_read_9743 ddb_input_read 3 9743 NULL
96844 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
96845 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
96846 +__alloc_percpu_9764 __alloc_percpu 1-2 9764 NULL
96847 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
96848 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
96849 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
96850 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 NULL
96851 +pnp_mem_start_9817 pnp_mem_start 0 9817 NULL
96852 +kernel_physical_mapping_init_9818 kernel_physical_mapping_init 0-2-1 9818 NULL
96853 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
96854 +cfg80211_send_deauth_9862 cfg80211_send_deauth 3 9862 NULL
96855 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
96856 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
96857 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
96858 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
96859 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
96860 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
96861 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
96862 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 3-5 9895 NULL
96863 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
96864 +gen6_get_total_gtt_size_9913 gen6_get_total_gtt_size 0-1 9913 NULL
96865 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
96866 +read_file_misc_9948 read_file_misc 3 9948 NULL
96867 +set_rxd_buffer_pointer_9950 set_rxd_buffer_pointer 8 9950 NULL
96868 +ext2_new_blocks_9954 ext2_new_blocks 2 9954 NULL
96869 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 3-4 9957 NULL
96870 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
96871 +btrfs_add_link_9973 btrfs_add_link 5 9973 NULL
96872 +ath6kl_usb_submit_ctrl_out_9978 ath6kl_usb_submit_ctrl_out 6 9978 NULL
96873 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
96874 +handle_request_10024 handle_request 9 10024 NULL
96875 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
96876 +ieee80211_probereq_get_10040 ieee80211_probereq_get 4-5 10040 NULL
96877 +xen_destroy_contiguous_region_10054 xen_destroy_contiguous_region 1 10054 NULL
96878 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
96879 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
96880 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
96881 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
96882 +jbd_alloc_10112 jbd_alloc 0 10112 NULL nohasharray
96883 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 &jbd_alloc_10112
96884 +offset_to_bit_10134 offset_to_bit 0 10134 NULL
96885 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
96886 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
96887 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
96888 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
96889 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
96890 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
96891 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
96892 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
96893 +do_ioctl_trans_10194 do_ioctl_trans 3 10194 NULL
96894 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
96895 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
96896 +ubi_leb_change_10289 ubi_leb_change 4 10289 NULL
96897 +read_emulate_10310 read_emulate 2-4 10310 NULL
96898 +read_file_spectral_count_10320 read_file_spectral_count 3 10320 NULL
96899 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
96900 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
96901 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
96902 +get_dump_page_10338 get_dump_page 1 10338 NULL
96903 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
96904 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
96905 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
96906 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
96907 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
96908 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
96909 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
96910 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
96911 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
96912 +ca91cx42_alloc_resource_10502 ca91cx42_alloc_resource 2 10502 NULL
96913 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
96914 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
96915 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
96916 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
96917 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
96918 +get_vm_area_caller_10527 get_vm_area_caller 1 10527 NULL
96919 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL
96920 +ieee80211_send_probe_req_10539 ieee80211_send_probe_req 4-6 10539 NULL
96921 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
96922 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
96923 +otp_read_10594 otp_read 2-4-5 10594 NULL
96924 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
96925 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
96926 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
96927 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 NULL
96928 +parport_write_10669 parport_write 0 10669 NULL
96929 +inl_10708 inl 0 10708 NULL nohasharray
96930 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
96931 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
96932 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
96933 +spi_sync_10731 spi_sync 0 10731 NULL
96934 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
96935 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
96936 +compat_sys_msgsnd_10738 compat_sys_msgsnd 2 10738 NULL
96937 +sys_syslog_10746 sys_syslog 3 10746 NULL
96938 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
96939 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
96940 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 4-2 10765 NULL
96941 +wb_set_dirty_10778 wb_set_dirty 2 10778 NULL
96942 +__qp_memcpy_to_queue_10779 __qp_memcpy_to_queue 2-4 10779 NULL
96943 +sys_bind_10799 sys_bind 3 10799 NULL
96944 +compat_put_int_10828 compat_put_int 1 10828 NULL
96945 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
96946 +ida_get_new_above_10853 ida_get_new_above 2 10853 NULL
96947 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
96948 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
96949 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
96950 +mid_get_vbt_data_r0_10876 mid_get_vbt_data_r0 2 10876 NULL
96951 +bl_mark_for_commit_10879 bl_mark_for_commit 2-3 10879 NULL
96952 +get_scq_10897 get_scq 2 10897 NULL
96953 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
96954 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
96955 +__copy_from_user_10918 __copy_from_user 3 10918 NULL
96956 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
96957 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
96958 +i915_min_freq_write_10981 i915_min_freq_write 3 10981 NULL
96959 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
96960 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
96961 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
96962 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
96963 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
96964 +mb_find_next_bit_11037 mb_find_next_bit 2-3-0 11037 NULL
96965 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
96966 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
96967 +count_argc_11083 count_argc 0 11083 NULL
96968 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
96969 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
96970 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
96971 +page_offset_11120 page_offset 0 11120 NULL
96972 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL
96973 +acpi_os_map_memory_11161 acpi_os_map_memory 1-2 11161 NULL
96974 +ioat2_alloc_ring_11172 ioat2_alloc_ring 2 11172 NULL nohasharray
96975 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 3-4 11172 &ioat2_alloc_ring_11172
96976 +__swab16p_11220 __swab16p 0 11220 NULL
96977 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
96978 +mmap_region_11247 mmap_region 0-2 11247 NULL
96979 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
96980 +dm_cache_discard_bitset_resize_11262 dm_cache_discard_bitset_resize 3 11262 NULL
96981 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
96982 +cru_detect_11272 cru_detect 1 11272 NULL
96983 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
96984 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 NULL
96985 +construct_key_11329 construct_key 3 11329 NULL nohasharray
96986 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
96987 +next_segment_11330 next_segment 0-2-1 11330 NULL
96988 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 1-2 11332 NULL
96989 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
96990 +i915_max_freq_write_11350 i915_max_freq_write 3 11350 NULL
96991 +sel_write_create_11353 sel_write_create 3 11353 NULL
96992 +handle_unit_11355 handle_unit 0-1 11355 NULL
96993 +batadv_skb_head_push_11360 batadv_skb_head_push 2 11360 NULL
96994 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
96995 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
96996 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
96997 +___alloc_bootmem_11410 ___alloc_bootmem 1-2 11410 NULL
96998 +str_to_user_11411 str_to_user 2 11411 NULL
96999 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
97000 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
97001 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
97002 +trace_options_read_11419 trace_options_read 3 11419 NULL
97003 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 NULL
97004 +prepare_image_11424 prepare_image 0 11424 NULL
97005 +vring_size_11426 vring_size 0-1-2 11426 NULL
97006 +bttv_read_11432 bttv_read 3 11432 NULL
97007 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
97008 +swp_offset_11475 swp_offset 0 11475 NULL
97009 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 NULL
97010 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
97011 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
97012 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
97013 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
97014 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
97015 +skb_cow_data_11565 skb_cow_data 0-2 11565 NULL
97016 +mlx4_init_cmpt_table_11569 mlx4_init_cmpt_table 3 11569 NULL
97017 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
97018 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
97019 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
97020 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
97021 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
97022 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
97023 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
97024 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
97025 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
97026 +split_11691 split 2 11691 NULL
97027 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
97028 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
97029 +tcf_csum_ipv6_icmp_11738 tcf_csum_ipv6_icmp 4 11738 NULL
97030 +nfsd4_get_drc_mem_11748 nfsd4_get_drc_mem 0-1-2 11748 NULL
97031 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
97032 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
97033 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
97034 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
97035 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
97036 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2-3 11818 NULL
97037 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
97038 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
97039 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
97040 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
97041 +nf_nat_sdp_media_11863 nf_nat_sdp_media 9 11863 NULL
97042 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
97043 +ieee80211_rx_bss_info_11887 ieee80211_rx_bss_info 3 11887 NULL
97044 +kmalloc_slab_11917 kmalloc_slab 1 11917 NULL
97045 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
97046 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
97047 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
97048 +dccp_feat_clone_sp_val_11942 dccp_feat_clone_sp_val 3 11942 NULL
97049 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
97050 +atmel_read16_11981 atmel_read16 0 11981 NULL
97051 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
97052 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
97053 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
97054 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
97055 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
97056 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
97057 +pse36_gfn_delta_12087 pse36_gfn_delta 0-1 12087 NULL
97058 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
97059 +set_powered_12129 set_powered 4 12129 NULL
97060 +nfs_writedata_alloc_12133 nfs_writedata_alloc 2 12133 NULL
97061 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
97062 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
97063 +batadv_add_packet_12136 batadv_add_packet 3 12136 NULL
97064 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
97065 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
97066 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
97067 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
97068 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
97069 +wil_rxdesc_phy_length_12165 wil_rxdesc_phy_length 0 12165 NULL
97070 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
97071 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
97072 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
97073 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
97074 +bl_is_sector_init_12199 bl_is_sector_init 2 12199 NULL
97075 +free_initrd_mem_12203 free_initrd_mem 1 12203 NULL
97076 +receive_copy_12216 receive_copy 3 12216 NULL
97077 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
97078 +fuse_get_req_12221 fuse_get_req 2 12221 NULL nohasharray
97079 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 &fuse_get_req_12221
97080 +__alloc_bootmem_low_nopanic_12235 __alloc_bootmem_low_nopanic 1-2 12235 NULL
97081 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
97082 +ath_descdma_setup_12257 ath_descdma_setup 5 12257 NULL
97083 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
97084 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
97085 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
97086 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
97087 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
97088 +vxge_get_num_vfs_12302 vxge_get_num_vfs 0 12302 NULL
97089 +tipc_msg_build_12326 tipc_msg_build 4 12326 NULL
97090 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
97091 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
97092 +paging32_walk_addr_12359 paging32_walk_addr 3 12359 NULL
97093 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
97094 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
97095 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL
97096 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
97097 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
97098 +qla4_82xx_pci_mem_write_direct_12479 qla4_82xx_pci_mem_write_direct 2 12479 NULL
97099 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
97100 +rtllib_auth_challenge_12493 rtllib_auth_challenge 3 12493 NULL
97101 +fnic_trace_ctrl_read_12497 fnic_trace_ctrl_read 3 12497 NULL
97102 +nfs_readdir_make_qstr_12509 nfs_readdir_make_qstr 3 12509 NULL
97103 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
97104 +kvm_setup_async_pf_12555 kvm_setup_async_pf 3 12555 NULL
97105 +ib_umem_get_12557 ib_umem_get 2-3 12557 NULL
97106 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
97107 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
97108 +macvtap_compat_ioctl_12587 macvtap_compat_ioctl 3 12587 NULL
97109 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
97110 +ipv6_get_l4proto_12600 ipv6_get_l4proto 2 12600 NULL
97111 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
97112 +fc_fcp_frame_alloc_12624 fc_fcp_frame_alloc 2 12624 NULL
97113 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
97114 +ctrl_cdev_compat_ioctl_12634 ctrl_cdev_compat_ioctl 3 12634 NULL
97115 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
97116 +wb_create_12651 wb_create 1 12651 NULL
97117 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
97118 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
97119 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
97120 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
97121 +ivtv_write_12721 ivtv_write 3 12721 NULL
97122 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
97123 +__videobuf_alloc_cached_12740 __videobuf_alloc_cached 1 12740 NULL
97124 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
97125 +listxattr_12769 listxattr 3 12769 NULL
97126 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
97127 +ieee80211_rx_mgmt_beacon_12780 ieee80211_rx_mgmt_beacon 3 12780 NULL
97128 +platform_create_bundle_12785 platform_create_bundle 4-6 12785 NULL
97129 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
97130 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
97131 +readq_12825 readq 0 12825 NULL
97132 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
97133 +spidev_sync_12842 spidev_sync 0 12842 NULL nohasharray
97134 +ath6kl_wmi_add_wow_pattern_cmd_12842 ath6kl_wmi_add_wow_pattern_cmd 4 12842 &spidev_sync_12842
97135 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
97136 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
97137 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
97138 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
97139 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
97140 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
97141 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
97142 +bm_status_write_12964 bm_status_write 3 12964 NULL
97143 +_drbd_md_first_sector_12984 _drbd_md_first_sector 0 12984 NULL
97144 +raid56_parity_recover_12987 raid56_parity_recover 5 12987 NULL
97145 +acpi_tb_install_table_12988 acpi_tb_install_table 1 12988 NULL
97146 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
97147 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
97148 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
97149 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
97150 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
97151 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 NULL
97152 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
97153 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
97154 +blk_rq_map_sg_13092 blk_rq_map_sg 0 13092 NULL
97155 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3 13100 NULL
97156 +ubifs_compat_ioctl_13108 ubifs_compat_ioctl 3 13108 NULL
97157 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
97158 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
97159 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
97160 +blk_update_request_13146 blk_update_request 3 13146 NULL
97161 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
97162 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
97163 +ucs2_strlen_13178 ucs2_strlen 0 13178 NULL
97164 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
97165 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
97166 +compat_put_ulong_13186 compat_put_ulong 1 13186 NULL
97167 +__cmpxchg64_13187 __cmpxchg64 0 13187 NULL
97168 +comedi_read_13199 comedi_read 3 13199 NULL
97169 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
97170 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
97171 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
97172 +fnic_trace_ctrl_write_13229 fnic_trace_ctrl_write 3 13229 NULL
97173 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
97174 +fw_download_code_13249 fw_download_code 3 13249 NULL nohasharray
97175 +kvm_lapic_enable_pv_eoi_13249 kvm_lapic_enable_pv_eoi 2 13249 &fw_download_code_13249
97176 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
97177 +hostap_80211_get_hdrlen_13255 hostap_80211_get_hdrlen 0 13255 NULL
97178 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
97179 +c4iw_reg_user_mr_13269 c4iw_reg_user_mr 2-3 13269 NULL
97180 +carl9170_rx_13272 carl9170_rx 3 13272 NULL
97181 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
97182 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
97183 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
97184 +platform_device_add_resources_13289 platform_device_add_resources 3 13289 NULL
97185 +i915_drop_caches_write_13308 i915_drop_caches_write 3 13308 NULL
97186 +us122l_ctl_msg_13330 us122l_ctl_msg 8 13330 NULL
97187 +__clone_and_map_data_bio_13334 __clone_and_map_data_bio 4-8 13334 NULL
97188 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5-2 13337 NULL
97189 +cache_ctr_13364 cache_ctr 2 13364 NULL
97190 +mthca_alloc_mtt_range_13371 mthca_alloc_mtt_range 2 13371 NULL
97191 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
97192 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
97193 +carl9170_rx_untie_data_13405 carl9170_rx_untie_data 3 13405 NULL
97194 +sky2_receive_13407 sky2_receive 2 13407 NULL
97195 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
97196 +keyring_read_13438 keyring_read 3 13438 NULL
97197 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL nohasharray
97198 +set_tap_pwup_pfs_13440 set_tap_pwup_pfs 3 13440 &sctp_setsockopt_peer_primary_addr_13440
97199 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 8-9-7 13443 NULL
97200 +mthca_buddy_alloc_13454 mthca_buddy_alloc 2 13454 NULL
97201 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2 13512 NULL
97202 +core_status_13515 core_status 4 13515 NULL
97203 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
97204 +bm_init_13529 bm_init 2 13529 NULL
97205 +non_atomic_pte_lookup_13540 non_atomic_pte_lookup 2 13540 NULL
97206 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
97207 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
97208 +sys_madvise_13569 sys_madvise 1 13569 NULL
97209 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
97210 +cache_write_13589 cache_write 3 13589 NULL
97211 +mpt_lan_receive_post_turbo_13592 mpt_lan_receive_post_turbo 2 13592 NULL
97212 +aac_sa_ioremap_13596 aac_sa_ioremap 2 13596 NULL nohasharray
97213 +irias_new_octseq_value_13596 irias_new_octseq_value 2 13596 &aac_sa_ioremap_13596
97214 +usb_dump_interface_descriptor_13603 usb_dump_interface_descriptor 0 13603 NULL
97215 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
97216 +wm8994_bulk_write_13615 wm8994_bulk_write 2-3 13615 NULL
97217 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
97218 +iio_device_add_event_sysfs_13627 iio_device_add_event_sysfs 0 13627 NULL
97219 +packet_snd_13634 packet_snd 3 13634 NULL
97220 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
97221 +cache_downcall_13666 cache_downcall 3 13666 NULL
97222 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
97223 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
97224 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
97225 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
97226 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
97227 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
97228 +random_read_13815 random_read 3 13815 NULL
97229 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
97230 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2-3 13851 NULL
97231 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL nohasharray
97232 +alloc_trace_uprobe_13870 alloc_trace_uprobe 3 13870 &compat_ip_setsockopt_13870
97233 +qp_memcpy_to_queue_13886 qp_memcpy_to_queue 2-5 13886 NULL
97234 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
97235 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
97236 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
97237 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
97238 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
97239 +compat_chaninfo_13945 compat_chaninfo 2 13945 NULL
97240 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
97241 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
97242 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
97243 +com90xx_found_13974 com90xx_found 3 13974 NULL
97244 +qcam_read_13977 qcam_read 3 13977 NULL
97245 +dsp_read_13980 dsp_read 2 13980 NULL
97246 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
97247 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
97248 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
97249 +_rtl92s_firmware_downloadcode_14021 _rtl92s_firmware_downloadcode 3 14021 NULL
97250 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
97251 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
97252 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
97253 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
97254 +i915_drop_caches_read_14060 i915_drop_caches_read 3 14060 NULL
97255 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
97256 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
97257 +nlmsg_len_14115 nlmsg_len 0 14115 NULL
97258 +vfio_fops_compat_ioctl_14130 vfio_fops_compat_ioctl 3 14130 NULL
97259 +ntfs_rl_replace_14136 ntfs_rl_replace 2-4 14136 NULL
97260 +em_canid_change_14150 em_canid_change 3 14150 NULL
97261 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
97262 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
97263 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
97264 +alloc_async_14208 alloc_async 1 14208 NULL
97265 +sys_kexec_load_14222 sys_kexec_load 2 14222 NULL
97266 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
97267 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4-2 14244 NULL
97268 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 2-4 14245 NULL
97269 +reiserfs_compat_ioctl_14265 reiserfs_compat_ioctl 3 14265 NULL
97270 +ath6kl_connect_event_14267 ath6kl_connect_event 8-9-7 14267 NULL
97271 +add_numbered_child_14273 add_numbered_child 5 14273 NULL
97272 +OS_mem_token_alloc_14276 OS_mem_token_alloc 1 14276 NULL
97273 +snd_seq_oss_readq_new_14283 snd_seq_oss_readq_new 2 14283 NULL
97274 +rr_status_14293 rr_status 5 14293 NULL
97275 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
97276 +oo_objects_14319 oo_objects 0 14319 NULL
97277 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
97278 +scsi2int_14358 scsi2int 0 14358 NULL
97279 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
97280 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
97281 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
97282 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
97283 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
97284 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
97285 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
97286 +block_size_14443 block_size 0 14443 NULL
97287 +ci13xxx_add_device_14456 ci13xxx_add_device 3 14456 NULL
97288 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
97289 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
97290 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 NULL
97291 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
97292 +dataflash_read_user_otp_14536 dataflash_read_user_otp 2-3 14536 NULL nohasharray
97293 +ep0_write_14536 ep0_write 3 14536 &dataflash_read_user_otp_14536
97294 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
97295 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
97296 +usb_dump_desc_14553 usb_dump_desc 0 14553 NULL
97297 +qp_host_alloc_queue_14566 qp_host_alloc_queue 1 14566 NULL
97298 +remap_to_origin_then_cache_14583 remap_to_origin_then_cache 3 14583 NULL
97299 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
97300 +ceph_osdc_alloc_request_14597 ceph_osdc_alloc_request 3 14597 NULL
97301 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
97302 +dbJoin_14644 dbJoin 0 14644 NULL
97303 +profile_replace_14652 profile_replace 3 14652 NULL
97304 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
97305 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
97306 +tsi148_master_set_14685 tsi148_master_set 4 14685 NULL
97307 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
97308 +get_bio_block_14714 get_bio_block 0 14714 NULL
97309 +vfd_write_14717 vfd_write 3 14717 NULL
97310 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
97311 +raid1_resize_14740 raid1_resize 2 14740 NULL
97312 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
97313 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
97314 +qla82xx_pci_mem_write_2M_14765 qla82xx_pci_mem_write_2M 2 14765 NULL
97315 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
97316 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
97317 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
97318 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
97319 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
97320 +bcma_scan_read32_14802 bcma_scan_read32 0 14802 NULL
97321 +__mutex_fastpath_lock_retval_14844 __mutex_fastpath_lock_retval 0 14844 NULL
97322 +mrp_attr_create_14853 mrp_attr_create 3 14853 NULL
97323 +lcd_write_14857 lcd_write 3 14857 NULL nohasharray
97324 +__krealloc_14857 __krealloc 2 14857 &lcd_write_14857
97325 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
97326 +sriov_enable_migration_14889 sriov_enable_migration 2 14889 NULL
97327 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
97328 +unifi_read_14899 unifi_read 3 14899 NULL
97329 +krealloc_14908 krealloc 2 14908 NULL
97330 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2 14910 NULL
97331 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL nohasharray
97332 +qp_memcpy_to_queue_iov_14923 qp_memcpy_to_queue_iov 2-5 14923 &__arch_hweight64_14923
97333 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
97334 +queue_cnt_14951 queue_cnt 0 14951 NULL
97335 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
97336 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
97337 +setkey_14987 setkey 3 14987 NULL nohasharray
97338 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
97339 +vmap_15025 vmap 2 15025 NULL
97340 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
97341 +irq_get_next_irq_15053 irq_get_next_irq 1 15053 NULL
97342 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
97343 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
97344 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
97345 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5 15072 NULL
97346 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
97347 +start_port_15124 start_port 0 15124 NULL
97348 +memchr_15126 memchr 0 15126 NULL
97349 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
97350 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
97351 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
97352 +reserve_resources_15194 reserve_resources 3 15194 NULL
97353 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
97354 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
97355 +compat_raw_ioctl_15290 compat_raw_ioctl 3 15290 NULL
97356 +sys_connect_15291 sys_connect 3 15291 NULL nohasharray
97357 +xlate_dev_mem_ptr_15291 xlate_dev_mem_ptr 1 15291 &sys_connect_15291
97358 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
97359 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
97360 +tpm_tis_init_15304 tpm_tis_init 2-3 15304 NULL
97361 +fcoe_ctlr_send_keep_alive_15308 fcoe_ctlr_send_keep_alive 3 15308 NULL
97362 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-5-3 15330 NULL
97363 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
97364 +ioread16_15342 ioread16 0 15342 NULL
97365 +alloc_ring_15345 alloc_ring 2-4 15345 NULL
97366 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
97367 +graph_depth_read_15371 graph_depth_read 3 15371 NULL
97368 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
97369 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
97370 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
97371 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
97372 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
97373 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
97374 +get_modalias_15406 get_modalias 2 15406 NULL
97375 +dm_cache_resize_15422 dm_cache_resize 2 15422 NULL
97376 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4 15423 NULL
97377 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 2 15438 NULL
97378 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
97379 +memweight_15450 memweight 2 15450 NULL
97380 +vmalloc_15464 vmalloc 1 15464 NULL
97381 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
97382 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
97383 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
97384 +ql_process_mac_rx_page_15543 ql_process_mac_rx_page 4 15543 NULL
97385 +ieee80211_amsdu_to_8023s_15561 ieee80211_amsdu_to_8023s 5 15561 NULL
97386 +persistent_status_15574 persistent_status 4 15574 NULL
97387 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
97388 +vme_user_write_15587 vme_user_write 3 15587 NULL
97389 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7 15595 NULL
97390 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
97391 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
97392 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
97393 +set_dis_tap_pfs_15621 set_dis_tap_pfs 3 15621 NULL
97394 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
97395 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 2-4 15642 NULL nohasharray
97396 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
97397 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
97398 +fs_path_add_15648 fs_path_add 3 15648 NULL
97399 +xsd_read_15653 xsd_read 3 15653 NULL
97400 +compat_sys_fcntl_15654 compat_sys_fcntl 3 15654 NULL
97401 +unix_bind_15668 unix_bind 3 15668 NULL
97402 +dm_read_15674 dm_read 3 15674 NULL
97403 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
97404 +uf_sme_queue_message_15697 uf_sme_queue_message 3 15697 NULL
97405 +ocfs2_split_tree_15716 ocfs2_split_tree 5 15716 NULL
97406 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
97407 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1 15762 NULL
97408 +do_test_15766 do_test 1 15766 NULL
97409 +set_std_nic_pfs_15792 set_std_nic_pfs 3 15792 NULL
97410 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
97411 +snd_pcm_ioctl_compat_15804 snd_pcm_ioctl_compat 3 15804 NULL
97412 +gx1_read_conf_reg_15817 gx1_read_conf_reg 0 15817 NULL nohasharray
97413 +nameseq_list_15817 nameseq_list 3 15817 &gx1_read_conf_reg_15817 nohasharray
97414 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
97415 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL
97416 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
97417 +table_size_15851 table_size 0-1-2 15851 NULL
97418 +ubi_io_write_15870 ubi_io_write 5-4 15870 NULL nohasharray
97419 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
97420 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
97421 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
97422 +native_read_msr_15905 native_read_msr 0 15905 NULL
97423 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
97424 +power_read_15939 power_read 3 15939 NULL
97425 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
97426 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 4-2-5 15952 NULL
97427 +remap_pci_mem_15966 remap_pci_mem 1-2 15966 NULL
97428 +frame_alloc_15981 frame_alloc 4 15981 NULL
97429 +alloc_vm_area_15989 alloc_vm_area 1 15989 NULL
97430 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
97431 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
97432 +got_frame_16028 got_frame 2 16028 NULL
97433 +read_file_spectral_period_16057 read_file_spectral_period 3 16057 NULL
97434 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
97435 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
97436 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
97437 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
97438 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
97439 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
97440 +fsm_init_16134 fsm_init 2 16134 NULL
97441 +hysdn_rx_netpkt_16136 hysdn_rx_netpkt 3 16136 NULL
97442 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
97443 +bnx2i_get_cid_num_16166 bnx2i_get_cid_num 0 16166 NULL
97444 +mapping_level_16188 mapping_level 2 16188 NULL
97445 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
97446 +create_table_16213 create_table 2 16213 NULL
97447 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
97448 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
97449 +swiotlb_sync_single_for_device_16247 swiotlb_sync_single_for_device 2 16247 NULL nohasharray
97450 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 &swiotlb_sync_single_for_device_16247
97451 +mark_written_sectors_16262 mark_written_sectors 2 16262 NULL
97452 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
97453 +set_disc_pfs_16270 set_disc_pfs 3 16270 NULL
97454 +mq_force_mapping_16277 mq_force_mapping 2 16277 NULL
97455 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
97456 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
97457 +nand_bch_init_16280 nand_bch_init 3-2 16280 &drbd_setsockopt_16280
97458 +account_16283 account 0-2-4 16283 NULL nohasharray
97459 +mirror_status_16283 mirror_status 5 16283 &account_16283
97460 +retry_instruction_16285 retry_instruction 2 16285 NULL
97461 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
97462 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
97463 +wb_map_16301 wb_map 2 16301 NULL
97464 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
97465 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
97466 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
97467 +nl80211_send_unprot_deauth_16378 nl80211_send_unprot_deauth 4 16378 NULL
97468 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
97469 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
97470 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
97471 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
97472 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
97473 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
97474 +raid10_resize_16537 raid10_resize 2 16537 NULL
97475 +tcp_manip_pkt_16563 tcp_manip_pkt 4 16563 NULL
97476 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
97477 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
97478 +virt_to_scatterlist_16582 virt_to_scatterlist 2 16582 NULL
97479 +palmas_irq_get_virq_16613 palmas_irq_get_virq 2 16613 NULL
97480 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
97481 +mfd_add_devices_16668 mfd_add_devices 4 16668 NULL
97482 +ax88179_write_cmd_async_16671 ax88179_write_cmd_async 5 16671 NULL
97483 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
97484 +compat_blkdev_driver_ioctl_16769 compat_blkdev_driver_ioctl 4 16769 NULL
97485 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
97486 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
97487 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
97488 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
97489 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
97490 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
97491 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
97492 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
97493 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
97494 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
97495 +st_write_16874 st_write 3 16874 NULL
97496 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
97497 +idx_to_pfn_16919 idx_to_pfn 0 16919 NULL
97498 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
97499 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
97500 +_sp2d_alloc_16944 _sp2d_alloc 1-2-3 16944 NULL
97501 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
97502 +cfg80211_send_unprot_disassoc_16951 cfg80211_send_unprot_disassoc 3 16951 NULL
97503 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
97504 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
97505 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
97506 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
97507 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
97508 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
97509 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
97510 +__kmalloc_reserve_17080 __kmalloc_reserve 1 17080 NULL
97511 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
97512 +mac_address_string_17091 mac_address_string 0 17091 NULL
97513 +entry_length_17093 entry_length 0 17093 NULL
97514 +sys_preadv_17100 sys_preadv 3 17100 NULL
97515 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
97516 +mwifiex_get_common_rates_17131 mwifiex_get_common_rates 3 17131 NULL
97517 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
97518 +sep_read_17161 sep_read 3 17161 NULL
97519 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
97520 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
97521 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
97522 +access_remote_vm_17189 access_remote_vm 0-2-4 17189 NULL
97523 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
97524 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
97525 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
97526 +to_oblock_17254 to_oblock 0-1 17254 NULL
97527 +unpack_value_17259 unpack_value 1 17259 NULL
97528 +__be16_to_cpup_17261 __be16_to_cpup 0 17261 NULL
97529 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
97530 +alloc_ep_17269 alloc_ep 1 17269 NULL
97531 +pg_read_17276 pg_read 3 17276 NULL
97532 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
97533 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
97534 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
97535 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
97536 +install_breakpoint_17292 install_breakpoint 4 17292 NULL
97537 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
97538 +skb_pad_17302 skb_pad 2 17302 NULL
97539 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
97540 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
97541 +ata_host_alloc_pinfo_17325 ata_host_alloc_pinfo 3 17325 NULL
97542 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
97543 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
97544 +_fd_dma_mem_free_17406 _fd_dma_mem_free 1 17406 NULL
97545 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
97546 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
97547 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
97548 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
97549 +compat_cmd_17465 compat_cmd 2 17465 NULL
97550 +probe_bios_17467 probe_bios 1 17467 NULL
97551 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
97552 +__alloc_session_17485 __alloc_session 2-1 17485 NULL
97553 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
97554 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
97555 +__copy_to_user_17551 __copy_to_user 0-3 17551 NULL
97556 +copy_from_user_17559 copy_from_user 3 17559 NULL
97557 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
97558 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
97559 +rts51x_write_mem_17598 rts51x_write_mem 4 17598 NULL
97560 +iwl_dump_nic_event_log_17601 iwl_dump_nic_event_log 0 17601 NULL
97561 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
97562 +osst_execute_17607 osst_execute 7-6 17607 NULL
97563 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
97564 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
97565 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
97566 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
97567 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
97568 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
97569 +gfn_to_pfn_memslot_17693 gfn_to_pfn_memslot 2 17693 NULL
97570 +__einj_error_trigger_17707 __einj_error_trigger 1 17707 NULL nohasharray
97571 +venus_rename_17707 venus_rename 5-4 17707 &__einj_error_trigger_17707
97572 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
97573 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
97574 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
97575 +brcmf_usb_attach_17766 brcmf_usb_attach 2-3 17766 NULL
97576 +ubifs_leb_change_17789 ubifs_leb_change 4 17789 NULL
97577 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
97578 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
97579 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
97580 +count_leafs_17842 count_leafs 0 17842 NULL
97581 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
97582 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
97583 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
97584 +orinoco_set_key_17878 orinoco_set_key 5-7 17878 NULL
97585 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
97586 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
97587 +compat_sys_pwritev_17886 compat_sys_pwritev 3 17886 NULL
97588 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
97589 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
97590 +recover_head_17904 recover_head 3 17904 NULL
97591 +dccp_feat_register_sp_17914 dccp_feat_register_sp 5 17914 NULL
97592 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
97593 +srp_iu_pool_alloc_17920 srp_iu_pool_alloc 2 17920 NULL
97594 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
97595 +ufs_free_blocks_17963 ufs_free_blocks 2-3 17963 NULL
97596 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
97597 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
97598 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
97599 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
97600 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
97601 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
97602 +fill_read_18019 fill_read 0 18019 NULL
97603 +o2hb_highest_node_18034 o2hb_highest_node 2 18034 NULL
97604 +cryptd_alloc_instance_18048 cryptd_alloc_instance 2-3 18048 NULL
97605 +find_next_inuse_18051 find_next_inuse 2-3 18051 NULL
97606 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
97607 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
97608 +hex_byte_pack_18064 hex_byte_pack 0 18064 NULL
97609 +packet_came_18072 packet_came 3 18072 NULL
97610 +kvm_read_guest_page_18074 kvm_read_guest_page 5-2 18074 NULL
97611 +get_vm_area_18080 get_vm_area 1 18080 NULL
97612 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
97613 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
97614 +svc_getnl_18120 svc_getnl 0 18120 NULL
97615 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-1-2 18131 NULL
97616 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
97617 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
97618 +_has_tag_18169 _has_tag 2 18169 NULL
97619 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
97620 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
97621 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
97622 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
97623 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
97624 +snd_ctl_ioctl_compat_18250 snd_ctl_ioctl_compat 3 18250 NULL
97625 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
97626 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
97627 +alloc_ring_18278 alloc_ring 2-4 18278 NULL
97628 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
97629 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
97630 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
97631 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
97632 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
97633 +um_idi_write_18293 um_idi_write 3 18293 NULL
97634 +nouveau_disp_create__18305 nouveau_disp_create_ 4-7 18305 NULL
97635 +ip6ip6_err_18308 ip6ip6_err 5 18308 NULL
97636 +vga_r_18310 vga_r 0 18310 NULL
97637 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
97638 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
97639 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
97640 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
97641 +ep_io_18367 ep_io 0 18367 NULL
97642 +qib_user_sdma_num_pages_18371 qib_user_sdma_num_pages 0 18371 NULL
97643 +__video_register_device_18399 __video_register_device 3 18399 NULL
97644 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 NULL
97645 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
97646 +usbnet_write_cmd_nopm_18426 usbnet_write_cmd_nopm 7 18426 NULL
97647 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL
97648 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
97649 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
97650 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
97651 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
97652 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL
97653 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 NULL
97654 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
97655 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 5-6-9 18530 NULL
97656 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
97657 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
97658 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
97659 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
97660 +debug_output_18575 debug_output 3 18575 NULL
97661 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
97662 +__netdev_alloc_skb_18595 __netdev_alloc_skb 2 18595 NULL
97663 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL
97664 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
97665 +batadv_arp_get_type_18609 batadv_arp_get_type 3 18609 NULL
97666 +from_buffer_18625 from_buffer 3 18625 NULL
97667 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
97668 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
97669 +unmap_page_18665 unmap_page 2-3 18665 NULL
97670 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 NULL
97671 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
97672 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 NULL
97673 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
97674 +ocfs2_trim_extent_18711 ocfs2_trim_extent 4-3 18711 NULL
97675 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
97676 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
97677 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
97678 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
97679 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
97680 +md_compat_ioctl_18764 md_compat_ioctl 4 18764 NULL
97681 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
97682 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
97683 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
97684 +fat_compat_dir_ioctl_18800 fat_compat_dir_ioctl 3 18800 NULL
97685 +ieee80211_auth_challenge_18810 ieee80211_auth_challenge 3 18810 NULL
97686 +madvise_hwpoison_18812 madvise_hwpoison 2 18812 NULL
97687 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
97688 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
97689 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
97690 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
97691 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
97692 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL
97693 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
97694 +___alloc_bootmem_node_18882 ___alloc_bootmem_node 2-3 18882 NULL
97695 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
97696 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
97697 +mangle_packet_18920 mangle_packet 7-9 18920 NULL
97698 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
97699 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
97700 +gfn_to_pfn_atomic_18981 gfn_to_pfn_atomic 2 18981 NULL
97701 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL
97702 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
97703 +huge_page_size_19008 huge_page_size 0 19008 NULL
97704 +usbdev_compat_ioctl_19026 usbdev_compat_ioctl 3 19026 NULL
97705 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
97706 +revalidate_19043 revalidate 2 19043 NULL
97707 +drm_fb_helper_init_19044 drm_fb_helper_init 3-4 19044 NULL
97708 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
97709 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
97710 +sys_process_vm_readv_19090 sys_process_vm_readv 3-5 19090 NULL nohasharray
97711 +brcmf_usbdev_qinit_19090 brcmf_usbdev_qinit 2 19090 &sys_process_vm_readv_19090
97712 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
97713 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
97714 +skb_gro_offset_19123 skb_gro_offset 0 19123 NULL
97715 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
97716 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
97717 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
97718 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
97719 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
97720 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
97721 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
97722 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3 19214 NULL
97723 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
97724 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
97725 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
97726 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
97727 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
97728 +sys_fcntl_19267 sys_fcntl 3 19267 NULL
97729 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
97730 +io_mapping_map_wc_19284 io_mapping_map_wc 2 19284 NULL
97731 +qc_capture_19298 qc_capture 3 19298 NULL
97732 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 3-4 19303 NULL
97733 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
97734 +gfn_to_gpa_19320 gfn_to_gpa 0-1 19320 NULL
97735 +debug_read_19322 debug_read 3 19322 NULL
97736 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL
97737 +read_zero_19366 read_zero 3 19366 NULL
97738 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
97739 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
97740 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
97741 +__phys_addr_19434 __phys_addr 0 19434 NULL
97742 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
97743 +hpet_compat_ioctl_19455 hpet_compat_ioctl 3 19455 NULL
97744 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
97745 +sky2_read16_19475 sky2_read16 0 19475 NULL
97746 +efivar_create_sysfs_entry_19485 efivar_create_sysfs_entry 2 19485 NULL
97747 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
97748 +skb_realloc_headroom_19516 skb_realloc_headroom 2 19516 NULL
97749 +dev_alloc_skb_19517 dev_alloc_skb 1 19517 NULL
97750 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
97751 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
97752 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
97753 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL nohasharray
97754 +wlcore_hw_get_rx_packet_len_19565 wlcore_hw_get_rx_packet_len 0 19565 &ieee80211_if_read_tkip_mic_test_19565
97755 +nfsd_read_19568 nfsd_read 5 19568 NULL
97756 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
97757 +bm_status_read_19583 bm_status_read 3 19583 NULL
97758 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
97759 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
97760 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
97761 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
97762 +usbnet_write_cmd_19679 usbnet_write_cmd 7 19679 NULL
97763 +bio_detain_19690 bio_detain 2 19690 NULL
97764 +read_reg_19723 read_reg 0 19723 NULL
97765 +wm8350_block_write_19727 wm8350_block_write 3-2 19727 NULL
97766 +memcpy_toiovecend_19736 memcpy_toiovecend 4-3 19736 NULL
97767 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
97768 +p9_client_read_19750 p9_client_read 5 19750 NULL
97769 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
97770 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
97771 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
97772 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
97773 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
97774 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
97775 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
97776 +vfs_getxattr_19832 vfs_getxattr 0 19832 NULL
97777 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
97778 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
97779 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
97780 +__nla_put_19857 __nla_put 3 19857 NULL
97781 +ip6gre_err_19869 ip6gre_err 5 19869 NULL
97782 +mrp_request_join_19882 mrp_request_join 4 19882 NULL
97783 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
97784 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
97785 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
97786 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
97787 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
97788 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
97789 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
97790 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
97791 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
97792 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
97793 +team_options_register_20091 team_options_register 3 20091 NULL
97794 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
97795 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
97796 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
97797 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
97798 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
97799 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
97800 +crystalhd_map_dio_20181 crystalhd_map_dio 3 20181 NULL
97801 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
97802 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
97803 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
97804 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
97805 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
97806 +_rtl92s_get_h2c_cmdlen_20312 _rtl92s_get_h2c_cmdlen 0 20312 NULL
97807 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
97808 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
97809 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
97810 +handle_arr_calc_size_20355 handle_arr_calc_size 0-1 20355 NULL
97811 +qla82xx_pci_mem_read_direct_20368 qla82xx_pci_mem_read_direct 2 20368 NULL
97812 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
97813 +u64_to_uptr_20384 u64_to_uptr 1 20384 NULL
97814 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL
97815 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL
97816 +xen_create_contiguous_region_20457 xen_create_contiguous_region 1 20457 NULL
97817 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
97818 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
97819 +read_buf_20469 read_buf 2 20469 NULL
97820 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
97821 +fast_user_write_20494 fast_user_write 5 20494 NULL
97822 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL nohasharray
97823 +hidraw_report_event_20503 hidraw_report_event 3 20503 &ocfs2_db_frozen_trigger_20503
97824 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
97825 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 2-3 20517 NULL
97826 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
97827 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
97828 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
97829 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
97830 +venus_create_20555 venus_create 4 20555 NULL
97831 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
97832 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
97833 +i915_max_freq_read_20581 i915_max_freq_read 3 20581 NULL
97834 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL
97835 +lirc_write_20604 lirc_write 3 20604 NULL
97836 +qib_qsfp_write_20614 qib_qsfp_write 0-4-2 20614 NULL
97837 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
97838 +kfifo_copy_to_user_20646 kfifo_copy_to_user 3 20646 NULL
97839 +cpulist_scnprintf_20648 cpulist_scnprintf 0-2 20648 NULL
97840 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
97841 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
97842 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL
97843 +get_user_page_nowait_20682 get_user_page_nowait 3 20682 NULL nohasharray
97844 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 &get_user_page_nowait_20682
97845 +cpumask_size_20683 cpumask_size 0 20683 NULL
97846 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
97847 +gru_vtop_20689 gru_vtop 2 20689 NULL
97848 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
97849 +__maestro_read_20700 __maestro_read 0 20700 NULL
97850 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
97851 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
97852 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
97853 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
97854 +vring_add_indirect_20737 vring_add_indirect 3-4 20737 NULL
97855 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
97856 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
97857 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
97858 +brcmf_p2p_escan_20763 brcmf_p2p_escan 2 20763 NULL
97859 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
97860 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
97861 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
97862 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
97863 +sys_sendto_20809 sys_sendto 6 20809 NULL
97864 +strndup_user_20819 strndup_user 2 20819 NULL
97865 +calc_layout_20829 calc_layout 3 20829 NULL
97866 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
97867 +uvc_alloc_entity_20836 uvc_alloc_entity 3-4 20836 NULL
97868 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
97869 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
97870 +skb_tail_pointer_20878 skb_tail_pointer 0 20878 NULL
97871 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
97872 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
97873 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
97874 +compat_sys_readv_20911 compat_sys_readv 3 20911 NULL
97875 +htable_bits_20933 htable_bits 0 20933 NULL
97876 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
97877 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
97878 +nfs_map_name_to_uid_20962 nfs_map_name_to_uid 3 20962 NULL
97879 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
97880 +brcmf_tx_frame_20978 brcmf_tx_frame 3 20978 NULL
97881 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
97882 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4 21001 NULL
97883 +ceph_osdc_new_request_21017 ceph_osdc_new_request 14-4 21017 NULL
97884 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
97885 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
97886 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
97887 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
97888 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
97889 +compat_sock_ioctl_trans_21092 compat_sock_ioctl_trans 4 21092 NULL
97890 +multipath_status_21094 multipath_status 5 21094 NULL
97891 +__cfg80211_send_disassoc_21096 __cfg80211_send_disassoc 3 21096 NULL
97892 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
97893 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
97894 +bitset_size_in_bytes_21124 bitset_size_in_bytes 0-1 21124 NULL
97895 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
97896 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
97897 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
97898 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
97899 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
97900 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4 21220 NULL
97901 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
97902 +input_ff_create_21240 input_ff_create 2 21240 NULL
97903 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
97904 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
97905 +ip_vs_icmp_xmit_21269 ip_vs_icmp_xmit 4 21269 NULL
97906 +make_alloc_exact_21279 make_alloc_exact 1-3 21279 NULL
97907 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
97908 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
97909 +add_res_range_21310 add_res_range 4 21310 NULL
97910 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
97911 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
97912 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
97913 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
97914 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
97915 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
97916 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
97917 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
97918 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
97919 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
97920 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
97921 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
97922 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
97923 +concat_writev_21451 concat_writev 3 21451 NULL
97924 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
97925 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
97926 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
97927 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
97928 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
97929 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
97930 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
97931 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
97932 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
97933 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
97934 +validate_nnode_21638 validate_nnode 0 21638 NULL
97935 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-3 21639 NULL
97936 +carl9170_rx_copy_data_21656 carl9170_rx_copy_data 2 21656 NULL
97937 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
97938 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
97939 +regmap_register_patch_21681 regmap_register_patch 3 21681 NULL
97940 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1-2 21687 NULL
97941 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
97942 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL
97943 +vm_brk_21739 vm_brk 1 21739 NULL
97944 +__nf_nat_mangle_tcp_packet_21744 __nf_nat_mangle_tcp_packet 8-6 21744 NULL
97945 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
97946 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
97947 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
97948 +__ioremap_caller_21800 __ioremap_caller 1-2 21800 NULL
97949 +min_odd_21802 min_odd 0 21802 NULL
97950 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
97951 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
97952 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
97953 +acpi_tb_check_xsdt_21862 acpi_tb_check_xsdt 1 21862 NULL
97954 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
97955 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
97956 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL nohasharray
97957 +tcp_cookie_size_check_21873 tcp_cookie_size_check 0-1 21873 &sisusbcon_bmove_21873
97958 +xen_swiotlb_map_page_21886 xen_swiotlb_map_page 3 21886 NULL
97959 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 1-2 21895 NULL
97960 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
97961 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
97962 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
97963 +security_mmap_addr_21970 security_mmap_addr 0 21970 NULL
97964 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
97965 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
97966 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 0-3 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
97967 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
97968 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
97969 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
97970 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2 22077 NULL
97971 +write_opcode_22082 write_opcode 2 22082 NULL
97972 +mem_rw_22085 mem_rw 3 22085 NULL
97973 +is_swbp_at_addr_22089 is_swbp_at_addr 2 22089 NULL
97974 +lowpan_fragment_xmit_22095 lowpan_fragment_xmit 3-4 22095 NULL
97975 +sys_remap_file_pages_22124 sys_remap_file_pages 1 22124 NULL
97976 +__bitmap_size_22138 __bitmap_size 0 22138 NULL
97977 +compat_insn_22142 compat_insn 2 22142 NULL
97978 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
97979 +__kfifo_alloc_22173 __kfifo_alloc 3 22173 NULL
97980 +fls_22210 fls 0 22210 NULL
97981 +mem_write_22232 mem_write 3 22232 NULL
97982 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
97983 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
97984 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
97985 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
97986 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
97987 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
97988 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
97989 +extend_brk_22301 extend_brk 0 22301 NULL
97990 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
97991 +get_segment_base_22324 get_segment_base 0 22324 NULL
97992 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 2-3 22334 NULL
97993 +atomic_read_22342 atomic_read 0 22342 NULL
97994 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
97995 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL nohasharray
97996 +memcg_size_22360 memcg_size 0 22360 &irq_reserve_irq_22360
97997 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
97998 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 NULL
97999 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
98000 +alloc_large_system_hash_22391 alloc_large_system_hash 2 22391 NULL
98001 +btmrvl_psmode_read_22395 btmrvl_psmode_read 3 22395 NULL
98002 +crash_shrink_memory_22401 crash_shrink_memory 1 22401 NULL
98003 +zoran_write_22404 zoran_write 3 22404 NULL
98004 +queue_reply_22416 queue_reply 3 22416 NULL
98005 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
98006 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
98007 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
98008 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
98009 +batadv_check_unicast_packet_22468 batadv_check_unicast_packet 3 22468 NULL
98010 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
98011 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
98012 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
98013 +ip4_addr_string_22511 ip4_addr_string 0 22511 NULL
98014 +swiotlb_tbl_unmap_single_22522 swiotlb_tbl_unmap_single 2 22522 NULL nohasharray
98015 +usb_dump_config_descriptor_22522 usb_dump_config_descriptor 0 22522 &swiotlb_tbl_unmap_single_22522
98016 +pskb_may_pull_22546 pskb_may_pull 2 22546 NULL
98017 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
98018 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
98019 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
98020 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
98021 +snapshot_read_22601 snapshot_read 3 22601 NULL
98022 +remove_breakpoint_22628 remove_breakpoint 3 22628 NULL
98023 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
98024 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
98025 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
98026 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
98027 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
98028 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL
98029 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
98030 +compat_fd_ioctl_22694 compat_fd_ioctl 4 22694 NULL
98031 +map_22700 map 2 22700 NULL
98032 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
98033 +brcmf_sdbrcm_read_control_22721 brcmf_sdbrcm_read_control 3 22721 NULL
98034 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4 22735 NULL
98035 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL
98036 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
98037 +print_frame_22769 print_frame 0 22769 NULL
98038 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
98039 +compat_blkdev_ioctl_22841 compat_blkdev_ioctl 3 22841 NULL
98040 +clone_bio_integrity_22842 clone_bio_integrity 4 22842 NULL
98041 +read_file_rcstat_22854 read_file_rcstat 3 22854 NULL
98042 +do_atm_iobuf_22857 do_atm_iobuf 3 22857 NULL
98043 +create_attr_set_22861 create_attr_set 1 22861 NULL
98044 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
98045 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
98046 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
98047 +policy_emit_config_values_22900 policy_emit_config_values 3 22900 NULL
98048 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
98049 +alloc_sglist_22960 alloc_sglist 1-2-3 22960 NULL
98050 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
98051 +vme_get_size_22964 vme_get_size 0 22964 NULL
98052 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
98053 +page_table_range_init_count_22977 page_table_range_init_count 0 22977 NULL
98054 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
98055 +set_msr_hyperv_22985 set_msr_hyperv 3 22985 NULL
98056 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
98057 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
98058 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
98059 +st_status_23032 st_status 5 23032 NULL
98060 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
98061 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL
98062 +kvm_mmu_gva_to_gpa_write_23075 kvm_mmu_gva_to_gpa_write 0 23075 NULL
98063 +vm_map_ram_23078 vm_map_ram 2 23078 NULL nohasharray
98064 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
98065 +qla4_82xx_pci_mem_read_2M_23081 qla4_82xx_pci_mem_read_2M 2 23081 NULL
98066 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
98067 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
98068 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
98069 +fls_long_23096 fls_long 0 23096 NULL
98070 +ntfs_ucstonls_23097 ntfs_ucstonls 3-5 23097 NULL
98071 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
98072 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
98073 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
98074 +__clear_user_23118 __clear_user 0 23118 NULL
98075 +dm_write_async_23120 dm_write_async 3 23120 NULL
98076 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
98077 +ca91cx42_master_set_23146 ca91cx42_master_set 4 23146 NULL
98078 +read_file_ani_23161 read_file_ani 3 23161 NULL
98079 +ioremap_23172 ioremap 1-2 23172 NULL
98080 +usblp_write_23178 usblp_write 3 23178 NULL
98081 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
98082 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
98083 +ieee80211_get_mesh_hdrlen_23183 ieee80211_get_mesh_hdrlen 0 23183 NULL
98084 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
98085 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
98086 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
98087 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL nohasharray
98088 +compat_rawv6_ioctl_23210 compat_rawv6_ioctl 3 23210 &pm80x_free_irq_23210
98089 +tty_buffer_request_room_23228 tty_buffer_request_room 2 23228 NULL
98090 +xlog_get_bp_23229 xlog_get_bp 2 23229 NULL
98091 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
98092 +__gfn_to_rmap_23240 __gfn_to_rmap 1-2 23240 NULL
98093 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
98094 +ipv6_skip_exthdr_23283 ipv6_skip_exthdr 0-2 23283 NULL
98095 +doc_probe_23285 doc_probe 1 23285 NULL
98096 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
98097 +perf_mmap_free_page_23302 perf_mmap_free_page 1 23302 NULL
98098 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
98099 +mc13xxx_get_num_regulators_dt_23344 mc13xxx_get_num_regulators_dt 0 23344 NULL
98100 +page_readlink_23346 page_readlink 3 23346 NULL
98101 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
98102 +fd_setup_write_same_buf_23369 fd_setup_write_same_buf 3 23369 NULL
98103 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
98104 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
98105 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
98106 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 NULL
98107 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
98108 +linear_conf_23485 linear_conf 2 23485 NULL nohasharray
98109 +divasa_remap_pci_bar_23485 divasa_remap_pci_bar 3-4 23485 &linear_conf_23485
98110 +event_filter_read_23494 event_filter_read 3 23494 NULL
98111 +__gfn_to_hva_many_23508 __gfn_to_hva_many 0-2 23508 NULL
98112 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
98113 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
98114 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
98115 +dbg_leb_change_23555 dbg_leb_change 4 23555 NULL
98116 +venus_symlink_23570 venus_symlink 4-6 23570 NULL
98117 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
98118 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
98119 +do_mmap_pgoff_23600 do_mmap_pgoff 0 23600 NULL
98120 +_alloc_cdb_cont_23609 _alloc_cdb_cont 2 23609 NULL
98121 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
98122 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
98123 +ext3_compat_ioctl_23659 ext3_compat_ioctl 3 23659 NULL
98124 +sInW_23663 sInW 0 23663 NULL
98125 +proc_ioctl_compat_23682 proc_ioctl_compat 2 23682 NULL
98126 +nftl_partscan_23688 nftl_partscan 0 23688 NULL
98127 +cx18_read_23699 cx18_read 3 23699 NULL
98128 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
98129 +pack_sg_list_p_23739 pack_sg_list_p 0-2 23739 NULL
98130 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
98131 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
98132 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
98133 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
98134 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
98135 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2-3 23824 NULL
98136 +ceph_copy_page_vector_to_user_23829 ceph_copy_page_vector_to_user 3-4 23829 NULL
98137 +xfs_dir2_leaf_getdents_23841 xfs_dir2_leaf_getdents 3 23841 NULL
98138 +pgdat_end_pfn_23842 pgdat_end_pfn 0 23842 NULL
98139 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
98140 +p54_init_common_23850 p54_init_common 1 23850 NULL
98141 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
98142 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
98143 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
98144 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
98145 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
98146 +tipc_snprintf_23893 tipc_snprintf 2 23893 NULL
98147 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
98148 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
98149 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
98150 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
98151 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
98152 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL
98153 +__alloc_skb_23940 __alloc_skb 1 23940 NULL
98154 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
98155 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
98156 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
98157 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
98158 +dgrp_send_24028 dgrp_send 0-2 24028 NULL
98159 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
98160 +adis16400_show_serial_number_24037 adis16400_show_serial_number 3 24037 NULL
98161 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
98162 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
98163 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
98164 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
98165 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
98166 +mpu401_read_24126 mpu401_read 3 24126 NULL
98167 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
98168 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
98169 +set_discard_24162 set_discard 2 24162 NULL
98170 +adu_read_24177 adu_read 3 24177 NULL
98171 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
98172 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
98173 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
98174 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
98175 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 1-2-3 24224 NULL nohasharray
98176 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
98177 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
98178 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
98179 +dm_cache_save_hint_24257 dm_cache_save_hint 2 24257 NULL
98180 +em28xx_alloc_urbs_24260 em28xx_alloc_urbs 4-6 24260 NULL
98181 +thin_status_24278 thin_status 5 24278 NULL
98182 +compat_sys_preadv64_24283 compat_sys_preadv64 3 24283 NULL
98183 +msg_size_24288 msg_size 0 24288 NULL
98184 +ext2_free_blocks_24292 ext2_free_blocks 2-3 24292 NULL
98185 +map_page_24298 map_page 3-4 24298 NULL
98186 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
98187 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
98188 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
98189 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
98190 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
98191 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
98192 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
98193 +igetword_24373 igetword 0 24373 NULL
98194 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
98195 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398
98196 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
98197 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
98198 +iwl_nvm_read_section_24438 iwl_nvm_read_section 0 24438 NULL
98199 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 4-6 24439 NULL
98200 +smk_user_access_24440 smk_user_access 3 24440 NULL
98201 +page_address_24444 page_address 0 24444 NULL
98202 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
98203 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 5-6 24466 NULL
98204 +read_file_spec_scan_ctl_24491 read_file_spec_scan_ctl 3 24491 NULL
98205 +pd_video_read_24510 pd_video_read 3 24510 NULL
98206 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
98207 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
98208 +named_prepare_buf_24532 named_prepare_buf 2 24532 NULL
98209 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
98210 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
98211 +tsi148_alloc_resource_24563 tsi148_alloc_resource 2 24563 NULL
98212 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
98213 +count_preds_24600 count_preds 0 24600 NULL
98214 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL
98215 +kvm_pv_enable_async_pf_24637 kvm_pv_enable_async_pf 2 24637 NULL
98216 +context_alloc_24645 context_alloc 3 24645 NULL
98217 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
98218 +unifi_net_data_malloc_24716 unifi_net_data_malloc 3 24716 NULL
98219 +read_fs_24717 read_fs 0 24717 NULL
98220 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
98221 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
98222 +ath_rxbuf_alloc_24745 ath_rxbuf_alloc 2 24745 NULL
98223 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
98224 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
98225 +nfsd4_sanitize_slot_size_24756 nfsd4_sanitize_slot_size 0-1 24756 NULL
98226 +i915_cache_sharing_read_24775 i915_cache_sharing_read 3 24775 NULL
98227 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
98228 +skb_make_writable_24783 skb_make_writable 2 24783 NULL
98229 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
98230 +cache_read_24790 cache_read 3 24790 NULL
98231 +unpack_str_24798 unpack_str 0 24798 NULL
98232 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
98233 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
98234 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
98235 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
98236 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
98237 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
98238 +setup_buffering_24872 setup_buffering 3 24872 NULL
98239 +bnx2fc_cmd_mgr_alloc_24873 bnx2fc_cmd_mgr_alloc 3-2 24873 NULL
98240 +queues_read_24877 queues_read 3 24877 NULL
98241 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
98242 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 NULL
98243 +next_token_24929 next_token 0 24929 NULL
98244 +uf_create_device_nodes_24948 uf_create_device_nodes 2 24948 NULL
98245 +ocfs2_fiemap_24949 ocfs2_fiemap 3-4 24949 NULL
98246 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
98247 +sys_rt_sigpending_24961 sys_rt_sigpending 2 24961 NULL
98248 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
98249 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
98250 +nf_nat_sdp_port_24977 nf_nat_sdp_port 7 24977 NULL
98251 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
98252 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
98253 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
98254 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
98255 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
98256 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
98257 +ceph_osdc_writepages_25085 ceph_osdc_writepages 5 25085 NULL
98258 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
98259 +sys_fgetxattr_25166 sys_fgetxattr 4 25166 NULL
98260 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL
98261 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
98262 +ks8851_rdreg32_25187 ks8851_rdreg32 0 25187 NULL
98263 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
98264 +free_memcg_kmem_pages_25228 free_memcg_kmem_pages 1 25228 NULL
98265 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
98266 +tcf_csum_ipv6_udp_25241 tcf_csum_ipv6_udp 4 25241 NULL
98267 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 3-5 25245 NULL
98268 +stripe_status_25259 stripe_status 5 25259 NULL
98269 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
98270 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
98271 +vfs_writev_25278 vfs_writev 3 25278 NULL
98272 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
98273 +snd_seq_ioctl_compat_25307 snd_seq_ioctl_compat 3 25307 NULL
98274 +help_25316 help 5 25316 NULL nohasharray
98275 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 &help_25316
98276 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
98277 +rio_destid_next_25368 rio_destid_next 2 25368 NULL nohasharray
98278 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
98279 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
98280 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
98281 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
98282 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
98283 +ath6kl_wmi_beginscan_cmd_25462 ath6kl_wmi_beginscan_cmd 8 25462 NULL
98284 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
98285 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
98286 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
98287 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4 25502 NULL
98288 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
98289 +sb_permission_25523 sb_permission 0 25523 NULL
98290 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
98291 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
98292 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
98293 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
98294 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
98295 +find_extend_vma_25597 find_extend_vma 2 25597 NULL
98296 +__devres_alloc_25598 __devres_alloc 2 25598 NULL
98297 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
98298 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
98299 +__get_user_pages_25628 __get_user_pages 0-3-4 25628 NULL nohasharray
98300 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
98301 +__direct_map_25647 __direct_map 5-6 25647 NULL
98302 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2 25667 NULL
98303 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
98304 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
98305 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
98306 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 NULL
98307 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
98308 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
98309 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2-3 25726 &sel_write_context_25726
98310 +mcs_unwrap_fir_25733 mcs_unwrap_fir 3 25733 NULL
98311 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
98312 +__set_clear_dirty_25744 __set_clear_dirty 2 25744 NULL
98313 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
98314 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
98315 +sg_read_25799 sg_read 3 25799 NULL
98316 +system_enable_read_25815 system_enable_read 3 25815 NULL
98317 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
98318 +mthca_map_user_db_25823 mthca_map_user_db 5 25823 NULL
98319 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
98320 +parport_read_25855 parport_read 0 25855 NULL
98321 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
98322 +uf_ap_process_data_pdu_25860 uf_ap_process_data_pdu 7 25860 NULL
98323 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
98324 +run_delalloc_nocow_25896 run_delalloc_nocow 3 25896 NULL
98325 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
98326 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
98327 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
98328 +rcname_read_25919 rcname_read 3 25919 NULL
98329 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
98330 +key_flags_read_25931 key_flags_read 3 25931 NULL
98331 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
98332 +flush_25957 flush 2 25957 NULL
98333 +video_register_device_25971 video_register_device 3 25971 NULL
98334 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
98335 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
98336 +lpfc_sli_probe_sriov_nr_virtfn_26004 lpfc_sli_probe_sriov_nr_virtfn 2 26004 NULL
98337 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
98338 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
98339 +skb_mac_header_26034 skb_mac_header 0 26034 NULL
98340 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
98341 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
98342 +tun_do_read_26047 tun_do_read 5 26047 NULL
98343 +__alloc_memory_core_early_26053 __alloc_memory_core_early 2-3 26053 NULL
98344 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
98345 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
98346 +skb_cow_26138 skb_cow 2 26138 NULL
98347 +usb_dump_device_strings_26146 usb_dump_device_strings 0 26146 NULL
98348 +copy_oldmem_page_26164 copy_oldmem_page 3-1 26164 NULL
98349 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
98350 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
98351 +mid_get_vbt_data_r1_26170 mid_get_vbt_data_r1 2 26170 NULL
98352 +disk_devt_26180 disk_devt 0 26180 NULL
98353 +get_registers_26187 get_registers 3 26187 NULL
98354 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
98355 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
98356 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
98357 +mce_write_26201 mce_write 3 26201 NULL
98358 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
98359 +bio_split_26235 bio_split 2 26235 NULL
98360 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
98361 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
98362 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
98363 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
98364 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
98365 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
98366 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5 26357 NULL
98367 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
98368 +dup_to_netobj_26363 dup_to_netobj 3 26363 NULL
98369 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
98370 +dma_declare_contiguous_26455 dma_declare_contiguous 2 26455 NULL
98371 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
98372 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
98373 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
98374 +read_vmcore_26501 read_vmcore 3 26501 NULL
98375 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 3-4 26507 NULL
98376 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
98377 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
98378 +ip6_addr_string_26568 ip6_addr_string 0 26568 NULL
98379 +kvm_iommu_put_pages_26571 kvm_iommu_put_pages 2 26571 NULL
98380 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL nohasharray
98381 +batadv_receive_server_sync_packet_26577 batadv_receive_server_sync_packet 3 26577 &rts51x_read_mem_26577
98382 +cirrusfb_get_memsize_26597 cirrusfb_get_memsize 0 26597 NULL
98383 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
98384 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
98385 +pack_value_26625 pack_value 1 26625 NULL
98386 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
98387 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
98388 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
98389 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
98390 +__alloc_pred_stack_26687 __alloc_pred_stack 2 26687 NULL
98391 +rtllib_authentication_req_26713 rtllib_authentication_req 3 26713 NULL
98392 +aty_ld_le32_26720 aty_ld_le32 0 26720 NULL
98393 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
98394 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
98395 +srp_ring_alloc_26760 srp_ring_alloc 2 26760 NULL
98396 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
98397 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
98398 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
98399 +iwl_trans_read_mem32_26825 iwl_trans_read_mem32 0 26825 NULL
98400 +smk_write_load_26829 smk_write_load 3 26829 NULL
98401 +sizeof_pwm_leds_priv_26830 sizeof_pwm_leds_priv 0-1 26830 NULL
98402 +slgt_compat_ioctl_26834 slgt_compat_ioctl 3 26834 NULL
98403 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
98404 +scnprint_id_26842 scnprint_id 3 26842 NULL
98405 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
98406 +netxen_nic_hw_read_wx_128M_26858 netxen_nic_hw_read_wx_128M 2 26858 NULL
98407 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
98408 +ext2_compat_ioctl_26883 ext2_compat_ioctl 3 26883 NULL
98409 +slhc_uncompress_26905 slhc_uncompress 0-3 26905 NULL
98410 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
98411 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
98412 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
98413 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
98414 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
98415 +carl9170_handle_mpdu_26940 carl9170_handle_mpdu 3 26940 NULL nohasharray
98416 +create_bm_block_list_26940 create_bm_block_list 0 26940 &carl9170_handle_mpdu_26940
98417 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
98418 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
98419 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
98420 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
98421 +swiotlb_bounce_27046 swiotlb_bounce 2-1 27046 NULL
98422 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
98423 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
98424 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
98425 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
98426 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
98427 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
98428 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
98429 +nes_reg_user_mr_27106 nes_reg_user_mr 2-3 27106 NULL
98430 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
98431 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
98432 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
98433 +pms_capture_27142 pms_capture 4 27142 NULL
98434 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
98435 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
98436 +i2400m_net_rx_27170 i2400m_net_rx 5 27170 NULL
98437 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
98438 +mmc_blk_compat_ioctl_27194 mmc_blk_compat_ioctl 4 27194 NULL
98439 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
98440 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
98441 +cfpkt_add_trail_27260 cfpkt_add_trail 3 27260 NULL
98442 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
98443 +hpi_read_reg_27302 hpi_read_reg 0 27302 NULL
98444 +copy_from_buf_27308 copy_from_buf 4-2 27308 NULL
98445 +ath6kl_wmi_test_cmd_27312 ath6kl_wmi_test_cmd 3 27312 NULL
98446 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
98447 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
98448 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
98449 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
98450 +init_memory_mapping_27395 init_memory_mapping 0 27395 NULL
98451 +phys_pte_init_27411 phys_pte_init 0-3-2 27411 NULL
98452 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
98453 +acpi_os_get_root_pointer_27416 acpi_os_get_root_pointer 0 27416 NULL nohasharray
98454 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 &acpi_os_get_root_pointer_27416
98455 +pack_sg_list_27425 pack_sg_list 0-2 27425 NULL
98456 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
98457 +set_tpl_pfs_27490 set_tpl_pfs 3 27490 NULL
98458 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
98459 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
98460 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
98461 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
98462 +__usbnet_write_cmd_27500 __usbnet_write_cmd 7 27500 NULL
98463 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
98464 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
98465 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
98466 +libipw_alloc_txb_27579 libipw_alloc_txb 1-2-3 27579 NULL
98467 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
98468 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
98469 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &nl80211_send_connect_result_27642
98470 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
98471 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
98472 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
98473 +set_bypass_pwoff_pfs_27669 set_bypass_pwoff_pfs 3 27669 NULL
98474 +qword_get_27670 qword_get 0 27670 NULL
98475 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
98476 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4 27702 NULL
98477 +evm_write_key_27715 evm_write_key 3 27715 NULL
98478 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
98479 +reg_w_buf_27724 reg_w_buf 3 27724 NULL
98480 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
98481 +a4t_cs_init_27734 a4t_cs_init 3 27734 NULL
98482 +kcalloc_27770 kcalloc 1-2 27770 NULL
98483 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
98484 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
98485 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL
98486 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
98487 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
98488 +init_header_complete_27833 init_header_complete 0 27833 NULL nohasharray
98489 +sys_listxattr_27833 sys_listxattr 3 27833 &init_header_complete_27833
98490 +read_profile_27859 read_profile 3 27859 NULL
98491 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
98492 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
98493 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
98494 +gluebi_write_27905 gluebi_write 3 27905 NULL
98495 +bm_find_next_27929 bm_find_next 2 27929 NULL
98496 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
98497 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
98498 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 NULL
98499 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
98500 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
98501 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
98502 +serial8250_port_size_28019 serial8250_port_size 0 28019 NULL
98503 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
98504 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
98505 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2 28053 NULL
98506 +pool_status_28055 pool_status 5 28055 NULL
98507 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
98508 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
98509 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
98510 +GetRecvByte_28082 GetRecvByte 0 28082 NULL
98511 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
98512 +gdth_init_isa_28091 gdth_init_isa 1 28091 NULL
98513 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 3-2 28102 NULL
98514 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
98515 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
98516 +video_read_28148 video_read 3 28148 NULL
98517 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
98518 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
98519 +vread_28173 vread 0 28173 NULL
98520 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
98521 +d_path_28198 d_path 0 28198 NULL
98522 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
98523 +__qp_memcpy_from_queue_28220 __qp_memcpy_from_queue 3-4 28220 NULL
98524 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL nohasharray
98525 +set_dis_disc_pfs_28225 set_dis_disc_pfs 3 28225 &line6_alloc_sysex_buffer_28225
98526 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
98527 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
98528 +usemap_size_28281 usemap_size 0 28281 NULL
98529 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
98530 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
98531 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
98532 +__mlock_vma_pages_range_28315 __mlock_vma_pages_range 2-3 28315 NULL
98533 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
98534 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
98535 +snapshot_write_28351 snapshot_write 3 28351 NULL
98536 +sys_writev_28384 sys_writev 3 28384 NULL
98537 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
98538 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
98539 +set_bypass_pfs_28395 set_bypass_pfs 3 28395 NULL
98540 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
98541 +__split_large_page_28429 __split_large_page 2 28429 NULL
98542 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
98543 +set_memory_uc_28439 set_memory_uc 1 28439 NULL
98544 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
98545 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
98546 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
98547 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
98548 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
98549 +max_response_pages_28492 max_response_pages 0 28492 NULL
98550 +clear_discard_28494 clear_discard 2 28494 NULL
98551 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
98552 +__next_node_28521 __next_node 1 28521 NULL
98553 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
98554 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
98555 +run_delalloc_range_28545 run_delalloc_range 3 28545 NULL nohasharray
98556 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545
98557 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
98558 +asymmetric_verify_28567 asymmetric_verify 3 28567 NULL
98559 +phys_pud_init_28574 phys_pud_init 0-3-2 28574 NULL
98560 +cfg80211_send_rx_auth_28580 cfg80211_send_rx_auth 3 28580 NULL
98561 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
98562 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
98563 +extract_entropy_28604 extract_entropy 3-5 28604 NULL
98564 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
98565 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
98566 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
98567 +_set_range_28627 _set_range 3 28627 NULL
98568 +v4l2_compat_ioctl32_28630 v4l2_compat_ioctl32 3 28630 NULL
98569 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
98570 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
98571 +__dev_alloc_skb_28681 __dev_alloc_skb 1 28681 NULL
98572 +nl80211_send_new_peer_candidate_28692 nl80211_send_new_peer_candidate 5 28692 NULL nohasharray
98573 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 &nl80211_send_new_peer_candidate_28692
98574 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
98575 +spi_execute_28736 spi_execute 5 28736 NULL
98576 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL nohasharray
98577 +phantom_compat_ioctl_28738 phantom_compat_ioctl 3 28738 &snd_pcm_aio_write_28738
98578 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
98579 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
98580 +dvb_net_sec_callback_28786 dvb_net_sec_callback 2 28786 NULL
98581 +sel_write_member_28800 sel_write_member 3 28800 NULL
98582 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
98583 +btrfs_ref_to_path_28809 btrfs_ref_to_path 0 28809 NULL
98584 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
98585 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
98586 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
98587 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
98588 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
98589 +to_cblock_28899 to_cblock 0-1 28899 NULL
98590 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
98591 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
98592 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
98593 +push_rx_28939 push_rx 3 28939 NULL
98594 +btrfs_trim_block_group_28963 btrfs_trim_block_group 3 28963 NULL
98595 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
98596 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
98597 +bin_uuid_28999 bin_uuid 3 28999 NULL
98598 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
98599 +sys_fcntl64_29031 sys_fcntl64 3 29031 NULL
98600 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
98601 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL
98602 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
98603 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
98604 +memblock_alloc_base_nid_29072 memblock_alloc_base_nid 1-2 29072 NULL
98605 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
98606 +mark_extents_written_29082 mark_extents_written 2 29082 NULL
98607 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
98608 +snprintf_29125 snprintf 0 29125 NULL
98609 +iov_shorten_29130 iov_shorten 0 29130 NULL
98610 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
98611 +reshape_ring_29147 reshape_ring 2 29147 NULL
98612 +alloc_irqs_from_29152 alloc_irqs_from 1-2 29152 NULL
98613 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
98614 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL nohasharray
98615 +alloc_group_attrs_29203 alloc_group_attrs 3 29203 &wusb_prf_256_29203
98616 +__mm_populate_29204 __mm_populate 1 29204 NULL
98617 +comedi_alloc_subdevices_29207 comedi_alloc_subdevices 2 29207 NULL
98618 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
98619 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
98620 +devm_ioremap_29235 devm_ioremap 2-3 29235 NULL
98621 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
98622 +recover_peb_29238 recover_peb 6-7 29238 NULL
98623 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
98624 +block_div_29268 block_div 0-1-2 29268 NULL
98625 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
98626 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
98627 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
98628 +lo_compat_ioctl_29336 lo_compat_ioctl 4 29336 NULL
98629 +tun_put_user_29337 tun_put_user 5 29337 NULL
98630 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
98631 +alloc_and_copy_ftrace_hash_29368 alloc_and_copy_ftrace_hash 1 29368 NULL
98632 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
98633 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
98634 +mempool_create_29437 mempool_create 1 29437 NULL
98635 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
98636 +apei_exec_ctx_get_output_29457 apei_exec_ctx_get_output 0 29457 NULL
98637 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
98638 +do_register_entry_29478 do_register_entry 4 29478 NULL
98639 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
98640 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
98641 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
98642 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
98643 +_regmap_raw_write_29541 _regmap_raw_write 4-2 29541 NULL
98644 +set_brk_29551 set_brk 1 29551 NULL nohasharray
98645 +ftrace_write_29551 ftrace_write 3 29551 &set_brk_29551
98646 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
98647 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL nohasharray
98648 +alloc_empty_pages_29566 alloc_empty_pages 2 29566 &leaf_dealloc_29566
98649 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
98650 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4 29589 NULL
98651 +slots_per_page_29601 slots_per_page 0 29601 NULL
98652 +qla4_82xx_pci_set_window_29605 qla4_82xx_pci_set_window 0-2 29605 NULL
98653 +alloc_low_pages_29623 alloc_low_pages 1 29623 NULL
98654 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
98655 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
98656 +lowmem_page_address_29649 lowmem_page_address 0 29649 NULL
98657 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
98658 +br_send_bpdu_29669 br_send_bpdu 3 29669 NULL
98659 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
98660 +sd_alloc_ctl_entry_29708 sd_alloc_ctl_entry 1 29708 NULL nohasharray
98661 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 &sd_alloc_ctl_entry_29708
98662 +probes_write_29711 probes_write 3 29711 NULL
98663 +emi62_writememory_29731 emi62_writememory 4 29731 NULL
98664 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
98665 +ip_vs_conn_fill_param_sync_29771 ip_vs_conn_fill_param_sync 6 29771 NULL
98666 +dbAlloc_29794 dbAlloc 0 29794 NULL
98667 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
98668 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
98669 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
98670 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
98671 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
98672 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
98673 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
98674 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
98675 +nfc_targets_found_29886 nfc_targets_found 3 29886 NULL
98676 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
98677 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
98678 +irias_add_octseq_attrib_29983 irias_add_octseq_attrib 4 29983 NULL nohasharray
98679 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 &irias_add_octseq_attrib_29983
98680 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
98681 +vmci_host_setup_notify_30002 vmci_host_setup_notify 2 30002 NULL
98682 +utf32_to_utf8_30028 utf32_to_utf8 0 30028 NULL
98683 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
98684 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
98685 +drp_wmove_30043 drp_wmove 4 30043 NULL
98686 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
98687 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
98688 +tg3_run_loopback_30093 tg3_run_loopback 2 30093 NULL
98689 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL nohasharray
98690 +dma_to_phys_30098 dma_to_phys 0-2 30098 &rx_filter_data_filter_read_30098
98691 +skb_pagelen_30113 skb_pagelen 0 30113 NULL
98692 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
98693 +calgary_unmap_page_30130 calgary_unmap_page 2-3 30130 NULL
98694 +_osd_req_sizeof_alist_header_30134 _osd_req_sizeof_alist_header 0 30134 NULL
98695 +u_memcpya_30139 u_memcpya 2-3 30139 NULL
98696 +cx25821_video_ioctl_30188 cx25821_video_ioctl 2 30188 NULL
98697 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
98698 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
98699 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
98700 +nfs_idmap_request_key_30208 nfs_idmap_request_key 3 30208 NULL
98701 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
98702 +snd_ac97_pcm_assign_30218 snd_ac97_pcm_assign 2 30218 NULL
98703 +f2fs_compat_ioctl_30261 f2fs_compat_ioctl 3 30261 NULL
98704 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
98705 +compat_readv_30273 compat_readv 3 30273 NULL
98706 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
98707 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
98708 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
98709 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
98710 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
98711 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
98712 +resource_from_user_30341 resource_from_user 3 30341 NULL
98713 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
98714 +sys_get_mempolicy_30379 sys_get_mempolicy 3-4 30379 NULL
98715 +mangle_sdp_packet_30381 mangle_sdp_packet 10 30381 NULL
98716 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
98717 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
98718 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
98719 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
98720 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
98721 +mq_create_30425 mq_create 1 30425 NULL
98722 +enable_write_30456 enable_write 3 30456 NULL
98723 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
98724 +urandom_read_30462 urandom_read 3 30462 NULL
98725 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
98726 +ocrdma_reg_user_mr_30474 ocrdma_reg_user_mr 2-3 30474 NULL
98727 +write_head_30481 write_head 4 30481 NULL
98728 +adu_write_30487 adu_write 3 30487 NULL
98729 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL
98730 +batadv_dat_snoop_incoming_arp_request_30548 batadv_dat_snoop_incoming_arp_request 3 30548 NULL
98731 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
98732 +set_le_30581 set_le 4 30581 NULL
98733 +from_cblock_30582 from_cblock 0-1 30582 NULL
98734 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
98735 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
98736 +sgl_map_user_pages_30610 sgl_map_user_pages 2-3-4 30610 NULL
98737 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
98738 +ieee80211_if_read_dot11MeshAwakeWindowDuration_30631 ieee80211_if_read_dot11MeshAwakeWindowDuration 3 30631 NULL
98739 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
98740 +agp_remap_30665 agp_remap 2 30665 NULL
98741 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
98742 +il_free_pages_30692 il_free_pages 2 30692 NULL
98743 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
98744 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
98745 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
98746 +snapshot_status_30744 snapshot_status 5 30744 NULL
98747 +tcf_csum_ipv4_udp_30777 tcf_csum_ipv4_udp 4 30777 NULL
98748 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
98749 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
98750 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
98751 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL
98752 +hda_hwdep_ioctl_compat_30847 hda_hwdep_ioctl_compat 4 30847 NULL
98753 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
98754 +iommu_map_mmio_space_30919 iommu_map_mmio_space 1 30919 NULL
98755 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
98756 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
98757 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
98758 +i2400mu_rx_size_grow_30989 i2400mu_rx_size_grow 0 30989 NULL
98759 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
98760 +phys_pmd_init_31024 phys_pmd_init 0-3-2 31024 NULL
98761 +compat_sys_mq_timedsend_31060 compat_sys_mq_timedsend 3 31060 NULL
98762 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
98763 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
98764 +sys_mincore_31079 sys_mincore 1 31079 NULL
98765 +ttm_bo_ioremap_31082 ttm_bo_ioremap 2-3 31082 NULL
98766 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
98767 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3-4 31109 NULL
98768 +depth_read_31112 depth_read 3 31112 NULL
98769 +ssb_read16_31139 ssb_read16 0 31139 NULL
98770 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
98771 +size_inside_page_31141 size_inside_page 0 31141 NULL
98772 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
98773 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
98774 +acpi_ex_system_memory_space_handler_31192 acpi_ex_system_memory_space_handler 2 31192 NULL
98775 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
98776 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
98777 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
98778 +kvm_mmu_page_fault_31213 kvm_mmu_page_fault 2 31213 NULL
98779 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
98780 +__read_reg_31216 __read_reg 0 31216 NULL
98781 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
98782 +cyy_readb_31240 cyy_readb 0 31240 NULL
98783 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
98784 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
98785 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
98786 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
98787 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
98788 +command_file_write_31318 command_file_write 3 31318 NULL
98789 +em28xx_init_usb_xfer_31337 em28xx_init_usb_xfer 4-6 31337 NULL
98790 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
98791 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 3-2 31374 NULL
98792 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
98793 +inb_31388 inb 0 31388 NULL
98794 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
98795 +mcs7830_set_reg_31413 mcs7830_set_reg 3 31413 NULL
98796 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
98797 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
98798 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
98799 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
98800 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
98801 +do_fcntl_31468 do_fcntl 3 31468 NULL
98802 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
98803 +alg_setkey_31485 alg_setkey 3 31485 NULL
98804 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
98805 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
98806 +__alloc_bootmem_31498 __alloc_bootmem 1-2 31498 NULL
98807 +rmode_tss_base_31510 rmode_tss_base 0 31510 NULL
98808 +hidraw_write_31536 hidraw_write 3 31536 NULL
98809 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
98810 +usbvision_read_31555 usbvision_read 3 31555 NULL
98811 +normalize_31566 normalize 0-1-2 31566 NULL
98812 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
98813 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
98814 +osst_write_31581 osst_write 3 31581 NULL
98815 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
98816 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
98817 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
98818 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
98819 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
98820 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
98821 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
98822 +emulator_set_cr_31665 emulator_set_cr 3 31665 NULL
98823 +__lgread_31668 __lgread 4 31668 NULL
98824 +symbol_string_31670 symbol_string 0 31670 NULL
98825 +_usb_writeN_sync_31682 _usb_writeN_sync 4 31682 NULL
98826 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
98827 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
98828 +audit_log_n_string_31705 audit_log_n_string 3 31705 NULL
98829 +ath6kl_wmi_send_probe_response_cmd_31728 ath6kl_wmi_send_probe_response_cmd 6 31728 NULL nohasharray
98830 +gfn_to_hva_read_31728 gfn_to_hva_read 2 31728 &ath6kl_wmi_send_probe_response_cmd_31728
98831 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL
98832 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3 31741 NULL
98833 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
98834 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
98835 +bcm_char_read_31750 bcm_char_read 3 31750 NULL
98836 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
98837 +set_memory_wb_31761 set_memory_wb 1 31761 NULL
98838 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
98839 +get_count_order_31800 get_count_order 0 31800 NULL
98840 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
98841 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
98842 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
98843 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
98844 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
98845 +ddb_output_write_31902 ddb_output_write 3 31902 NULL
98846 +xattr_permission_31907 xattr_permission 0 31907 NULL
98847 +new_dir_31919 new_dir 3 31919 NULL
98848 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
98849 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
98850 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4 31942 NULL
98851 +vb2_write_31948 vb2_write 3 31948 NULL
98852 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
98853 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
98854 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
98855 +find_next_zero_bit_31990 find_next_zero_bit 0-2-3 31990 NULL
98856 +default_setup_hpet_msi_31991 default_setup_hpet_msi 1 31991 NULL
98857 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
98858 +calc_hmac_32010 calc_hmac 3 32010 NULL
98859 +vmcs_read64_32012 vmcs_read64 0 32012 NULL
98860 +aead_len_32021 aead_len 0 32021 NULL
98861 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3 32032 NULL
98862 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
98863 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
98864 +sys_sched_setaffinity_32046 sys_sched_setaffinity 2 32046 NULL
98865 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
98866 +cfg80211_send_unprot_deauth_32080 cfg80211_send_unprot_deauth 3 32080 NULL
98867 +bio_alloc_32095 bio_alloc 2 32095 NULL
98868 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
98869 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
98870 +disk_status_32120 disk_status 4 32120 NULL
98871 +venus_link_32165 venus_link 5 32165 NULL
98872 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
98873 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
98874 +load_header_32183 load_header 0 32183 NULL
98875 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
98876 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
98877 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
98878 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
98879 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
98880 +fb_compat_ioctl_32265 fb_compat_ioctl 3 32265 NULL
98881 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
98882 +hex_string_32310 hex_string 0 32310 NULL
98883 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
98884 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
98885 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
98886 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL
98887 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL
98888 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
98889 +usbtmc_read_32377 usbtmc_read 3 32377 NULL
98890 +qla4_82xx_pci_mem_write_2M_32398 qla4_82xx_pci_mem_write_2M 2 32398 NULL
98891 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
98892 +vmci_qp_alloc_32405 vmci_qp_alloc 3-5 32405 NULL
98893 +log_text_32428 log_text 0 32428 NULL
98894 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
98895 +hid_input_report_32458 hid_input_report 4 32458 NULL
98896 +cache_status_32462 cache_status 5 32462 NULL
98897 +ieee80211_fill_mesh_addresses_32465 ieee80211_fill_mesh_addresses 0 32465 NULL
98898 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
98899 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
98900 +disconnect_32521 disconnect 4 32521 NULL
98901 +qsfp_read_32522 qsfp_read 0-4-2 32522 NULL
98902 +ilo_read_32531 ilo_read 3 32531 NULL
98903 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL
98904 +gnttab_set_unmap_op_32534 gnttab_set_unmap_op 2 32534 NULL
98905 +ieee80211_send_auth_32543 ieee80211_send_auth 6 32543 NULL
98906 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
98907 +__first_node_32558 __first_node 0 32558 NULL
98908 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
98909 +pnp_mem_len_32584 pnp_mem_len 0 32584 NULL
98910 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
98911 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
98912 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
98913 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
98914 +sys_set_mempolicy_32608 sys_set_mempolicy 3 32608 NULL
98915 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
98916 +ieee80211_hdrlen_32637 ieee80211_hdrlen 0 32637 NULL
98917 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
98918 +kvmalloc_32646 kvmalloc 1 32646 NULL
98919 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
98920 +generic_readlink_32654 generic_readlink 3 32654 NULL
98921 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
98922 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
98923 +snd_hwdep_ioctl_compat_32736 snd_hwdep_ioctl_compat 3 32736 NULL
98924 +get_arg_page_32746 get_arg_page 2 32746 NULL
98925 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
98926 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
98927 +tty_compat_ioctl_32761 tty_compat_ioctl 3 32761 NULL
98928 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
98929 +firmwareUpload_32794 firmwareUpload 3 32794 NULL
98930 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
98931 +vga_rseq_32848 vga_rseq 0 32848 NULL
98932 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
98933 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
98934 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
98935 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
98936 +ath6kl_usb_post_recv_transfers_32892 ath6kl_usb_post_recv_transfers 2 32892 NULL
98937 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
98938 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
98939 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
98940 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
98941 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
98942 +arch_ptrace_32981 arch_ptrace 3 32981 NULL
98943 +compat_filldir_32999 compat_filldir 3 32999 NULL
98944 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3 33007 NULL
98945 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
98946 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
98947 +bitmap_resize_33054 bitmap_resize 2 33054 NULL
98948 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
98949 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
98950 +alloc_tio_33077 alloc_tio 3 33077 NULL
98951 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
98952 +ieee80211_fragment_33112 ieee80211_fragment 4 33112 NULL
98953 +write_node_33121 write_node 4 33121 NULL
98954 +calc_patch_size_33124 calc_patch_size 0 33124 NULL
98955 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
98956 +__len_within_target_33132 __len_within_target 0 33132 NULL
98957 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
98958 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 2-3 33204 NULL
98959 +pp_read_33210 pp_read 3 33210 NULL
98960 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL
98961 +build_completion_wait_33242 build_completion_wait 2 33242 NULL
98962 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
98963 +sched_find_first_bit_33270 sched_find_first_bit 0 33270 NULL
98964 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
98965 +mei_compat_ioctl_33275 mei_compat_ioctl 3 33275 NULL
98966 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
98967 +ath6kl_usb_ctrl_msg_exchange_33327 ath6kl_usb_ctrl_msg_exchange 4 33327 NULL
98968 +gsm_mux_rx_netchar_33336 gsm_mux_rx_netchar 3 33336 NULL
98969 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
98970 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
98971 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
98972 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
98973 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
98974 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
98975 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
98976 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 2-3 33394 NULL
98977 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
98978 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
98979 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
98980 +ubh_scanc_33436 ubh_scanc 0-4-3 33436 NULL
98981 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
98982 +create_entry_33479 create_entry 2 33479 NULL
98983 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
98984 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
98985 +netxen_nic_hw_write_wx_128M_33488 netxen_nic_hw_write_wx_128M 2 33488 NULL
98986 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
98987 +res_counter_read_33499 res_counter_read 4 33499 NULL
98988 +fb_read_33506 fb_read 3 33506 NULL
98989 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
98990 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
98991 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
98992 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
98993 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
98994 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 NULL
98995 +dup_array_33551 dup_array 3 33551 NULL
98996 +solo_enc_read_33553 solo_enc_read 3 33553 NULL
98997 +count_subheaders_33591 count_subheaders 0 33591 NULL
98998 +scsi_execute_33596 scsi_execute 5 33596 NULL
98999 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
99000 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL nohasharray
99001 +ip6_find_1stfragopt_33608 ip6_find_1stfragopt 0 33608 &xt_compat_target_offset_33608
99002 +usb_gstrings_attach_33615 usb_gstrings_attach 3 33615 NULL nohasharray
99003 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 &usb_gstrings_attach_33615
99004 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
99005 +inw_p_33668 inw_p 0 33668 NULL
99006 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
99007 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
99008 +ath6kl_wmi_startscan_cmd_33674 ath6kl_wmi_startscan_cmd 8 33674 NULL
99009 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
99010 +compat_insnlist_33706 compat_insnlist 2 33706 NULL
99011 +sys_keyctl_33708 sys_keyctl 4 33708 NULL nohasharray
99012 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 &sys_keyctl_33708
99013 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
99014 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
99015 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
99016 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
99017 +Read_hfc_33755 Read_hfc 0 33755 NULL
99018 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
99019 +hashtab_create_33769 hashtab_create 3 33769 NULL
99020 +midibuf_message_length_33770 midibuf_message_length 0 33770 NULL
99021 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
99022 +find_next_offset_33804 find_next_offset 3 33804 NULL
99023 +sky2_rx_pad_33819 sky2_rx_pad 0 33819 NULL
99024 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
99025 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
99026 +udplite_manip_pkt_33832 udplite_manip_pkt 4 33832 NULL
99027 +usb_dump_endpoint_descriptor_33849 usb_dump_endpoint_descriptor 0 33849 NULL
99028 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
99029 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
99030 +cap_mmap_addr_33853 cap_mmap_addr 0 33853 NULL
99031 +get_user_pages_33908 get_user_pages 0-3-4 33908 NULL
99032 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
99033 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
99034 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
99035 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL
99036 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
99037 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
99038 +ppp_write_34034 ppp_write 3 34034 NULL
99039 +tty_insert_flip_string_34042 tty_insert_flip_string 3 34042 NULL
99040 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
99041 +acpi_dev_get_irqresource_34064 acpi_dev_get_irqresource 2 34064 NULL
99042 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
99043 +read_file_ant_diversity_34071 read_file_ant_diversity 3 34071 NULL
99044 +compat_hdio_ioctl_34088 compat_hdio_ioctl 4 34088 NULL
99045 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
99046 +is_discarded_oblock_34120 is_discarded_oblock 2 34120 NULL
99047 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
99048 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2 34135 NULL
99049 +cdc_mbim_process_dgram_34136 cdc_mbim_process_dgram 3 34136 NULL
99050 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
99051 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
99052 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
99053 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
99054 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
99055 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
99056 +zone_spanned_pages_in_node_34299 zone_spanned_pages_in_node 0 34299 NULL
99057 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
99058 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
99059 +__insert_34349 __insert 2-3 34349 NULL
99060 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 NULL
99061 +rngapi_reset_34366 rngapi_reset 3 34366 NULL nohasharray
99062 +p54_alloc_skb_34366 p54_alloc_skb 3 34366 &rngapi_reset_34366
99063 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
99064 +ea_read_34378 ea_read 0 34378 NULL
99065 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
99066 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
99067 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
99068 +iwl_calib_set_34400 iwl_calib_set 3 34400 NULL nohasharray
99069 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 &iwl_calib_set_34400
99070 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
99071 +usbtest_alloc_urb_34446 usbtest_alloc_urb 3-5 34446 NULL
99072 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
99073 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
99074 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
99075 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
99076 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL
99077 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 0-2-5-4 34547 NULL
99078 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
99079 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL
99080 +velocity_rx_copy_34583 velocity_rx_copy 2 34583 NULL
99081 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
99082 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
99083 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL
99084 +brcmf_cfg80211_mgmt_tx_34608 brcmf_cfg80211_mgmt_tx 7 34608 NULL
99085 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL
99086 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
99087 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
99088 +tomoyo_dump_page_34649 tomoyo_dump_page 2 34649 NULL
99089 +nf_nat_mangle_udp_packet_34661 nf_nat_mangle_udp_packet 8-6 34661 NULL
99090 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
99091 +port_print_34704 port_print 3 34704 NULL
99092 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
99093 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
99094 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
99095 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
99096 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
99097 +__copy_in_user_34790 __copy_in_user 3 34790 NULL
99098 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
99099 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
99100 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
99101 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
99102 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
99103 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
99104 +msg_print_text_34889 msg_print_text 0 34889 NULL
99105 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
99106 +compat_put_uint_34905 compat_put_uint 1 34905 NULL
99107 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
99108 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
99109 +skb_gro_header_slow_34958 skb_gro_header_slow 2 34958 NULL
99110 +Realloc_34961 Realloc 2 34961 NULL
99111 +mq_lookup_34990 mq_lookup 2 34990 NULL
99112 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
99113 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
99114 +dm_cache_insert_mapping_35005 dm_cache_insert_mapping 2-3 35005 NULL
99115 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
99116 +alloc_p2m_page_35025 alloc_p2m_page 0 35025 NULL
99117 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
99118 +btmrvl_gpiogap_write_35053 btmrvl_gpiogap_write 3 35053 NULL
99119 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
99120 +store_ifalias_35088 store_ifalias 4 35088 NULL
99121 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
99122 +capi_write_35104 capi_write 3 35104 NULL nohasharray
99123 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
99124 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
99125 +pointer_35138 pointer 0 35138 NULL
99126 +gntdev_alloc_map_35145 gntdev_alloc_map 2 35145 NULL
99127 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
99128 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
99129 +mlx4_ib_get_cq_umem_35184 mlx4_ib_get_cq_umem 5-6 35184 NULL
99130 +iwl_nvm_read_chunk_35198 iwl_nvm_read_chunk 0 35198 NULL
99131 +uprobe_get_swbp_addr_35201 uprobe_get_swbp_addr 0 35201 NULL
99132 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
99133 +_osd_req_alist_elem_size_35216 _osd_req_alist_elem_size 0-2 35216 NULL
99134 +striped_read_35218 striped_read 0-2-8-3 35218 NULL nohasharray
99135 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
99136 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 NULL nohasharray
99137 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 &rx_rx_cmplt_task_read_35226
99138 +gfn_to_page_many_atomic_35234 gfn_to_page_many_atomic 2 35234 NULL
99139 +set_fd_set_35249 set_fd_set 1 35249 NULL
99140 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
99141 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
99142 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
99143 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
99144 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
99145 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
99146 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
99147 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
99148 +sys_setsockopt_35320 sys_setsockopt 5 35320 NULL
99149 +irq_domain_disassociate_many_35325 irq_domain_disassociate_many 2-3 35325 NULL
99150 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
99151 +pskb_network_may_pull_35336 pskb_network_may_pull 2 35336 NULL
99152 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
99153 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
99154 +hpi_alloc_control_cache_35351 hpi_alloc_control_cache 1 35351 NULL
99155 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
99156 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
99157 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
99158 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
99159 +i915_wedged_read_35474 i915_wedged_read 3 35474 NULL
99160 +ecryptfs_get_zeroed_pages_35483 ecryptfs_get_zeroed_pages 0 35483 NULL
99161 +do_atm_ioctl_35519 do_atm_ioctl 3 35519 NULL
99162 +async_setkey_35521 async_setkey 3 35521 NULL
99163 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
99164 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
99165 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
99166 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
99167 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
99168 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
99169 +spk_msg_set_35586 spk_msg_set 3 35586 NULL
99170 +ReadZReg_35604 ReadZReg 0 35604 NULL
99171 +kernel_readv_35617 kernel_readv 3 35617 NULL
99172 +ixgbe_pci_sriov_configure_35624 ixgbe_pci_sriov_configure 2 35624 NULL
99173 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
99174 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
99175 +store_debug_level_35652 store_debug_level 3 35652 NULL
99176 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
99177 +compat_sys_kexec_load_35674 compat_sys_kexec_load 2 35674 NULL
99178 +dm_table_create_35687 dm_table_create 3 35687 NULL
99179 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
99180 +pci_enable_sriov_35745 pci_enable_sriov 2 35745 NULL
99181 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
99182 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
99183 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
99184 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
99185 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
99186 +fls64_35862 fls64 0 35862 NULL
99187 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
99188 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
99189 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
99190 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
99191 +rbio_nr_pages_35916 rbio_nr_pages 0-1-2 35916 NULL
99192 +vol_cdev_compat_ioctl_35923 vol_cdev_compat_ioctl 3 35923 NULL
99193 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
99194 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
99195 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
99196 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
99197 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL
99198 +acl_alloc_35979 acl_alloc 1 35979 NULL
99199 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
99200 +koneplus_sysfs_write_35993 koneplus_sysfs_write 6 35993 NULL
99201 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
99202 +ubi_eba_write_leb_36029 ubi_eba_write_leb 5-6 36029 NULL
99203 +account_shadowed_36048 account_shadowed 2 36048 NULL
99204 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
99205 +write_emulate_36065 write_emulate 2-4 36065 NULL
99206 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
99207 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
99208 +ext3_new_blocks_36073 ext3_new_blocks 3 36073 NULL
99209 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
99210 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
99211 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
99212 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
99213 +compat_ptrace_request_36131 compat_ptrace_request 3-4 36131 NULL
99214 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
99215 +max8925_irq_domain_map_36133 max8925_irq_domain_map 2 36133 NULL
99216 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
99217 +alloc_vm_area_36149 alloc_vm_area 1 36149 NULL
99218 +twl_set_36154 twl_set 2 36154 NULL
99219 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
99220 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
99221 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
99222 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
99223 +is_dirty_36223 is_dirty 2 36223 NULL
99224 +dma_alloc_attrs_36225 dma_alloc_attrs 0 36225 NULL
99225 +nfqnl_mangle_36226 nfqnl_mangle 4-2 36226 NULL
99226 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
99227 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
99228 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
99229 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
99230 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
99231 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL
99232 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
99233 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
99234 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
99235 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
99236 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
99237 +fuse_get_user_addr_36312 fuse_get_user_addr 0 36312 NULL
99238 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
99239 +lc_create_36332 lc_create 4 36332 NULL
99240 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
99241 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
99242 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
99243 +to_sector_36361 to_sector 0-1 36361 NULL
99244 +tunables_read_36385 tunables_read 3 36385 NULL
99245 +afs_alloc_flat_call_36399 afs_alloc_flat_call 2-3 36399 NULL
99246 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
99247 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
99248 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
99249 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 NULL
99250 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
99251 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
99252 +get_param_l_36518 get_param_l 0 36518 NULL
99253 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
99254 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
99255 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
99256 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
99257 +get_entry_len_36549 get_entry_len 0 36549 NULL
99258 +__kfifo_to_user_36555 __kfifo_to_user 3 36555 NULL nohasharray
99259 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
99260 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
99261 +ssb_bus_scan_36578 ssb_bus_scan 2 36578 NULL
99262 +__erst_read_36579 __erst_read 0 36579 NULL
99263 +put_cmsg_36589 put_cmsg 4 36589 NULL
99264 +pcnet32_realloc_rx_ring_36598 pcnet32_realloc_rx_ring 3 36598 NULL
99265 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
99266 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
99267 +format_decode_36638 format_decode 0 36638 NULL
99268 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
99269 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
99270 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
99271 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
99272 +ptr_to_compat_36680 ptr_to_compat 0 36680 NULL
99273 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 NULL
99274 +extract_icmp6_fields_36732 extract_icmp6_fields 2 36732 NULL
99275 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4 36740 NULL
99276 +cxgbi_device_register_36746 cxgbi_device_register 1-2 36746 NULL
99277 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
99278 +ip4ip6_err_36772 ip4ip6_err 5 36772 NULL
99279 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
99280 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
99281 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
99282 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
99283 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 NULL
99284 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
99285 +cm_write_36858 cm_write 3 36858 NULL
99286 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
99287 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
99288 +raid56_parity_write_36877 raid56_parity_write 5 36877 NULL
99289 +__btrfs_map_block_36883 __btrfs_map_block 3 36883 NULL
99290 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
99291 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
99292 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
99293 +build_key_36931 build_key 1 36931 NULL
99294 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
99295 +write_leb_36957 write_leb 5 36957 NULL
99296 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
99297 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
99298 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
99299 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
99300 +setxattr_37006 setxattr 4 37006 NULL
99301 +qp_broker_create_37053 qp_broker_create 6-5 37053 NULL nohasharray
99302 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 &qp_broker_create_37053
99303 +parse_command_37079 parse_command 2 37079 NULL
99304 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
99305 +tun_get_user_37094 tun_get_user 5 37094 NULL
99306 +has_wrprotected_page_37123 has_wrprotected_page 2-3 37123 NULL
99307 +snd_hda_get_conn_list_37132 snd_hda_get_conn_list 0 37132 NULL
99308 +msg_word_37164 msg_word 0 37164 NULL
99309 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
99310 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL
99311 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
99312 +__do_replace_37227 __do_replace 5 37227 NULL
99313 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
99314 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
99315 +ath6kl_wmi_set_ie_cmd_37260 ath6kl_wmi_set_ie_cmd 6 37260 NULL
99316 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
99317 +nested_svm_map_37268 nested_svm_map 2 37268 NULL
99318 +c101_run_37279 c101_run 2 37279 NULL
99319 +srp_target_alloc_37288 srp_target_alloc 3 37288 NULL
99320 +ieee80211_if_read_power_mode_37305 ieee80211_if_read_power_mode 3 37305 NULL
99321 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
99322 +send_msg_37323 send_msg 4 37323 NULL
99323 +brcmf_sdbrcm_membytes_37324 brcmf_sdbrcm_membytes 3-5 37324 NULL
99324 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL
99325 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
99326 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
99327 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
99328 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
99329 +sys_getxattr_37418 sys_getxattr 4 37418 NULL
99330 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
99331 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
99332 +find_next_bit_37422 find_next_bit 0-2-3 37422 &acpi_os_allocate_zeroed_37422
99333 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4 37428 NULL
99334 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
99335 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
99336 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
99337 +__remove_37457 __remove 2 37457 NULL
99338 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
99339 +get_est_timing_37484 get_est_timing 0 37484 NULL
99340 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
99341 +kvm_vcpu_compat_ioctl_37500 kvm_vcpu_compat_ioctl 3 37500 NULL
99342 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 NULL
99343 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
99344 +hdr_size_37536 hdr_size 0 37536 NULL
99345 +a2p_37544 a2p 0-1 37544 NULL
99346 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL nohasharray
99347 +nf_nat_mangle_tcp_packet_37551 nf_nat_mangle_tcp_packet 6-8 37551 &sep_create_dcb_dmatables_context_37551
99348 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
99349 +mlx4_get_mgm_entry_size_37607 mlx4_get_mgm_entry_size 0 37607 NULL
99350 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6-3 37611 NULL
99351 +policy_residency_37629 policy_residency 0 37629 NULL
99352 +check_pt_base_37635 check_pt_base 3 37635 NULL
99353 +alloc_fd_37637 alloc_fd 1 37637 NULL
99354 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
99355 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
99356 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
99357 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
99358 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
99359 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
99360 +nametbl_header_37698 nametbl_header 2 37698 NULL
99361 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
99362 +dm_thin_remove_block_37724 dm_thin_remove_block 2 37724 NULL
99363 +find_active_uprobe_37733 find_active_uprobe 1 37733 NULL
99364 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
99365 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 6-4-5 37749 NULL
99366 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
99367 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
99368 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
99369 +dma_pte_addr_37784 dma_pte_addr 0 37784 NULL
99370 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
99371 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
99372 +deny_write_access_37813 deny_write_access 0 37813 NULL
99373 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
99374 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-5-4 37827 NULL
99375 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
99376 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 NULL
99377 +sys_setxattr_37880 sys_setxattr 4 37880 NULL
99378 +dvb_net_sec_37884 dvb_net_sec 3 37884 NULL
99379 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
99380 +compat_sys_rt_sigpending_37899 compat_sys_rt_sigpending 2 37899 NULL
99381 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
99382 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 NULL
99383 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
99384 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
99385 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 3-4 37967 NULL
99386 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
99387 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
99388 +vfs_readv_38011 vfs_readv 3 38011 NULL
99389 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
99390 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
99391 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
99392 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL nohasharray
99393 +is_discarded_38058 is_discarded 2 38058 &_xfs_buf_alloc_38058
99394 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
99395 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
99396 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
99397 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
99398 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
99399 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
99400 +ep0_read_38095 ep0_read 3 38095 NULL
99401 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL
99402 +rbd_obj_read_sync_38098 rbd_obj_read_sync 3-4 38098 NULL
99403 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
99404 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
99405 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 3-4 38153 NULL
99406 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
99407 +cdev_add_38176 cdev_add 2-3 38176 NULL
99408 +brcmf_sdcard_recv_buf_38179 brcmf_sdcard_recv_buf 6 38179 NULL
99409 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
99410 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
99411 +ext3_new_block_38208 ext3_new_block 3 38208 NULL
99412 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
99413 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
99414 +palmas_gpio_to_irq_38235 palmas_gpio_to_irq 2 38235 NULL
99415 +vhost_net_compat_ioctl_38237 vhost_net_compat_ioctl 3 38237 NULL
99416 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
99417 +from_dblock_38256 from_dblock 0-1 38256 NULL
99418 +vmci_qp_broker_set_page_store_38260 vmci_qp_broker_set_page_store 2-3 38260 NULL
99419 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
99420 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &ieee80211_if_read_auto_open_plinks_38268
99421 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 NULL nohasharray
99422 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 &xfs_bmbt_to_bmdr_38275
99423 +ftdi_process_packet_38281 ftdi_process_packet 4 38281 NULL nohasharray
99424 +swiotlb_sync_single_for_cpu_38281 swiotlb_sync_single_for_cpu 2 38281 &ftdi_process_packet_38281
99425 +gpa_to_gfn_38291 gpa_to_gfn 0-1 38291 NULL
99426 +zd_mac_rx_38296 zd_mac_rx 3 38296 NULL
99427 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
99428 +ida_simple_get_38326 ida_simple_get 2 38326 NULL
99429 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
99430 +pyra_sysfs_write_38370 pyra_sysfs_write 6 38370 NULL
99431 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
99432 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
99433 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 2 38413 NULL
99434 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
99435 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
99436 +asix_write_cmd_async_38420 asix_write_cmd_async 5 38420 NULL
99437 +pcnet32_realloc_tx_ring_38428 pcnet32_realloc_tx_ring 3 38428 NULL
99438 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
99439 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
99440 +i915_min_freq_read_38470 i915_min_freq_read 3 38470 NULL
99441 +kvm_arch_setup_async_pf_38481 kvm_arch_setup_async_pf 3 38481 NULL
99442 +blk_end_bidi_request_38482 blk_end_bidi_request 3-4 38482 NULL
99443 +dev_names_read_38509 dev_names_read 3 38509 NULL
99444 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
99445 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
99446 +set_queue_count_38519 set_queue_count 0 38519 NULL
99447 +mlx4_ib_db_map_user_38529 mlx4_ib_db_map_user 2 38529 NULL
99448 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
99449 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
99450 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
99451 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
99452 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
99453 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
99454 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
99455 +cosa_net_setup_rx_38594 cosa_net_setup_rx 2 38594 NULL
99456 +compat_sys_ptrace_38595 compat_sys_ptrace 3-4 38595 NULL
99457 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
99458 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
99459 +cma_create_area_38642 cma_create_area 2 38642 NULL
99460 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
99461 +qp_broker_alloc_38646 qp_broker_alloc 5-6 38646 NULL
99462 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
99463 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
99464 +cfg80211_send_disassoc_38678 cfg80211_send_disassoc 3 38678 NULL
99465 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
99466 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
99467 +rbio_add_io_page_38700 rbio_add_io_page 6 38700 NULL
99468 +find_next_usable_block_38716 find_next_usable_block 1-3 38716 NULL
99469 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
99470 +phys_to_virt_38757 phys_to_virt 0-1 38757 NULL
99471 +udf_readpages_38761 udf_readpages 4 38761 NULL
99472 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
99473 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
99474 +err_decode_38804 err_decode 2 38804 NULL
99475 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
99476 +sys_select_38827 sys_select 1 38827 NULL
99477 +b43_txhdr_size_38832 b43_txhdr_size 0 38832 NULL
99478 +direct_entry_38836 direct_entry 3 38836 NULL
99479 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
99480 +interfaces_38859 interfaces 2 38859 NULL
99481 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
99482 +sizeof_gpio_leds_priv_38882 sizeof_gpio_leds_priv 0-1 38882 NULL
99483 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
99484 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
99485 +process_bulk_data_command_38906 process_bulk_data_command 4 38906 NULL
99486 +ext3_trim_all_free_38929 ext3_trim_all_free 3-4-2 38929 NULL
99487 +sbp_count_se_tpg_luns_38943 sbp_count_se_tpg_luns 0 38943 NULL
99488 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
99489 +usb_maxpacket_38977 usb_maxpacket 0 38977 NULL
99490 +OSDSetBlock_38986 OSDSetBlock 4-2 38986 NULL
99491 +udf_new_block_38999 udf_new_block 4 38999 NULL
99492 +get_nodes_39012 get_nodes 3 39012 NULL
99493 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
99494 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
99495 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
99496 +line6_midibuf_read_39067 line6_midibuf_read 0-3 39067 NULL
99497 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
99498 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
99499 +__kfifo_to_user_r_39123 __kfifo_to_user_r 3 39123 NULL
99500 +ea_foreach_39133 ea_foreach 0 39133 NULL
99501 +generic_permission_39150 generic_permission 0 39150 NULL
99502 +alloc_ring_39151 alloc_ring 2-4 39151 NULL
99503 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
99504 +create_bounce_buffer_39155 create_bounce_buffer 3 39155 NULL
99505 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
99506 +init_list_set_39188 init_list_set 2-3 39188 NULL
99507 +ubi_more_update_data_39189 ubi_more_update_data 4 39189 NULL
99508 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
99509 +qla4_82xx_pci_mem_read_direct_39208 qla4_82xx_pci_mem_read_direct 2 39208 NULL
99510 +vfio_group_fops_compat_ioctl_39219 vfio_group_fops_compat_ioctl 3 39219 NULL
99511 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
99512 +batadv_tt_response_fill_table_39236 batadv_tt_response_fill_table 1 39236 NULL
99513 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
99514 +drm_order_39244 drm_order 0 39244 NULL
99515 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
99516 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
99517 +__skb_cow_39254 __skb_cow 2 39254 NULL
99518 +ath6kl_wmi_set_appie_cmd_39266 ath6kl_wmi_set_appie_cmd 5 39266 NULL
99519 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
99520 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
99521 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
99522 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
99523 +__cfg80211_send_deauth_39344 __cfg80211_send_deauth 3 39344 NULL
99524 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3 39351 NULL
99525 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
99526 +do_write_log_from_user_39362 do_write_log_from_user 3 39362 NULL
99527 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
99528 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
99529 +fnic_trace_debugfs_read_39380 fnic_trace_debugfs_read 3 39380 NULL
99530 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
99531 +__send_to_port_39386 __send_to_port 3 39386 NULL
99532 +user_power_read_39414 user_power_read 3 39414 NULL
99533 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
99534 +sys_semop_39457 sys_semop 3 39457 NULL
99535 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
99536 +do_get_mempolicy_39485 do_get_mempolicy 3 39485 NULL
99537 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
99538 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
99539 +int_proc_write_39542 int_proc_write 3 39542 NULL
99540 +pp_write_39554 pp_write 3 39554 NULL
99541 +ol_dqblk_block_39558 ol_dqblk_block 0-3-2 39558 NULL
99542 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
99543 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
99544 +handle_response_icmp_39574 handle_response_icmp 7 39574 NULL
99545 +mtdchar_compat_ioctl_39602 mtdchar_compat_ioctl 3 39602 NULL
99546 +n_tty_compat_ioctl_helper_39605 n_tty_compat_ioctl_helper 4 39605 NULL
99547 +ext_depth_39607 ext_depth 0 39607 NULL
99548 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
99549 +sdio_readb_39618 sdio_readb 0 39618 NULL
99550 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
99551 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
99552 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
99553 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL nohasharray
99554 +prism2_info_hostscanresults_39657 prism2_info_hostscanresults 3 39657 &tcp_try_rmem_schedule_39657
99555 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
99556 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
99557 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
99558 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
99559 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
99560 +tcf_csum_ipv4_tcp_39713 tcf_csum_ipv4_tcp 4 39713 NULL
99561 +remap_to_origin_clear_discard_39767 remap_to_origin_clear_discard 3 39767 NULL
99562 +ocfs2_pages_per_cluster_39790 ocfs2_pages_per_cluster 0 39790 NULL
99563 +crypto_ablkcipher_blocksize_39811 crypto_ablkcipher_blocksize 0 39811 NULL
99564 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
99565 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
99566 +sys_migrate_pages_39825 sys_migrate_pages 2 39825 NULL
99567 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
99568 +pkt_add_39897 pkt_add 3 39897 NULL
99569 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
99570 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
99571 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
99572 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
99573 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
99574 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
99575 +__spi_async_39932 __spi_async 0 39932 NULL
99576 +__get_order_39935 __get_order 0 39935 NULL
99577 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL nohasharray
99578 +fwnet_pd_new_39947 fwnet_pd_new 4 39947 &error_error_frame_read_39947
99579 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3 39955 NULL
99580 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
99581 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
99582 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
99583 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
99584 +nf_nat_icmpv6_reply_translation_40023 nf_nat_icmpv6_reply_translation 5 40023 NULL nohasharray
99585 +ivtvfb_write_40023 ivtvfb_write 3 40023 &nf_nat_icmpv6_reply_translation_40023
99586 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
99587 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
99588 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
99589 +add_tty_40055 add_tty 1 40055 NULL nohasharray
99590 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
99591 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
99592 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
99593 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
99594 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
99595 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
99596 +pt_write_40159 pt_write 3 40159 NULL
99597 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
99598 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
99599 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
99600 +allocate_probes_40204 allocate_probes 1 40204 NULL
99601 +compat_put_long_40214 compat_put_long 1 40214 NULL
99602 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
99603 +osst_read_40237 osst_read 3 40237 NULL
99604 +lpage_info_slot_40243 lpage_info_slot 1-3 40243 NULL
99605 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4 40248 NULL
99606 +of_get_child_count_40254 of_get_child_count 0 40254 NULL
99607 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
99608 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
99609 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
99610 +crash_free_reserved_phys_range_40292 crash_free_reserved_phys_range 1 40292 NULL
99611 +ubi_io_write_data_40305 ubi_io_write_data 4-5 40305 NULL
99612 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
99613 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
99614 +mmio_read_40348 mmio_read 4 40348 NULL
99615 +usb_dump_interface_40353 usb_dump_interface 0 40353 NULL
99616 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4 40355 NULL
99617 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
99618 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 2-3 40365 NULL
99619 +fwnet_incoming_packet_40380 fwnet_incoming_packet 3 40380 NULL
99620 +brcmf_sdbrcm_get_image_40397 brcmf_sdbrcm_get_image 0-2 40397 NULL
99621 +atmel_rmem16_40450 atmel_rmem16 0 40450 NULL
99622 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
99623 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
99624 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
99625 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
99626 +tty_write_room_40495 tty_write_room 0 40495 NULL
99627 +persistent_ram_new_40501 persistent_ram_new 1-2 40501 NULL
99628 +sg_phys_40507 sg_phys 0 40507 NULL
99629 +TSS_checkhmac2_40520 TSS_checkhmac2 5-7 40520 NULL
99630 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
99631 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
99632 +esp_alloc_tmp_40558 esp_alloc_tmp 3-2 40558 NULL
99633 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
99634 +skge_rx_get_40598 skge_rx_get 3 40598 NULL
99635 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
99636 +bl_mark_sectors_init_40613 bl_mark_sectors_init 2-3 40613 NULL
99637 +cpuset_sprintf_cpulist_40627 cpuset_sprintf_cpulist 0 40627 NULL
99638 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
99639 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
99640 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
99641 +fops_read_40672 fops_read 3 40672 NULL
99642 +alloc_rbio_40676 alloc_rbio 4 40676 NULL
99643 +videobuf_dma_init_user_locked_40678 videobuf_dma_init_user_locked 3 40678 NULL
99644 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
99645 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
99646 +fuse_readpages_40737 fuse_readpages 4 40737 NULL
99647 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
99648 +find_next_zero_bit_le_40744 find_next_zero_bit_le 0-2-3 40744 &xfs_iext_remove_direct_40744
99649 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
99650 +fat_generic_compat_ioctl_40755 fat_generic_compat_ioctl 3 40755 NULL
99651 +card_send_command_40757 card_send_command 3 40757 NULL
99652 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
99653 +pg_write_40766 pg_write 3 40766 NULL
99654 +show_list_40775 show_list 3 40775 NULL
99655 +kfifo_out_copy_r_40784 kfifo_out_copy_r 0-3 40784 NULL
99656 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
99657 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
99658 +netdev_alloc_skb_ip_align_40811 netdev_alloc_skb_ip_align 2 40811 NULL
99659 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
99660 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
99661 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
99662 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
99663 +read_file_queue_40895 read_file_queue 3 40895 NULL
99664 +waiters_read_40902 waiters_read 3 40902 NULL
99665 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
99666 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
99667 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
99668 +snd_vx_create_40948 snd_vx_create 4 40948 NULL
99669 +skb_end_offset_40949 skb_end_offset 0 40949 NULL
99670 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
99671 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
99672 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
99673 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
99674 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
99675 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
99676 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
99677 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
99678 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL
99679 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
99680 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
99681 +nvme_map_user_pages_41093 nvme_map_user_pages 3-4 41093 &roccat_read_41093
99682 +dma_attach_41094 dma_attach 5-6 41094 NULL
99683 +provide_user_output_41105 provide_user_output 3 41105 NULL
99684 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
99685 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
99686 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
99687 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
99688 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
99689 +netif_get_num_default_rss_queues_41187 netif_get_num_default_rss_queues 0 41187 NULL
99690 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
99691 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
99692 +xfs_readdir_41200 xfs_readdir 3 41200 NULL
99693 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
99694 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
99695 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2-3 41255 NULL
99696 +erst_read_41260 erst_read 0 41260 NULL
99697 +__fprog_create_41263 __fprog_create 2 41263 NULL
99698 +alloc_context_41283 alloc_context 1 41283 NULL
99699 +arch_gnttab_map_shared_41306 arch_gnttab_map_shared 3 41306 NULL
99700 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
99701 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
99702 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
99703 +kmp_init_41373 kmp_init 2 41373 NULL
99704 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
99705 +is_writethrough_io_41406 is_writethrough_io 3 41406 NULL
99706 +sys_flistxattr_41407 sys_flistxattr 3 41407 NULL
99707 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
99708 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
99709 +vsock_dev_compat_ioctl_41427 vsock_dev_compat_ioctl 3 41427 NULL
99710 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
99711 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
99712 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
99713 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 4-6 41442 NULL
99714 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
99715 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
99716 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
99717 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
99718 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
99719 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
99720 +ldisc_receive_41516 ldisc_receive 4 41516 NULL
99721 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
99722 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
99723 +nr_status_frames_41559 nr_status_frames 0-1 41559 NULL
99724 +batadv_receive_client_update_packet_41578 batadv_receive_client_update_packet 3 41578 NULL
99725 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
99726 +read_file_rx_chainmask_41605 read_file_rx_chainmask 3 41605 NULL
99727 +vga_io_r_41609 vga_io_r 0 41609 NULL
99728 +tcp_hdrlen_41610 tcp_hdrlen 0 41610 NULL
99729 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 NULL
99730 +a2mp_send_41615 a2mp_send 4 41615 NULL
99731 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
99732 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
99733 +get_std_timing_41654 get_std_timing 0 41654 NULL
99734 +squashfs_cache_init_41656 squashfs_cache_init 2 41656 NULL
99735 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
99736 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
99737 +aac_src_ioremap_41688 aac_src_ioremap 2 41688 NULL
99738 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
99739 +sys_pwritev_41722 sys_pwritev 3 41722 NULL
99740 +get_bios_ebda_41730 get_bios_ebda 0 41730 NULL
99741 +fillonedir_41746 fillonedir 3 41746 NULL
99742 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
99743 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
99744 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
99745 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
99746 +lp_gpio_to_irq_41822 lp_gpio_to_irq 2 41822 NULL
99747 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
99748 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
99749 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
99750 +ieee80211_rx_radiotap_space_41870 ieee80211_rx_radiotap_space 0 41870 NULL
99751 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
99752 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
99753 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
99754 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
99755 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
99756 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
99757 +portnames_read_41958 portnames_read 3 41958 NULL
99758 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 4 41959 NULL
99759 +dst_mtu_41969 dst_mtu 0 41969 NULL
99760 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
99761 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
99762 +lguest_map_42008 lguest_map 1-2 42008 NULL
99763 +pool_allocate_42012 pool_allocate 3 42012 NULL
99764 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
99765 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
99766 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
99767 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
99768 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
99769 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
99770 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
99771 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
99772 +alloc_bitset_42085 alloc_bitset 1 42085 NULL
99773 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
99774 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
99775 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
99776 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL nohasharray
99777 +dw_dma_cyclic_prep_42113 dw_dma_cyclic_prep 3-4 42113 &sysfs_read_file_42113
99778 +Read_hfc16_stable_42131 Read_hfc16_stable 0 42131 NULL
99779 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
99780 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
99781 +iwl_mvm_send_cmd_42173 iwl_mvm_send_cmd 0 42173 NULL
99782 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
99783 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
99784 +btmrvl_hsmode_write_42252 btmrvl_hsmode_write 3 42252 NULL
99785 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
99786 +netxen_nic_map_indirect_address_128M_42257 netxen_nic_map_indirect_address_128M 2 42257 NULL
99787 +savu_sysfs_write_42273 savu_sysfs_write 6 42273 NULL
99788 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
99789 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
99790 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
99791 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
99792 +gfn_to_hva_42305 gfn_to_hva 0-2 42305 NULL
99793 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 NULL
99794 +free_cblock_42318 free_cblock 2 42318 NULL
99795 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
99796 +tcp_sync_mss_42330 tcp_sync_mss 0-2 42330 NULL
99797 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
99798 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
99799 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
99800 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
99801 +krng_get_random_42420 krng_get_random 3 42420 NULL
99802 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
99803 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
99804 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
99805 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
99806 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
99807 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
99808 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
99809 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
99810 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
99811 +brcmf_sdbrcm_bus_txctl_42492 brcmf_sdbrcm_bus_txctl 3 42492 NULL
99812 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
99813 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
99814 +snd_emux_create_port_42533 snd_emux_create_port 3 42533 NULL
99815 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
99816 +i915_ring_stop_read_42549 i915_ring_stop_read 3 42549 NULL nohasharray
99817 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 &i915_ring_stop_read_42549
99818 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
99819 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
99820 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
99821 +map_state_42602 map_state 1 42602 NULL nohasharray
99822 +__pskb_pull_42602 __pskb_pull 2 42602 &map_state_42602
99823 +nd_get_link_42603 nd_get_link 0 42603 NULL
99824 +sys_move_pages_42626 sys_move_pages 2 42626 NULL
99825 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
99826 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
99827 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
99828 +l2tp_xmit_skb_42672 l2tp_xmit_skb 3 42672 NULL
99829 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
99830 +vb2_read_42703 vb2_read 3 42703 NULL
99831 +sierra_net_send_cmd_42708 sierra_net_send_cmd 3 42708 NULL
99832 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 4 42717 NULL
99833 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
99834 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
99835 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
99836 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
99837 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
99838 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL
99839 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
99840 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
99841 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2-3 42804 NULL
99842 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
99843 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
99844 +set_arg_42824 set_arg 3 42824 NULL
99845 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
99846 +prandom_u32_42853 prandom_u32 0 42853 NULL
99847 +of_property_count_strings_42863 of_property_count_strings 0 42863 NULL
99848 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
99849 +pskb_expand_head_42881 pskb_expand_head 2-3 42881 NULL
99850 +vt_compat_ioctl_42887 vt_compat_ioctl 3 42887 NULL
99851 +tipc_port_recv_sections_42890 tipc_port_recv_sections 4 42890 NULL
99852 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
99853 +SendTxCommandPacket_42901 SendTxCommandPacket 3 42901 NULL
99854 +hd_end_request_42904 hd_end_request 2 42904 NULL
99855 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
99856 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
99857 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
99858 +sys_sethostname_42962 sys_sethostname 2 42962 NULL
99859 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
99860 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
99861 +snd_timer_user_ioctl_compat_42985 snd_timer_user_ioctl_compat 3 42985 NULL
99862 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 4-2 42990 NULL
99863 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
99864 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
99865 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
99866 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
99867 +nfs_map_group_to_gid_43082 nfs_map_group_to_gid 3 43082 NULL
99868 +cpuset_sprintf_memlist_43088 cpuset_sprintf_memlist 0 43088 NULL
99869 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
99870 +read_file_dfs_43145 read_file_dfs 3 43145 NULL
99871 +uuid_string_43154 uuid_string 0 43154 NULL
99872 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
99873 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
99874 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
99875 +process_measurement_43190 process_measurement 0 43190 NULL
99876 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
99877 +uio_write_43202 uio_write 3 43202 NULL
99878 +iso_callback_43208 iso_callback 3 43208 NULL
99879 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
99880 +atomic_long_add_return_43217 atomic_long_add_return 1 43217 NULL
99881 +comedi_compat_ioctl_43218 comedi_compat_ioctl 3 43218 NULL
99882 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
99883 +fixup_leb_43256 fixup_leb 3 43256 NULL
99884 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
99885 +evtchn_write_43278 evtchn_write 3 43278 NULL
99886 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
99887 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
99888 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
99889 +mmu_set_spte_43327 mmu_set_spte 6-7 43327 NULL
99890 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
99891 +kvm_host_page_size_43348 kvm_host_page_size 2 43348 NULL
99892 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
99893 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1-2 43423 NULL nohasharray
99894 +gdm_wimax_netif_rx_43423 gdm_wimax_netif_rx 3 43423 &__alloc_bootmem_low_43423
99895 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
99896 +ucs2_strsize_43438 ucs2_strsize 0 43438 NULL
99897 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
99898 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
99899 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
99900 +alloc_new_reservation_43480 alloc_new_reservation 4 43480 NULL
99901 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
99902 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
99903 +do_readlink_43518 do_readlink 2 43518 NULL
99904 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
99905 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
99906 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
99907 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
99908 +ath_rx_init_43564 ath_rx_init 2 43564 NULL
99909 +_fc_frame_alloc_43568 _fc_frame_alloc 1 43568 NULL
99910 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
99911 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
99912 +proc_read_43614 proc_read 3 43614 NULL
99913 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
99914 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 NULL
99915 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4-2 43679 NULL
99916 +calgary_map_page_43686 calgary_map_page 3-4 43686 NULL
99917 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
99918 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
99919 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5 43733 NULL
99920 +osdv1_attr_list_elem_size_43747 osdv1_attr_list_elem_size 0-1 43747 NULL
99921 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
99922 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
99923 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
99924 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
99925 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
99926 +btrfs_copy_from_user_43806 btrfs_copy_from_user 3-1 43806 NULL
99927 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
99928 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
99929 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
99930 +p54_download_eeprom_43842 p54_download_eeprom 4 43842 NULL
99931 +read_flush_43851 read_flush 3 43851 NULL
99932 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
99933 +pm860x_bulk_write_43875 pm860x_bulk_write 2-3 43875 NULL
99934 +prism2_sta_send_mgmt_43916 prism2_sta_send_mgmt 5 43916 NULL
99935 +SendString_43928 SendString 3 43928 NULL
99936 +xen_register_gsi_43946 xen_register_gsi 1-2 43946 NULL
99937 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
99938 +__get_required_blob_size_43980 __get_required_blob_size 0-2-3 43980 NULL
99939 +nla_reserve_43984 nla_reserve 3 43984 NULL
99940 +__clkdev_alloc_43990 __clkdev_alloc 1 43990 NULL
99941 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
99942 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &scsi_command_size_43992
99943 +emit_flags_44006 emit_flags 4-3 44006 NULL
99944 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
99945 +swiotlb_unmap_page_44063 swiotlb_unmap_page 2 44063 NULL
99946 +load_discard_44083 load_discard 3 44083 NULL
99947 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
99948 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
99949 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
99950 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
99951 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
99952 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
99953 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
99954 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
99955 +__set_free_44211 __set_free 2 44211 NULL
99956 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
99957 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
99958 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
99959 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
99960 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
99961 +enlarge_skb_44248 enlarge_skb 2 44248 NULL
99962 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
99963 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
99964 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
99965 +bitmap_scnprintf_44318 bitmap_scnprintf 2 44318 NULL
99966 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
99967 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 5 44343 NULL
99968 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
99969 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
99970 +__is_discarded_44359 __is_discarded 2 44359 NULL
99971 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
99972 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
99973 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
99974 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
99975 +check_user_page_hwpoison_44412 check_user_page_hwpoison 1 44412 NULL
99976 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
99977 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
99978 +___alloc_bootmem_node_nopanic_44461 ___alloc_bootmem_node_nopanic 2-3 44461 NULL
99979 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
99980 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
99981 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
99982 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
99983 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
99984 +spidev_write_44510 spidev_write 3 44510 NULL
99985 +sys_msgsnd_44537 sys_msgsnd 3 44537 NULL nohasharray
99986 +comm_write_44537 comm_write 3 44537 &sys_msgsnd_44537
99987 +dgrp_config_proc_write_44571 dgrp_config_proc_write 3 44571 NULL
99988 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
99989 +slip_compat_ioctl_44599 slip_compat_ioctl 4 44599 NULL
99990 +brcmf_sdbrcm_glom_len_44618 brcmf_sdbrcm_glom_len 0 44618 NULL
99991 +cfpkt_add_body_44630 cfpkt_add_body 3 44630 NULL
99992 +ext2_new_block_44645 ext2_new_block 2 44645 NULL
99993 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
99994 +mpi_resize_44674 mpi_resize 2 44674 NULL
99995 +ts_read_44687 ts_read 3 44687 NULL
99996 +qib_get_user_pages_44689 qib_get_user_pages 1-2 44689 NULL
99997 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
99998 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
99999 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
100000 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
100001 +WIL_GET_BITS_44747 WIL_GET_BITS 0-1-2-3 44747 NULL
100002 +set_brk_44749 set_brk 1 44749 NULL
100003 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
100004 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
100005 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4 44769 NULL
100006 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
100007 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
100008 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
100009 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
100010 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
100011 +sisusb_write_44834 sisusb_write 3 44834 NULL
100012 +nl80211_send_unprot_disassoc_44846 nl80211_send_unprot_disassoc 4 44846 NULL
100013 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
100014 +skb_availroom_44883 skb_availroom 0 44883 NULL
100015 +nf_bridge_encap_header_len_44890 nf_bridge_encap_header_len 0 44890 NULL
100016 +do_tty_write_44896 do_tty_write 5 44896 NULL
100017 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
100018 +nf_nat_seq_adjust_44989 nf_nat_seq_adjust 4 44989 NULL
100019 +bytepos_delta_45017 bytepos_delta 0 45017 NULL
100020 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
100021 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
100022 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
100023 +sel_write_user_45060 sel_write_user 3 45060 NULL
100024 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL nohasharray
100025 +do_video_ioctl_45069 do_video_ioctl 3 45069 &snd_mixart_BA0_read_45069
100026 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
100027 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
100028 +usbdev_read_45114 usbdev_read 3 45114 NULL
100029 +send_to_tty_45141 send_to_tty 3 45141 NULL
100030 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
100031 +crypto_aead_blocksize_45148 crypto_aead_blocksize 0 45148 NULL
100032 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
100033 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
100034 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
100035 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
100036 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
100037 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
100038 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 NULL
100039 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
100040 +add_child_45201 add_child 4 45201 NULL
100041 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
100042 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
100043 +__dirty_45228 __dirty 2 45228 NULL
100044 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
100045 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
100046 +vcc_compat_ioctl_45291 vcc_compat_ioctl 3 45291 NULL
100047 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
100048 +pte_val_45313 pte_val 0 45313 NULL
100049 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
100050 +lane2_associate_req_45398 lane2_associate_req 4 45398 NULL
100051 +keymap_store_45406 keymap_store 4 45406 NULL
100052 +paging64_gva_to_gpa_45421 paging64_gva_to_gpa 2 45421 NULL nohasharray
100053 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 &paging64_gva_to_gpa_45421
100054 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
100055 +intel_render_ring_init_dri_45446 intel_render_ring_init_dri 2-3 45446 NULL
100056 +__node_remap_45458 __node_remap 4 45458 NULL
100057 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
100058 +udp_manip_pkt_45467 udp_manip_pkt 4 45467 NULL
100059 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
100060 +arizona_init_fll_45503 arizona_init_fll 5 45503 NULL
100061 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
100062 +sys_lgetxattr_45531 sys_lgetxattr 4 45531 NULL
100063 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
100064 +copy_macs_45534 copy_macs 4 45534 NULL
100065 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
100066 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
100067 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
100068 +atomic_long_sub_return_45551 atomic_long_sub_return 1 45551 NULL
100069 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
100070 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
100071 +_regmap_bus_raw_write_45559 _regmap_bus_raw_write 2 45559 NULL
100072 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
100073 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
100074 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
100075 +rdma_set_ib_paths_45592 rdma_set_ib_paths 3 45592 NULL
100076 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
100077 +audit_log_n_hex_45617 audit_log_n_hex 3 45617 NULL
100078 +ebitmap_next_positive_45651 ebitmap_next_positive 3 45651 NULL
100079 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
100080 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
100081 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
100082 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
100083 +dm_compat_ctl_ioctl_45692 dm_compat_ctl_ioctl 3 45692 NULL
100084 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
100085 +bscnl_emit_45699 bscnl_emit 2-5-0 45699 &unix_dgram_sendmsg_45699
100086 +dvb_ca_en50221_init_45718 dvb_ca_en50221_init 4 45718 NULL
100087 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL
100088 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3 45748 NULL nohasharray
100089 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
100090 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
100091 +nilfs_compat_ioctl_45769 nilfs_compat_ioctl 3 45769 NULL
100092 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
100093 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
100094 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
100095 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
100096 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
100097 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
100098 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
100099 +isdn_write_45863 isdn_write 3 45863 NULL
100100 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
100101 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
100102 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
100103 +wm_adsp_region_to_reg_45915 wm_adsp_region_to_reg 0-2 45915 NULL
100104 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
100105 +nf_nat_ftp_fmt_cmd_45926 nf_nat_ftp_fmt_cmd 0 45926 NULL
100106 +smp_scan_config_45934 smp_scan_config 1 45934 NULL
100107 +alloc_mr_45935 alloc_mr 1 45935 NULL
100108 +split_large_page_45941 split_large_page 2 45941 NULL
100109 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
100110 +ezusb_writememory_45976 ezusb_writememory 4 45976 NULL
100111 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
100112 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
100113 +get_free_entries_46030 get_free_entries 1 46030 NULL
100114 +__access_remote_vm_46031 __access_remote_vm 0-5-3 46031 NULL
100115 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
100116 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
100117 +line6_midibuf_bytes_used_46059 line6_midibuf_bytes_used 0 46059 NULL
100118 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6 46060 NULL nohasharray
100119 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
100120 +slhc_toss_46066 slhc_toss 0 46066 NULL
100121 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
100122 +vfio_config_do_rw_46091 vfio_config_do_rw 3 46091 NULL
100123 +ata_host_alloc_46094 ata_host_alloc 2 46094 NULL
100124 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
100125 +pkt_ctl_compat_ioctl_46110 pkt_ctl_compat_ioctl 3 46110 NULL
100126 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
100127 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
100128 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
100129 +paging32_walk_addr_nested_46121 paging32_walk_addr_nested 3 46121 NULL
100130 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
100131 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
100132 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
100133 +add_conn_list_46197 add_conn_list 3 46197 NULL
100134 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
100135 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
100136 +dsp_write_46218 dsp_write 2 46218 NULL
100137 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
100138 +nf_nat_ftp_46265 nf_nat_ftp 6 46265 NULL
100139 +ReadReg_46277 ReadReg 0 46277 NULL
100140 +batadv_iv_ogm_queue_add_46319 batadv_iv_ogm_queue_add 3 46319 NULL
100141 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL
100142 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
100143 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
100144 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
100145 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
100146 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
100147 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
100148 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
100149 +filldir64_46469 filldir64 3 46469 NULL
100150 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
100151 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
100152 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
100153 +kmsg_read_46514 kmsg_read 3 46514 NULL
100154 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
100155 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
100156 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
100157 +mv_get_hc_count_46554 mv_get_hc_count 0 46554 NULL
100158 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
100159 +irq_domain_associate_46564 irq_domain_associate 2 46564 NULL
100160 +dn_current_mss_46574 dn_current_mss 0 46574 NULL
100161 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
100162 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
100163 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
100164 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
100165 +__kfifo_out_r_46623 __kfifo_out_r 0-3 46623 NULL
100166 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
100167 +vfs_getxattr_alloc_46649 vfs_getxattr_alloc 0 46649 NULL
100168 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
100169 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
100170 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
100171 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
100172 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
100173 +prepare_copy_46725 prepare_copy 2 46725 NULL
100174 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
100175 +set_memory_wc_46747 set_memory_wc 1 46747 NULL
100176 +ext4_count_free_46754 ext4_count_free 2 46754 NULL nohasharray
100177 +pte_pfn_46754 pte_pfn 0 46754 &ext4_count_free_46754
100178 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
100179 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
100180 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
100181 +_sys_packet_req_46793 _sys_packet_req 4 46793 NULL
100182 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
100183 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
100184 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
100185 +spi_async_46857 spi_async 0 46857 NULL
100186 +vsnprintf_46863 vsnprintf 0 46863 NULL
100187 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
100188 +sip_sprintf_addr_46872 sip_sprintf_addr 0 46872 NULL
100189 +rvmalloc_46873 rvmalloc 1 46873 NULL
100190 +qp_memcpy_from_queue_iov_46874 qp_memcpy_from_queue_iov 4-5 46874 NULL
100191 +hpi_read_word_nolock_46881 hpi_read_word_nolock 0 46881 NULL
100192 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
100193 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
100194 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
100195 +ol_dqblk_off_46904 ol_dqblk_off 3-2 46904 NULL
100196 +ieee80211_if_fmt_power_mode_46906 ieee80211_if_fmt_power_mode 3 46906 NULL
100197 +wlcore_alloc_hw_46917 wlcore_alloc_hw 1 46917 NULL
100198 +fb_write_46924 fb_write 3 46924 NULL
100199 +btmrvl_curpsmode_read_46939 btmrvl_curpsmode_read 3 46939 NULL
100200 +kvm_register_read_46948 kvm_register_read 0 46948 NULL
100201 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
100202 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
100203 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
100204 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
100205 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
100206 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
100207 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
100208 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
100209 +__map_single_47020 __map_single 3-4-7 47020 NULL
100210 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2 47024 NULL
100211 +swiotlb_sync_single_47031 swiotlb_sync_single 2 47031 NULL
100212 +set_dis_bypass_pfs_47038 set_dis_bypass_pfs 3 47038 NULL
100213 +fs_path_len_47060 fs_path_len 0 47060 NULL
100214 +ufs_new_fragments_47070 ufs_new_fragments 3-5-4 47070 NULL
100215 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
100216 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
100217 +mousedev_read_47123 mousedev_read 3 47123 NULL
100218 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
100219 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
100220 +persistent_ram_iomap_47156 persistent_ram_iomap 1-2 47156 NULL
100221 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
100222 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
100223 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
100224 +svc_pool_map_alloc_arrays_47181 svc_pool_map_alloc_arrays 2 47181 NULL
100225 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
100226 +ioremap_cache_47189 ioremap_cache 1-2 47189 NULL
100227 +gnttab_set_map_op_47206 gnttab_set_map_op 2 47206 NULL
100228 +l2headersize_47238 l2headersize 0 47238 NULL
100229 +options_write_47243 options_write 3 47243 NULL
100230 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
100231 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
100232 +ablkcipher_next_slow_47274 ablkcipher_next_slow 4-3 47274 NULL
100233 +tty_audit_log_47280 tty_audit_log 8 47280 NULL
100234 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
100235 +vsnprintf_47291 vsnprintf 0 47291 NULL
100236 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
100237 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
100238 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
100239 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
100240 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
100241 +nv_rd32_47390 nv_rd32 0 47390 NULL nohasharray
100242 +trace_options_core_read_47390 trace_options_core_read 3 47390 &nv_rd32_47390
100243 +nametbl_list_47391 nametbl_list 2 47391 NULL
100244 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
100245 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
100246 +gfn_to_pfn_prot_47398 gfn_to_pfn_prot 2 47398 NULL
100247 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
100248 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
100249 +vzalloc_47421 vzalloc 1 47421 NULL
100250 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
100251 +__load_mapping_47460 __load_mapping 2 47460 NULL
100252 +wb_force_mapping_47485 wb_force_mapping 2 47485 NULL nohasharray
100253 +newpart_47485 newpart 6 47485 &wb_force_mapping_47485
100254 +core_sys_select_47494 core_sys_select 1 47494 NULL
100255 +unlink_simple_47506 unlink_simple 3 47506 NULL
100256 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
100257 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
100258 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
100259 +oz_events_read_47535 oz_events_read 3 47535 NULL
100260 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
100261 +read_ldt_47570 read_ldt 2 47570 NULL
100262 +pci_iomap_47575 pci_iomap 3 47575 NULL
100263 +rpipe_get_idx_47579 rpipe_get_idx 2 47579 NULL
100264 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
100265 +sctp_ssnmap_new_47608 sctp_ssnmap_new 1-2 47608 NULL
100266 +uea_request_47613 uea_request 4 47613 NULL
100267 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
100268 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
100269 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
100270 +__build_packet_message_47643 __build_packet_message 3-9 47643 NULL
100271 +save_microcode_47717 save_microcode 3 47717 NULL
100272 +bits_to_user_47733 bits_to_user 2-3 47733 NULL
100273 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
100274 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
100275 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
100276 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
100277 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
100278 +i915_wedged_write_47771 i915_wedged_write 3 47771 NULL
100279 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
100280 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
100281 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
100282 +stmmac_set_bfsize_47834 stmmac_set_bfsize 0 47834 NULL
100283 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
100284 +vhci_read_47878 vhci_read 3 47878 NULL
100285 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
100286 +load_mapping_47904 load_mapping 3 47904 NULL
100287 +osd_req_read_sg_47905 osd_req_read_sg 5 47905 NULL
100288 +comedi_write_47926 comedi_write 3 47926 NULL
100289 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
100290 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
100291 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
100292 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
100293 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
100294 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
100295 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
100296 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
100297 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
100298 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
100299 +palmas_bulk_write_48068 palmas_bulk_write 2-3-5 48068 NULL
100300 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
100301 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5 48102 NULL
100302 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
100303 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
100304 +set_discoverable_48141 set_discoverable 4 48141 NULL
100305 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
100306 +bitmap_onto_48152 bitmap_onto 4 48152 NULL
100307 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
100308 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
100309 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL
100310 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
100311 +init_ipath_48187 init_ipath 1 48187 NULL
100312 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
100313 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
100314 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
100315 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
100316 +read_file_recv_48232 read_file_recv 3 48232 NULL
100317 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL
100318 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
100319 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
100320 +send_set_info_48288 send_set_info 7 48288 NULL
100321 +set_disc_pwup_pfs_48300 set_disc_pwup_pfs 3 48300 NULL
100322 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
100323 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
100324 +hash_setkey_48310 hash_setkey 3 48310 NULL
100325 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
100326 +skb_add_data_48363 skb_add_data 3 48363 NULL
100327 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
100328 +ixgbe_pci_sriov_enable_48410 ixgbe_pci_sriov_enable 2 48410 NULL
100329 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
100330 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
100331 +nfs4_alloc_pages_48426 nfs4_alloc_pages 1 48426 NULL
100332 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
100333 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
100334 +send_control_msg_48498 send_control_msg 6 48498 NULL
100335 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
100336 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
100337 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
100338 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
100339 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
100340 +wiimote_hid_send_48528 wiimote_hid_send 3 48528 NULL
100341 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
100342 +named_distribute_48544 named_distribute 4 48544 NULL
100343 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
100344 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
100345 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
100346 +mtd_read_48655 mtd_read 0 48655 NULL
100347 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
100348 +sm501_create_subdev_48668 sm501_create_subdev 3-4 48668 NULL nohasharray
100349 +sys_setgroups_48668 sys_setgroups 1 48668 &sm501_create_subdev_48668
100350 +altera_drscan_48698 altera_drscan 2 48698 NULL
100351 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
100352 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
100353 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
100354 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 NULL
100355 +lua_sysfs_write_48797 lua_sysfs_write 6 48797 NULL
100356 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
100357 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
100358 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
100359 +efi_memory_uc_48828 efi_memory_uc 1 48828 NULL
100360 +azx_get_position_48841 azx_get_position 0 48841 NULL
100361 +vc_do_resize_48842 vc_do_resize 3-4 48842 NULL
100362 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 NULL
100363 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
100364 +sys_setgroups16_48882 sys_setgroups16 1 48882 NULL
100365 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
100366 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
100367 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
100368 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
100369 +gdth_isa_probe_one_48925 gdth_isa_probe_one 1 48925 NULL
100370 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
100371 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
100372 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
100373 +vmci_handle_arr_create_48971 vmci_handle_arr_create 1 48971 NULL
100374 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
100375 +_alloc_set_attr_list_48991 _alloc_set_attr_list 4 48991 NULL
100376 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
100377 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
100378 +transient_status_49027 transient_status 4 49027 NULL
100379 +ipath_reg_user_mr_49038 ipath_reg_user_mr 2-3 49038 NULL
100380 +setup_msi_irq_49052 setup_msi_irq 3-4 49052 NULL
100381 +ubi_read_49061 ubi_read 0 49061 NULL
100382 +scsi_register_49094 scsi_register 2 49094 NULL
100383 +paging64_walk_addr_nested_49100 paging64_walk_addr_nested 3 49100 NULL
100384 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
100385 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 NULL
100386 +pt_read_49136 pt_read 3 49136 NULL
100387 +tipc_multicast_49144 tipc_multicast 5 49144 NULL
100388 +atyfb_setup_generic_49151 atyfb_setup_generic 3 49151 NULL
100389 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
100390 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
100391 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
100392 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
100393 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
100394 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
100395 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
100396 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
100397 +nouveau_therm_create__49228 nouveau_therm_create_ 4 49228 NULL
100398 +nouveau_i2c_port_create__49237 nouveau_i2c_port_create_ 6 49237 NULL
100399 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
100400 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
100401 +osd_req_add_get_attr_list_49278 osd_req_add_get_attr_list 3 49278 NULL
100402 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
100403 +uio_read_49300 uio_read 3 49300 NULL
100404 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
100405 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
100406 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-3-4 49330 NULL
100407 +cfpkt_setlen_49343 cfpkt_setlen 2 49343 NULL
100408 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
100409 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-5-3 49370 NULL
100410 +px_raw_event_49371 px_raw_event 4 49371 NULL
100411 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
100412 +applesmc_create_nodes_49392 applesmc_create_nodes 2 49392 NULL
100413 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
100414 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
100415 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
100416 +md_domain_init_49432 md_domain_init 2 49432 NULL
100417 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
100418 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
100419 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
100420 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
100421 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
100422 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
100423 +acpi_os_ioremap_49523 acpi_os_ioremap 1-2 49523 NULL
100424 +smk_write_access_49561 smk_write_access 3 49561 NULL
100425 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
100426 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
100427 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
100428 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
100429 +btrfs_mksubvol_49616 btrfs_mksubvol 3 49616 NULL
100430 +heap_init_49617 heap_init 2 49617 NULL
100431 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
100432 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
100433 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
100434 +sys_gethostname_49698 sys_gethostname 2 49698 NULL
100435 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
100436 +dm_thin_insert_block_49720 dm_thin_insert_block 2-3 49720 NULL
100437 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
100438 +sys_fsetxattr_49736 sys_fsetxattr 4 49736 NULL
100439 +check_frame_49741 check_frame 0 49741 NULL
100440 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
100441 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
100442 +fuse_wr_pages_49753 fuse_wr_pages 0-1-2 49753 NULL
100443 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
100444 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
100445 +isku_sysfs_write_49767 isku_sysfs_write 6 49767 NULL
100446 +ceph_osdc_readpages_49789 ceph_osdc_readpages 10-4 49789 NULL
100447 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
100448 +arch_gnttab_map_status_49812 arch_gnttab_map_status 3 49812 NULL
100449 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
100450 +add_uuid_49831 add_uuid 4 49831 NULL
100451 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
100452 +twl4030_write_49846 twl4030_write 2 49846 NULL
100453 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
100454 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
100455 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
100456 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
100457 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
100458 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
100459 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
100460 +b43legacy_pio_read_49978 b43legacy_pio_read 0 49978 NULL
100461 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
100462 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
100463 +__module_alloc_50004 __module_alloc 1 50004 NULL
100464 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
100465 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
100466 +isdn_read_50021 isdn_read 3 50021 NULL
100467 +qp_alloc_queue_50028 qp_alloc_queue 1 50028 NULL
100468 +alloc_ebda_hpc_50046 alloc_ebda_hpc 1-2 50046 NULL
100469 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
100470 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
100471 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
100472 +pcpu_get_vm_areas_50085 pcpu_get_vm_areas 3 50085 NULL
100473 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
100474 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
100475 +read_file_slot_50111 read_file_slot 3 50111 NULL
100476 +copy_items_50140 copy_items 6 50140 NULL
100477 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
100478 +set_cmd_header_50155 set_cmd_header 0 50155 NULL
100479 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
100480 +aac_nark_ioremap_50163 aac_nark_ioremap 2 50163 NULL nohasharray
100481 +kmalloc_node_50163 kmalloc_node 1 50163 &aac_nark_ioremap_50163
100482 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
100483 +odev_update_50169 odev_update 2 50169 NULL
100484 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
100485 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172
100486 +ib_send_cm_drep_50186 ib_send_cm_drep 3 50186 NULL
100487 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 4-6 50198 NULL
100488 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
100489 +ieee80211_skb_resize_50211 ieee80211_skb_resize 3 50211 NULL
100490 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
100491 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
100492 +afs_extract_data_50261 afs_extract_data 5 50261 NULL
100493 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
100494 +soc_codec_reg_show_50302 soc_codec_reg_show 0 50302 NULL
100495 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
100496 +do_launder_page_50329 do_launder_page 0 50329 NULL
100497 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
100498 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
100499 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
100500 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
100501 +roccat_common2_send_with_status_50343 roccat_common2_send_with_status 4 50343 NULL
100502 +tpm_read_50344 tpm_read 3 50344 NULL
100503 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
100504 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
100505 +unpack_u16_chunk_50357 unpack_u16_chunk 0 50357 NULL
100506 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
100507 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
100508 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
100509 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
100510 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
100511 +validate_acl_mac_addrs_50429 validate_acl_mac_addrs 0 50429 NULL
100512 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL
100513 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
100514 +force_mapping_50464 force_mapping 2 50464 NULL
100515 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
100516 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
100517 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
100518 +fwnet_receive_packet_50537 fwnet_receive_packet 9 50537 NULL
100519 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
100520 +hme_read_desc32_50574 hme_read_desc32 0 50574 NULL
100521 +fat_readpages_50582 fat_readpages 4 50582 NULL
100522 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
100523 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
100524 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
100525 +__ffs_50625 __ffs 0 50625 NULL
100526 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
100527 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL nohasharray
100528 +sys_readv_50664 sys_readv 3 50664 &ath6kl_tm_rx_event_50664
100529 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
100530 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2 50669 NULL
100531 +btmrvl_psstate_read_50683 btmrvl_psstate_read 3 50683 NULL
100532 +swiotlb_free_coherent_50690 swiotlb_free_coherent 4 50690 NULL
100533 +paging32_gva_to_gpa_50696 paging32_gva_to_gpa 2 50696 NULL
100534 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
100535 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
100536 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
100537 +skb_padto_50759 skb_padto 2 50759 NULL
100538 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
100539 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
100540 +bio_alloc_map_data_50782 bio_alloc_map_data 1-2 50782 NULL
100541 +tpm_write_50798 tpm_write 3 50798 NULL
100542 +write_flush_50803 write_flush 3 50803 NULL
100543 +dvb_play_50814 dvb_play 3 50814 NULL
100544 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
100545 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
100546 +SetArea_50835 SetArea 4 50835 NULL nohasharray
100547 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835
100548 +videobuf_dma_init_user_50839 videobuf_dma_init_user 3 50839 NULL
100549 +self_check_write_50856 self_check_write 5 50856 NULL
100550 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
100551 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
100552 +osd_req_write_sg_50908 osd_req_write_sg 5 50908 NULL
100553 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
100554 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
100555 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
100556 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
100557 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
100558 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
100559 +timeout_write_50991 timeout_write 3 50991 NULL
100560 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL
100561 +proc_write_51003 proc_write 3 51003 NULL
100562 +snd_pcm_default_page_ops_51021 snd_pcm_default_page_ops 2 51021 NULL
100563 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
100564 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
100565 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
100566 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
100567 +dump_midi_51040 dump_midi 3 51040 NULL
100568 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
100569 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
100570 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
100571 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
100572 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
100573 +ti_recv_51110 ti_recv 3 51110 NULL
100574 +dgrp_net_read_51113 dgrp_net_read 3 51113 NULL
100575 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
100576 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
100577 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
100578 +set_dirty_51144 set_dirty 3 51144 NULL
100579 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
100580 +compat_sys_pwritev64_51151 compat_sys_pwritev64 3 51151 NULL
100581 +blk_bio_map_sg_51213 blk_bio_map_sg 0 51213 NULL
100582 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
100583 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
100584 +tipc_send_51238 tipc_send 4 51238 NULL
100585 +drm_property_create_51239 drm_property_create 4 51239 NULL
100586 +st_read_51251 st_read 3 51251 NULL
100587 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
100588 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
100589 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
100590 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL
100591 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
100592 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
100593 +get_cell_51316 get_cell 2 51316 NULL
100594 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
100595 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
100596 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
100597 +compat_arch_ptrace_51337 compat_arch_ptrace 3-4 51337 &alloc_smp_req_51337
100598 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
100599 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
100600 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
100601 +ieee80211_wx_set_gen_ie_51399 ieee80211_wx_set_gen_ie 3 51399 NULL
100602 +ceph_sync_read_51410 ceph_sync_read 3 51410 NULL
100603 +x86_swiotlb_free_coherent_51421 x86_swiotlb_free_coherent 4 51421 NULL
100604 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
100605 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
100606 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
100607 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
100608 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
100609 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
100610 +vaddr_51480 vaddr 0 51480 NULL
100611 +__cpa_process_fault_51502 __cpa_process_fault 2 51502 NULL
100612 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
100613 +load_pdptrs_51541 load_pdptrs 3 51541 NULL
100614 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
100615 +icmp_manip_pkt_51560 icmp_manip_pkt 4 51560 NULL
100616 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
100617 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
100618 +raw_ioctl_51607 raw_ioctl 3 51607 NULL
100619 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
100620 +gnttab_end_foreign_access_51617 gnttab_end_foreign_access 3 51617 NULL
100621 +dns_resolve_server_name_to_ip_51632 dns_resolve_server_name_to_ip 0 51632 NULL
100622 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
100623 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
100624 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
100625 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
100626 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
100627 +sfi_sysfs_install_table_51688 sfi_sysfs_install_table 1 51688 NULL
100628 +host_mapping_level_51696 host_mapping_level 2 51696 NULL
100629 +sel_write_access_51704 sel_write_access 3 51704 NULL
100630 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
100631 +v9fs_alloc_rdir_buf_51716 v9fs_alloc_rdir_buf 2 51716 NULL
100632 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
100633 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
100634 +hid_parse_report_51737 hid_parse_report 3 51737 NULL
100635 +get_user_pages_fast_51751 get_user_pages_fast 0-1-2 51751 NULL
100636 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
100637 +if_write_51756 if_write 3 51756 NULL
100638 +ioremap_prot_51764 ioremap_prot 1-2 51764 NULL
100639 +iio_buffer_add_channel_sysfs_51766 iio_buffer_add_channel_sysfs 0 51766 NULL
100640 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
100641 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
100642 +ioread32_51847 ioread32 0 51847 NULL nohasharray
100643 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
100644 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
100645 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
100646 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
100647 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
100648 +user_read_51881 user_read 3 51881 NULL
100649 +memblock_alloc_51884 memblock_alloc 1-2 51884 NULL
100650 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
100651 +virt_to_phys_51896 virt_to_phys 0 51896 NULL
100652 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
100653 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
100654 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
100655 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
100656 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
100657 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
100658 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
100659 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
100660 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
100661 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
100662 +rdmalt_52022 rdmalt 0 52022 NULL
100663 +vxge_rx_alloc_52024 vxge_rx_alloc 3 52024 NULL
100664 +override_release_52032 override_release 2 52032 NULL
100665 +end_port_52042 end_port 0 52042 NULL
100666 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
100667 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
100668 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
100669 +__fuse_request_alloc_52060 __fuse_request_alloc 1 52060 NULL
100670 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
100671 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
100672 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
100673 +retry_count_read_52129 retry_count_read 3 52129 NULL
100674 +zram_meta_alloc_52140 zram_meta_alloc 1 52140 NULL
100675 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
100676 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2 52145 &hysdn_conf_write_52145
100677 +htable_size_52148 htable_size 0-1 52148 NULL
100678 +__le16_to_cpup_52155 __le16_to_cpup 0 52155 NULL nohasharray
100679 +smk_write_load2_52155 smk_write_load2 3 52155 &__le16_to_cpup_52155
100680 +alix_present_52165 alix_present 1 52165 NULL
100681 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
100682 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
100683 +print_prefix_52176 print_prefix 0 52176 NULL
100684 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
100685 +vmci_qp_broker_alloc_52216 vmci_qp_broker_alloc 5-6 52216 NULL
100686 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
100687 +fuse_request_alloc_52243 fuse_request_alloc 1 52243 NULL
100688 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
100689 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
100690 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
100691 +hva_to_pfn_slow_52262 hva_to_pfn_slow 1 52262 NULL
100692 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
100693 +ath6kl_wmi_get_new_buf_52304 ath6kl_wmi_get_new_buf 1 52304 NULL
100694 +read_file_reset_52310 read_file_reset 3 52310 NULL
100695 +request_asymmetric_key_52317 request_asymmetric_key 2-4 52317 NULL
100696 +hwflags_read_52318 hwflags_read 3 52318 NULL
100697 +ntfs_rl_split_52328 ntfs_rl_split 2-4 52328 NULL
100698 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
100699 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
100700 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
100701 +mq_emit_config_values_52378 mq_emit_config_values 3 52378 NULL
100702 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
100703 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
100704 +aer_inject_write_52399 aer_inject_write 3 52399 NULL
100705 +aac_rx_ioremap_52410 aac_rx_ioremap 2 52410 NULL
100706 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
100707 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
100708 +delay_status_52431 delay_status 5 52431 NULL
100709 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
100710 +nl80211_send_mgmt_tx_status_52445 nl80211_send_mgmt_tx_status 5 52445 NULL
100711 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1-2 52477 NULL
100712 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
100713 +fd_do_rw_52495 fd_do_rw 3 52495 NULL nohasharray
100714 +skb_cow_head_52495 skb_cow_head 2 52495 &fd_do_rw_52495
100715 +qib_user_sdma_pin_pages_52498 qib_user_sdma_pin_pages 3-5 52498 NULL
100716 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
100717 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
100718 +dup_variable_bug_52525 dup_variable_bug 3 52525 NULL
100719 +from_oblock_52546 from_oblock 0-1 52546 NULL
100720 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
100721 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
100722 +emit_code_52583 emit_code 0-3 52583 NULL
100723 +tps80031_writes_52638 tps80031_writes 3-4 52638 NULL
100724 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
100725 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
100726 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
100727 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
100728 +blkcipher_next_slow_52733 blkcipher_next_slow 3-4 52733 NULL
100729 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
100730 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
100731 +copy_ctr_args_52761 copy_ctr_args 2 52761 NULL
100732 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
100733 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
100734 +mon_bin_get_event_52863 mon_bin_get_event 4 52863 NULL
100735 +twlreg_write_52880 twlreg_write 3 52880 NULL
100736 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
100737 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
100738 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
100739 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
100740 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
100741 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL nohasharray
100742 +__iio_device_attr_init_52936 __iio_device_attr_init 0 52936 &iblock_get_bio_52936
100743 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
100744 +send_packet_52960 send_packet 4 52960 NULL
100745 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
100746 +hx8357_spi_write_then_read_52964 hx8357_spi_write_then_read 3 52964 NULL nohasharray
100747 +compat_sock_ioctl_52964 compat_sock_ioctl 3 52964 &hx8357_spi_write_then_read_52964
100748 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
100749 +num_node_state_52989 num_node_state 0 52989 NULL
100750 +batadv_check_management_packet_52993 batadv_check_management_packet 3 52993 NULL
100751 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
100752 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
100753 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
100754 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
100755 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
100756 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
100757 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
100758 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
100759 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
100760 +verity_status_53120 verity_status 5 53120 NULL
100761 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
100762 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
100763 +ieee80211_bss_info_update_53170 ieee80211_bss_info_update 4 53170 NULL
100764 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
100765 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
100766 +fixup_user_fault_53210 fixup_user_fault 3 53210 NULL
100767 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
100768 +rbd_obj_method_sync_53252 rbd_obj_method_sync 8 53252 NULL
100769 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
100770 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
100771 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
100772 +batadv_interface_rx_53325 batadv_interface_rx 4 53325 NULL
100773 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
100774 +vm_mmap_53339 vm_mmap 0 53339 NULL
100775 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
100776 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
100777 +iwl_pcie_txq_alloc_53413 iwl_pcie_txq_alloc 3 53413 NULL
100778 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
100779 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
100780 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
100781 +acpi_tb_parse_root_table_53455 acpi_tb_parse_root_table 1 53455 NULL
100782 +n2_run_53459 n2_run 3 53459 NULL
100783 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
100784 +rds_tcp_data_recv_53476 rds_tcp_data_recv 3 53476 NULL
100785 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
100786 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
100787 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
100788 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
100789 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
100790 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
100791 +check_acl_53512 check_acl 0 53512 NULL
100792 +alloc_pages_exact_nid_53515 alloc_pages_exact_nid 2 53515 NULL
100793 +set_registers_53582 set_registers 3 53582 NULL
100794 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
100795 +gfn_to_pfn_async_53597 gfn_to_pfn_async 2 53597 NULL
100796 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1-2 53626 NULL
100797 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
100798 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 NULL
100799 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
100800 +_preload_range_53676 _preload_range 2-3 53676 NULL
100801 +fuse_fill_write_pages_53682 fuse_fill_write_pages 4 53682 NULL
100802 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
100803 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 NULL nohasharray
100804 +igb_alloc_q_vector_53690 igb_alloc_q_vector 4-6 53690 &bdev_logical_block_size_53690
100805 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
100806 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
100807 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
100808 +wdm_write_53735 wdm_write 3 53735 NULL
100809 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3 53737 NULL
100810 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
100811 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
100812 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
100813 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
100814 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
100815 +qp_alloc_host_work_53798 qp_alloc_host_work 3-5 53798 NULL
100816 +__tty_alloc_driver_53799 __tty_alloc_driver 1 53799 NULL
100817 +regmap_raw_write_53803 regmap_raw_write 2-4 53803 NULL
100818 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
100819 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
100820 +pms_read_53873 pms_read 3 53873 NULL
100821 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
100822 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 5-4-3 53900 NULL
100823 +proc_file_read_53905 proc_file_read 3 53905 NULL
100824 +early_reserve_e820_53915 early_reserve_e820 1-2 53915 NULL
100825 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 4 53938 NULL
100826 +mthca_setup_cmd_doorbells_53954 mthca_setup_cmd_doorbells 2 53954 NULL
100827 +mlx4_num_eq_uar_53965 mlx4_num_eq_uar 0 53965 NULL
100828 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
100829 +mthca_reg_user_mr_53980 mthca_reg_user_mr 2-3 53980 NULL
100830 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
100831 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
100832 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 4-2-5 54018 NULL
100833 +cmpk_message_handle_tx_54024 cmpk_message_handle_tx 4 54024 NULL
100834 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
100835 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
100836 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
100837 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
100838 +_malloc_54077 _malloc 1 54077 NULL
100839 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
100840 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL
100841 +create_xattr_54106 create_xattr 5 54106 NULL
100842 +strn_len_54122 strn_len 0 54122 NULL
100843 +isku_receive_54130 isku_receive 4 54130 NULL
100844 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
100845 +i2400m_zrealloc_2x_54166 i2400m_zrealloc_2x 3 54166 NULL nohasharray
100846 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 &i2400m_zrealloc_2x_54166
100847 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
100848 +acpi_os_read_memory_54186 acpi_os_read_memory 1-3 54186 NULL
100849 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
100850 +_format_mac_addr_54229 _format_mac_addr 2-0 54229 NULL
100851 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
100852 +reada_add_block_54247 reada_add_block 2 54247 NULL
100853 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 NULL
100854 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
100855 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
100856 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
100857 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
100858 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
100859 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
100860 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
100861 +get_iovec_page_array_54298 get_iovec_page_array 6 54298 NULL
100862 +sprintf_54306 sprintf 0 54306 NULL
100863 +irq_domain_associate_many_54307 irq_domain_associate_many 2 54307 NULL
100864 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
100865 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
100866 +__get_free_pages_54352 __get_free_pages 0 54352 NULL nohasharray
100867 +_osd_realloc_seg_54352 _osd_realloc_seg 3 54352 &__get_free_pages_54352
100868 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
100869 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
100870 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
100871 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
100872 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
100873 +ah_alloc_tmp_54378 ah_alloc_tmp 3-2 54378 NULL
100874 +gart_unmap_page_54379 gart_unmap_page 2-3 54379 NULL
100875 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 0-3 54387 NULL
100876 +i386_mmap_check_54388 i386_mmap_check 0 54388 NULL
100877 +__do_krealloc_54389 __do_krealloc 2 54389 NULL
100878 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
100879 +copy_gadget_strings_54417 copy_gadget_strings 2-3 54417 NULL
100880 +swiotlb_tbl_sync_single_54486 swiotlb_tbl_sync_single 2 54486 NULL
100881 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
100882 +swiotlb_tbl_map_single_54495 swiotlb_tbl_map_single 3-0 54495 NULL
100883 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
100884 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL nohasharray
100885 +xen_bus_to_phys_54514 xen_bus_to_phys 0 54514 &cgroup_write_X64_54514
100886 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
100887 +vmci_transport_dgram_enqueue_54525 vmci_transport_dgram_enqueue 4 54525 NULL
100888 +viacam_read_54526 viacam_read 3 54526 NULL
100889 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
100890 +setsockopt_54539 setsockopt 5 54539 NULL
100891 +mwifiex_usb_submit_rx_urb_54558 mwifiex_usb_submit_rx_urb 2 54558 NULL
100892 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
100893 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
100894 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
100895 +fwSendNullPacket_54618 fwSendNullPacket 2 54618 NULL
100896 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
100897 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
100898 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
100899 +kvm_read_cr3_54662 kvm_read_cr3 0 54662 NULL
100900 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
100901 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
100902 +evm_read_key_54674 evm_read_key 3 54674 NULL
100903 +resource_string_54699 resource_string 0 54699 NULL
100904 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
100905 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL
100906 +_add_sg_continuation_descriptor_54721 _add_sg_continuation_descriptor 3 54721 NULL
100907 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
100908 +kzalloc_54740 kzalloc 1 54740 NULL
100909 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
100910 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
100911 +batadv_iv_ogm_aggregate_new_54761 batadv_iv_ogm_aggregate_new 2 54761 NULL
100912 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
100913 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
100914 +domain_init_54797 domain_init 2 54797 NULL
100915 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
100916 +get_dev_size_54807 get_dev_size 0 54807 NULL
100917 +nfsd_write_54809 nfsd_write 6 54809 NULL
100918 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
100919 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &aes_decrypt_fail_read_54815
100920 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
100921 +write_rio_54837 write_rio 3 54837 NULL
100922 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
100923 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
100924 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
100925 +printer_read_54851 printer_read 3 54851 NULL
100926 +qib_reg_user_mr_54858 qib_reg_user_mr 2-3 54858 NULL
100927 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
100928 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
100929 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
100930 +tcf_csum_ipv6_tcp_54877 tcf_csum_ipv6_tcp 4 54877 NULL
100931 +iscsi_pool_init_54913 iscsi_pool_init 2-4 54913 NULL
100932 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
100933 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
100934 +add_port_54941 add_port 2 54941 NULL
100935 +virtblk_add_buf_wait_54943 virtblk_add_buf_wait 3-4 54943 NULL
100936 +wl12xx_cmd_build_probe_req_54946 wl12xx_cmd_build_probe_req 6-8 54946 NULL
100937 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
100938 +c4_add_card_54968 c4_add_card 3 54968 NULL
100939 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
100940 +__proc_file_read_54978 __proc_file_read 3 54978 NULL
100941 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
100942 +Bus_to_Virtual_54991 Bus_to_Virtual 1 54991 NULL
100943 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
100944 +paging32_get_level1_sp_gpa_55022 paging32_get_level1_sp_gpa 0 55022 NULL
100945 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
100946 +__netdev_alloc_skb_ip_align_55067 __netdev_alloc_skb_ip_align 2 55067 NULL
100947 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
100948 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
100949 +hx8357_spi_write_array_55095 hx8357_spi_write_array 3 55095 NULL
100950 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
100951 +corrupt_data_55120 corrupt_data 0 55120 NULL
100952 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
100953 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3 55137 NULL nohasharray
100954 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
100955 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
100956 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
100957 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
100958 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
100959 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
100960 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL
100961 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 NULL
100962 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
100963 +dump_command_55220 dump_command 1 55220 NULL
100964 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
100965 +tipc_port_reject_sections_55229 tipc_port_reject_sections 5 55229 NULL
100966 +register_unifi_sdio_55239 register_unifi_sdio 2 55239 NULL
100967 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
100968 +ptrace_request_55288 ptrace_request 3 55288 NULL
100969 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
100970 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
100971 +qp_alloc_guest_work_55305 qp_alloc_guest_work 3-5 55305 NULL nohasharray
100972 +__get_vm_area_node_55305 __get_vm_area_node 1 55305 &qp_alloc_guest_work_55305
100973 +do_shmat_55336 do_shmat 5 55336 NULL
100974 +vme_user_read_55338 vme_user_read 3 55338 NULL
100975 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
100976 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
100977 +__memblock_alloc_base_55359 __memblock_alloc_base 1-2 55359 NULL
100978 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 NULL
100979 +nf_nat_ipv4_manip_pkt_55387 nf_nat_ipv4_manip_pkt 2 55387 NULL
100980 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
100981 +alloc_skb_55439 alloc_skb 1 55439 NULL
100982 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
100983 +isdnhdlc_decode_55466 isdnhdlc_decode 0 55466 NULL
100984 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
100985 +batadv_unicast_push_and_fill_skb_55474 batadv_unicast_push_and_fill_skb 2 55474 NULL
100986 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
100987 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
100988 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL
100989 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
100990 +cfpkt_pad_trail_55511 cfpkt_pad_trail 2 55511 NULL nohasharray
100991 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 &cfpkt_pad_trail_55511
100992 +ea_get_55522 ea_get 0 55522 NULL
100993 +buffer_size_55534 buffer_size 0 55534 NULL
100994 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
100995 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
100996 +add_partition_55588 add_partition 2 55588 NULL
100997 +free_pages_55603 free_pages 1 55603 NULL
100998 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
100999 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
101000 +edge_tty_recv_55622 edge_tty_recv 3 55622 NULL
101001 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
101002 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
101003 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
101004 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
101005 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
101006 +ib_umad_compat_ioctl_55650 ib_umad_compat_ioctl 3 55650 NULL
101007 +cfg80211_send_rx_assoc_55651 cfg80211_send_rx_assoc 4 55651 NULL
101008 +read_oldmem_55658 read_oldmem 3 55658 NULL
101009 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
101010 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
101011 +get_info_55681 get_info 3 55681 NULL
101012 +wil_vring_alloc_skb_55703 wil_vring_alloc_skb 4 55703 NULL
101013 +__videobuf_alloc_uncached_55711 __videobuf_alloc_uncached 1 55711 NULL
101014 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
101015 +mtdswap_init_55719 mtdswap_init 2 55719 NULL
101016 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 2 55738 NULL
101017 +set_local_name_55757 set_local_name 4 55757 NULL
101018 +strlen_55778 strlen 0 55778 NULL
101019 +set_spte_55783 set_spte 5-4 55783 NULL
101020 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
101021 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
101022 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
101023 +sb16_copy_from_user_55836 sb16_copy_from_user 10-6-7 55836 NULL
101024 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
101025 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
101026 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
101027 +hsc_write_55875 hsc_write 3 55875 NULL
101028 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
101029 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
101030 +paging64_page_fault_55942 paging64_page_fault 2 55942 NULL
101031 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
101032 +ceph_get_direct_page_vector_55956 ceph_get_direct_page_vector 2 55956 NULL
101033 +simple_read_from_buffer_55957 simple_read_from_buffer 2-5 55957 NULL
101034 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
101035 +ssb_bus_pcmciabus_register_56020 ssb_bus_pcmciabus_register 3 56020 NULL
101036 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
101037 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
101038 +__set_discard_56081 __set_discard 2 56081 NULL
101039 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
101040 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
101041 +kmem_zalloc_large_56128 kmem_zalloc_large 1 56128 NULL
101042 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
101043 +map_addr_56144 map_addr 7 56144 NULL
101044 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
101045 +create_irq_nr_56180 create_irq_nr 1 56180 NULL
101046 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
101047 +skb_headroom_56200 skb_headroom 0 56200 NULL
101048 +usb_dump_iad_descriptor_56204 usb_dump_iad_descriptor 0 56204 NULL
101049 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
101050 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
101051 +cp210x_get_config_56229 cp210x_get_config 4 56229 NULL
101052 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
101053 +fd_copyin_56247 fd_copyin 3 56247 NULL
101054 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
101055 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
101056 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
101057 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
101058 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
101059 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
101060 +compat_cdrom_read_audio_56304 compat_cdrom_read_audio 4 56304 NULL
101061 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
101062 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
101063 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
101064 +sixpack_compat_ioctl_56346 sixpack_compat_ioctl 4 56346 NULL
101065 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
101066 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 4 56368 NULL
101067 +dev_read_56369 dev_read 3 56369 NULL
101068 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
101069 +__get_vm_area_caller_56416 __get_vm_area_caller 1 56416 NULL nohasharray
101070 +acpi_os_write_memory_56416 acpi_os_write_memory 1-3 56416 &__get_vm_area_caller_56416
101071 +store_msg_56417 store_msg 3 56417 NULL
101072 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
101073 +fl_create_56435 fl_create 5 56435 NULL
101074 +gnttab_map_56439 gnttab_map 2 56439 NULL
101075 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2 56453 NULL
101076 +set_connectable_56458 set_connectable 4 56458 NULL
101077 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
101078 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
101079 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
101080 +ieee80211_rx_mgmt_probe_beacon_56491 ieee80211_rx_mgmt_probe_beacon 3 56491 NULL
101081 +cfg80211_connect_result_56515 cfg80211_connect_result 4-6 56515 NULL
101082 +ip_options_get_56538 ip_options_get 4 56538 NULL
101083 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
101084 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
101085 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
101086 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
101087 +event_filter_write_56609 event_filter_write 3 56609 NULL
101088 +gather_array_56641 gather_array 3 56641 NULL
101089 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
101090 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
101091 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
101092 +build_map_info_56696 build_map_info 2 56696 NULL
101093 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3 56702 NULL
101094 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
101095 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
101096 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
101097 +pcpu_populate_chunk_56741 pcpu_populate_chunk 2-3 56741 NULL
101098 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
101099 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
101100 +alloc_iommu_56778 alloc_iommu 2-3 56778 NULL
101101 +__carl9170_rx_56784 __carl9170_rx 3 56784 NULL
101102 +hash_lookup_56792 hash_lookup 2 56792 NULL
101103 +do_syslog_56807 do_syslog 3 56807 NULL
101104 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
101105 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
101106 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4 56847 NULL
101107 +wb_lookup_56858 wb_lookup 2 56858 NULL
101108 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
101109 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
101110 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
101111 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
101112 +strcspn_56913 strcspn 0 56913 NULL
101113 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
101114 +check_header_56930 check_header 2 56930 NULL
101115 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL
101116 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
101117 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
101118 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
101119 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
101120 +aircable_process_packet_57027 aircable_process_packet 4 57027 NULL
101121 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
101122 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
101123 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
101124 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
101125 +autofs_dev_ioctl_compat_57059 autofs_dev_ioctl_compat 3 57059 NULL
101126 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
101127 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
101128 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
101129 +sis190_try_rx_copy_57069 sis190_try_rx_copy 3 57069 NULL
101130 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
101131 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
101132 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
101133 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
101134 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
101135 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
101136 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
101137 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
101138 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
101139 +__ipath_get_user_pages_57166 __ipath_get_user_pages 1-2 57166 NULL
101140 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
101141 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
101142 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
101143 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
101144 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
101145 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
101146 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
101147 +security_mmap_file_57268 security_mmap_file 0 57268 NULL
101148 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
101149 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
101150 +ath6kl_buf_alloc_57304 ath6kl_buf_alloc 1 57304 NULL
101151 +fw_file_size_57307 fw_file_size 0 57307 NULL
101152 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
101153 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
101154 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
101155 +check_mirror_57342 check_mirror 1-2 57342 NULL nohasharray
101156 +usblp_read_57342 usblp_read 3 57342 &check_mirror_57342
101157 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
101158 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
101159 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
101160 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
101161 +read_file_blob_57406 read_file_blob 3 57406 NULL
101162 +enclosure_register_57412 enclosure_register 3 57412 NULL
101163 +gre_manip_pkt_57416 gre_manip_pkt 4 57416 NULL
101164 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL nohasharray
101165 +alloc_ftrace_hash_57431 alloc_ftrace_hash 1 57431 &compat_keyctl_instantiate_key_iov_57431
101166 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
101167 +sys_pselect6_57449 sys_pselect6 1 57449 NULL
101168 +ReadReg_57453 ReadReg 0 57453 NULL
101169 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
101170 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL nohasharray
101171 +send_midi_async_57463 send_midi_async 3 57463 &crypto_tfm_alg_blocksize_57463
101172 +sisusb_clear_vram_57466 sisusb_clear_vram 3-2 57466 NULL
101173 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
101174 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
101175 +ocfs2_write_cluster_57483 ocfs2_write_cluster 8-2-9 57483 NULL
101176 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
101177 +skb_headlen_57501 skb_headlen 0 57501 NULL
101178 +copy_in_user_57502 copy_in_user 3 57502 NULL
101179 +ks8842_read32_57505 ks8842_read32 0 57505 NULL nohasharray
101180 +ckhdid_printf_57505 ckhdid_printf 2 57505 &ks8842_read32_57505
101181 +init_tag_map_57515 init_tag_map 3 57515 NULL
101182 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
101183 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517
101184 +inode_permission_57531 inode_permission 0 57531 NULL
101185 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL nohasharray
101186 +DoC_Probe_57534 DoC_Probe 1 57534 &acpi_dev_get_resources_57534
101187 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 NULL
101188 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
101189 +uio_find_mem_index_57584 uio_find_mem_index 0 57584 NULL
101190 +read_file_spectral_fft_period_57593 read_file_spectral_fft_period 3 57593 NULL
101191 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
101192 +sk_stream_alloc_skb_57622 sk_stream_alloc_skb 2 57622 NULL
101193 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 NULL
101194 +osdmap_set_max_osd_57630 osdmap_set_max_osd 2 57630 NULL nohasharray
101195 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 &osdmap_set_max_osd_57630
101196 +mem_read_57631 mem_read 3 57631 NULL
101197 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
101198 +sys_mq_timedsend_57661 sys_mq_timedsend 3 57661 NULL
101199 +r3964_write_57662 r3964_write 4 57662 NULL
101200 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
101201 +__lgwrite_57669 __lgwrite 4 57669 NULL
101202 +ieee80211_MFIE_rate_len_57692 ieee80211_MFIE_rate_len 0 57692 NULL
101203 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
101204 +check_prefree_segments_57702 check_prefree_segments 2 57702 NULL
101205 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
101206 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
101207 +nouveau_gpio_create__57735 nouveau_gpio_create_ 4-5 57735 NULL
101208 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL
101209 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
101210 +ld2_57794 ld2 0 57794 NULL
101211 +ivtv_read_57796 ivtv_read 3 57796 NULL
101212 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
101213 +ipath_user_sdma_num_pages_57813 ipath_user_sdma_num_pages 0 57813 NULL
101214 +usb_dump_config_57817 usb_dump_config 0 57817 NULL
101215 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
101216 +copy_to_user_57835 copy_to_user 3 57835 NULL
101217 +flash_read_57843 flash_read 3 57843 NULL
101218 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
101219 +emi26_writememory_57908 emi26_writememory 4 57908 NULL
101220 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL
101221 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
101222 +twl_i2c_write_57923 twl_i2c_write 4-3 57923 NULL
101223 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
101224 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
101225 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
101226 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
101227 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
101228 +i915_cache_sharing_write_57961 i915_cache_sharing_write 3 57961 NULL
101229 +hfc_empty_fifo_57972 hfc_empty_fifo 2 57972 NULL
101230 +c2_reg_user_mr_57982 c2_reg_user_mr 2-3 57982 NULL
101231 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
101232 +regcache_rbtree_insert_to_block_58009 regcache_rbtree_insert_to_block 5 58009 NULL
101233 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
101234 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
101235 +mce_async_out_58056 mce_async_out 3 58056 NULL
101236 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
101237 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
101238 +cm4040_write_58079 cm4040_write 3 58079 NULL
101239 +udi_log_event_58105 udi_log_event 3 58105 NULL
101240 +savemem_58129 savemem 3 58129 NULL
101241 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
101242 +slhc_init_58135 slhc_init 1-2 58135 &ipv6_flowlabel_opt_58135
101243 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
101244 +asix_write_cmd_58192 asix_write_cmd 5 58192 NULL
101245 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
101246 +hva_to_pfn_58241 hva_to_pfn 1 58241 NULL
101247 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
101248 +read_file_debug_58256 read_file_debug 3 58256 NULL
101249 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
101250 +profile_load_58267 profile_load 3 58267 NULL
101251 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
101252 +r100_mm_rreg_58276 r100_mm_rreg 0 58276 NULL
101253 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
101254 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
101255 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
101256 +pcim_iomap_58334 pcim_iomap 3 58334 NULL
101257 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
101258 +next_pidmap_58347 next_pidmap 2 58347 NULL
101259 +vmalloc_to_sg_58354 vmalloc_to_sg 2 58354 NULL
101260 +save_hint_58359 save_hint 2 58359 NULL
101261 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 NULL
101262 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
101263 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3 58406 NULL
101264 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
101265 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
101266 +__iio_add_chan_devattr_58451 __iio_add_chan_devattr 0 58451 NULL
101267 +capabilities_read_58457 capabilities_read 3 58457 NULL
101268 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
101269 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
101270 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
101271 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
101272 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
101273 +batadv_bla_is_backbone_gw_58488 batadv_bla_is_backbone_gw 3 58488 NULL
101274 +memblock_alloc_try_nid_58493 memblock_alloc_try_nid 1-2 58493 NULL
101275 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
101276 +__clear_discard_58546 __clear_discard 2 58546 NULL
101277 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
101278 +sip_sprintf_addr_port_58574 sip_sprintf_addr_port 0 58574 NULL
101279 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
101280 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
101281 +xip_file_read_58592 xip_file_read 3 58592 NULL
101282 +gdth_search_isa_58595 gdth_search_isa 1 58595 NULL
101283 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
101284 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
101285 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL nohasharray
101286 +efi_ioremap_58634 efi_ioremap 1-2 58634 &module_alloc_update_bounds_rx_58634
101287 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
101288 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
101289 +__gfn_to_pfn_58671 __gfn_to_pfn 2 58671 NULL
101290 +iwl_trans_send_cmd_58681 iwl_trans_send_cmd 0 58681 NULL
101291 +find_zero_58685 find_zero 0-1 58685 NULL nohasharray
101292 +mcs7830_set_reg_async_58685 mcs7830_set_reg_async 3 58685 &find_zero_58685
101293 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
101294 +pci_alloc_consistent_58688 pci_alloc_consistent 0 58688 NULL
101295 +tps6586x_writes_58689 tps6586x_writes 3-2 58689 NULL
101296 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
101297 +acpi_map_58725 acpi_map 1-2 58725 NULL
101298 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
101299 +csum_exist_in_range_58730 csum_exist_in_range 2 58730 NULL
101300 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
101301 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
101302 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
101303 +oblock_to_dblock_58762 oblock_to_dblock 0-2 58762 NULL
101304 +__do_config_autodelink_58763 __do_config_autodelink 3 58763 NULL
101305 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
101306 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
101307 +isku_sysfs_read_58806 isku_sysfs_read 6 58806 NULL
101308 +ep_read_58813 ep_read 3 58813 NULL
101309 +command_write_58841 command_write 3 58841 NULL
101310 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3 58850 NULL
101311 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
101312 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
101313 +cs553x_init_one_58886 cs553x_init_one 3 58886 NULL
101314 +raw_ctl_compat_ioctl_58905 raw_ctl_compat_ioctl 3 58905 NULL
101315 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
101316 +tun_chr_compat_ioctl_58921 tun_chr_compat_ioctl 3 58921 NULL
101317 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
101318 +st5481_isoc_flatten_58952 st5481_isoc_flatten 0 58952 NULL
101319 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
101320 +idx_to_kaddr_58968 idx_to_kaddr 0 58968 NULL
101321 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
101322 +remap_to_cache_dirty_58991 remap_to_cache_dirty 4-3 58991 NULL
101323 +handle_rx_packet_58993 handle_rx_packet 3 58993 NULL
101324 +edac_align_ptr_59003 edac_align_ptr 0 59003 NULL
101325 +ep_write_59008 ep_write 3 59008 NULL
101326 +i915_ring_stop_write_59010 i915_ring_stop_write 3 59010 NULL
101327 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
101328 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
101329 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
101330 +regmap_bulk_write_59049 regmap_bulk_write 4-2 59049 NULL
101331 +vfio_device_fops_compat_ioctl_59111 vfio_device_fops_compat_ioctl 3 59111 NULL
101332 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
101333 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
101334 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
101335 +__iio_add_event_config_attrs_59136 __iio_add_event_config_attrs 0 59136 NULL
101336 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
101337 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
101338 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
101339 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
101340 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
101341 +ocfs2_move_extent_59187 ocfs2_move_extent 3 59187 NULL
101342 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
101343 +fast_rx_path_59214 fast_rx_path 3 59214 NULL
101344 +inftl_partscan_59216 inftl_partscan 0 59216 NULL
101345 +skb_transport_header_59223 skb_transport_header 0 59223 NULL
101346 +dt3155_read_59226 dt3155_read 3 59226 NULL
101347 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
101348 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
101349 +solo_v4l2_read_59247 solo_v4l2_read 3 59247 NULL
101350 +nla_len_59258 nla_len 0 59258 NULL
101351 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4 59304 NULL
101352 +fd_copyout_59323 fd_copyout 3 59323 NULL
101353 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
101354 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
101355 +paging64_get_level1_sp_gpa_59346 paging64_get_level1_sp_gpa 0 59346 NULL nohasharray
101356 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 &paging64_get_level1_sp_gpa_59346
101357 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
101358 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
101359 +fc_frame_alloc_fill_59394 fc_frame_alloc_fill 2 59394 NULL
101360 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
101361 +squashfs_read_data_59440 squashfs_read_data 6 59440 NULL
101362 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2 59445 NULL
101363 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
101364 +do_compat_semctl_59449 do_compat_semctl 4 59449 NULL
101365 +virtqueue_add_buf_59470 virtqueue_add_buf 3-4 59470 NULL
101366 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
101367 +nfsd_nrpools_59503 nfsd_nrpools 0 59503 NULL
101368 +rds_pin_pages_59507 rds_pin_pages 0-1-2 59507 NULL
101369 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
101370 +tunables_write_59563 tunables_write 3 59563 NULL
101371 +memdup_user_59590 memdup_user 2 59590 NULL
101372 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
101373 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL
101374 +mtrr_write_59622 mtrr_write 3 59622 NULL
101375 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
101376 +ubifs_setxattr_59650 ubifs_setxattr 4 59650 NULL nohasharray
101377 +hidraw_read_59650 hidraw_read 3 59650 &ubifs_setxattr_59650
101378 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
101379 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
101380 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
101381 +can_nocow_odirect_59681 can_nocow_odirect 3 59681 NULL
101382 +sriov_enable_59689 sriov_enable 2 59689 NULL
101383 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
101384 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
101385 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
101386 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
101387 +strnlen_59746 strnlen 0 59746 NULL
101388 +sctp_manip_pkt_59749 sctp_manip_pkt 4 59749 NULL
101389 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 NULL
101390 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
101391 +venus_remove_59781 venus_remove 4 59781 NULL
101392 +ipw_write_59807 ipw_write 3 59807 NULL
101393 +rtllib_wx_set_gen_ie_59808 rtllib_wx_set_gen_ie 3 59808 NULL
101394 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
101395 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
101396 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
101397 +regmap_raw_write_async_59849 regmap_raw_write_async 2-4 59849 NULL
101398 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
101399 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL
101400 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
101401 +swiotlb_map_page_59909 swiotlb_map_page 3 59909 NULL
101402 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
101403 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
101404 +lookup_node_59953 lookup_node 2 59953 NULL
101405 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 NULL nohasharray
101406 +compat_ipmi_ioctl_59956 compat_ipmi_ioctl 3 59956 &il_dbgfs_missed_beacon_read_59956
101407 +kvm_set_cr3_59965 kvm_set_cr3 2 59965 NULL
101408 +fb_getput_cmap_59971 fb_getput_cmap 3 59971 NULL
101409 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
101410 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
101411 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
101412 +ieee80211_if_fmt_dot11MeshAwakeWindowDuration_60006 ieee80211_if_fmt_dot11MeshAwakeWindowDuration 3 60006 NULL
101413 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
101414 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
101415 +register_device_60015 register_device 2-3 60015 NULL
101416 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
101417 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
101418 +sys_sched_getaffinity_60033 sys_sched_getaffinity 2 60033 NULL
101419 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
101420 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
101421 +pin_2_irq_60050 pin_2_irq 0-3 60050 NULL nohasharray
101422 +vcs_size_60050 vcs_size 0 60050 &pin_2_irq_60050
101423 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 NULL
101424 +compat_writev_60063 compat_writev 3 60063 NULL
101425 +ieee80211_build_probe_req_60064 ieee80211_build_probe_req 6-8 60064 NULL
101426 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
101427 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
101428 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
101429 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
101430 +ttm_bo_kmap_60118 ttm_bo_kmap 3-2 60118 NULL
101431 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
101432 +init_state_60165 init_state 2 60165 NULL
101433 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
101434 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
101435 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
101436 +svc_compat_ioctl_60194 svc_compat_ioctl 3 60194 NULL
101437 +ib_send_cm_mra_60202 ib_send_cm_mra 4 60202 NULL nohasharray
101438 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 &ib_send_cm_mra_60202
101439 +set_tap_pfs_60203 set_tap_pfs 3 60203 NULL
101440 +ieee80211_mgmt_tx_60209 ieee80211_mgmt_tx 7 60209 NULL
101441 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
101442 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL nohasharray
101443 +__phys_addr_nodebug_60230 __phys_addr_nodebug 0-1 60230 &arizona_map_irq_60230
101444 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
101445 +compat_sys_fcntl64_60256 compat_sys_fcntl64 3 60256 NULL
101446 +printer_write_60276 printer_write 3 60276 NULL
101447 +__pskb_pull_tail_60287 __pskb_pull_tail 2 60287 NULL
101448 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
101449 +getDataLength_60301 getDataLength 0 60301 NULL
101450 +ceph_parse_server_name_60318 ceph_parse_server_name 2 60318 NULL
101451 +__kfifo_from_user_r_60345 __kfifo_from_user_r 3-5 60345 NULL
101452 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
101453 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 5 60379 NULL
101454 +instruction_pointer_60384 instruction_pointer 0 60384 NULL
101455 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
101456 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
101457 +driver_names_read_60399 driver_names_read 3 60399 NULL
101458 +paging32_walk_addr_generic_60415 paging32_walk_addr_generic 4 60415 NULL
101459 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
101460 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
101461 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
101462 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
101463 +tipc_buf_acquire_60437 tipc_buf_acquire 1 60437 NULL
101464 +rx_data_60442 rx_data 4 60442 NULL
101465 +tcf_csum_ipv4_igmp_60446 tcf_csum_ipv4_igmp 3 60446 NULL
101466 +snd_hda_get_num_raw_conns_60462 snd_hda_get_num_raw_conns 0 60462 NULL
101467 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
101468 +ath_tx_init_60515 ath_tx_init 2 60515 NULL
101469 +hysdn_sched_rx_60533 hysdn_sched_rx 3 60533 NULL
101470 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
101471 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
101472 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
101473 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
101474 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
101475 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
101476 +fb_get_fscreeninfo_60640 fb_get_fscreeninfo 3 60640 NULL
101477 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
101478 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
101479 +read_vbt_r10_60679 read_vbt_r10 1 60679 NULL
101480 +init_data_container_60709 init_data_container 1 60709 NULL
101481 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
101482 +raid_status_60755 raid_status 5 60755 NULL
101483 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
101484 +opticon_write_60775 opticon_write 4 60775 NULL
101485 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
101486 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
101487 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
101488 +alloc_buf_60864 alloc_buf 3-2 60864 NULL
101489 +generic_writepages_60871 generic_writepages 0 60871 NULL
101490 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
101491 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
101492 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
101493 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
101494 +sys_mlock_60932 sys_mlock 1 60932 NULL
101495 +pti_char_write_60960 pti_char_write 3 60960 NULL
101496 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 2-3 60961 NULL
101497 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
101498 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
101499 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
101500 +symtab_init_61050 symtab_init 2 61050 NULL
101501 +fuse_send_write_61053 fuse_send_write 0 61053 NULL
101502 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
101503 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
101504 +get_derived_key_61100 get_derived_key 4 61100 NULL
101505 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
101506 +p80211_headerlen_61119 p80211_headerlen 0 61119 NULL nohasharray
101507 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 &p80211_headerlen_61119
101508 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
101509 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
101510 +__vmalloc_61168 __vmalloc 1 61168 NULL
101511 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
101512 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
101513 +sys_lsetxattr_61177 sys_lsetxattr 4 61177 NULL
101514 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
101515 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
101516 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 NULL
101517 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 NULL
101518 +sys_add_key_61288 sys_add_key 4 61288 NULL
101519 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
101520 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
101521 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 NULL
101522 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 NULL
101523 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
101524 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
101525 +sys_ptrace_61369 sys_ptrace 3 61369 NULL
101526 +change_xattr_61390 change_xattr 5 61390 NULL
101527 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
101528 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5 61440 NULL
101529 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
101530 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
101531 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 4-2-5 61483 NULL
101532 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
101533 +erst_errno_61526 erst_errno 0 61526 NULL
101534 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
101535 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
101536 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
101537 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
101538 +seq_open_private_61589 seq_open_private 3 61589 NULL
101539 +__get_vm_area_61599 __get_vm_area 1 61599 NULL
101540 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
101541 +ncp_compat_ioctl_61608 ncp_compat_ioctl 3 61608 NULL
101542 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
101543 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
101544 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
101545 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
101546 +resize_stripes_61650 resize_stripes 2 61650 NULL
101547 +ttm_page_pool_free_61661 ttm_page_pool_free 2 61661 NULL
101548 +insert_one_name_61668 insert_one_name 7 61668 NULL
101549 +lock_loop_61681 lock_loop 1 61681 NULL
101550 +filter_read_61692 filter_read 3 61692 NULL
101551 +iov_length_61716 iov_length 0 61716 NULL
101552 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
101553 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
101554 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
101555 +batadv_dat_snoop_incoming_arp_reply_61801 batadv_dat_snoop_incoming_arp_reply 3 61801 NULL
101556 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
101557 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
101558 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2 61854 NULL
101559 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
101560 +get_fw_name_61874 get_fw_name 3 61874 NULL
101561 +free_init_pages_61875 free_init_pages 2 61875 NULL
101562 +twl4030_sih_setup_61878 twl4030_sih_setup 3 61878 NULL
101563 +ieee80211_rtl_auth_challenge_61897 ieee80211_rtl_auth_challenge 3 61897 NULL
101564 +ax25_addr_size_61899 ax25_addr_size 0 61899 NULL nohasharray
101565 +cxgb4_pktgl_to_skb_61899 cxgb4_pktgl_to_skb 2 61899 &ax25_addr_size_61899
101566 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
101567 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
101568 +au0828_init_isoc_61917 au0828_init_isoc 3-2 61917 NULL
101569 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
101570 +send_bulk_static_data_61932 send_bulk_static_data 3 61932 NULL
101571 +gfn_to_pfn_memslot_atomic_61947 gfn_to_pfn_memslot_atomic 2 61947 NULL
101572 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
101573 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
101574 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
101575 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
101576 +cow_file_range_61979 cow_file_range 3 61979 NULL
101577 +module_alloc_exec_61991 module_alloc_exec 1 61991 NULL
101578 +virtnet_send_command_61993 virtnet_send_command 5-6 61993 NULL
101579 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
101580 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
101581 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
101582 +ppp_tx_cp_62044 ppp_tx_cp 5 62044 NULL
101583 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
101584 +do_pselect_62061 do_pselect 1 62061 NULL
101585 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2-3 62074 NULL
101586 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
101587 +ipath_user_sdma_pin_pages_62100 ipath_user_sdma_pin_pages 3-5 62100 NULL
101588 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
101589 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
101590 +qib_diag_write_62133 qib_diag_write 3 62133 NULL
101591 +ql_status_62135 ql_status 5 62135 NULL
101592 +video_usercopy_62151 video_usercopy 2 62151 NULL
101593 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
101594 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
101595 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
101596 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
101597 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
101598 +allocate_partition_62245 allocate_partition 4 62245 NULL
101599 +__qib_get_user_pages_62287 __qib_get_user_pages 1-2 62287 NULL
101600 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
101601 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
101602 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
101603 +udf_sb_alloc_partition_maps_62313 udf_sb_alloc_partition_maps 2 62313 NULL
101604 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
101605 +subseq_list_62332 subseq_list 3-0 62332 NULL
101606 +flash_write_62354 flash_write 3 62354 NULL
101607 +set_wd_exp_mode_pfs_62372 set_wd_exp_mode_pfs 3 62372 NULL
101608 +twl_get_num_slaves_62386 twl_get_num_slaves 0 62386 NULL
101609 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
101610 +altera_irscan_62396 altera_irscan 2 62396 NULL
101611 +set_ssp_62411 set_ssp 4 62411 NULL
101612 +unmap_single_62423 unmap_single 2 62423 NULL
101613 +netdev_alloc_skb_62437 netdev_alloc_skb 2 62437 NULL
101614 +e1000_check_copybreak_62448 e1000_check_copybreak 3 62448 NULL
101615 +ip_vs_icmp_xmit_v6_62477 ip_vs_icmp_xmit_v6 4 62477 NULL
101616 +ceph_dns_resolve_name_62488 ceph_dns_resolve_name 2 62488 NULL
101617 +remove_mapping_62491 remove_mapping 2 62491 NULL
101618 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
101619 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
101620 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL nohasharray
101621 +i915_next_seqno_read_62524 i915_next_seqno_read 3 62524 &pep_sendmsg_62524
101622 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
101623 +debugfs_read_62535 debugfs_read 3 62535 NULL
101624 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
101625 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
101626 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
101627 +get_subdir_62581 get_subdir 3 62581 NULL
101628 +prism2_send_mgmt_62605 prism2_send_mgmt 4 62605 NULL nohasharray
101629 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 &prism2_send_mgmt_62605
101630 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7 62619 NULL
101631 +ems_pcmcia_add_card_62627 ems_pcmcia_add_card 2 62627 NULL
101632 +compat_rangeinfo_62630 compat_rangeinfo 2 62630 NULL
101633 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
101634 +memblock_alloc_nid_62652 memblock_alloc_nid 1-2 62652 NULL
101635 +ima_file_mmap_62663 ima_file_mmap 0 62663 NULL
101636 +write_62671 write 3 62671 NULL
101637 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
101638 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
101639 +ioremap_wc_62695 ioremap_wc 1-2 62695 NULL
101640 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
101641 +rdm_62719 rdm 0 62719 NULL
101642 +key_replays_read_62746 key_replays_read 3 62746 NULL
101643 +init_chip_wc_pat_62768 init_chip_wc_pat 2 62768 NULL
101644 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
101645 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
101646 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
101647 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
101648 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
101649 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
101650 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
101651 +set_swbp_62853 set_swbp 3 62853 NULL
101652 +hpi_read_word_62862 hpi_read_word 0 62862 NULL
101653 +aoechr_write_62883 aoechr_write 3 62883 NULL
101654 +resize_info_buffer_62889 resize_info_buffer 2 62889 NULL
101655 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
101656 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
101657 +getdqbuf_62908 getdqbuf 1 62908 NULL
101658 +try_async_pf_62914 try_async_pf 3 62914 NULL
101659 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
101660 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 NULL
101661 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
101662 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
101663 +unlink1_63059 unlink1 3 63059 NULL
101664 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
101665 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 3 63078 NULL
101666 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-2-3 63087 NULL
101667 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
101668 +alloc_cblock_63133 alloc_cblock 2 63133 NULL
101669 +ib_send_cm_rtu_63138 ib_send_cm_rtu 3 63138 NULL
101670 +xen_zap_pfn_range_63149 xen_zap_pfn_range 1 63149 NULL
101671 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
101672 +vme_master_read_63221 vme_master_read 0 63221 NULL
101673 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
101674 +ptp_read_63251 ptp_read 4 63251 NULL
101675 +raid5_resize_63306 raid5_resize 2 63306 NULL
101676 +proc_info_read_63344 proc_info_read 3 63344 NULL
101677 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
101678 +idmouse_read_63374 idmouse_read 3 63374 NULL
101679 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
101680 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
101681 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
101682 +nouveau_event_create_63411 nouveau_event_create 1 63411 NULL
101683 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
101684 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 2-4-3 63429 NULL
101685 +kone_send_63435 kone_send 4 63435 NULL
101686 +gfn_to_hva_many_63437 gfn_to_hva_many 0-2 63437 NULL
101687 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
101688 +ipv6_is_mld_63461 ipv6_is_mld 3 63461 NULL
101689 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
101690 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
101691 +read_kcore_63488 read_kcore 3 63488 NULL
101692 +save_hint_63497 save_hint 2 63497 NULL
101693 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
101694 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4 63534 NULL
101695 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
101696 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
101697 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
101698 +kvm_write_guest_page_63555 kvm_write_guest_page 5-2 63555 &dbg_leb_write_63555
101699 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
101700 +iwch_reg_user_mr_63575 iwch_reg_user_mr 2-3 63575 NULL
101701 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
101702 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
101703 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
101704 +module_alloc_63630 module_alloc 1 63630 NULL
101705 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
101706 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
101707 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 4-5-3 63640 NULL
101708 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
101709 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
101710 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
101711 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
101712 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
101713 +alloc_tty_driver_63681 alloc_tty_driver 1 63681 NULL
101714 +mkiss_compat_ioctl_63686 mkiss_compat_ioctl 4 63686 NULL
101715 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
101716 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
101717 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4 63720 NULL
101718 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
101719 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
101720 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
101721 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2-3 63778 NULL
101722 +snapshot_compat_ioctl_63792 snapshot_compat_ioctl 3 63792 NULL
101723 +kovaplus_sysfs_write_63795 kovaplus_sysfs_write 6 63795 NULL
101724 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
101725 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
101726 +sel_write_load_63830 sel_write_load 3 63830 NULL
101727 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
101728 +init_map_ipmac_63896 init_map_ipmac 4-3 63896 NULL
101729 +divas_write_63901 divas_write 3 63901 NULL
101730 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 NULL
101731 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-3-2 63922 NULL
101732 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
101733 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
101734 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
101735 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
101736 +__team_options_register_63941 __team_options_register 3 63941 NULL
101737 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
101738 +ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz_63968 ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz 3 63968 NULL
101739 +ieee80211_authentication_req_63973 ieee80211_authentication_req 3 63973 NULL
101740 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
101741 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
101742 +kmemdup_64015 kmemdup 2 64015 NULL
101743 +offset_to_vaddr_64025 offset_to_vaddr 0-2 64025 NULL nohasharray
101744 +tcf_csum_skb_nextlayer_64025 tcf_csum_skb_nextlayer 3 64025 &offset_to_vaddr_64025
101745 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
101746 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
101747 +sep_lli_table_secure_dma_64042 sep_lli_table_secure_dma 2-3 64042 NULL
101748 +get_u8_64076 get_u8 0 64076 NULL
101749 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
101750 +vmci_handle_arr_get_size_64088 vmci_handle_arr_get_size 0 64088 NULL
101751 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
101752 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
101753 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
101754 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
101755 +init_bch_64130 init_bch 1-2 64130 NULL
101756 +uea_idma_write_64139 uea_idma_write 3 64139 NULL
101757 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
101758 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
101759 +__comedi_buf_alloc_64155 __comedi_buf_alloc 3 64155 NULL
101760 +cpumask_scnprintf_64170 cpumask_scnprintf 2 64170 NULL
101761 +read_pulse_64227 read_pulse 0-3 64227 NULL
101762 +header_len_64232 header_len 0 64232 NULL
101763 +redrat3_transmit_ir_64244 redrat3_transmit_ir 3 64244 NULL
101764 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
101765 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
101766 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
101767 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
101768 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
101769 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
101770 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
101771 +ffz_64324 ffz 0 64324 NULL
101772 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
101773 +ts_write_64336 ts_write 3 64336 NULL
101774 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
101775 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
101776 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
101777 +bnx2x_vfop_mcast_cmd_64354 bnx2x_vfop_mcast_cmd 5 64354 NULL
101778 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
101779 +ilo_write_64378 ilo_write 3 64378 NULL
101780 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
101781 +vmcs_readl_64381 vmcs_readl 0 64381 NULL
101782 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
101783 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
101784 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
101785 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
101786 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
101787 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
101788 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
101789 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
101790 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL nohasharray
101791 +read_file_spectral_short_repeat_64431 read_file_spectral_short_repeat 3 64431 &ext4_trim_extent_64431
101792 +cap_capable_64462 cap_capable 0 64462 NULL
101793 +ip_vs_create_timeout_table_64478 ip_vs_create_timeout_table 2 64478 NULL
101794 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
101795 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
101796 +remove_uuid_64505 remove_uuid 4 64505 NULL nohasharray
101797 +handle_abnormal_pfn_64505 handle_abnormal_pfn 3 64505 &remove_uuid_64505
101798 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
101799 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
101800 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
101801 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
101802 +__spi_sync_64561 __spi_sync 0 64561 NULL
101803 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
101804 +fanotify_write_64623 fanotify_write 3 64623 NULL
101805 +to_dblock_64655 to_dblock 0-1 64655 NULL
101806 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
101807 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
101808 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661
101809 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
101810 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
101811 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
101812 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
101813 +__feat_register_sp_64712 __feat_register_sp 6 64712 NULL
101814 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
101815 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
101816 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
101817 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
101818 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
101819 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
101820 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
101821 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
101822 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
101823 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
101824 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
101825 +vaddr_get_pfn_64818 vaddr_get_pfn 1 64818 NULL
101826 +gfn_to_page_64826 gfn_to_page 2 64826 NULL
101827 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
101828 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
101829 +gfn_to_pfn_64870 gfn_to_pfn 2 64870 NULL
101830 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
101831 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
101832 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
101833 +snd_rawmidi_ioctl_compat_64954 snd_rawmidi_ioctl_compat 3 64954 NULL
101834 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
101835 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
101836 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
101837 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
101838 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
101839 +pskb_pull_65005 pskb_pull 2 65005 NULL
101840 +unifi_write_65012 unifi_write 3 65012 NULL
101841 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
101842 +nfs_readdata_alloc_65015 nfs_readdata_alloc 2 65015 NULL
101843 +insert_dent_65034 insert_dent 7 65034 NULL
101844 +compat_put_ushort_65040 compat_put_ushort 1 65040 NULL
101845 +brcmf_sdcard_rwdata_65041 brcmf_sdcard_rwdata 5 65041 NULL
101846 +tty_audit_log_65043 tty_audit_log 8 65043 NULL
101847 +compat_cmdtest_65064 compat_cmdtest 2 65064 NULL
101848 +count_run_65072 count_run 0-2-4 65072 NULL nohasharray
101849 +bnx2fc_process_l2_frame_compl_65072 bnx2fc_process_l2_frame_compl 3 65072 &count_run_65072
101850 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2-3 65076 NULL
101851 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
101852 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 NULL
101853 +ssb_bus_register_65183 ssb_bus_register 3 65183 NULL
101854 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
101855 +print_endpoint_stat_65232 print_endpoint_stat 3-4-0 65232 NULL
101856 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
101857 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
101858 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
101859 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
101860 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
101861 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
101862 +get_var_len_65304 get_var_len 0 65304 NULL
101863 +unpack_array_65318 unpack_array 0 65318 NULL
101864 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
101865 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
101866 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
101867 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
101868 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
101869 +__ext4_new_inode_65370 __ext4_new_inode 5 65370 NULL
101870 +strchr_65372 strchr 0 65372 NULL
101871 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1-2 65397 NULL
101872 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
101873 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
101874 +iio_device_add_channel_sysfs_65406 iio_device_add_channel_sysfs 0 65406 NULL
101875 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 3-4 65410 NULL
101876 +drm_calloc_large_65421 drm_calloc_large 1-2 65421 NULL
101877 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
101878 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
101879 +ath_rx_edma_init_65483 ath_rx_edma_init 2 65483 NULL
101880 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
101881 +alloc_dr_65495 alloc_dr 2 65495 NULL
101882 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
101883 new file mode 100644
101884 index 0000000..9db0d0e
101885 --- /dev/null
101886 +++ b/tools/gcc/size_overflow_plugin.c
101887 @@ -0,0 +1,2114 @@
101888 +/*
101889 + * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com>
101890 + * Licensed under the GPL v2, or (at your option) v3
101891 + *
101892 + * Homepage:
101893 + * http://www.grsecurity.net/~ephox/overflow_plugin/
101894 + *
101895 + * Documentation:
101896 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
101897 + *
101898 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
101899 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
101900 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
101901 + *
101902 + * Usage:
101903 + * $ 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
101904 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
101905 + */
101906 +
101907 +#include "gcc-plugin.h"
101908 +#include "config.h"
101909 +#include "system.h"
101910 +#include "coretypes.h"
101911 +#include "tree.h"
101912 +#include "tree-pass.h"
101913 +#include "intl.h"
101914 +#include "plugin-version.h"
101915 +#include "tm.h"
101916 +#include "toplev.h"
101917 +#include "function.h"
101918 +#include "tree-flow.h"
101919 +#include "plugin.h"
101920 +#include "gimple.h"
101921 +#include "diagnostic.h"
101922 +#include "cfgloop.h"
101923 +
101924 +#if BUILDING_GCC_VERSION >= 4008
101925 +#define TODO_dump_func 0
101926 +#endif
101927 +
101928 +struct size_overflow_hash {
101929 + const struct size_overflow_hash * const next;
101930 + const char * const name;
101931 + const unsigned int param;
101932 +};
101933 +
101934 +#include "size_overflow_hash.h"
101935 +
101936 +enum mark {
101937 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
101938 +};
101939 +
101940 +enum err_code_conditions {
101941 + CAST_ONLY, FROM_CONST
101942 +};
101943 +
101944 +static unsigned int call_count = 0;
101945 +
101946 +#define __unused __attribute__((__unused__))
101947 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
101948 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
101949 +#define BEFORE_STMT true
101950 +#define AFTER_STMT false
101951 +#define CREATE_NEW_VAR NULL_TREE
101952 +#define CODES_LIMIT 32
101953 +#define MAX_PARAM 31
101954 +#define MY_STMT GF_PLF_1
101955 +#define NO_CAST_CHECK GF_PLF_2
101956 +#define FROM_ARG true
101957 +#define FROM_RET false
101958 +
101959 +#if BUILDING_GCC_VERSION == 4005
101960 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
101961 +#endif
101962 +
101963 +int plugin_is_GPL_compatible;
101964 +void debug_gimple_stmt(gimple gs);
101965 +
101966 +static tree expand(struct pointer_set_t *visited, tree lhs);
101967 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs);
101968 +static tree report_size_overflow_decl;
101969 +static const_tree const_char_ptr_type_node;
101970 +static unsigned int handle_function(void);
101971 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
101972 +static tree get_size_overflow_type(gimple stmt, const_tree node);
101973 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
101974 +static void print_missing_msg(tree func, unsigned int argnum);
101975 +
101976 +static struct plugin_info size_overflow_plugin_info = {
101977 + .version = "20130410beta",
101978 + .help = "no-size-overflow\tturn off size overflow checking\n",
101979 +};
101980 +
101981 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
101982 +{
101983 + unsigned int arg_count;
101984 + enum tree_code code = TREE_CODE(*node);
101985 +
101986 + switch (code) {
101987 + case FUNCTION_DECL:
101988 + arg_count = type_num_arguments(TREE_TYPE(*node));
101989 + break;
101990 + case FUNCTION_TYPE:
101991 + case METHOD_TYPE:
101992 + arg_count = type_num_arguments(*node);
101993 + break;
101994 + default:
101995 + *no_add_attrs = true;
101996 + error("%s: %qE attribute only applies to functions", __func__, name);
101997 + return NULL_TREE;
101998 + }
101999 +
102000 + for (; args; args = TREE_CHAIN(args)) {
102001 + tree position = TREE_VALUE(args);
102002 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
102003 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
102004 + *no_add_attrs = true;
102005 + }
102006 + }
102007 + return NULL_TREE;
102008 +}
102009 +
102010 +static const char* get_asm_name(tree node)
102011 +{
102012 + return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node));
102013 +}
102014 +
102015 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
102016 +{
102017 + unsigned int arg_count, arg_num;
102018 + enum tree_code code = TREE_CODE(*node);
102019 +
102020 + switch (code) {
102021 + case FUNCTION_DECL:
102022 + arg_count = type_num_arguments(TREE_TYPE(*node));
102023 + break;
102024 + case FUNCTION_TYPE:
102025 + case METHOD_TYPE:
102026 + arg_count = type_num_arguments(*node);
102027 + break;
102028 + case FIELD_DECL:
102029 + arg_num = TREE_INT_CST_LOW(TREE_VALUE(args));
102030 + if (arg_num != 0) {
102031 + *no_add_attrs = true;
102032 + error("%s: %qE attribute parameter can only be 0 in structure fields", __func__, name);
102033 + }
102034 + return NULL_TREE;
102035 + default:
102036 + *no_add_attrs = true;
102037 + error("%qE attribute only applies to functions", name);
102038 + return NULL_TREE;
102039 + }
102040 +
102041 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
102042 + return NULL_TREE;
102043 +
102044 + for (; args; args = TREE_CHAIN(args)) {
102045 + tree position = TREE_VALUE(args);
102046 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
102047 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
102048 + *no_add_attrs = true;
102049 + }
102050 + }
102051 + return NULL_TREE;
102052 +}
102053 +
102054 +static struct attribute_spec size_overflow_attr = {
102055 + .name = "size_overflow",
102056 + .min_length = 1,
102057 + .max_length = -1,
102058 + .decl_required = true,
102059 + .type_required = false,
102060 + .function_type_required = false,
102061 + .handler = handle_size_overflow_attribute,
102062 +#if BUILDING_GCC_VERSION >= 4007
102063 + .affects_type_identity = false
102064 +#endif
102065 +};
102066 +
102067 +static struct attribute_spec intentional_overflow_attr = {
102068 + .name = "intentional_overflow",
102069 + .min_length = 1,
102070 + .max_length = -1,
102071 + .decl_required = true,
102072 + .type_required = false,
102073 + .function_type_required = false,
102074 + .handler = handle_intentional_overflow_attribute,
102075 +#if BUILDING_GCC_VERSION >= 4007
102076 + .affects_type_identity = false
102077 +#endif
102078 +};
102079 +
102080 +static void register_attributes(void __unused *event_data, void __unused *data)
102081 +{
102082 + register_attribute(&size_overflow_attr);
102083 + register_attribute(&intentional_overflow_attr);
102084 +}
102085 +
102086 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
102087 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
102088 +{
102089 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
102090 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
102091 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
102092 +
102093 + unsigned int m = 0x57559429;
102094 + unsigned int n = 0x5052acdb;
102095 + const unsigned int *key4 = (const unsigned int *)key;
102096 + unsigned int h = len;
102097 + unsigned int k = len + seed + n;
102098 + unsigned long long p;
102099 +
102100 + while (len >= 8) {
102101 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
102102 + len -= 8;
102103 + }
102104 + if (len >= 4) {
102105 + cwmixb(key4[0]) key4 += 1;
102106 + len -= 4;
102107 + }
102108 + if (len)
102109 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
102110 + cwmixb(h ^ (k + n));
102111 + return k ^ h;
102112 +
102113 +#undef cwfold
102114 +#undef cwmixa
102115 +#undef cwmixb
102116 +}
102117 +
102118 +static inline unsigned int get_hash_num(const char *fndecl, const char *tree_codes, unsigned int len, unsigned int seed)
102119 +{
102120 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
102121 + unsigned int codes = CrapWow(tree_codes, len, seed) & 0xffff;
102122 + return fn ^ codes;
102123 +}
102124 +
102125 +static inline tree get_original_function_decl(tree fndecl)
102126 +{
102127 + if (DECL_ABSTRACT_ORIGIN(fndecl))
102128 + return DECL_ABSTRACT_ORIGIN(fndecl);
102129 + return fndecl;
102130 +}
102131 +
102132 +static inline gimple get_def_stmt(const_tree node)
102133 +{
102134 + gcc_assert(node != NULL_TREE);
102135 + if (TREE_CODE(node) != SSA_NAME)
102136 + return NULL;
102137 + return SSA_NAME_DEF_STMT(node);
102138 +}
102139 +
102140 +static unsigned char get_tree_code(const_tree type)
102141 +{
102142 + switch (TREE_CODE(type)) {
102143 + case ARRAY_TYPE:
102144 + return 0;
102145 + case BOOLEAN_TYPE:
102146 + return 1;
102147 + case ENUMERAL_TYPE:
102148 + return 2;
102149 + case FUNCTION_TYPE:
102150 + return 3;
102151 + case INTEGER_TYPE:
102152 + return 4;
102153 + case POINTER_TYPE:
102154 + return 5;
102155 + case RECORD_TYPE:
102156 + return 6;
102157 + case UNION_TYPE:
102158 + return 7;
102159 + case VOID_TYPE:
102160 + return 8;
102161 + case REAL_TYPE:
102162 + return 9;
102163 + case VECTOR_TYPE:
102164 + return 10;
102165 + case REFERENCE_TYPE:
102166 + return 11;
102167 + case OFFSET_TYPE:
102168 + return 12;
102169 + case COMPLEX_TYPE:
102170 + return 13;
102171 + default:
102172 + debug_tree((tree)type);
102173 + gcc_unreachable();
102174 + }
102175 +}
102176 +
102177 +static size_t add_type_codes(const_tree type, unsigned char *tree_codes, size_t len)
102178 +{
102179 + gcc_assert(type != NULL_TREE);
102180 +
102181 + while (type && len < CODES_LIMIT) {
102182 + tree_codes[len] = get_tree_code(type);
102183 + len++;
102184 + type = TREE_TYPE(type);
102185 + }
102186 + return len;
102187 +}
102188 +
102189 +static unsigned int get_function_decl(const_tree fndecl, unsigned char *tree_codes)
102190 +{
102191 + const_tree arg, result, arg_field, type = TREE_TYPE(fndecl);
102192 + enum tree_code code = TREE_CODE(type);
102193 + size_t len = 0;
102194 +
102195 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
102196 +
102197 + arg = TYPE_ARG_TYPES(type);
102198 + // skip builtins __builtin_constant_p
102199 + if (!arg && DECL_BUILT_IN(fndecl))
102200 + return 0;
102201 +
102202 + if (TREE_CODE_CLASS(code) == tcc_type)
102203 + result = type;
102204 + else
102205 + result = DECL_RESULT(fndecl);
102206 +
102207 + gcc_assert(result != NULL_TREE);
102208 + len = add_type_codes(TREE_TYPE(result), tree_codes, len);
102209 +
102210 + if (arg == NULL_TREE) {
102211 + gcc_assert(CODE_CONTAINS_STRUCT(TREE_CODE(fndecl), TS_DECL_NON_COMMON));
102212 + arg_field = DECL_ARGUMENT_FLD(fndecl);
102213 + if (arg_field == NULL_TREE)
102214 + return 0;
102215 + arg = TREE_TYPE(arg_field);
102216 + len = add_type_codes(arg, tree_codes, len);
102217 + gcc_assert(len != 0);
102218 + return len;
102219 + }
102220 +
102221 + gcc_assert(arg != NULL_TREE && TREE_CODE(arg) == TREE_LIST);
102222 + while (arg && len < CODES_LIMIT) {
102223 + len = add_type_codes(TREE_VALUE(arg), tree_codes, len);
102224 + arg = TREE_CHAIN(arg);
102225 + }
102226 +
102227 + gcc_assert(len != 0);
102228 + return len;
102229 +}
102230 +
102231 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
102232 +{
102233 + unsigned int hash;
102234 + const struct size_overflow_hash *entry;
102235 + unsigned char tree_codes[CODES_LIMIT];
102236 + size_t len;
102237 + const char *func_name;
102238 +
102239 + fndecl = get_original_function_decl(fndecl);
102240 + len = get_function_decl(fndecl, tree_codes);
102241 + if (len == 0)
102242 + return NULL;
102243 +
102244 + func_name = get_asm_name(fndecl);
102245 + hash = get_hash_num(func_name, (const char*) tree_codes, len, 0);
102246 +
102247 + entry = size_overflow_hash[hash];
102248 + while (entry) {
102249 + if (!strcmp(entry->name, func_name))
102250 + return entry;
102251 + entry = entry->next;
102252 + }
102253 +
102254 + return NULL;
102255 +}
102256 +
102257 +static bool is_bool(const_tree node)
102258 +{
102259 + const_tree type;
102260 +
102261 + if (node == NULL_TREE)
102262 + return false;
102263 +
102264 + type = TREE_TYPE(node);
102265 + if (!INTEGRAL_TYPE_P(type))
102266 + return false;
102267 + if (TREE_CODE(type) == BOOLEAN_TYPE)
102268 + return true;
102269 + if (TYPE_PRECISION(type) == 1)
102270 + return true;
102271 + return false;
102272 +}
102273 +
102274 +static bool skip_types(const_tree var)
102275 +{
102276 + tree type;
102277 +
102278 + if (is_gimple_constant(var))
102279 + return true;
102280 +
102281 + switch (TREE_CODE(var)) {
102282 + case ADDR_EXPR:
102283 +#if BUILDING_GCC_VERSION >= 4006
102284 + case MEM_REF:
102285 +#endif
102286 + case ARRAY_REF:
102287 + case BIT_FIELD_REF:
102288 + case INDIRECT_REF:
102289 + case TARGET_MEM_REF:
102290 + return true;
102291 + case PARM_DECL:
102292 + case VAR_DECL:
102293 + case COMPONENT_REF:
102294 + return false;
102295 + default:
102296 + break;
102297 + }
102298 +
102299 + gcc_assert(TREE_CODE(var) == SSA_NAME);
102300 +
102301 + type = TREE_TYPE(var);
102302 + switch (TREE_CODE(type)) {
102303 + case INTEGER_TYPE:
102304 + case ENUMERAL_TYPE:
102305 + return false;
102306 + case BOOLEAN_TYPE:
102307 + return is_bool(var);
102308 + default:
102309 + break;
102310 + }
102311 +
102312 + gcc_assert(TREE_CODE(type) == POINTER_TYPE);
102313 +
102314 + type = TREE_TYPE(type);
102315 + gcc_assert(type != NULL_TREE);
102316 + switch (TREE_CODE(type)) {
102317 + case RECORD_TYPE:
102318 + case POINTER_TYPE:
102319 + case ARRAY_TYPE:
102320 + return true;
102321 + case VOID_TYPE:
102322 + case INTEGER_TYPE:
102323 + case UNION_TYPE:
102324 + return false;
102325 + default:
102326 + break;
102327 + }
102328 +
102329 + debug_tree((tree)var);
102330 + gcc_unreachable();
102331 +}
102332 +
102333 +static unsigned int find_arg_number(const_tree arg, tree func)
102334 +{
102335 + tree var;
102336 + unsigned int argnum = 1;
102337 +
102338 + if (TREE_CODE(arg) == SSA_NAME)
102339 + arg = SSA_NAME_VAR(arg);
102340 +
102341 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
102342 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
102343 + continue;
102344 + if (!skip_types(var))
102345 + return argnum;
102346 + }
102347 +
102348 + return 0;
102349 +}
102350 +
102351 +static tree create_new_var(tree type)
102352 +{
102353 + tree new_var = create_tmp_var(type, "cicus");
102354 +
102355 +#if BUILDING_GCC_VERSION <= 4007
102356 + add_referenced_var(new_var);
102357 + mark_sym_for_renaming(new_var);
102358 +#endif
102359 + return new_var;
102360 +}
102361 +
102362 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
102363 +{
102364 + gimple assign;
102365 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
102366 + tree type = TREE_TYPE(rhs1);
102367 + tree lhs = create_new_var(type);
102368 +
102369 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
102370 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
102371 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
102372 +
102373 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
102374 + update_stmt(assign);
102375 + gimple_set_plf(assign, MY_STMT, true);
102376 + return assign;
102377 +}
102378 +
102379 +static tree cast_a_tree(tree type, tree var)
102380 +{
102381 + gcc_assert(type != NULL_TREE);
102382 + gcc_assert(var != NULL_TREE);
102383 + gcc_assert(fold_convertible_p(type, var));
102384 +
102385 + return fold_convert(type, var);
102386 +}
102387 +
102388 +static tree get_lhs(const_gimple stmt)
102389 +{
102390 + switch (gimple_code(stmt)) {
102391 + case GIMPLE_ASSIGN:
102392 + return gimple_get_lhs(stmt);
102393 + case GIMPLE_PHI:
102394 + return gimple_phi_result(stmt);
102395 + case GIMPLE_CALL:
102396 + return gimple_call_lhs(stmt);
102397 + default:
102398 + return NULL_TREE;
102399 + }
102400 +}
102401 +
102402 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
102403 +{
102404 + const_gimple def_stmt = get_def_stmt(rhs);
102405 +
102406 + if (force)
102407 + return false;
102408 +
102409 + if (is_gimple_constant(rhs))
102410 + return false;
102411 +
102412 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
102413 + return false;
102414 +
102415 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
102416 + return false;
102417 +
102418 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
102419 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
102420 + return false;
102421 +
102422 + return true;
102423 +}
102424 +
102425 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
102426 +{
102427 + gimple assign, def_stmt;
102428 +
102429 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
102430 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
102431 + gcc_unreachable();
102432 +
102433 + def_stmt = get_def_stmt(rhs);
102434 + if (skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
102435 + return def_stmt;
102436 +
102437 + if (lhs == CREATE_NEW_VAR)
102438 + lhs = create_new_var(dst_type);
102439 +
102440 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
102441 +
102442 + if (!gsi_end_p(*gsi)) {
102443 + location_t loc = gimple_location(gsi_stmt(*gsi));
102444 + gimple_set_location(assign, loc);
102445 + }
102446 +
102447 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
102448 +
102449 + if (before)
102450 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
102451 + else
102452 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
102453 + update_stmt(assign);
102454 + gimple_set_plf(assign, MY_STMT, true);
102455 +
102456 + return assign;
102457 +}
102458 +
102459 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
102460 +{
102461 + gimple_stmt_iterator gsi;
102462 + tree lhs;
102463 + const_gimple new_stmt;
102464 +
102465 + if (rhs == NULL_TREE)
102466 + return NULL_TREE;
102467 +
102468 + gsi = gsi_for_stmt(stmt);
102469 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
102470 +
102471 + lhs = get_lhs(new_stmt);
102472 + gcc_assert(lhs != NULL_TREE);
102473 + return lhs;
102474 +}
102475 +
102476 +static tree cast_to_TI_type(gimple stmt, tree node)
102477 +{
102478 + gimple_stmt_iterator gsi;
102479 + gimple cast_stmt;
102480 + tree type = TREE_TYPE(node);
102481 +
102482 + if (types_compatible_p(type, intTI_type_node))
102483 + return node;
102484 +
102485 + gsi = gsi_for_stmt(stmt);
102486 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
102487 + return gimple_get_lhs(cast_stmt);
102488 +}
102489 +
102490 +static void check_function_hash(const_gimple stmt)
102491 +{
102492 + tree func;
102493 + const struct size_overflow_hash *hash;
102494 +
102495 + if (gimple_code(stmt) != GIMPLE_CALL)
102496 + return;
102497 +
102498 + func = gimple_call_fndecl(stmt);
102499 + //fs/xattr.c D.34222_15 = D.34219_14 (dentry_3(D), name_7(D), 0B, 0);
102500 + if (func == NULL_TREE)
102501 + return;
102502 +
102503 + hash = get_function_hash(func);
102504 + if (!hash)
102505 + print_missing_msg(func, 0);
102506 +}
102507 +
102508 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
102509 +{
102510 + tree lhs, new_lhs;
102511 + gimple_stmt_iterator gsi;
102512 +
102513 + if (rhs1 == NULL_TREE) {
102514 + debug_gimple_stmt(oldstmt);
102515 + error("%s: rhs1 is NULL_TREE", __func__);
102516 + gcc_unreachable();
102517 + }
102518 +
102519 + switch (gimple_code(oldstmt)) {
102520 + case GIMPLE_ASM:
102521 + lhs = rhs1;
102522 + break;
102523 + case GIMPLE_CALL:
102524 + lhs = gimple_call_lhs(oldstmt);
102525 + break;
102526 + case GIMPLE_ASSIGN:
102527 + lhs = gimple_get_lhs(oldstmt);
102528 + break;
102529 + default:
102530 + debug_gimple_stmt(oldstmt);
102531 + gcc_unreachable();
102532 + }
102533 +
102534 + gsi = gsi_for_stmt(oldstmt);
102535 + pointer_set_insert(visited, oldstmt);
102536 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
102537 + basic_block next_bb, cur_bb;
102538 + const_edge e;
102539 +
102540 + gcc_assert(before == false);
102541 + gcc_assert(stmt_can_throw_internal(oldstmt));
102542 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
102543 + gcc_assert(!gsi_end_p(gsi));
102544 +
102545 + cur_bb = gimple_bb(oldstmt);
102546 + next_bb = cur_bb->next_bb;
102547 + e = find_edge(cur_bb, next_bb);
102548 + gcc_assert(e != NULL);
102549 + gcc_assert(e->flags & EDGE_FALLTHRU);
102550 +
102551 + gsi = gsi_after_labels(next_bb);
102552 + gcc_assert(!gsi_end_p(gsi));
102553 +
102554 + before = true;
102555 + oldstmt = gsi_stmt(gsi);
102556 + }
102557 +
102558 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
102559 + return new_lhs;
102560 +}
102561 +
102562 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
102563 +{
102564 + gimple stmt;
102565 + gimple_stmt_iterator gsi;
102566 + tree size_overflow_type, new_var, lhs = gimple_get_lhs(oldstmt);
102567 +
102568 + if (gimple_plf(oldstmt, MY_STMT))
102569 + return lhs;
102570 +
102571 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
102572 + rhs1 = gimple_assign_rhs1(oldstmt);
102573 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
102574 + }
102575 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
102576 + rhs2 = gimple_assign_rhs2(oldstmt);
102577 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
102578 + }
102579 +
102580 + stmt = gimple_copy(oldstmt);
102581 + gimple_set_location(stmt, gimple_location(oldstmt));
102582 + gimple_set_plf(stmt, MY_STMT, true);
102583 +
102584 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
102585 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
102586 +
102587 + size_overflow_type = get_size_overflow_type(oldstmt, node);
102588 +
102589 + new_var = create_new_var(size_overflow_type);
102590 + new_var = make_ssa_name(new_var, stmt);
102591 + gimple_set_lhs(stmt, new_var);
102592 +
102593 + if (rhs1 != NULL_TREE)
102594 + gimple_assign_set_rhs1(stmt, rhs1);
102595 +
102596 + if (rhs2 != NULL_TREE)
102597 + gimple_assign_set_rhs2(stmt, rhs2);
102598 +#if BUILDING_GCC_VERSION >= 4007
102599 + if (rhs3 != NULL_TREE)
102600 + gimple_assign_set_rhs3(stmt, rhs3);
102601 +#endif
102602 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
102603 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
102604 +
102605 + gsi = gsi_for_stmt(oldstmt);
102606 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
102607 + update_stmt(stmt);
102608 + pointer_set_insert(visited, oldstmt);
102609 + return gimple_get_lhs(stmt);
102610 +}
102611 +
102612 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type)
102613 +{
102614 + basic_block first_bb;
102615 + gimple assign;
102616 + gimple_stmt_iterator gsi;
102617 +
102618 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
102619 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
102620 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
102621 +
102622 + gsi = gsi_start_bb(first_bb);
102623 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
102624 + return gimple_get_lhs(assign);
102625 +}
102626 +
102627 +static tree use_phi_ssa_name(tree phi_ssa_name, tree new_arg)
102628 +{
102629 + gimple_stmt_iterator gsi;
102630 + const_gimple assign;
102631 + gimple def_stmt = get_def_stmt(new_arg);
102632 +
102633 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
102634 + gsi = gsi_after_labels(gimple_bb(def_stmt));
102635 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, BEFORE_STMT, true);
102636 + } else {
102637 + gsi = gsi_for_stmt(def_stmt);
102638 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, AFTER_STMT, true);
102639 + }
102640 +
102641 + return gimple_get_lhs(assign);
102642 +}
102643 +
102644 +static tree cast_visited_phi_arg(tree phi_ssa_name, tree arg, tree size_overflow_type)
102645 +{
102646 + basic_block bb;
102647 + gimple_stmt_iterator gsi;
102648 + const_gimple assign, def_stmt;
102649 +
102650 + def_stmt = get_def_stmt(arg);
102651 + bb = gimple_bb(def_stmt);
102652 + gcc_assert(bb->index != 0);
102653 + gsi = gsi_after_labels(bb);
102654 +
102655 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
102656 + return gimple_get_lhs(assign);
102657 +}
102658 +
102659 +static tree create_new_phi_arg(tree phi_ssa_name, tree new_arg, tree arg, gimple oldstmt)
102660 +{
102661 + tree size_overflow_type;
102662 + const_gimple def_stmt = get_def_stmt(arg);
102663 +
102664 + if (phi_ssa_name != NULL_TREE)
102665 + phi_ssa_name = SSA_NAME_VAR(phi_ssa_name);
102666 +
102667 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
102668 +
102669 + if (new_arg != NULL_TREE) {
102670 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
102671 + return use_phi_ssa_name(phi_ssa_name, new_arg);
102672 + }
102673 +
102674 + switch(gimple_code(def_stmt)) {
102675 + case GIMPLE_PHI:
102676 + return cast_visited_phi_arg(phi_ssa_name, arg, size_overflow_type);
102677 + case GIMPLE_NOP:
102678 + return cast_parm_decl(phi_ssa_name, arg, size_overflow_type);
102679 + default:
102680 + debug_gimple_stmt((gimple)def_stmt);
102681 + gcc_unreachable();
102682 + }
102683 +}
102684 +
102685 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
102686 +{
102687 + basic_block bb;
102688 + gimple phi;
102689 + gimple_seq seq;
102690 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
102691 +
102692 + bb = gsi_bb(gsi);
102693 +
102694 + phi = create_phi_node(result, bb);
102695 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
102696 + seq = phi_nodes(bb);
102697 + gsi = gsi_last(seq);
102698 + gsi_remove(&gsi, false);
102699 +
102700 + gsi = gsi_for_stmt(oldstmt);
102701 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
102702 + gimple_set_bb(phi, bb);
102703 + gimple_set_plf(phi, MY_STMT, true);
102704 + return phi;
102705 +}
102706 +
102707 +static tree handle_phi(struct pointer_set_t *visited, tree orig_result)
102708 +{
102709 + gimple new_phi = NULL;
102710 + gimple oldstmt = get_def_stmt(orig_result);
102711 + tree phi_ssa_name = NULL_TREE;
102712 + unsigned int i;
102713 +
102714 + pointer_set_insert(visited, oldstmt);
102715 + for (i = 0; i < gimple_phi_num_args(oldstmt); i++) {
102716 + tree arg, new_arg;
102717 +
102718 + arg = gimple_phi_arg_def(oldstmt, i);
102719 +
102720 + new_arg = expand(visited, arg);
102721 + new_arg = create_new_phi_arg(phi_ssa_name, new_arg, arg, oldstmt);
102722 + if (i == 0) {
102723 + phi_ssa_name = new_arg;
102724 + new_phi = overflow_create_phi_node(oldstmt, SSA_NAME_VAR(phi_ssa_name));
102725 + }
102726 +
102727 + gcc_assert(new_phi != NULL);
102728 + add_phi_arg(new_phi, new_arg, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
102729 + }
102730 +
102731 + gcc_assert(new_phi != NULL);
102732 + update_stmt(new_phi);
102733 + return gimple_phi_result(new_phi);
102734 +}
102735 +
102736 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
102737 +{
102738 + const_gimple assign;
102739 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
102740 + tree origtype = TREE_TYPE(orig_rhs);
102741 +
102742 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
102743 +
102744 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
102745 + return gimple_get_lhs(assign);
102746 +}
102747 +
102748 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
102749 +{
102750 + const_tree rhs1, lhs, rhs1_type, lhs_type;
102751 + enum machine_mode lhs_mode, rhs_mode;
102752 + gimple def_stmt = get_def_stmt(no_const_rhs);
102753 +
102754 + if (!gimple_assign_cast_p(def_stmt))
102755 + return false;
102756 +
102757 + rhs1 = gimple_assign_rhs1(def_stmt);
102758 + lhs = gimple_get_lhs(def_stmt);
102759 + rhs1_type = TREE_TYPE(rhs1);
102760 + lhs_type = TREE_TYPE(lhs);
102761 + rhs_mode = TYPE_MODE(rhs1_type);
102762 + lhs_mode = TYPE_MODE(lhs_type);
102763 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
102764 + return false;
102765 +
102766 + return true;
102767 +}
102768 +
102769 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
102770 +{
102771 + tree rhs1 = gimple_assign_rhs1(stmt);
102772 + tree lhs = gimple_get_lhs(stmt);
102773 + const_tree rhs1_type = TREE_TYPE(rhs1);
102774 + const_tree lhs_type = TREE_TYPE(lhs);
102775 +
102776 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
102777 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102778 +
102779 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
102780 +}
102781 +
102782 +static bool no_uses(tree node)
102783 +{
102784 + imm_use_iterator imm_iter;
102785 + use_operand_p use_p;
102786 +
102787 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
102788 + const_gimple use_stmt = USE_STMT(use_p);
102789 + if (use_stmt == NULL)
102790 + return true;
102791 + if (is_gimple_debug(use_stmt))
102792 + continue;
102793 + if (!(gimple_bb(use_stmt)->flags & BB_REACHABLE))
102794 + continue;
102795 + return false;
102796 + }
102797 + return true;
102798 +}
102799 +
102800 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
102801 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
102802 +{
102803 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
102804 + gimple def_stmt = get_def_stmt(lhs);
102805 +
102806 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
102807 + return false;
102808 +
102809 + rhs1 = gimple_assign_rhs1(def_stmt);
102810 + rhs_type = TREE_TYPE(rhs1);
102811 + lhs_type = TREE_TYPE(lhs);
102812 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
102813 + return false;
102814 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
102815 + return false;
102816 +
102817 + def_stmt = get_def_stmt(rhs1);
102818 + if (!def_stmt || gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_num_ops(def_stmt) != 3)
102819 + return false;
102820 +
102821 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
102822 + return false;
102823 +
102824 + rhs1 = gimple_assign_rhs1(def_stmt);
102825 + rhs2 = gimple_assign_rhs2(def_stmt);
102826 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
102827 + return false;
102828 +
102829 + if (is_gimple_constant(rhs2))
102830 + not_const_rhs = rhs1;
102831 + else
102832 + not_const_rhs = rhs2;
102833 +
102834 + return no_uses(not_const_rhs);
102835 +}
102836 +
102837 +static bool skip_lhs_cast_check(const_gimple stmt)
102838 +{
102839 + const_tree rhs = gimple_assign_rhs1(stmt);
102840 + const_gimple def_stmt = get_def_stmt(rhs);
102841 +
102842 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
102843 + if (gimple_code(def_stmt) == GIMPLE_ASM)
102844 + return true;
102845 +
102846 + if (is_const_plus_unsigned_signed_truncation(rhs))
102847 + return true;
102848 +
102849 + return false;
102850 +}
102851 +
102852 +static tree create_cast_overflow_check(struct pointer_set_t *visited, tree new_rhs1, gimple stmt)
102853 +{
102854 + bool cast_lhs, cast_rhs;
102855 + tree lhs = gimple_get_lhs(stmt);
102856 + tree rhs = gimple_assign_rhs1(stmt);
102857 + const_tree lhs_type = TREE_TYPE(lhs);
102858 + const_tree rhs_type = TREE_TYPE(rhs);
102859 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
102860 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
102861 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
102862 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
102863 +
102864 + static bool check_lhs[3][4] = {
102865 + // ss su us uu
102866 + { false, true, true, false }, // lhs > rhs
102867 + { false, false, false, false }, // lhs = rhs
102868 + { true, true, true, true }, // lhs < rhs
102869 + };
102870 +
102871 + static bool check_rhs[3][4] = {
102872 + // ss su us uu
102873 + { true, false, true, true }, // lhs > rhs
102874 + { true, false, true, true }, // lhs = rhs
102875 + { true, false, true, true }, // lhs < rhs
102876 + };
102877 +
102878 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
102879 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
102880 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102881 +
102882 + if (lhs_size > rhs_size) {
102883 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102884 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102885 + } else if (lhs_size == rhs_size) {
102886 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102887 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102888 + } else {
102889 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102890 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
102891 + }
102892 +
102893 + if (!cast_lhs && !cast_rhs)
102894 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102895 +
102896 + if (cast_lhs && !skip_lhs_cast_check(stmt))
102897 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
102898 +
102899 + if (cast_rhs)
102900 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
102901 +
102902 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102903 +}
102904 +
102905 +static tree handle_unary_rhs(struct pointer_set_t *visited, gimple stmt)
102906 +{
102907 + tree rhs1, new_rhs1, lhs = gimple_get_lhs(stmt);
102908 +
102909 + if (gimple_plf(stmt, MY_STMT))
102910 + return lhs;
102911 +
102912 + rhs1 = gimple_assign_rhs1(stmt);
102913 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
102914 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102915 +
102916 + new_rhs1 = expand(visited, rhs1);
102917 +
102918 + if (new_rhs1 == NULL_TREE)
102919 + return create_cast_assign(visited, stmt);
102920 +
102921 + if (gimple_plf(stmt, NO_CAST_CHECK))
102922 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102923 +
102924 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
102925 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
102926 +
102927 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
102928 + check_size_overflow(stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
102929 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102930 + }
102931 +
102932 + if (!gimple_assign_cast_p(stmt))
102933 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
102934 +
102935 + return create_cast_overflow_check(visited, new_rhs1, stmt);
102936 +}
102937 +
102938 +static tree handle_unary_ops(struct pointer_set_t *visited, gimple stmt)
102939 +{
102940 + tree rhs1, lhs = gimple_get_lhs(stmt);
102941 + gimple def_stmt = get_def_stmt(lhs);
102942 +
102943 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
102944 + rhs1 = gimple_assign_rhs1(def_stmt);
102945 +
102946 + if (is_gimple_constant(rhs1))
102947 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102948 +
102949 + switch (TREE_CODE(rhs1)) {
102950 + case SSA_NAME:
102951 + return handle_unary_rhs(visited, def_stmt);
102952 + case ARRAY_REF:
102953 + case BIT_FIELD_REF:
102954 + case ADDR_EXPR:
102955 + case COMPONENT_REF:
102956 + case INDIRECT_REF:
102957 +#if BUILDING_GCC_VERSION >= 4006
102958 + case MEM_REF:
102959 +#endif
102960 + case TARGET_MEM_REF:
102961 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
102962 + case PARM_DECL:
102963 + case VAR_DECL:
102964 + return create_assign(visited, stmt, lhs, AFTER_STMT);
102965 +
102966 + default:
102967 + debug_gimple_stmt(def_stmt);
102968 + debug_tree(rhs1);
102969 + gcc_unreachable();
102970 + }
102971 +}
102972 +
102973 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
102974 +{
102975 + gimple cond_stmt;
102976 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
102977 +
102978 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
102979 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
102980 + update_stmt(cond_stmt);
102981 +}
102982 +
102983 +static tree create_string_param(tree string)
102984 +{
102985 + tree i_type, a_type;
102986 + const int length = TREE_STRING_LENGTH(string);
102987 +
102988 + gcc_assert(length > 0);
102989 +
102990 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
102991 + a_type = build_array_type(char_type_node, i_type);
102992 +
102993 + TREE_TYPE(string) = a_type;
102994 + TREE_CONSTANT(string) = 1;
102995 + TREE_READONLY(string) = 1;
102996 +
102997 + return build1(ADDR_EXPR, ptr_type_node, string);
102998 +}
102999 +
103000 +static void insert_cond_result(basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
103001 +{
103002 + gimple func_stmt;
103003 + const_gimple def_stmt;
103004 + const_tree loc_line;
103005 + tree loc_file, ssa_name, current_func;
103006 + expanded_location xloc;
103007 + char *ssa_name_buf;
103008 + int len;
103009 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
103010 +
103011 + def_stmt = get_def_stmt(arg);
103012 + xloc = expand_location(gimple_location(def_stmt));
103013 +
103014 + if (!gimple_has_location(def_stmt)) {
103015 + xloc = expand_location(gimple_location(stmt));
103016 + if (!gimple_has_location(stmt))
103017 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
103018 + }
103019 +
103020 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
103021 +
103022 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
103023 + loc_file = create_string_param(loc_file);
103024 +
103025 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
103026 + current_func = create_string_param(current_func);
103027 +
103028 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
103029 + call_count++;
103030 + 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);
103031 + gcc_assert(len > 0);
103032 + ssa_name = build_string(len + 1, ssa_name_buf);
103033 + free(ssa_name_buf);
103034 + ssa_name = create_string_param(ssa_name);
103035 +
103036 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
103037 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
103038 +
103039 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
103040 +}
103041 +
103042 +static void __unused print_the_code_insertions(const_gimple stmt)
103043 +{
103044 + location_t loc = gimple_location(stmt);
103045 +
103046 + inform(loc, "Integer size_overflow check applied here.");
103047 +}
103048 +
103049 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
103050 +{
103051 + basic_block cond_bb, join_bb, bb_true;
103052 + edge e;
103053 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
103054 +
103055 + cond_bb = gimple_bb(stmt);
103056 + if (before)
103057 + gsi_prev(&gsi);
103058 + if (gsi_end_p(gsi))
103059 + e = split_block_after_labels(cond_bb);
103060 + else
103061 + e = split_block(cond_bb, gsi_stmt(gsi));
103062 + cond_bb = e->src;
103063 + join_bb = e->dest;
103064 + e->flags = EDGE_FALSE_VALUE;
103065 + e->probability = REG_BR_PROB_BASE;
103066 +
103067 + bb_true = create_empty_bb(cond_bb);
103068 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
103069 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
103070 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
103071 +
103072 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
103073 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
103074 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
103075 +
103076 + if (current_loops != NULL) {
103077 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
103078 + add_bb_to_loop(bb_true, cond_bb->loop_father);
103079 + }
103080 +
103081 + insert_cond(cond_bb, arg, cond_code, type_value);
103082 + insert_cond_result(bb_true, stmt, arg, min);
103083 +
103084 +// print_the_code_insertions(stmt);
103085 +}
103086 +
103087 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
103088 +{
103089 + const_tree rhs_type = TREE_TYPE(rhs);
103090 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
103091 +
103092 + gcc_assert(rhs_type != NULL_TREE);
103093 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
103094 + return;
103095 +
103096 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
103097 +
103098 + if (is_const_plus_unsigned_signed_truncation(rhs))
103099 + return;
103100 +
103101 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
103102 + // typemax (-1) < typemin (0)
103103 + if (TREE_OVERFLOW(type_max))
103104 + return;
103105 +
103106 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
103107 +
103108 + cast_rhs_type = TREE_TYPE(cast_rhs);
103109 + type_max_type = TREE_TYPE(type_max);
103110 + type_min_type = TREE_TYPE(type_min);
103111 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
103112 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
103113 +
103114 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max, before, false);
103115 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min, before, true);
103116 +}
103117 +
103118 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
103119 +{
103120 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
103121 + return false;
103122 + if (!is_gimple_constant(rhs))
103123 + return false;
103124 + return true;
103125 +}
103126 +
103127 +static tree get_def_stmt_rhs(const_tree var)
103128 +{
103129 + tree rhs1, def_stmt_rhs1;
103130 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
103131 +
103132 + def_stmt = get_def_stmt(var);
103133 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
103134 +
103135 + rhs1 = gimple_assign_rhs1(def_stmt);
103136 + rhs1_def_stmt = get_def_stmt(rhs1);
103137 + if (!gimple_assign_cast_p(rhs1_def_stmt))
103138 + return rhs1;
103139 +
103140 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
103141 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
103142 +
103143 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
103144 + case GIMPLE_CALL:
103145 + case GIMPLE_NOP:
103146 + case GIMPLE_ASM:
103147 + case GIMPLE_PHI:
103148 + return def_stmt_rhs1;
103149 + case GIMPLE_ASSIGN:
103150 + return rhs1;
103151 + default:
103152 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
103153 + gcc_unreachable();
103154 + }
103155 +}
103156 +
103157 +static tree handle_intentional_overflow(struct pointer_set_t *visited, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
103158 +{
103159 + tree new_rhs, orig_rhs;
103160 + void (*gimple_assign_set_rhs)(gimple, tree);
103161 + tree rhs1 = gimple_assign_rhs1(stmt);
103162 + tree rhs2 = gimple_assign_rhs2(stmt);
103163 + tree lhs = gimple_get_lhs(stmt);
103164 +
103165 + if (!check_overflow)
103166 + return create_assign(visited, stmt, lhs, AFTER_STMT);
103167 +
103168 + if (change_rhs == NULL_TREE)
103169 + return create_assign(visited, stmt, lhs, AFTER_STMT);
103170 +
103171 + if (new_rhs2 == NULL_TREE) {
103172 + orig_rhs = rhs1;
103173 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
103174 + } else {
103175 + orig_rhs = rhs2;
103176 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
103177 + }
103178 +
103179 + check_size_overflow(stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
103180 +
103181 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
103182 + gimple_assign_set_rhs(stmt, new_rhs);
103183 + update_stmt(stmt);
103184 +
103185 + return create_assign(visited, stmt, lhs, AFTER_STMT);
103186 +}
103187 +
103188 +static bool is_subtraction_special(const_gimple stmt)
103189 +{
103190 + gimple rhs1_def_stmt, rhs2_def_stmt;
103191 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
103192 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
103193 + const_tree rhs1 = gimple_assign_rhs1(stmt);
103194 + const_tree rhs2 = gimple_assign_rhs2(stmt);
103195 +
103196 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
103197 + return false;
103198 +
103199 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
103200 +
103201 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
103202 + return false;
103203 +
103204 + rhs1_def_stmt = get_def_stmt(rhs1);
103205 + rhs2_def_stmt = get_def_stmt(rhs2);
103206 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
103207 + return false;
103208 +
103209 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
103210 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
103211 + rhs1_def_stmt_lhs = gimple_get_lhs(rhs1_def_stmt);
103212 + rhs2_def_stmt_lhs = gimple_get_lhs(rhs2_def_stmt);
103213 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
103214 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
103215 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
103216 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
103217 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
103218 + return false;
103219 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
103220 + return false;
103221 +
103222 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
103223 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
103224 + return true;
103225 +}
103226 +
103227 +static tree handle_integer_truncation(struct pointer_set_t *visited, const_tree lhs)
103228 +{
103229 + tree new_rhs1, new_rhs2;
103230 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
103231 + gimple assign, stmt = get_def_stmt(lhs);
103232 + tree rhs1 = gimple_assign_rhs1(stmt);
103233 + tree rhs2 = gimple_assign_rhs2(stmt);
103234 +
103235 + if (!is_subtraction_special(stmt))
103236 + return NULL_TREE;
103237 +
103238 + new_rhs1 = expand(visited, rhs1);
103239 + new_rhs2 = expand(visited, rhs2);
103240 +
103241 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
103242 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
103243 +
103244 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
103245 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
103246 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
103247 + }
103248 +
103249 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
103250 + new_lhs = gimple_get_lhs(assign);
103251 + check_size_overflow(assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
103252 +
103253 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
103254 +}
103255 +
103256 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
103257 +{
103258 + const_gimple def_stmt;
103259 +
103260 + if (TREE_CODE(rhs) != SSA_NAME)
103261 + return false;
103262 +
103263 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
103264 + return false;
103265 +
103266 + def_stmt = get_def_stmt(rhs);
103267 + if (gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
103268 + return false;
103269 +
103270 + return true;
103271 +}
103272 +
103273 +static tree handle_binary_ops(struct pointer_set_t *visited, tree lhs)
103274 +{
103275 + tree rhs1, rhs2, new_lhs;
103276 + gimple def_stmt = get_def_stmt(lhs);
103277 + tree new_rhs1 = NULL_TREE;
103278 + tree new_rhs2 = NULL_TREE;
103279 +
103280 + rhs1 = gimple_assign_rhs1(def_stmt);
103281 + rhs2 = gimple_assign_rhs2(def_stmt);
103282 +
103283 + /* no DImode/TImode division in the 32/64 bit kernel */
103284 + switch (gimple_assign_rhs_code(def_stmt)) {
103285 + case RDIV_EXPR:
103286 + case TRUNC_DIV_EXPR:
103287 + case CEIL_DIV_EXPR:
103288 + case FLOOR_DIV_EXPR:
103289 + case ROUND_DIV_EXPR:
103290 + case TRUNC_MOD_EXPR:
103291 + case CEIL_MOD_EXPR:
103292 + case FLOOR_MOD_EXPR:
103293 + case ROUND_MOD_EXPR:
103294 + case EXACT_DIV_EXPR:
103295 + case POINTER_PLUS_EXPR:
103296 + case BIT_AND_EXPR:
103297 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
103298 + default:
103299 + break;
103300 + }
103301 +
103302 + new_lhs = handle_integer_truncation(visited, lhs);
103303 + if (new_lhs != NULL_TREE)
103304 + return new_lhs;
103305 +
103306 + if (TREE_CODE(rhs1) == SSA_NAME)
103307 + new_rhs1 = expand(visited, rhs1);
103308 + if (TREE_CODE(rhs2) == SSA_NAME)
103309 + new_rhs2 = expand(visited, rhs2);
103310 +
103311 + if (is_a_neg_overflow(def_stmt, rhs2))
103312 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs1, NULL_TREE);
103313 + if (is_a_neg_overflow(def_stmt, rhs1))
103314 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs2, new_rhs2);
103315 +
103316 +
103317 + if (is_a_constant_overflow(def_stmt, rhs2))
103318 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
103319 + if (is_a_constant_overflow(def_stmt, rhs1))
103320 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
103321 +
103322 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
103323 +}
103324 +
103325 +#if BUILDING_GCC_VERSION >= 4007
103326 +static tree get_new_rhs(struct pointer_set_t *visited, tree size_overflow_type, tree rhs)
103327 +{
103328 + if (is_gimple_constant(rhs))
103329 + return cast_a_tree(size_overflow_type, rhs);
103330 + if (TREE_CODE(rhs) != SSA_NAME)
103331 + return NULL_TREE;
103332 + return expand(visited, rhs);
103333 +}
103334 +
103335 +static tree handle_ternary_ops(struct pointer_set_t *visited, tree lhs)
103336 +{
103337 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
103338 + gimple def_stmt = get_def_stmt(lhs);
103339 +
103340 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
103341 +
103342 + rhs1 = gimple_assign_rhs1(def_stmt);
103343 + rhs2 = gimple_assign_rhs2(def_stmt);
103344 + rhs3 = gimple_assign_rhs3(def_stmt);
103345 + new_rhs1 = get_new_rhs(visited, size_overflow_type, rhs1);
103346 + new_rhs2 = get_new_rhs(visited, size_overflow_type, rhs2);
103347 + new_rhs3 = get_new_rhs(visited, size_overflow_type, rhs3);
103348 +
103349 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
103350 +}
103351 +#endif
103352 +
103353 +static tree get_size_overflow_type(gimple stmt, const_tree node)
103354 +{
103355 + const_tree type;
103356 + tree new_type;
103357 +
103358 + gcc_assert(node != NULL_TREE);
103359 +
103360 + type = TREE_TYPE(node);
103361 +
103362 + if (gimple_plf(stmt, MY_STMT))
103363 + return TREE_TYPE(node);
103364 +
103365 + switch (TYPE_MODE(type)) {
103366 + case QImode:
103367 + new_type = intHI_type_node;
103368 + break;
103369 + case HImode:
103370 + new_type = intSI_type_node;
103371 + break;
103372 + case SImode:
103373 + new_type = intDI_type_node;
103374 + break;
103375 + case DImode:
103376 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
103377 + new_type = intDI_type_node;
103378 + else
103379 + new_type = intTI_type_node;
103380 + break;
103381 + default:
103382 + debug_tree((tree)node);
103383 + error("%s: unsupported gcc configuration.", __func__);
103384 + gcc_unreachable();
103385 + }
103386 +
103387 + if (TYPE_QUALS(type) != 0)
103388 + return build_qualified_type(new_type, TYPE_QUALS(type));
103389 + return new_type;
103390 +}
103391 +
103392 +static tree expand_visited(gimple def_stmt)
103393 +{
103394 + const_gimple next_stmt;
103395 + gimple_stmt_iterator gsi;
103396 + enum gimple_code code = gimple_code(def_stmt);
103397 +
103398 + if (code == GIMPLE_ASM)
103399 + return NULL_TREE;
103400 +
103401 + gsi = gsi_for_stmt(def_stmt);
103402 + gsi_next(&gsi);
103403 +
103404 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
103405 + return NULL_TREE;
103406 + gcc_assert(!gsi_end_p(gsi));
103407 + next_stmt = gsi_stmt(gsi);
103408 +
103409 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
103410 + return NULL_TREE;
103411 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
103412 +
103413 + return get_lhs(next_stmt);
103414 +}
103415 +
103416 +static tree expand(struct pointer_set_t *visited, tree lhs)
103417 +{
103418 + gimple def_stmt;
103419 +
103420 + if (skip_types(lhs))
103421 + return NULL_TREE;
103422 +
103423 + def_stmt = get_def_stmt(lhs);
103424 +
103425 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
103426 + return NULL_TREE;
103427 +
103428 + if (gimple_plf(def_stmt, MY_STMT))
103429 + return lhs;
103430 +
103431 + if (pointer_set_contains(visited, def_stmt))
103432 + return expand_visited(def_stmt);
103433 +
103434 + switch (gimple_code(def_stmt)) {
103435 + case GIMPLE_PHI:
103436 + return handle_phi(visited, lhs);
103437 + case GIMPLE_CALL:
103438 + case GIMPLE_ASM:
103439 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
103440 + case GIMPLE_ASSIGN:
103441 + switch (gimple_num_ops(def_stmt)) {
103442 + case 2:
103443 + return handle_unary_ops(visited, def_stmt);
103444 + case 3:
103445 + return handle_binary_ops(visited, lhs);
103446 +#if BUILDING_GCC_VERSION >= 4007
103447 + case 4:
103448 + return handle_ternary_ops(visited, lhs);
103449 +#endif
103450 + }
103451 + default:
103452 + debug_gimple_stmt(def_stmt);
103453 + error("%s: unknown gimple code", __func__);
103454 + gcc_unreachable();
103455 + }
103456 +}
103457 +
103458 +static tree get_new_tree(gimple stmt, const_tree orig_node, tree new_node)
103459 +{
103460 + const_gimple assign;
103461 + tree orig_type = TREE_TYPE(orig_node);
103462 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
103463 +
103464 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
103465 + return gimple_get_lhs(assign);
103466 +}
103467 +
103468 +static void change_function_arg(gimple stmt, const_tree orig_arg, unsigned int argnum, tree new_arg)
103469 +{
103470 + gimple_call_set_arg(stmt, argnum, get_new_tree(stmt, orig_arg, new_arg));
103471 + update_stmt(stmt);
103472 +}
103473 +
103474 +static void change_function_return(gimple stmt, const_tree orig_ret, tree new_ret)
103475 +{
103476 + gimple_return_set_retval(stmt, get_new_tree(stmt, orig_ret, new_ret));
103477 + update_stmt(stmt);
103478 +}
103479 +
103480 +static bool get_function_arg(unsigned int* argnum, const_tree fndecl)
103481 +{
103482 + tree arg;
103483 + const_tree origarg;
103484 +
103485 + if (!DECL_ABSTRACT_ORIGIN(fndecl))
103486 + return true;
103487 +
103488 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
103489 + while (origarg && *argnum) {
103490 + (*argnum)--;
103491 + origarg = TREE_CHAIN(origarg);
103492 + }
103493 +
103494 + gcc_assert(*argnum == 0);
103495 +
103496 + gcc_assert(origarg != NULL_TREE);
103497 + *argnum = 0;
103498 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg), (*argnum)++)
103499 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
103500 + return true;
103501 + return false;
103502 +}
103503 +
103504 +static enum mark walk_phi(struct pointer_set_t *visited, bool *search_err_code, const_tree result)
103505 +{
103506 + gimple phi = get_def_stmt(result);
103507 + unsigned int i, n = gimple_phi_num_args(phi);
103508 +
103509 + if (!phi)
103510 + return MARK_NO;
103511 +
103512 + pointer_set_insert(visited, phi);
103513 + for (i = 0; i < n; i++) {
103514 + enum mark marked;
103515 + const_tree arg = gimple_phi_arg_def(phi, i);
103516 + marked = pre_expand(visited, search_err_code, arg);
103517 + if (marked != MARK_NO)
103518 + return marked;
103519 + }
103520 + return MARK_NO;
103521 +}
103522 +
103523 +static enum mark walk_unary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
103524 +{
103525 + gimple def_stmt = get_def_stmt(lhs);
103526 + const_tree rhs;
103527 +
103528 + if (!def_stmt)
103529 + return MARK_NO;
103530 +
103531 + rhs = gimple_assign_rhs1(def_stmt);
103532 +
103533 + def_stmt = get_def_stmt(rhs);
103534 + if (is_gimple_constant(rhs))
103535 + search_err_code[FROM_CONST] = true;
103536 +
103537 + return pre_expand(visited, search_err_code, rhs);
103538 +}
103539 +
103540 +static enum mark walk_binary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
103541 +{
103542 + gimple def_stmt = get_def_stmt(lhs);
103543 + const_tree rhs1, rhs2;
103544 + enum mark marked;
103545 +
103546 + if (!def_stmt)
103547 + return MARK_NO;
103548 +
103549 + search_err_code[CAST_ONLY] = false;
103550 +
103551 + rhs1 = gimple_assign_rhs1(def_stmt);
103552 + rhs2 = gimple_assign_rhs2(def_stmt);
103553 + marked = pre_expand(visited, search_err_code, rhs1);
103554 + if (marked != MARK_NO)
103555 + return marked;
103556 + return pre_expand(visited, search_err_code, rhs2);
103557 +}
103558 +
103559 +static const_tree search_field_decl(const_tree comp_ref)
103560 +{
103561 + const_tree field = NULL_TREE;
103562 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
103563 +
103564 + for (i = 0; i < len; i++) {
103565 + field = TREE_OPERAND(comp_ref, i);
103566 + if (TREE_CODE(field) == FIELD_DECL)
103567 + break;
103568 + }
103569 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
103570 + return field;
103571 +}
103572 +
103573 +static enum mark mark_status(const_tree fndecl, unsigned int argnum)
103574 +{
103575 + const_tree attr, p;
103576 +
103577 + // 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);
103578 + if (fndecl == NULL_TREE)
103579 + return MARK_NO;
103580 +
103581 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(fndecl));
103582 + if (!attr || !TREE_VALUE(attr))
103583 + return MARK_NO;
103584 +
103585 + p = TREE_VALUE(attr);
103586 + if (TREE_INT_CST_HIGH(TREE_VALUE(p)) == -1)
103587 + return MARK_TURN_OFF;
103588 + if (!TREE_INT_CST_LOW(TREE_VALUE(p)))
103589 + return MARK_NOT_INTENTIONAL;
103590 + if (argnum == 0) {
103591 + gcc_assert(current_function_decl == fndecl);
103592 + return MARK_NO;
103593 + }
103594 +
103595 + do {
103596 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(p)))
103597 + return MARK_YES;
103598 + p = TREE_CHAIN(p);
103599 + } while (p);
103600 +
103601 + return MARK_NO;
103602 +}
103603 +
103604 +static void print_missing_msg(tree func, unsigned int argnum)
103605 +{
103606 + unsigned int new_hash;
103607 + size_t len;
103608 + unsigned char tree_codes[CODES_LIMIT];
103609 + location_t loc;
103610 + const char *curfunc;
103611 +
103612 + func = get_original_function_decl(func);
103613 + loc = DECL_SOURCE_LOCATION(func);
103614 + curfunc = get_asm_name(func);
103615 +
103616 + len = get_function_decl(func, tree_codes);
103617 + new_hash = get_hash_num(curfunc, (const char *) tree_codes, len, 0);
103618 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, new_hash);
103619 +}
103620 +
103621 +static unsigned int search_missing_attribute(const_tree arg)
103622 +{
103623 + unsigned int argnum;
103624 + const struct size_overflow_hash *hash;
103625 + const_tree type = TREE_TYPE(arg);
103626 + tree func = get_original_function_decl(current_function_decl);
103627 +
103628 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
103629 +
103630 + if (TREE_CODE(type) == POINTER_TYPE)
103631 + return 0;
103632 +
103633 + argnum = find_arg_number(arg, func);
103634 + if (argnum == 0)
103635 + return 0;
103636 +
103637 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(func)))
103638 + return argnum;
103639 +
103640 + hash = get_function_hash(func);
103641 + if (!hash || !(hash->param & (1U << argnum))) {
103642 + print_missing_msg(func, argnum);
103643 + return 0;
103644 + }
103645 + return argnum;
103646 +}
103647 +
103648 +static enum mark is_already_marked(const_tree lhs)
103649 +{
103650 + unsigned int argnum;
103651 + const_tree fndecl;
103652 +
103653 + argnum = search_missing_attribute(lhs);
103654 + fndecl = get_original_function_decl(current_function_decl);
103655 + if (argnum && mark_status(fndecl, argnum) == MARK_YES)
103656 + return MARK_YES;
103657 + return MARK_NO;
103658 +}
103659 +
103660 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
103661 +{
103662 + const_gimple def_stmt;
103663 +
103664 + if (skip_types(lhs))
103665 + return MARK_NO;
103666 +
103667 + if (TREE_CODE(lhs) == PARM_DECL)
103668 + return is_already_marked(lhs);
103669 +
103670 + if (TREE_CODE(lhs) == COMPONENT_REF) {
103671 + const_tree field, attr;
103672 +
103673 + field = search_field_decl(lhs);
103674 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(field));
103675 + if (!attr || !TREE_VALUE(attr))
103676 + return MARK_NO;
103677 + return MARK_YES;
103678 + }
103679 +
103680 + def_stmt = get_def_stmt(lhs);
103681 +
103682 + if (!def_stmt)
103683 + return MARK_NO;
103684 +
103685 + if (pointer_set_contains(visited, def_stmt))
103686 + return MARK_NO;
103687 +
103688 + switch (gimple_code(def_stmt)) {
103689 + case GIMPLE_NOP:
103690 + if (TREE_CODE(SSA_NAME_VAR(lhs)) == PARM_DECL)
103691 + return is_already_marked(lhs);
103692 + return MARK_NO;
103693 + case GIMPLE_PHI:
103694 + return walk_phi(visited, search_err_code, lhs);
103695 + case GIMPLE_CALL:
103696 + if (mark_status((gimple_call_fndecl(def_stmt)), 0) == MARK_TURN_OFF)
103697 + return MARK_TURN_OFF;
103698 + check_function_hash(def_stmt);
103699 + return MARK_NO;
103700 + case GIMPLE_ASM:
103701 + search_err_code[CAST_ONLY] = false;
103702 + return MARK_NO;
103703 + case GIMPLE_ASSIGN:
103704 + switch (gimple_num_ops(def_stmt)) {
103705 + case 2:
103706 + return walk_unary_ops(visited, search_err_code, lhs);
103707 + case 3:
103708 + return walk_binary_ops(visited, search_err_code, lhs);
103709 + }
103710 + default:
103711 + debug_gimple_stmt((gimple)def_stmt);
103712 + error("%s: unknown gimple code", __func__);
103713 + gcc_unreachable();
103714 + }
103715 +}
103716 +
103717 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
103718 +static bool skip_asm(const_tree arg)
103719 +{
103720 + gimple def_stmt = get_def_stmt(arg);
103721 +
103722 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
103723 + return false;
103724 +
103725 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
103726 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
103727 +}
103728 +
103729 +/*
103730 +0</MARK_YES: no dup, search attributes (so, int)
103731 +0/MARK_NOT_INTENTIONAL: no dup, search attribute (int)
103732 +-1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
103733 +*/
103734 +
103735 +static bool search_attributes(tree fndecl, const_tree arg, unsigned int argnum, bool where)
103736 +{
103737 + struct pointer_set_t *visited;
103738 + enum mark is_marked, is_found;
103739 + location_t loc;
103740 + bool search_err_code[2] = {true, false};
103741 +
103742 + is_marked = mark_status(current_function_decl, 0);
103743 + if (is_marked == MARK_TURN_OFF)
103744 + return true;
103745 +
103746 + is_marked = mark_status(fndecl, argnum + 1);
103747 + if (is_marked == MARK_TURN_OFF || is_marked == MARK_NOT_INTENTIONAL)
103748 + return true;
103749 +
103750 + visited = pointer_set_create();
103751 + is_found = pre_expand(visited, search_err_code, arg);
103752 + pointer_set_destroy(visited);
103753 +
103754 + if (where == FROM_RET && search_err_code[CAST_ONLY] && search_err_code[FROM_CONST])
103755 + return true;
103756 +
103757 + if (where == FROM_ARG && skip_asm(arg))
103758 + return true;
103759 +
103760 + if (is_found == MARK_TURN_OFF)
103761 + return true;
103762 +
103763 + if ((is_found == MARK_YES && is_marked == MARK_YES))
103764 + return true;
103765 +
103766 + if (is_found == MARK_YES) {
103767 + loc = DECL_SOURCE_LOCATION(fndecl);
103768 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", get_asm_name(fndecl), argnum + 1);
103769 + return true;
103770 + }
103771 + return false;
103772 +}
103773 +
103774 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
103775 +{
103776 + struct pointer_set_t *visited;
103777 + tree arg, new_arg;
103778 + bool match;
103779 +
103780 + if (argnum == 0)
103781 + return;
103782 +
103783 + argnum--;
103784 +
103785 + match = get_function_arg(&argnum, fndecl);
103786 + if (!match)
103787 + return;
103788 + gcc_assert(gimple_call_num_args(stmt) > argnum);
103789 + arg = gimple_call_arg(stmt, argnum);
103790 + if (arg == NULL_TREE)
103791 + return;
103792 +
103793 + if (skip_types(arg))
103794 + return;
103795 +
103796 + if (search_attributes(fndecl, arg, argnum, FROM_ARG))
103797 + return;
103798 +
103799 + visited = pointer_set_create();
103800 + new_arg = expand(visited, arg);
103801 + pointer_set_destroy(visited);
103802 +
103803 + if (new_arg == NULL_TREE)
103804 + return;
103805 +
103806 + change_function_arg(stmt, arg, argnum, new_arg);
103807 + check_size_overflow(stmt, TREE_TYPE(new_arg), new_arg, arg, BEFORE_STMT);
103808 +}
103809 +
103810 +static void handle_function_by_attribute(gimple stmt, const_tree attr, tree fndecl)
103811 +{
103812 + tree p = TREE_VALUE(attr);
103813 + do {
103814 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p)));
103815 + p = TREE_CHAIN(p);
103816 + } while (p);
103817 +}
103818 +
103819 +static void handle_function_by_hash(gimple stmt, tree fndecl)
103820 +{
103821 + unsigned int num;
103822 + const struct size_overflow_hash *hash;
103823 +
103824 + hash = get_function_hash(fndecl);
103825 + if (!hash)
103826 + return;
103827 +
103828 + for (num = 0; num <= MAX_PARAM; num++)
103829 + if (hash->param & (1U << num))
103830 + handle_function_arg(stmt, fndecl, num);
103831 +}
103832 +
103833 +static bool check_return_value(void)
103834 +{
103835 + const struct size_overflow_hash *hash;
103836 +
103837 + hash = get_function_hash(current_function_decl);
103838 + if (!hash || !(hash->param & 1U << 0))
103839 + return false;
103840 +
103841 + return true;
103842 +}
103843 +
103844 +static void handle_return_value(gimple ret_stmt)
103845 +{
103846 + struct pointer_set_t *visited;
103847 + tree ret, new_ret;
103848 +
103849 + if (gimple_code(ret_stmt) != GIMPLE_RETURN)
103850 + return;
103851 +
103852 + ret = gimple_return_retval(ret_stmt);
103853 +
103854 + if (skip_types(ret))
103855 + return;
103856 +
103857 + if (search_attributes(current_function_decl, ret, 0, FROM_RET))
103858 + return;
103859 +
103860 + visited = pointer_set_create();
103861 + new_ret = expand(visited, ret);
103862 + pointer_set_destroy(visited);
103863 +
103864 + change_function_return(ret_stmt, ret, new_ret);
103865 + check_size_overflow(ret_stmt, TREE_TYPE(new_ret), new_ret, ret, BEFORE_STMT);
103866 +}
103867 +
103868 +static void set_plf_false(void)
103869 +{
103870 + basic_block bb;
103871 +
103872 + FOR_ALL_BB(bb) {
103873 + gimple_stmt_iterator si;
103874 +
103875 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
103876 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
103877 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
103878 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
103879 + }
103880 +}
103881 +
103882 +static unsigned int handle_function(void)
103883 +{
103884 + basic_block next, bb = ENTRY_BLOCK_PTR->next_bb;
103885 + bool check_ret;
103886 +
103887 + set_plf_false();
103888 +
103889 + check_ret = check_return_value();
103890 +
103891 + do {
103892 + gimple_stmt_iterator gsi;
103893 + next = bb->next_bb;
103894 +
103895 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
103896 + tree fndecl, attr;
103897 + gimple stmt = gsi_stmt(gsi);
103898 +
103899 + if (check_ret)
103900 + handle_return_value(stmt);
103901 +
103902 + if (!(is_gimple_call(stmt)))
103903 + continue;
103904 + fndecl = gimple_call_fndecl(stmt);
103905 + if (fndecl == NULL_TREE)
103906 + continue;
103907 + if (gimple_call_num_args(stmt) == 0)
103908 + continue;
103909 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
103910 + if (!attr || !TREE_VALUE(attr))
103911 + handle_function_by_hash(stmt, fndecl);
103912 + else
103913 + handle_function_by_attribute(stmt, attr, fndecl);
103914 + gsi = gsi_for_stmt(stmt);
103915 + next = gimple_bb(stmt)->next_bb;
103916 + }
103917 + bb = next;
103918 + } while (bb);
103919 + return 0;
103920 +}
103921 +
103922 +static struct gimple_opt_pass size_overflow_pass = {
103923 + .pass = {
103924 + .type = GIMPLE_PASS,
103925 + .name = "size_overflow",
103926 +#if BUILDING_GCC_VERSION >= 4008
103927 + .optinfo_flags = OPTGROUP_NONE,
103928 +#endif
103929 + .gate = NULL,
103930 + .execute = handle_function,
103931 + .sub = NULL,
103932 + .next = NULL,
103933 + .static_pass_number = 0,
103934 + .tv_id = TV_NONE,
103935 + .properties_required = PROP_cfg,
103936 + .properties_provided = 0,
103937 + .properties_destroyed = 0,
103938 + .todo_flags_start = 0,
103939 + .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
103940 + }
103941 +};
103942 +
103943 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
103944 +{
103945 + tree fntype;
103946 +
103947 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
103948 +
103949 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
103950 + fntype = build_function_type_list(void_type_node,
103951 + const_char_ptr_type_node,
103952 + unsigned_type_node,
103953 + const_char_ptr_type_node,
103954 + const_char_ptr_type_node,
103955 + NULL_TREE);
103956 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
103957 +
103958 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
103959 + TREE_PUBLIC(report_size_overflow_decl) = 1;
103960 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
103961 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
103962 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
103963 +}
103964 +
103965 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
103966 +{
103967 + int i;
103968 + const char * const plugin_name = plugin_info->base_name;
103969 + const int argc = plugin_info->argc;
103970 + const struct plugin_argument * const argv = plugin_info->argv;
103971 + bool enable = true;
103972 +
103973 + struct register_pass_info size_overflow_pass_info = {
103974 + .pass = &size_overflow_pass.pass,
103975 + .reference_pass_name = "ssa",
103976 + .ref_pass_instance_number = 1,
103977 + .pos_op = PASS_POS_INSERT_AFTER
103978 + };
103979 +
103980 + if (!plugin_default_version_check(version, &gcc_version)) {
103981 + error(G_("incompatible gcc/plugin versions"));
103982 + return 1;
103983 + }
103984 +
103985 + for (i = 0; i < argc; ++i) {
103986 + if (!strcmp(argv[i].key, "no-size-overflow")) {
103987 + enable = false;
103988 + continue;
103989 + }
103990 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103991 + }
103992 +
103993 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
103994 + if (enable) {
103995 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
103996 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
103997 + }
103998 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
103999 +
104000 + return 0;
104001 +}
104002 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
104003 new file mode 100644
104004 index 0000000..ac2901e
104005 --- /dev/null
104006 +++ b/tools/gcc/stackleak_plugin.c
104007 @@ -0,0 +1,327 @@
104008 +/*
104009 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
104010 + * Licensed under the GPL v2
104011 + *
104012 + * Note: the choice of the license means that the compilation process is
104013 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
104014 + * but for the kernel it doesn't matter since it doesn't link against
104015 + * any of the gcc libraries
104016 + *
104017 + * gcc plugin to help implement various PaX features
104018 + *
104019 + * - track lowest stack pointer
104020 + *
104021 + * TODO:
104022 + * - initialize all local variables
104023 + *
104024 + * BUGS:
104025 + * - none known
104026 + */
104027 +#include "gcc-plugin.h"
104028 +#include "config.h"
104029 +#include "system.h"
104030 +#include "coretypes.h"
104031 +#include "tree.h"
104032 +#include "tree-pass.h"
104033 +#include "flags.h"
104034 +#include "intl.h"
104035 +#include "toplev.h"
104036 +#include "plugin.h"
104037 +//#include "expr.h" where are you...
104038 +#include "diagnostic.h"
104039 +#include "plugin-version.h"
104040 +#include "tm.h"
104041 +#include "function.h"
104042 +#include "basic-block.h"
104043 +#include "gimple.h"
104044 +#include "rtl.h"
104045 +#include "emit-rtl.h"
104046 +
104047 +#if BUILDING_GCC_VERSION >= 4008
104048 +#define TODO_dump_func 0
104049 +#endif
104050 +
104051 +extern void print_gimple_stmt(FILE *, gimple, int, int);
104052 +
104053 +int plugin_is_GPL_compatible;
104054 +
104055 +static int track_frame_size = -1;
104056 +static const char track_function[] = "pax_track_stack";
104057 +static const char check_function[] = "pax_check_alloca";
104058 +static bool init_locals;
104059 +
104060 +static struct plugin_info stackleak_plugin_info = {
104061 + .version = "201302112000",
104062 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
104063 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
104064 +};
104065 +
104066 +static bool gate_stackleak_track_stack(void);
104067 +static unsigned int execute_stackleak_tree_instrument(void);
104068 +static unsigned int execute_stackleak_final(void);
104069 +
104070 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
104071 + .pass = {
104072 + .type = GIMPLE_PASS,
104073 + .name = "stackleak_tree_instrument",
104074 +#if BUILDING_GCC_VERSION >= 4008
104075 + .optinfo_flags = OPTGROUP_NONE,
104076 +#endif
104077 + .gate = gate_stackleak_track_stack,
104078 + .execute = execute_stackleak_tree_instrument,
104079 + .sub = NULL,
104080 + .next = NULL,
104081 + .static_pass_number = 0,
104082 + .tv_id = TV_NONE,
104083 + .properties_required = PROP_gimple_leh | PROP_cfg,
104084 + .properties_provided = 0,
104085 + .properties_destroyed = 0,
104086 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
104087 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
104088 + }
104089 +};
104090 +
104091 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
104092 + .pass = {
104093 + .type = RTL_PASS,
104094 + .name = "stackleak_final",
104095 +#if BUILDING_GCC_VERSION >= 4008
104096 + .optinfo_flags = OPTGROUP_NONE,
104097 +#endif
104098 + .gate = gate_stackleak_track_stack,
104099 + .execute = execute_stackleak_final,
104100 + .sub = NULL,
104101 + .next = NULL,
104102 + .static_pass_number = 0,
104103 + .tv_id = TV_NONE,
104104 + .properties_required = 0,
104105 + .properties_provided = 0,
104106 + .properties_destroyed = 0,
104107 + .todo_flags_start = 0,
104108 + .todo_flags_finish = TODO_dump_func
104109 + }
104110 +};
104111 +
104112 +static bool gate_stackleak_track_stack(void)
104113 +{
104114 + return track_frame_size >= 0;
104115 +}
104116 +
104117 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
104118 +{
104119 + gimple check_alloca;
104120 + tree fntype, fndecl, alloca_size;
104121 +
104122 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
104123 + fndecl = build_fn_decl(check_function, fntype);
104124 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
104125 +
104126 + // insert call to void pax_check_alloca(unsigned long size)
104127 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
104128 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
104129 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
104130 +}
104131 +
104132 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
104133 +{
104134 + gimple track_stack;
104135 + tree fntype, fndecl;
104136 +
104137 + fntype = build_function_type_list(void_type_node, NULL_TREE);
104138 + fndecl = build_fn_decl(track_function, fntype);
104139 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
104140 +
104141 + // insert call to void pax_track_stack(void)
104142 + track_stack = gimple_build_call(fndecl, 0);
104143 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
104144 +}
104145 +
104146 +#if BUILDING_GCC_VERSION == 4005
104147 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
104148 +{
104149 + tree fndecl;
104150 +
104151 + if (!is_gimple_call(stmt))
104152 + return false;
104153 + fndecl = gimple_call_fndecl(stmt);
104154 + if (!fndecl)
104155 + return false;
104156 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
104157 + return false;
104158 +// print_node(stderr, "pax", fndecl, 4);
104159 + return DECL_FUNCTION_CODE(fndecl) == code;
104160 +}
104161 +#endif
104162 +
104163 +static bool is_alloca(gimple stmt)
104164 +{
104165 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
104166 + return true;
104167 +
104168 +#if BUILDING_GCC_VERSION >= 4007
104169 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
104170 + return true;
104171 +#endif
104172 +
104173 + return false;
104174 +}
104175 +
104176 +static unsigned int execute_stackleak_tree_instrument(void)
104177 +{
104178 + basic_block bb, entry_bb;
104179 + bool prologue_instrumented = false, is_leaf = true;
104180 +
104181 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
104182 +
104183 + // 1. loop through BBs and GIMPLE statements
104184 + FOR_EACH_BB(bb) {
104185 + gimple_stmt_iterator gsi;
104186 +
104187 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
104188 + gimple stmt;
104189 +
104190 + stmt = gsi_stmt(gsi);
104191 +
104192 + if (is_gimple_call(stmt))
104193 + is_leaf = false;
104194 +
104195 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
104196 + if (!is_alloca(stmt))
104197 + continue;
104198 +
104199 + // 2. insert stack overflow check before each __builtin_alloca call
104200 + stackleak_check_alloca(&gsi);
104201 +
104202 + // 3. insert track call after each __builtin_alloca call
104203 + stackleak_add_instrumentation(&gsi);
104204 + if (bb == entry_bb)
104205 + prologue_instrumented = true;
104206 + }
104207 + }
104208 +
104209 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
104210 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
104211 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
104212 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
104213 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
104214 + return 0;
104215 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
104216 + return 0;
104217 +
104218 + // 4. insert track call at the beginning
104219 + if (!prologue_instrumented) {
104220 + gimple_stmt_iterator gsi;
104221 +
104222 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
104223 + if (dom_info_available_p(CDI_DOMINATORS))
104224 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
104225 + gsi = gsi_start_bb(bb);
104226 + stackleak_add_instrumentation(&gsi);
104227 + }
104228 +
104229 + return 0;
104230 +}
104231 +
104232 +static unsigned int execute_stackleak_final(void)
104233 +{
104234 + rtx insn, next;
104235 +
104236 + if (cfun->calls_alloca)
104237 + return 0;
104238 +
104239 + // keep calls only if function frame is big enough
104240 + if (get_frame_size() >= track_frame_size)
104241 + return 0;
104242 +
104243 + // 1. find pax_track_stack calls
104244 + for (insn = get_insns(); insn; insn = next) {
104245 + // 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))
104246 + rtx body;
104247 +
104248 + next = NEXT_INSN(insn);
104249 + if (!CALL_P(insn))
104250 + continue;
104251 + body = PATTERN(insn);
104252 + if (GET_CODE(body) != CALL)
104253 + continue;
104254 + body = XEXP(body, 0);
104255 + if (GET_CODE(body) != MEM)
104256 + continue;
104257 + body = XEXP(body, 0);
104258 + if (GET_CODE(body) != SYMBOL_REF)
104259 + continue;
104260 + if (strcmp(XSTR(body, 0), track_function))
104261 + continue;
104262 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
104263 + // 2. delete call
104264 + delete_insn_and_edges(insn);
104265 +#if BUILDING_GCC_VERSION >= 4007
104266 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
104267 + insn = next;
104268 + next = NEXT_INSN(insn);
104269 + delete_insn_and_edges(insn);
104270 + }
104271 +#endif
104272 + }
104273 +
104274 +// print_simple_rtl(stderr, get_insns());
104275 +// print_rtl(stderr, get_insns());
104276 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
104277 +
104278 + return 0;
104279 +}
104280 +
104281 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
104282 +{
104283 + const char * const plugin_name = plugin_info->base_name;
104284 + const int argc = plugin_info->argc;
104285 + const struct plugin_argument * const argv = plugin_info->argv;
104286 + int i;
104287 + struct register_pass_info stackleak_tree_instrument_pass_info = {
104288 + .pass = &stackleak_tree_instrument_pass.pass,
104289 +// .reference_pass_name = "tree_profile",
104290 + .reference_pass_name = "optimized",
104291 + .ref_pass_instance_number = 1,
104292 + .pos_op = PASS_POS_INSERT_BEFORE
104293 + };
104294 + struct register_pass_info stackleak_final_pass_info = {
104295 + .pass = &stackleak_final_rtl_opt_pass.pass,
104296 + .reference_pass_name = "final",
104297 + .ref_pass_instance_number = 1,
104298 + .pos_op = PASS_POS_INSERT_BEFORE
104299 + };
104300 +
104301 + if (!plugin_default_version_check(version, &gcc_version)) {
104302 + error(G_("incompatible gcc/plugin versions"));
104303 + return 1;
104304 + }
104305 +
104306 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
104307 +
104308 + for (i = 0; i < argc; ++i) {
104309 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
104310 + if (!argv[i].value) {
104311 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
104312 + continue;
104313 + }
104314 + track_frame_size = atoi(argv[i].value);
104315 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
104316 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
104317 + continue;
104318 + }
104319 + if (!strcmp(argv[i].key, "initialize-locals")) {
104320 + if (argv[i].value) {
104321 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
104322 + continue;
104323 + }
104324 + init_locals = true;
104325 + continue;
104326 + }
104327 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
104328 + }
104329 +
104330 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
104331 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
104332 +
104333 + return 0;
104334 +}
104335 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
104336 new file mode 100644
104337 index 0000000..4fae911
104338 --- /dev/null
104339 +++ b/tools/gcc/structleak_plugin.c
104340 @@ -0,0 +1,277 @@
104341 +/*
104342 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
104343 + * Licensed under the GPL v2
104344 + *
104345 + * Note: the choice of the license means that the compilation process is
104346 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
104347 + * but for the kernel it doesn't matter since it doesn't link against
104348 + * any of the gcc libraries
104349 + *
104350 + * gcc plugin to forcibly initialize certain local variables that could
104351 + * otherwise leak kernel stack to userland if they aren't properly initialized
104352 + * by later code
104353 + *
104354 + * Homepage: http://pax.grsecurity.net/
104355 + *
104356 + * Usage:
104357 + * $ # for 4.5/4.6/C based 4.7
104358 + * $ 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
104359 + * $ # for C++ based 4.7/4.8+
104360 + * $ 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
104361 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
104362 + *
104363 + * TODO: eliminate redundant initializers
104364 + * increase type coverage
104365 + */
104366 +
104367 +#include "gcc-plugin.h"
104368 +#include "config.h"
104369 +#include "system.h"
104370 +#include "coretypes.h"
104371 +#include "tree.h"
104372 +#include "tree-pass.h"
104373 +#include "intl.h"
104374 +#include "plugin-version.h"
104375 +#include "tm.h"
104376 +#include "toplev.h"
104377 +#include "function.h"
104378 +#include "tree-flow.h"
104379 +#include "plugin.h"
104380 +#include "gimple.h"
104381 +#include "diagnostic.h"
104382 +#include "cfgloop.h"
104383 +#include "langhooks.h"
104384 +
104385 +#if BUILDING_GCC_VERSION >= 4008
104386 +#define TODO_dump_func 0
104387 +#endif
104388 +
104389 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
104390 +
104391 +// unused type flag in all versions 4.5-4.8
104392 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
104393 +
104394 +int plugin_is_GPL_compatible;
104395 +void debug_gimple_stmt(gimple gs);
104396 +
104397 +static struct plugin_info structleak_plugin_info = {
104398 + .version = "201304082245",
104399 + .help = "disable\tdo not activate plugin\n",
104400 +};
104401 +
104402 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
104403 +{
104404 + *no_add_attrs = true;
104405 +
104406 + // check for types? for now accept everything linux has to offer
104407 + if (TREE_CODE(*node) != FIELD_DECL)
104408 + return NULL_TREE;
104409 +
104410 + *no_add_attrs = false;
104411 + return NULL_TREE;
104412 +}
104413 +
104414 +static struct attribute_spec user_attr = {
104415 + .name = "user",
104416 + .min_length = 0,
104417 + .max_length = 0,
104418 + .decl_required = false,
104419 + .type_required = false,
104420 + .function_type_required = false,
104421 + .handler = handle_user_attribute,
104422 +#if BUILDING_GCC_VERSION >= 4007
104423 + .affects_type_identity = true
104424 +#endif
104425 +};
104426 +
104427 +static void register_attributes(void *event_data, void *data)
104428 +{
104429 + register_attribute(&user_attr);
104430 +// register_attribute(&force_attr);
104431 +}
104432 +
104433 +static tree get_field_type(tree field)
104434 +{
104435 + return strip_array_types(TREE_TYPE(field));
104436 +}
104437 +
104438 +static bool is_userspace_type(tree type)
104439 +{
104440 + tree field;
104441 +
104442 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
104443 + tree fieldtype = get_field_type(field);
104444 + enum tree_code code = TREE_CODE(fieldtype);
104445 +
104446 + if (code == RECORD_TYPE || code == UNION_TYPE)
104447 + if (is_userspace_type(fieldtype))
104448 + return true;
104449 +
104450 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
104451 + return true;
104452 + }
104453 + return false;
104454 +}
104455 +
104456 +static void finish_type(void *event_data, void *data)
104457 +{
104458 + tree type = (tree)event_data;
104459 +
104460 + if (TYPE_USERSPACE(type))
104461 + return;
104462 +
104463 + if (is_userspace_type(type))
104464 + TYPE_USERSPACE(type) = 1;
104465 +}
104466 +
104467 +static void initialize(tree var)
104468 +{
104469 + basic_block bb;
104470 + gimple_stmt_iterator gsi;
104471 + tree initializer;
104472 + gimple init_stmt;
104473 +
104474 + // this is the original entry bb before the forced split
104475 + // TODO: check further BBs in case more splits occured before us
104476 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
104477 +
104478 + // first check if the variable is already initialized, warn otherwise
104479 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
104480 + gimple stmt = gsi_stmt(gsi);
104481 + tree rhs1;
104482 +
104483 + // we're looking for an assignment of a single rhs...
104484 + if (!gimple_assign_single_p(stmt))
104485 + continue;
104486 + rhs1 = gimple_assign_rhs1(stmt);
104487 +#if BUILDING_GCC_VERSION >= 4007
104488 + // ... of a non-clobbering expression...
104489 + if (TREE_CLOBBER_P(rhs1))
104490 + continue;
104491 +#endif
104492 + // ... to our variable...
104493 + if (gimple_get_lhs(stmt) != var)
104494 + continue;
104495 + // if it's an initializer then we're good
104496 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
104497 + return;
104498 + }
104499 +
104500 + // these aren't the 0days you're looking for
104501 +// inform(DECL_SOURCE_LOCATION(var), "userspace variable will be forcibly initialized");
104502 +
104503 + // build the initializer expression
104504 + initializer = build_constructor(TREE_TYPE(var), NULL);
104505 +
104506 + // build the initializer stmt
104507 + init_stmt = gimple_build_assign(var, initializer);
104508 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
104509 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
104510 + update_stmt(init_stmt);
104511 +}
104512 +
104513 +static unsigned int handle_function(void)
104514 +{
104515 + basic_block bb;
104516 + unsigned int ret = 0;
104517 + tree var;
104518 +
104519 +#if BUILDING_GCC_VERSION == 4005
104520 + tree vars;
104521 +#else
104522 + unsigned int i;
104523 +#endif
104524 +
104525 + // split the first bb where we can put the forced initializers
104526 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
104527 + if (dom_info_available_p(CDI_DOMINATORS))
104528 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
104529 +
104530 + // enumarate all local variables and forcibly initialize our targets
104531 +#if BUILDING_GCC_VERSION == 4005
104532 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
104533 + var = TREE_VALUE(vars);
104534 +#else
104535 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
104536 +#endif
104537 + tree type = TREE_TYPE(var);
104538 +
104539 + gcc_assert(DECL_P(var));
104540 + if (!auto_var_in_fn_p(var, current_function_decl))
104541 + continue;
104542 +
104543 + // only care about structure types
104544 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
104545 + continue;
104546 +
104547 + // if the type is of interest, examine the variable
104548 + if (TYPE_USERSPACE(type))
104549 + initialize(var);
104550 + }
104551 +
104552 + return ret;
104553 +}
104554 +
104555 +static struct gimple_opt_pass structleak_pass = {
104556 + .pass = {
104557 + .type = GIMPLE_PASS,
104558 + .name = "structleak",
104559 +#if BUILDING_GCC_VERSION >= 4008
104560 + .optinfo_flags = OPTGROUP_NONE,
104561 +#endif
104562 + .gate = NULL,
104563 + .execute = handle_function,
104564 + .sub = NULL,
104565 + .next = NULL,
104566 + .static_pass_number = 0,
104567 + .tv_id = TV_NONE,
104568 + .properties_required = PROP_cfg,
104569 + .properties_provided = 0,
104570 + .properties_destroyed = 0,
104571 + .todo_flags_start = 0,
104572 + .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
104573 + }
104574 +};
104575 +
104576 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
104577 +{
104578 + int i;
104579 + const char * const plugin_name = plugin_info->base_name;
104580 + const int argc = plugin_info->argc;
104581 + const struct plugin_argument * const argv = plugin_info->argv;
104582 + bool enable = true;
104583 +
104584 + struct register_pass_info structleak_pass_info = {
104585 + .pass = &structleak_pass.pass,
104586 + .reference_pass_name = "ssa",
104587 + .ref_pass_instance_number = 1,
104588 + .pos_op = PASS_POS_INSERT_AFTER
104589 + };
104590 +
104591 + if (!plugin_default_version_check(version, &gcc_version)) {
104592 + error(G_("incompatible gcc/plugin versions"));
104593 + return 1;
104594 + }
104595 +
104596 + if (strcmp(lang_hooks.name, "GNU C")) {
104597 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
104598 + enable = false;
104599 + }
104600 +
104601 + for (i = 0; i < argc; ++i) {
104602 + if (!strcmp(argv[i].key, "disable")) {
104603 + enable = false;
104604 + continue;
104605 + }
104606 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
104607 + }
104608 +
104609 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
104610 + if (enable) {
104611 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
104612 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
104613 + }
104614 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
104615 +
104616 + return 0;
104617 +}
104618 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
104619 index 6789d78..4afd019e 100644
104620 --- a/tools/perf/util/include/asm/alternative-asm.h
104621 +++ b/tools/perf/util/include/asm/alternative-asm.h
104622 @@ -5,4 +5,7 @@
104623
104624 #define altinstruction_entry #
104625
104626 + .macro pax_force_retaddr rip=0, reload=0
104627 + .endm
104628 +
104629 #endif
104630 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
104631 index 96b919d..c49bb74 100644
104632 --- a/tools/perf/util/include/linux/compiler.h
104633 +++ b/tools/perf/util/include/linux/compiler.h
104634 @@ -18,4 +18,12 @@
104635 #define __force
104636 #endif
104637
104638 +#ifndef __size_overflow
104639 +# define __size_overflow(...)
104640 +#endif
104641 +
104642 +#ifndef __intentional_overflow
104643 +# define __intentional_overflow(...)
104644 +#endif
104645 +
104646 #endif
104647 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
104648 index 302681c..3bde377 100644
104649 --- a/virt/kvm/kvm_main.c
104650 +++ b/virt/kvm/kvm_main.c
104651 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
104652
104653 static cpumask_var_t cpus_hardware_enabled;
104654 static int kvm_usage_count = 0;
104655 -static atomic_t hardware_enable_failed;
104656 +static atomic_unchecked_t hardware_enable_failed;
104657
104658 struct kmem_cache *kvm_vcpu_cache;
104659 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
104660
104661 -static __read_mostly struct preempt_ops kvm_preempt_ops;
104662 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
104663 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
104664 +static struct preempt_ops kvm_preempt_ops = {
104665 + .sched_in = kvm_sched_in,
104666 + .sched_out = kvm_sched_out,
104667 +};
104668
104669 struct dentry *kvm_debugfs_dir;
104670
104671 @@ -766,7 +771,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
104672 /* We can read the guest memory with __xxx_user() later on. */
104673 if ((mem->slot < KVM_USER_MEM_SLOTS) &&
104674 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
104675 - !access_ok(VERIFY_WRITE,
104676 + !__access_ok(VERIFY_WRITE,
104677 (void __user *)(unsigned long)mem->userspace_addr,
104678 mem->memory_size)))
104679 goto out;
104680 @@ -1878,7 +1883,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
104681 return 0;
104682 }
104683
104684 -static struct file_operations kvm_vcpu_fops = {
104685 +static file_operations_no_const kvm_vcpu_fops __read_only = {
104686 .release = kvm_vcpu_release,
104687 .unlocked_ioctl = kvm_vcpu_ioctl,
104688 #ifdef CONFIG_COMPAT
104689 @@ -2561,7 +2566,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
104690 return 0;
104691 }
104692
104693 -static struct file_operations kvm_vm_fops = {
104694 +static file_operations_no_const kvm_vm_fops __read_only = {
104695 .release = kvm_vm_release,
104696 .unlocked_ioctl = kvm_vm_ioctl,
104697 #ifdef CONFIG_COMPAT
104698 @@ -2662,7 +2667,7 @@ out:
104699 return r;
104700 }
104701
104702 -static struct file_operations kvm_chardev_ops = {
104703 +static file_operations_no_const kvm_chardev_ops __read_only = {
104704 .unlocked_ioctl = kvm_dev_ioctl,
104705 .compat_ioctl = kvm_dev_ioctl,
104706 .llseek = noop_llseek,
104707 @@ -2688,7 +2693,7 @@ static void hardware_enable_nolock(void *junk)
104708
104709 if (r) {
104710 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
104711 - atomic_inc(&hardware_enable_failed);
104712 + atomic_inc_unchecked(&hardware_enable_failed);
104713 printk(KERN_INFO "kvm: enabling virtualization on "
104714 "CPU%d failed\n", cpu);
104715 }
104716 @@ -2742,10 +2747,10 @@ static int hardware_enable_all(void)
104717
104718 kvm_usage_count++;
104719 if (kvm_usage_count == 1) {
104720 - atomic_set(&hardware_enable_failed, 0);
104721 + atomic_set_unchecked(&hardware_enable_failed, 0);
104722 on_each_cpu(hardware_enable_nolock, NULL, 1);
104723
104724 - if (atomic_read(&hardware_enable_failed)) {
104725 + if (atomic_read_unchecked(&hardware_enable_failed)) {
104726 hardware_disable_all_nolock();
104727 r = -EBUSY;
104728 }
104729 @@ -3099,7 +3104,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
104730 kvm_arch_vcpu_put(vcpu);
104731 }
104732
104733 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104734 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104735 struct module *module)
104736 {
104737 int r;
104738 @@ -3146,7 +3151,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104739 if (!vcpu_align)
104740 vcpu_align = __alignof__(struct kvm_vcpu);
104741 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
104742 - 0, NULL);
104743 + SLAB_USERCOPY, NULL);
104744 if (!kvm_vcpu_cache) {
104745 r = -ENOMEM;
104746 goto out_free_3;
104747 @@ -3156,9 +3161,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104748 if (r)
104749 goto out_free;
104750
104751 + pax_open_kernel();
104752 kvm_chardev_ops.owner = module;
104753 kvm_vm_fops.owner = module;
104754 kvm_vcpu_fops.owner = module;
104755 + pax_close_kernel();
104756
104757 r = misc_register(&kvm_dev);
104758 if (r) {
104759 @@ -3168,9 +3175,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
104760
104761 register_syscore_ops(&kvm_syscore_ops);
104762
104763 - kvm_preempt_ops.sched_in = kvm_sched_in;
104764 - kvm_preempt_ops.sched_out = kvm_sched_out;
104765 -
104766 r = kvm_init_debug();
104767 if (r) {
104768 printk(KERN_ERR "kvm: create debugfs files failed\n");