]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-2.9.1-3.10.8-201308201820.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-2.9.1-3.10.8-201308201820.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..889ee23 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 @@ -1928,6 +1932,10 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
247 noexec=on: enable non-executable mappings (default)
248 noexec=off: disable non-executable mappings
249
250 + nopcid [X86-64]
251 + Disable PCID (Process-Context IDentifier) even if it
252 + is supported by the processor.
253 +
254 nosmap [X86]
255 Disable SMAP (Supervisor Mode Access Prevention)
256 even if it is supported by processor.
257 @@ -2195,6 +2203,25 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
258 the specified number of seconds. This is to be used if
259 your oopses keep scrolling off the screen.
260
261 + pax_nouderef [X86] disables UDEREF. Most likely needed under certain
262 + virtualization environments that don't cope well with the
263 + expand down segment used by UDEREF on X86-32 or the frequent
264 + page table updates on X86-64.
265 +
266 + pax_sanitize_slab=
267 + 0/1 to disable/enable slab object sanitization (enabled by
268 + default).
269 +
270 + pax_softmode= 0/1 to disable/enable PaX softmode on boot already.
271 +
272 + pax_extra_latent_entropy
273 + Enable a very simple form of latent entropy extraction
274 + from the first 4GB of memory as the bootmem allocator
275 + passes the memory pages to the buddy allocator.
276 +
277 + pax_weakuderef [X86-64] enables the weaker but faster form of UDEREF
278 + when the processor supports PCID.
279 +
280 pcbit= [HW,ISDN]
281
282 pcd. [PARIDE]
283 diff --git a/Makefile b/Makefile
284 index 1a21612..678323e 100644
285 --- a/Makefile
286 +++ b/Makefile
287 @@ -241,8 +241,9 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
288
289 HOSTCC = gcc
290 HOSTCXX = g++
291 -HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
292 -HOSTCXXFLAGS = -O2
293 +HOSTCFLAGS = -Wall -W -Wmissing-prototypes -Wstrict-prototypes -Wno-unused-parameter -Wno-missing-field-initializers -O2 -fomit-frame-pointer -fno-delete-null-pointer-checks
294 +HOSTCFLAGS += $(call cc-option, -Wno-empty-body)
295 +HOSTCXXFLAGS = -O2 -Wall -W -fno-delete-null-pointer-checks
296
297 # Decide whether to build built-in, modular, or both.
298 # Normally, just do built-in.
299 @@ -414,8 +415,8 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
300 # Rules shared between *config targets and build targets
301
302 # Basic helpers built in scripts/
303 -PHONY += scripts_basic
304 -scripts_basic:
305 +PHONY += scripts_basic gcc-plugins
306 +scripts_basic: gcc-plugins
307 $(Q)$(MAKE) $(build)=scripts/basic
308 $(Q)rm -f .tmp_quiet_recordmcount
309
310 @@ -576,6 +577,65 @@ else
311 KBUILD_CFLAGS += -O2
312 endif
313
314 +ifndef DISABLE_PAX_PLUGINS
315 +ifeq ($(call cc-ifversion, -ge, 0408, y), y)
316 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCXX)" "$(HOSTCXX)" "$(CC)")
317 +else
318 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCC)" "$(HOSTCXX)" "$(CC)")
319 +endif
320 +ifneq ($(PLUGINCC),)
321 +ifdef CONFIG_PAX_CONSTIFY_PLUGIN
322 +CONSTIFY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/constify_plugin.so -DCONSTIFY_PLUGIN
323 +endif
324 +ifdef CONFIG_PAX_MEMORY_STACKLEAK
325 +STACKLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/stackleak_plugin.so -DSTACKLEAK_PLUGIN
326 +STACKLEAK_PLUGIN_CFLAGS += -fplugin-arg-stackleak_plugin-track-lowest-sp=100
327 +endif
328 +ifdef CONFIG_KALLOCSTAT_PLUGIN
329 +KALLOCSTAT_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kallocstat_plugin.so
330 +endif
331 +ifdef CONFIG_PAX_KERNEXEC_PLUGIN
332 +KERNEXEC_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kernexec_plugin.so
333 +KERNEXEC_PLUGIN_CFLAGS += -fplugin-arg-kernexec_plugin-method=$(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD) -DKERNEXEC_PLUGIN
334 +KERNEXEC_PLUGIN_AFLAGS := -DKERNEXEC_PLUGIN
335 +endif
336 +ifdef CONFIG_CHECKER_PLUGIN
337 +ifeq ($(call cc-ifversion, -ge, 0406, y), y)
338 +CHECKER_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/checker_plugin.so -DCHECKER_PLUGIN
339 +endif
340 +endif
341 +COLORIZE_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/colorize_plugin.so
342 +ifdef CONFIG_PAX_SIZE_OVERFLOW
343 +SIZE_OVERFLOW_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/size_overflow_plugin.so -DSIZE_OVERFLOW_PLUGIN
344 +endif
345 +ifdef CONFIG_PAX_LATENT_ENTROPY
346 +LATENT_ENTROPY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/latent_entropy_plugin.so -DLATENT_ENTROPY_PLUGIN
347 +endif
348 +ifdef CONFIG_PAX_MEMORY_STRUCTLEAK
349 +STRUCTLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/structleak_plugin.so -DSTRUCTLEAK_PLUGIN
350 +endif
351 +GCC_PLUGINS_CFLAGS := $(CONSTIFY_PLUGIN_CFLAGS) $(STACKLEAK_PLUGIN_CFLAGS) $(KALLOCSTAT_PLUGIN_CFLAGS)
352 +GCC_PLUGINS_CFLAGS += $(KERNEXEC_PLUGIN_CFLAGS) $(CHECKER_PLUGIN_CFLAGS) $(COLORIZE_PLUGIN_CFLAGS)
353 +GCC_PLUGINS_CFLAGS += $(SIZE_OVERFLOW_PLUGIN_CFLAGS) $(LATENT_ENTROPY_PLUGIN_CFLAGS) $(STRUCTLEAK_PLUGIN_CFLAGS)
354 +GCC_PLUGINS_AFLAGS := $(KERNEXEC_PLUGIN_AFLAGS)
355 +export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGINS_AFLAGS CONSTIFY_PLUGIN
356 +ifeq ($(KBUILD_EXTMOD),)
357 +gcc-plugins:
358 + $(Q)$(MAKE) $(build)=tools/gcc
359 +else
360 +gcc-plugins: ;
361 +endif
362 +else
363 +gcc-plugins:
364 +ifeq ($(call cc-ifversion, -ge, 0405, y), y)
365 + $(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.))
366 +else
367 + $(Q)echo "warning, your gcc version does not support plugins, you should upgrade it to gcc 4.5 at least"
368 +endif
369 + $(Q)echo "PAX_MEMORY_STACKLEAK, constification, PAX_LATENT_ENTROPY and other features will be less secure. PAX_SIZE_OVERFLOW will not be active."
370 +endif
371 +endif
372 +
373 include $(srctree)/arch/$(SRCARCH)/Makefile
374
375 ifdef CONFIG_READABLE_ASM
376 @@ -733,7 +793,7 @@ export mod_sign_cmd
377
378
379 ifeq ($(KBUILD_EXTMOD),)
380 -core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
381 +core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ grsecurity/
382
383 vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
384 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
385 @@ -782,6 +842,8 @@ endif
386
387 # The actual objects are generated when descending,
388 # make sure no implicit rule kicks in
389 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
390 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
391 $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
392
393 # Handle descending into subdirectories listed in $(vmlinux-dirs)
394 @@ -791,7 +853,7 @@ $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
395 # Error messages still appears in the original language
396
397 PHONY += $(vmlinux-dirs)
398 -$(vmlinux-dirs): prepare scripts
399 +$(vmlinux-dirs): gcc-plugins prepare scripts
400 $(Q)$(MAKE) $(build)=$@
401
402 # Store (new) KERNELRELASE string in include/config/kernel.release
403 @@ -835,6 +897,7 @@ prepare0: archprepare FORCE
404 $(Q)$(MAKE) $(build)=.
405
406 # All the preparing..
407 +prepare: KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
408 prepare: prepare0
409
410 # Generate some files
411 @@ -942,6 +1005,8 @@ all: modules
412 # using awk while concatenating to the final file.
413
414 PHONY += modules
415 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
416 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
417 modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
418 $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
419 @$(kecho) ' Building modules, stage 2.';
420 @@ -957,7 +1022,7 @@ modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
421
422 # Target to prepare building external modules
423 PHONY += modules_prepare
424 -modules_prepare: prepare scripts
425 +modules_prepare: gcc-plugins prepare scripts
426
427 # Target to install modules
428 PHONY += modules_install
429 @@ -1023,7 +1088,7 @@ MRPROPER_FILES += .config .config.old .version .old_version $(version_h) \
430 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
431 signing_key.priv signing_key.x509 x509.genkey \
432 extra_certificates signing_key.x509.keyid \
433 - signing_key.x509.signer
434 + signing_key.x509.signer tools/gcc/size_overflow_hash.h
435
436 # clean - Delete most, but leave enough to build external modules
437 #
438 @@ -1063,6 +1128,7 @@ distclean: mrproper
439 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
440 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
441 -o -name '.*.rej' \
442 + -o -name '.*.rej' -o -name '*.so' \
443 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
444 -type f -print | xargs rm -f
445
446 @@ -1223,6 +1289,8 @@ PHONY += $(module-dirs) modules
447 $(module-dirs): crmodverdir $(objtree)/Module.symvers
448 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
449
450 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
451 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
452 modules: $(module-dirs)
453 @$(kecho) ' Building modules, stage 2.';
454 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
455 @@ -1359,17 +1427,21 @@ else
456 target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
457 endif
458
459 -%.s: %.c prepare scripts FORCE
460 +%.s: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
461 +%.s: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
462 +%.s: %.c gcc-plugins prepare scripts FORCE
463 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
464 %.i: %.c prepare scripts FORCE
465 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
466 -%.o: %.c prepare scripts FORCE
467 +%.o: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
468 +%.o: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
469 +%.o: %.c gcc-plugins prepare scripts FORCE
470 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
471 %.lst: %.c prepare scripts FORCE
472 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
473 -%.s: %.S prepare scripts FORCE
474 +%.s: %.S gcc-plugins prepare scripts FORCE
475 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
476 -%.o: %.S prepare scripts FORCE
477 +%.o: %.S gcc-plugins prepare scripts FORCE
478 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
479 %.symtypes: %.c prepare scripts FORCE
480 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
481 @@ -1379,11 +1451,15 @@ endif
482 $(cmd_crmodverdir)
483 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
484 $(build)=$(build-dir)
485 -%/: prepare scripts FORCE
486 +%/: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
487 +%/: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
488 +%/: gcc-plugins prepare scripts FORCE
489 $(cmd_crmodverdir)
490 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
491 $(build)=$(build-dir)
492 -%.ko: prepare scripts FORCE
493 +%.ko: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
494 +%.ko: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
495 +%.ko: gcc-plugins prepare scripts FORCE
496 $(cmd_crmodverdir)
497 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
498 $(build)=$(build-dir) $(@:.ko=.o)
499 diff --git a/arch/alpha/include/asm/atomic.h b/arch/alpha/include/asm/atomic.h
500 index c2cbe4f..f7264b4 100644
501 --- a/arch/alpha/include/asm/atomic.h
502 +++ b/arch/alpha/include/asm/atomic.h
503 @@ -250,6 +250,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
504 #define atomic_dec(v) atomic_sub(1,(v))
505 #define atomic64_dec(v) atomic64_sub(1,(v))
506
507 +#define atomic64_read_unchecked(v) atomic64_read(v)
508 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
509 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
510 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
511 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
512 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
513 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
514 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
515 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
516 +
517 #define smp_mb__before_atomic_dec() smp_mb()
518 #define smp_mb__after_atomic_dec() smp_mb()
519 #define smp_mb__before_atomic_inc() smp_mb()
520 diff --git a/arch/alpha/include/asm/cache.h b/arch/alpha/include/asm/cache.h
521 index ad368a9..fbe0f25 100644
522 --- a/arch/alpha/include/asm/cache.h
523 +++ b/arch/alpha/include/asm/cache.h
524 @@ -4,19 +4,19 @@
525 #ifndef __ARCH_ALPHA_CACHE_H
526 #define __ARCH_ALPHA_CACHE_H
527
528 +#include <linux/const.h>
529
530 /* Bytes per L1 (data) cache line. */
531 #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_EV6)
532 -# define L1_CACHE_BYTES 64
533 # define L1_CACHE_SHIFT 6
534 #else
535 /* Both EV4 and EV5 are write-through, read-allocate,
536 direct-mapped, physical.
537 */
538 -# define L1_CACHE_BYTES 32
539 # define L1_CACHE_SHIFT 5
540 #endif
541
542 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
543 #define SMP_CACHE_BYTES L1_CACHE_BYTES
544
545 #endif
546 diff --git a/arch/alpha/include/asm/elf.h b/arch/alpha/include/asm/elf.h
547 index 968d999..d36b2df 100644
548 --- a/arch/alpha/include/asm/elf.h
549 +++ b/arch/alpha/include/asm/elf.h
550 @@ -91,6 +91,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
551
552 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x1000000)
553
554 +#ifdef CONFIG_PAX_ASLR
555 +#define PAX_ELF_ET_DYN_BASE (current->personality & ADDR_LIMIT_32BIT ? 0x10000 : 0x120000000UL)
556 +
557 +#define PAX_DELTA_MMAP_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 28)
558 +#define PAX_DELTA_STACK_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 19)
559 +#endif
560 +
561 /* $0 is set by ld.so to a pointer to a function which might be
562 registered using atexit. This provides a mean for the dynamic
563 linker to call DT_FINI functions for shared libraries that have
564 diff --git a/arch/alpha/include/asm/pgalloc.h b/arch/alpha/include/asm/pgalloc.h
565 index bc2a0da..8ad11ee 100644
566 --- a/arch/alpha/include/asm/pgalloc.h
567 +++ b/arch/alpha/include/asm/pgalloc.h
568 @@ -29,6 +29,12 @@ pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
569 pgd_set(pgd, pmd);
570 }
571
572 +static inline void
573 +pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
574 +{
575 + pgd_populate(mm, pgd, pmd);
576 +}
577 +
578 extern pgd_t *pgd_alloc(struct mm_struct *mm);
579
580 static inline void
581 diff --git a/arch/alpha/include/asm/pgtable.h b/arch/alpha/include/asm/pgtable.h
582 index 81a4342..348b927 100644
583 --- a/arch/alpha/include/asm/pgtable.h
584 +++ b/arch/alpha/include/asm/pgtable.h
585 @@ -102,6 +102,17 @@ struct vm_area_struct;
586 #define PAGE_SHARED __pgprot(_PAGE_VALID | __ACCESS_BITS)
587 #define PAGE_COPY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
588 #define PAGE_READONLY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
589 +
590 +#ifdef CONFIG_PAX_PAGEEXEC
591 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOE)
592 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
593 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
594 +#else
595 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
596 +# define PAGE_COPY_NOEXEC PAGE_COPY
597 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
598 +#endif
599 +
600 #define PAGE_KERNEL __pgprot(_PAGE_VALID | _PAGE_ASM | _PAGE_KRE | _PAGE_KWE)
601
602 #define _PAGE_NORMAL(x) __pgprot(_PAGE_VALID | __ACCESS_BITS | (x))
603 diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c
604 index 2fd00b7..cfd5069 100644
605 --- a/arch/alpha/kernel/module.c
606 +++ b/arch/alpha/kernel/module.c
607 @@ -160,7 +160,7 @@ apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab,
608
609 /* The small sections were sorted to the end of the segment.
610 The following should definitely cover them. */
611 - gp = (u64)me->module_core + me->core_size - 0x8000;
612 + gp = (u64)me->module_core_rw + me->core_size_rw - 0x8000;
613 got = sechdrs[me->arch.gotsecindex].sh_addr;
614
615 for (i = 0; i < n; i++) {
616 diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
617 index b9e37ad..44c24e7 100644
618 --- a/arch/alpha/kernel/osf_sys.c
619 +++ b/arch/alpha/kernel/osf_sys.c
620 @@ -1297,10 +1297,11 @@ SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
621 generic version except that we know how to honor ADDR_LIMIT_32BIT. */
622
623 static unsigned long
624 -arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
625 - unsigned long limit)
626 +arch_get_unmapped_area_1(struct file *filp, unsigned long addr, unsigned long len,
627 + unsigned long limit, unsigned long flags)
628 {
629 struct vm_unmapped_area_info info;
630 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
631
632 info.flags = 0;
633 info.length = len;
634 @@ -1308,6 +1309,7 @@ arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
635 info.high_limit = limit;
636 info.align_mask = 0;
637 info.align_offset = 0;
638 + info.threadstack_offset = offset;
639 return vm_unmapped_area(&info);
640 }
641
642 @@ -1340,20 +1342,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
643 merely specific addresses, but regions of memory -- perhaps
644 this feature should be incorporated into all ports? */
645
646 +#ifdef CONFIG_PAX_RANDMMAP
647 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
648 +#endif
649 +
650 if (addr) {
651 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit);
652 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(addr), len, limit, flags);
653 if (addr != (unsigned long) -ENOMEM)
654 return addr;
655 }
656
657 /* Next, try allocating at TASK_UNMAPPED_BASE. */
658 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),
659 - len, limit);
660 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(current->mm->mmap_base), len, limit, flags);
661 +
662 if (addr != (unsigned long) -ENOMEM)
663 return addr;
664
665 /* Finally, try allocating in low memory. */
666 - addr = arch_get_unmapped_area_1 (PAGE_SIZE, len, limit);
667 + addr = arch_get_unmapped_area_1 (filp, PAGE_SIZE, len, limit, flags);
668
669 return addr;
670 }
671 diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
672 index 0c4132d..88f0d53 100644
673 --- a/arch/alpha/mm/fault.c
674 +++ b/arch/alpha/mm/fault.c
675 @@ -53,6 +53,124 @@ __load_new_mm_context(struct mm_struct *next_mm)
676 __reload_thread(pcb);
677 }
678
679 +#ifdef CONFIG_PAX_PAGEEXEC
680 +/*
681 + * PaX: decide what to do with offenders (regs->pc = fault address)
682 + *
683 + * returns 1 when task should be killed
684 + * 2 when patched PLT trampoline was detected
685 + * 3 when unpatched PLT trampoline was detected
686 + */
687 +static int pax_handle_fetch_fault(struct pt_regs *regs)
688 +{
689 +
690 +#ifdef CONFIG_PAX_EMUPLT
691 + int err;
692 +
693 + do { /* PaX: patched PLT emulation #1 */
694 + unsigned int ldah, ldq, jmp;
695 +
696 + err = get_user(ldah, (unsigned int *)regs->pc);
697 + err |= get_user(ldq, (unsigned int *)(regs->pc+4));
698 + err |= get_user(jmp, (unsigned int *)(regs->pc+8));
699 +
700 + if (err)
701 + break;
702 +
703 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
704 + (ldq & 0xFFFF0000U) == 0xA77B0000U &&
705 + jmp == 0x6BFB0000U)
706 + {
707 + unsigned long r27, addr;
708 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
709 + unsigned long addrl = ldq | 0xFFFFFFFFFFFF0000UL;
710 +
711 + addr = regs->r27 + ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
712 + err = get_user(r27, (unsigned long *)addr);
713 + if (err)
714 + break;
715 +
716 + regs->r27 = r27;
717 + regs->pc = r27;
718 + return 2;
719 + }
720 + } while (0);
721 +
722 + do { /* PaX: patched PLT emulation #2 */
723 + unsigned int ldah, lda, br;
724 +
725 + err = get_user(ldah, (unsigned int *)regs->pc);
726 + err |= get_user(lda, (unsigned int *)(regs->pc+4));
727 + err |= get_user(br, (unsigned int *)(regs->pc+8));
728 +
729 + if (err)
730 + break;
731 +
732 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
733 + (lda & 0xFFFF0000U) == 0xA77B0000U &&
734 + (br & 0xFFE00000U) == 0xC3E00000U)
735 + {
736 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL;
737 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
738 + unsigned long addrl = lda | 0xFFFFFFFFFFFF0000UL;
739 +
740 + regs->r27 += ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
741 + regs->pc += 12 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
742 + return 2;
743 + }
744 + } while (0);
745 +
746 + do { /* PaX: unpatched PLT emulation */
747 + unsigned int br;
748 +
749 + err = get_user(br, (unsigned int *)regs->pc);
750 +
751 + if (!err && (br & 0xFFE00000U) == 0xC3800000U) {
752 + unsigned int br2, ldq, nop, jmp;
753 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL, resolver;
754 +
755 + addr = regs->pc + 4 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
756 + err = get_user(br2, (unsigned int *)addr);
757 + err |= get_user(ldq, (unsigned int *)(addr+4));
758 + err |= get_user(nop, (unsigned int *)(addr+8));
759 + err |= get_user(jmp, (unsigned int *)(addr+12));
760 + err |= get_user(resolver, (unsigned long *)(addr+16));
761 +
762 + if (err)
763 + break;
764 +
765 + if (br2 == 0xC3600000U &&
766 + ldq == 0xA77B000CU &&
767 + nop == 0x47FF041FU &&
768 + jmp == 0x6B7B0000U)
769 + {
770 + regs->r28 = regs->pc+4;
771 + regs->r27 = addr+16;
772 + regs->pc = resolver;
773 + return 3;
774 + }
775 + }
776 + } while (0);
777 +#endif
778 +
779 + return 1;
780 +}
781 +
782 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
783 +{
784 + unsigned long i;
785 +
786 + printk(KERN_ERR "PAX: bytes at PC: ");
787 + for (i = 0; i < 5; i++) {
788 + unsigned int c;
789 + if (get_user(c, (unsigned int *)pc+i))
790 + printk(KERN_CONT "???????? ");
791 + else
792 + printk(KERN_CONT "%08x ", c);
793 + }
794 + printk("\n");
795 +}
796 +#endif
797
798 /*
799 * This routine handles page faults. It determines the address,
800 @@ -133,8 +251,29 @@ retry:
801 good_area:
802 si_code = SEGV_ACCERR;
803 if (cause < 0) {
804 - if (!(vma->vm_flags & VM_EXEC))
805 + if (!(vma->vm_flags & VM_EXEC)) {
806 +
807 +#ifdef CONFIG_PAX_PAGEEXEC
808 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->pc)
809 + goto bad_area;
810 +
811 + up_read(&mm->mmap_sem);
812 + switch (pax_handle_fetch_fault(regs)) {
813 +
814 +#ifdef CONFIG_PAX_EMUPLT
815 + case 2:
816 + case 3:
817 + return;
818 +#endif
819 +
820 + }
821 + pax_report_fault(regs, (void *)regs->pc, (void *)rdusp());
822 + do_group_exit(SIGKILL);
823 +#else
824 goto bad_area;
825 +#endif
826 +
827 + }
828 } else if (!cause) {
829 /* Allow reads even for write-only mappings */
830 if (!(vma->vm_flags & (VM_READ | VM_WRITE)))
831 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
832 index 18a9f5e..ca910b7 100644
833 --- a/arch/arm/Kconfig
834 +++ b/arch/arm/Kconfig
835 @@ -1766,7 +1766,7 @@ config ALIGNMENT_TRAP
836
837 config UACCESS_WITH_MEMCPY
838 bool "Use kernel mem{cpy,set}() for {copy_to,clear}_user()"
839 - depends on MMU
840 + depends on MMU && !PAX_MEMORY_UDEREF
841 default y if CPU_FEROCEON
842 help
843 Implement faster copy_to_user and clear_user methods for CPU
844 diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
845 index da1c77d..2ee6056 100644
846 --- a/arch/arm/include/asm/atomic.h
847 +++ b/arch/arm/include/asm/atomic.h
848 @@ -17,17 +17,35 @@
849 #include <asm/barrier.h>
850 #include <asm/cmpxchg.h>
851
852 +#ifdef CONFIG_GENERIC_ATOMIC64
853 +#include <asm-generic/atomic64.h>
854 +#endif
855 +
856 #define ATOMIC_INIT(i) { (i) }
857
858 #ifdef __KERNEL__
859
860 +#define _ASM_EXTABLE(from, to) \
861 +" .pushsection __ex_table,\"a\"\n"\
862 +" .align 3\n" \
863 +" .long " #from ", " #to"\n" \
864 +" .popsection"
865 +
866 /*
867 * On ARM, ordinary assignment (str instruction) doesn't clear the local
868 * strex/ldrex monitor on some implementations. The reason we can use it for
869 * atomic_set() is the clrex or dummy strex done on every exception return.
870 */
871 #define atomic_read(v) (*(volatile int *)&(v)->counter)
872 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
873 +{
874 + return v->counter;
875 +}
876 #define atomic_set(v,i) (((v)->counter) = (i))
877 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
878 +{
879 + v->counter = i;
880 +}
881
882 #if __LINUX_ARM_ARCH__ >= 6
883
884 @@ -42,6 +60,35 @@ static inline void atomic_add(int i, atomic_t *v)
885 int result;
886
887 __asm__ __volatile__("@ atomic_add\n"
888 +"1: ldrex %1, [%3]\n"
889 +" adds %0, %1, %4\n"
890 +
891 +#ifdef CONFIG_PAX_REFCOUNT
892 +" bvc 3f\n"
893 +"2: bkpt 0xf103\n"
894 +"3:\n"
895 +#endif
896 +
897 +" strex %1, %0, [%3]\n"
898 +" teq %1, #0\n"
899 +" bne 1b"
900 +
901 +#ifdef CONFIG_PAX_REFCOUNT
902 +"\n4:\n"
903 + _ASM_EXTABLE(2b, 4b)
904 +#endif
905 +
906 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
907 + : "r" (&v->counter), "Ir" (i)
908 + : "cc");
909 +}
910 +
911 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
912 +{
913 + unsigned long tmp;
914 + int result;
915 +
916 + __asm__ __volatile__("@ atomic_add_unchecked\n"
917 "1: ldrex %0, [%3]\n"
918 " add %0, %0, %4\n"
919 " strex %1, %0, [%3]\n"
920 @@ -60,6 +107,42 @@ static inline int atomic_add_return(int i, atomic_t *v)
921 smp_mb();
922
923 __asm__ __volatile__("@ atomic_add_return\n"
924 +"1: ldrex %1, [%3]\n"
925 +" adds %0, %1, %4\n"
926 +
927 +#ifdef CONFIG_PAX_REFCOUNT
928 +" bvc 3f\n"
929 +" mov %0, %1\n"
930 +"2: bkpt 0xf103\n"
931 +"3:\n"
932 +#endif
933 +
934 +" strex %1, %0, [%3]\n"
935 +" teq %1, #0\n"
936 +" bne 1b"
937 +
938 +#ifdef CONFIG_PAX_REFCOUNT
939 +"\n4:\n"
940 + _ASM_EXTABLE(2b, 4b)
941 +#endif
942 +
943 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
944 + : "r" (&v->counter), "Ir" (i)
945 + : "cc");
946 +
947 + smp_mb();
948 +
949 + return result;
950 +}
951 +
952 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
953 +{
954 + unsigned long tmp;
955 + int result;
956 +
957 + smp_mb();
958 +
959 + __asm__ __volatile__("@ atomic_add_return_unchecked\n"
960 "1: ldrex %0, [%3]\n"
961 " add %0, %0, %4\n"
962 " strex %1, %0, [%3]\n"
963 @@ -80,6 +163,35 @@ static inline void atomic_sub(int i, atomic_t *v)
964 int result;
965
966 __asm__ __volatile__("@ atomic_sub\n"
967 +"1: ldrex %1, [%3]\n"
968 +" subs %0, %1, %4\n"
969 +
970 +#ifdef CONFIG_PAX_REFCOUNT
971 +" bvc 3f\n"
972 +"2: bkpt 0xf103\n"
973 +"3:\n"
974 +#endif
975 +
976 +" strex %1, %0, [%3]\n"
977 +" teq %1, #0\n"
978 +" bne 1b"
979 +
980 +#ifdef CONFIG_PAX_REFCOUNT
981 +"\n4:\n"
982 + _ASM_EXTABLE(2b, 4b)
983 +#endif
984 +
985 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
986 + : "r" (&v->counter), "Ir" (i)
987 + : "cc");
988 +}
989 +
990 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
991 +{
992 + unsigned long tmp;
993 + int result;
994 +
995 + __asm__ __volatile__("@ atomic_sub_unchecked\n"
996 "1: ldrex %0, [%3]\n"
997 " sub %0, %0, %4\n"
998 " strex %1, %0, [%3]\n"
999 @@ -98,11 +210,25 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1000 smp_mb();
1001
1002 __asm__ __volatile__("@ atomic_sub_return\n"
1003 -"1: ldrex %0, [%3]\n"
1004 -" sub %0, %0, %4\n"
1005 +"1: ldrex %1, [%3]\n"
1006 +" subs %0, %1, %4\n"
1007 +
1008 +#ifdef CONFIG_PAX_REFCOUNT
1009 +" bvc 3f\n"
1010 +" mov %0, %1\n"
1011 +"2: bkpt 0xf103\n"
1012 +"3:\n"
1013 +#endif
1014 +
1015 " strex %1, %0, [%3]\n"
1016 " teq %1, #0\n"
1017 " bne 1b"
1018 +
1019 +#ifdef CONFIG_PAX_REFCOUNT
1020 +"\n4:\n"
1021 + _ASM_EXTABLE(2b, 4b)
1022 +#endif
1023 +
1024 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1025 : "r" (&v->counter), "Ir" (i)
1026 : "cc");
1027 @@ -134,6 +260,28 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)
1028 return oldval;
1029 }
1030
1031 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *ptr, int old, int new)
1032 +{
1033 + unsigned long oldval, res;
1034 +
1035 + smp_mb();
1036 +
1037 + do {
1038 + __asm__ __volatile__("@ atomic_cmpxchg_unchecked\n"
1039 + "ldrex %1, [%3]\n"
1040 + "mov %0, #0\n"
1041 + "teq %1, %4\n"
1042 + "strexeq %0, %5, [%3]\n"
1043 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1044 + : "r" (&ptr->counter), "Ir" (old), "r" (new)
1045 + : "cc");
1046 + } while (res);
1047 +
1048 + smp_mb();
1049 +
1050 + return oldval;
1051 +}
1052 +
1053 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1054 {
1055 unsigned long tmp, tmp2;
1056 @@ -167,7 +315,17 @@ static inline int atomic_add_return(int i, atomic_t *v)
1057
1058 return val;
1059 }
1060 +
1061 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
1062 +{
1063 + return atomic_add_return(i, v);
1064 +}
1065 +
1066 #define atomic_add(i, v) (void) atomic_add_return(i, v)
1067 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
1068 +{
1069 + (void) atomic_add_return(i, v);
1070 +}
1071
1072 static inline int atomic_sub_return(int i, atomic_t *v)
1073 {
1074 @@ -182,6 +340,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1075 return val;
1076 }
1077 #define atomic_sub(i, v) (void) atomic_sub_return(i, v)
1078 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
1079 +{
1080 + (void) atomic_sub_return(i, v);
1081 +}
1082
1083 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1084 {
1085 @@ -197,6 +359,11 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1086 return ret;
1087 }
1088
1089 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
1090 +{
1091 + return atomic_cmpxchg(v, old, new);
1092 +}
1093 +
1094 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1095 {
1096 unsigned long flags;
1097 @@ -209,6 +376,10 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1098 #endif /* __LINUX_ARM_ARCH__ */
1099
1100 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
1101 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
1102 +{
1103 + return xchg(&v->counter, new);
1104 +}
1105
1106 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1107 {
1108 @@ -221,11 +392,27 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1109 }
1110
1111 #define atomic_inc(v) atomic_add(1, v)
1112 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
1113 +{
1114 + atomic_add_unchecked(1, v);
1115 +}
1116 #define atomic_dec(v) atomic_sub(1, v)
1117 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
1118 +{
1119 + atomic_sub_unchecked(1, v);
1120 +}
1121
1122 #define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0)
1123 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
1124 +{
1125 + return atomic_add_return_unchecked(1, v) == 0;
1126 +}
1127 #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0)
1128 #define atomic_inc_return(v) (atomic_add_return(1, v))
1129 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
1130 +{
1131 + return atomic_add_return_unchecked(1, v);
1132 +}
1133 #define atomic_dec_return(v) (atomic_sub_return(1, v))
1134 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
1135
1136 @@ -241,6 +428,14 @@ typedef struct {
1137 u64 __aligned(8) counter;
1138 } atomic64_t;
1139
1140 +#ifdef CONFIG_PAX_REFCOUNT
1141 +typedef struct {
1142 + u64 __aligned(8) counter;
1143 +} atomic64_unchecked_t;
1144 +#else
1145 +typedef atomic64_t atomic64_unchecked_t;
1146 +#endif
1147 +
1148 #define ATOMIC64_INIT(i) { (i) }
1149
1150 #ifdef CONFIG_ARM_LPAE
1151 @@ -257,6 +452,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1152 return result;
1153 }
1154
1155 +static inline u64 atomic64_read_unchecked(const atomic64_unchecked_t *v)
1156 +{
1157 + u64 result;
1158 +
1159 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1160 +" ldrd %0, %H0, [%1]"
1161 + : "=&r" (result)
1162 + : "r" (&v->counter), "Qo" (v->counter)
1163 + );
1164 +
1165 + return result;
1166 +}
1167 +
1168 static inline void atomic64_set(atomic64_t *v, u64 i)
1169 {
1170 __asm__ __volatile__("@ atomic64_set\n"
1171 @@ -265,6 +473,15 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1172 : "r" (&v->counter), "r" (i)
1173 );
1174 }
1175 +
1176 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1177 +{
1178 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1179 +" strd %2, %H2, [%1]"
1180 + : "=Qo" (v->counter)
1181 + : "r" (&v->counter), "r" (i)
1182 + );
1183 +}
1184 #else
1185 static inline u64 atomic64_read(const atomic64_t *v)
1186 {
1187 @@ -279,6 +496,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1188 return result;
1189 }
1190
1191 +static inline u64 atomic64_read_unchecked(atomic64_unchecked_t *v)
1192 +{
1193 + u64 result;
1194 +
1195 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1196 +" ldrexd %0, %H0, [%1]"
1197 + : "=&r" (result)
1198 + : "r" (&v->counter), "Qo" (v->counter)
1199 + );
1200 +
1201 + return result;
1202 +}
1203 +
1204 static inline void atomic64_set(atomic64_t *v, u64 i)
1205 {
1206 u64 tmp;
1207 @@ -292,6 +522,21 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1208 : "r" (&v->counter), "r" (i)
1209 : "cc");
1210 }
1211 +
1212 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1213 +{
1214 + u64 tmp;
1215 +
1216 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1217 +"1: ldrexd %0, %H0, [%2]\n"
1218 +" strexd %0, %3, %H3, [%2]\n"
1219 +" teq %0, #0\n"
1220 +" bne 1b"
1221 + : "=&r" (tmp), "=Qo" (v->counter)
1222 + : "r" (&v->counter), "r" (i)
1223 + : "cc");
1224 +}
1225 +
1226 #endif
1227
1228 static inline void atomic64_add(u64 i, atomic64_t *v)
1229 @@ -302,6 +547,36 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1230 __asm__ __volatile__("@ atomic64_add\n"
1231 "1: ldrexd %0, %H0, [%3]\n"
1232 " adds %0, %0, %4\n"
1233 +" adcs %H0, %H0, %H4\n"
1234 +
1235 +#ifdef CONFIG_PAX_REFCOUNT
1236 +" bvc 3f\n"
1237 +"2: bkpt 0xf103\n"
1238 +"3:\n"
1239 +#endif
1240 +
1241 +" strexd %1, %0, %H0, [%3]\n"
1242 +" teq %1, #0\n"
1243 +" bne 1b"
1244 +
1245 +#ifdef CONFIG_PAX_REFCOUNT
1246 +"\n4:\n"
1247 + _ASM_EXTABLE(2b, 4b)
1248 +#endif
1249 +
1250 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1251 + : "r" (&v->counter), "r" (i)
1252 + : "cc");
1253 +}
1254 +
1255 +static inline void atomic64_add_unchecked(u64 i, atomic64_unchecked_t *v)
1256 +{
1257 + u64 result;
1258 + unsigned long tmp;
1259 +
1260 + __asm__ __volatile__("@ atomic64_add_unchecked\n"
1261 +"1: ldrexd %0, %H0, [%3]\n"
1262 +" adds %0, %0, %4\n"
1263 " adc %H0, %H0, %H4\n"
1264 " strexd %1, %0, %H0, [%3]\n"
1265 " teq %1, #0\n"
1266 @@ -313,12 +588,49 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1267
1268 static inline u64 atomic64_add_return(u64 i, atomic64_t *v)
1269 {
1270 - u64 result;
1271 - unsigned long tmp;
1272 + u64 result, tmp;
1273
1274 smp_mb();
1275
1276 __asm__ __volatile__("@ atomic64_add_return\n"
1277 +"1: ldrexd %1, %H1, [%3]\n"
1278 +" adds %0, %1, %4\n"
1279 +" adcs %H0, %H1, %H4\n"
1280 +
1281 +#ifdef CONFIG_PAX_REFCOUNT
1282 +" bvc 3f\n"
1283 +" mov %0, %1\n"
1284 +" mov %H0, %H1\n"
1285 +"2: bkpt 0xf103\n"
1286 +"3:\n"
1287 +#endif
1288 +
1289 +" strexd %1, %0, %H0, [%3]\n"
1290 +" teq %1, #0\n"
1291 +" bne 1b"
1292 +
1293 +#ifdef CONFIG_PAX_REFCOUNT
1294 +"\n4:\n"
1295 + _ASM_EXTABLE(2b, 4b)
1296 +#endif
1297 +
1298 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1299 + : "r" (&v->counter), "r" (i)
1300 + : "cc");
1301 +
1302 + smp_mb();
1303 +
1304 + return result;
1305 +}
1306 +
1307 +static inline u64 atomic64_add_return_unchecked(u64 i, atomic64_unchecked_t *v)
1308 +{
1309 + u64 result;
1310 + unsigned long tmp;
1311 +
1312 + smp_mb();
1313 +
1314 + __asm__ __volatile__("@ atomic64_add_return_unchecked\n"
1315 "1: ldrexd %0, %H0, [%3]\n"
1316 " adds %0, %0, %4\n"
1317 " adc %H0, %H0, %H4\n"
1318 @@ -342,6 +654,36 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1319 __asm__ __volatile__("@ atomic64_sub\n"
1320 "1: ldrexd %0, %H0, [%3]\n"
1321 " subs %0, %0, %4\n"
1322 +" sbcs %H0, %H0, %H4\n"
1323 +
1324 +#ifdef CONFIG_PAX_REFCOUNT
1325 +" bvc 3f\n"
1326 +"2: bkpt 0xf103\n"
1327 +"3:\n"
1328 +#endif
1329 +
1330 +" strexd %1, %0, %H0, [%3]\n"
1331 +" teq %1, #0\n"
1332 +" bne 1b"
1333 +
1334 +#ifdef CONFIG_PAX_REFCOUNT
1335 +"\n4:\n"
1336 + _ASM_EXTABLE(2b, 4b)
1337 +#endif
1338 +
1339 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1340 + : "r" (&v->counter), "r" (i)
1341 + : "cc");
1342 +}
1343 +
1344 +static inline void atomic64_sub_unchecked(u64 i, atomic64_unchecked_t *v)
1345 +{
1346 + u64 result;
1347 + unsigned long tmp;
1348 +
1349 + __asm__ __volatile__("@ atomic64_sub_unchecked\n"
1350 +"1: ldrexd %0, %H0, [%3]\n"
1351 +" subs %0, %0, %4\n"
1352 " sbc %H0, %H0, %H4\n"
1353 " strexd %1, %0, %H0, [%3]\n"
1354 " teq %1, #0\n"
1355 @@ -353,18 +695,32 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1356
1357 static inline u64 atomic64_sub_return(u64 i, atomic64_t *v)
1358 {
1359 - u64 result;
1360 - unsigned long tmp;
1361 + u64 result, tmp;
1362
1363 smp_mb();
1364
1365 __asm__ __volatile__("@ atomic64_sub_return\n"
1366 -"1: ldrexd %0, %H0, [%3]\n"
1367 -" subs %0, %0, %4\n"
1368 -" sbc %H0, %H0, %H4\n"
1369 +"1: ldrexd %1, %H1, [%3]\n"
1370 +" subs %0, %1, %4\n"
1371 +" sbcs %H0, %H1, %H4\n"
1372 +
1373 +#ifdef CONFIG_PAX_REFCOUNT
1374 +" bvc 3f\n"
1375 +" mov %0, %1\n"
1376 +" mov %H0, %H1\n"
1377 +"2: bkpt 0xf103\n"
1378 +"3:\n"
1379 +#endif
1380 +
1381 " strexd %1, %0, %H0, [%3]\n"
1382 " teq %1, #0\n"
1383 " bne 1b"
1384 +
1385 +#ifdef CONFIG_PAX_REFCOUNT
1386 +"\n4:\n"
1387 + _ASM_EXTABLE(2b, 4b)
1388 +#endif
1389 +
1390 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1391 : "r" (&v->counter), "r" (i)
1392 : "cc");
1393 @@ -398,6 +754,30 @@ static inline u64 atomic64_cmpxchg(atomic64_t *ptr, u64 old, u64 new)
1394 return oldval;
1395 }
1396
1397 +static inline u64 atomic64_cmpxchg_unchecked(atomic64_unchecked_t *ptr, u64 old, u64 new)
1398 +{
1399 + u64 oldval;
1400 + unsigned long res;
1401 +
1402 + smp_mb();
1403 +
1404 + do {
1405 + __asm__ __volatile__("@ atomic64_cmpxchg_unchecked\n"
1406 + "ldrexd %1, %H1, [%3]\n"
1407 + "mov %0, #0\n"
1408 + "teq %1, %4\n"
1409 + "teqeq %H1, %H4\n"
1410 + "strexdeq %0, %5, %H5, [%3]"
1411 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1412 + : "r" (&ptr->counter), "r" (old), "r" (new)
1413 + : "cc");
1414 + } while (res);
1415 +
1416 + smp_mb();
1417 +
1418 + return oldval;
1419 +}
1420 +
1421 static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1422 {
1423 u64 result;
1424 @@ -421,21 +801,34 @@ static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1425
1426 static inline u64 atomic64_dec_if_positive(atomic64_t *v)
1427 {
1428 - u64 result;
1429 - unsigned long tmp;
1430 + u64 result, tmp;
1431
1432 smp_mb();
1433
1434 __asm__ __volatile__("@ atomic64_dec_if_positive\n"
1435 -"1: ldrexd %0, %H0, [%3]\n"
1436 -" subs %0, %0, #1\n"
1437 -" sbc %H0, %H0, #0\n"
1438 +"1: ldrexd %1, %H1, [%3]\n"
1439 +" subs %0, %1, #1\n"
1440 +" sbcs %H0, %H1, #0\n"
1441 +
1442 +#ifdef CONFIG_PAX_REFCOUNT
1443 +" bvc 3f\n"
1444 +" mov %0, %1\n"
1445 +" mov %H0, %H1\n"
1446 +"2: bkpt 0xf103\n"
1447 +"3:\n"
1448 +#endif
1449 +
1450 " teq %H0, #0\n"
1451 -" bmi 2f\n"
1452 +" bmi 4f\n"
1453 " strexd %1, %0, %H0, [%3]\n"
1454 " teq %1, #0\n"
1455 " bne 1b\n"
1456 -"2:"
1457 +"4:\n"
1458 +
1459 +#ifdef CONFIG_PAX_REFCOUNT
1460 + _ASM_EXTABLE(2b, 4b)
1461 +#endif
1462 +
1463 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1464 : "r" (&v->counter)
1465 : "cc");
1466 @@ -458,13 +851,25 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1467 " teq %0, %5\n"
1468 " teqeq %H0, %H5\n"
1469 " moveq %1, #0\n"
1470 -" beq 2f\n"
1471 +" beq 4f\n"
1472 " adds %0, %0, %6\n"
1473 -" adc %H0, %H0, %H6\n"
1474 +" adcs %H0, %H0, %H6\n"
1475 +
1476 +#ifdef CONFIG_PAX_REFCOUNT
1477 +" bvc 3f\n"
1478 +"2: bkpt 0xf103\n"
1479 +"3:\n"
1480 +#endif
1481 +
1482 " strexd %2, %0, %H0, [%4]\n"
1483 " teq %2, #0\n"
1484 " bne 1b\n"
1485 -"2:"
1486 +"4:\n"
1487 +
1488 +#ifdef CONFIG_PAX_REFCOUNT
1489 + _ASM_EXTABLE(2b, 4b)
1490 +#endif
1491 +
1492 : "=&r" (val), "+r" (ret), "=&r" (tmp), "+Qo" (v->counter)
1493 : "r" (&v->counter), "r" (u), "r" (a)
1494 : "cc");
1495 @@ -477,10 +882,13 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1496
1497 #define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
1498 #define atomic64_inc(v) atomic64_add(1LL, (v))
1499 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1LL, (v))
1500 #define atomic64_inc_return(v) atomic64_add_return(1LL, (v))
1501 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1LL, (v))
1502 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
1503 #define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
1504 #define atomic64_dec(v) atomic64_sub(1LL, (v))
1505 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1LL, (v))
1506 #define atomic64_dec_return(v) atomic64_sub_return(1LL, (v))
1507 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
1508 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
1509 diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
1510 index 75fe66b..ba3dee4 100644
1511 --- a/arch/arm/include/asm/cache.h
1512 +++ b/arch/arm/include/asm/cache.h
1513 @@ -4,8 +4,10 @@
1514 #ifndef __ASMARM_CACHE_H
1515 #define __ASMARM_CACHE_H
1516
1517 +#include <linux/const.h>
1518 +
1519 #define L1_CACHE_SHIFT CONFIG_ARM_L1_CACHE_SHIFT
1520 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
1521 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
1522
1523 /*
1524 * Memory returned by kmalloc() may be used for DMA, so we must make
1525 @@ -24,5 +26,6 @@
1526 #endif
1527
1528 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
1529 +#define __read_only __attribute__ ((__section__(".data..read_only")))
1530
1531 #endif
1532 diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
1533 index 17d0ae8..014e350 100644
1534 --- a/arch/arm/include/asm/cacheflush.h
1535 +++ b/arch/arm/include/asm/cacheflush.h
1536 @@ -116,7 +116,7 @@ struct cpu_cache_fns {
1537 void (*dma_unmap_area)(const void *, size_t, int);
1538
1539 void (*dma_flush_range)(const void *, const void *);
1540 -};
1541 +} __no_const;
1542
1543 /*
1544 * Select the calling method
1545 diff --git a/arch/arm/include/asm/checksum.h b/arch/arm/include/asm/checksum.h
1546 index 6dcc164..b14d917 100644
1547 --- a/arch/arm/include/asm/checksum.h
1548 +++ b/arch/arm/include/asm/checksum.h
1549 @@ -37,7 +37,19 @@ __wsum
1550 csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
1551
1552 __wsum
1553 -csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1554 +__csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1555 +
1556 +static inline __wsum
1557 +csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr)
1558 +{
1559 + __wsum ret;
1560 + pax_open_userland();
1561 + ret = __csum_partial_copy_from_user(src, dst, len, sum, err_ptr);
1562 + pax_close_userland();
1563 + return ret;
1564 +}
1565 +
1566 +
1567
1568 /*
1569 * Fold a partial checksum without adding pseudo headers
1570 diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
1571 index 4f009c1..466c59b 100644
1572 --- a/arch/arm/include/asm/cmpxchg.h
1573 +++ b/arch/arm/include/asm/cmpxchg.h
1574 @@ -102,6 +102,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
1575
1576 #define xchg(ptr,x) \
1577 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1578 +#define xchg_unchecked(ptr,x) \
1579 + ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1580
1581 #include <asm-generic/cmpxchg-local.h>
1582
1583 diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h
1584 index 6ddbe44..b5e38b1 100644
1585 --- a/arch/arm/include/asm/domain.h
1586 +++ b/arch/arm/include/asm/domain.h
1587 @@ -48,18 +48,37 @@
1588 * Domain types
1589 */
1590 #define DOMAIN_NOACCESS 0
1591 -#define DOMAIN_CLIENT 1
1592 #ifdef CONFIG_CPU_USE_DOMAINS
1593 +#define DOMAIN_USERCLIENT 1
1594 +#define DOMAIN_KERNELCLIENT 1
1595 #define DOMAIN_MANAGER 3
1596 +#define DOMAIN_VECTORS DOMAIN_USER
1597 #else
1598 +
1599 +#ifdef CONFIG_PAX_KERNEXEC
1600 #define DOMAIN_MANAGER 1
1601 +#define DOMAIN_KERNEXEC 3
1602 +#else
1603 +#define DOMAIN_MANAGER 1
1604 +#endif
1605 +
1606 +#ifdef CONFIG_PAX_MEMORY_UDEREF
1607 +#define DOMAIN_USERCLIENT 0
1608 +#define DOMAIN_UDEREF 1
1609 +#define DOMAIN_VECTORS DOMAIN_KERNEL
1610 +#else
1611 +#define DOMAIN_USERCLIENT 1
1612 +#define DOMAIN_VECTORS DOMAIN_USER
1613 +#endif
1614 +#define DOMAIN_KERNELCLIENT 1
1615 +
1616 #endif
1617
1618 #define domain_val(dom,type) ((type) << (2*(dom)))
1619
1620 #ifndef __ASSEMBLY__
1621
1622 -#ifdef CONFIG_CPU_USE_DOMAINS
1623 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1624 static inline void set_domain(unsigned val)
1625 {
1626 asm volatile(
1627 @@ -68,15 +87,7 @@ static inline void set_domain(unsigned val)
1628 isb();
1629 }
1630
1631 -#define modify_domain(dom,type) \
1632 - do { \
1633 - struct thread_info *thread = current_thread_info(); \
1634 - unsigned int domain = thread->cpu_domain; \
1635 - domain &= ~domain_val(dom, DOMAIN_MANAGER); \
1636 - thread->cpu_domain = domain | domain_val(dom, type); \
1637 - set_domain(thread->cpu_domain); \
1638 - } while (0)
1639 -
1640 +extern void modify_domain(unsigned int dom, unsigned int type);
1641 #else
1642 static inline void set_domain(unsigned val) { }
1643 static inline void modify_domain(unsigned dom, unsigned type) { }
1644 diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
1645 index 56211f2..17e8a25 100644
1646 --- a/arch/arm/include/asm/elf.h
1647 +++ b/arch/arm/include/asm/elf.h
1648 @@ -116,7 +116,14 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1649 the loader. We need to make sure that it is out of the way of the program
1650 that it will "exec", and that there is sufficient room for the brk. */
1651
1652 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
1653 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1654 +
1655 +#ifdef CONFIG_PAX_ASLR
1656 +#define PAX_ELF_ET_DYN_BASE 0x00008000UL
1657 +
1658 +#define PAX_DELTA_MMAP_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1659 +#define PAX_DELTA_STACK_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1660 +#endif
1661
1662 /* When the program starts, a1 contains a pointer to a function to be
1663 registered with atexit, as per the SVR4 ABI. A value of 0 means we
1664 @@ -126,10 +133,6 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1665 extern void elf_set_personality(const struct elf32_hdr *);
1666 #define SET_PERSONALITY(ex) elf_set_personality(&(ex))
1667
1668 -struct mm_struct;
1669 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
1670 -#define arch_randomize_brk arch_randomize_brk
1671 -
1672 #ifdef CONFIG_MMU
1673 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
1674 struct linux_binprm;
1675 diff --git a/arch/arm/include/asm/fncpy.h b/arch/arm/include/asm/fncpy.h
1676 index de53547..52b9a28 100644
1677 --- a/arch/arm/include/asm/fncpy.h
1678 +++ b/arch/arm/include/asm/fncpy.h
1679 @@ -81,7 +81,9 @@
1680 BUG_ON((uintptr_t)(dest_buf) & (FNCPY_ALIGN - 1) || \
1681 (__funcp_address & ~(uintptr_t)1 & (FNCPY_ALIGN - 1))); \
1682 \
1683 + pax_open_kernel(); \
1684 memcpy(dest_buf, (void const *)(__funcp_address & ~1), size); \
1685 + pax_close_kernel(); \
1686 flush_icache_range((unsigned long)(dest_buf), \
1687 (unsigned long)(dest_buf) + (size)); \
1688 \
1689 diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
1690 index e42cf59..7b94b8f 100644
1691 --- a/arch/arm/include/asm/futex.h
1692 +++ b/arch/arm/include/asm/futex.h
1693 @@ -50,6 +50,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1694 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1695 return -EFAULT;
1696
1697 + pax_open_userland();
1698 +
1699 smp_mb();
1700 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1701 "1: ldrex %1, [%4]\n"
1702 @@ -65,6 +67,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1703 : "cc", "memory");
1704 smp_mb();
1705
1706 + pax_close_userland();
1707 +
1708 *uval = val;
1709 return ret;
1710 }
1711 @@ -95,6 +99,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1712 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1713 return -EFAULT;
1714
1715 + pax_open_userland();
1716 +
1717 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1718 "1: " TUSER(ldr) " %1, [%4]\n"
1719 " teq %1, %2\n"
1720 @@ -105,6 +111,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1721 : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
1722 : "cc", "memory");
1723
1724 + pax_close_userland();
1725 +
1726 *uval = val;
1727 return ret;
1728 }
1729 @@ -127,6 +135,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1730 return -EFAULT;
1731
1732 pagefault_disable(); /* implies preempt_disable() */
1733 + pax_open_userland();
1734
1735 switch (op) {
1736 case FUTEX_OP_SET:
1737 @@ -148,6 +157,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1738 ret = -ENOSYS;
1739 }
1740
1741 + pax_close_userland();
1742 pagefault_enable(); /* subsumes preempt_enable() */
1743
1744 if (!ret) {
1745 diff --git a/arch/arm/include/asm/kmap_types.h b/arch/arm/include/asm/kmap_types.h
1746 index 83eb2f7..ed77159 100644
1747 --- a/arch/arm/include/asm/kmap_types.h
1748 +++ b/arch/arm/include/asm/kmap_types.h
1749 @@ -4,6 +4,6 @@
1750 /*
1751 * This is the "bare minimum". AIO seems to require this.
1752 */
1753 -#define KM_TYPE_NR 16
1754 +#define KM_TYPE_NR 17
1755
1756 #endif
1757 diff --git a/arch/arm/include/asm/mach/dma.h b/arch/arm/include/asm/mach/dma.h
1758 index 9e614a1..3302cca 100644
1759 --- a/arch/arm/include/asm/mach/dma.h
1760 +++ b/arch/arm/include/asm/mach/dma.h
1761 @@ -22,7 +22,7 @@ struct dma_ops {
1762 int (*residue)(unsigned int, dma_t *); /* optional */
1763 int (*setspeed)(unsigned int, dma_t *, int); /* optional */
1764 const char *type;
1765 -};
1766 +} __do_const;
1767
1768 struct dma_struct {
1769 void *addr; /* single DMA address */
1770 diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h
1771 index 2fe141f..192dc01 100644
1772 --- a/arch/arm/include/asm/mach/map.h
1773 +++ b/arch/arm/include/asm/mach/map.h
1774 @@ -27,13 +27,16 @@ struct map_desc {
1775 #define MT_MINICLEAN 6
1776 #define MT_LOW_VECTORS 7
1777 #define MT_HIGH_VECTORS 8
1778 -#define MT_MEMORY 9
1779 +#define MT_MEMORY_RWX 9
1780 #define MT_ROM 10
1781 -#define MT_MEMORY_NONCACHED 11
1782 +#define MT_MEMORY_NONCACHED_RX 11
1783 #define MT_MEMORY_DTCM 12
1784 #define MT_MEMORY_ITCM 13
1785 #define MT_MEMORY_SO 14
1786 #define MT_MEMORY_DMA_READY 15
1787 +#define MT_MEMORY_RW 16
1788 +#define MT_MEMORY_RX 17
1789 +#define MT_MEMORY_NONCACHED_RW 18
1790
1791 #ifdef CONFIG_MMU
1792 extern void iotable_init(struct map_desc *, int);
1793 diff --git a/arch/arm/include/asm/outercache.h b/arch/arm/include/asm/outercache.h
1794 index 12f71a1..04e063c 100644
1795 --- a/arch/arm/include/asm/outercache.h
1796 +++ b/arch/arm/include/asm/outercache.h
1797 @@ -35,7 +35,7 @@ struct outer_cache_fns {
1798 #endif
1799 void (*set_debug)(unsigned long);
1800 void (*resume)(void);
1801 -};
1802 +} __no_const;
1803
1804 #ifdef CONFIG_OUTER_CACHE
1805
1806 diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
1807 index cbdc7a2..32f44fe 100644
1808 --- a/arch/arm/include/asm/page.h
1809 +++ b/arch/arm/include/asm/page.h
1810 @@ -114,7 +114,7 @@ struct cpu_user_fns {
1811 void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
1812 void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
1813 unsigned long vaddr, struct vm_area_struct *vma);
1814 -};
1815 +} __no_const;
1816
1817 #ifdef MULTI_USER
1818 extern struct cpu_user_fns cpu_user;
1819 diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
1820 index 943504f..c37a730 100644
1821 --- a/arch/arm/include/asm/pgalloc.h
1822 +++ b/arch/arm/include/asm/pgalloc.h
1823 @@ -17,6 +17,7 @@
1824 #include <asm/processor.h>
1825 #include <asm/cacheflush.h>
1826 #include <asm/tlbflush.h>
1827 +#include <asm/system_info.h>
1828
1829 #define check_pgt_cache() do { } while (0)
1830
1831 @@ -43,6 +44,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1832 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
1833 }
1834
1835 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1836 +{
1837 + pud_populate(mm, pud, pmd);
1838 +}
1839 +
1840 #else /* !CONFIG_ARM_LPAE */
1841
1842 /*
1843 @@ -51,6 +57,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1844 #define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
1845 #define pmd_free(mm, pmd) do { } while (0)
1846 #define pud_populate(mm,pmd,pte) BUG()
1847 +#define pud_populate_kernel(mm,pmd,pte) BUG()
1848
1849 #endif /* CONFIG_ARM_LPAE */
1850
1851 @@ -126,6 +133,19 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
1852 __free_page(pte);
1853 }
1854
1855 +static inline void __section_update(pmd_t *pmdp, unsigned long addr, pmdval_t prot)
1856 +{
1857 +#ifdef CONFIG_ARM_LPAE
1858 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1859 +#else
1860 + if (addr & SECTION_SIZE)
1861 + pmdp[1] = __pmd(pmd_val(pmdp[1]) | prot);
1862 + else
1863 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1864 +#endif
1865 + flush_pmd_entry(pmdp);
1866 +}
1867 +
1868 static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,
1869 pmdval_t prot)
1870 {
1871 @@ -155,7 +175,7 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
1872 static inline void
1873 pmd_populate(struct mm_struct *mm, pmd_t *pmdp, pgtable_t ptep)
1874 {
1875 - __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE);
1876 + __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE | __supported_pmd_mask);
1877 }
1878 #define pmd_pgtable(pmd) pmd_page(pmd)
1879
1880 diff --git a/arch/arm/include/asm/pgtable-2level-hwdef.h b/arch/arm/include/asm/pgtable-2level-hwdef.h
1881 index 5cfba15..f415e1a 100644
1882 --- a/arch/arm/include/asm/pgtable-2level-hwdef.h
1883 +++ b/arch/arm/include/asm/pgtable-2level-hwdef.h
1884 @@ -20,12 +20,15 @@
1885 #define PMD_TYPE_FAULT (_AT(pmdval_t, 0) << 0)
1886 #define PMD_TYPE_TABLE (_AT(pmdval_t, 1) << 0)
1887 #define PMD_TYPE_SECT (_AT(pmdval_t, 2) << 0)
1888 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 2) /* v7 */
1889 #define PMD_BIT4 (_AT(pmdval_t, 1) << 4)
1890 #define PMD_DOMAIN(x) (_AT(pmdval_t, (x)) << 5)
1891 #define PMD_PROTECTION (_AT(pmdval_t, 1) << 9) /* v5 */
1892 +
1893 /*
1894 * - section
1895 */
1896 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 0) /* v7 */
1897 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1898 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1899 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 4) /* v6 */
1900 @@ -37,6 +40,7 @@
1901 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17) /* v6 */
1902 #define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18) /* v6 */
1903 #define PMD_SECT_AF (_AT(pmdval_t, 0))
1904 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 0))
1905
1906 #define PMD_SECT_UNCACHED (_AT(pmdval_t, 0))
1907 #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE)
1908 @@ -66,6 +70,7 @@
1909 * - extended small page/tiny page
1910 */
1911 #define PTE_EXT_XN (_AT(pteval_t, 1) << 0) /* v6 */
1912 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 2) /* v7 */
1913 #define PTE_EXT_AP_MASK (_AT(pteval_t, 3) << 4)
1914 #define PTE_EXT_AP0 (_AT(pteval_t, 1) << 4)
1915 #define PTE_EXT_AP1 (_AT(pteval_t, 2) << 4)
1916 diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
1917 index f97ee02..cc9fe9e 100644
1918 --- a/arch/arm/include/asm/pgtable-2level.h
1919 +++ b/arch/arm/include/asm/pgtable-2level.h
1920 @@ -126,6 +126,9 @@
1921 #define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */
1922 #define L_PTE_NONE (_AT(pteval_t, 1) << 11)
1923
1924 +/* Two-level page tables only have PXN in the PGD, not in the PTE. */
1925 +#define L_PTE_PXN (_AT(pteval_t, 0))
1926 +
1927 /*
1928 * These are the memory types, defined to be compatible with
1929 * pre-ARMv6 CPUs cacheable and bufferable bits: XXCB
1930 diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h
1931 index 18f5cef..25b8f43 100644
1932 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h
1933 +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h
1934 @@ -41,6 +41,7 @@
1935 */
1936 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1937 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1938 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 1) << 7)
1939 #define PMD_SECT_S (_AT(pmdval_t, 3) << 8)
1940 #define PMD_SECT_AF (_AT(pmdval_t, 1) << 10)
1941 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 11)
1942 @@ -71,6 +72,7 @@
1943 #define PTE_EXT_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1944 #define PTE_EXT_AF (_AT(pteval_t, 1) << 10) /* Access Flag */
1945 #define PTE_EXT_NG (_AT(pteval_t, 1) << 11) /* nG */
1946 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1947 #define PTE_EXT_XN (_AT(pteval_t, 1) << 54) /* XN */
1948
1949 /*
1950 diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
1951 index 86b8fe3..e25f975 100644
1952 --- a/arch/arm/include/asm/pgtable-3level.h
1953 +++ b/arch/arm/include/asm/pgtable-3level.h
1954 @@ -74,6 +74,7 @@
1955 #define L_PTE_RDONLY (_AT(pteval_t, 1) << 7) /* AP[2] */
1956 #define L_PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1957 #define L_PTE_YOUNG (_AT(pteval_t, 1) << 10) /* AF */
1958 +#define L_PTE_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1959 #define L_PTE_XN (_AT(pteval_t, 1) << 54) /* XN */
1960 #define L_PTE_DIRTY (_AT(pteval_t, 1) << 55) /* unused */
1961 #define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56) /* unused */
1962 @@ -82,6 +83,7 @@
1963 /*
1964 * To be used in assembly code with the upper page attributes.
1965 */
1966 +#define L_PTE_PXN_HIGH (1 << (53 - 32))
1967 #define L_PTE_XN_HIGH (1 << (54 - 32))
1968 #define L_PTE_DIRTY_HIGH (1 << (55 - 32))
1969
1970 diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
1971 index 9bcd262..fba731c 100644
1972 --- a/arch/arm/include/asm/pgtable.h
1973 +++ b/arch/arm/include/asm/pgtable.h
1974 @@ -30,6 +30,9 @@
1975 #include <asm/pgtable-2level.h>
1976 #endif
1977
1978 +#define ktla_ktva(addr) (addr)
1979 +#define ktva_ktla(addr) (addr)
1980 +
1981 /*
1982 * Just any arbitrary offset to the start of the vmalloc VM area: the
1983 * current 8MB value just means that there will be a 8MB "hole" after the
1984 @@ -45,6 +48,9 @@
1985 #define LIBRARY_TEXT_START 0x0c000000
1986
1987 #ifndef __ASSEMBLY__
1988 +extern pteval_t __supported_pte_mask;
1989 +extern pmdval_t __supported_pmd_mask;
1990 +
1991 extern void __pte_error(const char *file, int line, pte_t);
1992 extern void __pmd_error(const char *file, int line, pmd_t);
1993 extern void __pgd_error(const char *file, int line, pgd_t);
1994 @@ -53,6 +59,50 @@ extern void __pgd_error(const char *file, int line, pgd_t);
1995 #define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd)
1996 #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd)
1997
1998 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
1999 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
2000 +
2001 +#ifdef CONFIG_PAX_KERNEXEC
2002 +#include <asm/domain.h>
2003 +#include <linux/thread_info.h>
2004 +#include <linux/preempt.h>
2005 +#endif
2006 +
2007 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2008 +static inline int test_domain(int domain, int domaintype)
2009 +{
2010 + return ((current_thread_info()->cpu_domain) & domain_val(domain, 3)) == domain_val(domain, domaintype);
2011 +}
2012 +#endif
2013 +
2014 +#ifdef CONFIG_PAX_KERNEXEC
2015 +static inline unsigned long pax_open_kernel(void) {
2016 +#ifdef CONFIG_ARM_LPAE
2017 + /* TODO */
2018 +#else
2019 + preempt_disable();
2020 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC));
2021 + modify_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC);
2022 +#endif
2023 + return 0;
2024 +}
2025 +
2026 +static inline unsigned long pax_close_kernel(void) {
2027 +#ifdef CONFIG_ARM_LPAE
2028 + /* TODO */
2029 +#else
2030 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_MANAGER));
2031 + /* DOMAIN_MANAGER = "client" under KERNEXEC */
2032 + modify_domain(DOMAIN_KERNEL, DOMAIN_MANAGER);
2033 + preempt_enable_no_resched();
2034 +#endif
2035 + return 0;
2036 +}
2037 +#else
2038 +static inline unsigned long pax_open_kernel(void) { return 0; }
2039 +static inline unsigned long pax_close_kernel(void) { return 0; }
2040 +#endif
2041 +
2042 /*
2043 * This is the lowest virtual address we can permit any user space
2044 * mapping to be mapped at. This is particularly important for
2045 @@ -72,8 +122,8 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2046 /*
2047 * The pgprot_* and protection_map entries will be fixed up in runtime
2048 * to include the cachable and bufferable bits based on memory policy,
2049 - * as well as any architecture dependent bits like global/ASID and SMP
2050 - * shared mapping bits.
2051 + * as well as any architecture dependent bits like global/ASID, PXN,
2052 + * and SMP shared mapping bits.
2053 */
2054 #define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
2055
2056 @@ -257,7 +307,7 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
2057 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
2058 {
2059 const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |
2060 - L_PTE_NONE | L_PTE_VALID;
2061 + L_PTE_NONE | L_PTE_VALID | __supported_pte_mask;
2062 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
2063 return pte;
2064 }
2065 diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h
2066 index f3628fb..a0672dd 100644
2067 --- a/arch/arm/include/asm/proc-fns.h
2068 +++ b/arch/arm/include/asm/proc-fns.h
2069 @@ -75,7 +75,7 @@ extern struct processor {
2070 unsigned int suspend_size;
2071 void (*do_suspend)(void *);
2072 void (*do_resume)(void *);
2073 -} processor;
2074 +} __do_const processor;
2075
2076 #ifndef MULTI_CPU
2077 extern void cpu_proc_init(void);
2078 diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h
2079 index ce0dbe7..c085b6f 100644
2080 --- a/arch/arm/include/asm/psci.h
2081 +++ b/arch/arm/include/asm/psci.h
2082 @@ -29,7 +29,7 @@ struct psci_operations {
2083 int (*cpu_off)(struct psci_power_state state);
2084 int (*cpu_on)(unsigned long cpuid, unsigned long entry_point);
2085 int (*migrate)(unsigned long cpuid);
2086 -};
2087 +} __no_const;
2088
2089 extern struct psci_operations psci_ops;
2090
2091 diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
2092 index d3a22be..3a69ad5 100644
2093 --- a/arch/arm/include/asm/smp.h
2094 +++ b/arch/arm/include/asm/smp.h
2095 @@ -107,7 +107,7 @@ struct smp_operations {
2096 int (*cpu_disable)(unsigned int cpu);
2097 #endif
2098 #endif
2099 -};
2100 +} __no_const;
2101
2102 /*
2103 * set platform specific SMP operations
2104 diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
2105 index f00b569..aa5bb41 100644
2106 --- a/arch/arm/include/asm/thread_info.h
2107 +++ b/arch/arm/include/asm/thread_info.h
2108 @@ -77,9 +77,9 @@ struct thread_info {
2109 .flags = 0, \
2110 .preempt_count = INIT_PREEMPT_COUNT, \
2111 .addr_limit = KERNEL_DS, \
2112 - .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2113 - domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2114 - domain_val(DOMAIN_IO, DOMAIN_CLIENT), \
2115 + .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_USERCLIENT) | \
2116 + domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT) | \
2117 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT), \
2118 .restart_block = { \
2119 .fn = do_no_restart_syscall, \
2120 }, \
2121 @@ -152,7 +152,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2122 #define TIF_SYSCALL_AUDIT 9
2123 #define TIF_SYSCALL_TRACEPOINT 10
2124 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */
2125 -#define TIF_NOHZ 12 /* in adaptive nohz mode */
2126 +/* within 8 bits of TIF_SYSCALL_TRACE
2127 + * to meet flexible second operand requirements
2128 + */
2129 +#define TIF_GRSEC_SETXID 12
2130 +#define TIF_NOHZ 13 /* in adaptive nohz mode */
2131 #define TIF_USING_IWMMXT 17
2132 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
2133 #define TIF_RESTORE_SIGMASK 20
2134 @@ -165,10 +169,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2135 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
2136 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
2137 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
2138 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
2139
2140 /* Checks for any syscall work in entry-common.S */
2141 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
2142 - _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
2143 + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_GRSEC_SETXID)
2144
2145 /*
2146 * Change these and you break ASM code in entry-common.S
2147 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
2148 index 7e1f760..de33b13 100644
2149 --- a/arch/arm/include/asm/uaccess.h
2150 +++ b/arch/arm/include/asm/uaccess.h
2151 @@ -18,6 +18,7 @@
2152 #include <asm/domain.h>
2153 #include <asm/unified.h>
2154 #include <asm/compiler.h>
2155 +#include <asm/pgtable.h>
2156
2157 #define VERIFY_READ 0
2158 #define VERIFY_WRITE 1
2159 @@ -63,11 +64,38 @@ extern int __put_user_bad(void);
2160 static inline void set_fs(mm_segment_t fs)
2161 {
2162 current_thread_info()->addr_limit = fs;
2163 - modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
2164 + modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_KERNELCLIENT : DOMAIN_MANAGER);
2165 }
2166
2167 #define segment_eq(a,b) ((a) == (b))
2168
2169 +#define __HAVE_ARCH_PAX_OPEN_USERLAND
2170 +#define __HAVE_ARCH_PAX_CLOSE_USERLAND
2171 +
2172 +static inline void pax_open_userland(void)
2173 +{
2174 +
2175 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2176 + if (segment_eq(get_fs(), USER_DS)) {
2177 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_UDEREF));
2178 + modify_domain(DOMAIN_USER, DOMAIN_UDEREF);
2179 + }
2180 +#endif
2181 +
2182 +}
2183 +
2184 +static inline void pax_close_userland(void)
2185 +{
2186 +
2187 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2188 + if (segment_eq(get_fs(), USER_DS)) {
2189 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_NOACCESS));
2190 + modify_domain(DOMAIN_USER, DOMAIN_NOACCESS);
2191 + }
2192 +#endif
2193 +
2194 +}
2195 +
2196 #define __addr_ok(addr) ({ \
2197 unsigned long flag; \
2198 __asm__("cmp %2, %0; movlo %0, #0" \
2199 @@ -143,8 +171,12 @@ extern int __get_user_4(void *);
2200
2201 #define get_user(x,p) \
2202 ({ \
2203 + int __e; \
2204 might_fault(); \
2205 - __get_user_check(x,p); \
2206 + pax_open_userland(); \
2207 + __e = __get_user_check(x,p); \
2208 + pax_close_userland(); \
2209 + __e; \
2210 })
2211
2212 extern int __put_user_1(void *, unsigned int);
2213 @@ -188,8 +220,12 @@ extern int __put_user_8(void *, unsigned long long);
2214
2215 #define put_user(x,p) \
2216 ({ \
2217 + int __e; \
2218 might_fault(); \
2219 - __put_user_check(x,p); \
2220 + pax_open_userland(); \
2221 + __e = __put_user_check(x,p); \
2222 + pax_close_userland(); \
2223 + __e; \
2224 })
2225
2226 #else /* CONFIG_MMU */
2227 @@ -230,13 +266,17 @@ static inline void set_fs(mm_segment_t fs)
2228 #define __get_user(x,ptr) \
2229 ({ \
2230 long __gu_err = 0; \
2231 + pax_open_userland(); \
2232 __get_user_err((x),(ptr),__gu_err); \
2233 + pax_close_userland(); \
2234 __gu_err; \
2235 })
2236
2237 #define __get_user_error(x,ptr,err) \
2238 ({ \
2239 + pax_open_userland(); \
2240 __get_user_err((x),(ptr),err); \
2241 + pax_close_userland(); \
2242 (void) 0; \
2243 })
2244
2245 @@ -312,13 +352,17 @@ do { \
2246 #define __put_user(x,ptr) \
2247 ({ \
2248 long __pu_err = 0; \
2249 + pax_open_userland(); \
2250 __put_user_err((x),(ptr),__pu_err); \
2251 + pax_close_userland(); \
2252 __pu_err; \
2253 })
2254
2255 #define __put_user_error(x,ptr,err) \
2256 ({ \
2257 + pax_open_userland(); \
2258 __put_user_err((x),(ptr),err); \
2259 + pax_close_userland(); \
2260 (void) 0; \
2261 })
2262
2263 @@ -418,11 +462,44 @@ do { \
2264
2265
2266 #ifdef CONFIG_MMU
2267 -extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
2268 -extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
2269 +extern unsigned long __must_check ___copy_from_user(void *to, const void __user *from, unsigned long n);
2270 +extern unsigned long __must_check ___copy_to_user(void __user *to, const void *from, unsigned long n);
2271 +
2272 +static inline unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n)
2273 +{
2274 + unsigned long ret;
2275 +
2276 + check_object_size(to, n, false);
2277 + pax_open_userland();
2278 + ret = ___copy_from_user(to, from, n);
2279 + pax_close_userland();
2280 + return ret;
2281 +}
2282 +
2283 +static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
2284 +{
2285 + unsigned long ret;
2286 +
2287 + check_object_size(from, n, true);
2288 + pax_open_userland();
2289 + ret = ___copy_to_user(to, from, n);
2290 + pax_close_userland();
2291 + return ret;
2292 +}
2293 +
2294 extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2295 -extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
2296 +extern unsigned long __must_check ___clear_user(void __user *addr, unsigned long n);
2297 extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
2298 +
2299 +static inline unsigned long __must_check __clear_user(void __user *addr, unsigned long n)
2300 +{
2301 + unsigned long ret;
2302 + pax_open_userland();
2303 + ret = ___clear_user(addr, n);
2304 + pax_close_userland();
2305 + return ret;
2306 +}
2307 +
2308 #else
2309 #define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0)
2310 #define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0)
2311 @@ -431,6 +508,9 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
2312
2313 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
2314 {
2315 + if ((long)n < 0)
2316 + return n;
2317 +
2318 if (access_ok(VERIFY_READ, from, n))
2319 n = __copy_from_user(to, from, n);
2320 else /* security hole - plug it */
2321 @@ -440,6 +520,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
2322
2323 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
2324 {
2325 + if ((long)n < 0)
2326 + return n;
2327 +
2328 if (access_ok(VERIFY_WRITE, to, n))
2329 n = __copy_to_user(to, from, n);
2330 return n;
2331 diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
2332 index 96ee092..37f1844 100644
2333 --- a/arch/arm/include/uapi/asm/ptrace.h
2334 +++ b/arch/arm/include/uapi/asm/ptrace.h
2335 @@ -73,7 +73,7 @@
2336 * ARMv7 groups of PSR bits
2337 */
2338 #define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */
2339 -#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */
2340 +#define PSR_ISET_MASK 0x01000020 /* ISA state (J, T) mask */
2341 #define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
2342 #define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */
2343
2344 diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
2345 index 60d3b73..e5a0f22 100644
2346 --- a/arch/arm/kernel/armksyms.c
2347 +++ b/arch/arm/kernel/armksyms.c
2348 @@ -53,7 +53,7 @@ EXPORT_SYMBOL(arm_delay_ops);
2349
2350 /* networking */
2351 EXPORT_SYMBOL(csum_partial);
2352 -EXPORT_SYMBOL(csum_partial_copy_from_user);
2353 +EXPORT_SYMBOL(__csum_partial_copy_from_user);
2354 EXPORT_SYMBOL(csum_partial_copy_nocheck);
2355 EXPORT_SYMBOL(__csum_ipv6_magic);
2356
2357 @@ -89,9 +89,9 @@ EXPORT_SYMBOL(__memzero);
2358 #ifdef CONFIG_MMU
2359 EXPORT_SYMBOL(copy_page);
2360
2361 -EXPORT_SYMBOL(__copy_from_user);
2362 -EXPORT_SYMBOL(__copy_to_user);
2363 -EXPORT_SYMBOL(__clear_user);
2364 +EXPORT_SYMBOL(___copy_from_user);
2365 +EXPORT_SYMBOL(___copy_to_user);
2366 +EXPORT_SYMBOL(___clear_user);
2367
2368 EXPORT_SYMBOL(__get_user_1);
2369 EXPORT_SYMBOL(__get_user_2);
2370 diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2371 index d43c7e5..257c050 100644
2372 --- a/arch/arm/kernel/entry-armv.S
2373 +++ b/arch/arm/kernel/entry-armv.S
2374 @@ -47,6 +47,87 @@
2375 9997:
2376 .endm
2377
2378 + .macro pax_enter_kernel
2379 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2380 + @ make aligned space for saved DACR
2381 + sub sp, sp, #8
2382 + @ save regs
2383 + stmdb sp!, {r1, r2}
2384 + @ read DACR from cpu_domain into r1
2385 + mov r2, sp
2386 + @ assume 8K pages, since we have to split the immediate in two
2387 + bic r2, r2, #(0x1fc0)
2388 + bic r2, r2, #(0x3f)
2389 + ldr r1, [r2, #TI_CPU_DOMAIN]
2390 + @ store old DACR on stack
2391 + str r1, [sp, #8]
2392 +#ifdef CONFIG_PAX_KERNEXEC
2393 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2394 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2395 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2396 +#endif
2397 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2398 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2399 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2400 +#endif
2401 + @ write r1 to current_thread_info()->cpu_domain
2402 + str r1, [r2, #TI_CPU_DOMAIN]
2403 + @ write r1 to DACR
2404 + mcr p15, 0, r1, c3, c0, 0
2405 + @ instruction sync
2406 + instr_sync
2407 + @ restore regs
2408 + ldmia sp!, {r1, r2}
2409 +#endif
2410 + .endm
2411 +
2412 + .macro pax_open_userland
2413 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2414 + @ save regs
2415 + stmdb sp!, {r0, r1}
2416 + @ read DACR from cpu_domain into r1
2417 + mov r0, sp
2418 + @ assume 8K pages, since we have to split the immediate in two
2419 + bic r0, r0, #(0x1fc0)
2420 + bic r0, r0, #(0x3f)
2421 + ldr r1, [r0, #TI_CPU_DOMAIN]
2422 + @ set current DOMAIN_USER to DOMAIN_CLIENT
2423 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2424 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2425 + @ write r1 to current_thread_info()->cpu_domain
2426 + str r1, [r0, #TI_CPU_DOMAIN]
2427 + @ write r1 to DACR
2428 + mcr p15, 0, r1, c3, c0, 0
2429 + @ instruction sync
2430 + instr_sync
2431 + @ restore regs
2432 + ldmia sp!, {r0, r1}
2433 +#endif
2434 + .endm
2435 +
2436 + .macro pax_close_userland
2437 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2438 + @ save regs
2439 + stmdb sp!, {r0, r1}
2440 + @ read DACR from cpu_domain into r1
2441 + mov r0, sp
2442 + @ assume 8K pages, since we have to split the immediate in two
2443 + bic r0, r0, #(0x1fc0)
2444 + bic r0, r0, #(0x3f)
2445 + ldr r1, [r0, #TI_CPU_DOMAIN]
2446 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2447 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2448 + @ write r1 to current_thread_info()->cpu_domain
2449 + str r1, [r0, #TI_CPU_DOMAIN]
2450 + @ write r1 to DACR
2451 + mcr p15, 0, r1, c3, c0, 0
2452 + @ instruction sync
2453 + instr_sync
2454 + @ restore regs
2455 + ldmia sp!, {r0, r1}
2456 +#endif
2457 + .endm
2458 +
2459 .macro pabt_helper
2460 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
2461 #ifdef MULTI_PABORT
2462 @@ -89,11 +170,15 @@
2463 * Invalid mode handlers
2464 */
2465 .macro inv_entry, reason
2466 +
2467 + pax_enter_kernel
2468 +
2469 sub sp, sp, #S_FRAME_SIZE
2470 ARM( stmib sp, {r1 - lr} )
2471 THUMB( stmia sp, {r0 - r12} )
2472 THUMB( str sp, [sp, #S_SP] )
2473 THUMB( str lr, [sp, #S_LR] )
2474 +
2475 mov r1, #\reason
2476 .endm
2477
2478 @@ -149,7 +234,11 @@ ENDPROC(__und_invalid)
2479 .macro svc_entry, stack_hole=0
2480 UNWIND(.fnstart )
2481 UNWIND(.save {r0 - pc} )
2482 +
2483 + pax_enter_kernel
2484 +
2485 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2486 +
2487 #ifdef CONFIG_THUMB2_KERNEL
2488 SPFIX( str r0, [sp] ) @ temporarily saved
2489 SPFIX( mov r0, sp )
2490 @@ -164,7 +253,12 @@ ENDPROC(__und_invalid)
2491 ldmia r0, {r3 - r5}
2492 add r7, sp, #S_SP - 4 @ here for interlock avoidance
2493 mov r6, #-1 @ "" "" "" ""
2494 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2495 + @ offset sp by 8 as done in pax_enter_kernel
2496 + add r2, sp, #(S_FRAME_SIZE + \stack_hole + 4)
2497 +#else
2498 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2499 +#endif
2500 SPFIX( addeq r2, r2, #4 )
2501 str r3, [sp, #-4]! @ save the "real" r0 copied
2502 @ from the exception stack
2503 @@ -316,6 +410,9 @@ ENDPROC(__pabt_svc)
2504 .macro usr_entry
2505 UNWIND(.fnstart )
2506 UNWIND(.cantunwind ) @ don't unwind the user space
2507 +
2508 + pax_enter_kernel_user
2509 +
2510 sub sp, sp, #S_FRAME_SIZE
2511 ARM( stmib sp, {r1 - r12} )
2512 THUMB( stmia sp, {r0 - r12} )
2513 @@ -357,7 +454,8 @@ ENDPROC(__pabt_svc)
2514 .endm
2515
2516 .macro kuser_cmpxchg_check
2517 -#if !defined(CONFIG_CPU_32v6K) && !defined(CONFIG_NEEDS_SYSCALL_FOR_CMPXCHG)
2518 +#if !defined(CONFIG_CPU_32v6K) && defined(CONFIG_KUSER_HELPERS) && \
2519 + !defined(CONFIG_NEEDS_SYSCALL_FOR_CMPXCHG)
2520 #ifndef CONFIG_MMU
2521 #warning "NPTL on non MMU needs fixing"
2522 #else
2523 @@ -414,7 +512,9 @@ __und_usr:
2524 tst r3, #PSR_T_BIT @ Thumb mode?
2525 bne __und_usr_thumb
2526 sub r4, r2, #4 @ ARM instr at LR - 4
2527 + pax_open_userland
2528 1: ldrt r0, [r4]
2529 + pax_close_userland
2530 #ifdef CONFIG_CPU_ENDIAN_BE8
2531 rev r0, r0 @ little endian instruction
2532 #endif
2533 @@ -449,10 +549,14 @@ __und_usr_thumb:
2534 */
2535 .arch armv6t2
2536 #endif
2537 + pax_open_userland
2538 2: ldrht r5, [r4]
2539 + pax_close_userland
2540 cmp r5, #0xe800 @ 32bit instruction if xx != 0
2541 blo __und_usr_fault_16 @ 16bit undefined instruction
2542 + pax_open_userland
2543 3: ldrht r0, [r2]
2544 + pax_close_userland
2545 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
2546 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
2547 orr r0, r0, r5, lsl #16
2548 @@ -481,7 +585,8 @@ ENDPROC(__und_usr)
2549 */
2550 .pushsection .fixup, "ax"
2551 .align 2
2552 -4: mov pc, r9
2553 +4: pax_close_userland
2554 + mov pc, r9
2555 .popsection
2556 .pushsection __ex_table,"a"
2557 .long 1b, 4b
2558 @@ -690,7 +795,7 @@ ENTRY(__switch_to)
2559 THUMB( stmia ip!, {r4 - sl, fp} ) @ Store most regs on stack
2560 THUMB( str sp, [ip], #4 )
2561 THUMB( str lr, [ip], #4 )
2562 -#ifdef CONFIG_CPU_USE_DOMAINS
2563 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2564 ldr r6, [r2, #TI_CPU_DOMAIN]
2565 #endif
2566 set_tls r3, r4, r5
2567 @@ -699,7 +804,7 @@ ENTRY(__switch_to)
2568 ldr r8, =__stack_chk_guard
2569 ldr r7, [r7, #TSK_STACK_CANARY]
2570 #endif
2571 -#ifdef CONFIG_CPU_USE_DOMAINS
2572 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2573 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
2574 #endif
2575 mov r5, r0
2576 diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2577 index bc5bc0a..d0998ca 100644
2578 --- a/arch/arm/kernel/entry-common.S
2579 +++ b/arch/arm/kernel/entry-common.S
2580 @@ -10,18 +10,46 @@
2581
2582 #include <asm/unistd.h>
2583 #include <asm/ftrace.h>
2584 +#include <asm/domain.h>
2585 #include <asm/unwind.h>
2586
2587 +#include "entry-header.S"
2588 +
2589 #ifdef CONFIG_NEED_RET_TO_USER
2590 #include <mach/entry-macro.S>
2591 #else
2592 .macro arch_ret_to_user, tmp1, tmp2
2593 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2594 + @ save regs
2595 + stmdb sp!, {r1, r2}
2596 + @ read DACR from cpu_domain into r1
2597 + mov r2, sp
2598 + @ assume 8K pages, since we have to split the immediate in two
2599 + bic r2, r2, #(0x1fc0)
2600 + bic r2, r2, #(0x3f)
2601 + ldr r1, [r2, #TI_CPU_DOMAIN]
2602 +#ifdef CONFIG_PAX_KERNEXEC
2603 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2604 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2605 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2606 +#endif
2607 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2608 + @ set current DOMAIN_USER to DOMAIN_UDEREF
2609 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2610 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2611 +#endif
2612 + @ write r1 to current_thread_info()->cpu_domain
2613 + str r1, [r2, #TI_CPU_DOMAIN]
2614 + @ write r1 to DACR
2615 + mcr p15, 0, r1, c3, c0, 0
2616 + @ instruction sync
2617 + instr_sync
2618 + @ restore regs
2619 + ldmia sp!, {r1, r2}
2620 +#endif
2621 .endm
2622 #endif
2623
2624 -#include "entry-header.S"
2625 -
2626 -
2627 .align 5
2628 /*
2629 * This is the fast syscall return path. We do as little as
2630 @@ -350,6 +378,7 @@ ENDPROC(ftrace_stub)
2631
2632 .align 5
2633 ENTRY(vector_swi)
2634 +
2635 sub sp, sp, #S_FRAME_SIZE
2636 stmia sp, {r0 - r12} @ Calling r0 - r12
2637 ARM( add r8, sp, #S_PC )
2638 @@ -399,6 +428,12 @@ ENTRY(vector_swi)
2639 ldr scno, [lr, #-4] @ get SWI instruction
2640 #endif
2641
2642 + /*
2643 + * do this here to avoid a performance hit of wrapping the code above
2644 + * that directly dereferences userland to parse the SWI instruction
2645 + */
2646 + pax_enter_kernel_user
2647 +
2648 #ifdef CONFIG_ALIGNMENT_TRAP
2649 ldr ip, __cr_alignment
2650 ldr ip, [ip]
2651 diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2652 index 160f337..db67ee4 100644
2653 --- a/arch/arm/kernel/entry-header.S
2654 +++ b/arch/arm/kernel/entry-header.S
2655 @@ -73,6 +73,60 @@
2656 msr cpsr_c, \rtemp @ switch back to the SVC mode
2657 .endm
2658
2659 + .macro pax_enter_kernel_user
2660 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2661 + @ save regs
2662 + stmdb sp!, {r0, r1}
2663 + @ read DACR from cpu_domain into r1
2664 + mov r0, sp
2665 + @ assume 8K pages, since we have to split the immediate in two
2666 + bic r0, r0, #(0x1fc0)
2667 + bic r0, r0, #(0x3f)
2668 + ldr r1, [r0, #TI_CPU_DOMAIN]
2669 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2670 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2671 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2672 +#endif
2673 +#ifdef CONFIG_PAX_KERNEXEC
2674 + @ set current DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2675 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2676 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2677 +#endif
2678 + @ write r1 to current_thread_info()->cpu_domain
2679 + str r1, [r0, #TI_CPU_DOMAIN]
2680 + @ write r1 to DACR
2681 + mcr p15, 0, r1, c3, c0, 0
2682 + @ instruction sync
2683 + instr_sync
2684 + @ restore regs
2685 + ldmia sp!, {r0, r1}
2686 +#endif
2687 + .endm
2688 +
2689 + .macro pax_exit_kernel
2690 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2691 + @ save regs
2692 + stmdb sp!, {r0, r1}
2693 + @ read old DACR from stack into r1
2694 + ldr r1, [sp, #(8 + S_SP)]
2695 + sub r1, r1, #8
2696 + ldr r1, [r1]
2697 +
2698 + @ write r1 to current_thread_info()->cpu_domain
2699 + mov r0, sp
2700 + @ assume 8K pages, since we have to split the immediate in two
2701 + bic r0, r0, #(0x1fc0)
2702 + bic r0, r0, #(0x3f)
2703 + str r1, [r0, #TI_CPU_DOMAIN]
2704 + @ write r1 to DACR
2705 + mcr p15, 0, r1, c3, c0, 0
2706 + @ instruction sync
2707 + instr_sync
2708 + @ restore regs
2709 + ldmia sp!, {r0, r1}
2710 +#endif
2711 + .endm
2712 +
2713 #ifndef CONFIG_THUMB2_KERNEL
2714 .macro svc_exit, rpsr, irq = 0
2715 .if \irq != 0
2716 @@ -92,6 +146,9 @@
2717 blne trace_hardirqs_off
2718 #endif
2719 .endif
2720 +
2721 + pax_exit_kernel
2722 +
2723 msr spsr_cxsf, \rpsr
2724 #if defined(CONFIG_CPU_V6)
2725 ldr r0, [sp]
2726 @@ -155,6 +212,9 @@
2727 blne trace_hardirqs_off
2728 #endif
2729 .endif
2730 +
2731 + pax_exit_kernel
2732 +
2733 ldr lr, [sp, #S_SP] @ top of the stack
2734 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
2735 clrex @ clear the exclusive monitor
2736 diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
2737 index 25442f4..d4948fc 100644
2738 --- a/arch/arm/kernel/fiq.c
2739 +++ b/arch/arm/kernel/fiq.c
2740 @@ -84,17 +84,16 @@ int show_fiq_list(struct seq_file *p, int prec)
2741
2742 void set_fiq_handler(void *start, unsigned int length)
2743 {
2744 -#if defined(CONFIG_CPU_USE_DOMAINS)
2745 - void *base = (void *)0xffff0000;
2746 -#else
2747 void *base = vectors_page;
2748 -#endif
2749 unsigned offset = FIQ_OFFSET;
2750
2751 + pax_open_kernel();
2752 memcpy(base + offset, start, length);
2753 + pax_close_kernel();
2754 +
2755 + if (!cache_is_vipt_nonaliasing())
2756 + flush_icache_range(base + offset, offset + length);
2757 flush_icache_range(0xffff0000 + offset, 0xffff0000 + offset + length);
2758 - if (!vectors_high())
2759 - flush_icache_range(offset, offset + length);
2760 }
2761
2762 int claim_fiq(struct fiq_handler *f)
2763 diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2764 index 8bac553..caee108 100644
2765 --- a/arch/arm/kernel/head.S
2766 +++ b/arch/arm/kernel/head.S
2767 @@ -52,7 +52,9 @@
2768 .equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE
2769
2770 .macro pgtbl, rd, phys
2771 - add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE
2772 + mov \rd, #TEXT_OFFSET
2773 + sub \rd, #PG_DIR_SIZE
2774 + add \rd, \rd, \phys
2775 .endm
2776
2777 /*
2778 @@ -434,7 +436,7 @@ __enable_mmu:
2779 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2780 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2781 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
2782 - domain_val(DOMAIN_IO, DOMAIN_CLIENT))
2783 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT))
2784 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
2785 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
2786 #endif
2787 diff --git a/arch/arm/kernel/hw_breakpoint.c b/arch/arm/kernel/hw_breakpoint.c
2788 index 1fd749e..47adb08 100644
2789 --- a/arch/arm/kernel/hw_breakpoint.c
2790 +++ b/arch/arm/kernel/hw_breakpoint.c
2791 @@ -1029,7 +1029,7 @@ static int __cpuinit dbg_reset_notify(struct notifier_block *self,
2792 return NOTIFY_OK;
2793 }
2794
2795 -static struct notifier_block __cpuinitdata dbg_reset_nb = {
2796 +static struct notifier_block dbg_reset_nb = {
2797 .notifier_call = dbg_reset_notify,
2798 };
2799
2800 diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
2801 index 1e9be5d..03edbc2 100644
2802 --- a/arch/arm/kernel/module.c
2803 +++ b/arch/arm/kernel/module.c
2804 @@ -37,12 +37,37 @@
2805 #endif
2806
2807 #ifdef CONFIG_MMU
2808 -void *module_alloc(unsigned long size)
2809 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2810 {
2811 + if (!size || PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR)
2812 + return NULL;
2813 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2814 - GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
2815 + GFP_KERNEL, prot, -1,
2816 __builtin_return_address(0));
2817 }
2818 +
2819 +void *module_alloc(unsigned long size)
2820 +{
2821 +
2822 +#ifdef CONFIG_PAX_KERNEXEC
2823 + return __module_alloc(size, PAGE_KERNEL);
2824 +#else
2825 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2826 +#endif
2827 +
2828 +}
2829 +
2830 +#ifdef CONFIG_PAX_KERNEXEC
2831 +void module_free_exec(struct module *mod, void *module_region)
2832 +{
2833 + module_free(mod, module_region);
2834 +}
2835 +
2836 +void *module_alloc_exec(unsigned long size)
2837 +{
2838 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2839 +}
2840 +#endif
2841 #endif
2842
2843 int
2844 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2845 index 07314af..c46655c 100644
2846 --- a/arch/arm/kernel/patch.c
2847 +++ b/arch/arm/kernel/patch.c
2848 @@ -18,6 +18,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2849 bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
2850 int size;
2851
2852 + pax_open_kernel();
2853 if (thumb2 && __opcode_is_thumb16(insn)) {
2854 *(u16 *)addr = __opcode_to_mem_thumb16(insn);
2855 size = sizeof(u16);
2856 @@ -39,6 +40,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2857 *(u32 *)addr = insn;
2858 size = sizeof(u32);
2859 }
2860 + pax_close_kernel();
2861
2862 flush_icache_range((uintptr_t)(addr),
2863 (uintptr_t)(addr) + size);
2864 diff --git a/arch/arm/kernel/perf_event.c b/arch/arm/kernel/perf_event.c
2865 index e19edc6..e186ee1 100644
2866 --- a/arch/arm/kernel/perf_event.c
2867 +++ b/arch/arm/kernel/perf_event.c
2868 @@ -56,7 +56,7 @@ armpmu_map_hw_event(const unsigned (*event_map)[PERF_COUNT_HW_MAX], u64 config)
2869 int mapping;
2870
2871 if (config >= PERF_COUNT_HW_MAX)
2872 - return -ENOENT;
2873 + return -EINVAL;
2874
2875 mapping = (*event_map)[config];
2876 return mapping == HW_OP_UNSUPPORTED ? -ENOENT : mapping;
2877 diff --git a/arch/arm/kernel/perf_event_cpu.c b/arch/arm/kernel/perf_event_cpu.c
2878 index 1f2740e..b36e225 100644
2879 --- a/arch/arm/kernel/perf_event_cpu.c
2880 +++ b/arch/arm/kernel/perf_event_cpu.c
2881 @@ -171,7 +171,7 @@ static int __cpuinit cpu_pmu_notify(struct notifier_block *b,
2882 return NOTIFY_OK;
2883 }
2884
2885 -static struct notifier_block __cpuinitdata cpu_pmu_hotplug_notifier = {
2886 +static struct notifier_block cpu_pmu_hotplug_notifier = {
2887 .notifier_call = cpu_pmu_notify,
2888 };
2889
2890 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2891 index 5bc2615..dcd439f 100644
2892 --- a/arch/arm/kernel/process.c
2893 +++ b/arch/arm/kernel/process.c
2894 @@ -223,6 +223,7 @@ void machine_power_off(void)
2895
2896 if (pm_power_off)
2897 pm_power_off();
2898 + BUG();
2899 }
2900
2901 /*
2902 @@ -236,7 +237,7 @@ void machine_power_off(void)
2903 * executing pre-reset code, and using RAM that the primary CPU's code wishes
2904 * to use. Implementing such co-ordination would be essentially impossible.
2905 */
2906 -void machine_restart(char *cmd)
2907 +__noreturn void machine_restart(char *cmd)
2908 {
2909 smp_send_stop();
2910
2911 @@ -258,8 +259,8 @@ void __show_regs(struct pt_regs *regs)
2912
2913 show_regs_print_info(KERN_DEFAULT);
2914
2915 - print_symbol("PC is at %s\n", instruction_pointer(regs));
2916 - print_symbol("LR is at %s\n", regs->ARM_lr);
2917 + printk("PC is at %pA\n", (void *)instruction_pointer(regs));
2918 + printk("LR is at %pA\n", (void *)regs->ARM_lr);
2919 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2920 "sp : %08lx ip : %08lx fp : %08lx\n",
2921 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2922 @@ -426,12 +427,6 @@ unsigned long get_wchan(struct task_struct *p)
2923 return 0;
2924 }
2925
2926 -unsigned long arch_randomize_brk(struct mm_struct *mm)
2927 -{
2928 - unsigned long range_end = mm->brk + 0x02000000;
2929 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2930 -}
2931 -
2932 #ifdef CONFIG_MMU
2933 #ifdef CONFIG_KUSER_HELPERS
2934 /*
2935 @@ -447,7 +442,7 @@ static struct vm_area_struct gate_vma = {
2936
2937 static int __init gate_vma_init(void)
2938 {
2939 - gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2940 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2941 return 0;
2942 }
2943 arch_initcall(gate_vma_init);
2944 @@ -466,48 +461,23 @@ int in_gate_area_no_mm(unsigned long addr)
2945 {
2946 return in_gate_area(NULL, addr);
2947 }
2948 -#define is_gate_vma(vma) ((vma) = &gate_vma)
2949 +#define is_gate_vma(vma) ((vma) == &gate_vma)
2950 #else
2951 #define is_gate_vma(vma) 0
2952 #endif
2953
2954 const char *arch_vma_name(struct vm_area_struct *vma)
2955 {
2956 - return is_gate_vma(vma) ? "[vectors]" :
2957 - (vma->vm_mm && vma->vm_start == vma->vm_mm->context.sigpage) ?
2958 - "[sigpage]" : NULL;
2959 + return is_gate_vma(vma) ? "[vectors]" : NULL;
2960 }
2961
2962 -static struct page *signal_page;
2963 -extern struct page *get_signal_page(void);
2964 -
2965 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
2966 {
2967 struct mm_struct *mm = current->mm;
2968 - unsigned long addr;
2969 - int ret;
2970 -
2971 - if (!signal_page)
2972 - signal_page = get_signal_page();
2973 - if (!signal_page)
2974 - return -ENOMEM;
2975
2976 down_write(&mm->mmap_sem);
2977 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
2978 - if (IS_ERR_VALUE(addr)) {
2979 - ret = addr;
2980 - goto up_fail;
2981 - }
2982 -
2983 - ret = install_special_mapping(mm, addr, PAGE_SIZE,
2984 - VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC,
2985 - &signal_page);
2986 -
2987 - if (ret == 0)
2988 - mm->context.sigpage = addr;
2989 -
2990 - up_fail:
2991 + mm->context.sigpage = (PAGE_OFFSET + (get_random_int() % 0x3FFEFFE0)) & 0xFFFFFFFC;
2992 up_write(&mm->mmap_sem);
2993 - return ret;
2994 + return 0;
2995 }
2996 #endif
2997 diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
2998 index 3653164..d83e55d 100644
2999 --- a/arch/arm/kernel/psci.c
3000 +++ b/arch/arm/kernel/psci.c
3001 @@ -24,7 +24,7 @@
3002 #include <asm/opcodes-virt.h>
3003 #include <asm/psci.h>
3004
3005 -struct psci_operations psci_ops;
3006 +struct psci_operations psci_ops __read_only;
3007
3008 static int (*invoke_psci_fn)(u32, u32, u32, u32);
3009
3010 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
3011 index 03deeff..741ce88 100644
3012 --- a/arch/arm/kernel/ptrace.c
3013 +++ b/arch/arm/kernel/ptrace.c
3014 @@ -937,10 +937,19 @@ static int tracehook_report_syscall(struct pt_regs *regs,
3015 return current_thread_info()->syscall;
3016 }
3017
3018 +#ifdef CONFIG_GRKERNSEC_SETXID
3019 +extern void gr_delayed_cred_worker(void);
3020 +#endif
3021 +
3022 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
3023 {
3024 current_thread_info()->syscall = scno;
3025
3026 +#ifdef CONFIG_GRKERNSEC_SETXID
3027 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
3028 + gr_delayed_cred_worker();
3029 +#endif
3030 +
3031 /* Do the secure computing check first; failures should be fast. */
3032 if (secure_computing(scno) == -1)
3033 return -1;
3034 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
3035 index b4b1d39..efdc9be 100644
3036 --- a/arch/arm/kernel/setup.c
3037 +++ b/arch/arm/kernel/setup.c
3038 @@ -97,21 +97,23 @@ EXPORT_SYMBOL(system_serial_high);
3039 unsigned int elf_hwcap __read_mostly;
3040 EXPORT_SYMBOL(elf_hwcap);
3041
3042 +pteval_t __supported_pte_mask __read_only;
3043 +pmdval_t __supported_pmd_mask __read_only;
3044
3045 #ifdef MULTI_CPU
3046 -struct processor processor __read_mostly;
3047 +struct processor processor;
3048 #endif
3049 #ifdef MULTI_TLB
3050 -struct cpu_tlb_fns cpu_tlb __read_mostly;
3051 +struct cpu_tlb_fns cpu_tlb __read_only;
3052 #endif
3053 #ifdef MULTI_USER
3054 -struct cpu_user_fns cpu_user __read_mostly;
3055 +struct cpu_user_fns cpu_user __read_only;
3056 #endif
3057 #ifdef MULTI_CACHE
3058 -struct cpu_cache_fns cpu_cache __read_mostly;
3059 +struct cpu_cache_fns cpu_cache __read_only;
3060 #endif
3061 #ifdef CONFIG_OUTER_CACHE
3062 -struct outer_cache_fns outer_cache __read_mostly;
3063 +struct outer_cache_fns outer_cache __read_only;
3064 EXPORT_SYMBOL(outer_cache);
3065 #endif
3066
3067 @@ -236,9 +238,13 @@ static int __get_cpu_architecture(void)
3068 asm("mrc p15, 0, %0, c0, c1, 4"
3069 : "=r" (mmfr0));
3070 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
3071 - (mmfr0 & 0x000000f0) >= 0x00000030)
3072 + (mmfr0 & 0x000000f0) >= 0x00000030) {
3073 cpu_arch = CPU_ARCH_ARMv7;
3074 - else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3075 + if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
3076 + __supported_pte_mask |= L_PTE_PXN;
3077 + __supported_pmd_mask |= PMD_PXNTABLE;
3078 + }
3079 + } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3080 (mmfr0 & 0x000000f0) == 0x00000020)
3081 cpu_arch = CPU_ARCH_ARMv6;
3082 else
3083 @@ -479,7 +485,7 @@ static void __init setup_processor(void)
3084 __cpu_architecture = __get_cpu_architecture();
3085
3086 #ifdef MULTI_CPU
3087 - processor = *list->proc;
3088 + memcpy((void *)&processor, list->proc, sizeof processor);
3089 #endif
3090 #ifdef MULTI_TLB
3091 cpu_tlb = *list->tlb;
3092 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
3093 index 5a42c12..a2bb7c6 100644
3094 --- a/arch/arm/kernel/signal.c
3095 +++ b/arch/arm/kernel/signal.c
3096 @@ -45,8 +45,6 @@ static const unsigned long sigreturn_codes[7] = {
3097 MOV_R7_NR_RT_SIGRETURN, SWI_SYS_RT_SIGRETURN, SWI_THUMB_RT_SIGRETURN,
3098 };
3099
3100 -static unsigned long signal_return_offset;
3101 -
3102 #ifdef CONFIG_CRUNCH
3103 static int preserve_crunch_context(struct crunch_sigframe __user *frame)
3104 {
3105 @@ -406,8 +404,7 @@ setup_return(struct pt_regs *regs, struct ksignal *ksig,
3106 * except when the MPU has protected the vectors
3107 * page from PL0
3108 */
3109 - retcode = mm->context.sigpage + signal_return_offset +
3110 - (idx << 2) + thumb;
3111 + retcode = mm->context.sigpage + (idx << 2) + thumb;
3112 } else
3113 #endif
3114 {
3115 @@ -611,33 +608,3 @@ do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall)
3116 } while (thread_flags & _TIF_WORK_MASK);
3117 return 0;
3118 }
3119 -
3120 -struct page *get_signal_page(void)
3121 -{
3122 - unsigned long ptr;
3123 - unsigned offset;
3124 - struct page *page;
3125 - void *addr;
3126 -
3127 - page = alloc_pages(GFP_KERNEL, 0);
3128 -
3129 - if (!page)
3130 - return NULL;
3131 -
3132 - addr = page_address(page);
3133 -
3134 - /* Give the signal return code some randomness */
3135 - offset = 0x200 + (get_random_int() & 0x7fc);
3136 - signal_return_offset = offset;
3137 -
3138 - /*
3139 - * Copy signal return handlers into the vector page, and
3140 - * set sigreturn to be a pointer to these.
3141 - */
3142 - memcpy(addr + offset, sigreturn_codes, sizeof(sigreturn_codes));
3143 -
3144 - ptr = (unsigned long)addr + offset;
3145 - flush_icache_range(ptr, ptr + sizeof(sigreturn_codes));
3146 -
3147 - return page;
3148 -}
3149 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
3150 index 5919eb4..b5d6dfe 100644
3151 --- a/arch/arm/kernel/smp.c
3152 +++ b/arch/arm/kernel/smp.c
3153 @@ -70,7 +70,7 @@ enum ipi_msg_type {
3154
3155 static DECLARE_COMPLETION(cpu_running);
3156
3157 -static struct smp_operations smp_ops;
3158 +static struct smp_operations smp_ops __read_only;
3159
3160 void __init smp_set_ops(struct smp_operations *ops)
3161 {
3162 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
3163 index 6b9567e..b8af2d6 100644
3164 --- a/arch/arm/kernel/traps.c
3165 +++ b/arch/arm/kernel/traps.c
3166 @@ -55,7 +55,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
3167 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
3168 {
3169 #ifdef CONFIG_KALLSYMS
3170 - printk("[<%08lx>] (%pS) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
3171 + printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
3172 #else
3173 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
3174 #endif
3175 @@ -257,6 +257,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
3176 static int die_owner = -1;
3177 static unsigned int die_nest_count;
3178
3179 +extern void gr_handle_kernel_exploit(void);
3180 +
3181 static unsigned long oops_begin(void)
3182 {
3183 int cpu;
3184 @@ -299,6 +301,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3185 panic("Fatal exception in interrupt");
3186 if (panic_on_oops)
3187 panic("Fatal exception");
3188 +
3189 + gr_handle_kernel_exploit();
3190 +
3191 if (signr)
3192 do_exit(signr);
3193 }
3194 @@ -592,7 +597,9 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
3195 * The user helper at 0xffff0fe0 must be used instead.
3196 * (see entry-armv.S for details)
3197 */
3198 + pax_open_kernel();
3199 *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
3200 + pax_close_kernel();
3201 }
3202 return 0;
3203
3204 @@ -848,5 +855,9 @@ void __init early_trap_init(void *vectors_base)
3205 kuser_init(vectors_base);
3206
3207 flush_icache_range(vectors, vectors + PAGE_SIZE * 2);
3208 - modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3209 +
3210 +#ifndef CONFIG_PAX_MEMORY_UDEREF
3211 + modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3212 +#endif
3213 +
3214 }
3215 diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3216 index 33f2ea3..0b91824 100644
3217 --- a/arch/arm/kernel/vmlinux.lds.S
3218 +++ b/arch/arm/kernel/vmlinux.lds.S
3219 @@ -8,7 +8,11 @@
3220 #include <asm/thread_info.h>
3221 #include <asm/memory.h>
3222 #include <asm/page.h>
3223 -
3224 +
3225 +#ifdef CONFIG_PAX_KERNEXEC
3226 +#include <asm/pgtable.h>
3227 +#endif
3228 +
3229 #define PROC_INFO \
3230 . = ALIGN(4); \
3231 VMLINUX_SYMBOL(__proc_info_begin) = .; \
3232 @@ -94,6 +98,11 @@ SECTIONS
3233 _text = .;
3234 HEAD_TEXT
3235 }
3236 +
3237 +#ifdef CONFIG_PAX_KERNEXEC
3238 + . = ALIGN(1<<SECTION_SHIFT);
3239 +#endif
3240 +
3241 .text : { /* Real text segment */
3242 _stext = .; /* Text and read-only data */
3243 __exception_text_start = .;
3244 @@ -116,6 +125,8 @@ SECTIONS
3245 ARM_CPU_KEEP(PROC_INFO)
3246 }
3247
3248 + _etext = .; /* End of text section */
3249 +
3250 RO_DATA(PAGE_SIZE)
3251
3252 . = ALIGN(4);
3253 @@ -146,7 +157,9 @@ SECTIONS
3254
3255 NOTES
3256
3257 - _etext = .; /* End of text and rodata section */
3258 +#ifdef CONFIG_PAX_KERNEXEC
3259 + . = ALIGN(1<<SECTION_SHIFT);
3260 +#endif
3261
3262 #ifndef CONFIG_XIP_KERNEL
3263 . = ALIGN(PAGE_SIZE);
3264 @@ -224,6 +237,11 @@ SECTIONS
3265 . = PAGE_OFFSET + TEXT_OFFSET;
3266 #else
3267 __init_end = .;
3268 +
3269 +#ifdef CONFIG_PAX_KERNEXEC
3270 + . = ALIGN(1<<SECTION_SHIFT);
3271 +#endif
3272 +
3273 . = ALIGN(THREAD_SIZE);
3274 __data_loc = .;
3275 #endif
3276 diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3277 index 14a0d98..7771a7d 100644
3278 --- a/arch/arm/lib/clear_user.S
3279 +++ b/arch/arm/lib/clear_user.S
3280 @@ -12,14 +12,14 @@
3281
3282 .text
3283
3284 -/* Prototype: int __clear_user(void *addr, size_t sz)
3285 +/* Prototype: int ___clear_user(void *addr, size_t sz)
3286 * Purpose : clear some user memory
3287 * Params : addr - user memory address to clear
3288 * : sz - number of bytes to clear
3289 * Returns : number of bytes NOT cleared
3290 */
3291 ENTRY(__clear_user_std)
3292 -WEAK(__clear_user)
3293 +WEAK(___clear_user)
3294 stmfd sp!, {r1, lr}
3295 mov r2, #0
3296 cmp r1, #4
3297 @@ -44,7 +44,7 @@ WEAK(__clear_user)
3298 USER( strnebt r2, [r0])
3299 mov r0, #0
3300 ldmfd sp!, {r1, pc}
3301 -ENDPROC(__clear_user)
3302 +ENDPROC(___clear_user)
3303 ENDPROC(__clear_user_std)
3304
3305 .pushsection .fixup,"ax"
3306 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3307 index 66a477a..bee61d3 100644
3308 --- a/arch/arm/lib/copy_from_user.S
3309 +++ b/arch/arm/lib/copy_from_user.S
3310 @@ -16,7 +16,7 @@
3311 /*
3312 * Prototype:
3313 *
3314 - * size_t __copy_from_user(void *to, const void *from, size_t n)
3315 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
3316 *
3317 * Purpose:
3318 *
3319 @@ -84,11 +84,11 @@
3320
3321 .text
3322
3323 -ENTRY(__copy_from_user)
3324 +ENTRY(___copy_from_user)
3325
3326 #include "copy_template.S"
3327
3328 -ENDPROC(__copy_from_user)
3329 +ENDPROC(___copy_from_user)
3330
3331 .pushsection .fixup,"ax"
3332 .align 0
3333 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3334 index 6ee2f67..d1cce76 100644
3335 --- a/arch/arm/lib/copy_page.S
3336 +++ b/arch/arm/lib/copy_page.S
3337 @@ -10,6 +10,7 @@
3338 * ASM optimised string functions
3339 */
3340 #include <linux/linkage.h>
3341 +#include <linux/const.h>
3342 #include <asm/assembler.h>
3343 #include <asm/asm-offsets.h>
3344 #include <asm/cache.h>
3345 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3346 index d066df6..df28194 100644
3347 --- a/arch/arm/lib/copy_to_user.S
3348 +++ b/arch/arm/lib/copy_to_user.S
3349 @@ -16,7 +16,7 @@
3350 /*
3351 * Prototype:
3352 *
3353 - * size_t __copy_to_user(void *to, const void *from, size_t n)
3354 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
3355 *
3356 * Purpose:
3357 *
3358 @@ -88,11 +88,11 @@
3359 .text
3360
3361 ENTRY(__copy_to_user_std)
3362 -WEAK(__copy_to_user)
3363 +WEAK(___copy_to_user)
3364
3365 #include "copy_template.S"
3366
3367 -ENDPROC(__copy_to_user)
3368 +ENDPROC(___copy_to_user)
3369 ENDPROC(__copy_to_user_std)
3370
3371 .pushsection .fixup,"ax"
3372 diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3373 index 7d08b43..f7ca7ea 100644
3374 --- a/arch/arm/lib/csumpartialcopyuser.S
3375 +++ b/arch/arm/lib/csumpartialcopyuser.S
3376 @@ -57,8 +57,8 @@
3377 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3378 */
3379
3380 -#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3381 -#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3382 +#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3383 +#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3384
3385 #include "csumpartialcopygeneric.S"
3386
3387 diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3388 index 64dbfa5..84a3fd9 100644
3389 --- a/arch/arm/lib/delay.c
3390 +++ b/arch/arm/lib/delay.c
3391 @@ -28,7 +28,7 @@
3392 /*
3393 * Default to the loop-based delay implementation.
3394 */
3395 -struct arm_delay_ops arm_delay_ops = {
3396 +struct arm_delay_ops arm_delay_ops __read_only = {
3397 .delay = __loop_delay,
3398 .const_udelay = __loop_const_udelay,
3399 .udelay = __loop_udelay,
3400 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3401 index 025f742..8432b08 100644
3402 --- a/arch/arm/lib/uaccess_with_memcpy.c
3403 +++ b/arch/arm/lib/uaccess_with_memcpy.c
3404 @@ -104,7 +104,7 @@ out:
3405 }
3406
3407 unsigned long
3408 -__copy_to_user(void __user *to, const void *from, unsigned long n)
3409 +___copy_to_user(void __user *to, const void *from, unsigned long n)
3410 {
3411 /*
3412 * This test is stubbed out of the main function above to keep
3413 diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
3414 index f389228..592ef66 100644
3415 --- a/arch/arm/mach-kirkwood/common.c
3416 +++ b/arch/arm/mach-kirkwood/common.c
3417 @@ -149,7 +149,16 @@ static void clk_gate_fn_disable(struct clk_hw *hw)
3418 clk_gate_ops.disable(hw);
3419 }
3420
3421 -static struct clk_ops clk_gate_fn_ops;
3422 +static int clk_gate_fn_is_enabled(struct clk_hw *hw)
3423 +{
3424 + return clk_gate_ops.is_enabled(hw);
3425 +}
3426 +
3427 +static struct clk_ops clk_gate_fn_ops = {
3428 + .enable = clk_gate_fn_enable,
3429 + .disable = clk_gate_fn_disable,
3430 + .is_enabled = clk_gate_fn_is_enabled,
3431 +};
3432
3433 static struct clk __init *clk_register_gate_fn(struct device *dev,
3434 const char *name,
3435 @@ -183,14 +192,6 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
3436 gate_fn->fn_en = fn_en;
3437 gate_fn->fn_dis = fn_dis;
3438
3439 - /* ops is the gate ops, but with our enable/disable functions */
3440 - if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
3441 - clk_gate_fn_ops.disable != clk_gate_fn_disable) {
3442 - clk_gate_fn_ops = clk_gate_ops;
3443 - clk_gate_fn_ops.enable = clk_gate_fn_enable;
3444 - clk_gate_fn_ops.disable = clk_gate_fn_disable;
3445 - }
3446 -
3447 clk = clk_register(dev, &gate_fn->gate.hw);
3448
3449 if (IS_ERR(clk))
3450 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3451 index f6eeb87..cc90868 100644
3452 --- a/arch/arm/mach-omap2/board-n8x0.c
3453 +++ b/arch/arm/mach-omap2/board-n8x0.c
3454 @@ -631,7 +631,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3455 }
3456 #endif
3457
3458 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3459 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3460 .late_init = n8x0_menelaus_late_init,
3461 };
3462
3463 diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
3464 index 6c4da12..d9ca72d 100644
3465 --- a/arch/arm/mach-omap2/gpmc.c
3466 +++ b/arch/arm/mach-omap2/gpmc.c
3467 @@ -147,7 +147,6 @@ struct omap3_gpmc_regs {
3468 };
3469
3470 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
3471 -static struct irq_chip gpmc_irq_chip;
3472 static unsigned gpmc_irq_start;
3473
3474 static struct resource gpmc_mem_root;
3475 @@ -711,6 +710,18 @@ static void gpmc_irq_noop(struct irq_data *data) { }
3476
3477 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
3478
3479 +static struct irq_chip gpmc_irq_chip = {
3480 + .name = "gpmc",
3481 + .irq_startup = gpmc_irq_noop_ret,
3482 + .irq_enable = gpmc_irq_enable,
3483 + .irq_disable = gpmc_irq_disable,
3484 + .irq_shutdown = gpmc_irq_noop,
3485 + .irq_ack = gpmc_irq_noop,
3486 + .irq_mask = gpmc_irq_noop,
3487 + .irq_unmask = gpmc_irq_noop,
3488 +
3489 +};
3490 +
3491 static int gpmc_setup_irq(void)
3492 {
3493 int i;
3494 @@ -725,15 +736,6 @@ static int gpmc_setup_irq(void)
3495 return gpmc_irq_start;
3496 }
3497
3498 - gpmc_irq_chip.name = "gpmc";
3499 - gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
3500 - gpmc_irq_chip.irq_enable = gpmc_irq_enable;
3501 - gpmc_irq_chip.irq_disable = gpmc_irq_disable;
3502 - gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
3503 - gpmc_irq_chip.irq_ack = gpmc_irq_noop;
3504 - gpmc_irq_chip.irq_mask = gpmc_irq_noop;
3505 - gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
3506 -
3507 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
3508 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
3509
3510 diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3511 index f8bb3b9..831e7b8 100644
3512 --- a/arch/arm/mach-omap2/omap-wakeupgen.c
3513 +++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3514 @@ -339,7 +339,7 @@ static int __cpuinit irq_cpu_hotplug_notify(struct notifier_block *self,
3515 return NOTIFY_OK;
3516 }
3517
3518 -static struct notifier_block __refdata irq_hotplug_notifier = {
3519 +static struct notifier_block irq_hotplug_notifier = {
3520 .notifier_call = irq_cpu_hotplug_notify,
3521 };
3522
3523 diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3524 index e6d2307..d057195 100644
3525 --- a/arch/arm/mach-omap2/omap_device.c
3526 +++ b/arch/arm/mach-omap2/omap_device.c
3527 @@ -499,7 +499,7 @@ void omap_device_delete(struct omap_device *od)
3528 struct platform_device __init *omap_device_build(const char *pdev_name,
3529 int pdev_id,
3530 struct omap_hwmod *oh,
3531 - void *pdata, int pdata_len)
3532 + const void *pdata, int pdata_len)
3533 {
3534 struct omap_hwmod *ohs[] = { oh };
3535
3536 @@ -527,7 +527,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name,
3537 struct platform_device __init *omap_device_build_ss(const char *pdev_name,
3538 int pdev_id,
3539 struct omap_hwmod **ohs,
3540 - int oh_cnt, void *pdata,
3541 + int oh_cnt, const void *pdata,
3542 int pdata_len)
3543 {
3544 int ret = -ENOMEM;
3545 diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3546 index 044c31d..2ee0861 100644
3547 --- a/arch/arm/mach-omap2/omap_device.h
3548 +++ b/arch/arm/mach-omap2/omap_device.h
3549 @@ -72,12 +72,12 @@ int omap_device_idle(struct platform_device *pdev);
3550 /* Core code interface */
3551
3552 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3553 - struct omap_hwmod *oh, void *pdata,
3554 + struct omap_hwmod *oh, const void *pdata,
3555 int pdata_len);
3556
3557 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3558 struct omap_hwmod **oh, int oh_cnt,
3559 - void *pdata, int pdata_len);
3560 + const void *pdata, int pdata_len);
3561
3562 struct omap_device *omap_device_alloc(struct platform_device *pdev,
3563 struct omap_hwmod **ohs, int oh_cnt);
3564 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3565 index 7341eff..fd75e34 100644
3566 --- a/arch/arm/mach-omap2/omap_hwmod.c
3567 +++ b/arch/arm/mach-omap2/omap_hwmod.c
3568 @@ -194,10 +194,10 @@ struct omap_hwmod_soc_ops {
3569 int (*init_clkdm)(struct omap_hwmod *oh);
3570 void (*update_context_lost)(struct omap_hwmod *oh);
3571 int (*get_context_lost)(struct omap_hwmod *oh);
3572 -};
3573 +} __no_const;
3574
3575 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3576 -static struct omap_hwmod_soc_ops soc_ops;
3577 +static struct omap_hwmod_soc_ops soc_ops __read_only;
3578
3579 /* omap_hwmod_list contains all registered struct omap_hwmods */
3580 static LIST_HEAD(omap_hwmod_list);
3581 diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3582 index d15c7bb..b2d1f0c 100644
3583 --- a/arch/arm/mach-omap2/wd_timer.c
3584 +++ b/arch/arm/mach-omap2/wd_timer.c
3585 @@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3586 struct omap_hwmod *oh;
3587 char *oh_name = "wd_timer2";
3588 char *dev_name = "omap_wdt";
3589 - struct omap_wd_timer_platform_data pdata;
3590 + static struct omap_wd_timer_platform_data pdata = {
3591 + .read_reset_sources = prm_read_reset_sources
3592 + };
3593
3594 if (!cpu_class_is_omap2() || of_have_populated_dt())
3595 return 0;
3596 @@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3597 return -EINVAL;
3598 }
3599
3600 - pdata.read_reset_sources = prm_read_reset_sources;
3601 -
3602 pdev = omap_device_build(dev_name, id, oh, &pdata,
3603 sizeof(struct omap_wd_timer_platform_data));
3604 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
3605 diff --git a/arch/arm/mach-tegra/cpuidle-tegra20.c b/arch/arm/mach-tegra/cpuidle-tegra20.c
3606 index 0cdba8d..297993e 100644
3607 --- a/arch/arm/mach-tegra/cpuidle-tegra20.c
3608 +++ b/arch/arm/mach-tegra/cpuidle-tegra20.c
3609 @@ -181,7 +181,7 @@ static int tegra20_idle_lp2_coupled(struct cpuidle_device *dev,
3610 bool entered_lp2 = false;
3611
3612 if (tegra_pending_sgi())
3613 - ACCESS_ONCE(abort_flag) = true;
3614 + ACCESS_ONCE_RW(abort_flag) = true;
3615
3616 cpuidle_coupled_parallel_barrier(dev, &abort_barrier);
3617
3618 diff --git a/arch/arm/mach-ux500/setup.h b/arch/arm/mach-ux500/setup.h
3619 index cad3ca86..1d79e0f 100644
3620 --- a/arch/arm/mach-ux500/setup.h
3621 +++ b/arch/arm/mach-ux500/setup.h
3622 @@ -37,13 +37,6 @@ extern void ux500_timer_init(void);
3623 .type = MT_DEVICE, \
3624 }
3625
3626 -#define __MEM_DEV_DESC(x, sz) { \
3627 - .virtual = IO_ADDRESS(x), \
3628 - .pfn = __phys_to_pfn(x), \
3629 - .length = sz, \
3630 - .type = MT_MEMORY, \
3631 -}
3632 -
3633 extern struct smp_operations ux500_smp_ops;
3634 extern void ux500_cpu_die(unsigned int cpu);
3635
3636 diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3637 index 2950082..d0f0782 100644
3638 --- a/arch/arm/mm/Kconfig
3639 +++ b/arch/arm/mm/Kconfig
3640 @@ -436,7 +436,7 @@ config CPU_32v5
3641
3642 config CPU_32v6
3643 bool
3644 - select CPU_USE_DOMAINS if CPU_V6 && MMU
3645 + select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3646 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3647
3648 config CPU_32v6K
3649 @@ -585,6 +585,7 @@ config CPU_CP15_MPU
3650
3651 config CPU_USE_DOMAINS
3652 bool
3653 + depends on !ARM_LPAE && !PAX_KERNEXEC
3654 help
3655 This option enables or disables the use of domain switching
3656 via the set_fs() function.
3657 @@ -780,6 +781,7 @@ config NEED_KUSER_HELPERS
3658 config KUSER_HELPERS
3659 bool "Enable kuser helpers in vector page" if !NEED_KUSER_HELPERS
3660 default y
3661 + depends on !(CPU_V6 || CPU_V6K || CPU_V7)
3662 help
3663 Warning: disabling this option may break user programs.
3664
3665 @@ -790,7 +792,7 @@ config KUSER_HELPERS
3666 run on ARMv4 through to ARMv7 without modification.
3667
3668 However, the fixed address nature of these helpers can be used
3669 - by ROP (return orientated programming) authors when creating
3670 + by ROP (Return Oriented Programming) authors when creating
3671 exploits.
3672
3673 If all of the binaries and libraries which run on your platform
3674 diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3675 index 6f4585b..7b6f52b 100644
3676 --- a/arch/arm/mm/alignment.c
3677 +++ b/arch/arm/mm/alignment.c
3678 @@ -211,10 +211,12 @@ union offset_union {
3679 #define __get16_unaligned_check(ins,val,addr) \
3680 do { \
3681 unsigned int err = 0, v, a = addr; \
3682 + pax_open_userland(); \
3683 __get8_unaligned_check(ins,v,a,err); \
3684 val = v << ((BE) ? 8 : 0); \
3685 __get8_unaligned_check(ins,v,a,err); \
3686 val |= v << ((BE) ? 0 : 8); \
3687 + pax_close_userland(); \
3688 if (err) \
3689 goto fault; \
3690 } while (0)
3691 @@ -228,6 +230,7 @@ union offset_union {
3692 #define __get32_unaligned_check(ins,val,addr) \
3693 do { \
3694 unsigned int err = 0, v, a = addr; \
3695 + pax_open_userland(); \
3696 __get8_unaligned_check(ins,v,a,err); \
3697 val = v << ((BE) ? 24 : 0); \
3698 __get8_unaligned_check(ins,v,a,err); \
3699 @@ -236,6 +239,7 @@ union offset_union {
3700 val |= v << ((BE) ? 8 : 16); \
3701 __get8_unaligned_check(ins,v,a,err); \
3702 val |= v << ((BE) ? 0 : 24); \
3703 + pax_close_userland(); \
3704 if (err) \
3705 goto fault; \
3706 } while (0)
3707 @@ -249,6 +253,7 @@ union offset_union {
3708 #define __put16_unaligned_check(ins,val,addr) \
3709 do { \
3710 unsigned int err = 0, v = val, a = addr; \
3711 + pax_open_userland(); \
3712 __asm__( FIRST_BYTE_16 \
3713 ARM( "1: "ins" %1, [%2], #1\n" ) \
3714 THUMB( "1: "ins" %1, [%2]\n" ) \
3715 @@ -268,6 +273,7 @@ union offset_union {
3716 " .popsection\n" \
3717 : "=r" (err), "=&r" (v), "=&r" (a) \
3718 : "0" (err), "1" (v), "2" (a)); \
3719 + pax_close_userland(); \
3720 if (err) \
3721 goto fault; \
3722 } while (0)
3723 @@ -281,6 +287,7 @@ union offset_union {
3724 #define __put32_unaligned_check(ins,val,addr) \
3725 do { \
3726 unsigned int err = 0, v = val, a = addr; \
3727 + pax_open_userland(); \
3728 __asm__( FIRST_BYTE_32 \
3729 ARM( "1: "ins" %1, [%2], #1\n" ) \
3730 THUMB( "1: "ins" %1, [%2]\n" ) \
3731 @@ -310,6 +317,7 @@ union offset_union {
3732 " .popsection\n" \
3733 : "=r" (err), "=&r" (v), "=&r" (a) \
3734 : "0" (err), "1" (v), "2" (a)); \
3735 + pax_close_userland(); \
3736 if (err) \
3737 goto fault; \
3738 } while (0)
3739 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
3740 index 5dbf13f..ee1ec24 100644
3741 --- a/arch/arm/mm/fault.c
3742 +++ b/arch/arm/mm/fault.c
3743 @@ -25,6 +25,7 @@
3744 #include <asm/system_misc.h>
3745 #include <asm/system_info.h>
3746 #include <asm/tlbflush.h>
3747 +#include <asm/sections.h>
3748
3749 #include "fault.h"
3750
3751 @@ -138,6 +139,20 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
3752 if (fixup_exception(regs))
3753 return;
3754
3755 +#ifdef CONFIG_PAX_KERNEXEC
3756 + if ((fsr & FSR_WRITE) &&
3757 + (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
3758 + (MODULES_VADDR <= addr && addr < MODULES_END)))
3759 + {
3760 + if (current->signal->curr_ip)
3761 + 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),
3762 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3763 + else
3764 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
3765 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3766 + }
3767 +#endif
3768 +
3769 /*
3770 * No handler, we'll have to terminate things with extreme prejudice.
3771 */
3772 @@ -174,6 +189,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
3773 }
3774 #endif
3775
3776 +#ifdef CONFIG_PAX_PAGEEXEC
3777 + if (fsr & FSR_LNX_PF) {
3778 + pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
3779 + do_group_exit(SIGKILL);
3780 + }
3781 +#endif
3782 +
3783 tsk->thread.address = addr;
3784 tsk->thread.error_code = fsr;
3785 tsk->thread.trap_no = 14;
3786 @@ -398,6 +420,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3787 }
3788 #endif /* CONFIG_MMU */
3789
3790 +#ifdef CONFIG_PAX_PAGEEXEC
3791 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3792 +{
3793 + long i;
3794 +
3795 + printk(KERN_ERR "PAX: bytes at PC: ");
3796 + for (i = 0; i < 20; i++) {
3797 + unsigned char c;
3798 + if (get_user(c, (__force unsigned char __user *)pc+i))
3799 + printk(KERN_CONT "?? ");
3800 + else
3801 + printk(KERN_CONT "%02x ", c);
3802 + }
3803 + printk("\n");
3804 +
3805 + printk(KERN_ERR "PAX: bytes at SP-4: ");
3806 + for (i = -1; i < 20; i++) {
3807 + unsigned long c;
3808 + if (get_user(c, (__force unsigned long __user *)sp+i))
3809 + printk(KERN_CONT "???????? ");
3810 + else
3811 + printk(KERN_CONT "%08lx ", c);
3812 + }
3813 + printk("\n");
3814 +}
3815 +#endif
3816 +
3817 /*
3818 * First Level Translation Fault Handler
3819 *
3820 @@ -543,9 +592,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3821 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
3822 struct siginfo info;
3823
3824 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3825 + if (addr < TASK_SIZE && is_domain_fault(fsr)) {
3826 + if (current->signal->curr_ip)
3827 + 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),
3828 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3829 + else
3830 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3831 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3832 + goto die;
3833 + }
3834 +#endif
3835 +
3836 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
3837 return;
3838
3839 +die:
3840 printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
3841 inf->name, fsr, addr);
3842
3843 @@ -569,15 +631,67 @@ hook_ifault_code(int nr, int (*fn)(unsigned long, unsigned int, struct pt_regs *
3844 ifsr_info[nr].name = name;
3845 }
3846
3847 +asmlinkage int sys_sigreturn(struct pt_regs *regs);
3848 +asmlinkage int sys_rt_sigreturn(struct pt_regs *regs);
3849 +
3850 asmlinkage void __exception
3851 do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
3852 {
3853 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
3854 struct siginfo info;
3855
3856 + if (user_mode(regs)) {
3857 + unsigned long sigpage = current->mm->context.sigpage;
3858 +
3859 + if (sigpage <= addr && addr < sigpage + 7*4) {
3860 + if (addr < sigpage + 3*4)
3861 + sys_sigreturn(regs);
3862 + else
3863 + sys_rt_sigreturn(regs);
3864 + return;
3865 + }
3866 + if (addr == 0xffff0fe0UL) {
3867 + /*
3868 + * PaX: __kuser_get_tls emulation
3869 + */
3870 + regs->ARM_r0 = current_thread_info()->tp_value;
3871 + regs->ARM_pc = regs->ARM_lr;
3872 + return;
3873 + }
3874 + }
3875 +
3876 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3877 + else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
3878 + if (current->signal->curr_ip)
3879 + 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),
3880 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3881 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3882 + else
3883 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
3884 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3885 + addr >= TASK_SIZE ? "non-executable kernel" : "userland", addr);
3886 + goto die;
3887 + }
3888 +#endif
3889 +
3890 +#ifdef CONFIG_PAX_REFCOUNT
3891 + if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
3892 + unsigned int bkpt;
3893 +
3894 + if (!probe_kernel_address((unsigned int *)addr, bkpt) && bkpt == 0xe12f1073) {
3895 + current->thread.error_code = ifsr;
3896 + current->thread.trap_no = 0;
3897 + pax_report_refcount_overflow(regs);
3898 + fixup_exception(regs);
3899 + return;
3900 + }
3901 + }
3902 +#endif
3903 +
3904 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
3905 return;
3906
3907 +die:
3908 printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
3909 inf->name, ifsr, addr);
3910
3911 diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
3912 index cf08bdf..772656c 100644
3913 --- a/arch/arm/mm/fault.h
3914 +++ b/arch/arm/mm/fault.h
3915 @@ -3,6 +3,7 @@
3916
3917 /*
3918 * Fault status register encodings. We steal bit 31 for our own purposes.
3919 + * Set when the FSR value is from an instruction fault.
3920 */
3921 #define FSR_LNX_PF (1 << 31)
3922 #define FSR_WRITE (1 << 11)
3923 @@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
3924 }
3925 #endif
3926
3927 +/* valid for LPAE and !LPAE */
3928 +static inline int is_xn_fault(unsigned int fsr)
3929 +{
3930 + return ((fsr_fs(fsr) & 0x3c) == 0xc);
3931 +}
3932 +
3933 +static inline int is_domain_fault(unsigned int fsr)
3934 +{
3935 + return ((fsr_fs(fsr) & 0xD) == 0x9);
3936 +}
3937 +
3938 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
3939 unsigned long search_exception_table(unsigned long addr);
3940
3941 diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
3942 index 0ecc43f..190b956 100644
3943 --- a/arch/arm/mm/init.c
3944 +++ b/arch/arm/mm/init.c
3945 @@ -30,6 +30,8 @@
3946 #include <asm/setup.h>
3947 #include <asm/tlb.h>
3948 #include <asm/fixmap.h>
3949 +#include <asm/system_info.h>
3950 +#include <asm/cp15.h>
3951
3952 #include <asm/mach/arch.h>
3953 #include <asm/mach/map.h>
3954 @@ -726,7 +728,46 @@ void free_initmem(void)
3955 {
3956 #ifdef CONFIG_HAVE_TCM
3957 extern char __tcm_start, __tcm_end;
3958 +#endif
3959
3960 +#ifdef CONFIG_PAX_KERNEXEC
3961 + unsigned long addr;
3962 + pgd_t *pgd;
3963 + pud_t *pud;
3964 + pmd_t *pmd;
3965 + int cpu_arch = cpu_architecture();
3966 + unsigned int cr = get_cr();
3967 +
3968 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
3969 + /* make pages tables, etc before .text NX */
3970 + for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
3971 + pgd = pgd_offset_k(addr);
3972 + pud = pud_offset(pgd, addr);
3973 + pmd = pmd_offset(pud, addr);
3974 + __section_update(pmd, addr, PMD_SECT_XN);
3975 + }
3976 + /* make init NX */
3977 + for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
3978 + pgd = pgd_offset_k(addr);
3979 + pud = pud_offset(pgd, addr);
3980 + pmd = pmd_offset(pud, addr);
3981 + __section_update(pmd, addr, PMD_SECT_XN);
3982 + }
3983 + /* make kernel code/rodata RX */
3984 + for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
3985 + pgd = pgd_offset_k(addr);
3986 + pud = pud_offset(pgd, addr);
3987 + pmd = pmd_offset(pud, addr);
3988 +#ifdef CONFIG_ARM_LPAE
3989 + __section_update(pmd, addr, PMD_SECT_RDONLY);
3990 +#else
3991 + __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
3992 +#endif
3993 + }
3994 + }
3995 +#endif
3996 +
3997 +#ifdef CONFIG_HAVE_TCM
3998 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
3999 free_reserved_area(&__tcm_start, &__tcm_end, 0, "TCM link");
4000 #endif
4001 diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
4002 index 04d9006..c547d85 100644
4003 --- a/arch/arm/mm/ioremap.c
4004 +++ b/arch/arm/mm/ioremap.c
4005 @@ -392,9 +392,9 @@ __arm_ioremap_exec(unsigned long phys_addr, size_t size, bool cached)
4006 unsigned int mtype;
4007
4008 if (cached)
4009 - mtype = MT_MEMORY;
4010 + mtype = MT_MEMORY_RX;
4011 else
4012 - mtype = MT_MEMORY_NONCACHED;
4013 + mtype = MT_MEMORY_NONCACHED_RX;
4014
4015 return __arm_ioremap_caller(phys_addr, size, mtype,
4016 __builtin_return_address(0));
4017 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
4018 index 10062ce..8695745 100644
4019 --- a/arch/arm/mm/mmap.c
4020 +++ b/arch/arm/mm/mmap.c
4021 @@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4022 struct vm_area_struct *vma;
4023 int do_align = 0;
4024 int aliasing = cache_is_vipt_aliasing();
4025 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4026 struct vm_unmapped_area_info info;
4027
4028 /*
4029 @@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4030 if (len > TASK_SIZE)
4031 return -ENOMEM;
4032
4033 +#ifdef CONFIG_PAX_RANDMMAP
4034 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4035 +#endif
4036 +
4037 if (addr) {
4038 if (do_align)
4039 addr = COLOUR_ALIGN(addr, pgoff);
4040 @@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4041 addr = PAGE_ALIGN(addr);
4042
4043 vma = find_vma(mm, addr);
4044 - if (TASK_SIZE - len >= addr &&
4045 - (!vma || addr + len <= vma->vm_start))
4046 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4047 return addr;
4048 }
4049
4050 @@ -99,6 +103,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4051 info.high_limit = TASK_SIZE;
4052 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4053 info.align_offset = pgoff << PAGE_SHIFT;
4054 + info.threadstack_offset = offset;
4055 return vm_unmapped_area(&info);
4056 }
4057
4058 @@ -112,6 +117,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4059 unsigned long addr = addr0;
4060 int do_align = 0;
4061 int aliasing = cache_is_vipt_aliasing();
4062 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4063 struct vm_unmapped_area_info info;
4064
4065 /*
4066 @@ -132,6 +138,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4067 return addr;
4068 }
4069
4070 +#ifdef CONFIG_PAX_RANDMMAP
4071 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4072 +#endif
4073 +
4074 /* requesting a specific address */
4075 if (addr) {
4076 if (do_align)
4077 @@ -139,8 +149,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4078 else
4079 addr = PAGE_ALIGN(addr);
4080 vma = find_vma(mm, addr);
4081 - if (TASK_SIZE - len >= addr &&
4082 - (!vma || addr + len <= vma->vm_start))
4083 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4084 return addr;
4085 }
4086
4087 @@ -150,6 +159,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4088 info.high_limit = mm->mmap_base;
4089 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4090 info.align_offset = pgoff << PAGE_SHIFT;
4091 + info.threadstack_offset = offset;
4092 addr = vm_unmapped_area(&info);
4093
4094 /*
4095 @@ -173,6 +183,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4096 {
4097 unsigned long random_factor = 0UL;
4098
4099 +#ifdef CONFIG_PAX_RANDMMAP
4100 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4101 +#endif
4102 +
4103 /* 8 bits of randomness in 20 address space bits */
4104 if ((current->flags & PF_RANDOMIZE) &&
4105 !(current->personality & ADDR_NO_RANDOMIZE))
4106 @@ -180,10 +194,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4107
4108 if (mmap_is_legacy()) {
4109 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
4110 +
4111 +#ifdef CONFIG_PAX_RANDMMAP
4112 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4113 + mm->mmap_base += mm->delta_mmap;
4114 +#endif
4115 +
4116 mm->get_unmapped_area = arch_get_unmapped_area;
4117 mm->unmap_area = arch_unmap_area;
4118 } else {
4119 mm->mmap_base = mmap_base(random_factor);
4120 +
4121 +#ifdef CONFIG_PAX_RANDMMAP
4122 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4123 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
4124 +#endif
4125 +
4126 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
4127 mm->unmap_area = arch_unmap_area_topdown;
4128 }
4129 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
4130 index daf336f..4e6392c 100644
4131 --- a/arch/arm/mm/mmu.c
4132 +++ b/arch/arm/mm/mmu.c
4133 @@ -36,6 +36,22 @@
4134 #include "mm.h"
4135 #include "tcm.h"
4136
4137 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
4138 +void modify_domain(unsigned int dom, unsigned int type)
4139 +{
4140 + struct thread_info *thread = current_thread_info();
4141 + unsigned int domain = thread->cpu_domain;
4142 + /*
4143 + * DOMAIN_MANAGER might be defined to some other value,
4144 + * use the arch-defined constant
4145 + */
4146 + domain &= ~domain_val(dom, 3);
4147 + thread->cpu_domain = domain | domain_val(dom, type);
4148 + set_domain(thread->cpu_domain);
4149 +}
4150 +EXPORT_SYMBOL(modify_domain);
4151 +#endif
4152 +
4153 /*
4154 * empty_zero_page is a special page that is used for
4155 * zero-initialized data and COW.
4156 @@ -228,10 +244,18 @@ __setup("noalign", noalign_setup);
4157
4158 #endif /* ifdef CONFIG_CPU_CP15 / else */
4159
4160 -#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
4161 +#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY
4162 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
4163
4164 -static struct mem_type mem_types[] = {
4165 +#ifdef CONFIG_PAX_KERNEXEC
4166 +#define L_PTE_KERNEXEC L_PTE_RDONLY
4167 +#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
4168 +#else
4169 +#define L_PTE_KERNEXEC L_PTE_DIRTY
4170 +#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
4171 +#endif
4172 +
4173 +static struct mem_type mem_types[] __read_only = {
4174 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
4175 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
4176 L_PTE_SHARED,
4177 @@ -260,16 +284,16 @@ static struct mem_type mem_types[] = {
4178 [MT_UNCACHED] = {
4179 .prot_pte = PROT_PTE_DEVICE,
4180 .prot_l1 = PMD_TYPE_TABLE,
4181 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4182 + .prot_sect = PROT_SECT_DEVICE,
4183 .domain = DOMAIN_IO,
4184 },
4185 [MT_CACHECLEAN] = {
4186 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4187 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4188 .domain = DOMAIN_KERNEL,
4189 },
4190 #ifndef CONFIG_ARM_LPAE
4191 [MT_MINICLEAN] = {
4192 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
4193 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_RDONLY,
4194 .domain = DOMAIN_KERNEL,
4195 },
4196 #endif
4197 @@ -277,36 +301,54 @@ static struct mem_type mem_types[] = {
4198 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4199 L_PTE_RDONLY,
4200 .prot_l1 = PMD_TYPE_TABLE,
4201 - .domain = DOMAIN_USER,
4202 + .domain = DOMAIN_VECTORS,
4203 },
4204 [MT_HIGH_VECTORS] = {
4205 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4206 L_PTE_USER | L_PTE_RDONLY,
4207 .prot_l1 = PMD_TYPE_TABLE,
4208 - .domain = DOMAIN_USER,
4209 + .domain = DOMAIN_VECTORS,
4210 },
4211 - [MT_MEMORY] = {
4212 + [MT_MEMORY_RWX] = {
4213 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4214 .prot_l1 = PMD_TYPE_TABLE,
4215 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4216 .domain = DOMAIN_KERNEL,
4217 },
4218 + [MT_MEMORY_RW] = {
4219 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4220 + .prot_l1 = PMD_TYPE_TABLE,
4221 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4222 + .domain = DOMAIN_KERNEL,
4223 + },
4224 + [MT_MEMORY_RX] = {
4225 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4226 + .prot_l1 = PMD_TYPE_TABLE,
4227 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4228 + .domain = DOMAIN_KERNEL,
4229 + },
4230 [MT_ROM] = {
4231 - .prot_sect = PMD_TYPE_SECT,
4232 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4233 .domain = DOMAIN_KERNEL,
4234 },
4235 - [MT_MEMORY_NONCACHED] = {
4236 + [MT_MEMORY_NONCACHED_RW] = {
4237 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4238 L_PTE_MT_BUFFERABLE,
4239 .prot_l1 = PMD_TYPE_TABLE,
4240 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4241 .domain = DOMAIN_KERNEL,
4242 },
4243 + [MT_MEMORY_NONCACHED_RX] = {
4244 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4245 + L_PTE_MT_BUFFERABLE,
4246 + .prot_l1 = PMD_TYPE_TABLE,
4247 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4248 + .domain = DOMAIN_KERNEL,
4249 + },
4250 [MT_MEMORY_DTCM] = {
4251 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4252 - L_PTE_XN,
4253 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4254 .prot_l1 = PMD_TYPE_TABLE,
4255 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4256 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4257 .domain = DOMAIN_KERNEL,
4258 },
4259 [MT_MEMORY_ITCM] = {
4260 @@ -316,10 +358,10 @@ static struct mem_type mem_types[] = {
4261 },
4262 [MT_MEMORY_SO] = {
4263 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4264 - L_PTE_MT_UNCACHED | L_PTE_XN,
4265 + L_PTE_MT_UNCACHED,
4266 .prot_l1 = PMD_TYPE_TABLE,
4267 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
4268 - PMD_SECT_UNCACHED | PMD_SECT_XN,
4269 + PMD_SECT_UNCACHED,
4270 .domain = DOMAIN_KERNEL,
4271 },
4272 [MT_MEMORY_DMA_READY] = {
4273 @@ -405,9 +447,35 @@ static void __init build_mem_type_table(void)
4274 * to prevent speculative instruction fetches.
4275 */
4276 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
4277 + mem_types[MT_DEVICE].prot_pte |= L_PTE_XN;
4278 mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
4279 + mem_types[MT_DEVICE_NONSHARED].prot_pte |= L_PTE_XN;
4280 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
4281 + mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_XN;
4282 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
4283 + mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_XN;
4284 +
4285 + /* Mark other regions on ARMv6+ as execute-never */
4286 +
4287 +#ifdef CONFIG_PAX_KERNEXEC
4288 + mem_types[MT_UNCACHED].prot_sect |= PMD_SECT_XN;
4289 + mem_types[MT_UNCACHED].prot_pte |= L_PTE_XN;
4290 + mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_XN;
4291 + mem_types[MT_CACHECLEAN].prot_pte |= L_PTE_XN;
4292 +#ifndef CONFIG_ARM_LPAE
4293 + mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_XN;
4294 + mem_types[MT_MINICLEAN].prot_pte |= L_PTE_XN;
4295 +#endif
4296 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
4297 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_XN;
4298 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_XN;
4299 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= PMD_SECT_XN;
4300 + mem_types[MT_MEMORY_DTCM].prot_sect |= PMD_SECT_XN;
4301 + mem_types[MT_MEMORY_DTCM].prot_pte |= L_PTE_XN;
4302 +#endif
4303 +
4304 + mem_types[MT_MEMORY_SO].prot_sect |= PMD_SECT_XN;
4305 + mem_types[MT_MEMORY_SO].prot_pte |= L_PTE_XN;
4306 }
4307 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4308 /*
4309 @@ -468,6 +536,9 @@ static void __init build_mem_type_table(void)
4310 * from SVC mode and no access from userspace.
4311 */
4312 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4313 +#ifdef CONFIG_PAX_KERNEXEC
4314 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4315 +#endif
4316 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4317 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4318 #endif
4319 @@ -485,11 +556,17 @@ static void __init build_mem_type_table(void)
4320 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4321 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4322 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4323 - mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
4324 - mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
4325 + mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4326 + mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4327 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4328 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4329 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4330 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4331 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4332 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
4333 - mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
4334 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_S;
4335 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= L_PTE_SHARED;
4336 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_S;
4337 + mem_types[MT_MEMORY_NONCACHED_RX].prot_pte |= L_PTE_SHARED;
4338 }
4339 }
4340
4341 @@ -500,15 +577,20 @@ static void __init build_mem_type_table(void)
4342 if (cpu_arch >= CPU_ARCH_ARMv6) {
4343 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4344 /* Non-cacheable Normal is XCB = 001 */
4345 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4346 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4347 + PMD_SECT_BUFFERED;
4348 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4349 PMD_SECT_BUFFERED;
4350 } else {
4351 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4352 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4353 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4354 + PMD_SECT_TEX(1);
4355 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4356 PMD_SECT_TEX(1);
4357 }
4358 } else {
4359 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4360 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_BUFFERABLE;
4361 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_BUFFERABLE;
4362 }
4363
4364 #ifdef CONFIG_ARM_LPAE
4365 @@ -524,6 +606,8 @@ static void __init build_mem_type_table(void)
4366 vecs_pgprot |= PTE_EXT_AF;
4367 #endif
4368
4369 + user_pgprot |= __supported_pte_mask;
4370 +
4371 for (i = 0; i < 16; i++) {
4372 pteval_t v = pgprot_val(protection_map[i]);
4373 protection_map[i] = __pgprot(v | user_pgprot);
4374 @@ -541,10 +625,15 @@ static void __init build_mem_type_table(void)
4375
4376 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4377 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4378 - mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
4379 - mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
4380 + mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4381 + mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4382 + mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4383 + mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4384 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4385 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4386 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4387 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
4388 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= ecc_mask;
4389 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= ecc_mask;
4390 mem_types[MT_ROM].prot_sect |= cp->pmd;
4391
4392 switch (cp->pmd) {
4393 @@ -1166,18 +1255,15 @@ void __init arm_mm_memblock_reserve(void)
4394 * called function. This means you can't use any function or debugging
4395 * method which may touch any device, otherwise the kernel _will_ crash.
4396 */
4397 +
4398 +static char vectors[PAGE_SIZE * 2] __read_only __aligned(PAGE_SIZE);
4399 +
4400 static void __init devicemaps_init(struct machine_desc *mdesc)
4401 {
4402 struct map_desc map;
4403 unsigned long addr;
4404 - void *vectors;
4405
4406 - /*
4407 - * Allocate the vector page early.
4408 - */
4409 - vectors = early_alloc(PAGE_SIZE * 2);
4410 -
4411 - early_trap_init(vectors);
4412 + early_trap_init(&vectors);
4413
4414 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4415 pmd_clear(pmd_off_k(addr));
4416 @@ -1217,7 +1303,7 @@ static void __init devicemaps_init(struct machine_desc *mdesc)
4417 * location (0xffff0000). If we aren't using high-vectors, also
4418 * create a mapping at the low-vectors virtual address.
4419 */
4420 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4421 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4422 map.virtual = 0xffff0000;
4423 map.length = PAGE_SIZE;
4424 #ifdef CONFIG_KUSER_HELPERS
4425 @@ -1287,8 +1373,39 @@ static void __init map_lowmem(void)
4426 map.pfn = __phys_to_pfn(start);
4427 map.virtual = __phys_to_virt(start);
4428 map.length = end - start;
4429 - map.type = MT_MEMORY;
4430
4431 +#ifdef CONFIG_PAX_KERNEXEC
4432 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4433 + struct map_desc kernel;
4434 + struct map_desc initmap;
4435 +
4436 + /* when freeing initmem we will make this RW */
4437 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4438 + initmap.virtual = (unsigned long)__init_begin;
4439 + initmap.length = _sdata - __init_begin;
4440 + initmap.type = MT_MEMORY_RWX;
4441 + create_mapping(&initmap);
4442 +
4443 + /* when freeing initmem we will make this RX */
4444 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4445 + kernel.virtual = (unsigned long)_stext;
4446 + kernel.length = __init_begin - _stext;
4447 + kernel.type = MT_MEMORY_RWX;
4448 + create_mapping(&kernel);
4449 +
4450 + if (map.virtual < (unsigned long)_stext) {
4451 + map.length = (unsigned long)_stext - map.virtual;
4452 + map.type = MT_MEMORY_RWX;
4453 + create_mapping(&map);
4454 + }
4455 +
4456 + map.pfn = __phys_to_pfn(__pa(_sdata));
4457 + map.virtual = (unsigned long)_sdata;
4458 + map.length = end - __pa(_sdata);
4459 + }
4460 +#endif
4461 +
4462 + map.type = MT_MEMORY_RW;
4463 create_mapping(&map);
4464 }
4465 }
4466 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4467 index a5bc92d..0bb4730 100644
4468 --- a/arch/arm/plat-omap/sram.c
4469 +++ b/arch/arm/plat-omap/sram.c
4470 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4471 * Looks like we need to preserve some bootloader code at the
4472 * beginning of SRAM for jumping to flash for reboot to work...
4473 */
4474 + pax_open_kernel();
4475 memset_io(omap_sram_base + omap_sram_skip, 0,
4476 omap_sram_size - omap_sram_skip);
4477 + pax_close_kernel();
4478 }
4479 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4480 index ce6d763..cfea917 100644
4481 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4482 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4483 @@ -47,7 +47,7 @@ struct samsung_dma_ops {
4484 int (*started)(unsigned ch);
4485 int (*flush)(unsigned ch);
4486 int (*stop)(unsigned ch);
4487 -};
4488 +} __no_const;
4489
4490 extern void *samsung_dmadev_get_ops(void);
4491 extern void *s3c_dma_get_ops(void);
4492 diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
4493 index f4726dc..39ed646 100644
4494 --- a/arch/arm64/kernel/debug-monitors.c
4495 +++ b/arch/arm64/kernel/debug-monitors.c
4496 @@ -149,7 +149,7 @@ static int __cpuinit os_lock_notify(struct notifier_block *self,
4497 return NOTIFY_OK;
4498 }
4499
4500 -static struct notifier_block __cpuinitdata os_lock_nb = {
4501 +static struct notifier_block os_lock_nb = {
4502 .notifier_call = os_lock_notify,
4503 };
4504
4505 diff --git a/arch/arm64/kernel/hw_breakpoint.c b/arch/arm64/kernel/hw_breakpoint.c
4506 index 5ab825c..96aaec8 100644
4507 --- a/arch/arm64/kernel/hw_breakpoint.c
4508 +++ b/arch/arm64/kernel/hw_breakpoint.c
4509 @@ -831,7 +831,7 @@ static int __cpuinit hw_breakpoint_reset_notify(struct notifier_block *self,
4510 return NOTIFY_OK;
4511 }
4512
4513 -static struct notifier_block __cpuinitdata hw_breakpoint_reset_nb = {
4514 +static struct notifier_block hw_breakpoint_reset_nb = {
4515 .notifier_call = hw_breakpoint_reset_notify,
4516 };
4517
4518 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4519 index c3a58a1..78fbf54 100644
4520 --- a/arch/avr32/include/asm/cache.h
4521 +++ b/arch/avr32/include/asm/cache.h
4522 @@ -1,8 +1,10 @@
4523 #ifndef __ASM_AVR32_CACHE_H
4524 #define __ASM_AVR32_CACHE_H
4525
4526 +#include <linux/const.h>
4527 +
4528 #define L1_CACHE_SHIFT 5
4529 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4530 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4531
4532 /*
4533 * Memory returned by kmalloc() may be used for DMA, so we must make
4534 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4535 index d232888..87c8df1 100644
4536 --- a/arch/avr32/include/asm/elf.h
4537 +++ b/arch/avr32/include/asm/elf.h
4538 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4539 the loader. We need to make sure that it is out of the way of the program
4540 that it will "exec", and that there is sufficient room for the brk. */
4541
4542 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4543 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4544
4545 +#ifdef CONFIG_PAX_ASLR
4546 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4547 +
4548 +#define PAX_DELTA_MMAP_LEN 15
4549 +#define PAX_DELTA_STACK_LEN 15
4550 +#endif
4551
4552 /* This yields a mask that user programs can use to figure out what
4553 instruction set this CPU supports. This could be done in user space,
4554 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4555 index 479330b..53717a8 100644
4556 --- a/arch/avr32/include/asm/kmap_types.h
4557 +++ b/arch/avr32/include/asm/kmap_types.h
4558 @@ -2,9 +2,9 @@
4559 #define __ASM_AVR32_KMAP_TYPES_H
4560
4561 #ifdef CONFIG_DEBUG_HIGHMEM
4562 -# define KM_TYPE_NR 29
4563 +# define KM_TYPE_NR 30
4564 #else
4565 -# define KM_TYPE_NR 14
4566 +# define KM_TYPE_NR 15
4567 #endif
4568
4569 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4570 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4571 index b2f2d2d..d1c85cb 100644
4572 --- a/arch/avr32/mm/fault.c
4573 +++ b/arch/avr32/mm/fault.c
4574 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4575
4576 int exception_trace = 1;
4577
4578 +#ifdef CONFIG_PAX_PAGEEXEC
4579 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4580 +{
4581 + unsigned long i;
4582 +
4583 + printk(KERN_ERR "PAX: bytes at PC: ");
4584 + for (i = 0; i < 20; i++) {
4585 + unsigned char c;
4586 + if (get_user(c, (unsigned char *)pc+i))
4587 + printk(KERN_CONT "???????? ");
4588 + else
4589 + printk(KERN_CONT "%02x ", c);
4590 + }
4591 + printk("\n");
4592 +}
4593 +#endif
4594 +
4595 /*
4596 * This routine handles page faults. It determines the address and the
4597 * problem, and then passes it off to one of the appropriate routines.
4598 @@ -174,6 +191,16 @@ bad_area:
4599 up_read(&mm->mmap_sem);
4600
4601 if (user_mode(regs)) {
4602 +
4603 +#ifdef CONFIG_PAX_PAGEEXEC
4604 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4605 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4606 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4607 + do_group_exit(SIGKILL);
4608 + }
4609 + }
4610 +#endif
4611 +
4612 if (exception_trace && printk_ratelimit())
4613 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4614 "sp %08lx ecr %lu\n",
4615 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4616 index 568885a..f8008df 100644
4617 --- a/arch/blackfin/include/asm/cache.h
4618 +++ b/arch/blackfin/include/asm/cache.h
4619 @@ -7,6 +7,7 @@
4620 #ifndef __ARCH_BLACKFIN_CACHE_H
4621 #define __ARCH_BLACKFIN_CACHE_H
4622
4623 +#include <linux/const.h>
4624 #include <linux/linkage.h> /* for asmlinkage */
4625
4626 /*
4627 @@ -14,7 +15,7 @@
4628 * Blackfin loads 32 bytes for cache
4629 */
4630 #define L1_CACHE_SHIFT 5
4631 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4632 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4633 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4634
4635 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4636 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4637 index aea2718..3639a60 100644
4638 --- a/arch/cris/include/arch-v10/arch/cache.h
4639 +++ b/arch/cris/include/arch-v10/arch/cache.h
4640 @@ -1,8 +1,9 @@
4641 #ifndef _ASM_ARCH_CACHE_H
4642 #define _ASM_ARCH_CACHE_H
4643
4644 +#include <linux/const.h>
4645 /* Etrax 100LX have 32-byte cache-lines. */
4646 -#define L1_CACHE_BYTES 32
4647 #define L1_CACHE_SHIFT 5
4648 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4649
4650 #endif /* _ASM_ARCH_CACHE_H */
4651 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4652 index 7caf25d..ee65ac5 100644
4653 --- a/arch/cris/include/arch-v32/arch/cache.h
4654 +++ b/arch/cris/include/arch-v32/arch/cache.h
4655 @@ -1,11 +1,12 @@
4656 #ifndef _ASM_CRIS_ARCH_CACHE_H
4657 #define _ASM_CRIS_ARCH_CACHE_H
4658
4659 +#include <linux/const.h>
4660 #include <arch/hwregs/dma.h>
4661
4662 /* A cache-line is 32 bytes. */
4663 -#define L1_CACHE_BYTES 32
4664 #define L1_CACHE_SHIFT 5
4665 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4666
4667 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4668
4669 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4670 index b86329d..6709906 100644
4671 --- a/arch/frv/include/asm/atomic.h
4672 +++ b/arch/frv/include/asm/atomic.h
4673 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4674 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4675 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
4676
4677 +#define atomic64_read_unchecked(v) atomic64_read(v)
4678 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4679 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4680 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4681 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4682 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4683 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4684 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4685 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4686 +
4687 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4688 {
4689 int c, old;
4690 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4691 index 2797163..c2a401d 100644
4692 --- a/arch/frv/include/asm/cache.h
4693 +++ b/arch/frv/include/asm/cache.h
4694 @@ -12,10 +12,11 @@
4695 #ifndef __ASM_CACHE_H
4696 #define __ASM_CACHE_H
4697
4698 +#include <linux/const.h>
4699
4700 /* bytes per L1 cache line */
4701 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4702 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4703 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4704
4705 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4706 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4707 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4708 index 43901f2..0d8b865 100644
4709 --- a/arch/frv/include/asm/kmap_types.h
4710 +++ b/arch/frv/include/asm/kmap_types.h
4711 @@ -2,6 +2,6 @@
4712 #ifndef _ASM_KMAP_TYPES_H
4713 #define _ASM_KMAP_TYPES_H
4714
4715 -#define KM_TYPE_NR 17
4716 +#define KM_TYPE_NR 18
4717
4718 #endif
4719 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4720 index 836f147..4cf23f5 100644
4721 --- a/arch/frv/mm/elf-fdpic.c
4722 +++ b/arch/frv/mm/elf-fdpic.c
4723 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4724 {
4725 struct vm_area_struct *vma;
4726 struct vm_unmapped_area_info info;
4727 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4728
4729 if (len > TASK_SIZE)
4730 return -ENOMEM;
4731 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4732 if (addr) {
4733 addr = PAGE_ALIGN(addr);
4734 vma = find_vma(current->mm, addr);
4735 - if (TASK_SIZE - len >= addr &&
4736 - (!vma || addr + len <= vma->vm_start))
4737 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4738 goto success;
4739 }
4740
4741 @@ -85,6 +85,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4742 info.high_limit = (current->mm->start_stack - 0x00200000);
4743 info.align_mask = 0;
4744 info.align_offset = 0;
4745 + info.threadstack_offset = offset;
4746 addr = vm_unmapped_area(&info);
4747 if (!(addr & ~PAGE_MASK))
4748 goto success;
4749 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
4750 index f4ca594..adc72fd6 100644
4751 --- a/arch/hexagon/include/asm/cache.h
4752 +++ b/arch/hexagon/include/asm/cache.h
4753 @@ -21,9 +21,11 @@
4754 #ifndef __ASM_CACHE_H
4755 #define __ASM_CACHE_H
4756
4757 +#include <linux/const.h>
4758 +
4759 /* Bytes per L1 cache line */
4760 -#define L1_CACHE_SHIFT (5)
4761 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4762 +#define L1_CACHE_SHIFT 5
4763 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4764
4765 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
4766 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
4767 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
4768 index 6e6fe18..a6ae668 100644
4769 --- a/arch/ia64/include/asm/atomic.h
4770 +++ b/arch/ia64/include/asm/atomic.h
4771 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
4772 #define atomic64_inc(v) atomic64_add(1, (v))
4773 #define atomic64_dec(v) atomic64_sub(1, (v))
4774
4775 +#define atomic64_read_unchecked(v) atomic64_read(v)
4776 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4777 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4778 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4779 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4780 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4781 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4782 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4783 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4784 +
4785 /* Atomic operations are already serializing */
4786 #define smp_mb__before_atomic_dec() barrier()
4787 #define smp_mb__after_atomic_dec() barrier()
4788 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
4789 index 988254a..e1ee885 100644
4790 --- a/arch/ia64/include/asm/cache.h
4791 +++ b/arch/ia64/include/asm/cache.h
4792 @@ -1,6 +1,7 @@
4793 #ifndef _ASM_IA64_CACHE_H
4794 #define _ASM_IA64_CACHE_H
4795
4796 +#include <linux/const.h>
4797
4798 /*
4799 * Copyright (C) 1998-2000 Hewlett-Packard Co
4800 @@ -9,7 +10,7 @@
4801
4802 /* Bytes per L1 (data) cache line. */
4803 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
4804 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4805 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4806
4807 #ifdef CONFIG_SMP
4808 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
4809 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
4810 index 5a83c5c..4d7f553 100644
4811 --- a/arch/ia64/include/asm/elf.h
4812 +++ b/arch/ia64/include/asm/elf.h
4813 @@ -42,6 +42,13 @@
4814 */
4815 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
4816
4817 +#ifdef CONFIG_PAX_ASLR
4818 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
4819 +
4820 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4821 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4822 +#endif
4823 +
4824 #define PT_IA_64_UNWIND 0x70000001
4825
4826 /* IA-64 relocations: */
4827 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
4828 index 96a8d92..617a1cf 100644
4829 --- a/arch/ia64/include/asm/pgalloc.h
4830 +++ b/arch/ia64/include/asm/pgalloc.h
4831 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4832 pgd_val(*pgd_entry) = __pa(pud);
4833 }
4834
4835 +static inline void
4836 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4837 +{
4838 + pgd_populate(mm, pgd_entry, pud);
4839 +}
4840 +
4841 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
4842 {
4843 return quicklist_alloc(0, GFP_KERNEL, NULL);
4844 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4845 pud_val(*pud_entry) = __pa(pmd);
4846 }
4847
4848 +static inline void
4849 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4850 +{
4851 + pud_populate(mm, pud_entry, pmd);
4852 +}
4853 +
4854 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
4855 {
4856 return quicklist_alloc(0, GFP_KERNEL, NULL);
4857 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
4858 index 815810c..d60bd4c 100644
4859 --- a/arch/ia64/include/asm/pgtable.h
4860 +++ b/arch/ia64/include/asm/pgtable.h
4861 @@ -12,7 +12,7 @@
4862 * David Mosberger-Tang <davidm@hpl.hp.com>
4863 */
4864
4865 -
4866 +#include <linux/const.h>
4867 #include <asm/mman.h>
4868 #include <asm/page.h>
4869 #include <asm/processor.h>
4870 @@ -142,6 +142,17 @@
4871 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4872 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4873 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
4874 +
4875 +#ifdef CONFIG_PAX_PAGEEXEC
4876 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
4877 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4878 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4879 +#else
4880 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
4881 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
4882 +# define PAGE_COPY_NOEXEC PAGE_COPY
4883 +#endif
4884 +
4885 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
4886 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
4887 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
4888 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
4889 index 54ff557..70c88b7 100644
4890 --- a/arch/ia64/include/asm/spinlock.h
4891 +++ b/arch/ia64/include/asm/spinlock.h
4892 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
4893 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
4894
4895 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
4896 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
4897 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
4898 }
4899
4900 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
4901 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
4902 index 449c8c0..18965fb 100644
4903 --- a/arch/ia64/include/asm/uaccess.h
4904 +++ b/arch/ia64/include/asm/uaccess.h
4905 @@ -240,12 +240,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
4906 static inline unsigned long
4907 __copy_to_user (void __user *to, const void *from, unsigned long count)
4908 {
4909 + if (count > INT_MAX)
4910 + return count;
4911 +
4912 + if (!__builtin_constant_p(count))
4913 + check_object_size(from, count, true);
4914 +
4915 return __copy_user(to, (__force void __user *) from, count);
4916 }
4917
4918 static inline unsigned long
4919 __copy_from_user (void *to, const void __user *from, unsigned long count)
4920 {
4921 + if (count > INT_MAX)
4922 + return count;
4923 +
4924 + if (!__builtin_constant_p(count))
4925 + check_object_size(to, count, false);
4926 +
4927 return __copy_user((__force void __user *) to, from, count);
4928 }
4929
4930 @@ -255,10 +267,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4931 ({ \
4932 void __user *__cu_to = (to); \
4933 const void *__cu_from = (from); \
4934 - long __cu_len = (n); \
4935 + unsigned long __cu_len = (n); \
4936 \
4937 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
4938 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
4939 + if (!__builtin_constant_p(n)) \
4940 + check_object_size(__cu_from, __cu_len, true); \
4941 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
4942 + } \
4943 __cu_len; \
4944 })
4945
4946 @@ -266,11 +281,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
4947 ({ \
4948 void *__cu_to = (to); \
4949 const void __user *__cu_from = (from); \
4950 - long __cu_len = (n); \
4951 + unsigned long __cu_len = (n); \
4952 \
4953 __chk_user_ptr(__cu_from); \
4954 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
4955 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
4956 + if (!__builtin_constant_p(n)) \
4957 + check_object_size(__cu_to, __cu_len, false); \
4958 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
4959 + } \
4960 __cu_len; \
4961 })
4962
4963 diff --git a/arch/ia64/kernel/err_inject.c b/arch/ia64/kernel/err_inject.c
4964 index 2d67317..07d8bfa 100644
4965 --- a/arch/ia64/kernel/err_inject.c
4966 +++ b/arch/ia64/kernel/err_inject.c
4967 @@ -256,7 +256,7 @@ static int __cpuinit err_inject_cpu_callback(struct notifier_block *nfb,
4968 return NOTIFY_OK;
4969 }
4970
4971 -static struct notifier_block __cpuinitdata err_inject_cpu_notifier =
4972 +static struct notifier_block err_inject_cpu_notifier =
4973 {
4974 .notifier_call = err_inject_cpu_callback,
4975 };
4976 diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c
4977 index d7396db..b33e873 100644
4978 --- a/arch/ia64/kernel/mca.c
4979 +++ b/arch/ia64/kernel/mca.c
4980 @@ -1922,7 +1922,7 @@ static int __cpuinit mca_cpu_callback(struct notifier_block *nfb,
4981 return NOTIFY_OK;
4982 }
4983
4984 -static struct notifier_block mca_cpu_notifier __cpuinitdata = {
4985 +static struct notifier_block mca_cpu_notifier = {
4986 .notifier_call = mca_cpu_callback
4987 };
4988
4989 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
4990 index 24603be..948052d 100644
4991 --- a/arch/ia64/kernel/module.c
4992 +++ b/arch/ia64/kernel/module.c
4993 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
4994 void
4995 module_free (struct module *mod, void *module_region)
4996 {
4997 - if (mod && mod->arch.init_unw_table &&
4998 - module_region == mod->module_init) {
4999 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
5000 unw_remove_unwind_table(mod->arch.init_unw_table);
5001 mod->arch.init_unw_table = NULL;
5002 }
5003 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
5004 }
5005
5006 static inline int
5007 +in_init_rx (const struct module *mod, uint64_t addr)
5008 +{
5009 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
5010 +}
5011 +
5012 +static inline int
5013 +in_init_rw (const struct module *mod, uint64_t addr)
5014 +{
5015 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
5016 +}
5017 +
5018 +static inline int
5019 in_init (const struct module *mod, uint64_t addr)
5020 {
5021 - return addr - (uint64_t) mod->module_init < mod->init_size;
5022 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
5023 +}
5024 +
5025 +static inline int
5026 +in_core_rx (const struct module *mod, uint64_t addr)
5027 +{
5028 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
5029 +}
5030 +
5031 +static inline int
5032 +in_core_rw (const struct module *mod, uint64_t addr)
5033 +{
5034 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
5035 }
5036
5037 static inline int
5038 in_core (const struct module *mod, uint64_t addr)
5039 {
5040 - return addr - (uint64_t) mod->module_core < mod->core_size;
5041 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
5042 }
5043
5044 static inline int
5045 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
5046 break;
5047
5048 case RV_BDREL:
5049 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
5050 + if (in_init_rx(mod, val))
5051 + val -= (uint64_t) mod->module_init_rx;
5052 + else if (in_init_rw(mod, val))
5053 + val -= (uint64_t) mod->module_init_rw;
5054 + else if (in_core_rx(mod, val))
5055 + val -= (uint64_t) mod->module_core_rx;
5056 + else if (in_core_rw(mod, val))
5057 + val -= (uint64_t) mod->module_core_rw;
5058 break;
5059
5060 case RV_LTV:
5061 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
5062 * addresses have been selected...
5063 */
5064 uint64_t gp;
5065 - if (mod->core_size > MAX_LTOFF)
5066 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
5067 /*
5068 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
5069 * at the end of the module.
5070 */
5071 - gp = mod->core_size - MAX_LTOFF / 2;
5072 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
5073 else
5074 - gp = mod->core_size / 2;
5075 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
5076 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
5077 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
5078 mod->arch.gp = gp;
5079 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
5080 }
5081 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
5082 index 2b3c2d7..a318d84 100644
5083 --- a/arch/ia64/kernel/palinfo.c
5084 +++ b/arch/ia64/kernel/palinfo.c
5085 @@ -980,7 +980,7 @@ static int __cpuinit palinfo_cpu_callback(struct notifier_block *nfb,
5086 return NOTIFY_OK;
5087 }
5088
5089 -static struct notifier_block __refdata palinfo_cpu_notifier =
5090 +static struct notifier_block palinfo_cpu_notifier =
5091 {
5092 .notifier_call = palinfo_cpu_callback,
5093 .priority = 0,
5094 diff --git a/arch/ia64/kernel/salinfo.c b/arch/ia64/kernel/salinfo.c
5095 index 4bc580a..7767f24 100644
5096 --- a/arch/ia64/kernel/salinfo.c
5097 +++ b/arch/ia64/kernel/salinfo.c
5098 @@ -609,7 +609,7 @@ salinfo_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu
5099 return NOTIFY_OK;
5100 }
5101
5102 -static struct notifier_block salinfo_cpu_notifier __cpuinitdata =
5103 +static struct notifier_block salinfo_cpu_notifier =
5104 {
5105 .notifier_call = salinfo_cpu_callback,
5106 .priority = 0,
5107 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
5108 index 41e33f8..65180b2 100644
5109 --- a/arch/ia64/kernel/sys_ia64.c
5110 +++ b/arch/ia64/kernel/sys_ia64.c
5111 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5112 unsigned long align_mask = 0;
5113 struct mm_struct *mm = current->mm;
5114 struct vm_unmapped_area_info info;
5115 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5116
5117 if (len > RGN_MAP_LIMIT)
5118 return -ENOMEM;
5119 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5120 if (REGION_NUMBER(addr) == RGN_HPAGE)
5121 addr = 0;
5122 #endif
5123 +
5124 +#ifdef CONFIG_PAX_RANDMMAP
5125 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5126 + addr = mm->free_area_cache;
5127 + else
5128 +#endif
5129 +
5130 if (!addr)
5131 addr = TASK_UNMAPPED_BASE;
5132
5133 @@ -61,6 +69,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5134 info.high_limit = TASK_SIZE;
5135 info.align_mask = align_mask;
5136 info.align_offset = 0;
5137 + info.threadstack_offset = offset;
5138 return vm_unmapped_area(&info);
5139 }
5140
5141 diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c
5142 index dc00b2c..cce53c2 100644
5143 --- a/arch/ia64/kernel/topology.c
5144 +++ b/arch/ia64/kernel/topology.c
5145 @@ -445,7 +445,7 @@ static int __cpuinit cache_cpu_callback(struct notifier_block *nfb,
5146 return NOTIFY_OK;
5147 }
5148
5149 -static struct notifier_block __cpuinitdata cache_cpu_notifier =
5150 +static struct notifier_block cache_cpu_notifier =
5151 {
5152 .notifier_call = cache_cpu_callback
5153 };
5154 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
5155 index 0ccb28f..8992469 100644
5156 --- a/arch/ia64/kernel/vmlinux.lds.S
5157 +++ b/arch/ia64/kernel/vmlinux.lds.S
5158 @@ -198,7 +198,7 @@ SECTIONS {
5159 /* Per-cpu data: */
5160 . = ALIGN(PERCPU_PAGE_SIZE);
5161 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
5162 - __phys_per_cpu_start = __per_cpu_load;
5163 + __phys_per_cpu_start = per_cpu_load;
5164 /*
5165 * ensure percpu data fits
5166 * into percpu page size
5167 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
5168 index 6cf0341..d352594 100644
5169 --- a/arch/ia64/mm/fault.c
5170 +++ b/arch/ia64/mm/fault.c
5171 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
5172 return pte_present(pte);
5173 }
5174
5175 +#ifdef CONFIG_PAX_PAGEEXEC
5176 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5177 +{
5178 + unsigned long i;
5179 +
5180 + printk(KERN_ERR "PAX: bytes at PC: ");
5181 + for (i = 0; i < 8; i++) {
5182 + unsigned int c;
5183 + if (get_user(c, (unsigned int *)pc+i))
5184 + printk(KERN_CONT "???????? ");
5185 + else
5186 + printk(KERN_CONT "%08x ", c);
5187 + }
5188 + printk("\n");
5189 +}
5190 +#endif
5191 +
5192 # define VM_READ_BIT 0
5193 # define VM_WRITE_BIT 1
5194 # define VM_EXEC_BIT 2
5195 @@ -149,8 +166,21 @@ retry:
5196 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5197 goto bad_area;
5198
5199 - if ((vma->vm_flags & mask) != mask)
5200 + if ((vma->vm_flags & mask) != mask) {
5201 +
5202 +#ifdef CONFIG_PAX_PAGEEXEC
5203 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5204 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5205 + goto bad_area;
5206 +
5207 + up_read(&mm->mmap_sem);
5208 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5209 + do_group_exit(SIGKILL);
5210 + }
5211 +#endif
5212 +
5213 goto bad_area;
5214 + }
5215
5216 /*
5217 * If for any reason at all we couldn't handle the fault, make
5218 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5219 index 76069c1..c2aa816 100644
5220 --- a/arch/ia64/mm/hugetlbpage.c
5221 +++ b/arch/ia64/mm/hugetlbpage.c
5222 @@ -149,6 +149,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5223 unsigned long pgoff, unsigned long flags)
5224 {
5225 struct vm_unmapped_area_info info;
5226 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5227
5228 if (len > RGN_MAP_LIMIT)
5229 return -ENOMEM;
5230 @@ -172,6 +173,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5231 info.high_limit = HPAGE_REGION_BASE + RGN_MAP_LIMIT;
5232 info.align_mask = PAGE_MASK & (HPAGE_SIZE - 1);
5233 info.align_offset = 0;
5234 + info.threadstack_offset = offset;
5235 return vm_unmapped_area(&info);
5236 }
5237
5238 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5239 index d1fe4b4..2628f37 100644
5240 --- a/arch/ia64/mm/init.c
5241 +++ b/arch/ia64/mm/init.c
5242 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5243 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5244 vma->vm_end = vma->vm_start + PAGE_SIZE;
5245 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5246 +
5247 +#ifdef CONFIG_PAX_PAGEEXEC
5248 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5249 + vma->vm_flags &= ~VM_EXEC;
5250 +
5251 +#ifdef CONFIG_PAX_MPROTECT
5252 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5253 + vma->vm_flags &= ~VM_MAYEXEC;
5254 +#endif
5255 +
5256 + }
5257 +#endif
5258 +
5259 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5260 down_write(&current->mm->mmap_sem);
5261 if (insert_vm_struct(current->mm, vma)) {
5262 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5263 index 40b3ee9..8c2c112 100644
5264 --- a/arch/m32r/include/asm/cache.h
5265 +++ b/arch/m32r/include/asm/cache.h
5266 @@ -1,8 +1,10 @@
5267 #ifndef _ASM_M32R_CACHE_H
5268 #define _ASM_M32R_CACHE_H
5269
5270 +#include <linux/const.h>
5271 +
5272 /* L1 cache line size */
5273 #define L1_CACHE_SHIFT 4
5274 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5275 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5276
5277 #endif /* _ASM_M32R_CACHE_H */
5278 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5279 index 82abd15..d95ae5d 100644
5280 --- a/arch/m32r/lib/usercopy.c
5281 +++ b/arch/m32r/lib/usercopy.c
5282 @@ -14,6 +14,9 @@
5283 unsigned long
5284 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5285 {
5286 + if ((long)n < 0)
5287 + return n;
5288 +
5289 prefetch(from);
5290 if (access_ok(VERIFY_WRITE, to, n))
5291 __copy_user(to,from,n);
5292 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5293 unsigned long
5294 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5295 {
5296 + if ((long)n < 0)
5297 + return n;
5298 +
5299 prefetchw(to);
5300 if (access_ok(VERIFY_READ, from, n))
5301 __copy_user_zeroing(to,from,n);
5302 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5303 index 0395c51..5f26031 100644
5304 --- a/arch/m68k/include/asm/cache.h
5305 +++ b/arch/m68k/include/asm/cache.h
5306 @@ -4,9 +4,11 @@
5307 #ifndef __ARCH_M68K_CACHE_H
5308 #define __ARCH_M68K_CACHE_H
5309
5310 +#include <linux/const.h>
5311 +
5312 /* bytes per L1 cache line */
5313 #define L1_CACHE_SHIFT 4
5314 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5315 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5316
5317 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5318
5319 diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
5320 index 3c52fa6..11b2ad8 100644
5321 --- a/arch/metag/mm/hugetlbpage.c
5322 +++ b/arch/metag/mm/hugetlbpage.c
5323 @@ -200,6 +200,7 @@ hugetlb_get_unmapped_area_new_pmd(unsigned long len)
5324 info.high_limit = TASK_SIZE;
5325 info.align_mask = PAGE_MASK & HUGEPT_MASK;
5326 info.align_offset = 0;
5327 + info.threadstack_offset = 0;
5328 return vm_unmapped_area(&info);
5329 }
5330
5331 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5332 index 4efe96a..60e8699 100644
5333 --- a/arch/microblaze/include/asm/cache.h
5334 +++ b/arch/microblaze/include/asm/cache.h
5335 @@ -13,11 +13,12 @@
5336 #ifndef _ASM_MICROBLAZE_CACHE_H
5337 #define _ASM_MICROBLAZE_CACHE_H
5338
5339 +#include <linux/const.h>
5340 #include <asm/registers.h>
5341
5342 #define L1_CACHE_SHIFT 5
5343 /* word-granular cache in microblaze */
5344 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5345 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5346
5347 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5348
5349 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5350 index 08b6079..eb272cf 100644
5351 --- a/arch/mips/include/asm/atomic.h
5352 +++ b/arch/mips/include/asm/atomic.h
5353 @@ -21,6 +21,10 @@
5354 #include <asm/cmpxchg.h>
5355 #include <asm/war.h>
5356
5357 +#ifdef CONFIG_GENERIC_ATOMIC64
5358 +#include <asm-generic/atomic64.h>
5359 +#endif
5360 +
5361 #define ATOMIC_INIT(i) { (i) }
5362
5363 /*
5364 @@ -759,6 +763,16 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
5365 */
5366 #define atomic64_add_negative(i, v) (atomic64_add_return(i, (v)) < 0)
5367
5368 +#define atomic64_read_unchecked(v) atomic64_read(v)
5369 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5370 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5371 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5372 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5373 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5374 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5375 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5376 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5377 +
5378 #endif /* CONFIG_64BIT */
5379
5380 /*
5381 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
5382 index b4db69f..8f3b093 100644
5383 --- a/arch/mips/include/asm/cache.h
5384 +++ b/arch/mips/include/asm/cache.h
5385 @@ -9,10 +9,11 @@
5386 #ifndef _ASM_CACHE_H
5387 #define _ASM_CACHE_H
5388
5389 +#include <linux/const.h>
5390 #include <kmalloc.h>
5391
5392 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
5393 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5394 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5395
5396 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
5397 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5398 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
5399 index cf3ae24..238d22f 100644
5400 --- a/arch/mips/include/asm/elf.h
5401 +++ b/arch/mips/include/asm/elf.h
5402 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
5403 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
5404 #endif
5405
5406 +#ifdef CONFIG_PAX_ASLR
5407 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5408 +
5409 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5410 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5411 +#endif
5412 +
5413 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
5414 struct linux_binprm;
5415 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
5416 int uses_interp);
5417
5418 -struct mm_struct;
5419 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
5420 -#define arch_randomize_brk arch_randomize_brk
5421 -
5422 #endif /* _ASM_ELF_H */
5423 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
5424 index c1f6afa..38cc6e9 100644
5425 --- a/arch/mips/include/asm/exec.h
5426 +++ b/arch/mips/include/asm/exec.h
5427 @@ -12,6 +12,6 @@
5428 #ifndef _ASM_EXEC_H
5429 #define _ASM_EXEC_H
5430
5431 -extern unsigned long arch_align_stack(unsigned long sp);
5432 +#define arch_align_stack(x) ((x) & ~0xfUL)
5433
5434 #endif /* _ASM_EXEC_H */
5435 diff --git a/arch/mips/include/asm/local.h b/arch/mips/include/asm/local.h
5436 index d44622c..64990d2 100644
5437 --- a/arch/mips/include/asm/local.h
5438 +++ b/arch/mips/include/asm/local.h
5439 @@ -12,15 +12,25 @@ typedef struct
5440 atomic_long_t a;
5441 } local_t;
5442
5443 +typedef struct {
5444 + atomic_long_unchecked_t a;
5445 +} local_unchecked_t;
5446 +
5447 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
5448
5449 #define local_read(l) atomic_long_read(&(l)->a)
5450 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
5451 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
5452 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
5453
5454 #define local_add(i, l) atomic_long_add((i), (&(l)->a))
5455 +#define local_add_unchecked(i, l) atomic_long_add_unchecked((i), (&(l)->a))
5456 #define local_sub(i, l) atomic_long_sub((i), (&(l)->a))
5457 +#define local_sub_unchecked(i, l) atomic_long_sub_unchecked((i), (&(l)->a))
5458 #define local_inc(l) atomic_long_inc(&(l)->a)
5459 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
5460 #define local_dec(l) atomic_long_dec(&(l)->a)
5461 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
5462
5463 /*
5464 * Same as above, but return the result value
5465 @@ -70,6 +80,51 @@ static __inline__ long local_add_return(long i, local_t * l)
5466 return result;
5467 }
5468
5469 +static __inline__ long local_add_return_unchecked(long i, local_unchecked_t * l)
5470 +{
5471 + unsigned long result;
5472 +
5473 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5474 + unsigned long temp;
5475 +
5476 + __asm__ __volatile__(
5477 + " .set mips3 \n"
5478 + "1:" __LL "%1, %2 # local_add_return \n"
5479 + " addu %0, %1, %3 \n"
5480 + __SC "%0, %2 \n"
5481 + " beqzl %0, 1b \n"
5482 + " addu %0, %1, %3 \n"
5483 + " .set mips0 \n"
5484 + : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
5485 + : "Ir" (i), "m" (l->a.counter)
5486 + : "memory");
5487 + } else if (kernel_uses_llsc) {
5488 + unsigned long temp;
5489 +
5490 + __asm__ __volatile__(
5491 + " .set mips3 \n"
5492 + "1:" __LL "%1, %2 # local_add_return \n"
5493 + " addu %0, %1, %3 \n"
5494 + __SC "%0, %2 \n"
5495 + " beqz %0, 1b \n"
5496 + " addu %0, %1, %3 \n"
5497 + " .set mips0 \n"
5498 + : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
5499 + : "Ir" (i), "m" (l->a.counter)
5500 + : "memory");
5501 + } else {
5502 + unsigned long flags;
5503 +
5504 + local_irq_save(flags);
5505 + result = l->a.counter;
5506 + result += i;
5507 + l->a.counter = result;
5508 + local_irq_restore(flags);
5509 + }
5510 +
5511 + return result;
5512 +}
5513 +
5514 static __inline__ long local_sub_return(long i, local_t * l)
5515 {
5516 unsigned long result;
5517 @@ -117,6 +172,8 @@ static __inline__ long local_sub_return(long i, local_t * l)
5518
5519 #define local_cmpxchg(l, o, n) \
5520 ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
5521 +#define local_cmpxchg_unchecked(l, o, n) \
5522 + ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
5523 #define local_xchg(l, n) (atomic_long_xchg((&(l)->a), (n)))
5524
5525 /**
5526 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
5527 index f59552f..3abe9b9 100644
5528 --- a/arch/mips/include/asm/page.h
5529 +++ b/arch/mips/include/asm/page.h
5530 @@ -95,7 +95,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
5531 #ifdef CONFIG_CPU_MIPS32
5532 typedef struct { unsigned long pte_low, pte_high; } pte_t;
5533 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
5534 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
5535 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
5536 #else
5537 typedef struct { unsigned long long pte; } pte_t;
5538 #define pte_val(x) ((x).pte)
5539 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
5540 index 881d18b..cea38bc 100644
5541 --- a/arch/mips/include/asm/pgalloc.h
5542 +++ b/arch/mips/include/asm/pgalloc.h
5543 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5544 {
5545 set_pud(pud, __pud((unsigned long)pmd));
5546 }
5547 +
5548 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
5549 +{
5550 + pud_populate(mm, pud, pmd);
5551 +}
5552 #endif
5553
5554 /*
5555 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
5556 index 895320e..bf63e10 100644
5557 --- a/arch/mips/include/asm/thread_info.h
5558 +++ b/arch/mips/include/asm/thread_info.h
5559 @@ -115,6 +115,8 @@ static inline struct thread_info *current_thread_info(void)
5560 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
5561 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
5562 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
5563 +/* li takes a 32bit immediate */
5564 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
5565 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
5566
5567 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
5568 @@ -130,15 +132,18 @@ static inline struct thread_info *current_thread_info(void)
5569 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
5570 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
5571 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
5572 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
5573 +
5574 +#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5575
5576 /* work to do in syscall_trace_leave() */
5577 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT)
5578 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
5579
5580 /* work to do on interrupt/exception return */
5581 #define _TIF_WORK_MASK \
5582 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
5583 /* work to do on any return to u-space */
5584 -#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT)
5585 +#define _TIF_ALLWORK_MASK (_TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT | _TIF_GRSEC_SETXID)
5586
5587 #endif /* __KERNEL__ */
5588
5589 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
5590 index 1188e00..41cf144 100644
5591 --- a/arch/mips/kernel/binfmt_elfn32.c
5592 +++ b/arch/mips/kernel/binfmt_elfn32.c
5593 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5594 #undef ELF_ET_DYN_BASE
5595 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5596
5597 +#ifdef CONFIG_PAX_ASLR
5598 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5599 +
5600 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5601 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5602 +#endif
5603 +
5604 #include <asm/processor.h>
5605 #include <linux/module.h>
5606 #include <linux/elfcore.h>
5607 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
5608 index 202e581..689ca79 100644
5609 --- a/arch/mips/kernel/binfmt_elfo32.c
5610 +++ b/arch/mips/kernel/binfmt_elfo32.c
5611 @@ -56,6 +56,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
5612 #undef ELF_ET_DYN_BASE
5613 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
5614
5615 +#ifdef CONFIG_PAX_ASLR
5616 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
5617 +
5618 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5619 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
5620 +#endif
5621 +
5622 #include <asm/processor.h>
5623
5624 /*
5625 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
5626 index c6a041d..b3e7318 100644
5627 --- a/arch/mips/kernel/process.c
5628 +++ b/arch/mips/kernel/process.c
5629 @@ -563,15 +563,3 @@ unsigned long get_wchan(struct task_struct *task)
5630 out:
5631 return pc;
5632 }
5633 -
5634 -/*
5635 - * Don't forget that the stack pointer must be aligned on a 8 bytes
5636 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
5637 - */
5638 -unsigned long arch_align_stack(unsigned long sp)
5639 -{
5640 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
5641 - sp -= get_random_int() & ~PAGE_MASK;
5642 -
5643 - return sp & ALMASK;
5644 -}
5645 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
5646 index 9c6299c..2fb4c22 100644
5647 --- a/arch/mips/kernel/ptrace.c
5648 +++ b/arch/mips/kernel/ptrace.c
5649 @@ -528,6 +528,10 @@ static inline int audit_arch(void)
5650 return arch;
5651 }
5652
5653 +#ifdef CONFIG_GRKERNSEC_SETXID
5654 +extern void gr_delayed_cred_worker(void);
5655 +#endif
5656 +
5657 /*
5658 * Notification of system call entry/exit
5659 * - triggered by current->work.syscall_trace
5660 @@ -537,6 +541,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
5661 /* do the secure computing check first */
5662 secure_computing_strict(regs->regs[2]);
5663
5664 +#ifdef CONFIG_GRKERNSEC_SETXID
5665 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
5666 + gr_delayed_cred_worker();
5667 +#endif
5668 +
5669 if (!(current->ptrace & PT_PTRACED))
5670 goto out;
5671
5672 diff --git a/arch/mips/kernel/scall32-o32.S b/arch/mips/kernel/scall32-o32.S
5673 index 9b36424..e7f4154 100644
5674 --- a/arch/mips/kernel/scall32-o32.S
5675 +++ b/arch/mips/kernel/scall32-o32.S
5676 @@ -52,7 +52,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5677
5678 stack_done:
5679 lw t0, TI_FLAGS($28) # syscall tracing enabled?
5680 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5681 + li t1, _TIF_SYSCALL_WORK
5682 and t0, t1
5683 bnez t0, syscall_trace_entry # -> yes
5684
5685 diff --git a/arch/mips/kernel/scall64-64.S b/arch/mips/kernel/scall64-64.S
5686 index 97a5909..59622f8 100644
5687 --- a/arch/mips/kernel/scall64-64.S
5688 +++ b/arch/mips/kernel/scall64-64.S
5689 @@ -54,7 +54,7 @@ NESTED(handle_sys64, PT_SIZE, sp)
5690
5691 sd a3, PT_R26(sp) # save a3 for syscall restarting
5692
5693 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5694 + li t1, _TIF_SYSCALL_WORK
5695 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5696 and t0, t1, t0
5697 bnez t0, syscall_trace_entry
5698 diff --git a/arch/mips/kernel/scall64-n32.S b/arch/mips/kernel/scall64-n32.S
5699 index edcb659..fb2ab09 100644
5700 --- a/arch/mips/kernel/scall64-n32.S
5701 +++ b/arch/mips/kernel/scall64-n32.S
5702 @@ -47,7 +47,7 @@ NESTED(handle_sysn32, PT_SIZE, sp)
5703
5704 sd a3, PT_R26(sp) # save a3 for syscall restarting
5705
5706 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5707 + li t1, _TIF_SYSCALL_WORK
5708 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5709 and t0, t1, t0
5710 bnez t0, n32_syscall_trace_entry
5711 diff --git a/arch/mips/kernel/scall64-o32.S b/arch/mips/kernel/scall64-o32.S
5712 index 74f485d..47d2c38 100644
5713 --- a/arch/mips/kernel/scall64-o32.S
5714 +++ b/arch/mips/kernel/scall64-o32.S
5715 @@ -81,7 +81,7 @@ NESTED(handle_sys, PT_SIZE, sp)
5716 PTR 4b, bad_stack
5717 .previous
5718
5719 - li t1, _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT
5720 + li t1, _TIF_SYSCALL_WORK
5721 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
5722 and t0, t1, t0
5723 bnez t0, trace_a_syscall
5724 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
5725 index 0fead53..eeb00a6 100644
5726 --- a/arch/mips/mm/fault.c
5727 +++ b/arch/mips/mm/fault.c
5728 @@ -27,6 +27,23 @@
5729 #include <asm/highmem.h> /* For VMALLOC_END */
5730 #include <linux/kdebug.h>
5731
5732 +#ifdef CONFIG_PAX_PAGEEXEC
5733 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5734 +{
5735 + unsigned long i;
5736 +
5737 + printk(KERN_ERR "PAX: bytes at PC: ");
5738 + for (i = 0; i < 5; i++) {
5739 + unsigned int c;
5740 + if (get_user(c, (unsigned int *)pc+i))
5741 + printk(KERN_CONT "???????? ");
5742 + else
5743 + printk(KERN_CONT "%08x ", c);
5744 + }
5745 + printk("\n");
5746 +}
5747 +#endif
5748 +
5749 /*
5750 * This routine handles page faults. It determines the address,
5751 * and the problem, and then passes it off to one of the appropriate
5752 @@ -196,6 +213,14 @@ bad_area:
5753 bad_area_nosemaphore:
5754 /* User mode accesses just cause a SIGSEGV */
5755 if (user_mode(regs)) {
5756 +
5757 +#ifdef CONFIG_PAX_PAGEEXEC
5758 + if (cpu_has_rixi && (mm->pax_flags & MF_PAX_PAGEEXEC) && !write && address == instruction_pointer(regs)) {
5759 + pax_report_fault(regs, (void *)address, (void *)user_stack_pointer(regs));
5760 + do_group_exit(SIGKILL);
5761 + }
5762 +#endif
5763 +
5764 tsk->thread.cp0_badvaddr = address;
5765 tsk->thread.error_code = write;
5766 #if 0
5767 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
5768 index 7e5fe27..9656513 100644
5769 --- a/arch/mips/mm/mmap.c
5770 +++ b/arch/mips/mm/mmap.c
5771 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5772 struct vm_area_struct *vma;
5773 unsigned long addr = addr0;
5774 int do_color_align;
5775 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5776 struct vm_unmapped_area_info info;
5777
5778 if (unlikely(len > TASK_SIZE))
5779 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5780 do_color_align = 1;
5781
5782 /* requesting a specific address */
5783 +
5784 +#ifdef CONFIG_PAX_RANDMMAP
5785 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
5786 +#endif
5787 +
5788 if (addr) {
5789 if (do_color_align)
5790 addr = COLOUR_ALIGN(addr, pgoff);
5791 @@ -91,14 +97,14 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
5792 addr = PAGE_ALIGN(addr);
5793
5794 vma = find_vma(mm, addr);
5795 - if (TASK_SIZE - len >= addr &&
5796 - (!vma || addr + len <= vma->vm_start))
5797 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len, offset))
5798 return addr;
5799 }
5800
5801 info.length = len;
5802 info.align_mask = do_color_align ? (PAGE_MASK & shm_align_mask) : 0;
5803 info.align_offset = pgoff << PAGE_SHIFT;
5804 + info.threadstack_offset = offset;
5805
5806 if (dir == DOWN) {
5807 info.flags = VM_UNMAPPED_AREA_TOPDOWN;
5808 @@ -146,6 +152,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5809 {
5810 unsigned long random_factor = 0UL;
5811
5812 +#ifdef CONFIG_PAX_RANDMMAP
5813 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
5814 +#endif
5815 +
5816 if (current->flags & PF_RANDOMIZE) {
5817 random_factor = get_random_int();
5818 random_factor = random_factor << PAGE_SHIFT;
5819 @@ -157,42 +167,27 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
5820
5821 if (mmap_is_legacy()) {
5822 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
5823 +
5824 +#ifdef CONFIG_PAX_RANDMMAP
5825 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5826 + mm->mmap_base += mm->delta_mmap;
5827 +#endif
5828 +
5829 mm->get_unmapped_area = arch_get_unmapped_area;
5830 mm->unmap_area = arch_unmap_area;
5831 } else {
5832 mm->mmap_base = mmap_base(random_factor);
5833 +
5834 +#ifdef CONFIG_PAX_RANDMMAP
5835 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5836 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
5837 +#endif
5838 +
5839 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
5840 mm->unmap_area = arch_unmap_area_topdown;
5841 }
5842 }
5843
5844 -static inline unsigned long brk_rnd(void)
5845 -{
5846 - unsigned long rnd = get_random_int();
5847 -
5848 - rnd = rnd << PAGE_SHIFT;
5849 - /* 8MB for 32bit, 256MB for 64bit */
5850 - if (TASK_IS_32BIT_ADDR)
5851 - rnd = rnd & 0x7ffffful;
5852 - else
5853 - rnd = rnd & 0xffffffful;
5854 -
5855 - return rnd;
5856 -}
5857 -
5858 -unsigned long arch_randomize_brk(struct mm_struct *mm)
5859 -{
5860 - unsigned long base = mm->brk;
5861 - unsigned long ret;
5862 -
5863 - ret = PAGE_ALIGN(base + brk_rnd());
5864 -
5865 - if (ret < mm->brk)
5866 - return mm->brk;
5867 -
5868 - return ret;
5869 -}
5870 -
5871 int __virt_addr_valid(const volatile void *kaddr)
5872 {
5873 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
5874 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5875 index 967d144..db12197 100644
5876 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
5877 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
5878 @@ -11,12 +11,14 @@
5879 #ifndef _ASM_PROC_CACHE_H
5880 #define _ASM_PROC_CACHE_H
5881
5882 +#include <linux/const.h>
5883 +
5884 /* L1 cache */
5885
5886 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5887 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
5888 -#define L1_CACHE_BYTES 16 /* bytes per entry */
5889 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
5890 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5891 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
5892
5893 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5894 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5895 index bcb5df2..84fabd2 100644
5896 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5897 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
5898 @@ -16,13 +16,15 @@
5899 #ifndef _ASM_PROC_CACHE_H
5900 #define _ASM_PROC_CACHE_H
5901
5902 +#include <linux/const.h>
5903 +
5904 /*
5905 * L1 cache
5906 */
5907 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
5908 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
5909 -#define L1_CACHE_BYTES 32 /* bytes per entry */
5910 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
5911 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
5912 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
5913
5914 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
5915 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
5916 index 4ce7a01..449202a 100644
5917 --- a/arch/openrisc/include/asm/cache.h
5918 +++ b/arch/openrisc/include/asm/cache.h
5919 @@ -19,11 +19,13 @@
5920 #ifndef __ASM_OPENRISC_CACHE_H
5921 #define __ASM_OPENRISC_CACHE_H
5922
5923 +#include <linux/const.h>
5924 +
5925 /* FIXME: How can we replace these with values from the CPU...
5926 * they shouldn't be hard-coded!
5927 */
5928
5929 -#define L1_CACHE_BYTES 16
5930 #define L1_CACHE_SHIFT 4
5931 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5932
5933 #endif /* __ASM_OPENRISC_CACHE_H */
5934 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
5935 index 472886c..00e7df9 100644
5936 --- a/arch/parisc/include/asm/atomic.h
5937 +++ b/arch/parisc/include/asm/atomic.h
5938 @@ -252,6 +252,16 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
5939 return dec;
5940 }
5941
5942 +#define atomic64_read_unchecked(v) atomic64_read(v)
5943 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
5944 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
5945 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
5946 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
5947 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
5948 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
5949 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
5950 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
5951 +
5952 #endif /* !CONFIG_64BIT */
5953
5954
5955 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
5956 index 47f11c7..3420df2 100644
5957 --- a/arch/parisc/include/asm/cache.h
5958 +++ b/arch/parisc/include/asm/cache.h
5959 @@ -5,6 +5,7 @@
5960 #ifndef __ARCH_PARISC_CACHE_H
5961 #define __ARCH_PARISC_CACHE_H
5962
5963 +#include <linux/const.h>
5964
5965 /*
5966 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
5967 @@ -15,13 +16,13 @@
5968 * just ruin performance.
5969 */
5970 #ifdef CONFIG_PA20
5971 -#define L1_CACHE_BYTES 64
5972 #define L1_CACHE_SHIFT 6
5973 #else
5974 -#define L1_CACHE_BYTES 32
5975 #define L1_CACHE_SHIFT 5
5976 #endif
5977
5978 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5979 +
5980 #ifndef __ASSEMBLY__
5981
5982 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5983 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
5984 index ad2b503..bdf1651 100644
5985 --- a/arch/parisc/include/asm/elf.h
5986 +++ b/arch/parisc/include/asm/elf.h
5987 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
5988
5989 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
5990
5991 +#ifdef CONFIG_PAX_ASLR
5992 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
5993 +
5994 +#define PAX_DELTA_MMAP_LEN 16
5995 +#define PAX_DELTA_STACK_LEN 16
5996 +#endif
5997 +
5998 /* This yields a mask that user programs can use to figure out what
5999 instruction set this CPU supports. This could be done in user space,
6000 but it's not easy, and we've already done it here. */
6001 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
6002 index fc987a1..6e068ef 100644
6003 --- a/arch/parisc/include/asm/pgalloc.h
6004 +++ b/arch/parisc/include/asm/pgalloc.h
6005 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
6006 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
6007 }
6008
6009 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
6010 +{
6011 + pgd_populate(mm, pgd, pmd);
6012 +}
6013 +
6014 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
6015 {
6016 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
6017 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
6018 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
6019 #define pmd_free(mm, x) do { } while (0)
6020 #define pgd_populate(mm, pmd, pte) BUG()
6021 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
6022
6023 #endif
6024
6025 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
6026 index 1e40d7f..a3eb445 100644
6027 --- a/arch/parisc/include/asm/pgtable.h
6028 +++ b/arch/parisc/include/asm/pgtable.h
6029 @@ -223,6 +223,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
6030 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
6031 #define PAGE_COPY PAGE_EXECREAD
6032 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
6033 +
6034 +#ifdef CONFIG_PAX_PAGEEXEC
6035 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
6036 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
6037 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
6038 +#else
6039 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
6040 +# define PAGE_COPY_NOEXEC PAGE_COPY
6041 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
6042 +#endif
6043 +
6044 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
6045 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
6046 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
6047 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
6048 index e0a8235..ce2f1e1 100644
6049 --- a/arch/parisc/include/asm/uaccess.h
6050 +++ b/arch/parisc/include/asm/uaccess.h
6051 @@ -245,10 +245,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
6052 const void __user *from,
6053 unsigned long n)
6054 {
6055 - int sz = __compiletime_object_size(to);
6056 + size_t sz = __compiletime_object_size(to);
6057 int ret = -EFAULT;
6058
6059 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
6060 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
6061 ret = __copy_from_user(to, from, n);
6062 else
6063 copy_from_user_overflow();
6064 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
6065 index 2a625fb..9908930 100644
6066 --- a/arch/parisc/kernel/module.c
6067 +++ b/arch/parisc/kernel/module.c
6068 @@ -98,16 +98,38 @@
6069
6070 /* three functions to determine where in the module core
6071 * or init pieces the location is */
6072 +static inline int in_init_rx(struct module *me, void *loc)
6073 +{
6074 + return (loc >= me->module_init_rx &&
6075 + loc < (me->module_init_rx + me->init_size_rx));
6076 +}
6077 +
6078 +static inline int in_init_rw(struct module *me, void *loc)
6079 +{
6080 + return (loc >= me->module_init_rw &&
6081 + loc < (me->module_init_rw + me->init_size_rw));
6082 +}
6083 +
6084 static inline int in_init(struct module *me, void *loc)
6085 {
6086 - return (loc >= me->module_init &&
6087 - loc <= (me->module_init + me->init_size));
6088 + return in_init_rx(me, loc) || in_init_rw(me, loc);
6089 +}
6090 +
6091 +static inline int in_core_rx(struct module *me, void *loc)
6092 +{
6093 + return (loc >= me->module_core_rx &&
6094 + loc < (me->module_core_rx + me->core_size_rx));
6095 +}
6096 +
6097 +static inline int in_core_rw(struct module *me, void *loc)
6098 +{
6099 + return (loc >= me->module_core_rw &&
6100 + loc < (me->module_core_rw + me->core_size_rw));
6101 }
6102
6103 static inline int in_core(struct module *me, void *loc)
6104 {
6105 - return (loc >= me->module_core &&
6106 - loc <= (me->module_core + me->core_size));
6107 + return in_core_rx(me, loc) || in_core_rw(me, loc);
6108 }
6109
6110 static inline int in_local(struct module *me, void *loc)
6111 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
6112 }
6113
6114 /* align things a bit */
6115 - me->core_size = ALIGN(me->core_size, 16);
6116 - me->arch.got_offset = me->core_size;
6117 - me->core_size += gots * sizeof(struct got_entry);
6118 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
6119 + me->arch.got_offset = me->core_size_rw;
6120 + me->core_size_rw += gots * sizeof(struct got_entry);
6121
6122 - me->core_size = ALIGN(me->core_size, 16);
6123 - me->arch.fdesc_offset = me->core_size;
6124 - me->core_size += fdescs * sizeof(Elf_Fdesc);
6125 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
6126 + me->arch.fdesc_offset = me->core_size_rw;
6127 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
6128
6129 me->arch.got_max = gots;
6130 me->arch.fdesc_max = fdescs;
6131 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
6132
6133 BUG_ON(value == 0);
6134
6135 - got = me->module_core + me->arch.got_offset;
6136 + got = me->module_core_rw + me->arch.got_offset;
6137 for (i = 0; got[i].addr; i++)
6138 if (got[i].addr == value)
6139 goto out;
6140 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
6141 #ifdef CONFIG_64BIT
6142 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
6143 {
6144 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
6145 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
6146
6147 if (!value) {
6148 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
6149 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
6150
6151 /* Create new one */
6152 fdesc->addr = value;
6153 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
6154 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
6155 return (Elf_Addr)fdesc;
6156 }
6157 #endif /* CONFIG_64BIT */
6158 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
6159
6160 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
6161 end = table + sechdrs[me->arch.unwind_section].sh_size;
6162 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
6163 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
6164
6165 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
6166 me->arch.unwind_section, table, end, gp);
6167 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
6168 index 5dfd248..64914ac 100644
6169 --- a/arch/parisc/kernel/sys_parisc.c
6170 +++ b/arch/parisc/kernel/sys_parisc.c
6171 @@ -33,9 +33,11 @@
6172 #include <linux/utsname.h>
6173 #include <linux/personality.h>
6174
6175 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
6176 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
6177 + unsigned long flags)
6178 {
6179 struct vm_unmapped_area_info info;
6180 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
6181
6182 info.flags = 0;
6183 info.length = len;
6184 @@ -43,6 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
6185 info.high_limit = TASK_SIZE;
6186 info.align_mask = 0;
6187 info.align_offset = 0;
6188 + info.threadstack_offset = offset;
6189 return vm_unmapped_area(&info);
6190 }
6191
6192 @@ -61,10 +64,11 @@ static int get_offset(struct address_space *mapping)
6193 return (unsigned long) mapping >> 8;
6194 }
6195
6196 -static unsigned long get_shared_area(struct address_space *mapping,
6197 - unsigned long addr, unsigned long len, unsigned long pgoff)
6198 +static unsigned long get_shared_area(struct file *filp, struct address_space *mapping,
6199 + unsigned long addr, unsigned long len, unsigned long pgoff, unsigned long flags)
6200 {
6201 struct vm_unmapped_area_info info;
6202 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
6203
6204 info.flags = 0;
6205 info.length = len;
6206 @@ -72,6 +76,7 @@ static unsigned long get_shared_area(struct address_space *mapping,
6207 info.high_limit = TASK_SIZE;
6208 info.align_mask = PAGE_MASK & (SHMLBA - 1);
6209 info.align_offset = (get_offset(mapping) + pgoff) << PAGE_SHIFT;
6210 + info.threadstack_offset = offset;
6211 return vm_unmapped_area(&info);
6212 }
6213
6214 @@ -86,15 +91,22 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
6215 return -EINVAL;
6216 return addr;
6217 }
6218 - if (!addr)
6219 + if (!addr) {
6220 addr = TASK_UNMAPPED_BASE;
6221
6222 +#ifdef CONFIG_PAX_RANDMMAP
6223 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
6224 + addr += current->mm->delta_mmap;
6225 +#endif
6226 +
6227 + }
6228 +
6229 if (filp) {
6230 - addr = get_shared_area(filp->f_mapping, addr, len, pgoff);
6231 + addr = get_shared_area(filp, filp->f_mapping, addr, len, pgoff, flags);
6232 } else if(flags & MAP_SHARED) {
6233 - addr = get_shared_area(NULL, addr, len, pgoff);
6234 + addr = get_shared_area(filp, NULL, addr, len, pgoff, flags);
6235 } else {
6236 - addr = get_unshared_area(addr, len);
6237 + addr = get_unshared_area(filp, addr, len, flags);
6238 }
6239 return addr;
6240 }
6241 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
6242 index 04e47c6..7a8faf6 100644
6243 --- a/arch/parisc/kernel/traps.c
6244 +++ b/arch/parisc/kernel/traps.c
6245 @@ -727,9 +727,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
6246
6247 down_read(&current->mm->mmap_sem);
6248 vma = find_vma(current->mm,regs->iaoq[0]);
6249 - if (vma && (regs->iaoq[0] >= vma->vm_start)
6250 - && (vma->vm_flags & VM_EXEC)) {
6251 -
6252 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
6253 fault_address = regs->iaoq[0];
6254 fault_space = regs->iasq[0];
6255
6256 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
6257 index f247a34..dc0f219 100644
6258 --- a/arch/parisc/mm/fault.c
6259 +++ b/arch/parisc/mm/fault.c
6260 @@ -15,6 +15,7 @@
6261 #include <linux/sched.h>
6262 #include <linux/interrupt.h>
6263 #include <linux/module.h>
6264 +#include <linux/unistd.h>
6265
6266 #include <asm/uaccess.h>
6267 #include <asm/traps.h>
6268 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
6269 static unsigned long
6270 parisc_acctyp(unsigned long code, unsigned int inst)
6271 {
6272 - if (code == 6 || code == 16)
6273 + if (code == 6 || code == 7 || code == 16)
6274 return VM_EXEC;
6275
6276 switch (inst & 0xf0000000) {
6277 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
6278 }
6279 #endif
6280
6281 +#ifdef CONFIG_PAX_PAGEEXEC
6282 +/*
6283 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
6284 + *
6285 + * returns 1 when task should be killed
6286 + * 2 when rt_sigreturn trampoline was detected
6287 + * 3 when unpatched PLT trampoline was detected
6288 + */
6289 +static int pax_handle_fetch_fault(struct pt_regs *regs)
6290 +{
6291 +
6292 +#ifdef CONFIG_PAX_EMUPLT
6293 + int err;
6294 +
6295 + do { /* PaX: unpatched PLT emulation */
6296 + unsigned int bl, depwi;
6297 +
6298 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
6299 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
6300 +
6301 + if (err)
6302 + break;
6303 +
6304 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
6305 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
6306 +
6307 + err = get_user(ldw, (unsigned int *)addr);
6308 + err |= get_user(bv, (unsigned int *)(addr+4));
6309 + err |= get_user(ldw2, (unsigned int *)(addr+8));
6310 +
6311 + if (err)
6312 + break;
6313 +
6314 + if (ldw == 0x0E801096U &&
6315 + bv == 0xEAC0C000U &&
6316 + ldw2 == 0x0E881095U)
6317 + {
6318 + unsigned int resolver, map;
6319 +
6320 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
6321 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
6322 + if (err)
6323 + break;
6324 +
6325 + regs->gr[20] = instruction_pointer(regs)+8;
6326 + regs->gr[21] = map;
6327 + regs->gr[22] = resolver;
6328 + regs->iaoq[0] = resolver | 3UL;
6329 + regs->iaoq[1] = regs->iaoq[0] + 4;
6330 + return 3;
6331 + }
6332 + }
6333 + } while (0);
6334 +#endif
6335 +
6336 +#ifdef CONFIG_PAX_EMUTRAMP
6337 +
6338 +#ifndef CONFIG_PAX_EMUSIGRT
6339 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
6340 + return 1;
6341 +#endif
6342 +
6343 + do { /* PaX: rt_sigreturn emulation */
6344 + unsigned int ldi1, ldi2, bel, nop;
6345 +
6346 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
6347 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
6348 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
6349 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
6350 +
6351 + if (err)
6352 + break;
6353 +
6354 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
6355 + ldi2 == 0x3414015AU &&
6356 + bel == 0xE4008200U &&
6357 + nop == 0x08000240U)
6358 + {
6359 + regs->gr[25] = (ldi1 & 2) >> 1;
6360 + regs->gr[20] = __NR_rt_sigreturn;
6361 + regs->gr[31] = regs->iaoq[1] + 16;
6362 + regs->sr[0] = regs->iasq[1];
6363 + regs->iaoq[0] = 0x100UL;
6364 + regs->iaoq[1] = regs->iaoq[0] + 4;
6365 + regs->iasq[0] = regs->sr[2];
6366 + regs->iasq[1] = regs->sr[2];
6367 + return 2;
6368 + }
6369 + } while (0);
6370 +#endif
6371 +
6372 + return 1;
6373 +}
6374 +
6375 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6376 +{
6377 + unsigned long i;
6378 +
6379 + printk(KERN_ERR "PAX: bytes at PC: ");
6380 + for (i = 0; i < 5; i++) {
6381 + unsigned int c;
6382 + if (get_user(c, (unsigned int *)pc+i))
6383 + printk(KERN_CONT "???????? ");
6384 + else
6385 + printk(KERN_CONT "%08x ", c);
6386 + }
6387 + printk("\n");
6388 +}
6389 +#endif
6390 +
6391 int fixup_exception(struct pt_regs *regs)
6392 {
6393 const struct exception_table_entry *fix;
6394 @@ -194,8 +305,33 @@ good_area:
6395
6396 acc_type = parisc_acctyp(code,regs->iir);
6397
6398 - if ((vma->vm_flags & acc_type) != acc_type)
6399 + if ((vma->vm_flags & acc_type) != acc_type) {
6400 +
6401 +#ifdef CONFIG_PAX_PAGEEXEC
6402 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
6403 + (address & ~3UL) == instruction_pointer(regs))
6404 + {
6405 + up_read(&mm->mmap_sem);
6406 + switch (pax_handle_fetch_fault(regs)) {
6407 +
6408 +#ifdef CONFIG_PAX_EMUPLT
6409 + case 3:
6410 + return;
6411 +#endif
6412 +
6413 +#ifdef CONFIG_PAX_EMUTRAMP
6414 + case 2:
6415 + return;
6416 +#endif
6417 +
6418 + }
6419 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
6420 + do_group_exit(SIGKILL);
6421 + }
6422 +#endif
6423 +
6424 goto bad_area;
6425 + }
6426
6427 /*
6428 * If for any reason at all we couldn't handle the fault, make
6429 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
6430 index e3b1d41..8e81edf 100644
6431 --- a/arch/powerpc/include/asm/atomic.h
6432 +++ b/arch/powerpc/include/asm/atomic.h
6433 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
6434 return t1;
6435 }
6436
6437 +#define atomic64_read_unchecked(v) atomic64_read(v)
6438 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
6439 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
6440 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
6441 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
6442 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
6443 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
6444 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
6445 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
6446 +
6447 #endif /* __powerpc64__ */
6448
6449 #endif /* __KERNEL__ */
6450 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
6451 index 9e495c9..b6878e5 100644
6452 --- a/arch/powerpc/include/asm/cache.h
6453 +++ b/arch/powerpc/include/asm/cache.h
6454 @@ -3,6 +3,7 @@
6455
6456 #ifdef __KERNEL__
6457
6458 +#include <linux/const.h>
6459
6460 /* bytes per L1 cache line */
6461 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
6462 @@ -22,7 +23,7 @@
6463 #define L1_CACHE_SHIFT 7
6464 #endif
6465
6466 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6467 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6468
6469 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6470
6471 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
6472 index cc0655a..13eac2e 100644
6473 --- a/arch/powerpc/include/asm/elf.h
6474 +++ b/arch/powerpc/include/asm/elf.h
6475 @@ -28,8 +28,19 @@
6476 the loader. We need to make sure that it is out of the way of the program
6477 that it will "exec", and that there is sufficient room for the brk. */
6478
6479 -extern unsigned long randomize_et_dyn(unsigned long base);
6480 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
6481 +#define ELF_ET_DYN_BASE (0x20000000)
6482 +
6483 +#ifdef CONFIG_PAX_ASLR
6484 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
6485 +
6486 +#ifdef __powerpc64__
6487 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
6488 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
6489 +#else
6490 +#define PAX_DELTA_MMAP_LEN 15
6491 +#define PAX_DELTA_STACK_LEN 15
6492 +#endif
6493 +#endif
6494
6495 /*
6496 * Our registers are always unsigned longs, whether we're a 32 bit
6497 @@ -123,10 +134,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6498 (0x7ff >> (PAGE_SHIFT - 12)) : \
6499 (0x3ffff >> (PAGE_SHIFT - 12)))
6500
6501 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6502 -#define arch_randomize_brk arch_randomize_brk
6503 -
6504 -
6505 #ifdef CONFIG_SPU_BASE
6506 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
6507 #define NT_SPU 1
6508 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
6509 index 8196e9c..d83a9f3 100644
6510 --- a/arch/powerpc/include/asm/exec.h
6511 +++ b/arch/powerpc/include/asm/exec.h
6512 @@ -4,6 +4,6 @@
6513 #ifndef _ASM_POWERPC_EXEC_H
6514 #define _ASM_POWERPC_EXEC_H
6515
6516 -extern unsigned long arch_align_stack(unsigned long sp);
6517 +#define arch_align_stack(x) ((x) & ~0xfUL)
6518
6519 #endif /* _ASM_POWERPC_EXEC_H */
6520 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
6521 index 5acabbd..7ea14fa 100644
6522 --- a/arch/powerpc/include/asm/kmap_types.h
6523 +++ b/arch/powerpc/include/asm/kmap_types.h
6524 @@ -10,7 +10,7 @@
6525 * 2 of the License, or (at your option) any later version.
6526 */
6527
6528 -#define KM_TYPE_NR 16
6529 +#define KM_TYPE_NR 17
6530
6531 #endif /* __KERNEL__ */
6532 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
6533 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
6534 index 8565c25..2865190 100644
6535 --- a/arch/powerpc/include/asm/mman.h
6536 +++ b/arch/powerpc/include/asm/mman.h
6537 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
6538 }
6539 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
6540
6541 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
6542 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
6543 {
6544 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
6545 }
6546 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
6547 index 988c812..63c7d70 100644
6548 --- a/arch/powerpc/include/asm/page.h
6549 +++ b/arch/powerpc/include/asm/page.h
6550 @@ -220,8 +220,9 @@ extern long long virt_phys_offset;
6551 * and needs to be executable. This means the whole heap ends
6552 * up being executable.
6553 */
6554 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6555 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6556 +#define VM_DATA_DEFAULT_FLAGS32 \
6557 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6558 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6559
6560 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6561 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6562 @@ -249,6 +250,9 @@ extern long long virt_phys_offset;
6563 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
6564 #endif
6565
6566 +#define ktla_ktva(addr) (addr)
6567 +#define ktva_ktla(addr) (addr)
6568 +
6569 #ifndef CONFIG_PPC_BOOK3S_64
6570 /*
6571 * Use the top bit of the higher-level page table entries to indicate whether
6572 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
6573 index 88693ce..ac6f9ab 100644
6574 --- a/arch/powerpc/include/asm/page_64.h
6575 +++ b/arch/powerpc/include/asm/page_64.h
6576 @@ -153,15 +153,18 @@ do { \
6577 * stack by default, so in the absence of a PT_GNU_STACK program header
6578 * we turn execute permission off.
6579 */
6580 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
6581 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6582 +#define VM_STACK_DEFAULT_FLAGS32 \
6583 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
6584 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6585
6586 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
6587 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
6588
6589 +#ifndef CONFIG_PAX_PAGEEXEC
6590 #define VM_STACK_DEFAULT_FLAGS \
6591 (is_32bit_task() ? \
6592 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
6593 +#endif
6594
6595 #include <asm-generic/getorder.h>
6596
6597 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
6598 index b66ae72..4a378cd 100644
6599 --- a/arch/powerpc/include/asm/pgalloc-64.h
6600 +++ b/arch/powerpc/include/asm/pgalloc-64.h
6601 @@ -53,6 +53,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
6602 #ifndef CONFIG_PPC_64K_PAGES
6603
6604 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
6605 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
6606
6607 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
6608 {
6609 @@ -70,6 +71,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6610 pud_set(pud, (unsigned long)pmd);
6611 }
6612
6613 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6614 +{
6615 + pud_populate(mm, pud, pmd);
6616 +}
6617 +
6618 #define pmd_populate(mm, pmd, pte_page) \
6619 pmd_populate_kernel(mm, pmd, page_address(pte_page))
6620 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
6621 @@ -171,6 +177,7 @@ extern void __tlb_remove_table(void *_table);
6622 #endif
6623
6624 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
6625 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
6626
6627 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
6628 pte_t *pte)
6629 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
6630 index 7aeb955..19f748e 100644
6631 --- a/arch/powerpc/include/asm/pgtable.h
6632 +++ b/arch/powerpc/include/asm/pgtable.h
6633 @@ -2,6 +2,7 @@
6634 #define _ASM_POWERPC_PGTABLE_H
6635 #ifdef __KERNEL__
6636
6637 +#include <linux/const.h>
6638 #ifndef __ASSEMBLY__
6639 #include <asm/processor.h> /* For TASK_SIZE */
6640 #include <asm/mmu.h>
6641 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
6642 index 4aad413..85d86bf 100644
6643 --- a/arch/powerpc/include/asm/pte-hash32.h
6644 +++ b/arch/powerpc/include/asm/pte-hash32.h
6645 @@ -21,6 +21,7 @@
6646 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
6647 #define _PAGE_USER 0x004 /* usermode access allowed */
6648 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
6649 +#define _PAGE_EXEC _PAGE_GUARDED
6650 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
6651 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
6652 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
6653 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
6654 index e1fb161..2290d1d 100644
6655 --- a/arch/powerpc/include/asm/reg.h
6656 +++ b/arch/powerpc/include/asm/reg.h
6657 @@ -234,6 +234,7 @@
6658 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
6659 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
6660 #define DSISR_NOHPTE 0x40000000 /* no translation found */
6661 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
6662 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
6663 #define DSISR_ISSTORE 0x02000000 /* access was a store */
6664 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
6665 diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
6666 index 48cfc85..891382f 100644
6667 --- a/arch/powerpc/include/asm/smp.h
6668 +++ b/arch/powerpc/include/asm/smp.h
6669 @@ -50,7 +50,7 @@ struct smp_ops_t {
6670 int (*cpu_disable)(void);
6671 void (*cpu_die)(unsigned int nr);
6672 int (*cpu_bootable)(unsigned int nr);
6673 -};
6674 +} __no_const;
6675
6676 extern void smp_send_debugger_break(void);
6677 extern void start_secondary_resume(void);
6678 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
6679 index ba7b197..d292e26 100644
6680 --- a/arch/powerpc/include/asm/thread_info.h
6681 +++ b/arch/powerpc/include/asm/thread_info.h
6682 @@ -93,7 +93,6 @@ static inline struct thread_info *current_thread_info(void)
6683 #define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
6684 TIF_NEED_RESCHED */
6685 #define TIF_32BIT 4 /* 32 bit binary */
6686 -#define TIF_PERFMON_WORK 5 /* work for pfm_handle_work() */
6687 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
6688 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
6689 #define TIF_SINGLESTEP 8 /* singlestepping active */
6690 @@ -107,6 +106,9 @@ static inline struct thread_info *current_thread_info(void)
6691 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
6692 for stack store? */
6693 #define TIF_MEMDIE 17 /* is terminating due to OOM killer */
6694 +#define TIF_PERFMON_WORK 18 /* work for pfm_handle_work() */
6695 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
6696 +#define TIF_GRSEC_SETXID 5 /* update credentials on syscall entry/exit */
6697
6698 /* as above, but as bit values */
6699 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6700 @@ -126,9 +128,10 @@ static inline struct thread_info *current_thread_info(void)
6701 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
6702 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
6703 #define _TIF_NOHZ (1<<TIF_NOHZ)
6704 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6705 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
6706 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
6707 - _TIF_NOHZ)
6708 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
6709
6710 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
6711 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
6712 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
6713 index 4db4959..aba5c41 100644
6714 --- a/arch/powerpc/include/asm/uaccess.h
6715 +++ b/arch/powerpc/include/asm/uaccess.h
6716 @@ -318,52 +318,6 @@ do { \
6717 extern unsigned long __copy_tofrom_user(void __user *to,
6718 const void __user *from, unsigned long size);
6719
6720 -#ifndef __powerpc64__
6721 -
6722 -static inline unsigned long copy_from_user(void *to,
6723 - const void __user *from, unsigned long n)
6724 -{
6725 - unsigned long over;
6726 -
6727 - if (access_ok(VERIFY_READ, from, n))
6728 - return __copy_tofrom_user((__force void __user *)to, from, n);
6729 - if ((unsigned long)from < TASK_SIZE) {
6730 - over = (unsigned long)from + n - TASK_SIZE;
6731 - return __copy_tofrom_user((__force void __user *)to, from,
6732 - n - over) + over;
6733 - }
6734 - return n;
6735 -}
6736 -
6737 -static inline unsigned long copy_to_user(void __user *to,
6738 - const void *from, unsigned long n)
6739 -{
6740 - unsigned long over;
6741 -
6742 - if (access_ok(VERIFY_WRITE, to, n))
6743 - return __copy_tofrom_user(to, (__force void __user *)from, n);
6744 - if ((unsigned long)to < TASK_SIZE) {
6745 - over = (unsigned long)to + n - TASK_SIZE;
6746 - return __copy_tofrom_user(to, (__force void __user *)from,
6747 - n - over) + over;
6748 - }
6749 - return n;
6750 -}
6751 -
6752 -#else /* __powerpc64__ */
6753 -
6754 -#define __copy_in_user(to, from, size) \
6755 - __copy_tofrom_user((to), (from), (size))
6756 -
6757 -extern unsigned long copy_from_user(void *to, const void __user *from,
6758 - unsigned long n);
6759 -extern unsigned long copy_to_user(void __user *to, const void *from,
6760 - unsigned long n);
6761 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
6762 - unsigned long n);
6763 -
6764 -#endif /* __powerpc64__ */
6765 -
6766 static inline unsigned long __copy_from_user_inatomic(void *to,
6767 const void __user *from, unsigned long n)
6768 {
6769 @@ -387,6 +341,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
6770 if (ret == 0)
6771 return 0;
6772 }
6773 +
6774 + if (!__builtin_constant_p(n))
6775 + check_object_size(to, n, false);
6776 +
6777 return __copy_tofrom_user((__force void __user *)to, from, n);
6778 }
6779
6780 @@ -413,6 +371,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
6781 if (ret == 0)
6782 return 0;
6783 }
6784 +
6785 + if (!__builtin_constant_p(n))
6786 + check_object_size(from, n, true);
6787 +
6788 return __copy_tofrom_user(to, (__force const void __user *)from, n);
6789 }
6790
6791 @@ -430,6 +392,92 @@ static inline unsigned long __copy_to_user(void __user *to,
6792 return __copy_to_user_inatomic(to, from, size);
6793 }
6794
6795 +#ifndef __powerpc64__
6796 +
6797 +static inline unsigned long __must_check copy_from_user(void *to,
6798 + const void __user *from, unsigned long n)
6799 +{
6800 + unsigned long over;
6801 +
6802 + if ((long)n < 0)
6803 + return n;
6804 +
6805 + if (access_ok(VERIFY_READ, from, n)) {
6806 + if (!__builtin_constant_p(n))
6807 + check_object_size(to, n, false);
6808 + return __copy_tofrom_user((__force void __user *)to, from, n);
6809 + }
6810 + if ((unsigned long)from < TASK_SIZE) {
6811 + over = (unsigned long)from + n - TASK_SIZE;
6812 + if (!__builtin_constant_p(n - over))
6813 + check_object_size(to, n - over, false);
6814 + return __copy_tofrom_user((__force void __user *)to, from,
6815 + n - over) + over;
6816 + }
6817 + return n;
6818 +}
6819 +
6820 +static inline unsigned long __must_check copy_to_user(void __user *to,
6821 + const void *from, unsigned long n)
6822 +{
6823 + unsigned long over;
6824 +
6825 + if ((long)n < 0)
6826 + return n;
6827 +
6828 + if (access_ok(VERIFY_WRITE, to, n)) {
6829 + if (!__builtin_constant_p(n))
6830 + check_object_size(from, n, true);
6831 + return __copy_tofrom_user(to, (__force void __user *)from, n);
6832 + }
6833 + if ((unsigned long)to < TASK_SIZE) {
6834 + over = (unsigned long)to + n - TASK_SIZE;
6835 + if (!__builtin_constant_p(n))
6836 + check_object_size(from, n - over, true);
6837 + return __copy_tofrom_user(to, (__force void __user *)from,
6838 + n - over) + over;
6839 + }
6840 + return n;
6841 +}
6842 +
6843 +#else /* __powerpc64__ */
6844 +
6845 +#define __copy_in_user(to, from, size) \
6846 + __copy_tofrom_user((to), (from), (size))
6847 +
6848 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
6849 +{
6850 + if ((long)n < 0 || n > INT_MAX)
6851 + return n;
6852 +
6853 + if (!__builtin_constant_p(n))
6854 + check_object_size(to, n, false);
6855 +
6856 + if (likely(access_ok(VERIFY_READ, from, n)))
6857 + n = __copy_from_user(to, from, n);
6858 + else
6859 + memset(to, 0, n);
6860 + return n;
6861 +}
6862 +
6863 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
6864 +{
6865 + if ((long)n < 0 || n > INT_MAX)
6866 + return n;
6867 +
6868 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
6869 + if (!__builtin_constant_p(n))
6870 + check_object_size(from, n, true);
6871 + n = __copy_to_user(to, from, n);
6872 + }
6873 + return n;
6874 +}
6875 +
6876 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
6877 + unsigned long n);
6878 +
6879 +#endif /* __powerpc64__ */
6880 +
6881 extern unsigned long __clear_user(void __user *addr, unsigned long size);
6882
6883 static inline unsigned long clear_user(void __user *addr, unsigned long size)
6884 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
6885 index 645170a..6cf0271 100644
6886 --- a/arch/powerpc/kernel/exceptions-64e.S
6887 +++ b/arch/powerpc/kernel/exceptions-64e.S
6888 @@ -757,6 +757,7 @@ storage_fault_common:
6889 std r14,_DAR(r1)
6890 std r15,_DSISR(r1)
6891 addi r3,r1,STACK_FRAME_OVERHEAD
6892 + bl .save_nvgprs
6893 mr r4,r14
6894 mr r5,r15
6895 ld r14,PACA_EXGEN+EX_R14(r13)
6896 @@ -765,8 +766,7 @@ storage_fault_common:
6897 cmpdi r3,0
6898 bne- 1f
6899 b .ret_from_except_lite
6900 -1: bl .save_nvgprs
6901 - mr r5,r3
6902 +1: mr r5,r3
6903 addi r3,r1,STACK_FRAME_OVERHEAD
6904 ld r4,_DAR(r1)
6905 bl .bad_page_fault
6906 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
6907 index 902ca3c..e942155 100644
6908 --- a/arch/powerpc/kernel/exceptions-64s.S
6909 +++ b/arch/powerpc/kernel/exceptions-64s.S
6910 @@ -1357,10 +1357,10 @@ handle_page_fault:
6911 11: ld r4,_DAR(r1)
6912 ld r5,_DSISR(r1)
6913 addi r3,r1,STACK_FRAME_OVERHEAD
6914 + bl .save_nvgprs
6915 bl .do_page_fault
6916 cmpdi r3,0
6917 beq+ 12f
6918 - bl .save_nvgprs
6919 mr r5,r3
6920 addi r3,r1,STACK_FRAME_OVERHEAD
6921 lwz r4,_DAR(r1)
6922 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
6923 index 2e3200c..72095ce 100644
6924 --- a/arch/powerpc/kernel/module_32.c
6925 +++ b/arch/powerpc/kernel/module_32.c
6926 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
6927 me->arch.core_plt_section = i;
6928 }
6929 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
6930 - printk("Module doesn't contain .plt or .init.plt sections.\n");
6931 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
6932 return -ENOEXEC;
6933 }
6934
6935 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
6936
6937 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
6938 /* Init, or core PLT? */
6939 - if (location >= mod->module_core
6940 - && location < mod->module_core + mod->core_size)
6941 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
6942 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
6943 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
6944 - else
6945 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
6946 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
6947 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
6948 + else {
6949 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
6950 + return ~0UL;
6951 + }
6952
6953 /* Find this entry, or if that fails, the next avail. entry */
6954 while (entry->jump[0]) {
6955 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
6956 index 7baa27b..f6b394a 100644
6957 --- a/arch/powerpc/kernel/process.c
6958 +++ b/arch/powerpc/kernel/process.c
6959 @@ -884,8 +884,8 @@ void show_regs(struct pt_regs * regs)
6960 * Lookup NIP late so we have the best change of getting the
6961 * above info out without failing
6962 */
6963 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
6964 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
6965 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
6966 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
6967 #endif
6968 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
6969 printk("PACATMSCRATCH [%llx]\n", get_paca()->tm_scratch);
6970 @@ -1345,10 +1345,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
6971 newsp = stack[0];
6972 ip = stack[STACK_FRAME_LR_SAVE];
6973 if (!firstframe || ip != lr) {
6974 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
6975 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
6976 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
6977 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
6978 - printk(" (%pS)",
6979 + printk(" (%pA)",
6980 (void *)current->ret_stack[curr_frame].ret);
6981 curr_frame--;
6982 }
6983 @@ -1368,7 +1368,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
6984 struct pt_regs *regs = (struct pt_regs *)
6985 (sp + STACK_FRAME_OVERHEAD);
6986 lr = regs->link;
6987 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
6988 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
6989 regs->trap, (void *)regs->nip, (void *)lr);
6990 firstframe = 1;
6991 }
6992 @@ -1404,58 +1404,3 @@ void notrace __ppc64_runlatch_off(void)
6993 mtspr(SPRN_CTRLT, ctrl);
6994 }
6995 #endif /* CONFIG_PPC64 */
6996 -
6997 -unsigned long arch_align_stack(unsigned long sp)
6998 -{
6999 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
7000 - sp -= get_random_int() & ~PAGE_MASK;
7001 - return sp & ~0xf;
7002 -}
7003 -
7004 -static inline unsigned long brk_rnd(void)
7005 -{
7006 - unsigned long rnd = 0;
7007 -
7008 - /* 8MB for 32bit, 1GB for 64bit */
7009 - if (is_32bit_task())
7010 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
7011 - else
7012 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
7013 -
7014 - return rnd << PAGE_SHIFT;
7015 -}
7016 -
7017 -unsigned long arch_randomize_brk(struct mm_struct *mm)
7018 -{
7019 - unsigned long base = mm->brk;
7020 - unsigned long ret;
7021 -
7022 -#ifdef CONFIG_PPC_STD_MMU_64
7023 - /*
7024 - * If we are using 1TB segments and we are allowed to randomise
7025 - * the heap, we can put it above 1TB so it is backed by a 1TB
7026 - * segment. Otherwise the heap will be in the bottom 1TB
7027 - * which always uses 256MB segments and this may result in a
7028 - * performance penalty.
7029 - */
7030 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
7031 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
7032 -#endif
7033 -
7034 - ret = PAGE_ALIGN(base + brk_rnd());
7035 -
7036 - if (ret < mm->brk)
7037 - return mm->brk;
7038 -
7039 - return ret;
7040 -}
7041 -
7042 -unsigned long randomize_et_dyn(unsigned long base)
7043 -{
7044 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
7045 -
7046 - if (ret < base)
7047 - return base;
7048 -
7049 - return ret;
7050 -}
7051 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
7052 index 64f7bd5..8dd550f 100644
7053 --- a/arch/powerpc/kernel/ptrace.c
7054 +++ b/arch/powerpc/kernel/ptrace.c
7055 @@ -1783,6 +1783,10 @@ long arch_ptrace(struct task_struct *child, long request,
7056 return ret;
7057 }
7058
7059 +#ifdef CONFIG_GRKERNSEC_SETXID
7060 +extern void gr_delayed_cred_worker(void);
7061 +#endif
7062 +
7063 /*
7064 * We must return the syscall number to actually look up in the table.
7065 * This can be -1L to skip running any syscall at all.
7066 @@ -1795,6 +1799,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
7067
7068 secure_computing_strict(regs->gpr[0]);
7069
7070 +#ifdef CONFIG_GRKERNSEC_SETXID
7071 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
7072 + gr_delayed_cred_worker();
7073 +#endif
7074 +
7075 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
7076 tracehook_report_syscall_entry(regs))
7077 /*
7078 @@ -1829,6 +1838,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
7079 {
7080 int step;
7081
7082 +#ifdef CONFIG_GRKERNSEC_SETXID
7083 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
7084 + gr_delayed_cred_worker();
7085 +#endif
7086 +
7087 audit_syscall_exit(regs);
7088
7089 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
7090 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
7091 index 0f83122..c0aca6a 100644
7092 --- a/arch/powerpc/kernel/signal_32.c
7093 +++ b/arch/powerpc/kernel/signal_32.c
7094 @@ -987,7 +987,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
7095 /* Save user registers on the stack */
7096 frame = &rt_sf->uc.uc_mcontext;
7097 addr = frame;
7098 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
7099 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
7100 sigret = 0;
7101 tramp = current->mm->context.vdso_base + vdso32_rt_sigtramp;
7102 } else {
7103 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
7104 index 887e99d..310bc11 100644
7105 --- a/arch/powerpc/kernel/signal_64.c
7106 +++ b/arch/powerpc/kernel/signal_64.c
7107 @@ -751,7 +751,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
7108 #endif
7109
7110 /* Set up to return from userspace. */
7111 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
7112 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
7113 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
7114 } else {
7115 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
7116 diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c
7117 index e68a845..8b140e6 100644
7118 --- a/arch/powerpc/kernel/sysfs.c
7119 +++ b/arch/powerpc/kernel/sysfs.c
7120 @@ -522,7 +522,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
7121 return NOTIFY_OK;
7122 }
7123
7124 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
7125 +static struct notifier_block sysfs_cpu_nb = {
7126 .notifier_call = sysfs_cpu_notify,
7127 };
7128
7129 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
7130 index 88929b1..bece8f8 100644
7131 --- a/arch/powerpc/kernel/traps.c
7132 +++ b/arch/powerpc/kernel/traps.c
7133 @@ -141,6 +141,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
7134 return flags;
7135 }
7136
7137 +extern void gr_handle_kernel_exploit(void);
7138 +
7139 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
7140 int signr)
7141 {
7142 @@ -190,6 +192,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
7143 panic("Fatal exception in interrupt");
7144 if (panic_on_oops)
7145 panic("Fatal exception");
7146 +
7147 + gr_handle_kernel_exploit();
7148 +
7149 do_exit(signr);
7150 }
7151
7152 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
7153 index d4f463a..8fb7431 100644
7154 --- a/arch/powerpc/kernel/vdso.c
7155 +++ b/arch/powerpc/kernel/vdso.c
7156 @@ -34,6 +34,7 @@
7157 #include <asm/firmware.h>
7158 #include <asm/vdso.h>
7159 #include <asm/vdso_datapage.h>
7160 +#include <asm/mman.h>
7161
7162 #include "setup.h"
7163
7164 @@ -222,7 +223,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
7165 vdso_base = VDSO32_MBASE;
7166 #endif
7167
7168 - current->mm->context.vdso_base = 0;
7169 + current->mm->context.vdso_base = ~0UL;
7170
7171 /* vDSO has a problem and was disabled, just don't "enable" it for the
7172 * process
7173 @@ -242,7 +243,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
7174 vdso_base = get_unmapped_area(NULL, vdso_base,
7175 (vdso_pages << PAGE_SHIFT) +
7176 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
7177 - 0, 0);
7178 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
7179 if (IS_ERR_VALUE(vdso_base)) {
7180 rc = vdso_base;
7181 goto fail_mmapsem;
7182 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
7183 index 5eea6f3..5d10396 100644
7184 --- a/arch/powerpc/lib/usercopy_64.c
7185 +++ b/arch/powerpc/lib/usercopy_64.c
7186 @@ -9,22 +9,6 @@
7187 #include <linux/module.h>
7188 #include <asm/uaccess.h>
7189
7190 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
7191 -{
7192 - if (likely(access_ok(VERIFY_READ, from, n)))
7193 - n = __copy_from_user(to, from, n);
7194 - else
7195 - memset(to, 0, n);
7196 - return n;
7197 -}
7198 -
7199 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
7200 -{
7201 - if (likely(access_ok(VERIFY_WRITE, to, n)))
7202 - n = __copy_to_user(to, from, n);
7203 - return n;
7204 -}
7205 -
7206 unsigned long copy_in_user(void __user *to, const void __user *from,
7207 unsigned long n)
7208 {
7209 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
7210 return n;
7211 }
7212
7213 -EXPORT_SYMBOL(copy_from_user);
7214 -EXPORT_SYMBOL(copy_to_user);
7215 EXPORT_SYMBOL(copy_in_user);
7216
7217 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
7218 index 8726779..a33c512 100644
7219 --- a/arch/powerpc/mm/fault.c
7220 +++ b/arch/powerpc/mm/fault.c
7221 @@ -33,6 +33,10 @@
7222 #include <linux/magic.h>
7223 #include <linux/ratelimit.h>
7224 #include <linux/context_tracking.h>
7225 +#include <linux/slab.h>
7226 +#include <linux/pagemap.h>
7227 +#include <linux/compiler.h>
7228 +#include <linux/unistd.h>
7229
7230 #include <asm/firmware.h>
7231 #include <asm/page.h>
7232 @@ -69,6 +73,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
7233 }
7234 #endif
7235
7236 +#ifdef CONFIG_PAX_PAGEEXEC
7237 +/*
7238 + * PaX: decide what to do with offenders (regs->nip = fault address)
7239 + *
7240 + * returns 1 when task should be killed
7241 + */
7242 +static int pax_handle_fetch_fault(struct pt_regs *regs)
7243 +{
7244 + return 1;
7245 +}
7246 +
7247 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7248 +{
7249 + unsigned long i;
7250 +
7251 + printk(KERN_ERR "PAX: bytes at PC: ");
7252 + for (i = 0; i < 5; i++) {
7253 + unsigned int c;
7254 + if (get_user(c, (unsigned int __user *)pc+i))
7255 + printk(KERN_CONT "???????? ");
7256 + else
7257 + printk(KERN_CONT "%08x ", c);
7258 + }
7259 + printk("\n");
7260 +}
7261 +#endif
7262 +
7263 /*
7264 * Check whether the instruction at regs->nip is a store using
7265 * an update addressing form which will update r1.
7266 @@ -216,7 +247,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
7267 * indicate errors in DSISR but can validly be set in SRR1.
7268 */
7269 if (trap == 0x400)
7270 - error_code &= 0x48200000;
7271 + error_code &= 0x58200000;
7272 else
7273 is_write = error_code & DSISR_ISSTORE;
7274 #else
7275 @@ -371,7 +402,7 @@ good_area:
7276 * "undefined". Of those that can be set, this is the only
7277 * one which seems bad.
7278 */
7279 - if (error_code & 0x10000000)
7280 + if (error_code & DSISR_GUARDED)
7281 /* Guarded storage error. */
7282 goto bad_area;
7283 #endif /* CONFIG_8xx */
7284 @@ -386,7 +417,7 @@ good_area:
7285 * processors use the same I/D cache coherency mechanism
7286 * as embedded.
7287 */
7288 - if (error_code & DSISR_PROTFAULT)
7289 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
7290 goto bad_area;
7291 #endif /* CONFIG_PPC_STD_MMU */
7292
7293 @@ -471,6 +502,23 @@ bad_area:
7294 bad_area_nosemaphore:
7295 /* User mode accesses cause a SIGSEGV */
7296 if (user_mode(regs)) {
7297 +
7298 +#ifdef CONFIG_PAX_PAGEEXEC
7299 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
7300 +#ifdef CONFIG_PPC_STD_MMU
7301 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
7302 +#else
7303 + if (is_exec && regs->nip == address) {
7304 +#endif
7305 + switch (pax_handle_fetch_fault(regs)) {
7306 + }
7307 +
7308 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
7309 + do_group_exit(SIGKILL);
7310 + }
7311 + }
7312 +#endif
7313 +
7314 _exception(SIGSEGV, regs, code, address);
7315 goto bail;
7316 }
7317 diff --git a/arch/powerpc/mm/mmap_64.c b/arch/powerpc/mm/mmap_64.c
7318 index 67a42ed..cd463e0 100644
7319 --- a/arch/powerpc/mm/mmap_64.c
7320 +++ b/arch/powerpc/mm/mmap_64.c
7321 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
7322 {
7323 unsigned long rnd = 0;
7324
7325 +#ifdef CONFIG_PAX_RANDMMAP
7326 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7327 +#endif
7328 +
7329 if (current->flags & PF_RANDOMIZE) {
7330 /* 8MB for 32bit, 1GB for 64bit */
7331 if (is_32bit_task())
7332 @@ -91,10 +95,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7333 */
7334 if (mmap_is_legacy()) {
7335 mm->mmap_base = TASK_UNMAPPED_BASE;
7336 +
7337 +#ifdef CONFIG_PAX_RANDMMAP
7338 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7339 + mm->mmap_base += mm->delta_mmap;
7340 +#endif
7341 +
7342 mm->get_unmapped_area = arch_get_unmapped_area;
7343 mm->unmap_area = arch_unmap_area;
7344 } else {
7345 mm->mmap_base = mmap_base();
7346 +
7347 +#ifdef CONFIG_PAX_RANDMMAP
7348 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7349 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7350 +#endif
7351 +
7352 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7353 mm->unmap_area = arch_unmap_area_topdown;
7354 }
7355 diff --git a/arch/powerpc/mm/mmu_context_nohash.c b/arch/powerpc/mm/mmu_context_nohash.c
7356 index e779642..e5bb889 100644
7357 --- a/arch/powerpc/mm/mmu_context_nohash.c
7358 +++ b/arch/powerpc/mm/mmu_context_nohash.c
7359 @@ -363,7 +363,7 @@ static int __cpuinit mmu_context_cpu_notify(struct notifier_block *self,
7360 return NOTIFY_OK;
7361 }
7362
7363 -static struct notifier_block __cpuinitdata mmu_context_cpu_nb = {
7364 +static struct notifier_block mmu_context_cpu_nb = {
7365 .notifier_call = mmu_context_cpu_notify,
7366 };
7367
7368 diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c
7369 index cafad40..9cbc0fc 100644
7370 --- a/arch/powerpc/mm/numa.c
7371 +++ b/arch/powerpc/mm/numa.c
7372 @@ -920,7 +920,7 @@ static void __init *careful_zallocation(int nid, unsigned long size,
7373 return ret;
7374 }
7375
7376 -static struct notifier_block __cpuinitdata ppc64_numa_nb = {
7377 +static struct notifier_block ppc64_numa_nb = {
7378 .notifier_call = cpu_numa_callback,
7379 .priority = 1 /* Must run before sched domains notifier. */
7380 };
7381 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
7382 index 3e99c14..f00953c 100644
7383 --- a/arch/powerpc/mm/slice.c
7384 +++ b/arch/powerpc/mm/slice.c
7385 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
7386 if ((mm->task_size - len) < addr)
7387 return 0;
7388 vma = find_vma(mm, addr);
7389 - return (!vma || (addr + len) <= vma->vm_start);
7390 + return check_heap_stack_gap(vma, addr, len, 0);
7391 }
7392
7393 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
7394 @@ -277,6 +277,12 @@ static unsigned long slice_find_area_bottomup(struct mm_struct *mm,
7395 info.align_offset = 0;
7396
7397 addr = TASK_UNMAPPED_BASE;
7398 +
7399 +#ifdef CONFIG_PAX_RANDMMAP
7400 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7401 + addr += mm->delta_mmap;
7402 +#endif
7403 +
7404 while (addr < TASK_SIZE) {
7405 info.low_limit = addr;
7406 if (!slice_scan_available(addr, available, 1, &addr))
7407 @@ -410,6 +416,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
7408 if (fixed && addr > (mm->task_size - len))
7409 return -EINVAL;
7410
7411 +#ifdef CONFIG_PAX_RANDMMAP
7412 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
7413 + addr = 0;
7414 +#endif
7415 +
7416 /* If hint, make sure it matches our alignment restrictions */
7417 if (!fixed && addr) {
7418 addr = _ALIGN_UP(addr, 1ul << pshift);
7419 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
7420 index 9098692..3d54cd1 100644
7421 --- a/arch/powerpc/platforms/cell/spufs/file.c
7422 +++ b/arch/powerpc/platforms/cell/spufs/file.c
7423 @@ -280,9 +280,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
7424 return VM_FAULT_NOPAGE;
7425 }
7426
7427 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
7428 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
7429 unsigned long address,
7430 - void *buf, int len, int write)
7431 + void *buf, size_t len, int write)
7432 {
7433 struct spu_context *ctx = vma->vm_file->private_data;
7434 unsigned long offset = address - vma->vm_start;
7435 diff --git a/arch/powerpc/platforms/powermac/smp.c b/arch/powerpc/platforms/powermac/smp.c
7436 index bdb738a..49c9f95 100644
7437 --- a/arch/powerpc/platforms/powermac/smp.c
7438 +++ b/arch/powerpc/platforms/powermac/smp.c
7439 @@ -885,7 +885,7 @@ static int smp_core99_cpu_notify(struct notifier_block *self,
7440 return NOTIFY_OK;
7441 }
7442
7443 -static struct notifier_block __cpuinitdata smp_core99_cpu_nb = {
7444 +static struct notifier_block smp_core99_cpu_nb = {
7445 .notifier_call = smp_core99_cpu_notify,
7446 };
7447 #endif /* CONFIG_HOTPLUG_CPU */
7448 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
7449 index c797832..ce575c8 100644
7450 --- a/arch/s390/include/asm/atomic.h
7451 +++ b/arch/s390/include/asm/atomic.h
7452 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
7453 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
7454 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
7455
7456 +#define atomic64_read_unchecked(v) atomic64_read(v)
7457 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7458 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7459 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7460 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7461 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7462 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7463 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7464 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7465 +
7466 #define smp_mb__before_atomic_dec() smp_mb()
7467 #define smp_mb__after_atomic_dec() smp_mb()
7468 #define smp_mb__before_atomic_inc() smp_mb()
7469 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
7470 index 4d7ccac..d03d0ad 100644
7471 --- a/arch/s390/include/asm/cache.h
7472 +++ b/arch/s390/include/asm/cache.h
7473 @@ -9,8 +9,10 @@
7474 #ifndef __ARCH_S390_CACHE_H
7475 #define __ARCH_S390_CACHE_H
7476
7477 -#define L1_CACHE_BYTES 256
7478 +#include <linux/const.h>
7479 +
7480 #define L1_CACHE_SHIFT 8
7481 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7482 #define NET_SKB_PAD 32
7483
7484 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7485 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
7486 index 78f4f87..598ce39 100644
7487 --- a/arch/s390/include/asm/elf.h
7488 +++ b/arch/s390/include/asm/elf.h
7489 @@ -162,8 +162,14 @@ extern unsigned int vdso_enabled;
7490 the loader. We need to make sure that it is out of the way of the program
7491 that it will "exec", and that there is sufficient room for the brk. */
7492
7493 -extern unsigned long randomize_et_dyn(unsigned long base);
7494 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
7495 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
7496 +
7497 +#ifdef CONFIG_PAX_ASLR
7498 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
7499 +
7500 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7501 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
7502 +#endif
7503
7504 /* This yields a mask that user programs can use to figure out what
7505 instruction set this CPU supports. */
7506 @@ -222,9 +228,6 @@ struct linux_binprm;
7507 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
7508 int arch_setup_additional_pages(struct linux_binprm *, int);
7509
7510 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7511 -#define arch_randomize_brk arch_randomize_brk
7512 -
7513 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
7514
7515 #endif
7516 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
7517 index c4a93d6..4d2a9b4 100644
7518 --- a/arch/s390/include/asm/exec.h
7519 +++ b/arch/s390/include/asm/exec.h
7520 @@ -7,6 +7,6 @@
7521 #ifndef __ASM_EXEC_H
7522 #define __ASM_EXEC_H
7523
7524 -extern unsigned long arch_align_stack(unsigned long sp);
7525 +#define arch_align_stack(x) ((x) & ~0xfUL)
7526
7527 #endif /* __ASM_EXEC_H */
7528 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
7529 index 9c33ed4..e40cbef 100644
7530 --- a/arch/s390/include/asm/uaccess.h
7531 +++ b/arch/s390/include/asm/uaccess.h
7532 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
7533 copy_to_user(void __user *to, const void *from, unsigned long n)
7534 {
7535 might_fault();
7536 +
7537 + if ((long)n < 0)
7538 + return n;
7539 +
7540 return __copy_to_user(to, from, n);
7541 }
7542
7543 @@ -275,6 +279,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
7544 static inline unsigned long __must_check
7545 __copy_from_user(void *to, const void __user *from, unsigned long n)
7546 {
7547 + if ((long)n < 0)
7548 + return n;
7549 +
7550 if (__builtin_constant_p(n) && (n <= 256))
7551 return uaccess.copy_from_user_small(n, from, to);
7552 else
7553 @@ -306,10 +313,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
7554 static inline unsigned long __must_check
7555 copy_from_user(void *to, const void __user *from, unsigned long n)
7556 {
7557 - unsigned int sz = __compiletime_object_size(to);
7558 + size_t sz = __compiletime_object_size(to);
7559
7560 might_fault();
7561 - if (unlikely(sz != -1 && sz < n)) {
7562 +
7563 + if ((long)n < 0)
7564 + return n;
7565 +
7566 + if (unlikely(sz != (size_t)-1 && sz < n)) {
7567 copy_from_user_overflow();
7568 return n;
7569 }
7570 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
7571 index 7845e15..59c4353 100644
7572 --- a/arch/s390/kernel/module.c
7573 +++ b/arch/s390/kernel/module.c
7574 @@ -169,11 +169,11 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
7575
7576 /* Increase core size by size of got & plt and set start
7577 offsets for got and plt. */
7578 - me->core_size = ALIGN(me->core_size, 4);
7579 - me->arch.got_offset = me->core_size;
7580 - me->core_size += me->arch.got_size;
7581 - me->arch.plt_offset = me->core_size;
7582 - me->core_size += me->arch.plt_size;
7583 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
7584 + me->arch.got_offset = me->core_size_rw;
7585 + me->core_size_rw += me->arch.got_size;
7586 + me->arch.plt_offset = me->core_size_rx;
7587 + me->core_size_rx += me->arch.plt_size;
7588 return 0;
7589 }
7590
7591 @@ -289,7 +289,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7592 if (info->got_initialized == 0) {
7593 Elf_Addr *gotent;
7594
7595 - gotent = me->module_core + me->arch.got_offset +
7596 + gotent = me->module_core_rw + me->arch.got_offset +
7597 info->got_offset;
7598 *gotent = val;
7599 info->got_initialized = 1;
7600 @@ -312,7 +312,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7601 rc = apply_rela_bits(loc, val, 0, 64, 0);
7602 else if (r_type == R_390_GOTENT ||
7603 r_type == R_390_GOTPLTENT) {
7604 - val += (Elf_Addr) me->module_core - loc;
7605 + val += (Elf_Addr) me->module_core_rw - loc;
7606 rc = apply_rela_bits(loc, val, 1, 32, 1);
7607 }
7608 break;
7609 @@ -325,7 +325,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7610 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
7611 if (info->plt_initialized == 0) {
7612 unsigned int *ip;
7613 - ip = me->module_core + me->arch.plt_offset +
7614 + ip = me->module_core_rx + me->arch.plt_offset +
7615 info->plt_offset;
7616 #ifndef CONFIG_64BIT
7617 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
7618 @@ -350,7 +350,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7619 val - loc + 0xffffUL < 0x1ffffeUL) ||
7620 (r_type == R_390_PLT32DBL &&
7621 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
7622 - val = (Elf_Addr) me->module_core +
7623 + val = (Elf_Addr) me->module_core_rx +
7624 me->arch.plt_offset +
7625 info->plt_offset;
7626 val += rela->r_addend - loc;
7627 @@ -372,7 +372,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7628 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
7629 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
7630 val = val + rela->r_addend -
7631 - ((Elf_Addr) me->module_core + me->arch.got_offset);
7632 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
7633 if (r_type == R_390_GOTOFF16)
7634 rc = apply_rela_bits(loc, val, 0, 16, 0);
7635 else if (r_type == R_390_GOTOFF32)
7636 @@ -382,7 +382,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
7637 break;
7638 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
7639 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
7640 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
7641 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
7642 rela->r_addend - loc;
7643 if (r_type == R_390_GOTPC)
7644 rc = apply_rela_bits(loc, val, 1, 32, 0);
7645 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
7646 index 2bc3edd..ab9d598 100644
7647 --- a/arch/s390/kernel/process.c
7648 +++ b/arch/s390/kernel/process.c
7649 @@ -236,39 +236,3 @@ unsigned long get_wchan(struct task_struct *p)
7650 }
7651 return 0;
7652 }
7653 -
7654 -unsigned long arch_align_stack(unsigned long sp)
7655 -{
7656 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
7657 - sp -= get_random_int() & ~PAGE_MASK;
7658 - return sp & ~0xf;
7659 -}
7660 -
7661 -static inline unsigned long brk_rnd(void)
7662 -{
7663 - /* 8MB for 32bit, 1GB for 64bit */
7664 - if (is_32bit_task())
7665 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
7666 - else
7667 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
7668 -}
7669 -
7670 -unsigned long arch_randomize_brk(struct mm_struct *mm)
7671 -{
7672 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
7673 -
7674 - if (ret < mm->brk)
7675 - return mm->brk;
7676 - return ret;
7677 -}
7678 -
7679 -unsigned long randomize_et_dyn(unsigned long base)
7680 -{
7681 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
7682 -
7683 - if (!(current->flags & PF_RANDOMIZE))
7684 - return base;
7685 - if (ret < base)
7686 - return base;
7687 - return ret;
7688 -}
7689 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
7690 index 06bafec..2bca531 100644
7691 --- a/arch/s390/mm/mmap.c
7692 +++ b/arch/s390/mm/mmap.c
7693 @@ -90,10 +90,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7694 */
7695 if (mmap_is_legacy()) {
7696 mm->mmap_base = TASK_UNMAPPED_BASE;
7697 +
7698 +#ifdef CONFIG_PAX_RANDMMAP
7699 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7700 + mm->mmap_base += mm->delta_mmap;
7701 +#endif
7702 +
7703 mm->get_unmapped_area = arch_get_unmapped_area;
7704 mm->unmap_area = arch_unmap_area;
7705 } else {
7706 mm->mmap_base = mmap_base();
7707 +
7708 +#ifdef CONFIG_PAX_RANDMMAP
7709 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7710 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7711 +#endif
7712 +
7713 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
7714 mm->unmap_area = arch_unmap_area_topdown;
7715 }
7716 @@ -175,10 +187,22 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
7717 */
7718 if (mmap_is_legacy()) {
7719 mm->mmap_base = TASK_UNMAPPED_BASE;
7720 +
7721 +#ifdef CONFIG_PAX_RANDMMAP
7722 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7723 + mm->mmap_base += mm->delta_mmap;
7724 +#endif
7725 +
7726 mm->get_unmapped_area = s390_get_unmapped_area;
7727 mm->unmap_area = arch_unmap_area;
7728 } else {
7729 mm->mmap_base = mmap_base();
7730 +
7731 +#ifdef CONFIG_PAX_RANDMMAP
7732 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7733 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
7734 +#endif
7735 +
7736 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
7737 mm->unmap_area = arch_unmap_area_topdown;
7738 }
7739 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
7740 index ae3d59f..f65f075 100644
7741 --- a/arch/score/include/asm/cache.h
7742 +++ b/arch/score/include/asm/cache.h
7743 @@ -1,7 +1,9 @@
7744 #ifndef _ASM_SCORE_CACHE_H
7745 #define _ASM_SCORE_CACHE_H
7746
7747 +#include <linux/const.h>
7748 +
7749 #define L1_CACHE_SHIFT 4
7750 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7751 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7752
7753 #endif /* _ASM_SCORE_CACHE_H */
7754 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
7755 index f9f3cd5..58ff438 100644
7756 --- a/arch/score/include/asm/exec.h
7757 +++ b/arch/score/include/asm/exec.h
7758 @@ -1,6 +1,6 @@
7759 #ifndef _ASM_SCORE_EXEC_H
7760 #define _ASM_SCORE_EXEC_H
7761
7762 -extern unsigned long arch_align_stack(unsigned long sp);
7763 +#define arch_align_stack(x) (x)
7764
7765 #endif /* _ASM_SCORE_EXEC_H */
7766 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
7767 index f4c6d02..e9355c3 100644
7768 --- a/arch/score/kernel/process.c
7769 +++ b/arch/score/kernel/process.c
7770 @@ -116,8 +116,3 @@ unsigned long get_wchan(struct task_struct *task)
7771
7772 return task_pt_regs(task)->cp0_epc;
7773 }
7774 -
7775 -unsigned long arch_align_stack(unsigned long sp)
7776 -{
7777 - return sp;
7778 -}
7779 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
7780 index ef9e555..331bd29 100644
7781 --- a/arch/sh/include/asm/cache.h
7782 +++ b/arch/sh/include/asm/cache.h
7783 @@ -9,10 +9,11 @@
7784 #define __ASM_SH_CACHE_H
7785 #ifdef __KERNEL__
7786
7787 +#include <linux/const.h>
7788 #include <linux/init.h>
7789 #include <cpu/cache.h>
7790
7791 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7792 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7793
7794 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
7795
7796 diff --git a/arch/sh/kernel/cpu/sh4a/smp-shx3.c b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7797 index 03f2b55..b0270327 100644
7798 --- a/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7799 +++ b/arch/sh/kernel/cpu/sh4a/smp-shx3.c
7800 @@ -143,7 +143,7 @@ shx3_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
7801 return NOTIFY_OK;
7802 }
7803
7804 -static struct notifier_block __cpuinitdata shx3_cpu_notifier = {
7805 +static struct notifier_block shx3_cpu_notifier = {
7806 .notifier_call = shx3_cpu_callback,
7807 };
7808
7809 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
7810 index 6777177..cb5e44f 100644
7811 --- a/arch/sh/mm/mmap.c
7812 +++ b/arch/sh/mm/mmap.c
7813 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7814 struct mm_struct *mm = current->mm;
7815 struct vm_area_struct *vma;
7816 int do_colour_align;
7817 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7818 struct vm_unmapped_area_info info;
7819
7820 if (flags & MAP_FIXED) {
7821 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7822 if (filp || (flags & MAP_SHARED))
7823 do_colour_align = 1;
7824
7825 +#ifdef CONFIG_PAX_RANDMMAP
7826 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7827 +#endif
7828 +
7829 if (addr) {
7830 if (do_colour_align)
7831 addr = COLOUR_ALIGN(addr, pgoff);
7832 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7833 addr = PAGE_ALIGN(addr);
7834
7835 vma = find_vma(mm, addr);
7836 - if (TASK_SIZE - len >= addr &&
7837 - (!vma || addr + len <= vma->vm_start))
7838 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7839 return addr;
7840 }
7841
7842 info.flags = 0;
7843 info.length = len;
7844 - info.low_limit = TASK_UNMAPPED_BASE;
7845 + info.low_limit = mm->mmap_base;
7846 info.high_limit = TASK_SIZE;
7847 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
7848 info.align_offset = pgoff << PAGE_SHIFT;
7849 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7850 struct mm_struct *mm = current->mm;
7851 unsigned long addr = addr0;
7852 int do_colour_align;
7853 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
7854 struct vm_unmapped_area_info info;
7855
7856 if (flags & MAP_FIXED) {
7857 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7858 if (filp || (flags & MAP_SHARED))
7859 do_colour_align = 1;
7860
7861 +#ifdef CONFIG_PAX_RANDMMAP
7862 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
7863 +#endif
7864 +
7865 /* requesting a specific address */
7866 if (addr) {
7867 if (do_colour_align)
7868 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7869 addr = PAGE_ALIGN(addr);
7870
7871 vma = find_vma(mm, addr);
7872 - if (TASK_SIZE - len >= addr &&
7873 - (!vma || addr + len <= vma->vm_start))
7874 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
7875 return addr;
7876 }
7877
7878 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
7879 VM_BUG_ON(addr != -ENOMEM);
7880 info.flags = 0;
7881 info.low_limit = TASK_UNMAPPED_BASE;
7882 +
7883 +#ifdef CONFIG_PAX_RANDMMAP
7884 + if (mm->pax_flags & MF_PAX_RANDMMAP)
7885 + info.low_limit += mm->delta_mmap;
7886 +#endif
7887 +
7888 info.high_limit = TASK_SIZE;
7889 addr = vm_unmapped_area(&info);
7890 }
7891 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
7892 index be56a24..443328f 100644
7893 --- a/arch/sparc/include/asm/atomic_64.h
7894 +++ b/arch/sparc/include/asm/atomic_64.h
7895 @@ -14,18 +14,40 @@
7896 #define ATOMIC64_INIT(i) { (i) }
7897
7898 #define atomic_read(v) (*(volatile int *)&(v)->counter)
7899 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
7900 +{
7901 + return v->counter;
7902 +}
7903 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
7904 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
7905 +{
7906 + return v->counter;
7907 +}
7908
7909 #define atomic_set(v, i) (((v)->counter) = i)
7910 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
7911 +{
7912 + v->counter = i;
7913 +}
7914 #define atomic64_set(v, i) (((v)->counter) = i)
7915 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
7916 +{
7917 + v->counter = i;
7918 +}
7919
7920 extern void atomic_add(int, atomic_t *);
7921 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
7922 extern void atomic64_add(long, atomic64_t *);
7923 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
7924 extern void atomic_sub(int, atomic_t *);
7925 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
7926 extern void atomic64_sub(long, atomic64_t *);
7927 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
7928
7929 extern int atomic_add_ret(int, atomic_t *);
7930 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
7931 extern long atomic64_add_ret(long, atomic64_t *);
7932 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
7933 extern int atomic_sub_ret(int, atomic_t *);
7934 extern long atomic64_sub_ret(long, atomic64_t *);
7935
7936 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7937 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
7938
7939 #define atomic_inc_return(v) atomic_add_ret(1, v)
7940 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
7941 +{
7942 + return atomic_add_ret_unchecked(1, v);
7943 +}
7944 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
7945 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
7946 +{
7947 + return atomic64_add_ret_unchecked(1, v);
7948 +}
7949
7950 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
7951 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
7952
7953 #define atomic_add_return(i, v) atomic_add_ret(i, v)
7954 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
7955 +{
7956 + return atomic_add_ret_unchecked(i, v);
7957 +}
7958 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
7959 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
7960 +{
7961 + return atomic64_add_ret_unchecked(i, v);
7962 +}
7963
7964 /*
7965 * atomic_inc_and_test - increment and test
7966 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7967 * other cases.
7968 */
7969 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
7970 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
7971 +{
7972 + return atomic_inc_return_unchecked(v) == 0;
7973 +}
7974 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
7975
7976 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
7977 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
7978 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
7979
7980 #define atomic_inc(v) atomic_add(1, v)
7981 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
7982 +{
7983 + atomic_add_unchecked(1, v);
7984 +}
7985 #define atomic64_inc(v) atomic64_add(1, v)
7986 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
7987 +{
7988 + atomic64_add_unchecked(1, v);
7989 +}
7990
7991 #define atomic_dec(v) atomic_sub(1, v)
7992 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
7993 +{
7994 + atomic_sub_unchecked(1, v);
7995 +}
7996 #define atomic64_dec(v) atomic64_sub(1, v)
7997 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
7998 +{
7999 + atomic64_sub_unchecked(1, v);
8000 +}
8001
8002 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
8003 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
8004
8005 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
8006 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
8007 +{
8008 + return cmpxchg(&v->counter, old, new);
8009 +}
8010 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
8011 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
8012 +{
8013 + return xchg(&v->counter, new);
8014 +}
8015
8016 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
8017 {
8018 - int c, old;
8019 + int c, old, new;
8020 c = atomic_read(v);
8021 for (;;) {
8022 - if (unlikely(c == (u)))
8023 + if (unlikely(c == u))
8024 break;
8025 - old = atomic_cmpxchg((v), c, c + (a));
8026 +
8027 + asm volatile("addcc %2, %0, %0\n"
8028 +
8029 +#ifdef CONFIG_PAX_REFCOUNT
8030 + "tvs %%icc, 6\n"
8031 +#endif
8032 +
8033 + : "=r" (new)
8034 + : "0" (c), "ir" (a)
8035 + : "cc");
8036 +
8037 + old = atomic_cmpxchg(v, c, new);
8038 if (likely(old == c))
8039 break;
8040 c = old;
8041 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
8042 #define atomic64_cmpxchg(v, o, n) \
8043 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
8044 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
8045 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
8046 +{
8047 + return xchg(&v->counter, new);
8048 +}
8049
8050 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
8051 {
8052 - long c, old;
8053 + long c, old, new;
8054 c = atomic64_read(v);
8055 for (;;) {
8056 - if (unlikely(c == (u)))
8057 + if (unlikely(c == u))
8058 break;
8059 - old = atomic64_cmpxchg((v), c, c + (a));
8060 +
8061 + asm volatile("addcc %2, %0, %0\n"
8062 +
8063 +#ifdef CONFIG_PAX_REFCOUNT
8064 + "tvs %%xcc, 6\n"
8065 +#endif
8066 +
8067 + : "=r" (new)
8068 + : "0" (c), "ir" (a)
8069 + : "cc");
8070 +
8071 + old = atomic64_cmpxchg(v, c, new);
8072 if (likely(old == c))
8073 break;
8074 c = old;
8075 }
8076 - return c != (u);
8077 + return c != u;
8078 }
8079
8080 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
8081 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
8082 index 5bb6991..5c2132e 100644
8083 --- a/arch/sparc/include/asm/cache.h
8084 +++ b/arch/sparc/include/asm/cache.h
8085 @@ -7,10 +7,12 @@
8086 #ifndef _SPARC_CACHE_H
8087 #define _SPARC_CACHE_H
8088
8089 +#include <linux/const.h>
8090 +
8091 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
8092
8093 #define L1_CACHE_SHIFT 5
8094 -#define L1_CACHE_BYTES 32
8095 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8096
8097 #ifdef CONFIG_SPARC32
8098 #define SMP_CACHE_BYTES_SHIFT 5
8099 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
8100 index a24e41f..47677ff 100644
8101 --- a/arch/sparc/include/asm/elf_32.h
8102 +++ b/arch/sparc/include/asm/elf_32.h
8103 @@ -114,6 +114,13 @@ typedef struct {
8104
8105 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
8106
8107 +#ifdef CONFIG_PAX_ASLR
8108 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
8109 +
8110 +#define PAX_DELTA_MMAP_LEN 16
8111 +#define PAX_DELTA_STACK_LEN 16
8112 +#endif
8113 +
8114 /* This yields a mask that user programs can use to figure out what
8115 instruction set this cpu supports. This can NOT be done in userspace
8116 on Sparc. */
8117 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
8118 index 370ca1e..d4f4a98 100644
8119 --- a/arch/sparc/include/asm/elf_64.h
8120 +++ b/arch/sparc/include/asm/elf_64.h
8121 @@ -189,6 +189,13 @@ typedef struct {
8122 #define ELF_ET_DYN_BASE 0x0000010000000000UL
8123 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
8124
8125 +#ifdef CONFIG_PAX_ASLR
8126 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
8127 +
8128 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
8129 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
8130 +#endif
8131 +
8132 extern unsigned long sparc64_elf_hwcap;
8133 #define ELF_HWCAP sparc64_elf_hwcap
8134
8135 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
8136 index 9b1c36d..209298b 100644
8137 --- a/arch/sparc/include/asm/pgalloc_32.h
8138 +++ b/arch/sparc/include/asm/pgalloc_32.h
8139 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
8140 }
8141
8142 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
8143 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
8144
8145 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
8146 unsigned long address)
8147 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
8148 index bcfe063..b333142 100644
8149 --- a/arch/sparc/include/asm/pgalloc_64.h
8150 +++ b/arch/sparc/include/asm/pgalloc_64.h
8151 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
8152 }
8153
8154 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
8155 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
8156
8157 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
8158 {
8159 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
8160 index 6fc1348..390c50a 100644
8161 --- a/arch/sparc/include/asm/pgtable_32.h
8162 +++ b/arch/sparc/include/asm/pgtable_32.h
8163 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
8164 #define PAGE_SHARED SRMMU_PAGE_SHARED
8165 #define PAGE_COPY SRMMU_PAGE_COPY
8166 #define PAGE_READONLY SRMMU_PAGE_RDONLY
8167 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
8168 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
8169 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
8170 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
8171
8172 /* Top-level page directory - dummy used by init-mm.
8173 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
8174
8175 /* xwr */
8176 #define __P000 PAGE_NONE
8177 -#define __P001 PAGE_READONLY
8178 -#define __P010 PAGE_COPY
8179 -#define __P011 PAGE_COPY
8180 +#define __P001 PAGE_READONLY_NOEXEC
8181 +#define __P010 PAGE_COPY_NOEXEC
8182 +#define __P011 PAGE_COPY_NOEXEC
8183 #define __P100 PAGE_READONLY
8184 #define __P101 PAGE_READONLY
8185 #define __P110 PAGE_COPY
8186 #define __P111 PAGE_COPY
8187
8188 #define __S000 PAGE_NONE
8189 -#define __S001 PAGE_READONLY
8190 -#define __S010 PAGE_SHARED
8191 -#define __S011 PAGE_SHARED
8192 +#define __S001 PAGE_READONLY_NOEXEC
8193 +#define __S010 PAGE_SHARED_NOEXEC
8194 +#define __S011 PAGE_SHARED_NOEXEC
8195 #define __S100 PAGE_READONLY
8196 #define __S101 PAGE_READONLY
8197 #define __S110 PAGE_SHARED
8198 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
8199 index 79da178..c2eede8 100644
8200 --- a/arch/sparc/include/asm/pgtsrmmu.h
8201 +++ b/arch/sparc/include/asm/pgtsrmmu.h
8202 @@ -115,6 +115,11 @@
8203 SRMMU_EXEC | SRMMU_REF)
8204 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
8205 SRMMU_EXEC | SRMMU_REF)
8206 +
8207 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
8208 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
8209 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
8210 +
8211 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
8212 SRMMU_DIRTY | SRMMU_REF)
8213
8214 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
8215 index 9689176..63c18ea 100644
8216 --- a/arch/sparc/include/asm/spinlock_64.h
8217 +++ b/arch/sparc/include/asm/spinlock_64.h
8218 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
8219
8220 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
8221
8222 -static void inline arch_read_lock(arch_rwlock_t *lock)
8223 +static inline void arch_read_lock(arch_rwlock_t *lock)
8224 {
8225 unsigned long tmp1, tmp2;
8226
8227 __asm__ __volatile__ (
8228 "1: ldsw [%2], %0\n"
8229 " brlz,pn %0, 2f\n"
8230 -"4: add %0, 1, %1\n"
8231 +"4: addcc %0, 1, %1\n"
8232 +
8233 +#ifdef CONFIG_PAX_REFCOUNT
8234 +" tvs %%icc, 6\n"
8235 +#endif
8236 +
8237 " cas [%2], %0, %1\n"
8238 " cmp %0, %1\n"
8239 " bne,pn %%icc, 1b\n"
8240 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
8241 " .previous"
8242 : "=&r" (tmp1), "=&r" (tmp2)
8243 : "r" (lock)
8244 - : "memory");
8245 + : "memory", "cc");
8246 }
8247
8248 -static int inline arch_read_trylock(arch_rwlock_t *lock)
8249 +static inline int arch_read_trylock(arch_rwlock_t *lock)
8250 {
8251 int tmp1, tmp2;
8252
8253 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8254 "1: ldsw [%2], %0\n"
8255 " brlz,a,pn %0, 2f\n"
8256 " mov 0, %0\n"
8257 -" add %0, 1, %1\n"
8258 +" addcc %0, 1, %1\n"
8259 +
8260 +#ifdef CONFIG_PAX_REFCOUNT
8261 +" tvs %%icc, 6\n"
8262 +#endif
8263 +
8264 " cas [%2], %0, %1\n"
8265 " cmp %0, %1\n"
8266 " bne,pn %%icc, 1b\n"
8267 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
8268 return tmp1;
8269 }
8270
8271 -static void inline arch_read_unlock(arch_rwlock_t *lock)
8272 +static inline void arch_read_unlock(arch_rwlock_t *lock)
8273 {
8274 unsigned long tmp1, tmp2;
8275
8276 __asm__ __volatile__(
8277 "1: lduw [%2], %0\n"
8278 -" sub %0, 1, %1\n"
8279 +" subcc %0, 1, %1\n"
8280 +
8281 +#ifdef CONFIG_PAX_REFCOUNT
8282 +" tvs %%icc, 6\n"
8283 +#endif
8284 +
8285 " cas [%2], %0, %1\n"
8286 " cmp %0, %1\n"
8287 " bne,pn %%xcc, 1b\n"
8288 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
8289 : "memory");
8290 }
8291
8292 -static void inline arch_write_lock(arch_rwlock_t *lock)
8293 +static inline void arch_write_lock(arch_rwlock_t *lock)
8294 {
8295 unsigned long mask, tmp1, tmp2;
8296
8297 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
8298 : "memory");
8299 }
8300
8301 -static void inline arch_write_unlock(arch_rwlock_t *lock)
8302 +static inline void arch_write_unlock(arch_rwlock_t *lock)
8303 {
8304 __asm__ __volatile__(
8305 " stw %%g0, [%0]"
8306 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
8307 : "memory");
8308 }
8309
8310 -static int inline arch_write_trylock(arch_rwlock_t *lock)
8311 +static inline int arch_write_trylock(arch_rwlock_t *lock)
8312 {
8313 unsigned long mask, tmp1, tmp2, result;
8314
8315 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
8316 index dd38075..e7cac83 100644
8317 --- a/arch/sparc/include/asm/thread_info_32.h
8318 +++ b/arch/sparc/include/asm/thread_info_32.h
8319 @@ -49,6 +49,8 @@ struct thread_info {
8320 unsigned long w_saved;
8321
8322 struct restart_block restart_block;
8323 +
8324 + unsigned long lowest_stack;
8325 };
8326
8327 /*
8328 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
8329 index d5e5042..9bfee76 100644
8330 --- a/arch/sparc/include/asm/thread_info_64.h
8331 +++ b/arch/sparc/include/asm/thread_info_64.h
8332 @@ -63,6 +63,8 @@ struct thread_info {
8333 struct pt_regs *kern_una_regs;
8334 unsigned int kern_una_insn;
8335
8336 + unsigned long lowest_stack;
8337 +
8338 unsigned long fpregs[0] __attribute__ ((aligned(64)));
8339 };
8340
8341 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
8342 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
8343 /* flag bit 6 is available */
8344 #define TIF_32BIT 7 /* 32-bit binary */
8345 -/* flag bit 8 is available */
8346 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
8347 #define TIF_SECCOMP 9 /* secure computing */
8348 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
8349 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
8350 +
8351 /* NOTE: Thread flags >= 12 should be ones we have no interest
8352 * in using in assembly, else we can't use the mask as
8353 * an immediate value in instructions such as andcc.
8354 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
8355 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
8356 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
8357 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
8358 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
8359
8360 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
8361 _TIF_DO_NOTIFY_RESUME_MASK | \
8362 _TIF_NEED_RESCHED)
8363 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
8364
8365 +#define _TIF_WORK_SYSCALL \
8366 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
8367 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
8368 +
8369 +
8370 /*
8371 * Thread-synchronous status.
8372 *
8373 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
8374 index 0167d26..767bb0c 100644
8375 --- a/arch/sparc/include/asm/uaccess.h
8376 +++ b/arch/sparc/include/asm/uaccess.h
8377 @@ -1,5 +1,6 @@
8378 #ifndef ___ASM_SPARC_UACCESS_H
8379 #define ___ASM_SPARC_UACCESS_H
8380 +
8381 #if defined(__sparc__) && defined(__arch64__)
8382 #include <asm/uaccess_64.h>
8383 #else
8384 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
8385 index 53a28dd..50c38c3 100644
8386 --- a/arch/sparc/include/asm/uaccess_32.h
8387 +++ b/arch/sparc/include/asm/uaccess_32.h
8388 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
8389
8390 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8391 {
8392 - if (n && __access_ok((unsigned long) to, n))
8393 + if ((long)n < 0)
8394 + return n;
8395 +
8396 + if (n && __access_ok((unsigned long) to, n)) {
8397 + if (!__builtin_constant_p(n))
8398 + check_object_size(from, n, true);
8399 return __copy_user(to, (__force void __user *) from, n);
8400 - else
8401 + } else
8402 return n;
8403 }
8404
8405 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
8406 {
8407 + if ((long)n < 0)
8408 + return n;
8409 +
8410 + if (!__builtin_constant_p(n))
8411 + check_object_size(from, n, true);
8412 +
8413 return __copy_user(to, (__force void __user *) from, n);
8414 }
8415
8416 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8417 {
8418 - if (n && __access_ok((unsigned long) from, n))
8419 + if ((long)n < 0)
8420 + return n;
8421 +
8422 + if (n && __access_ok((unsigned long) from, n)) {
8423 + if (!__builtin_constant_p(n))
8424 + check_object_size(to, n, false);
8425 return __copy_user((__force void __user *) to, from, n);
8426 - else
8427 + } else
8428 return n;
8429 }
8430
8431 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
8432 {
8433 + if ((long)n < 0)
8434 + return n;
8435 +
8436 return __copy_user((__force void __user *) to, from, n);
8437 }
8438
8439 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
8440 index e562d3c..191f176 100644
8441 --- a/arch/sparc/include/asm/uaccess_64.h
8442 +++ b/arch/sparc/include/asm/uaccess_64.h
8443 @@ -10,6 +10,7 @@
8444 #include <linux/compiler.h>
8445 #include <linux/string.h>
8446 #include <linux/thread_info.h>
8447 +#include <linux/kernel.h>
8448 #include <asm/asi.h>
8449 #include <asm/spitfire.h>
8450 #include <asm-generic/uaccess-unaligned.h>
8451 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
8452 static inline unsigned long __must_check
8453 copy_from_user(void *to, const void __user *from, unsigned long size)
8454 {
8455 - unsigned long ret = ___copy_from_user(to, from, size);
8456 + unsigned long ret;
8457
8458 + if ((long)size < 0 || size > INT_MAX)
8459 + return size;
8460 +
8461 + if (!__builtin_constant_p(size))
8462 + check_object_size(to, size, false);
8463 +
8464 + ret = ___copy_from_user(to, from, size);
8465 if (unlikely(ret))
8466 ret = copy_from_user_fixup(to, from, size);
8467
8468 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
8469 static inline unsigned long __must_check
8470 copy_to_user(void __user *to, const void *from, unsigned long size)
8471 {
8472 - unsigned long ret = ___copy_to_user(to, from, size);
8473 + unsigned long ret;
8474
8475 + if ((long)size < 0 || size > INT_MAX)
8476 + return size;
8477 +
8478 + if (!__builtin_constant_p(size))
8479 + check_object_size(from, size, true);
8480 +
8481 + ret = ___copy_to_user(to, from, size);
8482 if (unlikely(ret))
8483 ret = copy_to_user_fixup(to, from, size);
8484 return ret;
8485 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
8486 index d432fb2..6056af1 100644
8487 --- a/arch/sparc/kernel/Makefile
8488 +++ b/arch/sparc/kernel/Makefile
8489 @@ -3,7 +3,7 @@
8490 #
8491
8492 asflags-y := -ansi
8493 -ccflags-y := -Werror
8494 +#ccflags-y := -Werror
8495
8496 extra-y := head_$(BITS).o
8497
8498 diff --git a/arch/sparc/kernel/ds.c b/arch/sparc/kernel/ds.c
8499 index 5ef48da..11d460f 100644
8500 --- a/arch/sparc/kernel/ds.c
8501 +++ b/arch/sparc/kernel/ds.c
8502 @@ -783,6 +783,16 @@ void ldom_set_var(const char *var, const char *value)
8503 char *base, *p;
8504 int msg_len, loops;
8505
8506 + if (strlen(var) + strlen(value) + 2 >
8507 + sizeof(pkt) - sizeof(pkt.header)) {
8508 + printk(KERN_ERR PFX
8509 + "contents length: %zu, which more than max: %lu,"
8510 + "so could not set (%s) variable to (%s).\n",
8511 + strlen(var) + strlen(value) + 2,
8512 + sizeof(pkt) - sizeof(pkt.header), var, value);
8513 + return;
8514 + }
8515 +
8516 memset(&pkt, 0, sizeof(pkt));
8517 pkt.header.data.tag.type = DS_DATA;
8518 pkt.header.data.handle = cp->handle;
8519 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
8520 index fdd819d..5af08c8 100644
8521 --- a/arch/sparc/kernel/process_32.c
8522 +++ b/arch/sparc/kernel/process_32.c
8523 @@ -116,14 +116,14 @@ void show_regs(struct pt_regs *r)
8524
8525 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
8526 r->psr, r->pc, r->npc, r->y, print_tainted());
8527 - printk("PC: <%pS>\n", (void *) r->pc);
8528 + printk("PC: <%pA>\n", (void *) r->pc);
8529 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8530 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
8531 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
8532 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8533 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
8534 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
8535 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
8536 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
8537
8538 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
8539 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
8540 @@ -160,7 +160,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
8541 rw = (struct reg_window32 *) fp;
8542 pc = rw->ins[7];
8543 printk("[%08lx : ", pc);
8544 - printk("%pS ] ", (void *) pc);
8545 + printk("%pA ] ", (void *) pc);
8546 fp = rw->ins[6];
8547 } while (++count < 16);
8548 printk("\n");
8549 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
8550 index baebab2..9cd13b1 100644
8551 --- a/arch/sparc/kernel/process_64.c
8552 +++ b/arch/sparc/kernel/process_64.c
8553 @@ -158,7 +158,7 @@ static void show_regwindow(struct pt_regs *regs)
8554 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
8555 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
8556 if (regs->tstate & TSTATE_PRIV)
8557 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
8558 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
8559 }
8560
8561 void show_regs(struct pt_regs *regs)
8562 @@ -167,7 +167,7 @@ void show_regs(struct pt_regs *regs)
8563
8564 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
8565 regs->tpc, regs->tnpc, regs->y, print_tainted());
8566 - printk("TPC: <%pS>\n", (void *) regs->tpc);
8567 + printk("TPC: <%pA>\n", (void *) regs->tpc);
8568 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
8569 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
8570 regs->u_regs[3]);
8571 @@ -180,7 +180,7 @@ void show_regs(struct pt_regs *regs)
8572 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
8573 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
8574 regs->u_regs[15]);
8575 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
8576 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
8577 show_regwindow(regs);
8578 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
8579 }
8580 @@ -269,7 +269,7 @@ void arch_trigger_all_cpu_backtrace(void)
8581 ((tp && tp->task) ? tp->task->pid : -1));
8582
8583 if (gp->tstate & TSTATE_PRIV) {
8584 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
8585 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
8586 (void *) gp->tpc,
8587 (void *) gp->o7,
8588 (void *) gp->i7,
8589 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
8590 index 79cc0d1..ec62734 100644
8591 --- a/arch/sparc/kernel/prom_common.c
8592 +++ b/arch/sparc/kernel/prom_common.c
8593 @@ -144,7 +144,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
8594
8595 unsigned int prom_early_allocated __initdata;
8596
8597 -static struct of_pdt_ops prom_sparc_ops __initdata = {
8598 +static struct of_pdt_ops prom_sparc_ops __initconst = {
8599 .nextprop = prom_common_nextprop,
8600 .getproplen = prom_getproplen,
8601 .getproperty = prom_getproperty,
8602 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
8603 index 7ff45e4..a58f271 100644
8604 --- a/arch/sparc/kernel/ptrace_64.c
8605 +++ b/arch/sparc/kernel/ptrace_64.c
8606 @@ -1057,6 +1057,10 @@ long arch_ptrace(struct task_struct *child, long request,
8607 return ret;
8608 }
8609
8610 +#ifdef CONFIG_GRKERNSEC_SETXID
8611 +extern void gr_delayed_cred_worker(void);
8612 +#endif
8613 +
8614 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8615 {
8616 int ret = 0;
8617 @@ -1064,6 +1068,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8618 /* do the secure computing check first */
8619 secure_computing_strict(regs->u_regs[UREG_G1]);
8620
8621 +#ifdef CONFIG_GRKERNSEC_SETXID
8622 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8623 + gr_delayed_cred_worker();
8624 +#endif
8625 +
8626 if (test_thread_flag(TIF_SYSCALL_TRACE))
8627 ret = tracehook_report_syscall_entry(regs);
8628
8629 @@ -1084,6 +1093,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
8630
8631 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
8632 {
8633 +#ifdef CONFIG_GRKERNSEC_SETXID
8634 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8635 + gr_delayed_cred_worker();
8636 +#endif
8637 +
8638 audit_syscall_exit(regs);
8639
8640 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8641 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
8642 index 3a8d184..49498a8 100644
8643 --- a/arch/sparc/kernel/sys_sparc_32.c
8644 +++ b/arch/sparc/kernel/sys_sparc_32.c
8645 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8646 if (len > TASK_SIZE - PAGE_SIZE)
8647 return -ENOMEM;
8648 if (!addr)
8649 - addr = TASK_UNMAPPED_BASE;
8650 + addr = current->mm->mmap_base;
8651
8652 info.flags = 0;
8653 info.length = len;
8654 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
8655 index 2daaaa6..4fb84dc 100644
8656 --- a/arch/sparc/kernel/sys_sparc_64.c
8657 +++ b/arch/sparc/kernel/sys_sparc_64.c
8658 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8659 struct vm_area_struct * vma;
8660 unsigned long task_size = TASK_SIZE;
8661 int do_color_align;
8662 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8663 struct vm_unmapped_area_info info;
8664
8665 if (flags & MAP_FIXED) {
8666 /* We do not accept a shared mapping if it would violate
8667 * cache aliasing constraints.
8668 */
8669 - if ((flags & MAP_SHARED) &&
8670 + if ((filp || (flags & MAP_SHARED)) &&
8671 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8672 return -EINVAL;
8673 return addr;
8674 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8675 if (filp || (flags & MAP_SHARED))
8676 do_color_align = 1;
8677
8678 +#ifdef CONFIG_PAX_RANDMMAP
8679 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8680 +#endif
8681 +
8682 if (addr) {
8683 if (do_color_align)
8684 addr = COLOR_ALIGN(addr, pgoff);
8685 @@ -118,22 +123,28 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
8686 addr = PAGE_ALIGN(addr);
8687
8688 vma = find_vma(mm, addr);
8689 - if (task_size - len >= addr &&
8690 - (!vma || addr + len <= vma->vm_start))
8691 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8692 return addr;
8693 }
8694
8695 info.flags = 0;
8696 info.length = len;
8697 - info.low_limit = TASK_UNMAPPED_BASE;
8698 + info.low_limit = mm->mmap_base;
8699 info.high_limit = min(task_size, VA_EXCLUDE_START);
8700 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
8701 info.align_offset = pgoff << PAGE_SHIFT;
8702 + info.threadstack_offset = offset;
8703 addr = vm_unmapped_area(&info);
8704
8705 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
8706 VM_BUG_ON(addr != -ENOMEM);
8707 info.low_limit = VA_EXCLUDE_END;
8708 +
8709 +#ifdef CONFIG_PAX_RANDMMAP
8710 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8711 + info.low_limit += mm->delta_mmap;
8712 +#endif
8713 +
8714 info.high_limit = task_size;
8715 addr = vm_unmapped_area(&info);
8716 }
8717 @@ -151,6 +162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8718 unsigned long task_size = STACK_TOP32;
8719 unsigned long addr = addr0;
8720 int do_color_align;
8721 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8722 struct vm_unmapped_area_info info;
8723
8724 /* This should only ever run for 32-bit processes. */
8725 @@ -160,7 +172,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8726 /* We do not accept a shared mapping if it would violate
8727 * cache aliasing constraints.
8728 */
8729 - if ((flags & MAP_SHARED) &&
8730 + if ((filp || (flags & MAP_SHARED)) &&
8731 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
8732 return -EINVAL;
8733 return addr;
8734 @@ -173,6 +185,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8735 if (filp || (flags & MAP_SHARED))
8736 do_color_align = 1;
8737
8738 +#ifdef CONFIG_PAX_RANDMMAP
8739 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8740 +#endif
8741 +
8742 /* requesting a specific address */
8743 if (addr) {
8744 if (do_color_align)
8745 @@ -181,8 +197,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8746 addr = PAGE_ALIGN(addr);
8747
8748 vma = find_vma(mm, addr);
8749 - if (task_size - len >= addr &&
8750 - (!vma || addr + len <= vma->vm_start))
8751 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8752 return addr;
8753 }
8754
8755 @@ -192,6 +207,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8756 info.high_limit = mm->mmap_base;
8757 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
8758 info.align_offset = pgoff << PAGE_SHIFT;
8759 + info.threadstack_offset = offset;
8760 addr = vm_unmapped_area(&info);
8761
8762 /*
8763 @@ -204,6 +220,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8764 VM_BUG_ON(addr != -ENOMEM);
8765 info.flags = 0;
8766 info.low_limit = TASK_UNMAPPED_BASE;
8767 +
8768 +#ifdef CONFIG_PAX_RANDMMAP
8769 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8770 + info.low_limit += mm->delta_mmap;
8771 +#endif
8772 +
8773 info.high_limit = STACK_TOP32;
8774 addr = vm_unmapped_area(&info);
8775 }
8776 @@ -260,10 +282,14 @@ unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, u
8777 EXPORT_SYMBOL(get_fb_unmapped_area);
8778
8779 /* Essentially the same as PowerPC. */
8780 -static unsigned long mmap_rnd(void)
8781 +static unsigned long mmap_rnd(struct mm_struct *mm)
8782 {
8783 unsigned long rnd = 0UL;
8784
8785 +#ifdef CONFIG_PAX_RANDMMAP
8786 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8787 +#endif
8788 +
8789 if (current->flags & PF_RANDOMIZE) {
8790 unsigned long val = get_random_int();
8791 if (test_thread_flag(TIF_32BIT))
8792 @@ -276,7 +302,7 @@ static unsigned long mmap_rnd(void)
8793
8794 void arch_pick_mmap_layout(struct mm_struct *mm)
8795 {
8796 - unsigned long random_factor = mmap_rnd();
8797 + unsigned long random_factor = mmap_rnd(mm);
8798 unsigned long gap;
8799
8800 /*
8801 @@ -289,6 +315,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8802 gap == RLIM_INFINITY ||
8803 sysctl_legacy_va_layout) {
8804 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
8805 +
8806 +#ifdef CONFIG_PAX_RANDMMAP
8807 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8808 + mm->mmap_base += mm->delta_mmap;
8809 +#endif
8810 +
8811 mm->get_unmapped_area = arch_get_unmapped_area;
8812 mm->unmap_area = arch_unmap_area;
8813 } else {
8814 @@ -301,6 +333,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8815 gap = (task_size / 6 * 5);
8816
8817 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
8818 +
8819 +#ifdef CONFIG_PAX_RANDMMAP
8820 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8821 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8822 +#endif
8823 +
8824 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8825 mm->unmap_area = arch_unmap_area_topdown;
8826 }
8827 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
8828 index 22a1098..6255eb9 100644
8829 --- a/arch/sparc/kernel/syscalls.S
8830 +++ b/arch/sparc/kernel/syscalls.S
8831 @@ -52,7 +52,7 @@ sys32_rt_sigreturn:
8832 #endif
8833 .align 32
8834 1: ldx [%g6 + TI_FLAGS], %l5
8835 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8836 + andcc %l5, _TIF_WORK_SYSCALL, %g0
8837 be,pt %icc, rtrap
8838 nop
8839 call syscall_trace_leave
8840 @@ -184,7 +184,7 @@ linux_sparc_syscall32:
8841
8842 srl %i5, 0, %o5 ! IEU1
8843 srl %i2, 0, %o2 ! IEU0 Group
8844 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8845 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8846 bne,pn %icc, linux_syscall_trace32 ! CTI
8847 mov %i0, %l5 ! IEU1
8848 call %l7 ! CTI Group brk forced
8849 @@ -207,7 +207,7 @@ linux_sparc_syscall:
8850
8851 mov %i3, %o3 ! IEU1
8852 mov %i4, %o4 ! IEU0 Group
8853 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8854 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8855 bne,pn %icc, linux_syscall_trace ! CTI Group
8856 mov %i0, %l5 ! IEU0
8857 2: call %l7 ! CTI Group brk forced
8858 @@ -223,7 +223,7 @@ ret_sys_call:
8859
8860 cmp %o0, -ERESTART_RESTARTBLOCK
8861 bgeu,pn %xcc, 1f
8862 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
8863 + andcc %l0, _TIF_WORK_SYSCALL, %g0
8864 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
8865
8866 2:
8867 diff --git a/arch/sparc/kernel/sysfs.c b/arch/sparc/kernel/sysfs.c
8868 index 654e8aa..45f431b 100644
8869 --- a/arch/sparc/kernel/sysfs.c
8870 +++ b/arch/sparc/kernel/sysfs.c
8871 @@ -266,7 +266,7 @@ static int __cpuinit sysfs_cpu_notify(struct notifier_block *self,
8872 return NOTIFY_OK;
8873 }
8874
8875 -static struct notifier_block __cpuinitdata sysfs_cpu_nb = {
8876 +static struct notifier_block sysfs_cpu_nb = {
8877 .notifier_call = sysfs_cpu_notify,
8878 };
8879
8880 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
8881 index 6629829..036032d 100644
8882 --- a/arch/sparc/kernel/traps_32.c
8883 +++ b/arch/sparc/kernel/traps_32.c
8884 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
8885 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
8886 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
8887
8888 +extern void gr_handle_kernel_exploit(void);
8889 +
8890 void die_if_kernel(char *str, struct pt_regs *regs)
8891 {
8892 static int die_counter;
8893 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
8894 count++ < 30 &&
8895 (((unsigned long) rw) >= PAGE_OFFSET) &&
8896 !(((unsigned long) rw) & 0x7)) {
8897 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
8898 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
8899 (void *) rw->ins[7]);
8900 rw = (struct reg_window32 *)rw->ins[6];
8901 }
8902 }
8903 printk("Instruction DUMP:");
8904 instruction_dump ((unsigned long *) regs->pc);
8905 - if(regs->psr & PSR_PS)
8906 + if(regs->psr & PSR_PS) {
8907 + gr_handle_kernel_exploit();
8908 do_exit(SIGKILL);
8909 + }
8910 do_exit(SIGSEGV);
8911 }
8912
8913 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
8914 index b3f833a..ac74b2d 100644
8915 --- a/arch/sparc/kernel/traps_64.c
8916 +++ b/arch/sparc/kernel/traps_64.c
8917 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
8918 i + 1,
8919 p->trapstack[i].tstate, p->trapstack[i].tpc,
8920 p->trapstack[i].tnpc, p->trapstack[i].tt);
8921 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
8922 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
8923 }
8924 }
8925
8926 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
8927
8928 lvl -= 0x100;
8929 if (regs->tstate & TSTATE_PRIV) {
8930 +
8931 +#ifdef CONFIG_PAX_REFCOUNT
8932 + if (lvl == 6)
8933 + pax_report_refcount_overflow(regs);
8934 +#endif
8935 +
8936 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
8937 die_if_kernel(buffer, regs);
8938 }
8939 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
8940 void bad_trap_tl1(struct pt_regs *regs, long lvl)
8941 {
8942 char buffer[32];
8943 -
8944 +
8945 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
8946 0, lvl, SIGTRAP) == NOTIFY_STOP)
8947 return;
8948
8949 +#ifdef CONFIG_PAX_REFCOUNT
8950 + if (lvl == 6)
8951 + pax_report_refcount_overflow(regs);
8952 +#endif
8953 +
8954 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
8955
8956 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
8957 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
8958 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
8959 printk("%s" "ERROR(%d): ",
8960 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
8961 - printk("TPC<%pS>\n", (void *) regs->tpc);
8962 + printk("TPC<%pA>\n", (void *) regs->tpc);
8963 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
8964 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
8965 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
8966 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
8967 smp_processor_id(),
8968 (type & 0x1) ? 'I' : 'D',
8969 regs->tpc);
8970 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
8971 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
8972 panic("Irrecoverable Cheetah+ parity error.");
8973 }
8974
8975 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
8976 smp_processor_id(),
8977 (type & 0x1) ? 'I' : 'D',
8978 regs->tpc);
8979 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
8980 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
8981 }
8982
8983 struct sun4v_error_entry {
8984 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
8985
8986 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
8987 regs->tpc, tl);
8988 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
8989 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
8990 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
8991 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
8992 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
8993 (void *) regs->u_regs[UREG_I7]);
8994 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
8995 "pte[%lx] error[%lx]\n",
8996 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
8997
8998 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
8999 regs->tpc, tl);
9000 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
9001 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
9002 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
9003 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
9004 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
9005 (void *) regs->u_regs[UREG_I7]);
9006 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
9007 "pte[%lx] error[%lx]\n",
9008 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
9009 fp = (unsigned long)sf->fp + STACK_BIAS;
9010 }
9011
9012 - printk(" [%016lx] %pS\n", pc, (void *) pc);
9013 + printk(" [%016lx] %pA\n", pc, (void *) pc);
9014 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
9015 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
9016 int index = tsk->curr_ret_stack;
9017 if (tsk->ret_stack && index >= graph) {
9018 pc = tsk->ret_stack[index - graph].ret;
9019 - printk(" [%016lx] %pS\n", pc, (void *) pc);
9020 + printk(" [%016lx] %pA\n", pc, (void *) pc);
9021 graph++;
9022 }
9023 }
9024 @@ -2360,6 +2371,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
9025 return (struct reg_window *) (fp + STACK_BIAS);
9026 }
9027
9028 +extern void gr_handle_kernel_exploit(void);
9029 +
9030 void die_if_kernel(char *str, struct pt_regs *regs)
9031 {
9032 static int die_counter;
9033 @@ -2388,7 +2401,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9034 while (rw &&
9035 count++ < 30 &&
9036 kstack_valid(tp, (unsigned long) rw)) {
9037 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
9038 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
9039 (void *) rw->ins[7]);
9040
9041 rw = kernel_stack_up(rw);
9042 @@ -2401,8 +2414,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9043 }
9044 user_instruction_dump ((unsigned int __user *) regs->tpc);
9045 }
9046 - if (regs->tstate & TSTATE_PRIV)
9047 + if (regs->tstate & TSTATE_PRIV) {
9048 + gr_handle_kernel_exploit();
9049 do_exit(SIGKILL);
9050 + }
9051 do_exit(SIGSEGV);
9052 }
9053 EXPORT_SYMBOL(die_if_kernel);
9054 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
9055 index 8201c25e..072a2a7 100644
9056 --- a/arch/sparc/kernel/unaligned_64.c
9057 +++ b/arch/sparc/kernel/unaligned_64.c
9058 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
9059 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
9060
9061 if (__ratelimit(&ratelimit)) {
9062 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
9063 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
9064 regs->tpc, (void *) regs->tpc);
9065 }
9066 }
9067 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
9068 index dbe119b..089c7c1 100644
9069 --- a/arch/sparc/lib/Makefile
9070 +++ b/arch/sparc/lib/Makefile
9071 @@ -2,7 +2,7 @@
9072 #
9073
9074 asflags-y := -ansi -DST_DIV0=0x02
9075 -ccflags-y := -Werror
9076 +#ccflags-y := -Werror
9077
9078 lib-$(CONFIG_SPARC32) += ashrdi3.o
9079 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
9080 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
9081 index 85c233d..68500e0 100644
9082 --- a/arch/sparc/lib/atomic_64.S
9083 +++ b/arch/sparc/lib/atomic_64.S
9084 @@ -17,7 +17,12 @@
9085 ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
9086 BACKOFF_SETUP(%o2)
9087 1: lduw [%o1], %g1
9088 - add %g1, %o0, %g7
9089 + addcc %g1, %o0, %g7
9090 +
9091 +#ifdef CONFIG_PAX_REFCOUNT
9092 + tvs %icc, 6
9093 +#endif
9094 +
9095 cas [%o1], %g1, %g7
9096 cmp %g1, %g7
9097 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9098 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
9099 2: BACKOFF_SPIN(%o2, %o3, 1b)
9100 ENDPROC(atomic_add)
9101
9102 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9103 + BACKOFF_SETUP(%o2)
9104 +1: lduw [%o1], %g1
9105 + add %g1, %o0, %g7
9106 + cas [%o1], %g1, %g7
9107 + cmp %g1, %g7
9108 + bne,pn %icc, 2f
9109 + nop
9110 + retl
9111 + nop
9112 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9113 +ENDPROC(atomic_add_unchecked)
9114 +
9115 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9116 BACKOFF_SETUP(%o2)
9117 1: lduw [%o1], %g1
9118 - sub %g1, %o0, %g7
9119 + subcc %g1, %o0, %g7
9120 +
9121 +#ifdef CONFIG_PAX_REFCOUNT
9122 + tvs %icc, 6
9123 +#endif
9124 +
9125 cas [%o1], %g1, %g7
9126 cmp %g1, %g7
9127 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9128 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9129 2: BACKOFF_SPIN(%o2, %o3, 1b)
9130 ENDPROC(atomic_sub)
9131
9132 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
9133 + BACKOFF_SETUP(%o2)
9134 +1: lduw [%o1], %g1
9135 + sub %g1, %o0, %g7
9136 + cas [%o1], %g1, %g7
9137 + cmp %g1, %g7
9138 + bne,pn %icc, 2f
9139 + nop
9140 + retl
9141 + nop
9142 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9143 +ENDPROC(atomic_sub_unchecked)
9144 +
9145 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9146 BACKOFF_SETUP(%o2)
9147 1: lduw [%o1], %g1
9148 - add %g1, %o0, %g7
9149 + addcc %g1, %o0, %g7
9150 +
9151 +#ifdef CONFIG_PAX_REFCOUNT
9152 + tvs %icc, 6
9153 +#endif
9154 +
9155 cas [%o1], %g1, %g7
9156 cmp %g1, %g7
9157 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9158 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9159 2: BACKOFF_SPIN(%o2, %o3, 1b)
9160 ENDPROC(atomic_add_ret)
9161
9162 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9163 + BACKOFF_SETUP(%o2)
9164 +1: lduw [%o1], %g1
9165 + addcc %g1, %o0, %g7
9166 + cas [%o1], %g1, %g7
9167 + cmp %g1, %g7
9168 + bne,pn %icc, 2f
9169 + add %g7, %o0, %g7
9170 + sra %g7, 0, %o0
9171 + retl
9172 + nop
9173 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9174 +ENDPROC(atomic_add_ret_unchecked)
9175 +
9176 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
9177 BACKOFF_SETUP(%o2)
9178 1: lduw [%o1], %g1
9179 - sub %g1, %o0, %g7
9180 + subcc %g1, %o0, %g7
9181 +
9182 +#ifdef CONFIG_PAX_REFCOUNT
9183 + tvs %icc, 6
9184 +#endif
9185 +
9186 cas [%o1], %g1, %g7
9187 cmp %g1, %g7
9188 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
9189 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
9190 ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
9191 BACKOFF_SETUP(%o2)
9192 1: ldx [%o1], %g1
9193 - add %g1, %o0, %g7
9194 + addcc %g1, %o0, %g7
9195 +
9196 +#ifdef CONFIG_PAX_REFCOUNT
9197 + tvs %xcc, 6
9198 +#endif
9199 +
9200 casx [%o1], %g1, %g7
9201 cmp %g1, %g7
9202 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9203 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
9204 2: BACKOFF_SPIN(%o2, %o3, 1b)
9205 ENDPROC(atomic64_add)
9206
9207 +ENTRY(atomic64_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9208 + BACKOFF_SETUP(%o2)
9209 +1: ldx [%o1], %g1
9210 + addcc %g1, %o0, %g7
9211 + casx [%o1], %g1, %g7
9212 + cmp %g1, %g7
9213 + bne,pn %xcc, 2f
9214 + nop
9215 + retl
9216 + nop
9217 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9218 +ENDPROC(atomic64_add_unchecked)
9219 +
9220 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9221 BACKOFF_SETUP(%o2)
9222 1: ldx [%o1], %g1
9223 - sub %g1, %o0, %g7
9224 + subcc %g1, %o0, %g7
9225 +
9226 +#ifdef CONFIG_PAX_REFCOUNT
9227 + tvs %xcc, 6
9228 +#endif
9229 +
9230 casx [%o1], %g1, %g7
9231 cmp %g1, %g7
9232 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9233 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
9234 2: BACKOFF_SPIN(%o2, %o3, 1b)
9235 ENDPROC(atomic64_sub)
9236
9237 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
9238 + BACKOFF_SETUP(%o2)
9239 +1: ldx [%o1], %g1
9240 + subcc %g1, %o0, %g7
9241 + casx [%o1], %g1, %g7
9242 + cmp %g1, %g7
9243 + bne,pn %xcc, 2f
9244 + nop
9245 + retl
9246 + nop
9247 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9248 +ENDPROC(atomic64_sub_unchecked)
9249 +
9250 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9251 BACKOFF_SETUP(%o2)
9252 1: ldx [%o1], %g1
9253 - add %g1, %o0, %g7
9254 + addcc %g1, %o0, %g7
9255 +
9256 +#ifdef CONFIG_PAX_REFCOUNT
9257 + tvs %xcc, 6
9258 +#endif
9259 +
9260 casx [%o1], %g1, %g7
9261 cmp %g1, %g7
9262 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9263 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
9264 2: BACKOFF_SPIN(%o2, %o3, 1b)
9265 ENDPROC(atomic64_add_ret)
9266
9267 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
9268 + BACKOFF_SETUP(%o2)
9269 +1: ldx [%o1], %g1
9270 + addcc %g1, %o0, %g7
9271 + casx [%o1], %g1, %g7
9272 + cmp %g1, %g7
9273 + bne,pn %xcc, 2f
9274 + add %g7, %o0, %g7
9275 + mov %g7, %o0
9276 + retl
9277 + nop
9278 +2: BACKOFF_SPIN(%o2, %o3, 1b)
9279 +ENDPROC(atomic64_add_ret_unchecked)
9280 +
9281 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
9282 BACKOFF_SETUP(%o2)
9283 1: ldx [%o1], %g1
9284 - sub %g1, %o0, %g7
9285 + subcc %g1, %o0, %g7
9286 +
9287 +#ifdef CONFIG_PAX_REFCOUNT
9288 + tvs %xcc, 6
9289 +#endif
9290 +
9291 casx [%o1], %g1, %g7
9292 cmp %g1, %g7
9293 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
9294 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
9295 index 0c4e35e..745d3e4 100644
9296 --- a/arch/sparc/lib/ksyms.c
9297 +++ b/arch/sparc/lib/ksyms.c
9298 @@ -109,12 +109,18 @@ EXPORT_SYMBOL(__downgrade_write);
9299
9300 /* Atomic counter implementation. */
9301 EXPORT_SYMBOL(atomic_add);
9302 +EXPORT_SYMBOL(atomic_add_unchecked);
9303 EXPORT_SYMBOL(atomic_add_ret);
9304 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
9305 EXPORT_SYMBOL(atomic_sub);
9306 +EXPORT_SYMBOL(atomic_sub_unchecked);
9307 EXPORT_SYMBOL(atomic_sub_ret);
9308 EXPORT_SYMBOL(atomic64_add);
9309 +EXPORT_SYMBOL(atomic64_add_unchecked);
9310 EXPORT_SYMBOL(atomic64_add_ret);
9311 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
9312 EXPORT_SYMBOL(atomic64_sub);
9313 +EXPORT_SYMBOL(atomic64_sub_unchecked);
9314 EXPORT_SYMBOL(atomic64_sub_ret);
9315 EXPORT_SYMBOL(atomic64_dec_if_positive);
9316
9317 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
9318 index 30c3ecc..736f015 100644
9319 --- a/arch/sparc/mm/Makefile
9320 +++ b/arch/sparc/mm/Makefile
9321 @@ -2,7 +2,7 @@
9322 #
9323
9324 asflags-y := -ansi
9325 -ccflags-y := -Werror
9326 +#ccflags-y := -Werror
9327
9328 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
9329 obj-y += fault_$(BITS).o
9330 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
9331 index e98bfda..ea8d221 100644
9332 --- a/arch/sparc/mm/fault_32.c
9333 +++ b/arch/sparc/mm/fault_32.c
9334 @@ -21,6 +21,9 @@
9335 #include <linux/perf_event.h>
9336 #include <linux/interrupt.h>
9337 #include <linux/kdebug.h>
9338 +#include <linux/slab.h>
9339 +#include <linux/pagemap.h>
9340 +#include <linux/compiler.h>
9341
9342 #include <asm/page.h>
9343 #include <asm/pgtable.h>
9344 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
9345 return safe_compute_effective_address(regs, insn);
9346 }
9347
9348 +#ifdef CONFIG_PAX_PAGEEXEC
9349 +#ifdef CONFIG_PAX_DLRESOLVE
9350 +static void pax_emuplt_close(struct vm_area_struct *vma)
9351 +{
9352 + vma->vm_mm->call_dl_resolve = 0UL;
9353 +}
9354 +
9355 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9356 +{
9357 + unsigned int *kaddr;
9358 +
9359 + vmf->page = alloc_page(GFP_HIGHUSER);
9360 + if (!vmf->page)
9361 + return VM_FAULT_OOM;
9362 +
9363 + kaddr = kmap(vmf->page);
9364 + memset(kaddr, 0, PAGE_SIZE);
9365 + kaddr[0] = 0x9DE3BFA8U; /* save */
9366 + flush_dcache_page(vmf->page);
9367 + kunmap(vmf->page);
9368 + return VM_FAULT_MAJOR;
9369 +}
9370 +
9371 +static const struct vm_operations_struct pax_vm_ops = {
9372 + .close = pax_emuplt_close,
9373 + .fault = pax_emuplt_fault
9374 +};
9375 +
9376 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9377 +{
9378 + int ret;
9379 +
9380 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9381 + vma->vm_mm = current->mm;
9382 + vma->vm_start = addr;
9383 + vma->vm_end = addr + PAGE_SIZE;
9384 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9385 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9386 + vma->vm_ops = &pax_vm_ops;
9387 +
9388 + ret = insert_vm_struct(current->mm, vma);
9389 + if (ret)
9390 + return ret;
9391 +
9392 + ++current->mm->total_vm;
9393 + return 0;
9394 +}
9395 +#endif
9396 +
9397 +/*
9398 + * PaX: decide what to do with offenders (regs->pc = fault address)
9399 + *
9400 + * returns 1 when task should be killed
9401 + * 2 when patched PLT trampoline was detected
9402 + * 3 when unpatched PLT trampoline was detected
9403 + */
9404 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9405 +{
9406 +
9407 +#ifdef CONFIG_PAX_EMUPLT
9408 + int err;
9409 +
9410 + do { /* PaX: patched PLT emulation #1 */
9411 + unsigned int sethi1, sethi2, jmpl;
9412 +
9413 + err = get_user(sethi1, (unsigned int *)regs->pc);
9414 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
9415 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
9416 +
9417 + if (err)
9418 + break;
9419 +
9420 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9421 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9422 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9423 + {
9424 + unsigned int addr;
9425 +
9426 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9427 + addr = regs->u_regs[UREG_G1];
9428 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9429 + regs->pc = addr;
9430 + regs->npc = addr+4;
9431 + return 2;
9432 + }
9433 + } while (0);
9434 +
9435 + do { /* PaX: patched PLT emulation #2 */
9436 + unsigned int ba;
9437 +
9438 + err = get_user(ba, (unsigned int *)regs->pc);
9439 +
9440 + if (err)
9441 + break;
9442 +
9443 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9444 + unsigned int addr;
9445 +
9446 + if ((ba & 0xFFC00000U) == 0x30800000U)
9447 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9448 + else
9449 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9450 + regs->pc = addr;
9451 + regs->npc = addr+4;
9452 + return 2;
9453 + }
9454 + } while (0);
9455 +
9456 + do { /* PaX: patched PLT emulation #3 */
9457 + unsigned int sethi, bajmpl, nop;
9458 +
9459 + err = get_user(sethi, (unsigned int *)regs->pc);
9460 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
9461 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9462 +
9463 + if (err)
9464 + break;
9465 +
9466 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9467 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9468 + nop == 0x01000000U)
9469 + {
9470 + unsigned int addr;
9471 +
9472 + addr = (sethi & 0x003FFFFFU) << 10;
9473 + regs->u_regs[UREG_G1] = addr;
9474 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9475 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9476 + else
9477 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9478 + regs->pc = addr;
9479 + regs->npc = addr+4;
9480 + return 2;
9481 + }
9482 + } while (0);
9483 +
9484 + do { /* PaX: unpatched PLT emulation step 1 */
9485 + unsigned int sethi, ba, nop;
9486 +
9487 + err = get_user(sethi, (unsigned int *)regs->pc);
9488 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
9489 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
9490 +
9491 + if (err)
9492 + break;
9493 +
9494 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9495 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9496 + nop == 0x01000000U)
9497 + {
9498 + unsigned int addr, save, call;
9499 +
9500 + if ((ba & 0xFFC00000U) == 0x30800000U)
9501 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
9502 + else
9503 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
9504 +
9505 + err = get_user(save, (unsigned int *)addr);
9506 + err |= get_user(call, (unsigned int *)(addr+4));
9507 + err |= get_user(nop, (unsigned int *)(addr+8));
9508 + if (err)
9509 + break;
9510 +
9511 +#ifdef CONFIG_PAX_DLRESOLVE
9512 + if (save == 0x9DE3BFA8U &&
9513 + (call & 0xC0000000U) == 0x40000000U &&
9514 + nop == 0x01000000U)
9515 + {
9516 + struct vm_area_struct *vma;
9517 + unsigned long call_dl_resolve;
9518 +
9519 + down_read(&current->mm->mmap_sem);
9520 + call_dl_resolve = current->mm->call_dl_resolve;
9521 + up_read(&current->mm->mmap_sem);
9522 + if (likely(call_dl_resolve))
9523 + goto emulate;
9524 +
9525 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9526 +
9527 + down_write(&current->mm->mmap_sem);
9528 + if (current->mm->call_dl_resolve) {
9529 + call_dl_resolve = current->mm->call_dl_resolve;
9530 + up_write(&current->mm->mmap_sem);
9531 + if (vma)
9532 + kmem_cache_free(vm_area_cachep, vma);
9533 + goto emulate;
9534 + }
9535 +
9536 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9537 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9538 + up_write(&current->mm->mmap_sem);
9539 + if (vma)
9540 + kmem_cache_free(vm_area_cachep, vma);
9541 + return 1;
9542 + }
9543 +
9544 + if (pax_insert_vma(vma, call_dl_resolve)) {
9545 + up_write(&current->mm->mmap_sem);
9546 + kmem_cache_free(vm_area_cachep, vma);
9547 + return 1;
9548 + }
9549 +
9550 + current->mm->call_dl_resolve = call_dl_resolve;
9551 + up_write(&current->mm->mmap_sem);
9552 +
9553 +emulate:
9554 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9555 + regs->pc = call_dl_resolve;
9556 + regs->npc = addr+4;
9557 + return 3;
9558 + }
9559 +#endif
9560 +
9561 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
9562 + if ((save & 0xFFC00000U) == 0x05000000U &&
9563 + (call & 0xFFFFE000U) == 0x85C0A000U &&
9564 + nop == 0x01000000U)
9565 + {
9566 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9567 + regs->u_regs[UREG_G2] = addr + 4;
9568 + addr = (save & 0x003FFFFFU) << 10;
9569 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
9570 + regs->pc = addr;
9571 + regs->npc = addr+4;
9572 + return 3;
9573 + }
9574 + }
9575 + } while (0);
9576 +
9577 + do { /* PaX: unpatched PLT emulation step 2 */
9578 + unsigned int save, call, nop;
9579 +
9580 + err = get_user(save, (unsigned int *)(regs->pc-4));
9581 + err |= get_user(call, (unsigned int *)regs->pc);
9582 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
9583 + if (err)
9584 + break;
9585 +
9586 + if (save == 0x9DE3BFA8U &&
9587 + (call & 0xC0000000U) == 0x40000000U &&
9588 + nop == 0x01000000U)
9589 + {
9590 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
9591 +
9592 + regs->u_regs[UREG_RETPC] = regs->pc;
9593 + regs->pc = dl_resolve;
9594 + regs->npc = dl_resolve+4;
9595 + return 3;
9596 + }
9597 + } while (0);
9598 +#endif
9599 +
9600 + return 1;
9601 +}
9602 +
9603 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
9604 +{
9605 + unsigned long i;
9606 +
9607 + printk(KERN_ERR "PAX: bytes at PC: ");
9608 + for (i = 0; i < 8; i++) {
9609 + unsigned int c;
9610 + if (get_user(c, (unsigned int *)pc+i))
9611 + printk(KERN_CONT "???????? ");
9612 + else
9613 + printk(KERN_CONT "%08x ", c);
9614 + }
9615 + printk("\n");
9616 +}
9617 +#endif
9618 +
9619 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
9620 int text_fault)
9621 {
9622 @@ -230,6 +504,24 @@ good_area:
9623 if (!(vma->vm_flags & VM_WRITE))
9624 goto bad_area;
9625 } else {
9626 +
9627 +#ifdef CONFIG_PAX_PAGEEXEC
9628 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
9629 + up_read(&mm->mmap_sem);
9630 + switch (pax_handle_fetch_fault(regs)) {
9631 +
9632 +#ifdef CONFIG_PAX_EMUPLT
9633 + case 2:
9634 + case 3:
9635 + return;
9636 +#endif
9637 +
9638 + }
9639 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
9640 + do_group_exit(SIGKILL);
9641 + }
9642 +#endif
9643 +
9644 /* Allow reads even for write-only mappings */
9645 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
9646 goto bad_area;
9647 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
9648 index 5062ff3..e0b75f3 100644
9649 --- a/arch/sparc/mm/fault_64.c
9650 +++ b/arch/sparc/mm/fault_64.c
9651 @@ -21,6 +21,9 @@
9652 #include <linux/kprobes.h>
9653 #include <linux/kdebug.h>
9654 #include <linux/percpu.h>
9655 +#include <linux/slab.h>
9656 +#include <linux/pagemap.h>
9657 +#include <linux/compiler.h>
9658
9659 #include <asm/page.h>
9660 #include <asm/pgtable.h>
9661 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
9662 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
9663 regs->tpc);
9664 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
9665 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
9666 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
9667 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
9668 dump_stack();
9669 unhandled_fault(regs->tpc, current, regs);
9670 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
9671 show_regs(regs);
9672 }
9673
9674 +#ifdef CONFIG_PAX_PAGEEXEC
9675 +#ifdef CONFIG_PAX_DLRESOLVE
9676 +static void pax_emuplt_close(struct vm_area_struct *vma)
9677 +{
9678 + vma->vm_mm->call_dl_resolve = 0UL;
9679 +}
9680 +
9681 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
9682 +{
9683 + unsigned int *kaddr;
9684 +
9685 + vmf->page = alloc_page(GFP_HIGHUSER);
9686 + if (!vmf->page)
9687 + return VM_FAULT_OOM;
9688 +
9689 + kaddr = kmap(vmf->page);
9690 + memset(kaddr, 0, PAGE_SIZE);
9691 + kaddr[0] = 0x9DE3BFA8U; /* save */
9692 + flush_dcache_page(vmf->page);
9693 + kunmap(vmf->page);
9694 + return VM_FAULT_MAJOR;
9695 +}
9696 +
9697 +static const struct vm_operations_struct pax_vm_ops = {
9698 + .close = pax_emuplt_close,
9699 + .fault = pax_emuplt_fault
9700 +};
9701 +
9702 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
9703 +{
9704 + int ret;
9705 +
9706 + INIT_LIST_HEAD(&vma->anon_vma_chain);
9707 + vma->vm_mm = current->mm;
9708 + vma->vm_start = addr;
9709 + vma->vm_end = addr + PAGE_SIZE;
9710 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
9711 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
9712 + vma->vm_ops = &pax_vm_ops;
9713 +
9714 + ret = insert_vm_struct(current->mm, vma);
9715 + if (ret)
9716 + return ret;
9717 +
9718 + ++current->mm->total_vm;
9719 + return 0;
9720 +}
9721 +#endif
9722 +
9723 +/*
9724 + * PaX: decide what to do with offenders (regs->tpc = fault address)
9725 + *
9726 + * returns 1 when task should be killed
9727 + * 2 when patched PLT trampoline was detected
9728 + * 3 when unpatched PLT trampoline was detected
9729 + */
9730 +static int pax_handle_fetch_fault(struct pt_regs *regs)
9731 +{
9732 +
9733 +#ifdef CONFIG_PAX_EMUPLT
9734 + int err;
9735 +
9736 + do { /* PaX: patched PLT emulation #1 */
9737 + unsigned int sethi1, sethi2, jmpl;
9738 +
9739 + err = get_user(sethi1, (unsigned int *)regs->tpc);
9740 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
9741 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
9742 +
9743 + if (err)
9744 + break;
9745 +
9746 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
9747 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
9748 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
9749 + {
9750 + unsigned long addr;
9751 +
9752 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
9753 + addr = regs->u_regs[UREG_G1];
9754 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9755 +
9756 + if (test_thread_flag(TIF_32BIT))
9757 + addr &= 0xFFFFFFFFUL;
9758 +
9759 + regs->tpc = addr;
9760 + regs->tnpc = addr+4;
9761 + return 2;
9762 + }
9763 + } while (0);
9764 +
9765 + do { /* PaX: patched PLT emulation #2 */
9766 + unsigned int ba;
9767 +
9768 + err = get_user(ba, (unsigned int *)regs->tpc);
9769 +
9770 + if (err)
9771 + break;
9772 +
9773 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
9774 + unsigned long addr;
9775 +
9776 + if ((ba & 0xFFC00000U) == 0x30800000U)
9777 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9778 + else
9779 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9780 +
9781 + if (test_thread_flag(TIF_32BIT))
9782 + addr &= 0xFFFFFFFFUL;
9783 +
9784 + regs->tpc = addr;
9785 + regs->tnpc = addr+4;
9786 + return 2;
9787 + }
9788 + } while (0);
9789 +
9790 + do { /* PaX: patched PLT emulation #3 */
9791 + unsigned int sethi, bajmpl, nop;
9792 +
9793 + err = get_user(sethi, (unsigned int *)regs->tpc);
9794 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
9795 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9796 +
9797 + if (err)
9798 + break;
9799 +
9800 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9801 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
9802 + nop == 0x01000000U)
9803 + {
9804 + unsigned long addr;
9805 +
9806 + addr = (sethi & 0x003FFFFFU) << 10;
9807 + regs->u_regs[UREG_G1] = addr;
9808 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
9809 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
9810 + else
9811 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9812 +
9813 + if (test_thread_flag(TIF_32BIT))
9814 + addr &= 0xFFFFFFFFUL;
9815 +
9816 + regs->tpc = addr;
9817 + regs->tnpc = addr+4;
9818 + return 2;
9819 + }
9820 + } while (0);
9821 +
9822 + do { /* PaX: patched PLT emulation #4 */
9823 + unsigned int sethi, mov1, call, mov2;
9824 +
9825 + err = get_user(sethi, (unsigned int *)regs->tpc);
9826 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
9827 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
9828 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
9829 +
9830 + if (err)
9831 + break;
9832 +
9833 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9834 + mov1 == 0x8210000FU &&
9835 + (call & 0xC0000000U) == 0x40000000U &&
9836 + mov2 == 0x9E100001U)
9837 + {
9838 + unsigned long addr;
9839 +
9840 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
9841 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
9842 +
9843 + if (test_thread_flag(TIF_32BIT))
9844 + addr &= 0xFFFFFFFFUL;
9845 +
9846 + regs->tpc = addr;
9847 + regs->tnpc = addr+4;
9848 + return 2;
9849 + }
9850 + } while (0);
9851 +
9852 + do { /* PaX: patched PLT emulation #5 */
9853 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
9854 +
9855 + err = get_user(sethi, (unsigned int *)regs->tpc);
9856 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
9857 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
9858 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
9859 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
9860 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
9861 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
9862 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
9863 +
9864 + if (err)
9865 + break;
9866 +
9867 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9868 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
9869 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9870 + (or1 & 0xFFFFE000U) == 0x82106000U &&
9871 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
9872 + sllx == 0x83287020U &&
9873 + jmpl == 0x81C04005U &&
9874 + nop == 0x01000000U)
9875 + {
9876 + unsigned long addr;
9877 +
9878 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
9879 + regs->u_regs[UREG_G1] <<= 32;
9880 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
9881 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
9882 + regs->tpc = addr;
9883 + regs->tnpc = addr+4;
9884 + return 2;
9885 + }
9886 + } while (0);
9887 +
9888 + do { /* PaX: patched PLT emulation #6 */
9889 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
9890 +
9891 + err = get_user(sethi, (unsigned int *)regs->tpc);
9892 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
9893 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
9894 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
9895 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
9896 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
9897 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
9898 +
9899 + if (err)
9900 + break;
9901 +
9902 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9903 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
9904 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
9905 + sllx == 0x83287020U &&
9906 + (or & 0xFFFFE000U) == 0x8A116000U &&
9907 + jmpl == 0x81C04005U &&
9908 + nop == 0x01000000U)
9909 + {
9910 + unsigned long addr;
9911 +
9912 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
9913 + regs->u_regs[UREG_G1] <<= 32;
9914 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
9915 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
9916 + regs->tpc = addr;
9917 + regs->tnpc = addr+4;
9918 + return 2;
9919 + }
9920 + } while (0);
9921 +
9922 + do { /* PaX: unpatched PLT emulation step 1 */
9923 + unsigned int sethi, ba, nop;
9924 +
9925 + err = get_user(sethi, (unsigned int *)regs->tpc);
9926 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
9927 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
9928 +
9929 + if (err)
9930 + break;
9931 +
9932 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
9933 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
9934 + nop == 0x01000000U)
9935 + {
9936 + unsigned long addr;
9937 + unsigned int save, call;
9938 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
9939 +
9940 + if ((ba & 0xFFC00000U) == 0x30800000U)
9941 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
9942 + else
9943 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
9944 +
9945 + if (test_thread_flag(TIF_32BIT))
9946 + addr &= 0xFFFFFFFFUL;
9947 +
9948 + err = get_user(save, (unsigned int *)addr);
9949 + err |= get_user(call, (unsigned int *)(addr+4));
9950 + err |= get_user(nop, (unsigned int *)(addr+8));
9951 + if (err)
9952 + break;
9953 +
9954 +#ifdef CONFIG_PAX_DLRESOLVE
9955 + if (save == 0x9DE3BFA8U &&
9956 + (call & 0xC0000000U) == 0x40000000U &&
9957 + nop == 0x01000000U)
9958 + {
9959 + struct vm_area_struct *vma;
9960 + unsigned long call_dl_resolve;
9961 +
9962 + down_read(&current->mm->mmap_sem);
9963 + call_dl_resolve = current->mm->call_dl_resolve;
9964 + up_read(&current->mm->mmap_sem);
9965 + if (likely(call_dl_resolve))
9966 + goto emulate;
9967 +
9968 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
9969 +
9970 + down_write(&current->mm->mmap_sem);
9971 + if (current->mm->call_dl_resolve) {
9972 + call_dl_resolve = current->mm->call_dl_resolve;
9973 + up_write(&current->mm->mmap_sem);
9974 + if (vma)
9975 + kmem_cache_free(vm_area_cachep, vma);
9976 + goto emulate;
9977 + }
9978 +
9979 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
9980 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
9981 + up_write(&current->mm->mmap_sem);
9982 + if (vma)
9983 + kmem_cache_free(vm_area_cachep, vma);
9984 + return 1;
9985 + }
9986 +
9987 + if (pax_insert_vma(vma, call_dl_resolve)) {
9988 + up_write(&current->mm->mmap_sem);
9989 + kmem_cache_free(vm_area_cachep, vma);
9990 + return 1;
9991 + }
9992 +
9993 + current->mm->call_dl_resolve = call_dl_resolve;
9994 + up_write(&current->mm->mmap_sem);
9995 +
9996 +emulate:
9997 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
9998 + regs->tpc = call_dl_resolve;
9999 + regs->tnpc = addr+4;
10000 + return 3;
10001 + }
10002 +#endif
10003 +
10004 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
10005 + if ((save & 0xFFC00000U) == 0x05000000U &&
10006 + (call & 0xFFFFE000U) == 0x85C0A000U &&
10007 + nop == 0x01000000U)
10008 + {
10009 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10010 + regs->u_regs[UREG_G2] = addr + 4;
10011 + addr = (save & 0x003FFFFFU) << 10;
10012 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10013 +
10014 + if (test_thread_flag(TIF_32BIT))
10015 + addr &= 0xFFFFFFFFUL;
10016 +
10017 + regs->tpc = addr;
10018 + regs->tnpc = addr+4;
10019 + return 3;
10020 + }
10021 +
10022 + /* PaX: 64-bit PLT stub */
10023 + err = get_user(sethi1, (unsigned int *)addr);
10024 + err |= get_user(sethi2, (unsigned int *)(addr+4));
10025 + err |= get_user(or1, (unsigned int *)(addr+8));
10026 + err |= get_user(or2, (unsigned int *)(addr+12));
10027 + err |= get_user(sllx, (unsigned int *)(addr+16));
10028 + err |= get_user(add, (unsigned int *)(addr+20));
10029 + err |= get_user(jmpl, (unsigned int *)(addr+24));
10030 + err |= get_user(nop, (unsigned int *)(addr+28));
10031 + if (err)
10032 + break;
10033 +
10034 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
10035 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10036 + (or1 & 0xFFFFE000U) == 0x88112000U &&
10037 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
10038 + sllx == 0x89293020U &&
10039 + add == 0x8A010005U &&
10040 + jmpl == 0x89C14000U &&
10041 + nop == 0x01000000U)
10042 + {
10043 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10044 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
10045 + regs->u_regs[UREG_G4] <<= 32;
10046 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
10047 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
10048 + regs->u_regs[UREG_G4] = addr + 24;
10049 + addr = regs->u_regs[UREG_G5];
10050 + regs->tpc = addr;
10051 + regs->tnpc = addr+4;
10052 + return 3;
10053 + }
10054 + }
10055 + } while (0);
10056 +
10057 +#ifdef CONFIG_PAX_DLRESOLVE
10058 + do { /* PaX: unpatched PLT emulation step 2 */
10059 + unsigned int save, call, nop;
10060 +
10061 + err = get_user(save, (unsigned int *)(regs->tpc-4));
10062 + err |= get_user(call, (unsigned int *)regs->tpc);
10063 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
10064 + if (err)
10065 + break;
10066 +
10067 + if (save == 0x9DE3BFA8U &&
10068 + (call & 0xC0000000U) == 0x40000000U &&
10069 + nop == 0x01000000U)
10070 + {
10071 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
10072 +
10073 + if (test_thread_flag(TIF_32BIT))
10074 + dl_resolve &= 0xFFFFFFFFUL;
10075 +
10076 + regs->u_regs[UREG_RETPC] = regs->tpc;
10077 + regs->tpc = dl_resolve;
10078 + regs->tnpc = dl_resolve+4;
10079 + return 3;
10080 + }
10081 + } while (0);
10082 +#endif
10083 +
10084 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
10085 + unsigned int sethi, ba, nop;
10086 +
10087 + err = get_user(sethi, (unsigned int *)regs->tpc);
10088 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
10089 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10090 +
10091 + if (err)
10092 + break;
10093 +
10094 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10095 + (ba & 0xFFF00000U) == 0x30600000U &&
10096 + nop == 0x01000000U)
10097 + {
10098 + unsigned long addr;
10099 +
10100 + addr = (sethi & 0x003FFFFFU) << 10;
10101 + regs->u_regs[UREG_G1] = addr;
10102 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10103 +
10104 + if (test_thread_flag(TIF_32BIT))
10105 + addr &= 0xFFFFFFFFUL;
10106 +
10107 + regs->tpc = addr;
10108 + regs->tnpc = addr+4;
10109 + return 2;
10110 + }
10111 + } while (0);
10112 +
10113 +#endif
10114 +
10115 + return 1;
10116 +}
10117 +
10118 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
10119 +{
10120 + unsigned long i;
10121 +
10122 + printk(KERN_ERR "PAX: bytes at PC: ");
10123 + for (i = 0; i < 8; i++) {
10124 + unsigned int c;
10125 + if (get_user(c, (unsigned int *)pc+i))
10126 + printk(KERN_CONT "???????? ");
10127 + else
10128 + printk(KERN_CONT "%08x ", c);
10129 + }
10130 + printk("\n");
10131 +}
10132 +#endif
10133 +
10134 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
10135 {
10136 struct mm_struct *mm = current->mm;
10137 @@ -341,6 +804,29 @@ retry:
10138 if (!vma)
10139 goto bad_area;
10140
10141 +#ifdef CONFIG_PAX_PAGEEXEC
10142 + /* PaX: detect ITLB misses on non-exec pages */
10143 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
10144 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
10145 + {
10146 + if (address != regs->tpc)
10147 + goto good_area;
10148 +
10149 + up_read(&mm->mmap_sem);
10150 + switch (pax_handle_fetch_fault(regs)) {
10151 +
10152 +#ifdef CONFIG_PAX_EMUPLT
10153 + case 2:
10154 + case 3:
10155 + return;
10156 +#endif
10157 +
10158 + }
10159 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
10160 + do_group_exit(SIGKILL);
10161 + }
10162 +#endif
10163 +
10164 /* Pure DTLB misses do not tell us whether the fault causing
10165 * load/store/atomic was a write or not, it only says that there
10166 * was no match. So in such a case we (carefully) read the
10167 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
10168 index d2b5944..d878f3c 100644
10169 --- a/arch/sparc/mm/hugetlbpage.c
10170 +++ b/arch/sparc/mm/hugetlbpage.c
10171 @@ -28,7 +28,8 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
10172 unsigned long addr,
10173 unsigned long len,
10174 unsigned long pgoff,
10175 - unsigned long flags)
10176 + unsigned long flags,
10177 + unsigned long offset)
10178 {
10179 unsigned long task_size = TASK_SIZE;
10180 struct vm_unmapped_area_info info;
10181 @@ -38,15 +39,22 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
10182
10183 info.flags = 0;
10184 info.length = len;
10185 - info.low_limit = TASK_UNMAPPED_BASE;
10186 + info.low_limit = mm->mmap_base;
10187 info.high_limit = min(task_size, VA_EXCLUDE_START);
10188 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
10189 info.align_offset = 0;
10190 + info.threadstack_offset = offset;
10191 addr = vm_unmapped_area(&info);
10192
10193 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
10194 VM_BUG_ON(addr != -ENOMEM);
10195 info.low_limit = VA_EXCLUDE_END;
10196 +
10197 +#ifdef CONFIG_PAX_RANDMMAP
10198 + if (mm->pax_flags & MF_PAX_RANDMMAP)
10199 + info.low_limit += mm->delta_mmap;
10200 +#endif
10201 +
10202 info.high_limit = task_size;
10203 addr = vm_unmapped_area(&info);
10204 }
10205 @@ -58,7 +66,8 @@ static unsigned long
10206 hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10207 const unsigned long len,
10208 const unsigned long pgoff,
10209 - const unsigned long flags)
10210 + const unsigned long flags,
10211 + const unsigned long offset)
10212 {
10213 struct mm_struct *mm = current->mm;
10214 unsigned long addr = addr0;
10215 @@ -73,6 +82,7 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10216 info.high_limit = mm->mmap_base;
10217 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
10218 info.align_offset = 0;
10219 + info.threadstack_offset = offset;
10220 addr = vm_unmapped_area(&info);
10221
10222 /*
10223 @@ -85,6 +95,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
10224 VM_BUG_ON(addr != -ENOMEM);
10225 info.flags = 0;
10226 info.low_limit = TASK_UNMAPPED_BASE;
10227 +
10228 +#ifdef CONFIG_PAX_RANDMMAP
10229 + if (mm->pax_flags & MF_PAX_RANDMMAP)
10230 + info.low_limit += mm->delta_mmap;
10231 +#endif
10232 +
10233 info.high_limit = STACK_TOP32;
10234 addr = vm_unmapped_area(&info);
10235 }
10236 @@ -99,6 +115,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
10237 struct mm_struct *mm = current->mm;
10238 struct vm_area_struct *vma;
10239 unsigned long task_size = TASK_SIZE;
10240 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
10241
10242 if (test_thread_flag(TIF_32BIT))
10243 task_size = STACK_TOP32;
10244 @@ -114,19 +131,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
10245 return addr;
10246 }
10247
10248 +#ifdef CONFIG_PAX_RANDMMAP
10249 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
10250 +#endif
10251 +
10252 if (addr) {
10253 addr = ALIGN(addr, HPAGE_SIZE);
10254 vma = find_vma(mm, addr);
10255 - if (task_size - len >= addr &&
10256 - (!vma || addr + len <= vma->vm_start))
10257 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
10258 return addr;
10259 }
10260 if (mm->get_unmapped_area == arch_get_unmapped_area)
10261 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
10262 - pgoff, flags);
10263 + pgoff, flags, offset);
10264 else
10265 return hugetlb_get_unmapped_area_topdown(file, addr, len,
10266 - pgoff, flags);
10267 + pgoff, flags, offset);
10268 }
10269
10270 pte_t *huge_pte_alloc(struct mm_struct *mm,
10271 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
10272 index f4500c6..889656c 100644
10273 --- a/arch/tile/include/asm/atomic_64.h
10274 +++ b/arch/tile/include/asm/atomic_64.h
10275 @@ -143,6 +143,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
10276
10277 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
10278
10279 +#define atomic64_read_unchecked(v) atomic64_read(v)
10280 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
10281 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
10282 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
10283 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
10284 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
10285 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
10286 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
10287 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
10288 +
10289 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
10290 #define smp_mb__before_atomic_dec() smp_mb()
10291 #define smp_mb__after_atomic_dec() smp_mb()
10292 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
10293 index a9a5299..0fce79e 100644
10294 --- a/arch/tile/include/asm/cache.h
10295 +++ b/arch/tile/include/asm/cache.h
10296 @@ -15,11 +15,12 @@
10297 #ifndef _ASM_TILE_CACHE_H
10298 #define _ASM_TILE_CACHE_H
10299
10300 +#include <linux/const.h>
10301 #include <arch/chip.h>
10302
10303 /* bytes per L1 data cache line */
10304 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
10305 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10306 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10307
10308 /* bytes per L2 cache line */
10309 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
10310 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
10311 index 8a082bc..7a6bf87 100644
10312 --- a/arch/tile/include/asm/uaccess.h
10313 +++ b/arch/tile/include/asm/uaccess.h
10314 @@ -408,9 +408,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
10315 const void __user *from,
10316 unsigned long n)
10317 {
10318 - int sz = __compiletime_object_size(to);
10319 + size_t sz = __compiletime_object_size(to);
10320
10321 - if (likely(sz == -1 || sz >= n))
10322 + if (likely(sz == (size_t)-1 || sz >= n))
10323 n = _copy_from_user(to, from, n);
10324 else
10325 copy_from_user_overflow();
10326 diff --git a/arch/tile/mm/hugetlbpage.c b/arch/tile/mm/hugetlbpage.c
10327 index 650ccff..45fe2d6 100644
10328 --- a/arch/tile/mm/hugetlbpage.c
10329 +++ b/arch/tile/mm/hugetlbpage.c
10330 @@ -239,6 +239,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
10331 info.high_limit = TASK_SIZE;
10332 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
10333 info.align_offset = 0;
10334 + info.threadstack_offset = 0;
10335 return vm_unmapped_area(&info);
10336 }
10337
10338 @@ -256,6 +257,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
10339 info.high_limit = current->mm->mmap_base;
10340 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
10341 info.align_offset = 0;
10342 + info.threadstack_offset = 0;
10343 addr = vm_unmapped_area(&info);
10344
10345 /*
10346 diff --git a/arch/um/Makefile b/arch/um/Makefile
10347 index 133f7de..1d6f2f1 100644
10348 --- a/arch/um/Makefile
10349 +++ b/arch/um/Makefile
10350 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
10351 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
10352 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
10353
10354 +ifdef CONSTIFY_PLUGIN
10355 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10356 +endif
10357 +
10358 #This will adjust *FLAGS accordingly to the platform.
10359 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
10360
10361 diff --git a/arch/um/defconfig b/arch/um/defconfig
10362 index 08107a7..ab22afe 100644
10363 --- a/arch/um/defconfig
10364 +++ b/arch/um/defconfig
10365 @@ -51,7 +51,6 @@ CONFIG_X86_CMPXCHG=y
10366 CONFIG_X86_L1_CACHE_SHIFT=5
10367 CONFIG_X86_XADD=y
10368 CONFIG_X86_PPRO_FENCE=y
10369 -CONFIG_X86_WP_WORKS_OK=y
10370 CONFIG_X86_INVLPG=y
10371 CONFIG_X86_BSWAP=y
10372 CONFIG_X86_POPAD_OK=y
10373 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
10374 index 19e1bdd..3665b77 100644
10375 --- a/arch/um/include/asm/cache.h
10376 +++ b/arch/um/include/asm/cache.h
10377 @@ -1,6 +1,7 @@
10378 #ifndef __UM_CACHE_H
10379 #define __UM_CACHE_H
10380
10381 +#include <linux/const.h>
10382
10383 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
10384 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
10385 @@ -12,6 +13,6 @@
10386 # define L1_CACHE_SHIFT 5
10387 #endif
10388
10389 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10390 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10391
10392 #endif
10393 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
10394 index 2e0a6b1..a64d0f5 100644
10395 --- a/arch/um/include/asm/kmap_types.h
10396 +++ b/arch/um/include/asm/kmap_types.h
10397 @@ -8,6 +8,6 @@
10398
10399 /* No more #include "asm/arch/kmap_types.h" ! */
10400
10401 -#define KM_TYPE_NR 14
10402 +#define KM_TYPE_NR 15
10403
10404 #endif
10405 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
10406 index 5ff53d9..5850cdf 100644
10407 --- a/arch/um/include/asm/page.h
10408 +++ b/arch/um/include/asm/page.h
10409 @@ -14,6 +14,9 @@
10410 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
10411 #define PAGE_MASK (~(PAGE_SIZE-1))
10412
10413 +#define ktla_ktva(addr) (addr)
10414 +#define ktva_ktla(addr) (addr)
10415 +
10416 #ifndef __ASSEMBLY__
10417
10418 struct page;
10419 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
10420 index 0032f92..cd151e0 100644
10421 --- a/arch/um/include/asm/pgtable-3level.h
10422 +++ b/arch/um/include/asm/pgtable-3level.h
10423 @@ -58,6 +58,7 @@
10424 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
10425 #define pud_populate(mm, pud, pmd) \
10426 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
10427 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
10428
10429 #ifdef CONFIG_64BIT
10430 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
10431 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
10432 index bbcef52..6a2a483 100644
10433 --- a/arch/um/kernel/process.c
10434 +++ b/arch/um/kernel/process.c
10435 @@ -367,22 +367,6 @@ int singlestepping(void * t)
10436 return 2;
10437 }
10438
10439 -/*
10440 - * Only x86 and x86_64 have an arch_align_stack().
10441 - * All other arches have "#define arch_align_stack(x) (x)"
10442 - * in their asm/system.h
10443 - * As this is included in UML from asm-um/system-generic.h,
10444 - * we can use it to behave as the subarch does.
10445 - */
10446 -#ifndef arch_align_stack
10447 -unsigned long arch_align_stack(unsigned long sp)
10448 -{
10449 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
10450 - sp -= get_random_int() % 8192;
10451 - return sp & ~0xf;
10452 -}
10453 -#endif
10454 -
10455 unsigned long get_wchan(struct task_struct *p)
10456 {
10457 unsigned long stack_page, sp, ip;
10458 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
10459 index ad8f795..2c7eec6 100644
10460 --- a/arch/unicore32/include/asm/cache.h
10461 +++ b/arch/unicore32/include/asm/cache.h
10462 @@ -12,8 +12,10 @@
10463 #ifndef __UNICORE_CACHE_H__
10464 #define __UNICORE_CACHE_H__
10465
10466 -#define L1_CACHE_SHIFT (5)
10467 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
10468 +#include <linux/const.h>
10469 +
10470 +#define L1_CACHE_SHIFT 5
10471 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
10472
10473 /*
10474 * Memory returned by kmalloc() may be used for DMA, so we must make
10475 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
10476 index fe120da..24177f7 100644
10477 --- a/arch/x86/Kconfig
10478 +++ b/arch/x86/Kconfig
10479 @@ -239,7 +239,7 @@ config X86_HT
10480
10481 config X86_32_LAZY_GS
10482 def_bool y
10483 - depends on X86_32 && !CC_STACKPROTECTOR
10484 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
10485
10486 config ARCH_HWEIGHT_CFLAGS
10487 string
10488 @@ -1073,6 +1073,7 @@ config MICROCODE_EARLY
10489
10490 config X86_MSR
10491 tristate "/dev/cpu/*/msr - Model-specific register support"
10492 + depends on !GRKERNSEC_KMEM
10493 ---help---
10494 This device gives privileged processes access to the x86
10495 Model-Specific Registers (MSRs). It is a character device with
10496 @@ -1096,7 +1097,7 @@ choice
10497
10498 config NOHIGHMEM
10499 bool "off"
10500 - depends on !X86_NUMAQ
10501 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10502 ---help---
10503 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
10504 However, the address space of 32-bit x86 processors is only 4
10505 @@ -1133,7 +1134,7 @@ config NOHIGHMEM
10506
10507 config HIGHMEM4G
10508 bool "4GB"
10509 - depends on !X86_NUMAQ
10510 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
10511 ---help---
10512 Select this if you have a 32-bit processor and between 1 and 4
10513 gigabytes of physical RAM.
10514 @@ -1186,7 +1187,7 @@ config PAGE_OFFSET
10515 hex
10516 default 0xB0000000 if VMSPLIT_3G_OPT
10517 default 0x80000000 if VMSPLIT_2G
10518 - default 0x78000000 if VMSPLIT_2G_OPT
10519 + default 0x70000000 if VMSPLIT_2G_OPT
10520 default 0x40000000 if VMSPLIT_1G
10521 default 0xC0000000
10522 depends on X86_32
10523 @@ -1584,6 +1585,7 @@ config SECCOMP
10524
10525 config CC_STACKPROTECTOR
10526 bool "Enable -fstack-protector buffer overflow detection"
10527 + depends on X86_64 || !PAX_MEMORY_UDEREF
10528 ---help---
10529 This option turns on the -fstack-protector GCC feature. This
10530 feature puts, at the beginning of functions, a canary value on
10531 @@ -1703,6 +1705,8 @@ config X86_NEED_RELOCS
10532 config PHYSICAL_ALIGN
10533 hex "Alignment value to which kernel should be aligned" if X86_32
10534 default "0x1000000"
10535 + range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
10536 + range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
10537 range 0x2000 0x1000000
10538 ---help---
10539 This value puts the alignment restrictions on physical address
10540 @@ -1778,9 +1782,10 @@ config DEBUG_HOTPLUG_CPU0
10541 If unsure, say N.
10542
10543 config COMPAT_VDSO
10544 - def_bool y
10545 + def_bool n
10546 prompt "Compat VDSO support"
10547 depends on X86_32 || IA32_EMULATION
10548 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
10549 ---help---
10550 Map the 32-bit VDSO to the predictable old-style address too.
10551
10552 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
10553 index c026cca..14657ae 100644
10554 --- a/arch/x86/Kconfig.cpu
10555 +++ b/arch/x86/Kconfig.cpu
10556 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
10557
10558 config X86_F00F_BUG
10559 def_bool y
10560 - depends on M586MMX || M586TSC || M586 || M486
10561 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
10562
10563 config X86_INVD_BUG
10564 def_bool y
10565 @@ -327,7 +327,7 @@ config X86_INVD_BUG
10566
10567 config X86_ALIGNMENT_16
10568 def_bool y
10569 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10570 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
10571
10572 config X86_INTEL_USERCOPY
10573 def_bool y
10574 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
10575 # generates cmov.
10576 config X86_CMOV
10577 def_bool y
10578 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10579 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
10580
10581 config X86_MINIMUM_CPU_FAMILY
10582 int
10583 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
10584 index c198b7e..63eea60 100644
10585 --- a/arch/x86/Kconfig.debug
10586 +++ b/arch/x86/Kconfig.debug
10587 @@ -84,7 +84,7 @@ config X86_PTDUMP
10588 config DEBUG_RODATA
10589 bool "Write protect kernel read-only data structures"
10590 default y
10591 - depends on DEBUG_KERNEL
10592 + depends on DEBUG_KERNEL && BROKEN
10593 ---help---
10594 Mark the kernel read-only data as write-protected in the pagetables,
10595 in order to catch accidental (and incorrect) writes to such const
10596 @@ -102,7 +102,7 @@ config DEBUG_RODATA_TEST
10597
10598 config DEBUG_SET_MODULE_RONX
10599 bool "Set loadable kernel module data as NX and text as RO"
10600 - depends on MODULES
10601 + depends on MODULES && BROKEN
10602 ---help---
10603 This option helps catch unintended modifications to loadable
10604 kernel module's text and read-only data. It also prevents execution
10605 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
10606 index 5c47726..8c4fa67 100644
10607 --- a/arch/x86/Makefile
10608 +++ b/arch/x86/Makefile
10609 @@ -54,6 +54,7 @@ else
10610 UTS_MACHINE := x86_64
10611 CHECKFLAGS += -D__x86_64__ -m64
10612
10613 + biarch := $(call cc-option,-m64)
10614 KBUILD_AFLAGS += -m64
10615 KBUILD_CFLAGS += -m64
10616
10617 @@ -234,3 +235,12 @@ define archhelp
10618 echo ' FDARGS="..." arguments for the booted kernel'
10619 echo ' FDINITRD=file initrd for the booted kernel'
10620 endef
10621 +
10622 +define OLD_LD
10623 +
10624 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
10625 +*** Please upgrade your binutils to 2.18 or newer
10626 +endef
10627 +
10628 +archprepare:
10629 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
10630 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
10631 index 379814b..add62ce 100644
10632 --- a/arch/x86/boot/Makefile
10633 +++ b/arch/x86/boot/Makefile
10634 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
10635 $(call cc-option, -fno-stack-protector) \
10636 $(call cc-option, -mpreferred-stack-boundary=2)
10637 KBUILD_CFLAGS += $(call cc-option, -m32)
10638 +ifdef CONSTIFY_PLUGIN
10639 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10640 +endif
10641 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10642 GCOV_PROFILE := n
10643
10644 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
10645 index 878e4b9..20537ab 100644
10646 --- a/arch/x86/boot/bitops.h
10647 +++ b/arch/x86/boot/bitops.h
10648 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10649 u8 v;
10650 const u32 *p = (const u32 *)addr;
10651
10652 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10653 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
10654 return v;
10655 }
10656
10657 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
10658
10659 static inline void set_bit(int nr, void *addr)
10660 {
10661 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10662 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
10663 }
10664
10665 #endif /* BOOT_BITOPS_H */
10666 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
10667 index 5b75319..331a4ca 100644
10668 --- a/arch/x86/boot/boot.h
10669 +++ b/arch/x86/boot/boot.h
10670 @@ -85,7 +85,7 @@ static inline void io_delay(void)
10671 static inline u16 ds(void)
10672 {
10673 u16 seg;
10674 - asm("movw %%ds,%0" : "=rm" (seg));
10675 + asm volatile("movw %%ds,%0" : "=rm" (seg));
10676 return seg;
10677 }
10678
10679 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
10680 static inline int memcmp(const void *s1, const void *s2, size_t len)
10681 {
10682 u8 diff;
10683 - asm("repe; cmpsb; setnz %0"
10684 + asm volatile("repe; cmpsb; setnz %0"
10685 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
10686 return diff;
10687 }
10688 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
10689 index 5ef205c..342191d 100644
10690 --- a/arch/x86/boot/compressed/Makefile
10691 +++ b/arch/x86/boot/compressed/Makefile
10692 @@ -14,6 +14,9 @@ cflags-$(CONFIG_X86_64) := -mcmodel=small
10693 KBUILD_CFLAGS += $(cflags-y)
10694 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
10695 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
10696 +ifdef CONSTIFY_PLUGIN
10697 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
10698 +endif
10699
10700 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
10701 GCOV_PROFILE := n
10702 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
10703 index d606463..b887794 100644
10704 --- a/arch/x86/boot/compressed/eboot.c
10705 +++ b/arch/x86/boot/compressed/eboot.c
10706 @@ -150,7 +150,6 @@ again:
10707 *addr = max_addr;
10708 }
10709
10710 -free_pool:
10711 efi_call_phys1(sys_table->boottime->free_pool, map);
10712
10713 fail:
10714 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
10715 if (i == map_size / desc_size)
10716 status = EFI_NOT_FOUND;
10717
10718 -free_pool:
10719 efi_call_phys1(sys_table->boottime->free_pool, map);
10720 fail:
10721 return status;
10722 diff --git a/arch/x86/boot/compressed/efi_stub_32.S b/arch/x86/boot/compressed/efi_stub_32.S
10723 index a53440e..c3dbf1e 100644
10724 --- a/arch/x86/boot/compressed/efi_stub_32.S
10725 +++ b/arch/x86/boot/compressed/efi_stub_32.S
10726 @@ -46,16 +46,13 @@ ENTRY(efi_call_phys)
10727 * parameter 2, ..., param n. To make things easy, we save the return
10728 * address of efi_call_phys in a global variable.
10729 */
10730 - popl %ecx
10731 - movl %ecx, saved_return_addr(%edx)
10732 - /* get the function pointer into ECX*/
10733 - popl %ecx
10734 - movl %ecx, efi_rt_function_ptr(%edx)
10735 + popl saved_return_addr(%edx)
10736 + popl efi_rt_function_ptr(%edx)
10737
10738 /*
10739 * 3. Call the physical function.
10740 */
10741 - call *%ecx
10742 + call *efi_rt_function_ptr(%edx)
10743
10744 /*
10745 * 4. Balance the stack. And because EAX contain the return value,
10746 @@ -67,15 +64,12 @@ ENTRY(efi_call_phys)
10747 1: popl %edx
10748 subl $1b, %edx
10749
10750 - movl efi_rt_function_ptr(%edx), %ecx
10751 - pushl %ecx
10752 + pushl efi_rt_function_ptr(%edx)
10753
10754 /*
10755 * 10. Push the saved return address onto the stack and return.
10756 */
10757 - movl saved_return_addr(%edx), %ecx
10758 - pushl %ecx
10759 - ret
10760 + jmpl *saved_return_addr(%edx)
10761 ENDPROC(efi_call_phys)
10762 .previous
10763
10764 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
10765 index 1e3184f..0d11e2e 100644
10766 --- a/arch/x86/boot/compressed/head_32.S
10767 +++ b/arch/x86/boot/compressed/head_32.S
10768 @@ -118,7 +118,7 @@ preferred_addr:
10769 notl %eax
10770 andl %eax, %ebx
10771 #else
10772 - movl $LOAD_PHYSICAL_ADDR, %ebx
10773 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10774 #endif
10775
10776 /* Target address to relocate to for decompression */
10777 @@ -204,7 +204,7 @@ relocated:
10778 * and where it was actually loaded.
10779 */
10780 movl %ebp, %ebx
10781 - subl $LOAD_PHYSICAL_ADDR, %ebx
10782 + subl $____LOAD_PHYSICAL_ADDR, %ebx
10783 jz 2f /* Nothing to be done if loaded at compiled addr. */
10784 /*
10785 * Process relocations.
10786 @@ -212,8 +212,7 @@ relocated:
10787
10788 1: subl $4, %edi
10789 movl (%edi), %ecx
10790 - testl %ecx, %ecx
10791 - jz 2f
10792 + jecxz 2f
10793 addl %ebx, -__PAGE_OFFSET(%ebx, %ecx)
10794 jmp 1b
10795 2:
10796 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
10797 index 16f24e6..47491a3 100644
10798 --- a/arch/x86/boot/compressed/head_64.S
10799 +++ b/arch/x86/boot/compressed/head_64.S
10800 @@ -97,7 +97,7 @@ ENTRY(startup_32)
10801 notl %eax
10802 andl %eax, %ebx
10803 #else
10804 - movl $LOAD_PHYSICAL_ADDR, %ebx
10805 + movl $____LOAD_PHYSICAL_ADDR, %ebx
10806 #endif
10807
10808 /* Target address to relocate to for decompression */
10809 @@ -272,7 +272,7 @@ preferred_addr:
10810 notq %rax
10811 andq %rax, %rbp
10812 #else
10813 - movq $LOAD_PHYSICAL_ADDR, %rbp
10814 + movq $____LOAD_PHYSICAL_ADDR, %rbp
10815 #endif
10816
10817 /* Target address to relocate to for decompression */
10818 @@ -363,8 +363,8 @@ gdt:
10819 .long gdt
10820 .word 0
10821 .quad 0x0000000000000000 /* NULL descriptor */
10822 - .quad 0x00af9a000000ffff /* __KERNEL_CS */
10823 - .quad 0x00cf92000000ffff /* __KERNEL_DS */
10824 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
10825 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
10826 .quad 0x0080890000000000 /* TS descriptor */
10827 .quad 0x0000000000000000 /* TS continued */
10828 gdt_end:
10829 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
10830 index 7cb56c6..d382d84 100644
10831 --- a/arch/x86/boot/compressed/misc.c
10832 +++ b/arch/x86/boot/compressed/misc.c
10833 @@ -303,7 +303,7 @@ static void parse_elf(void *output)
10834 case PT_LOAD:
10835 #ifdef CONFIG_RELOCATABLE
10836 dest = output;
10837 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
10838 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
10839 #else
10840 dest = (void *)(phdr->p_paddr);
10841 #endif
10842 @@ -354,7 +354,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
10843 error("Destination address too large");
10844 #endif
10845 #ifndef CONFIG_RELOCATABLE
10846 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
10847 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
10848 error("Wrong destination address");
10849 #endif
10850
10851 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
10852 index 4d3ff03..e4972ff 100644
10853 --- a/arch/x86/boot/cpucheck.c
10854 +++ b/arch/x86/boot/cpucheck.c
10855 @@ -74,7 +74,7 @@ static int has_fpu(void)
10856 u16 fcw = -1, fsw = -1;
10857 u32 cr0;
10858
10859 - asm("movl %%cr0,%0" : "=r" (cr0));
10860 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
10861 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
10862 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
10863 asm volatile("movl %0,%%cr0" : : "r" (cr0));
10864 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
10865 {
10866 u32 f0, f1;
10867
10868 - asm("pushfl ; "
10869 + asm volatile("pushfl ; "
10870 "pushfl ; "
10871 "popl %0 ; "
10872 "movl %0,%1 ; "
10873 @@ -115,7 +115,7 @@ static void get_flags(void)
10874 set_bit(X86_FEATURE_FPU, cpu.flags);
10875
10876 if (has_eflag(X86_EFLAGS_ID)) {
10877 - asm("cpuid"
10878 + asm volatile("cpuid"
10879 : "=a" (max_intel_level),
10880 "=b" (cpu_vendor[0]),
10881 "=d" (cpu_vendor[1]),
10882 @@ -124,7 +124,7 @@ static void get_flags(void)
10883
10884 if (max_intel_level >= 0x00000001 &&
10885 max_intel_level <= 0x0000ffff) {
10886 - asm("cpuid"
10887 + asm volatile("cpuid"
10888 : "=a" (tfms),
10889 "=c" (cpu.flags[4]),
10890 "=d" (cpu.flags[0])
10891 @@ -136,7 +136,7 @@ static void get_flags(void)
10892 cpu.model += ((tfms >> 16) & 0xf) << 4;
10893 }
10894
10895 - asm("cpuid"
10896 + asm volatile("cpuid"
10897 : "=a" (max_amd_level)
10898 : "a" (0x80000000)
10899 : "ebx", "ecx", "edx");
10900 @@ -144,7 +144,7 @@ static void get_flags(void)
10901 if (max_amd_level >= 0x80000001 &&
10902 max_amd_level <= 0x8000ffff) {
10903 u32 eax = 0x80000001;
10904 - asm("cpuid"
10905 + asm volatile("cpuid"
10906 : "+a" (eax),
10907 "=c" (cpu.flags[6]),
10908 "=d" (cpu.flags[1])
10909 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10910 u32 ecx = MSR_K7_HWCR;
10911 u32 eax, edx;
10912
10913 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10914 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10915 eax &= ~(1 << 15);
10916 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10917 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10918
10919 get_flags(); /* Make sure it really did something */
10920 err = check_flags();
10921 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10922 u32 ecx = MSR_VIA_FCR;
10923 u32 eax, edx;
10924
10925 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10926 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10927 eax |= (1<<1)|(1<<7);
10928 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10929 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10930
10931 set_bit(X86_FEATURE_CX8, cpu.flags);
10932 err = check_flags();
10933 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
10934 u32 eax, edx;
10935 u32 level = 1;
10936
10937 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10938 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10939 - asm("cpuid"
10940 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
10941 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
10942 + asm volatile("cpuid"
10943 : "+a" (level), "=d" (cpu.flags[0])
10944 : : "ecx", "ebx");
10945 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10946 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
10947
10948 err = check_flags();
10949 }
10950 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
10951 index 9ec06a1..2c25e79 100644
10952 --- a/arch/x86/boot/header.S
10953 +++ b/arch/x86/boot/header.S
10954 @@ -409,10 +409,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
10955 # single linked list of
10956 # struct setup_data
10957
10958 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
10959 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
10960
10961 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
10962 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
10963 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
10964 +#else
10965 #define VO_INIT_SIZE (VO__end - VO__text)
10966 +#endif
10967 #if ZO_INIT_SIZE > VO_INIT_SIZE
10968 #define INIT_SIZE ZO_INIT_SIZE
10969 #else
10970 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
10971 index db75d07..8e6d0af 100644
10972 --- a/arch/x86/boot/memory.c
10973 +++ b/arch/x86/boot/memory.c
10974 @@ -19,7 +19,7 @@
10975
10976 static int detect_memory_e820(void)
10977 {
10978 - int count = 0;
10979 + unsigned int count = 0;
10980 struct biosregs ireg, oreg;
10981 struct e820entry *desc = boot_params.e820_map;
10982 static struct e820entry buf; /* static so it is zeroed */
10983 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
10984 index 11e8c6e..fdbb1ed 100644
10985 --- a/arch/x86/boot/video-vesa.c
10986 +++ b/arch/x86/boot/video-vesa.c
10987 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
10988
10989 boot_params.screen_info.vesapm_seg = oreg.es;
10990 boot_params.screen_info.vesapm_off = oreg.di;
10991 + boot_params.screen_info.vesapm_size = oreg.cx;
10992 }
10993
10994 /*
10995 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
10996 index 43eda28..5ab5fdb 100644
10997 --- a/arch/x86/boot/video.c
10998 +++ b/arch/x86/boot/video.c
10999 @@ -96,7 +96,7 @@ static void store_mode_params(void)
11000 static unsigned int get_entry(void)
11001 {
11002 char entry_buf[4];
11003 - int i, len = 0;
11004 + unsigned int i, len = 0;
11005 int key;
11006 unsigned int v;
11007
11008 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
11009 index 9105655..5e37f27 100644
11010 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
11011 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
11012 @@ -8,6 +8,8 @@
11013 * including this sentence is retained in full.
11014 */
11015
11016 +#include <asm/alternative-asm.h>
11017 +
11018 .extern crypto_ft_tab
11019 .extern crypto_it_tab
11020 .extern crypto_fl_tab
11021 @@ -70,6 +72,8 @@
11022 je B192; \
11023 leaq 32(r9),r9;
11024
11025 +#define ret pax_force_retaddr 0, 1; ret
11026 +
11027 #define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \
11028 movq r1,r2; \
11029 movq r3,r4; \
11030 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
11031 index 477e9d7..3ab339f 100644
11032 --- a/arch/x86/crypto/aesni-intel_asm.S
11033 +++ b/arch/x86/crypto/aesni-intel_asm.S
11034 @@ -31,6 +31,7 @@
11035
11036 #include <linux/linkage.h>
11037 #include <asm/inst.h>
11038 +#include <asm/alternative-asm.h>
11039
11040 #ifdef __x86_64__
11041 .data
11042 @@ -1441,6 +1442,7 @@ _return_T_done_decrypt:
11043 pop %r14
11044 pop %r13
11045 pop %r12
11046 + pax_force_retaddr 0, 1
11047 ret
11048 ENDPROC(aesni_gcm_dec)
11049
11050 @@ -1705,6 +1707,7 @@ _return_T_done_encrypt:
11051 pop %r14
11052 pop %r13
11053 pop %r12
11054 + pax_force_retaddr 0, 1
11055 ret
11056 ENDPROC(aesni_gcm_enc)
11057
11058 @@ -1722,6 +1725,7 @@ _key_expansion_256a:
11059 pxor %xmm1, %xmm0
11060 movaps %xmm0, (TKEYP)
11061 add $0x10, TKEYP
11062 + pax_force_retaddr_bts
11063 ret
11064 ENDPROC(_key_expansion_128)
11065 ENDPROC(_key_expansion_256a)
11066 @@ -1748,6 +1752,7 @@ _key_expansion_192a:
11067 shufps $0b01001110, %xmm2, %xmm1
11068 movaps %xmm1, 0x10(TKEYP)
11069 add $0x20, TKEYP
11070 + pax_force_retaddr_bts
11071 ret
11072 ENDPROC(_key_expansion_192a)
11073
11074 @@ -1768,6 +1773,7 @@ _key_expansion_192b:
11075
11076 movaps %xmm0, (TKEYP)
11077 add $0x10, TKEYP
11078 + pax_force_retaddr_bts
11079 ret
11080 ENDPROC(_key_expansion_192b)
11081
11082 @@ -1781,6 +1787,7 @@ _key_expansion_256b:
11083 pxor %xmm1, %xmm2
11084 movaps %xmm2, (TKEYP)
11085 add $0x10, TKEYP
11086 + pax_force_retaddr_bts
11087 ret
11088 ENDPROC(_key_expansion_256b)
11089
11090 @@ -1894,6 +1901,7 @@ ENTRY(aesni_set_key)
11091 #ifndef __x86_64__
11092 popl KEYP
11093 #endif
11094 + pax_force_retaddr 0, 1
11095 ret
11096 ENDPROC(aesni_set_key)
11097
11098 @@ -1916,6 +1924,7 @@ ENTRY(aesni_enc)
11099 popl KLEN
11100 popl KEYP
11101 #endif
11102 + pax_force_retaddr 0, 1
11103 ret
11104 ENDPROC(aesni_enc)
11105
11106 @@ -1974,6 +1983,7 @@ _aesni_enc1:
11107 AESENC KEY STATE
11108 movaps 0x70(TKEYP), KEY
11109 AESENCLAST KEY STATE
11110 + pax_force_retaddr_bts
11111 ret
11112 ENDPROC(_aesni_enc1)
11113
11114 @@ -2083,6 +2093,7 @@ _aesni_enc4:
11115 AESENCLAST KEY STATE2
11116 AESENCLAST KEY STATE3
11117 AESENCLAST KEY STATE4
11118 + pax_force_retaddr_bts
11119 ret
11120 ENDPROC(_aesni_enc4)
11121
11122 @@ -2106,6 +2117,7 @@ ENTRY(aesni_dec)
11123 popl KLEN
11124 popl KEYP
11125 #endif
11126 + pax_force_retaddr 0, 1
11127 ret
11128 ENDPROC(aesni_dec)
11129
11130 @@ -2164,6 +2176,7 @@ _aesni_dec1:
11131 AESDEC KEY STATE
11132 movaps 0x70(TKEYP), KEY
11133 AESDECLAST KEY STATE
11134 + pax_force_retaddr_bts
11135 ret
11136 ENDPROC(_aesni_dec1)
11137
11138 @@ -2273,6 +2286,7 @@ _aesni_dec4:
11139 AESDECLAST KEY STATE2
11140 AESDECLAST KEY STATE3
11141 AESDECLAST KEY STATE4
11142 + pax_force_retaddr_bts
11143 ret
11144 ENDPROC(_aesni_dec4)
11145
11146 @@ -2331,6 +2345,7 @@ ENTRY(aesni_ecb_enc)
11147 popl KEYP
11148 popl LEN
11149 #endif
11150 + pax_force_retaddr 0, 1
11151 ret
11152 ENDPROC(aesni_ecb_enc)
11153
11154 @@ -2390,6 +2405,7 @@ ENTRY(aesni_ecb_dec)
11155 popl KEYP
11156 popl LEN
11157 #endif
11158 + pax_force_retaddr 0, 1
11159 ret
11160 ENDPROC(aesni_ecb_dec)
11161
11162 @@ -2432,6 +2448,7 @@ ENTRY(aesni_cbc_enc)
11163 popl LEN
11164 popl IVP
11165 #endif
11166 + pax_force_retaddr 0, 1
11167 ret
11168 ENDPROC(aesni_cbc_enc)
11169
11170 @@ -2523,6 +2540,7 @@ ENTRY(aesni_cbc_dec)
11171 popl LEN
11172 popl IVP
11173 #endif
11174 + pax_force_retaddr 0, 1
11175 ret
11176 ENDPROC(aesni_cbc_dec)
11177
11178 @@ -2550,6 +2568,7 @@ _aesni_inc_init:
11179 mov $1, TCTR_LOW
11180 MOVQ_R64_XMM TCTR_LOW INC
11181 MOVQ_R64_XMM CTR TCTR_LOW
11182 + pax_force_retaddr_bts
11183 ret
11184 ENDPROC(_aesni_inc_init)
11185
11186 @@ -2579,6 +2598,7 @@ _aesni_inc:
11187 .Linc_low:
11188 movaps CTR, IV
11189 PSHUFB_XMM BSWAP_MASK IV
11190 + pax_force_retaddr_bts
11191 ret
11192 ENDPROC(_aesni_inc)
11193
11194 @@ -2640,6 +2660,7 @@ ENTRY(aesni_ctr_enc)
11195 .Lctr_enc_ret:
11196 movups IV, (IVP)
11197 .Lctr_enc_just_ret:
11198 + pax_force_retaddr 0, 1
11199 ret
11200 ENDPROC(aesni_ctr_enc)
11201
11202 @@ -2766,6 +2787,7 @@ ENTRY(aesni_xts_crypt8)
11203 pxor INC, STATE4
11204 movdqu STATE4, 0x70(OUTP)
11205
11206 + pax_force_retaddr 0, 1
11207 ret
11208 ENDPROC(aesni_xts_crypt8)
11209
11210 diff --git a/arch/x86/crypto/blowfish-avx2-asm_64.S b/arch/x86/crypto/blowfish-avx2-asm_64.S
11211 index 784452e..46982c7 100644
11212 --- a/arch/x86/crypto/blowfish-avx2-asm_64.S
11213 +++ b/arch/x86/crypto/blowfish-avx2-asm_64.S
11214 @@ -221,6 +221,7 @@ __blowfish_enc_blk32:
11215
11216 write_block(RXl, RXr);
11217
11218 + pax_force_retaddr 0, 1
11219 ret;
11220 ENDPROC(__blowfish_enc_blk32)
11221
11222 @@ -250,6 +251,7 @@ __blowfish_dec_blk32:
11223
11224 write_block(RXl, RXr);
11225
11226 + pax_force_retaddr 0, 1
11227 ret;
11228 ENDPROC(__blowfish_dec_blk32)
11229
11230 @@ -284,6 +286,7 @@ ENTRY(blowfish_ecb_enc_32way)
11231
11232 vzeroupper;
11233
11234 + pax_force_retaddr 0, 1
11235 ret;
11236 ENDPROC(blowfish_ecb_enc_32way)
11237
11238 @@ -318,6 +321,7 @@ ENTRY(blowfish_ecb_dec_32way)
11239
11240 vzeroupper;
11241
11242 + pax_force_retaddr 0, 1
11243 ret;
11244 ENDPROC(blowfish_ecb_dec_32way)
11245
11246 @@ -365,6 +369,7 @@ ENTRY(blowfish_cbc_dec_32way)
11247
11248 vzeroupper;
11249
11250 + pax_force_retaddr 0, 1
11251 ret;
11252 ENDPROC(blowfish_cbc_dec_32way)
11253
11254 @@ -445,5 +450,6 @@ ENTRY(blowfish_ctr_32way)
11255
11256 vzeroupper;
11257
11258 + pax_force_retaddr 0, 1
11259 ret;
11260 ENDPROC(blowfish_ctr_32way)
11261 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
11262 index 246c670..4d1ed00 100644
11263 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
11264 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
11265 @@ -21,6 +21,7 @@
11266 */
11267
11268 #include <linux/linkage.h>
11269 +#include <asm/alternative-asm.h>
11270
11271 .file "blowfish-x86_64-asm.S"
11272 .text
11273 @@ -149,9 +150,11 @@ ENTRY(__blowfish_enc_blk)
11274 jnz .L__enc_xor;
11275
11276 write_block();
11277 + pax_force_retaddr 0, 1
11278 ret;
11279 .L__enc_xor:
11280 xor_block();
11281 + pax_force_retaddr 0, 1
11282 ret;
11283 ENDPROC(__blowfish_enc_blk)
11284
11285 @@ -183,6 +186,7 @@ ENTRY(blowfish_dec_blk)
11286
11287 movq %r11, %rbp;
11288
11289 + pax_force_retaddr 0, 1
11290 ret;
11291 ENDPROC(blowfish_dec_blk)
11292
11293 @@ -334,6 +338,7 @@ ENTRY(__blowfish_enc_blk_4way)
11294
11295 popq %rbx;
11296 popq %rbp;
11297 + pax_force_retaddr 0, 1
11298 ret;
11299
11300 .L__enc_xor4:
11301 @@ -341,6 +346,7 @@ ENTRY(__blowfish_enc_blk_4way)
11302
11303 popq %rbx;
11304 popq %rbp;
11305 + pax_force_retaddr 0, 1
11306 ret;
11307 ENDPROC(__blowfish_enc_blk_4way)
11308
11309 @@ -375,5 +381,6 @@ ENTRY(blowfish_dec_blk_4way)
11310 popq %rbx;
11311 popq %rbp;
11312
11313 + pax_force_retaddr 0, 1
11314 ret;
11315 ENDPROC(blowfish_dec_blk_4way)
11316 diff --git a/arch/x86/crypto/camellia-aesni-avx-asm_64.S b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
11317 index ce71f92..2dd5b1e 100644
11318 --- a/arch/x86/crypto/camellia-aesni-avx-asm_64.S
11319 +++ b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
11320 @@ -16,6 +16,7 @@
11321 */
11322
11323 #include <linux/linkage.h>
11324 +#include <asm/alternative-asm.h>
11325
11326 #define CAMELLIA_TABLE_BYTE_LEN 272
11327
11328 @@ -191,6 +192,7 @@ roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
11329 roundsm16(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
11330 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14, %xmm15,
11331 %rcx, (%r9));
11332 + pax_force_retaddr_bts
11333 ret;
11334 ENDPROC(roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
11335
11336 @@ -199,6 +201,7 @@ roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
11337 roundsm16(%xmm4, %xmm5, %xmm6, %xmm7, %xmm0, %xmm1, %xmm2, %xmm3,
11338 %xmm12, %xmm13, %xmm14, %xmm15, %xmm8, %xmm9, %xmm10, %xmm11,
11339 %rax, (%r9));
11340 + pax_force_retaddr_bts
11341 ret;
11342 ENDPROC(roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
11343
11344 @@ -780,6 +783,7 @@ __camellia_enc_blk16:
11345 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
11346 %xmm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 16(%rax));
11347
11348 + pax_force_retaddr_bts
11349 ret;
11350
11351 .align 8
11352 @@ -865,6 +869,7 @@ __camellia_dec_blk16:
11353 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
11354 %xmm15, (key_table)(CTX), (%rax), 1 * 16(%rax));
11355
11356 + pax_force_retaddr_bts
11357 ret;
11358
11359 .align 8
11360 @@ -904,6 +909,7 @@ ENTRY(camellia_ecb_enc_16way)
11361 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
11362 %xmm8, %rsi);
11363
11364 + pax_force_retaddr 0, 1
11365 ret;
11366 ENDPROC(camellia_ecb_enc_16way)
11367
11368 @@ -932,6 +938,7 @@ ENTRY(camellia_ecb_dec_16way)
11369 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
11370 %xmm8, %rsi);
11371
11372 + pax_force_retaddr 0, 1
11373 ret;
11374 ENDPROC(camellia_ecb_dec_16way)
11375
11376 @@ -981,6 +988,7 @@ ENTRY(camellia_cbc_dec_16way)
11377 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
11378 %xmm8, %rsi);
11379
11380 + pax_force_retaddr 0, 1
11381 ret;
11382 ENDPROC(camellia_cbc_dec_16way)
11383
11384 @@ -1092,6 +1100,7 @@ ENTRY(camellia_ctr_16way)
11385 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
11386 %xmm8, %rsi);
11387
11388 + pax_force_retaddr 0, 1
11389 ret;
11390 ENDPROC(camellia_ctr_16way)
11391
11392 @@ -1234,6 +1243,7 @@ camellia_xts_crypt_16way:
11393 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
11394 %xmm8, %rsi);
11395
11396 + pax_force_retaddr 0, 1
11397 ret;
11398 ENDPROC(camellia_xts_crypt_16way)
11399
11400 diff --git a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
11401 index 91a1878..bcf340a 100644
11402 --- a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
11403 +++ b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
11404 @@ -11,6 +11,7 @@
11405 */
11406
11407 #include <linux/linkage.h>
11408 +#include <asm/alternative-asm.h>
11409
11410 #define CAMELLIA_TABLE_BYTE_LEN 272
11411
11412 @@ -212,6 +213,7 @@ roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
11413 roundsm32(%ymm0, %ymm1, %ymm2, %ymm3, %ymm4, %ymm5, %ymm6, %ymm7,
11414 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14, %ymm15,
11415 %rcx, (%r9));
11416 + pax_force_retaddr_bts
11417 ret;
11418 ENDPROC(roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
11419
11420 @@ -220,6 +222,7 @@ roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
11421 roundsm32(%ymm4, %ymm5, %ymm6, %ymm7, %ymm0, %ymm1, %ymm2, %ymm3,
11422 %ymm12, %ymm13, %ymm14, %ymm15, %ymm8, %ymm9, %ymm10, %ymm11,
11423 %rax, (%r9));
11424 + pax_force_retaddr_bts
11425 ret;
11426 ENDPROC(roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
11427
11428 @@ -802,6 +805,7 @@ __camellia_enc_blk32:
11429 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
11430 %ymm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 32(%rax));
11431
11432 + pax_force_retaddr_bts
11433 ret;
11434
11435 .align 8
11436 @@ -887,6 +891,7 @@ __camellia_dec_blk32:
11437 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
11438 %ymm15, (key_table)(CTX), (%rax), 1 * 32(%rax));
11439
11440 + pax_force_retaddr_bts
11441 ret;
11442
11443 .align 8
11444 @@ -930,6 +935,7 @@ ENTRY(camellia_ecb_enc_32way)
11445
11446 vzeroupper;
11447
11448 + pax_force_retaddr 0, 1
11449 ret;
11450 ENDPROC(camellia_ecb_enc_32way)
11451
11452 @@ -962,6 +968,7 @@ ENTRY(camellia_ecb_dec_32way)
11453
11454 vzeroupper;
11455
11456 + pax_force_retaddr 0, 1
11457 ret;
11458 ENDPROC(camellia_ecb_dec_32way)
11459
11460 @@ -1028,6 +1035,7 @@ ENTRY(camellia_cbc_dec_32way)
11461
11462 vzeroupper;
11463
11464 + pax_force_retaddr 0, 1
11465 ret;
11466 ENDPROC(camellia_cbc_dec_32way)
11467
11468 @@ -1166,6 +1174,7 @@ ENTRY(camellia_ctr_32way)
11469
11470 vzeroupper;
11471
11472 + pax_force_retaddr 0, 1
11473 ret;
11474 ENDPROC(camellia_ctr_32way)
11475
11476 @@ -1331,6 +1340,7 @@ camellia_xts_crypt_32way:
11477
11478 vzeroupper;
11479
11480 + pax_force_retaddr 0, 1
11481 ret;
11482 ENDPROC(camellia_xts_crypt_32way)
11483
11484 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
11485 index 310319c..ce174a4 100644
11486 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
11487 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
11488 @@ -21,6 +21,7 @@
11489 */
11490
11491 #include <linux/linkage.h>
11492 +#include <asm/alternative-asm.h>
11493
11494 .file "camellia-x86_64-asm_64.S"
11495 .text
11496 @@ -228,12 +229,14 @@ ENTRY(__camellia_enc_blk)
11497 enc_outunpack(mov, RT1);
11498
11499 movq RRBP, %rbp;
11500 + pax_force_retaddr 0, 1
11501 ret;
11502
11503 .L__enc_xor:
11504 enc_outunpack(xor, RT1);
11505
11506 movq RRBP, %rbp;
11507 + pax_force_retaddr 0, 1
11508 ret;
11509 ENDPROC(__camellia_enc_blk)
11510
11511 @@ -272,6 +275,7 @@ ENTRY(camellia_dec_blk)
11512 dec_outunpack();
11513
11514 movq RRBP, %rbp;
11515 + pax_force_retaddr 0, 1
11516 ret;
11517 ENDPROC(camellia_dec_blk)
11518
11519 @@ -463,6 +467,7 @@ ENTRY(__camellia_enc_blk_2way)
11520
11521 movq RRBP, %rbp;
11522 popq %rbx;
11523 + pax_force_retaddr 0, 1
11524 ret;
11525
11526 .L__enc2_xor:
11527 @@ -470,6 +475,7 @@ ENTRY(__camellia_enc_blk_2way)
11528
11529 movq RRBP, %rbp;
11530 popq %rbx;
11531 + pax_force_retaddr 0, 1
11532 ret;
11533 ENDPROC(__camellia_enc_blk_2way)
11534
11535 @@ -510,5 +516,6 @@ ENTRY(camellia_dec_blk_2way)
11536
11537 movq RRBP, %rbp;
11538 movq RXOR, %rbx;
11539 + pax_force_retaddr 0, 1
11540 ret;
11541 ENDPROC(camellia_dec_blk_2way)
11542 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11543 index c35fd5d..c1ee236 100644
11544 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11545 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
11546 @@ -24,6 +24,7 @@
11547 */
11548
11549 #include <linux/linkage.h>
11550 +#include <asm/alternative-asm.h>
11551
11552 .file "cast5-avx-x86_64-asm_64.S"
11553
11554 @@ -281,6 +282,7 @@ __cast5_enc_blk16:
11555 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11556 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11557
11558 + pax_force_retaddr 0, 1
11559 ret;
11560 ENDPROC(__cast5_enc_blk16)
11561
11562 @@ -352,6 +354,7 @@ __cast5_dec_blk16:
11563 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
11564 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
11565
11566 + pax_force_retaddr 0, 1
11567 ret;
11568
11569 .L__skip_dec:
11570 @@ -388,6 +391,7 @@ ENTRY(cast5_ecb_enc_16way)
11571 vmovdqu RR4, (6*4*4)(%r11);
11572 vmovdqu RL4, (7*4*4)(%r11);
11573
11574 + pax_force_retaddr
11575 ret;
11576 ENDPROC(cast5_ecb_enc_16way)
11577
11578 @@ -420,6 +424,7 @@ ENTRY(cast5_ecb_dec_16way)
11579 vmovdqu RR4, (6*4*4)(%r11);
11580 vmovdqu RL4, (7*4*4)(%r11);
11581
11582 + pax_force_retaddr
11583 ret;
11584 ENDPROC(cast5_ecb_dec_16way)
11585
11586 @@ -469,6 +474,7 @@ ENTRY(cast5_cbc_dec_16way)
11587
11588 popq %r12;
11589
11590 + pax_force_retaddr
11591 ret;
11592 ENDPROC(cast5_cbc_dec_16way)
11593
11594 @@ -542,5 +548,6 @@ ENTRY(cast5_ctr_16way)
11595
11596 popq %r12;
11597
11598 + pax_force_retaddr
11599 ret;
11600 ENDPROC(cast5_ctr_16way)
11601 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11602 index e3531f8..18ded3a 100644
11603 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11604 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
11605 @@ -24,6 +24,7 @@
11606 */
11607
11608 #include <linux/linkage.h>
11609 +#include <asm/alternative-asm.h>
11610 #include "glue_helper-asm-avx.S"
11611
11612 .file "cast6-avx-x86_64-asm_64.S"
11613 @@ -295,6 +296,7 @@ __cast6_enc_blk8:
11614 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11615 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11616
11617 + pax_force_retaddr 0, 1
11618 ret;
11619 ENDPROC(__cast6_enc_blk8)
11620
11621 @@ -340,6 +342,7 @@ __cast6_dec_blk8:
11622 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
11623 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
11624
11625 + pax_force_retaddr 0, 1
11626 ret;
11627 ENDPROC(__cast6_dec_blk8)
11628
11629 @@ -358,6 +361,7 @@ ENTRY(cast6_ecb_enc_8way)
11630
11631 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11632
11633 + pax_force_retaddr
11634 ret;
11635 ENDPROC(cast6_ecb_enc_8way)
11636
11637 @@ -376,6 +380,7 @@ ENTRY(cast6_ecb_dec_8way)
11638
11639 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11640
11641 + pax_force_retaddr
11642 ret;
11643 ENDPROC(cast6_ecb_dec_8way)
11644
11645 @@ -399,6 +404,7 @@ ENTRY(cast6_cbc_dec_8way)
11646
11647 popq %r12;
11648
11649 + pax_force_retaddr
11650 ret;
11651 ENDPROC(cast6_cbc_dec_8way)
11652
11653 @@ -424,6 +430,7 @@ ENTRY(cast6_ctr_8way)
11654
11655 popq %r12;
11656
11657 + pax_force_retaddr
11658 ret;
11659 ENDPROC(cast6_ctr_8way)
11660
11661 @@ -446,6 +453,7 @@ ENTRY(cast6_xts_enc_8way)
11662 /* dst <= regs xor IVs(in dst) */
11663 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11664
11665 + pax_force_retaddr
11666 ret;
11667 ENDPROC(cast6_xts_enc_8way)
11668
11669 @@ -468,5 +476,6 @@ ENTRY(cast6_xts_dec_8way)
11670 /* dst <= regs xor IVs(in dst) */
11671 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11672
11673 + pax_force_retaddr
11674 ret;
11675 ENDPROC(cast6_xts_dec_8way)
11676 diff --git a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
11677 index dbc4339..3d868c5 100644
11678 --- a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
11679 +++ b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
11680 @@ -45,6 +45,7 @@
11681
11682 #include <asm/inst.h>
11683 #include <linux/linkage.h>
11684 +#include <asm/alternative-asm.h>
11685
11686 ## ISCSI CRC 32 Implementation with crc32 and pclmulqdq Instruction
11687
11688 @@ -312,6 +313,7 @@ do_return:
11689 popq %rsi
11690 popq %rdi
11691 popq %rbx
11692 + pax_force_retaddr 0, 1
11693 ret
11694
11695 ################################################################
11696 diff --git a/arch/x86/crypto/ghash-clmulni-intel_asm.S b/arch/x86/crypto/ghash-clmulni-intel_asm.S
11697 index 586f41a..d02851e 100644
11698 --- a/arch/x86/crypto/ghash-clmulni-intel_asm.S
11699 +++ b/arch/x86/crypto/ghash-clmulni-intel_asm.S
11700 @@ -18,6 +18,7 @@
11701
11702 #include <linux/linkage.h>
11703 #include <asm/inst.h>
11704 +#include <asm/alternative-asm.h>
11705
11706 .data
11707
11708 @@ -93,6 +94,7 @@ __clmul_gf128mul_ble:
11709 psrlq $1, T2
11710 pxor T2, T1
11711 pxor T1, DATA
11712 + pax_force_retaddr
11713 ret
11714 ENDPROC(__clmul_gf128mul_ble)
11715
11716 @@ -105,6 +107,7 @@ ENTRY(clmul_ghash_mul)
11717 call __clmul_gf128mul_ble
11718 PSHUFB_XMM BSWAP DATA
11719 movups DATA, (%rdi)
11720 + pax_force_retaddr
11721 ret
11722 ENDPROC(clmul_ghash_mul)
11723
11724 @@ -132,6 +135,7 @@ ENTRY(clmul_ghash_update)
11725 PSHUFB_XMM BSWAP DATA
11726 movups DATA, (%rdi)
11727 .Lupdate_just_ret:
11728 + pax_force_retaddr
11729 ret
11730 ENDPROC(clmul_ghash_update)
11731
11732 @@ -157,5 +161,6 @@ ENTRY(clmul_ghash_setkey)
11733 pand .Lpoly, %xmm1
11734 pxor %xmm1, %xmm0
11735 movups %xmm0, (%rdi)
11736 + pax_force_retaddr
11737 ret
11738 ENDPROC(clmul_ghash_setkey)
11739 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11740 index 9279e0b..9270820 100644
11741 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
11742 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
11743 @@ -1,4 +1,5 @@
11744 #include <linux/linkage.h>
11745 +#include <asm/alternative-asm.h>
11746
11747 # enter salsa20_encrypt_bytes
11748 ENTRY(salsa20_encrypt_bytes)
11749 @@ -789,6 +790,7 @@ ENTRY(salsa20_encrypt_bytes)
11750 add %r11,%rsp
11751 mov %rdi,%rax
11752 mov %rsi,%rdx
11753 + pax_force_retaddr 0, 1
11754 ret
11755 # bytesatleast65:
11756 ._bytesatleast65:
11757 @@ -889,6 +891,7 @@ ENTRY(salsa20_keysetup)
11758 add %r11,%rsp
11759 mov %rdi,%rax
11760 mov %rsi,%rdx
11761 + pax_force_retaddr
11762 ret
11763 ENDPROC(salsa20_keysetup)
11764
11765 @@ -914,5 +917,6 @@ ENTRY(salsa20_ivsetup)
11766 add %r11,%rsp
11767 mov %rdi,%rax
11768 mov %rsi,%rdx
11769 + pax_force_retaddr
11770 ret
11771 ENDPROC(salsa20_ivsetup)
11772 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11773 index 2f202f4..d9164d6 100644
11774 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11775 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
11776 @@ -24,6 +24,7 @@
11777 */
11778
11779 #include <linux/linkage.h>
11780 +#include <asm/alternative-asm.h>
11781 #include "glue_helper-asm-avx.S"
11782
11783 .file "serpent-avx-x86_64-asm_64.S"
11784 @@ -618,6 +619,7 @@ __serpent_enc_blk8_avx:
11785 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11786 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11787
11788 + pax_force_retaddr
11789 ret;
11790 ENDPROC(__serpent_enc_blk8_avx)
11791
11792 @@ -672,6 +674,7 @@ __serpent_dec_blk8_avx:
11793 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11794 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11795
11796 + pax_force_retaddr
11797 ret;
11798 ENDPROC(__serpent_dec_blk8_avx)
11799
11800 @@ -688,6 +691,7 @@ ENTRY(serpent_ecb_enc_8way_avx)
11801
11802 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11803
11804 + pax_force_retaddr
11805 ret;
11806 ENDPROC(serpent_ecb_enc_8way_avx)
11807
11808 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_8way_avx)
11809
11810 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11811
11812 + pax_force_retaddr
11813 ret;
11814 ENDPROC(serpent_ecb_dec_8way_avx)
11815
11816 @@ -720,6 +725,7 @@ ENTRY(serpent_cbc_dec_8way_avx)
11817
11818 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11819
11820 + pax_force_retaddr
11821 ret;
11822 ENDPROC(serpent_cbc_dec_8way_avx)
11823
11824 @@ -738,6 +744,7 @@ ENTRY(serpent_ctr_8way_avx)
11825
11826 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11827
11828 + pax_force_retaddr
11829 ret;
11830 ENDPROC(serpent_ctr_8way_avx)
11831
11832 @@ -758,6 +765,7 @@ ENTRY(serpent_xts_enc_8way_avx)
11833 /* dst <= regs xor IVs(in dst) */
11834 store_xts_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
11835
11836 + pax_force_retaddr
11837 ret;
11838 ENDPROC(serpent_xts_enc_8way_avx)
11839
11840 @@ -778,5 +786,6 @@ ENTRY(serpent_xts_dec_8way_avx)
11841 /* dst <= regs xor IVs(in dst) */
11842 store_xts_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
11843
11844 + pax_force_retaddr
11845 ret;
11846 ENDPROC(serpent_xts_dec_8way_avx)
11847 diff --git a/arch/x86/crypto/serpent-avx2-asm_64.S b/arch/x86/crypto/serpent-avx2-asm_64.S
11848 index b222085..abd483c 100644
11849 --- a/arch/x86/crypto/serpent-avx2-asm_64.S
11850 +++ b/arch/x86/crypto/serpent-avx2-asm_64.S
11851 @@ -15,6 +15,7 @@
11852 */
11853
11854 #include <linux/linkage.h>
11855 +#include <asm/alternative-asm.h>
11856 #include "glue_helper-asm-avx2.S"
11857
11858 .file "serpent-avx2-asm_64.S"
11859 @@ -610,6 +611,7 @@ __serpent_enc_blk16:
11860 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11861 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11862
11863 + pax_force_retaddr
11864 ret;
11865 ENDPROC(__serpent_enc_blk16)
11866
11867 @@ -664,6 +666,7 @@ __serpent_dec_blk16:
11868 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11869 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11870
11871 + pax_force_retaddr
11872 ret;
11873 ENDPROC(__serpent_dec_blk16)
11874
11875 @@ -684,6 +687,7 @@ ENTRY(serpent_ecb_enc_16way)
11876
11877 vzeroupper;
11878
11879 + pax_force_retaddr
11880 ret;
11881 ENDPROC(serpent_ecb_enc_16way)
11882
11883 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_16way)
11884
11885 vzeroupper;
11886
11887 + pax_force_retaddr
11888 ret;
11889 ENDPROC(serpent_ecb_dec_16way)
11890
11891 @@ -725,6 +730,7 @@ ENTRY(serpent_cbc_dec_16way)
11892
11893 vzeroupper;
11894
11895 + pax_force_retaddr
11896 ret;
11897 ENDPROC(serpent_cbc_dec_16way)
11898
11899 @@ -748,6 +754,7 @@ ENTRY(serpent_ctr_16way)
11900
11901 vzeroupper;
11902
11903 + pax_force_retaddr
11904 ret;
11905 ENDPROC(serpent_ctr_16way)
11906
11907 @@ -772,6 +779,7 @@ ENTRY(serpent_xts_enc_16way)
11908
11909 vzeroupper;
11910
11911 + pax_force_retaddr
11912 ret;
11913 ENDPROC(serpent_xts_enc_16way)
11914
11915 @@ -796,5 +804,6 @@ ENTRY(serpent_xts_dec_16way)
11916
11917 vzeroupper;
11918
11919 + pax_force_retaddr
11920 ret;
11921 ENDPROC(serpent_xts_dec_16way)
11922 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11923 index acc066c..1559cc4 100644
11924 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11925 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
11926 @@ -25,6 +25,7 @@
11927 */
11928
11929 #include <linux/linkage.h>
11930 +#include <asm/alternative-asm.h>
11931
11932 .file "serpent-sse2-x86_64-asm_64.S"
11933 .text
11934 @@ -690,12 +691,14 @@ ENTRY(__serpent_enc_blk_8way)
11935 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11936 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11937
11938 + pax_force_retaddr
11939 ret;
11940
11941 .L__enc_xor8:
11942 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
11943 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
11944
11945 + pax_force_retaddr
11946 ret;
11947 ENDPROC(__serpent_enc_blk_8way)
11948
11949 @@ -750,5 +753,6 @@ ENTRY(serpent_dec_blk_8way)
11950 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
11951 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
11952
11953 + pax_force_retaddr
11954 ret;
11955 ENDPROC(serpent_dec_blk_8way)
11956 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
11957 index a410950..3356d42 100644
11958 --- a/arch/x86/crypto/sha1_ssse3_asm.S
11959 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
11960 @@ -29,6 +29,7 @@
11961 */
11962
11963 #include <linux/linkage.h>
11964 +#include <asm/alternative-asm.h>
11965
11966 #define CTX %rdi // arg1
11967 #define BUF %rsi // arg2
11968 @@ -104,6 +105,7 @@
11969 pop %r12
11970 pop %rbp
11971 pop %rbx
11972 + pax_force_retaddr 0, 1
11973 ret
11974
11975 ENDPROC(\name)
11976 diff --git a/arch/x86/crypto/sha256-avx-asm.S b/arch/x86/crypto/sha256-avx-asm.S
11977 index 642f156..4ab07b9 100644
11978 --- a/arch/x86/crypto/sha256-avx-asm.S
11979 +++ b/arch/x86/crypto/sha256-avx-asm.S
11980 @@ -49,6 +49,7 @@
11981
11982 #ifdef CONFIG_AS_AVX
11983 #include <linux/linkage.h>
11984 +#include <asm/alternative-asm.h>
11985
11986 ## assume buffers not aligned
11987 #define VMOVDQ vmovdqu
11988 @@ -460,6 +461,7 @@ done_hash:
11989 popq %r13
11990 popq %rbp
11991 popq %rbx
11992 + pax_force_retaddr 0, 1
11993 ret
11994 ENDPROC(sha256_transform_avx)
11995
11996 diff --git a/arch/x86/crypto/sha256-avx2-asm.S b/arch/x86/crypto/sha256-avx2-asm.S
11997 index 9e86944..2e7f95a 100644
11998 --- a/arch/x86/crypto/sha256-avx2-asm.S
11999 +++ b/arch/x86/crypto/sha256-avx2-asm.S
12000 @@ -50,6 +50,7 @@
12001
12002 #ifdef CONFIG_AS_AVX2
12003 #include <linux/linkage.h>
12004 +#include <asm/alternative-asm.h>
12005
12006 ## assume buffers not aligned
12007 #define VMOVDQ vmovdqu
12008 @@ -720,6 +721,7 @@ done_hash:
12009 popq %r12
12010 popq %rbp
12011 popq %rbx
12012 + pax_force_retaddr 0, 1
12013 ret
12014 ENDPROC(sha256_transform_rorx)
12015
12016 diff --git a/arch/x86/crypto/sha256-ssse3-asm.S b/arch/x86/crypto/sha256-ssse3-asm.S
12017 index f833b74..c36ed14 100644
12018 --- a/arch/x86/crypto/sha256-ssse3-asm.S
12019 +++ b/arch/x86/crypto/sha256-ssse3-asm.S
12020 @@ -47,6 +47,7 @@
12021 ########################################################################
12022
12023 #include <linux/linkage.h>
12024 +#include <asm/alternative-asm.h>
12025
12026 ## assume buffers not aligned
12027 #define MOVDQ movdqu
12028 @@ -471,6 +472,7 @@ done_hash:
12029 popq %rbp
12030 popq %rbx
12031
12032 + pax_force_retaddr 0, 1
12033 ret
12034 ENDPROC(sha256_transform_ssse3)
12035
12036 diff --git a/arch/x86/crypto/sha512-avx-asm.S b/arch/x86/crypto/sha512-avx-asm.S
12037 index 974dde9..4533d34 100644
12038 --- a/arch/x86/crypto/sha512-avx-asm.S
12039 +++ b/arch/x86/crypto/sha512-avx-asm.S
12040 @@ -49,6 +49,7 @@
12041
12042 #ifdef CONFIG_AS_AVX
12043 #include <linux/linkage.h>
12044 +#include <asm/alternative-asm.h>
12045
12046 .text
12047
12048 @@ -364,6 +365,7 @@ updateblock:
12049 mov frame_RSPSAVE(%rsp), %rsp
12050
12051 nowork:
12052 + pax_force_retaddr 0, 1
12053 ret
12054 ENDPROC(sha512_transform_avx)
12055
12056 diff --git a/arch/x86/crypto/sha512-avx2-asm.S b/arch/x86/crypto/sha512-avx2-asm.S
12057 index 568b961..061ef1d 100644
12058 --- a/arch/x86/crypto/sha512-avx2-asm.S
12059 +++ b/arch/x86/crypto/sha512-avx2-asm.S
12060 @@ -51,6 +51,7 @@
12061
12062 #ifdef CONFIG_AS_AVX2
12063 #include <linux/linkage.h>
12064 +#include <asm/alternative-asm.h>
12065
12066 .text
12067
12068 @@ -678,6 +679,7 @@ done_hash:
12069
12070 # Restore Stack Pointer
12071 mov frame_RSPSAVE(%rsp), %rsp
12072 + pax_force_retaddr 0, 1
12073 ret
12074 ENDPROC(sha512_transform_rorx)
12075
12076 diff --git a/arch/x86/crypto/sha512-ssse3-asm.S b/arch/x86/crypto/sha512-ssse3-asm.S
12077 index fb56855..e23914f 100644
12078 --- a/arch/x86/crypto/sha512-ssse3-asm.S
12079 +++ b/arch/x86/crypto/sha512-ssse3-asm.S
12080 @@ -48,6 +48,7 @@
12081 ########################################################################
12082
12083 #include <linux/linkage.h>
12084 +#include <asm/alternative-asm.h>
12085
12086 .text
12087
12088 @@ -363,6 +364,7 @@ updateblock:
12089 mov frame_RSPSAVE(%rsp), %rsp
12090
12091 nowork:
12092 + pax_force_retaddr 0, 1
12093 ret
12094 ENDPROC(sha512_transform_ssse3)
12095
12096 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
12097 index 0505813..63b1d00 100644
12098 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
12099 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
12100 @@ -24,6 +24,7 @@
12101 */
12102
12103 #include <linux/linkage.h>
12104 +#include <asm/alternative-asm.h>
12105 #include "glue_helper-asm-avx.S"
12106
12107 .file "twofish-avx-x86_64-asm_64.S"
12108 @@ -284,6 +285,7 @@ __twofish_enc_blk8:
12109 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
12110 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
12111
12112 + pax_force_retaddr 0, 1
12113 ret;
12114 ENDPROC(__twofish_enc_blk8)
12115
12116 @@ -324,6 +326,7 @@ __twofish_dec_blk8:
12117 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
12118 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
12119
12120 + pax_force_retaddr 0, 1
12121 ret;
12122 ENDPROC(__twofish_dec_blk8)
12123
12124 @@ -342,6 +345,7 @@ ENTRY(twofish_ecb_enc_8way)
12125
12126 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
12127
12128 + pax_force_retaddr 0, 1
12129 ret;
12130 ENDPROC(twofish_ecb_enc_8way)
12131
12132 @@ -360,6 +364,7 @@ ENTRY(twofish_ecb_dec_8way)
12133
12134 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12135
12136 + pax_force_retaddr 0, 1
12137 ret;
12138 ENDPROC(twofish_ecb_dec_8way)
12139
12140 @@ -383,6 +388,7 @@ ENTRY(twofish_cbc_dec_8way)
12141
12142 popq %r12;
12143
12144 + pax_force_retaddr 0, 1
12145 ret;
12146 ENDPROC(twofish_cbc_dec_8way)
12147
12148 @@ -408,6 +414,7 @@ ENTRY(twofish_ctr_8way)
12149
12150 popq %r12;
12151
12152 + pax_force_retaddr 0, 1
12153 ret;
12154 ENDPROC(twofish_ctr_8way)
12155
12156 @@ -430,6 +437,7 @@ ENTRY(twofish_xts_enc_8way)
12157 /* dst <= regs xor IVs(in dst) */
12158 store_xts_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
12159
12160 + pax_force_retaddr 0, 1
12161 ret;
12162 ENDPROC(twofish_xts_enc_8way)
12163
12164 @@ -452,5 +460,6 @@ ENTRY(twofish_xts_dec_8way)
12165 /* dst <= regs xor IVs(in dst) */
12166 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
12167
12168 + pax_force_retaddr 0, 1
12169 ret;
12170 ENDPROC(twofish_xts_dec_8way)
12171 diff --git a/arch/x86/crypto/twofish-avx2-asm_64.S b/arch/x86/crypto/twofish-avx2-asm_64.S
12172 index e1a83b9..33006b9 100644
12173 --- a/arch/x86/crypto/twofish-avx2-asm_64.S
12174 +++ b/arch/x86/crypto/twofish-avx2-asm_64.S
12175 @@ -11,6 +11,7 @@
12176 */
12177
12178 #include <linux/linkage.h>
12179 +#include <asm/alternative-asm.h>
12180 #include "glue_helper-asm-avx2.S"
12181
12182 .file "twofish-avx2-asm_64.S"
12183 @@ -422,6 +423,7 @@ __twofish_enc_blk16:
12184 outunpack_enc16(RA, RB, RC, RD);
12185 write_blocks16(RA, RB, RC, RD);
12186
12187 + pax_force_retaddr_bts
12188 ret;
12189 ENDPROC(__twofish_enc_blk16)
12190
12191 @@ -454,6 +456,7 @@ __twofish_dec_blk16:
12192 outunpack_dec16(RA, RB, RC, RD);
12193 write_blocks16(RA, RB, RC, RD);
12194
12195 + pax_force_retaddr_bts
12196 ret;
12197 ENDPROC(__twofish_dec_blk16)
12198
12199 @@ -476,6 +479,7 @@ ENTRY(twofish_ecb_enc_16way)
12200 popq %r12;
12201 vzeroupper;
12202
12203 + pax_force_retaddr 0, 1
12204 ret;
12205 ENDPROC(twofish_ecb_enc_16way)
12206
12207 @@ -498,6 +502,7 @@ ENTRY(twofish_ecb_dec_16way)
12208 popq %r12;
12209 vzeroupper;
12210
12211 + pax_force_retaddr 0, 1
12212 ret;
12213 ENDPROC(twofish_ecb_dec_16way)
12214
12215 @@ -521,6 +526,7 @@ ENTRY(twofish_cbc_dec_16way)
12216 popq %r12;
12217 vzeroupper;
12218
12219 + pax_force_retaddr 0, 1
12220 ret;
12221 ENDPROC(twofish_cbc_dec_16way)
12222
12223 @@ -546,6 +552,7 @@ ENTRY(twofish_ctr_16way)
12224 popq %r12;
12225 vzeroupper;
12226
12227 + pax_force_retaddr 0, 1
12228 ret;
12229 ENDPROC(twofish_ctr_16way)
12230
12231 @@ -574,6 +581,7 @@ twofish_xts_crypt_16way:
12232 popq %r12;
12233 vzeroupper;
12234
12235 + pax_force_retaddr 0, 1
12236 ret;
12237 ENDPROC(twofish_xts_crypt_16way)
12238
12239 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
12240 index 1c3b7ce..b365c5e 100644
12241 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
12242 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
12243 @@ -21,6 +21,7 @@
12244 */
12245
12246 #include <linux/linkage.h>
12247 +#include <asm/alternative-asm.h>
12248
12249 .file "twofish-x86_64-asm-3way.S"
12250 .text
12251 @@ -258,6 +259,7 @@ ENTRY(__twofish_enc_blk_3way)
12252 popq %r13;
12253 popq %r14;
12254 popq %r15;
12255 + pax_force_retaddr 0, 1
12256 ret;
12257
12258 .L__enc_xor3:
12259 @@ -269,6 +271,7 @@ ENTRY(__twofish_enc_blk_3way)
12260 popq %r13;
12261 popq %r14;
12262 popq %r15;
12263 + pax_force_retaddr 0, 1
12264 ret;
12265 ENDPROC(__twofish_enc_blk_3way)
12266
12267 @@ -308,5 +311,6 @@ ENTRY(twofish_dec_blk_3way)
12268 popq %r13;
12269 popq %r14;
12270 popq %r15;
12271 + pax_force_retaddr 0, 1
12272 ret;
12273 ENDPROC(twofish_dec_blk_3way)
12274 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
12275 index a039d21..29e7615 100644
12276 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
12277 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
12278 @@ -22,6 +22,7 @@
12279
12280 #include <linux/linkage.h>
12281 #include <asm/asm-offsets.h>
12282 +#include <asm/alternative-asm.h>
12283
12284 #define a_offset 0
12285 #define b_offset 4
12286 @@ -265,6 +266,7 @@ ENTRY(twofish_enc_blk)
12287
12288 popq R1
12289 movq $1,%rax
12290 + pax_force_retaddr 0, 1
12291 ret
12292 ENDPROC(twofish_enc_blk)
12293
12294 @@ -317,5 +319,6 @@ ENTRY(twofish_dec_blk)
12295
12296 popq R1
12297 movq $1,%rax
12298 + pax_force_retaddr 0, 1
12299 ret
12300 ENDPROC(twofish_dec_blk)
12301 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
12302 index 52ff81c..98af645 100644
12303 --- a/arch/x86/ia32/ia32_aout.c
12304 +++ b/arch/x86/ia32/ia32_aout.c
12305 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
12306 unsigned long dump_start, dump_size;
12307 struct user32 dump;
12308
12309 + memset(&dump, 0, sizeof(dump));
12310 +
12311 fs = get_fs();
12312 set_fs(KERNEL_DS);
12313 has_dumped = 1;
12314 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
12315 index cf1a471..5ba2673 100644
12316 --- a/arch/x86/ia32/ia32_signal.c
12317 +++ b/arch/x86/ia32/ia32_signal.c
12318 @@ -340,7 +340,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
12319 sp -= frame_size;
12320 /* Align the stack pointer according to the i386 ABI,
12321 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
12322 - sp = ((sp + 4) & -16ul) - 4;
12323 + sp = ((sp - 12) & -16ul) - 4;
12324 return (void __user *) sp;
12325 }
12326
12327 @@ -398,7 +398,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
12328 * These are actually not used anymore, but left because some
12329 * gdb versions depend on them as a marker.
12330 */
12331 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
12332 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
12333 } put_user_catch(err);
12334
12335 if (err)
12336 @@ -440,7 +440,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
12337 0xb8,
12338 __NR_ia32_rt_sigreturn,
12339 0x80cd,
12340 - 0,
12341 + 0
12342 };
12343
12344 frame = get_sigframe(ksig, regs, sizeof(*frame), &fpstate);
12345 @@ -459,20 +459,22 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
12346 else
12347 put_user_ex(0, &frame->uc.uc_flags);
12348 put_user_ex(0, &frame->uc.uc_link);
12349 - err |= __compat_save_altstack(&frame->uc.uc_stack, regs->sp);
12350 + __compat_save_altstack_ex(&frame->uc.uc_stack, regs->sp);
12351
12352 if (ksig->ka.sa.sa_flags & SA_RESTORER)
12353 restorer = ksig->ka.sa.sa_restorer;
12354 + else if (current->mm->context.vdso)
12355 + /* Return stub is in 32bit vsyscall page */
12356 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
12357 else
12358 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
12359 - rt_sigreturn);
12360 + restorer = &frame->retcode;
12361 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
12362
12363 /*
12364 * Not actually used anymore, but left because some gdb
12365 * versions need it.
12366 */
12367 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
12368 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
12369 } put_user_catch(err);
12370
12371 err |= copy_siginfo_to_user32(&frame->info, &ksig->info);
12372 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
12373 index 474dc1b..9297c58 100644
12374 --- a/arch/x86/ia32/ia32entry.S
12375 +++ b/arch/x86/ia32/ia32entry.S
12376 @@ -15,8 +15,10 @@
12377 #include <asm/irqflags.h>
12378 #include <asm/asm.h>
12379 #include <asm/smap.h>
12380 +#include <asm/pgtable.h>
12381 #include <linux/linkage.h>
12382 #include <linux/err.h>
12383 +#include <asm/alternative-asm.h>
12384
12385 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
12386 #include <linux/elf-em.h>
12387 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
12388 ENDPROC(native_irq_enable_sysexit)
12389 #endif
12390
12391 + .macro pax_enter_kernel_user
12392 + pax_set_fptr_mask
12393 +#ifdef CONFIG_PAX_MEMORY_UDEREF
12394 + call pax_enter_kernel_user
12395 +#endif
12396 + .endm
12397 +
12398 + .macro pax_exit_kernel_user
12399 +#ifdef CONFIG_PAX_MEMORY_UDEREF
12400 + call pax_exit_kernel_user
12401 +#endif
12402 +#ifdef CONFIG_PAX_RANDKSTACK
12403 + pushq %rax
12404 + pushq %r11
12405 + call pax_randomize_kstack
12406 + popq %r11
12407 + popq %rax
12408 +#endif
12409 + .endm
12410 +
12411 + .macro pax_erase_kstack
12412 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
12413 + call pax_erase_kstack
12414 +#endif
12415 + .endm
12416 +
12417 /*
12418 * 32bit SYSENTER instruction entry.
12419 *
12420 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
12421 CFI_REGISTER rsp,rbp
12422 SWAPGS_UNSAFE_STACK
12423 movq PER_CPU_VAR(kernel_stack), %rsp
12424 - addq $(KERNEL_STACK_OFFSET),%rsp
12425 - /*
12426 - * No need to follow this irqs on/off section: the syscall
12427 - * disabled irqs, here we enable it straight after entry:
12428 - */
12429 - ENABLE_INTERRUPTS(CLBR_NONE)
12430 movl %ebp,%ebp /* zero extension */
12431 pushq_cfi $__USER32_DS
12432 /*CFI_REL_OFFSET ss,0*/
12433 @@ -135,24 +157,49 @@ ENTRY(ia32_sysenter_target)
12434 CFI_REL_OFFSET rsp,0
12435 pushfq_cfi
12436 /*CFI_REL_OFFSET rflags,0*/
12437 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
12438 - CFI_REGISTER rip,r10
12439 + orl $X86_EFLAGS_IF,(%rsp)
12440 + GET_THREAD_INFO(%r11)
12441 + movl TI_sysenter_return(%r11), %r11d
12442 + CFI_REGISTER rip,r11
12443 pushq_cfi $__USER32_CS
12444 /*CFI_REL_OFFSET cs,0*/
12445 movl %eax, %eax
12446 - pushq_cfi %r10
12447 + pushq_cfi %r11
12448 CFI_REL_OFFSET rip,0
12449 pushq_cfi %rax
12450 cld
12451 SAVE_ARGS 0,1,0
12452 + pax_enter_kernel_user
12453 +
12454 +#ifdef CONFIG_PAX_RANDKSTACK
12455 + pax_erase_kstack
12456 +#endif
12457 +
12458 + /*
12459 + * No need to follow this irqs on/off section: the syscall
12460 + * disabled irqs, here we enable it straight after entry:
12461 + */
12462 + ENABLE_INTERRUPTS(CLBR_NONE)
12463 /* no need to do an access_ok check here because rbp has been
12464 32bit zero extended */
12465 +
12466 +#ifdef CONFIG_PAX_MEMORY_UDEREF
12467 + addq pax_user_shadow_base,%rbp
12468 + ASM_PAX_OPEN_USERLAND
12469 +#endif
12470 +
12471 ASM_STAC
12472 1: movl (%rbp),%ebp
12473 _ASM_EXTABLE(1b,ia32_badarg)
12474 ASM_CLAC
12475 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12476 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12477 +
12478 +#ifdef CONFIG_PAX_MEMORY_UDEREF
12479 + ASM_PAX_CLOSE_USERLAND
12480 +#endif
12481 +
12482 + GET_THREAD_INFO(%r11)
12483 + orl $TS_COMPAT,TI_status(%r11)
12484 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
12485 CFI_REMEMBER_STATE
12486 jnz sysenter_tracesys
12487 cmpq $(IA32_NR_syscalls-1),%rax
12488 @@ -162,12 +209,15 @@ sysenter_do_call:
12489 sysenter_dispatch:
12490 call *ia32_sys_call_table(,%rax,8)
12491 movq %rax,RAX-ARGOFFSET(%rsp)
12492 + GET_THREAD_INFO(%r11)
12493 DISABLE_INTERRUPTS(CLBR_NONE)
12494 TRACE_IRQS_OFF
12495 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12496 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
12497 jnz sysexit_audit
12498 sysexit_from_sys_call:
12499 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12500 + pax_exit_kernel_user
12501 + pax_erase_kstack
12502 + andl $~TS_COMPAT,TI_status(%r11)
12503 /* clear IF, that popfq doesn't enable interrupts early */
12504 andl $~0x200,EFLAGS-R11(%rsp)
12505 movl RIP-R11(%rsp),%edx /* User %eip */
12506 @@ -193,6 +243,9 @@ sysexit_from_sys_call:
12507 movl %eax,%esi /* 2nd arg: syscall number */
12508 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
12509 call __audit_syscall_entry
12510 +
12511 + pax_erase_kstack
12512 +
12513 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
12514 cmpq $(IA32_NR_syscalls-1),%rax
12515 ja ia32_badsys
12516 @@ -204,7 +257,7 @@ sysexit_from_sys_call:
12517 .endm
12518
12519 .macro auditsys_exit exit
12520 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12521 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
12522 jnz ia32_ret_from_sys_call
12523 TRACE_IRQS_ON
12524 ENABLE_INTERRUPTS(CLBR_NONE)
12525 @@ -215,11 +268,12 @@ sysexit_from_sys_call:
12526 1: setbe %al /* 1 if error, 0 if not */
12527 movzbl %al,%edi /* zero-extend that into %edi */
12528 call __audit_syscall_exit
12529 + GET_THREAD_INFO(%r11)
12530 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
12531 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
12532 DISABLE_INTERRUPTS(CLBR_NONE)
12533 TRACE_IRQS_OFF
12534 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12535 + testl %edi,TI_flags(%r11)
12536 jz \exit
12537 CLEAR_RREGS -ARGOFFSET
12538 jmp int_with_check
12539 @@ -237,7 +291,7 @@ sysexit_audit:
12540
12541 sysenter_tracesys:
12542 #ifdef CONFIG_AUDITSYSCALL
12543 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12544 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
12545 jz sysenter_auditsys
12546 #endif
12547 SAVE_REST
12548 @@ -249,6 +303,9 @@ sysenter_tracesys:
12549 RESTORE_REST
12550 cmpq $(IA32_NR_syscalls-1),%rax
12551 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
12552 +
12553 + pax_erase_kstack
12554 +
12555 jmp sysenter_do_call
12556 CFI_ENDPROC
12557 ENDPROC(ia32_sysenter_target)
12558 @@ -276,19 +333,25 @@ ENDPROC(ia32_sysenter_target)
12559 ENTRY(ia32_cstar_target)
12560 CFI_STARTPROC32 simple
12561 CFI_SIGNAL_FRAME
12562 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
12563 + CFI_DEF_CFA rsp,0
12564 CFI_REGISTER rip,rcx
12565 /*CFI_REGISTER rflags,r11*/
12566 SWAPGS_UNSAFE_STACK
12567 movl %esp,%r8d
12568 CFI_REGISTER rsp,r8
12569 movq PER_CPU_VAR(kernel_stack),%rsp
12570 + SAVE_ARGS 8*6,0,0
12571 + pax_enter_kernel_user
12572 +
12573 +#ifdef CONFIG_PAX_RANDKSTACK
12574 + pax_erase_kstack
12575 +#endif
12576 +
12577 /*
12578 * No need to follow this irqs on/off section: the syscall
12579 * disabled irqs and here we enable it straight after entry:
12580 */
12581 ENABLE_INTERRUPTS(CLBR_NONE)
12582 - SAVE_ARGS 8,0,0
12583 movl %eax,%eax /* zero extension */
12584 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
12585 movq %rcx,RIP-ARGOFFSET(%rsp)
12586 @@ -304,12 +367,25 @@ ENTRY(ia32_cstar_target)
12587 /* no need to do an access_ok check here because r8 has been
12588 32bit zero extended */
12589 /* hardware stack frame is complete now */
12590 +
12591 +#ifdef CONFIG_PAX_MEMORY_UDEREF
12592 + ASM_PAX_OPEN_USERLAND
12593 + movq pax_user_shadow_base,%r8
12594 + addq RSP-ARGOFFSET(%rsp),%r8
12595 +#endif
12596 +
12597 ASM_STAC
12598 1: movl (%r8),%r9d
12599 _ASM_EXTABLE(1b,ia32_badarg)
12600 ASM_CLAC
12601 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12602 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12603 +
12604 +#ifdef CONFIG_PAX_MEMORY_UDEREF
12605 + ASM_PAX_CLOSE_USERLAND
12606 +#endif
12607 +
12608 + GET_THREAD_INFO(%r11)
12609 + orl $TS_COMPAT,TI_status(%r11)
12610 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
12611 CFI_REMEMBER_STATE
12612 jnz cstar_tracesys
12613 cmpq $IA32_NR_syscalls-1,%rax
12614 @@ -319,12 +395,15 @@ cstar_do_call:
12615 cstar_dispatch:
12616 call *ia32_sys_call_table(,%rax,8)
12617 movq %rax,RAX-ARGOFFSET(%rsp)
12618 + GET_THREAD_INFO(%r11)
12619 DISABLE_INTERRUPTS(CLBR_NONE)
12620 TRACE_IRQS_OFF
12621 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12622 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
12623 jnz sysretl_audit
12624 sysretl_from_sys_call:
12625 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12626 + pax_exit_kernel_user
12627 + pax_erase_kstack
12628 + andl $~TS_COMPAT,TI_status(%r11)
12629 RESTORE_ARGS 0,-ARG_SKIP,0,0,0
12630 movl RIP-ARGOFFSET(%rsp),%ecx
12631 CFI_REGISTER rip,rcx
12632 @@ -352,7 +431,7 @@ sysretl_audit:
12633
12634 cstar_tracesys:
12635 #ifdef CONFIG_AUDITSYSCALL
12636 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12637 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
12638 jz cstar_auditsys
12639 #endif
12640 xchgl %r9d,%ebp
12641 @@ -366,11 +445,19 @@ cstar_tracesys:
12642 xchgl %ebp,%r9d
12643 cmpq $(IA32_NR_syscalls-1),%rax
12644 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
12645 +
12646 + pax_erase_kstack
12647 +
12648 jmp cstar_do_call
12649 END(ia32_cstar_target)
12650
12651 ia32_badarg:
12652 ASM_CLAC
12653 +
12654 +#ifdef CONFIG_PAX_MEMORY_UDEREF
12655 + ASM_PAX_CLOSE_USERLAND
12656 +#endif
12657 +
12658 movq $-EFAULT,%rax
12659 jmp ia32_sysret
12660 CFI_ENDPROC
12661 @@ -407,19 +494,26 @@ ENTRY(ia32_syscall)
12662 CFI_REL_OFFSET rip,RIP-RIP
12663 PARAVIRT_ADJUST_EXCEPTION_FRAME
12664 SWAPGS
12665 - /*
12666 - * No need to follow this irqs on/off section: the syscall
12667 - * disabled irqs and here we enable it straight after entry:
12668 - */
12669 - ENABLE_INTERRUPTS(CLBR_NONE)
12670 movl %eax,%eax
12671 pushq_cfi %rax
12672 cld
12673 /* note the registers are not zero extended to the sf.
12674 this could be a problem. */
12675 SAVE_ARGS 0,1,0
12676 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12677 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
12678 + pax_enter_kernel_user
12679 +
12680 +#ifdef CONFIG_PAX_RANDKSTACK
12681 + pax_erase_kstack
12682 +#endif
12683 +
12684 + /*
12685 + * No need to follow this irqs on/off section: the syscall
12686 + * disabled irqs and here we enable it straight after entry:
12687 + */
12688 + ENABLE_INTERRUPTS(CLBR_NONE)
12689 + GET_THREAD_INFO(%r11)
12690 + orl $TS_COMPAT,TI_status(%r11)
12691 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
12692 jnz ia32_tracesys
12693 cmpq $(IA32_NR_syscalls-1),%rax
12694 ja ia32_badsys
12695 @@ -442,6 +536,9 @@ ia32_tracesys:
12696 RESTORE_REST
12697 cmpq $(IA32_NR_syscalls-1),%rax
12698 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
12699 +
12700 + pax_erase_kstack
12701 +
12702 jmp ia32_do_call
12703 END(ia32_syscall)
12704
12705 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
12706 index 8e0ceec..af13504 100644
12707 --- a/arch/x86/ia32/sys_ia32.c
12708 +++ b/arch/x86/ia32/sys_ia32.c
12709 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
12710 */
12711 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
12712 {
12713 - typeof(ubuf->st_uid) uid = 0;
12714 - typeof(ubuf->st_gid) gid = 0;
12715 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
12716 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
12717 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
12718 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
12719 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
12720 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
12721 index 372231c..a5aa1a1 100644
12722 --- a/arch/x86/include/asm/alternative-asm.h
12723 +++ b/arch/x86/include/asm/alternative-asm.h
12724 @@ -18,6 +18,45 @@
12725 .endm
12726 #endif
12727
12728 +#ifdef KERNEXEC_PLUGIN
12729 + .macro pax_force_retaddr_bts rip=0
12730 + btsq $63,\rip(%rsp)
12731 + .endm
12732 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
12733 + .macro pax_force_retaddr rip=0, reload=0
12734 + btsq $63,\rip(%rsp)
12735 + .endm
12736 + .macro pax_force_fptr ptr
12737 + btsq $63,\ptr
12738 + .endm
12739 + .macro pax_set_fptr_mask
12740 + .endm
12741 +#endif
12742 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
12743 + .macro pax_force_retaddr rip=0, reload=0
12744 + .if \reload
12745 + pax_set_fptr_mask
12746 + .endif
12747 + orq %r10,\rip(%rsp)
12748 + .endm
12749 + .macro pax_force_fptr ptr
12750 + orq %r10,\ptr
12751 + .endm
12752 + .macro pax_set_fptr_mask
12753 + movabs $0x8000000000000000,%r10
12754 + .endm
12755 +#endif
12756 +#else
12757 + .macro pax_force_retaddr rip=0, reload=0
12758 + .endm
12759 + .macro pax_force_fptr ptr
12760 + .endm
12761 + .macro pax_force_retaddr_bts rip=0
12762 + .endm
12763 + .macro pax_set_fptr_mask
12764 + .endm
12765 +#endif
12766 +
12767 .macro altinstruction_entry orig alt feature orig_len alt_len
12768 .long \orig - .
12769 .long \alt - .
12770 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
12771 index 58ed6d9..f1cbe58 100644
12772 --- a/arch/x86/include/asm/alternative.h
12773 +++ b/arch/x86/include/asm/alternative.h
12774 @@ -105,7 +105,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
12775 ".pushsection .discard,\"aw\",@progbits\n" \
12776 DISCARD_ENTRY(1) \
12777 ".popsection\n" \
12778 - ".pushsection .altinstr_replacement, \"ax\"\n" \
12779 + ".pushsection .altinstr_replacement, \"a\"\n" \
12780 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
12781 ".popsection"
12782
12783 @@ -119,7 +119,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
12784 DISCARD_ENTRY(1) \
12785 DISCARD_ENTRY(2) \
12786 ".popsection\n" \
12787 - ".pushsection .altinstr_replacement, \"ax\"\n" \
12788 + ".pushsection .altinstr_replacement, \"a\"\n" \
12789 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
12790 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
12791 ".popsection"
12792 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
12793 index 3388034..050f0b9 100644
12794 --- a/arch/x86/include/asm/apic.h
12795 +++ b/arch/x86/include/asm/apic.h
12796 @@ -44,7 +44,7 @@ static inline void generic_apic_probe(void)
12797
12798 #ifdef CONFIG_X86_LOCAL_APIC
12799
12800 -extern unsigned int apic_verbosity;
12801 +extern int apic_verbosity;
12802 extern int local_apic_timer_c2_ok;
12803
12804 extern int disable_apic;
12805 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
12806 index 20370c6..a2eb9b0 100644
12807 --- a/arch/x86/include/asm/apm.h
12808 +++ b/arch/x86/include/asm/apm.h
12809 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
12810 __asm__ __volatile__(APM_DO_ZERO_SEGS
12811 "pushl %%edi\n\t"
12812 "pushl %%ebp\n\t"
12813 - "lcall *%%cs:apm_bios_entry\n\t"
12814 + "lcall *%%ss:apm_bios_entry\n\t"
12815 "setc %%al\n\t"
12816 "popl %%ebp\n\t"
12817 "popl %%edi\n\t"
12818 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
12819 __asm__ __volatile__(APM_DO_ZERO_SEGS
12820 "pushl %%edi\n\t"
12821 "pushl %%ebp\n\t"
12822 - "lcall *%%cs:apm_bios_entry\n\t"
12823 + "lcall *%%ss:apm_bios_entry\n\t"
12824 "setc %%bl\n\t"
12825 "popl %%ebp\n\t"
12826 "popl %%edi\n\t"
12827 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
12828 index 722aa3b..3a0bb27 100644
12829 --- a/arch/x86/include/asm/atomic.h
12830 +++ b/arch/x86/include/asm/atomic.h
12831 @@ -22,7 +22,18 @@
12832 */
12833 static inline int atomic_read(const atomic_t *v)
12834 {
12835 - return (*(volatile int *)&(v)->counter);
12836 + return (*(volatile const int *)&(v)->counter);
12837 +}
12838 +
12839 +/**
12840 + * atomic_read_unchecked - read atomic variable
12841 + * @v: pointer of type atomic_unchecked_t
12842 + *
12843 + * Atomically reads the value of @v.
12844 + */
12845 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
12846 +{
12847 + return (*(volatile const int *)&(v)->counter);
12848 }
12849
12850 /**
12851 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
12852 }
12853
12854 /**
12855 + * atomic_set_unchecked - set atomic variable
12856 + * @v: pointer of type atomic_unchecked_t
12857 + * @i: required value
12858 + *
12859 + * Atomically sets the value of @v to @i.
12860 + */
12861 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
12862 +{
12863 + v->counter = i;
12864 +}
12865 +
12866 +/**
12867 * atomic_add - add integer to atomic variable
12868 * @i: integer value to add
12869 * @v: pointer of type atomic_t
12870 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
12871 */
12872 static inline void atomic_add(int i, atomic_t *v)
12873 {
12874 - asm volatile(LOCK_PREFIX "addl %1,%0"
12875 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
12876 +
12877 +#ifdef CONFIG_PAX_REFCOUNT
12878 + "jno 0f\n"
12879 + LOCK_PREFIX "subl %1,%0\n"
12880 + "int $4\n0:\n"
12881 + _ASM_EXTABLE(0b, 0b)
12882 +#endif
12883 +
12884 + : "+m" (v->counter)
12885 + : "ir" (i));
12886 +}
12887 +
12888 +/**
12889 + * atomic_add_unchecked - add integer to atomic variable
12890 + * @i: integer value to add
12891 + * @v: pointer of type atomic_unchecked_t
12892 + *
12893 + * Atomically adds @i to @v.
12894 + */
12895 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
12896 +{
12897 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
12898 : "+m" (v->counter)
12899 : "ir" (i));
12900 }
12901 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
12902 */
12903 static inline void atomic_sub(int i, atomic_t *v)
12904 {
12905 - asm volatile(LOCK_PREFIX "subl %1,%0"
12906 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
12907 +
12908 +#ifdef CONFIG_PAX_REFCOUNT
12909 + "jno 0f\n"
12910 + LOCK_PREFIX "addl %1,%0\n"
12911 + "int $4\n0:\n"
12912 + _ASM_EXTABLE(0b, 0b)
12913 +#endif
12914 +
12915 + : "+m" (v->counter)
12916 + : "ir" (i));
12917 +}
12918 +
12919 +/**
12920 + * atomic_sub_unchecked - subtract integer from atomic variable
12921 + * @i: integer value to subtract
12922 + * @v: pointer of type atomic_unchecked_t
12923 + *
12924 + * Atomically subtracts @i from @v.
12925 + */
12926 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
12927 +{
12928 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
12929 : "+m" (v->counter)
12930 : "ir" (i));
12931 }
12932 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12933 {
12934 unsigned char c;
12935
12936 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
12937 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
12938 +
12939 +#ifdef CONFIG_PAX_REFCOUNT
12940 + "jno 0f\n"
12941 + LOCK_PREFIX "addl %2,%0\n"
12942 + "int $4\n0:\n"
12943 + _ASM_EXTABLE(0b, 0b)
12944 +#endif
12945 +
12946 + "sete %1\n"
12947 : "+m" (v->counter), "=qm" (c)
12948 : "ir" (i) : "memory");
12949 return c;
12950 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
12951 */
12952 static inline void atomic_inc(atomic_t *v)
12953 {
12954 - asm volatile(LOCK_PREFIX "incl %0"
12955 + asm volatile(LOCK_PREFIX "incl %0\n"
12956 +
12957 +#ifdef CONFIG_PAX_REFCOUNT
12958 + "jno 0f\n"
12959 + LOCK_PREFIX "decl %0\n"
12960 + "int $4\n0:\n"
12961 + _ASM_EXTABLE(0b, 0b)
12962 +#endif
12963 +
12964 + : "+m" (v->counter));
12965 +}
12966 +
12967 +/**
12968 + * atomic_inc_unchecked - increment atomic variable
12969 + * @v: pointer of type atomic_unchecked_t
12970 + *
12971 + * Atomically increments @v by 1.
12972 + */
12973 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
12974 +{
12975 + asm volatile(LOCK_PREFIX "incl %0\n"
12976 : "+m" (v->counter));
12977 }
12978
12979 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
12980 */
12981 static inline void atomic_dec(atomic_t *v)
12982 {
12983 - asm volatile(LOCK_PREFIX "decl %0"
12984 + asm volatile(LOCK_PREFIX "decl %0\n"
12985 +
12986 +#ifdef CONFIG_PAX_REFCOUNT
12987 + "jno 0f\n"
12988 + LOCK_PREFIX "incl %0\n"
12989 + "int $4\n0:\n"
12990 + _ASM_EXTABLE(0b, 0b)
12991 +#endif
12992 +
12993 + : "+m" (v->counter));
12994 +}
12995 +
12996 +/**
12997 + * atomic_dec_unchecked - decrement atomic variable
12998 + * @v: pointer of type atomic_unchecked_t
12999 + *
13000 + * Atomically decrements @v by 1.
13001 + */
13002 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
13003 +{
13004 + asm volatile(LOCK_PREFIX "decl %0\n"
13005 : "+m" (v->counter));
13006 }
13007
13008 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
13009 {
13010 unsigned char c;
13011
13012 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
13013 + asm volatile(LOCK_PREFIX "decl %0\n"
13014 +
13015 +#ifdef CONFIG_PAX_REFCOUNT
13016 + "jno 0f\n"
13017 + LOCK_PREFIX "incl %0\n"
13018 + "int $4\n0:\n"
13019 + _ASM_EXTABLE(0b, 0b)
13020 +#endif
13021 +
13022 + "sete %1\n"
13023 : "+m" (v->counter), "=qm" (c)
13024 : : "memory");
13025 return c != 0;
13026 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
13027 {
13028 unsigned char c;
13029
13030 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
13031 + asm volatile(LOCK_PREFIX "incl %0\n"
13032 +
13033 +#ifdef CONFIG_PAX_REFCOUNT
13034 + "jno 0f\n"
13035 + LOCK_PREFIX "decl %0\n"
13036 + "int $4\n0:\n"
13037 + _ASM_EXTABLE(0b, 0b)
13038 +#endif
13039 +
13040 + "sete %1\n"
13041 + : "+m" (v->counter), "=qm" (c)
13042 + : : "memory");
13043 + return c != 0;
13044 +}
13045 +
13046 +/**
13047 + * atomic_inc_and_test_unchecked - increment and test
13048 + * @v: pointer of type atomic_unchecked_t
13049 + *
13050 + * Atomically increments @v by 1
13051 + * and returns true if the result is zero, or false for all
13052 + * other cases.
13053 + */
13054 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
13055 +{
13056 + unsigned char c;
13057 +
13058 + asm volatile(LOCK_PREFIX "incl %0\n"
13059 + "sete %1\n"
13060 : "+m" (v->counter), "=qm" (c)
13061 : : "memory");
13062 return c != 0;
13063 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
13064 {
13065 unsigned char c;
13066
13067 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
13068 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
13069 +
13070 +#ifdef CONFIG_PAX_REFCOUNT
13071 + "jno 0f\n"
13072 + LOCK_PREFIX "subl %2,%0\n"
13073 + "int $4\n0:\n"
13074 + _ASM_EXTABLE(0b, 0b)
13075 +#endif
13076 +
13077 + "sets %1\n"
13078 : "+m" (v->counter), "=qm" (c)
13079 : "ir" (i) : "memory");
13080 return c;
13081 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
13082 */
13083 static inline int atomic_add_return(int i, atomic_t *v)
13084 {
13085 + return i + xadd_check_overflow(&v->counter, i);
13086 +}
13087 +
13088 +/**
13089 + * atomic_add_return_unchecked - add integer and return
13090 + * @i: integer value to add
13091 + * @v: pointer of type atomic_unchecked_t
13092 + *
13093 + * Atomically adds @i to @v and returns @i + @v
13094 + */
13095 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
13096 +{
13097 return i + xadd(&v->counter, i);
13098 }
13099
13100 @@ -188,6 +362,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
13101 }
13102
13103 #define atomic_inc_return(v) (atomic_add_return(1, v))
13104 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
13105 +{
13106 + return atomic_add_return_unchecked(1, v);
13107 +}
13108 #define atomic_dec_return(v) (atomic_sub_return(1, v))
13109
13110 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
13111 @@ -195,11 +373,21 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
13112 return cmpxchg(&v->counter, old, new);
13113 }
13114
13115 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
13116 +{
13117 + return cmpxchg(&v->counter, old, new);
13118 +}
13119 +
13120 static inline int atomic_xchg(atomic_t *v, int new)
13121 {
13122 return xchg(&v->counter, new);
13123 }
13124
13125 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
13126 +{
13127 + return xchg(&v->counter, new);
13128 +}
13129 +
13130 /**
13131 * __atomic_add_unless - add unless the number is already a given value
13132 * @v: pointer of type atomic_t
13133 @@ -211,12 +399,25 @@ static inline int atomic_xchg(atomic_t *v, int new)
13134 */
13135 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
13136 {
13137 - int c, old;
13138 + int c, old, new;
13139 c = atomic_read(v);
13140 for (;;) {
13141 - if (unlikely(c == (u)))
13142 + if (unlikely(c == u))
13143 break;
13144 - old = atomic_cmpxchg((v), c, c + (a));
13145 +
13146 + asm volatile("addl %2,%0\n"
13147 +
13148 +#ifdef CONFIG_PAX_REFCOUNT
13149 + "jno 0f\n"
13150 + "subl %2,%0\n"
13151 + "int $4\n0:\n"
13152 + _ASM_EXTABLE(0b, 0b)
13153 +#endif
13154 +
13155 + : "=r" (new)
13156 + : "0" (c), "ir" (a));
13157 +
13158 + old = atomic_cmpxchg(v, c, new);
13159 if (likely(old == c))
13160 break;
13161 c = old;
13162 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
13163 }
13164
13165 /**
13166 + * atomic_inc_not_zero_hint - increment if not null
13167 + * @v: pointer of type atomic_t
13168 + * @hint: probable value of the atomic before the increment
13169 + *
13170 + * This version of atomic_inc_not_zero() gives a hint of probable
13171 + * value of the atomic. This helps processor to not read the memory
13172 + * before doing the atomic read/modify/write cycle, lowering
13173 + * number of bus transactions on some arches.
13174 + *
13175 + * Returns: 0 if increment was not done, 1 otherwise.
13176 + */
13177 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
13178 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
13179 +{
13180 + int val, c = hint, new;
13181 +
13182 + /* sanity test, should be removed by compiler if hint is a constant */
13183 + if (!hint)
13184 + return __atomic_add_unless(v, 1, 0);
13185 +
13186 + do {
13187 + asm volatile("incl %0\n"
13188 +
13189 +#ifdef CONFIG_PAX_REFCOUNT
13190 + "jno 0f\n"
13191 + "decl %0\n"
13192 + "int $4\n0:\n"
13193 + _ASM_EXTABLE(0b, 0b)
13194 +#endif
13195 +
13196 + : "=r" (new)
13197 + : "0" (c));
13198 +
13199 + val = atomic_cmpxchg(v, c, new);
13200 + if (val == c)
13201 + return 1;
13202 + c = val;
13203 + } while (c);
13204 +
13205 + return 0;
13206 +}
13207 +
13208 +/**
13209 * atomic_inc_short - increment of a short integer
13210 * @v: pointer to type int
13211 *
13212 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
13213 #endif
13214
13215 /* These are x86-specific, used by some header files */
13216 -#define atomic_clear_mask(mask, addr) \
13217 - asm volatile(LOCK_PREFIX "andl %0,%1" \
13218 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
13219 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
13220 +{
13221 + asm volatile(LOCK_PREFIX "andl %1,%0"
13222 + : "+m" (v->counter)
13223 + : "r" (~(mask))
13224 + : "memory");
13225 +}
13226
13227 -#define atomic_set_mask(mask, addr) \
13228 - asm volatile(LOCK_PREFIX "orl %0,%1" \
13229 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
13230 - : "memory")
13231 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
13232 +{
13233 + asm volatile(LOCK_PREFIX "andl %1,%0"
13234 + : "+m" (v->counter)
13235 + : "r" (~(mask))
13236 + : "memory");
13237 +}
13238 +
13239 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
13240 +{
13241 + asm volatile(LOCK_PREFIX "orl %1,%0"
13242 + : "+m" (v->counter)
13243 + : "r" (mask)
13244 + : "memory");
13245 +}
13246 +
13247 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
13248 +{
13249 + asm volatile(LOCK_PREFIX "orl %1,%0"
13250 + : "+m" (v->counter)
13251 + : "r" (mask)
13252 + : "memory");
13253 +}
13254
13255 /* Atomic operations are already serializing on x86 */
13256 #define smp_mb__before_atomic_dec() barrier()
13257 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
13258 index b154de7..aadebd8 100644
13259 --- a/arch/x86/include/asm/atomic64_32.h
13260 +++ b/arch/x86/include/asm/atomic64_32.h
13261 @@ -12,6 +12,14 @@ typedef struct {
13262 u64 __aligned(8) counter;
13263 } atomic64_t;
13264
13265 +#ifdef CONFIG_PAX_REFCOUNT
13266 +typedef struct {
13267 + u64 __aligned(8) counter;
13268 +} atomic64_unchecked_t;
13269 +#else
13270 +typedef atomic64_t atomic64_unchecked_t;
13271 +#endif
13272 +
13273 #define ATOMIC64_INIT(val) { (val) }
13274
13275 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
13276 @@ -37,21 +45,31 @@ typedef struct {
13277 ATOMIC64_DECL_ONE(sym##_386)
13278
13279 ATOMIC64_DECL_ONE(add_386);
13280 +ATOMIC64_DECL_ONE(add_unchecked_386);
13281 ATOMIC64_DECL_ONE(sub_386);
13282 +ATOMIC64_DECL_ONE(sub_unchecked_386);
13283 ATOMIC64_DECL_ONE(inc_386);
13284 +ATOMIC64_DECL_ONE(inc_unchecked_386);
13285 ATOMIC64_DECL_ONE(dec_386);
13286 +ATOMIC64_DECL_ONE(dec_unchecked_386);
13287 #endif
13288
13289 #define alternative_atomic64(f, out, in...) \
13290 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
13291
13292 ATOMIC64_DECL(read);
13293 +ATOMIC64_DECL(read_unchecked);
13294 ATOMIC64_DECL(set);
13295 +ATOMIC64_DECL(set_unchecked);
13296 ATOMIC64_DECL(xchg);
13297 ATOMIC64_DECL(add_return);
13298 +ATOMIC64_DECL(add_return_unchecked);
13299 ATOMIC64_DECL(sub_return);
13300 +ATOMIC64_DECL(sub_return_unchecked);
13301 ATOMIC64_DECL(inc_return);
13302 +ATOMIC64_DECL(inc_return_unchecked);
13303 ATOMIC64_DECL(dec_return);
13304 +ATOMIC64_DECL(dec_return_unchecked);
13305 ATOMIC64_DECL(dec_if_positive);
13306 ATOMIC64_DECL(inc_not_zero);
13307 ATOMIC64_DECL(add_unless);
13308 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
13309 }
13310
13311 /**
13312 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
13313 + * @p: pointer to type atomic64_unchecked_t
13314 + * @o: expected value
13315 + * @n: new value
13316 + *
13317 + * Atomically sets @v to @n if it was equal to @o and returns
13318 + * the old value.
13319 + */
13320 +
13321 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
13322 +{
13323 + return cmpxchg64(&v->counter, o, n);
13324 +}
13325 +
13326 +/**
13327 * atomic64_xchg - xchg atomic64 variable
13328 * @v: pointer to type atomic64_t
13329 * @n: value to assign
13330 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
13331 }
13332
13333 /**
13334 + * atomic64_set_unchecked - set atomic64 variable
13335 + * @v: pointer to type atomic64_unchecked_t
13336 + * @n: value to assign
13337 + *
13338 + * Atomically sets the value of @v to @n.
13339 + */
13340 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
13341 +{
13342 + unsigned high = (unsigned)(i >> 32);
13343 + unsigned low = (unsigned)i;
13344 + alternative_atomic64(set, /* no output */,
13345 + "S" (v), "b" (low), "c" (high)
13346 + : "eax", "edx", "memory");
13347 +}
13348 +
13349 +/**
13350 * atomic64_read - read atomic64 variable
13351 * @v: pointer to type atomic64_t
13352 *
13353 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
13354 }
13355
13356 /**
13357 + * atomic64_read_unchecked - read atomic64 variable
13358 + * @v: pointer to type atomic64_unchecked_t
13359 + *
13360 + * Atomically reads the value of @v and returns it.
13361 + */
13362 +static inline long long atomic64_read_unchecked(atomic64_unchecked_t *v)
13363 +{
13364 + long long r;
13365 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
13366 + return r;
13367 + }
13368 +
13369 +/**
13370 * atomic64_add_return - add and return
13371 * @i: integer value to add
13372 * @v: pointer to type atomic64_t
13373 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
13374 return i;
13375 }
13376
13377 +/**
13378 + * atomic64_add_return_unchecked - add and return
13379 + * @i: integer value to add
13380 + * @v: pointer to type atomic64_unchecked_t
13381 + *
13382 + * Atomically adds @i to @v and returns @i + *@v
13383 + */
13384 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
13385 +{
13386 + alternative_atomic64(add_return_unchecked,
13387 + ASM_OUTPUT2("+A" (i), "+c" (v)),
13388 + ASM_NO_INPUT_CLOBBER("memory"));
13389 + return i;
13390 +}
13391 +
13392 /*
13393 * Other variants with different arithmetic operators:
13394 */
13395 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
13396 return a;
13397 }
13398
13399 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
13400 +{
13401 + long long a;
13402 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
13403 + "S" (v) : "memory", "ecx");
13404 + return a;
13405 +}
13406 +
13407 static inline long long atomic64_dec_return(atomic64_t *v)
13408 {
13409 long long a;
13410 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
13411 }
13412
13413 /**
13414 + * atomic64_add_unchecked - add integer to atomic64 variable
13415 + * @i: integer value to add
13416 + * @v: pointer to type atomic64_unchecked_t
13417 + *
13418 + * Atomically adds @i to @v.
13419 + */
13420 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
13421 +{
13422 + __alternative_atomic64(add_unchecked, add_return_unchecked,
13423 + ASM_OUTPUT2("+A" (i), "+c" (v)),
13424 + ASM_NO_INPUT_CLOBBER("memory"));
13425 + return i;
13426 +}
13427 +
13428 +/**
13429 * atomic64_sub - subtract the atomic64 variable
13430 * @i: integer value to subtract
13431 * @v: pointer to type atomic64_t
13432 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
13433 index 0e1cbfc..5623683 100644
13434 --- a/arch/x86/include/asm/atomic64_64.h
13435 +++ b/arch/x86/include/asm/atomic64_64.h
13436 @@ -18,7 +18,19 @@
13437 */
13438 static inline long atomic64_read(const atomic64_t *v)
13439 {
13440 - return (*(volatile long *)&(v)->counter);
13441 + return (*(volatile const long *)&(v)->counter);
13442 +}
13443 +
13444 +/**
13445 + * atomic64_read_unchecked - read atomic64 variable
13446 + * @v: pointer of type atomic64_unchecked_t
13447 + *
13448 + * Atomically reads the value of @v.
13449 + * Doesn't imply a read memory barrier.
13450 + */
13451 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
13452 +{
13453 + return (*(volatile const long *)&(v)->counter);
13454 }
13455
13456 /**
13457 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
13458 }
13459
13460 /**
13461 + * atomic64_set_unchecked - set atomic64 variable
13462 + * @v: pointer to type atomic64_unchecked_t
13463 + * @i: required value
13464 + *
13465 + * Atomically sets the value of @v to @i.
13466 + */
13467 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
13468 +{
13469 + v->counter = i;
13470 +}
13471 +
13472 +/**
13473 * atomic64_add - add integer to atomic64 variable
13474 * @i: integer value to add
13475 * @v: pointer to type atomic64_t
13476 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
13477 */
13478 static inline void atomic64_add(long i, atomic64_t *v)
13479 {
13480 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
13481 +
13482 +#ifdef CONFIG_PAX_REFCOUNT
13483 + "jno 0f\n"
13484 + LOCK_PREFIX "subq %1,%0\n"
13485 + "int $4\n0:\n"
13486 + _ASM_EXTABLE(0b, 0b)
13487 +#endif
13488 +
13489 + : "=m" (v->counter)
13490 + : "er" (i), "m" (v->counter));
13491 +}
13492 +
13493 +/**
13494 + * atomic64_add_unchecked - add integer to atomic64 variable
13495 + * @i: integer value to add
13496 + * @v: pointer to type atomic64_unchecked_t
13497 + *
13498 + * Atomically adds @i to @v.
13499 + */
13500 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
13501 +{
13502 asm volatile(LOCK_PREFIX "addq %1,%0"
13503 : "=m" (v->counter)
13504 : "er" (i), "m" (v->counter));
13505 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
13506 */
13507 static inline void atomic64_sub(long i, atomic64_t *v)
13508 {
13509 - asm volatile(LOCK_PREFIX "subq %1,%0"
13510 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
13511 +
13512 +#ifdef CONFIG_PAX_REFCOUNT
13513 + "jno 0f\n"
13514 + LOCK_PREFIX "addq %1,%0\n"
13515 + "int $4\n0:\n"
13516 + _ASM_EXTABLE(0b, 0b)
13517 +#endif
13518 +
13519 + : "=m" (v->counter)
13520 + : "er" (i), "m" (v->counter));
13521 +}
13522 +
13523 +/**
13524 + * atomic64_sub_unchecked - subtract the atomic64 variable
13525 + * @i: integer value to subtract
13526 + * @v: pointer to type atomic64_unchecked_t
13527 + *
13528 + * Atomically subtracts @i from @v.
13529 + */
13530 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
13531 +{
13532 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
13533 : "=m" (v->counter)
13534 : "er" (i), "m" (v->counter));
13535 }
13536 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
13537 {
13538 unsigned char c;
13539
13540 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
13541 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
13542 +
13543 +#ifdef CONFIG_PAX_REFCOUNT
13544 + "jno 0f\n"
13545 + LOCK_PREFIX "addq %2,%0\n"
13546 + "int $4\n0:\n"
13547 + _ASM_EXTABLE(0b, 0b)
13548 +#endif
13549 +
13550 + "sete %1\n"
13551 : "=m" (v->counter), "=qm" (c)
13552 : "er" (i), "m" (v->counter) : "memory");
13553 return c;
13554 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
13555 */
13556 static inline void atomic64_inc(atomic64_t *v)
13557 {
13558 + asm volatile(LOCK_PREFIX "incq %0\n"
13559 +
13560 +#ifdef CONFIG_PAX_REFCOUNT
13561 + "jno 0f\n"
13562 + LOCK_PREFIX "decq %0\n"
13563 + "int $4\n0:\n"
13564 + _ASM_EXTABLE(0b, 0b)
13565 +#endif
13566 +
13567 + : "=m" (v->counter)
13568 + : "m" (v->counter));
13569 +}
13570 +
13571 +/**
13572 + * atomic64_inc_unchecked - increment atomic64 variable
13573 + * @v: pointer to type atomic64_unchecked_t
13574 + *
13575 + * Atomically increments @v by 1.
13576 + */
13577 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
13578 +{
13579 asm volatile(LOCK_PREFIX "incq %0"
13580 : "=m" (v->counter)
13581 : "m" (v->counter));
13582 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
13583 */
13584 static inline void atomic64_dec(atomic64_t *v)
13585 {
13586 - asm volatile(LOCK_PREFIX "decq %0"
13587 + asm volatile(LOCK_PREFIX "decq %0\n"
13588 +
13589 +#ifdef CONFIG_PAX_REFCOUNT
13590 + "jno 0f\n"
13591 + LOCK_PREFIX "incq %0\n"
13592 + "int $4\n0:\n"
13593 + _ASM_EXTABLE(0b, 0b)
13594 +#endif
13595 +
13596 + : "=m" (v->counter)
13597 + : "m" (v->counter));
13598 +}
13599 +
13600 +/**
13601 + * atomic64_dec_unchecked - decrement atomic64 variable
13602 + * @v: pointer to type atomic64_t
13603 + *
13604 + * Atomically decrements @v by 1.
13605 + */
13606 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
13607 +{
13608 + asm volatile(LOCK_PREFIX "decq %0\n"
13609 : "=m" (v->counter)
13610 : "m" (v->counter));
13611 }
13612 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
13613 {
13614 unsigned char c;
13615
13616 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
13617 + asm volatile(LOCK_PREFIX "decq %0\n"
13618 +
13619 +#ifdef CONFIG_PAX_REFCOUNT
13620 + "jno 0f\n"
13621 + LOCK_PREFIX "incq %0\n"
13622 + "int $4\n0:\n"
13623 + _ASM_EXTABLE(0b, 0b)
13624 +#endif
13625 +
13626 + "sete %1\n"
13627 : "=m" (v->counter), "=qm" (c)
13628 : "m" (v->counter) : "memory");
13629 return c != 0;
13630 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
13631 {
13632 unsigned char c;
13633
13634 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
13635 + asm volatile(LOCK_PREFIX "incq %0\n"
13636 +
13637 +#ifdef CONFIG_PAX_REFCOUNT
13638 + "jno 0f\n"
13639 + LOCK_PREFIX "decq %0\n"
13640 + "int $4\n0:\n"
13641 + _ASM_EXTABLE(0b, 0b)
13642 +#endif
13643 +
13644 + "sete %1\n"
13645 : "=m" (v->counter), "=qm" (c)
13646 : "m" (v->counter) : "memory");
13647 return c != 0;
13648 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
13649 {
13650 unsigned char c;
13651
13652 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
13653 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
13654 +
13655 +#ifdef CONFIG_PAX_REFCOUNT
13656 + "jno 0f\n"
13657 + LOCK_PREFIX "subq %2,%0\n"
13658 + "int $4\n0:\n"
13659 + _ASM_EXTABLE(0b, 0b)
13660 +#endif
13661 +
13662 + "sets %1\n"
13663 : "=m" (v->counter), "=qm" (c)
13664 : "er" (i), "m" (v->counter) : "memory");
13665 return c;
13666 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
13667 */
13668 static inline long atomic64_add_return(long i, atomic64_t *v)
13669 {
13670 + return i + xadd_check_overflow(&v->counter, i);
13671 +}
13672 +
13673 +/**
13674 + * atomic64_add_return_unchecked - add and return
13675 + * @i: integer value to add
13676 + * @v: pointer to type atomic64_unchecked_t
13677 + *
13678 + * Atomically adds @i to @v and returns @i + @v
13679 + */
13680 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
13681 +{
13682 return i + xadd(&v->counter, i);
13683 }
13684
13685 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
13686 }
13687
13688 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
13689 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
13690 +{
13691 + return atomic64_add_return_unchecked(1, v);
13692 +}
13693 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
13694
13695 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
13696 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
13697 return cmpxchg(&v->counter, old, new);
13698 }
13699
13700 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
13701 +{
13702 + return cmpxchg(&v->counter, old, new);
13703 +}
13704 +
13705 static inline long atomic64_xchg(atomic64_t *v, long new)
13706 {
13707 return xchg(&v->counter, new);
13708 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
13709 */
13710 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
13711 {
13712 - long c, old;
13713 + long c, old, new;
13714 c = atomic64_read(v);
13715 for (;;) {
13716 - if (unlikely(c == (u)))
13717 + if (unlikely(c == u))
13718 break;
13719 - old = atomic64_cmpxchg((v), c, c + (a));
13720 +
13721 + asm volatile("add %2,%0\n"
13722 +
13723 +#ifdef CONFIG_PAX_REFCOUNT
13724 + "jno 0f\n"
13725 + "sub %2,%0\n"
13726 + "int $4\n0:\n"
13727 + _ASM_EXTABLE(0b, 0b)
13728 +#endif
13729 +
13730 + : "=r" (new)
13731 + : "0" (c), "ir" (a));
13732 +
13733 + old = atomic64_cmpxchg(v, c, new);
13734 if (likely(old == c))
13735 break;
13736 c = old;
13737 }
13738 - return c != (u);
13739 + return c != u;
13740 }
13741
13742 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
13743 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
13744 index 6dfd019..28e188d 100644
13745 --- a/arch/x86/include/asm/bitops.h
13746 +++ b/arch/x86/include/asm/bitops.h
13747 @@ -40,7 +40,7 @@
13748 * a mask operation on a byte.
13749 */
13750 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
13751 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
13752 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
13753 #define CONST_MASK(nr) (1 << ((nr) & 7))
13754
13755 /**
13756 @@ -486,7 +486,7 @@ static inline int fls(int x)
13757 * at position 64.
13758 */
13759 #ifdef CONFIG_X86_64
13760 -static __always_inline int fls64(__u64 x)
13761 +static __always_inline long fls64(__u64 x)
13762 {
13763 int bitpos = -1;
13764 /*
13765 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
13766 index 4fa687a..60f2d39 100644
13767 --- a/arch/x86/include/asm/boot.h
13768 +++ b/arch/x86/include/asm/boot.h
13769 @@ -6,10 +6,15 @@
13770 #include <uapi/asm/boot.h>
13771
13772 /* Physical address where kernel should be loaded. */
13773 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
13774 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
13775 + (CONFIG_PHYSICAL_ALIGN - 1)) \
13776 & ~(CONFIG_PHYSICAL_ALIGN - 1))
13777
13778 +#ifndef __ASSEMBLY__
13779 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
13780 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
13781 +#endif
13782 +
13783 /* Minimum kernel alignment, as a power of two */
13784 #ifdef CONFIG_X86_64
13785 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
13786 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
13787 index 48f99f1..d78ebf9 100644
13788 --- a/arch/x86/include/asm/cache.h
13789 +++ b/arch/x86/include/asm/cache.h
13790 @@ -5,12 +5,13 @@
13791
13792 /* L1 cache line size */
13793 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
13794 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
13795 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
13796
13797 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
13798 +#define __read_only __attribute__((__section__(".data..read_only")))
13799
13800 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
13801 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
13802 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
13803
13804 #ifdef CONFIG_X86_VSMP
13805 #ifdef CONFIG_SMP
13806 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
13807 index 9863ee3..4a1f8e1 100644
13808 --- a/arch/x86/include/asm/cacheflush.h
13809 +++ b/arch/x86/include/asm/cacheflush.h
13810 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
13811 unsigned long pg_flags = pg->flags & _PGMT_MASK;
13812
13813 if (pg_flags == _PGMT_DEFAULT)
13814 - return -1;
13815 + return ~0UL;
13816 else if (pg_flags == _PGMT_WC)
13817 return _PAGE_CACHE_WC;
13818 else if (pg_flags == _PGMT_UC_MINUS)
13819 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
13820 index 46fc474..b02b0f9 100644
13821 --- a/arch/x86/include/asm/checksum_32.h
13822 +++ b/arch/x86/include/asm/checksum_32.h
13823 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
13824 int len, __wsum sum,
13825 int *src_err_ptr, int *dst_err_ptr);
13826
13827 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
13828 + int len, __wsum sum,
13829 + int *src_err_ptr, int *dst_err_ptr);
13830 +
13831 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
13832 + int len, __wsum sum,
13833 + int *src_err_ptr, int *dst_err_ptr);
13834 +
13835 /*
13836 * Note: when you get a NULL pointer exception here this means someone
13837 * passed in an incorrect kernel address to one of these functions.
13838 @@ -50,7 +58,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
13839 int *err_ptr)
13840 {
13841 might_sleep();
13842 - return csum_partial_copy_generic((__force void *)src, dst,
13843 + return csum_partial_copy_generic_from_user((__force void *)src, dst,
13844 len, sum, err_ptr, NULL);
13845 }
13846
13847 @@ -178,7 +186,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
13848 {
13849 might_sleep();
13850 if (access_ok(VERIFY_WRITE, dst, len))
13851 - return csum_partial_copy_generic(src, (__force void *)dst,
13852 + return csum_partial_copy_generic_to_user(src, (__force void *)dst,
13853 len, sum, NULL, err_ptr);
13854
13855 if (len)
13856 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
13857 index d47786a..ce1b05d 100644
13858 --- a/arch/x86/include/asm/cmpxchg.h
13859 +++ b/arch/x86/include/asm/cmpxchg.h
13860 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
13861 __compiletime_error("Bad argument size for cmpxchg");
13862 extern void __xadd_wrong_size(void)
13863 __compiletime_error("Bad argument size for xadd");
13864 +extern void __xadd_check_overflow_wrong_size(void)
13865 + __compiletime_error("Bad argument size for xadd_check_overflow");
13866 extern void __add_wrong_size(void)
13867 __compiletime_error("Bad argument size for add");
13868 +extern void __add_check_overflow_wrong_size(void)
13869 + __compiletime_error("Bad argument size for add_check_overflow");
13870
13871 /*
13872 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
13873 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
13874 __ret; \
13875 })
13876
13877 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
13878 + ({ \
13879 + __typeof__ (*(ptr)) __ret = (arg); \
13880 + switch (sizeof(*(ptr))) { \
13881 + case __X86_CASE_L: \
13882 + asm volatile (lock #op "l %0, %1\n" \
13883 + "jno 0f\n" \
13884 + "mov %0,%1\n" \
13885 + "int $4\n0:\n" \
13886 + _ASM_EXTABLE(0b, 0b) \
13887 + : "+r" (__ret), "+m" (*(ptr)) \
13888 + : : "memory", "cc"); \
13889 + break; \
13890 + case __X86_CASE_Q: \
13891 + asm volatile (lock #op "q %q0, %1\n" \
13892 + "jno 0f\n" \
13893 + "mov %0,%1\n" \
13894 + "int $4\n0:\n" \
13895 + _ASM_EXTABLE(0b, 0b) \
13896 + : "+r" (__ret), "+m" (*(ptr)) \
13897 + : : "memory", "cc"); \
13898 + break; \
13899 + default: \
13900 + __ ## op ## _check_overflow_wrong_size(); \
13901 + } \
13902 + __ret; \
13903 + })
13904 +
13905 /*
13906 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
13907 * Since this is generally used to protect other memory information, we
13908 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
13909 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
13910 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
13911
13912 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
13913 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
13914 +
13915 #define __add(ptr, inc, lock) \
13916 ({ \
13917 __typeof__ (*(ptr)) __ret = (inc); \
13918 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
13919 index 59c6c40..5e0b22c 100644
13920 --- a/arch/x86/include/asm/compat.h
13921 +++ b/arch/x86/include/asm/compat.h
13922 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
13923 typedef u32 compat_uint_t;
13924 typedef u32 compat_ulong_t;
13925 typedef u64 __attribute__((aligned(4))) compat_u64;
13926 -typedef u32 compat_uptr_t;
13927 +typedef u32 __user compat_uptr_t;
13928
13929 struct compat_timespec {
13930 compat_time_t tv_sec;
13931 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
13932 index e99ac27..10d834e 100644
13933 --- a/arch/x86/include/asm/cpufeature.h
13934 +++ b/arch/x86/include/asm/cpufeature.h
13935 @@ -203,7 +203,7 @@
13936 #define X86_FEATURE_DECODEASSISTS (8*32+12) /* AMD Decode Assists support */
13937 #define X86_FEATURE_PAUSEFILTER (8*32+13) /* AMD filtered pause intercept */
13938 #define X86_FEATURE_PFTHRESHOLD (8*32+14) /* AMD pause filter threshold */
13939 -
13940 +#define X86_FEATURE_STRONGUDEREF (8*32+31) /* PaX PCID based strong UDEREF */
13941
13942 /* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx), word 9 */
13943 #define X86_FEATURE_FSGSBASE (9*32+ 0) /* {RD/WR}{FS/GS}BASE instructions*/
13944 @@ -211,7 +211,7 @@
13945 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
13946 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
13947 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
13948 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
13949 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
13950 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
13951 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
13952 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
13953 @@ -353,6 +353,7 @@ extern const char * const x86_power_flags[32];
13954 #undef cpu_has_centaur_mcr
13955 #define cpu_has_centaur_mcr 0
13956
13957 +#define cpu_has_pcid boot_cpu_has(X86_FEATURE_PCID)
13958 #endif /* CONFIG_X86_64 */
13959
13960 #if __GNUC__ >= 4
13961 @@ -394,7 +395,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
13962 ".section .discard,\"aw\",@progbits\n"
13963 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
13964 ".previous\n"
13965 - ".section .altinstr_replacement,\"ax\"\n"
13966 + ".section .altinstr_replacement,\"a\"\n"
13967 "3: movb $1,%0\n"
13968 "4:\n"
13969 ".previous\n"
13970 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
13971 index 8bf1c06..b6ae785 100644
13972 --- a/arch/x86/include/asm/desc.h
13973 +++ b/arch/x86/include/asm/desc.h
13974 @@ -4,6 +4,7 @@
13975 #include <asm/desc_defs.h>
13976 #include <asm/ldt.h>
13977 #include <asm/mmu.h>
13978 +#include <asm/pgtable.h>
13979
13980 #include <linux/smp.h>
13981 #include <linux/percpu.h>
13982 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13983
13984 desc->type = (info->read_exec_only ^ 1) << 1;
13985 desc->type |= info->contents << 2;
13986 + desc->type |= info->seg_not_present ^ 1;
13987
13988 desc->s = 1;
13989 desc->dpl = 0x3;
13990 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
13991 }
13992
13993 extern struct desc_ptr idt_descr;
13994 -extern gate_desc idt_table[];
13995 extern struct desc_ptr nmi_idt_descr;
13996 -extern gate_desc nmi_idt_table[];
13997 -
13998 -struct gdt_page {
13999 - struct desc_struct gdt[GDT_ENTRIES];
14000 -} __attribute__((aligned(PAGE_SIZE)));
14001 -
14002 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
14003 +extern gate_desc idt_table[256];
14004 +extern gate_desc nmi_idt_table[256];
14005
14006 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
14007 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
14008 {
14009 - return per_cpu(gdt_page, cpu).gdt;
14010 + return cpu_gdt_table[cpu];
14011 }
14012
14013 #ifdef CONFIG_X86_64
14014 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
14015 unsigned long base, unsigned dpl, unsigned flags,
14016 unsigned short seg)
14017 {
14018 - gate->a = (seg << 16) | (base & 0xffff);
14019 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
14020 + gate->gate.offset_low = base;
14021 + gate->gate.seg = seg;
14022 + gate->gate.reserved = 0;
14023 + gate->gate.type = type;
14024 + gate->gate.s = 0;
14025 + gate->gate.dpl = dpl;
14026 + gate->gate.p = 1;
14027 + gate->gate.offset_high = base >> 16;
14028 }
14029
14030 #endif
14031 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
14032
14033 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
14034 {
14035 + pax_open_kernel();
14036 memcpy(&idt[entry], gate, sizeof(*gate));
14037 + pax_close_kernel();
14038 }
14039
14040 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
14041 {
14042 + pax_open_kernel();
14043 memcpy(&ldt[entry], desc, 8);
14044 + pax_close_kernel();
14045 }
14046
14047 static inline void
14048 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
14049 default: size = sizeof(*gdt); break;
14050 }
14051
14052 + pax_open_kernel();
14053 memcpy(&gdt[entry], desc, size);
14054 + pax_close_kernel();
14055 }
14056
14057 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
14058 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
14059
14060 static inline void native_load_tr_desc(void)
14061 {
14062 + pax_open_kernel();
14063 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
14064 + pax_close_kernel();
14065 }
14066
14067 static inline void native_load_gdt(const struct desc_ptr *dtr)
14068 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
14069 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
14070 unsigned int i;
14071
14072 + pax_open_kernel();
14073 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
14074 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
14075 + pax_close_kernel();
14076 }
14077
14078 #define _LDT_empty(info) \
14079 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
14080 preempt_enable();
14081 }
14082
14083 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
14084 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
14085 {
14086 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
14087 }
14088 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
14089 }
14090
14091 #ifdef CONFIG_X86_64
14092 -static inline void set_nmi_gate(int gate, void *addr)
14093 +static inline void set_nmi_gate(int gate, const void *addr)
14094 {
14095 gate_desc s;
14096
14097 @@ -320,7 +333,7 @@ static inline void set_nmi_gate(int gate, void *addr)
14098 }
14099 #endif
14100
14101 -static inline void _set_gate(int gate, unsigned type, void *addr,
14102 +static inline void _set_gate(int gate, unsigned type, const void *addr,
14103 unsigned dpl, unsigned ist, unsigned seg)
14104 {
14105 gate_desc s;
14106 @@ -339,7 +352,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
14107 * Pentium F0 0F bugfix can have resulted in the mapped
14108 * IDT being write-protected.
14109 */
14110 -static inline void set_intr_gate(unsigned int n, void *addr)
14111 +static inline void set_intr_gate(unsigned int n, const void *addr)
14112 {
14113 BUG_ON((unsigned)n > 0xFF);
14114 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
14115 @@ -369,19 +382,19 @@ static inline void alloc_intr_gate(unsigned int n, void *addr)
14116 /*
14117 * This routine sets up an interrupt gate at directory privilege level 3.
14118 */
14119 -static inline void set_system_intr_gate(unsigned int n, void *addr)
14120 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
14121 {
14122 BUG_ON((unsigned)n > 0xFF);
14123 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
14124 }
14125
14126 -static inline void set_system_trap_gate(unsigned int n, void *addr)
14127 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
14128 {
14129 BUG_ON((unsigned)n > 0xFF);
14130 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
14131 }
14132
14133 -static inline void set_trap_gate(unsigned int n, void *addr)
14134 +static inline void set_trap_gate(unsigned int n, const void *addr)
14135 {
14136 BUG_ON((unsigned)n > 0xFF);
14137 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
14138 @@ -390,19 +403,31 @@ static inline void set_trap_gate(unsigned int n, void *addr)
14139 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
14140 {
14141 BUG_ON((unsigned)n > 0xFF);
14142 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
14143 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
14144 }
14145
14146 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
14147 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
14148 {
14149 BUG_ON((unsigned)n > 0xFF);
14150 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
14151 }
14152
14153 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
14154 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
14155 {
14156 BUG_ON((unsigned)n > 0xFF);
14157 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
14158 }
14159
14160 +#ifdef CONFIG_X86_32
14161 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
14162 +{
14163 + struct desc_struct d;
14164 +
14165 + if (likely(limit))
14166 + limit = (limit - 1UL) >> PAGE_SHIFT;
14167 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
14168 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
14169 +}
14170 +#endif
14171 +
14172 #endif /* _ASM_X86_DESC_H */
14173 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
14174 index 278441f..b95a174 100644
14175 --- a/arch/x86/include/asm/desc_defs.h
14176 +++ b/arch/x86/include/asm/desc_defs.h
14177 @@ -31,6 +31,12 @@ struct desc_struct {
14178 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
14179 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
14180 };
14181 + struct {
14182 + u16 offset_low;
14183 + u16 seg;
14184 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
14185 + unsigned offset_high: 16;
14186 + } gate;
14187 };
14188 } __attribute__((packed));
14189
14190 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
14191 index ced283a..ffe04cc 100644
14192 --- a/arch/x86/include/asm/div64.h
14193 +++ b/arch/x86/include/asm/div64.h
14194 @@ -39,7 +39,7 @@
14195 __mod; \
14196 })
14197
14198 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
14199 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
14200 {
14201 union {
14202 u64 v64;
14203 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
14204 index 9c999c1..3860cb8 100644
14205 --- a/arch/x86/include/asm/elf.h
14206 +++ b/arch/x86/include/asm/elf.h
14207 @@ -243,7 +243,25 @@ extern int force_personality32;
14208 the loader. We need to make sure that it is out of the way of the program
14209 that it will "exec", and that there is sufficient room for the brk. */
14210
14211 +#ifdef CONFIG_PAX_SEGMEXEC
14212 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
14213 +#else
14214 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
14215 +#endif
14216 +
14217 +#ifdef CONFIG_PAX_ASLR
14218 +#ifdef CONFIG_X86_32
14219 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
14220 +
14221 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
14222 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
14223 +#else
14224 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
14225 +
14226 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
14227 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
14228 +#endif
14229 +#endif
14230
14231 /* This yields a mask that user programs can use to figure out what
14232 instruction set this CPU supports. This could be done in user space,
14233 @@ -296,16 +314,12 @@ do { \
14234
14235 #define ARCH_DLINFO \
14236 do { \
14237 - if (vdso_enabled) \
14238 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
14239 - (unsigned long)current->mm->context.vdso); \
14240 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
14241 } while (0)
14242
14243 #define ARCH_DLINFO_X32 \
14244 do { \
14245 - if (vdso_enabled) \
14246 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
14247 - (unsigned long)current->mm->context.vdso); \
14248 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
14249 } while (0)
14250
14251 #define AT_SYSINFO 32
14252 @@ -320,7 +334,7 @@ else \
14253
14254 #endif /* !CONFIG_X86_32 */
14255
14256 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
14257 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
14258
14259 #define VDSO_ENTRY \
14260 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
14261 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
14262 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
14263 #define compat_arch_setup_additional_pages syscall32_setup_pages
14264
14265 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
14266 -#define arch_randomize_brk arch_randomize_brk
14267 -
14268 /*
14269 * True on X86_32 or when emulating IA32 on X86_64
14270 */
14271 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
14272 index 75ce3f4..882e801 100644
14273 --- a/arch/x86/include/asm/emergency-restart.h
14274 +++ b/arch/x86/include/asm/emergency-restart.h
14275 @@ -13,6 +13,6 @@ enum reboot_type {
14276
14277 extern enum reboot_type reboot_type;
14278
14279 -extern void machine_emergency_restart(void);
14280 +extern void machine_emergency_restart(void) __noreturn;
14281
14282 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
14283 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
14284 index e25cc33..7d3ec01 100644
14285 --- a/arch/x86/include/asm/fpu-internal.h
14286 +++ b/arch/x86/include/asm/fpu-internal.h
14287 @@ -126,8 +126,11 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
14288 #define user_insn(insn, output, input...) \
14289 ({ \
14290 int err; \
14291 + pax_open_userland(); \
14292 asm volatile(ASM_STAC "\n" \
14293 - "1:" #insn "\n\t" \
14294 + "1:" \
14295 + __copyuser_seg \
14296 + #insn "\n\t" \
14297 "2: " ASM_CLAC "\n" \
14298 ".section .fixup,\"ax\"\n" \
14299 "3: movl $-1,%[err]\n" \
14300 @@ -136,6 +139,7 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
14301 _ASM_EXTABLE(1b, 3b) \
14302 : [err] "=r" (err), output \
14303 : "0"(0), input); \
14304 + pax_close_userland(); \
14305 err; \
14306 })
14307
14308 @@ -300,7 +304,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
14309 "emms\n\t" /* clear stack tags */
14310 "fildl %P[addr]", /* set F?P to defined value */
14311 X86_FEATURE_FXSAVE_LEAK,
14312 - [addr] "m" (tsk->thread.fpu.has_fpu));
14313 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
14314
14315 return fpu_restore_checking(&tsk->thread.fpu);
14316 }
14317 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
14318 index be27ba1..04a8801 100644
14319 --- a/arch/x86/include/asm/futex.h
14320 +++ b/arch/x86/include/asm/futex.h
14321 @@ -12,6 +12,7 @@
14322 #include <asm/smap.h>
14323
14324 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
14325 + typecheck(u32 __user *, uaddr); \
14326 asm volatile("\t" ASM_STAC "\n" \
14327 "1:\t" insn "\n" \
14328 "2:\t" ASM_CLAC "\n" \
14329 @@ -20,15 +21,16 @@
14330 "\tjmp\t2b\n" \
14331 "\t.previous\n" \
14332 _ASM_EXTABLE(1b, 3b) \
14333 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
14334 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
14335 : "i" (-EFAULT), "0" (oparg), "1" (0))
14336
14337 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
14338 + typecheck(u32 __user *, uaddr); \
14339 asm volatile("\t" ASM_STAC "\n" \
14340 "1:\tmovl %2, %0\n" \
14341 "\tmovl\t%0, %3\n" \
14342 "\t" insn "\n" \
14343 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
14344 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
14345 "\tjnz\t1b\n" \
14346 "3:\t" ASM_CLAC "\n" \
14347 "\t.section .fixup,\"ax\"\n" \
14348 @@ -38,7 +40,7 @@
14349 _ASM_EXTABLE(1b, 4b) \
14350 _ASM_EXTABLE(2b, 4b) \
14351 : "=&a" (oldval), "=&r" (ret), \
14352 - "+m" (*uaddr), "=&r" (tem) \
14353 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
14354 : "r" (oparg), "i" (-EFAULT), "1" (0))
14355
14356 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
14357 @@ -57,12 +59,13 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
14358
14359 pagefault_disable();
14360
14361 + pax_open_userland();
14362 switch (op) {
14363 case FUTEX_OP_SET:
14364 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
14365 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
14366 break;
14367 case FUTEX_OP_ADD:
14368 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
14369 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
14370 uaddr, oparg);
14371 break;
14372 case FUTEX_OP_OR:
14373 @@ -77,6 +80,7 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
14374 default:
14375 ret = -ENOSYS;
14376 }
14377 + pax_close_userland();
14378
14379 pagefault_enable();
14380
14381 @@ -115,18 +119,20 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
14382 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
14383 return -EFAULT;
14384
14385 + pax_open_userland();
14386 asm volatile("\t" ASM_STAC "\n"
14387 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
14388 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
14389 "2:\t" ASM_CLAC "\n"
14390 "\t.section .fixup, \"ax\"\n"
14391 "3:\tmov %3, %0\n"
14392 "\tjmp 2b\n"
14393 "\t.previous\n"
14394 _ASM_EXTABLE(1b, 3b)
14395 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
14396 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
14397 : "i" (-EFAULT), "r" (newval), "1" (oldval)
14398 : "memory"
14399 );
14400 + pax_close_userland();
14401
14402 *uval = oldval;
14403 return ret;
14404 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
14405 index 1da97ef..9c2ebff 100644
14406 --- a/arch/x86/include/asm/hw_irq.h
14407 +++ b/arch/x86/include/asm/hw_irq.h
14408 @@ -148,8 +148,8 @@ extern void setup_ioapic_dest(void);
14409 extern void enable_IO_APIC(void);
14410
14411 /* Statistics */
14412 -extern atomic_t irq_err_count;
14413 -extern atomic_t irq_mis_count;
14414 +extern atomic_unchecked_t irq_err_count;
14415 +extern atomic_unchecked_t irq_mis_count;
14416
14417 /* EISA */
14418 extern void eisa_set_level_irq(unsigned int irq);
14419 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
14420 index a203659..9889f1c 100644
14421 --- a/arch/x86/include/asm/i8259.h
14422 +++ b/arch/x86/include/asm/i8259.h
14423 @@ -62,7 +62,7 @@ struct legacy_pic {
14424 void (*init)(int auto_eoi);
14425 int (*irq_pending)(unsigned int irq);
14426 void (*make_irq)(unsigned int irq);
14427 -};
14428 +} __do_const;
14429
14430 extern struct legacy_pic *legacy_pic;
14431 extern struct legacy_pic null_legacy_pic;
14432 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
14433 index d8e8eef..1765f78 100644
14434 --- a/arch/x86/include/asm/io.h
14435 +++ b/arch/x86/include/asm/io.h
14436 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
14437 "m" (*(volatile type __force *)addr) barrier); }
14438
14439 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
14440 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
14441 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
14442 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
14443 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
14444
14445 build_mmio_read(__readb, "b", unsigned char, "=q", )
14446 -build_mmio_read(__readw, "w", unsigned short, "=r", )
14447 -build_mmio_read(__readl, "l", unsigned int, "=r", )
14448 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
14449 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
14450
14451 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
14452 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
14453 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
14454 return ioremap_nocache(offset, size);
14455 }
14456
14457 -extern void iounmap(volatile void __iomem *addr);
14458 +extern void iounmap(const volatile void __iomem *addr);
14459
14460 extern void set_iounmap_nonlazy(void);
14461
14462 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
14463
14464 #include <linux/vmalloc.h>
14465
14466 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
14467 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
14468 +{
14469 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
14470 +}
14471 +
14472 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
14473 +{
14474 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
14475 +}
14476 +
14477 /*
14478 * Convert a virtual cached pointer to an uncached pointer
14479 */
14480 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
14481 index bba3cf8..06bc8da 100644
14482 --- a/arch/x86/include/asm/irqflags.h
14483 +++ b/arch/x86/include/asm/irqflags.h
14484 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
14485 sti; \
14486 sysexit
14487
14488 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
14489 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
14490 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
14491 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
14492 +
14493 #else
14494 #define INTERRUPT_RETURN iret
14495 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
14496 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
14497 index 5a6d287..f815789 100644
14498 --- a/arch/x86/include/asm/kprobes.h
14499 +++ b/arch/x86/include/asm/kprobes.h
14500 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
14501 #define RELATIVEJUMP_SIZE 5
14502 #define RELATIVECALL_OPCODE 0xe8
14503 #define RELATIVE_ADDR_SIZE 4
14504 -#define MAX_STACK_SIZE 64
14505 -#define MIN_STACK_SIZE(ADDR) \
14506 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
14507 - THREAD_SIZE - (unsigned long)(ADDR))) \
14508 - ? (MAX_STACK_SIZE) \
14509 - : (((unsigned long)current_thread_info()) + \
14510 - THREAD_SIZE - (unsigned long)(ADDR)))
14511 +#define MAX_STACK_SIZE 64UL
14512 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
14513
14514 #define flush_insn_slot(p) do { } while (0)
14515
14516 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
14517 index 2d89e39..baee879 100644
14518 --- a/arch/x86/include/asm/local.h
14519 +++ b/arch/x86/include/asm/local.h
14520 @@ -10,33 +10,97 @@ typedef struct {
14521 atomic_long_t a;
14522 } local_t;
14523
14524 +typedef struct {
14525 + atomic_long_unchecked_t a;
14526 +} local_unchecked_t;
14527 +
14528 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
14529
14530 #define local_read(l) atomic_long_read(&(l)->a)
14531 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
14532 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
14533 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
14534
14535 static inline void local_inc(local_t *l)
14536 {
14537 - asm volatile(_ASM_INC "%0"
14538 + asm volatile(_ASM_INC "%0\n"
14539 +
14540 +#ifdef CONFIG_PAX_REFCOUNT
14541 + "jno 0f\n"
14542 + _ASM_DEC "%0\n"
14543 + "int $4\n0:\n"
14544 + _ASM_EXTABLE(0b, 0b)
14545 +#endif
14546 +
14547 + : "+m" (l->a.counter));
14548 +}
14549 +
14550 +static inline void local_inc_unchecked(local_unchecked_t *l)
14551 +{
14552 + asm volatile(_ASM_INC "%0\n"
14553 : "+m" (l->a.counter));
14554 }
14555
14556 static inline void local_dec(local_t *l)
14557 {
14558 - asm volatile(_ASM_DEC "%0"
14559 + asm volatile(_ASM_DEC "%0\n"
14560 +
14561 +#ifdef CONFIG_PAX_REFCOUNT
14562 + "jno 0f\n"
14563 + _ASM_INC "%0\n"
14564 + "int $4\n0:\n"
14565 + _ASM_EXTABLE(0b, 0b)
14566 +#endif
14567 +
14568 + : "+m" (l->a.counter));
14569 +}
14570 +
14571 +static inline void local_dec_unchecked(local_unchecked_t *l)
14572 +{
14573 + asm volatile(_ASM_DEC "%0\n"
14574 : "+m" (l->a.counter));
14575 }
14576
14577 static inline void local_add(long i, local_t *l)
14578 {
14579 - asm volatile(_ASM_ADD "%1,%0"
14580 + asm volatile(_ASM_ADD "%1,%0\n"
14581 +
14582 +#ifdef CONFIG_PAX_REFCOUNT
14583 + "jno 0f\n"
14584 + _ASM_SUB "%1,%0\n"
14585 + "int $4\n0:\n"
14586 + _ASM_EXTABLE(0b, 0b)
14587 +#endif
14588 +
14589 + : "+m" (l->a.counter)
14590 + : "ir" (i));
14591 +}
14592 +
14593 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
14594 +{
14595 + asm volatile(_ASM_ADD "%1,%0\n"
14596 : "+m" (l->a.counter)
14597 : "ir" (i));
14598 }
14599
14600 static inline void local_sub(long i, local_t *l)
14601 {
14602 - asm volatile(_ASM_SUB "%1,%0"
14603 + asm volatile(_ASM_SUB "%1,%0\n"
14604 +
14605 +#ifdef CONFIG_PAX_REFCOUNT
14606 + "jno 0f\n"
14607 + _ASM_ADD "%1,%0\n"
14608 + "int $4\n0:\n"
14609 + _ASM_EXTABLE(0b, 0b)
14610 +#endif
14611 +
14612 + : "+m" (l->a.counter)
14613 + : "ir" (i));
14614 +}
14615 +
14616 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
14617 +{
14618 + asm volatile(_ASM_SUB "%1,%0\n"
14619 : "+m" (l->a.counter)
14620 : "ir" (i));
14621 }
14622 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
14623 {
14624 unsigned char c;
14625
14626 - asm volatile(_ASM_SUB "%2,%0; sete %1"
14627 + asm volatile(_ASM_SUB "%2,%0\n"
14628 +
14629 +#ifdef CONFIG_PAX_REFCOUNT
14630 + "jno 0f\n"
14631 + _ASM_ADD "%2,%0\n"
14632 + "int $4\n0:\n"
14633 + _ASM_EXTABLE(0b, 0b)
14634 +#endif
14635 +
14636 + "sete %1\n"
14637 : "+m" (l->a.counter), "=qm" (c)
14638 : "ir" (i) : "memory");
14639 return c;
14640 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
14641 {
14642 unsigned char c;
14643
14644 - asm volatile(_ASM_DEC "%0; sete %1"
14645 + asm volatile(_ASM_DEC "%0\n"
14646 +
14647 +#ifdef CONFIG_PAX_REFCOUNT
14648 + "jno 0f\n"
14649 + _ASM_INC "%0\n"
14650 + "int $4\n0:\n"
14651 + _ASM_EXTABLE(0b, 0b)
14652 +#endif
14653 +
14654 + "sete %1\n"
14655 : "+m" (l->a.counter), "=qm" (c)
14656 : : "memory");
14657 return c != 0;
14658 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
14659 {
14660 unsigned char c;
14661
14662 - asm volatile(_ASM_INC "%0; sete %1"
14663 + asm volatile(_ASM_INC "%0\n"
14664 +
14665 +#ifdef CONFIG_PAX_REFCOUNT
14666 + "jno 0f\n"
14667 + _ASM_DEC "%0\n"
14668 + "int $4\n0:\n"
14669 + _ASM_EXTABLE(0b, 0b)
14670 +#endif
14671 +
14672 + "sete %1\n"
14673 : "+m" (l->a.counter), "=qm" (c)
14674 : : "memory");
14675 return c != 0;
14676 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
14677 {
14678 unsigned char c;
14679
14680 - asm volatile(_ASM_ADD "%2,%0; sets %1"
14681 + asm volatile(_ASM_ADD "%2,%0\n"
14682 +
14683 +#ifdef CONFIG_PAX_REFCOUNT
14684 + "jno 0f\n"
14685 + _ASM_SUB "%2,%0\n"
14686 + "int $4\n0:\n"
14687 + _ASM_EXTABLE(0b, 0b)
14688 +#endif
14689 +
14690 + "sets %1\n"
14691 : "+m" (l->a.counter), "=qm" (c)
14692 : "ir" (i) : "memory");
14693 return c;
14694 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
14695 static inline long local_add_return(long i, local_t *l)
14696 {
14697 long __i = i;
14698 + asm volatile(_ASM_XADD "%0, %1\n"
14699 +
14700 +#ifdef CONFIG_PAX_REFCOUNT
14701 + "jno 0f\n"
14702 + _ASM_MOV "%0,%1\n"
14703 + "int $4\n0:\n"
14704 + _ASM_EXTABLE(0b, 0b)
14705 +#endif
14706 +
14707 + : "+r" (i), "+m" (l->a.counter)
14708 + : : "memory");
14709 + return i + __i;
14710 +}
14711 +
14712 +/**
14713 + * local_add_return_unchecked - add and return
14714 + * @i: integer value to add
14715 + * @l: pointer to type local_unchecked_t
14716 + *
14717 + * Atomically adds @i to @l and returns @i + @l
14718 + */
14719 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
14720 +{
14721 + long __i = i;
14722 asm volatile(_ASM_XADD "%0, %1;"
14723 : "+r" (i), "+m" (l->a.counter)
14724 : : "memory");
14725 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
14726
14727 #define local_cmpxchg(l, o, n) \
14728 (cmpxchg_local(&((l)->a.counter), (o), (n)))
14729 +#define local_cmpxchg_unchecked(l, o, n) \
14730 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
14731 /* Always has a lock prefix */
14732 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
14733
14734 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
14735 new file mode 100644
14736 index 0000000..2bfd3ba
14737 --- /dev/null
14738 +++ b/arch/x86/include/asm/mman.h
14739 @@ -0,0 +1,15 @@
14740 +#ifndef _X86_MMAN_H
14741 +#define _X86_MMAN_H
14742 +
14743 +#include <uapi/asm/mman.h>
14744 +
14745 +#ifdef __KERNEL__
14746 +#ifndef __ASSEMBLY__
14747 +#ifdef CONFIG_X86_32
14748 +#define arch_mmap_check i386_mmap_check
14749 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
14750 +#endif
14751 +#endif
14752 +#endif
14753 +
14754 +#endif /* X86_MMAN_H */
14755 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
14756 index 5f55e69..e20bfb1 100644
14757 --- a/arch/x86/include/asm/mmu.h
14758 +++ b/arch/x86/include/asm/mmu.h
14759 @@ -9,7 +9,7 @@
14760 * we put the segment information here.
14761 */
14762 typedef struct {
14763 - void *ldt;
14764 + struct desc_struct *ldt;
14765 int size;
14766
14767 #ifdef CONFIG_X86_64
14768 @@ -18,7 +18,19 @@ typedef struct {
14769 #endif
14770
14771 struct mutex lock;
14772 - void *vdso;
14773 + unsigned long vdso;
14774 +
14775 +#ifdef CONFIG_X86_32
14776 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
14777 + unsigned long user_cs_base;
14778 + unsigned long user_cs_limit;
14779 +
14780 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
14781 + cpumask_t cpu_user_cs_mask;
14782 +#endif
14783 +
14784 +#endif
14785 +#endif
14786 } mm_context_t;
14787
14788 #ifdef CONFIG_SMP
14789 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
14790 index cdbf367..4c73c9e 100644
14791 --- a/arch/x86/include/asm/mmu_context.h
14792 +++ b/arch/x86/include/asm/mmu_context.h
14793 @@ -24,6 +24,20 @@ void destroy_context(struct mm_struct *mm);
14794
14795 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
14796 {
14797 +
14798 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
14799 + if (!(static_cpu_has(X86_FEATURE_PCID))) {
14800 + unsigned int i;
14801 + pgd_t *pgd;
14802 +
14803 + pax_open_kernel();
14804 + pgd = get_cpu_pgd(smp_processor_id(), kernel);
14805 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
14806 + set_pgd_batched(pgd+i, native_make_pgd(0));
14807 + pax_close_kernel();
14808 + }
14809 +#endif
14810 +
14811 #ifdef CONFIG_SMP
14812 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
14813 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
14814 @@ -34,16 +48,55 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
14815 struct task_struct *tsk)
14816 {
14817 unsigned cpu = smp_processor_id();
14818 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14819 + int tlbstate = TLBSTATE_OK;
14820 +#endif
14821
14822 if (likely(prev != next)) {
14823 #ifdef CONFIG_SMP
14824 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14825 + tlbstate = this_cpu_read(cpu_tlbstate.state);
14826 +#endif
14827 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
14828 this_cpu_write(cpu_tlbstate.active_mm, next);
14829 #endif
14830 cpumask_set_cpu(cpu, mm_cpumask(next));
14831
14832 /* Re-load page tables */
14833 +#ifdef CONFIG_PAX_PER_CPU_PGD
14834 + pax_open_kernel();
14835 +
14836 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
14837 + if (static_cpu_has(X86_FEATURE_PCID))
14838 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
14839 + else
14840 +#endif
14841 +
14842 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
14843 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
14844 + pax_close_kernel();
14845 + BUG_ON((__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL) != (read_cr3() & __PHYSICAL_MASK) && (__pa(get_cpu_pgd(cpu, user)) | PCID_USER) != (read_cr3() & __PHYSICAL_MASK));
14846 +
14847 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
14848 + if (static_cpu_has(X86_FEATURE_PCID)) {
14849 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
14850 + unsigned long descriptor[2];
14851 + descriptor[0] = PCID_USER;
14852 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
14853 + } else {
14854 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
14855 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
14856 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
14857 + else
14858 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
14859 + }
14860 + } else
14861 +#endif
14862 +
14863 + load_cr3(get_cpu_pgd(cpu, kernel));
14864 +#else
14865 load_cr3(next->pgd);
14866 +#endif
14867
14868 /* stop flush ipis for the previous mm */
14869 cpumask_clear_cpu(cpu, mm_cpumask(prev));
14870 @@ -53,9 +106,63 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
14871 */
14872 if (unlikely(prev->context.ldt != next->context.ldt))
14873 load_LDT_nolock(&next->context);
14874 - }
14875 +
14876 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
14877 + if (!(__supported_pte_mask & _PAGE_NX)) {
14878 + smp_mb__before_clear_bit();
14879 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
14880 + smp_mb__after_clear_bit();
14881 + cpu_set(cpu, next->context.cpu_user_cs_mask);
14882 + }
14883 +#endif
14884 +
14885 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14886 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
14887 + prev->context.user_cs_limit != next->context.user_cs_limit))
14888 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
14889 #ifdef CONFIG_SMP
14890 + else if (unlikely(tlbstate != TLBSTATE_OK))
14891 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
14892 +#endif
14893 +#endif
14894 +
14895 + }
14896 else {
14897 +
14898 +#ifdef CONFIG_PAX_PER_CPU_PGD
14899 + pax_open_kernel();
14900 +
14901 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
14902 + if (static_cpu_has(X86_FEATURE_PCID))
14903 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
14904 + else
14905 +#endif
14906 +
14907 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
14908 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
14909 + pax_close_kernel();
14910 + BUG_ON((__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL) != (read_cr3() & __PHYSICAL_MASK) && (__pa(get_cpu_pgd(cpu, user)) | PCID_USER) != (read_cr3() & __PHYSICAL_MASK));
14911 +
14912 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
14913 + if (static_cpu_has(X86_FEATURE_PCID)) {
14914 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
14915 + unsigned long descriptor[2];
14916 + descriptor[0] = PCID_USER;
14917 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
14918 + } else {
14919 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
14920 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
14921 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
14922 + else
14923 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
14924 + }
14925 + } else
14926 +#endif
14927 +
14928 + load_cr3(get_cpu_pgd(cpu, kernel));
14929 +#endif
14930 +
14931 +#ifdef CONFIG_SMP
14932 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
14933 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
14934
14935 @@ -64,11 +171,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
14936 * tlb flush IPI delivery. We must reload CR3
14937 * to make sure to use no freed page tables.
14938 */
14939 +
14940 +#ifndef CONFIG_PAX_PER_CPU_PGD
14941 load_cr3(next->pgd);
14942 +#endif
14943 +
14944 load_LDT_nolock(&next->context);
14945 +
14946 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
14947 + if (!(__supported_pte_mask & _PAGE_NX))
14948 + cpu_set(cpu, next->context.cpu_user_cs_mask);
14949 +#endif
14950 +
14951 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
14952 +#ifdef CONFIG_PAX_PAGEEXEC
14953 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
14954 +#endif
14955 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
14956 +#endif
14957 +
14958 }
14959 +#endif
14960 }
14961 -#endif
14962 }
14963
14964 #define activate_mm(prev, next) \
14965 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
14966 index e3b7819..b257c64 100644
14967 --- a/arch/x86/include/asm/module.h
14968 +++ b/arch/x86/include/asm/module.h
14969 @@ -5,6 +5,7 @@
14970
14971 #ifdef CONFIG_X86_64
14972 /* X86_64 does not define MODULE_PROC_FAMILY */
14973 +#define MODULE_PROC_FAMILY ""
14974 #elif defined CONFIG_M486
14975 #define MODULE_PROC_FAMILY "486 "
14976 #elif defined CONFIG_M586
14977 @@ -57,8 +58,20 @@
14978 #error unknown processor family
14979 #endif
14980
14981 -#ifdef CONFIG_X86_32
14982 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
14983 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
14984 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
14985 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
14986 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
14987 +#else
14988 +#define MODULE_PAX_KERNEXEC ""
14989 #endif
14990
14991 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14992 +#define MODULE_PAX_UDEREF "UDEREF "
14993 +#else
14994 +#define MODULE_PAX_UDEREF ""
14995 +#endif
14996 +
14997 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
14998 +
14999 #endif /* _ASM_X86_MODULE_H */
15000 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
15001 index 86f9301..b365cda 100644
15002 --- a/arch/x86/include/asm/nmi.h
15003 +++ b/arch/x86/include/asm/nmi.h
15004 @@ -40,11 +40,11 @@ struct nmiaction {
15005 nmi_handler_t handler;
15006 unsigned long flags;
15007 const char *name;
15008 -};
15009 +} __do_const;
15010
15011 #define register_nmi_handler(t, fn, fg, n, init...) \
15012 ({ \
15013 - static struct nmiaction init fn##_na = { \
15014 + static const struct nmiaction init fn##_na = { \
15015 .handler = (fn), \
15016 .name = (n), \
15017 .flags = (fg), \
15018 @@ -52,7 +52,7 @@ struct nmiaction {
15019 __register_nmi_handler((t), &fn##_na); \
15020 })
15021
15022 -int __register_nmi_handler(unsigned int, struct nmiaction *);
15023 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
15024
15025 void unregister_nmi_handler(unsigned int, const char *);
15026
15027 diff --git a/arch/x86/include/asm/page.h b/arch/x86/include/asm/page.h
15028 index c878924..21f4889 100644
15029 --- a/arch/x86/include/asm/page.h
15030 +++ b/arch/x86/include/asm/page.h
15031 @@ -52,6 +52,7 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
15032 __phys_addr_symbol(__phys_reloc_hide((unsigned long)(x)))
15033
15034 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
15035 +#define __early_va(x) ((void *)((unsigned long)(x)+__START_KERNEL_map - phys_base))
15036
15037 #define __boot_va(x) __va(x)
15038 #define __boot_pa(x) __pa(x)
15039 diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h
15040 index 0f1ddee..e2fc3d1 100644
15041 --- a/arch/x86/include/asm/page_64.h
15042 +++ b/arch/x86/include/asm/page_64.h
15043 @@ -7,9 +7,9 @@
15044
15045 /* duplicated to the one in bootmem.h */
15046 extern unsigned long max_pfn;
15047 -extern unsigned long phys_base;
15048 +extern const unsigned long phys_base;
15049
15050 -static inline unsigned long __phys_addr_nodebug(unsigned long x)
15051 +static inline unsigned long __intentional_overflow(-1) __phys_addr_nodebug(unsigned long x)
15052 {
15053 unsigned long y = x - __START_KERNEL_map;
15054
15055 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
15056 index cfdc9ee..3f7b5d6 100644
15057 --- a/arch/x86/include/asm/paravirt.h
15058 +++ b/arch/x86/include/asm/paravirt.h
15059 @@ -560,7 +560,7 @@ static inline pmd_t __pmd(pmdval_t val)
15060 return (pmd_t) { ret };
15061 }
15062
15063 -static inline pmdval_t pmd_val(pmd_t pmd)
15064 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
15065 {
15066 pmdval_t ret;
15067
15068 @@ -626,6 +626,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
15069 val);
15070 }
15071
15072 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
15073 +{
15074 + pgdval_t val = native_pgd_val(pgd);
15075 +
15076 + if (sizeof(pgdval_t) > sizeof(long))
15077 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
15078 + val, (u64)val >> 32);
15079 + else
15080 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
15081 + val);
15082 +}
15083 +
15084 static inline void pgd_clear(pgd_t *pgdp)
15085 {
15086 set_pgd(pgdp, __pgd(0));
15087 @@ -710,6 +722,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
15088 pv_mmu_ops.set_fixmap(idx, phys, flags);
15089 }
15090
15091 +#ifdef CONFIG_PAX_KERNEXEC
15092 +static inline unsigned long pax_open_kernel(void)
15093 +{
15094 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
15095 +}
15096 +
15097 +static inline unsigned long pax_close_kernel(void)
15098 +{
15099 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
15100 +}
15101 +#else
15102 +static inline unsigned long pax_open_kernel(void) { return 0; }
15103 +static inline unsigned long pax_close_kernel(void) { return 0; }
15104 +#endif
15105 +
15106 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
15107
15108 static inline int arch_spin_is_locked(struct arch_spinlock *lock)
15109 @@ -926,7 +953,7 @@ extern void default_banner(void);
15110
15111 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
15112 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
15113 -#define PARA_INDIRECT(addr) *%cs:addr
15114 +#define PARA_INDIRECT(addr) *%ss:addr
15115 #endif
15116
15117 #define INTERRUPT_RETURN \
15118 @@ -1001,6 +1028,21 @@ extern void default_banner(void);
15119 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
15120 CLBR_NONE, \
15121 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
15122 +
15123 +#define GET_CR0_INTO_RDI \
15124 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
15125 + mov %rax,%rdi
15126 +
15127 +#define SET_RDI_INTO_CR0 \
15128 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
15129 +
15130 +#define GET_CR3_INTO_RDI \
15131 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
15132 + mov %rax,%rdi
15133 +
15134 +#define SET_RDI_INTO_CR3 \
15135 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
15136 +
15137 #endif /* CONFIG_X86_32 */
15138
15139 #endif /* __ASSEMBLY__ */
15140 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
15141 index 0db1fca..52310cc 100644
15142 --- a/arch/x86/include/asm/paravirt_types.h
15143 +++ b/arch/x86/include/asm/paravirt_types.h
15144 @@ -84,7 +84,7 @@ struct pv_init_ops {
15145 */
15146 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
15147 unsigned long addr, unsigned len);
15148 -};
15149 +} __no_const;
15150
15151
15152 struct pv_lazy_ops {
15153 @@ -98,7 +98,7 @@ struct pv_time_ops {
15154 unsigned long long (*sched_clock)(void);
15155 unsigned long long (*steal_clock)(int cpu);
15156 unsigned long (*get_tsc_khz)(void);
15157 -};
15158 +} __no_const;
15159
15160 struct pv_cpu_ops {
15161 /* hooks for various privileged instructions */
15162 @@ -192,7 +192,7 @@ struct pv_cpu_ops {
15163
15164 void (*start_context_switch)(struct task_struct *prev);
15165 void (*end_context_switch)(struct task_struct *next);
15166 -};
15167 +} __no_const;
15168
15169 struct pv_irq_ops {
15170 /*
15171 @@ -223,7 +223,7 @@ struct pv_apic_ops {
15172 unsigned long start_eip,
15173 unsigned long start_esp);
15174 #endif
15175 -};
15176 +} __no_const;
15177
15178 struct pv_mmu_ops {
15179 unsigned long (*read_cr2)(void);
15180 @@ -313,6 +313,7 @@ struct pv_mmu_ops {
15181 struct paravirt_callee_save make_pud;
15182
15183 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
15184 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
15185 #endif /* PAGETABLE_LEVELS == 4 */
15186 #endif /* PAGETABLE_LEVELS >= 3 */
15187
15188 @@ -324,6 +325,12 @@ struct pv_mmu_ops {
15189 an mfn. We can tell which is which from the index. */
15190 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
15191 phys_addr_t phys, pgprot_t flags);
15192 +
15193 +#ifdef CONFIG_PAX_KERNEXEC
15194 + unsigned long (*pax_open_kernel)(void);
15195 + unsigned long (*pax_close_kernel)(void);
15196 +#endif
15197 +
15198 };
15199
15200 struct arch_spinlock;
15201 @@ -334,7 +341,7 @@ struct pv_lock_ops {
15202 void (*spin_lock_flags)(struct arch_spinlock *lock, unsigned long flags);
15203 int (*spin_trylock)(struct arch_spinlock *lock);
15204 void (*spin_unlock)(struct arch_spinlock *lock);
15205 -};
15206 +} __no_const;
15207
15208 /* This contains all the paravirt structures: we get a convenient
15209 * number for each function using the offset which we use to indicate
15210 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
15211 index b4389a4..7024269 100644
15212 --- a/arch/x86/include/asm/pgalloc.h
15213 +++ b/arch/x86/include/asm/pgalloc.h
15214 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
15215 pmd_t *pmd, pte_t *pte)
15216 {
15217 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
15218 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
15219 +}
15220 +
15221 +static inline void pmd_populate_user(struct mm_struct *mm,
15222 + pmd_t *pmd, pte_t *pte)
15223 +{
15224 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
15225 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
15226 }
15227
15228 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
15229
15230 #ifdef CONFIG_X86_PAE
15231 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
15232 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
15233 +{
15234 + pud_populate(mm, pudp, pmd);
15235 +}
15236 #else /* !CONFIG_X86_PAE */
15237 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
15238 {
15239 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
15240 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
15241 }
15242 +
15243 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
15244 +{
15245 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
15246 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
15247 +}
15248 #endif /* CONFIG_X86_PAE */
15249
15250 #if PAGETABLE_LEVELS > 3
15251 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
15252 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
15253 }
15254
15255 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
15256 +{
15257 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
15258 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
15259 +}
15260 +
15261 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
15262 {
15263 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
15264 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
15265 index f2b489c..4f7e2e5 100644
15266 --- a/arch/x86/include/asm/pgtable-2level.h
15267 +++ b/arch/x86/include/asm/pgtable-2level.h
15268 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
15269
15270 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
15271 {
15272 + pax_open_kernel();
15273 *pmdp = pmd;
15274 + pax_close_kernel();
15275 }
15276
15277 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
15278 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
15279 index 4cc9f2b..5fd9226 100644
15280 --- a/arch/x86/include/asm/pgtable-3level.h
15281 +++ b/arch/x86/include/asm/pgtable-3level.h
15282 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
15283
15284 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
15285 {
15286 + pax_open_kernel();
15287 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
15288 + pax_close_kernel();
15289 }
15290
15291 static inline void native_set_pud(pud_t *pudp, pud_t pud)
15292 {
15293 + pax_open_kernel();
15294 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
15295 + pax_close_kernel();
15296 }
15297
15298 /*
15299 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
15300 index 1e67223..92a9585 100644
15301 --- a/arch/x86/include/asm/pgtable.h
15302 +++ b/arch/x86/include/asm/pgtable.h
15303 @@ -44,6 +44,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
15304
15305 #ifndef __PAGETABLE_PUD_FOLDED
15306 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
15307 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
15308 #define pgd_clear(pgd) native_pgd_clear(pgd)
15309 #endif
15310
15311 @@ -81,12 +82,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
15312
15313 #define arch_end_context_switch(prev) do {} while(0)
15314
15315 +#define pax_open_kernel() native_pax_open_kernel()
15316 +#define pax_close_kernel() native_pax_close_kernel()
15317 #endif /* CONFIG_PARAVIRT */
15318
15319 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
15320 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
15321 +
15322 +#ifdef CONFIG_PAX_KERNEXEC
15323 +static inline unsigned long native_pax_open_kernel(void)
15324 +{
15325 + unsigned long cr0;
15326 +
15327 + preempt_disable();
15328 + barrier();
15329 + cr0 = read_cr0() ^ X86_CR0_WP;
15330 + BUG_ON(cr0 & X86_CR0_WP);
15331 + write_cr0(cr0);
15332 + return cr0 ^ X86_CR0_WP;
15333 +}
15334 +
15335 +static inline unsigned long native_pax_close_kernel(void)
15336 +{
15337 + unsigned long cr0;
15338 +
15339 + cr0 = read_cr0() ^ X86_CR0_WP;
15340 + BUG_ON(!(cr0 & X86_CR0_WP));
15341 + write_cr0(cr0);
15342 + barrier();
15343 + preempt_enable_no_resched();
15344 + return cr0 ^ X86_CR0_WP;
15345 +}
15346 +#else
15347 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
15348 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
15349 +#endif
15350 +
15351 /*
15352 * The following only work if pte_present() is true.
15353 * Undefined behaviour if not..
15354 */
15355 +static inline int pte_user(pte_t pte)
15356 +{
15357 + return pte_val(pte) & _PAGE_USER;
15358 +}
15359 +
15360 static inline int pte_dirty(pte_t pte)
15361 {
15362 return pte_flags(pte) & _PAGE_DIRTY;
15363 @@ -147,6 +187,11 @@ static inline unsigned long pud_pfn(pud_t pud)
15364 return (pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT;
15365 }
15366
15367 +static inline unsigned long pgd_pfn(pgd_t pgd)
15368 +{
15369 + return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT;
15370 +}
15371 +
15372 #define pte_page(pte) pfn_to_page(pte_pfn(pte))
15373
15374 static inline int pmd_large(pmd_t pte)
15375 @@ -200,9 +245,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
15376 return pte_clear_flags(pte, _PAGE_RW);
15377 }
15378
15379 +static inline pte_t pte_mkread(pte_t pte)
15380 +{
15381 + return __pte(pte_val(pte) | _PAGE_USER);
15382 +}
15383 +
15384 static inline pte_t pte_mkexec(pte_t pte)
15385 {
15386 - return pte_clear_flags(pte, _PAGE_NX);
15387 +#ifdef CONFIG_X86_PAE
15388 + if (__supported_pte_mask & _PAGE_NX)
15389 + return pte_clear_flags(pte, _PAGE_NX);
15390 + else
15391 +#endif
15392 + return pte_set_flags(pte, _PAGE_USER);
15393 +}
15394 +
15395 +static inline pte_t pte_exprotect(pte_t pte)
15396 +{
15397 +#ifdef CONFIG_X86_PAE
15398 + if (__supported_pte_mask & _PAGE_NX)
15399 + return pte_set_flags(pte, _PAGE_NX);
15400 + else
15401 +#endif
15402 + return pte_clear_flags(pte, _PAGE_USER);
15403 }
15404
15405 static inline pte_t pte_mkdirty(pte_t pte)
15406 @@ -394,6 +459,16 @@ pte_t *populate_extra_pte(unsigned long vaddr);
15407 #endif
15408
15409 #ifndef __ASSEMBLY__
15410 +
15411 +#ifdef CONFIG_PAX_PER_CPU_PGD
15412 +extern pgd_t cpu_pgd[NR_CPUS][2][PTRS_PER_PGD];
15413 +enum cpu_pgd_type {kernel = 0, user = 1};
15414 +static inline pgd_t *get_cpu_pgd(unsigned int cpu, enum cpu_pgd_type type)
15415 +{
15416 + return cpu_pgd[cpu][type];
15417 +}
15418 +#endif
15419 +
15420 #include <linux/mm_types.h>
15421 #include <linux/log2.h>
15422
15423 @@ -529,7 +604,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
15424 * Currently stuck as a macro due to indirect forward reference to
15425 * linux/mmzone.h's __section_mem_map_addr() definition:
15426 */
15427 -#define pud_page(pud) pfn_to_page(pud_val(pud) >> PAGE_SHIFT)
15428 +#define pud_page(pud) pfn_to_page((pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT)
15429
15430 /* Find an entry in the second-level page table.. */
15431 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
15432 @@ -569,7 +644,7 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
15433 * Currently stuck as a macro due to indirect forward reference to
15434 * linux/mmzone.h's __section_mem_map_addr() definition:
15435 */
15436 -#define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)
15437 +#define pgd_page(pgd) pfn_to_page((pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT)
15438
15439 /* to find an entry in a page-table-directory. */
15440 static inline unsigned long pud_index(unsigned long address)
15441 @@ -584,7 +659,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
15442
15443 static inline int pgd_bad(pgd_t pgd)
15444 {
15445 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
15446 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
15447 }
15448
15449 static inline int pgd_none(pgd_t pgd)
15450 @@ -607,7 +682,12 @@ static inline int pgd_none(pgd_t pgd)
15451 * pgd_offset() returns a (pgd_t *)
15452 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
15453 */
15454 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
15455 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
15456 +
15457 +#ifdef CONFIG_PAX_PER_CPU_PGD
15458 +#define pgd_offset_cpu(cpu, type, address) (get_cpu_pgd(cpu, type) + pgd_index(address))
15459 +#endif
15460 +
15461 /*
15462 * a shortcut which implies the use of the kernel's pgd, instead
15463 * of a process's
15464 @@ -618,6 +698,23 @@ static inline int pgd_none(pgd_t pgd)
15465 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
15466 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
15467
15468 +#ifdef CONFIG_X86_32
15469 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
15470 +#else
15471 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
15472 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
15473 +
15474 +#ifdef CONFIG_PAX_MEMORY_UDEREF
15475 +#ifdef __ASSEMBLY__
15476 +#define pax_user_shadow_base pax_user_shadow_base(%rip)
15477 +#else
15478 +extern unsigned long pax_user_shadow_base;
15479 +extern pgdval_t clone_pgd_mask;
15480 +#endif
15481 +#endif
15482 +
15483 +#endif
15484 +
15485 #ifndef __ASSEMBLY__
15486
15487 extern int direct_gbpages;
15488 @@ -784,11 +881,24 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
15489 * dst and src can be on the same page, but the range must not overlap,
15490 * and must not cross a page boundary.
15491 */
15492 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
15493 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
15494 {
15495 - memcpy(dst, src, count * sizeof(pgd_t));
15496 + pax_open_kernel();
15497 + while (count--)
15498 + *dst++ = *src++;
15499 + pax_close_kernel();
15500 }
15501
15502 +#ifdef CONFIG_PAX_PER_CPU_PGD
15503 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
15504 +#endif
15505 +
15506 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
15507 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
15508 +#else
15509 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
15510 +#endif
15511 +
15512 #define PTE_SHIFT ilog2(PTRS_PER_PTE)
15513 static inline int page_level_shift(enum pg_level level)
15514 {
15515 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
15516 index 9ee3221..b979c6b 100644
15517 --- a/arch/x86/include/asm/pgtable_32.h
15518 +++ b/arch/x86/include/asm/pgtable_32.h
15519 @@ -25,9 +25,6 @@
15520 struct mm_struct;
15521 struct vm_area_struct;
15522
15523 -extern pgd_t swapper_pg_dir[1024];
15524 -extern pgd_t initial_page_table[1024];
15525 -
15526 static inline void pgtable_cache_init(void) { }
15527 static inline void check_pgt_cache(void) { }
15528 void paging_init(void);
15529 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
15530 # include <asm/pgtable-2level.h>
15531 #endif
15532
15533 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
15534 +extern pgd_t initial_page_table[PTRS_PER_PGD];
15535 +#ifdef CONFIG_X86_PAE
15536 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
15537 +#endif
15538 +
15539 #if defined(CONFIG_HIGHPTE)
15540 #define pte_offset_map(dir, address) \
15541 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
15542 @@ -62,12 +65,17 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
15543 /* Clear a kernel PTE and flush it from the TLB */
15544 #define kpte_clear_flush(ptep, vaddr) \
15545 do { \
15546 + pax_open_kernel(); \
15547 pte_clear(&init_mm, (vaddr), (ptep)); \
15548 + pax_close_kernel(); \
15549 __flush_tlb_one((vaddr)); \
15550 } while (0)
15551
15552 #endif /* !__ASSEMBLY__ */
15553
15554 +#define HAVE_ARCH_UNMAPPED_AREA
15555 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
15556 +
15557 /*
15558 * kern_addr_valid() is (1) for FLATMEM and (0) for
15559 * SPARSEMEM and DISCONTIGMEM
15560 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
15561 index ed5903b..c7fe163 100644
15562 --- a/arch/x86/include/asm/pgtable_32_types.h
15563 +++ b/arch/x86/include/asm/pgtable_32_types.h
15564 @@ -8,7 +8,7 @@
15565 */
15566 #ifdef CONFIG_X86_PAE
15567 # include <asm/pgtable-3level_types.h>
15568 -# define PMD_SIZE (1UL << PMD_SHIFT)
15569 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
15570 # define PMD_MASK (~(PMD_SIZE - 1))
15571 #else
15572 # include <asm/pgtable-2level_types.h>
15573 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
15574 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
15575 #endif
15576
15577 +#ifdef CONFIG_PAX_KERNEXEC
15578 +#ifndef __ASSEMBLY__
15579 +extern unsigned char MODULES_EXEC_VADDR[];
15580 +extern unsigned char MODULES_EXEC_END[];
15581 +#endif
15582 +#include <asm/boot.h>
15583 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
15584 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
15585 +#else
15586 +#define ktla_ktva(addr) (addr)
15587 +#define ktva_ktla(addr) (addr)
15588 +#endif
15589 +
15590 #define MODULES_VADDR VMALLOC_START
15591 #define MODULES_END VMALLOC_END
15592 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
15593 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
15594 index e22c1db..23a625a 100644
15595 --- a/arch/x86/include/asm/pgtable_64.h
15596 +++ b/arch/x86/include/asm/pgtable_64.h
15597 @@ -16,10 +16,14 @@
15598
15599 extern pud_t level3_kernel_pgt[512];
15600 extern pud_t level3_ident_pgt[512];
15601 +extern pud_t level3_vmalloc_start_pgt[512];
15602 +extern pud_t level3_vmalloc_end_pgt[512];
15603 +extern pud_t level3_vmemmap_pgt[512];
15604 +extern pud_t level2_vmemmap_pgt[512];
15605 extern pmd_t level2_kernel_pgt[512];
15606 extern pmd_t level2_fixmap_pgt[512];
15607 -extern pmd_t level2_ident_pgt[512];
15608 -extern pgd_t init_level4_pgt[];
15609 +extern pmd_t level2_ident_pgt[512*2];
15610 +extern pgd_t init_level4_pgt[512];
15611
15612 #define swapper_pg_dir init_level4_pgt
15613
15614 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
15615
15616 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
15617 {
15618 + pax_open_kernel();
15619 *pmdp = pmd;
15620 + pax_close_kernel();
15621 }
15622
15623 static inline void native_pmd_clear(pmd_t *pmd)
15624 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
15625
15626 static inline void native_set_pud(pud_t *pudp, pud_t pud)
15627 {
15628 + pax_open_kernel();
15629 *pudp = pud;
15630 + pax_close_kernel();
15631 }
15632
15633 static inline void native_pud_clear(pud_t *pud)
15634 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
15635
15636 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
15637 {
15638 + pax_open_kernel();
15639 + *pgdp = pgd;
15640 + pax_close_kernel();
15641 +}
15642 +
15643 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
15644 +{
15645 *pgdp = pgd;
15646 }
15647
15648 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
15649 index 2d88344..4679fc3 100644
15650 --- a/arch/x86/include/asm/pgtable_64_types.h
15651 +++ b/arch/x86/include/asm/pgtable_64_types.h
15652 @@ -61,6 +61,11 @@ typedef struct { pteval_t pte; } pte_t;
15653 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
15654 #define MODULES_END _AC(0xffffffffff000000, UL)
15655 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
15656 +#define MODULES_EXEC_VADDR MODULES_VADDR
15657 +#define MODULES_EXEC_END MODULES_END
15658 +
15659 +#define ktla_ktva(addr) (addr)
15660 +#define ktva_ktla(addr) (addr)
15661
15662 #define EARLY_DYNAMIC_PAGE_TABLES 64
15663
15664 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
15665 index e642300..0ef8f31 100644
15666 --- a/arch/x86/include/asm/pgtable_types.h
15667 +++ b/arch/x86/include/asm/pgtable_types.h
15668 @@ -16,13 +16,12 @@
15669 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
15670 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
15671 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
15672 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
15673 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
15674 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
15675 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
15676 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
15677 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
15678 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
15679 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
15680 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
15681 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
15682 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
15683
15684 /* If _PAGE_BIT_PRESENT is clear, we use these: */
15685 @@ -40,7 +39,6 @@
15686 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
15687 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
15688 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
15689 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
15690 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
15691 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
15692 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
15693 @@ -57,8 +55,10 @@
15694
15695 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
15696 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
15697 -#else
15698 +#elif defined(CONFIG_KMEMCHECK)
15699 #define _PAGE_NX (_AT(pteval_t, 0))
15700 +#else
15701 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
15702 #endif
15703
15704 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
15705 @@ -116,6 +116,9 @@
15706 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
15707 _PAGE_ACCESSED)
15708
15709 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
15710 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
15711 +
15712 #define __PAGE_KERNEL_EXEC \
15713 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
15714 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
15715 @@ -126,7 +129,7 @@
15716 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
15717 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
15718 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
15719 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
15720 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
15721 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
15722 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
15723 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
15724 @@ -188,8 +191,8 @@
15725 * bits are combined, this will alow user to access the high address mapped
15726 * VDSO in the presence of CONFIG_COMPAT_VDSO
15727 */
15728 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
15729 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
15730 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
15731 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
15732 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
15733 #endif
15734
15735 @@ -227,7 +230,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
15736 {
15737 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
15738 }
15739 +#endif
15740
15741 +#if PAGETABLE_LEVELS == 3
15742 +#include <asm-generic/pgtable-nopud.h>
15743 +#endif
15744 +
15745 +#if PAGETABLE_LEVELS == 2
15746 +#include <asm-generic/pgtable-nopmd.h>
15747 +#endif
15748 +
15749 +#ifndef __ASSEMBLY__
15750 #if PAGETABLE_LEVELS > 3
15751 typedef struct { pudval_t pud; } pud_t;
15752
15753 @@ -241,8 +254,6 @@ static inline pudval_t native_pud_val(pud_t pud)
15754 return pud.pud;
15755 }
15756 #else
15757 -#include <asm-generic/pgtable-nopud.h>
15758 -
15759 static inline pudval_t native_pud_val(pud_t pud)
15760 {
15761 return native_pgd_val(pud.pgd);
15762 @@ -262,8 +273,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
15763 return pmd.pmd;
15764 }
15765 #else
15766 -#include <asm-generic/pgtable-nopmd.h>
15767 -
15768 static inline pmdval_t native_pmd_val(pmd_t pmd)
15769 {
15770 return native_pgd_val(pmd.pud.pgd);
15771 @@ -303,7 +312,6 @@ typedef struct page *pgtable_t;
15772
15773 extern pteval_t __supported_pte_mask;
15774 extern void set_nx(void);
15775 -extern int nx_enabled;
15776
15777 #define pgprot_writecombine pgprot_writecombine
15778 extern pgprot_t pgprot_writecombine(pgprot_t prot);
15779 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
15780 index 22224b3..b3a2f90 100644
15781 --- a/arch/x86/include/asm/processor.h
15782 +++ b/arch/x86/include/asm/processor.h
15783 @@ -198,9 +198,21 @@ static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
15784 : "memory");
15785 }
15786
15787 +/* invpcid (%rdx),%rax */
15788 +#define __ASM_INVPCID ".byte 0x66,0x0f,0x38,0x82,0x02"
15789 +
15790 +#define INVPCID_SINGLE_ADDRESS 0UL
15791 +#define INVPCID_SINGLE_CONTEXT 1UL
15792 +#define INVPCID_ALL_GLOBAL 2UL
15793 +#define INVPCID_ALL_MONGLOBAL 3UL
15794 +
15795 +#define PCID_KERNEL 0UL
15796 +#define PCID_USER 1UL
15797 +#define PCID_NOFLUSH (1UL << 63)
15798 +
15799 static inline void load_cr3(pgd_t *pgdir)
15800 {
15801 - write_cr3(__pa(pgdir));
15802 + write_cr3(__pa(pgdir) | PCID_KERNEL);
15803 }
15804
15805 #ifdef CONFIG_X86_32
15806 @@ -282,7 +294,7 @@ struct tss_struct {
15807
15808 } ____cacheline_aligned;
15809
15810 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
15811 +extern struct tss_struct init_tss[NR_CPUS];
15812
15813 /*
15814 * Save the original ist values for checking stack pointers during debugging
15815 @@ -452,6 +464,7 @@ struct thread_struct {
15816 unsigned short ds;
15817 unsigned short fsindex;
15818 unsigned short gsindex;
15819 + unsigned short ss;
15820 #endif
15821 #ifdef CONFIG_X86_32
15822 unsigned long ip;
15823 @@ -552,29 +565,8 @@ static inline void load_sp0(struct tss_struct *tss,
15824 extern unsigned long mmu_cr4_features;
15825 extern u32 *trampoline_cr4_features;
15826
15827 -static inline void set_in_cr4(unsigned long mask)
15828 -{
15829 - unsigned long cr4;
15830 -
15831 - mmu_cr4_features |= mask;
15832 - if (trampoline_cr4_features)
15833 - *trampoline_cr4_features = mmu_cr4_features;
15834 - cr4 = read_cr4();
15835 - cr4 |= mask;
15836 - write_cr4(cr4);
15837 -}
15838 -
15839 -static inline void clear_in_cr4(unsigned long mask)
15840 -{
15841 - unsigned long cr4;
15842 -
15843 - mmu_cr4_features &= ~mask;
15844 - if (trampoline_cr4_features)
15845 - *trampoline_cr4_features = mmu_cr4_features;
15846 - cr4 = read_cr4();
15847 - cr4 &= ~mask;
15848 - write_cr4(cr4);
15849 -}
15850 +extern void set_in_cr4(unsigned long mask);
15851 +extern void clear_in_cr4(unsigned long mask);
15852
15853 typedef struct {
15854 unsigned long seg;
15855 @@ -823,11 +815,18 @@ static inline void spin_lock_prefetch(const void *x)
15856 */
15857 #define TASK_SIZE PAGE_OFFSET
15858 #define TASK_SIZE_MAX TASK_SIZE
15859 +
15860 +#ifdef CONFIG_PAX_SEGMEXEC
15861 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
15862 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
15863 +#else
15864 #define STACK_TOP TASK_SIZE
15865 -#define STACK_TOP_MAX STACK_TOP
15866 +#endif
15867 +
15868 +#define STACK_TOP_MAX TASK_SIZE
15869
15870 #define INIT_THREAD { \
15871 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
15872 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
15873 .vm86_info = NULL, \
15874 .sysenter_cs = __KERNEL_CS, \
15875 .io_bitmap_ptr = NULL, \
15876 @@ -841,7 +840,7 @@ static inline void spin_lock_prefetch(const void *x)
15877 */
15878 #define INIT_TSS { \
15879 .x86_tss = { \
15880 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
15881 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
15882 .ss0 = __KERNEL_DS, \
15883 .ss1 = __KERNEL_CS, \
15884 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
15885 @@ -852,11 +851,7 @@ static inline void spin_lock_prefetch(const void *x)
15886 extern unsigned long thread_saved_pc(struct task_struct *tsk);
15887
15888 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
15889 -#define KSTK_TOP(info) \
15890 -({ \
15891 - unsigned long *__ptr = (unsigned long *)(info); \
15892 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
15893 -})
15894 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
15895
15896 /*
15897 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
15898 @@ -871,7 +866,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
15899 #define task_pt_regs(task) \
15900 ({ \
15901 struct pt_regs *__regs__; \
15902 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
15903 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
15904 __regs__ - 1; \
15905 })
15906
15907 @@ -881,13 +876,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
15908 /*
15909 * User space process size. 47bits minus one guard page.
15910 */
15911 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
15912 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
15913
15914 /* This decides where the kernel will search for a free chunk of vm
15915 * space during mmap's.
15916 */
15917 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
15918 - 0xc0000000 : 0xFFFFe000)
15919 + 0xc0000000 : 0xFFFFf000)
15920
15921 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
15922 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
15923 @@ -898,11 +893,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
15924 #define STACK_TOP_MAX TASK_SIZE_MAX
15925
15926 #define INIT_THREAD { \
15927 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
15928 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
15929 }
15930
15931 #define INIT_TSS { \
15932 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
15933 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
15934 }
15935
15936 /*
15937 @@ -930,6 +925,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
15938 */
15939 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
15940
15941 +#ifdef CONFIG_PAX_SEGMEXEC
15942 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
15943 +#endif
15944 +
15945 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
15946
15947 /* Get/set a process' ability to use the timestamp counter instruction */
15948 @@ -942,7 +941,8 @@ extern int set_tsc_mode(unsigned int val);
15949 extern u16 amd_get_nb_id(int cpu);
15950
15951 struct aperfmperf {
15952 - u64 aperf, mperf;
15953 + u64 aperf __intentional_overflow(0);
15954 + u64 mperf __intentional_overflow(0);
15955 };
15956
15957 static inline void get_aperfmperf(struct aperfmperf *am)
15958 @@ -970,7 +970,7 @@ unsigned long calc_aperfmperf_ratio(struct aperfmperf *old,
15959 return ratio;
15960 }
15961
15962 -extern unsigned long arch_align_stack(unsigned long sp);
15963 +#define arch_align_stack(x) ((x) & ~0xfUL)
15964 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
15965
15966 void default_idle(void);
15967 @@ -980,6 +980,6 @@ bool xen_set_default_idle(void);
15968 #define xen_set_default_idle 0
15969 #endif
15970
15971 -void stop_this_cpu(void *dummy);
15972 +void stop_this_cpu(void *dummy) __noreturn;
15973
15974 #endif /* _ASM_X86_PROCESSOR_H */
15975 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
15976 index 942a086..6c26446 100644
15977 --- a/arch/x86/include/asm/ptrace.h
15978 +++ b/arch/x86/include/asm/ptrace.h
15979 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
15980 }
15981
15982 /*
15983 - * user_mode_vm(regs) determines whether a register set came from user mode.
15984 + * user_mode(regs) determines whether a register set came from user mode.
15985 * This is true if V8086 mode was enabled OR if the register set was from
15986 * protected mode with RPL-3 CS value. This tricky test checks that with
15987 * one comparison. Many places in the kernel can bypass this full check
15988 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
15989 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
15990 + * be used.
15991 */
15992 -static inline int user_mode(struct pt_regs *regs)
15993 +static inline int user_mode_novm(struct pt_regs *regs)
15994 {
15995 #ifdef CONFIG_X86_32
15996 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
15997 #else
15998 - return !!(regs->cs & 3);
15999 + return !!(regs->cs & SEGMENT_RPL_MASK);
16000 #endif
16001 }
16002
16003 -static inline int user_mode_vm(struct pt_regs *regs)
16004 +static inline int user_mode(struct pt_regs *regs)
16005 {
16006 #ifdef CONFIG_X86_32
16007 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
16008 USER_RPL;
16009 #else
16010 - return user_mode(regs);
16011 + return user_mode_novm(regs);
16012 #endif
16013 }
16014
16015 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
16016 #ifdef CONFIG_X86_64
16017 static inline bool user_64bit_mode(struct pt_regs *regs)
16018 {
16019 + unsigned long cs = regs->cs & 0xffff;
16020 #ifndef CONFIG_PARAVIRT
16021 /*
16022 * On non-paravirt systems, this is the only long mode CPL 3
16023 * selector. We do not allow long mode selectors in the LDT.
16024 */
16025 - return regs->cs == __USER_CS;
16026 + return cs == __USER_CS;
16027 #else
16028 /* Headers are too twisted for this to go in paravirt.h. */
16029 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
16030 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
16031 #endif
16032 }
16033
16034 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
16035 * Traps from the kernel do not save sp and ss.
16036 * Use the helper function to retrieve sp.
16037 */
16038 - if (offset == offsetof(struct pt_regs, sp) &&
16039 - regs->cs == __KERNEL_CS)
16040 - return kernel_stack_pointer(regs);
16041 + if (offset == offsetof(struct pt_regs, sp)) {
16042 + unsigned long cs = regs->cs & 0xffff;
16043 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
16044 + return kernel_stack_pointer(regs);
16045 + }
16046 #endif
16047 return *(unsigned long *)((unsigned long)regs + offset);
16048 }
16049 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
16050 index 9c6b890..5305f53 100644
16051 --- a/arch/x86/include/asm/realmode.h
16052 +++ b/arch/x86/include/asm/realmode.h
16053 @@ -22,16 +22,14 @@ struct real_mode_header {
16054 #endif
16055 /* APM/BIOS reboot */
16056 u32 machine_real_restart_asm;
16057 -#ifdef CONFIG_X86_64
16058 u32 machine_real_restart_seg;
16059 -#endif
16060 };
16061
16062 /* This must match data at trampoline_32/64.S */
16063 struct trampoline_header {
16064 #ifdef CONFIG_X86_32
16065 u32 start;
16066 - u16 gdt_pad;
16067 + u16 boot_cs;
16068 u16 gdt_limit;
16069 u32 gdt_base;
16070 #else
16071 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
16072 index a82c4f1..ac45053 100644
16073 --- a/arch/x86/include/asm/reboot.h
16074 +++ b/arch/x86/include/asm/reboot.h
16075 @@ -6,13 +6,13 @@
16076 struct pt_regs;
16077
16078 struct machine_ops {
16079 - void (*restart)(char *cmd);
16080 - void (*halt)(void);
16081 - void (*power_off)(void);
16082 + void (* __noreturn restart)(char *cmd);
16083 + void (* __noreturn halt)(void);
16084 + void (* __noreturn power_off)(void);
16085 void (*shutdown)(void);
16086 void (*crash_shutdown)(struct pt_regs *);
16087 - void (*emergency_restart)(void);
16088 -};
16089 + void (* __noreturn emergency_restart)(void);
16090 +} __no_const;
16091
16092 extern struct machine_ops machine_ops;
16093
16094 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
16095 index cad82c9..2e5c5c1 100644
16096 --- a/arch/x86/include/asm/rwsem.h
16097 +++ b/arch/x86/include/asm/rwsem.h
16098 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
16099 {
16100 asm volatile("# beginning down_read\n\t"
16101 LOCK_PREFIX _ASM_INC "(%1)\n\t"
16102 +
16103 +#ifdef CONFIG_PAX_REFCOUNT
16104 + "jno 0f\n"
16105 + LOCK_PREFIX _ASM_DEC "(%1)\n"
16106 + "int $4\n0:\n"
16107 + _ASM_EXTABLE(0b, 0b)
16108 +#endif
16109 +
16110 /* adds 0x00000001 */
16111 " jns 1f\n"
16112 " call call_rwsem_down_read_failed\n"
16113 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
16114 "1:\n\t"
16115 " mov %1,%2\n\t"
16116 " add %3,%2\n\t"
16117 +
16118 +#ifdef CONFIG_PAX_REFCOUNT
16119 + "jno 0f\n"
16120 + "sub %3,%2\n"
16121 + "int $4\n0:\n"
16122 + _ASM_EXTABLE(0b, 0b)
16123 +#endif
16124 +
16125 " jle 2f\n\t"
16126 LOCK_PREFIX " cmpxchg %2,%0\n\t"
16127 " jnz 1b\n\t"
16128 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
16129 long tmp;
16130 asm volatile("# beginning down_write\n\t"
16131 LOCK_PREFIX " xadd %1,(%2)\n\t"
16132 +
16133 +#ifdef CONFIG_PAX_REFCOUNT
16134 + "jno 0f\n"
16135 + "mov %1,(%2)\n"
16136 + "int $4\n0:\n"
16137 + _ASM_EXTABLE(0b, 0b)
16138 +#endif
16139 +
16140 /* adds 0xffff0001, returns the old value */
16141 " test " __ASM_SEL(%w1,%k1) "," __ASM_SEL(%w1,%k1) "\n\t"
16142 /* was the active mask 0 before? */
16143 @@ -155,6 +179,14 @@ static inline void __up_read(struct rw_semaphore *sem)
16144 long tmp;
16145 asm volatile("# beginning __up_read\n\t"
16146 LOCK_PREFIX " xadd %1,(%2)\n\t"
16147 +
16148 +#ifdef CONFIG_PAX_REFCOUNT
16149 + "jno 0f\n"
16150 + "mov %1,(%2)\n"
16151 + "int $4\n0:\n"
16152 + _ASM_EXTABLE(0b, 0b)
16153 +#endif
16154 +
16155 /* subtracts 1, returns the old value */
16156 " jns 1f\n\t"
16157 " call call_rwsem_wake\n" /* expects old value in %edx */
16158 @@ -173,6 +205,14 @@ static inline void __up_write(struct rw_semaphore *sem)
16159 long tmp;
16160 asm volatile("# beginning __up_write\n\t"
16161 LOCK_PREFIX " xadd %1,(%2)\n\t"
16162 +
16163 +#ifdef CONFIG_PAX_REFCOUNT
16164 + "jno 0f\n"
16165 + "mov %1,(%2)\n"
16166 + "int $4\n0:\n"
16167 + _ASM_EXTABLE(0b, 0b)
16168 +#endif
16169 +
16170 /* subtracts 0xffff0001, returns the old value */
16171 " jns 1f\n\t"
16172 " call call_rwsem_wake\n" /* expects old value in %edx */
16173 @@ -190,6 +230,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
16174 {
16175 asm volatile("# beginning __downgrade_write\n\t"
16176 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
16177 +
16178 +#ifdef CONFIG_PAX_REFCOUNT
16179 + "jno 0f\n"
16180 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
16181 + "int $4\n0:\n"
16182 + _ASM_EXTABLE(0b, 0b)
16183 +#endif
16184 +
16185 /*
16186 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
16187 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
16188 @@ -208,7 +256,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
16189 */
16190 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
16191 {
16192 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
16193 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
16194 +
16195 +#ifdef CONFIG_PAX_REFCOUNT
16196 + "jno 0f\n"
16197 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
16198 + "int $4\n0:\n"
16199 + _ASM_EXTABLE(0b, 0b)
16200 +#endif
16201 +
16202 : "+m" (sem->count)
16203 : "er" (delta));
16204 }
16205 @@ -218,7 +274,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
16206 */
16207 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
16208 {
16209 - return delta + xadd(&sem->count, delta);
16210 + return delta + xadd_check_overflow(&sem->count, delta);
16211 }
16212
16213 #endif /* __KERNEL__ */
16214 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
16215 index c48a950..bc40804 100644
16216 --- a/arch/x86/include/asm/segment.h
16217 +++ b/arch/x86/include/asm/segment.h
16218 @@ -64,10 +64,15 @@
16219 * 26 - ESPFIX small SS
16220 * 27 - per-cpu [ offset to per-cpu data area ]
16221 * 28 - stack_canary-20 [ for stack protector ]
16222 - * 29 - unused
16223 - * 30 - unused
16224 + * 29 - PCI BIOS CS
16225 + * 30 - PCI BIOS DS
16226 * 31 - TSS for double fault handler
16227 */
16228 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
16229 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
16230 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
16231 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
16232 +
16233 #define GDT_ENTRY_TLS_MIN 6
16234 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
16235
16236 @@ -79,6 +84,8 @@
16237
16238 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
16239
16240 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
16241 +
16242 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
16243
16244 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
16245 @@ -104,6 +111,12 @@
16246 #define __KERNEL_STACK_CANARY 0
16247 #endif
16248
16249 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
16250 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
16251 +
16252 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
16253 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
16254 +
16255 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
16256
16257 /*
16258 @@ -141,7 +154,7 @@
16259 */
16260
16261 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
16262 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
16263 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
16264
16265
16266 #else
16267 @@ -165,6 +178,8 @@
16268 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
16269 #define __USER32_DS __USER_DS
16270
16271 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
16272 +
16273 #define GDT_ENTRY_TSS 8 /* needs two entries */
16274 #define GDT_ENTRY_LDT 10 /* needs two entries */
16275 #define GDT_ENTRY_TLS_MIN 12
16276 @@ -173,6 +188,8 @@
16277 #define GDT_ENTRY_PER_CPU 15 /* Abused to load per CPU data from limit */
16278 #define __PER_CPU_SEG (GDT_ENTRY_PER_CPU * 8 + 3)
16279
16280 +#define GDT_ENTRY_UDEREF_KERNEL_DS 16
16281 +
16282 /* TLS indexes for 64bit - hardcoded in arch_prctl */
16283 #define FS_TLS 0
16284 #define GS_TLS 1
16285 @@ -180,12 +197,14 @@
16286 #define GS_TLS_SEL ((GDT_ENTRY_TLS_MIN+GS_TLS)*8 + 3)
16287 #define FS_TLS_SEL ((GDT_ENTRY_TLS_MIN+FS_TLS)*8 + 3)
16288
16289 -#define GDT_ENTRIES 16
16290 +#define GDT_ENTRIES 17
16291
16292 #endif
16293
16294 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
16295 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
16296 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
16297 +#define __UDEREF_KERNEL_DS (GDT_ENTRY_UDEREF_KERNEL_DS*8)
16298 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
16299 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
16300 #ifndef CONFIG_PARAVIRT
16301 @@ -265,7 +284,7 @@ static inline unsigned long get_limit(unsigned long segment)
16302 {
16303 unsigned long __limit;
16304 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
16305 - return __limit + 1;
16306 + return __limit;
16307 }
16308
16309 #endif /* !__ASSEMBLY__ */
16310 diff --git a/arch/x86/include/asm/smap.h b/arch/x86/include/asm/smap.h
16311 index 8d3120f..352b440 100644
16312 --- a/arch/x86/include/asm/smap.h
16313 +++ b/arch/x86/include/asm/smap.h
16314 @@ -25,11 +25,40 @@
16315
16316 #include <asm/alternative-asm.h>
16317
16318 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16319 +#define ASM_PAX_OPEN_USERLAND \
16320 + 661: jmp 663f; \
16321 + .pushsection .altinstr_replacement, "a" ; \
16322 + 662: pushq %rax; nop; \
16323 + .popsection ; \
16324 + .pushsection .altinstructions, "a" ; \
16325 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
16326 + .popsection ; \
16327 + call __pax_open_userland; \
16328 + popq %rax; \
16329 + 663:
16330 +
16331 +#define ASM_PAX_CLOSE_USERLAND \
16332 + 661: jmp 663f; \
16333 + .pushsection .altinstr_replacement, "a" ; \
16334 + 662: pushq %rax; nop; \
16335 + .popsection; \
16336 + .pushsection .altinstructions, "a" ; \
16337 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
16338 + .popsection; \
16339 + call __pax_close_userland; \
16340 + popq %rax; \
16341 + 663:
16342 +#else
16343 +#define ASM_PAX_OPEN_USERLAND
16344 +#define ASM_PAX_CLOSE_USERLAND
16345 +#endif
16346 +
16347 #ifdef CONFIG_X86_SMAP
16348
16349 #define ASM_CLAC \
16350 661: ASM_NOP3 ; \
16351 - .pushsection .altinstr_replacement, "ax" ; \
16352 + .pushsection .altinstr_replacement, "a" ; \
16353 662: __ASM_CLAC ; \
16354 .popsection ; \
16355 .pushsection .altinstructions, "a" ; \
16356 @@ -38,7 +67,7 @@
16357
16358 #define ASM_STAC \
16359 661: ASM_NOP3 ; \
16360 - .pushsection .altinstr_replacement, "ax" ; \
16361 + .pushsection .altinstr_replacement, "a" ; \
16362 662: __ASM_STAC ; \
16363 .popsection ; \
16364 .pushsection .altinstructions, "a" ; \
16365 @@ -56,6 +85,37 @@
16366
16367 #include <asm/alternative.h>
16368
16369 +#define __HAVE_ARCH_PAX_OPEN_USERLAND
16370 +#define __HAVE_ARCH_PAX_CLOSE_USERLAND
16371 +
16372 +extern void __pax_open_userland(void);
16373 +static __always_inline unsigned long pax_open_userland(void)
16374 +{
16375 +
16376 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16377 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[open]", X86_FEATURE_STRONGUDEREF)
16378 + :
16379 + : [open] "i" (__pax_open_userland)
16380 + : "memory", "rax");
16381 +#endif
16382 +
16383 + return 0;
16384 +}
16385 +
16386 +extern void __pax_close_userland(void);
16387 +static __always_inline unsigned long pax_close_userland(void)
16388 +{
16389 +
16390 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16391 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[close]", X86_FEATURE_STRONGUDEREF)
16392 + :
16393 + : [close] "i" (__pax_close_userland)
16394 + : "memory", "rax");
16395 +#endif
16396 +
16397 + return 0;
16398 +}
16399 +
16400 #ifdef CONFIG_X86_SMAP
16401
16402 static __always_inline void clac(void)
16403 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
16404 index b073aae..39f9bdd 100644
16405 --- a/arch/x86/include/asm/smp.h
16406 +++ b/arch/x86/include/asm/smp.h
16407 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
16408 /* cpus sharing the last level cache: */
16409 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
16410 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
16411 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
16412 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
16413
16414 static inline struct cpumask *cpu_sibling_mask(int cpu)
16415 {
16416 @@ -79,7 +79,7 @@ struct smp_ops {
16417
16418 void (*send_call_func_ipi)(const struct cpumask *mask);
16419 void (*send_call_func_single_ipi)(int cpu);
16420 -};
16421 +} __no_const;
16422
16423 /* Globals due to paravirt */
16424 extern void set_cpu_sibling_map(int cpu);
16425 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus __cpuinitdata;
16426 extern int safe_smp_processor_id(void);
16427
16428 #elif defined(CONFIG_X86_64_SMP)
16429 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
16430 -
16431 -#define stack_smp_processor_id() \
16432 -({ \
16433 - struct thread_info *ti; \
16434 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
16435 - ti->cpu; \
16436 -})
16437 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
16438 +#define stack_smp_processor_id() raw_smp_processor_id()
16439 #define safe_smp_processor_id() smp_processor_id()
16440
16441 #endif
16442 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
16443 index 33692ea..350a534 100644
16444 --- a/arch/x86/include/asm/spinlock.h
16445 +++ b/arch/x86/include/asm/spinlock.h
16446 @@ -172,6 +172,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
16447 static inline void arch_read_lock(arch_rwlock_t *rw)
16448 {
16449 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
16450 +
16451 +#ifdef CONFIG_PAX_REFCOUNT
16452 + "jno 0f\n"
16453 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
16454 + "int $4\n0:\n"
16455 + _ASM_EXTABLE(0b, 0b)
16456 +#endif
16457 +
16458 "jns 1f\n"
16459 "call __read_lock_failed\n\t"
16460 "1:\n"
16461 @@ -181,6 +189,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
16462 static inline void arch_write_lock(arch_rwlock_t *rw)
16463 {
16464 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
16465 +
16466 +#ifdef CONFIG_PAX_REFCOUNT
16467 + "jno 0f\n"
16468 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
16469 + "int $4\n0:\n"
16470 + _ASM_EXTABLE(0b, 0b)
16471 +#endif
16472 +
16473 "jz 1f\n"
16474 "call __write_lock_failed\n\t"
16475 "1:\n"
16476 @@ -210,13 +226,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
16477
16478 static inline void arch_read_unlock(arch_rwlock_t *rw)
16479 {
16480 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
16481 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
16482 +
16483 +#ifdef CONFIG_PAX_REFCOUNT
16484 + "jno 0f\n"
16485 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
16486 + "int $4\n0:\n"
16487 + _ASM_EXTABLE(0b, 0b)
16488 +#endif
16489 +
16490 :"+m" (rw->lock) : : "memory");
16491 }
16492
16493 static inline void arch_write_unlock(arch_rwlock_t *rw)
16494 {
16495 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
16496 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
16497 +
16498 +#ifdef CONFIG_PAX_REFCOUNT
16499 + "jno 0f\n"
16500 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
16501 + "int $4\n0:\n"
16502 + _ASM_EXTABLE(0b, 0b)
16503 +#endif
16504 +
16505 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
16506 }
16507
16508 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
16509 index 6a99859..03cb807 100644
16510 --- a/arch/x86/include/asm/stackprotector.h
16511 +++ b/arch/x86/include/asm/stackprotector.h
16512 @@ -47,7 +47,7 @@
16513 * head_32 for boot CPU and setup_per_cpu_areas() for others.
16514 */
16515 #define GDT_STACK_CANARY_INIT \
16516 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
16517 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
16518
16519 /*
16520 * Initialize the stackprotector canary value.
16521 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
16522
16523 static inline void load_stack_canary_segment(void)
16524 {
16525 -#ifdef CONFIG_X86_32
16526 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
16527 asm volatile ("mov %0, %%gs" : : "r" (0));
16528 #endif
16529 }
16530 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
16531 index 70bbe39..4ae2bd4 100644
16532 --- a/arch/x86/include/asm/stacktrace.h
16533 +++ b/arch/x86/include/asm/stacktrace.h
16534 @@ -11,28 +11,20 @@
16535
16536 extern int kstack_depth_to_print;
16537
16538 -struct thread_info;
16539 +struct task_struct;
16540 struct stacktrace_ops;
16541
16542 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
16543 - unsigned long *stack,
16544 - unsigned long bp,
16545 - const struct stacktrace_ops *ops,
16546 - void *data,
16547 - unsigned long *end,
16548 - int *graph);
16549 +typedef unsigned long walk_stack_t(struct task_struct *task,
16550 + void *stack_start,
16551 + unsigned long *stack,
16552 + unsigned long bp,
16553 + const struct stacktrace_ops *ops,
16554 + void *data,
16555 + unsigned long *end,
16556 + int *graph);
16557
16558 -extern unsigned long
16559 -print_context_stack(struct thread_info *tinfo,
16560 - unsigned long *stack, unsigned long bp,
16561 - const struct stacktrace_ops *ops, void *data,
16562 - unsigned long *end, int *graph);
16563 -
16564 -extern unsigned long
16565 -print_context_stack_bp(struct thread_info *tinfo,
16566 - unsigned long *stack, unsigned long bp,
16567 - const struct stacktrace_ops *ops, void *data,
16568 - unsigned long *end, int *graph);
16569 +extern walk_stack_t print_context_stack;
16570 +extern walk_stack_t print_context_stack_bp;
16571
16572 /* Generic stack tracer with callbacks */
16573
16574 @@ -40,7 +32,7 @@ struct stacktrace_ops {
16575 void (*address)(void *data, unsigned long address, int reliable);
16576 /* On negative return stop dumping */
16577 int (*stack)(void *data, char *name);
16578 - walk_stack_t walk_stack;
16579 + walk_stack_t *walk_stack;
16580 };
16581
16582 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
16583 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
16584 index 4ec45b3..a4f0a8a 100644
16585 --- a/arch/x86/include/asm/switch_to.h
16586 +++ b/arch/x86/include/asm/switch_to.h
16587 @@ -108,7 +108,7 @@ do { \
16588 "call __switch_to\n\t" \
16589 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
16590 __switch_canary \
16591 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
16592 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
16593 "movq %%rax,%%rdi\n\t" \
16594 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
16595 "jnz ret_from_fork\n\t" \
16596 @@ -119,7 +119,7 @@ do { \
16597 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
16598 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
16599 [_tif_fork] "i" (_TIF_FORK), \
16600 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
16601 + [thread_info] "m" (current_tinfo), \
16602 [current_task] "m" (current_task) \
16603 __switch_canary_iparam \
16604 : "memory", "cc" __EXTRA_CLOBBER)
16605 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
16606 index a1df6e8..e002940 100644
16607 --- a/arch/x86/include/asm/thread_info.h
16608 +++ b/arch/x86/include/asm/thread_info.h
16609 @@ -10,6 +10,7 @@
16610 #include <linux/compiler.h>
16611 #include <asm/page.h>
16612 #include <asm/types.h>
16613 +#include <asm/percpu.h>
16614
16615 /*
16616 * low level task data that entry.S needs immediate access to
16617 @@ -23,7 +24,6 @@ struct exec_domain;
16618 #include <linux/atomic.h>
16619
16620 struct thread_info {
16621 - struct task_struct *task; /* main task structure */
16622 struct exec_domain *exec_domain; /* execution domain */
16623 __u32 flags; /* low level flags */
16624 __u32 status; /* thread synchronous flags */
16625 @@ -33,19 +33,13 @@ struct thread_info {
16626 mm_segment_t addr_limit;
16627 struct restart_block restart_block;
16628 void __user *sysenter_return;
16629 -#ifdef CONFIG_X86_32
16630 - unsigned long previous_esp; /* ESP of the previous stack in
16631 - case of nested (IRQ) stacks
16632 - */
16633 - __u8 supervisor_stack[0];
16634 -#endif
16635 + unsigned long lowest_stack;
16636 unsigned int sig_on_uaccess_error:1;
16637 unsigned int uaccess_err:1; /* uaccess failed */
16638 };
16639
16640 -#define INIT_THREAD_INFO(tsk) \
16641 +#define INIT_THREAD_INFO \
16642 { \
16643 - .task = &tsk, \
16644 .exec_domain = &default_exec_domain, \
16645 .flags = 0, \
16646 .cpu = 0, \
16647 @@ -56,7 +50,7 @@ struct thread_info {
16648 }, \
16649 }
16650
16651 -#define init_thread_info (init_thread_union.thread_info)
16652 +#define init_thread_info (init_thread_union.stack)
16653 #define init_stack (init_thread_union.stack)
16654
16655 #else /* !__ASSEMBLY__ */
16656 @@ -97,6 +91,7 @@ struct thread_info {
16657 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
16658 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
16659 #define TIF_X32 30 /* 32-bit native x86-64 binary */
16660 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
16661
16662 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
16663 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
16664 @@ -121,17 +116,18 @@ struct thread_info {
16665 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
16666 #define _TIF_ADDR32 (1 << TIF_ADDR32)
16667 #define _TIF_X32 (1 << TIF_X32)
16668 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
16669
16670 /* work to do in syscall_trace_enter() */
16671 #define _TIF_WORK_SYSCALL_ENTRY \
16672 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
16673 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
16674 - _TIF_NOHZ)
16675 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
16676
16677 /* work to do in syscall_trace_leave() */
16678 #define _TIF_WORK_SYSCALL_EXIT \
16679 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
16680 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
16681 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
16682
16683 /* work to do on interrupt/exception return */
16684 #define _TIF_WORK_MASK \
16685 @@ -142,7 +138,7 @@ struct thread_info {
16686 /* work to do on any return to user space */
16687 #define _TIF_ALLWORK_MASK \
16688 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
16689 - _TIF_NOHZ)
16690 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
16691
16692 /* Only used for 64 bit */
16693 #define _TIF_DO_NOTIFY_MASK \
16694 @@ -158,45 +154,40 @@ struct thread_info {
16695
16696 #define PREEMPT_ACTIVE 0x10000000
16697
16698 -#ifdef CONFIG_X86_32
16699 -
16700 -#define STACK_WARN (THREAD_SIZE/8)
16701 -/*
16702 - * macros/functions for gaining access to the thread information structure
16703 - *
16704 - * preempt_count needs to be 1 initially, until the scheduler is functional.
16705 - */
16706 -#ifndef __ASSEMBLY__
16707 -
16708 -
16709 -/* how to get the current stack pointer from C */
16710 -register unsigned long current_stack_pointer asm("esp") __used;
16711 -
16712 -/* how to get the thread information struct from C */
16713 -static inline struct thread_info *current_thread_info(void)
16714 -{
16715 - return (struct thread_info *)
16716 - (current_stack_pointer & ~(THREAD_SIZE - 1));
16717 -}
16718 -
16719 -#else /* !__ASSEMBLY__ */
16720 -
16721 +#ifdef __ASSEMBLY__
16722 /* how to get the thread information struct from ASM */
16723 #define GET_THREAD_INFO(reg) \
16724 - movl $-THREAD_SIZE, reg; \
16725 - andl %esp, reg
16726 + mov PER_CPU_VAR(current_tinfo), reg
16727
16728 /* use this one if reg already contains %esp */
16729 -#define GET_THREAD_INFO_WITH_ESP(reg) \
16730 - andl $-THREAD_SIZE, reg
16731 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
16732 +#else
16733 +/* how to get the thread information struct from C */
16734 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
16735 +
16736 +static __always_inline struct thread_info *current_thread_info(void)
16737 +{
16738 + return this_cpu_read_stable(current_tinfo);
16739 +}
16740 +#endif
16741 +
16742 +#ifdef CONFIG_X86_32
16743 +
16744 +#define STACK_WARN (THREAD_SIZE/8)
16745 +/*
16746 + * macros/functions for gaining access to the thread information structure
16747 + *
16748 + * preempt_count needs to be 1 initially, until the scheduler is functional.
16749 + */
16750 +#ifndef __ASSEMBLY__
16751 +
16752 +/* how to get the current stack pointer from C */
16753 +register unsigned long current_stack_pointer asm("esp") __used;
16754
16755 #endif
16756
16757 #else /* X86_32 */
16758
16759 -#include <asm/percpu.h>
16760 -#define KERNEL_STACK_OFFSET (5*8)
16761 -
16762 /*
16763 * macros/functions for gaining access to the thread information structure
16764 * preempt_count needs to be 1 initially, until the scheduler is functional.
16765 @@ -204,27 +195,8 @@ static inline struct thread_info *current_thread_info(void)
16766 #ifndef __ASSEMBLY__
16767 DECLARE_PER_CPU(unsigned long, kernel_stack);
16768
16769 -static inline struct thread_info *current_thread_info(void)
16770 -{
16771 - struct thread_info *ti;
16772 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
16773 - KERNEL_STACK_OFFSET - THREAD_SIZE);
16774 - return ti;
16775 -}
16776 -
16777 -#else /* !__ASSEMBLY__ */
16778 -
16779 -/* how to get the thread information struct from ASM */
16780 -#define GET_THREAD_INFO(reg) \
16781 - movq PER_CPU_VAR(kernel_stack),reg ; \
16782 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
16783 -
16784 -/*
16785 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
16786 - * a certain register (to be used in assembler memory operands).
16787 - */
16788 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
16789 -
16790 +/* how to get the current stack pointer from C */
16791 +register unsigned long current_stack_pointer asm("rsp") __used;
16792 #endif
16793
16794 #endif /* !X86_32 */
16795 @@ -283,5 +255,12 @@ static inline bool is_ia32_task(void)
16796 extern void arch_task_cache_init(void);
16797 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
16798 extern void arch_release_task_struct(struct task_struct *tsk);
16799 +
16800 +#define __HAVE_THREAD_FUNCTIONS
16801 +#define task_thread_info(task) (&(task)->tinfo)
16802 +#define task_stack_page(task) ((task)->stack)
16803 +#define setup_thread_stack(p, org) do {} while (0)
16804 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
16805 +
16806 #endif
16807 #endif /* _ASM_X86_THREAD_INFO_H */
16808 diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h
16809 index 50a7fc0..7c437a7 100644
16810 --- a/arch/x86/include/asm/tlbflush.h
16811 +++ b/arch/x86/include/asm/tlbflush.h
16812 @@ -17,18 +17,40 @@
16813
16814 static inline void __native_flush_tlb(void)
16815 {
16816 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
16817 + unsigned long descriptor[2];
16818 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_MONGLOBAL) : "memory");
16819 + return;
16820 + }
16821 +
16822 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16823 + if (static_cpu_has(X86_FEATURE_PCID)) {
16824 + unsigned int cpu = raw_get_cpu();
16825 +
16826 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
16827 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
16828 + raw_put_cpu_no_resched();
16829 + return;
16830 + }
16831 +#endif
16832 +
16833 native_write_cr3(native_read_cr3());
16834 }
16835
16836 static inline void __native_flush_tlb_global_irq_disabled(void)
16837 {
16838 - unsigned long cr4;
16839 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
16840 + unsigned long descriptor[2];
16841 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_GLOBAL) : "memory");
16842 + } else {
16843 + unsigned long cr4;
16844
16845 - cr4 = native_read_cr4();
16846 - /* clear PGE */
16847 - native_write_cr4(cr4 & ~X86_CR4_PGE);
16848 - /* write old PGE again and flush TLBs */
16849 - native_write_cr4(cr4);
16850 + cr4 = native_read_cr4();
16851 + /* clear PGE */
16852 + native_write_cr4(cr4 & ~X86_CR4_PGE);
16853 + /* write old PGE again and flush TLBs */
16854 + native_write_cr4(cr4);
16855 + }
16856 }
16857
16858 static inline void __native_flush_tlb_global(void)
16859 @@ -49,6 +71,42 @@ static inline void __native_flush_tlb_global(void)
16860
16861 static inline void __native_flush_tlb_single(unsigned long addr)
16862 {
16863 +
16864 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
16865 + unsigned long descriptor[2];
16866 +
16867 + descriptor[0] = PCID_KERNEL;
16868 + descriptor[1] = addr;
16869 +
16870 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16871 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) || addr >= TASK_SIZE_MAX) {
16872 + if (addr < TASK_SIZE_MAX)
16873 + descriptor[1] += pax_user_shadow_base;
16874 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
16875 + }
16876 +
16877 + descriptor[0] = PCID_USER;
16878 + descriptor[1] = addr;
16879 +#endif
16880 +
16881 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
16882 + return;
16883 + }
16884 +
16885 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16886 + if (static_cpu_has(X86_FEATURE_PCID)) {
16887 + unsigned int cpu = raw_get_cpu();
16888 +
16889 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
16890 + asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
16891 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
16892 + raw_put_cpu_no_resched();
16893 +
16894 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) && addr < TASK_SIZE_MAX)
16895 + addr += pax_user_shadow_base;
16896 + }
16897 +#endif
16898 +
16899 asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
16900 }
16901
16902 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
16903 index 5ee2687..74590b9 100644
16904 --- a/arch/x86/include/asm/uaccess.h
16905 +++ b/arch/x86/include/asm/uaccess.h
16906 @@ -7,6 +7,7 @@
16907 #include <linux/compiler.h>
16908 #include <linux/thread_info.h>
16909 #include <linux/string.h>
16910 +#include <linux/sched.h>
16911 #include <asm/asm.h>
16912 #include <asm/page.h>
16913 #include <asm/smap.h>
16914 @@ -29,7 +30,12 @@
16915
16916 #define get_ds() (KERNEL_DS)
16917 #define get_fs() (current_thread_info()->addr_limit)
16918 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
16919 +void __set_fs(mm_segment_t x);
16920 +void set_fs(mm_segment_t x);
16921 +#else
16922 #define set_fs(x) (current_thread_info()->addr_limit = (x))
16923 +#endif
16924
16925 #define segment_eq(a, b) ((a).seg == (b).seg)
16926
16927 @@ -77,8 +83,33 @@
16928 * checks that the pointer is in the user space range - after calling
16929 * this function, memory access functions may still return -EFAULT.
16930 */
16931 -#define access_ok(type, addr, size) \
16932 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
16933 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
16934 +#define access_ok(type, addr, size) \
16935 +({ \
16936 + long __size = size; \
16937 + unsigned long __addr = (unsigned long)addr; \
16938 + unsigned long __addr_ao = __addr & PAGE_MASK; \
16939 + unsigned long __end_ao = __addr + __size - 1; \
16940 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
16941 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
16942 + while(__addr_ao <= __end_ao) { \
16943 + char __c_ao; \
16944 + __addr_ao += PAGE_SIZE; \
16945 + if (__size > PAGE_SIZE) \
16946 + cond_resched(); \
16947 + if (__get_user(__c_ao, (char __user *)__addr)) \
16948 + break; \
16949 + if (type != VERIFY_WRITE) { \
16950 + __addr = __addr_ao; \
16951 + continue; \
16952 + } \
16953 + if (__put_user(__c_ao, (char __user *)__addr)) \
16954 + break; \
16955 + __addr = __addr_ao; \
16956 + } \
16957 + } \
16958 + __ret_ao; \
16959 +})
16960
16961 /*
16962 * The exception table consists of pairs of addresses relative to the
16963 @@ -165,10 +196,12 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
16964 register __inttype(*(ptr)) __val_gu asm("%edx"); \
16965 __chk_user_ptr(ptr); \
16966 might_fault(); \
16967 + pax_open_userland(); \
16968 asm volatile("call __get_user_%P3" \
16969 : "=a" (__ret_gu), "=r" (__val_gu) \
16970 : "0" (ptr), "i" (sizeof(*(ptr)))); \
16971 (x) = (__typeof__(*(ptr))) __val_gu; \
16972 + pax_close_userland(); \
16973 __ret_gu; \
16974 })
16975
16976 @@ -176,13 +209,21 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
16977 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
16978 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
16979
16980 -
16981 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
16982 +#define __copyuser_seg "gs;"
16983 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
16984 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
16985 +#else
16986 +#define __copyuser_seg
16987 +#define __COPYUSER_SET_ES
16988 +#define __COPYUSER_RESTORE_ES
16989 +#endif
16990
16991 #ifdef CONFIG_X86_32
16992 #define __put_user_asm_u64(x, addr, err, errret) \
16993 asm volatile(ASM_STAC "\n" \
16994 - "1: movl %%eax,0(%2)\n" \
16995 - "2: movl %%edx,4(%2)\n" \
16996 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
16997 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
16998 "3: " ASM_CLAC "\n" \
16999 ".section .fixup,\"ax\"\n" \
17000 "4: movl %3,%0\n" \
17001 @@ -195,8 +236,8 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
17002
17003 #define __put_user_asm_ex_u64(x, addr) \
17004 asm volatile(ASM_STAC "\n" \
17005 - "1: movl %%eax,0(%1)\n" \
17006 - "2: movl %%edx,4(%1)\n" \
17007 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
17008 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
17009 "3: " ASM_CLAC "\n" \
17010 _ASM_EXTABLE_EX(1b, 2b) \
17011 _ASM_EXTABLE_EX(2b, 3b) \
17012 @@ -246,7 +287,8 @@ extern void __put_user_8(void);
17013 __typeof__(*(ptr)) __pu_val; \
17014 __chk_user_ptr(ptr); \
17015 might_fault(); \
17016 - __pu_val = x; \
17017 + __pu_val = (x); \
17018 + pax_open_userland(); \
17019 switch (sizeof(*(ptr))) { \
17020 case 1: \
17021 __put_user_x(1, __pu_val, ptr, __ret_pu); \
17022 @@ -264,6 +306,7 @@ extern void __put_user_8(void);
17023 __put_user_x(X, __pu_val, ptr, __ret_pu); \
17024 break; \
17025 } \
17026 + pax_close_userland(); \
17027 __ret_pu; \
17028 })
17029
17030 @@ -344,8 +387,10 @@ do { \
17031 } while (0)
17032
17033 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
17034 +do { \
17035 + pax_open_userland(); \
17036 asm volatile(ASM_STAC "\n" \
17037 - "1: mov"itype" %2,%"rtype"1\n" \
17038 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
17039 "2: " ASM_CLAC "\n" \
17040 ".section .fixup,\"ax\"\n" \
17041 "3: mov %3,%0\n" \
17042 @@ -353,8 +398,10 @@ do { \
17043 " jmp 2b\n" \
17044 ".previous\n" \
17045 _ASM_EXTABLE(1b, 3b) \
17046 - : "=r" (err), ltype(x) \
17047 - : "m" (__m(addr)), "i" (errret), "0" (err))
17048 + : "=r" (err), ltype (x) \
17049 + : "m" (__m(addr)), "i" (errret), "0" (err)); \
17050 + pax_close_userland(); \
17051 +} while (0)
17052
17053 #define __get_user_size_ex(x, ptr, size) \
17054 do { \
17055 @@ -378,7 +425,7 @@ do { \
17056 } while (0)
17057
17058 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
17059 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
17060 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
17061 "2:\n" \
17062 _ASM_EXTABLE_EX(1b, 2b) \
17063 : ltype(x) : "m" (__m(addr)))
17064 @@ -395,13 +442,24 @@ do { \
17065 int __gu_err; \
17066 unsigned long __gu_val; \
17067 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
17068 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
17069 + (x) = (__typeof__(*(ptr)))__gu_val; \
17070 __gu_err; \
17071 })
17072
17073 /* FIXME: this hack is definitely wrong -AK */
17074 struct __large_struct { unsigned long buf[100]; };
17075 -#define __m(x) (*(struct __large_struct __user *)(x))
17076 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17077 +#define ____m(x) \
17078 +({ \
17079 + unsigned long ____x = (unsigned long)(x); \
17080 + if (____x < pax_user_shadow_base) \
17081 + ____x += pax_user_shadow_base; \
17082 + (typeof(x))____x; \
17083 +})
17084 +#else
17085 +#define ____m(x) (x)
17086 +#endif
17087 +#define __m(x) (*(struct __large_struct __user *)____m(x))
17088
17089 /*
17090 * Tell gcc we read from memory instead of writing: this is because
17091 @@ -409,8 +467,10 @@ struct __large_struct { unsigned long buf[100]; };
17092 * aliasing issues.
17093 */
17094 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
17095 +do { \
17096 + pax_open_userland(); \
17097 asm volatile(ASM_STAC "\n" \
17098 - "1: mov"itype" %"rtype"1,%2\n" \
17099 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
17100 "2: " ASM_CLAC "\n" \
17101 ".section .fixup,\"ax\"\n" \
17102 "3: mov %3,%0\n" \
17103 @@ -418,10 +478,12 @@ struct __large_struct { unsigned long buf[100]; };
17104 ".previous\n" \
17105 _ASM_EXTABLE(1b, 3b) \
17106 : "=r"(err) \
17107 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
17108 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err));\
17109 + pax_close_userland(); \
17110 +} while (0)
17111
17112 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
17113 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
17114 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
17115 "2:\n" \
17116 _ASM_EXTABLE_EX(1b, 2b) \
17117 : : ltype(x), "m" (__m(addr)))
17118 @@ -431,11 +493,13 @@ struct __large_struct { unsigned long buf[100]; };
17119 */
17120 #define uaccess_try do { \
17121 current_thread_info()->uaccess_err = 0; \
17122 + pax_open_userland(); \
17123 stac(); \
17124 barrier();
17125
17126 #define uaccess_catch(err) \
17127 clac(); \
17128 + pax_close_userland(); \
17129 (err) |= (current_thread_info()->uaccess_err ? -EFAULT : 0); \
17130 } while (0)
17131
17132 @@ -460,8 +524,12 @@ struct __large_struct { unsigned long buf[100]; };
17133 * On error, the variable @x is set to zero.
17134 */
17135
17136 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17137 +#define __get_user(x, ptr) get_user((x), (ptr))
17138 +#else
17139 #define __get_user(x, ptr) \
17140 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
17141 +#endif
17142
17143 /**
17144 * __put_user: - Write a simple value into user space, with less checking.
17145 @@ -483,8 +551,12 @@ struct __large_struct { unsigned long buf[100]; };
17146 * Returns zero on success, or -EFAULT on error.
17147 */
17148
17149 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17150 +#define __put_user(x, ptr) put_user((x), (ptr))
17151 +#else
17152 #define __put_user(x, ptr) \
17153 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
17154 +#endif
17155
17156 #define __get_user_unaligned __get_user
17157 #define __put_user_unaligned __put_user
17158 @@ -502,7 +574,7 @@ struct __large_struct { unsigned long buf[100]; };
17159 #define get_user_ex(x, ptr) do { \
17160 unsigned long __gue_val; \
17161 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
17162 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
17163 + (x) = (__typeof__(*(ptr)))__gue_val; \
17164 } while (0)
17165
17166 #define put_user_try uaccess_try
17167 @@ -519,8 +591,8 @@ strncpy_from_user(char *dst, const char __user *src, long count);
17168 extern __must_check long strlen_user(const char __user *str);
17169 extern __must_check long strnlen_user(const char __user *str, long n);
17170
17171 -unsigned long __must_check clear_user(void __user *mem, unsigned long len);
17172 -unsigned long __must_check __clear_user(void __user *mem, unsigned long len);
17173 +unsigned long __must_check clear_user(void __user *mem, unsigned long len) __size_overflow(2);
17174 +unsigned long __must_check __clear_user(void __user *mem, unsigned long len) __size_overflow(2);
17175
17176 /*
17177 * movsl can be slow when source and dest are not both 8-byte aligned
17178 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
17179 index 7f760a9..04b1c65 100644
17180 --- a/arch/x86/include/asm/uaccess_32.h
17181 +++ b/arch/x86/include/asm/uaccess_32.h
17182 @@ -11,15 +11,15 @@
17183 #include <asm/page.h>
17184
17185 unsigned long __must_check __copy_to_user_ll
17186 - (void __user *to, const void *from, unsigned long n);
17187 + (void __user *to, const void *from, unsigned long n) __size_overflow(3);
17188 unsigned long __must_check __copy_from_user_ll
17189 - (void *to, const void __user *from, unsigned long n);
17190 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
17191 unsigned long __must_check __copy_from_user_ll_nozero
17192 - (void *to, const void __user *from, unsigned long n);
17193 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
17194 unsigned long __must_check __copy_from_user_ll_nocache
17195 - (void *to, const void __user *from, unsigned long n);
17196 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
17197 unsigned long __must_check __copy_from_user_ll_nocache_nozero
17198 - (void *to, const void __user *from, unsigned long n);
17199 + (void *to, const void __user *from, unsigned long n) __size_overflow(3);
17200
17201 /**
17202 * __copy_to_user_inatomic: - Copy a block of data into user space, with less checking.
17203 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
17204 static __always_inline unsigned long __must_check
17205 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
17206 {
17207 + if ((long)n < 0)
17208 + return n;
17209 +
17210 + check_object_size(from, n, true);
17211 +
17212 if (__builtin_constant_p(n)) {
17213 unsigned long ret;
17214
17215 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
17216 __copy_to_user(void __user *to, const void *from, unsigned long n)
17217 {
17218 might_fault();
17219 +
17220 return __copy_to_user_inatomic(to, from, n);
17221 }
17222
17223 static __always_inline unsigned long
17224 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
17225 {
17226 + if ((long)n < 0)
17227 + return n;
17228 +
17229 /* Avoid zeroing the tail if the copy fails..
17230 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
17231 * but as the zeroing behaviour is only significant when n is not
17232 @@ -137,6 +146,12 @@ static __always_inline unsigned long
17233 __copy_from_user(void *to, const void __user *from, unsigned long n)
17234 {
17235 might_fault();
17236 +
17237 + if ((long)n < 0)
17238 + return n;
17239 +
17240 + check_object_size(to, n, false);
17241 +
17242 if (__builtin_constant_p(n)) {
17243 unsigned long ret;
17244
17245 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
17246 const void __user *from, unsigned long n)
17247 {
17248 might_fault();
17249 +
17250 + if ((long)n < 0)
17251 + return n;
17252 +
17253 if (__builtin_constant_p(n)) {
17254 unsigned long ret;
17255
17256 @@ -181,15 +200,19 @@ static __always_inline unsigned long
17257 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
17258 unsigned long n)
17259 {
17260 - return __copy_from_user_ll_nocache_nozero(to, from, n);
17261 + if ((long)n < 0)
17262 + return n;
17263 +
17264 + return __copy_from_user_ll_nocache_nozero(to, from, n);
17265 }
17266
17267 -unsigned long __must_check copy_to_user(void __user *to,
17268 - const void *from, unsigned long n);
17269 -unsigned long __must_check _copy_from_user(void *to,
17270 - const void __user *from,
17271 - unsigned long n);
17272 -
17273 +extern void copy_to_user_overflow(void)
17274 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
17275 + __compiletime_error("copy_to_user() buffer size is not provably correct")
17276 +#else
17277 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
17278 +#endif
17279 +;
17280
17281 extern void copy_from_user_overflow(void)
17282 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
17283 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
17284 #endif
17285 ;
17286
17287 -static inline unsigned long __must_check copy_from_user(void *to,
17288 - const void __user *from,
17289 - unsigned long n)
17290 +/**
17291 + * copy_to_user: - Copy a block of data into user space.
17292 + * @to: Destination address, in user space.
17293 + * @from: Source address, in kernel space.
17294 + * @n: Number of bytes to copy.
17295 + *
17296 + * Context: User context only. This function may sleep.
17297 + *
17298 + * Copy data from kernel space to user space.
17299 + *
17300 + * Returns number of bytes that could not be copied.
17301 + * On success, this will be zero.
17302 + */
17303 +static inline unsigned long __must_check
17304 +copy_to_user(void __user *to, const void *from, unsigned long n)
17305 {
17306 - int sz = __compiletime_object_size(to);
17307 + size_t sz = __compiletime_object_size(from);
17308
17309 - if (likely(sz == -1 || sz >= n))
17310 - n = _copy_from_user(to, from, n);
17311 - else
17312 + if (unlikely(sz != (size_t)-1 && sz < n))
17313 + copy_to_user_overflow();
17314 + else if (access_ok(VERIFY_WRITE, to, n))
17315 + n = __copy_to_user(to, from, n);
17316 + return n;
17317 +}
17318 +
17319 +/**
17320 + * copy_from_user: - Copy a block of data from user space.
17321 + * @to: Destination address, in kernel space.
17322 + * @from: Source address, in user space.
17323 + * @n: Number of bytes to copy.
17324 + *
17325 + * Context: User context only. This function may sleep.
17326 + *
17327 + * Copy data from user space to kernel space.
17328 + *
17329 + * Returns number of bytes that could not be copied.
17330 + * On success, this will be zero.
17331 + *
17332 + * If some data could not be copied, this function will pad the copied
17333 + * data to the requested size using zero bytes.
17334 + */
17335 +static inline unsigned long __must_check
17336 +copy_from_user(void *to, const void __user *from, unsigned long n)
17337 +{
17338 + size_t sz = __compiletime_object_size(to);
17339 +
17340 + check_object_size(to, n, false);
17341 +
17342 + if (unlikely(sz != (size_t)-1 && sz < n))
17343 copy_from_user_overflow();
17344 -
17345 + else if (access_ok(VERIFY_READ, from, n))
17346 + n = __copy_from_user(to, from, n);
17347 + else if ((long)n > 0)
17348 + memset(to, 0, n);
17349 return n;
17350 }
17351
17352 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
17353 index 142810c..1f2a0a7 100644
17354 --- a/arch/x86/include/asm/uaccess_64.h
17355 +++ b/arch/x86/include/asm/uaccess_64.h
17356 @@ -10,6 +10,9 @@
17357 #include <asm/alternative.h>
17358 #include <asm/cpufeature.h>
17359 #include <asm/page.h>
17360 +#include <asm/pgtable.h>
17361 +
17362 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
17363
17364 /*
17365 * Copy To/From Userspace
17366 @@ -17,13 +20,13 @@
17367
17368 /* Handles exceptions in both to and from, but doesn't do access_ok */
17369 __must_check unsigned long
17370 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
17371 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
17372 __must_check unsigned long
17373 -copy_user_generic_string(void *to, const void *from, unsigned len);
17374 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
17375 __must_check unsigned long
17376 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
17377 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
17378
17379 -static __always_inline __must_check unsigned long
17380 +static __always_inline __must_check __size_overflow(3) unsigned long
17381 copy_user_generic(void *to, const void *from, unsigned len)
17382 {
17383 unsigned ret;
17384 @@ -41,142 +44,204 @@ copy_user_generic(void *to, const void *from, unsigned len)
17385 ASM_OUTPUT2("=a" (ret), "=D" (to), "=S" (from),
17386 "=d" (len)),
17387 "1" (to), "2" (from), "3" (len)
17388 - : "memory", "rcx", "r8", "r9", "r10", "r11");
17389 + : "memory", "rcx", "r8", "r9", "r11");
17390 return ret;
17391 }
17392
17393 +static __always_inline __must_check unsigned long
17394 +__copy_to_user(void __user *to, const void *from, unsigned long len);
17395 +static __always_inline __must_check unsigned long
17396 +__copy_from_user(void *to, const void __user *from, unsigned long len);
17397 __must_check unsigned long
17398 -_copy_to_user(void __user *to, const void *from, unsigned len);
17399 -__must_check unsigned long
17400 -_copy_from_user(void *to, const void __user *from, unsigned len);
17401 -__must_check unsigned long
17402 -copy_in_user(void __user *to, const void __user *from, unsigned len);
17403 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
17404 +
17405 +extern void copy_to_user_overflow(void)
17406 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
17407 + __compiletime_error("copy_to_user() buffer size is not provably correct")
17408 +#else
17409 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
17410 +#endif
17411 +;
17412 +
17413 +extern void copy_from_user_overflow(void)
17414 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
17415 + __compiletime_error("copy_from_user() buffer size is not provably correct")
17416 +#else
17417 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
17418 +#endif
17419 +;
17420
17421 static inline unsigned long __must_check copy_from_user(void *to,
17422 const void __user *from,
17423 unsigned long n)
17424 {
17425 - int sz = __compiletime_object_size(to);
17426 -
17427 might_fault();
17428 - if (likely(sz == -1 || sz >= n))
17429 - n = _copy_from_user(to, from, n);
17430 -#ifdef CONFIG_DEBUG_VM
17431 - else
17432 - WARN(1, "Buffer overflow detected!\n");
17433 -#endif
17434 +
17435 + check_object_size(to, n, false);
17436 +
17437 + if (access_ok(VERIFY_READ, from, n))
17438 + n = __copy_from_user(to, from, n);
17439 + else if (n < INT_MAX)
17440 + memset(to, 0, n);
17441 return n;
17442 }
17443
17444 static __always_inline __must_check
17445 -int copy_to_user(void __user *dst, const void *src, unsigned size)
17446 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
17447 {
17448 might_fault();
17449
17450 - return _copy_to_user(dst, src, size);
17451 + if (access_ok(VERIFY_WRITE, dst, size))
17452 + size = __copy_to_user(dst, src, size);
17453 + return size;
17454 }
17455
17456 static __always_inline __must_check
17457 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
17458 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
17459 {
17460 - int ret = 0;
17461 + size_t sz = __compiletime_object_size(dst);
17462 + unsigned ret = 0;
17463
17464 might_fault();
17465 +
17466 + if (size > INT_MAX)
17467 + return size;
17468 +
17469 + check_object_size(dst, size, false);
17470 +
17471 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17472 + if (!__access_ok(VERIFY_READ, src, size))
17473 + return size;
17474 +#endif
17475 +
17476 + if (unlikely(sz != (size_t)-1 && sz < size)) {
17477 + copy_from_user_overflow();
17478 + return size;
17479 + }
17480 +
17481 if (!__builtin_constant_p(size))
17482 - return copy_user_generic(dst, (__force void *)src, size);
17483 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
17484 switch (size) {
17485 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
17486 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
17487 ret, "b", "b", "=q", 1);
17488 return ret;
17489 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
17490 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
17491 ret, "w", "w", "=r", 2);
17492 return ret;
17493 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
17494 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
17495 ret, "l", "k", "=r", 4);
17496 return ret;
17497 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
17498 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
17499 ret, "q", "", "=r", 8);
17500 return ret;
17501 case 10:
17502 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
17503 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
17504 ret, "q", "", "=r", 10);
17505 if (unlikely(ret))
17506 return ret;
17507 __get_user_asm(*(u16 *)(8 + (char *)dst),
17508 - (u16 __user *)(8 + (char __user *)src),
17509 + (const u16 __user *)(8 + (const char __user *)src),
17510 ret, "w", "w", "=r", 2);
17511 return ret;
17512 case 16:
17513 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
17514 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
17515 ret, "q", "", "=r", 16);
17516 if (unlikely(ret))
17517 return ret;
17518 __get_user_asm(*(u64 *)(8 + (char *)dst),
17519 - (u64 __user *)(8 + (char __user *)src),
17520 + (const u64 __user *)(8 + (const char __user *)src),
17521 ret, "q", "", "=r", 8);
17522 return ret;
17523 default:
17524 - return copy_user_generic(dst, (__force void *)src, size);
17525 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
17526 }
17527 }
17528
17529 static __always_inline __must_check
17530 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
17531 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
17532 {
17533 - int ret = 0;
17534 + size_t sz = __compiletime_object_size(src);
17535 + unsigned ret = 0;
17536
17537 might_fault();
17538 +
17539 + if (size > INT_MAX)
17540 + return size;
17541 +
17542 + check_object_size(src, size, true);
17543 +
17544 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17545 + if (!__access_ok(VERIFY_WRITE, dst, size))
17546 + return size;
17547 +#endif
17548 +
17549 + if (unlikely(sz != (size_t)-1 && sz < size)) {
17550 + copy_to_user_overflow();
17551 + return size;
17552 + }
17553 +
17554 if (!__builtin_constant_p(size))
17555 - return copy_user_generic((__force void *)dst, src, size);
17556 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
17557 switch (size) {
17558 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
17559 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
17560 ret, "b", "b", "iq", 1);
17561 return ret;
17562 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
17563 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
17564 ret, "w", "w", "ir", 2);
17565 return ret;
17566 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
17567 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
17568 ret, "l", "k", "ir", 4);
17569 return ret;
17570 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
17571 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
17572 ret, "q", "", "er", 8);
17573 return ret;
17574 case 10:
17575 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
17576 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
17577 ret, "q", "", "er", 10);
17578 if (unlikely(ret))
17579 return ret;
17580 asm("":::"memory");
17581 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
17582 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
17583 ret, "w", "w", "ir", 2);
17584 return ret;
17585 case 16:
17586 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
17587 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
17588 ret, "q", "", "er", 16);
17589 if (unlikely(ret))
17590 return ret;
17591 asm("":::"memory");
17592 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
17593 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
17594 ret, "q", "", "er", 8);
17595 return ret;
17596 default:
17597 - return copy_user_generic((__force void *)dst, src, size);
17598 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
17599 }
17600 }
17601
17602 static __always_inline __must_check
17603 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
17604 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
17605 {
17606 - int ret = 0;
17607 + unsigned ret = 0;
17608
17609 might_fault();
17610 +
17611 + if (size > INT_MAX)
17612 + return size;
17613 +
17614 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17615 + if (!__access_ok(VERIFY_READ, src, size))
17616 + return size;
17617 + if (!__access_ok(VERIFY_WRITE, dst, size))
17618 + return size;
17619 +#endif
17620 +
17621 if (!__builtin_constant_p(size))
17622 - return copy_user_generic((__force void *)dst,
17623 - (__force void *)src, size);
17624 + return copy_user_generic((__force_kernel void *)____m(dst),
17625 + (__force_kernel const void *)____m(src), size);
17626 switch (size) {
17627 case 1: {
17628 u8 tmp;
17629 - __get_user_asm(tmp, (u8 __user *)src,
17630 + __get_user_asm(tmp, (const u8 __user *)src,
17631 ret, "b", "b", "=q", 1);
17632 if (likely(!ret))
17633 __put_user_asm(tmp, (u8 __user *)dst,
17634 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
17635 }
17636 case 2: {
17637 u16 tmp;
17638 - __get_user_asm(tmp, (u16 __user *)src,
17639 + __get_user_asm(tmp, (const u16 __user *)src,
17640 ret, "w", "w", "=r", 2);
17641 if (likely(!ret))
17642 __put_user_asm(tmp, (u16 __user *)dst,
17643 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
17644
17645 case 4: {
17646 u32 tmp;
17647 - __get_user_asm(tmp, (u32 __user *)src,
17648 + __get_user_asm(tmp, (const u32 __user *)src,
17649 ret, "l", "k", "=r", 4);
17650 if (likely(!ret))
17651 __put_user_asm(tmp, (u32 __user *)dst,
17652 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
17653 }
17654 case 8: {
17655 u64 tmp;
17656 - __get_user_asm(tmp, (u64 __user *)src,
17657 + __get_user_asm(tmp, (const u64 __user *)src,
17658 ret, "q", "", "=r", 8);
17659 if (likely(!ret))
17660 __put_user_asm(tmp, (u64 __user *)dst,
17661 @@ -212,41 +277,72 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
17662 return ret;
17663 }
17664 default:
17665 - return copy_user_generic((__force void *)dst,
17666 - (__force void *)src, size);
17667 + return copy_user_generic((__force_kernel void *)____m(dst),
17668 + (__force_kernel const void *)____m(src), size);
17669 }
17670 }
17671
17672 static __must_check __always_inline int
17673 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
17674 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
17675 {
17676 - return copy_user_generic(dst, (__force const void *)src, size);
17677 + if (size > INT_MAX)
17678 + return size;
17679 +
17680 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17681 + if (!__access_ok(VERIFY_READ, src, size))
17682 + return size;
17683 +#endif
17684 +
17685 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
17686 }
17687
17688 -static __must_check __always_inline int
17689 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
17690 +static __must_check __always_inline unsigned long
17691 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
17692 {
17693 - return copy_user_generic((__force void *)dst, src, size);
17694 + if (size > INT_MAX)
17695 + return size;
17696 +
17697 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17698 + if (!__access_ok(VERIFY_WRITE, dst, size))
17699 + return size;
17700 +#endif
17701 +
17702 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
17703 }
17704
17705 -extern long __copy_user_nocache(void *dst, const void __user *src,
17706 - unsigned size, int zerorest);
17707 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
17708 + unsigned long size, int zerorest) __size_overflow(3);
17709
17710 -static inline int
17711 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
17712 +static inline unsigned long __copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
17713 {
17714 might_sleep();
17715 +
17716 + if (size > INT_MAX)
17717 + return size;
17718 +
17719 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17720 + if (!__access_ok(VERIFY_READ, src, size))
17721 + return size;
17722 +#endif
17723 +
17724 return __copy_user_nocache(dst, src, size, 1);
17725 }
17726
17727 -static inline int
17728 -__copy_from_user_inatomic_nocache(void *dst, const void __user *src,
17729 - unsigned size)
17730 +static inline unsigned long __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
17731 + unsigned long size)
17732 {
17733 + if (size > INT_MAX)
17734 + return size;
17735 +
17736 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17737 + if (!__access_ok(VERIFY_READ, src, size))
17738 + return size;
17739 +#endif
17740 +
17741 return __copy_user_nocache(dst, src, size, 0);
17742 }
17743
17744 -unsigned long
17745 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
17746 +extern unsigned long
17747 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
17748
17749 #endif /* _ASM_X86_UACCESS_64_H */
17750 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
17751 index 5b238981..77fdd78 100644
17752 --- a/arch/x86/include/asm/word-at-a-time.h
17753 +++ b/arch/x86/include/asm/word-at-a-time.h
17754 @@ -11,7 +11,7 @@
17755 * and shift, for example.
17756 */
17757 struct word_at_a_time {
17758 - const unsigned long one_bits, high_bits;
17759 + unsigned long one_bits, high_bits;
17760 };
17761
17762 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
17763 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
17764 index d8d9922..bf6cecb 100644
17765 --- a/arch/x86/include/asm/x86_init.h
17766 +++ b/arch/x86/include/asm/x86_init.h
17767 @@ -129,7 +129,7 @@ struct x86_init_ops {
17768 struct x86_init_timers timers;
17769 struct x86_init_iommu iommu;
17770 struct x86_init_pci pci;
17771 -};
17772 +} __no_const;
17773
17774 /**
17775 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
17776 @@ -140,7 +140,7 @@ struct x86_cpuinit_ops {
17777 void (*setup_percpu_clockev)(void);
17778 void (*early_percpu_clock_init)(void);
17779 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
17780 -};
17781 +} __no_const;
17782
17783 /**
17784 * struct x86_platform_ops - platform specific runtime functions
17785 @@ -166,7 +166,7 @@ struct x86_platform_ops {
17786 void (*save_sched_clock_state)(void);
17787 void (*restore_sched_clock_state)(void);
17788 void (*apic_post_init)(void);
17789 -};
17790 +} __no_const;
17791
17792 struct pci_dev;
17793 struct msi_msg;
17794 @@ -180,7 +180,7 @@ struct x86_msi_ops {
17795 void (*teardown_msi_irqs)(struct pci_dev *dev);
17796 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
17797 int (*setup_hpet_msi)(unsigned int irq, unsigned int id);
17798 -};
17799 +} __no_const;
17800
17801 struct IO_APIC_route_entry;
17802 struct io_apic_irq_attr;
17803 @@ -201,7 +201,7 @@ struct x86_io_apic_ops {
17804 unsigned int destination, int vector,
17805 struct io_apic_irq_attr *attr);
17806 void (*eoi_ioapic_pin)(int apic, int pin, int vector);
17807 -};
17808 +} __no_const;
17809
17810 extern struct x86_init_ops x86_init;
17811 extern struct x86_cpuinit_ops x86_cpuinit;
17812 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
17813 index 0415cda..3b22adc 100644
17814 --- a/arch/x86/include/asm/xsave.h
17815 +++ b/arch/x86/include/asm/xsave.h
17816 @@ -70,8 +70,11 @@ static inline int xsave_user(struct xsave_struct __user *buf)
17817 if (unlikely(err))
17818 return -EFAULT;
17819
17820 + pax_open_userland();
17821 __asm__ __volatile__(ASM_STAC "\n"
17822 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
17823 + "1:"
17824 + __copyuser_seg
17825 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
17826 "2: " ASM_CLAC "\n"
17827 ".section .fixup,\"ax\"\n"
17828 "3: movl $-1,%[err]\n"
17829 @@ -81,18 +84,22 @@ static inline int xsave_user(struct xsave_struct __user *buf)
17830 : [err] "=r" (err)
17831 : "D" (buf), "a" (-1), "d" (-1), "0" (0)
17832 : "memory");
17833 + pax_close_userland();
17834 return err;
17835 }
17836
17837 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
17838 {
17839 int err;
17840 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
17841 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
17842 u32 lmask = mask;
17843 u32 hmask = mask >> 32;
17844
17845 + pax_open_userland();
17846 __asm__ __volatile__(ASM_STAC "\n"
17847 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
17848 + "1:"
17849 + __copyuser_seg
17850 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
17851 "2: " ASM_CLAC "\n"
17852 ".section .fixup,\"ax\"\n"
17853 "3: movl $-1,%[err]\n"
17854 @@ -102,6 +109,7 @@ static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
17855 : [err] "=r" (err)
17856 : "D" (xstate), "a" (lmask), "d" (hmask), "0" (0)
17857 : "memory"); /* memory required? */
17858 + pax_close_userland();
17859 return err;
17860 }
17861
17862 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
17863 index bbae024..e1528f9 100644
17864 --- a/arch/x86/include/uapi/asm/e820.h
17865 +++ b/arch/x86/include/uapi/asm/e820.h
17866 @@ -63,7 +63,7 @@ struct e820map {
17867 #define ISA_START_ADDRESS 0xa0000
17868 #define ISA_END_ADDRESS 0x100000
17869
17870 -#define BIOS_BEGIN 0x000a0000
17871 +#define BIOS_BEGIN 0x000c0000
17872 #define BIOS_END 0x00100000
17873
17874 #define BIOS_ROM_BASE 0xffe00000
17875 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
17876 index 7bd3bd3..5dac791 100644
17877 --- a/arch/x86/kernel/Makefile
17878 +++ b/arch/x86/kernel/Makefile
17879 @@ -22,7 +22,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
17880 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
17881 obj-$(CONFIG_IRQ_WORK) += irq_work.o
17882 obj-y += probe_roms.o
17883 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
17884 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
17885 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
17886 obj-y += syscall_$(BITS).o
17887 obj-$(CONFIG_X86_64) += vsyscall_64.o
17888 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
17889 index 230c8ea..f915130 100644
17890 --- a/arch/x86/kernel/acpi/boot.c
17891 +++ b/arch/x86/kernel/acpi/boot.c
17892 @@ -1361,7 +1361,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
17893 * If your system is blacklisted here, but you find that acpi=force
17894 * works for you, please contact linux-acpi@vger.kernel.org
17895 */
17896 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
17897 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
17898 /*
17899 * Boxes that need ACPI disabled
17900 */
17901 @@ -1436,7 +1436,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
17902 };
17903
17904 /* second table for DMI checks that should run after early-quirks */
17905 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
17906 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
17907 /*
17908 * HP laptops which use a DSDT reporting as HP/SB400/10000,
17909 * which includes some code which overrides all temperature
17910 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
17911 index ec94e11..7fbbec0 100644
17912 --- a/arch/x86/kernel/acpi/sleep.c
17913 +++ b/arch/x86/kernel/acpi/sleep.c
17914 @@ -88,8 +88,12 @@ int acpi_suspend_lowlevel(void)
17915 #else /* CONFIG_64BIT */
17916 #ifdef CONFIG_SMP
17917 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
17918 +
17919 + pax_open_kernel();
17920 early_gdt_descr.address =
17921 (unsigned long)get_cpu_gdt_table(smp_processor_id());
17922 + pax_close_kernel();
17923 +
17924 initial_gs = per_cpu_offset(smp_processor_id());
17925 #endif
17926 initial_code = (unsigned long)wakeup_long64;
17927 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
17928 index d1daa66..59fecba 100644
17929 --- a/arch/x86/kernel/acpi/wakeup_32.S
17930 +++ b/arch/x86/kernel/acpi/wakeup_32.S
17931 @@ -29,13 +29,11 @@ wakeup_pmode_return:
17932 # and restore the stack ... but you need gdt for this to work
17933 movl saved_context_esp, %esp
17934
17935 - movl %cs:saved_magic, %eax
17936 - cmpl $0x12345678, %eax
17937 + cmpl $0x12345678, saved_magic
17938 jne bogus_magic
17939
17940 # jump to place where we left off
17941 - movl saved_eip, %eax
17942 - jmp *%eax
17943 + jmp *(saved_eip)
17944
17945 bogus_magic:
17946 jmp bogus_magic
17947 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
17948 index c15cf9a..0e63558 100644
17949 --- a/arch/x86/kernel/alternative.c
17950 +++ b/arch/x86/kernel/alternative.c
17951 @@ -268,6 +268,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
17952 */
17953 for (a = start; a < end; a++) {
17954 instr = (u8 *)&a->instr_offset + a->instr_offset;
17955 +
17956 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
17957 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
17958 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
17959 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
17960 +#endif
17961 +
17962 replacement = (u8 *)&a->repl_offset + a->repl_offset;
17963 BUG_ON(a->replacementlen > a->instrlen);
17964 BUG_ON(a->instrlen > sizeof(insnbuf));
17965 @@ -299,10 +306,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
17966 for (poff = start; poff < end; poff++) {
17967 u8 *ptr = (u8 *)poff + *poff;
17968
17969 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
17970 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
17971 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
17972 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
17973 +#endif
17974 +
17975 if (!*poff || ptr < text || ptr >= text_end)
17976 continue;
17977 /* turn DS segment override prefix into lock prefix */
17978 - if (*ptr == 0x3e)
17979 + if (*ktla_ktva(ptr) == 0x3e)
17980 text_poke(ptr, ((unsigned char []){0xf0}), 1);
17981 }
17982 mutex_unlock(&text_mutex);
17983 @@ -317,10 +330,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
17984 for (poff = start; poff < end; poff++) {
17985 u8 *ptr = (u8 *)poff + *poff;
17986
17987 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
17988 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
17989 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
17990 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
17991 +#endif
17992 +
17993 if (!*poff || ptr < text || ptr >= text_end)
17994 continue;
17995 /* turn lock prefix into DS segment override prefix */
17996 - if (*ptr == 0xf0)
17997 + if (*ktla_ktva(ptr) == 0xf0)
17998 text_poke(ptr, ((unsigned char []){0x3E}), 1);
17999 }
18000 mutex_unlock(&text_mutex);
18001 @@ -468,7 +487,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
18002
18003 BUG_ON(p->len > MAX_PATCH_LEN);
18004 /* prep the buffer with the original instructions */
18005 - memcpy(insnbuf, p->instr, p->len);
18006 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
18007 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
18008 (unsigned long)p->instr, p->len);
18009
18010 @@ -515,7 +534,7 @@ void __init alternative_instructions(void)
18011 if (!uniproc_patched || num_possible_cpus() == 1)
18012 free_init_pages("SMP alternatives",
18013 (unsigned long)__smp_locks,
18014 - (unsigned long)__smp_locks_end);
18015 + PAGE_ALIGN((unsigned long)__smp_locks_end));
18016 #endif
18017
18018 apply_paravirt(__parainstructions, __parainstructions_end);
18019 @@ -535,13 +554,17 @@ void __init alternative_instructions(void)
18020 * instructions. And on the local CPU you need to be protected again NMI or MCE
18021 * handlers seeing an inconsistent instruction while you patch.
18022 */
18023 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
18024 +void *__kprobes text_poke_early(void *addr, const void *opcode,
18025 size_t len)
18026 {
18027 unsigned long flags;
18028 local_irq_save(flags);
18029 - memcpy(addr, opcode, len);
18030 +
18031 + pax_open_kernel();
18032 + memcpy(ktla_ktva(addr), opcode, len);
18033 sync_core();
18034 + pax_close_kernel();
18035 +
18036 local_irq_restore(flags);
18037 /* Could also do a CLFLUSH here to speed up CPU recovery; but
18038 that causes hangs on some VIA CPUs. */
18039 @@ -563,36 +586,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
18040 */
18041 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
18042 {
18043 - unsigned long flags;
18044 - char *vaddr;
18045 + unsigned char *vaddr = ktla_ktva(addr);
18046 struct page *pages[2];
18047 - int i;
18048 + size_t i;
18049
18050 if (!core_kernel_text((unsigned long)addr)) {
18051 - pages[0] = vmalloc_to_page(addr);
18052 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
18053 + pages[0] = vmalloc_to_page(vaddr);
18054 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
18055 } else {
18056 - pages[0] = virt_to_page(addr);
18057 + pages[0] = virt_to_page(vaddr);
18058 WARN_ON(!PageReserved(pages[0]));
18059 - pages[1] = virt_to_page(addr + PAGE_SIZE);
18060 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
18061 }
18062 BUG_ON(!pages[0]);
18063 - local_irq_save(flags);
18064 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
18065 - if (pages[1])
18066 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
18067 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
18068 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
18069 - clear_fixmap(FIX_TEXT_POKE0);
18070 - if (pages[1])
18071 - clear_fixmap(FIX_TEXT_POKE1);
18072 - local_flush_tlb();
18073 - sync_core();
18074 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
18075 - that causes hangs on some VIA CPUs. */
18076 + text_poke_early(addr, opcode, len);
18077 for (i = 0; i < len; i++)
18078 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
18079 - local_irq_restore(flags);
18080 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
18081 return addr;
18082 }
18083
18084 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
18085 index 904611b..004dde6 100644
18086 --- a/arch/x86/kernel/apic/apic.c
18087 +++ b/arch/x86/kernel/apic/apic.c
18088 @@ -189,7 +189,7 @@ int first_system_vector = 0xfe;
18089 /*
18090 * Debug level, exported for io_apic.c
18091 */
18092 -unsigned int apic_verbosity;
18093 +int apic_verbosity;
18094
18095 int pic_mode;
18096
18097 @@ -1955,7 +1955,7 @@ void smp_error_interrupt(struct pt_regs *regs)
18098 apic_write(APIC_ESR, 0);
18099 v1 = apic_read(APIC_ESR);
18100 ack_APIC_irq();
18101 - atomic_inc(&irq_err_count);
18102 + atomic_inc_unchecked(&irq_err_count);
18103
18104 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
18105 smp_processor_id(), v0 , v1);
18106 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
18107 index 00c77cf..2dc6a2d 100644
18108 --- a/arch/x86/kernel/apic/apic_flat_64.c
18109 +++ b/arch/x86/kernel/apic/apic_flat_64.c
18110 @@ -157,7 +157,7 @@ static int flat_probe(void)
18111 return 1;
18112 }
18113
18114 -static struct apic apic_flat = {
18115 +static struct apic apic_flat __read_only = {
18116 .name = "flat",
18117 .probe = flat_probe,
18118 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
18119 @@ -271,7 +271,7 @@ static int physflat_probe(void)
18120 return 0;
18121 }
18122
18123 -static struct apic apic_physflat = {
18124 +static struct apic apic_physflat __read_only = {
18125
18126 .name = "physical flat",
18127 .probe = physflat_probe,
18128 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
18129 index e145f28..2752888 100644
18130 --- a/arch/x86/kernel/apic/apic_noop.c
18131 +++ b/arch/x86/kernel/apic/apic_noop.c
18132 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
18133 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
18134 }
18135
18136 -struct apic apic_noop = {
18137 +struct apic apic_noop __read_only = {
18138 .name = "noop",
18139 .probe = noop_probe,
18140 .acpi_madt_oem_check = NULL,
18141 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
18142 index d50e364..543bee3 100644
18143 --- a/arch/x86/kernel/apic/bigsmp_32.c
18144 +++ b/arch/x86/kernel/apic/bigsmp_32.c
18145 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
18146 return dmi_bigsmp;
18147 }
18148
18149 -static struct apic apic_bigsmp = {
18150 +static struct apic apic_bigsmp __read_only = {
18151
18152 .name = "bigsmp",
18153 .probe = probe_bigsmp,
18154 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
18155 index 0874799..a7a7892 100644
18156 --- a/arch/x86/kernel/apic/es7000_32.c
18157 +++ b/arch/x86/kernel/apic/es7000_32.c
18158 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
18159 return ret && es7000_apic_is_cluster();
18160 }
18161
18162 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
18163 -static struct apic __refdata apic_es7000_cluster = {
18164 +static struct apic apic_es7000_cluster __read_only = {
18165
18166 .name = "es7000",
18167 .probe = probe_es7000,
18168 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
18169 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
18170 };
18171
18172 -static struct apic __refdata apic_es7000 = {
18173 +static struct apic apic_es7000 __read_only = {
18174
18175 .name = "es7000",
18176 .probe = probe_es7000,
18177 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
18178 index 9ed796c..e930fe4 100644
18179 --- a/arch/x86/kernel/apic/io_apic.c
18180 +++ b/arch/x86/kernel/apic/io_apic.c
18181 @@ -1060,7 +1060,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
18182 }
18183 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
18184
18185 -void lock_vector_lock(void)
18186 +void lock_vector_lock(void) __acquires(vector_lock)
18187 {
18188 /* Used to the online set of cpus does not change
18189 * during assign_irq_vector.
18190 @@ -1068,7 +1068,7 @@ void lock_vector_lock(void)
18191 raw_spin_lock(&vector_lock);
18192 }
18193
18194 -void unlock_vector_lock(void)
18195 +void unlock_vector_lock(void) __releases(vector_lock)
18196 {
18197 raw_spin_unlock(&vector_lock);
18198 }
18199 @@ -2362,7 +2362,7 @@ static void ack_apic_edge(struct irq_data *data)
18200 ack_APIC_irq();
18201 }
18202
18203 -atomic_t irq_mis_count;
18204 +atomic_unchecked_t irq_mis_count;
18205
18206 #ifdef CONFIG_GENERIC_PENDING_IRQ
18207 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
18208 @@ -2503,7 +2503,7 @@ static void ack_apic_level(struct irq_data *data)
18209 * at the cpu.
18210 */
18211 if (!(v & (1 << (i & 0x1f)))) {
18212 - atomic_inc(&irq_mis_count);
18213 + atomic_inc_unchecked(&irq_mis_count);
18214
18215 eoi_ioapic_irq(irq, cfg);
18216 }
18217 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
18218 index d661ee9..791fd33 100644
18219 --- a/arch/x86/kernel/apic/numaq_32.c
18220 +++ b/arch/x86/kernel/apic/numaq_32.c
18221 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
18222 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
18223 }
18224
18225 -/* Use __refdata to keep false positive warning calm. */
18226 -static struct apic __refdata apic_numaq = {
18227 +static struct apic apic_numaq __read_only = {
18228
18229 .name = "NUMAQ",
18230 .probe = probe_numaq,
18231 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
18232 index eb35ef9..f184a21 100644
18233 --- a/arch/x86/kernel/apic/probe_32.c
18234 +++ b/arch/x86/kernel/apic/probe_32.c
18235 @@ -72,7 +72,7 @@ static int probe_default(void)
18236 return 1;
18237 }
18238
18239 -static struct apic apic_default = {
18240 +static struct apic apic_default __read_only = {
18241
18242 .name = "default",
18243 .probe = probe_default,
18244 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
18245 index 77c95c0..434f8a4 100644
18246 --- a/arch/x86/kernel/apic/summit_32.c
18247 +++ b/arch/x86/kernel/apic/summit_32.c
18248 @@ -486,7 +486,7 @@ void setup_summit(void)
18249 }
18250 #endif
18251
18252 -static struct apic apic_summit = {
18253 +static struct apic apic_summit __read_only = {
18254
18255 .name = "summit",
18256 .probe = probe_summit,
18257 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
18258 index c88baa4..757aee1 100644
18259 --- a/arch/x86/kernel/apic/x2apic_cluster.c
18260 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
18261 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
18262 return notifier_from_errno(err);
18263 }
18264
18265 -static struct notifier_block __refdata x2apic_cpu_notifier = {
18266 +static struct notifier_block x2apic_cpu_notifier = {
18267 .notifier_call = update_clusterinfo,
18268 };
18269
18270 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
18271 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
18272 }
18273
18274 -static struct apic apic_x2apic_cluster = {
18275 +static struct apic apic_x2apic_cluster __read_only = {
18276
18277 .name = "cluster x2apic",
18278 .probe = x2apic_cluster_probe,
18279 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
18280 index 562a76d..a003c0f 100644
18281 --- a/arch/x86/kernel/apic/x2apic_phys.c
18282 +++ b/arch/x86/kernel/apic/x2apic_phys.c
18283 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
18284 return apic == &apic_x2apic_phys;
18285 }
18286
18287 -static struct apic apic_x2apic_phys = {
18288 +static struct apic apic_x2apic_phys __read_only = {
18289
18290 .name = "physical x2apic",
18291 .probe = x2apic_phys_probe,
18292 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
18293 index 794f6eb..67e1db2 100644
18294 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
18295 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
18296 @@ -342,7 +342,7 @@ static int uv_probe(void)
18297 return apic == &apic_x2apic_uv_x;
18298 }
18299
18300 -static struct apic __refdata apic_x2apic_uv_x = {
18301 +static struct apic apic_x2apic_uv_x __read_only = {
18302
18303 .name = "UV large system",
18304 .probe = uv_probe,
18305 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
18306 index 53a4e27..038760a 100644
18307 --- a/arch/x86/kernel/apm_32.c
18308 +++ b/arch/x86/kernel/apm_32.c
18309 @@ -433,7 +433,7 @@ static DEFINE_MUTEX(apm_mutex);
18310 * This is for buggy BIOS's that refer to (real mode) segment 0x40
18311 * even though they are called in protected mode.
18312 */
18313 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
18314 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
18315 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
18316
18317 static const char driver_version[] = "1.16ac"; /* no spaces */
18318 @@ -611,7 +611,10 @@ static long __apm_bios_call(void *_call)
18319 BUG_ON(cpu != 0);
18320 gdt = get_cpu_gdt_table(cpu);
18321 save_desc_40 = gdt[0x40 / 8];
18322 +
18323 + pax_open_kernel();
18324 gdt[0x40 / 8] = bad_bios_desc;
18325 + pax_close_kernel();
18326
18327 apm_irq_save(flags);
18328 APM_DO_SAVE_SEGS;
18329 @@ -620,7 +623,11 @@ static long __apm_bios_call(void *_call)
18330 &call->esi);
18331 APM_DO_RESTORE_SEGS;
18332 apm_irq_restore(flags);
18333 +
18334 + pax_open_kernel();
18335 gdt[0x40 / 8] = save_desc_40;
18336 + pax_close_kernel();
18337 +
18338 put_cpu();
18339
18340 return call->eax & 0xff;
18341 @@ -687,7 +694,10 @@ static long __apm_bios_call_simple(void *_call)
18342 BUG_ON(cpu != 0);
18343 gdt = get_cpu_gdt_table(cpu);
18344 save_desc_40 = gdt[0x40 / 8];
18345 +
18346 + pax_open_kernel();
18347 gdt[0x40 / 8] = bad_bios_desc;
18348 + pax_close_kernel();
18349
18350 apm_irq_save(flags);
18351 APM_DO_SAVE_SEGS;
18352 @@ -695,7 +705,11 @@ static long __apm_bios_call_simple(void *_call)
18353 &call->eax);
18354 APM_DO_RESTORE_SEGS;
18355 apm_irq_restore(flags);
18356 +
18357 + pax_open_kernel();
18358 gdt[0x40 / 8] = save_desc_40;
18359 + pax_close_kernel();
18360 +
18361 put_cpu();
18362 return error;
18363 }
18364 @@ -2362,12 +2376,15 @@ static int __init apm_init(void)
18365 * code to that CPU.
18366 */
18367 gdt = get_cpu_gdt_table(0);
18368 +
18369 + pax_open_kernel();
18370 set_desc_base(&gdt[APM_CS >> 3],
18371 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
18372 set_desc_base(&gdt[APM_CS_16 >> 3],
18373 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
18374 set_desc_base(&gdt[APM_DS >> 3],
18375 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
18376 + pax_close_kernel();
18377
18378 proc_create("apm", 0, NULL, &apm_file_ops);
18379
18380 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
18381 index 2861082..6d4718e 100644
18382 --- a/arch/x86/kernel/asm-offsets.c
18383 +++ b/arch/x86/kernel/asm-offsets.c
18384 @@ -33,6 +33,8 @@ void common(void) {
18385 OFFSET(TI_status, thread_info, status);
18386 OFFSET(TI_addr_limit, thread_info, addr_limit);
18387 OFFSET(TI_preempt_count, thread_info, preempt_count);
18388 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
18389 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
18390
18391 BLANK();
18392 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
18393 @@ -53,8 +55,26 @@ void common(void) {
18394 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
18395 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
18396 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
18397 +
18398 +#ifdef CONFIG_PAX_KERNEXEC
18399 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
18400 #endif
18401
18402 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18403 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
18404 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
18405 +#ifdef CONFIG_X86_64
18406 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
18407 +#endif
18408 +#endif
18409 +
18410 +#endif
18411 +
18412 + BLANK();
18413 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
18414 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
18415 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
18416 +
18417 #ifdef CONFIG_XEN
18418 BLANK();
18419 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
18420 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
18421 index e7c798b..2b2019b 100644
18422 --- a/arch/x86/kernel/asm-offsets_64.c
18423 +++ b/arch/x86/kernel/asm-offsets_64.c
18424 @@ -77,6 +77,7 @@ int main(void)
18425 BLANK();
18426 #undef ENTRY
18427
18428 + DEFINE(TSS_size, sizeof(struct tss_struct));
18429 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
18430 BLANK();
18431
18432 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
18433 index b0684e4..22ccfd7 100644
18434 --- a/arch/x86/kernel/cpu/Makefile
18435 +++ b/arch/x86/kernel/cpu/Makefile
18436 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
18437 CFLAGS_REMOVE_perf_event.o = -pg
18438 endif
18439
18440 -# Make sure load_percpu_segment has no stackprotector
18441 -nostackp := $(call cc-option, -fno-stack-protector)
18442 -CFLAGS_common.o := $(nostackp)
18443 -
18444 obj-y := intel_cacheinfo.o scattered.o topology.o
18445 obj-y += proc.o capflags.o powerflags.o common.o
18446 obj-y += rdrand.o
18447 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
18448 index 5013a48..0782c53 100644
18449 --- a/arch/x86/kernel/cpu/amd.c
18450 +++ b/arch/x86/kernel/cpu/amd.c
18451 @@ -744,7 +744,7 @@ static unsigned int __cpuinit amd_size_cache(struct cpuinfo_x86 *c,
18452 unsigned int size)
18453 {
18454 /* AMD errata T13 (order #21922) */
18455 - if ((c->x86 == 6)) {
18456 + if (c->x86 == 6) {
18457 /* Duron Rev A0 */
18458 if (c->x86_model == 3 && c->x86_mask == 0)
18459 size = 64;
18460 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
18461 index 22018f7..df77e23 100644
18462 --- a/arch/x86/kernel/cpu/common.c
18463 +++ b/arch/x86/kernel/cpu/common.c
18464 @@ -88,60 +88,6 @@ static const struct cpu_dev __cpuinitconst default_cpu = {
18465
18466 static const struct cpu_dev *this_cpu __cpuinitdata = &default_cpu;
18467
18468 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
18469 -#ifdef CONFIG_X86_64
18470 - /*
18471 - * We need valid kernel segments for data and code in long mode too
18472 - * IRET will check the segment types kkeil 2000/10/28
18473 - * Also sysret mandates a special GDT layout
18474 - *
18475 - * TLS descriptors are currently at a different place compared to i386.
18476 - * Hopefully nobody expects them at a fixed place (Wine?)
18477 - */
18478 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
18479 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
18480 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
18481 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
18482 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
18483 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
18484 -#else
18485 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
18486 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
18487 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
18488 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
18489 - /*
18490 - * Segments used for calling PnP BIOS have byte granularity.
18491 - * They code segments and data segments have fixed 64k limits,
18492 - * the transfer segment sizes are set at run time.
18493 - */
18494 - /* 32-bit code */
18495 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
18496 - /* 16-bit code */
18497 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
18498 - /* 16-bit data */
18499 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
18500 - /* 16-bit data */
18501 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
18502 - /* 16-bit data */
18503 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
18504 - /*
18505 - * The APM segments have byte granularity and their bases
18506 - * are set at run time. All have 64k limits.
18507 - */
18508 - /* 32-bit code */
18509 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
18510 - /* 16-bit code */
18511 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
18512 - /* data */
18513 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
18514 -
18515 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
18516 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
18517 - GDT_STACK_CANARY_INIT
18518 -#endif
18519 -} };
18520 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
18521 -
18522 static int __init x86_xsave_setup(char *s)
18523 {
18524 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
18525 @@ -288,6 +234,57 @@ static __always_inline void setup_smap(struct cpuinfo_x86 *c)
18526 set_in_cr4(X86_CR4_SMAP);
18527 }
18528
18529 +#ifdef CONFIG_X86_64
18530 +static __init int setup_disable_pcid(char *arg)
18531 +{
18532 + setup_clear_cpu_cap(X86_FEATURE_PCID);
18533 +
18534 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18535 + if (clone_pgd_mask != ~(pgdval_t)0UL)
18536 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
18537 +#endif
18538 +
18539 + return 1;
18540 +}
18541 +__setup("nopcid", setup_disable_pcid);
18542 +
18543 +static void setup_pcid(struct cpuinfo_x86 *c)
18544 +{
18545 + if (!cpu_has(c, X86_FEATURE_PCID)) {
18546 +
18547 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18548 + if (clone_pgd_mask != ~(pgdval_t)0UL) {
18549 + pax_open_kernel();
18550 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
18551 + pax_close_kernel();
18552 + printk("PAX: slow and weak UDEREF enabled\n");
18553 + } else
18554 + printk("PAX: UDEREF disabled\n");
18555 +#endif
18556 +
18557 + return;
18558 + }
18559 +
18560 + printk("PAX: PCID detected\n");
18561 + set_in_cr4(X86_CR4_PCIDE);
18562 +
18563 +#ifdef CONFIG_PAX_MEMORY_UDEREF
18564 + pax_open_kernel();
18565 + clone_pgd_mask = ~(pgdval_t)0UL;
18566 + pax_close_kernel();
18567 + if (pax_user_shadow_base)
18568 + printk("PAX: weak UDEREF enabled\n");
18569 + else {
18570 + set_cpu_cap(c, X86_FEATURE_STRONGUDEREF);
18571 + printk("PAX: strong UDEREF enabled\n");
18572 + }
18573 +#endif
18574 +
18575 + if (cpu_has(c, X86_FEATURE_INVPCID))
18576 + printk("PAX: INVPCID detected\n");
18577 +}
18578 +#endif
18579 +
18580 /*
18581 * Some CPU features depend on higher CPUID levels, which may not always
18582 * be available due to CPUID level capping or broken virtualization
18583 @@ -386,7 +383,7 @@ void switch_to_new_gdt(int cpu)
18584 {
18585 struct desc_ptr gdt_descr;
18586
18587 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
18588 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
18589 gdt_descr.size = GDT_SIZE - 1;
18590 load_gdt(&gdt_descr);
18591 /* Reload the per-cpu base */
18592 @@ -874,6 +871,10 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
18593 setup_smep(c);
18594 setup_smap(c);
18595
18596 +#ifdef CONFIG_X86_64
18597 + setup_pcid(c);
18598 +#endif
18599 +
18600 /*
18601 * The vendor-specific functions might have changed features.
18602 * Now we do "generic changes."
18603 @@ -882,6 +883,10 @@ static void __cpuinit identify_cpu(struct cpuinfo_x86 *c)
18604 /* Filter out anything that depends on CPUID levels we don't have */
18605 filter_cpuid_features(c, true);
18606
18607 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
18608 + setup_clear_cpu_cap(X86_FEATURE_SEP);
18609 +#endif
18610 +
18611 /* If the model name is still unset, do table lookup. */
18612 if (!c->x86_model_id[0]) {
18613 const char *p;
18614 @@ -1069,10 +1074,12 @@ static __init int setup_disablecpuid(char *arg)
18615 }
18616 __setup("clearcpuid=", setup_disablecpuid);
18617
18618 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
18619 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
18620 +
18621 #ifdef CONFIG_X86_64
18622 struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
18623 -struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1,
18624 - (unsigned long) nmi_idt_table };
18625 +struct desc_ptr nmi_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) nmi_idt_table };
18626
18627 DEFINE_PER_CPU_FIRST(union irq_stack_union,
18628 irq_stack_union) __aligned(PAGE_SIZE);
18629 @@ -1086,7 +1093,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
18630 EXPORT_PER_CPU_SYMBOL(current_task);
18631
18632 DEFINE_PER_CPU(unsigned long, kernel_stack) =
18633 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
18634 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
18635 EXPORT_PER_CPU_SYMBOL(kernel_stack);
18636
18637 DEFINE_PER_CPU(char *, irq_stack_ptr) =
18638 @@ -1231,7 +1238,7 @@ void __cpuinit cpu_init(void)
18639 load_ucode_ap();
18640
18641 cpu = stack_smp_processor_id();
18642 - t = &per_cpu(init_tss, cpu);
18643 + t = init_tss + cpu;
18644 oist = &per_cpu(orig_ist, cpu);
18645
18646 #ifdef CONFIG_NUMA
18647 @@ -1257,7 +1264,7 @@ void __cpuinit cpu_init(void)
18648 switch_to_new_gdt(cpu);
18649 loadsegment(fs, 0);
18650
18651 - load_idt((const struct desc_ptr *)&idt_descr);
18652 + load_idt(&idt_descr);
18653
18654 memset(me->thread.tls_array, 0, GDT_ENTRY_TLS_ENTRIES * 8);
18655 syscall_init();
18656 @@ -1266,7 +1273,6 @@ void __cpuinit cpu_init(void)
18657 wrmsrl(MSR_KERNEL_GS_BASE, 0);
18658 barrier();
18659
18660 - x86_configure_nx();
18661 enable_x2apic();
18662
18663 /*
18664 @@ -1318,7 +1324,7 @@ void __cpuinit cpu_init(void)
18665 {
18666 int cpu = smp_processor_id();
18667 struct task_struct *curr = current;
18668 - struct tss_struct *t = &per_cpu(init_tss, cpu);
18669 + struct tss_struct *t = init_tss + cpu;
18670 struct thread_struct *thread = &curr->thread;
18671
18672 show_ucode_info_early();
18673 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
18674 index 7c6f7d5..8cac382 100644
18675 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
18676 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
18677 @@ -1017,6 +1017,22 @@ static struct attribute *default_attrs[] = {
18678 };
18679
18680 #ifdef CONFIG_AMD_NB
18681 +static struct attribute *default_attrs_amd_nb[] = {
18682 + &type.attr,
18683 + &level.attr,
18684 + &coherency_line_size.attr,
18685 + &physical_line_partition.attr,
18686 + &ways_of_associativity.attr,
18687 + &number_of_sets.attr,
18688 + &size.attr,
18689 + &shared_cpu_map.attr,
18690 + &shared_cpu_list.attr,
18691 + NULL,
18692 + NULL,
18693 + NULL,
18694 + NULL
18695 +};
18696 +
18697 static struct attribute ** __cpuinit amd_l3_attrs(void)
18698 {
18699 static struct attribute **attrs;
18700 @@ -1027,18 +1043,7 @@ static struct attribute ** __cpuinit amd_l3_attrs(void)
18701
18702 n = ARRAY_SIZE(default_attrs);
18703
18704 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
18705 - n += 2;
18706 -
18707 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
18708 - n += 1;
18709 -
18710 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
18711 - if (attrs == NULL)
18712 - return attrs = default_attrs;
18713 -
18714 - for (n = 0; default_attrs[n]; n++)
18715 - attrs[n] = default_attrs[n];
18716 + attrs = default_attrs_amd_nb;
18717
18718 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
18719 attrs[n++] = &cache_disable_0.attr;
18720 @@ -1089,6 +1094,13 @@ static struct kobj_type ktype_cache = {
18721 .default_attrs = default_attrs,
18722 };
18723
18724 +#ifdef CONFIG_AMD_NB
18725 +static struct kobj_type ktype_cache_amd_nb = {
18726 + .sysfs_ops = &sysfs_ops,
18727 + .default_attrs = default_attrs_amd_nb,
18728 +};
18729 +#endif
18730 +
18731 static struct kobj_type ktype_percpu_entry = {
18732 .sysfs_ops = &sysfs_ops,
18733 };
18734 @@ -1154,20 +1166,26 @@ static int __cpuinit cache_add_dev(struct device *dev)
18735 return retval;
18736 }
18737
18738 +#ifdef CONFIG_AMD_NB
18739 + amd_l3_attrs();
18740 +#endif
18741 +
18742 for (i = 0; i < num_cache_leaves; i++) {
18743 + struct kobj_type *ktype;
18744 +
18745 this_object = INDEX_KOBJECT_PTR(cpu, i);
18746 this_object->cpu = cpu;
18747 this_object->index = i;
18748
18749 this_leaf = CPUID4_INFO_IDX(cpu, i);
18750
18751 - ktype_cache.default_attrs = default_attrs;
18752 + ktype = &ktype_cache;
18753 #ifdef CONFIG_AMD_NB
18754 if (this_leaf->base.nb)
18755 - ktype_cache.default_attrs = amd_l3_attrs();
18756 + ktype = &ktype_cache_amd_nb;
18757 #endif
18758 retval = kobject_init_and_add(&(this_object->kobj),
18759 - &ktype_cache,
18760 + ktype,
18761 per_cpu(ici_cache_kobject, cpu),
18762 "index%1lu", i);
18763 if (unlikely(retval)) {
18764 @@ -1222,7 +1240,7 @@ static int __cpuinit cacheinfo_cpu_callback(struct notifier_block *nfb,
18765 return NOTIFY_OK;
18766 }
18767
18768 -static struct notifier_block __cpuinitdata cacheinfo_cpu_notifier = {
18769 +static struct notifier_block cacheinfo_cpu_notifier = {
18770 .notifier_call = cacheinfo_cpu_callback,
18771 };
18772
18773 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
18774 index 9239504..b2471ce 100644
18775 --- a/arch/x86/kernel/cpu/mcheck/mce.c
18776 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
18777 @@ -45,6 +45,7 @@
18778 #include <asm/processor.h>
18779 #include <asm/mce.h>
18780 #include <asm/msr.h>
18781 +#include <asm/local.h>
18782
18783 #include "mce-internal.h"
18784
18785 @@ -246,7 +247,7 @@ static void print_mce(struct mce *m)
18786 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
18787 m->cs, m->ip);
18788
18789 - if (m->cs == __KERNEL_CS)
18790 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
18791 print_symbol("{%s}", m->ip);
18792 pr_cont("\n");
18793 }
18794 @@ -279,10 +280,10 @@ static void print_mce(struct mce *m)
18795
18796 #define PANIC_TIMEOUT 5 /* 5 seconds */
18797
18798 -static atomic_t mce_paniced;
18799 +static atomic_unchecked_t mce_paniced;
18800
18801 static int fake_panic;
18802 -static atomic_t mce_fake_paniced;
18803 +static atomic_unchecked_t mce_fake_paniced;
18804
18805 /* Panic in progress. Enable interrupts and wait for final IPI */
18806 static void wait_for_panic(void)
18807 @@ -306,7 +307,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
18808 /*
18809 * Make sure only one CPU runs in machine check panic
18810 */
18811 - if (atomic_inc_return(&mce_paniced) > 1)
18812 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
18813 wait_for_panic();
18814 barrier();
18815
18816 @@ -314,7 +315,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
18817 console_verbose();
18818 } else {
18819 /* Don't log too much for fake panic */
18820 - if (atomic_inc_return(&mce_fake_paniced) > 1)
18821 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
18822 return;
18823 }
18824 /* First print corrected ones that are still unlogged */
18825 @@ -353,7 +354,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
18826 if (!fake_panic) {
18827 if (panic_timeout == 0)
18828 panic_timeout = mca_cfg.panic_timeout;
18829 - panic(msg);
18830 + panic("%s", msg);
18831 } else
18832 pr_emerg(HW_ERR "Fake kernel panic: %s\n", msg);
18833 }
18834 @@ -683,7 +684,7 @@ static int mce_timed_out(u64 *t)
18835 * might have been modified by someone else.
18836 */
18837 rmb();
18838 - if (atomic_read(&mce_paniced))
18839 + if (atomic_read_unchecked(&mce_paniced))
18840 wait_for_panic();
18841 if (!mca_cfg.monarch_timeout)
18842 goto out;
18843 @@ -1654,7 +1655,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
18844 }
18845
18846 /* Call the installed machine check handler for this CPU setup. */
18847 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
18848 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
18849 unexpected_machine_check;
18850
18851 /*
18852 @@ -1677,7 +1678,9 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
18853 return;
18854 }
18855
18856 + pax_open_kernel();
18857 machine_check_vector = do_machine_check;
18858 + pax_close_kernel();
18859
18860 __mcheck_cpu_init_generic();
18861 __mcheck_cpu_init_vendor(c);
18862 @@ -1691,7 +1694,7 @@ void __cpuinit mcheck_cpu_init(struct cpuinfo_x86 *c)
18863 */
18864
18865 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
18866 -static int mce_chrdev_open_count; /* #times opened */
18867 +static local_t mce_chrdev_open_count; /* #times opened */
18868 static int mce_chrdev_open_exclu; /* already open exclusive? */
18869
18870 static int mce_chrdev_open(struct inode *inode, struct file *file)
18871 @@ -1699,7 +1702,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
18872 spin_lock(&mce_chrdev_state_lock);
18873
18874 if (mce_chrdev_open_exclu ||
18875 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
18876 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
18877 spin_unlock(&mce_chrdev_state_lock);
18878
18879 return -EBUSY;
18880 @@ -1707,7 +1710,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
18881
18882 if (file->f_flags & O_EXCL)
18883 mce_chrdev_open_exclu = 1;
18884 - mce_chrdev_open_count++;
18885 + local_inc(&mce_chrdev_open_count);
18886
18887 spin_unlock(&mce_chrdev_state_lock);
18888
18889 @@ -1718,7 +1721,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
18890 {
18891 spin_lock(&mce_chrdev_state_lock);
18892
18893 - mce_chrdev_open_count--;
18894 + local_dec(&mce_chrdev_open_count);
18895 mce_chrdev_open_exclu = 0;
18896
18897 spin_unlock(&mce_chrdev_state_lock);
18898 @@ -2364,7 +2367,7 @@ mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
18899 return NOTIFY_OK;
18900 }
18901
18902 -static struct notifier_block mce_cpu_notifier __cpuinitdata = {
18903 +static struct notifier_block mce_cpu_notifier = {
18904 .notifier_call = mce_cpu_callback,
18905 };
18906
18907 @@ -2374,7 +2377,7 @@ static __init void mce_init_banks(void)
18908
18909 for (i = 0; i < mca_cfg.banks; i++) {
18910 struct mce_bank *b = &mce_banks[i];
18911 - struct device_attribute *a = &b->attr;
18912 + device_attribute_no_const *a = &b->attr;
18913
18914 sysfs_attr_init(&a->attr);
18915 a->attr.name = b->attrname;
18916 @@ -2442,7 +2445,7 @@ struct dentry *mce_get_debugfs_dir(void)
18917 static void mce_reset(void)
18918 {
18919 cpu_missing = 0;
18920 - atomic_set(&mce_fake_paniced, 0);
18921 + atomic_set_unchecked(&mce_fake_paniced, 0);
18922 atomic_set(&mce_executing, 0);
18923 atomic_set(&mce_callin, 0);
18924 atomic_set(&global_nwo, 0);
18925 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
18926 index 1c044b1..37a2a43 100644
18927 --- a/arch/x86/kernel/cpu/mcheck/p5.c
18928 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
18929 @@ -11,6 +11,7 @@
18930 #include <asm/processor.h>
18931 #include <asm/mce.h>
18932 #include <asm/msr.h>
18933 +#include <asm/pgtable.h>
18934
18935 /* By default disabled */
18936 int mce_p5_enabled __read_mostly;
18937 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
18938 if (!cpu_has(c, X86_FEATURE_MCE))
18939 return;
18940
18941 + pax_open_kernel();
18942 machine_check_vector = pentium_machine_check;
18943 + pax_close_kernel();
18944 /* Make sure the vector pointer is visible before we enable MCEs: */
18945 wmb();
18946
18947 diff --git a/arch/x86/kernel/cpu/mcheck/therm_throt.c b/arch/x86/kernel/cpu/mcheck/therm_throt.c
18948 index 47a1870..8c019a7 100644
18949 --- a/arch/x86/kernel/cpu/mcheck/therm_throt.c
18950 +++ b/arch/x86/kernel/cpu/mcheck/therm_throt.c
18951 @@ -288,7 +288,7 @@ thermal_throttle_cpu_callback(struct notifier_block *nfb,
18952 return notifier_from_errno(err);
18953 }
18954
18955 -static struct notifier_block thermal_throttle_cpu_notifier __cpuinitdata =
18956 +static struct notifier_block thermal_throttle_cpu_notifier =
18957 {
18958 .notifier_call = thermal_throttle_cpu_callback,
18959 };
18960 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
18961 index e9a701a..35317d6 100644
18962 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
18963 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
18964 @@ -10,6 +10,7 @@
18965 #include <asm/processor.h>
18966 #include <asm/mce.h>
18967 #include <asm/msr.h>
18968 +#include <asm/pgtable.h>
18969
18970 /* Machine check handler for WinChip C6: */
18971 static void winchip_machine_check(struct pt_regs *regs, long error_code)
18972 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
18973 {
18974 u32 lo, hi;
18975
18976 + pax_open_kernel();
18977 machine_check_vector = winchip_machine_check;
18978 + pax_close_kernel();
18979 /* Make sure the vector pointer is visible before we enable MCEs: */
18980 wmb();
18981
18982 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
18983 index ca22b73..9987afe 100644
18984 --- a/arch/x86/kernel/cpu/mtrr/main.c
18985 +++ b/arch/x86/kernel/cpu/mtrr/main.c
18986 @@ -62,7 +62,7 @@ static DEFINE_MUTEX(mtrr_mutex);
18987 u64 size_or_mask, size_and_mask;
18988 static bool mtrr_aps_delayed_init;
18989
18990 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
18991 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
18992
18993 const struct mtrr_ops *mtrr_if;
18994
18995 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
18996 index df5e41f..816c719 100644
18997 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
18998 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
18999 @@ -25,7 +25,7 @@ struct mtrr_ops {
19000 int (*validate_add_page)(unsigned long base, unsigned long size,
19001 unsigned int type);
19002 int (*have_wrcomb)(void);
19003 -};
19004 +} __do_const;
19005
19006 extern int generic_get_free_region(unsigned long base, unsigned long size,
19007 int replace_reg);
19008 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
19009 index 1025f3c..824f677 100644
19010 --- a/arch/x86/kernel/cpu/perf_event.c
19011 +++ b/arch/x86/kernel/cpu/perf_event.c
19012 @@ -1311,7 +1311,7 @@ static void __init pmu_check_apic(void)
19013 pr_info("no hardware sampling interrupt available.\n");
19014 }
19015
19016 -static struct attribute_group x86_pmu_format_group = {
19017 +static attribute_group_no_const x86_pmu_format_group = {
19018 .name = "format",
19019 .attrs = NULL,
19020 };
19021 @@ -1410,7 +1410,7 @@ static struct attribute *events_attr[] = {
19022 NULL,
19023 };
19024
19025 -static struct attribute_group x86_pmu_events_group = {
19026 +static attribute_group_no_const x86_pmu_events_group = {
19027 .name = "events",
19028 .attrs = events_attr,
19029 };
19030 @@ -1920,7 +1920,7 @@ static unsigned long get_segment_base(unsigned int segment)
19031 if (idx > GDT_ENTRIES)
19032 return 0;
19033
19034 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
19035 + desc = get_cpu_gdt_table(smp_processor_id());
19036 }
19037
19038 return get_desc_base(desc + idx);
19039 @@ -2010,7 +2010,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
19040 break;
19041
19042 perf_callchain_store(entry, frame.return_address);
19043 - fp = frame.next_frame;
19044 + fp = (const void __force_user *)frame.next_frame;
19045 }
19046 }
19047
19048 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
19049 index a9e2207..d70c83a 100644
19050 --- a/arch/x86/kernel/cpu/perf_event_intel.c
19051 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
19052 @@ -2022,10 +2022,10 @@ __init int intel_pmu_init(void)
19053 * v2 and above have a perf capabilities MSR
19054 */
19055 if (version > 1) {
19056 - u64 capabilities;
19057 + u64 capabilities = x86_pmu.intel_cap.capabilities;
19058
19059 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
19060 - x86_pmu.intel_cap.capabilities = capabilities;
19061 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
19062 + x86_pmu.intel_cap.capabilities = capabilities;
19063 }
19064
19065 intel_ds_init();
19066 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
19067 index 8aac56b..588fb13 100644
19068 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
19069 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
19070 @@ -3093,7 +3093,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
19071 static int __init uncore_type_init(struct intel_uncore_type *type)
19072 {
19073 struct intel_uncore_pmu *pmus;
19074 - struct attribute_group *attr_group;
19075 + attribute_group_no_const *attr_group;
19076 struct attribute **attrs;
19077 int i, j;
19078
19079 @@ -3518,7 +3518,7 @@ static int
19080 return NOTIFY_OK;
19081 }
19082
19083 -static struct notifier_block uncore_cpu_nb __cpuinitdata = {
19084 +static struct notifier_block uncore_cpu_nb = {
19085 .notifier_call = uncore_cpu_notifier,
19086 /*
19087 * to migrate uncore events, our notifier should be executed
19088 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
19089 index f952891..4722ad4 100644
19090 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
19091 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
19092 @@ -488,7 +488,7 @@ struct intel_uncore_box {
19093 struct uncore_event_desc {
19094 struct kobj_attribute attr;
19095 const char *config;
19096 -};
19097 +} __do_const;
19098
19099 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
19100 { \
19101 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
19102 index 1e4dbcf..b9a34c2 100644
19103 --- a/arch/x86/kernel/cpuid.c
19104 +++ b/arch/x86/kernel/cpuid.c
19105 @@ -171,7 +171,7 @@ static int __cpuinit cpuid_class_cpu_callback(struct notifier_block *nfb,
19106 return notifier_from_errno(err);
19107 }
19108
19109 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
19110 +static struct notifier_block cpuid_class_cpu_notifier =
19111 {
19112 .notifier_call = cpuid_class_cpu_callback,
19113 };
19114 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
19115 index 74467fe..18793d5 100644
19116 --- a/arch/x86/kernel/crash.c
19117 +++ b/arch/x86/kernel/crash.c
19118 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
19119 {
19120 #ifdef CONFIG_X86_32
19121 struct pt_regs fixed_regs;
19122 -#endif
19123
19124 -#ifdef CONFIG_X86_32
19125 - if (!user_mode_vm(regs)) {
19126 + if (!user_mode(regs)) {
19127 crash_fixup_ss_esp(&fixed_regs, regs);
19128 regs = &fixed_regs;
19129 }
19130 diff --git a/arch/x86/kernel/crash_dump_64.c b/arch/x86/kernel/crash_dump_64.c
19131 index afa64ad..dce67dd 100644
19132 --- a/arch/x86/kernel/crash_dump_64.c
19133 +++ b/arch/x86/kernel/crash_dump_64.c
19134 @@ -36,7 +36,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
19135 return -ENOMEM;
19136
19137 if (userbuf) {
19138 - if (copy_to_user(buf, vaddr + offset, csize)) {
19139 + if (copy_to_user((char __force_user *)buf, vaddr + offset, csize)) {
19140 iounmap(vaddr);
19141 return -EFAULT;
19142 }
19143 diff --git a/arch/x86/kernel/doublefault_32.c b/arch/x86/kernel/doublefault_32.c
19144 index 155a13f..1672b9b 100644
19145 --- a/arch/x86/kernel/doublefault_32.c
19146 +++ b/arch/x86/kernel/doublefault_32.c
19147 @@ -11,7 +11,7 @@
19148
19149 #define DOUBLEFAULT_STACKSIZE (1024)
19150 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
19151 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
19152 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
19153
19154 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
19155
19156 @@ -21,7 +21,7 @@ static void doublefault_fn(void)
19157 unsigned long gdt, tss;
19158
19159 native_store_gdt(&gdt_desc);
19160 - gdt = gdt_desc.address;
19161 + gdt = (unsigned long)gdt_desc.address;
19162
19163 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
19164
19165 @@ -58,10 +58,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
19166 /* 0x2 bit is always set */
19167 .flags = X86_EFLAGS_SF | 0x2,
19168 .sp = STACK_START,
19169 - .es = __USER_DS,
19170 + .es = __KERNEL_DS,
19171 .cs = __KERNEL_CS,
19172 .ss = __KERNEL_DS,
19173 - .ds = __USER_DS,
19174 + .ds = __KERNEL_DS,
19175 .fs = __KERNEL_PERCPU,
19176
19177 .__cr3 = __pa_nodebug(swapper_pg_dir),
19178 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
19179 index deb6421..76bbc12 100644
19180 --- a/arch/x86/kernel/dumpstack.c
19181 +++ b/arch/x86/kernel/dumpstack.c
19182 @@ -2,6 +2,9 @@
19183 * Copyright (C) 1991, 1992 Linus Torvalds
19184 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
19185 */
19186 +#ifdef CONFIG_GRKERNSEC_HIDESYM
19187 +#define __INCLUDED_BY_HIDESYM 1
19188 +#endif
19189 #include <linux/kallsyms.h>
19190 #include <linux/kprobes.h>
19191 #include <linux/uaccess.h>
19192 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
19193 static void
19194 print_ftrace_graph_addr(unsigned long addr, void *data,
19195 const struct stacktrace_ops *ops,
19196 - struct thread_info *tinfo, int *graph)
19197 + struct task_struct *task, int *graph)
19198 {
19199 - struct task_struct *task;
19200 unsigned long ret_addr;
19201 int index;
19202
19203 if (addr != (unsigned long)return_to_handler)
19204 return;
19205
19206 - task = tinfo->task;
19207 index = task->curr_ret_stack;
19208
19209 if (!task->ret_stack || index < *graph)
19210 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
19211 static inline void
19212 print_ftrace_graph_addr(unsigned long addr, void *data,
19213 const struct stacktrace_ops *ops,
19214 - struct thread_info *tinfo, int *graph)
19215 + struct task_struct *task, int *graph)
19216 { }
19217 #endif
19218
19219 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
19220 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
19221 */
19222
19223 -static inline int valid_stack_ptr(struct thread_info *tinfo,
19224 - void *p, unsigned int size, void *end)
19225 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
19226 {
19227 - void *t = tinfo;
19228 if (end) {
19229 if (p < end && p >= (end-THREAD_SIZE))
19230 return 1;
19231 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
19232 }
19233
19234 unsigned long
19235 -print_context_stack(struct thread_info *tinfo,
19236 +print_context_stack(struct task_struct *task, void *stack_start,
19237 unsigned long *stack, unsigned long bp,
19238 const struct stacktrace_ops *ops, void *data,
19239 unsigned long *end, int *graph)
19240 {
19241 struct stack_frame *frame = (struct stack_frame *)bp;
19242
19243 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
19244 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
19245 unsigned long addr;
19246
19247 addr = *stack;
19248 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
19249 } else {
19250 ops->address(data, addr, 0);
19251 }
19252 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
19253 + print_ftrace_graph_addr(addr, data, ops, task, graph);
19254 }
19255 stack++;
19256 }
19257 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
19258 EXPORT_SYMBOL_GPL(print_context_stack);
19259
19260 unsigned long
19261 -print_context_stack_bp(struct thread_info *tinfo,
19262 +print_context_stack_bp(struct task_struct *task, void *stack_start,
19263 unsigned long *stack, unsigned long bp,
19264 const struct stacktrace_ops *ops, void *data,
19265 unsigned long *end, int *graph)
19266 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
19267 struct stack_frame *frame = (struct stack_frame *)bp;
19268 unsigned long *ret_addr = &frame->return_address;
19269
19270 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
19271 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
19272 unsigned long addr = *ret_addr;
19273
19274 if (!__kernel_text_address(addr))
19275 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
19276 ops->address(data, addr, 1);
19277 frame = frame->next_frame;
19278 ret_addr = &frame->return_address;
19279 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
19280 + print_ftrace_graph_addr(addr, data, ops, task, graph);
19281 }
19282
19283 return (unsigned long)frame;
19284 @@ -150,7 +149,7 @@ static int print_trace_stack(void *data, char *name)
19285 static void print_trace_address(void *data, unsigned long addr, int reliable)
19286 {
19287 touch_nmi_watchdog();
19288 - printk(data);
19289 + printk("%s", (char *)data);
19290 printk_address(addr, reliable);
19291 }
19292
19293 @@ -219,6 +218,8 @@ unsigned __kprobes long oops_begin(void)
19294 }
19295 EXPORT_SYMBOL_GPL(oops_begin);
19296
19297 +extern void gr_handle_kernel_exploit(void);
19298 +
19299 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
19300 {
19301 if (regs && kexec_should_crash(current))
19302 @@ -240,7 +241,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
19303 panic("Fatal exception in interrupt");
19304 if (panic_on_oops)
19305 panic("Fatal exception");
19306 - do_exit(signr);
19307 +
19308 + gr_handle_kernel_exploit();
19309 +
19310 + do_group_exit(signr);
19311 }
19312
19313 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
19314 @@ -268,7 +272,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
19315 print_modules();
19316 show_regs(regs);
19317 #ifdef CONFIG_X86_32
19318 - if (user_mode_vm(regs)) {
19319 + if (user_mode(regs)) {
19320 sp = regs->sp;
19321 ss = regs->ss & 0xffff;
19322 } else {
19323 @@ -296,7 +300,7 @@ void die(const char *str, struct pt_regs *regs, long err)
19324 unsigned long flags = oops_begin();
19325 int sig = SIGSEGV;
19326
19327 - if (!user_mode_vm(regs))
19328 + if (!user_mode(regs))
19329 report_bug(regs->ip, regs);
19330
19331 if (__die(str, regs, err))
19332 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
19333 index f2a1770..540657f 100644
19334 --- a/arch/x86/kernel/dumpstack_32.c
19335 +++ b/arch/x86/kernel/dumpstack_32.c
19336 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
19337 bp = stack_frame(task, regs);
19338
19339 for (;;) {
19340 - struct thread_info *context;
19341 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
19342
19343 - context = (struct thread_info *)
19344 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
19345 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
19346 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
19347
19348 - stack = (unsigned long *)context->previous_esp;
19349 - if (!stack)
19350 + if (stack_start == task_stack_page(task))
19351 break;
19352 + stack = *(unsigned long **)stack_start;
19353 if (ops->stack(data, "IRQ") < 0)
19354 break;
19355 touch_nmi_watchdog();
19356 @@ -87,27 +85,28 @@ void show_regs(struct pt_regs *regs)
19357 int i;
19358
19359 show_regs_print_info(KERN_EMERG);
19360 - __show_regs(regs, !user_mode_vm(regs));
19361 + __show_regs(regs, !user_mode(regs));
19362
19363 /*
19364 * When in-kernel, we also print out the stack and code at the
19365 * time of the fault..
19366 */
19367 - if (!user_mode_vm(regs)) {
19368 + if (!user_mode(regs)) {
19369 unsigned int code_prologue = code_bytes * 43 / 64;
19370 unsigned int code_len = code_bytes;
19371 unsigned char c;
19372 u8 *ip;
19373 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
19374
19375 pr_emerg("Stack:\n");
19376 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
19377
19378 pr_emerg("Code:");
19379
19380 - ip = (u8 *)regs->ip - code_prologue;
19381 + ip = (u8 *)regs->ip - code_prologue + cs_base;
19382 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
19383 /* try starting at IP */
19384 - ip = (u8 *)regs->ip;
19385 + ip = (u8 *)regs->ip + cs_base;
19386 code_len = code_len - code_prologue + 1;
19387 }
19388 for (i = 0; i < code_len; i++, ip++) {
19389 @@ -116,7 +115,7 @@ void show_regs(struct pt_regs *regs)
19390 pr_cont(" Bad EIP value.");
19391 break;
19392 }
19393 - if (ip == (u8 *)regs->ip)
19394 + if (ip == (u8 *)regs->ip + cs_base)
19395 pr_cont(" <%02x>", c);
19396 else
19397 pr_cont(" %02x", c);
19398 @@ -129,6 +128,7 @@ int is_valid_bugaddr(unsigned long ip)
19399 {
19400 unsigned short ud2;
19401
19402 + ip = ktla_ktva(ip);
19403 if (ip < PAGE_OFFSET)
19404 return 0;
19405 if (probe_kernel_address((unsigned short *)ip, ud2))
19406 @@ -136,3 +136,15 @@ int is_valid_bugaddr(unsigned long ip)
19407
19408 return ud2 == 0x0b0f;
19409 }
19410 +
19411 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19412 +void pax_check_alloca(unsigned long size)
19413 +{
19414 + unsigned long sp = (unsigned long)&sp, stack_left;
19415 +
19416 + /* all kernel stacks are of the same size */
19417 + stack_left = sp & (THREAD_SIZE - 1);
19418 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
19419 +}
19420 +EXPORT_SYMBOL(pax_check_alloca);
19421 +#endif
19422 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
19423 index addb207..99635fa 100644
19424 --- a/arch/x86/kernel/dumpstack_64.c
19425 +++ b/arch/x86/kernel/dumpstack_64.c
19426 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
19427 unsigned long *irq_stack_end =
19428 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
19429 unsigned used = 0;
19430 - struct thread_info *tinfo;
19431 int graph = 0;
19432 unsigned long dummy;
19433 + void *stack_start;
19434
19435 if (!task)
19436 task = current;
19437 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
19438 * current stack address. If the stacks consist of nested
19439 * exceptions
19440 */
19441 - tinfo = task_thread_info(task);
19442 for (;;) {
19443 char *id;
19444 unsigned long *estack_end;
19445 +
19446 estack_end = in_exception_stack(cpu, (unsigned long)stack,
19447 &used, &id);
19448
19449 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
19450 if (ops->stack(data, id) < 0)
19451 break;
19452
19453 - bp = ops->walk_stack(tinfo, stack, bp, ops,
19454 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
19455 data, estack_end, &graph);
19456 ops->stack(data, "<EOE>");
19457 /*
19458 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
19459 * second-to-last pointer (index -2 to end) in the
19460 * exception stack:
19461 */
19462 + if ((u16)estack_end[-1] != __KERNEL_DS)
19463 + goto out;
19464 stack = (unsigned long *) estack_end[-2];
19465 continue;
19466 }
19467 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
19468 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
19469 if (ops->stack(data, "IRQ") < 0)
19470 break;
19471 - bp = ops->walk_stack(tinfo, stack, bp,
19472 + bp = ops->walk_stack(task, irq_stack, stack, bp,
19473 ops, data, irq_stack_end, &graph);
19474 /*
19475 * We link to the next stack (which would be
19476 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
19477 /*
19478 * This handles the process stack:
19479 */
19480 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
19481 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
19482 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
19483 +out:
19484 put_cpu();
19485 }
19486 EXPORT_SYMBOL(dump_trace);
19487 @@ -300,3 +304,50 @@ int is_valid_bugaddr(unsigned long ip)
19488
19489 return ud2 == 0x0b0f;
19490 }
19491 +
19492 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19493 +void pax_check_alloca(unsigned long size)
19494 +{
19495 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
19496 + unsigned cpu, used;
19497 + char *id;
19498 +
19499 + /* check the process stack first */
19500 + stack_start = (unsigned long)task_stack_page(current);
19501 + stack_end = stack_start + THREAD_SIZE;
19502 + if (likely(stack_start <= sp && sp < stack_end)) {
19503 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
19504 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
19505 + return;
19506 + }
19507 +
19508 + cpu = get_cpu();
19509 +
19510 + /* check the irq stacks */
19511 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
19512 + stack_start = stack_end - IRQ_STACK_SIZE;
19513 + if (stack_start <= sp && sp < stack_end) {
19514 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
19515 + put_cpu();
19516 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
19517 + return;
19518 + }
19519 +
19520 + /* check the exception stacks */
19521 + used = 0;
19522 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
19523 + stack_start = stack_end - EXCEPTION_STKSZ;
19524 + if (stack_end && stack_start <= sp && sp < stack_end) {
19525 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
19526 + put_cpu();
19527 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
19528 + return;
19529 + }
19530 +
19531 + put_cpu();
19532 +
19533 + /* unknown stack */
19534 + BUG();
19535 +}
19536 +EXPORT_SYMBOL(pax_check_alloca);
19537 +#endif
19538 diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
19539 index d32abea..74daf4f 100644
19540 --- a/arch/x86/kernel/e820.c
19541 +++ b/arch/x86/kernel/e820.c
19542 @@ -800,8 +800,8 @@ unsigned long __init e820_end_of_low_ram_pfn(void)
19543
19544 static void early_panic(char *msg)
19545 {
19546 - early_printk(msg);
19547 - panic(msg);
19548 + early_printk("%s", msg);
19549 + panic("%s", msg);
19550 }
19551
19552 static int userdef __initdata;
19553 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
19554 index d15f575..d692043 100644
19555 --- a/arch/x86/kernel/early_printk.c
19556 +++ b/arch/x86/kernel/early_printk.c
19557 @@ -7,6 +7,7 @@
19558 #include <linux/pci_regs.h>
19559 #include <linux/pci_ids.h>
19560 #include <linux/errno.h>
19561 +#include <linux/sched.h>
19562 #include <asm/io.h>
19563 #include <asm/processor.h>
19564 #include <asm/fcntl.h>
19565 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
19566 index 8f3e2de..6b71e39 100644
19567 --- a/arch/x86/kernel/entry_32.S
19568 +++ b/arch/x86/kernel/entry_32.S
19569 @@ -177,13 +177,153 @@
19570 /*CFI_REL_OFFSET gs, PT_GS*/
19571 .endm
19572 .macro SET_KERNEL_GS reg
19573 +
19574 +#ifdef CONFIG_CC_STACKPROTECTOR
19575 movl $(__KERNEL_STACK_CANARY), \reg
19576 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
19577 + movl $(__USER_DS), \reg
19578 +#else
19579 + xorl \reg, \reg
19580 +#endif
19581 +
19582 movl \reg, %gs
19583 .endm
19584
19585 #endif /* CONFIG_X86_32_LAZY_GS */
19586
19587 -.macro SAVE_ALL
19588 +.macro pax_enter_kernel
19589 +#ifdef CONFIG_PAX_KERNEXEC
19590 + call pax_enter_kernel
19591 +#endif
19592 +.endm
19593 +
19594 +.macro pax_exit_kernel
19595 +#ifdef CONFIG_PAX_KERNEXEC
19596 + call pax_exit_kernel
19597 +#endif
19598 +.endm
19599 +
19600 +#ifdef CONFIG_PAX_KERNEXEC
19601 +ENTRY(pax_enter_kernel)
19602 +#ifdef CONFIG_PARAVIRT
19603 + pushl %eax
19604 + pushl %ecx
19605 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
19606 + mov %eax, %esi
19607 +#else
19608 + mov %cr0, %esi
19609 +#endif
19610 + bts $16, %esi
19611 + jnc 1f
19612 + mov %cs, %esi
19613 + cmp $__KERNEL_CS, %esi
19614 + jz 3f
19615 + ljmp $__KERNEL_CS, $3f
19616 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
19617 +2:
19618 +#ifdef CONFIG_PARAVIRT
19619 + mov %esi, %eax
19620 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
19621 +#else
19622 + mov %esi, %cr0
19623 +#endif
19624 +3:
19625 +#ifdef CONFIG_PARAVIRT
19626 + popl %ecx
19627 + popl %eax
19628 +#endif
19629 + ret
19630 +ENDPROC(pax_enter_kernel)
19631 +
19632 +ENTRY(pax_exit_kernel)
19633 +#ifdef CONFIG_PARAVIRT
19634 + pushl %eax
19635 + pushl %ecx
19636 +#endif
19637 + mov %cs, %esi
19638 + cmp $__KERNEXEC_KERNEL_CS, %esi
19639 + jnz 2f
19640 +#ifdef CONFIG_PARAVIRT
19641 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
19642 + mov %eax, %esi
19643 +#else
19644 + mov %cr0, %esi
19645 +#endif
19646 + btr $16, %esi
19647 + ljmp $__KERNEL_CS, $1f
19648 +1:
19649 +#ifdef CONFIG_PARAVIRT
19650 + mov %esi, %eax
19651 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
19652 +#else
19653 + mov %esi, %cr0
19654 +#endif
19655 +2:
19656 +#ifdef CONFIG_PARAVIRT
19657 + popl %ecx
19658 + popl %eax
19659 +#endif
19660 + ret
19661 +ENDPROC(pax_exit_kernel)
19662 +#endif
19663 +
19664 + .macro pax_erase_kstack
19665 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19666 + call pax_erase_kstack
19667 +#endif
19668 + .endm
19669 +
19670 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
19671 +/*
19672 + * ebp: thread_info
19673 + */
19674 +ENTRY(pax_erase_kstack)
19675 + pushl %edi
19676 + pushl %ecx
19677 + pushl %eax
19678 +
19679 + mov TI_lowest_stack(%ebp), %edi
19680 + mov $-0xBEEF, %eax
19681 + std
19682 +
19683 +1: mov %edi, %ecx
19684 + and $THREAD_SIZE_asm - 1, %ecx
19685 + shr $2, %ecx
19686 + repne scasl
19687 + jecxz 2f
19688 +
19689 + cmp $2*16, %ecx
19690 + jc 2f
19691 +
19692 + mov $2*16, %ecx
19693 + repe scasl
19694 + jecxz 2f
19695 + jne 1b
19696 +
19697 +2: cld
19698 + mov %esp, %ecx
19699 + sub %edi, %ecx
19700 +
19701 + cmp $THREAD_SIZE_asm, %ecx
19702 + jb 3f
19703 + ud2
19704 +3:
19705 +
19706 + shr $2, %ecx
19707 + rep stosl
19708 +
19709 + mov TI_task_thread_sp0(%ebp), %edi
19710 + sub $128, %edi
19711 + mov %edi, TI_lowest_stack(%ebp)
19712 +
19713 + popl %eax
19714 + popl %ecx
19715 + popl %edi
19716 + ret
19717 +ENDPROC(pax_erase_kstack)
19718 +#endif
19719 +
19720 +.macro __SAVE_ALL _DS
19721 cld
19722 PUSH_GS
19723 pushl_cfi %fs
19724 @@ -206,7 +346,7 @@
19725 CFI_REL_OFFSET ecx, 0
19726 pushl_cfi %ebx
19727 CFI_REL_OFFSET ebx, 0
19728 - movl $(__USER_DS), %edx
19729 + movl $\_DS, %edx
19730 movl %edx, %ds
19731 movl %edx, %es
19732 movl $(__KERNEL_PERCPU), %edx
19733 @@ -214,6 +354,15 @@
19734 SET_KERNEL_GS %edx
19735 .endm
19736
19737 +.macro SAVE_ALL
19738 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
19739 + __SAVE_ALL __KERNEL_DS
19740 + pax_enter_kernel
19741 +#else
19742 + __SAVE_ALL __USER_DS
19743 +#endif
19744 +.endm
19745 +
19746 .macro RESTORE_INT_REGS
19747 popl_cfi %ebx
19748 CFI_RESTORE ebx
19749 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
19750 popfl_cfi
19751 jmp syscall_exit
19752 CFI_ENDPROC
19753 -END(ret_from_fork)
19754 +ENDPROC(ret_from_fork)
19755
19756 ENTRY(ret_from_kernel_thread)
19757 CFI_STARTPROC
19758 @@ -344,7 +493,15 @@ ret_from_intr:
19759 andl $SEGMENT_RPL_MASK, %eax
19760 #endif
19761 cmpl $USER_RPL, %eax
19762 +
19763 +#ifdef CONFIG_PAX_KERNEXEC
19764 + jae resume_userspace
19765 +
19766 + pax_exit_kernel
19767 + jmp resume_kernel
19768 +#else
19769 jb resume_kernel # not returning to v8086 or userspace
19770 +#endif
19771
19772 ENTRY(resume_userspace)
19773 LOCKDEP_SYS_EXIT
19774 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
19775 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
19776 # int/exception return?
19777 jne work_pending
19778 - jmp restore_all
19779 -END(ret_from_exception)
19780 + jmp restore_all_pax
19781 +ENDPROC(ret_from_exception)
19782
19783 #ifdef CONFIG_PREEMPT
19784 ENTRY(resume_kernel)
19785 @@ -372,7 +529,7 @@ need_resched:
19786 jz restore_all
19787 call preempt_schedule_irq
19788 jmp need_resched
19789 -END(resume_kernel)
19790 +ENDPROC(resume_kernel)
19791 #endif
19792 CFI_ENDPROC
19793 /*
19794 @@ -406,30 +563,45 @@ sysenter_past_esp:
19795 /*CFI_REL_OFFSET cs, 0*/
19796 /*
19797 * Push current_thread_info()->sysenter_return to the stack.
19798 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
19799 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
19800 */
19801 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
19802 + pushl_cfi $0
19803 CFI_REL_OFFSET eip, 0
19804
19805 pushl_cfi %eax
19806 SAVE_ALL
19807 + GET_THREAD_INFO(%ebp)
19808 + movl TI_sysenter_return(%ebp),%ebp
19809 + movl %ebp,PT_EIP(%esp)
19810 ENABLE_INTERRUPTS(CLBR_NONE)
19811
19812 /*
19813 * Load the potential sixth argument from user stack.
19814 * Careful about security.
19815 */
19816 + movl PT_OLDESP(%esp),%ebp
19817 +
19818 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19819 + mov PT_OLDSS(%esp),%ds
19820 +1: movl %ds:(%ebp),%ebp
19821 + push %ss
19822 + pop %ds
19823 +#else
19824 cmpl $__PAGE_OFFSET-3,%ebp
19825 jae syscall_fault
19826 ASM_STAC
19827 1: movl (%ebp),%ebp
19828 ASM_CLAC
19829 +#endif
19830 +
19831 movl %ebp,PT_EBP(%esp)
19832 _ASM_EXTABLE(1b,syscall_fault)
19833
19834 GET_THREAD_INFO(%ebp)
19835
19836 +#ifdef CONFIG_PAX_RANDKSTACK
19837 + pax_erase_kstack
19838 +#endif
19839 +
19840 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
19841 jnz sysenter_audit
19842 sysenter_do_call:
19843 @@ -444,12 +616,24 @@ sysenter_do_call:
19844 testl $_TIF_ALLWORK_MASK, %ecx
19845 jne sysexit_audit
19846 sysenter_exit:
19847 +
19848 +#ifdef CONFIG_PAX_RANDKSTACK
19849 + pushl_cfi %eax
19850 + movl %esp, %eax
19851 + call pax_randomize_kstack
19852 + popl_cfi %eax
19853 +#endif
19854 +
19855 + pax_erase_kstack
19856 +
19857 /* if something modifies registers it must also disable sysexit */
19858 movl PT_EIP(%esp), %edx
19859 movl PT_OLDESP(%esp), %ecx
19860 xorl %ebp,%ebp
19861 TRACE_IRQS_ON
19862 1: mov PT_FS(%esp), %fs
19863 +2: mov PT_DS(%esp), %ds
19864 +3: mov PT_ES(%esp), %es
19865 PTGS_TO_GS
19866 ENABLE_INTERRUPTS_SYSEXIT
19867
19868 @@ -466,6 +650,9 @@ sysenter_audit:
19869 movl %eax,%edx /* 2nd arg: syscall number */
19870 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
19871 call __audit_syscall_entry
19872 +
19873 + pax_erase_kstack
19874 +
19875 pushl_cfi %ebx
19876 movl PT_EAX(%esp),%eax /* reload syscall number */
19877 jmp sysenter_do_call
19878 @@ -491,10 +678,16 @@ sysexit_audit:
19879
19880 CFI_ENDPROC
19881 .pushsection .fixup,"ax"
19882 -2: movl $0,PT_FS(%esp)
19883 +4: movl $0,PT_FS(%esp)
19884 + jmp 1b
19885 +5: movl $0,PT_DS(%esp)
19886 + jmp 1b
19887 +6: movl $0,PT_ES(%esp)
19888 jmp 1b
19889 .popsection
19890 - _ASM_EXTABLE(1b,2b)
19891 + _ASM_EXTABLE(1b,4b)
19892 + _ASM_EXTABLE(2b,5b)
19893 + _ASM_EXTABLE(3b,6b)
19894 PTGS_TO_GS_EX
19895 ENDPROC(ia32_sysenter_target)
19896
19897 @@ -509,6 +702,11 @@ ENTRY(system_call)
19898 pushl_cfi %eax # save orig_eax
19899 SAVE_ALL
19900 GET_THREAD_INFO(%ebp)
19901 +
19902 +#ifdef CONFIG_PAX_RANDKSTACK
19903 + pax_erase_kstack
19904 +#endif
19905 +
19906 # system call tracing in operation / emulation
19907 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
19908 jnz syscall_trace_entry
19909 @@ -527,6 +725,15 @@ syscall_exit:
19910 testl $_TIF_ALLWORK_MASK, %ecx # current->work
19911 jne syscall_exit_work
19912
19913 +restore_all_pax:
19914 +
19915 +#ifdef CONFIG_PAX_RANDKSTACK
19916 + movl %esp, %eax
19917 + call pax_randomize_kstack
19918 +#endif
19919 +
19920 + pax_erase_kstack
19921 +
19922 restore_all:
19923 TRACE_IRQS_IRET
19924 restore_all_notrace:
19925 @@ -583,14 +790,34 @@ ldt_ss:
19926 * compensating for the offset by changing to the ESPFIX segment with
19927 * a base address that matches for the difference.
19928 */
19929 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
19930 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
19931 mov %esp, %edx /* load kernel esp */
19932 mov PT_OLDESP(%esp), %eax /* load userspace esp */
19933 mov %dx, %ax /* eax: new kernel esp */
19934 sub %eax, %edx /* offset (low word is 0) */
19935 +#ifdef CONFIG_SMP
19936 + movl PER_CPU_VAR(cpu_number), %ebx
19937 + shll $PAGE_SHIFT_asm, %ebx
19938 + addl $cpu_gdt_table, %ebx
19939 +#else
19940 + movl $cpu_gdt_table, %ebx
19941 +#endif
19942 shr $16, %edx
19943 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
19944 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
19945 +
19946 +#ifdef CONFIG_PAX_KERNEXEC
19947 + mov %cr0, %esi
19948 + btr $16, %esi
19949 + mov %esi, %cr0
19950 +#endif
19951 +
19952 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
19953 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
19954 +
19955 +#ifdef CONFIG_PAX_KERNEXEC
19956 + bts $16, %esi
19957 + mov %esi, %cr0
19958 +#endif
19959 +
19960 pushl_cfi $__ESPFIX_SS
19961 pushl_cfi %eax /* new kernel esp */
19962 /* Disable interrupts, but do not irqtrace this section: we
19963 @@ -619,20 +846,18 @@ work_resched:
19964 movl TI_flags(%ebp), %ecx
19965 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
19966 # than syscall tracing?
19967 - jz restore_all
19968 + jz restore_all_pax
19969 testb $_TIF_NEED_RESCHED, %cl
19970 jnz work_resched
19971
19972 work_notifysig: # deal with pending signals and
19973 # notify-resume requests
19974 + movl %esp, %eax
19975 #ifdef CONFIG_VM86
19976 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
19977 - movl %esp, %eax
19978 jne work_notifysig_v86 # returning to kernel-space or
19979 # vm86-space
19980 1:
19981 -#else
19982 - movl %esp, %eax
19983 #endif
19984 TRACE_IRQS_ON
19985 ENABLE_INTERRUPTS(CLBR_NONE)
19986 @@ -653,7 +878,7 @@ work_notifysig_v86:
19987 movl %eax, %esp
19988 jmp 1b
19989 #endif
19990 -END(work_pending)
19991 +ENDPROC(work_pending)
19992
19993 # perform syscall exit tracing
19994 ALIGN
19995 @@ -661,11 +886,14 @@ syscall_trace_entry:
19996 movl $-ENOSYS,PT_EAX(%esp)
19997 movl %esp, %eax
19998 call syscall_trace_enter
19999 +
20000 + pax_erase_kstack
20001 +
20002 /* What it returned is what we'll actually use. */
20003 cmpl $(NR_syscalls), %eax
20004 jnae syscall_call
20005 jmp syscall_exit
20006 -END(syscall_trace_entry)
20007 +ENDPROC(syscall_trace_entry)
20008
20009 # perform syscall exit tracing
20010 ALIGN
20011 @@ -678,21 +906,25 @@ syscall_exit_work:
20012 movl %esp, %eax
20013 call syscall_trace_leave
20014 jmp resume_userspace
20015 -END(syscall_exit_work)
20016 +ENDPROC(syscall_exit_work)
20017 CFI_ENDPROC
20018
20019 RING0_INT_FRAME # can't unwind into user space anyway
20020 syscall_fault:
20021 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20022 + push %ss
20023 + pop %ds
20024 +#endif
20025 ASM_CLAC
20026 GET_THREAD_INFO(%ebp)
20027 movl $-EFAULT,PT_EAX(%esp)
20028 jmp resume_userspace
20029 -END(syscall_fault)
20030 +ENDPROC(syscall_fault)
20031
20032 syscall_badsys:
20033 movl $-ENOSYS,PT_EAX(%esp)
20034 jmp resume_userspace
20035 -END(syscall_badsys)
20036 +ENDPROC(syscall_badsys)
20037 CFI_ENDPROC
20038 /*
20039 * End of kprobes section
20040 @@ -708,8 +940,15 @@ END(syscall_badsys)
20041 * normal stack and adjusts ESP with the matching offset.
20042 */
20043 /* fixup the stack */
20044 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
20045 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
20046 +#ifdef CONFIG_SMP
20047 + movl PER_CPU_VAR(cpu_number), %ebx
20048 + shll $PAGE_SHIFT_asm, %ebx
20049 + addl $cpu_gdt_table, %ebx
20050 +#else
20051 + movl $cpu_gdt_table, %ebx
20052 +#endif
20053 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
20054 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
20055 shl $16, %eax
20056 addl %esp, %eax /* the adjusted stack pointer */
20057 pushl_cfi $__KERNEL_DS
20058 @@ -762,7 +1001,7 @@ vector=vector+1
20059 .endr
20060 2: jmp common_interrupt
20061 .endr
20062 -END(irq_entries_start)
20063 +ENDPROC(irq_entries_start)
20064
20065 .previous
20066 END(interrupt)
20067 @@ -813,7 +1052,7 @@ ENTRY(coprocessor_error)
20068 pushl_cfi $do_coprocessor_error
20069 jmp error_code
20070 CFI_ENDPROC
20071 -END(coprocessor_error)
20072 +ENDPROC(coprocessor_error)
20073
20074 ENTRY(simd_coprocessor_error)
20075 RING0_INT_FRAME
20076 @@ -826,7 +1065,7 @@ ENTRY(simd_coprocessor_error)
20077 .section .altinstructions,"a"
20078 altinstruction_entry 661b, 663f, X86_FEATURE_XMM, 662b-661b, 664f-663f
20079 .previous
20080 -.section .altinstr_replacement,"ax"
20081 +.section .altinstr_replacement,"a"
20082 663: pushl $do_simd_coprocessor_error
20083 664:
20084 .previous
20085 @@ -835,7 +1074,7 @@ ENTRY(simd_coprocessor_error)
20086 #endif
20087 jmp error_code
20088 CFI_ENDPROC
20089 -END(simd_coprocessor_error)
20090 +ENDPROC(simd_coprocessor_error)
20091
20092 ENTRY(device_not_available)
20093 RING0_INT_FRAME
20094 @@ -844,18 +1083,18 @@ ENTRY(device_not_available)
20095 pushl_cfi $do_device_not_available
20096 jmp error_code
20097 CFI_ENDPROC
20098 -END(device_not_available)
20099 +ENDPROC(device_not_available)
20100
20101 #ifdef CONFIG_PARAVIRT
20102 ENTRY(native_iret)
20103 iret
20104 _ASM_EXTABLE(native_iret, iret_exc)
20105 -END(native_iret)
20106 +ENDPROC(native_iret)
20107
20108 ENTRY(native_irq_enable_sysexit)
20109 sti
20110 sysexit
20111 -END(native_irq_enable_sysexit)
20112 +ENDPROC(native_irq_enable_sysexit)
20113 #endif
20114
20115 ENTRY(overflow)
20116 @@ -865,7 +1104,7 @@ ENTRY(overflow)
20117 pushl_cfi $do_overflow
20118 jmp error_code
20119 CFI_ENDPROC
20120 -END(overflow)
20121 +ENDPROC(overflow)
20122
20123 ENTRY(bounds)
20124 RING0_INT_FRAME
20125 @@ -874,7 +1113,7 @@ ENTRY(bounds)
20126 pushl_cfi $do_bounds
20127 jmp error_code
20128 CFI_ENDPROC
20129 -END(bounds)
20130 +ENDPROC(bounds)
20131
20132 ENTRY(invalid_op)
20133 RING0_INT_FRAME
20134 @@ -883,7 +1122,7 @@ ENTRY(invalid_op)
20135 pushl_cfi $do_invalid_op
20136 jmp error_code
20137 CFI_ENDPROC
20138 -END(invalid_op)
20139 +ENDPROC(invalid_op)
20140
20141 ENTRY(coprocessor_segment_overrun)
20142 RING0_INT_FRAME
20143 @@ -892,7 +1131,7 @@ ENTRY(coprocessor_segment_overrun)
20144 pushl_cfi $do_coprocessor_segment_overrun
20145 jmp error_code
20146 CFI_ENDPROC
20147 -END(coprocessor_segment_overrun)
20148 +ENDPROC(coprocessor_segment_overrun)
20149
20150 ENTRY(invalid_TSS)
20151 RING0_EC_FRAME
20152 @@ -900,7 +1139,7 @@ ENTRY(invalid_TSS)
20153 pushl_cfi $do_invalid_TSS
20154 jmp error_code
20155 CFI_ENDPROC
20156 -END(invalid_TSS)
20157 +ENDPROC(invalid_TSS)
20158
20159 ENTRY(segment_not_present)
20160 RING0_EC_FRAME
20161 @@ -908,7 +1147,7 @@ ENTRY(segment_not_present)
20162 pushl_cfi $do_segment_not_present
20163 jmp error_code
20164 CFI_ENDPROC
20165 -END(segment_not_present)
20166 +ENDPROC(segment_not_present)
20167
20168 ENTRY(stack_segment)
20169 RING0_EC_FRAME
20170 @@ -916,7 +1155,7 @@ ENTRY(stack_segment)
20171 pushl_cfi $do_stack_segment
20172 jmp error_code
20173 CFI_ENDPROC
20174 -END(stack_segment)
20175 +ENDPROC(stack_segment)
20176
20177 ENTRY(alignment_check)
20178 RING0_EC_FRAME
20179 @@ -924,7 +1163,7 @@ ENTRY(alignment_check)
20180 pushl_cfi $do_alignment_check
20181 jmp error_code
20182 CFI_ENDPROC
20183 -END(alignment_check)
20184 +ENDPROC(alignment_check)
20185
20186 ENTRY(divide_error)
20187 RING0_INT_FRAME
20188 @@ -933,7 +1172,7 @@ ENTRY(divide_error)
20189 pushl_cfi $do_divide_error
20190 jmp error_code
20191 CFI_ENDPROC
20192 -END(divide_error)
20193 +ENDPROC(divide_error)
20194
20195 #ifdef CONFIG_X86_MCE
20196 ENTRY(machine_check)
20197 @@ -943,7 +1182,7 @@ ENTRY(machine_check)
20198 pushl_cfi machine_check_vector
20199 jmp error_code
20200 CFI_ENDPROC
20201 -END(machine_check)
20202 +ENDPROC(machine_check)
20203 #endif
20204
20205 ENTRY(spurious_interrupt_bug)
20206 @@ -953,7 +1192,7 @@ ENTRY(spurious_interrupt_bug)
20207 pushl_cfi $do_spurious_interrupt_bug
20208 jmp error_code
20209 CFI_ENDPROC
20210 -END(spurious_interrupt_bug)
20211 +ENDPROC(spurious_interrupt_bug)
20212 /*
20213 * End of kprobes section
20214 */
20215 @@ -1063,7 +1302,7 @@ BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
20216
20217 ENTRY(mcount)
20218 ret
20219 -END(mcount)
20220 +ENDPROC(mcount)
20221
20222 ENTRY(ftrace_caller)
20223 cmpl $0, function_trace_stop
20224 @@ -1096,7 +1335,7 @@ ftrace_graph_call:
20225 .globl ftrace_stub
20226 ftrace_stub:
20227 ret
20228 -END(ftrace_caller)
20229 +ENDPROC(ftrace_caller)
20230
20231 ENTRY(ftrace_regs_caller)
20232 pushf /* push flags before compare (in cs location) */
20233 @@ -1197,7 +1436,7 @@ trace:
20234 popl %ecx
20235 popl %eax
20236 jmp ftrace_stub
20237 -END(mcount)
20238 +ENDPROC(mcount)
20239 #endif /* CONFIG_DYNAMIC_FTRACE */
20240 #endif /* CONFIG_FUNCTION_TRACER */
20241
20242 @@ -1215,7 +1454,7 @@ ENTRY(ftrace_graph_caller)
20243 popl %ecx
20244 popl %eax
20245 ret
20246 -END(ftrace_graph_caller)
20247 +ENDPROC(ftrace_graph_caller)
20248
20249 .globl return_to_handler
20250 return_to_handler:
20251 @@ -1271,15 +1510,18 @@ error_code:
20252 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
20253 REG_TO_PTGS %ecx
20254 SET_KERNEL_GS %ecx
20255 - movl $(__USER_DS), %ecx
20256 + movl $(__KERNEL_DS), %ecx
20257 movl %ecx, %ds
20258 movl %ecx, %es
20259 +
20260 + pax_enter_kernel
20261 +
20262 TRACE_IRQS_OFF
20263 movl %esp,%eax # pt_regs pointer
20264 call *%edi
20265 jmp ret_from_exception
20266 CFI_ENDPROC
20267 -END(page_fault)
20268 +ENDPROC(page_fault)
20269
20270 /*
20271 * Debug traps and NMI can happen at the one SYSENTER instruction
20272 @@ -1322,7 +1564,7 @@ debug_stack_correct:
20273 call do_debug
20274 jmp ret_from_exception
20275 CFI_ENDPROC
20276 -END(debug)
20277 +ENDPROC(debug)
20278
20279 /*
20280 * NMI is doubly nasty. It can happen _while_ we're handling
20281 @@ -1360,6 +1602,9 @@ nmi_stack_correct:
20282 xorl %edx,%edx # zero error code
20283 movl %esp,%eax # pt_regs pointer
20284 call do_nmi
20285 +
20286 + pax_exit_kernel
20287 +
20288 jmp restore_all_notrace
20289 CFI_ENDPROC
20290
20291 @@ -1396,12 +1641,15 @@ nmi_espfix_stack:
20292 FIXUP_ESPFIX_STACK # %eax == %esp
20293 xorl %edx,%edx # zero error code
20294 call do_nmi
20295 +
20296 + pax_exit_kernel
20297 +
20298 RESTORE_REGS
20299 lss 12+4(%esp), %esp # back to espfix stack
20300 CFI_ADJUST_CFA_OFFSET -24
20301 jmp irq_return
20302 CFI_ENDPROC
20303 -END(nmi)
20304 +ENDPROC(nmi)
20305
20306 ENTRY(int3)
20307 RING0_INT_FRAME
20308 @@ -1414,14 +1662,14 @@ ENTRY(int3)
20309 call do_int3
20310 jmp ret_from_exception
20311 CFI_ENDPROC
20312 -END(int3)
20313 +ENDPROC(int3)
20314
20315 ENTRY(general_protection)
20316 RING0_EC_FRAME
20317 pushl_cfi $do_general_protection
20318 jmp error_code
20319 CFI_ENDPROC
20320 -END(general_protection)
20321 +ENDPROC(general_protection)
20322
20323 #ifdef CONFIG_KVM_GUEST
20324 ENTRY(async_page_fault)
20325 @@ -1430,7 +1678,7 @@ ENTRY(async_page_fault)
20326 pushl_cfi $do_async_page_fault
20327 jmp error_code
20328 CFI_ENDPROC
20329 -END(async_page_fault)
20330 +ENDPROC(async_page_fault)
20331 #endif
20332
20333 /*
20334 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
20335 index 7272089..ee191c7 100644
20336 --- a/arch/x86/kernel/entry_64.S
20337 +++ b/arch/x86/kernel/entry_64.S
20338 @@ -59,6 +59,8 @@
20339 #include <asm/context_tracking.h>
20340 #include <asm/smap.h>
20341 #include <linux/err.h>
20342 +#include <asm/pgtable.h>
20343 +#include <asm/alternative-asm.h>
20344
20345 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
20346 #include <linux/elf-em.h>
20347 @@ -80,8 +82,9 @@
20348 #ifdef CONFIG_DYNAMIC_FTRACE
20349
20350 ENTRY(function_hook)
20351 + pax_force_retaddr
20352 retq
20353 -END(function_hook)
20354 +ENDPROC(function_hook)
20355
20356 /* skip is set if stack has been adjusted */
20357 .macro ftrace_caller_setup skip=0
20358 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
20359 #endif
20360
20361 GLOBAL(ftrace_stub)
20362 + pax_force_retaddr
20363 retq
20364 -END(ftrace_caller)
20365 +ENDPROC(ftrace_caller)
20366
20367 ENTRY(ftrace_regs_caller)
20368 /* Save the current flags before compare (in SS location)*/
20369 @@ -191,7 +195,7 @@ ftrace_restore_flags:
20370 popfq
20371 jmp ftrace_stub
20372
20373 -END(ftrace_regs_caller)
20374 +ENDPROC(ftrace_regs_caller)
20375
20376
20377 #else /* ! CONFIG_DYNAMIC_FTRACE */
20378 @@ -212,6 +216,7 @@ ENTRY(function_hook)
20379 #endif
20380
20381 GLOBAL(ftrace_stub)
20382 + pax_force_retaddr
20383 retq
20384
20385 trace:
20386 @@ -225,12 +230,13 @@ trace:
20387 #endif
20388 subq $MCOUNT_INSN_SIZE, %rdi
20389
20390 + pax_force_fptr ftrace_trace_function
20391 call *ftrace_trace_function
20392
20393 MCOUNT_RESTORE_FRAME
20394
20395 jmp ftrace_stub
20396 -END(function_hook)
20397 +ENDPROC(function_hook)
20398 #endif /* CONFIG_DYNAMIC_FTRACE */
20399 #endif /* CONFIG_FUNCTION_TRACER */
20400
20401 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
20402
20403 MCOUNT_RESTORE_FRAME
20404
20405 + pax_force_retaddr
20406 retq
20407 -END(ftrace_graph_caller)
20408 +ENDPROC(ftrace_graph_caller)
20409
20410 GLOBAL(return_to_handler)
20411 subq $24, %rsp
20412 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
20413 movq 8(%rsp), %rdx
20414 movq (%rsp), %rax
20415 addq $24, %rsp
20416 + pax_force_fptr %rdi
20417 jmp *%rdi
20418 +ENDPROC(return_to_handler)
20419 #endif
20420
20421
20422 @@ -284,6 +293,430 @@ ENTRY(native_usergs_sysret64)
20423 ENDPROC(native_usergs_sysret64)
20424 #endif /* CONFIG_PARAVIRT */
20425
20426 + .macro ljmpq sel, off
20427 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
20428 + .byte 0x48; ljmp *1234f(%rip)
20429 + .pushsection .rodata
20430 + .align 16
20431 + 1234: .quad \off; .word \sel
20432 + .popsection
20433 +#else
20434 + pushq $\sel
20435 + pushq $\off
20436 + lretq
20437 +#endif
20438 + .endm
20439 +
20440 + .macro pax_enter_kernel
20441 + pax_set_fptr_mask
20442 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
20443 + call pax_enter_kernel
20444 +#endif
20445 + .endm
20446 +
20447 + .macro pax_exit_kernel
20448 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
20449 + call pax_exit_kernel
20450 +#endif
20451 +
20452 + .endm
20453 +
20454 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
20455 +ENTRY(pax_enter_kernel)
20456 + pushq %rdi
20457 +
20458 +#ifdef CONFIG_PARAVIRT
20459 + PV_SAVE_REGS(CLBR_RDI)
20460 +#endif
20461 +
20462 +#ifdef CONFIG_PAX_KERNEXEC
20463 + GET_CR0_INTO_RDI
20464 + bts $16,%rdi
20465 + jnc 3f
20466 + mov %cs,%edi
20467 + cmp $__KERNEL_CS,%edi
20468 + jnz 2f
20469 +1:
20470 +#endif
20471 +
20472 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20473 + 661: jmp 111f
20474 + .pushsection .altinstr_replacement, "a"
20475 + 662: ASM_NOP2
20476 + .popsection
20477 + .pushsection .altinstructions, "a"
20478 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
20479 + .popsection
20480 + GET_CR3_INTO_RDI
20481 + cmp $0,%dil
20482 + jnz 112f
20483 + mov $__KERNEL_DS,%edi
20484 + mov %edi,%ss
20485 + jmp 111f
20486 +112: cmp $1,%dil
20487 + jz 113f
20488 + ud2
20489 +113: sub $4097,%rdi
20490 + bts $63,%rdi
20491 + SET_RDI_INTO_CR3
20492 + mov $__UDEREF_KERNEL_DS,%edi
20493 + mov %edi,%ss
20494 +111:
20495 +#endif
20496 +
20497 +#ifdef CONFIG_PARAVIRT
20498 + PV_RESTORE_REGS(CLBR_RDI)
20499 +#endif
20500 +
20501 + popq %rdi
20502 + pax_force_retaddr
20503 + retq
20504 +
20505 +#ifdef CONFIG_PAX_KERNEXEC
20506 +2: ljmpq __KERNEL_CS,1b
20507 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
20508 +4: SET_RDI_INTO_CR0
20509 + jmp 1b
20510 +#endif
20511 +ENDPROC(pax_enter_kernel)
20512 +
20513 +ENTRY(pax_exit_kernel)
20514 + pushq %rdi
20515 +
20516 +#ifdef CONFIG_PARAVIRT
20517 + PV_SAVE_REGS(CLBR_RDI)
20518 +#endif
20519 +
20520 +#ifdef CONFIG_PAX_KERNEXEC
20521 + mov %cs,%rdi
20522 + cmp $__KERNEXEC_KERNEL_CS,%edi
20523 + jz 2f
20524 + GET_CR0_INTO_RDI
20525 + bts $16,%rdi
20526 + jnc 4f
20527 +1:
20528 +#endif
20529 +
20530 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20531 + 661: jmp 111f
20532 + .pushsection .altinstr_replacement, "a"
20533 + 662: ASM_NOP2
20534 + .popsection
20535 + .pushsection .altinstructions, "a"
20536 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
20537 + .popsection
20538 + mov %ss,%edi
20539 + cmp $__UDEREF_KERNEL_DS,%edi
20540 + jnz 111f
20541 + GET_CR3_INTO_RDI
20542 + cmp $0,%dil
20543 + jz 112f
20544 + ud2
20545 +112: add $4097,%rdi
20546 + bts $63,%rdi
20547 + SET_RDI_INTO_CR3
20548 + mov $__KERNEL_DS,%edi
20549 + mov %edi,%ss
20550 +111:
20551 +#endif
20552 +
20553 +#ifdef CONFIG_PARAVIRT
20554 + PV_RESTORE_REGS(CLBR_RDI);
20555 +#endif
20556 +
20557 + popq %rdi
20558 + pax_force_retaddr
20559 + retq
20560 +
20561 +#ifdef CONFIG_PAX_KERNEXEC
20562 +2: GET_CR0_INTO_RDI
20563 + btr $16,%rdi
20564 + jnc 4f
20565 + ljmpq __KERNEL_CS,3f
20566 +3: SET_RDI_INTO_CR0
20567 + jmp 1b
20568 +4: ud2
20569 + jmp 4b
20570 +#endif
20571 +ENDPROC(pax_exit_kernel)
20572 +#endif
20573 +
20574 + .macro pax_enter_kernel_user
20575 + pax_set_fptr_mask
20576 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20577 + call pax_enter_kernel_user
20578 +#endif
20579 + .endm
20580 +
20581 + .macro pax_exit_kernel_user
20582 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20583 + call pax_exit_kernel_user
20584 +#endif
20585 +#ifdef CONFIG_PAX_RANDKSTACK
20586 + pushq %rax
20587 + pushq %r11
20588 + call pax_randomize_kstack
20589 + popq %r11
20590 + popq %rax
20591 +#endif
20592 + .endm
20593 +
20594 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20595 +ENTRY(pax_enter_kernel_user)
20596 + pushq %rdi
20597 + pushq %rbx
20598 +
20599 +#ifdef CONFIG_PARAVIRT
20600 + PV_SAVE_REGS(CLBR_RDI)
20601 +#endif
20602 +
20603 + 661: jmp 111f
20604 + .pushsection .altinstr_replacement, "a"
20605 + 662: ASM_NOP2
20606 + .popsection
20607 + .pushsection .altinstructions, "a"
20608 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
20609 + .popsection
20610 + GET_CR3_INTO_RDI
20611 + cmp $1,%dil
20612 + jnz 4f
20613 + sub $4097,%rdi
20614 + bts $63,%rdi
20615 + SET_RDI_INTO_CR3
20616 + jmp 3f
20617 +111:
20618 +
20619 + GET_CR3_INTO_RDI
20620 + mov %rdi,%rbx
20621 + add $__START_KERNEL_map,%rbx
20622 + sub phys_base(%rip),%rbx
20623 +
20624 +#ifdef CONFIG_PARAVIRT
20625 + cmpl $0, pv_info+PARAVIRT_enabled
20626 + jz 1f
20627 + pushq %rdi
20628 + i = 0
20629 + .rept USER_PGD_PTRS
20630 + mov i*8(%rbx),%rsi
20631 + mov $0,%sil
20632 + lea i*8(%rbx),%rdi
20633 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
20634 + i = i + 1
20635 + .endr
20636 + popq %rdi
20637 + jmp 2f
20638 +1:
20639 +#endif
20640 +
20641 + i = 0
20642 + .rept USER_PGD_PTRS
20643 + movb $0,i*8(%rbx)
20644 + i = i + 1
20645 + .endr
20646 +
20647 +2: SET_RDI_INTO_CR3
20648 +
20649 +#ifdef CONFIG_PAX_KERNEXEC
20650 + GET_CR0_INTO_RDI
20651 + bts $16,%rdi
20652 + SET_RDI_INTO_CR0
20653 +#endif
20654 +
20655 +3:
20656 +
20657 +#ifdef CONFIG_PARAVIRT
20658 + PV_RESTORE_REGS(CLBR_RDI)
20659 +#endif
20660 +
20661 + popq %rbx
20662 + popq %rdi
20663 + pax_force_retaddr
20664 + retq
20665 +4: ud2
20666 +ENDPROC(pax_enter_kernel_user)
20667 +
20668 +ENTRY(pax_exit_kernel_user)
20669 + pushq %rdi
20670 + pushq %rbx
20671 +
20672 +#ifdef CONFIG_PARAVIRT
20673 + PV_SAVE_REGS(CLBR_RDI)
20674 +#endif
20675 +
20676 + GET_CR3_INTO_RDI
20677 + 661: jmp 1f
20678 + .pushsection .altinstr_replacement, "a"
20679 + 662: ASM_NOP2
20680 + .popsection
20681 + .pushsection .altinstructions, "a"
20682 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
20683 + .popsection
20684 + cmp $0,%dil
20685 + jnz 3f
20686 + add $4097,%rdi
20687 + bts $63,%rdi
20688 + SET_RDI_INTO_CR3
20689 + jmp 2f
20690 +1:
20691 + mov %rdi,%rbx
20692 + add $__START_KERNEL_map,%rbx
20693 + sub phys_base(%rip),%rbx
20694 +
20695 +#ifdef CONFIG_PARAVIRT
20696 + cmpl $0, pv_info+PARAVIRT_enabled
20697 + jz 1f
20698 + pushq %rdi
20699 + i = 0
20700 + .rept USER_PGD_PTRS
20701 + mov i*8(%rbx),%rsi
20702 + mov $0x67,%sil
20703 + lea i*8(%rbx),%rdi
20704 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
20705 + i = i + 1
20706 + .endr
20707 + popq %rdi
20708 + jmp 2f
20709 +1:
20710 +#endif
20711 +
20712 +#ifdef CONFIG_PAX_KERNEXEC
20713 + GET_CR0_INTO_RDI
20714 + btr $16,%rdi
20715 + jnc 3f
20716 + SET_RDI_INTO_CR0
20717 +#endif
20718 +
20719 + i = 0
20720 + .rept USER_PGD_PTRS
20721 + movb $0x67,i*8(%rbx)
20722 + i = i + 1
20723 + .endr
20724 +2:
20725 +
20726 +#ifdef CONFIG_PARAVIRT
20727 + PV_RESTORE_REGS(CLBR_RDI)
20728 +#endif
20729 +
20730 + popq %rbx
20731 + popq %rdi
20732 + pax_force_retaddr
20733 + retq
20734 +3: ud2
20735 +ENDPROC(pax_exit_kernel_user)
20736 +#endif
20737 +
20738 + .macro pax_enter_kernel_nmi
20739 + pax_set_fptr_mask
20740 +
20741 +#ifdef CONFIG_PAX_KERNEXEC
20742 + GET_CR0_INTO_RDI
20743 + bts $16,%rdi
20744 + jc 110f
20745 + SET_RDI_INTO_CR0
20746 + or $2,%ebx
20747 +110:
20748 +#endif
20749 +
20750 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20751 + 661: jmp 111f
20752 + .pushsection .altinstr_replacement, "a"
20753 + 662: ASM_NOP2
20754 + .popsection
20755 + .pushsection .altinstructions, "a"
20756 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
20757 + .popsection
20758 + GET_CR3_INTO_RDI
20759 + cmp $0,%dil
20760 + jz 111f
20761 + sub $4097,%rdi
20762 + or $4,%ebx
20763 + bts $63,%rdi
20764 + SET_RDI_INTO_CR3
20765 + mov $__UDEREF_KERNEL_DS,%edi
20766 + mov %edi,%ss
20767 +111:
20768 +#endif
20769 + .endm
20770 +
20771 + .macro pax_exit_kernel_nmi
20772 +#ifdef CONFIG_PAX_KERNEXEC
20773 + btr $1,%ebx
20774 + jnc 110f
20775 + GET_CR0_INTO_RDI
20776 + btr $16,%rdi
20777 + SET_RDI_INTO_CR0
20778 +110:
20779 +#endif
20780 +
20781 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20782 + btr $2,%ebx
20783 + jnc 111f
20784 + GET_CR3_INTO_RDI
20785 + add $4097,%rdi
20786 + bts $63,%rdi
20787 + SET_RDI_INTO_CR3
20788 + mov $__KERNEL_DS,%edi
20789 + mov %edi,%ss
20790 +111:
20791 +#endif
20792 + .endm
20793 +
20794 + .macro pax_erase_kstack
20795 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20796 + call pax_erase_kstack
20797 +#endif
20798 + .endm
20799 +
20800 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
20801 +ENTRY(pax_erase_kstack)
20802 + pushq %rdi
20803 + pushq %rcx
20804 + pushq %rax
20805 + pushq %r11
20806 +
20807 + GET_THREAD_INFO(%r11)
20808 + mov TI_lowest_stack(%r11), %rdi
20809 + mov $-0xBEEF, %rax
20810 + std
20811 +
20812 +1: mov %edi, %ecx
20813 + and $THREAD_SIZE_asm - 1, %ecx
20814 + shr $3, %ecx
20815 + repne scasq
20816 + jecxz 2f
20817 +
20818 + cmp $2*8, %ecx
20819 + jc 2f
20820 +
20821 + mov $2*8, %ecx
20822 + repe scasq
20823 + jecxz 2f
20824 + jne 1b
20825 +
20826 +2: cld
20827 + mov %esp, %ecx
20828 + sub %edi, %ecx
20829 +
20830 + cmp $THREAD_SIZE_asm, %rcx
20831 + jb 3f
20832 + ud2
20833 +3:
20834 +
20835 + shr $3, %ecx
20836 + rep stosq
20837 +
20838 + mov TI_task_thread_sp0(%r11), %rdi
20839 + sub $256, %rdi
20840 + mov %rdi, TI_lowest_stack(%r11)
20841 +
20842 + popq %r11
20843 + popq %rax
20844 + popq %rcx
20845 + popq %rdi
20846 + pax_force_retaddr
20847 + ret
20848 +ENDPROC(pax_erase_kstack)
20849 +#endif
20850
20851 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
20852 #ifdef CONFIG_TRACE_IRQFLAGS
20853 @@ -375,8 +808,8 @@ ENDPROC(native_usergs_sysret64)
20854 .endm
20855
20856 .macro UNFAKE_STACK_FRAME
20857 - addq $8*6, %rsp
20858 - CFI_ADJUST_CFA_OFFSET -(6*8)
20859 + addq $8*6 + ARG_SKIP, %rsp
20860 + CFI_ADJUST_CFA_OFFSET -(6*8 + ARG_SKIP)
20861 .endm
20862
20863 /*
20864 @@ -463,7 +896,7 @@ ENDPROC(native_usergs_sysret64)
20865 movq %rsp, %rsi
20866
20867 leaq -RBP(%rsp),%rdi /* arg1 for handler */
20868 - testl $3, CS-RBP(%rsi)
20869 + testb $3, CS-RBP(%rsi)
20870 je 1f
20871 SWAPGS
20872 /*
20873 @@ -498,9 +931,10 @@ ENTRY(save_rest)
20874 movq_cfi r15, R15+16
20875 movq %r11, 8(%rsp) /* return address */
20876 FIXUP_TOP_OF_STACK %r11, 16
20877 + pax_force_retaddr
20878 ret
20879 CFI_ENDPROC
20880 -END(save_rest)
20881 +ENDPROC(save_rest)
20882
20883 /* save complete stack frame */
20884 .pushsection .kprobes.text, "ax"
20885 @@ -529,9 +963,10 @@ ENTRY(save_paranoid)
20886 js 1f /* negative -> in kernel */
20887 SWAPGS
20888 xorl %ebx,%ebx
20889 -1: ret
20890 +1: pax_force_retaddr_bts
20891 + ret
20892 CFI_ENDPROC
20893 -END(save_paranoid)
20894 +ENDPROC(save_paranoid)
20895 .popsection
20896
20897 /*
20898 @@ -553,7 +988,7 @@ ENTRY(ret_from_fork)
20899
20900 RESTORE_REST
20901
20902 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
20903 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
20904 jz 1f
20905
20906 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
20907 @@ -571,7 +1006,7 @@ ENTRY(ret_from_fork)
20908 RESTORE_REST
20909 jmp int_ret_from_sys_call
20910 CFI_ENDPROC
20911 -END(ret_from_fork)
20912 +ENDPROC(ret_from_fork)
20913
20914 /*
20915 * System call entry. Up to 6 arguments in registers are supported.
20916 @@ -608,7 +1043,7 @@ END(ret_from_fork)
20917 ENTRY(system_call)
20918 CFI_STARTPROC simple
20919 CFI_SIGNAL_FRAME
20920 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
20921 + CFI_DEF_CFA rsp,0
20922 CFI_REGISTER rip,rcx
20923 /*CFI_REGISTER rflags,r11*/
20924 SWAPGS_UNSAFE_STACK
20925 @@ -621,16 +1056,23 @@ GLOBAL(system_call_after_swapgs)
20926
20927 movq %rsp,PER_CPU_VAR(old_rsp)
20928 movq PER_CPU_VAR(kernel_stack),%rsp
20929 + SAVE_ARGS 8*6,0
20930 + pax_enter_kernel_user
20931 +
20932 +#ifdef CONFIG_PAX_RANDKSTACK
20933 + pax_erase_kstack
20934 +#endif
20935 +
20936 /*
20937 * No need to follow this irqs off/on section - it's straight
20938 * and short:
20939 */
20940 ENABLE_INTERRUPTS(CLBR_NONE)
20941 - SAVE_ARGS 8,0
20942 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
20943 movq %rcx,RIP-ARGOFFSET(%rsp)
20944 CFI_REL_OFFSET rip,RIP-ARGOFFSET
20945 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
20946 + GET_THREAD_INFO(%rcx)
20947 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
20948 jnz tracesys
20949 system_call_fastpath:
20950 #if __SYSCALL_MASK == ~0
20951 @@ -640,7 +1082,7 @@ system_call_fastpath:
20952 cmpl $__NR_syscall_max,%eax
20953 #endif
20954 ja badsys
20955 - movq %r10,%rcx
20956 + movq R10-ARGOFFSET(%rsp),%rcx
20957 call *sys_call_table(,%rax,8) # XXX: rip relative
20958 movq %rax,RAX-ARGOFFSET(%rsp)
20959 /*
20960 @@ -654,10 +1096,13 @@ sysret_check:
20961 LOCKDEP_SYS_EXIT
20962 DISABLE_INTERRUPTS(CLBR_NONE)
20963 TRACE_IRQS_OFF
20964 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
20965 + GET_THREAD_INFO(%rcx)
20966 + movl TI_flags(%rcx),%edx
20967 andl %edi,%edx
20968 jnz sysret_careful
20969 CFI_REMEMBER_STATE
20970 + pax_exit_kernel_user
20971 + pax_erase_kstack
20972 /*
20973 * sysretq will re-enable interrupts:
20974 */
20975 @@ -709,14 +1154,18 @@ badsys:
20976 * jump back to the normal fast path.
20977 */
20978 auditsys:
20979 - movq %r10,%r9 /* 6th arg: 4th syscall arg */
20980 + movq R10-ARGOFFSET(%rsp),%r9 /* 6th arg: 4th syscall arg */
20981 movq %rdx,%r8 /* 5th arg: 3rd syscall arg */
20982 movq %rsi,%rcx /* 4th arg: 2nd syscall arg */
20983 movq %rdi,%rdx /* 3rd arg: 1st syscall arg */
20984 movq %rax,%rsi /* 2nd arg: syscall number */
20985 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
20986 call __audit_syscall_entry
20987 +
20988 + pax_erase_kstack
20989 +
20990 LOAD_ARGS 0 /* reload call-clobbered registers */
20991 + pax_set_fptr_mask
20992 jmp system_call_fastpath
20993
20994 /*
20995 @@ -737,7 +1186,7 @@ sysret_audit:
20996 /* Do syscall tracing */
20997 tracesys:
20998 #ifdef CONFIG_AUDITSYSCALL
20999 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
21000 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
21001 jz auditsys
21002 #endif
21003 SAVE_REST
21004 @@ -745,12 +1194,16 @@ tracesys:
21005 FIXUP_TOP_OF_STACK %rdi
21006 movq %rsp,%rdi
21007 call syscall_trace_enter
21008 +
21009 + pax_erase_kstack
21010 +
21011 /*
21012 * Reload arg registers from stack in case ptrace changed them.
21013 * We don't reload %rax because syscall_trace_enter() returned
21014 * the value it wants us to use in the table lookup.
21015 */
21016 LOAD_ARGS ARGOFFSET, 1
21017 + pax_set_fptr_mask
21018 RESTORE_REST
21019 #if __SYSCALL_MASK == ~0
21020 cmpq $__NR_syscall_max,%rax
21021 @@ -759,7 +1212,7 @@ tracesys:
21022 cmpl $__NR_syscall_max,%eax
21023 #endif
21024 ja int_ret_from_sys_call /* RAX(%rsp) set to -ENOSYS above */
21025 - movq %r10,%rcx /* fixup for C */
21026 + movq R10-ARGOFFSET(%rsp),%rcx /* fixup for C */
21027 call *sys_call_table(,%rax,8)
21028 movq %rax,RAX-ARGOFFSET(%rsp)
21029 /* Use IRET because user could have changed frame */
21030 @@ -780,7 +1233,9 @@ GLOBAL(int_with_check)
21031 andl %edi,%edx
21032 jnz int_careful
21033 andl $~TS_COMPAT,TI_status(%rcx)
21034 - jmp retint_swapgs
21035 + pax_exit_kernel_user
21036 + pax_erase_kstack
21037 + jmp retint_swapgs_pax
21038
21039 /* Either reschedule or signal or syscall exit tracking needed. */
21040 /* First do a reschedule test. */
21041 @@ -826,7 +1281,7 @@ int_restore_rest:
21042 TRACE_IRQS_OFF
21043 jmp int_with_check
21044 CFI_ENDPROC
21045 -END(system_call)
21046 +ENDPROC(system_call)
21047
21048 .macro FORK_LIKE func
21049 ENTRY(stub_\func)
21050 @@ -839,9 +1294,10 @@ ENTRY(stub_\func)
21051 DEFAULT_FRAME 0 8 /* offset 8: return address */
21052 call sys_\func
21053 RESTORE_TOP_OF_STACK %r11, 8
21054 + pax_force_retaddr
21055 ret $REST_SKIP /* pop extended registers */
21056 CFI_ENDPROC
21057 -END(stub_\func)
21058 +ENDPROC(stub_\func)
21059 .endm
21060
21061 .macro FIXED_FRAME label,func
21062 @@ -851,9 +1307,10 @@ ENTRY(\label)
21063 FIXUP_TOP_OF_STACK %r11, 8-ARGOFFSET
21064 call \func
21065 RESTORE_TOP_OF_STACK %r11, 8-ARGOFFSET
21066 + pax_force_retaddr
21067 ret
21068 CFI_ENDPROC
21069 -END(\label)
21070 +ENDPROC(\label)
21071 .endm
21072
21073 FORK_LIKE clone
21074 @@ -870,9 +1327,10 @@ ENTRY(ptregscall_common)
21075 movq_cfi_restore R12+8, r12
21076 movq_cfi_restore RBP+8, rbp
21077 movq_cfi_restore RBX+8, rbx
21078 + pax_force_retaddr
21079 ret $REST_SKIP /* pop extended registers */
21080 CFI_ENDPROC
21081 -END(ptregscall_common)
21082 +ENDPROC(ptregscall_common)
21083
21084 ENTRY(stub_execve)
21085 CFI_STARTPROC
21086 @@ -885,7 +1343,7 @@ ENTRY(stub_execve)
21087 RESTORE_REST
21088 jmp int_ret_from_sys_call
21089 CFI_ENDPROC
21090 -END(stub_execve)
21091 +ENDPROC(stub_execve)
21092
21093 /*
21094 * sigreturn is special because it needs to restore all registers on return.
21095 @@ -902,7 +1360,7 @@ ENTRY(stub_rt_sigreturn)
21096 RESTORE_REST
21097 jmp int_ret_from_sys_call
21098 CFI_ENDPROC
21099 -END(stub_rt_sigreturn)
21100 +ENDPROC(stub_rt_sigreturn)
21101
21102 #ifdef CONFIG_X86_X32_ABI
21103 ENTRY(stub_x32_rt_sigreturn)
21104 @@ -916,7 +1374,7 @@ ENTRY(stub_x32_rt_sigreturn)
21105 RESTORE_REST
21106 jmp int_ret_from_sys_call
21107 CFI_ENDPROC
21108 -END(stub_x32_rt_sigreturn)
21109 +ENDPROC(stub_x32_rt_sigreturn)
21110
21111 ENTRY(stub_x32_execve)
21112 CFI_STARTPROC
21113 @@ -930,7 +1388,7 @@ ENTRY(stub_x32_execve)
21114 RESTORE_REST
21115 jmp int_ret_from_sys_call
21116 CFI_ENDPROC
21117 -END(stub_x32_execve)
21118 +ENDPROC(stub_x32_execve)
21119
21120 #endif
21121
21122 @@ -967,7 +1425,7 @@ vector=vector+1
21123 2: jmp common_interrupt
21124 .endr
21125 CFI_ENDPROC
21126 -END(irq_entries_start)
21127 +ENDPROC(irq_entries_start)
21128
21129 .previous
21130 END(interrupt)
21131 @@ -987,6 +1445,16 @@ END(interrupt)
21132 subq $ORIG_RAX-RBP, %rsp
21133 CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
21134 SAVE_ARGS_IRQ
21135 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21136 + testb $3, CS(%rdi)
21137 + jnz 1f
21138 + pax_enter_kernel
21139 + jmp 2f
21140 +1: pax_enter_kernel_user
21141 +2:
21142 +#else
21143 + pax_enter_kernel
21144 +#endif
21145 call \func
21146 .endm
21147
21148 @@ -1019,7 +1487,7 @@ ret_from_intr:
21149
21150 exit_intr:
21151 GET_THREAD_INFO(%rcx)
21152 - testl $3,CS-ARGOFFSET(%rsp)
21153 + testb $3,CS-ARGOFFSET(%rsp)
21154 je retint_kernel
21155
21156 /* Interrupt came from user space */
21157 @@ -1041,12 +1509,16 @@ retint_swapgs: /* return to user-space */
21158 * The iretq could re-enable interrupts:
21159 */
21160 DISABLE_INTERRUPTS(CLBR_ANY)
21161 + pax_exit_kernel_user
21162 +retint_swapgs_pax:
21163 TRACE_IRQS_IRETQ
21164 SWAPGS
21165 jmp restore_args
21166
21167 retint_restore_args: /* return to kernel space */
21168 DISABLE_INTERRUPTS(CLBR_ANY)
21169 + pax_exit_kernel
21170 + pax_force_retaddr (RIP-ARGOFFSET)
21171 /*
21172 * The iretq could re-enable interrupts:
21173 */
21174 @@ -1129,7 +1601,7 @@ ENTRY(retint_kernel)
21175 #endif
21176
21177 CFI_ENDPROC
21178 -END(common_interrupt)
21179 +ENDPROC(common_interrupt)
21180 /*
21181 * End of kprobes section
21182 */
21183 @@ -1147,7 +1619,7 @@ ENTRY(\sym)
21184 interrupt \do_sym
21185 jmp ret_from_intr
21186 CFI_ENDPROC
21187 -END(\sym)
21188 +ENDPROC(\sym)
21189 .endm
21190
21191 #ifdef CONFIG_SMP
21192 @@ -1208,12 +1680,22 @@ ENTRY(\sym)
21193 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
21194 call error_entry
21195 DEFAULT_FRAME 0
21196 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21197 + testb $3, CS(%rsp)
21198 + jnz 1f
21199 + pax_enter_kernel
21200 + jmp 2f
21201 +1: pax_enter_kernel_user
21202 +2:
21203 +#else
21204 + pax_enter_kernel
21205 +#endif
21206 movq %rsp,%rdi /* pt_regs pointer */
21207 xorl %esi,%esi /* no error code */
21208 call \do_sym
21209 jmp error_exit /* %ebx: no swapgs flag */
21210 CFI_ENDPROC
21211 -END(\sym)
21212 +ENDPROC(\sym)
21213 .endm
21214
21215 .macro paranoidzeroentry sym do_sym
21216 @@ -1226,15 +1708,25 @@ ENTRY(\sym)
21217 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
21218 call save_paranoid
21219 TRACE_IRQS_OFF
21220 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21221 + testb $3, CS(%rsp)
21222 + jnz 1f
21223 + pax_enter_kernel
21224 + jmp 2f
21225 +1: pax_enter_kernel_user
21226 +2:
21227 +#else
21228 + pax_enter_kernel
21229 +#endif
21230 movq %rsp,%rdi /* pt_regs pointer */
21231 xorl %esi,%esi /* no error code */
21232 call \do_sym
21233 jmp paranoid_exit /* %ebx: no swapgs flag */
21234 CFI_ENDPROC
21235 -END(\sym)
21236 +ENDPROC(\sym)
21237 .endm
21238
21239 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
21240 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r12)
21241 .macro paranoidzeroentry_ist sym do_sym ist
21242 ENTRY(\sym)
21243 INTR_FRAME
21244 @@ -1245,14 +1737,30 @@ ENTRY(\sym)
21245 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
21246 call save_paranoid
21247 TRACE_IRQS_OFF_DEBUG
21248 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21249 + testb $3, CS(%rsp)
21250 + jnz 1f
21251 + pax_enter_kernel
21252 + jmp 2f
21253 +1: pax_enter_kernel_user
21254 +2:
21255 +#else
21256 + pax_enter_kernel
21257 +#endif
21258 movq %rsp,%rdi /* pt_regs pointer */
21259 xorl %esi,%esi /* no error code */
21260 +#ifdef CONFIG_SMP
21261 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r12d
21262 + lea init_tss(%r12), %r12
21263 +#else
21264 + lea init_tss(%rip), %r12
21265 +#endif
21266 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
21267 call \do_sym
21268 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
21269 jmp paranoid_exit /* %ebx: no swapgs flag */
21270 CFI_ENDPROC
21271 -END(\sym)
21272 +ENDPROC(\sym)
21273 .endm
21274
21275 .macro errorentry sym do_sym
21276 @@ -1264,13 +1772,23 @@ ENTRY(\sym)
21277 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
21278 call error_entry
21279 DEFAULT_FRAME 0
21280 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21281 + testb $3, CS(%rsp)
21282 + jnz 1f
21283 + pax_enter_kernel
21284 + jmp 2f
21285 +1: pax_enter_kernel_user
21286 +2:
21287 +#else
21288 + pax_enter_kernel
21289 +#endif
21290 movq %rsp,%rdi /* pt_regs pointer */
21291 movq ORIG_RAX(%rsp),%rsi /* get error code */
21292 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
21293 call \do_sym
21294 jmp error_exit /* %ebx: no swapgs flag */
21295 CFI_ENDPROC
21296 -END(\sym)
21297 +ENDPROC(\sym)
21298 .endm
21299
21300 /* error code is on the stack already */
21301 @@ -1284,13 +1802,23 @@ ENTRY(\sym)
21302 call save_paranoid
21303 DEFAULT_FRAME 0
21304 TRACE_IRQS_OFF
21305 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21306 + testb $3, CS(%rsp)
21307 + jnz 1f
21308 + pax_enter_kernel
21309 + jmp 2f
21310 +1: pax_enter_kernel_user
21311 +2:
21312 +#else
21313 + pax_enter_kernel
21314 +#endif
21315 movq %rsp,%rdi /* pt_regs pointer */
21316 movq ORIG_RAX(%rsp),%rsi /* get error code */
21317 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
21318 call \do_sym
21319 jmp paranoid_exit /* %ebx: no swapgs flag */
21320 CFI_ENDPROC
21321 -END(\sym)
21322 +ENDPROC(\sym)
21323 .endm
21324
21325 zeroentry divide_error do_divide_error
21326 @@ -1320,9 +1848,10 @@ gs_change:
21327 2: mfence /* workaround */
21328 SWAPGS
21329 popfq_cfi
21330 + pax_force_retaddr
21331 ret
21332 CFI_ENDPROC
21333 -END(native_load_gs_index)
21334 +ENDPROC(native_load_gs_index)
21335
21336 _ASM_EXTABLE(gs_change,bad_gs)
21337 .section .fixup,"ax"
21338 @@ -1350,9 +1879,10 @@ ENTRY(call_softirq)
21339 CFI_DEF_CFA_REGISTER rsp
21340 CFI_ADJUST_CFA_OFFSET -8
21341 decl PER_CPU_VAR(irq_count)
21342 + pax_force_retaddr
21343 ret
21344 CFI_ENDPROC
21345 -END(call_softirq)
21346 +ENDPROC(call_softirq)
21347
21348 #ifdef CONFIG_XEN
21349 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
21350 @@ -1390,7 +1920,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
21351 decl PER_CPU_VAR(irq_count)
21352 jmp error_exit
21353 CFI_ENDPROC
21354 -END(xen_do_hypervisor_callback)
21355 +ENDPROC(xen_do_hypervisor_callback)
21356
21357 /*
21358 * Hypervisor uses this for application faults while it executes.
21359 @@ -1449,7 +1979,7 @@ ENTRY(xen_failsafe_callback)
21360 SAVE_ALL
21361 jmp error_exit
21362 CFI_ENDPROC
21363 -END(xen_failsafe_callback)
21364 +ENDPROC(xen_failsafe_callback)
21365
21366 apicinterrupt HYPERVISOR_CALLBACK_VECTOR \
21367 xen_hvm_callback_vector xen_evtchn_do_upcall
21368 @@ -1501,18 +2031,33 @@ ENTRY(paranoid_exit)
21369 DEFAULT_FRAME
21370 DISABLE_INTERRUPTS(CLBR_NONE)
21371 TRACE_IRQS_OFF_DEBUG
21372 - testl %ebx,%ebx /* swapgs needed? */
21373 + testl $1,%ebx /* swapgs needed? */
21374 jnz paranoid_restore
21375 - testl $3,CS(%rsp)
21376 + testb $3,CS(%rsp)
21377 jnz paranoid_userspace
21378 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21379 + pax_exit_kernel
21380 + TRACE_IRQS_IRETQ 0
21381 + SWAPGS_UNSAFE_STACK
21382 + RESTORE_ALL 8
21383 + pax_force_retaddr_bts
21384 + jmp irq_return
21385 +#endif
21386 paranoid_swapgs:
21387 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21388 + pax_exit_kernel_user
21389 +#else
21390 + pax_exit_kernel
21391 +#endif
21392 TRACE_IRQS_IRETQ 0
21393 SWAPGS_UNSAFE_STACK
21394 RESTORE_ALL 8
21395 jmp irq_return
21396 paranoid_restore:
21397 + pax_exit_kernel
21398 TRACE_IRQS_IRETQ_DEBUG 0
21399 RESTORE_ALL 8
21400 + pax_force_retaddr_bts
21401 jmp irq_return
21402 paranoid_userspace:
21403 GET_THREAD_INFO(%rcx)
21404 @@ -1541,7 +2086,7 @@ paranoid_schedule:
21405 TRACE_IRQS_OFF
21406 jmp paranoid_userspace
21407 CFI_ENDPROC
21408 -END(paranoid_exit)
21409 +ENDPROC(paranoid_exit)
21410
21411 /*
21412 * Exception entry point. This expects an error code/orig_rax on the stack.
21413 @@ -1568,12 +2113,13 @@ ENTRY(error_entry)
21414 movq_cfi r14, R14+8
21415 movq_cfi r15, R15+8
21416 xorl %ebx,%ebx
21417 - testl $3,CS+8(%rsp)
21418 + testb $3,CS+8(%rsp)
21419 je error_kernelspace
21420 error_swapgs:
21421 SWAPGS
21422 error_sti:
21423 TRACE_IRQS_OFF
21424 + pax_force_retaddr_bts
21425 ret
21426
21427 /*
21428 @@ -1600,7 +2146,7 @@ bstep_iret:
21429 movq %rcx,RIP+8(%rsp)
21430 jmp error_swapgs
21431 CFI_ENDPROC
21432 -END(error_entry)
21433 +ENDPROC(error_entry)
21434
21435
21436 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
21437 @@ -1611,7 +2157,7 @@ ENTRY(error_exit)
21438 DISABLE_INTERRUPTS(CLBR_NONE)
21439 TRACE_IRQS_OFF
21440 GET_THREAD_INFO(%rcx)
21441 - testl %eax,%eax
21442 + testl $1,%eax
21443 jne retint_kernel
21444 LOCKDEP_SYS_EXIT_IRQ
21445 movl TI_flags(%rcx),%edx
21446 @@ -1620,7 +2166,7 @@ ENTRY(error_exit)
21447 jnz retint_careful
21448 jmp retint_swapgs
21449 CFI_ENDPROC
21450 -END(error_exit)
21451 +ENDPROC(error_exit)
21452
21453 /*
21454 * Test if a given stack is an NMI stack or not.
21455 @@ -1678,9 +2224,11 @@ ENTRY(nmi)
21456 * If %cs was not the kernel segment, then the NMI triggered in user
21457 * space, which means it is definitely not nested.
21458 */
21459 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
21460 + je 1f
21461 cmpl $__KERNEL_CS, 16(%rsp)
21462 jne first_nmi
21463 -
21464 +1:
21465 /*
21466 * Check the special variable on the stack to see if NMIs are
21467 * executing.
21468 @@ -1714,8 +2262,7 @@ nested_nmi:
21469
21470 1:
21471 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
21472 - leaq -1*8(%rsp), %rdx
21473 - movq %rdx, %rsp
21474 + subq $8, %rsp
21475 CFI_ADJUST_CFA_OFFSET 1*8
21476 leaq -10*8(%rsp), %rdx
21477 pushq_cfi $__KERNEL_DS
21478 @@ -1733,6 +2280,7 @@ nested_nmi_out:
21479 CFI_RESTORE rdx
21480
21481 /* No need to check faults here */
21482 +# pax_force_retaddr_bts
21483 INTERRUPT_RETURN
21484
21485 CFI_RESTORE_STATE
21486 @@ -1849,6 +2397,8 @@ end_repeat_nmi:
21487 */
21488 movq %cr2, %r12
21489
21490 + pax_enter_kernel_nmi
21491 +
21492 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
21493 movq %rsp,%rdi
21494 movq $-1,%rsi
21495 @@ -1861,26 +2411,31 @@ end_repeat_nmi:
21496 movq %r12, %cr2
21497 1:
21498
21499 - testl %ebx,%ebx /* swapgs needed? */
21500 + testl $1,%ebx /* swapgs needed? */
21501 jnz nmi_restore
21502 nmi_swapgs:
21503 SWAPGS_UNSAFE_STACK
21504 nmi_restore:
21505 + pax_exit_kernel_nmi
21506 /* Pop the extra iret frame at once */
21507 RESTORE_ALL 6*8
21508 + testb $3, 8(%rsp)
21509 + jnz 1f
21510 + pax_force_retaddr_bts
21511 +1:
21512
21513 /* Clear the NMI executing stack variable */
21514 movq $0, 5*8(%rsp)
21515 jmp irq_return
21516 CFI_ENDPROC
21517 -END(nmi)
21518 +ENDPROC(nmi)
21519
21520 ENTRY(ignore_sysret)
21521 CFI_STARTPROC
21522 mov $-ENOSYS,%eax
21523 sysret
21524 CFI_ENDPROC
21525 -END(ignore_sysret)
21526 +ENDPROC(ignore_sysret)
21527
21528 /*
21529 * End of kprobes section
21530 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
21531 index 42a392a..fbbd930 100644
21532 --- a/arch/x86/kernel/ftrace.c
21533 +++ b/arch/x86/kernel/ftrace.c
21534 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
21535 {
21536 unsigned char replaced[MCOUNT_INSN_SIZE];
21537
21538 + ip = ktla_ktva(ip);
21539 +
21540 /*
21541 * Note: Due to modules and __init, code can
21542 * disappear and change, we need to protect against faulting
21543 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
21544 unsigned char old[MCOUNT_INSN_SIZE], *new;
21545 int ret;
21546
21547 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
21548 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
21549 new = ftrace_call_replace(ip, (unsigned long)func);
21550
21551 /* See comment above by declaration of modifying_ftrace_code */
21552 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
21553 /* Also update the regs callback function */
21554 if (!ret) {
21555 ip = (unsigned long)(&ftrace_regs_call);
21556 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
21557 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
21558 new = ftrace_call_replace(ip, (unsigned long)func);
21559 ret = ftrace_modify_code(ip, old, new);
21560 }
21561 @@ -279,7 +281,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
21562 * kernel identity mapping to modify code.
21563 */
21564 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
21565 - ip = (unsigned long)__va(__pa_symbol(ip));
21566 + ip = (unsigned long)__va(__pa_symbol(ktla_ktva(ip)));
21567
21568 return probe_kernel_write((void *)ip, val, size);
21569 }
21570 @@ -289,7 +291,7 @@ static int add_break(unsigned long ip, const char *old)
21571 unsigned char replaced[MCOUNT_INSN_SIZE];
21572 unsigned char brk = BREAKPOINT_INSTRUCTION;
21573
21574 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
21575 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
21576 return -EFAULT;
21577
21578 /* Make sure it is what we expect it to be */
21579 @@ -637,7 +639,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
21580 return ret;
21581
21582 fail_update:
21583 - probe_kernel_write((void *)ip, &old_code[0], 1);
21584 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
21585 goto out;
21586 }
21587
21588 @@ -670,6 +672,8 @@ static int ftrace_mod_jmp(unsigned long ip,
21589 {
21590 unsigned char code[MCOUNT_INSN_SIZE];
21591
21592 + ip = ktla_ktva(ip);
21593 +
21594 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
21595 return -EFAULT;
21596
21597 diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
21598 index 55b6761..a6456fc 100644
21599 --- a/arch/x86/kernel/head64.c
21600 +++ b/arch/x86/kernel/head64.c
21601 @@ -67,12 +67,12 @@ again:
21602 pgd = *pgd_p;
21603
21604 /*
21605 - * The use of __START_KERNEL_map rather than __PAGE_OFFSET here is
21606 - * critical -- __PAGE_OFFSET would point us back into the dynamic
21607 + * The use of __early_va rather than __va here is critical:
21608 + * __va would point us back into the dynamic
21609 * range and we might end up looping forever...
21610 */
21611 if (pgd)
21612 - pud_p = (pudval_t *)((pgd & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
21613 + pud_p = (pudval_t *)(__early_va(pgd & PTE_PFN_MASK));
21614 else {
21615 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
21616 reset_early_page_tables();
21617 @@ -82,13 +82,13 @@ again:
21618 pud_p = (pudval_t *)early_dynamic_pgts[next_early_pgt++];
21619 for (i = 0; i < PTRS_PER_PUD; i++)
21620 pud_p[i] = 0;
21621 - *pgd_p = (pgdval_t)pud_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
21622 + *pgd_p = (pgdval_t)__pa(pud_p) + _KERNPG_TABLE;
21623 }
21624 pud_p += pud_index(address);
21625 pud = *pud_p;
21626
21627 if (pud)
21628 - pmd_p = (pmdval_t *)((pud & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
21629 + pmd_p = (pmdval_t *)(__early_va(pud & PTE_PFN_MASK));
21630 else {
21631 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
21632 reset_early_page_tables();
21633 @@ -98,7 +98,7 @@ again:
21634 pmd_p = (pmdval_t *)early_dynamic_pgts[next_early_pgt++];
21635 for (i = 0; i < PTRS_PER_PMD; i++)
21636 pmd_p[i] = 0;
21637 - *pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
21638 + *pud_p = (pudval_t)__pa(pmd_p) + _KERNPG_TABLE;
21639 }
21640 pmd = (physaddr & PMD_MASK) + early_pmd_flags;
21641 pmd_p[pmd_index(address)] = pmd;
21642 @@ -175,7 +175,6 @@ void __init x86_64_start_kernel(char * real_mode_data)
21643 if (console_loglevel == 10)
21644 early_printk("Kernel alive\n");
21645
21646 - clear_page(init_level4_pgt);
21647 /* set init_level4_pgt kernel high mapping*/
21648 init_level4_pgt[511] = early_level4_pgt[511];
21649
21650 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
21651 index 73afd11..0ef46f2 100644
21652 --- a/arch/x86/kernel/head_32.S
21653 +++ b/arch/x86/kernel/head_32.S
21654 @@ -26,6 +26,12 @@
21655 /* Physical address */
21656 #define pa(X) ((X) - __PAGE_OFFSET)
21657
21658 +#ifdef CONFIG_PAX_KERNEXEC
21659 +#define ta(X) (X)
21660 +#else
21661 +#define ta(X) ((X) - __PAGE_OFFSET)
21662 +#endif
21663 +
21664 /*
21665 * References to members of the new_cpu_data structure.
21666 */
21667 @@ -55,11 +61,7 @@
21668 * and small than max_low_pfn, otherwise will waste some page table entries
21669 */
21670
21671 -#if PTRS_PER_PMD > 1
21672 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
21673 -#else
21674 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
21675 -#endif
21676 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
21677
21678 /* Number of possible pages in the lowmem region */
21679 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
21680 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
21681 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
21682
21683 /*
21684 + * Real beginning of normal "text" segment
21685 + */
21686 +ENTRY(stext)
21687 +ENTRY(_stext)
21688 +
21689 +/*
21690 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
21691 * %esi points to the real-mode code as a 32-bit pointer.
21692 * CS and DS must be 4 GB flat segments, but we don't depend on
21693 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
21694 * can.
21695 */
21696 __HEAD
21697 +
21698 +#ifdef CONFIG_PAX_KERNEXEC
21699 + jmp startup_32
21700 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
21701 +.fill PAGE_SIZE-5,1,0xcc
21702 +#endif
21703 +
21704 ENTRY(startup_32)
21705 movl pa(stack_start),%ecx
21706
21707 @@ -106,6 +121,59 @@ ENTRY(startup_32)
21708 2:
21709 leal -__PAGE_OFFSET(%ecx),%esp
21710
21711 +#ifdef CONFIG_SMP
21712 + movl $pa(cpu_gdt_table),%edi
21713 + movl $__per_cpu_load,%eax
21714 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
21715 + rorl $16,%eax
21716 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
21717 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
21718 + movl $__per_cpu_end - 1,%eax
21719 + subl $__per_cpu_start,%eax
21720 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
21721 +#endif
21722 +
21723 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21724 + movl $NR_CPUS,%ecx
21725 + movl $pa(cpu_gdt_table),%edi
21726 +1:
21727 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
21728 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
21729 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
21730 + addl $PAGE_SIZE_asm,%edi
21731 + loop 1b
21732 +#endif
21733 +
21734 +#ifdef CONFIG_PAX_KERNEXEC
21735 + movl $pa(boot_gdt),%edi
21736 + movl $__LOAD_PHYSICAL_ADDR,%eax
21737 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
21738 + rorl $16,%eax
21739 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
21740 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
21741 + rorl $16,%eax
21742 +
21743 + ljmp $(__BOOT_CS),$1f
21744 +1:
21745 +
21746 + movl $NR_CPUS,%ecx
21747 + movl $pa(cpu_gdt_table),%edi
21748 + addl $__PAGE_OFFSET,%eax
21749 +1:
21750 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
21751 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
21752 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
21753 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
21754 + rorl $16,%eax
21755 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
21756 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
21757 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
21758 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
21759 + rorl $16,%eax
21760 + addl $PAGE_SIZE_asm,%edi
21761 + loop 1b
21762 +#endif
21763 +
21764 /*
21765 * Clear BSS first so that there are no surprises...
21766 */
21767 @@ -201,8 +269,11 @@ ENTRY(startup_32)
21768 movl %eax, pa(max_pfn_mapped)
21769
21770 /* Do early initialization of the fixmap area */
21771 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
21772 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
21773 +#ifdef CONFIG_COMPAT_VDSO
21774 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
21775 +#else
21776 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
21777 +#endif
21778 #else /* Not PAE */
21779
21780 page_pde_offset = (__PAGE_OFFSET >> 20);
21781 @@ -232,8 +303,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
21782 movl %eax, pa(max_pfn_mapped)
21783
21784 /* Do early initialization of the fixmap area */
21785 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
21786 - movl %eax,pa(initial_page_table+0xffc)
21787 +#ifdef CONFIG_COMPAT_VDSO
21788 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
21789 +#else
21790 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
21791 +#endif
21792 #endif
21793
21794 #ifdef CONFIG_PARAVIRT
21795 @@ -247,9 +321,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
21796 cmpl $num_subarch_entries, %eax
21797 jae bad_subarch
21798
21799 - movl pa(subarch_entries)(,%eax,4), %eax
21800 - subl $__PAGE_OFFSET, %eax
21801 - jmp *%eax
21802 + jmp *pa(subarch_entries)(,%eax,4)
21803
21804 bad_subarch:
21805 WEAK(lguest_entry)
21806 @@ -261,10 +333,10 @@ WEAK(xen_entry)
21807 __INITDATA
21808
21809 subarch_entries:
21810 - .long default_entry /* normal x86/PC */
21811 - .long lguest_entry /* lguest hypervisor */
21812 - .long xen_entry /* Xen hypervisor */
21813 - .long default_entry /* Moorestown MID */
21814 + .long ta(default_entry) /* normal x86/PC */
21815 + .long ta(lguest_entry) /* lguest hypervisor */
21816 + .long ta(xen_entry) /* Xen hypervisor */
21817 + .long ta(default_entry) /* Moorestown MID */
21818 num_subarch_entries = (. - subarch_entries) / 4
21819 .previous
21820 #else
21821 @@ -355,6 +427,7 @@ default_entry:
21822 movl pa(mmu_cr4_features),%eax
21823 movl %eax,%cr4
21824
21825 +#ifdef CONFIG_X86_PAE
21826 testb $X86_CR4_PAE, %al # check if PAE is enabled
21827 jz enable_paging
21828
21829 @@ -383,6 +456,9 @@ default_entry:
21830 /* Make changes effective */
21831 wrmsr
21832
21833 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
21834 +#endif
21835 +
21836 enable_paging:
21837
21838 /*
21839 @@ -451,14 +527,20 @@ is486:
21840 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
21841 movl %eax,%ss # after changing gdt.
21842
21843 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
21844 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
21845 movl %eax,%ds
21846 movl %eax,%es
21847
21848 movl $(__KERNEL_PERCPU), %eax
21849 movl %eax,%fs # set this cpu's percpu
21850
21851 +#ifdef CONFIG_CC_STACKPROTECTOR
21852 movl $(__KERNEL_STACK_CANARY),%eax
21853 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
21854 + movl $(__USER_DS),%eax
21855 +#else
21856 + xorl %eax,%eax
21857 +#endif
21858 movl %eax,%gs
21859
21860 xorl %eax,%eax # Clear LDT
21861 @@ -534,8 +616,11 @@ setup_once:
21862 * relocation. Manually set base address in stack canary
21863 * segment descriptor.
21864 */
21865 - movl $gdt_page,%eax
21866 + movl $cpu_gdt_table,%eax
21867 movl $stack_canary,%ecx
21868 +#ifdef CONFIG_SMP
21869 + addl $__per_cpu_load,%ecx
21870 +#endif
21871 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
21872 shrl $16, %ecx
21873 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
21874 @@ -566,7 +651,7 @@ ENDPROC(early_idt_handlers)
21875 /* This is global to keep gas from relaxing the jumps */
21876 ENTRY(early_idt_handler)
21877 cld
21878 - cmpl $2,%ss:early_recursion_flag
21879 + cmpl $1,%ss:early_recursion_flag
21880 je hlt_loop
21881 incl %ss:early_recursion_flag
21882
21883 @@ -604,8 +689,8 @@ ENTRY(early_idt_handler)
21884 pushl (20+6*4)(%esp) /* trapno */
21885 pushl $fault_msg
21886 call printk
21887 -#endif
21888 call dump_stack
21889 +#endif
21890 hlt_loop:
21891 hlt
21892 jmp hlt_loop
21893 @@ -624,8 +709,11 @@ ENDPROC(early_idt_handler)
21894 /* This is the default interrupt "handler" :-) */
21895 ALIGN
21896 ignore_int:
21897 - cld
21898 #ifdef CONFIG_PRINTK
21899 + cmpl $2,%ss:early_recursion_flag
21900 + je hlt_loop
21901 + incl %ss:early_recursion_flag
21902 + cld
21903 pushl %eax
21904 pushl %ecx
21905 pushl %edx
21906 @@ -634,9 +722,6 @@ ignore_int:
21907 movl $(__KERNEL_DS),%eax
21908 movl %eax,%ds
21909 movl %eax,%es
21910 - cmpl $2,early_recursion_flag
21911 - je hlt_loop
21912 - incl early_recursion_flag
21913 pushl 16(%esp)
21914 pushl 24(%esp)
21915 pushl 32(%esp)
21916 @@ -670,29 +755,43 @@ ENTRY(setup_once_ref)
21917 /*
21918 * BSS section
21919 */
21920 -__PAGE_ALIGNED_BSS
21921 - .align PAGE_SIZE
21922 #ifdef CONFIG_X86_PAE
21923 +.section .initial_pg_pmd,"a",@progbits
21924 initial_pg_pmd:
21925 .fill 1024*KPMDS,4,0
21926 #else
21927 +.section .initial_page_table,"a",@progbits
21928 ENTRY(initial_page_table)
21929 .fill 1024,4,0
21930 #endif
21931 +.section .initial_pg_fixmap,"a",@progbits
21932 initial_pg_fixmap:
21933 .fill 1024,4,0
21934 +.section .empty_zero_page,"a",@progbits
21935 ENTRY(empty_zero_page)
21936 .fill 4096,1,0
21937 +.section .swapper_pg_dir,"a",@progbits
21938 ENTRY(swapper_pg_dir)
21939 +#ifdef CONFIG_X86_PAE
21940 + .fill 4,8,0
21941 +#else
21942 .fill 1024,4,0
21943 +#endif
21944 +
21945 +/*
21946 + * The IDT has to be page-aligned to simplify the Pentium
21947 + * F0 0F bug workaround.. We have a special link segment
21948 + * for this.
21949 + */
21950 +.section .idt,"a",@progbits
21951 +ENTRY(idt_table)
21952 + .fill 256,8,0
21953
21954 /*
21955 * This starts the data section.
21956 */
21957 #ifdef CONFIG_X86_PAE
21958 -__PAGE_ALIGNED_DATA
21959 - /* Page-aligned for the benefit of paravirt? */
21960 - .align PAGE_SIZE
21961 +.section .initial_page_table,"a",@progbits
21962 ENTRY(initial_page_table)
21963 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
21964 # if KPMDS == 3
21965 @@ -711,12 +810,20 @@ ENTRY(initial_page_table)
21966 # error "Kernel PMDs should be 1, 2 or 3"
21967 # endif
21968 .align PAGE_SIZE /* needs to be page-sized too */
21969 +
21970 +#ifdef CONFIG_PAX_PER_CPU_PGD
21971 +ENTRY(cpu_pgd)
21972 + .rept 2*NR_CPUS
21973 + .fill 4,8,0
21974 + .endr
21975 +#endif
21976 +
21977 #endif
21978
21979 .data
21980 .balign 4
21981 ENTRY(stack_start)
21982 - .long init_thread_union+THREAD_SIZE
21983 + .long init_thread_union+THREAD_SIZE-8
21984
21985 __INITRODATA
21986 int_msg:
21987 @@ -744,7 +851,7 @@ fault_msg:
21988 * segment size, and 32-bit linear address value:
21989 */
21990
21991 - .data
21992 +.section .rodata,"a",@progbits
21993 .globl boot_gdt_descr
21994 .globl idt_descr
21995
21996 @@ -753,7 +860,7 @@ fault_msg:
21997 .word 0 # 32 bit align gdt_desc.address
21998 boot_gdt_descr:
21999 .word __BOOT_DS+7
22000 - .long boot_gdt - __PAGE_OFFSET
22001 + .long pa(boot_gdt)
22002
22003 .word 0 # 32-bit align idt_desc.address
22004 idt_descr:
22005 @@ -764,7 +871,7 @@ idt_descr:
22006 .word 0 # 32 bit align gdt_desc.address
22007 ENTRY(early_gdt_descr)
22008 .word GDT_ENTRIES*8-1
22009 - .long gdt_page /* Overwritten for secondary CPUs */
22010 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
22011
22012 /*
22013 * The boot_gdt must mirror the equivalent in setup.S and is
22014 @@ -773,5 +880,65 @@ ENTRY(early_gdt_descr)
22015 .align L1_CACHE_BYTES
22016 ENTRY(boot_gdt)
22017 .fill GDT_ENTRY_BOOT_CS,8,0
22018 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
22019 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
22020 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
22021 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
22022 +
22023 + .align PAGE_SIZE_asm
22024 +ENTRY(cpu_gdt_table)
22025 + .rept NR_CPUS
22026 + .quad 0x0000000000000000 /* NULL descriptor */
22027 + .quad 0x0000000000000000 /* 0x0b reserved */
22028 + .quad 0x0000000000000000 /* 0x13 reserved */
22029 + .quad 0x0000000000000000 /* 0x1b reserved */
22030 +
22031 +#ifdef CONFIG_PAX_KERNEXEC
22032 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
22033 +#else
22034 + .quad 0x0000000000000000 /* 0x20 unused */
22035 +#endif
22036 +
22037 + .quad 0x0000000000000000 /* 0x28 unused */
22038 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
22039 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
22040 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
22041 + .quad 0x0000000000000000 /* 0x4b reserved */
22042 + .quad 0x0000000000000000 /* 0x53 reserved */
22043 + .quad 0x0000000000000000 /* 0x5b reserved */
22044 +
22045 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
22046 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
22047 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
22048 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
22049 +
22050 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
22051 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
22052 +
22053 + /*
22054 + * Segments used for calling PnP BIOS have byte granularity.
22055 + * The code segments and data segments have fixed 64k limits,
22056 + * the transfer segment sizes are set at run time.
22057 + */
22058 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
22059 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
22060 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
22061 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
22062 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
22063 +
22064 + /*
22065 + * The APM segments have byte granularity and their bases
22066 + * are set at run time. All have 64k limits.
22067 + */
22068 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
22069 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
22070 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
22071 +
22072 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
22073 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
22074 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
22075 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
22076 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
22077 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
22078 +
22079 + /* Be sure this is zeroed to avoid false validations in Xen */
22080 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
22081 + .endr
22082 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
22083 index a836860..1b5c665 100644
22084 --- a/arch/x86/kernel/head_64.S
22085 +++ b/arch/x86/kernel/head_64.S
22086 @@ -20,6 +20,8 @@
22087 #include <asm/processor-flags.h>
22088 #include <asm/percpu.h>
22089 #include <asm/nops.h>
22090 +#include <asm/cpufeature.h>
22091 +#include <asm/alternative-asm.h>
22092
22093 #ifdef CONFIG_PARAVIRT
22094 #include <asm/asm-offsets.h>
22095 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
22096 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
22097 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
22098 L3_START_KERNEL = pud_index(__START_KERNEL_map)
22099 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
22100 +L3_VMALLOC_START = pud_index(VMALLOC_START)
22101 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
22102 +L3_VMALLOC_END = pud_index(VMALLOC_END)
22103 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
22104 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
22105
22106 .text
22107 __HEAD
22108 @@ -89,11 +97,23 @@ startup_64:
22109 * Fixup the physical addresses in the page table
22110 */
22111 addq %rbp, early_level4_pgt + (L4_START_KERNEL*8)(%rip)
22112 + addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
22113 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
22114 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
22115 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
22116 + addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
22117
22118 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
22119 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
22120 + addq %rbp, level3_ident_pgt + (0*8)(%rip)
22121 +#ifndef CONFIG_XEN
22122 + addq %rbp, level3_ident_pgt + (1*8)(%rip)
22123 +#endif
22124
22125 - addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
22126 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
22127 +
22128 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
22129 + addq %rbp, level3_kernel_pgt + ((L3_START_KERNEL+1)*8)(%rip)
22130 +
22131 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
22132
22133 /*
22134 * Set up the identity mapping for the switchover. These
22135 @@ -177,8 +197,8 @@ ENTRY(secondary_startup_64)
22136 movq $(init_level4_pgt - __START_KERNEL_map), %rax
22137 1:
22138
22139 - /* Enable PAE mode and PGE */
22140 - movl $(X86_CR4_PAE | X86_CR4_PGE), %ecx
22141 + /* Enable PAE mode and PSE/PGE */
22142 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %ecx
22143 movq %rcx, %cr4
22144
22145 /* Setup early boot stage 4 level pagetables. */
22146 @@ -199,10 +219,18 @@ ENTRY(secondary_startup_64)
22147 movl $MSR_EFER, %ecx
22148 rdmsr
22149 btsl $_EFER_SCE, %eax /* Enable System Call */
22150 - btl $20,%edi /* No Execute supported? */
22151 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
22152 jnc 1f
22153 btsl $_EFER_NX, %eax
22154 btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
22155 + leaq init_level4_pgt(%rip), %rdi
22156 +#ifndef CONFIG_EFI
22157 + btsq $_PAGE_BIT_NX, 8*L4_PAGE_OFFSET(%rdi)
22158 +#endif
22159 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_START(%rdi)
22160 + btsq $_PAGE_BIT_NX, 8*L4_VMALLOC_END(%rdi)
22161 + btsq $_PAGE_BIT_NX, 8*L4_VMEMMAP_START(%rdi)
22162 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
22163 1: wrmsr /* Make changes effective */
22164
22165 /* Setup cr0 */
22166 @@ -282,6 +310,7 @@ ENTRY(secondary_startup_64)
22167 * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
22168 * address given in m16:64.
22169 */
22170 + pax_set_fptr_mask
22171 movq initial_code(%rip),%rax
22172 pushq $0 # fake return address to stop unwinder
22173 pushq $__KERNEL_CS # set correct cs
22174 @@ -388,7 +417,7 @@ ENTRY(early_idt_handler)
22175 call dump_stack
22176 #ifdef CONFIG_KALLSYMS
22177 leaq early_idt_ripmsg(%rip),%rdi
22178 - movq 40(%rsp),%rsi # %rip again
22179 + movq 88(%rsp),%rsi # %rip again
22180 call __print_symbol
22181 #endif
22182 #endif /* EARLY_PRINTK */
22183 @@ -416,6 +445,7 @@ ENDPROC(early_idt_handler)
22184 early_recursion_flag:
22185 .long 0
22186
22187 + .section .rodata,"a",@progbits
22188 #ifdef CONFIG_EARLY_PRINTK
22189 early_idt_msg:
22190 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
22191 @@ -443,29 +473,52 @@ NEXT_PAGE(early_level4_pgt)
22192 NEXT_PAGE(early_dynamic_pgts)
22193 .fill 512*EARLY_DYNAMIC_PAGE_TABLES,8,0
22194
22195 - .data
22196 + .section .rodata,"a",@progbits
22197
22198 -#ifndef CONFIG_XEN
22199 NEXT_PAGE(init_level4_pgt)
22200 - .fill 512,8,0
22201 -#else
22202 -NEXT_PAGE(init_level4_pgt)
22203 - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
22204 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
22205 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
22206 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
22207 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
22208 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
22209 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
22210 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
22211 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
22212 .org init_level4_pgt + L4_START_KERNEL*8, 0
22213 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
22214 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
22215
22216 +#ifdef CONFIG_PAX_PER_CPU_PGD
22217 +NEXT_PAGE(cpu_pgd)
22218 + .rept 2*NR_CPUS
22219 + .fill 512,8,0
22220 + .endr
22221 +#endif
22222 +
22223 NEXT_PAGE(level3_ident_pgt)
22224 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
22225 +#ifdef CONFIG_XEN
22226 .fill 511, 8, 0
22227 +#else
22228 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
22229 + .fill 510,8,0
22230 +#endif
22231 +
22232 +NEXT_PAGE(level3_vmalloc_start_pgt)
22233 + .fill 512,8,0
22234 +
22235 +NEXT_PAGE(level3_vmalloc_end_pgt)
22236 + .fill 512,8,0
22237 +
22238 +NEXT_PAGE(level3_vmemmap_pgt)
22239 + .fill L3_VMEMMAP_START,8,0
22240 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
22241 +
22242 NEXT_PAGE(level2_ident_pgt)
22243 - /* Since I easily can, map the first 1G.
22244 + /* Since I easily can, map the first 2G.
22245 * Don't set NX because code runs from these pages.
22246 */
22247 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
22248 -#endif
22249 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
22250
22251 NEXT_PAGE(level3_kernel_pgt)
22252 .fill L3_START_KERNEL,8,0
22253 @@ -473,6 +526,9 @@ NEXT_PAGE(level3_kernel_pgt)
22254 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
22255 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
22256
22257 +NEXT_PAGE(level2_vmemmap_pgt)
22258 + .fill 512,8,0
22259 +
22260 NEXT_PAGE(level2_kernel_pgt)
22261 /*
22262 * 512 MB kernel mapping. We spend a full page on this pagetable
22263 @@ -488,39 +544,70 @@ NEXT_PAGE(level2_kernel_pgt)
22264 KERNEL_IMAGE_SIZE/PMD_SIZE)
22265
22266 NEXT_PAGE(level2_fixmap_pgt)
22267 - .fill 506,8,0
22268 - .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
22269 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
22270 - .fill 5,8,0
22271 + .fill 507,8,0
22272 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
22273 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
22274 + .fill 4,8,0
22275
22276 -NEXT_PAGE(level1_fixmap_pgt)
22277 +NEXT_PAGE(level1_vsyscall_pgt)
22278 .fill 512,8,0
22279
22280 #undef PMDS
22281
22282 - .data
22283 + .align PAGE_SIZE
22284 +ENTRY(cpu_gdt_table)
22285 + .rept NR_CPUS
22286 + .quad 0x0000000000000000 /* NULL descriptor */
22287 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
22288 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
22289 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
22290 + .quad 0x00cffb000000ffff /* __USER32_CS */
22291 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
22292 + .quad 0x00affb000000ffff /* __USER_CS */
22293 +
22294 +#ifdef CONFIG_PAX_KERNEXEC
22295 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
22296 +#else
22297 + .quad 0x0 /* unused */
22298 +#endif
22299 +
22300 + .quad 0,0 /* TSS */
22301 + .quad 0,0 /* LDT */
22302 + .quad 0,0,0 /* three TLS descriptors */
22303 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
22304 + /* asm/segment.h:GDT_ENTRIES must match this */
22305 +
22306 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22307 + .quad 0x00cf93000000ffff /* __UDEREF_KERNEL_DS */
22308 +#else
22309 + .quad 0x0 /* unused */
22310 +#endif
22311 +
22312 + /* zero the remaining page */
22313 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
22314 + .endr
22315 +
22316 .align 16
22317 .globl early_gdt_descr
22318 early_gdt_descr:
22319 .word GDT_ENTRIES*8-1
22320 early_gdt_descr_base:
22321 - .quad INIT_PER_CPU_VAR(gdt_page)
22322 + .quad cpu_gdt_table
22323
22324 ENTRY(phys_base)
22325 /* This must match the first entry in level2_kernel_pgt */
22326 .quad 0x0000000000000000
22327
22328 #include "../../x86/xen/xen-head.S"
22329 -
22330 - .section .bss, "aw", @nobits
22331 +
22332 + .section .rodata,"a",@progbits
22333 +NEXT_PAGE(empty_zero_page)
22334 + .skip PAGE_SIZE
22335 +
22336 .align PAGE_SIZE
22337 ENTRY(idt_table)
22338 - .skip IDT_ENTRIES * 16
22339 + .fill 512,8,0
22340
22341 .align L1_CACHE_BYTES
22342 ENTRY(nmi_idt_table)
22343 - .skip IDT_ENTRIES * 16
22344 -
22345 - __PAGE_ALIGNED_BSS
22346 -NEXT_PAGE(empty_zero_page)
22347 - .skip PAGE_SIZE
22348 + .fill 512,8,0
22349 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
22350 index 0fa6912..37fce70 100644
22351 --- a/arch/x86/kernel/i386_ksyms_32.c
22352 +++ b/arch/x86/kernel/i386_ksyms_32.c
22353 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
22354 EXPORT_SYMBOL(cmpxchg8b_emu);
22355 #endif
22356
22357 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
22358 +
22359 /* Networking helper routines. */
22360 EXPORT_SYMBOL(csum_partial_copy_generic);
22361 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
22362 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
22363
22364 EXPORT_SYMBOL(__get_user_1);
22365 EXPORT_SYMBOL(__get_user_2);
22366 @@ -37,3 +41,7 @@ EXPORT_SYMBOL(strstr);
22367
22368 EXPORT_SYMBOL(csum_partial);
22369 EXPORT_SYMBOL(empty_zero_page);
22370 +
22371 +#ifdef CONFIG_PAX_KERNEXEC
22372 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
22373 +#endif
22374 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
22375 index f7ea30d..6318acc 100644
22376 --- a/arch/x86/kernel/i387.c
22377 +++ b/arch/x86/kernel/i387.c
22378 @@ -51,7 +51,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
22379 static inline bool interrupted_user_mode(void)
22380 {
22381 struct pt_regs *regs = get_irq_regs();
22382 - return regs && user_mode_vm(regs);
22383 + return regs && user_mode(regs);
22384 }
22385
22386 /*
22387 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
22388 index 9a5c460..84868423 100644
22389 --- a/arch/x86/kernel/i8259.c
22390 +++ b/arch/x86/kernel/i8259.c
22391 @@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
22392 static void make_8259A_irq(unsigned int irq)
22393 {
22394 disable_irq_nosync(irq);
22395 - io_apic_irqs &= ~(1<<irq);
22396 + io_apic_irqs &= ~(1UL<<irq);
22397 irq_set_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
22398 i8259A_chip.name);
22399 enable_irq(irq);
22400 @@ -209,7 +209,7 @@ spurious_8259A_irq:
22401 "spurious 8259A interrupt: IRQ%d.\n", irq);
22402 spurious_irq_mask |= irqmask;
22403 }
22404 - atomic_inc(&irq_err_count);
22405 + atomic_inc_unchecked(&irq_err_count);
22406 /*
22407 * Theoretically we do not have to handle this IRQ,
22408 * but in Linux this does not cause problems and is
22409 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
22410 /* (slave's support for AEOI in flat mode is to be investigated) */
22411 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
22412
22413 + pax_open_kernel();
22414 if (auto_eoi)
22415 /*
22416 * In AEOI mode we just have to mask the interrupt
22417 * when acking.
22418 */
22419 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
22420 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
22421 else
22422 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
22423 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
22424 + pax_close_kernel();
22425
22426 udelay(100); /* wait for 8259A to initialize */
22427
22428 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
22429 index a979b5b..1d6db75 100644
22430 --- a/arch/x86/kernel/io_delay.c
22431 +++ b/arch/x86/kernel/io_delay.c
22432 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
22433 * Quirk table for systems that misbehave (lock up, etc.) if port
22434 * 0x80 is used:
22435 */
22436 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
22437 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
22438 {
22439 .callback = dmi_io_delay_0xed_port,
22440 .ident = "Compaq Presario V6000",
22441 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
22442 index 4ddaf66..6292f4e 100644
22443 --- a/arch/x86/kernel/ioport.c
22444 +++ b/arch/x86/kernel/ioport.c
22445 @@ -6,6 +6,7 @@
22446 #include <linux/sched.h>
22447 #include <linux/kernel.h>
22448 #include <linux/capability.h>
22449 +#include <linux/security.h>
22450 #include <linux/errno.h>
22451 #include <linux/types.h>
22452 #include <linux/ioport.h>
22453 @@ -28,6 +29,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
22454
22455 if ((from + num <= from) || (from + num > IO_BITMAP_BITS))
22456 return -EINVAL;
22457 +#ifdef CONFIG_GRKERNSEC_IO
22458 + if (turn_on && grsec_disable_privio) {
22459 + gr_handle_ioperm();
22460 + return -EPERM;
22461 + }
22462 +#endif
22463 if (turn_on && !capable(CAP_SYS_RAWIO))
22464 return -EPERM;
22465
22466 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
22467 * because the ->io_bitmap_max value must match the bitmap
22468 * contents:
22469 */
22470 - tss = &per_cpu(init_tss, get_cpu());
22471 + tss = init_tss + get_cpu();
22472
22473 if (turn_on)
22474 bitmap_clear(t->io_bitmap_ptr, from, num);
22475 @@ -103,6 +110,12 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
22476 return -EINVAL;
22477 /* Trying to gain more privileges? */
22478 if (level > old) {
22479 +#ifdef CONFIG_GRKERNSEC_IO
22480 + if (grsec_disable_privio) {
22481 + gr_handle_iopl();
22482 + return -EPERM;
22483 + }
22484 +#endif
22485 if (!capable(CAP_SYS_RAWIO))
22486 return -EPERM;
22487 }
22488 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
22489 index ac0631d..ff7cb62 100644
22490 --- a/arch/x86/kernel/irq.c
22491 +++ b/arch/x86/kernel/irq.c
22492 @@ -18,7 +18,7 @@
22493 #include <asm/mce.h>
22494 #include <asm/hw_irq.h>
22495
22496 -atomic_t irq_err_count;
22497 +atomic_unchecked_t irq_err_count;
22498
22499 /* Function pointer for generic interrupt vector handling */
22500 void (*x86_platform_ipi_callback)(void) = NULL;
22501 @@ -122,9 +122,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
22502 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
22503 seq_printf(p, " Machine check polls\n");
22504 #endif
22505 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
22506 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
22507 #if defined(CONFIG_X86_IO_APIC)
22508 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
22509 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
22510 #endif
22511 return 0;
22512 }
22513 @@ -164,7 +164,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
22514
22515 u64 arch_irq_stat(void)
22516 {
22517 - u64 sum = atomic_read(&irq_err_count);
22518 + u64 sum = atomic_read_unchecked(&irq_err_count);
22519 return sum;
22520 }
22521
22522 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
22523 index 344faf8..355f60d 100644
22524 --- a/arch/x86/kernel/irq_32.c
22525 +++ b/arch/x86/kernel/irq_32.c
22526 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
22527 __asm__ __volatile__("andl %%esp,%0" :
22528 "=r" (sp) : "0" (THREAD_SIZE - 1));
22529
22530 - return sp < (sizeof(struct thread_info) + STACK_WARN);
22531 + return sp < STACK_WARN;
22532 }
22533
22534 static void print_stack_overflow(void)
22535 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
22536 * per-CPU IRQ handling contexts (thread information and stack)
22537 */
22538 union irq_ctx {
22539 - struct thread_info tinfo;
22540 - u32 stack[THREAD_SIZE/sizeof(u32)];
22541 + unsigned long previous_esp;
22542 + u32 stack[THREAD_SIZE/sizeof(u32)];
22543 } __attribute__((aligned(THREAD_SIZE)));
22544
22545 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
22546 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
22547 static inline int
22548 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
22549 {
22550 - union irq_ctx *curctx, *irqctx;
22551 + union irq_ctx *irqctx;
22552 u32 *isp, arg1, arg2;
22553
22554 - curctx = (union irq_ctx *) current_thread_info();
22555 irqctx = __this_cpu_read(hardirq_ctx);
22556
22557 /*
22558 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
22559 * handler) we can't do that and just have to keep using the
22560 * current stack (which is the irq stack already after all)
22561 */
22562 - if (unlikely(curctx == irqctx))
22563 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
22564 return 0;
22565
22566 /* build the stack frame on the IRQ stack */
22567 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
22568 - irqctx->tinfo.task = curctx->tinfo.task;
22569 - irqctx->tinfo.previous_esp = current_stack_pointer;
22570 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
22571 + irqctx->previous_esp = current_stack_pointer;
22572
22573 - /* Copy the preempt_count so that the [soft]irq checks work. */
22574 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
22575 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22576 + __set_fs(MAKE_MM_SEG(0));
22577 +#endif
22578
22579 if (unlikely(overflow))
22580 call_on_stack(print_stack_overflow, isp);
22581 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
22582 : "0" (irq), "1" (desc), "2" (isp),
22583 "D" (desc->handle_irq)
22584 : "memory", "cc", "ecx");
22585 +
22586 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22587 + __set_fs(current_thread_info()->addr_limit);
22588 +#endif
22589 +
22590 return 1;
22591 }
22592
22593 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
22594 */
22595 void __cpuinit irq_ctx_init(int cpu)
22596 {
22597 - union irq_ctx *irqctx;
22598 -
22599 if (per_cpu(hardirq_ctx, cpu))
22600 return;
22601
22602 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
22603 - THREADINFO_GFP,
22604 - THREAD_SIZE_ORDER));
22605 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
22606 - irqctx->tinfo.cpu = cpu;
22607 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
22608 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
22609 -
22610 - per_cpu(hardirq_ctx, cpu) = irqctx;
22611 -
22612 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
22613 - THREADINFO_GFP,
22614 - THREAD_SIZE_ORDER));
22615 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
22616 - irqctx->tinfo.cpu = cpu;
22617 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
22618 -
22619 - per_cpu(softirq_ctx, cpu) = irqctx;
22620 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
22621 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
22622 +
22623 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
22624 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
22625
22626 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
22627 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
22628 @@ -152,7 +141,6 @@ void __cpuinit irq_ctx_init(int cpu)
22629 asmlinkage void do_softirq(void)
22630 {
22631 unsigned long flags;
22632 - struct thread_info *curctx;
22633 union irq_ctx *irqctx;
22634 u32 *isp;
22635
22636 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
22637 local_irq_save(flags);
22638
22639 if (local_softirq_pending()) {
22640 - curctx = current_thread_info();
22641 irqctx = __this_cpu_read(softirq_ctx);
22642 - irqctx->tinfo.task = curctx->task;
22643 - irqctx->tinfo.previous_esp = current_stack_pointer;
22644 + irqctx->previous_esp = current_stack_pointer;
22645
22646 /* build the stack frame on the softirq stack */
22647 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
22648 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
22649 +
22650 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22651 + __set_fs(MAKE_MM_SEG(0));
22652 +#endif
22653
22654 call_on_stack(__do_softirq, isp);
22655 +
22656 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22657 + __set_fs(current_thread_info()->addr_limit);
22658 +#endif
22659 +
22660 /*
22661 * Shouldn't happen, we returned above if in_interrupt():
22662 */
22663 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
22664 if (unlikely(!desc))
22665 return false;
22666
22667 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
22668 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
22669 if (unlikely(overflow))
22670 print_stack_overflow();
22671 desc->handle_irq(irq, desc);
22672 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
22673 index d04d3ec..ea4b374 100644
22674 --- a/arch/x86/kernel/irq_64.c
22675 +++ b/arch/x86/kernel/irq_64.c
22676 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
22677 u64 estack_top, estack_bottom;
22678 u64 curbase = (u64)task_stack_page(current);
22679
22680 - if (user_mode_vm(regs))
22681 + if (user_mode(regs))
22682 return;
22683
22684 if (regs->sp >= curbase + sizeof(struct thread_info) +
22685 diff --git a/arch/x86/kernel/kdebugfs.c b/arch/x86/kernel/kdebugfs.c
22686 index dc1404b..bbc43e7 100644
22687 --- a/arch/x86/kernel/kdebugfs.c
22688 +++ b/arch/x86/kernel/kdebugfs.c
22689 @@ -27,7 +27,7 @@ struct setup_data_node {
22690 u32 len;
22691 };
22692
22693 -static ssize_t setup_data_read(struct file *file, char __user *user_buf,
22694 +static ssize_t __size_overflow(3) setup_data_read(struct file *file, char __user *user_buf,
22695 size_t count, loff_t *ppos)
22696 {
22697 struct setup_data_node *node = file->private_data;
22698 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
22699 index 836f832..a8bda67 100644
22700 --- a/arch/x86/kernel/kgdb.c
22701 +++ b/arch/x86/kernel/kgdb.c
22702 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
22703 #ifdef CONFIG_X86_32
22704 switch (regno) {
22705 case GDB_SS:
22706 - if (!user_mode_vm(regs))
22707 + if (!user_mode(regs))
22708 *(unsigned long *)mem = __KERNEL_DS;
22709 break;
22710 case GDB_SP:
22711 - if (!user_mode_vm(regs))
22712 + if (!user_mode(regs))
22713 *(unsigned long *)mem = kernel_stack_pointer(regs);
22714 break;
22715 case GDB_GS:
22716 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
22717 bp->attr.bp_addr = breakinfo[breakno].addr;
22718 bp->attr.bp_len = breakinfo[breakno].len;
22719 bp->attr.bp_type = breakinfo[breakno].type;
22720 - info->address = breakinfo[breakno].addr;
22721 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
22722 + info->address = ktla_ktva(breakinfo[breakno].addr);
22723 + else
22724 + info->address = breakinfo[breakno].addr;
22725 info->len = breakinfo[breakno].len;
22726 info->type = breakinfo[breakno].type;
22727 val = arch_install_hw_breakpoint(bp);
22728 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
22729 case 'k':
22730 /* clear the trace bit */
22731 linux_regs->flags &= ~X86_EFLAGS_TF;
22732 - atomic_set(&kgdb_cpu_doing_single_step, -1);
22733 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
22734
22735 /* set the trace bit if we're stepping */
22736 if (remcomInBuffer[0] == 's') {
22737 linux_regs->flags |= X86_EFLAGS_TF;
22738 - atomic_set(&kgdb_cpu_doing_single_step,
22739 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
22740 raw_smp_processor_id());
22741 }
22742
22743 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
22744
22745 switch (cmd) {
22746 case DIE_DEBUG:
22747 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
22748 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
22749 if (user_mode(regs))
22750 return single_step_cont(regs, args);
22751 break;
22752 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
22753 #endif /* CONFIG_DEBUG_RODATA */
22754
22755 bpt->type = BP_BREAKPOINT;
22756 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
22757 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
22758 BREAK_INSTR_SIZE);
22759 if (err)
22760 return err;
22761 - err = probe_kernel_write((char *)bpt->bpt_addr,
22762 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
22763 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
22764 #ifdef CONFIG_DEBUG_RODATA
22765 if (!err)
22766 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
22767 return -EBUSY;
22768 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
22769 BREAK_INSTR_SIZE);
22770 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
22771 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
22772 if (err)
22773 return err;
22774 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
22775 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
22776 if (mutex_is_locked(&text_mutex))
22777 goto knl_write;
22778 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
22779 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
22780 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
22781 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
22782 goto knl_write;
22783 return err;
22784 knl_write:
22785 #endif /* CONFIG_DEBUG_RODATA */
22786 - return probe_kernel_write((char *)bpt->bpt_addr,
22787 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
22788 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
22789 }
22790
22791 diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
22792 index 211bce4..6e2580a 100644
22793 --- a/arch/x86/kernel/kprobes/core.c
22794 +++ b/arch/x86/kernel/kprobes/core.c
22795 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
22796 s32 raddr;
22797 } __packed *insn;
22798
22799 - insn = (struct __arch_relative_insn *)from;
22800 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
22801 +
22802 + pax_open_kernel();
22803 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
22804 insn->op = op;
22805 + pax_close_kernel();
22806 }
22807
22808 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
22809 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
22810 kprobe_opcode_t opcode;
22811 kprobe_opcode_t *orig_opcodes = opcodes;
22812
22813 - if (search_exception_tables((unsigned long)opcodes))
22814 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
22815 return 0; /* Page fault may occur on this address. */
22816
22817 retry:
22818 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
22819 * for the first byte, we can recover the original instruction
22820 * from it and kp->opcode.
22821 */
22822 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
22823 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
22824 buf[0] = kp->opcode;
22825 - return (unsigned long)buf;
22826 + return ktva_ktla((unsigned long)buf);
22827 }
22828
22829 /*
22830 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
22831 /* Another subsystem puts a breakpoint, failed to recover */
22832 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
22833 return 0;
22834 + pax_open_kernel();
22835 memcpy(dest, insn.kaddr, insn.length);
22836 + pax_close_kernel();
22837
22838 #ifdef CONFIG_X86_64
22839 if (insn_rip_relative(&insn)) {
22840 @@ -359,7 +364,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
22841 return 0;
22842 }
22843 disp = (u8 *) dest + insn_offset_displacement(&insn);
22844 + pax_open_kernel();
22845 *(s32 *) disp = (s32) newdisp;
22846 + pax_close_kernel();
22847 }
22848 #endif
22849 return insn.length;
22850 @@ -498,7 +505,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
22851 * nor set current_kprobe, because it doesn't use single
22852 * stepping.
22853 */
22854 - regs->ip = (unsigned long)p->ainsn.insn;
22855 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
22856 preempt_enable_no_resched();
22857 return;
22858 }
22859 @@ -515,9 +522,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
22860 regs->flags &= ~X86_EFLAGS_IF;
22861 /* single step inline if the instruction is an int3 */
22862 if (p->opcode == BREAKPOINT_INSTRUCTION)
22863 - regs->ip = (unsigned long)p->addr;
22864 + regs->ip = ktla_ktva((unsigned long)p->addr);
22865 else
22866 - regs->ip = (unsigned long)p->ainsn.insn;
22867 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
22868 }
22869
22870 /*
22871 @@ -596,7 +603,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
22872 setup_singlestep(p, regs, kcb, 0);
22873 return 1;
22874 }
22875 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
22876 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
22877 /*
22878 * The breakpoint instruction was removed right
22879 * after we hit it. Another cpu has removed
22880 @@ -642,6 +649,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
22881 " movq %rax, 152(%rsp)\n"
22882 RESTORE_REGS_STRING
22883 " popfq\n"
22884 +#ifdef KERNEXEC_PLUGIN
22885 + " btsq $63,(%rsp)\n"
22886 +#endif
22887 #else
22888 " pushf\n"
22889 SAVE_REGS_STRING
22890 @@ -779,7 +789,7 @@ static void __kprobes
22891 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
22892 {
22893 unsigned long *tos = stack_addr(regs);
22894 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
22895 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
22896 unsigned long orig_ip = (unsigned long)p->addr;
22897 kprobe_opcode_t *insn = p->ainsn.insn;
22898
22899 @@ -961,7 +971,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
22900 struct die_args *args = data;
22901 int ret = NOTIFY_DONE;
22902
22903 - if (args->regs && user_mode_vm(args->regs))
22904 + if (args->regs && user_mode(args->regs))
22905 return ret;
22906
22907 switch (val) {
22908 diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
22909 index 76dc6f0..66bdfc3 100644
22910 --- a/arch/x86/kernel/kprobes/opt.c
22911 +++ b/arch/x86/kernel/kprobes/opt.c
22912 @@ -79,6 +79,7 @@ found:
22913 /* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
22914 static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
22915 {
22916 + pax_open_kernel();
22917 #ifdef CONFIG_X86_64
22918 *addr++ = 0x48;
22919 *addr++ = 0xbf;
22920 @@ -86,6 +87,7 @@ static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long v
22921 *addr++ = 0xb8;
22922 #endif
22923 *(unsigned long *)addr = val;
22924 + pax_close_kernel();
22925 }
22926
22927 static void __used __kprobes kprobes_optinsn_template_holder(void)
22928 @@ -338,7 +340,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
22929 * Verify if the address gap is in 2GB range, because this uses
22930 * a relative jump.
22931 */
22932 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
22933 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
22934 if (abs(rel) > 0x7fffffff)
22935 return -ERANGE;
22936
22937 @@ -353,16 +355,18 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
22938 op->optinsn.size = ret;
22939
22940 /* Copy arch-dep-instance from template */
22941 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
22942 + pax_open_kernel();
22943 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
22944 + pax_close_kernel();
22945
22946 /* Set probe information */
22947 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
22948
22949 /* Set probe function call */
22950 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
22951 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
22952
22953 /* Set returning jmp instruction at the tail of out-of-line buffer */
22954 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
22955 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
22956 (u8 *)op->kp.addr + op->optinsn.size);
22957
22958 flush_icache_range((unsigned long) buf,
22959 @@ -385,7 +389,7 @@ static void __kprobes setup_optimize_kprobe(struct text_poke_param *tprm,
22960 ((long)op->kp.addr + RELATIVEJUMP_SIZE));
22961
22962 /* Backup instructions which will be replaced by jump address */
22963 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
22964 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
22965 RELATIVE_ADDR_SIZE);
22966
22967 insn_buf[0] = RELATIVEJUMP_OPCODE;
22968 @@ -483,7 +487,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
22969 /* This kprobe is really able to run optimized path. */
22970 op = container_of(p, struct optimized_kprobe, kp);
22971 /* Detour through copied instructions */
22972 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
22973 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
22974 if (!reenter)
22975 reset_current_kprobe();
22976 preempt_enable_no_resched();
22977 diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c
22978 index cd6d9a5..16245a4 100644
22979 --- a/arch/x86/kernel/kvm.c
22980 +++ b/arch/x86/kernel/kvm.c
22981 @@ -455,7 +455,7 @@ static int __cpuinit kvm_cpu_notify(struct notifier_block *self,
22982 return NOTIFY_OK;
22983 }
22984
22985 -static struct notifier_block __cpuinitdata kvm_cpu_notifier = {
22986 +static struct notifier_block kvm_cpu_notifier = {
22987 .notifier_call = kvm_cpu_notify,
22988 };
22989 #endif
22990 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
22991 index ebc9873..1b9724b 100644
22992 --- a/arch/x86/kernel/ldt.c
22993 +++ b/arch/x86/kernel/ldt.c
22994 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
22995 if (reload) {
22996 #ifdef CONFIG_SMP
22997 preempt_disable();
22998 - load_LDT(pc);
22999 + load_LDT_nolock(pc);
23000 if (!cpumask_equal(mm_cpumask(current->mm),
23001 cpumask_of(smp_processor_id())))
23002 smp_call_function(flush_ldt, current->mm, 1);
23003 preempt_enable();
23004 #else
23005 - load_LDT(pc);
23006 + load_LDT_nolock(pc);
23007 #endif
23008 }
23009 if (oldsize) {
23010 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
23011 return err;
23012
23013 for (i = 0; i < old->size; i++)
23014 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
23015 + write_ldt_entry(new->ldt, i, old->ldt + i);
23016 return 0;
23017 }
23018
23019 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
23020 retval = copy_ldt(&mm->context, &old_mm->context);
23021 mutex_unlock(&old_mm->context.lock);
23022 }
23023 +
23024 + if (tsk == current) {
23025 + mm->context.vdso = 0;
23026 +
23027 +#ifdef CONFIG_X86_32
23028 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
23029 + mm->context.user_cs_base = 0UL;
23030 + mm->context.user_cs_limit = ~0UL;
23031 +
23032 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
23033 + cpus_clear(mm->context.cpu_user_cs_mask);
23034 +#endif
23035 +
23036 +#endif
23037 +#endif
23038 +
23039 + }
23040 +
23041 return retval;
23042 }
23043
23044 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
23045 }
23046 }
23047
23048 +#ifdef CONFIG_PAX_SEGMEXEC
23049 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
23050 + error = -EINVAL;
23051 + goto out_unlock;
23052 + }
23053 +#endif
23054 +
23055 fill_ldt(&ldt, &ldt_info);
23056 if (oldmode)
23057 ldt.avl = 0;
23058 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
23059 index 5b19e4d..6476a76 100644
23060 --- a/arch/x86/kernel/machine_kexec_32.c
23061 +++ b/arch/x86/kernel/machine_kexec_32.c
23062 @@ -26,7 +26,7 @@
23063 #include <asm/cacheflush.h>
23064 #include <asm/debugreg.h>
23065
23066 -static void set_idt(void *newidt, __u16 limit)
23067 +static void set_idt(struct desc_struct *newidt, __u16 limit)
23068 {
23069 struct desc_ptr curidt;
23070
23071 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
23072 }
23073
23074
23075 -static void set_gdt(void *newgdt, __u16 limit)
23076 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
23077 {
23078 struct desc_ptr curgdt;
23079
23080 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
23081 }
23082
23083 control_page = page_address(image->control_code_page);
23084 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
23085 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
23086
23087 relocate_kernel_ptr = control_page;
23088 page_list[PA_CONTROL_PAGE] = __pa(control_page);
23089 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
23090 index 22db92b..d546bec 100644
23091 --- a/arch/x86/kernel/microcode_core.c
23092 +++ b/arch/x86/kernel/microcode_core.c
23093 @@ -513,7 +513,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
23094 return NOTIFY_OK;
23095 }
23096
23097 -static struct notifier_block __refdata mc_cpu_notifier = {
23098 +static struct notifier_block mc_cpu_notifier = {
23099 .notifier_call = mc_cpu_callback,
23100 };
23101
23102 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
23103 index 5fb2ceb..3ae90bb 100644
23104 --- a/arch/x86/kernel/microcode_intel.c
23105 +++ b/arch/x86/kernel/microcode_intel.c
23106 @@ -293,13 +293,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
23107
23108 static int get_ucode_user(void *to, const void *from, size_t n)
23109 {
23110 - return copy_from_user(to, from, n);
23111 + return copy_from_user(to, (const void __force_user *)from, n);
23112 }
23113
23114 static enum ucode_state
23115 request_microcode_user(int cpu, const void __user *buf, size_t size)
23116 {
23117 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
23118 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
23119 }
23120
23121 static void microcode_fini_cpu(int cpu)
23122 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
23123 index 216a4d7..228255a 100644
23124 --- a/arch/x86/kernel/module.c
23125 +++ b/arch/x86/kernel/module.c
23126 @@ -43,15 +43,60 @@ do { \
23127 } while (0)
23128 #endif
23129
23130 -void *module_alloc(unsigned long size)
23131 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
23132 {
23133 - if (PAGE_ALIGN(size) > MODULES_LEN)
23134 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
23135 return NULL;
23136 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
23137 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
23138 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
23139 -1, __builtin_return_address(0));
23140 }
23141
23142 +void *module_alloc(unsigned long size)
23143 +{
23144 +
23145 +#ifdef CONFIG_PAX_KERNEXEC
23146 + return __module_alloc(size, PAGE_KERNEL);
23147 +#else
23148 + return __module_alloc(size, PAGE_KERNEL_EXEC);
23149 +#endif
23150 +
23151 +}
23152 +
23153 +#ifdef CONFIG_PAX_KERNEXEC
23154 +#ifdef CONFIG_X86_32
23155 +void *module_alloc_exec(unsigned long size)
23156 +{
23157 + struct vm_struct *area;
23158 +
23159 + if (size == 0)
23160 + return NULL;
23161 +
23162 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
23163 + return area ? area->addr : NULL;
23164 +}
23165 +EXPORT_SYMBOL(module_alloc_exec);
23166 +
23167 +void module_free_exec(struct module *mod, void *module_region)
23168 +{
23169 + vunmap(module_region);
23170 +}
23171 +EXPORT_SYMBOL(module_free_exec);
23172 +#else
23173 +void module_free_exec(struct module *mod, void *module_region)
23174 +{
23175 + module_free(mod, module_region);
23176 +}
23177 +EXPORT_SYMBOL(module_free_exec);
23178 +
23179 +void *module_alloc_exec(unsigned long size)
23180 +{
23181 + return __module_alloc(size, PAGE_KERNEL_RX);
23182 +}
23183 +EXPORT_SYMBOL(module_alloc_exec);
23184 +#endif
23185 +#endif
23186 +
23187 #ifdef CONFIG_X86_32
23188 int apply_relocate(Elf32_Shdr *sechdrs,
23189 const char *strtab,
23190 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
23191 unsigned int i;
23192 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
23193 Elf32_Sym *sym;
23194 - uint32_t *location;
23195 + uint32_t *plocation, location;
23196
23197 DEBUGP("Applying relocate section %u to %u\n",
23198 relsec, sechdrs[relsec].sh_info);
23199 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
23200 /* This is where to make the change */
23201 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
23202 - + rel[i].r_offset;
23203 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
23204 + location = (uint32_t)plocation;
23205 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
23206 + plocation = ktla_ktva((void *)plocation);
23207 /* This is the symbol it is referring to. Note that all
23208 undefined symbols have been resolved. */
23209 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
23210 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
23211 switch (ELF32_R_TYPE(rel[i].r_info)) {
23212 case R_386_32:
23213 /* We add the value into the location given */
23214 - *location += sym->st_value;
23215 + pax_open_kernel();
23216 + *plocation += sym->st_value;
23217 + pax_close_kernel();
23218 break;
23219 case R_386_PC32:
23220 /* Add the value, subtract its position */
23221 - *location += sym->st_value - (uint32_t)location;
23222 + pax_open_kernel();
23223 + *plocation += sym->st_value - location;
23224 + pax_close_kernel();
23225 break;
23226 default:
23227 pr_err("%s: Unknown relocation: %u\n",
23228 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
23229 case R_X86_64_NONE:
23230 break;
23231 case R_X86_64_64:
23232 + pax_open_kernel();
23233 *(u64 *)loc = val;
23234 + pax_close_kernel();
23235 break;
23236 case R_X86_64_32:
23237 + pax_open_kernel();
23238 *(u32 *)loc = val;
23239 + pax_close_kernel();
23240 if (val != *(u32 *)loc)
23241 goto overflow;
23242 break;
23243 case R_X86_64_32S:
23244 + pax_open_kernel();
23245 *(s32 *)loc = val;
23246 + pax_close_kernel();
23247 if ((s64)val != *(s32 *)loc)
23248 goto overflow;
23249 break;
23250 case R_X86_64_PC32:
23251 val -= (u64)loc;
23252 + pax_open_kernel();
23253 *(u32 *)loc = val;
23254 + pax_close_kernel();
23255 +
23256 #if 0
23257 if ((s64)val != *(s32 *)loc)
23258 goto overflow;
23259 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
23260 index ce13049..e2e9c3c 100644
23261 --- a/arch/x86/kernel/msr.c
23262 +++ b/arch/x86/kernel/msr.c
23263 @@ -233,7 +233,7 @@ static int __cpuinit msr_class_cpu_callback(struct notifier_block *nfb,
23264 return notifier_from_errno(err);
23265 }
23266
23267 -static struct notifier_block __refdata msr_class_cpu_notifier = {
23268 +static struct notifier_block msr_class_cpu_notifier = {
23269 .notifier_call = msr_class_cpu_callback,
23270 };
23271
23272 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
23273 index 6030805..2d33f21 100644
23274 --- a/arch/x86/kernel/nmi.c
23275 +++ b/arch/x86/kernel/nmi.c
23276 @@ -105,7 +105,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
23277 return handled;
23278 }
23279
23280 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
23281 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
23282 {
23283 struct nmi_desc *desc = nmi_to_desc(type);
23284 unsigned long flags;
23285 @@ -129,9 +129,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
23286 * event confuses some handlers (kdump uses this flag)
23287 */
23288 if (action->flags & NMI_FLAG_FIRST)
23289 - list_add_rcu(&action->list, &desc->head);
23290 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
23291 else
23292 - list_add_tail_rcu(&action->list, &desc->head);
23293 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
23294
23295 spin_unlock_irqrestore(&desc->lock, flags);
23296 return 0;
23297 @@ -154,7 +154,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
23298 if (!strcmp(n->name, name)) {
23299 WARN(in_nmi(),
23300 "Trying to free NMI (%s) from NMI context!\n", n->name);
23301 - list_del_rcu(&n->list);
23302 + pax_list_del_rcu((struct list_head *)&n->list);
23303 break;
23304 }
23305 }
23306 @@ -479,6 +479,17 @@ static inline void nmi_nesting_postprocess(void)
23307 dotraplinkage notrace __kprobes void
23308 do_nmi(struct pt_regs *regs, long error_code)
23309 {
23310 +
23311 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
23312 + if (!user_mode(regs)) {
23313 + unsigned long cs = regs->cs & 0xFFFF;
23314 + unsigned long ip = ktva_ktla(regs->ip);
23315 +
23316 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
23317 + regs->ip = ip;
23318 + }
23319 +#endif
23320 +
23321 nmi_nesting_preprocess(regs);
23322
23323 nmi_enter();
23324 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
23325 index 6d9582e..f746287 100644
23326 --- a/arch/x86/kernel/nmi_selftest.c
23327 +++ b/arch/x86/kernel/nmi_selftest.c
23328 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
23329 {
23330 /* trap all the unknown NMIs we may generate */
23331 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
23332 - __initdata);
23333 + __initconst);
23334 }
23335
23336 static void __init cleanup_nmi_testsuite(void)
23337 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
23338 unsigned long timeout;
23339
23340 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
23341 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
23342 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
23343 nmi_fail = FAILURE;
23344 return;
23345 }
23346 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
23347 index 676b8c7..870ba04 100644
23348 --- a/arch/x86/kernel/paravirt-spinlocks.c
23349 +++ b/arch/x86/kernel/paravirt-spinlocks.c
23350 @@ -13,7 +13,7 @@ default_spin_lock_flags(arch_spinlock_t *lock, unsigned long flags)
23351 arch_spin_lock(lock);
23352 }
23353
23354 -struct pv_lock_ops pv_lock_ops = {
23355 +struct pv_lock_ops pv_lock_ops __read_only = {
23356 #ifdef CONFIG_SMP
23357 .spin_is_locked = __ticket_spin_is_locked,
23358 .spin_is_contended = __ticket_spin_is_contended,
23359 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
23360 index cd6de64..27c6af0 100644
23361 --- a/arch/x86/kernel/paravirt.c
23362 +++ b/arch/x86/kernel/paravirt.c
23363 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
23364 {
23365 return x;
23366 }
23367 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
23368 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
23369 +#endif
23370
23371 void __init default_banner(void)
23372 {
23373 @@ -147,15 +150,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
23374 if (opfunc == NULL)
23375 /* If there's no function, patch it with a ud2a (BUG) */
23376 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
23377 - else if (opfunc == _paravirt_nop)
23378 + else if (opfunc == (void *)_paravirt_nop)
23379 /* If the operation is a nop, then nop the callsite */
23380 ret = paravirt_patch_nop();
23381
23382 /* identity functions just return their single argument */
23383 - else if (opfunc == _paravirt_ident_32)
23384 + else if (opfunc == (void *)_paravirt_ident_32)
23385 ret = paravirt_patch_ident_32(insnbuf, len);
23386 - else if (opfunc == _paravirt_ident_64)
23387 + else if (opfunc == (void *)_paravirt_ident_64)
23388 ret = paravirt_patch_ident_64(insnbuf, len);
23389 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
23390 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
23391 + ret = paravirt_patch_ident_64(insnbuf, len);
23392 +#endif
23393
23394 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
23395 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
23396 @@ -180,7 +187,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
23397 if (insn_len > len || start == NULL)
23398 insn_len = len;
23399 else
23400 - memcpy(insnbuf, start, insn_len);
23401 + memcpy(insnbuf, ktla_ktva(start), insn_len);
23402
23403 return insn_len;
23404 }
23405 @@ -304,7 +311,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
23406 return this_cpu_read(paravirt_lazy_mode);
23407 }
23408
23409 -struct pv_info pv_info = {
23410 +struct pv_info pv_info __read_only = {
23411 .name = "bare hardware",
23412 .paravirt_enabled = 0,
23413 .kernel_rpl = 0,
23414 @@ -315,16 +322,16 @@ struct pv_info pv_info = {
23415 #endif
23416 };
23417
23418 -struct pv_init_ops pv_init_ops = {
23419 +struct pv_init_ops pv_init_ops __read_only = {
23420 .patch = native_patch,
23421 };
23422
23423 -struct pv_time_ops pv_time_ops = {
23424 +struct pv_time_ops pv_time_ops __read_only = {
23425 .sched_clock = native_sched_clock,
23426 .steal_clock = native_steal_clock,
23427 };
23428
23429 -struct pv_irq_ops pv_irq_ops = {
23430 +struct pv_irq_ops pv_irq_ops __read_only = {
23431 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
23432 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
23433 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
23434 @@ -336,7 +343,7 @@ struct pv_irq_ops pv_irq_ops = {
23435 #endif
23436 };
23437
23438 -struct pv_cpu_ops pv_cpu_ops = {
23439 +struct pv_cpu_ops pv_cpu_ops __read_only = {
23440 .cpuid = native_cpuid,
23441 .get_debugreg = native_get_debugreg,
23442 .set_debugreg = native_set_debugreg,
23443 @@ -394,21 +401,26 @@ struct pv_cpu_ops pv_cpu_ops = {
23444 .end_context_switch = paravirt_nop,
23445 };
23446
23447 -struct pv_apic_ops pv_apic_ops = {
23448 +struct pv_apic_ops pv_apic_ops __read_only= {
23449 #ifdef CONFIG_X86_LOCAL_APIC
23450 .startup_ipi_hook = paravirt_nop,
23451 #endif
23452 };
23453
23454 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
23455 +#ifdef CONFIG_X86_32
23456 +#ifdef CONFIG_X86_PAE
23457 +/* 64-bit pagetable entries */
23458 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
23459 +#else
23460 /* 32-bit pagetable entries */
23461 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
23462 +#endif
23463 #else
23464 /* 64-bit pagetable entries */
23465 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
23466 #endif
23467
23468 -struct pv_mmu_ops pv_mmu_ops = {
23469 +struct pv_mmu_ops pv_mmu_ops __read_only = {
23470
23471 .read_cr2 = native_read_cr2,
23472 .write_cr2 = native_write_cr2,
23473 @@ -458,6 +470,7 @@ struct pv_mmu_ops pv_mmu_ops = {
23474 .make_pud = PTE_IDENT,
23475
23476 .set_pgd = native_set_pgd,
23477 + .set_pgd_batched = native_set_pgd_batched,
23478 #endif
23479 #endif /* PAGETABLE_LEVELS >= 3 */
23480
23481 @@ -478,6 +491,12 @@ struct pv_mmu_ops pv_mmu_ops = {
23482 },
23483
23484 .set_fixmap = native_set_fixmap,
23485 +
23486 +#ifdef CONFIG_PAX_KERNEXEC
23487 + .pax_open_kernel = native_pax_open_kernel,
23488 + .pax_close_kernel = native_pax_close_kernel,
23489 +#endif
23490 +
23491 };
23492
23493 EXPORT_SYMBOL_GPL(pv_time_ops);
23494 diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
23495 index 299d493..2ccb0ee 100644
23496 --- a/arch/x86/kernel/pci-calgary_64.c
23497 +++ b/arch/x86/kernel/pci-calgary_64.c
23498 @@ -1339,7 +1339,7 @@ static void __init get_tce_space_from_tar(void)
23499 tce_space = be64_to_cpu(readq(target));
23500 tce_space = tce_space & TAR_SW_BITS;
23501
23502 - tce_space = tce_space & (~specified_table_size);
23503 + tce_space = tce_space & (~(unsigned long)specified_table_size);
23504 info->tce_space = (u64 *)__va(tce_space);
23505 }
23506 }
23507 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
23508 index 35ccf75..7a15747 100644
23509 --- a/arch/x86/kernel/pci-iommu_table.c
23510 +++ b/arch/x86/kernel/pci-iommu_table.c
23511 @@ -2,7 +2,7 @@
23512 #include <asm/iommu_table.h>
23513 #include <linux/string.h>
23514 #include <linux/kallsyms.h>
23515 -
23516 +#include <linux/sched.h>
23517
23518 #define DEBUG 1
23519
23520 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
23521 index 6c483ba..d10ce2f 100644
23522 --- a/arch/x86/kernel/pci-swiotlb.c
23523 +++ b/arch/x86/kernel/pci-swiotlb.c
23524 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
23525 void *vaddr, dma_addr_t dma_addr,
23526 struct dma_attrs *attrs)
23527 {
23528 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
23529 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
23530 }
23531
23532 static struct dma_map_ops swiotlb_dma_ops = {
23533 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
23534 index 81a5f5e..20f8b58 100644
23535 --- a/arch/x86/kernel/process.c
23536 +++ b/arch/x86/kernel/process.c
23537 @@ -36,7 +36,8 @@
23538 * section. Since TSS's are completely CPU-local, we want them
23539 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
23540 */
23541 -DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
23542 +struct tss_struct init_tss[NR_CPUS] ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
23543 +EXPORT_SYMBOL(init_tss);
23544
23545 #ifdef CONFIG_X86_64
23546 static DEFINE_PER_CPU(unsigned char, is_idle);
23547 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
23548 task_xstate_cachep =
23549 kmem_cache_create("task_xstate", xstate_size,
23550 __alignof__(union thread_xstate),
23551 - SLAB_PANIC | SLAB_NOTRACK, NULL);
23552 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
23553 }
23554
23555 /*
23556 @@ -105,7 +106,7 @@ void exit_thread(void)
23557 unsigned long *bp = t->io_bitmap_ptr;
23558
23559 if (bp) {
23560 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
23561 + struct tss_struct *tss = init_tss + get_cpu();
23562
23563 t->io_bitmap_ptr = NULL;
23564 clear_thread_flag(TIF_IO_BITMAP);
23565 @@ -125,6 +126,9 @@ void flush_thread(void)
23566 {
23567 struct task_struct *tsk = current;
23568
23569 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
23570 + loadsegment(gs, 0);
23571 +#endif
23572 flush_ptrace_hw_breakpoint(tsk);
23573 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
23574 drop_init_fpu(tsk);
23575 @@ -271,7 +275,7 @@ static void __exit_idle(void)
23576 void exit_idle(void)
23577 {
23578 /* idle loop has pid 0 */
23579 - if (current->pid)
23580 + if (task_pid_nr(current))
23581 return;
23582 __exit_idle();
23583 }
23584 @@ -327,7 +331,7 @@ bool xen_set_default_idle(void)
23585 return ret;
23586 }
23587 #endif
23588 -void stop_this_cpu(void *dummy)
23589 +__noreturn void stop_this_cpu(void *dummy)
23590 {
23591 local_irq_disable();
23592 /*
23593 @@ -456,16 +460,37 @@ static int __init idle_setup(char *str)
23594 }
23595 early_param("idle", idle_setup);
23596
23597 -unsigned long arch_align_stack(unsigned long sp)
23598 +#ifdef CONFIG_PAX_RANDKSTACK
23599 +void pax_randomize_kstack(struct pt_regs *regs)
23600 {
23601 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
23602 - sp -= get_random_int() % 8192;
23603 - return sp & ~0xf;
23604 -}
23605 + struct thread_struct *thread = &current->thread;
23606 + unsigned long time;
23607
23608 -unsigned long arch_randomize_brk(struct mm_struct *mm)
23609 -{
23610 - unsigned long range_end = mm->brk + 0x02000000;
23611 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
23612 -}
23613 + if (!randomize_va_space)
23614 + return;
23615 +
23616 + if (v8086_mode(regs))
23617 + return;
23618
23619 + rdtscl(time);
23620 +
23621 + /* P4 seems to return a 0 LSB, ignore it */
23622 +#ifdef CONFIG_MPENTIUM4
23623 + time &= 0x3EUL;
23624 + time <<= 2;
23625 +#elif defined(CONFIG_X86_64)
23626 + time &= 0xFUL;
23627 + time <<= 4;
23628 +#else
23629 + time &= 0x1FUL;
23630 + time <<= 3;
23631 +#endif
23632 +
23633 + thread->sp0 ^= time;
23634 + load_sp0(init_tss + smp_processor_id(), thread);
23635 +
23636 +#ifdef CONFIG_X86_64
23637 + this_cpu_write(kernel_stack, thread->sp0);
23638 +#endif
23639 +}
23640 +#endif
23641 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
23642 index 7305f7d..22f73d6 100644
23643 --- a/arch/x86/kernel/process_32.c
23644 +++ b/arch/x86/kernel/process_32.c
23645 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
23646 unsigned long thread_saved_pc(struct task_struct *tsk)
23647 {
23648 return ((unsigned long *)tsk->thread.sp)[3];
23649 +//XXX return tsk->thread.eip;
23650 }
23651
23652 void __show_regs(struct pt_regs *regs, int all)
23653 @@ -74,19 +75,18 @@ void __show_regs(struct pt_regs *regs, int all)
23654 unsigned long sp;
23655 unsigned short ss, gs;
23656
23657 - if (user_mode_vm(regs)) {
23658 + if (user_mode(regs)) {
23659 sp = regs->sp;
23660 ss = regs->ss & 0xffff;
23661 - gs = get_user_gs(regs);
23662 } else {
23663 sp = kernel_stack_pointer(regs);
23664 savesegment(ss, ss);
23665 - savesegment(gs, gs);
23666 }
23667 + gs = get_user_gs(regs);
23668
23669 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
23670 (u16)regs->cs, regs->ip, regs->flags,
23671 - smp_processor_id());
23672 + raw_smp_processor_id());
23673 print_symbol("EIP is at %s\n", regs->ip);
23674
23675 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
23676 @@ -128,20 +128,21 @@ void release_thread(struct task_struct *dead_task)
23677 int copy_thread(unsigned long clone_flags, unsigned long sp,
23678 unsigned long arg, struct task_struct *p)
23679 {
23680 - struct pt_regs *childregs = task_pt_regs(p);
23681 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
23682 struct task_struct *tsk;
23683 int err;
23684
23685 p->thread.sp = (unsigned long) childregs;
23686 p->thread.sp0 = (unsigned long) (childregs+1);
23687 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
23688
23689 if (unlikely(p->flags & PF_KTHREAD)) {
23690 /* kernel thread */
23691 memset(childregs, 0, sizeof(struct pt_regs));
23692 p->thread.ip = (unsigned long) ret_from_kernel_thread;
23693 - task_user_gs(p) = __KERNEL_STACK_CANARY;
23694 - childregs->ds = __USER_DS;
23695 - childregs->es = __USER_DS;
23696 + savesegment(gs, childregs->gs);
23697 + childregs->ds = __KERNEL_DS;
23698 + childregs->es = __KERNEL_DS;
23699 childregs->fs = __KERNEL_PERCPU;
23700 childregs->bx = sp; /* function */
23701 childregs->bp = arg;
23702 @@ -248,7 +249,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
23703 struct thread_struct *prev = &prev_p->thread,
23704 *next = &next_p->thread;
23705 int cpu = smp_processor_id();
23706 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
23707 + struct tss_struct *tss = init_tss + cpu;
23708 fpu_switch_t fpu;
23709
23710 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
23711 @@ -272,6 +273,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
23712 */
23713 lazy_save_gs(prev->gs);
23714
23715 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23716 + __set_fs(task_thread_info(next_p)->addr_limit);
23717 +#endif
23718 +
23719 /*
23720 * Load the per-thread Thread-Local Storage descriptor.
23721 */
23722 @@ -302,6 +307,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
23723 */
23724 arch_end_context_switch(next_p);
23725
23726 + this_cpu_write(current_task, next_p);
23727 + this_cpu_write(current_tinfo, &next_p->tinfo);
23728 +
23729 /*
23730 * Restore %gs if needed (which is common)
23731 */
23732 @@ -310,8 +318,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
23733
23734 switch_fpu_finish(next_p, fpu);
23735
23736 - this_cpu_write(current_task, next_p);
23737 -
23738 return prev_p;
23739 }
23740
23741 @@ -341,4 +347,3 @@ unsigned long get_wchan(struct task_struct *p)
23742 } while (count++ < 16);
23743 return 0;
23744 }
23745 -
23746 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
23747 index 355ae06..560fbbe 100644
23748 --- a/arch/x86/kernel/process_64.c
23749 +++ b/arch/x86/kernel/process_64.c
23750 @@ -151,10 +151,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
23751 struct pt_regs *childregs;
23752 struct task_struct *me = current;
23753
23754 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
23755 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
23756 childregs = task_pt_regs(p);
23757 p->thread.sp = (unsigned long) childregs;
23758 p->thread.usersp = me->thread.usersp;
23759 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
23760 set_tsk_thread_flag(p, TIF_FORK);
23761 p->fpu_counter = 0;
23762 p->thread.io_bitmap_ptr = NULL;
23763 @@ -165,6 +166,8 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
23764 p->thread.fs = p->thread.fsindex ? 0 : me->thread.fs;
23765 savesegment(es, p->thread.es);
23766 savesegment(ds, p->thread.ds);
23767 + savesegment(ss, p->thread.ss);
23768 + BUG_ON(p->thread.ss == __UDEREF_KERNEL_DS);
23769 memset(p->thread.ptrace_bps, 0, sizeof(p->thread.ptrace_bps));
23770
23771 if (unlikely(p->flags & PF_KTHREAD)) {
23772 @@ -273,7 +276,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
23773 struct thread_struct *prev = &prev_p->thread;
23774 struct thread_struct *next = &next_p->thread;
23775 int cpu = smp_processor_id();
23776 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
23777 + struct tss_struct *tss = init_tss + cpu;
23778 unsigned fsindex, gsindex;
23779 fpu_switch_t fpu;
23780
23781 @@ -296,6 +299,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
23782 if (unlikely(next->ds | prev->ds))
23783 loadsegment(ds, next->ds);
23784
23785 + savesegment(ss, prev->ss);
23786 + if (unlikely(next->ss != prev->ss))
23787 + loadsegment(ss, next->ss);
23788
23789 /* We must save %fs and %gs before load_TLS() because
23790 * %fs and %gs may be cleared by load_TLS().
23791 @@ -355,10 +361,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
23792 prev->usersp = this_cpu_read(old_rsp);
23793 this_cpu_write(old_rsp, next->usersp);
23794 this_cpu_write(current_task, next_p);
23795 + this_cpu_write(current_tinfo, &next_p->tinfo);
23796
23797 - this_cpu_write(kernel_stack,
23798 - (unsigned long)task_stack_page(next_p) +
23799 - THREAD_SIZE - KERNEL_STACK_OFFSET);
23800 + this_cpu_write(kernel_stack, next->sp0);
23801
23802 /*
23803 * Now maybe reload the debug registers and handle I/O bitmaps
23804 @@ -427,12 +432,11 @@ unsigned long get_wchan(struct task_struct *p)
23805 if (!p || p == current || p->state == TASK_RUNNING)
23806 return 0;
23807 stack = (unsigned long)task_stack_page(p);
23808 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
23809 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
23810 return 0;
23811 fp = *(u64 *)(p->thread.sp);
23812 do {
23813 - if (fp < (unsigned long)stack ||
23814 - fp >= (unsigned long)stack+THREAD_SIZE)
23815 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
23816 return 0;
23817 ip = *(u64 *)(fp+8);
23818 if (!in_sched_functions(ip))
23819 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
23820 index 29a8120..a50b5ee 100644
23821 --- a/arch/x86/kernel/ptrace.c
23822 +++ b/arch/x86/kernel/ptrace.c
23823 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
23824 {
23825 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
23826 unsigned long sp = (unsigned long)&regs->sp;
23827 - struct thread_info *tinfo;
23828
23829 - if (context == (sp & ~(THREAD_SIZE - 1)))
23830 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
23831 return sp;
23832
23833 - tinfo = (struct thread_info *)context;
23834 - if (tinfo->previous_esp)
23835 - return tinfo->previous_esp;
23836 + sp = *(unsigned long *)context;
23837 + if (sp)
23838 + return sp;
23839
23840 return (unsigned long)regs;
23841 }
23842 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
23843 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
23844 {
23845 int i;
23846 - int dr7 = 0;
23847 + unsigned long dr7 = 0;
23848 struct arch_hw_breakpoint *info;
23849
23850 for (i = 0; i < HBP_NUM; i++) {
23851 @@ -856,7 +855,7 @@ long arch_ptrace(struct task_struct *child, long request,
23852 unsigned long addr, unsigned long data)
23853 {
23854 int ret;
23855 - unsigned long __user *datap = (unsigned long __user *)data;
23856 + unsigned long __user *datap = (__force unsigned long __user *)data;
23857
23858 switch (request) {
23859 /* read the word at location addr in the USER area. */
23860 @@ -941,14 +940,14 @@ long arch_ptrace(struct task_struct *child, long request,
23861 if ((int) addr < 0)
23862 return -EIO;
23863 ret = do_get_thread_area(child, addr,
23864 - (struct user_desc __user *)data);
23865 + (__force struct user_desc __user *) data);
23866 break;
23867
23868 case PTRACE_SET_THREAD_AREA:
23869 if ((int) addr < 0)
23870 return -EIO;
23871 ret = do_set_thread_area(child, addr,
23872 - (struct user_desc __user *)data, 0);
23873 + (__force struct user_desc __user *) data, 0);
23874 break;
23875 #endif
23876
23877 @@ -1326,7 +1325,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
23878
23879 #ifdef CONFIG_X86_64
23880
23881 -static struct user_regset x86_64_regsets[] __read_mostly = {
23882 +static user_regset_no_const x86_64_regsets[] __read_only = {
23883 [REGSET_GENERAL] = {
23884 .core_note_type = NT_PRSTATUS,
23885 .n = sizeof(struct user_regs_struct) / sizeof(long),
23886 @@ -1367,7 +1366,7 @@ static const struct user_regset_view user_x86_64_view = {
23887 #endif /* CONFIG_X86_64 */
23888
23889 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
23890 -static struct user_regset x86_32_regsets[] __read_mostly = {
23891 +static user_regset_no_const x86_32_regsets[] __read_only = {
23892 [REGSET_GENERAL] = {
23893 .core_note_type = NT_PRSTATUS,
23894 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
23895 @@ -1420,7 +1419,7 @@ static const struct user_regset_view user_x86_32_view = {
23896 */
23897 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
23898
23899 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
23900 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
23901 {
23902 #ifdef CONFIG_X86_64
23903 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
23904 @@ -1455,7 +1454,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
23905 memset(info, 0, sizeof(*info));
23906 info->si_signo = SIGTRAP;
23907 info->si_code = si_code;
23908 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
23909 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
23910 }
23911
23912 void user_single_step_siginfo(struct task_struct *tsk,
23913 @@ -1484,6 +1483,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
23914 # define IS_IA32 0
23915 #endif
23916
23917 +#ifdef CONFIG_GRKERNSEC_SETXID
23918 +extern void gr_delayed_cred_worker(void);
23919 +#endif
23920 +
23921 /*
23922 * We must return the syscall number to actually look up in the table.
23923 * This can be -1L to skip running any syscall at all.
23924 @@ -1494,6 +1497,11 @@ long syscall_trace_enter(struct pt_regs *regs)
23925
23926 user_exit();
23927
23928 +#ifdef CONFIG_GRKERNSEC_SETXID
23929 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
23930 + gr_delayed_cred_worker();
23931 +#endif
23932 +
23933 /*
23934 * If we stepped into a sysenter/syscall insn, it trapped in
23935 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
23936 @@ -1549,6 +1557,11 @@ void syscall_trace_leave(struct pt_regs *regs)
23937 */
23938 user_exit();
23939
23940 +#ifdef CONFIG_GRKERNSEC_SETXID
23941 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
23942 + gr_delayed_cred_worker();
23943 +#endif
23944 +
23945 audit_syscall_exit(regs);
23946
23947 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
23948 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
23949 index 2cb9470..ff1fd80 100644
23950 --- a/arch/x86/kernel/pvclock.c
23951 +++ b/arch/x86/kernel/pvclock.c
23952 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
23953 return pv_tsc_khz;
23954 }
23955
23956 -static atomic64_t last_value = ATOMIC64_INIT(0);
23957 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
23958
23959 void pvclock_resume(void)
23960 {
23961 - atomic64_set(&last_value, 0);
23962 + atomic64_set_unchecked(&last_value, 0);
23963 }
23964
23965 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
23966 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
23967 * updating at the same time, and one of them could be slightly behind,
23968 * making the assumption that last_value always go forward fail to hold.
23969 */
23970 - last = atomic64_read(&last_value);
23971 + last = atomic64_read_unchecked(&last_value);
23972 do {
23973 if (ret < last)
23974 return last;
23975 - last = atomic64_cmpxchg(&last_value, last, ret);
23976 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
23977 } while (unlikely(last != ret));
23978
23979 return ret;
23980 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
23981 index 76fa1e9..abf09ea 100644
23982 --- a/arch/x86/kernel/reboot.c
23983 +++ b/arch/x86/kernel/reboot.c
23984 @@ -36,7 +36,7 @@ void (*pm_power_off)(void);
23985 EXPORT_SYMBOL(pm_power_off);
23986
23987 static const struct desc_ptr no_idt = {};
23988 -static int reboot_mode;
23989 +static unsigned short reboot_mode;
23990 enum reboot_type reboot_type = BOOT_ACPI;
23991 int reboot_force;
23992
23993 @@ -157,6 +157,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
23994
23995 void __noreturn machine_real_restart(unsigned int type)
23996 {
23997 +
23998 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
23999 + struct desc_struct *gdt;
24000 +#endif
24001 +
24002 local_irq_disable();
24003
24004 /*
24005 @@ -184,7 +189,29 @@ void __noreturn machine_real_restart(unsigned int type)
24006
24007 /* Jump to the identity-mapped low memory code */
24008 #ifdef CONFIG_X86_32
24009 - asm volatile("jmpl *%0" : :
24010 +
24011 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
24012 + gdt = get_cpu_gdt_table(smp_processor_id());
24013 + pax_open_kernel();
24014 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24015 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
24016 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
24017 + loadsegment(ds, __KERNEL_DS);
24018 + loadsegment(es, __KERNEL_DS);
24019 + loadsegment(ss, __KERNEL_DS);
24020 +#endif
24021 +#ifdef CONFIG_PAX_KERNEXEC
24022 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
24023 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
24024 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
24025 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
24026 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
24027 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
24028 +#endif
24029 + pax_close_kernel();
24030 +#endif
24031 +
24032 + asm volatile("ljmpl *%0" : :
24033 "rm" (real_mode_header->machine_real_restart_asm),
24034 "a" (type));
24035 #else
24036 @@ -531,7 +558,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
24037 * try to force a triple fault and then cycle between hitting the keyboard
24038 * controller and doing that
24039 */
24040 -static void native_machine_emergency_restart(void)
24041 +static void __noreturn native_machine_emergency_restart(void)
24042 {
24043 int i;
24044 int attempt = 0;
24045 @@ -654,13 +681,13 @@ void native_machine_shutdown(void)
24046 #endif
24047 }
24048
24049 -static void __machine_emergency_restart(int emergency)
24050 +static void __noreturn __machine_emergency_restart(int emergency)
24051 {
24052 reboot_emergency = emergency;
24053 machine_ops.emergency_restart();
24054 }
24055
24056 -static void native_machine_restart(char *__unused)
24057 +static void __noreturn native_machine_restart(char *__unused)
24058 {
24059 pr_notice("machine restart\n");
24060
24061 @@ -669,7 +696,7 @@ static void native_machine_restart(char *__unused)
24062 __machine_emergency_restart(0);
24063 }
24064
24065 -static void native_machine_halt(void)
24066 +static void __noreturn native_machine_halt(void)
24067 {
24068 /* Stop other cpus and apics */
24069 machine_shutdown();
24070 @@ -679,7 +706,7 @@ static void native_machine_halt(void)
24071 stop_this_cpu(NULL);
24072 }
24073
24074 -static void native_machine_power_off(void)
24075 +static void __noreturn native_machine_power_off(void)
24076 {
24077 if (pm_power_off) {
24078 if (!reboot_force)
24079 @@ -688,9 +715,10 @@ static void native_machine_power_off(void)
24080 }
24081 /* A fallback in case there is no PM info available */
24082 tboot_shutdown(TB_SHUTDOWN_HALT);
24083 + unreachable();
24084 }
24085
24086 -struct machine_ops machine_ops = {
24087 +struct machine_ops machine_ops __read_only = {
24088 .power_off = native_machine_power_off,
24089 .shutdown = native_machine_shutdown,
24090 .emergency_restart = native_machine_emergency_restart,
24091 diff --git a/arch/x86/kernel/reboot_fixups_32.c b/arch/x86/kernel/reboot_fixups_32.c
24092 index c8e41e9..64049ef 100644
24093 --- a/arch/x86/kernel/reboot_fixups_32.c
24094 +++ b/arch/x86/kernel/reboot_fixups_32.c
24095 @@ -57,7 +57,7 @@ struct device_fixup {
24096 unsigned int vendor;
24097 unsigned int device;
24098 void (*reboot_fixup)(struct pci_dev *);
24099 -};
24100 +} __do_const;
24101
24102 /*
24103 * PCI ids solely used for fixups_table go here
24104 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
24105 index f2bb9c9..bed145d7 100644
24106 --- a/arch/x86/kernel/relocate_kernel_64.S
24107 +++ b/arch/x86/kernel/relocate_kernel_64.S
24108 @@ -11,6 +11,7 @@
24109 #include <asm/kexec.h>
24110 #include <asm/processor-flags.h>
24111 #include <asm/pgtable_types.h>
24112 +#include <asm/alternative-asm.h>
24113
24114 /*
24115 * Must be relocatable PIC code callable as a C function
24116 @@ -167,6 +168,7 @@ identity_mapped:
24117 xorq %r14, %r14
24118 xorq %r15, %r15
24119
24120 + pax_force_retaddr 0, 1
24121 ret
24122
24123 1:
24124 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
24125 index 56f7fcf..2cfe4f1 100644
24126 --- a/arch/x86/kernel/setup.c
24127 +++ b/arch/x86/kernel/setup.c
24128 @@ -110,6 +110,7 @@
24129 #include <asm/mce.h>
24130 #include <asm/alternative.h>
24131 #include <asm/prom.h>
24132 +#include <asm/boot.h>
24133
24134 /*
24135 * max_low_pfn_mapped: highest direct mapped pfn under 4GB
24136 @@ -205,12 +206,50 @@ EXPORT_SYMBOL(boot_cpu_data);
24137 #endif
24138
24139
24140 -#if !defined(CONFIG_X86_PAE) || defined(CONFIG_X86_64)
24141 -unsigned long mmu_cr4_features;
24142 +#ifdef CONFIG_X86_64
24143 +unsigned long mmu_cr4_features __read_only = X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE;
24144 +#elif defined(CONFIG_X86_PAE)
24145 +unsigned long mmu_cr4_features __read_only = X86_CR4_PAE;
24146 #else
24147 -unsigned long mmu_cr4_features = X86_CR4_PAE;
24148 +unsigned long mmu_cr4_features __read_only;
24149 #endif
24150
24151 +void set_in_cr4(unsigned long mask)
24152 +{
24153 + unsigned long cr4 = read_cr4();
24154 +
24155 + if ((cr4 & mask) == mask && cr4 == mmu_cr4_features)
24156 + return;
24157 +
24158 + pax_open_kernel();
24159 + mmu_cr4_features |= mask;
24160 + pax_close_kernel();
24161 +
24162 + if (trampoline_cr4_features)
24163 + *trampoline_cr4_features = mmu_cr4_features;
24164 + cr4 |= mask;
24165 + write_cr4(cr4);
24166 +}
24167 +EXPORT_SYMBOL(set_in_cr4);
24168 +
24169 +void clear_in_cr4(unsigned long mask)
24170 +{
24171 + unsigned long cr4 = read_cr4();
24172 +
24173 + if (!(cr4 & mask) && cr4 == mmu_cr4_features)
24174 + return;
24175 +
24176 + pax_open_kernel();
24177 + mmu_cr4_features &= ~mask;
24178 + pax_close_kernel();
24179 +
24180 + if (trampoline_cr4_features)
24181 + *trampoline_cr4_features = mmu_cr4_features;
24182 + cr4 &= ~mask;
24183 + write_cr4(cr4);
24184 +}
24185 +EXPORT_SYMBOL(clear_in_cr4);
24186 +
24187 /* Boot loader ID and version as integers, for the benefit of proc_dointvec */
24188 int bootloader_type, bootloader_version;
24189
24190 @@ -444,7 +483,7 @@ static void __init parse_setup_data(void)
24191
24192 switch (data->type) {
24193 case SETUP_E820_EXT:
24194 - parse_e820_ext(data);
24195 + parse_e820_ext((struct setup_data __force_kernel *)data);
24196 break;
24197 case SETUP_DTB:
24198 add_dtb(pa_data);
24199 @@ -771,7 +810,7 @@ static void __init trim_bios_range(void)
24200 * area (640->1Mb) as ram even though it is not.
24201 * take them out.
24202 */
24203 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
24204 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
24205
24206 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
24207 }
24208 @@ -779,7 +818,7 @@ static void __init trim_bios_range(void)
24209 /* called before trim_bios_range() to spare extra sanitize */
24210 static void __init e820_add_kernel_range(void)
24211 {
24212 - u64 start = __pa_symbol(_text);
24213 + u64 start = __pa_symbol(ktla_ktva(_text));
24214 u64 size = __pa_symbol(_end) - start;
24215
24216 /*
24217 @@ -841,8 +880,12 @@ static void __init trim_low_memory_range(void)
24218
24219 void __init setup_arch(char **cmdline_p)
24220 {
24221 +#ifdef CONFIG_X86_32
24222 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(__bss_stop) - LOAD_PHYSICAL_ADDR);
24223 +#else
24224 memblock_reserve(__pa_symbol(_text),
24225 (unsigned long)__bss_stop - (unsigned long)_text);
24226 +#endif
24227
24228 early_reserve_initrd();
24229
24230 @@ -934,14 +977,14 @@ void __init setup_arch(char **cmdline_p)
24231
24232 if (!boot_params.hdr.root_flags)
24233 root_mountflags &= ~MS_RDONLY;
24234 - init_mm.start_code = (unsigned long) _text;
24235 - init_mm.end_code = (unsigned long) _etext;
24236 + init_mm.start_code = ktla_ktva((unsigned long) _text);
24237 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
24238 init_mm.end_data = (unsigned long) _edata;
24239 init_mm.brk = _brk_end;
24240
24241 - code_resource.start = __pa_symbol(_text);
24242 - code_resource.end = __pa_symbol(_etext)-1;
24243 - data_resource.start = __pa_symbol(_etext);
24244 + code_resource.start = __pa_symbol(ktla_ktva(_text));
24245 + code_resource.end = __pa_symbol(ktla_ktva(_etext))-1;
24246 + data_resource.start = __pa_symbol(_sdata);
24247 data_resource.end = __pa_symbol(_edata)-1;
24248 bss_resource.start = __pa_symbol(__bss_start);
24249 bss_resource.end = __pa_symbol(__bss_stop)-1;
24250 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
24251 index 5cdff03..80fa283 100644
24252 --- a/arch/x86/kernel/setup_percpu.c
24253 +++ b/arch/x86/kernel/setup_percpu.c
24254 @@ -21,19 +21,17 @@
24255 #include <asm/cpu.h>
24256 #include <asm/stackprotector.h>
24257
24258 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
24259 +#ifdef CONFIG_SMP
24260 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
24261 EXPORT_PER_CPU_SYMBOL(cpu_number);
24262 +#endif
24263
24264 -#ifdef CONFIG_X86_64
24265 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
24266 -#else
24267 -#define BOOT_PERCPU_OFFSET 0
24268 -#endif
24269
24270 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
24271 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
24272
24273 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
24274 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
24275 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
24276 };
24277 EXPORT_SYMBOL(__per_cpu_offset);
24278 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
24279 {
24280 #ifdef CONFIG_NEED_MULTIPLE_NODES
24281 pg_data_t *last = NULL;
24282 - unsigned int cpu;
24283 + int cpu;
24284
24285 for_each_possible_cpu(cpu) {
24286 int node = early_cpu_to_node(cpu);
24287 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
24288 {
24289 #ifdef CONFIG_X86_32
24290 struct desc_struct gdt;
24291 + unsigned long base = per_cpu_offset(cpu);
24292
24293 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
24294 - 0x2 | DESCTYPE_S, 0x8);
24295 - gdt.s = 1;
24296 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
24297 + 0x83 | DESCTYPE_S, 0xC);
24298 write_gdt_entry(get_cpu_gdt_table(cpu),
24299 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
24300 #endif
24301 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
24302 /* alrighty, percpu areas up and running */
24303 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
24304 for_each_possible_cpu(cpu) {
24305 +#ifdef CONFIG_CC_STACKPROTECTOR
24306 +#ifdef CONFIG_X86_32
24307 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
24308 +#endif
24309 +#endif
24310 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
24311 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
24312 per_cpu(cpu_number, cpu) = cpu;
24313 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
24314 */
24315 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
24316 #endif
24317 +#ifdef CONFIG_CC_STACKPROTECTOR
24318 +#ifdef CONFIG_X86_32
24319 + if (!cpu)
24320 + per_cpu(stack_canary.canary, cpu) = canary;
24321 +#endif
24322 +#endif
24323 /*
24324 * Up to this point, the boot CPU has been using .init.data
24325 * area. Reload any changed state for the boot CPU.
24326 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
24327 index 6956299..18126ec4 100644
24328 --- a/arch/x86/kernel/signal.c
24329 +++ b/arch/x86/kernel/signal.c
24330 @@ -196,7 +196,7 @@ static unsigned long align_sigframe(unsigned long sp)
24331 * Align the stack pointer according to the i386 ABI,
24332 * i.e. so that on function entry ((sp + 4) & 15) == 0.
24333 */
24334 - sp = ((sp + 4) & -16ul) - 4;
24335 + sp = ((sp - 12) & -16ul) - 4;
24336 #else /* !CONFIG_X86_32 */
24337 sp = round_down(sp, 16) - 8;
24338 #endif
24339 @@ -304,9 +304,9 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
24340 }
24341
24342 if (current->mm->context.vdso)
24343 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
24344 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
24345 else
24346 - restorer = &frame->retcode;
24347 + restorer = (void __user *)&frame->retcode;
24348 if (ksig->ka.sa.sa_flags & SA_RESTORER)
24349 restorer = ksig->ka.sa.sa_restorer;
24350
24351 @@ -320,7 +320,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
24352 * reasons and because gdb uses it as a signature to notice
24353 * signal handler stack frames.
24354 */
24355 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
24356 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
24357
24358 if (err)
24359 return -EFAULT;
24360 @@ -364,10 +364,13 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
24361 else
24362 put_user_ex(0, &frame->uc.uc_flags);
24363 put_user_ex(0, &frame->uc.uc_link);
24364 - err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
24365 + __save_altstack_ex(&frame->uc.uc_stack, regs->sp);
24366
24367 /* Set up to return from userspace. */
24368 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
24369 + if (current->mm->context.vdso)
24370 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
24371 + else
24372 + restorer = (void __user *)&frame->retcode;
24373 if (ksig->ka.sa.sa_flags & SA_RESTORER)
24374 restorer = ksig->ka.sa.sa_restorer;
24375 put_user_ex(restorer, &frame->pretcode);
24376 @@ -379,7 +382,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
24377 * reasons and because gdb uses it as a signature to notice
24378 * signal handler stack frames.
24379 */
24380 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
24381 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
24382 } put_user_catch(err);
24383
24384 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
24385 @@ -429,7 +432,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
24386 else
24387 put_user_ex(0, &frame->uc.uc_flags);
24388 put_user_ex(0, &frame->uc.uc_link);
24389 - err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
24390 + __save_altstack_ex(&frame->uc.uc_stack, regs->sp);
24391
24392 /* Set up to return from userspace. If provided, use a stub
24393 already in userspace. */
24394 @@ -615,7 +618,12 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
24395 {
24396 int usig = signr_convert(ksig->sig);
24397 sigset_t *set = sigmask_to_save();
24398 - compat_sigset_t *cset = (compat_sigset_t *) set;
24399 + sigset_t sigcopy;
24400 + compat_sigset_t *cset;
24401 +
24402 + sigcopy = *set;
24403 +
24404 + cset = (compat_sigset_t *) &sigcopy;
24405
24406 /* Set up the stack frame */
24407 if (is_ia32_frame()) {
24408 @@ -626,7 +634,7 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
24409 } else if (is_x32_frame()) {
24410 return x32_setup_rt_frame(ksig, cset, regs);
24411 } else {
24412 - return __setup_rt_frame(ksig->sig, ksig, set, regs);
24413 + return __setup_rt_frame(ksig->sig, ksig, &sigcopy, regs);
24414 }
24415 }
24416
24417 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
24418 index 48d2b7d..90d328a 100644
24419 --- a/arch/x86/kernel/smp.c
24420 +++ b/arch/x86/kernel/smp.c
24421 @@ -285,7 +285,7 @@ static int __init nonmi_ipi_setup(char *str)
24422
24423 __setup("nonmi_ipi", nonmi_ipi_setup);
24424
24425 -struct smp_ops smp_ops = {
24426 +struct smp_ops smp_ops __read_only = {
24427 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
24428 .smp_prepare_cpus = native_smp_prepare_cpus,
24429 .smp_cpus_done = native_smp_cpus_done,
24430 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
24431 index bfd348e..914f323 100644
24432 --- a/arch/x86/kernel/smpboot.c
24433 +++ b/arch/x86/kernel/smpboot.c
24434 @@ -251,14 +251,18 @@ notrace static void __cpuinit start_secondary(void *unused)
24435
24436 enable_start_cpu0 = 0;
24437
24438 -#ifdef CONFIG_X86_32
24439 - /* switch away from the initial page table */
24440 - load_cr3(swapper_pg_dir);
24441 - __flush_tlb_all();
24442 -#endif
24443 -
24444 /* otherwise gcc will move up smp_processor_id before the cpu_init */
24445 barrier();
24446 +
24447 + /* switch away from the initial page table */
24448 +#ifdef CONFIG_PAX_PER_CPU_PGD
24449 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
24450 + __flush_tlb_all();
24451 +#elif defined(CONFIG_X86_32)
24452 + load_cr3(swapper_pg_dir);
24453 + __flush_tlb_all();
24454 +#endif
24455 +
24456 /*
24457 * Check TSC synchronization with the BP:
24458 */
24459 @@ -748,6 +752,7 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
24460 idle->thread.sp = (unsigned long) (((struct pt_regs *)
24461 (THREAD_SIZE + task_stack_page(idle))) - 1);
24462 per_cpu(current_task, cpu) = idle;
24463 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
24464
24465 #ifdef CONFIG_X86_32
24466 /* Stack for startup_32 can be just as for start_secondary onwards */
24467 @@ -755,11 +760,13 @@ static int __cpuinit do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
24468 #else
24469 clear_tsk_thread_flag(idle, TIF_FORK);
24470 initial_gs = per_cpu_offset(cpu);
24471 - per_cpu(kernel_stack, cpu) =
24472 - (unsigned long)task_stack_page(idle) -
24473 - KERNEL_STACK_OFFSET + THREAD_SIZE;
24474 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
24475 #endif
24476 +
24477 + pax_open_kernel();
24478 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
24479 + pax_close_kernel();
24480 +
24481 initial_code = (unsigned long)start_secondary;
24482 stack_start = idle->thread.sp;
24483
24484 @@ -908,6 +915,15 @@ int __cpuinit native_cpu_up(unsigned int cpu, struct task_struct *tidle)
24485 /* the FPU context is blank, nobody can own it */
24486 __cpu_disable_lazy_restore(cpu);
24487
24488 +#ifdef CONFIG_PAX_PER_CPU_PGD
24489 + clone_pgd_range(get_cpu_pgd(cpu, kernel) + KERNEL_PGD_BOUNDARY,
24490 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
24491 + KERNEL_PGD_PTRS);
24492 + clone_pgd_range(get_cpu_pgd(cpu, user) + KERNEL_PGD_BOUNDARY,
24493 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
24494 + KERNEL_PGD_PTRS);
24495 +#endif
24496 +
24497 err = do_boot_cpu(apicid, cpu, tidle);
24498 if (err) {
24499 pr_debug("do_boot_cpu failed %d\n", err);
24500 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
24501 index 9b4d51d..5d28b58 100644
24502 --- a/arch/x86/kernel/step.c
24503 +++ b/arch/x86/kernel/step.c
24504 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
24505 struct desc_struct *desc;
24506 unsigned long base;
24507
24508 - seg &= ~7UL;
24509 + seg >>= 3;
24510
24511 mutex_lock(&child->mm->context.lock);
24512 - if (unlikely((seg >> 3) >= child->mm->context.size))
24513 + if (unlikely(seg >= child->mm->context.size))
24514 addr = -1L; /* bogus selector, access would fault */
24515 else {
24516 desc = child->mm->context.ldt + seg;
24517 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
24518 addr += base;
24519 }
24520 mutex_unlock(&child->mm->context.lock);
24521 - }
24522 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
24523 + addr = ktla_ktva(addr);
24524
24525 return addr;
24526 }
24527 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
24528 unsigned char opcode[15];
24529 unsigned long addr = convert_ip_to_linear(child, regs);
24530
24531 + if (addr == -EINVAL)
24532 + return 0;
24533 +
24534 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
24535 for (i = 0; i < copied; i++) {
24536 switch (opcode[i]) {
24537 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
24538 new file mode 100644
24539 index 0000000..5877189
24540 --- /dev/null
24541 +++ b/arch/x86/kernel/sys_i386_32.c
24542 @@ -0,0 +1,189 @@
24543 +/*
24544 + * This file contains various random system calls that
24545 + * have a non-standard calling sequence on the Linux/i386
24546 + * platform.
24547 + */
24548 +
24549 +#include <linux/errno.h>
24550 +#include <linux/sched.h>
24551 +#include <linux/mm.h>
24552 +#include <linux/fs.h>
24553 +#include <linux/smp.h>
24554 +#include <linux/sem.h>
24555 +#include <linux/msg.h>
24556 +#include <linux/shm.h>
24557 +#include <linux/stat.h>
24558 +#include <linux/syscalls.h>
24559 +#include <linux/mman.h>
24560 +#include <linux/file.h>
24561 +#include <linux/utsname.h>
24562 +#include <linux/ipc.h>
24563 +#include <linux/elf.h>
24564 +
24565 +#include <linux/uaccess.h>
24566 +#include <linux/unistd.h>
24567 +
24568 +#include <asm/syscalls.h>
24569 +
24570 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
24571 +{
24572 + unsigned long pax_task_size = TASK_SIZE;
24573 +
24574 +#ifdef CONFIG_PAX_SEGMEXEC
24575 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
24576 + pax_task_size = SEGMEXEC_TASK_SIZE;
24577 +#endif
24578 +
24579 + if (flags & MAP_FIXED)
24580 + if (len > pax_task_size || addr > pax_task_size - len)
24581 + return -EINVAL;
24582 +
24583 + return 0;
24584 +}
24585 +
24586 +/*
24587 + * Align a virtual address to avoid aliasing in the I$ on AMD F15h.
24588 + */
24589 +static unsigned long get_align_mask(void)
24590 +{
24591 + if (va_align.flags < 0 || !(va_align.flags & ALIGN_VA_32))
24592 + return 0;
24593 +
24594 + if (!(current->flags & PF_RANDOMIZE))
24595 + return 0;
24596 +
24597 + return va_align.mask;
24598 +}
24599 +
24600 +unsigned long
24601 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
24602 + unsigned long len, unsigned long pgoff, unsigned long flags)
24603 +{
24604 + struct mm_struct *mm = current->mm;
24605 + struct vm_area_struct *vma;
24606 + unsigned long pax_task_size = TASK_SIZE;
24607 + struct vm_unmapped_area_info info;
24608 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
24609 +
24610 +#ifdef CONFIG_PAX_SEGMEXEC
24611 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
24612 + pax_task_size = SEGMEXEC_TASK_SIZE;
24613 +#endif
24614 +
24615 + pax_task_size -= PAGE_SIZE;
24616 +
24617 + if (len > pax_task_size)
24618 + return -ENOMEM;
24619 +
24620 + if (flags & MAP_FIXED)
24621 + return addr;
24622 +
24623 +#ifdef CONFIG_PAX_RANDMMAP
24624 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
24625 +#endif
24626 +
24627 + if (addr) {
24628 + addr = PAGE_ALIGN(addr);
24629 + if (pax_task_size - len >= addr) {
24630 + vma = find_vma(mm, addr);
24631 + if (check_heap_stack_gap(vma, addr, len, offset))
24632 + return addr;
24633 + }
24634 + }
24635 +
24636 + info.flags = 0;
24637 + info.length = len;
24638 + info.align_mask = filp ? get_align_mask() : 0;
24639 + info.align_offset = pgoff << PAGE_SHIFT;
24640 + info.threadstack_offset = offset;
24641 +
24642 +#ifdef CONFIG_PAX_PAGEEXEC
24643 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE)) {
24644 + info.low_limit = 0x00110000UL;
24645 + info.high_limit = mm->start_code;
24646 +
24647 +#ifdef CONFIG_PAX_RANDMMAP
24648 + if (mm->pax_flags & MF_PAX_RANDMMAP)
24649 + info.low_limit += mm->delta_mmap & 0x03FFF000UL;
24650 +#endif
24651 +
24652 + if (info.low_limit < info.high_limit) {
24653 + addr = vm_unmapped_area(&info);
24654 + if (!IS_ERR_VALUE(addr))
24655 + return addr;
24656 + }
24657 + } else
24658 +#endif
24659 +
24660 + info.low_limit = mm->mmap_base;
24661 + info.high_limit = pax_task_size;
24662 +
24663 + return vm_unmapped_area(&info);
24664 +}
24665 +
24666 +unsigned long
24667 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
24668 + const unsigned long len, const unsigned long pgoff,
24669 + const unsigned long flags)
24670 +{
24671 + struct vm_area_struct *vma;
24672 + struct mm_struct *mm = current->mm;
24673 + unsigned long addr = addr0, pax_task_size = TASK_SIZE;
24674 + struct vm_unmapped_area_info info;
24675 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
24676 +
24677 +#ifdef CONFIG_PAX_SEGMEXEC
24678 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
24679 + pax_task_size = SEGMEXEC_TASK_SIZE;
24680 +#endif
24681 +
24682 + pax_task_size -= PAGE_SIZE;
24683 +
24684 + /* requested length too big for entire address space */
24685 + if (len > pax_task_size)
24686 + return -ENOMEM;
24687 +
24688 + if (flags & MAP_FIXED)
24689 + return addr;
24690 +
24691 +#ifdef CONFIG_PAX_PAGEEXEC
24692 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
24693 + goto bottomup;
24694 +#endif
24695 +
24696 +#ifdef CONFIG_PAX_RANDMMAP
24697 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
24698 +#endif
24699 +
24700 + /* requesting a specific address */
24701 + if (addr) {
24702 + addr = PAGE_ALIGN(addr);
24703 + if (pax_task_size - len >= addr) {
24704 + vma = find_vma(mm, addr);
24705 + if (check_heap_stack_gap(vma, addr, len, offset))
24706 + return addr;
24707 + }
24708 + }
24709 +
24710 + info.flags = VM_UNMAPPED_AREA_TOPDOWN;
24711 + info.length = len;
24712 + info.low_limit = PAGE_SIZE;
24713 + info.high_limit = mm->mmap_base;
24714 + info.align_mask = filp ? get_align_mask() : 0;
24715 + info.align_offset = pgoff << PAGE_SHIFT;
24716 + info.threadstack_offset = offset;
24717 +
24718 + addr = vm_unmapped_area(&info);
24719 + if (!(addr & ~PAGE_MASK))
24720 + return addr;
24721 + VM_BUG_ON(addr != -ENOMEM);
24722 +
24723 +bottomup:
24724 + /*
24725 + * A failed mmap() very likely causes application failure,
24726 + * so fall back to the bottom-up function here. This scenario
24727 + * can happen with large stack limits and large mmap()
24728 + * allocations.
24729 + */
24730 + return arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
24731 +}
24732 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
24733 index 48f8375..ace2781 100644
24734 --- a/arch/x86/kernel/sys_x86_64.c
24735 +++ b/arch/x86/kernel/sys_x86_64.c
24736 @@ -81,8 +81,8 @@ out:
24737 return error;
24738 }
24739
24740 -static void find_start_end(unsigned long flags, unsigned long *begin,
24741 - unsigned long *end)
24742 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
24743 + unsigned long *begin, unsigned long *end)
24744 {
24745 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
24746 unsigned long new_begin;
24747 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
24748 *begin = new_begin;
24749 }
24750 } else {
24751 - *begin = mmap_legacy_base();
24752 + *begin = mm->mmap_base;
24753 *end = TASK_SIZE;
24754 }
24755 }
24756 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
24757 struct vm_area_struct *vma;
24758 struct vm_unmapped_area_info info;
24759 unsigned long begin, end;
24760 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
24761
24762 if (flags & MAP_FIXED)
24763 return addr;
24764
24765 - find_start_end(flags, &begin, &end);
24766 + find_start_end(mm, flags, &begin, &end);
24767
24768 if (len > end)
24769 return -ENOMEM;
24770
24771 +#ifdef CONFIG_PAX_RANDMMAP
24772 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
24773 +#endif
24774 +
24775 if (addr) {
24776 addr = PAGE_ALIGN(addr);
24777 vma = find_vma(mm, addr);
24778 - if (end - len >= addr &&
24779 - (!vma || addr + len <= vma->vm_start))
24780 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
24781 return addr;
24782 }
24783
24784 @@ -137,6 +141,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
24785 info.high_limit = end;
24786 info.align_mask = filp ? get_align_mask() : 0;
24787 info.align_offset = pgoff << PAGE_SHIFT;
24788 + info.threadstack_offset = offset;
24789 return vm_unmapped_area(&info);
24790 }
24791
24792 @@ -149,6 +154,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
24793 struct mm_struct *mm = current->mm;
24794 unsigned long addr = addr0;
24795 struct vm_unmapped_area_info info;
24796 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
24797
24798 /* requested length too big for entire address space */
24799 if (len > TASK_SIZE)
24800 @@ -161,12 +167,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
24801 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
24802 goto bottomup;
24803
24804 +#ifdef CONFIG_PAX_RANDMMAP
24805 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
24806 +#endif
24807 +
24808 /* requesting a specific address */
24809 if (addr) {
24810 addr = PAGE_ALIGN(addr);
24811 vma = find_vma(mm, addr);
24812 - if (TASK_SIZE - len >= addr &&
24813 - (!vma || addr + len <= vma->vm_start))
24814 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
24815 return addr;
24816 }
24817
24818 @@ -176,6 +185,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
24819 info.high_limit = mm->mmap_base;
24820 info.align_mask = filp ? get_align_mask() : 0;
24821 info.align_offset = pgoff << PAGE_SHIFT;
24822 + info.threadstack_offset = offset;
24823 addr = vm_unmapped_area(&info);
24824 if (!(addr & ~PAGE_MASK))
24825 return addr;
24826 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
24827 index f84fe00..f41d9f1 100644
24828 --- a/arch/x86/kernel/tboot.c
24829 +++ b/arch/x86/kernel/tboot.c
24830 @@ -220,7 +220,7 @@ static int tboot_setup_sleep(void)
24831
24832 void tboot_shutdown(u32 shutdown_type)
24833 {
24834 - void (*shutdown)(void);
24835 + void (* __noreturn shutdown)(void);
24836
24837 if (!tboot_enabled())
24838 return;
24839 @@ -242,7 +242,7 @@ void tboot_shutdown(u32 shutdown_type)
24840
24841 switch_to_tboot_pt();
24842
24843 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
24844 + shutdown = (void *)tboot->shutdown_entry;
24845 shutdown();
24846
24847 /* should not reach here */
24848 @@ -300,7 +300,7 @@ static int tboot_sleep(u8 sleep_state, u32 pm1a_control, u32 pm1b_control)
24849 return 0;
24850 }
24851
24852 -static atomic_t ap_wfs_count;
24853 +static atomic_unchecked_t ap_wfs_count;
24854
24855 static int tboot_wait_for_aps(int num_aps)
24856 {
24857 @@ -324,16 +324,16 @@ static int __cpuinit tboot_cpu_callback(struct notifier_block *nfb,
24858 {
24859 switch (action) {
24860 case CPU_DYING:
24861 - atomic_inc(&ap_wfs_count);
24862 + atomic_inc_unchecked(&ap_wfs_count);
24863 if (num_online_cpus() == 1)
24864 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
24865 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
24866 return NOTIFY_BAD;
24867 break;
24868 }
24869 return NOTIFY_OK;
24870 }
24871
24872 -static struct notifier_block tboot_cpu_notifier __cpuinitdata =
24873 +static struct notifier_block tboot_cpu_notifier =
24874 {
24875 .notifier_call = tboot_cpu_callback,
24876 };
24877 @@ -345,7 +345,7 @@ static __init int tboot_late_init(void)
24878
24879 tboot_create_trampoline();
24880
24881 - atomic_set(&ap_wfs_count, 0);
24882 + atomic_set_unchecked(&ap_wfs_count, 0);
24883 register_hotcpu_notifier(&tboot_cpu_notifier);
24884
24885 acpi_os_set_prepare_sleep(&tboot_sleep);
24886 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
24887 index 24d3c91..d06b473 100644
24888 --- a/arch/x86/kernel/time.c
24889 +++ b/arch/x86/kernel/time.c
24890 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
24891 {
24892 unsigned long pc = instruction_pointer(regs);
24893
24894 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
24895 + if (!user_mode(regs) && in_lock_functions(pc)) {
24896 #ifdef CONFIG_FRAME_POINTER
24897 - return *(unsigned long *)(regs->bp + sizeof(long));
24898 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
24899 #else
24900 unsigned long *sp =
24901 (unsigned long *)kernel_stack_pointer(regs);
24902 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
24903 * or above a saved flags. Eflags has bits 22-31 zero,
24904 * kernel addresses don't.
24905 */
24906 +
24907 +#ifdef CONFIG_PAX_KERNEXEC
24908 + return ktla_ktva(sp[0]);
24909 +#else
24910 if (sp[0] >> 22)
24911 return sp[0];
24912 if (sp[1] >> 22)
24913 return sp[1];
24914 #endif
24915 +
24916 +#endif
24917 }
24918 return pc;
24919 }
24920 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
24921 index f7fec09..9991981 100644
24922 --- a/arch/x86/kernel/tls.c
24923 +++ b/arch/x86/kernel/tls.c
24924 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
24925 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
24926 return -EINVAL;
24927
24928 +#ifdef CONFIG_PAX_SEGMEXEC
24929 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
24930 + return -EINVAL;
24931 +#endif
24932 +
24933 set_tls_desc(p, idx, &info, 1);
24934
24935 return 0;
24936 @@ -200,7 +205,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
24937
24938 if (kbuf)
24939 info = kbuf;
24940 - else if (__copy_from_user(infobuf, ubuf, count))
24941 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
24942 return -EFAULT;
24943 else
24944 info = infobuf;
24945 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
24946 index 772e2a8..bad5bf6 100644
24947 --- a/arch/x86/kernel/traps.c
24948 +++ b/arch/x86/kernel/traps.c
24949 @@ -68,12 +68,6 @@
24950 #include <asm/setup.h>
24951
24952 asmlinkage int system_call(void);
24953 -
24954 -/*
24955 - * The IDT has to be page-aligned to simplify the Pentium
24956 - * F0 0F bug workaround.
24957 - */
24958 -gate_desc idt_table[NR_VECTORS] __page_aligned_data = { { { { 0, 0 } } }, };
24959 #endif
24960
24961 DECLARE_BITMAP(used_vectors, NR_VECTORS);
24962 @@ -106,11 +100,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
24963 }
24964
24965 static int __kprobes
24966 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
24967 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
24968 struct pt_regs *regs, long error_code)
24969 {
24970 #ifdef CONFIG_X86_32
24971 - if (regs->flags & X86_VM_MASK) {
24972 + if (v8086_mode(regs)) {
24973 /*
24974 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
24975 * On nmi (interrupt 2), do_trap should not be called.
24976 @@ -123,12 +117,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
24977 return -1;
24978 }
24979 #endif
24980 - if (!user_mode(regs)) {
24981 + if (!user_mode_novm(regs)) {
24982 if (!fixup_exception(regs)) {
24983 tsk->thread.error_code = error_code;
24984 tsk->thread.trap_nr = trapnr;
24985 +
24986 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
24987 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
24988 + str = "PAX: suspicious stack segment fault";
24989 +#endif
24990 +
24991 die(str, regs, error_code);
24992 }
24993 +
24994 +#ifdef CONFIG_PAX_REFCOUNT
24995 + if (trapnr == 4)
24996 + pax_report_refcount_overflow(regs);
24997 +#endif
24998 +
24999 return 0;
25000 }
25001
25002 @@ -136,7 +142,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
25003 }
25004
25005 static void __kprobes
25006 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
25007 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
25008 long error_code, siginfo_t *info)
25009 {
25010 struct task_struct *tsk = current;
25011 @@ -160,7 +166,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
25012 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
25013 printk_ratelimit()) {
25014 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
25015 - tsk->comm, tsk->pid, str,
25016 + tsk->comm, task_pid_nr(tsk), str,
25017 regs->ip, regs->sp, error_code);
25018 print_vma_addr(" in ", regs->ip);
25019 pr_cont("\n");
25020 @@ -273,7 +279,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
25021 conditional_sti(regs);
25022
25023 #ifdef CONFIG_X86_32
25024 - if (regs->flags & X86_VM_MASK) {
25025 + if (v8086_mode(regs)) {
25026 local_irq_enable();
25027 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
25028 goto exit;
25029 @@ -281,18 +287,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
25030 #endif
25031
25032 tsk = current;
25033 - if (!user_mode(regs)) {
25034 + if (!user_mode_novm(regs)) {
25035 if (fixup_exception(regs))
25036 goto exit;
25037
25038 tsk->thread.error_code = error_code;
25039 tsk->thread.trap_nr = X86_TRAP_GP;
25040 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
25041 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
25042 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
25043 +
25044 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25045 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
25046 + die("PAX: suspicious general protection fault", regs, error_code);
25047 + else
25048 +#endif
25049 +
25050 die("general protection fault", regs, error_code);
25051 + }
25052 goto exit;
25053 }
25054
25055 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
25056 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
25057 + struct mm_struct *mm = tsk->mm;
25058 + unsigned long limit;
25059 +
25060 + down_write(&mm->mmap_sem);
25061 + limit = mm->context.user_cs_limit;
25062 + if (limit < TASK_SIZE) {
25063 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
25064 + up_write(&mm->mmap_sem);
25065 + return;
25066 + }
25067 + up_write(&mm->mmap_sem);
25068 + }
25069 +#endif
25070 +
25071 tsk->thread.error_code = error_code;
25072 tsk->thread.trap_nr = X86_TRAP_GP;
25073
25074 @@ -450,7 +480,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
25075 /* It's safe to allow irq's after DR6 has been saved */
25076 preempt_conditional_sti(regs);
25077
25078 - if (regs->flags & X86_VM_MASK) {
25079 + if (v8086_mode(regs)) {
25080 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
25081 X86_TRAP_DB);
25082 preempt_conditional_cli(regs);
25083 @@ -465,7 +495,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
25084 * We already checked v86 mode above, so we can check for kernel mode
25085 * by just checking the CPL of CS.
25086 */
25087 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
25088 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
25089 tsk->thread.debugreg6 &= ~DR_STEP;
25090 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
25091 regs->flags &= ~X86_EFLAGS_TF;
25092 @@ -497,7 +527,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
25093 return;
25094 conditional_sti(regs);
25095
25096 - if (!user_mode_vm(regs))
25097 + if (!user_mode(regs))
25098 {
25099 if (!fixup_exception(regs)) {
25100 task->thread.error_code = error_code;
25101 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
25102 index 2ed8459..7cf329f 100644
25103 --- a/arch/x86/kernel/uprobes.c
25104 +++ b/arch/x86/kernel/uprobes.c
25105 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
25106 int ret = NOTIFY_DONE;
25107
25108 /* We are only interested in userspace traps */
25109 - if (regs && !user_mode_vm(regs))
25110 + if (regs && !user_mode(regs))
25111 return NOTIFY_DONE;
25112
25113 switch (val) {
25114 @@ -719,7 +719,7 @@ arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, struct pt_regs
25115
25116 if (ncopied != rasize) {
25117 pr_err("uprobe: return address clobbered: pid=%d, %%sp=%#lx, "
25118 - "%%ip=%#lx\n", current->pid, regs->sp, regs->ip);
25119 + "%%ip=%#lx\n", task_pid_nr(current), regs->sp, regs->ip);
25120
25121 force_sig_info(SIGSEGV, SEND_SIG_FORCED, current);
25122 }
25123 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
25124 index b9242ba..50c5edd 100644
25125 --- a/arch/x86/kernel/verify_cpu.S
25126 +++ b/arch/x86/kernel/verify_cpu.S
25127 @@ -20,6 +20,7 @@
25128 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
25129 * arch/x86/kernel/trampoline_64.S: secondary processor verification
25130 * arch/x86/kernel/head_32.S: processor startup
25131 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
25132 *
25133 * verify_cpu, returns the status of longmode and SSE in register %eax.
25134 * 0: Success 1: Failure
25135 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
25136 index e8edcf5..27f9344 100644
25137 --- a/arch/x86/kernel/vm86_32.c
25138 +++ b/arch/x86/kernel/vm86_32.c
25139 @@ -44,6 +44,7 @@
25140 #include <linux/ptrace.h>
25141 #include <linux/audit.h>
25142 #include <linux/stddef.h>
25143 +#include <linux/grsecurity.h>
25144
25145 #include <asm/uaccess.h>
25146 #include <asm/io.h>
25147 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
25148 do_exit(SIGSEGV);
25149 }
25150
25151 - tss = &per_cpu(init_tss, get_cpu());
25152 + tss = init_tss + get_cpu();
25153 current->thread.sp0 = current->thread.saved_sp0;
25154 current->thread.sysenter_cs = __KERNEL_CS;
25155 load_sp0(tss, &current->thread);
25156 @@ -214,6 +215,14 @@ SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
25157
25158 if (tsk->thread.saved_sp0)
25159 return -EPERM;
25160 +
25161 +#ifdef CONFIG_GRKERNSEC_VM86
25162 + if (!capable(CAP_SYS_RAWIO)) {
25163 + gr_handle_vm86();
25164 + return -EPERM;
25165 + }
25166 +#endif
25167 +
25168 tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
25169 offsetof(struct kernel_vm86_struct, vm86plus) -
25170 sizeof(info.regs));
25171 @@ -238,6 +247,13 @@ SYSCALL_DEFINE2(vm86, unsigned long, cmd, unsigned long, arg)
25172 int tmp;
25173 struct vm86plus_struct __user *v86;
25174
25175 +#ifdef CONFIG_GRKERNSEC_VM86
25176 + if (!capable(CAP_SYS_RAWIO)) {
25177 + gr_handle_vm86();
25178 + return -EPERM;
25179 + }
25180 +#endif
25181 +
25182 tsk = current;
25183 switch (cmd) {
25184 case VM86_REQUEST_IRQ:
25185 @@ -318,7 +334,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
25186 tsk->thread.saved_fs = info->regs32->fs;
25187 tsk->thread.saved_gs = get_user_gs(info->regs32);
25188
25189 - tss = &per_cpu(init_tss, get_cpu());
25190 + tss = init_tss + get_cpu();
25191 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
25192 if (cpu_has_sep)
25193 tsk->thread.sysenter_cs = 0;
25194 @@ -525,7 +541,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
25195 goto cannot_handle;
25196 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
25197 goto cannot_handle;
25198 - intr_ptr = (unsigned long __user *) (i << 2);
25199 + intr_ptr = (__force unsigned long __user *) (i << 2);
25200 if (get_user(segoffs, intr_ptr))
25201 goto cannot_handle;
25202 if ((segoffs >> 16) == BIOSSEG)
25203 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
25204 index 10c4f30..57377c2 100644
25205 --- a/arch/x86/kernel/vmlinux.lds.S
25206 +++ b/arch/x86/kernel/vmlinux.lds.S
25207 @@ -26,6 +26,13 @@
25208 #include <asm/page_types.h>
25209 #include <asm/cache.h>
25210 #include <asm/boot.h>
25211 +#include <asm/segment.h>
25212 +
25213 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25214 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
25215 +#else
25216 +#define __KERNEL_TEXT_OFFSET 0
25217 +#endif
25218
25219 #undef i386 /* in case the preprocessor is a 32bit one */
25220
25221 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
25222
25223 PHDRS {
25224 text PT_LOAD FLAGS(5); /* R_E */
25225 +#ifdef CONFIG_X86_32
25226 + module PT_LOAD FLAGS(5); /* R_E */
25227 +#endif
25228 +#ifdef CONFIG_XEN
25229 + rodata PT_LOAD FLAGS(5); /* R_E */
25230 +#else
25231 + rodata PT_LOAD FLAGS(4); /* R__ */
25232 +#endif
25233 data PT_LOAD FLAGS(6); /* RW_ */
25234 -#ifdef CONFIG_X86_64
25235 + init.begin PT_LOAD FLAGS(6); /* RW_ */
25236 #ifdef CONFIG_SMP
25237 percpu PT_LOAD FLAGS(6); /* RW_ */
25238 #endif
25239 + text.init PT_LOAD FLAGS(5); /* R_E */
25240 + text.exit PT_LOAD FLAGS(5); /* R_E */
25241 init PT_LOAD FLAGS(7); /* RWE */
25242 -#endif
25243 note PT_NOTE FLAGS(0); /* ___ */
25244 }
25245
25246 SECTIONS
25247 {
25248 #ifdef CONFIG_X86_32
25249 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
25250 - phys_startup_32 = startup_32 - LOAD_OFFSET;
25251 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
25252 #else
25253 - . = __START_KERNEL;
25254 - phys_startup_64 = startup_64 - LOAD_OFFSET;
25255 + . = __START_KERNEL;
25256 #endif
25257
25258 /* Text and read-only data */
25259 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
25260 - _text = .;
25261 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
25262 /* bootstrapping code */
25263 +#ifdef CONFIG_X86_32
25264 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
25265 +#else
25266 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
25267 +#endif
25268 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
25269 + _text = .;
25270 HEAD_TEXT
25271 . = ALIGN(8);
25272 _stext = .;
25273 @@ -104,13 +124,48 @@ SECTIONS
25274 IRQENTRY_TEXT
25275 *(.fixup)
25276 *(.gnu.warning)
25277 - /* End of text section */
25278 - _etext = .;
25279 } :text = 0x9090
25280
25281 - NOTES :text :note
25282 + . += __KERNEL_TEXT_OFFSET;
25283
25284 - EXCEPTION_TABLE(16) :text = 0x9090
25285 +#ifdef CONFIG_X86_32
25286 + . = ALIGN(PAGE_SIZE);
25287 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
25288 +
25289 +#ifdef CONFIG_PAX_KERNEXEC
25290 + MODULES_EXEC_VADDR = .;
25291 + BYTE(0)
25292 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
25293 + . = ALIGN(HPAGE_SIZE) - 1;
25294 + MODULES_EXEC_END = .;
25295 +#endif
25296 +
25297 + } :module
25298 +#endif
25299 +
25300 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
25301 + /* End of text section */
25302 + BYTE(0)
25303 + _etext = . - __KERNEL_TEXT_OFFSET;
25304 + }
25305 +
25306 +#ifdef CONFIG_X86_32
25307 + . = ALIGN(PAGE_SIZE);
25308 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
25309 + *(.idt)
25310 + . = ALIGN(PAGE_SIZE);
25311 + *(.empty_zero_page)
25312 + *(.initial_pg_fixmap)
25313 + *(.initial_pg_pmd)
25314 + *(.initial_page_table)
25315 + *(.swapper_pg_dir)
25316 + } :rodata
25317 +#endif
25318 +
25319 + . = ALIGN(PAGE_SIZE);
25320 + NOTES :rodata :note
25321 +
25322 + EXCEPTION_TABLE(16) :rodata
25323
25324 #if defined(CONFIG_DEBUG_RODATA)
25325 /* .text should occupy whole number of pages */
25326 @@ -122,16 +177,20 @@ SECTIONS
25327
25328 /* Data */
25329 .data : AT(ADDR(.data) - LOAD_OFFSET) {
25330 +
25331 +#ifdef CONFIG_PAX_KERNEXEC
25332 + . = ALIGN(HPAGE_SIZE);
25333 +#else
25334 + . = ALIGN(PAGE_SIZE);
25335 +#endif
25336 +
25337 /* Start of data section */
25338 _sdata = .;
25339
25340 /* init_task */
25341 INIT_TASK_DATA(THREAD_SIZE)
25342
25343 -#ifdef CONFIG_X86_32
25344 - /* 32 bit has nosave before _edata */
25345 NOSAVE_DATA
25346 -#endif
25347
25348 PAGE_ALIGNED_DATA(PAGE_SIZE)
25349
25350 @@ -172,12 +231,19 @@ SECTIONS
25351 #endif /* CONFIG_X86_64 */
25352
25353 /* Init code and data - will be freed after init */
25354 - . = ALIGN(PAGE_SIZE);
25355 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
25356 + BYTE(0)
25357 +
25358 +#ifdef CONFIG_PAX_KERNEXEC
25359 + . = ALIGN(HPAGE_SIZE);
25360 +#else
25361 + . = ALIGN(PAGE_SIZE);
25362 +#endif
25363 +
25364 __init_begin = .; /* paired with __init_end */
25365 - }
25366 + } :init.begin
25367
25368 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
25369 +#ifdef CONFIG_SMP
25370 /*
25371 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
25372 * output PHDR, so the next output section - .init.text - should
25373 @@ -186,12 +252,27 @@ SECTIONS
25374 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
25375 #endif
25376
25377 - INIT_TEXT_SECTION(PAGE_SIZE)
25378 -#ifdef CONFIG_X86_64
25379 - :init
25380 -#endif
25381 + . = ALIGN(PAGE_SIZE);
25382 + init_begin = .;
25383 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
25384 + VMLINUX_SYMBOL(_sinittext) = .;
25385 + INIT_TEXT
25386 + VMLINUX_SYMBOL(_einittext) = .;
25387 + . = ALIGN(PAGE_SIZE);
25388 + } :text.init
25389
25390 - INIT_DATA_SECTION(16)
25391 + /*
25392 + * .exit.text is discard at runtime, not link time, to deal with
25393 + * references from .altinstructions and .eh_frame
25394 + */
25395 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
25396 + EXIT_TEXT
25397 + . = ALIGN(16);
25398 + } :text.exit
25399 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
25400 +
25401 + . = ALIGN(PAGE_SIZE);
25402 + INIT_DATA_SECTION(16) :init
25403
25404 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
25405 __x86_cpu_dev_start = .;
25406 @@ -253,19 +334,12 @@ SECTIONS
25407 }
25408
25409 . = ALIGN(8);
25410 - /*
25411 - * .exit.text is discard at runtime, not link time, to deal with
25412 - * references from .altinstructions and .eh_frame
25413 - */
25414 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
25415 - EXIT_TEXT
25416 - }
25417
25418 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
25419 EXIT_DATA
25420 }
25421
25422 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
25423 +#ifndef CONFIG_SMP
25424 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
25425 #endif
25426
25427 @@ -284,16 +358,10 @@ SECTIONS
25428 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
25429 __smp_locks = .;
25430 *(.smp_locks)
25431 - . = ALIGN(PAGE_SIZE);
25432 __smp_locks_end = .;
25433 + . = ALIGN(PAGE_SIZE);
25434 }
25435
25436 -#ifdef CONFIG_X86_64
25437 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
25438 - NOSAVE_DATA
25439 - }
25440 -#endif
25441 -
25442 /* BSS */
25443 . = ALIGN(PAGE_SIZE);
25444 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
25445 @@ -309,6 +377,7 @@ SECTIONS
25446 __brk_base = .;
25447 . += 64 * 1024; /* 64k alignment slop space */
25448 *(.brk_reservation) /* areas brk users have reserved */
25449 + . = ALIGN(HPAGE_SIZE);
25450 __brk_limit = .;
25451 }
25452
25453 @@ -335,13 +404,12 @@ SECTIONS
25454 * for the boot processor.
25455 */
25456 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
25457 -INIT_PER_CPU(gdt_page);
25458 INIT_PER_CPU(irq_stack_union);
25459
25460 /*
25461 * Build-time check on the image size:
25462 */
25463 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
25464 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
25465 "kernel image bigger than KERNEL_IMAGE_SIZE");
25466
25467 #ifdef CONFIG_SMP
25468 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
25469 index 9a907a6..f83f921 100644
25470 --- a/arch/x86/kernel/vsyscall_64.c
25471 +++ b/arch/x86/kernel/vsyscall_64.c
25472 @@ -56,15 +56,13 @@
25473 DEFINE_VVAR(int, vgetcpu_mode);
25474 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
25475
25476 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
25477 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
25478
25479 static int __init vsyscall_setup(char *str)
25480 {
25481 if (str) {
25482 if (!strcmp("emulate", str))
25483 vsyscall_mode = EMULATE;
25484 - else if (!strcmp("native", str))
25485 - vsyscall_mode = NATIVE;
25486 else if (!strcmp("none", str))
25487 vsyscall_mode = NONE;
25488 else
25489 @@ -323,8 +321,7 @@ do_ret:
25490 return true;
25491
25492 sigsegv:
25493 - force_sig(SIGSEGV, current);
25494 - return true;
25495 + do_group_exit(SIGKILL);
25496 }
25497
25498 /*
25499 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
25500 extern char __vvar_page;
25501 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
25502
25503 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
25504 - vsyscall_mode == NATIVE
25505 - ? PAGE_KERNEL_VSYSCALL
25506 - : PAGE_KERNEL_VVAR);
25507 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
25508 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
25509 (unsigned long)VSYSCALL_START);
25510
25511 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
25512 index b014d94..6d6ca7b 100644
25513 --- a/arch/x86/kernel/x8664_ksyms_64.c
25514 +++ b/arch/x86/kernel/x8664_ksyms_64.c
25515 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
25516 EXPORT_SYMBOL(copy_user_generic_unrolled);
25517 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
25518 EXPORT_SYMBOL(__copy_user_nocache);
25519 -EXPORT_SYMBOL(_copy_from_user);
25520 -EXPORT_SYMBOL(_copy_to_user);
25521
25522 EXPORT_SYMBOL(copy_page);
25523 EXPORT_SYMBOL(clear_page);
25524 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
25525 index 45a14db..075bb9b 100644
25526 --- a/arch/x86/kernel/x86_init.c
25527 +++ b/arch/x86/kernel/x86_init.c
25528 @@ -85,7 +85,7 @@ struct x86_init_ops x86_init __initdata = {
25529 },
25530 };
25531
25532 -struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
25533 +struct x86_cpuinit_ops x86_cpuinit __cpuinitconst = {
25534 .early_percpu_clock_init = x86_init_noop,
25535 .setup_percpu_clockev = setup_secondary_APIC_clock,
25536 };
25537 @@ -93,7 +93,7 @@ struct x86_cpuinit_ops x86_cpuinit __cpuinitdata = {
25538 static void default_nmi_init(void) { };
25539 static int default_i8042_detect(void) { return 1; };
25540
25541 -struct x86_platform_ops x86_platform = {
25542 +struct x86_platform_ops x86_platform __read_only = {
25543 .calibrate_tsc = native_calibrate_tsc,
25544 .get_wallclock = mach_get_cmos_time,
25545 .set_wallclock = mach_set_rtc_mmss,
25546 @@ -107,7 +107,7 @@ struct x86_platform_ops x86_platform = {
25547 };
25548
25549 EXPORT_SYMBOL_GPL(x86_platform);
25550 -struct x86_msi_ops x86_msi = {
25551 +struct x86_msi_ops x86_msi __read_only = {
25552 .setup_msi_irqs = native_setup_msi_irqs,
25553 .compose_msi_msg = native_compose_msi_msg,
25554 .teardown_msi_irq = native_teardown_msi_irq,
25555 @@ -116,7 +116,7 @@ struct x86_msi_ops x86_msi = {
25556 .setup_hpet_msi = default_setup_hpet_msi,
25557 };
25558
25559 -struct x86_io_apic_ops x86_io_apic_ops = {
25560 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
25561 .init = native_io_apic_init_mappings,
25562 .read = native_io_apic_read,
25563 .write = native_io_apic_write,
25564 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
25565 index ada87a3..afea76d 100644
25566 --- a/arch/x86/kernel/xsave.c
25567 +++ b/arch/x86/kernel/xsave.c
25568 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
25569 {
25570 int err;
25571
25572 + buf = (struct xsave_struct __user *)____m(buf);
25573 if (use_xsave())
25574 err = xsave_user(buf);
25575 else if (use_fxsr())
25576 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
25577 */
25578 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
25579 {
25580 + buf = (void __user *)____m(buf);
25581 if (use_xsave()) {
25582 if ((unsigned long)buf % 64 || fx_only) {
25583 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
25584 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
25585 index a20ecb5..d0e2194 100644
25586 --- a/arch/x86/kvm/cpuid.c
25587 +++ b/arch/x86/kvm/cpuid.c
25588 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
25589 struct kvm_cpuid2 *cpuid,
25590 struct kvm_cpuid_entry2 __user *entries)
25591 {
25592 - int r;
25593 + int r, i;
25594
25595 r = -E2BIG;
25596 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
25597 goto out;
25598 r = -EFAULT;
25599 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
25600 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
25601 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
25602 goto out;
25603 + for (i = 0; i < cpuid->nent; ++i) {
25604 + struct kvm_cpuid_entry2 cpuid_entry;
25605 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
25606 + goto out;
25607 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
25608 + }
25609 vcpu->arch.cpuid_nent = cpuid->nent;
25610 kvm_apic_set_version(vcpu);
25611 kvm_x86_ops->cpuid_update(vcpu);
25612 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
25613 struct kvm_cpuid2 *cpuid,
25614 struct kvm_cpuid_entry2 __user *entries)
25615 {
25616 - int r;
25617 + int r, i;
25618
25619 r = -E2BIG;
25620 if (cpuid->nent < vcpu->arch.cpuid_nent)
25621 goto out;
25622 r = -EFAULT;
25623 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
25624 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
25625 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
25626 goto out;
25627 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
25628 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
25629 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
25630 + goto out;
25631 + }
25632 return 0;
25633
25634 out:
25635 diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c
25636 index 5953dce..f11a7d2 100644
25637 --- a/arch/x86/kvm/emulate.c
25638 +++ b/arch/x86/kvm/emulate.c
25639 @@ -329,6 +329,7 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
25640
25641 #define ____emulate_2op(ctxt, _op, _x, _y, _suffix, _dsttype) \
25642 do { \
25643 + unsigned long _tmp; \
25644 __asm__ __volatile__ ( \
25645 _PRE_EFLAGS("0", "4", "2") \
25646 _op _suffix " %"_x"3,%1; " \
25647 @@ -343,8 +344,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
25648 /* Raw emulation: instruction has two explicit operands. */
25649 #define __emulate_2op_nobyte(ctxt,_op,_wx,_wy,_lx,_ly,_qx,_qy) \
25650 do { \
25651 - unsigned long _tmp; \
25652 - \
25653 switch ((ctxt)->dst.bytes) { \
25654 case 2: \
25655 ____emulate_2op(ctxt,_op,_wx,_wy,"w",u16); \
25656 @@ -360,7 +359,6 @@ static void invalidate_registers(struct x86_emulate_ctxt *ctxt)
25657
25658 #define __emulate_2op(ctxt,_op,_bx,_by,_wx,_wy,_lx,_ly,_qx,_qy) \
25659 do { \
25660 - unsigned long _tmp; \
25661 switch ((ctxt)->dst.bytes) { \
25662 case 1: \
25663 ____emulate_2op(ctxt,_op,_bx,_by,"b",u8); \
25664 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
25665 index 0eee2c8..94a32c3 100644
25666 --- a/arch/x86/kvm/lapic.c
25667 +++ b/arch/x86/kvm/lapic.c
25668 @@ -55,7 +55,7 @@
25669 #define APIC_BUS_CYCLE_NS 1
25670
25671 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
25672 -#define apic_debug(fmt, arg...)
25673 +#define apic_debug(fmt, arg...) do {} while (0)
25674
25675 #define APIC_LVT_NUM 6
25676 /* 14 is the version for Xeon and Pentium 8.4.8*/
25677 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
25678 index da20860..d19fdf5 100644
25679 --- a/arch/x86/kvm/paging_tmpl.h
25680 +++ b/arch/x86/kvm/paging_tmpl.h
25681 @@ -208,7 +208,7 @@ retry_walk:
25682 if (unlikely(kvm_is_error_hva(host_addr)))
25683 goto error;
25684
25685 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
25686 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
25687 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
25688 goto error;
25689 walker->ptep_user[walker->level - 1] = ptep_user;
25690 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
25691 index a14a6ea..dc86cf0 100644
25692 --- a/arch/x86/kvm/svm.c
25693 +++ b/arch/x86/kvm/svm.c
25694 @@ -3493,7 +3493,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
25695 int cpu = raw_smp_processor_id();
25696
25697 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
25698 +
25699 + pax_open_kernel();
25700 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
25701 + pax_close_kernel();
25702 +
25703 load_TR_desc();
25704 }
25705
25706 @@ -3894,6 +3898,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
25707 #endif
25708 #endif
25709
25710 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
25711 + __set_fs(current_thread_info()->addr_limit);
25712 +#endif
25713 +
25714 reload_tss(vcpu);
25715
25716 local_irq_disable();
25717 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
25718 index 5402c94..c3bdeee 100644
25719 --- a/arch/x86/kvm/vmx.c
25720 +++ b/arch/x86/kvm/vmx.c
25721 @@ -1311,12 +1311,12 @@ static void vmcs_write64(unsigned long field, u64 value)
25722 #endif
25723 }
25724
25725 -static void vmcs_clear_bits(unsigned long field, u32 mask)
25726 +static void vmcs_clear_bits(unsigned long field, unsigned long mask)
25727 {
25728 vmcs_writel(field, vmcs_readl(field) & ~mask);
25729 }
25730
25731 -static void vmcs_set_bits(unsigned long field, u32 mask)
25732 +static void vmcs_set_bits(unsigned long field, unsigned long mask)
25733 {
25734 vmcs_writel(field, vmcs_readl(field) | mask);
25735 }
25736 @@ -1517,7 +1517,11 @@ static void reload_tss(void)
25737 struct desc_struct *descs;
25738
25739 descs = (void *)gdt->address;
25740 +
25741 + pax_open_kernel();
25742 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
25743 + pax_close_kernel();
25744 +
25745 load_TR_desc();
25746 }
25747
25748 @@ -1741,6 +1745,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
25749 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
25750 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
25751
25752 +#ifdef CONFIG_PAX_PER_CPU_PGD
25753 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
25754 +#endif
25755 +
25756 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
25757 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
25758 vmx->loaded_vmcs->cpu = cpu;
25759 @@ -2935,8 +2943,11 @@ static __init int hardware_setup(void)
25760 if (!cpu_has_vmx_flexpriority())
25761 flexpriority_enabled = 0;
25762
25763 - if (!cpu_has_vmx_tpr_shadow())
25764 - kvm_x86_ops->update_cr8_intercept = NULL;
25765 + if (!cpu_has_vmx_tpr_shadow()) {
25766 + pax_open_kernel();
25767 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
25768 + pax_close_kernel();
25769 + }
25770
25771 if (enable_ept && !cpu_has_vmx_ept_2m_page())
25772 kvm_disable_largepages();
25773 @@ -2947,13 +2958,15 @@ static __init int hardware_setup(void)
25774 if (!cpu_has_vmx_apicv())
25775 enable_apicv = 0;
25776
25777 + pax_open_kernel();
25778 if (enable_apicv)
25779 - kvm_x86_ops->update_cr8_intercept = NULL;
25780 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
25781 else {
25782 - kvm_x86_ops->hwapic_irr_update = NULL;
25783 - kvm_x86_ops->deliver_posted_interrupt = NULL;
25784 - kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
25785 + *(void **)&kvm_x86_ops->hwapic_irr_update = NULL;
25786 + *(void **)&kvm_x86_ops->deliver_posted_interrupt = NULL;
25787 + *(void **)&kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
25788 }
25789 + pax_close_kernel();
25790
25791 if (nested)
25792 nested_vmx_setup_ctls_msrs();
25793 @@ -4076,7 +4089,10 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
25794
25795 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
25796 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
25797 +
25798 +#ifndef CONFIG_PAX_PER_CPU_PGD
25799 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
25800 +#endif
25801
25802 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
25803 #ifdef CONFIG_X86_64
25804 @@ -4098,7 +4114,7 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
25805 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
25806 vmx->host_idt_base = dt.address;
25807
25808 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
25809 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
25810
25811 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
25812 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
25813 @@ -7030,6 +7046,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
25814 "jmp 2f \n\t"
25815 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
25816 "2: "
25817 +
25818 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25819 + "ljmp %[cs],$3f\n\t"
25820 + "3: "
25821 +#endif
25822 +
25823 /* Save guest registers, load host registers, keep flags */
25824 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
25825 "pop %0 \n\t"
25826 @@ -7082,6 +7104,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
25827 #endif
25828 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
25829 [wordsize]"i"(sizeof(ulong))
25830 +
25831 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25832 + ,[cs]"i"(__KERNEL_CS)
25833 +#endif
25834 +
25835 : "cc", "memory"
25836 #ifdef CONFIG_X86_64
25837 , "rax", "rbx", "rdi", "rsi"
25838 @@ -7095,7 +7122,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
25839 if (debugctlmsr)
25840 update_debugctlmsr(debugctlmsr);
25841
25842 -#ifndef CONFIG_X86_64
25843 +#ifdef CONFIG_X86_32
25844 /*
25845 * The sysexit path does not restore ds/es, so we must set them to
25846 * a reasonable value ourselves.
25847 @@ -7104,8 +7131,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
25848 * may be executed in interrupt context, which saves and restore segments
25849 * around it, nullifying its effect.
25850 */
25851 - loadsegment(ds, __USER_DS);
25852 - loadsegment(es, __USER_DS);
25853 + loadsegment(ds, __KERNEL_DS);
25854 + loadsegment(es, __KERNEL_DS);
25855 + loadsegment(ss, __KERNEL_DS);
25856 +
25857 +#ifdef CONFIG_PAX_KERNEXEC
25858 + loadsegment(fs, __KERNEL_PERCPU);
25859 +#endif
25860 +
25861 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25862 + __set_fs(current_thread_info()->addr_limit);
25863 +#endif
25864 +
25865 #endif
25866
25867 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
25868 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
25869 index e8ba99c..ee9d7d9 100644
25870 --- a/arch/x86/kvm/x86.c
25871 +++ b/arch/x86/kvm/x86.c
25872 @@ -1725,8 +1725,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
25873 {
25874 struct kvm *kvm = vcpu->kvm;
25875 int lm = is_long_mode(vcpu);
25876 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
25877 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
25878 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
25879 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
25880 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
25881 : kvm->arch.xen_hvm_config.blob_size_32;
25882 u32 page_num = data & ~PAGE_MASK;
25883 @@ -2609,6 +2609,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
25884 if (n < msr_list.nmsrs)
25885 goto out;
25886 r = -EFAULT;
25887 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
25888 + goto out;
25889 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
25890 num_msrs_to_save * sizeof(u32)))
25891 goto out;
25892 @@ -5297,7 +5299,7 @@ static struct notifier_block pvclock_gtod_notifier = {
25893 };
25894 #endif
25895
25896 -int kvm_arch_init(void *opaque)
25897 +int kvm_arch_init(const void *opaque)
25898 {
25899 int r;
25900 struct kvm_x86_ops *ops = (struct kvm_x86_ops *)opaque;
25901 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
25902 index 7114c63..a1018fc 100644
25903 --- a/arch/x86/lguest/boot.c
25904 +++ b/arch/x86/lguest/boot.c
25905 @@ -1201,9 +1201,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
25906 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
25907 * Launcher to reboot us.
25908 */
25909 -static void lguest_restart(char *reason)
25910 +static __noreturn void lguest_restart(char *reason)
25911 {
25912 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
25913 + BUG();
25914 }
25915
25916 /*G:050
25917 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
25918 index 00933d5..3a64af9 100644
25919 --- a/arch/x86/lib/atomic64_386_32.S
25920 +++ b/arch/x86/lib/atomic64_386_32.S
25921 @@ -48,6 +48,10 @@ BEGIN(read)
25922 movl (v), %eax
25923 movl 4(v), %edx
25924 RET_ENDP
25925 +BEGIN(read_unchecked)
25926 + movl (v), %eax
25927 + movl 4(v), %edx
25928 +RET_ENDP
25929 #undef v
25930
25931 #define v %esi
25932 @@ -55,6 +59,10 @@ BEGIN(set)
25933 movl %ebx, (v)
25934 movl %ecx, 4(v)
25935 RET_ENDP
25936 +BEGIN(set_unchecked)
25937 + movl %ebx, (v)
25938 + movl %ecx, 4(v)
25939 +RET_ENDP
25940 #undef v
25941
25942 #define v %esi
25943 @@ -70,6 +78,20 @@ RET_ENDP
25944 BEGIN(add)
25945 addl %eax, (v)
25946 adcl %edx, 4(v)
25947 +
25948 +#ifdef CONFIG_PAX_REFCOUNT
25949 + jno 0f
25950 + subl %eax, (v)
25951 + sbbl %edx, 4(v)
25952 + int $4
25953 +0:
25954 + _ASM_EXTABLE(0b, 0b)
25955 +#endif
25956 +
25957 +RET_ENDP
25958 +BEGIN(add_unchecked)
25959 + addl %eax, (v)
25960 + adcl %edx, 4(v)
25961 RET_ENDP
25962 #undef v
25963
25964 @@ -77,6 +99,24 @@ RET_ENDP
25965 BEGIN(add_return)
25966 addl (v), %eax
25967 adcl 4(v), %edx
25968 +
25969 +#ifdef CONFIG_PAX_REFCOUNT
25970 + into
25971 +1234:
25972 + _ASM_EXTABLE(1234b, 2f)
25973 +#endif
25974 +
25975 + movl %eax, (v)
25976 + movl %edx, 4(v)
25977 +
25978 +#ifdef CONFIG_PAX_REFCOUNT
25979 +2:
25980 +#endif
25981 +
25982 +RET_ENDP
25983 +BEGIN(add_return_unchecked)
25984 + addl (v), %eax
25985 + adcl 4(v), %edx
25986 movl %eax, (v)
25987 movl %edx, 4(v)
25988 RET_ENDP
25989 @@ -86,6 +126,20 @@ RET_ENDP
25990 BEGIN(sub)
25991 subl %eax, (v)
25992 sbbl %edx, 4(v)
25993 +
25994 +#ifdef CONFIG_PAX_REFCOUNT
25995 + jno 0f
25996 + addl %eax, (v)
25997 + adcl %edx, 4(v)
25998 + int $4
25999 +0:
26000 + _ASM_EXTABLE(0b, 0b)
26001 +#endif
26002 +
26003 +RET_ENDP
26004 +BEGIN(sub_unchecked)
26005 + subl %eax, (v)
26006 + sbbl %edx, 4(v)
26007 RET_ENDP
26008 #undef v
26009
26010 @@ -96,6 +150,27 @@ BEGIN(sub_return)
26011 sbbl $0, %edx
26012 addl (v), %eax
26013 adcl 4(v), %edx
26014 +
26015 +#ifdef CONFIG_PAX_REFCOUNT
26016 + into
26017 +1234:
26018 + _ASM_EXTABLE(1234b, 2f)
26019 +#endif
26020 +
26021 + movl %eax, (v)
26022 + movl %edx, 4(v)
26023 +
26024 +#ifdef CONFIG_PAX_REFCOUNT
26025 +2:
26026 +#endif
26027 +
26028 +RET_ENDP
26029 +BEGIN(sub_return_unchecked)
26030 + negl %edx
26031 + negl %eax
26032 + sbbl $0, %edx
26033 + addl (v), %eax
26034 + adcl 4(v), %edx
26035 movl %eax, (v)
26036 movl %edx, 4(v)
26037 RET_ENDP
26038 @@ -105,6 +180,20 @@ RET_ENDP
26039 BEGIN(inc)
26040 addl $1, (v)
26041 adcl $0, 4(v)
26042 +
26043 +#ifdef CONFIG_PAX_REFCOUNT
26044 + jno 0f
26045 + subl $1, (v)
26046 + sbbl $0, 4(v)
26047 + int $4
26048 +0:
26049 + _ASM_EXTABLE(0b, 0b)
26050 +#endif
26051 +
26052 +RET_ENDP
26053 +BEGIN(inc_unchecked)
26054 + addl $1, (v)
26055 + adcl $0, 4(v)
26056 RET_ENDP
26057 #undef v
26058
26059 @@ -114,6 +203,26 @@ BEGIN(inc_return)
26060 movl 4(v), %edx
26061 addl $1, %eax
26062 adcl $0, %edx
26063 +
26064 +#ifdef CONFIG_PAX_REFCOUNT
26065 + into
26066 +1234:
26067 + _ASM_EXTABLE(1234b, 2f)
26068 +#endif
26069 +
26070 + movl %eax, (v)
26071 + movl %edx, 4(v)
26072 +
26073 +#ifdef CONFIG_PAX_REFCOUNT
26074 +2:
26075 +#endif
26076 +
26077 +RET_ENDP
26078 +BEGIN(inc_return_unchecked)
26079 + movl (v), %eax
26080 + movl 4(v), %edx
26081 + addl $1, %eax
26082 + adcl $0, %edx
26083 movl %eax, (v)
26084 movl %edx, 4(v)
26085 RET_ENDP
26086 @@ -123,6 +232,20 @@ RET_ENDP
26087 BEGIN(dec)
26088 subl $1, (v)
26089 sbbl $0, 4(v)
26090 +
26091 +#ifdef CONFIG_PAX_REFCOUNT
26092 + jno 0f
26093 + addl $1, (v)
26094 + adcl $0, 4(v)
26095 + int $4
26096 +0:
26097 + _ASM_EXTABLE(0b, 0b)
26098 +#endif
26099 +
26100 +RET_ENDP
26101 +BEGIN(dec_unchecked)
26102 + subl $1, (v)
26103 + sbbl $0, 4(v)
26104 RET_ENDP
26105 #undef v
26106
26107 @@ -132,6 +255,26 @@ BEGIN(dec_return)
26108 movl 4(v), %edx
26109 subl $1, %eax
26110 sbbl $0, %edx
26111 +
26112 +#ifdef CONFIG_PAX_REFCOUNT
26113 + into
26114 +1234:
26115 + _ASM_EXTABLE(1234b, 2f)
26116 +#endif
26117 +
26118 + movl %eax, (v)
26119 + movl %edx, 4(v)
26120 +
26121 +#ifdef CONFIG_PAX_REFCOUNT
26122 +2:
26123 +#endif
26124 +
26125 +RET_ENDP
26126 +BEGIN(dec_return_unchecked)
26127 + movl (v), %eax
26128 + movl 4(v), %edx
26129 + subl $1, %eax
26130 + sbbl $0, %edx
26131 movl %eax, (v)
26132 movl %edx, 4(v)
26133 RET_ENDP
26134 @@ -143,6 +286,13 @@ BEGIN(add_unless)
26135 adcl %edx, %edi
26136 addl (v), %eax
26137 adcl 4(v), %edx
26138 +
26139 +#ifdef CONFIG_PAX_REFCOUNT
26140 + into
26141 +1234:
26142 + _ASM_EXTABLE(1234b, 2f)
26143 +#endif
26144 +
26145 cmpl %eax, %ecx
26146 je 3f
26147 1:
26148 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
26149 1:
26150 addl $1, %eax
26151 adcl $0, %edx
26152 +
26153 +#ifdef CONFIG_PAX_REFCOUNT
26154 + into
26155 +1234:
26156 + _ASM_EXTABLE(1234b, 2f)
26157 +#endif
26158 +
26159 movl %eax, (v)
26160 movl %edx, 4(v)
26161 movl $1, %eax
26162 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
26163 movl 4(v), %edx
26164 subl $1, %eax
26165 sbbl $0, %edx
26166 +
26167 +#ifdef CONFIG_PAX_REFCOUNT
26168 + into
26169 +1234:
26170 + _ASM_EXTABLE(1234b, 1f)
26171 +#endif
26172 +
26173 js 1f
26174 movl %eax, (v)
26175 movl %edx, 4(v)
26176 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
26177 index f5cc9eb..51fa319 100644
26178 --- a/arch/x86/lib/atomic64_cx8_32.S
26179 +++ b/arch/x86/lib/atomic64_cx8_32.S
26180 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
26181 CFI_STARTPROC
26182
26183 read64 %ecx
26184 + pax_force_retaddr
26185 ret
26186 CFI_ENDPROC
26187 ENDPROC(atomic64_read_cx8)
26188
26189 +ENTRY(atomic64_read_unchecked_cx8)
26190 + CFI_STARTPROC
26191 +
26192 + read64 %ecx
26193 + pax_force_retaddr
26194 + ret
26195 + CFI_ENDPROC
26196 +ENDPROC(atomic64_read_unchecked_cx8)
26197 +
26198 ENTRY(atomic64_set_cx8)
26199 CFI_STARTPROC
26200
26201 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
26202 cmpxchg8b (%esi)
26203 jne 1b
26204
26205 + pax_force_retaddr
26206 ret
26207 CFI_ENDPROC
26208 ENDPROC(atomic64_set_cx8)
26209
26210 +ENTRY(atomic64_set_unchecked_cx8)
26211 + CFI_STARTPROC
26212 +
26213 +1:
26214 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
26215 + * are atomic on 586 and newer */
26216 + cmpxchg8b (%esi)
26217 + jne 1b
26218 +
26219 + pax_force_retaddr
26220 + ret
26221 + CFI_ENDPROC
26222 +ENDPROC(atomic64_set_unchecked_cx8)
26223 +
26224 ENTRY(atomic64_xchg_cx8)
26225 CFI_STARTPROC
26226
26227 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
26228 cmpxchg8b (%esi)
26229 jne 1b
26230
26231 + pax_force_retaddr
26232 ret
26233 CFI_ENDPROC
26234 ENDPROC(atomic64_xchg_cx8)
26235
26236 -.macro addsub_return func ins insc
26237 -ENTRY(atomic64_\func\()_return_cx8)
26238 +.macro addsub_return func ins insc unchecked=""
26239 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
26240 CFI_STARTPROC
26241 SAVE ebp
26242 SAVE ebx
26243 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
26244 movl %edx, %ecx
26245 \ins\()l %esi, %ebx
26246 \insc\()l %edi, %ecx
26247 +
26248 +.ifb \unchecked
26249 +#ifdef CONFIG_PAX_REFCOUNT
26250 + into
26251 +2:
26252 + _ASM_EXTABLE(2b, 3f)
26253 +#endif
26254 +.endif
26255 +
26256 LOCK_PREFIX
26257 cmpxchg8b (%ebp)
26258 jne 1b
26259 -
26260 -10:
26261 movl %ebx, %eax
26262 movl %ecx, %edx
26263 +
26264 +.ifb \unchecked
26265 +#ifdef CONFIG_PAX_REFCOUNT
26266 +3:
26267 +#endif
26268 +.endif
26269 +
26270 RESTORE edi
26271 RESTORE esi
26272 RESTORE ebx
26273 RESTORE ebp
26274 + pax_force_retaddr
26275 ret
26276 CFI_ENDPROC
26277 -ENDPROC(atomic64_\func\()_return_cx8)
26278 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
26279 .endm
26280
26281 addsub_return add add adc
26282 addsub_return sub sub sbb
26283 +addsub_return add add adc _unchecked
26284 +addsub_return sub sub sbb _unchecked
26285
26286 -.macro incdec_return func ins insc
26287 -ENTRY(atomic64_\func\()_return_cx8)
26288 +.macro incdec_return func ins insc unchecked=""
26289 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
26290 CFI_STARTPROC
26291 SAVE ebx
26292
26293 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
26294 movl %edx, %ecx
26295 \ins\()l $1, %ebx
26296 \insc\()l $0, %ecx
26297 +
26298 +.ifb \unchecked
26299 +#ifdef CONFIG_PAX_REFCOUNT
26300 + into
26301 +2:
26302 + _ASM_EXTABLE(2b, 3f)
26303 +#endif
26304 +.endif
26305 +
26306 LOCK_PREFIX
26307 cmpxchg8b (%esi)
26308 jne 1b
26309
26310 -10:
26311 movl %ebx, %eax
26312 movl %ecx, %edx
26313 +
26314 +.ifb \unchecked
26315 +#ifdef CONFIG_PAX_REFCOUNT
26316 +3:
26317 +#endif
26318 +.endif
26319 +
26320 RESTORE ebx
26321 + pax_force_retaddr
26322 ret
26323 CFI_ENDPROC
26324 -ENDPROC(atomic64_\func\()_return_cx8)
26325 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
26326 .endm
26327
26328 incdec_return inc add adc
26329 incdec_return dec sub sbb
26330 +incdec_return inc add adc _unchecked
26331 +incdec_return dec sub sbb _unchecked
26332
26333 ENTRY(atomic64_dec_if_positive_cx8)
26334 CFI_STARTPROC
26335 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
26336 movl %edx, %ecx
26337 subl $1, %ebx
26338 sbb $0, %ecx
26339 +
26340 +#ifdef CONFIG_PAX_REFCOUNT
26341 + into
26342 +1234:
26343 + _ASM_EXTABLE(1234b, 2f)
26344 +#endif
26345 +
26346 js 2f
26347 LOCK_PREFIX
26348 cmpxchg8b (%esi)
26349 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
26350 movl %ebx, %eax
26351 movl %ecx, %edx
26352 RESTORE ebx
26353 + pax_force_retaddr
26354 ret
26355 CFI_ENDPROC
26356 ENDPROC(atomic64_dec_if_positive_cx8)
26357 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
26358 movl %edx, %ecx
26359 addl %ebp, %ebx
26360 adcl %edi, %ecx
26361 +
26362 +#ifdef CONFIG_PAX_REFCOUNT
26363 + into
26364 +1234:
26365 + _ASM_EXTABLE(1234b, 3f)
26366 +#endif
26367 +
26368 LOCK_PREFIX
26369 cmpxchg8b (%esi)
26370 jne 1b
26371 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
26372 CFI_ADJUST_CFA_OFFSET -8
26373 RESTORE ebx
26374 RESTORE ebp
26375 + pax_force_retaddr
26376 ret
26377 4:
26378 cmpl %edx, 4(%esp)
26379 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
26380 xorl %ecx, %ecx
26381 addl $1, %ebx
26382 adcl %edx, %ecx
26383 +
26384 +#ifdef CONFIG_PAX_REFCOUNT
26385 + into
26386 +1234:
26387 + _ASM_EXTABLE(1234b, 3f)
26388 +#endif
26389 +
26390 LOCK_PREFIX
26391 cmpxchg8b (%esi)
26392 jne 1b
26393 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
26394 movl $1, %eax
26395 3:
26396 RESTORE ebx
26397 + pax_force_retaddr
26398 ret
26399 CFI_ENDPROC
26400 ENDPROC(atomic64_inc_not_zero_cx8)
26401 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
26402 index e78b8ee..7e173a8 100644
26403 --- a/arch/x86/lib/checksum_32.S
26404 +++ b/arch/x86/lib/checksum_32.S
26405 @@ -29,7 +29,8 @@
26406 #include <asm/dwarf2.h>
26407 #include <asm/errno.h>
26408 #include <asm/asm.h>
26409 -
26410 +#include <asm/segment.h>
26411 +
26412 /*
26413 * computes a partial checksum, e.g. for TCP/UDP fragments
26414 */
26415 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
26416
26417 #define ARGBASE 16
26418 #define FP 12
26419 -
26420 -ENTRY(csum_partial_copy_generic)
26421 +
26422 +ENTRY(csum_partial_copy_generic_to_user)
26423 CFI_STARTPROC
26424 +
26425 +#ifdef CONFIG_PAX_MEMORY_UDEREF
26426 + pushl_cfi %gs
26427 + popl_cfi %es
26428 + jmp csum_partial_copy_generic
26429 +#endif
26430 +
26431 +ENTRY(csum_partial_copy_generic_from_user)
26432 +
26433 +#ifdef CONFIG_PAX_MEMORY_UDEREF
26434 + pushl_cfi %gs
26435 + popl_cfi %ds
26436 +#endif
26437 +
26438 +ENTRY(csum_partial_copy_generic)
26439 subl $4,%esp
26440 CFI_ADJUST_CFA_OFFSET 4
26441 pushl_cfi %edi
26442 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
26443 jmp 4f
26444 SRC(1: movw (%esi), %bx )
26445 addl $2, %esi
26446 -DST( movw %bx, (%edi) )
26447 +DST( movw %bx, %es:(%edi) )
26448 addl $2, %edi
26449 addw %bx, %ax
26450 adcl $0, %eax
26451 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
26452 SRC(1: movl (%esi), %ebx )
26453 SRC( movl 4(%esi), %edx )
26454 adcl %ebx, %eax
26455 -DST( movl %ebx, (%edi) )
26456 +DST( movl %ebx, %es:(%edi) )
26457 adcl %edx, %eax
26458 -DST( movl %edx, 4(%edi) )
26459 +DST( movl %edx, %es:4(%edi) )
26460
26461 SRC( movl 8(%esi), %ebx )
26462 SRC( movl 12(%esi), %edx )
26463 adcl %ebx, %eax
26464 -DST( movl %ebx, 8(%edi) )
26465 +DST( movl %ebx, %es:8(%edi) )
26466 adcl %edx, %eax
26467 -DST( movl %edx, 12(%edi) )
26468 +DST( movl %edx, %es:12(%edi) )
26469
26470 SRC( movl 16(%esi), %ebx )
26471 SRC( movl 20(%esi), %edx )
26472 adcl %ebx, %eax
26473 -DST( movl %ebx, 16(%edi) )
26474 +DST( movl %ebx, %es:16(%edi) )
26475 adcl %edx, %eax
26476 -DST( movl %edx, 20(%edi) )
26477 +DST( movl %edx, %es:20(%edi) )
26478
26479 SRC( movl 24(%esi), %ebx )
26480 SRC( movl 28(%esi), %edx )
26481 adcl %ebx, %eax
26482 -DST( movl %ebx, 24(%edi) )
26483 +DST( movl %ebx, %es:24(%edi) )
26484 adcl %edx, %eax
26485 -DST( movl %edx, 28(%edi) )
26486 +DST( movl %edx, %es:28(%edi) )
26487
26488 lea 32(%esi), %esi
26489 lea 32(%edi), %edi
26490 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
26491 shrl $2, %edx # This clears CF
26492 SRC(3: movl (%esi), %ebx )
26493 adcl %ebx, %eax
26494 -DST( movl %ebx, (%edi) )
26495 +DST( movl %ebx, %es:(%edi) )
26496 lea 4(%esi), %esi
26497 lea 4(%edi), %edi
26498 dec %edx
26499 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
26500 jb 5f
26501 SRC( movw (%esi), %cx )
26502 leal 2(%esi), %esi
26503 -DST( movw %cx, (%edi) )
26504 +DST( movw %cx, %es:(%edi) )
26505 leal 2(%edi), %edi
26506 je 6f
26507 shll $16,%ecx
26508 SRC(5: movb (%esi), %cl )
26509 -DST( movb %cl, (%edi) )
26510 +DST( movb %cl, %es:(%edi) )
26511 6: addl %ecx, %eax
26512 adcl $0, %eax
26513 7:
26514 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
26515
26516 6001:
26517 movl ARGBASE+20(%esp), %ebx # src_err_ptr
26518 - movl $-EFAULT, (%ebx)
26519 + movl $-EFAULT, %ss:(%ebx)
26520
26521 # zero the complete destination - computing the rest
26522 # is too much work
26523 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
26524
26525 6002:
26526 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
26527 - movl $-EFAULT,(%ebx)
26528 + movl $-EFAULT,%ss:(%ebx)
26529 jmp 5000b
26530
26531 .previous
26532
26533 + pushl_cfi %ss
26534 + popl_cfi %ds
26535 + pushl_cfi %ss
26536 + popl_cfi %es
26537 popl_cfi %ebx
26538 CFI_RESTORE ebx
26539 popl_cfi %esi
26540 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
26541 popl_cfi %ecx # equivalent to addl $4,%esp
26542 ret
26543 CFI_ENDPROC
26544 -ENDPROC(csum_partial_copy_generic)
26545 +ENDPROC(csum_partial_copy_generic_to_user)
26546
26547 #else
26548
26549 /* Version for PentiumII/PPro */
26550
26551 #define ROUND1(x) \
26552 + nop; nop; nop; \
26553 SRC(movl x(%esi), %ebx ) ; \
26554 addl %ebx, %eax ; \
26555 - DST(movl %ebx, x(%edi) ) ;
26556 + DST(movl %ebx, %es:x(%edi)) ;
26557
26558 #define ROUND(x) \
26559 + nop; nop; nop; \
26560 SRC(movl x(%esi), %ebx ) ; \
26561 adcl %ebx, %eax ; \
26562 - DST(movl %ebx, x(%edi) ) ;
26563 + DST(movl %ebx, %es:x(%edi)) ;
26564
26565 #define ARGBASE 12
26566 -
26567 -ENTRY(csum_partial_copy_generic)
26568 +
26569 +ENTRY(csum_partial_copy_generic_to_user)
26570 CFI_STARTPROC
26571 +
26572 +#ifdef CONFIG_PAX_MEMORY_UDEREF
26573 + pushl_cfi %gs
26574 + popl_cfi %es
26575 + jmp csum_partial_copy_generic
26576 +#endif
26577 +
26578 +ENTRY(csum_partial_copy_generic_from_user)
26579 +
26580 +#ifdef CONFIG_PAX_MEMORY_UDEREF
26581 + pushl_cfi %gs
26582 + popl_cfi %ds
26583 +#endif
26584 +
26585 +ENTRY(csum_partial_copy_generic)
26586 pushl_cfi %ebx
26587 CFI_REL_OFFSET ebx, 0
26588 pushl_cfi %edi
26589 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
26590 subl %ebx, %edi
26591 lea -1(%esi),%edx
26592 andl $-32,%edx
26593 - lea 3f(%ebx,%ebx), %ebx
26594 + lea 3f(%ebx,%ebx,2), %ebx
26595 testl %esi, %esi
26596 jmp *%ebx
26597 1: addl $64,%esi
26598 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
26599 jb 5f
26600 SRC( movw (%esi), %dx )
26601 leal 2(%esi), %esi
26602 -DST( movw %dx, (%edi) )
26603 +DST( movw %dx, %es:(%edi) )
26604 leal 2(%edi), %edi
26605 je 6f
26606 shll $16,%edx
26607 5:
26608 SRC( movb (%esi), %dl )
26609 -DST( movb %dl, (%edi) )
26610 +DST( movb %dl, %es:(%edi) )
26611 6: addl %edx, %eax
26612 adcl $0, %eax
26613 7:
26614 .section .fixup, "ax"
26615 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
26616 - movl $-EFAULT, (%ebx)
26617 + movl $-EFAULT, %ss:(%ebx)
26618 # zero the complete destination (computing the rest is too much work)
26619 movl ARGBASE+8(%esp),%edi # dst
26620 movl ARGBASE+12(%esp),%ecx # len
26621 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
26622 rep; stosb
26623 jmp 7b
26624 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
26625 - movl $-EFAULT, (%ebx)
26626 + movl $-EFAULT, %ss:(%ebx)
26627 jmp 7b
26628 .previous
26629
26630 +#ifdef CONFIG_PAX_MEMORY_UDEREF
26631 + pushl_cfi %ss
26632 + popl_cfi %ds
26633 + pushl_cfi %ss
26634 + popl_cfi %es
26635 +#endif
26636 +
26637 popl_cfi %esi
26638 CFI_RESTORE esi
26639 popl_cfi %edi
26640 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
26641 CFI_RESTORE ebx
26642 ret
26643 CFI_ENDPROC
26644 -ENDPROC(csum_partial_copy_generic)
26645 +ENDPROC(csum_partial_copy_generic_to_user)
26646
26647 #undef ROUND
26648 #undef ROUND1
26649 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
26650 index f2145cf..cea889d 100644
26651 --- a/arch/x86/lib/clear_page_64.S
26652 +++ b/arch/x86/lib/clear_page_64.S
26653 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
26654 movl $4096/8,%ecx
26655 xorl %eax,%eax
26656 rep stosq
26657 + pax_force_retaddr
26658 ret
26659 CFI_ENDPROC
26660 ENDPROC(clear_page_c)
26661 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
26662 movl $4096,%ecx
26663 xorl %eax,%eax
26664 rep stosb
26665 + pax_force_retaddr
26666 ret
26667 CFI_ENDPROC
26668 ENDPROC(clear_page_c_e)
26669 @@ -43,6 +45,7 @@ ENTRY(clear_page)
26670 leaq 64(%rdi),%rdi
26671 jnz .Lloop
26672 nop
26673 + pax_force_retaddr
26674 ret
26675 CFI_ENDPROC
26676 .Lclear_page_end:
26677 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
26678
26679 #include <asm/cpufeature.h>
26680
26681 - .section .altinstr_replacement,"ax"
26682 + .section .altinstr_replacement,"a"
26683 1: .byte 0xeb /* jmp <disp8> */
26684 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
26685 2: .byte 0xeb /* jmp <disp8> */
26686 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
26687 index 1e572c5..2a162cd 100644
26688 --- a/arch/x86/lib/cmpxchg16b_emu.S
26689 +++ b/arch/x86/lib/cmpxchg16b_emu.S
26690 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
26691
26692 popf
26693 mov $1, %al
26694 + pax_force_retaddr
26695 ret
26696
26697 not_same:
26698 popf
26699 xor %al,%al
26700 + pax_force_retaddr
26701 ret
26702
26703 CFI_ENDPROC
26704 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
26705 index 176cca6..1166c50 100644
26706 --- a/arch/x86/lib/copy_page_64.S
26707 +++ b/arch/x86/lib/copy_page_64.S
26708 @@ -9,6 +9,7 @@ copy_page_rep:
26709 CFI_STARTPROC
26710 movl $4096/8, %ecx
26711 rep movsq
26712 + pax_force_retaddr
26713 ret
26714 CFI_ENDPROC
26715 ENDPROC(copy_page_rep)
26716 @@ -20,12 +21,14 @@ ENDPROC(copy_page_rep)
26717
26718 ENTRY(copy_page)
26719 CFI_STARTPROC
26720 - subq $2*8, %rsp
26721 - CFI_ADJUST_CFA_OFFSET 2*8
26722 + subq $3*8, %rsp
26723 + CFI_ADJUST_CFA_OFFSET 3*8
26724 movq %rbx, (%rsp)
26725 CFI_REL_OFFSET rbx, 0
26726 movq %r12, 1*8(%rsp)
26727 CFI_REL_OFFSET r12, 1*8
26728 + movq %r13, 2*8(%rsp)
26729 + CFI_REL_OFFSET r13, 2*8
26730
26731 movl $(4096/64)-5, %ecx
26732 .p2align 4
26733 @@ -36,7 +39,7 @@ ENTRY(copy_page)
26734 movq 0x8*2(%rsi), %rdx
26735 movq 0x8*3(%rsi), %r8
26736 movq 0x8*4(%rsi), %r9
26737 - movq 0x8*5(%rsi), %r10
26738 + movq 0x8*5(%rsi), %r13
26739 movq 0x8*6(%rsi), %r11
26740 movq 0x8*7(%rsi), %r12
26741
26742 @@ -47,7 +50,7 @@ ENTRY(copy_page)
26743 movq %rdx, 0x8*2(%rdi)
26744 movq %r8, 0x8*3(%rdi)
26745 movq %r9, 0x8*4(%rdi)
26746 - movq %r10, 0x8*5(%rdi)
26747 + movq %r13, 0x8*5(%rdi)
26748 movq %r11, 0x8*6(%rdi)
26749 movq %r12, 0x8*7(%rdi)
26750
26751 @@ -66,7 +69,7 @@ ENTRY(copy_page)
26752 movq 0x8*2(%rsi), %rdx
26753 movq 0x8*3(%rsi), %r8
26754 movq 0x8*4(%rsi), %r9
26755 - movq 0x8*5(%rsi), %r10
26756 + movq 0x8*5(%rsi), %r13
26757 movq 0x8*6(%rsi), %r11
26758 movq 0x8*7(%rsi), %r12
26759
26760 @@ -75,7 +78,7 @@ ENTRY(copy_page)
26761 movq %rdx, 0x8*2(%rdi)
26762 movq %r8, 0x8*3(%rdi)
26763 movq %r9, 0x8*4(%rdi)
26764 - movq %r10, 0x8*5(%rdi)
26765 + movq %r13, 0x8*5(%rdi)
26766 movq %r11, 0x8*6(%rdi)
26767 movq %r12, 0x8*7(%rdi)
26768
26769 @@ -87,8 +90,11 @@ ENTRY(copy_page)
26770 CFI_RESTORE rbx
26771 movq 1*8(%rsp), %r12
26772 CFI_RESTORE r12
26773 - addq $2*8, %rsp
26774 - CFI_ADJUST_CFA_OFFSET -2*8
26775 + movq 2*8(%rsp), %r13
26776 + CFI_RESTORE r13
26777 + addq $3*8, %rsp
26778 + CFI_ADJUST_CFA_OFFSET -3*8
26779 + pax_force_retaddr
26780 ret
26781 .Lcopy_page_end:
26782 CFI_ENDPROC
26783 @@ -99,7 +105,7 @@ ENDPROC(copy_page)
26784
26785 #include <asm/cpufeature.h>
26786
26787 - .section .altinstr_replacement,"ax"
26788 + .section .altinstr_replacement,"a"
26789 1: .byte 0xeb /* jmp <disp8> */
26790 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
26791 2:
26792 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
26793 index a30ca15..6b3f4e1 100644
26794 --- a/arch/x86/lib/copy_user_64.S
26795 +++ b/arch/x86/lib/copy_user_64.S
26796 @@ -18,31 +18,7 @@
26797 #include <asm/alternative-asm.h>
26798 #include <asm/asm.h>
26799 #include <asm/smap.h>
26800 -
26801 -/*
26802 - * By placing feature2 after feature1 in altinstructions section, we logically
26803 - * implement:
26804 - * If CPU has feature2, jmp to alt2 is used
26805 - * else if CPU has feature1, jmp to alt1 is used
26806 - * else jmp to orig is used.
26807 - */
26808 - .macro ALTERNATIVE_JUMP feature1,feature2,orig,alt1,alt2
26809 -0:
26810 - .byte 0xe9 /* 32bit jump */
26811 - .long \orig-1f /* by default jump to orig */
26812 -1:
26813 - .section .altinstr_replacement,"ax"
26814 -2: .byte 0xe9 /* near jump with 32bit immediate */
26815 - .long \alt1-1b /* offset */ /* or alternatively to alt1 */
26816 -3: .byte 0xe9 /* near jump with 32bit immediate */
26817 - .long \alt2-1b /* offset */ /* or alternatively to alt2 */
26818 - .previous
26819 -
26820 - .section .altinstructions,"a"
26821 - altinstruction_entry 0b,2b,\feature1,5,5
26822 - altinstruction_entry 0b,3b,\feature2,5,5
26823 - .previous
26824 - .endm
26825 +#include <asm/pgtable.h>
26826
26827 .macro ALIGN_DESTINATION
26828 #ifdef FIX_ALIGNMENT
26829 @@ -70,52 +46,6 @@
26830 #endif
26831 .endm
26832
26833 -/* Standard copy_to_user with segment limit checking */
26834 -ENTRY(_copy_to_user)
26835 - CFI_STARTPROC
26836 - GET_THREAD_INFO(%rax)
26837 - movq %rdi,%rcx
26838 - addq %rdx,%rcx
26839 - jc bad_to_user
26840 - cmpq TI_addr_limit(%rax),%rcx
26841 - ja bad_to_user
26842 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
26843 - copy_user_generic_unrolled,copy_user_generic_string, \
26844 - copy_user_enhanced_fast_string
26845 - CFI_ENDPROC
26846 -ENDPROC(_copy_to_user)
26847 -
26848 -/* Standard copy_from_user with segment limit checking */
26849 -ENTRY(_copy_from_user)
26850 - CFI_STARTPROC
26851 - GET_THREAD_INFO(%rax)
26852 - movq %rsi,%rcx
26853 - addq %rdx,%rcx
26854 - jc bad_from_user
26855 - cmpq TI_addr_limit(%rax),%rcx
26856 - ja bad_from_user
26857 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
26858 - copy_user_generic_unrolled,copy_user_generic_string, \
26859 - copy_user_enhanced_fast_string
26860 - CFI_ENDPROC
26861 -ENDPROC(_copy_from_user)
26862 -
26863 - .section .fixup,"ax"
26864 - /* must zero dest */
26865 -ENTRY(bad_from_user)
26866 -bad_from_user:
26867 - CFI_STARTPROC
26868 - movl %edx,%ecx
26869 - xorl %eax,%eax
26870 - rep
26871 - stosb
26872 -bad_to_user:
26873 - movl %edx,%eax
26874 - ret
26875 - CFI_ENDPROC
26876 -ENDPROC(bad_from_user)
26877 - .previous
26878 -
26879 /*
26880 * copy_user_generic_unrolled - memory copy with exception handling.
26881 * This version is for CPUs like P4 that don't have efficient micro
26882 @@ -131,6 +61,7 @@ ENDPROC(bad_from_user)
26883 */
26884 ENTRY(copy_user_generic_unrolled)
26885 CFI_STARTPROC
26886 + ASM_PAX_OPEN_USERLAND
26887 ASM_STAC
26888 cmpl $8,%edx
26889 jb 20f /* less then 8 bytes, go to byte copy loop */
26890 @@ -141,19 +72,19 @@ ENTRY(copy_user_generic_unrolled)
26891 jz 17f
26892 1: movq (%rsi),%r8
26893 2: movq 1*8(%rsi),%r9
26894 -3: movq 2*8(%rsi),%r10
26895 +3: movq 2*8(%rsi),%rax
26896 4: movq 3*8(%rsi),%r11
26897 5: movq %r8,(%rdi)
26898 6: movq %r9,1*8(%rdi)
26899 -7: movq %r10,2*8(%rdi)
26900 +7: movq %rax,2*8(%rdi)
26901 8: movq %r11,3*8(%rdi)
26902 9: movq 4*8(%rsi),%r8
26903 10: movq 5*8(%rsi),%r9
26904 -11: movq 6*8(%rsi),%r10
26905 +11: movq 6*8(%rsi),%rax
26906 12: movq 7*8(%rsi),%r11
26907 13: movq %r8,4*8(%rdi)
26908 14: movq %r9,5*8(%rdi)
26909 -15: movq %r10,6*8(%rdi)
26910 +15: movq %rax,6*8(%rdi)
26911 16: movq %r11,7*8(%rdi)
26912 leaq 64(%rsi),%rsi
26913 leaq 64(%rdi),%rdi
26914 @@ -180,6 +111,8 @@ ENTRY(copy_user_generic_unrolled)
26915 jnz 21b
26916 23: xor %eax,%eax
26917 ASM_CLAC
26918 + ASM_PAX_CLOSE_USERLAND
26919 + pax_force_retaddr
26920 ret
26921
26922 .section .fixup,"ax"
26923 @@ -235,6 +168,7 @@ ENDPROC(copy_user_generic_unrolled)
26924 */
26925 ENTRY(copy_user_generic_string)
26926 CFI_STARTPROC
26927 + ASM_PAX_OPEN_USERLAND
26928 ASM_STAC
26929 andl %edx,%edx
26930 jz 4f
26931 @@ -251,6 +185,8 @@ ENTRY(copy_user_generic_string)
26932 movsb
26933 4: xorl %eax,%eax
26934 ASM_CLAC
26935 + ASM_PAX_CLOSE_USERLAND
26936 + pax_force_retaddr
26937 ret
26938
26939 .section .fixup,"ax"
26940 @@ -278,6 +214,7 @@ ENDPROC(copy_user_generic_string)
26941 */
26942 ENTRY(copy_user_enhanced_fast_string)
26943 CFI_STARTPROC
26944 + ASM_PAX_OPEN_USERLAND
26945 ASM_STAC
26946 andl %edx,%edx
26947 jz 2f
26948 @@ -286,6 +223,8 @@ ENTRY(copy_user_enhanced_fast_string)
26949 movsb
26950 2: xorl %eax,%eax
26951 ASM_CLAC
26952 + ASM_PAX_CLOSE_USERLAND
26953 + pax_force_retaddr
26954 ret
26955
26956 .section .fixup,"ax"
26957 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
26958 index 6a4f43c..55d26f2 100644
26959 --- a/arch/x86/lib/copy_user_nocache_64.S
26960 +++ b/arch/x86/lib/copy_user_nocache_64.S
26961 @@ -8,6 +8,7 @@
26962
26963 #include <linux/linkage.h>
26964 #include <asm/dwarf2.h>
26965 +#include <asm/alternative-asm.h>
26966
26967 #define FIX_ALIGNMENT 1
26968
26969 @@ -16,6 +17,7 @@
26970 #include <asm/thread_info.h>
26971 #include <asm/asm.h>
26972 #include <asm/smap.h>
26973 +#include <asm/pgtable.h>
26974
26975 .macro ALIGN_DESTINATION
26976 #ifdef FIX_ALIGNMENT
26977 @@ -49,6 +51,16 @@
26978 */
26979 ENTRY(__copy_user_nocache)
26980 CFI_STARTPROC
26981 +
26982 +#ifdef CONFIG_PAX_MEMORY_UDEREF
26983 + mov pax_user_shadow_base,%rcx
26984 + cmp %rcx,%rsi
26985 + jae 1f
26986 + add %rcx,%rsi
26987 +1:
26988 +#endif
26989 +
26990 + ASM_PAX_OPEN_USERLAND
26991 ASM_STAC
26992 cmpl $8,%edx
26993 jb 20f /* less then 8 bytes, go to byte copy loop */
26994 @@ -59,19 +71,19 @@ ENTRY(__copy_user_nocache)
26995 jz 17f
26996 1: movq (%rsi),%r8
26997 2: movq 1*8(%rsi),%r9
26998 -3: movq 2*8(%rsi),%r10
26999 +3: movq 2*8(%rsi),%rax
27000 4: movq 3*8(%rsi),%r11
27001 5: movnti %r8,(%rdi)
27002 6: movnti %r9,1*8(%rdi)
27003 -7: movnti %r10,2*8(%rdi)
27004 +7: movnti %rax,2*8(%rdi)
27005 8: movnti %r11,3*8(%rdi)
27006 9: movq 4*8(%rsi),%r8
27007 10: movq 5*8(%rsi),%r9
27008 -11: movq 6*8(%rsi),%r10
27009 +11: movq 6*8(%rsi),%rax
27010 12: movq 7*8(%rsi),%r11
27011 13: movnti %r8,4*8(%rdi)
27012 14: movnti %r9,5*8(%rdi)
27013 -15: movnti %r10,6*8(%rdi)
27014 +15: movnti %rax,6*8(%rdi)
27015 16: movnti %r11,7*8(%rdi)
27016 leaq 64(%rsi),%rsi
27017 leaq 64(%rdi),%rdi
27018 @@ -98,7 +110,9 @@ ENTRY(__copy_user_nocache)
27019 jnz 21b
27020 23: xorl %eax,%eax
27021 ASM_CLAC
27022 + ASM_PAX_CLOSE_USERLAND
27023 sfence
27024 + pax_force_retaddr
27025 ret
27026
27027 .section .fixup,"ax"
27028 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
27029 index 2419d5f..953ee51 100644
27030 --- a/arch/x86/lib/csum-copy_64.S
27031 +++ b/arch/x86/lib/csum-copy_64.S
27032 @@ -9,6 +9,7 @@
27033 #include <asm/dwarf2.h>
27034 #include <asm/errno.h>
27035 #include <asm/asm.h>
27036 +#include <asm/alternative-asm.h>
27037
27038 /*
27039 * Checksum copy with exception handling.
27040 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
27041 CFI_RESTORE rbp
27042 addq $7*8, %rsp
27043 CFI_ADJUST_CFA_OFFSET -7*8
27044 + pax_force_retaddr 0, 1
27045 ret
27046 CFI_RESTORE_STATE
27047
27048 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
27049 index 25b7ae8..c40113e 100644
27050 --- a/arch/x86/lib/csum-wrappers_64.c
27051 +++ b/arch/x86/lib/csum-wrappers_64.c
27052 @@ -52,8 +52,12 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
27053 len -= 2;
27054 }
27055 }
27056 - isum = csum_partial_copy_generic((__force const void *)src,
27057 + pax_open_userland();
27058 + stac();
27059 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
27060 dst, len, isum, errp, NULL);
27061 + clac();
27062 + pax_close_userland();
27063 if (unlikely(*errp))
27064 goto out_err;
27065
27066 @@ -105,8 +109,13 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
27067 }
27068
27069 *errp = 0;
27070 - return csum_partial_copy_generic(src, (void __force *)dst,
27071 + pax_open_userland();
27072 + stac();
27073 + isum = csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
27074 len, isum, NULL, errp);
27075 + clac();
27076 + pax_close_userland();
27077 + return isum;
27078 }
27079 EXPORT_SYMBOL(csum_partial_copy_to_user);
27080
27081 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
27082 index a451235..1daa956 100644
27083 --- a/arch/x86/lib/getuser.S
27084 +++ b/arch/x86/lib/getuser.S
27085 @@ -33,17 +33,40 @@
27086 #include <asm/thread_info.h>
27087 #include <asm/asm.h>
27088 #include <asm/smap.h>
27089 +#include <asm/segment.h>
27090 +#include <asm/pgtable.h>
27091 +#include <asm/alternative-asm.h>
27092 +
27093 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
27094 +#define __copyuser_seg gs;
27095 +#else
27096 +#define __copyuser_seg
27097 +#endif
27098
27099 .text
27100 ENTRY(__get_user_1)
27101 CFI_STARTPROC
27102 +
27103 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
27104 GET_THREAD_INFO(%_ASM_DX)
27105 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
27106 jae bad_get_user
27107 ASM_STAC
27108 -1: movzbl (%_ASM_AX),%edx
27109 +
27110 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27111 + mov pax_user_shadow_base,%_ASM_DX
27112 + cmp %_ASM_DX,%_ASM_AX
27113 + jae 1234f
27114 + add %_ASM_DX,%_ASM_AX
27115 +1234:
27116 +#endif
27117 +
27118 +#endif
27119 +
27120 +1: __copyuser_seg movzbl (%_ASM_AX),%edx
27121 xor %eax,%eax
27122 ASM_CLAC
27123 + pax_force_retaddr
27124 ret
27125 CFI_ENDPROC
27126 ENDPROC(__get_user_1)
27127 @@ -51,14 +74,28 @@ ENDPROC(__get_user_1)
27128 ENTRY(__get_user_2)
27129 CFI_STARTPROC
27130 add $1,%_ASM_AX
27131 +
27132 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
27133 jc bad_get_user
27134 GET_THREAD_INFO(%_ASM_DX)
27135 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
27136 jae bad_get_user
27137 ASM_STAC
27138 -2: movzwl -1(%_ASM_AX),%edx
27139 +
27140 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27141 + mov pax_user_shadow_base,%_ASM_DX
27142 + cmp %_ASM_DX,%_ASM_AX
27143 + jae 1234f
27144 + add %_ASM_DX,%_ASM_AX
27145 +1234:
27146 +#endif
27147 +
27148 +#endif
27149 +
27150 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
27151 xor %eax,%eax
27152 ASM_CLAC
27153 + pax_force_retaddr
27154 ret
27155 CFI_ENDPROC
27156 ENDPROC(__get_user_2)
27157 @@ -66,14 +103,28 @@ ENDPROC(__get_user_2)
27158 ENTRY(__get_user_4)
27159 CFI_STARTPROC
27160 add $3,%_ASM_AX
27161 +
27162 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
27163 jc bad_get_user
27164 GET_THREAD_INFO(%_ASM_DX)
27165 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
27166 jae bad_get_user
27167 ASM_STAC
27168 -3: movl -3(%_ASM_AX),%edx
27169 +
27170 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27171 + mov pax_user_shadow_base,%_ASM_DX
27172 + cmp %_ASM_DX,%_ASM_AX
27173 + jae 1234f
27174 + add %_ASM_DX,%_ASM_AX
27175 +1234:
27176 +#endif
27177 +
27178 +#endif
27179 +
27180 +3: __copyuser_seg movl -3(%_ASM_AX),%edx
27181 xor %eax,%eax
27182 ASM_CLAC
27183 + pax_force_retaddr
27184 ret
27185 CFI_ENDPROC
27186 ENDPROC(__get_user_4)
27187 @@ -86,10 +137,20 @@ ENTRY(__get_user_8)
27188 GET_THREAD_INFO(%_ASM_DX)
27189 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
27190 jae bad_get_user
27191 +
27192 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27193 + mov pax_user_shadow_base,%_ASM_DX
27194 + cmp %_ASM_DX,%_ASM_AX
27195 + jae 1234f
27196 + add %_ASM_DX,%_ASM_AX
27197 +1234:
27198 +#endif
27199 +
27200 ASM_STAC
27201 4: movq -7(%_ASM_AX),%rdx
27202 xor %eax,%eax
27203 ASM_CLAC
27204 + pax_force_retaddr
27205 ret
27206 #else
27207 add $7,%_ASM_AX
27208 @@ -98,10 +159,11 @@ ENTRY(__get_user_8)
27209 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
27210 jae bad_get_user_8
27211 ASM_STAC
27212 -4: movl -7(%_ASM_AX),%edx
27213 -5: movl -3(%_ASM_AX),%ecx
27214 +4: __copyuser_seg movl -7(%_ASM_AX),%edx
27215 +5: __copyuser_seg movl -3(%_ASM_AX),%ecx
27216 xor %eax,%eax
27217 ASM_CLAC
27218 + pax_force_retaddr
27219 ret
27220 #endif
27221 CFI_ENDPROC
27222 @@ -113,6 +175,7 @@ bad_get_user:
27223 xor %edx,%edx
27224 mov $(-EFAULT),%_ASM_AX
27225 ASM_CLAC
27226 + pax_force_retaddr
27227 ret
27228 CFI_ENDPROC
27229 END(bad_get_user)
27230 @@ -124,6 +187,7 @@ bad_get_user_8:
27231 xor %ecx,%ecx
27232 mov $(-EFAULT),%_ASM_AX
27233 ASM_CLAC
27234 + pax_force_retaddr
27235 ret
27236 CFI_ENDPROC
27237 END(bad_get_user_8)
27238 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
27239 index 54fcffe..7be149e 100644
27240 --- a/arch/x86/lib/insn.c
27241 +++ b/arch/x86/lib/insn.c
27242 @@ -20,8 +20,10 @@
27243
27244 #ifdef __KERNEL__
27245 #include <linux/string.h>
27246 +#include <asm/pgtable_types.h>
27247 #else
27248 #include <string.h>
27249 +#define ktla_ktva(addr) addr
27250 #endif
27251 #include <asm/inat.h>
27252 #include <asm/insn.h>
27253 @@ -53,8 +55,8 @@
27254 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
27255 {
27256 memset(insn, 0, sizeof(*insn));
27257 - insn->kaddr = kaddr;
27258 - insn->next_byte = kaddr;
27259 + insn->kaddr = ktla_ktva(kaddr);
27260 + insn->next_byte = ktla_ktva(kaddr);
27261 insn->x86_64 = x86_64 ? 1 : 0;
27262 insn->opnd_bytes = 4;
27263 if (x86_64)
27264 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
27265 index 05a95e7..326f2fa 100644
27266 --- a/arch/x86/lib/iomap_copy_64.S
27267 +++ b/arch/x86/lib/iomap_copy_64.S
27268 @@ -17,6 +17,7 @@
27269
27270 #include <linux/linkage.h>
27271 #include <asm/dwarf2.h>
27272 +#include <asm/alternative-asm.h>
27273
27274 /*
27275 * override generic version in lib/iomap_copy.c
27276 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
27277 CFI_STARTPROC
27278 movl %edx,%ecx
27279 rep movsd
27280 + pax_force_retaddr
27281 ret
27282 CFI_ENDPROC
27283 ENDPROC(__iowrite32_copy)
27284 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
27285 index 56313a3..9b59269 100644
27286 --- a/arch/x86/lib/memcpy_64.S
27287 +++ b/arch/x86/lib/memcpy_64.S
27288 @@ -24,7 +24,7 @@
27289 * This gets patched over the unrolled variant (below) via the
27290 * alternative instructions framework:
27291 */
27292 - .section .altinstr_replacement, "ax", @progbits
27293 + .section .altinstr_replacement, "a", @progbits
27294 .Lmemcpy_c:
27295 movq %rdi, %rax
27296 movq %rdx, %rcx
27297 @@ -33,6 +33,7 @@
27298 rep movsq
27299 movl %edx, %ecx
27300 rep movsb
27301 + pax_force_retaddr
27302 ret
27303 .Lmemcpy_e:
27304 .previous
27305 @@ -44,11 +45,12 @@
27306 * This gets patched over the unrolled variant (below) via the
27307 * alternative instructions framework:
27308 */
27309 - .section .altinstr_replacement, "ax", @progbits
27310 + .section .altinstr_replacement, "a", @progbits
27311 .Lmemcpy_c_e:
27312 movq %rdi, %rax
27313 movq %rdx, %rcx
27314 rep movsb
27315 + pax_force_retaddr
27316 ret
27317 .Lmemcpy_e_e:
27318 .previous
27319 @@ -76,13 +78,13 @@ ENTRY(memcpy)
27320 */
27321 movq 0*8(%rsi), %r8
27322 movq 1*8(%rsi), %r9
27323 - movq 2*8(%rsi), %r10
27324 + movq 2*8(%rsi), %rcx
27325 movq 3*8(%rsi), %r11
27326 leaq 4*8(%rsi), %rsi
27327
27328 movq %r8, 0*8(%rdi)
27329 movq %r9, 1*8(%rdi)
27330 - movq %r10, 2*8(%rdi)
27331 + movq %rcx, 2*8(%rdi)
27332 movq %r11, 3*8(%rdi)
27333 leaq 4*8(%rdi), %rdi
27334 jae .Lcopy_forward_loop
27335 @@ -105,12 +107,12 @@ ENTRY(memcpy)
27336 subq $0x20, %rdx
27337 movq -1*8(%rsi), %r8
27338 movq -2*8(%rsi), %r9
27339 - movq -3*8(%rsi), %r10
27340 + movq -3*8(%rsi), %rcx
27341 movq -4*8(%rsi), %r11
27342 leaq -4*8(%rsi), %rsi
27343 movq %r8, -1*8(%rdi)
27344 movq %r9, -2*8(%rdi)
27345 - movq %r10, -3*8(%rdi)
27346 + movq %rcx, -3*8(%rdi)
27347 movq %r11, -4*8(%rdi)
27348 leaq -4*8(%rdi), %rdi
27349 jae .Lcopy_backward_loop
27350 @@ -130,12 +132,13 @@ ENTRY(memcpy)
27351 */
27352 movq 0*8(%rsi), %r8
27353 movq 1*8(%rsi), %r9
27354 - movq -2*8(%rsi, %rdx), %r10
27355 + movq -2*8(%rsi, %rdx), %rcx
27356 movq -1*8(%rsi, %rdx), %r11
27357 movq %r8, 0*8(%rdi)
27358 movq %r9, 1*8(%rdi)
27359 - movq %r10, -2*8(%rdi, %rdx)
27360 + movq %rcx, -2*8(%rdi, %rdx)
27361 movq %r11, -1*8(%rdi, %rdx)
27362 + pax_force_retaddr
27363 retq
27364 .p2align 4
27365 .Lless_16bytes:
27366 @@ -148,6 +151,7 @@ ENTRY(memcpy)
27367 movq -1*8(%rsi, %rdx), %r9
27368 movq %r8, 0*8(%rdi)
27369 movq %r9, -1*8(%rdi, %rdx)
27370 + pax_force_retaddr
27371 retq
27372 .p2align 4
27373 .Lless_8bytes:
27374 @@ -161,6 +165,7 @@ ENTRY(memcpy)
27375 movl -4(%rsi, %rdx), %r8d
27376 movl %ecx, (%rdi)
27377 movl %r8d, -4(%rdi, %rdx)
27378 + pax_force_retaddr
27379 retq
27380 .p2align 4
27381 .Lless_3bytes:
27382 @@ -179,6 +184,7 @@ ENTRY(memcpy)
27383 movb %cl, (%rdi)
27384
27385 .Lend:
27386 + pax_force_retaddr
27387 retq
27388 CFI_ENDPROC
27389 ENDPROC(memcpy)
27390 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
27391 index 65268a6..5aa7815 100644
27392 --- a/arch/x86/lib/memmove_64.S
27393 +++ b/arch/x86/lib/memmove_64.S
27394 @@ -61,13 +61,13 @@ ENTRY(memmove)
27395 5:
27396 sub $0x20, %rdx
27397 movq 0*8(%rsi), %r11
27398 - movq 1*8(%rsi), %r10
27399 + movq 1*8(%rsi), %rcx
27400 movq 2*8(%rsi), %r9
27401 movq 3*8(%rsi), %r8
27402 leaq 4*8(%rsi), %rsi
27403
27404 movq %r11, 0*8(%rdi)
27405 - movq %r10, 1*8(%rdi)
27406 + movq %rcx, 1*8(%rdi)
27407 movq %r9, 2*8(%rdi)
27408 movq %r8, 3*8(%rdi)
27409 leaq 4*8(%rdi), %rdi
27410 @@ -81,10 +81,10 @@ ENTRY(memmove)
27411 4:
27412 movq %rdx, %rcx
27413 movq -8(%rsi, %rdx), %r11
27414 - lea -8(%rdi, %rdx), %r10
27415 + lea -8(%rdi, %rdx), %r9
27416 shrq $3, %rcx
27417 rep movsq
27418 - movq %r11, (%r10)
27419 + movq %r11, (%r9)
27420 jmp 13f
27421 .Lmemmove_end_forward:
27422
27423 @@ -95,14 +95,14 @@ ENTRY(memmove)
27424 7:
27425 movq %rdx, %rcx
27426 movq (%rsi), %r11
27427 - movq %rdi, %r10
27428 + movq %rdi, %r9
27429 leaq -8(%rsi, %rdx), %rsi
27430 leaq -8(%rdi, %rdx), %rdi
27431 shrq $3, %rcx
27432 std
27433 rep movsq
27434 cld
27435 - movq %r11, (%r10)
27436 + movq %r11, (%r9)
27437 jmp 13f
27438
27439 /*
27440 @@ -127,13 +127,13 @@ ENTRY(memmove)
27441 8:
27442 subq $0x20, %rdx
27443 movq -1*8(%rsi), %r11
27444 - movq -2*8(%rsi), %r10
27445 + movq -2*8(%rsi), %rcx
27446 movq -3*8(%rsi), %r9
27447 movq -4*8(%rsi), %r8
27448 leaq -4*8(%rsi), %rsi
27449
27450 movq %r11, -1*8(%rdi)
27451 - movq %r10, -2*8(%rdi)
27452 + movq %rcx, -2*8(%rdi)
27453 movq %r9, -3*8(%rdi)
27454 movq %r8, -4*8(%rdi)
27455 leaq -4*8(%rdi), %rdi
27456 @@ -151,11 +151,11 @@ ENTRY(memmove)
27457 * Move data from 16 bytes to 31 bytes.
27458 */
27459 movq 0*8(%rsi), %r11
27460 - movq 1*8(%rsi), %r10
27461 + movq 1*8(%rsi), %rcx
27462 movq -2*8(%rsi, %rdx), %r9
27463 movq -1*8(%rsi, %rdx), %r8
27464 movq %r11, 0*8(%rdi)
27465 - movq %r10, 1*8(%rdi)
27466 + movq %rcx, 1*8(%rdi)
27467 movq %r9, -2*8(%rdi, %rdx)
27468 movq %r8, -1*8(%rdi, %rdx)
27469 jmp 13f
27470 @@ -167,9 +167,9 @@ ENTRY(memmove)
27471 * Move data from 8 bytes to 15 bytes.
27472 */
27473 movq 0*8(%rsi), %r11
27474 - movq -1*8(%rsi, %rdx), %r10
27475 + movq -1*8(%rsi, %rdx), %r9
27476 movq %r11, 0*8(%rdi)
27477 - movq %r10, -1*8(%rdi, %rdx)
27478 + movq %r9, -1*8(%rdi, %rdx)
27479 jmp 13f
27480 10:
27481 cmpq $4, %rdx
27482 @@ -178,9 +178,9 @@ ENTRY(memmove)
27483 * Move data from 4 bytes to 7 bytes.
27484 */
27485 movl (%rsi), %r11d
27486 - movl -4(%rsi, %rdx), %r10d
27487 + movl -4(%rsi, %rdx), %r9d
27488 movl %r11d, (%rdi)
27489 - movl %r10d, -4(%rdi, %rdx)
27490 + movl %r9d, -4(%rdi, %rdx)
27491 jmp 13f
27492 11:
27493 cmp $2, %rdx
27494 @@ -189,9 +189,9 @@ ENTRY(memmove)
27495 * Move data from 2 bytes to 3 bytes.
27496 */
27497 movw (%rsi), %r11w
27498 - movw -2(%rsi, %rdx), %r10w
27499 + movw -2(%rsi, %rdx), %r9w
27500 movw %r11w, (%rdi)
27501 - movw %r10w, -2(%rdi, %rdx)
27502 + movw %r9w, -2(%rdi, %rdx)
27503 jmp 13f
27504 12:
27505 cmp $1, %rdx
27506 @@ -202,14 +202,16 @@ ENTRY(memmove)
27507 movb (%rsi), %r11b
27508 movb %r11b, (%rdi)
27509 13:
27510 + pax_force_retaddr
27511 retq
27512 CFI_ENDPROC
27513
27514 - .section .altinstr_replacement,"ax"
27515 + .section .altinstr_replacement,"a"
27516 .Lmemmove_begin_forward_efs:
27517 /* Forward moving data. */
27518 movq %rdx, %rcx
27519 rep movsb
27520 + pax_force_retaddr
27521 retq
27522 .Lmemmove_end_forward_efs:
27523 .previous
27524 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
27525 index 2dcb380..50a78bc 100644
27526 --- a/arch/x86/lib/memset_64.S
27527 +++ b/arch/x86/lib/memset_64.S
27528 @@ -16,7 +16,7 @@
27529 *
27530 * rax original destination
27531 */
27532 - .section .altinstr_replacement, "ax", @progbits
27533 + .section .altinstr_replacement, "a", @progbits
27534 .Lmemset_c:
27535 movq %rdi,%r9
27536 movq %rdx,%rcx
27537 @@ -30,6 +30,7 @@
27538 movl %edx,%ecx
27539 rep stosb
27540 movq %r9,%rax
27541 + pax_force_retaddr
27542 ret
27543 .Lmemset_e:
27544 .previous
27545 @@ -45,13 +46,14 @@
27546 *
27547 * rax original destination
27548 */
27549 - .section .altinstr_replacement, "ax", @progbits
27550 + .section .altinstr_replacement, "a", @progbits
27551 .Lmemset_c_e:
27552 movq %rdi,%r9
27553 movb %sil,%al
27554 movq %rdx,%rcx
27555 rep stosb
27556 movq %r9,%rax
27557 + pax_force_retaddr
27558 ret
27559 .Lmemset_e_e:
27560 .previous
27561 @@ -59,7 +61,7 @@
27562 ENTRY(memset)
27563 ENTRY(__memset)
27564 CFI_STARTPROC
27565 - movq %rdi,%r10
27566 + movq %rdi,%r11
27567
27568 /* expand byte value */
27569 movzbl %sil,%ecx
27570 @@ -117,7 +119,8 @@ ENTRY(__memset)
27571 jnz .Lloop_1
27572
27573 .Lende:
27574 - movq %r10,%rax
27575 + movq %r11,%rax
27576 + pax_force_retaddr
27577 ret
27578
27579 CFI_RESTORE_STATE
27580 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
27581 index c9f2d9b..e7fd2c0 100644
27582 --- a/arch/x86/lib/mmx_32.c
27583 +++ b/arch/x86/lib/mmx_32.c
27584 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
27585 {
27586 void *p;
27587 int i;
27588 + unsigned long cr0;
27589
27590 if (unlikely(in_interrupt()))
27591 return __memcpy(to, from, len);
27592 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
27593 kernel_fpu_begin();
27594
27595 __asm__ __volatile__ (
27596 - "1: prefetch (%0)\n" /* This set is 28 bytes */
27597 - " prefetch 64(%0)\n"
27598 - " prefetch 128(%0)\n"
27599 - " prefetch 192(%0)\n"
27600 - " prefetch 256(%0)\n"
27601 + "1: prefetch (%1)\n" /* This set is 28 bytes */
27602 + " prefetch 64(%1)\n"
27603 + " prefetch 128(%1)\n"
27604 + " prefetch 192(%1)\n"
27605 + " prefetch 256(%1)\n"
27606 "2: \n"
27607 ".section .fixup, \"ax\"\n"
27608 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
27609 + "3: \n"
27610 +
27611 +#ifdef CONFIG_PAX_KERNEXEC
27612 + " movl %%cr0, %0\n"
27613 + " movl %0, %%eax\n"
27614 + " andl $0xFFFEFFFF, %%eax\n"
27615 + " movl %%eax, %%cr0\n"
27616 +#endif
27617 +
27618 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
27619 +
27620 +#ifdef CONFIG_PAX_KERNEXEC
27621 + " movl %0, %%cr0\n"
27622 +#endif
27623 +
27624 " jmp 2b\n"
27625 ".previous\n"
27626 _ASM_EXTABLE(1b, 3b)
27627 - : : "r" (from));
27628 + : "=&r" (cr0) : "r" (from) : "ax");
27629
27630 for ( ; i > 5; i--) {
27631 __asm__ __volatile__ (
27632 - "1: prefetch 320(%0)\n"
27633 - "2: movq (%0), %%mm0\n"
27634 - " movq 8(%0), %%mm1\n"
27635 - " movq 16(%0), %%mm2\n"
27636 - " movq 24(%0), %%mm3\n"
27637 - " movq %%mm0, (%1)\n"
27638 - " movq %%mm1, 8(%1)\n"
27639 - " movq %%mm2, 16(%1)\n"
27640 - " movq %%mm3, 24(%1)\n"
27641 - " movq 32(%0), %%mm0\n"
27642 - " movq 40(%0), %%mm1\n"
27643 - " movq 48(%0), %%mm2\n"
27644 - " movq 56(%0), %%mm3\n"
27645 - " movq %%mm0, 32(%1)\n"
27646 - " movq %%mm1, 40(%1)\n"
27647 - " movq %%mm2, 48(%1)\n"
27648 - " movq %%mm3, 56(%1)\n"
27649 + "1: prefetch 320(%1)\n"
27650 + "2: movq (%1), %%mm0\n"
27651 + " movq 8(%1), %%mm1\n"
27652 + " movq 16(%1), %%mm2\n"
27653 + " movq 24(%1), %%mm3\n"
27654 + " movq %%mm0, (%2)\n"
27655 + " movq %%mm1, 8(%2)\n"
27656 + " movq %%mm2, 16(%2)\n"
27657 + " movq %%mm3, 24(%2)\n"
27658 + " movq 32(%1), %%mm0\n"
27659 + " movq 40(%1), %%mm1\n"
27660 + " movq 48(%1), %%mm2\n"
27661 + " movq 56(%1), %%mm3\n"
27662 + " movq %%mm0, 32(%2)\n"
27663 + " movq %%mm1, 40(%2)\n"
27664 + " movq %%mm2, 48(%2)\n"
27665 + " movq %%mm3, 56(%2)\n"
27666 ".section .fixup, \"ax\"\n"
27667 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
27668 + "3:\n"
27669 +
27670 +#ifdef CONFIG_PAX_KERNEXEC
27671 + " movl %%cr0, %0\n"
27672 + " movl %0, %%eax\n"
27673 + " andl $0xFFFEFFFF, %%eax\n"
27674 + " movl %%eax, %%cr0\n"
27675 +#endif
27676 +
27677 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
27678 +
27679 +#ifdef CONFIG_PAX_KERNEXEC
27680 + " movl %0, %%cr0\n"
27681 +#endif
27682 +
27683 " jmp 2b\n"
27684 ".previous\n"
27685 _ASM_EXTABLE(1b, 3b)
27686 - : : "r" (from), "r" (to) : "memory");
27687 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
27688
27689 from += 64;
27690 to += 64;
27691 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
27692 static void fast_copy_page(void *to, void *from)
27693 {
27694 int i;
27695 + unsigned long cr0;
27696
27697 kernel_fpu_begin();
27698
27699 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
27700 * but that is for later. -AV
27701 */
27702 __asm__ __volatile__(
27703 - "1: prefetch (%0)\n"
27704 - " prefetch 64(%0)\n"
27705 - " prefetch 128(%0)\n"
27706 - " prefetch 192(%0)\n"
27707 - " prefetch 256(%0)\n"
27708 + "1: prefetch (%1)\n"
27709 + " prefetch 64(%1)\n"
27710 + " prefetch 128(%1)\n"
27711 + " prefetch 192(%1)\n"
27712 + " prefetch 256(%1)\n"
27713 "2: \n"
27714 ".section .fixup, \"ax\"\n"
27715 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
27716 + "3: \n"
27717 +
27718 +#ifdef CONFIG_PAX_KERNEXEC
27719 + " movl %%cr0, %0\n"
27720 + " movl %0, %%eax\n"
27721 + " andl $0xFFFEFFFF, %%eax\n"
27722 + " movl %%eax, %%cr0\n"
27723 +#endif
27724 +
27725 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
27726 +
27727 +#ifdef CONFIG_PAX_KERNEXEC
27728 + " movl %0, %%cr0\n"
27729 +#endif
27730 +
27731 " jmp 2b\n"
27732 ".previous\n"
27733 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
27734 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
27735
27736 for (i = 0; i < (4096-320)/64; i++) {
27737 __asm__ __volatile__ (
27738 - "1: prefetch 320(%0)\n"
27739 - "2: movq (%0), %%mm0\n"
27740 - " movntq %%mm0, (%1)\n"
27741 - " movq 8(%0), %%mm1\n"
27742 - " movntq %%mm1, 8(%1)\n"
27743 - " movq 16(%0), %%mm2\n"
27744 - " movntq %%mm2, 16(%1)\n"
27745 - " movq 24(%0), %%mm3\n"
27746 - " movntq %%mm3, 24(%1)\n"
27747 - " movq 32(%0), %%mm4\n"
27748 - " movntq %%mm4, 32(%1)\n"
27749 - " movq 40(%0), %%mm5\n"
27750 - " movntq %%mm5, 40(%1)\n"
27751 - " movq 48(%0), %%mm6\n"
27752 - " movntq %%mm6, 48(%1)\n"
27753 - " movq 56(%0), %%mm7\n"
27754 - " movntq %%mm7, 56(%1)\n"
27755 + "1: prefetch 320(%1)\n"
27756 + "2: movq (%1), %%mm0\n"
27757 + " movntq %%mm0, (%2)\n"
27758 + " movq 8(%1), %%mm1\n"
27759 + " movntq %%mm1, 8(%2)\n"
27760 + " movq 16(%1), %%mm2\n"
27761 + " movntq %%mm2, 16(%2)\n"
27762 + " movq 24(%1), %%mm3\n"
27763 + " movntq %%mm3, 24(%2)\n"
27764 + " movq 32(%1), %%mm4\n"
27765 + " movntq %%mm4, 32(%2)\n"
27766 + " movq 40(%1), %%mm5\n"
27767 + " movntq %%mm5, 40(%2)\n"
27768 + " movq 48(%1), %%mm6\n"
27769 + " movntq %%mm6, 48(%2)\n"
27770 + " movq 56(%1), %%mm7\n"
27771 + " movntq %%mm7, 56(%2)\n"
27772 ".section .fixup, \"ax\"\n"
27773 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
27774 + "3:\n"
27775 +
27776 +#ifdef CONFIG_PAX_KERNEXEC
27777 + " movl %%cr0, %0\n"
27778 + " movl %0, %%eax\n"
27779 + " andl $0xFFFEFFFF, %%eax\n"
27780 + " movl %%eax, %%cr0\n"
27781 +#endif
27782 +
27783 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
27784 +
27785 +#ifdef CONFIG_PAX_KERNEXEC
27786 + " movl %0, %%cr0\n"
27787 +#endif
27788 +
27789 " jmp 2b\n"
27790 ".previous\n"
27791 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
27792 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
27793
27794 from += 64;
27795 to += 64;
27796 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
27797 static void fast_copy_page(void *to, void *from)
27798 {
27799 int i;
27800 + unsigned long cr0;
27801
27802 kernel_fpu_begin();
27803
27804 __asm__ __volatile__ (
27805 - "1: prefetch (%0)\n"
27806 - " prefetch 64(%0)\n"
27807 - " prefetch 128(%0)\n"
27808 - " prefetch 192(%0)\n"
27809 - " prefetch 256(%0)\n"
27810 + "1: prefetch (%1)\n"
27811 + " prefetch 64(%1)\n"
27812 + " prefetch 128(%1)\n"
27813 + " prefetch 192(%1)\n"
27814 + " prefetch 256(%1)\n"
27815 "2: \n"
27816 ".section .fixup, \"ax\"\n"
27817 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
27818 + "3: \n"
27819 +
27820 +#ifdef CONFIG_PAX_KERNEXEC
27821 + " movl %%cr0, %0\n"
27822 + " movl %0, %%eax\n"
27823 + " andl $0xFFFEFFFF, %%eax\n"
27824 + " movl %%eax, %%cr0\n"
27825 +#endif
27826 +
27827 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
27828 +
27829 +#ifdef CONFIG_PAX_KERNEXEC
27830 + " movl %0, %%cr0\n"
27831 +#endif
27832 +
27833 " jmp 2b\n"
27834 ".previous\n"
27835 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
27836 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
27837
27838 for (i = 0; i < 4096/64; i++) {
27839 __asm__ __volatile__ (
27840 - "1: prefetch 320(%0)\n"
27841 - "2: movq (%0), %%mm0\n"
27842 - " movq 8(%0), %%mm1\n"
27843 - " movq 16(%0), %%mm2\n"
27844 - " movq 24(%0), %%mm3\n"
27845 - " movq %%mm0, (%1)\n"
27846 - " movq %%mm1, 8(%1)\n"
27847 - " movq %%mm2, 16(%1)\n"
27848 - " movq %%mm3, 24(%1)\n"
27849 - " movq 32(%0), %%mm0\n"
27850 - " movq 40(%0), %%mm1\n"
27851 - " movq 48(%0), %%mm2\n"
27852 - " movq 56(%0), %%mm3\n"
27853 - " movq %%mm0, 32(%1)\n"
27854 - " movq %%mm1, 40(%1)\n"
27855 - " movq %%mm2, 48(%1)\n"
27856 - " movq %%mm3, 56(%1)\n"
27857 + "1: prefetch 320(%1)\n"
27858 + "2: movq (%1), %%mm0\n"
27859 + " movq 8(%1), %%mm1\n"
27860 + " movq 16(%1), %%mm2\n"
27861 + " movq 24(%1), %%mm3\n"
27862 + " movq %%mm0, (%2)\n"
27863 + " movq %%mm1, 8(%2)\n"
27864 + " movq %%mm2, 16(%2)\n"
27865 + " movq %%mm3, 24(%2)\n"
27866 + " movq 32(%1), %%mm0\n"
27867 + " movq 40(%1), %%mm1\n"
27868 + " movq 48(%1), %%mm2\n"
27869 + " movq 56(%1), %%mm3\n"
27870 + " movq %%mm0, 32(%2)\n"
27871 + " movq %%mm1, 40(%2)\n"
27872 + " movq %%mm2, 48(%2)\n"
27873 + " movq %%mm3, 56(%2)\n"
27874 ".section .fixup, \"ax\"\n"
27875 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
27876 + "3:\n"
27877 +
27878 +#ifdef CONFIG_PAX_KERNEXEC
27879 + " movl %%cr0, %0\n"
27880 + " movl %0, %%eax\n"
27881 + " andl $0xFFFEFFFF, %%eax\n"
27882 + " movl %%eax, %%cr0\n"
27883 +#endif
27884 +
27885 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
27886 +
27887 +#ifdef CONFIG_PAX_KERNEXEC
27888 + " movl %0, %%cr0\n"
27889 +#endif
27890 +
27891 " jmp 2b\n"
27892 ".previous\n"
27893 _ASM_EXTABLE(1b, 3b)
27894 - : : "r" (from), "r" (to) : "memory");
27895 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
27896
27897 from += 64;
27898 to += 64;
27899 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
27900 index f6d13ee..aca5f0b 100644
27901 --- a/arch/x86/lib/msr-reg.S
27902 +++ b/arch/x86/lib/msr-reg.S
27903 @@ -3,6 +3,7 @@
27904 #include <asm/dwarf2.h>
27905 #include <asm/asm.h>
27906 #include <asm/msr.h>
27907 +#include <asm/alternative-asm.h>
27908
27909 #ifdef CONFIG_X86_64
27910 /*
27911 @@ -16,7 +17,7 @@ ENTRY(\op\()_safe_regs)
27912 CFI_STARTPROC
27913 pushq_cfi %rbx
27914 pushq_cfi %rbp
27915 - movq %rdi, %r10 /* Save pointer */
27916 + movq %rdi, %r9 /* Save pointer */
27917 xorl %r11d, %r11d /* Return value */
27918 movl (%rdi), %eax
27919 movl 4(%rdi), %ecx
27920 @@ -27,16 +28,17 @@ ENTRY(\op\()_safe_regs)
27921 movl 28(%rdi), %edi
27922 CFI_REMEMBER_STATE
27923 1: \op
27924 -2: movl %eax, (%r10)
27925 +2: movl %eax, (%r9)
27926 movl %r11d, %eax /* Return value */
27927 - movl %ecx, 4(%r10)
27928 - movl %edx, 8(%r10)
27929 - movl %ebx, 12(%r10)
27930 - movl %ebp, 20(%r10)
27931 - movl %esi, 24(%r10)
27932 - movl %edi, 28(%r10)
27933 + movl %ecx, 4(%r9)
27934 + movl %edx, 8(%r9)
27935 + movl %ebx, 12(%r9)
27936 + movl %ebp, 20(%r9)
27937 + movl %esi, 24(%r9)
27938 + movl %edi, 28(%r9)
27939 popq_cfi %rbp
27940 popq_cfi %rbx
27941 + pax_force_retaddr
27942 ret
27943 3:
27944 CFI_RESTORE_STATE
27945 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
27946 index fc6ba17..d4d989d 100644
27947 --- a/arch/x86/lib/putuser.S
27948 +++ b/arch/x86/lib/putuser.S
27949 @@ -16,7 +16,9 @@
27950 #include <asm/errno.h>
27951 #include <asm/asm.h>
27952 #include <asm/smap.h>
27953 -
27954 +#include <asm/segment.h>
27955 +#include <asm/pgtable.h>
27956 +#include <asm/alternative-asm.h>
27957
27958 /*
27959 * __put_user_X
27960 @@ -30,57 +32,125 @@
27961 * as they get called from within inline assembly.
27962 */
27963
27964 -#define ENTER CFI_STARTPROC ; \
27965 - GET_THREAD_INFO(%_ASM_BX)
27966 -#define EXIT ASM_CLAC ; \
27967 - ret ; \
27968 +#define ENTER CFI_STARTPROC
27969 +#define EXIT ASM_CLAC ; \
27970 + pax_force_retaddr ; \
27971 + ret ; \
27972 CFI_ENDPROC
27973
27974 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27975 +#define _DEST %_ASM_CX,%_ASM_BX
27976 +#else
27977 +#define _DEST %_ASM_CX
27978 +#endif
27979 +
27980 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
27981 +#define __copyuser_seg gs;
27982 +#else
27983 +#define __copyuser_seg
27984 +#endif
27985 +
27986 .text
27987 ENTRY(__put_user_1)
27988 ENTER
27989 +
27990 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
27991 + GET_THREAD_INFO(%_ASM_BX)
27992 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
27993 jae bad_put_user
27994 ASM_STAC
27995 -1: movb %al,(%_ASM_CX)
27996 +
27997 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
27998 + mov pax_user_shadow_base,%_ASM_BX
27999 + cmp %_ASM_BX,%_ASM_CX
28000 + jb 1234f
28001 + xor %ebx,%ebx
28002 +1234:
28003 +#endif
28004 +
28005 +#endif
28006 +
28007 +1: __copyuser_seg movb %al,(_DEST)
28008 xor %eax,%eax
28009 EXIT
28010 ENDPROC(__put_user_1)
28011
28012 ENTRY(__put_user_2)
28013 ENTER
28014 +
28015 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28016 + GET_THREAD_INFO(%_ASM_BX)
28017 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28018 sub $1,%_ASM_BX
28019 cmp %_ASM_BX,%_ASM_CX
28020 jae bad_put_user
28021 ASM_STAC
28022 -2: movw %ax,(%_ASM_CX)
28023 +
28024 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28025 + mov pax_user_shadow_base,%_ASM_BX
28026 + cmp %_ASM_BX,%_ASM_CX
28027 + jb 1234f
28028 + xor %ebx,%ebx
28029 +1234:
28030 +#endif
28031 +
28032 +#endif
28033 +
28034 +2: __copyuser_seg movw %ax,(_DEST)
28035 xor %eax,%eax
28036 EXIT
28037 ENDPROC(__put_user_2)
28038
28039 ENTRY(__put_user_4)
28040 ENTER
28041 +
28042 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28043 + GET_THREAD_INFO(%_ASM_BX)
28044 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28045 sub $3,%_ASM_BX
28046 cmp %_ASM_BX,%_ASM_CX
28047 jae bad_put_user
28048 ASM_STAC
28049 -3: movl %eax,(%_ASM_CX)
28050 +
28051 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28052 + mov pax_user_shadow_base,%_ASM_BX
28053 + cmp %_ASM_BX,%_ASM_CX
28054 + jb 1234f
28055 + xor %ebx,%ebx
28056 +1234:
28057 +#endif
28058 +
28059 +#endif
28060 +
28061 +3: __copyuser_seg movl %eax,(_DEST)
28062 xor %eax,%eax
28063 EXIT
28064 ENDPROC(__put_user_4)
28065
28066 ENTRY(__put_user_8)
28067 ENTER
28068 +
28069 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28070 + GET_THREAD_INFO(%_ASM_BX)
28071 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
28072 sub $7,%_ASM_BX
28073 cmp %_ASM_BX,%_ASM_CX
28074 jae bad_put_user
28075 ASM_STAC
28076 -4: mov %_ASM_AX,(%_ASM_CX)
28077 +
28078 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28079 + mov pax_user_shadow_base,%_ASM_BX
28080 + cmp %_ASM_BX,%_ASM_CX
28081 + jb 1234f
28082 + xor %ebx,%ebx
28083 +1234:
28084 +#endif
28085 +
28086 +#endif
28087 +
28088 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
28089 #ifdef CONFIG_X86_32
28090 -5: movl %edx,4(%_ASM_CX)
28091 +5: __copyuser_seg movl %edx,4(_DEST)
28092 #endif
28093 xor %eax,%eax
28094 EXIT
28095 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
28096 index 1cad221..de671ee 100644
28097 --- a/arch/x86/lib/rwlock.S
28098 +++ b/arch/x86/lib/rwlock.S
28099 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
28100 FRAME
28101 0: LOCK_PREFIX
28102 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
28103 +
28104 +#ifdef CONFIG_PAX_REFCOUNT
28105 + jno 1234f
28106 + LOCK_PREFIX
28107 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
28108 + int $4
28109 +1234:
28110 + _ASM_EXTABLE(1234b, 1234b)
28111 +#endif
28112 +
28113 1: rep; nop
28114 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
28115 jne 1b
28116 LOCK_PREFIX
28117 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
28118 +
28119 +#ifdef CONFIG_PAX_REFCOUNT
28120 + jno 1234f
28121 + LOCK_PREFIX
28122 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
28123 + int $4
28124 +1234:
28125 + _ASM_EXTABLE(1234b, 1234b)
28126 +#endif
28127 +
28128 jnz 0b
28129 ENDFRAME
28130 + pax_force_retaddr
28131 ret
28132 CFI_ENDPROC
28133 END(__write_lock_failed)
28134 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
28135 FRAME
28136 0: LOCK_PREFIX
28137 READ_LOCK_SIZE(inc) (%__lock_ptr)
28138 +
28139 +#ifdef CONFIG_PAX_REFCOUNT
28140 + jno 1234f
28141 + LOCK_PREFIX
28142 + READ_LOCK_SIZE(dec) (%__lock_ptr)
28143 + int $4
28144 +1234:
28145 + _ASM_EXTABLE(1234b, 1234b)
28146 +#endif
28147 +
28148 1: rep; nop
28149 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
28150 js 1b
28151 LOCK_PREFIX
28152 READ_LOCK_SIZE(dec) (%__lock_ptr)
28153 +
28154 +#ifdef CONFIG_PAX_REFCOUNT
28155 + jno 1234f
28156 + LOCK_PREFIX
28157 + READ_LOCK_SIZE(inc) (%__lock_ptr)
28158 + int $4
28159 +1234:
28160 + _ASM_EXTABLE(1234b, 1234b)
28161 +#endif
28162 +
28163 js 0b
28164 ENDFRAME
28165 + pax_force_retaddr
28166 ret
28167 CFI_ENDPROC
28168 END(__read_lock_failed)
28169 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
28170 index 5dff5f0..cadebf4 100644
28171 --- a/arch/x86/lib/rwsem.S
28172 +++ b/arch/x86/lib/rwsem.S
28173 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
28174 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
28175 CFI_RESTORE __ASM_REG(dx)
28176 restore_common_regs
28177 + pax_force_retaddr
28178 ret
28179 CFI_ENDPROC
28180 ENDPROC(call_rwsem_down_read_failed)
28181 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
28182 movq %rax,%rdi
28183 call rwsem_down_write_failed
28184 restore_common_regs
28185 + pax_force_retaddr
28186 ret
28187 CFI_ENDPROC
28188 ENDPROC(call_rwsem_down_write_failed)
28189 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
28190 movq %rax,%rdi
28191 call rwsem_wake
28192 restore_common_regs
28193 -1: ret
28194 +1: pax_force_retaddr
28195 + ret
28196 CFI_ENDPROC
28197 ENDPROC(call_rwsem_wake)
28198
28199 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
28200 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
28201 CFI_RESTORE __ASM_REG(dx)
28202 restore_common_regs
28203 + pax_force_retaddr
28204 ret
28205 CFI_ENDPROC
28206 ENDPROC(call_rwsem_downgrade_wake)
28207 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
28208 index a63efd6..ccecad8 100644
28209 --- a/arch/x86/lib/thunk_64.S
28210 +++ b/arch/x86/lib/thunk_64.S
28211 @@ -8,6 +8,7 @@
28212 #include <linux/linkage.h>
28213 #include <asm/dwarf2.h>
28214 #include <asm/calling.h>
28215 +#include <asm/alternative-asm.h>
28216
28217 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
28218 .macro THUNK name, func, put_ret_addr_in_rdi=0
28219 @@ -41,5 +42,6 @@
28220 SAVE_ARGS
28221 restore:
28222 RESTORE_ARGS
28223 + pax_force_retaddr
28224 ret
28225 CFI_ENDPROC
28226 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
28227 index 3eb18ac..6890bc3 100644
28228 --- a/arch/x86/lib/usercopy_32.c
28229 +++ b/arch/x86/lib/usercopy_32.c
28230 @@ -42,11 +42,13 @@ do { \
28231 int __d0; \
28232 might_fault(); \
28233 __asm__ __volatile__( \
28234 + __COPYUSER_SET_ES \
28235 ASM_STAC "\n" \
28236 "0: rep; stosl\n" \
28237 " movl %2,%0\n" \
28238 "1: rep; stosb\n" \
28239 "2: " ASM_CLAC "\n" \
28240 + __COPYUSER_RESTORE_ES \
28241 ".section .fixup,\"ax\"\n" \
28242 "3: lea 0(%2,%0,4),%0\n" \
28243 " jmp 2b\n" \
28244 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
28245
28246 #ifdef CONFIG_X86_INTEL_USERCOPY
28247 static unsigned long
28248 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
28249 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
28250 {
28251 int d0, d1;
28252 __asm__ __volatile__(
28253 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
28254 " .align 2,0x90\n"
28255 "3: movl 0(%4), %%eax\n"
28256 "4: movl 4(%4), %%edx\n"
28257 - "5: movl %%eax, 0(%3)\n"
28258 - "6: movl %%edx, 4(%3)\n"
28259 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
28260 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
28261 "7: movl 8(%4), %%eax\n"
28262 "8: movl 12(%4),%%edx\n"
28263 - "9: movl %%eax, 8(%3)\n"
28264 - "10: movl %%edx, 12(%3)\n"
28265 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
28266 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
28267 "11: movl 16(%4), %%eax\n"
28268 "12: movl 20(%4), %%edx\n"
28269 - "13: movl %%eax, 16(%3)\n"
28270 - "14: movl %%edx, 20(%3)\n"
28271 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
28272 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
28273 "15: movl 24(%4), %%eax\n"
28274 "16: movl 28(%4), %%edx\n"
28275 - "17: movl %%eax, 24(%3)\n"
28276 - "18: movl %%edx, 28(%3)\n"
28277 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
28278 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
28279 "19: movl 32(%4), %%eax\n"
28280 "20: movl 36(%4), %%edx\n"
28281 - "21: movl %%eax, 32(%3)\n"
28282 - "22: movl %%edx, 36(%3)\n"
28283 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
28284 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
28285 "23: movl 40(%4), %%eax\n"
28286 "24: movl 44(%4), %%edx\n"
28287 - "25: movl %%eax, 40(%3)\n"
28288 - "26: movl %%edx, 44(%3)\n"
28289 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
28290 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
28291 "27: movl 48(%4), %%eax\n"
28292 "28: movl 52(%4), %%edx\n"
28293 - "29: movl %%eax, 48(%3)\n"
28294 - "30: movl %%edx, 52(%3)\n"
28295 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
28296 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
28297 "31: movl 56(%4), %%eax\n"
28298 "32: movl 60(%4), %%edx\n"
28299 - "33: movl %%eax, 56(%3)\n"
28300 - "34: movl %%edx, 60(%3)\n"
28301 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
28302 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
28303 " addl $-64, %0\n"
28304 " addl $64, %4\n"
28305 " addl $64, %3\n"
28306 @@ -149,10 +151,12 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
28307 " shrl $2, %0\n"
28308 " andl $3, %%eax\n"
28309 " cld\n"
28310 + __COPYUSER_SET_ES
28311 "99: rep; movsl\n"
28312 "36: movl %%eax, %0\n"
28313 "37: rep; movsb\n"
28314 "100:\n"
28315 + __COPYUSER_RESTORE_ES
28316 ".section .fixup,\"ax\"\n"
28317 "101: lea 0(%%eax,%0,4),%0\n"
28318 " jmp 100b\n"
28319 @@ -202,46 +206,150 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
28320 }
28321
28322 static unsigned long
28323 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
28324 +{
28325 + int d0, d1;
28326 + __asm__ __volatile__(
28327 + " .align 2,0x90\n"
28328 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
28329 + " cmpl $67, %0\n"
28330 + " jbe 3f\n"
28331 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
28332 + " .align 2,0x90\n"
28333 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
28334 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
28335 + "5: movl %%eax, 0(%3)\n"
28336 + "6: movl %%edx, 4(%3)\n"
28337 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
28338 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
28339 + "9: movl %%eax, 8(%3)\n"
28340 + "10: movl %%edx, 12(%3)\n"
28341 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
28342 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
28343 + "13: movl %%eax, 16(%3)\n"
28344 + "14: movl %%edx, 20(%3)\n"
28345 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
28346 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
28347 + "17: movl %%eax, 24(%3)\n"
28348 + "18: movl %%edx, 28(%3)\n"
28349 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
28350 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
28351 + "21: movl %%eax, 32(%3)\n"
28352 + "22: movl %%edx, 36(%3)\n"
28353 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
28354 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
28355 + "25: movl %%eax, 40(%3)\n"
28356 + "26: movl %%edx, 44(%3)\n"
28357 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
28358 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
28359 + "29: movl %%eax, 48(%3)\n"
28360 + "30: movl %%edx, 52(%3)\n"
28361 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
28362 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
28363 + "33: movl %%eax, 56(%3)\n"
28364 + "34: movl %%edx, 60(%3)\n"
28365 + " addl $-64, %0\n"
28366 + " addl $64, %4\n"
28367 + " addl $64, %3\n"
28368 + " cmpl $63, %0\n"
28369 + " ja 1b\n"
28370 + "35: movl %0, %%eax\n"
28371 + " shrl $2, %0\n"
28372 + " andl $3, %%eax\n"
28373 + " cld\n"
28374 + "99: rep; "__copyuser_seg" movsl\n"
28375 + "36: movl %%eax, %0\n"
28376 + "37: rep; "__copyuser_seg" movsb\n"
28377 + "100:\n"
28378 + ".section .fixup,\"ax\"\n"
28379 + "101: lea 0(%%eax,%0,4),%0\n"
28380 + " jmp 100b\n"
28381 + ".previous\n"
28382 + _ASM_EXTABLE(1b,100b)
28383 + _ASM_EXTABLE(2b,100b)
28384 + _ASM_EXTABLE(3b,100b)
28385 + _ASM_EXTABLE(4b,100b)
28386 + _ASM_EXTABLE(5b,100b)
28387 + _ASM_EXTABLE(6b,100b)
28388 + _ASM_EXTABLE(7b,100b)
28389 + _ASM_EXTABLE(8b,100b)
28390 + _ASM_EXTABLE(9b,100b)
28391 + _ASM_EXTABLE(10b,100b)
28392 + _ASM_EXTABLE(11b,100b)
28393 + _ASM_EXTABLE(12b,100b)
28394 + _ASM_EXTABLE(13b,100b)
28395 + _ASM_EXTABLE(14b,100b)
28396 + _ASM_EXTABLE(15b,100b)
28397 + _ASM_EXTABLE(16b,100b)
28398 + _ASM_EXTABLE(17b,100b)
28399 + _ASM_EXTABLE(18b,100b)
28400 + _ASM_EXTABLE(19b,100b)
28401 + _ASM_EXTABLE(20b,100b)
28402 + _ASM_EXTABLE(21b,100b)
28403 + _ASM_EXTABLE(22b,100b)
28404 + _ASM_EXTABLE(23b,100b)
28405 + _ASM_EXTABLE(24b,100b)
28406 + _ASM_EXTABLE(25b,100b)
28407 + _ASM_EXTABLE(26b,100b)
28408 + _ASM_EXTABLE(27b,100b)
28409 + _ASM_EXTABLE(28b,100b)
28410 + _ASM_EXTABLE(29b,100b)
28411 + _ASM_EXTABLE(30b,100b)
28412 + _ASM_EXTABLE(31b,100b)
28413 + _ASM_EXTABLE(32b,100b)
28414 + _ASM_EXTABLE(33b,100b)
28415 + _ASM_EXTABLE(34b,100b)
28416 + _ASM_EXTABLE(35b,100b)
28417 + _ASM_EXTABLE(36b,100b)
28418 + _ASM_EXTABLE(37b,100b)
28419 + _ASM_EXTABLE(99b,101b)
28420 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
28421 + : "1"(to), "2"(from), "0"(size)
28422 + : "eax", "edx", "memory");
28423 + return size;
28424 +}
28425 +
28426 +static unsigned long __size_overflow(3)
28427 __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
28428 {
28429 int d0, d1;
28430 __asm__ __volatile__(
28431 " .align 2,0x90\n"
28432 - "0: movl 32(%4), %%eax\n"
28433 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
28434 " cmpl $67, %0\n"
28435 " jbe 2f\n"
28436 - "1: movl 64(%4), %%eax\n"
28437 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
28438 " .align 2,0x90\n"
28439 - "2: movl 0(%4), %%eax\n"
28440 - "21: movl 4(%4), %%edx\n"
28441 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
28442 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
28443 " movl %%eax, 0(%3)\n"
28444 " movl %%edx, 4(%3)\n"
28445 - "3: movl 8(%4), %%eax\n"
28446 - "31: movl 12(%4),%%edx\n"
28447 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
28448 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
28449 " movl %%eax, 8(%3)\n"
28450 " movl %%edx, 12(%3)\n"
28451 - "4: movl 16(%4), %%eax\n"
28452 - "41: movl 20(%4), %%edx\n"
28453 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
28454 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
28455 " movl %%eax, 16(%3)\n"
28456 " movl %%edx, 20(%3)\n"
28457 - "10: movl 24(%4), %%eax\n"
28458 - "51: movl 28(%4), %%edx\n"
28459 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
28460 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
28461 " movl %%eax, 24(%3)\n"
28462 " movl %%edx, 28(%3)\n"
28463 - "11: movl 32(%4), %%eax\n"
28464 - "61: movl 36(%4), %%edx\n"
28465 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
28466 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
28467 " movl %%eax, 32(%3)\n"
28468 " movl %%edx, 36(%3)\n"
28469 - "12: movl 40(%4), %%eax\n"
28470 - "71: movl 44(%4), %%edx\n"
28471 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
28472 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
28473 " movl %%eax, 40(%3)\n"
28474 " movl %%edx, 44(%3)\n"
28475 - "13: movl 48(%4), %%eax\n"
28476 - "81: movl 52(%4), %%edx\n"
28477 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
28478 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
28479 " movl %%eax, 48(%3)\n"
28480 " movl %%edx, 52(%3)\n"
28481 - "14: movl 56(%4), %%eax\n"
28482 - "91: movl 60(%4), %%edx\n"
28483 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
28484 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
28485 " movl %%eax, 56(%3)\n"
28486 " movl %%edx, 60(%3)\n"
28487 " addl $-64, %0\n"
28488 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
28489 " shrl $2, %0\n"
28490 " andl $3, %%eax\n"
28491 " cld\n"
28492 - "6: rep; movsl\n"
28493 + "6: rep; "__copyuser_seg" movsl\n"
28494 " movl %%eax,%0\n"
28495 - "7: rep; movsb\n"
28496 + "7: rep; "__copyuser_seg" movsb\n"
28497 "8:\n"
28498 ".section .fixup,\"ax\"\n"
28499 "9: lea 0(%%eax,%0,4),%0\n"
28500 @@ -298,48 +406,48 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
28501 * hyoshiok@miraclelinux.com
28502 */
28503
28504 -static unsigned long __copy_user_zeroing_intel_nocache(void *to,
28505 +static unsigned long __size_overflow(3) __copy_user_zeroing_intel_nocache(void *to,
28506 const void __user *from, unsigned long size)
28507 {
28508 int d0, d1;
28509
28510 __asm__ __volatile__(
28511 " .align 2,0x90\n"
28512 - "0: movl 32(%4), %%eax\n"
28513 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
28514 " cmpl $67, %0\n"
28515 " jbe 2f\n"
28516 - "1: movl 64(%4), %%eax\n"
28517 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
28518 " .align 2,0x90\n"
28519 - "2: movl 0(%4), %%eax\n"
28520 - "21: movl 4(%4), %%edx\n"
28521 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
28522 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
28523 " movnti %%eax, 0(%3)\n"
28524 " movnti %%edx, 4(%3)\n"
28525 - "3: movl 8(%4), %%eax\n"
28526 - "31: movl 12(%4),%%edx\n"
28527 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
28528 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
28529 " movnti %%eax, 8(%3)\n"
28530 " movnti %%edx, 12(%3)\n"
28531 - "4: movl 16(%4), %%eax\n"
28532 - "41: movl 20(%4), %%edx\n"
28533 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
28534 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
28535 " movnti %%eax, 16(%3)\n"
28536 " movnti %%edx, 20(%3)\n"
28537 - "10: movl 24(%4), %%eax\n"
28538 - "51: movl 28(%4), %%edx\n"
28539 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
28540 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
28541 " movnti %%eax, 24(%3)\n"
28542 " movnti %%edx, 28(%3)\n"
28543 - "11: movl 32(%4), %%eax\n"
28544 - "61: movl 36(%4), %%edx\n"
28545 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
28546 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
28547 " movnti %%eax, 32(%3)\n"
28548 " movnti %%edx, 36(%3)\n"
28549 - "12: movl 40(%4), %%eax\n"
28550 - "71: movl 44(%4), %%edx\n"
28551 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
28552 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
28553 " movnti %%eax, 40(%3)\n"
28554 " movnti %%edx, 44(%3)\n"
28555 - "13: movl 48(%4), %%eax\n"
28556 - "81: movl 52(%4), %%edx\n"
28557 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
28558 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
28559 " movnti %%eax, 48(%3)\n"
28560 " movnti %%edx, 52(%3)\n"
28561 - "14: movl 56(%4), %%eax\n"
28562 - "91: movl 60(%4), %%edx\n"
28563 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
28564 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
28565 " movnti %%eax, 56(%3)\n"
28566 " movnti %%edx, 60(%3)\n"
28567 " addl $-64, %0\n"
28568 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
28569 " shrl $2, %0\n"
28570 " andl $3, %%eax\n"
28571 " cld\n"
28572 - "6: rep; movsl\n"
28573 + "6: rep; "__copyuser_seg" movsl\n"
28574 " movl %%eax,%0\n"
28575 - "7: rep; movsb\n"
28576 + "7: rep; "__copyuser_seg" movsb\n"
28577 "8:\n"
28578 ".section .fixup,\"ax\"\n"
28579 "9: lea 0(%%eax,%0,4),%0\n"
28580 @@ -392,48 +500,48 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
28581 return size;
28582 }
28583
28584 -static unsigned long __copy_user_intel_nocache(void *to,
28585 +static unsigned long __size_overflow(3) __copy_user_intel_nocache(void *to,
28586 const void __user *from, unsigned long size)
28587 {
28588 int d0, d1;
28589
28590 __asm__ __volatile__(
28591 " .align 2,0x90\n"
28592 - "0: movl 32(%4), %%eax\n"
28593 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
28594 " cmpl $67, %0\n"
28595 " jbe 2f\n"
28596 - "1: movl 64(%4), %%eax\n"
28597 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
28598 " .align 2,0x90\n"
28599 - "2: movl 0(%4), %%eax\n"
28600 - "21: movl 4(%4), %%edx\n"
28601 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
28602 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
28603 " movnti %%eax, 0(%3)\n"
28604 " movnti %%edx, 4(%3)\n"
28605 - "3: movl 8(%4), %%eax\n"
28606 - "31: movl 12(%4),%%edx\n"
28607 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
28608 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
28609 " movnti %%eax, 8(%3)\n"
28610 " movnti %%edx, 12(%3)\n"
28611 - "4: movl 16(%4), %%eax\n"
28612 - "41: movl 20(%4), %%edx\n"
28613 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
28614 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
28615 " movnti %%eax, 16(%3)\n"
28616 " movnti %%edx, 20(%3)\n"
28617 - "10: movl 24(%4), %%eax\n"
28618 - "51: movl 28(%4), %%edx\n"
28619 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
28620 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
28621 " movnti %%eax, 24(%3)\n"
28622 " movnti %%edx, 28(%3)\n"
28623 - "11: movl 32(%4), %%eax\n"
28624 - "61: movl 36(%4), %%edx\n"
28625 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
28626 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
28627 " movnti %%eax, 32(%3)\n"
28628 " movnti %%edx, 36(%3)\n"
28629 - "12: movl 40(%4), %%eax\n"
28630 - "71: movl 44(%4), %%edx\n"
28631 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
28632 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
28633 " movnti %%eax, 40(%3)\n"
28634 " movnti %%edx, 44(%3)\n"
28635 - "13: movl 48(%4), %%eax\n"
28636 - "81: movl 52(%4), %%edx\n"
28637 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
28638 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
28639 " movnti %%eax, 48(%3)\n"
28640 " movnti %%edx, 52(%3)\n"
28641 - "14: movl 56(%4), %%eax\n"
28642 - "91: movl 60(%4), %%edx\n"
28643 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
28644 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
28645 " movnti %%eax, 56(%3)\n"
28646 " movnti %%edx, 60(%3)\n"
28647 " addl $-64, %0\n"
28648 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
28649 " shrl $2, %0\n"
28650 " andl $3, %%eax\n"
28651 " cld\n"
28652 - "6: rep; movsl\n"
28653 + "6: rep; "__copyuser_seg" movsl\n"
28654 " movl %%eax,%0\n"
28655 - "7: rep; movsb\n"
28656 + "7: rep; "__copyuser_seg" movsb\n"
28657 "8:\n"
28658 ".section .fixup,\"ax\"\n"
28659 "9: lea 0(%%eax,%0,4),%0\n"
28660 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
28661 */
28662 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
28663 unsigned long size);
28664 -unsigned long __copy_user_intel(void __user *to, const void *from,
28665 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
28666 + unsigned long size);
28667 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
28668 unsigned long size);
28669 unsigned long __copy_user_zeroing_intel_nocache(void *to,
28670 const void __user *from, unsigned long size);
28671 #endif /* CONFIG_X86_INTEL_USERCOPY */
28672
28673 /* Generic arbitrary sized copy. */
28674 -#define __copy_user(to, from, size) \
28675 +#define __copy_user(to, from, size, prefix, set, restore) \
28676 do { \
28677 int __d0, __d1, __d2; \
28678 __asm__ __volatile__( \
28679 + set \
28680 " cmp $7,%0\n" \
28681 " jbe 1f\n" \
28682 " movl %1,%0\n" \
28683 " negl %0\n" \
28684 " andl $7,%0\n" \
28685 " subl %0,%3\n" \
28686 - "4: rep; movsb\n" \
28687 + "4: rep; "prefix"movsb\n" \
28688 " movl %3,%0\n" \
28689 " shrl $2,%0\n" \
28690 " andl $3,%3\n" \
28691 " .align 2,0x90\n" \
28692 - "0: rep; movsl\n" \
28693 + "0: rep; "prefix"movsl\n" \
28694 " movl %3,%0\n" \
28695 - "1: rep; movsb\n" \
28696 + "1: rep; "prefix"movsb\n" \
28697 "2:\n" \
28698 + restore \
28699 ".section .fixup,\"ax\"\n" \
28700 "5: addl %3,%0\n" \
28701 " jmp 2b\n" \
28702 @@ -538,14 +650,14 @@ do { \
28703 " negl %0\n" \
28704 " andl $7,%0\n" \
28705 " subl %0,%3\n" \
28706 - "4: rep; movsb\n" \
28707 + "4: rep; "__copyuser_seg"movsb\n" \
28708 " movl %3,%0\n" \
28709 " shrl $2,%0\n" \
28710 " andl $3,%3\n" \
28711 " .align 2,0x90\n" \
28712 - "0: rep; movsl\n" \
28713 + "0: rep; "__copyuser_seg"movsl\n" \
28714 " movl %3,%0\n" \
28715 - "1: rep; movsb\n" \
28716 + "1: rep; "__copyuser_seg"movsb\n" \
28717 "2:\n" \
28718 ".section .fixup,\"ax\"\n" \
28719 "5: addl %3,%0\n" \
28720 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
28721 {
28722 stac();
28723 if (movsl_is_ok(to, from, n))
28724 - __copy_user(to, from, n);
28725 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
28726 else
28727 - n = __copy_user_intel(to, from, n);
28728 + n = __generic_copy_to_user_intel(to, from, n);
28729 clac();
28730 return n;
28731 }
28732 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
28733 {
28734 stac();
28735 if (movsl_is_ok(to, from, n))
28736 - __copy_user(to, from, n);
28737 + __copy_user(to, from, n, __copyuser_seg, "", "");
28738 else
28739 - n = __copy_user_intel((void __user *)to,
28740 - (const void *)from, n);
28741 + n = __generic_copy_from_user_intel(to, from, n);
28742 clac();
28743 return n;
28744 }
28745 @@ -632,60 +743,38 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
28746 if (n > 64 && cpu_has_xmm2)
28747 n = __copy_user_intel_nocache(to, from, n);
28748 else
28749 - __copy_user(to, from, n);
28750 + __copy_user(to, from, n, __copyuser_seg, "", "");
28751 #else
28752 - __copy_user(to, from, n);
28753 + __copy_user(to, from, n, __copyuser_seg, "", "");
28754 #endif
28755 clac();
28756 return n;
28757 }
28758 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
28759
28760 -/**
28761 - * copy_to_user: - Copy a block of data into user space.
28762 - * @to: Destination address, in user space.
28763 - * @from: Source address, in kernel space.
28764 - * @n: Number of bytes to copy.
28765 - *
28766 - * Context: User context only. This function may sleep.
28767 - *
28768 - * Copy data from kernel space to user space.
28769 - *
28770 - * Returns number of bytes that could not be copied.
28771 - * On success, this will be zero.
28772 - */
28773 -unsigned long
28774 -copy_to_user(void __user *to, const void *from, unsigned long n)
28775 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28776 +void __set_fs(mm_segment_t x)
28777 {
28778 - if (access_ok(VERIFY_WRITE, to, n))
28779 - n = __copy_to_user(to, from, n);
28780 - return n;
28781 + switch (x.seg) {
28782 + case 0:
28783 + loadsegment(gs, 0);
28784 + break;
28785 + case TASK_SIZE_MAX:
28786 + loadsegment(gs, __USER_DS);
28787 + break;
28788 + case -1UL:
28789 + loadsegment(gs, __KERNEL_DS);
28790 + break;
28791 + default:
28792 + BUG();
28793 + }
28794 }
28795 -EXPORT_SYMBOL(copy_to_user);
28796 +EXPORT_SYMBOL(__set_fs);
28797
28798 -/**
28799 - * copy_from_user: - Copy a block of data from user space.
28800 - * @to: Destination address, in kernel space.
28801 - * @from: Source address, in user space.
28802 - * @n: Number of bytes to copy.
28803 - *
28804 - * Context: User context only. This function may sleep.
28805 - *
28806 - * Copy data from user space to kernel space.
28807 - *
28808 - * Returns number of bytes that could not be copied.
28809 - * On success, this will be zero.
28810 - *
28811 - * If some data could not be copied, this function will pad the copied
28812 - * data to the requested size using zero bytes.
28813 - */
28814 -unsigned long
28815 -_copy_from_user(void *to, const void __user *from, unsigned long n)
28816 +void set_fs(mm_segment_t x)
28817 {
28818 - if (access_ok(VERIFY_READ, from, n))
28819 - n = __copy_from_user(to, from, n);
28820 - else
28821 - memset(to, 0, n);
28822 - return n;
28823 + current_thread_info()->addr_limit = x;
28824 + __set_fs(x);
28825 }
28826 -EXPORT_SYMBOL(_copy_from_user);
28827 +EXPORT_SYMBOL(set_fs);
28828 +#endif
28829 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
28830 index 906fea3..0194a18 100644
28831 --- a/arch/x86/lib/usercopy_64.c
28832 +++ b/arch/x86/lib/usercopy_64.c
28833 @@ -18,6 +18,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
28834 might_fault();
28835 /* no memory constraint because it doesn't change any memory gcc knows
28836 about */
28837 + pax_open_userland();
28838 stac();
28839 asm volatile(
28840 " testq %[size8],%[size8]\n"
28841 @@ -39,9 +40,10 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
28842 _ASM_EXTABLE(0b,3b)
28843 _ASM_EXTABLE(1b,2b)
28844 : [size8] "=&c"(size), [dst] "=&D" (__d0)
28845 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
28846 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
28847 [zero] "r" (0UL), [eight] "r" (8UL));
28848 clac();
28849 + pax_close_userland();
28850 return size;
28851 }
28852 EXPORT_SYMBOL(__clear_user);
28853 @@ -54,12 +56,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
28854 }
28855 EXPORT_SYMBOL(clear_user);
28856
28857 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
28858 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
28859 {
28860 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
28861 - return copy_user_generic((__force void *)to, (__force void *)from, len);
28862 - }
28863 - return len;
28864 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
28865 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
28866 + return len;
28867 }
28868 EXPORT_SYMBOL(copy_in_user);
28869
28870 @@ -69,11 +70,13 @@ EXPORT_SYMBOL(copy_in_user);
28871 * it is not necessary to optimize tail handling.
28872 */
28873 unsigned long
28874 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
28875 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
28876 {
28877 char c;
28878 unsigned zero_len;
28879
28880 + clac();
28881 + pax_close_userland();
28882 for (; len; --len, to++) {
28883 if (__get_user_nocheck(c, from++, sizeof(char)))
28884 break;
28885 @@ -84,6 +87,5 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
28886 for (c = 0, zero_len = len; zerorest && zero_len; --zero_len)
28887 if (__put_user_nocheck(c, to++, sizeof(char)))
28888 break;
28889 - clac();
28890 return len;
28891 }
28892 diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile
28893 index 23d8e5f..9ccc13a 100644
28894 --- a/arch/x86/mm/Makefile
28895 +++ b/arch/x86/mm/Makefile
28896 @@ -28,3 +28,7 @@ obj-$(CONFIG_ACPI_NUMA) += srat.o
28897 obj-$(CONFIG_NUMA_EMU) += numa_emulation.o
28898
28899 obj-$(CONFIG_MEMTEST) += memtest.o
28900 +
28901 +quote:="
28902 +obj-$(CONFIG_X86_64) += uderef_64.o
28903 +CFLAGS_uderef_64.o := $(subst $(quote),,$(CONFIG_ARCH_HWEIGHT_CFLAGS))
28904 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
28905 index 903ec1e..c4166b2 100644
28906 --- a/arch/x86/mm/extable.c
28907 +++ b/arch/x86/mm/extable.c
28908 @@ -6,12 +6,24 @@
28909 static inline unsigned long
28910 ex_insn_addr(const struct exception_table_entry *x)
28911 {
28912 - return (unsigned long)&x->insn + x->insn;
28913 + unsigned long reloc = 0;
28914 +
28915 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
28916 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
28917 +#endif
28918 +
28919 + return (unsigned long)&x->insn + x->insn + reloc;
28920 }
28921 static inline unsigned long
28922 ex_fixup_addr(const struct exception_table_entry *x)
28923 {
28924 - return (unsigned long)&x->fixup + x->fixup;
28925 + unsigned long reloc = 0;
28926 +
28927 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
28928 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
28929 +#endif
28930 +
28931 + return (unsigned long)&x->fixup + x->fixup + reloc;
28932 }
28933
28934 int fixup_exception(struct pt_regs *regs)
28935 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
28936 unsigned long new_ip;
28937
28938 #ifdef CONFIG_PNPBIOS
28939 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
28940 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
28941 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
28942 extern u32 pnp_bios_is_utter_crap;
28943 pnp_bios_is_utter_crap = 1;
28944 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
28945 i += 4;
28946 p->fixup -= i;
28947 i += 4;
28948 +
28949 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
28950 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
28951 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
28952 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
28953 +#endif
28954 +
28955 }
28956 }
28957
28958 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
28959 index 654be4a..a4a3da1 100644
28960 --- a/arch/x86/mm/fault.c
28961 +++ b/arch/x86/mm/fault.c
28962 @@ -14,11 +14,18 @@
28963 #include <linux/hugetlb.h> /* hstate_index_to_shift */
28964 #include <linux/prefetch.h> /* prefetchw */
28965 #include <linux/context_tracking.h> /* exception_enter(), ... */
28966 +#include <linux/unistd.h>
28967 +#include <linux/compiler.h>
28968
28969 #include <asm/traps.h> /* dotraplinkage, ... */
28970 #include <asm/pgalloc.h> /* pgd_*(), ... */
28971 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
28972 #include <asm/fixmap.h> /* VSYSCALL_START */
28973 +#include <asm/tlbflush.h>
28974 +
28975 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28976 +#include <asm/stacktrace.h>
28977 +#endif
28978
28979 /*
28980 * Page fault error code bits:
28981 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
28982 int ret = 0;
28983
28984 /* kprobe_running() needs smp_processor_id() */
28985 - if (kprobes_built_in() && !user_mode_vm(regs)) {
28986 + if (kprobes_built_in() && !user_mode(regs)) {
28987 preempt_disable();
28988 if (kprobe_running() && kprobe_fault_handler(regs, 14))
28989 ret = 1;
28990 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
28991 return !instr_lo || (instr_lo>>1) == 1;
28992 case 0x00:
28993 /* Prefetch instruction is 0x0F0D or 0x0F18 */
28994 - if (probe_kernel_address(instr, opcode))
28995 + if (user_mode(regs)) {
28996 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
28997 + return 0;
28998 + } else if (probe_kernel_address(instr, opcode))
28999 return 0;
29000
29001 *prefetch = (instr_lo == 0xF) &&
29002 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
29003 while (instr < max_instr) {
29004 unsigned char opcode;
29005
29006 - if (probe_kernel_address(instr, opcode))
29007 + if (user_mode(regs)) {
29008 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
29009 + break;
29010 + } else if (probe_kernel_address(instr, opcode))
29011 break;
29012
29013 instr++;
29014 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
29015 force_sig_info(si_signo, &info, tsk);
29016 }
29017
29018 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
29019 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
29020 +#endif
29021 +
29022 +#ifdef CONFIG_PAX_EMUTRAMP
29023 +static int pax_handle_fetch_fault(struct pt_regs *regs);
29024 +#endif
29025 +
29026 +#ifdef CONFIG_PAX_PAGEEXEC
29027 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
29028 +{
29029 + pgd_t *pgd;
29030 + pud_t *pud;
29031 + pmd_t *pmd;
29032 +
29033 + pgd = pgd_offset(mm, address);
29034 + if (!pgd_present(*pgd))
29035 + return NULL;
29036 + pud = pud_offset(pgd, address);
29037 + if (!pud_present(*pud))
29038 + return NULL;
29039 + pmd = pmd_offset(pud, address);
29040 + if (!pmd_present(*pmd))
29041 + return NULL;
29042 + return pmd;
29043 +}
29044 +#endif
29045 +
29046 DEFINE_SPINLOCK(pgd_lock);
29047 LIST_HEAD(pgd_list);
29048
29049 @@ -232,10 +273,27 @@ void vmalloc_sync_all(void)
29050 for (address = VMALLOC_START & PMD_MASK;
29051 address >= TASK_SIZE && address < FIXADDR_TOP;
29052 address += PMD_SIZE) {
29053 +
29054 +#ifdef CONFIG_PAX_PER_CPU_PGD
29055 + unsigned long cpu;
29056 +#else
29057 struct page *page;
29058 +#endif
29059
29060 spin_lock(&pgd_lock);
29061 +
29062 +#ifdef CONFIG_PAX_PER_CPU_PGD
29063 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
29064 + pgd_t *pgd = get_cpu_pgd(cpu, user);
29065 + pmd_t *ret;
29066 +
29067 + ret = vmalloc_sync_one(pgd, address);
29068 + if (!ret)
29069 + break;
29070 + pgd = get_cpu_pgd(cpu, kernel);
29071 +#else
29072 list_for_each_entry(page, &pgd_list, lru) {
29073 + pgd_t *pgd;
29074 spinlock_t *pgt_lock;
29075 pmd_t *ret;
29076
29077 @@ -243,8 +301,14 @@ void vmalloc_sync_all(void)
29078 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
29079
29080 spin_lock(pgt_lock);
29081 - ret = vmalloc_sync_one(page_address(page), address);
29082 + pgd = page_address(page);
29083 +#endif
29084 +
29085 + ret = vmalloc_sync_one(pgd, address);
29086 +
29087 +#ifndef CONFIG_PAX_PER_CPU_PGD
29088 spin_unlock(pgt_lock);
29089 +#endif
29090
29091 if (!ret)
29092 break;
29093 @@ -278,6 +342,12 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
29094 * an interrupt in the middle of a task switch..
29095 */
29096 pgd_paddr = read_cr3();
29097 +
29098 +#ifdef CONFIG_PAX_PER_CPU_PGD
29099 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (pgd_paddr & __PHYSICAL_MASK));
29100 + vmalloc_sync_one(__va(pgd_paddr + PAGE_SIZE), address);
29101 +#endif
29102 +
29103 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
29104 if (!pmd_k)
29105 return -1;
29106 @@ -373,11 +443,25 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
29107 * happen within a race in page table update. In the later
29108 * case just flush:
29109 */
29110 - pgd = pgd_offset(current->active_mm, address);
29111 +
29112 pgd_ref = pgd_offset_k(address);
29113 if (pgd_none(*pgd_ref))
29114 return -1;
29115
29116 +#ifdef CONFIG_PAX_PER_CPU_PGD
29117 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (read_cr3() & __PHYSICAL_MASK));
29118 + pgd = pgd_offset_cpu(smp_processor_id(), user, address);
29119 + if (pgd_none(*pgd)) {
29120 + set_pgd(pgd, *pgd_ref);
29121 + arch_flush_lazy_mmu_mode();
29122 + } else {
29123 + BUG_ON(pgd_page_vaddr(*pgd) != pgd_page_vaddr(*pgd_ref));
29124 + }
29125 + pgd = pgd_offset_cpu(smp_processor_id(), kernel, address);
29126 +#else
29127 + pgd = pgd_offset(current->active_mm, address);
29128 +#endif
29129 +
29130 if (pgd_none(*pgd)) {
29131 set_pgd(pgd, *pgd_ref);
29132 arch_flush_lazy_mmu_mode();
29133 @@ -543,7 +627,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
29134 static int is_errata100(struct pt_regs *regs, unsigned long address)
29135 {
29136 #ifdef CONFIG_X86_64
29137 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
29138 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
29139 return 1;
29140 #endif
29141 return 0;
29142 @@ -570,7 +654,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
29143 }
29144
29145 static const char nx_warning[] = KERN_CRIT
29146 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
29147 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
29148
29149 static void
29150 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
29151 @@ -579,15 +663,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
29152 if (!oops_may_print())
29153 return;
29154
29155 - if (error_code & PF_INSTR) {
29156 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
29157 unsigned int level;
29158
29159 pte_t *pte = lookup_address(address, &level);
29160
29161 if (pte && pte_present(*pte) && !pte_exec(*pte))
29162 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
29163 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
29164 }
29165
29166 +#ifdef CONFIG_PAX_KERNEXEC
29167 + if (init_mm.start_code <= address && address < init_mm.end_code) {
29168 + if (current->signal->curr_ip)
29169 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
29170 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
29171 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
29172 + else
29173 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
29174 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
29175 + }
29176 +#endif
29177 +
29178 printk(KERN_ALERT "BUG: unable to handle kernel ");
29179 if (address < PAGE_SIZE)
29180 printk(KERN_CONT "NULL pointer dereference");
29181 @@ -750,6 +846,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
29182 return;
29183 }
29184 #endif
29185 +
29186 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
29187 + if (pax_is_fetch_fault(regs, error_code, address)) {
29188 +
29189 +#ifdef CONFIG_PAX_EMUTRAMP
29190 + switch (pax_handle_fetch_fault(regs)) {
29191 + case 2:
29192 + return;
29193 + }
29194 +#endif
29195 +
29196 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
29197 + do_group_exit(SIGKILL);
29198 + }
29199 +#endif
29200 +
29201 /* Kernel addresses are always protection faults: */
29202 if (address >= TASK_SIZE)
29203 error_code |= PF_PROT;
29204 @@ -835,7 +947,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
29205 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
29206 printk(KERN_ERR
29207 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
29208 - tsk->comm, tsk->pid, address);
29209 + tsk->comm, task_pid_nr(tsk), address);
29210 code = BUS_MCEERR_AR;
29211 }
29212 #endif
29213 @@ -898,6 +1010,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
29214 return 1;
29215 }
29216
29217 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
29218 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
29219 +{
29220 + pte_t *pte;
29221 + pmd_t *pmd;
29222 + spinlock_t *ptl;
29223 + unsigned char pte_mask;
29224 +
29225 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
29226 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
29227 + return 0;
29228 +
29229 + /* PaX: it's our fault, let's handle it if we can */
29230 +
29231 + /* PaX: take a look at read faults before acquiring any locks */
29232 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
29233 + /* instruction fetch attempt from a protected page in user mode */
29234 + up_read(&mm->mmap_sem);
29235 +
29236 +#ifdef CONFIG_PAX_EMUTRAMP
29237 + switch (pax_handle_fetch_fault(regs)) {
29238 + case 2:
29239 + return 1;
29240 + }
29241 +#endif
29242 +
29243 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
29244 + do_group_exit(SIGKILL);
29245 + }
29246 +
29247 + pmd = pax_get_pmd(mm, address);
29248 + if (unlikely(!pmd))
29249 + return 0;
29250 +
29251 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
29252 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
29253 + pte_unmap_unlock(pte, ptl);
29254 + return 0;
29255 + }
29256 +
29257 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
29258 + /* write attempt to a protected page in user mode */
29259 + pte_unmap_unlock(pte, ptl);
29260 + return 0;
29261 + }
29262 +
29263 +#ifdef CONFIG_SMP
29264 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
29265 +#else
29266 + if (likely(address > get_limit(regs->cs)))
29267 +#endif
29268 + {
29269 + set_pte(pte, pte_mkread(*pte));
29270 + __flush_tlb_one(address);
29271 + pte_unmap_unlock(pte, ptl);
29272 + up_read(&mm->mmap_sem);
29273 + return 1;
29274 + }
29275 +
29276 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
29277 +
29278 + /*
29279 + * PaX: fill DTLB with user rights and retry
29280 + */
29281 + __asm__ __volatile__ (
29282 + "orb %2,(%1)\n"
29283 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
29284 +/*
29285 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
29286 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
29287 + * page fault when examined during a TLB load attempt. this is true not only
29288 + * for PTEs holding a non-present entry but also present entries that will
29289 + * raise a page fault (such as those set up by PaX, or the copy-on-write
29290 + * mechanism). in effect it means that we do *not* need to flush the TLBs
29291 + * for our target pages since their PTEs are simply not in the TLBs at all.
29292 +
29293 + * the best thing in omitting it is that we gain around 15-20% speed in the
29294 + * fast path of the page fault handler and can get rid of tracing since we
29295 + * can no longer flush unintended entries.
29296 + */
29297 + "invlpg (%0)\n"
29298 +#endif
29299 + __copyuser_seg"testb $0,(%0)\n"
29300 + "xorb %3,(%1)\n"
29301 + :
29302 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
29303 + : "memory", "cc");
29304 + pte_unmap_unlock(pte, ptl);
29305 + up_read(&mm->mmap_sem);
29306 + return 1;
29307 +}
29308 +#endif
29309 +
29310 /*
29311 * Handle a spurious fault caused by a stale TLB entry.
29312 *
29313 @@ -964,6 +1169,9 @@ int show_unhandled_signals = 1;
29314 static inline int
29315 access_error(unsigned long error_code, struct vm_area_struct *vma)
29316 {
29317 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
29318 + return 1;
29319 +
29320 if (error_code & PF_WRITE) {
29321 /* write, present and write, not present: */
29322 if (unlikely(!(vma->vm_flags & VM_WRITE)))
29323 @@ -992,7 +1200,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
29324 if (error_code & PF_USER)
29325 return false;
29326
29327 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
29328 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
29329 return false;
29330
29331 return true;
29332 @@ -1008,18 +1216,33 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
29333 {
29334 struct vm_area_struct *vma;
29335 struct task_struct *tsk;
29336 - unsigned long address;
29337 struct mm_struct *mm;
29338 int fault;
29339 int write = error_code & PF_WRITE;
29340 unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE |
29341 (write ? FAULT_FLAG_WRITE : 0);
29342
29343 - tsk = current;
29344 - mm = tsk->mm;
29345 -
29346 /* Get the faulting address: */
29347 - address = read_cr2();
29348 + unsigned long address = read_cr2();
29349 +
29350 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29351 + if (!user_mode(regs) && address < 2 * pax_user_shadow_base) {
29352 + if (!search_exception_tables(regs->ip)) {
29353 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
29354 + bad_area_nosemaphore(regs, error_code, address);
29355 + return;
29356 + }
29357 + if (address < pax_user_shadow_base) {
29358 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
29359 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
29360 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
29361 + } else
29362 + address -= pax_user_shadow_base;
29363 + }
29364 +#endif
29365 +
29366 + tsk = current;
29367 + mm = tsk->mm;
29368
29369 /*
29370 * Detect and handle instructions that would cause a page fault for
29371 @@ -1080,7 +1303,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
29372 * User-mode registers count as a user access even for any
29373 * potential system fault or CPU buglet:
29374 */
29375 - if (user_mode_vm(regs)) {
29376 + if (user_mode(regs)) {
29377 local_irq_enable();
29378 error_code |= PF_USER;
29379 } else {
29380 @@ -1142,6 +1365,11 @@ retry:
29381 might_sleep();
29382 }
29383
29384 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
29385 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
29386 + return;
29387 +#endif
29388 +
29389 vma = find_vma(mm, address);
29390 if (unlikely(!vma)) {
29391 bad_area(regs, error_code, address);
29392 @@ -1153,18 +1381,24 @@ retry:
29393 bad_area(regs, error_code, address);
29394 return;
29395 }
29396 - if (error_code & PF_USER) {
29397 - /*
29398 - * Accessing the stack below %sp is always a bug.
29399 - * The large cushion allows instructions like enter
29400 - * and pusha to work. ("enter $65535, $31" pushes
29401 - * 32 pointers and then decrements %sp by 65535.)
29402 - */
29403 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
29404 - bad_area(regs, error_code, address);
29405 - return;
29406 - }
29407 + /*
29408 + * Accessing the stack below %sp is always a bug.
29409 + * The large cushion allows instructions like enter
29410 + * and pusha to work. ("enter $65535, $31" pushes
29411 + * 32 pointers and then decrements %sp by 65535.)
29412 + */
29413 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
29414 + bad_area(regs, error_code, address);
29415 + return;
29416 }
29417 +
29418 +#ifdef CONFIG_PAX_SEGMEXEC
29419 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
29420 + bad_area(regs, error_code, address);
29421 + return;
29422 + }
29423 +#endif
29424 +
29425 if (unlikely(expand_stack(vma, address))) {
29426 bad_area(regs, error_code, address);
29427 return;
29428 @@ -1230,3 +1464,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
29429 __do_page_fault(regs, error_code);
29430 exception_exit(prev_state);
29431 }
29432 +
29433 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
29434 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
29435 +{
29436 + struct mm_struct *mm = current->mm;
29437 + unsigned long ip = regs->ip;
29438 +
29439 + if (v8086_mode(regs))
29440 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
29441 +
29442 +#ifdef CONFIG_PAX_PAGEEXEC
29443 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
29444 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
29445 + return true;
29446 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
29447 + return true;
29448 + return false;
29449 + }
29450 +#endif
29451 +
29452 +#ifdef CONFIG_PAX_SEGMEXEC
29453 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
29454 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
29455 + return true;
29456 + return false;
29457 + }
29458 +#endif
29459 +
29460 + return false;
29461 +}
29462 +#endif
29463 +
29464 +#ifdef CONFIG_PAX_EMUTRAMP
29465 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
29466 +{
29467 + int err;
29468 +
29469 + do { /* PaX: libffi trampoline emulation */
29470 + unsigned char mov, jmp;
29471 + unsigned int addr1, addr2;
29472 +
29473 +#ifdef CONFIG_X86_64
29474 + if ((regs->ip + 9) >> 32)
29475 + break;
29476 +#endif
29477 +
29478 + err = get_user(mov, (unsigned char __user *)regs->ip);
29479 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
29480 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
29481 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
29482 +
29483 + if (err)
29484 + break;
29485 +
29486 + if (mov == 0xB8 && jmp == 0xE9) {
29487 + regs->ax = addr1;
29488 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
29489 + return 2;
29490 + }
29491 + } while (0);
29492 +
29493 + do { /* PaX: gcc trampoline emulation #1 */
29494 + unsigned char mov1, mov2;
29495 + unsigned short jmp;
29496 + unsigned int addr1, addr2;
29497 +
29498 +#ifdef CONFIG_X86_64
29499 + if ((regs->ip + 11) >> 32)
29500 + break;
29501 +#endif
29502 +
29503 + err = get_user(mov1, (unsigned char __user *)regs->ip);
29504 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
29505 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
29506 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
29507 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
29508 +
29509 + if (err)
29510 + break;
29511 +
29512 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
29513 + regs->cx = addr1;
29514 + regs->ax = addr2;
29515 + regs->ip = addr2;
29516 + return 2;
29517 + }
29518 + } while (0);
29519 +
29520 + do { /* PaX: gcc trampoline emulation #2 */
29521 + unsigned char mov, jmp;
29522 + unsigned int addr1, addr2;
29523 +
29524 +#ifdef CONFIG_X86_64
29525 + if ((regs->ip + 9) >> 32)
29526 + break;
29527 +#endif
29528 +
29529 + err = get_user(mov, (unsigned char __user *)regs->ip);
29530 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
29531 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
29532 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
29533 +
29534 + if (err)
29535 + break;
29536 +
29537 + if (mov == 0xB9 && jmp == 0xE9) {
29538 + regs->cx = addr1;
29539 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
29540 + return 2;
29541 + }
29542 + } while (0);
29543 +
29544 + return 1; /* PaX in action */
29545 +}
29546 +
29547 +#ifdef CONFIG_X86_64
29548 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
29549 +{
29550 + int err;
29551 +
29552 + do { /* PaX: libffi trampoline emulation */
29553 + unsigned short mov1, mov2, jmp1;
29554 + unsigned char stcclc, jmp2;
29555 + unsigned long addr1, addr2;
29556 +
29557 + err = get_user(mov1, (unsigned short __user *)regs->ip);
29558 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
29559 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
29560 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
29561 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
29562 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
29563 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
29564 +
29565 + if (err)
29566 + break;
29567 +
29568 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
29569 + regs->r11 = addr1;
29570 + regs->r10 = addr2;
29571 + if (stcclc == 0xF8)
29572 + regs->flags &= ~X86_EFLAGS_CF;
29573 + else
29574 + regs->flags |= X86_EFLAGS_CF;
29575 + regs->ip = addr1;
29576 + return 2;
29577 + }
29578 + } while (0);
29579 +
29580 + do { /* PaX: gcc trampoline emulation #1 */
29581 + unsigned short mov1, mov2, jmp1;
29582 + unsigned char jmp2;
29583 + unsigned int addr1;
29584 + unsigned long addr2;
29585 +
29586 + err = get_user(mov1, (unsigned short __user *)regs->ip);
29587 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
29588 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
29589 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
29590 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
29591 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
29592 +
29593 + if (err)
29594 + break;
29595 +
29596 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
29597 + regs->r11 = addr1;
29598 + regs->r10 = addr2;
29599 + regs->ip = addr1;
29600 + return 2;
29601 + }
29602 + } while (0);
29603 +
29604 + do { /* PaX: gcc trampoline emulation #2 */
29605 + unsigned short mov1, mov2, jmp1;
29606 + unsigned char jmp2;
29607 + unsigned long addr1, addr2;
29608 +
29609 + err = get_user(mov1, (unsigned short __user *)regs->ip);
29610 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
29611 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
29612 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
29613 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
29614 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
29615 +
29616 + if (err)
29617 + break;
29618 +
29619 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
29620 + regs->r11 = addr1;
29621 + regs->r10 = addr2;
29622 + regs->ip = addr1;
29623 + return 2;
29624 + }
29625 + } while (0);
29626 +
29627 + return 1; /* PaX in action */
29628 +}
29629 +#endif
29630 +
29631 +/*
29632 + * PaX: decide what to do with offenders (regs->ip = fault address)
29633 + *
29634 + * returns 1 when task should be killed
29635 + * 2 when gcc trampoline was detected
29636 + */
29637 +static int pax_handle_fetch_fault(struct pt_regs *regs)
29638 +{
29639 + if (v8086_mode(regs))
29640 + return 1;
29641 +
29642 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
29643 + return 1;
29644 +
29645 +#ifdef CONFIG_X86_32
29646 + return pax_handle_fetch_fault_32(regs);
29647 +#else
29648 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
29649 + return pax_handle_fetch_fault_32(regs);
29650 + else
29651 + return pax_handle_fetch_fault_64(regs);
29652 +#endif
29653 +}
29654 +#endif
29655 +
29656 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
29657 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
29658 +{
29659 + long i;
29660 +
29661 + printk(KERN_ERR "PAX: bytes at PC: ");
29662 + for (i = 0; i < 20; i++) {
29663 + unsigned char c;
29664 + if (get_user(c, (unsigned char __force_user *)pc+i))
29665 + printk(KERN_CONT "?? ");
29666 + else
29667 + printk(KERN_CONT "%02x ", c);
29668 + }
29669 + printk("\n");
29670 +
29671 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
29672 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
29673 + unsigned long c;
29674 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
29675 +#ifdef CONFIG_X86_32
29676 + printk(KERN_CONT "???????? ");
29677 +#else
29678 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
29679 + printk(KERN_CONT "???????? ???????? ");
29680 + else
29681 + printk(KERN_CONT "???????????????? ");
29682 +#endif
29683 + } else {
29684 +#ifdef CONFIG_X86_64
29685 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
29686 + printk(KERN_CONT "%08x ", (unsigned int)c);
29687 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
29688 + } else
29689 +#endif
29690 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
29691 + }
29692 + }
29693 + printk("\n");
29694 +}
29695 +#endif
29696 +
29697 +/**
29698 + * probe_kernel_write(): safely attempt to write to a location
29699 + * @dst: address to write to
29700 + * @src: pointer to the data that shall be written
29701 + * @size: size of the data chunk
29702 + *
29703 + * Safely write to address @dst from the buffer at @src. If a kernel fault
29704 + * happens, handle that and return -EFAULT.
29705 + */
29706 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
29707 +{
29708 + long ret;
29709 + mm_segment_t old_fs = get_fs();
29710 +
29711 + set_fs(KERNEL_DS);
29712 + pagefault_disable();
29713 + pax_open_kernel();
29714 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
29715 + pax_close_kernel();
29716 + pagefault_enable();
29717 + set_fs(old_fs);
29718 +
29719 + return ret ? -EFAULT : 0;
29720 +}
29721 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
29722 index dd74e46..7d26398 100644
29723 --- a/arch/x86/mm/gup.c
29724 +++ b/arch/x86/mm/gup.c
29725 @@ -255,7 +255,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
29726 addr = start;
29727 len = (unsigned long) nr_pages << PAGE_SHIFT;
29728 end = start + len;
29729 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
29730 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
29731 (void __user *)start, len)))
29732 return 0;
29733
29734 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
29735 index 252b8f5..4dcfdc1 100644
29736 --- a/arch/x86/mm/highmem_32.c
29737 +++ b/arch/x86/mm/highmem_32.c
29738 @@ -44,7 +44,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
29739 idx = type + KM_TYPE_NR*smp_processor_id();
29740 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
29741 BUG_ON(!pte_none(*(kmap_pte-idx)));
29742 +
29743 + pax_open_kernel();
29744 set_pte(kmap_pte-idx, mk_pte(page, prot));
29745 + pax_close_kernel();
29746 +
29747 arch_flush_lazy_mmu_mode();
29748
29749 return (void *)vaddr;
29750 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
29751 index ae1aa71..d9bea75 100644
29752 --- a/arch/x86/mm/hugetlbpage.c
29753 +++ b/arch/x86/mm/hugetlbpage.c
29754 @@ -271,23 +271,30 @@ follow_huge_pud(struct mm_struct *mm, unsigned long address,
29755 #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
29756 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
29757 unsigned long addr, unsigned long len,
29758 - unsigned long pgoff, unsigned long flags)
29759 + unsigned long pgoff, unsigned long flags, unsigned long offset)
29760 {
29761 struct hstate *h = hstate_file(file);
29762 struct vm_unmapped_area_info info;
29763 -
29764 +
29765 info.flags = 0;
29766 info.length = len;
29767 info.low_limit = TASK_UNMAPPED_BASE;
29768 +
29769 +#ifdef CONFIG_PAX_RANDMMAP
29770 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
29771 + info.low_limit += current->mm->delta_mmap;
29772 +#endif
29773 +
29774 info.high_limit = TASK_SIZE;
29775 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
29776 info.align_offset = 0;
29777 + info.threadstack_offset = offset;
29778 return vm_unmapped_area(&info);
29779 }
29780
29781 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
29782 unsigned long addr0, unsigned long len,
29783 - unsigned long pgoff, unsigned long flags)
29784 + unsigned long pgoff, unsigned long flags, unsigned long offset)
29785 {
29786 struct hstate *h = hstate_file(file);
29787 struct vm_unmapped_area_info info;
29788 @@ -299,6 +306,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
29789 info.high_limit = current->mm->mmap_base;
29790 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
29791 info.align_offset = 0;
29792 + info.threadstack_offset = offset;
29793 addr = vm_unmapped_area(&info);
29794
29795 /*
29796 @@ -311,6 +319,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
29797 VM_BUG_ON(addr != -ENOMEM);
29798 info.flags = 0;
29799 info.low_limit = TASK_UNMAPPED_BASE;
29800 +
29801 +#ifdef CONFIG_PAX_RANDMMAP
29802 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
29803 + info.low_limit += current->mm->delta_mmap;
29804 +#endif
29805 +
29806 info.high_limit = TASK_SIZE;
29807 addr = vm_unmapped_area(&info);
29808 }
29809 @@ -325,10 +339,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
29810 struct hstate *h = hstate_file(file);
29811 struct mm_struct *mm = current->mm;
29812 struct vm_area_struct *vma;
29813 + unsigned long pax_task_size = TASK_SIZE;
29814 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
29815
29816 if (len & ~huge_page_mask(h))
29817 return -EINVAL;
29818 - if (len > TASK_SIZE)
29819 +
29820 +#ifdef CONFIG_PAX_SEGMEXEC
29821 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
29822 + pax_task_size = SEGMEXEC_TASK_SIZE;
29823 +#endif
29824 +
29825 + pax_task_size -= PAGE_SIZE;
29826 +
29827 + if (len > pax_task_size)
29828 return -ENOMEM;
29829
29830 if (flags & MAP_FIXED) {
29831 @@ -337,19 +361,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
29832 return addr;
29833 }
29834
29835 +#ifdef CONFIG_PAX_RANDMMAP
29836 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
29837 +#endif
29838 +
29839 if (addr) {
29840 addr = ALIGN(addr, huge_page_size(h));
29841 vma = find_vma(mm, addr);
29842 - if (TASK_SIZE - len >= addr &&
29843 - (!vma || addr + len <= vma->vm_start))
29844 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
29845 return addr;
29846 }
29847 if (mm->get_unmapped_area == arch_get_unmapped_area)
29848 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
29849 - pgoff, flags);
29850 + pgoff, flags, offset);
29851 else
29852 return hugetlb_get_unmapped_area_topdown(file, addr, len,
29853 - pgoff, flags);
29854 + pgoff, flags, offset);
29855 }
29856
29857 #endif /*HAVE_ARCH_HUGETLB_UNMAPPED_AREA*/
29858 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
29859 index 1f34e92..c97b98f 100644
29860 --- a/arch/x86/mm/init.c
29861 +++ b/arch/x86/mm/init.c
29862 @@ -4,6 +4,7 @@
29863 #include <linux/swap.h>
29864 #include <linux/memblock.h>
29865 #include <linux/bootmem.h> /* for max_low_pfn */
29866 +#include <linux/tboot.h>
29867
29868 #include <asm/cacheflush.h>
29869 #include <asm/e820.h>
29870 @@ -17,6 +18,8 @@
29871 #include <asm/proto.h>
29872 #include <asm/dma.h> /* for MAX_DMA_PFN */
29873 #include <asm/microcode.h>
29874 +#include <asm/desc.h>
29875 +#include <asm/bios_ebda.h>
29876
29877 #include "mm_internal.h"
29878
29879 @@ -465,7 +468,18 @@ void __init init_mem_mapping(void)
29880 early_ioremap_page_table_range_init();
29881 #endif
29882
29883 +#ifdef CONFIG_PAX_PER_CPU_PGD
29884 + clone_pgd_range(get_cpu_pgd(0, kernel) + KERNEL_PGD_BOUNDARY,
29885 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
29886 + KERNEL_PGD_PTRS);
29887 + clone_pgd_range(get_cpu_pgd(0, user) + KERNEL_PGD_BOUNDARY,
29888 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
29889 + KERNEL_PGD_PTRS);
29890 + load_cr3(get_cpu_pgd(0, kernel));
29891 +#else
29892 load_cr3(swapper_pg_dir);
29893 +#endif
29894 +
29895 __flush_tlb_all();
29896
29897 early_memtest(0, max_pfn_mapped << PAGE_SHIFT);
29898 @@ -481,10 +495,40 @@ void __init init_mem_mapping(void)
29899 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
29900 * mmio resources as well as potential bios/acpi data regions.
29901 */
29902 +
29903 +#ifdef CONFIG_GRKERNSEC_KMEM
29904 +static unsigned int ebda_start __read_only;
29905 +static unsigned int ebda_end __read_only;
29906 +#endif
29907 +
29908 int devmem_is_allowed(unsigned long pagenr)
29909 {
29910 - if (pagenr < 256)
29911 +#ifdef CONFIG_GRKERNSEC_KMEM
29912 + /* allow BDA */
29913 + if (!pagenr)
29914 return 1;
29915 + /* allow EBDA */
29916 + if (pagenr >= ebda_start && pagenr < ebda_end)
29917 + return 1;
29918 + /* if tboot is in use, allow access to its hardcoded serial log range */
29919 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
29920 + return 1;
29921 +#else
29922 + if (!pagenr)
29923 + return 1;
29924 +#ifdef CONFIG_VM86
29925 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
29926 + return 1;
29927 +#endif
29928 +#endif
29929 +
29930 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
29931 + return 1;
29932 +#ifdef CONFIG_GRKERNSEC_KMEM
29933 + /* throw out everything else below 1MB */
29934 + if (pagenr <= 256)
29935 + return 0;
29936 +#endif
29937 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
29938 return 0;
29939 if (!page_is_ram(pagenr))
29940 @@ -538,8 +582,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
29941 #endif
29942 }
29943
29944 +#ifdef CONFIG_GRKERNSEC_KMEM
29945 +static inline void gr_init_ebda(void)
29946 +{
29947 + unsigned int ebda_addr;
29948 + unsigned int ebda_size = 0;
29949 +
29950 + ebda_addr = get_bios_ebda();
29951 + if (ebda_addr) {
29952 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
29953 + ebda_size <<= 10;
29954 + }
29955 + if (ebda_addr && ebda_size) {
29956 + ebda_start = ebda_addr >> PAGE_SHIFT;
29957 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
29958 + } else {
29959 + ebda_start = 0x9f000 >> PAGE_SHIFT;
29960 + ebda_end = 0xa0000 >> PAGE_SHIFT;
29961 + }
29962 +}
29963 +#else
29964 +static inline void gr_init_ebda(void) { }
29965 +#endif
29966 +
29967 void free_initmem(void)
29968 {
29969 +#ifdef CONFIG_PAX_KERNEXEC
29970 +#ifdef CONFIG_X86_32
29971 + /* PaX: limit KERNEL_CS to actual size */
29972 + unsigned long addr, limit;
29973 + struct desc_struct d;
29974 + int cpu;
29975 +#else
29976 + pgd_t *pgd;
29977 + pud_t *pud;
29978 + pmd_t *pmd;
29979 + unsigned long addr, end;
29980 +#endif
29981 +#endif
29982 +
29983 + gr_init_ebda();
29984 +
29985 +#ifdef CONFIG_PAX_KERNEXEC
29986 +#ifdef CONFIG_X86_32
29987 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
29988 + limit = (limit - 1UL) >> PAGE_SHIFT;
29989 +
29990 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
29991 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
29992 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
29993 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
29994 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
29995 + }
29996 +
29997 + /* PaX: make KERNEL_CS read-only */
29998 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
29999 + if (!paravirt_enabled())
30000 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
30001 +/*
30002 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
30003 + pgd = pgd_offset_k(addr);
30004 + pud = pud_offset(pgd, addr);
30005 + pmd = pmd_offset(pud, addr);
30006 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30007 + }
30008 +*/
30009 +#ifdef CONFIG_X86_PAE
30010 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
30011 +/*
30012 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
30013 + pgd = pgd_offset_k(addr);
30014 + pud = pud_offset(pgd, addr);
30015 + pmd = pmd_offset(pud, addr);
30016 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
30017 + }
30018 +*/
30019 +#endif
30020 +
30021 +#ifdef CONFIG_MODULES
30022 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
30023 +#endif
30024 +
30025 +#else
30026 + /* PaX: make kernel code/rodata read-only, rest non-executable */
30027 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
30028 + pgd = pgd_offset_k(addr);
30029 + pud = pud_offset(pgd, addr);
30030 + pmd = pmd_offset(pud, addr);
30031 + if (!pmd_present(*pmd))
30032 + continue;
30033 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
30034 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30035 + else
30036 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
30037 + }
30038 +
30039 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
30040 + end = addr + KERNEL_IMAGE_SIZE;
30041 + for (; addr < end; addr += PMD_SIZE) {
30042 + pgd = pgd_offset_k(addr);
30043 + pud = pud_offset(pgd, addr);
30044 + pmd = pmd_offset(pud, addr);
30045 + if (!pmd_present(*pmd))
30046 + continue;
30047 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
30048 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
30049 + }
30050 +#endif
30051 +
30052 + flush_tlb_all();
30053 +#endif
30054 +
30055 free_init_pages("unused kernel memory",
30056 (unsigned long)(&__init_begin),
30057 (unsigned long)(&__init_end));
30058 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
30059 index 3ac7e31..89611b7 100644
30060 --- a/arch/x86/mm/init_32.c
30061 +++ b/arch/x86/mm/init_32.c
30062 @@ -62,33 +62,6 @@ static noinline int do_test_wp_bit(void);
30063 bool __read_mostly __vmalloc_start_set = false;
30064
30065 /*
30066 - * Creates a middle page table and puts a pointer to it in the
30067 - * given global directory entry. This only returns the gd entry
30068 - * in non-PAE compilation mode, since the middle layer is folded.
30069 - */
30070 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
30071 -{
30072 - pud_t *pud;
30073 - pmd_t *pmd_table;
30074 -
30075 -#ifdef CONFIG_X86_PAE
30076 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
30077 - pmd_table = (pmd_t *)alloc_low_page();
30078 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
30079 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
30080 - pud = pud_offset(pgd, 0);
30081 - BUG_ON(pmd_table != pmd_offset(pud, 0));
30082 -
30083 - return pmd_table;
30084 - }
30085 -#endif
30086 - pud = pud_offset(pgd, 0);
30087 - pmd_table = pmd_offset(pud, 0);
30088 -
30089 - return pmd_table;
30090 -}
30091 -
30092 -/*
30093 * Create a page table and place a pointer to it in a middle page
30094 * directory entry:
30095 */
30096 @@ -98,13 +71,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
30097 pte_t *page_table = (pte_t *)alloc_low_page();
30098
30099 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
30100 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30101 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
30102 +#else
30103 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
30104 +#endif
30105 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
30106 }
30107
30108 return pte_offset_kernel(pmd, 0);
30109 }
30110
30111 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
30112 +{
30113 + pud_t *pud;
30114 + pmd_t *pmd_table;
30115 +
30116 + pud = pud_offset(pgd, 0);
30117 + pmd_table = pmd_offset(pud, 0);
30118 +
30119 + return pmd_table;
30120 +}
30121 +
30122 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
30123 {
30124 int pgd_idx = pgd_index(vaddr);
30125 @@ -208,6 +196,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
30126 int pgd_idx, pmd_idx;
30127 unsigned long vaddr;
30128 pgd_t *pgd;
30129 + pud_t *pud;
30130 pmd_t *pmd;
30131 pte_t *pte = NULL;
30132 unsigned long count = page_table_range_init_count(start, end);
30133 @@ -222,8 +211,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
30134 pgd = pgd_base + pgd_idx;
30135
30136 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
30137 - pmd = one_md_table_init(pgd);
30138 - pmd = pmd + pmd_index(vaddr);
30139 + pud = pud_offset(pgd, vaddr);
30140 + pmd = pmd_offset(pud, vaddr);
30141 +
30142 +#ifdef CONFIG_X86_PAE
30143 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
30144 +#endif
30145 +
30146 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
30147 pmd++, pmd_idx++) {
30148 pte = page_table_kmap_check(one_page_table_init(pmd),
30149 @@ -235,11 +229,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
30150 }
30151 }
30152
30153 -static inline int is_kernel_text(unsigned long addr)
30154 +static inline int is_kernel_text(unsigned long start, unsigned long end)
30155 {
30156 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
30157 - return 1;
30158 - return 0;
30159 + if ((start > ktla_ktva((unsigned long)_etext) ||
30160 + end <= ktla_ktva((unsigned long)_stext)) &&
30161 + (start > ktla_ktva((unsigned long)_einittext) ||
30162 + end <= ktla_ktva((unsigned long)_sinittext)) &&
30163 +
30164 +#ifdef CONFIG_ACPI_SLEEP
30165 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
30166 +#endif
30167 +
30168 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
30169 + return 0;
30170 + return 1;
30171 }
30172
30173 /*
30174 @@ -256,9 +259,10 @@ kernel_physical_mapping_init(unsigned long start,
30175 unsigned long last_map_addr = end;
30176 unsigned long start_pfn, end_pfn;
30177 pgd_t *pgd_base = swapper_pg_dir;
30178 - int pgd_idx, pmd_idx, pte_ofs;
30179 + unsigned int pgd_idx, pmd_idx, pte_ofs;
30180 unsigned long pfn;
30181 pgd_t *pgd;
30182 + pud_t *pud;
30183 pmd_t *pmd;
30184 pte_t *pte;
30185 unsigned pages_2m, pages_4k;
30186 @@ -291,8 +295,13 @@ repeat:
30187 pfn = start_pfn;
30188 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
30189 pgd = pgd_base + pgd_idx;
30190 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
30191 - pmd = one_md_table_init(pgd);
30192 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
30193 + pud = pud_offset(pgd, 0);
30194 + pmd = pmd_offset(pud, 0);
30195 +
30196 +#ifdef CONFIG_X86_PAE
30197 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
30198 +#endif
30199
30200 if (pfn >= end_pfn)
30201 continue;
30202 @@ -304,14 +313,13 @@ repeat:
30203 #endif
30204 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
30205 pmd++, pmd_idx++) {
30206 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
30207 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
30208
30209 /*
30210 * Map with big pages if possible, otherwise
30211 * create normal page tables:
30212 */
30213 if (use_pse) {
30214 - unsigned int addr2;
30215 pgprot_t prot = PAGE_KERNEL_LARGE;
30216 /*
30217 * first pass will use the same initial
30218 @@ -322,11 +330,7 @@ repeat:
30219 _PAGE_PSE);
30220
30221 pfn &= PMD_MASK >> PAGE_SHIFT;
30222 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
30223 - PAGE_OFFSET + PAGE_SIZE-1;
30224 -
30225 - if (is_kernel_text(addr) ||
30226 - is_kernel_text(addr2))
30227 + if (is_kernel_text(address, address + PMD_SIZE))
30228 prot = PAGE_KERNEL_LARGE_EXEC;
30229
30230 pages_2m++;
30231 @@ -343,7 +347,7 @@ repeat:
30232 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
30233 pte += pte_ofs;
30234 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
30235 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
30236 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
30237 pgprot_t prot = PAGE_KERNEL;
30238 /*
30239 * first pass will use the same initial
30240 @@ -351,7 +355,7 @@ repeat:
30241 */
30242 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
30243
30244 - if (is_kernel_text(addr))
30245 + if (is_kernel_text(address, address + PAGE_SIZE))
30246 prot = PAGE_KERNEL_EXEC;
30247
30248 pages_4k++;
30249 @@ -474,7 +478,7 @@ void __init native_pagetable_init(void)
30250
30251 pud = pud_offset(pgd, va);
30252 pmd = pmd_offset(pud, va);
30253 - if (!pmd_present(*pmd))
30254 + if (!pmd_present(*pmd)) // PAX TODO || pmd_large(*pmd))
30255 break;
30256
30257 /* should not be large page here */
30258 @@ -532,12 +536,10 @@ void __init early_ioremap_page_table_range_init(void)
30259
30260 static void __init pagetable_init(void)
30261 {
30262 - pgd_t *pgd_base = swapper_pg_dir;
30263 -
30264 - permanent_kmaps_init(pgd_base);
30265 + permanent_kmaps_init(swapper_pg_dir);
30266 }
30267
30268 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
30269 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
30270 EXPORT_SYMBOL_GPL(__supported_pte_mask);
30271
30272 /* user-defined highmem size */
30273 @@ -772,7 +774,7 @@ void __init mem_init(void)
30274 after_bootmem = 1;
30275
30276 codesize = (unsigned long) &_etext - (unsigned long) &_text;
30277 - datasize = (unsigned long) &_edata - (unsigned long) &_etext;
30278 + datasize = (unsigned long) &_edata - (unsigned long) &_sdata;
30279 initsize = (unsigned long) &__init_end - (unsigned long) &__init_begin;
30280
30281 printk(KERN_INFO "Memory: %luk/%luk available (%dk kernel code, "
30282 @@ -813,10 +815,10 @@ void __init mem_init(void)
30283 ((unsigned long)&__init_end -
30284 (unsigned long)&__init_begin) >> 10,
30285
30286 - (unsigned long)&_etext, (unsigned long)&_edata,
30287 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
30288 + (unsigned long)&_sdata, (unsigned long)&_edata,
30289 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
30290
30291 - (unsigned long)&_text, (unsigned long)&_etext,
30292 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
30293 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
30294
30295 /*
30296 @@ -906,6 +908,7 @@ void set_kernel_text_rw(void)
30297 if (!kernel_set_to_readonly)
30298 return;
30299
30300 + start = ktla_ktva(start);
30301 pr_debug("Set kernel text: %lx - %lx for read write\n",
30302 start, start+size);
30303
30304 @@ -920,6 +923,7 @@ void set_kernel_text_ro(void)
30305 if (!kernel_set_to_readonly)
30306 return;
30307
30308 + start = ktla_ktva(start);
30309 pr_debug("Set kernel text: %lx - %lx for read only\n",
30310 start, start+size);
30311
30312 @@ -948,6 +952,7 @@ void mark_rodata_ro(void)
30313 unsigned long start = PFN_ALIGN(_text);
30314 unsigned long size = PFN_ALIGN(_etext) - start;
30315
30316 + start = ktla_ktva(start);
30317 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
30318 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
30319 size >> 10);
30320 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
30321 index bb00c46..bf91a67 100644
30322 --- a/arch/x86/mm/init_64.c
30323 +++ b/arch/x86/mm/init_64.c
30324 @@ -151,7 +151,7 @@ early_param("gbpages", parse_direct_gbpages_on);
30325 * around without checking the pgd every time.
30326 */
30327
30328 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
30329 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
30330 EXPORT_SYMBOL_GPL(__supported_pte_mask);
30331
30332 int force_personality32;
30333 @@ -184,12 +184,29 @@ void sync_global_pgds(unsigned long start, unsigned long end)
30334
30335 for (address = start; address <= end; address += PGDIR_SIZE) {
30336 const pgd_t *pgd_ref = pgd_offset_k(address);
30337 +
30338 +#ifdef CONFIG_PAX_PER_CPU_PGD
30339 + unsigned long cpu;
30340 +#else
30341 struct page *page;
30342 +#endif
30343
30344 if (pgd_none(*pgd_ref))
30345 continue;
30346
30347 spin_lock(&pgd_lock);
30348 +
30349 +#ifdef CONFIG_PAX_PER_CPU_PGD
30350 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
30351 + pgd_t *pgd = pgd_offset_cpu(cpu, user, address);
30352 +
30353 + if (pgd_none(*pgd))
30354 + set_pgd(pgd, *pgd_ref);
30355 + else
30356 + BUG_ON(pgd_page_vaddr(*pgd)
30357 + != pgd_page_vaddr(*pgd_ref));
30358 + pgd = pgd_offset_cpu(cpu, kernel, address);
30359 +#else
30360 list_for_each_entry(page, &pgd_list, lru) {
30361 pgd_t *pgd;
30362 spinlock_t *pgt_lock;
30363 @@ -198,6 +215,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
30364 /* the pgt_lock only for Xen */
30365 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
30366 spin_lock(pgt_lock);
30367 +#endif
30368
30369 if (pgd_none(*pgd))
30370 set_pgd(pgd, *pgd_ref);
30371 @@ -205,7 +223,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
30372 BUG_ON(pgd_page_vaddr(*pgd)
30373 != pgd_page_vaddr(*pgd_ref));
30374
30375 +#ifndef CONFIG_PAX_PER_CPU_PGD
30376 spin_unlock(pgt_lock);
30377 +#endif
30378 +
30379 }
30380 spin_unlock(&pgd_lock);
30381 }
30382 @@ -238,7 +259,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
30383 {
30384 if (pgd_none(*pgd)) {
30385 pud_t *pud = (pud_t *)spp_getpage();
30386 - pgd_populate(&init_mm, pgd, pud);
30387 + pgd_populate_kernel(&init_mm, pgd, pud);
30388 if (pud != pud_offset(pgd, 0))
30389 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
30390 pud, pud_offset(pgd, 0));
30391 @@ -250,7 +271,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
30392 {
30393 if (pud_none(*pud)) {
30394 pmd_t *pmd = (pmd_t *) spp_getpage();
30395 - pud_populate(&init_mm, pud, pmd);
30396 + pud_populate_kernel(&init_mm, pud, pmd);
30397 if (pmd != pmd_offset(pud, 0))
30398 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
30399 pmd, pmd_offset(pud, 0));
30400 @@ -279,7 +300,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
30401 pmd = fill_pmd(pud, vaddr);
30402 pte = fill_pte(pmd, vaddr);
30403
30404 + pax_open_kernel();
30405 set_pte(pte, new_pte);
30406 + pax_close_kernel();
30407
30408 /*
30409 * It's enough to flush this one mapping.
30410 @@ -338,14 +361,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
30411 pgd = pgd_offset_k((unsigned long)__va(phys));
30412 if (pgd_none(*pgd)) {
30413 pud = (pud_t *) spp_getpage();
30414 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
30415 - _PAGE_USER));
30416 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
30417 }
30418 pud = pud_offset(pgd, (unsigned long)__va(phys));
30419 if (pud_none(*pud)) {
30420 pmd = (pmd_t *) spp_getpage();
30421 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
30422 - _PAGE_USER));
30423 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
30424 }
30425 pmd = pmd_offset(pud, phys);
30426 BUG_ON(!pmd_none(*pmd));
30427 @@ -586,7 +607,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
30428 prot);
30429
30430 spin_lock(&init_mm.page_table_lock);
30431 - pud_populate(&init_mm, pud, pmd);
30432 + pud_populate_kernel(&init_mm, pud, pmd);
30433 spin_unlock(&init_mm.page_table_lock);
30434 }
30435 __flush_tlb_all();
30436 @@ -627,7 +648,7 @@ kernel_physical_mapping_init(unsigned long start,
30437 page_size_mask);
30438
30439 spin_lock(&init_mm.page_table_lock);
30440 - pgd_populate(&init_mm, pgd, pud);
30441 + pgd_populate_kernel(&init_mm, pgd, pud);
30442 spin_unlock(&init_mm.page_table_lock);
30443 pgd_changed = true;
30444 }
30445 @@ -1221,8 +1242,8 @@ int kern_addr_valid(unsigned long addr)
30446 static struct vm_area_struct gate_vma = {
30447 .vm_start = VSYSCALL_START,
30448 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
30449 - .vm_page_prot = PAGE_READONLY_EXEC,
30450 - .vm_flags = VM_READ | VM_EXEC
30451 + .vm_page_prot = PAGE_READONLY,
30452 + .vm_flags = VM_READ
30453 };
30454
30455 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
30456 @@ -1256,7 +1277,7 @@ int in_gate_area_no_mm(unsigned long addr)
30457
30458 const char *arch_vma_name(struct vm_area_struct *vma)
30459 {
30460 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
30461 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
30462 return "[vdso]";
30463 if (vma == &gate_vma)
30464 return "[vsyscall]";
30465 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
30466 index 7b179b4..6bd17777 100644
30467 --- a/arch/x86/mm/iomap_32.c
30468 +++ b/arch/x86/mm/iomap_32.c
30469 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
30470 type = kmap_atomic_idx_push();
30471 idx = type + KM_TYPE_NR * smp_processor_id();
30472 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
30473 +
30474 + pax_open_kernel();
30475 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
30476 + pax_close_kernel();
30477 +
30478 arch_flush_lazy_mmu_mode();
30479
30480 return (void *)vaddr;
30481 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
30482 index 9a1e658..da003f3 100644
30483 --- a/arch/x86/mm/ioremap.c
30484 +++ b/arch/x86/mm/ioremap.c
30485 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
30486 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
30487 int is_ram = page_is_ram(pfn);
30488
30489 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
30490 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
30491 return NULL;
30492 WARN_ON_ONCE(is_ram);
30493 }
30494 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
30495 *
30496 * Caller must ensure there is only one unmapping for the same pointer.
30497 */
30498 -void iounmap(volatile void __iomem *addr)
30499 +void iounmap(const volatile void __iomem *addr)
30500 {
30501 struct vm_struct *p, *o;
30502
30503 @@ -310,6 +310,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
30504
30505 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
30506 if (page_is_ram(start >> PAGE_SHIFT))
30507 +#ifdef CONFIG_HIGHMEM
30508 + if ((start >> PAGE_SHIFT) < max_low_pfn)
30509 +#endif
30510 return __va(phys);
30511
30512 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
30513 @@ -322,6 +325,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
30514 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
30515 {
30516 if (page_is_ram(phys >> PAGE_SHIFT))
30517 +#ifdef CONFIG_HIGHMEM
30518 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
30519 +#endif
30520 return;
30521
30522 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
30523 @@ -339,7 +345,7 @@ static int __init early_ioremap_debug_setup(char *str)
30524 early_param("early_ioremap_debug", early_ioremap_debug_setup);
30525
30526 static __initdata int after_paging_init;
30527 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
30528 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
30529
30530 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
30531 {
30532 @@ -376,8 +382,7 @@ void __init early_ioremap_init(void)
30533 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
30534
30535 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
30536 - memset(bm_pte, 0, sizeof(bm_pte));
30537 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
30538 + pmd_populate_user(&init_mm, pmd, bm_pte);
30539
30540 /*
30541 * The boot-ioremap range spans multiple pmds, for which
30542 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
30543 index d87dd6d..bf3fa66 100644
30544 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
30545 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
30546 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
30547 * memory (e.g. tracked pages)? For now, we need this to avoid
30548 * invoking kmemcheck for PnP BIOS calls.
30549 */
30550 - if (regs->flags & X86_VM_MASK)
30551 + if (v8086_mode(regs))
30552 return false;
30553 - if (regs->cs != __KERNEL_CS)
30554 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
30555 return false;
30556
30557 pte = kmemcheck_pte_lookup(address);
30558 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
30559 index c1af323..4758dad 100644
30560 --- a/arch/x86/mm/mmap.c
30561 +++ b/arch/x86/mm/mmap.c
30562 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
30563 * Leave an at least ~128 MB hole with possible stack randomization.
30564 */
30565 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
30566 -#define MAX_GAP (TASK_SIZE/6*5)
30567 +#define MAX_GAP (pax_task_size/6*5)
30568
30569 static int mmap_is_legacy(void)
30570 {
30571 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
30572 return rnd << PAGE_SHIFT;
30573 }
30574
30575 -static unsigned long mmap_base(void)
30576 +static unsigned long mmap_base(struct mm_struct *mm)
30577 {
30578 unsigned long gap = rlimit(RLIMIT_STACK);
30579 + unsigned long pax_task_size = TASK_SIZE;
30580 +
30581 +#ifdef CONFIG_PAX_SEGMEXEC
30582 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
30583 + pax_task_size = SEGMEXEC_TASK_SIZE;
30584 +#endif
30585
30586 if (gap < MIN_GAP)
30587 gap = MIN_GAP;
30588 else if (gap > MAX_GAP)
30589 gap = MAX_GAP;
30590
30591 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
30592 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
30593 }
30594
30595 /*
30596 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
30597 * does, but not when emulating X86_32
30598 */
30599 -unsigned long mmap_legacy_base(void)
30600 +unsigned long mmap_legacy_base(struct mm_struct *mm)
30601 {
30602 - if (mmap_is_ia32())
30603 + if (mmap_is_ia32()) {
30604 +
30605 +#ifdef CONFIG_PAX_SEGMEXEC
30606 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
30607 + return SEGMEXEC_TASK_UNMAPPED_BASE;
30608 + else
30609 +#endif
30610 +
30611 return TASK_UNMAPPED_BASE;
30612 - else
30613 + } else
30614 return TASK_UNMAPPED_BASE + mmap_rnd();
30615 }
30616
30617 @@ -113,11 +126,23 @@ unsigned long mmap_legacy_base(void)
30618 void arch_pick_mmap_layout(struct mm_struct *mm)
30619 {
30620 if (mmap_is_legacy()) {
30621 - mm->mmap_base = mmap_legacy_base();
30622 + mm->mmap_base = mmap_legacy_base(mm);
30623 +
30624 +#ifdef CONFIG_PAX_RANDMMAP
30625 + if (mm->pax_flags & MF_PAX_RANDMMAP)
30626 + mm->mmap_base += mm->delta_mmap;
30627 +#endif
30628 +
30629 mm->get_unmapped_area = arch_get_unmapped_area;
30630 mm->unmap_area = arch_unmap_area;
30631 } else {
30632 - mm->mmap_base = mmap_base();
30633 + mm->mmap_base = mmap_base(mm);
30634 +
30635 +#ifdef CONFIG_PAX_RANDMMAP
30636 + if (mm->pax_flags & MF_PAX_RANDMMAP)
30637 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
30638 +#endif
30639 +
30640 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
30641 mm->unmap_area = arch_unmap_area_topdown;
30642 }
30643 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
30644 index dc0b727..f612039 100644
30645 --- a/arch/x86/mm/mmio-mod.c
30646 +++ b/arch/x86/mm/mmio-mod.c
30647 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
30648 break;
30649 default:
30650 {
30651 - unsigned char *ip = (unsigned char *)instptr;
30652 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
30653 my_trace->opcode = MMIO_UNKNOWN_OP;
30654 my_trace->width = 0;
30655 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
30656 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
30657 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
30658 void __iomem *addr)
30659 {
30660 - static atomic_t next_id;
30661 + static atomic_unchecked_t next_id;
30662 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
30663 /* These are page-unaligned. */
30664 struct mmiotrace_map map = {
30665 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
30666 .private = trace
30667 },
30668 .phys = offset,
30669 - .id = atomic_inc_return(&next_id)
30670 + .id = atomic_inc_return_unchecked(&next_id)
30671 };
30672 map.map_id = trace->id;
30673
30674 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
30675 ioremap_trace_core(offset, size, addr);
30676 }
30677
30678 -static void iounmap_trace_core(volatile void __iomem *addr)
30679 +static void iounmap_trace_core(const volatile void __iomem *addr)
30680 {
30681 struct mmiotrace_map map = {
30682 .phys = 0,
30683 @@ -328,7 +328,7 @@ not_enabled:
30684 }
30685 }
30686
30687 -void mmiotrace_iounmap(volatile void __iomem *addr)
30688 +void mmiotrace_iounmap(const volatile void __iomem *addr)
30689 {
30690 might_sleep();
30691 if (is_enabled()) /* recheck and proper locking in *_core() */
30692 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
30693 index a71c4e2..301ae44 100644
30694 --- a/arch/x86/mm/numa.c
30695 +++ b/arch/x86/mm/numa.c
30696 @@ -474,7 +474,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
30697 return true;
30698 }
30699
30700 -static int __init numa_register_memblks(struct numa_meminfo *mi)
30701 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
30702 {
30703 unsigned long uninitialized_var(pfn_align);
30704 int i, nid;
30705 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
30706 index d0b1773..4c3327c 100644
30707 --- a/arch/x86/mm/pageattr-test.c
30708 +++ b/arch/x86/mm/pageattr-test.c
30709 @@ -36,7 +36,7 @@ enum {
30710
30711 static int pte_testbit(pte_t pte)
30712 {
30713 - return pte_flags(pte) & _PAGE_UNUSED1;
30714 + return pte_flags(pte) & _PAGE_CPA_TEST;
30715 }
30716
30717 struct split_state {
30718 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
30719 index bb32480..75f2f5e 100644
30720 --- a/arch/x86/mm/pageattr.c
30721 +++ b/arch/x86/mm/pageattr.c
30722 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
30723 */
30724 #ifdef CONFIG_PCI_BIOS
30725 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
30726 - pgprot_val(forbidden) |= _PAGE_NX;
30727 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
30728 #endif
30729
30730 /*
30731 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
30732 * Does not cover __inittext since that is gone later on. On
30733 * 64bit we do not enforce !NX on the low mapping
30734 */
30735 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
30736 - pgprot_val(forbidden) |= _PAGE_NX;
30737 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
30738 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
30739
30740 +#ifdef CONFIG_DEBUG_RODATA
30741 /*
30742 * The .rodata section needs to be read-only. Using the pfn
30743 * catches all aliases.
30744 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
30745 if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT,
30746 __pa_symbol(__end_rodata) >> PAGE_SHIFT))
30747 pgprot_val(forbidden) |= _PAGE_RW;
30748 +#endif
30749
30750 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
30751 /*
30752 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
30753 }
30754 #endif
30755
30756 +#ifdef CONFIG_PAX_KERNEXEC
30757 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
30758 + pgprot_val(forbidden) |= _PAGE_RW;
30759 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
30760 + }
30761 +#endif
30762 +
30763 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
30764
30765 return prot;
30766 @@ -400,23 +409,37 @@ EXPORT_SYMBOL_GPL(slow_virt_to_phys);
30767 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
30768 {
30769 /* change init_mm */
30770 + pax_open_kernel();
30771 set_pte_atomic(kpte, pte);
30772 +
30773 #ifdef CONFIG_X86_32
30774 if (!SHARED_KERNEL_PMD) {
30775 +
30776 +#ifdef CONFIG_PAX_PER_CPU_PGD
30777 + unsigned long cpu;
30778 +#else
30779 struct page *page;
30780 +#endif
30781
30782 +#ifdef CONFIG_PAX_PER_CPU_PGD
30783 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
30784 + pgd_t *pgd = get_cpu_pgd(cpu, kernel);
30785 +#else
30786 list_for_each_entry(page, &pgd_list, lru) {
30787 - pgd_t *pgd;
30788 + pgd_t *pgd = (pgd_t *)page_address(page);
30789 +#endif
30790 +
30791 pud_t *pud;
30792 pmd_t *pmd;
30793
30794 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
30795 + pgd += pgd_index(address);
30796 pud = pud_offset(pgd, address);
30797 pmd = pmd_offset(pud, address);
30798 set_pte_atomic((pte_t *)pmd, pte);
30799 }
30800 }
30801 #endif
30802 + pax_close_kernel();
30803 }
30804
30805 static int
30806 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
30807 index 6574388..87e9bef 100644
30808 --- a/arch/x86/mm/pat.c
30809 +++ b/arch/x86/mm/pat.c
30810 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
30811
30812 if (!entry) {
30813 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
30814 - current->comm, current->pid, start, end - 1);
30815 + current->comm, task_pid_nr(current), start, end - 1);
30816 return -EINVAL;
30817 }
30818
30819 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
30820
30821 while (cursor < to) {
30822 if (!devmem_is_allowed(pfn)) {
30823 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
30824 - current->comm, from, to - 1);
30825 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
30826 + current->comm, from, to - 1, cursor);
30827 return 0;
30828 }
30829 cursor += PAGE_SIZE;
30830 @@ -577,7 +577,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
30831 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
30832 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
30833 "for [mem %#010Lx-%#010Lx]\n",
30834 - current->comm, current->pid,
30835 + current->comm, task_pid_nr(current),
30836 cattr_name(flags),
30837 base, (unsigned long long)(base + size-1));
30838 return -EINVAL;
30839 @@ -612,7 +612,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
30840 flags = lookup_memtype(paddr);
30841 if (want_flags != flags) {
30842 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
30843 - current->comm, current->pid,
30844 + current->comm, task_pid_nr(current),
30845 cattr_name(want_flags),
30846 (unsigned long long)paddr,
30847 (unsigned long long)(paddr + size - 1),
30848 @@ -634,7 +634,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
30849 free_memtype(paddr, paddr + size);
30850 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
30851 " for [mem %#010Lx-%#010Lx], got %s\n",
30852 - current->comm, current->pid,
30853 + current->comm, task_pid_nr(current),
30854 cattr_name(want_flags),
30855 (unsigned long long)paddr,
30856 (unsigned long long)(paddr + size - 1),
30857 diff --git a/arch/x86/mm/pat_rbtree.c b/arch/x86/mm/pat_rbtree.c
30858 index 415f6c4..d319983 100644
30859 --- a/arch/x86/mm/pat_rbtree.c
30860 +++ b/arch/x86/mm/pat_rbtree.c
30861 @@ -160,7 +160,7 @@ success:
30862
30863 failure:
30864 printk(KERN_INFO "%s:%d conflicting memory types "
30865 - "%Lx-%Lx %s<->%s\n", current->comm, current->pid, start,
30866 + "%Lx-%Lx %s<->%s\n", current->comm, task_pid_nr(current), start,
30867 end, cattr_name(found_type), cattr_name(match->type));
30868 return -EBUSY;
30869 }
30870 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
30871 index 9f0614d..92ae64a 100644
30872 --- a/arch/x86/mm/pf_in.c
30873 +++ b/arch/x86/mm/pf_in.c
30874 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
30875 int i;
30876 enum reason_type rv = OTHERS;
30877
30878 - p = (unsigned char *)ins_addr;
30879 + p = (unsigned char *)ktla_ktva(ins_addr);
30880 p += skip_prefix(p, &prf);
30881 p += get_opcode(p, &opcode);
30882
30883 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
30884 struct prefix_bits prf;
30885 int i;
30886
30887 - p = (unsigned char *)ins_addr;
30888 + p = (unsigned char *)ktla_ktva(ins_addr);
30889 p += skip_prefix(p, &prf);
30890 p += get_opcode(p, &opcode);
30891
30892 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
30893 struct prefix_bits prf;
30894 int i;
30895
30896 - p = (unsigned char *)ins_addr;
30897 + p = (unsigned char *)ktla_ktva(ins_addr);
30898 p += skip_prefix(p, &prf);
30899 p += get_opcode(p, &opcode);
30900
30901 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
30902 struct prefix_bits prf;
30903 int i;
30904
30905 - p = (unsigned char *)ins_addr;
30906 + p = (unsigned char *)ktla_ktva(ins_addr);
30907 p += skip_prefix(p, &prf);
30908 p += get_opcode(p, &opcode);
30909 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
30910 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
30911 struct prefix_bits prf;
30912 int i;
30913
30914 - p = (unsigned char *)ins_addr;
30915 + p = (unsigned char *)ktla_ktva(ins_addr);
30916 p += skip_prefix(p, &prf);
30917 p += get_opcode(p, &opcode);
30918 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
30919 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
30920 index 17fda6a..f7d54a0 100644
30921 --- a/arch/x86/mm/pgtable.c
30922 +++ b/arch/x86/mm/pgtable.c
30923 @@ -91,10 +91,67 @@ static inline void pgd_list_del(pgd_t *pgd)
30924 list_del(&page->lru);
30925 }
30926
30927 -#define UNSHARED_PTRS_PER_PGD \
30928 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
30929 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
30930 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
30931
30932 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
30933 +{
30934 + unsigned int count = USER_PGD_PTRS;
30935
30936 + if (!pax_user_shadow_base)
30937 + return;
30938 +
30939 + while (count--)
30940 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
30941 +}
30942 +#endif
30943 +
30944 +#ifdef CONFIG_PAX_PER_CPU_PGD
30945 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
30946 +{
30947 + unsigned int count = USER_PGD_PTRS;
30948 +
30949 + while (count--) {
30950 + pgd_t pgd;
30951 +
30952 +#ifdef CONFIG_X86_64
30953 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
30954 +#else
30955 + pgd = *src++;
30956 +#endif
30957 +
30958 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
30959 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
30960 +#endif
30961 +
30962 + *dst++ = pgd;
30963 + }
30964 +
30965 +}
30966 +#endif
30967 +
30968 +#ifdef CONFIG_X86_64
30969 +#define pxd_t pud_t
30970 +#define pyd_t pgd_t
30971 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
30972 +#define pxd_free(mm, pud) pud_free((mm), (pud))
30973 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
30974 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
30975 +#define PYD_SIZE PGDIR_SIZE
30976 +#else
30977 +#define pxd_t pmd_t
30978 +#define pyd_t pud_t
30979 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
30980 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
30981 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
30982 +#define pyd_offset(mm, address) pud_offset((mm), (address))
30983 +#define PYD_SIZE PUD_SIZE
30984 +#endif
30985 +
30986 +#ifdef CONFIG_PAX_PER_CPU_PGD
30987 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
30988 +static inline void pgd_dtor(pgd_t *pgd) {}
30989 +#else
30990 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
30991 {
30992 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
30993 @@ -135,6 +192,7 @@ static void pgd_dtor(pgd_t *pgd)
30994 pgd_list_del(pgd);
30995 spin_unlock(&pgd_lock);
30996 }
30997 +#endif
30998
30999 /*
31000 * List of all pgd's needed for non-PAE so it can invalidate entries
31001 @@ -147,7 +205,7 @@ static void pgd_dtor(pgd_t *pgd)
31002 * -- nyc
31003 */
31004
31005 -#ifdef CONFIG_X86_PAE
31006 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
31007 /*
31008 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
31009 * updating the top-level pagetable entries to guarantee the
31010 @@ -159,7 +217,7 @@ static void pgd_dtor(pgd_t *pgd)
31011 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
31012 * and initialize the kernel pmds here.
31013 */
31014 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
31015 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
31016
31017 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
31018 {
31019 @@ -177,36 +235,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
31020 */
31021 flush_tlb_mm(mm);
31022 }
31023 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
31024 +#define PREALLOCATED_PXDS USER_PGD_PTRS
31025 #else /* !CONFIG_X86_PAE */
31026
31027 /* No need to prepopulate any pagetable entries in non-PAE modes. */
31028 -#define PREALLOCATED_PMDS 0
31029 +#define PREALLOCATED_PXDS 0
31030
31031 #endif /* CONFIG_X86_PAE */
31032
31033 -static void free_pmds(pmd_t *pmds[])
31034 +static void free_pxds(pxd_t *pxds[])
31035 {
31036 int i;
31037
31038 - for(i = 0; i < PREALLOCATED_PMDS; i++)
31039 - if (pmds[i])
31040 - free_page((unsigned long)pmds[i]);
31041 + for(i = 0; i < PREALLOCATED_PXDS; i++)
31042 + if (pxds[i])
31043 + free_page((unsigned long)pxds[i]);
31044 }
31045
31046 -static int preallocate_pmds(pmd_t *pmds[])
31047 +static int preallocate_pxds(pxd_t *pxds[])
31048 {
31049 int i;
31050 bool failed = false;
31051
31052 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
31053 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
31054 - if (pmd == NULL)
31055 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
31056 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
31057 + if (pxd == NULL)
31058 failed = true;
31059 - pmds[i] = pmd;
31060 + pxds[i] = pxd;
31061 }
31062
31063 if (failed) {
31064 - free_pmds(pmds);
31065 + free_pxds(pxds);
31066 return -ENOMEM;
31067 }
31068
31069 @@ -219,51 +279,55 @@ static int preallocate_pmds(pmd_t *pmds[])
31070 * preallocate which never got a corresponding vma will need to be
31071 * freed manually.
31072 */
31073 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
31074 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
31075 {
31076 int i;
31077
31078 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
31079 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
31080 pgd_t pgd = pgdp[i];
31081
31082 if (pgd_val(pgd) != 0) {
31083 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
31084 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
31085
31086 - pgdp[i] = native_make_pgd(0);
31087 + set_pgd(pgdp + i, native_make_pgd(0));
31088
31089 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
31090 - pmd_free(mm, pmd);
31091 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
31092 + pxd_free(mm, pxd);
31093 }
31094 }
31095 }
31096
31097 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
31098 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
31099 {
31100 - pud_t *pud;
31101 + pyd_t *pyd;
31102 unsigned long addr;
31103 int i;
31104
31105 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
31106 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
31107 return;
31108
31109 - pud = pud_offset(pgd, 0);
31110 +#ifdef CONFIG_X86_64
31111 + pyd = pyd_offset(mm, 0L);
31112 +#else
31113 + pyd = pyd_offset(pgd, 0L);
31114 +#endif
31115
31116 - for (addr = i = 0; i < PREALLOCATED_PMDS;
31117 - i++, pud++, addr += PUD_SIZE) {
31118 - pmd_t *pmd = pmds[i];
31119 + for (addr = i = 0; i < PREALLOCATED_PXDS;
31120 + i++, pyd++, addr += PYD_SIZE) {
31121 + pxd_t *pxd = pxds[i];
31122
31123 if (i >= KERNEL_PGD_BOUNDARY)
31124 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
31125 - sizeof(pmd_t) * PTRS_PER_PMD);
31126 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
31127 + sizeof(pxd_t) * PTRS_PER_PMD);
31128
31129 - pud_populate(mm, pud, pmd);
31130 + pyd_populate(mm, pyd, pxd);
31131 }
31132 }
31133
31134 pgd_t *pgd_alloc(struct mm_struct *mm)
31135 {
31136 pgd_t *pgd;
31137 - pmd_t *pmds[PREALLOCATED_PMDS];
31138 + pxd_t *pxds[PREALLOCATED_PXDS];
31139
31140 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
31141
31142 @@ -272,11 +336,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
31143
31144 mm->pgd = pgd;
31145
31146 - if (preallocate_pmds(pmds) != 0)
31147 + if (preallocate_pxds(pxds) != 0)
31148 goto out_free_pgd;
31149
31150 if (paravirt_pgd_alloc(mm) != 0)
31151 - goto out_free_pmds;
31152 + goto out_free_pxds;
31153
31154 /*
31155 * Make sure that pre-populating the pmds is atomic with
31156 @@ -286,14 +350,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
31157 spin_lock(&pgd_lock);
31158
31159 pgd_ctor(mm, pgd);
31160 - pgd_prepopulate_pmd(mm, pgd, pmds);
31161 + pgd_prepopulate_pxd(mm, pgd, pxds);
31162
31163 spin_unlock(&pgd_lock);
31164
31165 return pgd;
31166
31167 -out_free_pmds:
31168 - free_pmds(pmds);
31169 +out_free_pxds:
31170 + free_pxds(pxds);
31171 out_free_pgd:
31172 free_page((unsigned long)pgd);
31173 out:
31174 @@ -302,7 +366,7 @@ out:
31175
31176 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
31177 {
31178 - pgd_mop_up_pmds(mm, pgd);
31179 + pgd_mop_up_pxds(mm, pgd);
31180 pgd_dtor(pgd);
31181 paravirt_pgd_free(mm, pgd);
31182 free_page((unsigned long)pgd);
31183 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
31184 index a69bcb8..19068ab 100644
31185 --- a/arch/x86/mm/pgtable_32.c
31186 +++ b/arch/x86/mm/pgtable_32.c
31187 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
31188 return;
31189 }
31190 pte = pte_offset_kernel(pmd, vaddr);
31191 +
31192 + pax_open_kernel();
31193 if (pte_val(pteval))
31194 set_pte_at(&init_mm, vaddr, pte, pteval);
31195 else
31196 pte_clear(&init_mm, vaddr, pte);
31197 + pax_close_kernel();
31198
31199 /*
31200 * It's enough to flush this one mapping.
31201 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
31202 index e666cbb..61788c45 100644
31203 --- a/arch/x86/mm/physaddr.c
31204 +++ b/arch/x86/mm/physaddr.c
31205 @@ -10,7 +10,7 @@
31206 #ifdef CONFIG_X86_64
31207
31208 #ifdef CONFIG_DEBUG_VIRTUAL
31209 -unsigned long __phys_addr(unsigned long x)
31210 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
31211 {
31212 unsigned long y = x - __START_KERNEL_map;
31213
31214 @@ -67,7 +67,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
31215 #else
31216
31217 #ifdef CONFIG_DEBUG_VIRTUAL
31218 -unsigned long __phys_addr(unsigned long x)
31219 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
31220 {
31221 unsigned long phys_addr = x - PAGE_OFFSET;
31222 /* VMALLOC_* aren't constants */
31223 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
31224 index 410531d..0f16030 100644
31225 --- a/arch/x86/mm/setup_nx.c
31226 +++ b/arch/x86/mm/setup_nx.c
31227 @@ -5,8 +5,10 @@
31228 #include <asm/pgtable.h>
31229 #include <asm/proto.h>
31230
31231 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
31232 static int disable_nx __cpuinitdata;
31233
31234 +#ifndef CONFIG_PAX_PAGEEXEC
31235 /*
31236 * noexec = on|off
31237 *
31238 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
31239 return 0;
31240 }
31241 early_param("noexec", noexec_setup);
31242 +#endif
31243 +
31244 +#endif
31245
31246 void __cpuinit x86_configure_nx(void)
31247 {
31248 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
31249 if (cpu_has_nx && !disable_nx)
31250 __supported_pte_mask |= _PAGE_NX;
31251 else
31252 +#endif
31253 __supported_pte_mask &= ~_PAGE_NX;
31254 }
31255
31256 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
31257 index 282375f..e03a98f 100644
31258 --- a/arch/x86/mm/tlb.c
31259 +++ b/arch/x86/mm/tlb.c
31260 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
31261 BUG();
31262 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
31263 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
31264 +
31265 +#ifndef CONFIG_PAX_PER_CPU_PGD
31266 load_cr3(swapper_pg_dir);
31267 +#endif
31268 +
31269 }
31270 }
31271 EXPORT_SYMBOL_GPL(leave_mm);
31272 diff --git a/arch/x86/mm/uderef_64.c b/arch/x86/mm/uderef_64.c
31273 new file mode 100644
31274 index 0000000..dace51c
31275 --- /dev/null
31276 +++ b/arch/x86/mm/uderef_64.c
31277 @@ -0,0 +1,37 @@
31278 +#include <linux/mm.h>
31279 +#include <asm/pgtable.h>
31280 +#include <asm/uaccess.h>
31281 +
31282 +#ifdef CONFIG_PAX_MEMORY_UDEREF
31283 +/* PaX: due to the special call convention these functions must
31284 + * - remain leaf functions under all configurations,
31285 + * - never be called directly, only dereferenced from the wrappers.
31286 + */
31287 +void __pax_open_userland(void)
31288 +{
31289 + unsigned int cpu;
31290 +
31291 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
31292 + return;
31293 +
31294 + cpu = raw_get_cpu();
31295 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_KERNEL);
31296 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
31297 + raw_put_cpu_no_resched();
31298 +}
31299 +EXPORT_SYMBOL(__pax_open_userland);
31300 +
31301 +void __pax_close_userland(void)
31302 +{
31303 + unsigned int cpu;
31304 +
31305 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
31306 + return;
31307 +
31308 + cpu = raw_get_cpu();
31309 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_USER);
31310 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
31311 + raw_put_cpu_no_resched();
31312 +}
31313 +EXPORT_SYMBOL(__pax_close_userland);
31314 +#endif
31315 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
31316 index 877b9a1..a8ecf42 100644
31317 --- a/arch/x86/net/bpf_jit.S
31318 +++ b/arch/x86/net/bpf_jit.S
31319 @@ -9,6 +9,7 @@
31320 */
31321 #include <linux/linkage.h>
31322 #include <asm/dwarf2.h>
31323 +#include <asm/alternative-asm.h>
31324
31325 /*
31326 * Calling convention :
31327 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
31328 jle bpf_slow_path_word
31329 mov (SKBDATA,%rsi),%eax
31330 bswap %eax /* ntohl() */
31331 + pax_force_retaddr
31332 ret
31333
31334 sk_load_half:
31335 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
31336 jle bpf_slow_path_half
31337 movzwl (SKBDATA,%rsi),%eax
31338 rol $8,%ax # ntohs()
31339 + pax_force_retaddr
31340 ret
31341
31342 sk_load_byte:
31343 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
31344 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
31345 jle bpf_slow_path_byte
31346 movzbl (SKBDATA,%rsi),%eax
31347 + pax_force_retaddr
31348 ret
31349
31350 /**
31351 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
31352 movzbl (SKBDATA,%rsi),%ebx
31353 and $15,%bl
31354 shl $2,%bl
31355 + pax_force_retaddr
31356 ret
31357
31358 /* rsi contains offset and can be scratched */
31359 @@ -109,6 +114,7 @@ bpf_slow_path_word:
31360 js bpf_error
31361 mov -12(%rbp),%eax
31362 bswap %eax
31363 + pax_force_retaddr
31364 ret
31365
31366 bpf_slow_path_half:
31367 @@ -117,12 +123,14 @@ bpf_slow_path_half:
31368 mov -12(%rbp),%ax
31369 rol $8,%ax
31370 movzwl %ax,%eax
31371 + pax_force_retaddr
31372 ret
31373
31374 bpf_slow_path_byte:
31375 bpf_slow_path_common(1)
31376 js bpf_error
31377 movzbl -12(%rbp),%eax
31378 + pax_force_retaddr
31379 ret
31380
31381 bpf_slow_path_byte_msh:
31382 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
31383 and $15,%al
31384 shl $2,%al
31385 xchg %eax,%ebx
31386 + pax_force_retaddr
31387 ret
31388
31389 #define sk_negative_common(SIZE) \
31390 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
31391 sk_negative_common(4)
31392 mov (%rax), %eax
31393 bswap %eax
31394 + pax_force_retaddr
31395 ret
31396
31397 bpf_slow_path_half_neg:
31398 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
31399 mov (%rax),%ax
31400 rol $8,%ax
31401 movzwl %ax,%eax
31402 + pax_force_retaddr
31403 ret
31404
31405 bpf_slow_path_byte_neg:
31406 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
31407 .globl sk_load_byte_negative_offset
31408 sk_negative_common(1)
31409 movzbl (%rax), %eax
31410 + pax_force_retaddr
31411 ret
31412
31413 bpf_slow_path_byte_msh_neg:
31414 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
31415 and $15,%al
31416 shl $2,%al
31417 xchg %eax,%ebx
31418 + pax_force_retaddr
31419 ret
31420
31421 bpf_error:
31422 @@ -197,4 +210,5 @@ bpf_error:
31423 xor %eax,%eax
31424 mov -8(%rbp),%rbx
31425 leaveq
31426 + pax_force_retaddr
31427 ret
31428 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
31429 index f66b540..3e88dfb 100644
31430 --- a/arch/x86/net/bpf_jit_comp.c
31431 +++ b/arch/x86/net/bpf_jit_comp.c
31432 @@ -12,6 +12,7 @@
31433 #include <linux/netdevice.h>
31434 #include <linux/filter.h>
31435 #include <linux/if_vlan.h>
31436 +#include <linux/random.h>
31437
31438 /*
31439 * Conventions :
31440 @@ -49,13 +50,90 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
31441 return ptr + len;
31442 }
31443
31444 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
31445 +#define MAX_INSTR_CODE_SIZE 96
31446 +#else
31447 +#define MAX_INSTR_CODE_SIZE 64
31448 +#endif
31449 +
31450 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
31451
31452 #define EMIT1(b1) EMIT(b1, 1)
31453 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
31454 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
31455 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
31456 +
31457 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
31458 +/* original constant will appear in ecx */
31459 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
31460 +do { \
31461 + /* mov ecx, randkey */ \
31462 + EMIT1(0xb9); \
31463 + EMIT(_key, 4); \
31464 + /* xor ecx, randkey ^ off */ \
31465 + EMIT2(0x81, 0xf1); \
31466 + EMIT((_key) ^ (_off), 4); \
31467 +} while (0)
31468 +
31469 +#define EMIT1_off32(b1, _off) \
31470 +do { \
31471 + switch (b1) { \
31472 + case 0x05: /* add eax, imm32 */ \
31473 + case 0x2d: /* sub eax, imm32 */ \
31474 + case 0x25: /* and eax, imm32 */ \
31475 + case 0x0d: /* or eax, imm32 */ \
31476 + case 0xb8: /* mov eax, imm32 */ \
31477 + case 0x35: /* xor eax, imm32 */ \
31478 + case 0x3d: /* cmp eax, imm32 */ \
31479 + case 0xa9: /* test eax, imm32 */ \
31480 + DILUTE_CONST_SEQUENCE(_off, randkey); \
31481 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
31482 + break; \
31483 + case 0xbb: /* mov ebx, imm32 */ \
31484 + DILUTE_CONST_SEQUENCE(_off, randkey); \
31485 + /* mov ebx, ecx */ \
31486 + EMIT2(0x89, 0xcb); \
31487 + break; \
31488 + case 0xbe: /* mov esi, imm32 */ \
31489 + DILUTE_CONST_SEQUENCE(_off, randkey); \
31490 + /* mov esi, ecx */ \
31491 + EMIT2(0x89, 0xce); \
31492 + break; \
31493 + case 0xe8: /* call rel imm32, always to known funcs */ \
31494 + EMIT1(b1); \
31495 + EMIT(_off, 4); \
31496 + break; \
31497 + case 0xe9: /* jmp rel imm32 */ \
31498 + EMIT1(b1); \
31499 + EMIT(_off, 4); \
31500 + /* prevent fall-through, we're not called if off = 0 */ \
31501 + EMIT(0xcccccccc, 4); \
31502 + EMIT(0xcccccccc, 4); \
31503 + break; \
31504 + default: \
31505 + BUILD_BUG(); \
31506 + } \
31507 +} while (0)
31508 +
31509 +#define EMIT2_off32(b1, b2, _off) \
31510 +do { \
31511 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
31512 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
31513 + EMIT(randkey, 4); \
31514 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
31515 + EMIT((_off) - randkey, 4); \
31516 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
31517 + DILUTE_CONST_SEQUENCE(_off, randkey); \
31518 + /* imul eax, ecx */ \
31519 + EMIT3(0x0f, 0xaf, 0xc1); \
31520 + } else { \
31521 + BUILD_BUG(); \
31522 + } \
31523 +} while (0)
31524 +#else
31525 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
31526 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
31527 +#endif
31528
31529 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
31530 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
31531 @@ -90,6 +168,24 @@ do { \
31532 #define X86_JBE 0x76
31533 #define X86_JA 0x77
31534
31535 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
31536 +#define APPEND_FLOW_VERIFY() \
31537 +do { \
31538 + /* mov ecx, randkey */ \
31539 + EMIT1(0xb9); \
31540 + EMIT(randkey, 4); \
31541 + /* cmp ecx, randkey */ \
31542 + EMIT2(0x81, 0xf9); \
31543 + EMIT(randkey, 4); \
31544 + /* jz after 8 int 3s */ \
31545 + EMIT2(0x74, 0x08); \
31546 + EMIT(0xcccccccc, 4); \
31547 + EMIT(0xcccccccc, 4); \
31548 +} while (0)
31549 +#else
31550 +#define APPEND_FLOW_VERIFY() do { } while (0)
31551 +#endif
31552 +
31553 #define EMIT_COND_JMP(op, offset) \
31554 do { \
31555 if (is_near(offset)) \
31556 @@ -97,6 +193,7 @@ do { \
31557 else { \
31558 EMIT2(0x0f, op + 0x10); \
31559 EMIT(offset, 4); /* jxx .+off32 */ \
31560 + APPEND_FLOW_VERIFY(); \
31561 } \
31562 } while (0)
31563
31564 @@ -121,6 +218,11 @@ static inline void bpf_flush_icache(void *start, void *end)
31565 set_fs(old_fs);
31566 }
31567
31568 +struct bpf_jit_work {
31569 + struct work_struct work;
31570 + void *image;
31571 +};
31572 +
31573 #define CHOOSE_LOAD_FUNC(K, func) \
31574 ((int)K < 0 ? ((int)K >= SKF_LL_OFF ? func##_negative_offset : func) : func##_positive_offset)
31575
31576 @@ -146,7 +248,7 @@ static int pkt_type_offset(void)
31577
31578 void bpf_jit_compile(struct sk_filter *fp)
31579 {
31580 - u8 temp[64];
31581 + u8 temp[MAX_INSTR_CODE_SIZE];
31582 u8 *prog;
31583 unsigned int proglen, oldproglen = 0;
31584 int ilen, i;
31585 @@ -159,6 +261,9 @@ void bpf_jit_compile(struct sk_filter *fp)
31586 unsigned int *addrs;
31587 const struct sock_filter *filter = fp->insns;
31588 int flen = fp->len;
31589 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
31590 + unsigned int randkey;
31591 +#endif
31592
31593 if (!bpf_jit_enable)
31594 return;
31595 @@ -167,11 +272,19 @@ void bpf_jit_compile(struct sk_filter *fp)
31596 if (addrs == NULL)
31597 return;
31598
31599 + fp->work = kmalloc(sizeof(*fp->work), GFP_KERNEL);
31600 + if (!fp->work)
31601 + goto out;
31602 +
31603 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
31604 + randkey = get_random_int();
31605 +#endif
31606 +
31607 /* Before first pass, make a rough estimation of addrs[]
31608 - * each bpf instruction is translated to less than 64 bytes
31609 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
31610 */
31611 for (proglen = 0, i = 0; i < flen; i++) {
31612 - proglen += 64;
31613 + proglen += MAX_INSTR_CODE_SIZE;
31614 addrs[i] = proglen;
31615 }
31616 cleanup_addr = proglen; /* epilogue address */
31617 @@ -282,10 +395,8 @@ void bpf_jit_compile(struct sk_filter *fp)
31618 case BPF_S_ALU_MUL_K: /* A *= K */
31619 if (is_imm8(K))
31620 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
31621 - else {
31622 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
31623 - EMIT(K, 4);
31624 - }
31625 + else
31626 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
31627 break;
31628 case BPF_S_ALU_DIV_X: /* A /= X; */
31629 seen |= SEEN_XREG;
31630 @@ -325,13 +436,23 @@ void bpf_jit_compile(struct sk_filter *fp)
31631 break;
31632 case BPF_S_ALU_MOD_K: /* A %= K; */
31633 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
31634 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
31635 + DILUTE_CONST_SEQUENCE(K, randkey);
31636 +#else
31637 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
31638 +#endif
31639 EMIT2(0xf7, 0xf1); /* div %ecx */
31640 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
31641 break;
31642 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
31643 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
31644 + DILUTE_CONST_SEQUENCE(K, randkey);
31645 + // imul rax, rcx
31646 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
31647 +#else
31648 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
31649 EMIT(K, 4);
31650 +#endif
31651 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
31652 break;
31653 case BPF_S_ALU_AND_X:
31654 @@ -602,8 +723,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
31655 if (is_imm8(K)) {
31656 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
31657 } else {
31658 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
31659 - EMIT(K, 4);
31660 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
31661 }
31662 } else {
31663 EMIT2(0x89,0xde); /* mov %ebx,%esi */
31664 @@ -686,17 +806,18 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
31665 break;
31666 default:
31667 /* hmm, too complex filter, give up with jit compiler */
31668 - goto out;
31669 + goto error;
31670 }
31671 ilen = prog - temp;
31672 if (image) {
31673 if (unlikely(proglen + ilen > oldproglen)) {
31674 pr_err("bpb_jit_compile fatal error\n");
31675 - kfree(addrs);
31676 - module_free(NULL, image);
31677 - return;
31678 + module_free_exec(NULL, image);
31679 + goto error;
31680 }
31681 + pax_open_kernel();
31682 memcpy(image + proglen, temp, ilen);
31683 + pax_close_kernel();
31684 }
31685 proglen += ilen;
31686 addrs[i] = proglen;
31687 @@ -717,11 +838,9 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
31688 break;
31689 }
31690 if (proglen == oldproglen) {
31691 - image = module_alloc(max_t(unsigned int,
31692 - proglen,
31693 - sizeof(struct work_struct)));
31694 + image = module_alloc_exec(proglen);
31695 if (!image)
31696 - goto out;
31697 + goto error;
31698 }
31699 oldproglen = proglen;
31700 }
31701 @@ -732,7 +851,10 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
31702 if (image) {
31703 bpf_flush_icache(image, image + proglen);
31704 fp->bpf_func = (void *)image;
31705 - }
31706 + } else
31707 +error:
31708 + kfree(fp->work);
31709 +
31710 out:
31711 kfree(addrs);
31712 return;
31713 @@ -740,18 +862,20 @@ out:
31714
31715 static void jit_free_defer(struct work_struct *arg)
31716 {
31717 - module_free(NULL, arg);
31718 + module_free_exec(NULL, ((struct bpf_jit_work *)arg)->image);
31719 + kfree(arg);
31720 }
31721
31722 /* run from softirq, we must use a work_struct to call
31723 - * module_free() from process context
31724 + * module_free_exec() from process context
31725 */
31726 void bpf_jit_free(struct sk_filter *fp)
31727 {
31728 if (fp->bpf_func != sk_run_filter) {
31729 - struct work_struct *work = (struct work_struct *)fp->bpf_func;
31730 + struct work_struct *work = &fp->work->work;
31731
31732 INIT_WORK(work, jit_free_defer);
31733 + fp->work->image = fp->bpf_func;
31734 schedule_work(work);
31735 }
31736 }
31737 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
31738 index d6aa6e8..266395a 100644
31739 --- a/arch/x86/oprofile/backtrace.c
31740 +++ b/arch/x86/oprofile/backtrace.c
31741 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
31742 struct stack_frame_ia32 *fp;
31743 unsigned long bytes;
31744
31745 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
31746 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
31747 if (bytes != sizeof(bufhead))
31748 return NULL;
31749
31750 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
31751 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
31752
31753 oprofile_add_trace(bufhead[0].return_address);
31754
31755 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
31756 struct stack_frame bufhead[2];
31757 unsigned long bytes;
31758
31759 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
31760 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
31761 if (bytes != sizeof(bufhead))
31762 return NULL;
31763
31764 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
31765 {
31766 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
31767
31768 - if (!user_mode_vm(regs)) {
31769 + if (!user_mode(regs)) {
31770 unsigned long stack = kernel_stack_pointer(regs);
31771 if (depth)
31772 dump_trace(NULL, regs, (unsigned long *)stack, 0,
31773 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
31774 index 48768df..ba9143c 100644
31775 --- a/arch/x86/oprofile/nmi_int.c
31776 +++ b/arch/x86/oprofile/nmi_int.c
31777 @@ -23,6 +23,7 @@
31778 #include <asm/nmi.h>
31779 #include <asm/msr.h>
31780 #include <asm/apic.h>
31781 +#include <asm/pgtable.h>
31782
31783 #include "op_counter.h"
31784 #include "op_x86_model.h"
31785 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
31786 if (ret)
31787 return ret;
31788
31789 - if (!model->num_virt_counters)
31790 - model->num_virt_counters = model->num_counters;
31791 + if (!model->num_virt_counters) {
31792 + pax_open_kernel();
31793 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
31794 + pax_close_kernel();
31795 + }
31796
31797 mux_init(ops);
31798
31799 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
31800 index b2b9443..be58856 100644
31801 --- a/arch/x86/oprofile/op_model_amd.c
31802 +++ b/arch/x86/oprofile/op_model_amd.c
31803 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
31804 num_counters = AMD64_NUM_COUNTERS;
31805 }
31806
31807 - op_amd_spec.num_counters = num_counters;
31808 - op_amd_spec.num_controls = num_counters;
31809 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
31810 + pax_open_kernel();
31811 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
31812 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
31813 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
31814 + pax_close_kernel();
31815
31816 return 0;
31817 }
31818 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
31819 index d90528e..0127e2b 100644
31820 --- a/arch/x86/oprofile/op_model_ppro.c
31821 +++ b/arch/x86/oprofile/op_model_ppro.c
31822 @@ -19,6 +19,7 @@
31823 #include <asm/msr.h>
31824 #include <asm/apic.h>
31825 #include <asm/nmi.h>
31826 +#include <asm/pgtable.h>
31827
31828 #include "op_x86_model.h"
31829 #include "op_counter.h"
31830 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
31831
31832 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
31833
31834 - op_arch_perfmon_spec.num_counters = num_counters;
31835 - op_arch_perfmon_spec.num_controls = num_counters;
31836 + pax_open_kernel();
31837 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
31838 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
31839 + pax_close_kernel();
31840 }
31841
31842 static int arch_perfmon_init(struct oprofile_operations *ignore)
31843 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
31844 index 71e8a67..6a313bb 100644
31845 --- a/arch/x86/oprofile/op_x86_model.h
31846 +++ b/arch/x86/oprofile/op_x86_model.h
31847 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
31848 void (*switch_ctrl)(struct op_x86_model_spec const *model,
31849 struct op_msrs const * const msrs);
31850 #endif
31851 -};
31852 +} __do_const;
31853
31854 struct op_counter_config;
31855
31856 diff --git a/arch/x86/pci/amd_bus.c b/arch/x86/pci/amd_bus.c
31857 index e9e6ed5..e47ae67 100644
31858 --- a/arch/x86/pci/amd_bus.c
31859 +++ b/arch/x86/pci/amd_bus.c
31860 @@ -337,7 +337,7 @@ static int __cpuinit amd_cpu_notify(struct notifier_block *self,
31861 return NOTIFY_OK;
31862 }
31863
31864 -static struct notifier_block __cpuinitdata amd_cpu_notifier = {
31865 +static struct notifier_block amd_cpu_notifier = {
31866 .notifier_call = amd_cpu_notify,
31867 };
31868
31869 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
31870 index 372e9b8..e775a6c 100644
31871 --- a/arch/x86/pci/irq.c
31872 +++ b/arch/x86/pci/irq.c
31873 @@ -50,7 +50,7 @@ struct irq_router {
31874 struct irq_router_handler {
31875 u16 vendor;
31876 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
31877 -};
31878 +} __do_const;
31879
31880 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
31881 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
31882 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
31883 return 0;
31884 }
31885
31886 -static __initdata struct irq_router_handler pirq_routers[] = {
31887 +static __initconst const struct irq_router_handler pirq_routers[] = {
31888 { PCI_VENDOR_ID_INTEL, intel_router_probe },
31889 { PCI_VENDOR_ID_AL, ali_router_probe },
31890 { PCI_VENDOR_ID_ITE, ite_router_probe },
31891 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
31892 static void __init pirq_find_router(struct irq_router *r)
31893 {
31894 struct irq_routing_table *rt = pirq_table;
31895 - struct irq_router_handler *h;
31896 + const struct irq_router_handler *h;
31897
31898 #ifdef CONFIG_PCI_BIOS
31899 if (!rt->signature) {
31900 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
31901 return 0;
31902 }
31903
31904 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
31905 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
31906 {
31907 .callback = fix_broken_hp_bios_irq9,
31908 .ident = "HP Pavilion N5400 Series Laptop",
31909 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
31910 index 6eb18c4..20d83de 100644
31911 --- a/arch/x86/pci/mrst.c
31912 +++ b/arch/x86/pci/mrst.c
31913 @@ -238,7 +238,9 @@ int __init pci_mrst_init(void)
31914 printk(KERN_INFO "Intel MID platform detected, using MID PCI ops\n");
31915 pci_mmcfg_late_init();
31916 pcibios_enable_irq = mrst_pci_irq_enable;
31917 - pci_root_ops = pci_mrst_ops;
31918 + pax_open_kernel();
31919 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
31920 + pax_close_kernel();
31921 pci_soc_mode = 1;
31922 /* Continue with standard init */
31923 return 1;
31924 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
31925 index c77b24a..c979855 100644
31926 --- a/arch/x86/pci/pcbios.c
31927 +++ b/arch/x86/pci/pcbios.c
31928 @@ -79,7 +79,7 @@ union bios32 {
31929 static struct {
31930 unsigned long address;
31931 unsigned short segment;
31932 -} bios32_indirect = { 0, __KERNEL_CS };
31933 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
31934
31935 /*
31936 * Returns the entry point for the given service, NULL on error
31937 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
31938 unsigned long length; /* %ecx */
31939 unsigned long entry; /* %edx */
31940 unsigned long flags;
31941 + struct desc_struct d, *gdt;
31942
31943 local_irq_save(flags);
31944 - __asm__("lcall *(%%edi); cld"
31945 +
31946 + gdt = get_cpu_gdt_table(smp_processor_id());
31947 +
31948 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
31949 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
31950 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
31951 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
31952 +
31953 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
31954 : "=a" (return_code),
31955 "=b" (address),
31956 "=c" (length),
31957 "=d" (entry)
31958 : "0" (service),
31959 "1" (0),
31960 - "D" (&bios32_indirect));
31961 + "D" (&bios32_indirect),
31962 + "r"(__PCIBIOS_DS)
31963 + : "memory");
31964 +
31965 + pax_open_kernel();
31966 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
31967 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
31968 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
31969 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
31970 + pax_close_kernel();
31971 +
31972 local_irq_restore(flags);
31973
31974 switch (return_code) {
31975 - case 0:
31976 - return address + entry;
31977 - case 0x80: /* Not present */
31978 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
31979 - return 0;
31980 - default: /* Shouldn't happen */
31981 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
31982 - service, return_code);
31983 + case 0: {
31984 + int cpu;
31985 + unsigned char flags;
31986 +
31987 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
31988 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
31989 + printk(KERN_WARNING "bios32_service: not valid\n");
31990 return 0;
31991 + }
31992 + address = address + PAGE_OFFSET;
31993 + length += 16UL; /* some BIOSs underreport this... */
31994 + flags = 4;
31995 + if (length >= 64*1024*1024) {
31996 + length >>= PAGE_SHIFT;
31997 + flags |= 8;
31998 + }
31999 +
32000 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
32001 + gdt = get_cpu_gdt_table(cpu);
32002 + pack_descriptor(&d, address, length, 0x9b, flags);
32003 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
32004 + pack_descriptor(&d, address, length, 0x93, flags);
32005 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
32006 + }
32007 + return entry;
32008 + }
32009 + case 0x80: /* Not present */
32010 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
32011 + return 0;
32012 + default: /* Shouldn't happen */
32013 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
32014 + service, return_code);
32015 + return 0;
32016 }
32017 }
32018
32019 static struct {
32020 unsigned long address;
32021 unsigned short segment;
32022 -} pci_indirect = { 0, __KERNEL_CS };
32023 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
32024
32025 -static int pci_bios_present;
32026 +static int pci_bios_present __read_only;
32027
32028 static int check_pcibios(void)
32029 {
32030 @@ -131,11 +174,13 @@ static int check_pcibios(void)
32031 unsigned long flags, pcibios_entry;
32032
32033 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
32034 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
32035 + pci_indirect.address = pcibios_entry;
32036
32037 local_irq_save(flags);
32038 - __asm__(
32039 - "lcall *(%%edi); cld\n\t"
32040 + __asm__("movw %w6, %%ds\n\t"
32041 + "lcall *%%ss:(%%edi); cld\n\t"
32042 + "push %%ss\n\t"
32043 + "pop %%ds\n\t"
32044 "jc 1f\n\t"
32045 "xor %%ah, %%ah\n"
32046 "1:"
32047 @@ -144,7 +189,8 @@ static int check_pcibios(void)
32048 "=b" (ebx),
32049 "=c" (ecx)
32050 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
32051 - "D" (&pci_indirect)
32052 + "D" (&pci_indirect),
32053 + "r" (__PCIBIOS_DS)
32054 : "memory");
32055 local_irq_restore(flags);
32056
32057 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32058
32059 switch (len) {
32060 case 1:
32061 - __asm__("lcall *(%%esi); cld\n\t"
32062 + __asm__("movw %w6, %%ds\n\t"
32063 + "lcall *%%ss:(%%esi); cld\n\t"
32064 + "push %%ss\n\t"
32065 + "pop %%ds\n\t"
32066 "jc 1f\n\t"
32067 "xor %%ah, %%ah\n"
32068 "1:"
32069 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32070 : "1" (PCIBIOS_READ_CONFIG_BYTE),
32071 "b" (bx),
32072 "D" ((long)reg),
32073 - "S" (&pci_indirect));
32074 + "S" (&pci_indirect),
32075 + "r" (__PCIBIOS_DS));
32076 /*
32077 * Zero-extend the result beyond 8 bits, do not trust the
32078 * BIOS having done it:
32079 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32080 *value &= 0xff;
32081 break;
32082 case 2:
32083 - __asm__("lcall *(%%esi); cld\n\t"
32084 + __asm__("movw %w6, %%ds\n\t"
32085 + "lcall *%%ss:(%%esi); cld\n\t"
32086 + "push %%ss\n\t"
32087 + "pop %%ds\n\t"
32088 "jc 1f\n\t"
32089 "xor %%ah, %%ah\n"
32090 "1:"
32091 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32092 : "1" (PCIBIOS_READ_CONFIG_WORD),
32093 "b" (bx),
32094 "D" ((long)reg),
32095 - "S" (&pci_indirect));
32096 + "S" (&pci_indirect),
32097 + "r" (__PCIBIOS_DS));
32098 /*
32099 * Zero-extend the result beyond 16 bits, do not trust the
32100 * BIOS having done it:
32101 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32102 *value &= 0xffff;
32103 break;
32104 case 4:
32105 - __asm__("lcall *(%%esi); cld\n\t"
32106 + __asm__("movw %w6, %%ds\n\t"
32107 + "lcall *%%ss:(%%esi); cld\n\t"
32108 + "push %%ss\n\t"
32109 + "pop %%ds\n\t"
32110 "jc 1f\n\t"
32111 "xor %%ah, %%ah\n"
32112 "1:"
32113 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
32114 : "1" (PCIBIOS_READ_CONFIG_DWORD),
32115 "b" (bx),
32116 "D" ((long)reg),
32117 - "S" (&pci_indirect));
32118 + "S" (&pci_indirect),
32119 + "r" (__PCIBIOS_DS));
32120 break;
32121 }
32122
32123 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
32124
32125 switch (len) {
32126 case 1:
32127 - __asm__("lcall *(%%esi); cld\n\t"
32128 + __asm__("movw %w6, %%ds\n\t"
32129 + "lcall *%%ss:(%%esi); cld\n\t"
32130 + "push %%ss\n\t"
32131 + "pop %%ds\n\t"
32132 "jc 1f\n\t"
32133 "xor %%ah, %%ah\n"
32134 "1:"
32135 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
32136 "c" (value),
32137 "b" (bx),
32138 "D" ((long)reg),
32139 - "S" (&pci_indirect));
32140 + "S" (&pci_indirect),
32141 + "r" (__PCIBIOS_DS));
32142 break;
32143 case 2:
32144 - __asm__("lcall *(%%esi); cld\n\t"
32145 + __asm__("movw %w6, %%ds\n\t"
32146 + "lcall *%%ss:(%%esi); cld\n\t"
32147 + "push %%ss\n\t"
32148 + "pop %%ds\n\t"
32149 "jc 1f\n\t"
32150 "xor %%ah, %%ah\n"
32151 "1:"
32152 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
32153 "c" (value),
32154 "b" (bx),
32155 "D" ((long)reg),
32156 - "S" (&pci_indirect));
32157 + "S" (&pci_indirect),
32158 + "r" (__PCIBIOS_DS));
32159 break;
32160 case 4:
32161 - __asm__("lcall *(%%esi); cld\n\t"
32162 + __asm__("movw %w6, %%ds\n\t"
32163 + "lcall *%%ss:(%%esi); cld\n\t"
32164 + "push %%ss\n\t"
32165 + "pop %%ds\n\t"
32166 "jc 1f\n\t"
32167 "xor %%ah, %%ah\n"
32168 "1:"
32169 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
32170 "c" (value),
32171 "b" (bx),
32172 "D" ((long)reg),
32173 - "S" (&pci_indirect));
32174 + "S" (&pci_indirect),
32175 + "r" (__PCIBIOS_DS));
32176 break;
32177 }
32178
32179 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
32180
32181 DBG("PCI: Fetching IRQ routing table... ");
32182 __asm__("push %%es\n\t"
32183 + "movw %w8, %%ds\n\t"
32184 "push %%ds\n\t"
32185 "pop %%es\n\t"
32186 - "lcall *(%%esi); cld\n\t"
32187 + "lcall *%%ss:(%%esi); cld\n\t"
32188 "pop %%es\n\t"
32189 + "push %%ss\n\t"
32190 + "pop %%ds\n"
32191 "jc 1f\n\t"
32192 "xor %%ah, %%ah\n"
32193 "1:"
32194 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
32195 "1" (0),
32196 "D" ((long) &opt),
32197 "S" (&pci_indirect),
32198 - "m" (opt)
32199 + "m" (opt),
32200 + "r" (__PCIBIOS_DS)
32201 : "memory");
32202 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
32203 if (ret & 0xff00)
32204 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
32205 {
32206 int ret;
32207
32208 - __asm__("lcall *(%%esi); cld\n\t"
32209 + __asm__("movw %w5, %%ds\n\t"
32210 + "lcall *%%ss:(%%esi); cld\n\t"
32211 + "push %%ss\n\t"
32212 + "pop %%ds\n"
32213 "jc 1f\n\t"
32214 "xor %%ah, %%ah\n"
32215 "1:"
32216 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
32217 : "0" (PCIBIOS_SET_PCI_HW_INT),
32218 "b" ((dev->bus->number << 8) | dev->devfn),
32219 "c" ((irq << 8) | (pin + 10)),
32220 - "S" (&pci_indirect));
32221 + "S" (&pci_indirect),
32222 + "r" (__PCIBIOS_DS));
32223 return !(ret & 0xff00);
32224 }
32225 EXPORT_SYMBOL(pcibios_set_irq_routing);
32226 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
32227 index 40e4469..d915bf9 100644
32228 --- a/arch/x86/platform/efi/efi_32.c
32229 +++ b/arch/x86/platform/efi/efi_32.c
32230 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
32231 {
32232 struct desc_ptr gdt_descr;
32233
32234 +#ifdef CONFIG_PAX_KERNEXEC
32235 + struct desc_struct d;
32236 +#endif
32237 +
32238 local_irq_save(efi_rt_eflags);
32239
32240 load_cr3(initial_page_table);
32241 __flush_tlb_all();
32242
32243 +#ifdef CONFIG_PAX_KERNEXEC
32244 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
32245 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
32246 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
32247 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
32248 +#endif
32249 +
32250 gdt_descr.address = __pa(get_cpu_gdt_table(0));
32251 gdt_descr.size = GDT_SIZE - 1;
32252 load_gdt(&gdt_descr);
32253 @@ -58,11 +69,24 @@ void efi_call_phys_epilog(void)
32254 {
32255 struct desc_ptr gdt_descr;
32256
32257 +#ifdef CONFIG_PAX_KERNEXEC
32258 + struct desc_struct d;
32259 +
32260 + memset(&d, 0, sizeof d);
32261 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
32262 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
32263 +#endif
32264 +
32265 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
32266 gdt_descr.size = GDT_SIZE - 1;
32267 load_gdt(&gdt_descr);
32268
32269 +#ifdef CONFIG_PAX_PER_CPU_PGD
32270 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
32271 +#else
32272 load_cr3(swapper_pg_dir);
32273 +#endif
32274 +
32275 __flush_tlb_all();
32276
32277 local_irq_restore(efi_rt_eflags);
32278 diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
32279 index 39a0e7f1..872396e 100644
32280 --- a/arch/x86/platform/efi/efi_64.c
32281 +++ b/arch/x86/platform/efi/efi_64.c
32282 @@ -76,6 +76,11 @@ void __init efi_call_phys_prelog(void)
32283 vaddress = (unsigned long)__va(pgd * PGDIR_SIZE);
32284 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), *pgd_offset_k(vaddress));
32285 }
32286 +
32287 +#ifdef CONFIG_PAX_PER_CPU_PGD
32288 + load_cr3(swapper_pg_dir);
32289 +#endif
32290 +
32291 __flush_tlb_all();
32292 }
32293
32294 @@ -89,6 +94,11 @@ void __init efi_call_phys_epilog(void)
32295 for (pgd = 0; pgd < n_pgds; pgd++)
32296 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), save_pgd[pgd]);
32297 kfree(save_pgd);
32298 +
32299 +#ifdef CONFIG_PAX_PER_CPU_PGD
32300 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
32301 +#endif
32302 +
32303 __flush_tlb_all();
32304 local_irq_restore(efi_flags);
32305 early_code_mapping_set_exec(0);
32306 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
32307 index fbe66e6..eae5e38 100644
32308 --- a/arch/x86/platform/efi/efi_stub_32.S
32309 +++ b/arch/x86/platform/efi/efi_stub_32.S
32310 @@ -6,7 +6,9 @@
32311 */
32312
32313 #include <linux/linkage.h>
32314 +#include <linux/init.h>
32315 #include <asm/page_types.h>
32316 +#include <asm/segment.h>
32317
32318 /*
32319 * efi_call_phys(void *, ...) is a function with variable parameters.
32320 @@ -20,7 +22,7 @@
32321 * service functions will comply with gcc calling convention, too.
32322 */
32323
32324 -.text
32325 +__INIT
32326 ENTRY(efi_call_phys)
32327 /*
32328 * 0. The function can only be called in Linux kernel. So CS has been
32329 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
32330 * The mapping of lower virtual memory has been created in prelog and
32331 * epilog.
32332 */
32333 - movl $1f, %edx
32334 - subl $__PAGE_OFFSET, %edx
32335 - jmp *%edx
32336 +#ifdef CONFIG_PAX_KERNEXEC
32337 + movl $(__KERNEXEC_EFI_DS), %edx
32338 + mov %edx, %ds
32339 + mov %edx, %es
32340 + mov %edx, %ss
32341 + addl $2f,(1f)
32342 + ljmp *(1f)
32343 +
32344 +__INITDATA
32345 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
32346 +.previous
32347 +
32348 +2:
32349 + subl $2b,(1b)
32350 +#else
32351 + jmp 1f-__PAGE_OFFSET
32352 1:
32353 +#endif
32354
32355 /*
32356 * 2. Now on the top of stack is the return
32357 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
32358 * parameter 2, ..., param n. To make things easy, we save the return
32359 * address of efi_call_phys in a global variable.
32360 */
32361 - popl %edx
32362 - movl %edx, saved_return_addr
32363 - /* get the function pointer into ECX*/
32364 - popl %ecx
32365 - movl %ecx, efi_rt_function_ptr
32366 - movl $2f, %edx
32367 - subl $__PAGE_OFFSET, %edx
32368 - pushl %edx
32369 + popl (saved_return_addr)
32370 + popl (efi_rt_function_ptr)
32371
32372 /*
32373 * 3. Clear PG bit in %CR0.
32374 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
32375 /*
32376 * 5. Call the physical function.
32377 */
32378 - jmp *%ecx
32379 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
32380
32381 -2:
32382 /*
32383 * 6. After EFI runtime service returns, control will return to
32384 * following instruction. We'd better readjust stack pointer first.
32385 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
32386 movl %cr0, %edx
32387 orl $0x80000000, %edx
32388 movl %edx, %cr0
32389 - jmp 1f
32390 -1:
32391 +
32392 /*
32393 * 8. Now restore the virtual mode from flat mode by
32394 * adding EIP with PAGE_OFFSET.
32395 */
32396 - movl $1f, %edx
32397 - jmp *%edx
32398 +#ifdef CONFIG_PAX_KERNEXEC
32399 + movl $(__KERNEL_DS), %edx
32400 + mov %edx, %ds
32401 + mov %edx, %es
32402 + mov %edx, %ss
32403 + ljmp $(__KERNEL_CS),$1f
32404 +#else
32405 + jmp 1f+__PAGE_OFFSET
32406 +#endif
32407 1:
32408
32409 /*
32410 * 9. Balance the stack. And because EAX contain the return value,
32411 * we'd better not clobber it.
32412 */
32413 - leal efi_rt_function_ptr, %edx
32414 - movl (%edx), %ecx
32415 - pushl %ecx
32416 + pushl (efi_rt_function_ptr)
32417
32418 /*
32419 - * 10. Push the saved return address onto the stack and return.
32420 + * 10. Return to the saved return address.
32421 */
32422 - leal saved_return_addr, %edx
32423 - movl (%edx), %ecx
32424 - pushl %ecx
32425 - ret
32426 + jmpl *(saved_return_addr)
32427 ENDPROC(efi_call_phys)
32428 .previous
32429
32430 -.data
32431 +__INITDATA
32432 saved_return_addr:
32433 .long 0
32434 efi_rt_function_ptr:
32435 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
32436 index 4c07cca..2c8427d 100644
32437 --- a/arch/x86/platform/efi/efi_stub_64.S
32438 +++ b/arch/x86/platform/efi/efi_stub_64.S
32439 @@ -7,6 +7,7 @@
32440 */
32441
32442 #include <linux/linkage.h>
32443 +#include <asm/alternative-asm.h>
32444
32445 #define SAVE_XMM \
32446 mov %rsp, %rax; \
32447 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
32448 call *%rdi
32449 addq $32, %rsp
32450 RESTORE_XMM
32451 + pax_force_retaddr 0, 1
32452 ret
32453 ENDPROC(efi_call0)
32454
32455 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
32456 call *%rdi
32457 addq $32, %rsp
32458 RESTORE_XMM
32459 + pax_force_retaddr 0, 1
32460 ret
32461 ENDPROC(efi_call1)
32462
32463 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
32464 call *%rdi
32465 addq $32, %rsp
32466 RESTORE_XMM
32467 + pax_force_retaddr 0, 1
32468 ret
32469 ENDPROC(efi_call2)
32470
32471 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
32472 call *%rdi
32473 addq $32, %rsp
32474 RESTORE_XMM
32475 + pax_force_retaddr 0, 1
32476 ret
32477 ENDPROC(efi_call3)
32478
32479 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
32480 call *%rdi
32481 addq $32, %rsp
32482 RESTORE_XMM
32483 + pax_force_retaddr 0, 1
32484 ret
32485 ENDPROC(efi_call4)
32486
32487 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
32488 call *%rdi
32489 addq $48, %rsp
32490 RESTORE_XMM
32491 + pax_force_retaddr 0, 1
32492 ret
32493 ENDPROC(efi_call5)
32494
32495 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
32496 call *%rdi
32497 addq $48, %rsp
32498 RESTORE_XMM
32499 + pax_force_retaddr 0, 1
32500 ret
32501 ENDPROC(efi_call6)
32502 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
32503 index a0a0a43..a48e233 100644
32504 --- a/arch/x86/platform/mrst/mrst.c
32505 +++ b/arch/x86/platform/mrst/mrst.c
32506 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
32507 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
32508 int sfi_mrtc_num;
32509
32510 -static void mrst_power_off(void)
32511 +static __noreturn void mrst_power_off(void)
32512 {
32513 + BUG();
32514 }
32515
32516 -static void mrst_reboot(void)
32517 +static __noreturn void mrst_reboot(void)
32518 {
32519 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
32520 + BUG();
32521 }
32522
32523 /* parse all the mtimer info to a static mtimer array */
32524 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
32525 index d6ee929..3637cb5 100644
32526 --- a/arch/x86/platform/olpc/olpc_dt.c
32527 +++ b/arch/x86/platform/olpc/olpc_dt.c
32528 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
32529 return res;
32530 }
32531
32532 -static struct of_pdt_ops prom_olpc_ops __initdata = {
32533 +static struct of_pdt_ops prom_olpc_ops __initconst = {
32534 .nextprop = olpc_dt_nextprop,
32535 .getproplen = olpc_dt_getproplen,
32536 .getproperty = olpc_dt_getproperty,
32537 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
32538 index 1cf5b30..fd45732 100644
32539 --- a/arch/x86/power/cpu.c
32540 +++ b/arch/x86/power/cpu.c
32541 @@ -137,11 +137,8 @@ static void do_fpu_end(void)
32542 static void fix_processor_context(void)
32543 {
32544 int cpu = smp_processor_id();
32545 - struct tss_struct *t = &per_cpu(init_tss, cpu);
32546 -#ifdef CONFIG_X86_64
32547 - struct desc_struct *desc = get_cpu_gdt_table(cpu);
32548 - tss_desc tss;
32549 -#endif
32550 + struct tss_struct *t = init_tss + cpu;
32551 +
32552 set_tss_desc(cpu, t); /*
32553 * This just modifies memory; should not be
32554 * necessary. But... This is necessary, because
32555 @@ -150,10 +147,6 @@ static void fix_processor_context(void)
32556 */
32557
32558 #ifdef CONFIG_X86_64
32559 - memcpy(&tss, &desc[GDT_ENTRY_TSS], sizeof(tss_desc));
32560 - tss.type = 0x9; /* The available 64-bit TSS (see AMD vol 2, pg 91 */
32561 - write_gdt_entry(desc, GDT_ENTRY_TSS, &tss, DESC_TSS);
32562 -
32563 syscall_init(); /* This sets MSR_*STAR and related */
32564 #endif
32565 load_TR_desc(); /* This does ltr */
32566 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
32567 index a44f457..9140171 100644
32568 --- a/arch/x86/realmode/init.c
32569 +++ b/arch/x86/realmode/init.c
32570 @@ -70,7 +70,13 @@ void __init setup_real_mode(void)
32571 __va(real_mode_header->trampoline_header);
32572
32573 #ifdef CONFIG_X86_32
32574 - trampoline_header->start = __pa_symbol(startup_32_smp);
32575 + trampoline_header->start = __pa_symbol(ktla_ktva(startup_32_smp));
32576 +
32577 +#ifdef CONFIG_PAX_KERNEXEC
32578 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
32579 +#endif
32580 +
32581 + trampoline_header->boot_cs = __BOOT_CS;
32582 trampoline_header->gdt_limit = __BOOT_DS + 7;
32583 trampoline_header->gdt_base = __pa_symbol(boot_gdt);
32584 #else
32585 @@ -86,7 +92,7 @@ void __init setup_real_mode(void)
32586 *trampoline_cr4_features = read_cr4();
32587
32588 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
32589 - trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
32590 + trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd & ~_PAGE_NX;
32591 trampoline_pgd[511] = init_level4_pgt[511].pgd;
32592 #endif
32593 }
32594 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
32595 index 8869287..d577672 100644
32596 --- a/arch/x86/realmode/rm/Makefile
32597 +++ b/arch/x86/realmode/rm/Makefile
32598 @@ -78,5 +78,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
32599 $(call cc-option, -fno-unit-at-a-time)) \
32600 $(call cc-option, -fno-stack-protector) \
32601 $(call cc-option, -mpreferred-stack-boundary=2)
32602 +ifdef CONSTIFY_PLUGIN
32603 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
32604 +endif
32605 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
32606 GCOV_PROFILE := n
32607 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
32608 index a28221d..93c40f1 100644
32609 --- a/arch/x86/realmode/rm/header.S
32610 +++ b/arch/x86/realmode/rm/header.S
32611 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
32612 #endif
32613 /* APM/BIOS reboot */
32614 .long pa_machine_real_restart_asm
32615 -#ifdef CONFIG_X86_64
32616 +#ifdef CONFIG_X86_32
32617 + .long __KERNEL_CS
32618 +#else
32619 .long __KERNEL32_CS
32620 #endif
32621 END(real_mode_header)
32622 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
32623 index c1b2791..f9e31c7 100644
32624 --- a/arch/x86/realmode/rm/trampoline_32.S
32625 +++ b/arch/x86/realmode/rm/trampoline_32.S
32626 @@ -25,6 +25,12 @@
32627 #include <asm/page_types.h>
32628 #include "realmode.h"
32629
32630 +#ifdef CONFIG_PAX_KERNEXEC
32631 +#define ta(X) (X)
32632 +#else
32633 +#define ta(X) (pa_ ## X)
32634 +#endif
32635 +
32636 .text
32637 .code16
32638
32639 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
32640
32641 cli # We should be safe anyway
32642
32643 - movl tr_start, %eax # where we need to go
32644 -
32645 movl $0xA5A5A5A5, trampoline_status
32646 # write marker for master knows we're running
32647
32648 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
32649 movw $1, %dx # protected mode (PE) bit
32650 lmsw %dx # into protected mode
32651
32652 - ljmpl $__BOOT_CS, $pa_startup_32
32653 + ljmpl *(trampoline_header)
32654
32655 .section ".text32","ax"
32656 .code32
32657 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
32658 .balign 8
32659 GLOBAL(trampoline_header)
32660 tr_start: .space 4
32661 - tr_gdt_pad: .space 2
32662 + tr_boot_cs: .space 2
32663 tr_gdt: .space 6
32664 END(trampoline_header)
32665
32666 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
32667 index bb360dc..d0fd8f8 100644
32668 --- a/arch/x86/realmode/rm/trampoline_64.S
32669 +++ b/arch/x86/realmode/rm/trampoline_64.S
32670 @@ -94,6 +94,7 @@ ENTRY(startup_32)
32671 movl %edx, %gs
32672
32673 movl pa_tr_cr4, %eax
32674 + andl $~X86_CR4_PCIDE, %eax
32675 movl %eax, %cr4 # Enable PAE mode
32676
32677 # Setup trampoline 4 level pagetables
32678 @@ -107,7 +108,7 @@ ENTRY(startup_32)
32679 wrmsr
32680
32681 # Enable paging and in turn activate Long Mode
32682 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
32683 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
32684 movl %eax, %cr0
32685
32686 /*
32687 diff --git a/arch/x86/tools/Makefile b/arch/x86/tools/Makefile
32688 index e812034..c747134 100644
32689 --- a/arch/x86/tools/Makefile
32690 +++ b/arch/x86/tools/Makefile
32691 @@ -37,7 +37,7 @@ $(obj)/test_get_len.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/in
32692
32693 $(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
32694
32695 -HOST_EXTRACFLAGS += -I$(srctree)/tools/include
32696 +HOST_EXTRACFLAGS += -I$(srctree)/tools/include -ggdb
32697 hostprogs-y += relocs
32698 relocs-objs := relocs_32.o relocs_64.o relocs_common.o
32699 relocs: $(obj)/relocs
32700 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
32701 index f7bab68..b6d9886 100644
32702 --- a/arch/x86/tools/relocs.c
32703 +++ b/arch/x86/tools/relocs.c
32704 @@ -1,5 +1,7 @@
32705 /* This is included from relocs_32/64.c */
32706
32707 +#include "../../../include/generated/autoconf.h"
32708 +
32709 #define ElfW(type) _ElfW(ELF_BITS, type)
32710 #define _ElfW(bits, type) __ElfW(bits, type)
32711 #define __ElfW(bits, type) Elf##bits##_##type
32712 @@ -11,6 +13,7 @@
32713 #define Elf_Sym ElfW(Sym)
32714
32715 static Elf_Ehdr ehdr;
32716 +static Elf_Phdr *phdr;
32717
32718 struct relocs {
32719 uint32_t *offset;
32720 @@ -383,9 +386,39 @@ static void read_ehdr(FILE *fp)
32721 }
32722 }
32723
32724 +static void read_phdrs(FILE *fp)
32725 +{
32726 + unsigned int i;
32727 +
32728 + phdr = calloc(ehdr.e_phnum, sizeof(Elf_Phdr));
32729 + if (!phdr) {
32730 + die("Unable to allocate %d program headers\n",
32731 + ehdr.e_phnum);
32732 + }
32733 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
32734 + die("Seek to %d failed: %s\n",
32735 + ehdr.e_phoff, strerror(errno));
32736 + }
32737 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
32738 + die("Cannot read ELF program headers: %s\n",
32739 + strerror(errno));
32740 + }
32741 + for(i = 0; i < ehdr.e_phnum; i++) {
32742 + phdr[i].p_type = elf_word_to_cpu(phdr[i].p_type);
32743 + phdr[i].p_offset = elf_off_to_cpu(phdr[i].p_offset);
32744 + phdr[i].p_vaddr = elf_addr_to_cpu(phdr[i].p_vaddr);
32745 + phdr[i].p_paddr = elf_addr_to_cpu(phdr[i].p_paddr);
32746 + phdr[i].p_filesz = elf_word_to_cpu(phdr[i].p_filesz);
32747 + phdr[i].p_memsz = elf_word_to_cpu(phdr[i].p_memsz);
32748 + phdr[i].p_flags = elf_word_to_cpu(phdr[i].p_flags);
32749 + phdr[i].p_align = elf_word_to_cpu(phdr[i].p_align);
32750 + }
32751 +
32752 +}
32753 +
32754 static void read_shdrs(FILE *fp)
32755 {
32756 - int i;
32757 + unsigned int i;
32758 Elf_Shdr shdr;
32759
32760 secs = calloc(ehdr.e_shnum, sizeof(struct section));
32761 @@ -420,7 +453,7 @@ static void read_shdrs(FILE *fp)
32762
32763 static void read_strtabs(FILE *fp)
32764 {
32765 - int i;
32766 + unsigned int i;
32767 for (i = 0; i < ehdr.e_shnum; i++) {
32768 struct section *sec = &secs[i];
32769 if (sec->shdr.sh_type != SHT_STRTAB) {
32770 @@ -445,7 +478,7 @@ static void read_strtabs(FILE *fp)
32771
32772 static void read_symtabs(FILE *fp)
32773 {
32774 - int i,j;
32775 + unsigned int i,j;
32776 for (i = 0; i < ehdr.e_shnum; i++) {
32777 struct section *sec = &secs[i];
32778 if (sec->shdr.sh_type != SHT_SYMTAB) {
32779 @@ -476,9 +509,11 @@ static void read_symtabs(FILE *fp)
32780 }
32781
32782
32783 -static void read_relocs(FILE *fp)
32784 +static void read_relocs(FILE *fp, int use_real_mode)
32785 {
32786 - int i,j;
32787 + unsigned int i,j;
32788 + uint32_t base;
32789 +
32790 for (i = 0; i < ehdr.e_shnum; i++) {
32791 struct section *sec = &secs[i];
32792 if (sec->shdr.sh_type != SHT_REL_TYPE) {
32793 @@ -498,9 +533,22 @@ static void read_relocs(FILE *fp)
32794 die("Cannot read symbol table: %s\n",
32795 strerror(errno));
32796 }
32797 + base = 0;
32798 +
32799 +#ifdef CONFIG_X86_32
32800 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
32801 + if (phdr[j].p_type != PT_LOAD )
32802 + continue;
32803 + 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)
32804 + continue;
32805 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
32806 + break;
32807 + }
32808 +#endif
32809 +
32810 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf_Rel); j++) {
32811 Elf_Rel *rel = &sec->reltab[j];
32812 - rel->r_offset = elf_addr_to_cpu(rel->r_offset);
32813 + rel->r_offset = elf_addr_to_cpu(rel->r_offset) + base;
32814 rel->r_info = elf_xword_to_cpu(rel->r_info);
32815 #if (SHT_REL_TYPE == SHT_RELA)
32816 rel->r_addend = elf_xword_to_cpu(rel->r_addend);
32817 @@ -512,7 +560,7 @@ static void read_relocs(FILE *fp)
32818
32819 static void print_absolute_symbols(void)
32820 {
32821 - int i;
32822 + unsigned int i;
32823 const char *format;
32824
32825 if (ELF_BITS == 64)
32826 @@ -525,7 +573,7 @@ static void print_absolute_symbols(void)
32827 for (i = 0; i < ehdr.e_shnum; i++) {
32828 struct section *sec = &secs[i];
32829 char *sym_strtab;
32830 - int j;
32831 + unsigned int j;
32832
32833 if (sec->shdr.sh_type != SHT_SYMTAB) {
32834 continue;
32835 @@ -552,7 +600,7 @@ static void print_absolute_symbols(void)
32836
32837 static void print_absolute_relocs(void)
32838 {
32839 - int i, printed = 0;
32840 + unsigned int i, printed = 0;
32841 const char *format;
32842
32843 if (ELF_BITS == 64)
32844 @@ -565,7 +613,7 @@ static void print_absolute_relocs(void)
32845 struct section *sec_applies, *sec_symtab;
32846 char *sym_strtab;
32847 Elf_Sym *sh_symtab;
32848 - int j;
32849 + unsigned int j;
32850 if (sec->shdr.sh_type != SHT_REL_TYPE) {
32851 continue;
32852 }
32853 @@ -642,13 +690,13 @@ static void add_reloc(struct relocs *r, uint32_t offset)
32854 static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
32855 Elf_Sym *sym, const char *symname))
32856 {
32857 - int i;
32858 + unsigned int i;
32859 /* Walk through the relocations */
32860 for (i = 0; i < ehdr.e_shnum; i++) {
32861 char *sym_strtab;
32862 Elf_Sym *sh_symtab;
32863 struct section *sec_applies, *sec_symtab;
32864 - int j;
32865 + unsigned int j;
32866 struct section *sec = &secs[i];
32867
32868 if (sec->shdr.sh_type != SHT_REL_TYPE) {
32869 @@ -812,6 +860,23 @@ static int do_reloc32(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
32870 {
32871 unsigned r_type = ELF32_R_TYPE(rel->r_info);
32872 int shn_abs = (sym->st_shndx == SHN_ABS) && !is_reloc(S_REL, symname);
32873 + char *sym_strtab = sec->link->link->strtab;
32874 +
32875 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
32876 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
32877 + return 0;
32878 +
32879 +#ifdef CONFIG_PAX_KERNEXEC
32880 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
32881 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
32882 + return 0;
32883 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
32884 + return 0;
32885 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
32886 + return 0;
32887 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
32888 + return 0;
32889 +#endif
32890
32891 switch (r_type) {
32892 case R_386_NONE:
32893 @@ -950,7 +1015,7 @@ static int write32_as_text(uint32_t v, FILE *f)
32894
32895 static void emit_relocs(int as_text, int use_real_mode)
32896 {
32897 - int i;
32898 + unsigned int i;
32899 int (*write_reloc)(uint32_t, FILE *) = write32;
32900 int (*do_reloc)(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
32901 const char *symname);
32902 @@ -1026,10 +1091,11 @@ void process(FILE *fp, int use_real_mode, int as_text,
32903 {
32904 regex_init(use_real_mode);
32905 read_ehdr(fp);
32906 + read_phdrs(fp);
32907 read_shdrs(fp);
32908 read_strtabs(fp);
32909 read_symtabs(fp);
32910 - read_relocs(fp);
32911 + read_relocs(fp, use_real_mode);
32912 if (ELF_BITS == 64)
32913 percpu_init();
32914 if (show_absolute_syms) {
32915 diff --git a/arch/x86/um/tls_32.c b/arch/x86/um/tls_32.c
32916 index 80ffa5b..a33bd15 100644
32917 --- a/arch/x86/um/tls_32.c
32918 +++ b/arch/x86/um/tls_32.c
32919 @@ -260,7 +260,7 @@ out:
32920 if (unlikely(task == current &&
32921 !t->arch.tls_array[idx - GDT_ENTRY_TLS_MIN].flushed)) {
32922 printk(KERN_ERR "get_tls_entry: task with pid %d got here "
32923 - "without flushed TLS.", current->pid);
32924 + "without flushed TLS.", task_pid_nr(current));
32925 }
32926
32927 return 0;
32928 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
32929 index fd14be1..e3c79c0 100644
32930 --- a/arch/x86/vdso/Makefile
32931 +++ b/arch/x86/vdso/Makefile
32932 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
32933 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
32934 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
32935
32936 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
32937 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
32938 GCOV_PROFILE := n
32939
32940 #
32941 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
32942 index 0faad64..39ef157 100644
32943 --- a/arch/x86/vdso/vdso32-setup.c
32944 +++ b/arch/x86/vdso/vdso32-setup.c
32945 @@ -25,6 +25,7 @@
32946 #include <asm/tlbflush.h>
32947 #include <asm/vdso.h>
32948 #include <asm/proto.h>
32949 +#include <asm/mman.h>
32950
32951 enum {
32952 VDSO_DISABLED = 0,
32953 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
32954 void enable_sep_cpu(void)
32955 {
32956 int cpu = get_cpu();
32957 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
32958 + struct tss_struct *tss = init_tss + cpu;
32959
32960 if (!boot_cpu_has(X86_FEATURE_SEP)) {
32961 put_cpu();
32962 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
32963 gate_vma.vm_start = FIXADDR_USER_START;
32964 gate_vma.vm_end = FIXADDR_USER_END;
32965 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
32966 - gate_vma.vm_page_prot = __P101;
32967 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
32968
32969 return 0;
32970 }
32971 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
32972 if (compat)
32973 addr = VDSO_HIGH_BASE;
32974 else {
32975 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
32976 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
32977 if (IS_ERR_VALUE(addr)) {
32978 ret = addr;
32979 goto up_fail;
32980 }
32981 }
32982
32983 - current->mm->context.vdso = (void *)addr;
32984 + current->mm->context.vdso = addr;
32985
32986 if (compat_uses_vma || !compat) {
32987 /*
32988 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
32989 }
32990
32991 current_thread_info()->sysenter_return =
32992 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
32993 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
32994
32995 up_fail:
32996 if (ret)
32997 - current->mm->context.vdso = NULL;
32998 + current->mm->context.vdso = 0;
32999
33000 up_write(&mm->mmap_sem);
33001
33002 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
33003
33004 const char *arch_vma_name(struct vm_area_struct *vma)
33005 {
33006 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
33007 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
33008 return "[vdso]";
33009 +
33010 +#ifdef CONFIG_PAX_SEGMEXEC
33011 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
33012 + return "[vdso]";
33013 +#endif
33014 +
33015 return NULL;
33016 }
33017
33018 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
33019 * Check to see if the corresponding task was created in compat vdso
33020 * mode.
33021 */
33022 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
33023 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
33024 return &gate_vma;
33025 return NULL;
33026 }
33027 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
33028 index 431e875..cbb23f3 100644
33029 --- a/arch/x86/vdso/vma.c
33030 +++ b/arch/x86/vdso/vma.c
33031 @@ -16,8 +16,6 @@
33032 #include <asm/vdso.h>
33033 #include <asm/page.h>
33034
33035 -unsigned int __read_mostly vdso_enabled = 1;
33036 -
33037 extern char vdso_start[], vdso_end[];
33038 extern unsigned short vdso_sync_cpuid;
33039
33040 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
33041 * unaligned here as a result of stack start randomization.
33042 */
33043 addr = PAGE_ALIGN(addr);
33044 - addr = align_vdso_addr(addr);
33045
33046 return addr;
33047 }
33048 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
33049 unsigned size)
33050 {
33051 struct mm_struct *mm = current->mm;
33052 - unsigned long addr;
33053 + unsigned long addr = 0;
33054 int ret;
33055
33056 - if (!vdso_enabled)
33057 - return 0;
33058 -
33059 down_write(&mm->mmap_sem);
33060 +
33061 +#ifdef CONFIG_PAX_RANDMMAP
33062 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
33063 +#endif
33064 +
33065 addr = vdso_addr(mm->start_stack, size);
33066 + addr = align_vdso_addr(addr);
33067 addr = get_unmapped_area(NULL, addr, size, 0, 0);
33068 if (IS_ERR_VALUE(addr)) {
33069 ret = addr;
33070 goto up_fail;
33071 }
33072
33073 - current->mm->context.vdso = (void *)addr;
33074 + mm->context.vdso = addr;
33075
33076 ret = install_special_mapping(mm, addr, size,
33077 VM_READ|VM_EXEC|
33078 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
33079 pages);
33080 - if (ret) {
33081 - current->mm->context.vdso = NULL;
33082 - goto up_fail;
33083 - }
33084 + if (ret)
33085 + mm->context.vdso = 0;
33086
33087 up_fail:
33088 up_write(&mm->mmap_sem);
33089 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
33090 vdsox32_size);
33091 }
33092 #endif
33093 -
33094 -static __init int vdso_setup(char *s)
33095 -{
33096 - vdso_enabled = simple_strtoul(s, NULL, 0);
33097 - return 0;
33098 -}
33099 -__setup("vdso=", vdso_setup);
33100 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
33101 index a492be2..08678da 100644
33102 --- a/arch/x86/xen/enlighten.c
33103 +++ b/arch/x86/xen/enlighten.c
33104 @@ -123,8 +123,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
33105
33106 struct shared_info xen_dummy_shared_info;
33107
33108 -void *xen_initial_gdt;
33109 -
33110 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
33111 __read_mostly int xen_have_vector_callback;
33112 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
33113 @@ -542,8 +540,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
33114 {
33115 unsigned long va = dtr->address;
33116 unsigned int size = dtr->size + 1;
33117 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
33118 - unsigned long frames[pages];
33119 + unsigned long frames[65536 / PAGE_SIZE];
33120 int f;
33121
33122 /*
33123 @@ -591,8 +588,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
33124 {
33125 unsigned long va = dtr->address;
33126 unsigned int size = dtr->size + 1;
33127 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
33128 - unsigned long frames[pages];
33129 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
33130 int f;
33131
33132 /*
33133 @@ -600,7 +596,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
33134 * 8-byte entries, or 16 4k pages..
33135 */
33136
33137 - BUG_ON(size > 65536);
33138 + BUG_ON(size > GDT_SIZE);
33139 BUG_ON(va & ~PAGE_MASK);
33140
33141 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
33142 @@ -985,7 +981,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
33143 return 0;
33144 }
33145
33146 -static void set_xen_basic_apic_ops(void)
33147 +static void __init set_xen_basic_apic_ops(void)
33148 {
33149 apic->read = xen_apic_read;
33150 apic->write = xen_apic_write;
33151 @@ -1290,30 +1286,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
33152 #endif
33153 };
33154
33155 -static void xen_reboot(int reason)
33156 +static __noreturn void xen_reboot(int reason)
33157 {
33158 struct sched_shutdown r = { .reason = reason };
33159
33160 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
33161 - BUG();
33162 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
33163 + BUG();
33164 }
33165
33166 -static void xen_restart(char *msg)
33167 +static __noreturn void xen_restart(char *msg)
33168 {
33169 xen_reboot(SHUTDOWN_reboot);
33170 }
33171
33172 -static void xen_emergency_restart(void)
33173 +static __noreturn void xen_emergency_restart(void)
33174 {
33175 xen_reboot(SHUTDOWN_reboot);
33176 }
33177
33178 -static void xen_machine_halt(void)
33179 +static __noreturn void xen_machine_halt(void)
33180 {
33181 xen_reboot(SHUTDOWN_poweroff);
33182 }
33183
33184 -static void xen_machine_power_off(void)
33185 +static __noreturn void xen_machine_power_off(void)
33186 {
33187 if (pm_power_off)
33188 pm_power_off();
33189 @@ -1464,7 +1460,17 @@ asmlinkage void __init xen_start_kernel(void)
33190 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
33191
33192 /* Work out if we support NX */
33193 - x86_configure_nx();
33194 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
33195 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
33196 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
33197 + unsigned l, h;
33198 +
33199 + __supported_pte_mask |= _PAGE_NX;
33200 + rdmsr(MSR_EFER, l, h);
33201 + l |= EFER_NX;
33202 + wrmsr(MSR_EFER, l, h);
33203 + }
33204 +#endif
33205
33206 xen_setup_features();
33207
33208 @@ -1495,13 +1501,6 @@ asmlinkage void __init xen_start_kernel(void)
33209
33210 machine_ops = xen_machine_ops;
33211
33212 - /*
33213 - * The only reliable way to retain the initial address of the
33214 - * percpu gdt_page is to remember it here, so we can go and
33215 - * mark it RW later, when the initial percpu area is freed.
33216 - */
33217 - xen_initial_gdt = &per_cpu(gdt_page, 0);
33218 -
33219 xen_smp_init();
33220
33221 #ifdef CONFIG_ACPI_NUMA
33222 @@ -1700,7 +1699,7 @@ static int __cpuinit xen_hvm_cpu_notify(struct notifier_block *self,
33223 return NOTIFY_OK;
33224 }
33225
33226 -static struct notifier_block xen_hvm_cpu_notifier __cpuinitdata = {
33227 +static struct notifier_block xen_hvm_cpu_notifier = {
33228 .notifier_call = xen_hvm_cpu_notify,
33229 };
33230
33231 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
33232 index fdc3ba2..3daee39 100644
33233 --- a/arch/x86/xen/mmu.c
33234 +++ b/arch/x86/xen/mmu.c
33235 @@ -1894,6 +1894,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
33236 /* L3_k[510] -> level2_kernel_pgt
33237 * L3_i[511] -> level2_fixmap_pgt */
33238 convert_pfn_mfn(level3_kernel_pgt);
33239 + convert_pfn_mfn(level3_vmalloc_start_pgt);
33240 + convert_pfn_mfn(level3_vmalloc_end_pgt);
33241 + convert_pfn_mfn(level3_vmemmap_pgt);
33242
33243 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
33244 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
33245 @@ -1923,8 +1926,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
33246 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
33247 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
33248 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
33249 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
33250 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
33251 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
33252 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
33253 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
33254 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
33255 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
33256 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
33257
33258 @@ -2108,6 +2115,7 @@ static void __init xen_post_allocator_init(void)
33259 pv_mmu_ops.set_pud = xen_set_pud;
33260 #if PAGETABLE_LEVELS == 4
33261 pv_mmu_ops.set_pgd = xen_set_pgd;
33262 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
33263 #endif
33264
33265 /* This will work as long as patching hasn't happened yet
33266 @@ -2186,6 +2194,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
33267 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
33268 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
33269 .set_pgd = xen_set_pgd_hyper,
33270 + .set_pgd_batched = xen_set_pgd_hyper,
33271
33272 .alloc_pud = xen_alloc_pmd_init,
33273 .release_pud = xen_release_pmd_init,
33274 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
33275 index d99cae8..18401e1 100644
33276 --- a/arch/x86/xen/smp.c
33277 +++ b/arch/x86/xen/smp.c
33278 @@ -240,11 +240,6 @@ static void __init xen_smp_prepare_boot_cpu(void)
33279 {
33280 BUG_ON(smp_processor_id() != 0);
33281 native_smp_prepare_boot_cpu();
33282 -
33283 - /* We've switched to the "real" per-cpu gdt, so make sure the
33284 - old memory can be recycled */
33285 - make_lowmem_page_readwrite(xen_initial_gdt);
33286 -
33287 xen_filter_cpu_maps();
33288 xen_setup_vcpu_info_placement();
33289 }
33290 @@ -314,7 +309,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
33291 ctxt->user_regs.ss = __KERNEL_DS;
33292 #ifdef CONFIG_X86_32
33293 ctxt->user_regs.fs = __KERNEL_PERCPU;
33294 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
33295 + savesegment(gs, ctxt->user_regs.gs);
33296 #else
33297 ctxt->gs_base_kernel = per_cpu_offset(cpu);
33298 #endif
33299 @@ -324,8 +319,8 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
33300
33301 {
33302 ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
33303 - ctxt->user_regs.ds = __USER_DS;
33304 - ctxt->user_regs.es = __USER_DS;
33305 + ctxt->user_regs.ds = __KERNEL_DS;
33306 + ctxt->user_regs.es = __KERNEL_DS;
33307
33308 xen_copy_trap_info(ctxt->trap_ctxt);
33309
33310 @@ -370,13 +365,12 @@ static int __cpuinit xen_cpu_up(unsigned int cpu, struct task_struct *idle)
33311 int rc;
33312
33313 per_cpu(current_task, cpu) = idle;
33314 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
33315 #ifdef CONFIG_X86_32
33316 irq_ctx_init(cpu);
33317 #else
33318 clear_tsk_thread_flag(idle, TIF_FORK);
33319 - per_cpu(kernel_stack, cpu) =
33320 - (unsigned long)task_stack_page(idle) -
33321 - KERNEL_STACK_OFFSET + THREAD_SIZE;
33322 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
33323 #endif
33324 xen_setup_runstate_info(cpu);
33325 xen_setup_timer(cpu);
33326 @@ -651,7 +645,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
33327
33328 void __init xen_smp_init(void)
33329 {
33330 - smp_ops = xen_smp_ops;
33331 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
33332 xen_fill_possible_map();
33333 xen_init_spinlocks();
33334 }
33335 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
33336 index 33ca6e4..0ded929 100644
33337 --- a/arch/x86/xen/xen-asm_32.S
33338 +++ b/arch/x86/xen/xen-asm_32.S
33339 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
33340 ESP_OFFSET=4 # bytes pushed onto stack
33341
33342 /*
33343 - * Store vcpu_info pointer for easy access. Do it this way to
33344 - * avoid having to reload %fs
33345 + * Store vcpu_info pointer for easy access.
33346 */
33347 #ifdef CONFIG_SMP
33348 - GET_THREAD_INFO(%eax)
33349 - movl %ss:TI_cpu(%eax), %eax
33350 - movl %ss:__per_cpu_offset(,%eax,4), %eax
33351 - mov %ss:xen_vcpu(%eax), %eax
33352 + push %fs
33353 + mov $(__KERNEL_PERCPU), %eax
33354 + mov %eax, %fs
33355 + mov PER_CPU_VAR(xen_vcpu), %eax
33356 + pop %fs
33357 #else
33358 movl %ss:xen_vcpu, %eax
33359 #endif
33360 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
33361 index 7faed58..ba4427c 100644
33362 --- a/arch/x86/xen/xen-head.S
33363 +++ b/arch/x86/xen/xen-head.S
33364 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
33365 #ifdef CONFIG_X86_32
33366 mov %esi,xen_start_info
33367 mov $init_thread_union+THREAD_SIZE,%esp
33368 +#ifdef CONFIG_SMP
33369 + movl $cpu_gdt_table,%edi
33370 + movl $__per_cpu_load,%eax
33371 + movw %ax,__KERNEL_PERCPU + 2(%edi)
33372 + rorl $16,%eax
33373 + movb %al,__KERNEL_PERCPU + 4(%edi)
33374 + movb %ah,__KERNEL_PERCPU + 7(%edi)
33375 + movl $__per_cpu_end - 1,%eax
33376 + subl $__per_cpu_start,%eax
33377 + movw %ax,__KERNEL_PERCPU + 0(%edi)
33378 +#endif
33379 #else
33380 mov %rsi,xen_start_info
33381 mov $init_thread_union+THREAD_SIZE,%rsp
33382 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
33383 index a95b417..b6dbd0b 100644
33384 --- a/arch/x86/xen/xen-ops.h
33385 +++ b/arch/x86/xen/xen-ops.h
33386 @@ -10,8 +10,6 @@
33387 extern const char xen_hypervisor_callback[];
33388 extern const char xen_failsafe_callback[];
33389
33390 -extern void *xen_initial_gdt;
33391 -
33392 struct trap_info;
33393 void xen_copy_trap_info(struct trap_info *traps);
33394
33395 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
33396 index 525bd3d..ef888b1 100644
33397 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
33398 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
33399 @@ -119,9 +119,9 @@
33400 ----------------------------------------------------------------------*/
33401
33402 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
33403 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
33404 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
33405 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
33406 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
33407
33408 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
33409 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
33410 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
33411 index 2f33760..835e50a 100644
33412 --- a/arch/xtensa/variants/fsf/include/variant/core.h
33413 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
33414 @@ -11,6 +11,7 @@
33415 #ifndef _XTENSA_CORE_H
33416 #define _XTENSA_CORE_H
33417
33418 +#include <linux/const.h>
33419
33420 /****************************************************************************
33421 Parameters Useful for Any Code, USER or PRIVILEGED
33422 @@ -112,9 +113,9 @@
33423 ----------------------------------------------------------------------*/
33424
33425 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
33426 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
33427 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
33428 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
33429 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
33430
33431 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
33432 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
33433 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
33434 index af00795..2bb8105 100644
33435 --- a/arch/xtensa/variants/s6000/include/variant/core.h
33436 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
33437 @@ -11,6 +11,7 @@
33438 #ifndef _XTENSA_CORE_CONFIGURATION_H
33439 #define _XTENSA_CORE_CONFIGURATION_H
33440
33441 +#include <linux/const.h>
33442
33443 /****************************************************************************
33444 Parameters Useful for Any Code, USER or PRIVILEGED
33445 @@ -118,9 +119,9 @@
33446 ----------------------------------------------------------------------*/
33447
33448 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
33449 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
33450 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
33451 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
33452 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
33453
33454 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
33455 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
33456 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
33457 index 58916af..eb9dbcf6 100644
33458 --- a/block/blk-iopoll.c
33459 +++ b/block/blk-iopoll.c
33460 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
33461 }
33462 EXPORT_SYMBOL(blk_iopoll_complete);
33463
33464 -static void blk_iopoll_softirq(struct softirq_action *h)
33465 +static void blk_iopoll_softirq(void)
33466 {
33467 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
33468 int rearm = 0, budget = blk_iopoll_budget;
33469 @@ -209,7 +209,7 @@ static int __cpuinit blk_iopoll_cpu_notify(struct notifier_block *self,
33470 return NOTIFY_OK;
33471 }
33472
33473 -static struct notifier_block __cpuinitdata blk_iopoll_cpu_notifier = {
33474 +static struct notifier_block blk_iopoll_cpu_notifier = {
33475 .notifier_call = blk_iopoll_cpu_notify,
33476 };
33477
33478 diff --git a/block/blk-map.c b/block/blk-map.c
33479 index 623e1cd..ca1e109 100644
33480 --- a/block/blk-map.c
33481 +++ b/block/blk-map.c
33482 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
33483 if (!len || !kbuf)
33484 return -EINVAL;
33485
33486 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
33487 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
33488 if (do_copy)
33489 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
33490 else
33491 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
33492 index 467c8de..f3628c5 100644
33493 --- a/block/blk-softirq.c
33494 +++ b/block/blk-softirq.c
33495 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
33496 * Softirq action handler - move entries to local list and loop over them
33497 * while passing them to the queue registered handler.
33498 */
33499 -static void blk_done_softirq(struct softirq_action *h)
33500 +static void blk_done_softirq(void)
33501 {
33502 struct list_head *cpu_list, local_list;
33503
33504 @@ -98,7 +98,7 @@ static int __cpuinit blk_cpu_notify(struct notifier_block *self,
33505 return NOTIFY_OK;
33506 }
33507
33508 -static struct notifier_block __cpuinitdata blk_cpu_notifier = {
33509 +static struct notifier_block blk_cpu_notifier = {
33510 .notifier_call = blk_cpu_notify,
33511 };
33512
33513 diff --git a/block/bsg.c b/block/bsg.c
33514 index 420a5a9..23834aa 100644
33515 --- a/block/bsg.c
33516 +++ b/block/bsg.c
33517 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
33518 struct sg_io_v4 *hdr, struct bsg_device *bd,
33519 fmode_t has_write_perm)
33520 {
33521 + unsigned char tmpcmd[sizeof(rq->__cmd)];
33522 + unsigned char *cmdptr;
33523 +
33524 if (hdr->request_len > BLK_MAX_CDB) {
33525 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
33526 if (!rq->cmd)
33527 return -ENOMEM;
33528 - }
33529 + cmdptr = rq->cmd;
33530 + } else
33531 + cmdptr = tmpcmd;
33532
33533 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
33534 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
33535 hdr->request_len))
33536 return -EFAULT;
33537
33538 + if (cmdptr != rq->cmd)
33539 + memcpy(rq->cmd, cmdptr, hdr->request_len);
33540 +
33541 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
33542 if (blk_verify_command(rq->cmd, has_write_perm))
33543 return -EPERM;
33544 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
33545 index 7c668c8..db3521c 100644
33546 --- a/block/compat_ioctl.c
33547 +++ b/block/compat_ioctl.c
33548 @@ -340,7 +340,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
33549 err |= __get_user(f->spec1, &uf->spec1);
33550 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
33551 err |= __get_user(name, &uf->name);
33552 - f->name = compat_ptr(name);
33553 + f->name = (void __force_kernel *)compat_ptr(name);
33554 if (err) {
33555 err = -EFAULT;
33556 goto out;
33557 diff --git a/block/genhd.c b/block/genhd.c
33558 index cdeb527..10aa34db 100644
33559 --- a/block/genhd.c
33560 +++ b/block/genhd.c
33561 @@ -467,21 +467,24 @@ static char *bdevt_str(dev_t devt, char *buf)
33562
33563 /*
33564 * Register device numbers dev..(dev+range-1)
33565 - * range must be nonzero
33566 + * Noop if @range is zero.
33567 * The hash chain is sorted on range, so that subranges can override.
33568 */
33569 void blk_register_region(dev_t devt, unsigned long range, struct module *module,
33570 struct kobject *(*probe)(dev_t, int *, void *),
33571 int (*lock)(dev_t, void *), void *data)
33572 {
33573 - kobj_map(bdev_map, devt, range, module, probe, lock, data);
33574 + if (range)
33575 + kobj_map(bdev_map, devt, range, module, probe, lock, data);
33576 }
33577
33578 EXPORT_SYMBOL(blk_register_region);
33579
33580 +/* undo blk_register_region(), noop if @range is zero */
33581 void blk_unregister_region(dev_t devt, unsigned long range)
33582 {
33583 - kobj_unmap(bdev_map, devt, range);
33584 + if (range)
33585 + kobj_unmap(bdev_map, devt, range);
33586 }
33587
33588 EXPORT_SYMBOL(blk_unregister_region);
33589 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
33590 index c85fc89..51e690b 100644
33591 --- a/block/partitions/efi.c
33592 +++ b/block/partitions/efi.c
33593 @@ -234,14 +234,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
33594 if (!gpt)
33595 return NULL;
33596
33597 + if (!le32_to_cpu(gpt->num_partition_entries))
33598 + return NULL;
33599 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
33600 + if (!pte)
33601 + return NULL;
33602 +
33603 count = le32_to_cpu(gpt->num_partition_entries) *
33604 le32_to_cpu(gpt->sizeof_partition_entry);
33605 - if (!count)
33606 - return NULL;
33607 - pte = kmalloc(count, GFP_KERNEL);
33608 - if (!pte)
33609 - return NULL;
33610 -
33611 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
33612 (u8 *) pte,
33613 count) < count) {
33614 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
33615 index a5ffcc9..3cedc9c 100644
33616 --- a/block/scsi_ioctl.c
33617 +++ b/block/scsi_ioctl.c
33618 @@ -224,8 +224,20 @@ EXPORT_SYMBOL(blk_verify_command);
33619 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
33620 struct sg_io_hdr *hdr, fmode_t mode)
33621 {
33622 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
33623 + unsigned char tmpcmd[sizeof(rq->__cmd)];
33624 + unsigned char *cmdptr;
33625 +
33626 + if (rq->cmd != rq->__cmd)
33627 + cmdptr = rq->cmd;
33628 + else
33629 + cmdptr = tmpcmd;
33630 +
33631 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
33632 return -EFAULT;
33633 +
33634 + if (cmdptr != rq->cmd)
33635 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
33636 +
33637 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
33638 return -EPERM;
33639
33640 @@ -434,6 +446,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
33641 int err;
33642 unsigned int in_len, out_len, bytes, opcode, cmdlen;
33643 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
33644 + unsigned char tmpcmd[sizeof(rq->__cmd)];
33645 + unsigned char *cmdptr;
33646
33647 if (!sic)
33648 return -EINVAL;
33649 @@ -467,9 +481,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
33650 */
33651 err = -EFAULT;
33652 rq->cmd_len = cmdlen;
33653 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
33654 +
33655 + if (rq->cmd != rq->__cmd)
33656 + cmdptr = rq->cmd;
33657 + else
33658 + cmdptr = tmpcmd;
33659 +
33660 + if (copy_from_user(cmdptr, sic->data, cmdlen))
33661 goto error;
33662
33663 + if (rq->cmd != cmdptr)
33664 + memcpy(rq->cmd, cmdptr, cmdlen);
33665 +
33666 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
33667 goto error;
33668
33669 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
33670 index 7bdd61b..afec999 100644
33671 --- a/crypto/cryptd.c
33672 +++ b/crypto/cryptd.c
33673 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
33674
33675 struct cryptd_blkcipher_request_ctx {
33676 crypto_completion_t complete;
33677 -};
33678 +} __no_const;
33679
33680 struct cryptd_hash_ctx {
33681 struct crypto_shash *child;
33682 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
33683
33684 struct cryptd_aead_request_ctx {
33685 crypto_completion_t complete;
33686 -};
33687 +} __no_const;
33688
33689 static void cryptd_queue_worker(struct work_struct *work);
33690
33691 diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
33692 index b2c99dc..476c9fb 100644
33693 --- a/crypto/pcrypt.c
33694 +++ b/crypto/pcrypt.c
33695 @@ -440,7 +440,7 @@ static int pcrypt_sysfs_add(struct padata_instance *pinst, const char *name)
33696 int ret;
33697
33698 pinst->kobj.kset = pcrypt_kset;
33699 - ret = kobject_add(&pinst->kobj, NULL, name);
33700 + ret = kobject_add(&pinst->kobj, NULL, "%s", name);
33701 if (!ret)
33702 kobject_uevent(&pinst->kobj, KOBJ_ADD);
33703
33704 @@ -455,8 +455,8 @@ static int pcrypt_init_padata(struct padata_pcrypt *pcrypt,
33705
33706 get_online_cpus();
33707
33708 - pcrypt->wq = alloc_workqueue(name,
33709 - WQ_MEM_RECLAIM | WQ_CPU_INTENSIVE, 1);
33710 + pcrypt->wq = alloc_workqueue("%s",
33711 + WQ_MEM_RECLAIM | WQ_CPU_INTENSIVE, 1, name);
33712 if (!pcrypt->wq)
33713 goto err;
33714
33715 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
33716 index f220d64..d359ad6 100644
33717 --- a/drivers/acpi/apei/apei-internal.h
33718 +++ b/drivers/acpi/apei/apei-internal.h
33719 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
33720 struct apei_exec_ins_type {
33721 u32 flags;
33722 apei_exec_ins_func_t run;
33723 -};
33724 +} __do_const;
33725
33726 struct apei_exec_context {
33727 u32 ip;
33728 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
33729 index 33dc6a0..4b24b47 100644
33730 --- a/drivers/acpi/apei/cper.c
33731 +++ b/drivers/acpi/apei/cper.c
33732 @@ -39,12 +39,12 @@
33733 */
33734 u64 cper_next_record_id(void)
33735 {
33736 - static atomic64_t seq;
33737 + static atomic64_unchecked_t seq;
33738
33739 - if (!atomic64_read(&seq))
33740 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
33741 + if (!atomic64_read_unchecked(&seq))
33742 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
33743
33744 - return atomic64_inc_return(&seq);
33745 + return atomic64_inc_return_unchecked(&seq);
33746 }
33747 EXPORT_SYMBOL_GPL(cper_next_record_id);
33748
33749 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
33750 index be60399..778b33e8 100644
33751 --- a/drivers/acpi/bgrt.c
33752 +++ b/drivers/acpi/bgrt.c
33753 @@ -87,8 +87,10 @@ static int __init bgrt_init(void)
33754 return -ENODEV;
33755
33756 sysfs_bin_attr_init(&image_attr);
33757 - image_attr.private = bgrt_image;
33758 - image_attr.size = bgrt_image_size;
33759 + pax_open_kernel();
33760 + *(void **)&image_attr.private = bgrt_image;
33761 + *(size_t *)&image_attr.size = bgrt_image_size;
33762 + pax_close_kernel();
33763
33764 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
33765 if (!bgrt_kobj)
33766 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
33767 index cb96296..b81293b 100644
33768 --- a/drivers/acpi/blacklist.c
33769 +++ b/drivers/acpi/blacklist.c
33770 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
33771 u32 is_critical_error;
33772 };
33773
33774 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
33775 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
33776
33777 /*
33778 * POLICY: If *anything* doesn't work, put it on the blacklist.
33779 @@ -193,7 +193,7 @@ static int __init dmi_disable_osi_win7(const struct dmi_system_id *d)
33780 return 0;
33781 }
33782
33783 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
33784 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
33785 {
33786 .callback = dmi_disable_osi_vista,
33787 .ident = "Fujitsu Siemens",
33788 diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
33789 index 7586544..636a2f0 100644
33790 --- a/drivers/acpi/ec_sys.c
33791 +++ b/drivers/acpi/ec_sys.c
33792 @@ -12,6 +12,7 @@
33793 #include <linux/acpi.h>
33794 #include <linux/debugfs.h>
33795 #include <linux/module.h>
33796 +#include <linux/uaccess.h>
33797 #include "internal.h"
33798
33799 MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>");
33800 @@ -34,7 +35,7 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
33801 * struct acpi_ec *ec = ((struct seq_file *)f->private_data)->private;
33802 */
33803 unsigned int size = EC_SPACE_SIZE;
33804 - u8 *data = (u8 *) buf;
33805 + u8 data;
33806 loff_t init_off = *off;
33807 int err = 0;
33808
33809 @@ -47,9 +48,11 @@ static ssize_t acpi_ec_read_io(struct file *f, char __user *buf,
33810 size = count;
33811
33812 while (size) {
33813 - err = ec_read(*off, &data[*off - init_off]);
33814 + err = ec_read(*off, &data);
33815 if (err)
33816 return err;
33817 + if (put_user(data, &buf[*off - init_off]))
33818 + return -EFAULT;
33819 *off += 1;
33820 size--;
33821 }
33822 @@ -65,7 +68,6 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
33823
33824 unsigned int size = count;
33825 loff_t init_off = *off;
33826 - u8 *data = (u8 *) buf;
33827 int err = 0;
33828
33829 if (*off >= EC_SPACE_SIZE)
33830 @@ -76,7 +78,9 @@ static ssize_t acpi_ec_write_io(struct file *f, const char __user *buf,
33831 }
33832
33833 while (size) {
33834 - u8 byte_write = data[*off - init_off];
33835 + u8 byte_write;
33836 + if (get_user(byte_write, &buf[*off - init_off]))
33837 + return -EFAULT;
33838 err = ec_write(*off, byte_write);
33839 if (err)
33840 return err;
33841 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
33842 index eb133c7..f571552 100644
33843 --- a/drivers/acpi/processor_idle.c
33844 +++ b/drivers/acpi/processor_idle.c
33845 @@ -994,7 +994,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
33846 {
33847 int i, count = CPUIDLE_DRIVER_STATE_START;
33848 struct acpi_processor_cx *cx;
33849 - struct cpuidle_state *state;
33850 + cpuidle_state_no_const *state;
33851 struct cpuidle_driver *drv = &acpi_idle_driver;
33852
33853 if (!pr->flags.power_setup_done)
33854 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
33855 index fcae5fa..e9f71ea 100644
33856 --- a/drivers/acpi/sysfs.c
33857 +++ b/drivers/acpi/sysfs.c
33858 @@ -423,11 +423,11 @@ static u32 num_counters;
33859 static struct attribute **all_attrs;
33860 static u32 acpi_gpe_count;
33861
33862 -static struct attribute_group interrupt_stats_attr_group = {
33863 +static attribute_group_no_const interrupt_stats_attr_group = {
33864 .name = "interrupts",
33865 };
33866
33867 -static struct kobj_attribute *counter_attrs;
33868 +static kobj_attribute_no_const *counter_attrs;
33869
33870 static void delete_gpe_attr_array(void)
33871 {
33872 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
33873 index 7b9bdd8..37638ca 100644
33874 --- a/drivers/ata/libahci.c
33875 +++ b/drivers/ata/libahci.c
33876 @@ -1230,7 +1230,7 @@ int ahci_kick_engine(struct ata_port *ap)
33877 }
33878 EXPORT_SYMBOL_GPL(ahci_kick_engine);
33879
33880 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
33881 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
33882 struct ata_taskfile *tf, int is_cmd, u16 flags,
33883 unsigned long timeout_msec)
33884 {
33885 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
33886 index adf002a..39bb8f9 100644
33887 --- a/drivers/ata/libata-core.c
33888 +++ b/drivers/ata/libata-core.c
33889 @@ -4792,7 +4792,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
33890 struct ata_port *ap;
33891 unsigned int tag;
33892
33893 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
33894 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
33895 ap = qc->ap;
33896
33897 qc->flags = 0;
33898 @@ -4808,7 +4808,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
33899 struct ata_port *ap;
33900 struct ata_link *link;
33901
33902 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
33903 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
33904 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
33905 ap = qc->ap;
33906 link = qc->dev->link;
33907 @@ -5926,6 +5926,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
33908 return;
33909
33910 spin_lock(&lock);
33911 + pax_open_kernel();
33912
33913 for (cur = ops->inherits; cur; cur = cur->inherits) {
33914 void **inherit = (void **)cur;
33915 @@ -5939,8 +5940,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
33916 if (IS_ERR(*pp))
33917 *pp = NULL;
33918
33919 - ops->inherits = NULL;
33920 + *(struct ata_port_operations **)&ops->inherits = NULL;
33921
33922 + pax_close_kernel();
33923 spin_unlock(&lock);
33924 }
33925
33926 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
33927 index 7638121..357a965 100644
33928 --- a/drivers/ata/pata_arasan_cf.c
33929 +++ b/drivers/ata/pata_arasan_cf.c
33930 @@ -865,7 +865,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
33931 /* Handle platform specific quirks */
33932 if (quirk) {
33933 if (quirk & CF_BROKEN_PIO) {
33934 - ap->ops->set_piomode = NULL;
33935 + pax_open_kernel();
33936 + *(void **)&ap->ops->set_piomode = NULL;
33937 + pax_close_kernel();
33938 ap->pio_mask = 0;
33939 }
33940 if (quirk & CF_BROKEN_MWDMA)
33941 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
33942 index f9b983a..887b9d8 100644
33943 --- a/drivers/atm/adummy.c
33944 +++ b/drivers/atm/adummy.c
33945 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
33946 vcc->pop(vcc, skb);
33947 else
33948 dev_kfree_skb_any(skb);
33949 - atomic_inc(&vcc->stats->tx);
33950 + atomic_inc_unchecked(&vcc->stats->tx);
33951
33952 return 0;
33953 }
33954 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
33955 index 77a7480d..05cde58 100644
33956 --- a/drivers/atm/ambassador.c
33957 +++ b/drivers/atm/ambassador.c
33958 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
33959 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
33960
33961 // VC layer stats
33962 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
33963 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
33964
33965 // free the descriptor
33966 kfree (tx_descr);
33967 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
33968 dump_skb ("<<<", vc, skb);
33969
33970 // VC layer stats
33971 - atomic_inc(&atm_vcc->stats->rx);
33972 + atomic_inc_unchecked(&atm_vcc->stats->rx);
33973 __net_timestamp(skb);
33974 // end of our responsibility
33975 atm_vcc->push (atm_vcc, skb);
33976 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
33977 } else {
33978 PRINTK (KERN_INFO, "dropped over-size frame");
33979 // should we count this?
33980 - atomic_inc(&atm_vcc->stats->rx_drop);
33981 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
33982 }
33983
33984 } else {
33985 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
33986 }
33987
33988 if (check_area (skb->data, skb->len)) {
33989 - atomic_inc(&atm_vcc->stats->tx_err);
33990 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
33991 return -ENOMEM; // ?
33992 }
33993
33994 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
33995 index 0e3f8f9..765a7a5 100644
33996 --- a/drivers/atm/atmtcp.c
33997 +++ b/drivers/atm/atmtcp.c
33998 @@ -206,7 +206,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
33999 if (vcc->pop) vcc->pop(vcc,skb);
34000 else dev_kfree_skb(skb);
34001 if (dev_data) return 0;
34002 - atomic_inc(&vcc->stats->tx_err);
34003 + atomic_inc_unchecked(&vcc->stats->tx_err);
34004 return -ENOLINK;
34005 }
34006 size = skb->len+sizeof(struct atmtcp_hdr);
34007 @@ -214,7 +214,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34008 if (!new_skb) {
34009 if (vcc->pop) vcc->pop(vcc,skb);
34010 else dev_kfree_skb(skb);
34011 - atomic_inc(&vcc->stats->tx_err);
34012 + atomic_inc_unchecked(&vcc->stats->tx_err);
34013 return -ENOBUFS;
34014 }
34015 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
34016 @@ -225,8 +225,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
34017 if (vcc->pop) vcc->pop(vcc,skb);
34018 else dev_kfree_skb(skb);
34019 out_vcc->push(out_vcc,new_skb);
34020 - atomic_inc(&vcc->stats->tx);
34021 - atomic_inc(&out_vcc->stats->rx);
34022 + atomic_inc_unchecked(&vcc->stats->tx);
34023 + atomic_inc_unchecked(&out_vcc->stats->rx);
34024 return 0;
34025 }
34026
34027 @@ -299,7 +299,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
34028 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
34029 read_unlock(&vcc_sklist_lock);
34030 if (!out_vcc) {
34031 - atomic_inc(&vcc->stats->tx_err);
34032 + atomic_inc_unchecked(&vcc->stats->tx_err);
34033 goto done;
34034 }
34035 skb_pull(skb,sizeof(struct atmtcp_hdr));
34036 @@ -311,8 +311,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
34037 __net_timestamp(new_skb);
34038 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
34039 out_vcc->push(out_vcc,new_skb);
34040 - atomic_inc(&vcc->stats->tx);
34041 - atomic_inc(&out_vcc->stats->rx);
34042 + atomic_inc_unchecked(&vcc->stats->tx);
34043 + atomic_inc_unchecked(&out_vcc->stats->rx);
34044 done:
34045 if (vcc->pop) vcc->pop(vcc,skb);
34046 else dev_kfree_skb(skb);
34047 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
34048 index b1955ba..b179940 100644
34049 --- a/drivers/atm/eni.c
34050 +++ b/drivers/atm/eni.c
34051 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
34052 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
34053 vcc->dev->number);
34054 length = 0;
34055 - atomic_inc(&vcc->stats->rx_err);
34056 + atomic_inc_unchecked(&vcc->stats->rx_err);
34057 }
34058 else {
34059 length = ATM_CELL_SIZE-1; /* no HEC */
34060 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
34061 size);
34062 }
34063 eff = length = 0;
34064 - atomic_inc(&vcc->stats->rx_err);
34065 + atomic_inc_unchecked(&vcc->stats->rx_err);
34066 }
34067 else {
34068 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
34069 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
34070 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
34071 vcc->dev->number,vcc->vci,length,size << 2,descr);
34072 length = eff = 0;
34073 - atomic_inc(&vcc->stats->rx_err);
34074 + atomic_inc_unchecked(&vcc->stats->rx_err);
34075 }
34076 }
34077 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
34078 @@ -767,7 +767,7 @@ rx_dequeued++;
34079 vcc->push(vcc,skb);
34080 pushed++;
34081 }
34082 - atomic_inc(&vcc->stats->rx);
34083 + atomic_inc_unchecked(&vcc->stats->rx);
34084 }
34085 wake_up(&eni_dev->rx_wait);
34086 }
34087 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
34088 PCI_DMA_TODEVICE);
34089 if (vcc->pop) vcc->pop(vcc,skb);
34090 else dev_kfree_skb_irq(skb);
34091 - atomic_inc(&vcc->stats->tx);
34092 + atomic_inc_unchecked(&vcc->stats->tx);
34093 wake_up(&eni_dev->tx_wait);
34094 dma_complete++;
34095 }
34096 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
34097 index b41c948..a002b17 100644
34098 --- a/drivers/atm/firestream.c
34099 +++ b/drivers/atm/firestream.c
34100 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
34101 }
34102 }
34103
34104 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
34105 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
34106
34107 fs_dprintk (FS_DEBUG_TXMEM, "i");
34108 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
34109 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
34110 #endif
34111 skb_put (skb, qe->p1 & 0xffff);
34112 ATM_SKB(skb)->vcc = atm_vcc;
34113 - atomic_inc(&atm_vcc->stats->rx);
34114 + atomic_inc_unchecked(&atm_vcc->stats->rx);
34115 __net_timestamp(skb);
34116 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
34117 atm_vcc->push (atm_vcc, skb);
34118 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
34119 kfree (pe);
34120 }
34121 if (atm_vcc)
34122 - atomic_inc(&atm_vcc->stats->rx_drop);
34123 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34124 break;
34125 case 0x1f: /* Reassembly abort: no buffers. */
34126 /* Silently increment error counter. */
34127 if (atm_vcc)
34128 - atomic_inc(&atm_vcc->stats->rx_drop);
34129 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
34130 break;
34131 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
34132 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
34133 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
34134 index 204814e..cede831 100644
34135 --- a/drivers/atm/fore200e.c
34136 +++ b/drivers/atm/fore200e.c
34137 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
34138 #endif
34139 /* check error condition */
34140 if (*entry->status & STATUS_ERROR)
34141 - atomic_inc(&vcc->stats->tx_err);
34142 + atomic_inc_unchecked(&vcc->stats->tx_err);
34143 else
34144 - atomic_inc(&vcc->stats->tx);
34145 + atomic_inc_unchecked(&vcc->stats->tx);
34146 }
34147 }
34148
34149 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
34150 if (skb == NULL) {
34151 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
34152
34153 - atomic_inc(&vcc->stats->rx_drop);
34154 + atomic_inc_unchecked(&vcc->stats->rx_drop);
34155 return -ENOMEM;
34156 }
34157
34158 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
34159
34160 dev_kfree_skb_any(skb);
34161
34162 - atomic_inc(&vcc->stats->rx_drop);
34163 + atomic_inc_unchecked(&vcc->stats->rx_drop);
34164 return -ENOMEM;
34165 }
34166
34167 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
34168
34169 vcc->push(vcc, skb);
34170 - atomic_inc(&vcc->stats->rx);
34171 + atomic_inc_unchecked(&vcc->stats->rx);
34172
34173 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
34174
34175 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
34176 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
34177 fore200e->atm_dev->number,
34178 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
34179 - atomic_inc(&vcc->stats->rx_err);
34180 + atomic_inc_unchecked(&vcc->stats->rx_err);
34181 }
34182 }
34183
34184 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
34185 goto retry_here;
34186 }
34187
34188 - atomic_inc(&vcc->stats->tx_err);
34189 + atomic_inc_unchecked(&vcc->stats->tx_err);
34190
34191 fore200e->tx_sat++;
34192 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
34193 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
34194 index 507362a..a845e57 100644
34195 --- a/drivers/atm/he.c
34196 +++ b/drivers/atm/he.c
34197 @@ -1698,7 +1698,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
34198
34199 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
34200 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
34201 - atomic_inc(&vcc->stats->rx_drop);
34202 + atomic_inc_unchecked(&vcc->stats->rx_drop);
34203 goto return_host_buffers;
34204 }
34205
34206 @@ -1725,7 +1725,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
34207 RBRQ_LEN_ERR(he_dev->rbrq_head)
34208 ? "LEN_ERR" : "",
34209 vcc->vpi, vcc->vci);
34210 - atomic_inc(&vcc->stats->rx_err);
34211 + atomic_inc_unchecked(&vcc->stats->rx_err);
34212 goto return_host_buffers;
34213 }
34214
34215 @@ -1777,7 +1777,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
34216 vcc->push(vcc, skb);
34217 spin_lock(&he_dev->global_lock);
34218
34219 - atomic_inc(&vcc->stats->rx);
34220 + atomic_inc_unchecked(&vcc->stats->rx);
34221
34222 return_host_buffers:
34223 ++pdus_assembled;
34224 @@ -2103,7 +2103,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
34225 tpd->vcc->pop(tpd->vcc, tpd->skb);
34226 else
34227 dev_kfree_skb_any(tpd->skb);
34228 - atomic_inc(&tpd->vcc->stats->tx_err);
34229 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
34230 }
34231 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
34232 return;
34233 @@ -2515,7 +2515,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
34234 vcc->pop(vcc, skb);
34235 else
34236 dev_kfree_skb_any(skb);
34237 - atomic_inc(&vcc->stats->tx_err);
34238 + atomic_inc_unchecked(&vcc->stats->tx_err);
34239 return -EINVAL;
34240 }
34241
34242 @@ -2526,7 +2526,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
34243 vcc->pop(vcc, skb);
34244 else
34245 dev_kfree_skb_any(skb);
34246 - atomic_inc(&vcc->stats->tx_err);
34247 + atomic_inc_unchecked(&vcc->stats->tx_err);
34248 return -EINVAL;
34249 }
34250 #endif
34251 @@ -2538,7 +2538,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
34252 vcc->pop(vcc, skb);
34253 else
34254 dev_kfree_skb_any(skb);
34255 - atomic_inc(&vcc->stats->tx_err);
34256 + atomic_inc_unchecked(&vcc->stats->tx_err);
34257 spin_unlock_irqrestore(&he_dev->global_lock, flags);
34258 return -ENOMEM;
34259 }
34260 @@ -2580,7 +2580,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
34261 vcc->pop(vcc, skb);
34262 else
34263 dev_kfree_skb_any(skb);
34264 - atomic_inc(&vcc->stats->tx_err);
34265 + atomic_inc_unchecked(&vcc->stats->tx_err);
34266 spin_unlock_irqrestore(&he_dev->global_lock, flags);
34267 return -ENOMEM;
34268 }
34269 @@ -2611,7 +2611,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
34270 __enqueue_tpd(he_dev, tpd, cid);
34271 spin_unlock_irqrestore(&he_dev->global_lock, flags);
34272
34273 - atomic_inc(&vcc->stats->tx);
34274 + atomic_inc_unchecked(&vcc->stats->tx);
34275
34276 return 0;
34277 }
34278 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
34279 index 1dc0519..1aadaf7 100644
34280 --- a/drivers/atm/horizon.c
34281 +++ b/drivers/atm/horizon.c
34282 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
34283 {
34284 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
34285 // VC layer stats
34286 - atomic_inc(&vcc->stats->rx);
34287 + atomic_inc_unchecked(&vcc->stats->rx);
34288 __net_timestamp(skb);
34289 // end of our responsibility
34290 vcc->push (vcc, skb);
34291 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
34292 dev->tx_iovec = NULL;
34293
34294 // VC layer stats
34295 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
34296 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
34297
34298 // free the skb
34299 hrz_kfree_skb (skb);
34300 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
34301 index 272f009..a18ba55 100644
34302 --- a/drivers/atm/idt77252.c
34303 +++ b/drivers/atm/idt77252.c
34304 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
34305 else
34306 dev_kfree_skb(skb);
34307
34308 - atomic_inc(&vcc->stats->tx);
34309 + atomic_inc_unchecked(&vcc->stats->tx);
34310 }
34311
34312 atomic_dec(&scq->used);
34313 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
34314 if ((sb = dev_alloc_skb(64)) == NULL) {
34315 printk("%s: Can't allocate buffers for aal0.\n",
34316 card->name);
34317 - atomic_add(i, &vcc->stats->rx_drop);
34318 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
34319 break;
34320 }
34321 if (!atm_charge(vcc, sb->truesize)) {
34322 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
34323 card->name);
34324 - atomic_add(i - 1, &vcc->stats->rx_drop);
34325 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
34326 dev_kfree_skb(sb);
34327 break;
34328 }
34329 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
34330 ATM_SKB(sb)->vcc = vcc;
34331 __net_timestamp(sb);
34332 vcc->push(vcc, sb);
34333 - atomic_inc(&vcc->stats->rx);
34334 + atomic_inc_unchecked(&vcc->stats->rx);
34335
34336 cell += ATM_CELL_PAYLOAD;
34337 }
34338 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
34339 "(CDC: %08x)\n",
34340 card->name, len, rpp->len, readl(SAR_REG_CDC));
34341 recycle_rx_pool_skb(card, rpp);
34342 - atomic_inc(&vcc->stats->rx_err);
34343 + atomic_inc_unchecked(&vcc->stats->rx_err);
34344 return;
34345 }
34346 if (stat & SAR_RSQE_CRC) {
34347 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
34348 recycle_rx_pool_skb(card, rpp);
34349 - atomic_inc(&vcc->stats->rx_err);
34350 + atomic_inc_unchecked(&vcc->stats->rx_err);
34351 return;
34352 }
34353 if (skb_queue_len(&rpp->queue) > 1) {
34354 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
34355 RXPRINTK("%s: Can't alloc RX skb.\n",
34356 card->name);
34357 recycle_rx_pool_skb(card, rpp);
34358 - atomic_inc(&vcc->stats->rx_err);
34359 + atomic_inc_unchecked(&vcc->stats->rx_err);
34360 return;
34361 }
34362 if (!atm_charge(vcc, skb->truesize)) {
34363 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
34364 __net_timestamp(skb);
34365
34366 vcc->push(vcc, skb);
34367 - atomic_inc(&vcc->stats->rx);
34368 + atomic_inc_unchecked(&vcc->stats->rx);
34369
34370 return;
34371 }
34372 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
34373 __net_timestamp(skb);
34374
34375 vcc->push(vcc, skb);
34376 - atomic_inc(&vcc->stats->rx);
34377 + atomic_inc_unchecked(&vcc->stats->rx);
34378
34379 if (skb->truesize > SAR_FB_SIZE_3)
34380 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
34381 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
34382 if (vcc->qos.aal != ATM_AAL0) {
34383 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
34384 card->name, vpi, vci);
34385 - atomic_inc(&vcc->stats->rx_drop);
34386 + atomic_inc_unchecked(&vcc->stats->rx_drop);
34387 goto drop;
34388 }
34389
34390 if ((sb = dev_alloc_skb(64)) == NULL) {
34391 printk("%s: Can't allocate buffers for AAL0.\n",
34392 card->name);
34393 - atomic_inc(&vcc->stats->rx_err);
34394 + atomic_inc_unchecked(&vcc->stats->rx_err);
34395 goto drop;
34396 }
34397
34398 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
34399 ATM_SKB(sb)->vcc = vcc;
34400 __net_timestamp(sb);
34401 vcc->push(vcc, sb);
34402 - atomic_inc(&vcc->stats->rx);
34403 + atomic_inc_unchecked(&vcc->stats->rx);
34404
34405 drop:
34406 skb_pull(queue, 64);
34407 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
34408
34409 if (vc == NULL) {
34410 printk("%s: NULL connection in send().\n", card->name);
34411 - atomic_inc(&vcc->stats->tx_err);
34412 + atomic_inc_unchecked(&vcc->stats->tx_err);
34413 dev_kfree_skb(skb);
34414 return -EINVAL;
34415 }
34416 if (!test_bit(VCF_TX, &vc->flags)) {
34417 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
34418 - atomic_inc(&vcc->stats->tx_err);
34419 + atomic_inc_unchecked(&vcc->stats->tx_err);
34420 dev_kfree_skb(skb);
34421 return -EINVAL;
34422 }
34423 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
34424 break;
34425 default:
34426 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
34427 - atomic_inc(&vcc->stats->tx_err);
34428 + atomic_inc_unchecked(&vcc->stats->tx_err);
34429 dev_kfree_skb(skb);
34430 return -EINVAL;
34431 }
34432
34433 if (skb_shinfo(skb)->nr_frags != 0) {
34434 printk("%s: No scatter-gather yet.\n", card->name);
34435 - atomic_inc(&vcc->stats->tx_err);
34436 + atomic_inc_unchecked(&vcc->stats->tx_err);
34437 dev_kfree_skb(skb);
34438 return -EINVAL;
34439 }
34440 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
34441
34442 err = queue_skb(card, vc, skb, oam);
34443 if (err) {
34444 - atomic_inc(&vcc->stats->tx_err);
34445 + atomic_inc_unchecked(&vcc->stats->tx_err);
34446 dev_kfree_skb(skb);
34447 return err;
34448 }
34449 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
34450 skb = dev_alloc_skb(64);
34451 if (!skb) {
34452 printk("%s: Out of memory in send_oam().\n", card->name);
34453 - atomic_inc(&vcc->stats->tx_err);
34454 + atomic_inc_unchecked(&vcc->stats->tx_err);
34455 return -ENOMEM;
34456 }
34457 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
34458 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
34459 index 4217f29..88f547a 100644
34460 --- a/drivers/atm/iphase.c
34461 +++ b/drivers/atm/iphase.c
34462 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
34463 status = (u_short) (buf_desc_ptr->desc_mode);
34464 if (status & (RX_CER | RX_PTE | RX_OFL))
34465 {
34466 - atomic_inc(&vcc->stats->rx_err);
34467 + atomic_inc_unchecked(&vcc->stats->rx_err);
34468 IF_ERR(printk("IA: bad packet, dropping it");)
34469 if (status & RX_CER) {
34470 IF_ERR(printk(" cause: packet CRC error\n");)
34471 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
34472 len = dma_addr - buf_addr;
34473 if (len > iadev->rx_buf_sz) {
34474 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
34475 - atomic_inc(&vcc->stats->rx_err);
34476 + atomic_inc_unchecked(&vcc->stats->rx_err);
34477 goto out_free_desc;
34478 }
34479
34480 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
34481 ia_vcc = INPH_IA_VCC(vcc);
34482 if (ia_vcc == NULL)
34483 {
34484 - atomic_inc(&vcc->stats->rx_err);
34485 + atomic_inc_unchecked(&vcc->stats->rx_err);
34486 atm_return(vcc, skb->truesize);
34487 dev_kfree_skb_any(skb);
34488 goto INCR_DLE;
34489 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
34490 if ((length > iadev->rx_buf_sz) || (length >
34491 (skb->len - sizeof(struct cpcs_trailer))))
34492 {
34493 - atomic_inc(&vcc->stats->rx_err);
34494 + atomic_inc_unchecked(&vcc->stats->rx_err);
34495 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
34496 length, skb->len);)
34497 atm_return(vcc, skb->truesize);
34498 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
34499
34500 IF_RX(printk("rx_dle_intr: skb push");)
34501 vcc->push(vcc,skb);
34502 - atomic_inc(&vcc->stats->rx);
34503 + atomic_inc_unchecked(&vcc->stats->rx);
34504 iadev->rx_pkt_cnt++;
34505 }
34506 INCR_DLE:
34507 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
34508 {
34509 struct k_sonet_stats *stats;
34510 stats = &PRIV(_ia_dev[board])->sonet_stats;
34511 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
34512 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
34513 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
34514 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
34515 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
34516 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
34517 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
34518 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
34519 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
34520 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
34521 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
34522 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
34523 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
34524 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
34525 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
34526 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
34527 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
34528 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
34529 }
34530 ia_cmds.status = 0;
34531 break;
34532 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
34533 if ((desc == 0) || (desc > iadev->num_tx_desc))
34534 {
34535 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
34536 - atomic_inc(&vcc->stats->tx);
34537 + atomic_inc_unchecked(&vcc->stats->tx);
34538 if (vcc->pop)
34539 vcc->pop(vcc, skb);
34540 else
34541 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
34542 ATM_DESC(skb) = vcc->vci;
34543 skb_queue_tail(&iadev->tx_dma_q, skb);
34544
34545 - atomic_inc(&vcc->stats->tx);
34546 + atomic_inc_unchecked(&vcc->stats->tx);
34547 iadev->tx_pkt_cnt++;
34548 /* Increment transaction counter */
34549 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
34550
34551 #if 0
34552 /* add flow control logic */
34553 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
34554 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
34555 if (iavcc->vc_desc_cnt > 10) {
34556 vcc->tx_quota = vcc->tx_quota * 3 / 4;
34557 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
34558 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
34559 index fa7d701..1e404c7 100644
34560 --- a/drivers/atm/lanai.c
34561 +++ b/drivers/atm/lanai.c
34562 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
34563 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
34564 lanai_endtx(lanai, lvcc);
34565 lanai_free_skb(lvcc->tx.atmvcc, skb);
34566 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
34567 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
34568 }
34569
34570 /* Try to fill the buffer - don't call unless there is backlog */
34571 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
34572 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
34573 __net_timestamp(skb);
34574 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
34575 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
34576 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
34577 out:
34578 lvcc->rx.buf.ptr = end;
34579 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
34580 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
34581 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
34582 "vcc %d\n", lanai->number, (unsigned int) s, vci);
34583 lanai->stats.service_rxnotaal5++;
34584 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
34585 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
34586 return 0;
34587 }
34588 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
34589 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
34590 int bytes;
34591 read_unlock(&vcc_sklist_lock);
34592 DPRINTK("got trashed rx pdu on vci %d\n", vci);
34593 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
34594 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
34595 lvcc->stats.x.aal5.service_trash++;
34596 bytes = (SERVICE_GET_END(s) * 16) -
34597 (((unsigned long) lvcc->rx.buf.ptr) -
34598 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
34599 }
34600 if (s & SERVICE_STREAM) {
34601 read_unlock(&vcc_sklist_lock);
34602 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
34603 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
34604 lvcc->stats.x.aal5.service_stream++;
34605 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
34606 "PDU on VCI %d!\n", lanai->number, vci);
34607 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
34608 return 0;
34609 }
34610 DPRINTK("got rx crc error on vci %d\n", vci);
34611 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
34612 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
34613 lvcc->stats.x.aal5.service_rxcrc++;
34614 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
34615 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
34616 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
34617 index 6587dc2..149833d 100644
34618 --- a/drivers/atm/nicstar.c
34619 +++ b/drivers/atm/nicstar.c
34620 @@ -1641,7 +1641,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
34621 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
34622 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
34623 card->index);
34624 - atomic_inc(&vcc->stats->tx_err);
34625 + atomic_inc_unchecked(&vcc->stats->tx_err);
34626 dev_kfree_skb_any(skb);
34627 return -EINVAL;
34628 }
34629 @@ -1649,7 +1649,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
34630 if (!vc->tx) {
34631 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
34632 card->index);
34633 - atomic_inc(&vcc->stats->tx_err);
34634 + atomic_inc_unchecked(&vcc->stats->tx_err);
34635 dev_kfree_skb_any(skb);
34636 return -EINVAL;
34637 }
34638 @@ -1657,14 +1657,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
34639 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
34640 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
34641 card->index);
34642 - atomic_inc(&vcc->stats->tx_err);
34643 + atomic_inc_unchecked(&vcc->stats->tx_err);
34644 dev_kfree_skb_any(skb);
34645 return -EINVAL;
34646 }
34647
34648 if (skb_shinfo(skb)->nr_frags != 0) {
34649 printk("nicstar%d: No scatter-gather yet.\n", card->index);
34650 - atomic_inc(&vcc->stats->tx_err);
34651 + atomic_inc_unchecked(&vcc->stats->tx_err);
34652 dev_kfree_skb_any(skb);
34653 return -EINVAL;
34654 }
34655 @@ -1712,11 +1712,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
34656 }
34657
34658 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
34659 - atomic_inc(&vcc->stats->tx_err);
34660 + atomic_inc_unchecked(&vcc->stats->tx_err);
34661 dev_kfree_skb_any(skb);
34662 return -EIO;
34663 }
34664 - atomic_inc(&vcc->stats->tx);
34665 + atomic_inc_unchecked(&vcc->stats->tx);
34666
34667 return 0;
34668 }
34669 @@ -2033,14 +2033,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
34670 printk
34671 ("nicstar%d: Can't allocate buffers for aal0.\n",
34672 card->index);
34673 - atomic_add(i, &vcc->stats->rx_drop);
34674 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
34675 break;
34676 }
34677 if (!atm_charge(vcc, sb->truesize)) {
34678 RXPRINTK
34679 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
34680 card->index);
34681 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
34682 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
34683 dev_kfree_skb_any(sb);
34684 break;
34685 }
34686 @@ -2055,7 +2055,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
34687 ATM_SKB(sb)->vcc = vcc;
34688 __net_timestamp(sb);
34689 vcc->push(vcc, sb);
34690 - atomic_inc(&vcc->stats->rx);
34691 + atomic_inc_unchecked(&vcc->stats->rx);
34692 cell += ATM_CELL_PAYLOAD;
34693 }
34694
34695 @@ -2072,7 +2072,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
34696 if (iovb == NULL) {
34697 printk("nicstar%d: Out of iovec buffers.\n",
34698 card->index);
34699 - atomic_inc(&vcc->stats->rx_drop);
34700 + atomic_inc_unchecked(&vcc->stats->rx_drop);
34701 recycle_rx_buf(card, skb);
34702 return;
34703 }
34704 @@ -2096,7 +2096,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
34705 small or large buffer itself. */
34706 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
34707 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
34708 - atomic_inc(&vcc->stats->rx_err);
34709 + atomic_inc_unchecked(&vcc->stats->rx_err);
34710 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
34711 NS_MAX_IOVECS);
34712 NS_PRV_IOVCNT(iovb) = 0;
34713 @@ -2116,7 +2116,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
34714 ("nicstar%d: Expected a small buffer, and this is not one.\n",
34715 card->index);
34716 which_list(card, skb);
34717 - atomic_inc(&vcc->stats->rx_err);
34718 + atomic_inc_unchecked(&vcc->stats->rx_err);
34719 recycle_rx_buf(card, skb);
34720 vc->rx_iov = NULL;
34721 recycle_iov_buf(card, iovb);
34722 @@ -2129,7 +2129,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
34723 ("nicstar%d: Expected a large buffer, and this is not one.\n",
34724 card->index);
34725 which_list(card, skb);
34726 - atomic_inc(&vcc->stats->rx_err);
34727 + atomic_inc_unchecked(&vcc->stats->rx_err);
34728 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
34729 NS_PRV_IOVCNT(iovb));
34730 vc->rx_iov = NULL;
34731 @@ -2152,7 +2152,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
34732 printk(" - PDU size mismatch.\n");
34733 else
34734 printk(".\n");
34735 - atomic_inc(&vcc->stats->rx_err);
34736 + atomic_inc_unchecked(&vcc->stats->rx_err);
34737 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
34738 NS_PRV_IOVCNT(iovb));
34739 vc->rx_iov = NULL;
34740 @@ -2166,7 +2166,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
34741 /* skb points to a small buffer */
34742 if (!atm_charge(vcc, skb->truesize)) {
34743 push_rxbufs(card, skb);
34744 - atomic_inc(&vcc->stats->rx_drop);
34745 + atomic_inc_unchecked(&vcc->stats->rx_drop);
34746 } else {
34747 skb_put(skb, len);
34748 dequeue_sm_buf(card, skb);
34749 @@ -2176,7 +2176,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
34750 ATM_SKB(skb)->vcc = vcc;
34751 __net_timestamp(skb);
34752 vcc->push(vcc, skb);
34753 - atomic_inc(&vcc->stats->rx);
34754 + atomic_inc_unchecked(&vcc->stats->rx);
34755 }
34756 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
34757 struct sk_buff *sb;
34758 @@ -2187,7 +2187,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
34759 if (len <= NS_SMBUFSIZE) {
34760 if (!atm_charge(vcc, sb->truesize)) {
34761 push_rxbufs(card, sb);
34762 - atomic_inc(&vcc->stats->rx_drop);
34763 + atomic_inc_unchecked(&vcc->stats->rx_drop);
34764 } else {
34765 skb_put(sb, len);
34766 dequeue_sm_buf(card, sb);
34767 @@ -2197,7 +2197,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
34768 ATM_SKB(sb)->vcc = vcc;
34769 __net_timestamp(sb);
34770 vcc->push(vcc, sb);
34771 - atomic_inc(&vcc->stats->rx);
34772 + atomic_inc_unchecked(&vcc->stats->rx);
34773 }
34774
34775 push_rxbufs(card, skb);
34776 @@ -2206,7 +2206,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
34777
34778 if (!atm_charge(vcc, skb->truesize)) {
34779 push_rxbufs(card, skb);
34780 - atomic_inc(&vcc->stats->rx_drop);
34781 + atomic_inc_unchecked(&vcc->stats->rx_drop);
34782 } else {
34783 dequeue_lg_buf(card, skb);
34784 #ifdef NS_USE_DESTRUCTORS
34785 @@ -2219,7 +2219,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
34786 ATM_SKB(skb)->vcc = vcc;
34787 __net_timestamp(skb);
34788 vcc->push(vcc, skb);
34789 - atomic_inc(&vcc->stats->rx);
34790 + atomic_inc_unchecked(&vcc->stats->rx);
34791 }
34792
34793 push_rxbufs(card, sb);
34794 @@ -2240,7 +2240,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
34795 printk
34796 ("nicstar%d: Out of huge buffers.\n",
34797 card->index);
34798 - atomic_inc(&vcc->stats->rx_drop);
34799 + atomic_inc_unchecked(&vcc->stats->rx_drop);
34800 recycle_iovec_rx_bufs(card,
34801 (struct iovec *)
34802 iovb->data,
34803 @@ -2291,7 +2291,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
34804 card->hbpool.count++;
34805 } else
34806 dev_kfree_skb_any(hb);
34807 - atomic_inc(&vcc->stats->rx_drop);
34808 + atomic_inc_unchecked(&vcc->stats->rx_drop);
34809 } else {
34810 /* Copy the small buffer to the huge buffer */
34811 sb = (struct sk_buff *)iov->iov_base;
34812 @@ -2328,7 +2328,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
34813 #endif /* NS_USE_DESTRUCTORS */
34814 __net_timestamp(hb);
34815 vcc->push(vcc, hb);
34816 - atomic_inc(&vcc->stats->rx);
34817 + atomic_inc_unchecked(&vcc->stats->rx);
34818 }
34819 }
34820
34821 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
34822 index 32784d1..4a8434a 100644
34823 --- a/drivers/atm/solos-pci.c
34824 +++ b/drivers/atm/solos-pci.c
34825 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
34826 }
34827 atm_charge(vcc, skb->truesize);
34828 vcc->push(vcc, skb);
34829 - atomic_inc(&vcc->stats->rx);
34830 + atomic_inc_unchecked(&vcc->stats->rx);
34831 break;
34832
34833 case PKT_STATUS:
34834 @@ -1116,7 +1116,7 @@ static uint32_t fpga_tx(struct solos_card *card)
34835 vcc = SKB_CB(oldskb)->vcc;
34836
34837 if (vcc) {
34838 - atomic_inc(&vcc->stats->tx);
34839 + atomic_inc_unchecked(&vcc->stats->tx);
34840 solos_pop(vcc, oldskb);
34841 } else {
34842 dev_kfree_skb_irq(oldskb);
34843 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
34844 index 0215934..ce9f5b1 100644
34845 --- a/drivers/atm/suni.c
34846 +++ b/drivers/atm/suni.c
34847 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
34848
34849
34850 #define ADD_LIMITED(s,v) \
34851 - atomic_add((v),&stats->s); \
34852 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
34853 + atomic_add_unchecked((v),&stats->s); \
34854 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
34855
34856
34857 static void suni_hz(unsigned long from_timer)
34858 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
34859 index 5120a96..e2572bd 100644
34860 --- a/drivers/atm/uPD98402.c
34861 +++ b/drivers/atm/uPD98402.c
34862 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
34863 struct sonet_stats tmp;
34864 int error = 0;
34865
34866 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
34867 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
34868 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
34869 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
34870 if (zero && !error) {
34871 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
34872
34873
34874 #define ADD_LIMITED(s,v) \
34875 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
34876 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
34877 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
34878 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
34879 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
34880 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
34881
34882
34883 static void stat_event(struct atm_dev *dev)
34884 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
34885 if (reason & uPD98402_INT_PFM) stat_event(dev);
34886 if (reason & uPD98402_INT_PCO) {
34887 (void) GET(PCOCR); /* clear interrupt cause */
34888 - atomic_add(GET(HECCT),
34889 + atomic_add_unchecked(GET(HECCT),
34890 &PRIV(dev)->sonet_stats.uncorr_hcs);
34891 }
34892 if ((reason & uPD98402_INT_RFO) &&
34893 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
34894 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
34895 uPD98402_INT_LOS),PIMR); /* enable them */
34896 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
34897 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
34898 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
34899 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
34900 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
34901 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
34902 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
34903 return 0;
34904 }
34905
34906 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
34907 index 969c3c2..9b72956 100644
34908 --- a/drivers/atm/zatm.c
34909 +++ b/drivers/atm/zatm.c
34910 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
34911 }
34912 if (!size) {
34913 dev_kfree_skb_irq(skb);
34914 - if (vcc) atomic_inc(&vcc->stats->rx_err);
34915 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
34916 continue;
34917 }
34918 if (!atm_charge(vcc,skb->truesize)) {
34919 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
34920 skb->len = size;
34921 ATM_SKB(skb)->vcc = vcc;
34922 vcc->push(vcc,skb);
34923 - atomic_inc(&vcc->stats->rx);
34924 + atomic_inc_unchecked(&vcc->stats->rx);
34925 }
34926 zout(pos & 0xffff,MTA(mbx));
34927 #if 0 /* probably a stupid idea */
34928 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
34929 skb_queue_head(&zatm_vcc->backlog,skb);
34930 break;
34931 }
34932 - atomic_inc(&vcc->stats->tx);
34933 + atomic_inc_unchecked(&vcc->stats->tx);
34934 wake_up(&zatm_vcc->tx_wait);
34935 }
34936
34937 diff --git a/drivers/base/attribute_container.c b/drivers/base/attribute_container.c
34938 index d78b204..ecc1929 100644
34939 --- a/drivers/base/attribute_container.c
34940 +++ b/drivers/base/attribute_container.c
34941 @@ -167,7 +167,7 @@ attribute_container_add_device(struct device *dev,
34942 ic->classdev.parent = get_device(dev);
34943 ic->classdev.class = cont->class;
34944 cont->class->dev_release = attribute_container_release;
34945 - dev_set_name(&ic->classdev, dev_name(dev));
34946 + dev_set_name(&ic->classdev, "%s", dev_name(dev));
34947 if (fn)
34948 fn(cont, dev, &ic->classdev);
34949 else
34950 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
34951 index d414331..b4dd4ba 100644
34952 --- a/drivers/base/bus.c
34953 +++ b/drivers/base/bus.c
34954 @@ -1163,7 +1163,7 @@ int subsys_interface_register(struct subsys_interface *sif)
34955 return -EINVAL;
34956
34957 mutex_lock(&subsys->p->mutex);
34958 - list_add_tail(&sif->node, &subsys->p->interfaces);
34959 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
34960 if (sif->add_dev) {
34961 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
34962 while ((dev = subsys_dev_iter_next(&iter)))
34963 @@ -1188,7 +1188,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
34964 subsys = sif->subsys;
34965
34966 mutex_lock(&subsys->p->mutex);
34967 - list_del_init(&sif->node);
34968 + pax_list_del_init((struct list_head *)&sif->node);
34969 if (sif->remove_dev) {
34970 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
34971 while ((dev = subsys_dev_iter_next(&iter)))
34972 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
34973 index 7413d06..79155fa 100644
34974 --- a/drivers/base/devtmpfs.c
34975 +++ b/drivers/base/devtmpfs.c
34976 @@ -354,7 +354,7 @@ int devtmpfs_mount(const char *mntdir)
34977 if (!thread)
34978 return 0;
34979
34980 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
34981 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
34982 if (err)
34983 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
34984 else
34985 @@ -380,11 +380,11 @@ static int devtmpfsd(void *p)
34986 *err = sys_unshare(CLONE_NEWNS);
34987 if (*err)
34988 goto out;
34989 - *err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
34990 + *err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)"/", (char __force_user *)"devtmpfs", MS_SILENT, (char __force_user *)options);
34991 if (*err)
34992 goto out;
34993 - sys_chdir("/.."); /* will traverse into overmounted root */
34994 - sys_chroot(".");
34995 + sys_chdir((char __force_user *)"/.."); /* will traverse into overmounted root */
34996 + sys_chroot((char __force_user *)".");
34997 complete(&setup_done);
34998 while (1) {
34999 spin_lock(&req_lock);
35000 diff --git a/drivers/base/node.c b/drivers/base/node.c
35001 index 7616a77c..8f57f51 100644
35002 --- a/drivers/base/node.c
35003 +++ b/drivers/base/node.c
35004 @@ -626,7 +626,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
35005 struct node_attr {
35006 struct device_attribute attr;
35007 enum node_states state;
35008 -};
35009 +} __do_const;
35010
35011 static ssize_t show_node_state(struct device *dev,
35012 struct device_attribute *attr, char *buf)
35013 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
35014 index 7072404..76dcebd 100644
35015 --- a/drivers/base/power/domain.c
35016 +++ b/drivers/base/power/domain.c
35017 @@ -1850,7 +1850,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
35018 {
35019 struct cpuidle_driver *cpuidle_drv;
35020 struct gpd_cpu_data *cpu_data;
35021 - struct cpuidle_state *idle_state;
35022 + cpuidle_state_no_const *idle_state;
35023 int ret = 0;
35024
35025 if (IS_ERR_OR_NULL(genpd) || state < 0)
35026 @@ -1918,7 +1918,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
35027 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
35028 {
35029 struct gpd_cpu_data *cpu_data;
35030 - struct cpuidle_state *idle_state;
35031 + cpuidle_state_no_const *idle_state;
35032 int ret = 0;
35033
35034 if (IS_ERR_OR_NULL(genpd))
35035 diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
35036 index a53ebd2..8f73eeb 100644
35037 --- a/drivers/base/power/sysfs.c
35038 +++ b/drivers/base/power/sysfs.c
35039 @@ -185,7 +185,7 @@ static ssize_t rtpm_status_show(struct device *dev,
35040 return -EIO;
35041 }
35042 }
35043 - return sprintf(buf, p);
35044 + return sprintf(buf, "%s", p);
35045 }
35046
35047 static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
35048 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
35049 index 79715e7..df06b3b 100644
35050 --- a/drivers/base/power/wakeup.c
35051 +++ b/drivers/base/power/wakeup.c
35052 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
35053 * They need to be modified together atomically, so it's better to use one
35054 * atomic variable to hold them both.
35055 */
35056 -static atomic_t combined_event_count = ATOMIC_INIT(0);
35057 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
35058
35059 #define IN_PROGRESS_BITS (sizeof(int) * 4)
35060 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
35061
35062 static void split_counters(unsigned int *cnt, unsigned int *inpr)
35063 {
35064 - unsigned int comb = atomic_read(&combined_event_count);
35065 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
35066
35067 *cnt = (comb >> IN_PROGRESS_BITS);
35068 *inpr = comb & MAX_IN_PROGRESS;
35069 @@ -395,7 +395,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
35070 ws->start_prevent_time = ws->last_time;
35071
35072 /* Increment the counter of events in progress. */
35073 - cec = atomic_inc_return(&combined_event_count);
35074 + cec = atomic_inc_return_unchecked(&combined_event_count);
35075
35076 trace_wakeup_source_activate(ws->name, cec);
35077 }
35078 @@ -521,7 +521,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
35079 * Increment the counter of registered wakeup events and decrement the
35080 * couter of wakeup events in progress simultaneously.
35081 */
35082 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
35083 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
35084 trace_wakeup_source_deactivate(ws->name, cec);
35085
35086 split_counters(&cnt, &inpr);
35087 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
35088 index e8d11b6..7b1b36f 100644
35089 --- a/drivers/base/syscore.c
35090 +++ b/drivers/base/syscore.c
35091 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
35092 void register_syscore_ops(struct syscore_ops *ops)
35093 {
35094 mutex_lock(&syscore_ops_lock);
35095 - list_add_tail(&ops->node, &syscore_ops_list);
35096 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
35097 mutex_unlock(&syscore_ops_lock);
35098 }
35099 EXPORT_SYMBOL_GPL(register_syscore_ops);
35100 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
35101 void unregister_syscore_ops(struct syscore_ops *ops)
35102 {
35103 mutex_lock(&syscore_ops_lock);
35104 - list_del(&ops->node);
35105 + pax_list_del((struct list_head *)&ops->node);
35106 mutex_unlock(&syscore_ops_lock);
35107 }
35108 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
35109 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
35110 index 62b6c2c..4a11354 100644
35111 --- a/drivers/block/cciss.c
35112 +++ b/drivers/block/cciss.c
35113 @@ -1189,6 +1189,8 @@ static int cciss_ioctl32_passthru(struct block_device *bdev, fmode_t mode,
35114 int err;
35115 u32 cp;
35116
35117 + memset(&arg64, 0, sizeof(arg64));
35118 +
35119 err = 0;
35120 err |=
35121 copy_from_user(&arg64.LUN_info, &arg32->LUN_info,
35122 @@ -3010,7 +3012,7 @@ static void start_io(ctlr_info_t *h)
35123 while (!list_empty(&h->reqQ)) {
35124 c = list_entry(h->reqQ.next, CommandList_struct, list);
35125 /* can't do anything if fifo is full */
35126 - if ((h->access.fifo_full(h))) {
35127 + if ((h->access->fifo_full(h))) {
35128 dev_warn(&h->pdev->dev, "fifo full\n");
35129 break;
35130 }
35131 @@ -3020,7 +3022,7 @@ static void start_io(ctlr_info_t *h)
35132 h->Qdepth--;
35133
35134 /* Tell the controller execute command */
35135 - h->access.submit_command(h, c);
35136 + h->access->submit_command(h, c);
35137
35138 /* Put job onto the completed Q */
35139 addQ(&h->cmpQ, c);
35140 @@ -3446,17 +3448,17 @@ startio:
35141
35142 static inline unsigned long get_next_completion(ctlr_info_t *h)
35143 {
35144 - return h->access.command_completed(h);
35145 + return h->access->command_completed(h);
35146 }
35147
35148 static inline int interrupt_pending(ctlr_info_t *h)
35149 {
35150 - return h->access.intr_pending(h);
35151 + return h->access->intr_pending(h);
35152 }
35153
35154 static inline long interrupt_not_for_us(ctlr_info_t *h)
35155 {
35156 - return ((h->access.intr_pending(h) == 0) ||
35157 + return ((h->access->intr_pending(h) == 0) ||
35158 (h->interrupts_enabled == 0));
35159 }
35160
35161 @@ -3489,7 +3491,7 @@ static inline u32 next_command(ctlr_info_t *h)
35162 u32 a;
35163
35164 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
35165 - return h->access.command_completed(h);
35166 + return h->access->command_completed(h);
35167
35168 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
35169 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
35170 @@ -4046,7 +4048,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
35171 trans_support & CFGTBL_Trans_use_short_tags);
35172
35173 /* Change the access methods to the performant access methods */
35174 - h->access = SA5_performant_access;
35175 + h->access = &SA5_performant_access;
35176 h->transMethod = CFGTBL_Trans_Performant;
35177
35178 return;
35179 @@ -4319,7 +4321,7 @@ static int cciss_pci_init(ctlr_info_t *h)
35180 if (prod_index < 0)
35181 return -ENODEV;
35182 h->product_name = products[prod_index].product_name;
35183 - h->access = *(products[prod_index].access);
35184 + h->access = products[prod_index].access;
35185
35186 if (cciss_board_disabled(h)) {
35187 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
35188 @@ -5051,7 +5053,7 @@ reinit_after_soft_reset:
35189 }
35190
35191 /* make sure the board interrupts are off */
35192 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
35193 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
35194 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
35195 if (rc)
35196 goto clean2;
35197 @@ -5101,7 +5103,7 @@ reinit_after_soft_reset:
35198 * fake ones to scoop up any residual completions.
35199 */
35200 spin_lock_irqsave(&h->lock, flags);
35201 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
35202 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
35203 spin_unlock_irqrestore(&h->lock, flags);
35204 free_irq(h->intr[h->intr_mode], h);
35205 rc = cciss_request_irq(h, cciss_msix_discard_completions,
35206 @@ -5121,9 +5123,9 @@ reinit_after_soft_reset:
35207 dev_info(&h->pdev->dev, "Board READY.\n");
35208 dev_info(&h->pdev->dev,
35209 "Waiting for stale completions to drain.\n");
35210 - h->access.set_intr_mask(h, CCISS_INTR_ON);
35211 + h->access->set_intr_mask(h, CCISS_INTR_ON);
35212 msleep(10000);
35213 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
35214 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
35215
35216 rc = controller_reset_failed(h->cfgtable);
35217 if (rc)
35218 @@ -5146,7 +5148,7 @@ reinit_after_soft_reset:
35219 cciss_scsi_setup(h);
35220
35221 /* Turn the interrupts on so we can service requests */
35222 - h->access.set_intr_mask(h, CCISS_INTR_ON);
35223 + h->access->set_intr_mask(h, CCISS_INTR_ON);
35224
35225 /* Get the firmware version */
35226 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
35227 @@ -5218,7 +5220,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
35228 kfree(flush_buf);
35229 if (return_code != IO_OK)
35230 dev_warn(&h->pdev->dev, "Error flushing cache\n");
35231 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
35232 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
35233 free_irq(h->intr[h->intr_mode], h);
35234 }
35235
35236 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
35237 index 7fda30e..eb5dfe0 100644
35238 --- a/drivers/block/cciss.h
35239 +++ b/drivers/block/cciss.h
35240 @@ -101,7 +101,7 @@ struct ctlr_info
35241 /* information about each logical volume */
35242 drive_info_struct *drv[CISS_MAX_LUN];
35243
35244 - struct access_method access;
35245 + struct access_method *access;
35246
35247 /* queue and queue Info */
35248 struct list_head reqQ;
35249 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
35250 index 639d26b..fd6ad1f 100644
35251 --- a/drivers/block/cpqarray.c
35252 +++ b/drivers/block/cpqarray.c
35253 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
35254 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
35255 goto Enomem4;
35256 }
35257 - hba[i]->access.set_intr_mask(hba[i], 0);
35258 + hba[i]->access->set_intr_mask(hba[i], 0);
35259 if (request_irq(hba[i]->intr, do_ida_intr,
35260 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
35261 {
35262 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
35263 add_timer(&hba[i]->timer);
35264
35265 /* Enable IRQ now that spinlock and rate limit timer are set up */
35266 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
35267 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
35268
35269 for(j=0; j<NWD; j++) {
35270 struct gendisk *disk = ida_gendisk[i][j];
35271 @@ -694,7 +694,7 @@ DBGINFO(
35272 for(i=0; i<NR_PRODUCTS; i++) {
35273 if (board_id == products[i].board_id) {
35274 c->product_name = products[i].product_name;
35275 - c->access = *(products[i].access);
35276 + c->access = products[i].access;
35277 break;
35278 }
35279 }
35280 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
35281 hba[ctlr]->intr = intr;
35282 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
35283 hba[ctlr]->product_name = products[j].product_name;
35284 - hba[ctlr]->access = *(products[j].access);
35285 + hba[ctlr]->access = products[j].access;
35286 hba[ctlr]->ctlr = ctlr;
35287 hba[ctlr]->board_id = board_id;
35288 hba[ctlr]->pci_dev = NULL; /* not PCI */
35289 @@ -978,7 +978,7 @@ static void start_io(ctlr_info_t *h)
35290
35291 while((c = h->reqQ) != NULL) {
35292 /* Can't do anything if we're busy */
35293 - if (h->access.fifo_full(h) == 0)
35294 + if (h->access->fifo_full(h) == 0)
35295 return;
35296
35297 /* Get the first entry from the request Q */
35298 @@ -986,7 +986,7 @@ static void start_io(ctlr_info_t *h)
35299 h->Qdepth--;
35300
35301 /* Tell the controller to do our bidding */
35302 - h->access.submit_command(h, c);
35303 + h->access->submit_command(h, c);
35304
35305 /* Get onto the completion Q */
35306 addQ(&h->cmpQ, c);
35307 @@ -1048,7 +1048,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
35308 unsigned long flags;
35309 __u32 a,a1;
35310
35311 - istat = h->access.intr_pending(h);
35312 + istat = h->access->intr_pending(h);
35313 /* Is this interrupt for us? */
35314 if (istat == 0)
35315 return IRQ_NONE;
35316 @@ -1059,7 +1059,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
35317 */
35318 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
35319 if (istat & FIFO_NOT_EMPTY) {
35320 - while((a = h->access.command_completed(h))) {
35321 + while((a = h->access->command_completed(h))) {
35322 a1 = a; a &= ~3;
35323 if ((c = h->cmpQ) == NULL)
35324 {
35325 @@ -1193,6 +1193,7 @@ out_passthru:
35326 ida_pci_info_struct pciinfo;
35327
35328 if (!arg) return -EINVAL;
35329 + memset(&pciinfo, 0, sizeof(pciinfo));
35330 pciinfo.bus = host->pci_dev->bus->number;
35331 pciinfo.dev_fn = host->pci_dev->devfn;
35332 pciinfo.board_id = host->board_id;
35333 @@ -1447,11 +1448,11 @@ static int sendcmd(
35334 /*
35335 * Disable interrupt
35336 */
35337 - info_p->access.set_intr_mask(info_p, 0);
35338 + info_p->access->set_intr_mask(info_p, 0);
35339 /* Make sure there is room in the command FIFO */
35340 /* Actually it should be completely empty at this time. */
35341 for (i = 200000; i > 0; i--) {
35342 - temp = info_p->access.fifo_full(info_p);
35343 + temp = info_p->access->fifo_full(info_p);
35344 if (temp != 0) {
35345 break;
35346 }
35347 @@ -1464,7 +1465,7 @@ DBG(
35348 /*
35349 * Send the cmd
35350 */
35351 - info_p->access.submit_command(info_p, c);
35352 + info_p->access->submit_command(info_p, c);
35353 complete = pollcomplete(ctlr);
35354
35355 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
35356 @@ -1547,9 +1548,9 @@ static int revalidate_allvol(ctlr_info_t *host)
35357 * we check the new geometry. Then turn interrupts back on when
35358 * we're done.
35359 */
35360 - host->access.set_intr_mask(host, 0);
35361 + host->access->set_intr_mask(host, 0);
35362 getgeometry(ctlr);
35363 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
35364 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
35365
35366 for(i=0; i<NWD; i++) {
35367 struct gendisk *disk = ida_gendisk[ctlr][i];
35368 @@ -1589,7 +1590,7 @@ static int pollcomplete(int ctlr)
35369 /* Wait (up to 2 seconds) for a command to complete */
35370
35371 for (i = 200000; i > 0; i--) {
35372 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
35373 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
35374 if (done == 0) {
35375 udelay(10); /* a short fixed delay */
35376 } else
35377 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
35378 index be73e9d..7fbf140 100644
35379 --- a/drivers/block/cpqarray.h
35380 +++ b/drivers/block/cpqarray.h
35381 @@ -99,7 +99,7 @@ struct ctlr_info {
35382 drv_info_t drv[NWD];
35383 struct proc_dir_entry *proc;
35384
35385 - struct access_method access;
35386 + struct access_method *access;
35387
35388 cmdlist_t *reqQ;
35389 cmdlist_t *cmpQ;
35390 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
35391 index f943aac..99bfd19 100644
35392 --- a/drivers/block/drbd/drbd_int.h
35393 +++ b/drivers/block/drbd/drbd_int.h
35394 @@ -582,7 +582,7 @@ struct drbd_epoch {
35395 struct drbd_tconn *tconn;
35396 struct list_head list;
35397 unsigned int barrier_nr;
35398 - atomic_t epoch_size; /* increased on every request added. */
35399 + atomic_unchecked_t epoch_size; /* increased on every request added. */
35400 atomic_t active; /* increased on every req. added, and dec on every finished. */
35401 unsigned long flags;
35402 };
35403 @@ -1021,7 +1021,7 @@ struct drbd_conf {
35404 unsigned int al_tr_number;
35405 int al_tr_cycle;
35406 wait_queue_head_t seq_wait;
35407 - atomic_t packet_seq;
35408 + atomic_unchecked_t packet_seq;
35409 unsigned int peer_seq;
35410 spinlock_t peer_seq_lock;
35411 unsigned int minor;
35412 @@ -1562,7 +1562,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
35413 char __user *uoptval;
35414 int err;
35415
35416 - uoptval = (char __user __force *)optval;
35417 + uoptval = (char __force_user *)optval;
35418
35419 set_fs(KERNEL_DS);
35420 if (level == SOL_SOCKET)
35421 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
35422 index a5dca6a..bb27967 100644
35423 --- a/drivers/block/drbd/drbd_main.c
35424 +++ b/drivers/block/drbd/drbd_main.c
35425 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
35426 p->sector = sector;
35427 p->block_id = block_id;
35428 p->blksize = blksize;
35429 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
35430 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
35431 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
35432 }
35433
35434 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
35435 return -EIO;
35436 p->sector = cpu_to_be64(req->i.sector);
35437 p->block_id = (unsigned long)req;
35438 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
35439 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
35440 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
35441 if (mdev->state.conn >= C_SYNC_SOURCE &&
35442 mdev->state.conn <= C_PAUSED_SYNC_T)
35443 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
35444 {
35445 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
35446
35447 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
35448 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
35449 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
35450 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
35451 kfree(tconn->current_epoch);
35452
35453 idr_destroy(&tconn->volumes);
35454 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
35455 index 4222aff..1f79506 100644
35456 --- a/drivers/block/drbd/drbd_receiver.c
35457 +++ b/drivers/block/drbd/drbd_receiver.c
35458 @@ -834,7 +834,7 @@ int drbd_connected(struct drbd_conf *mdev)
35459 {
35460 int err;
35461
35462 - atomic_set(&mdev->packet_seq, 0);
35463 + atomic_set_unchecked(&mdev->packet_seq, 0);
35464 mdev->peer_seq = 0;
35465
35466 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
35467 @@ -1193,7 +1193,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
35468 do {
35469 next_epoch = NULL;
35470
35471 - epoch_size = atomic_read(&epoch->epoch_size);
35472 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
35473
35474 switch (ev & ~EV_CLEANUP) {
35475 case EV_PUT:
35476 @@ -1233,7 +1233,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
35477 rv = FE_DESTROYED;
35478 } else {
35479 epoch->flags = 0;
35480 - atomic_set(&epoch->epoch_size, 0);
35481 + atomic_set_unchecked(&epoch->epoch_size, 0);
35482 /* atomic_set(&epoch->active, 0); is already zero */
35483 if (rv == FE_STILL_LIVE)
35484 rv = FE_RECYCLED;
35485 @@ -1451,7 +1451,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
35486 conn_wait_active_ee_empty(tconn);
35487 drbd_flush(tconn);
35488
35489 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
35490 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
35491 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
35492 if (epoch)
35493 break;
35494 @@ -1464,11 +1464,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
35495 }
35496
35497 epoch->flags = 0;
35498 - atomic_set(&epoch->epoch_size, 0);
35499 + atomic_set_unchecked(&epoch->epoch_size, 0);
35500 atomic_set(&epoch->active, 0);
35501
35502 spin_lock(&tconn->epoch_lock);
35503 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
35504 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
35505 list_add(&epoch->list, &tconn->current_epoch->list);
35506 tconn->current_epoch = epoch;
35507 tconn->epochs++;
35508 @@ -2172,7 +2172,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
35509
35510 err = wait_for_and_update_peer_seq(mdev, peer_seq);
35511 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
35512 - atomic_inc(&tconn->current_epoch->epoch_size);
35513 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
35514 err2 = drbd_drain_block(mdev, pi->size);
35515 if (!err)
35516 err = err2;
35517 @@ -2206,7 +2206,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
35518
35519 spin_lock(&tconn->epoch_lock);
35520 peer_req->epoch = tconn->current_epoch;
35521 - atomic_inc(&peer_req->epoch->epoch_size);
35522 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
35523 atomic_inc(&peer_req->epoch->active);
35524 spin_unlock(&tconn->epoch_lock);
35525
35526 @@ -4347,7 +4347,7 @@ struct data_cmd {
35527 int expect_payload;
35528 size_t pkt_size;
35529 int (*fn)(struct drbd_tconn *, struct packet_info *);
35530 -};
35531 +} __do_const;
35532
35533 static struct data_cmd drbd_cmd_handler[] = {
35534 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
35535 @@ -4467,7 +4467,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
35536 if (!list_empty(&tconn->current_epoch->list))
35537 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
35538 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
35539 - atomic_set(&tconn->current_epoch->epoch_size, 0);
35540 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
35541 tconn->send.seen_any_write_yet = false;
35542
35543 conn_info(tconn, "Connection closed\n");
35544 @@ -5223,7 +5223,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
35545 struct asender_cmd {
35546 size_t pkt_size;
35547 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
35548 -};
35549 +} __do_const;
35550
35551 static struct asender_cmd asender_tbl[] = {
35552 [P_PING] = { 0, got_Ping },
35553 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
35554 index d92d50f..a7e9d97 100644
35555 --- a/drivers/block/loop.c
35556 +++ b/drivers/block/loop.c
35557 @@ -232,7 +232,7 @@ static int __do_lo_send_write(struct file *file,
35558
35559 file_start_write(file);
35560 set_fs(get_ds());
35561 - bw = file->f_op->write(file, buf, len, &pos);
35562 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
35563 set_fs(old_fs);
35564 file_end_write(file);
35565 if (likely(bw == len))
35566 diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
35567 index f5d0ea1..c62380a 100644
35568 --- a/drivers/block/pktcdvd.c
35569 +++ b/drivers/block/pktcdvd.c
35570 @@ -84,7 +84,7 @@
35571 #define MAX_SPEED 0xffff
35572
35573 #define ZONE(sector, pd) (((sector) + (pd)->offset) & \
35574 - ~(sector_t)((pd)->settings.size - 1))
35575 + ~(sector_t)((pd)->settings.size - 1UL))
35576
35577 static DEFINE_MUTEX(pktcdvd_mutex);
35578 static struct pktcdvd_device *pkt_devs[MAX_WRITERS];
35579 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
35580 index 8a3aff7..d7538c2 100644
35581 --- a/drivers/cdrom/cdrom.c
35582 +++ b/drivers/cdrom/cdrom.c
35583 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
35584 ENSURE(reset, CDC_RESET);
35585 ENSURE(generic_packet, CDC_GENERIC_PACKET);
35586 cdi->mc_flags = 0;
35587 - cdo->n_minors = 0;
35588 cdi->options = CDO_USE_FFLAGS;
35589
35590 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
35591 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
35592 else
35593 cdi->cdda_method = CDDA_OLD;
35594
35595 - if (!cdo->generic_packet)
35596 - cdo->generic_packet = cdrom_dummy_generic_packet;
35597 + if (!cdo->generic_packet) {
35598 + pax_open_kernel();
35599 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
35600 + pax_close_kernel();
35601 + }
35602
35603 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
35604 mutex_lock(&cdrom_mutex);
35605 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
35606 if (cdi->exit)
35607 cdi->exit(cdi);
35608
35609 - cdi->ops->n_minors--;
35610 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
35611 }
35612
35613 @@ -2107,7 +2108,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf,
35614 */
35615 nr = nframes;
35616 do {
35617 - cgc.buffer = kmalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
35618 + cgc.buffer = kzalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
35619 if (cgc.buffer)
35620 break;
35621
35622 @@ -3429,7 +3430,7 @@ static int cdrom_print_info(const char *header, int val, char *info,
35623 struct cdrom_device_info *cdi;
35624 int ret;
35625
35626 - ret = scnprintf(info + *pos, max_size - *pos, header);
35627 + ret = scnprintf(info + *pos, max_size - *pos, "%s", header);
35628 if (!ret)
35629 return 1;
35630
35631 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
35632 index 4afcb65..a68a32d 100644
35633 --- a/drivers/cdrom/gdrom.c
35634 +++ b/drivers/cdrom/gdrom.c
35635 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
35636 .audio_ioctl = gdrom_audio_ioctl,
35637 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
35638 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
35639 - .n_minors = 1,
35640 };
35641
35642 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
35643 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
35644 index 3bb6fa3..34013fb 100644
35645 --- a/drivers/char/Kconfig
35646 +++ b/drivers/char/Kconfig
35647 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
35648
35649 config DEVKMEM
35650 bool "/dev/kmem virtual device support"
35651 - default y
35652 + default n
35653 + depends on !GRKERNSEC_KMEM
35654 help
35655 Say Y here if you want to support the /dev/kmem device. The
35656 /dev/kmem device is rarely used, but can be used for certain
35657 @@ -582,6 +583,7 @@ config DEVPORT
35658 bool
35659 depends on !M68K
35660 depends on ISA || PCI
35661 + depends on !GRKERNSEC_KMEM
35662 default y
35663
35664 source "drivers/s390/char/Kconfig"
35665 diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
35666 index a48e05b..6bac831 100644
35667 --- a/drivers/char/agp/compat_ioctl.c
35668 +++ b/drivers/char/agp/compat_ioctl.c
35669 @@ -108,7 +108,7 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
35670 return -ENOMEM;
35671 }
35672
35673 - if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
35674 + if (copy_from_user(usegment, (void __force_user *) ureserve.seg_list,
35675 sizeof(*usegment) * ureserve.seg_count)) {
35676 kfree(usegment);
35677 kfree(ksegment);
35678 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
35679 index 2e04433..771f2cc 100644
35680 --- a/drivers/char/agp/frontend.c
35681 +++ b/drivers/char/agp/frontend.c
35682 @@ -817,7 +817,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
35683 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
35684 return -EFAULT;
35685
35686 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
35687 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
35688 return -EFAULT;
35689
35690 client = agp_find_client_by_pid(reserve.pid);
35691 @@ -847,7 +847,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
35692 if (segment == NULL)
35693 return -ENOMEM;
35694
35695 - if (copy_from_user(segment, (void __user *) reserve.seg_list,
35696 + if (copy_from_user(segment, (void __force_user *) reserve.seg_list,
35697 sizeof(struct agp_segment) * reserve.seg_count)) {
35698 kfree(segment);
35699 return -EFAULT;
35700 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
35701 index 4f94375..413694e 100644
35702 --- a/drivers/char/genrtc.c
35703 +++ b/drivers/char/genrtc.c
35704 @@ -273,6 +273,7 @@ static int gen_rtc_ioctl(struct file *file,
35705 switch (cmd) {
35706
35707 case RTC_PLL_GET:
35708 + memset(&pll, 0, sizeof(pll));
35709 if (get_rtc_pll(&pll))
35710 return -EINVAL;
35711 else
35712 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
35713 index d784650..e8bfd69 100644
35714 --- a/drivers/char/hpet.c
35715 +++ b/drivers/char/hpet.c
35716 @@ -559,7 +559,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
35717 }
35718
35719 static int
35720 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
35721 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
35722 struct hpet_info *info)
35723 {
35724 struct hpet_timer __iomem *timer;
35725 diff --git a/drivers/char/hw_random/intel-rng.c b/drivers/char/hw_random/intel-rng.c
35726 index 86fe45c..c0ea948 100644
35727 --- a/drivers/char/hw_random/intel-rng.c
35728 +++ b/drivers/char/hw_random/intel-rng.c
35729 @@ -314,7 +314,7 @@ PFX "RNG, try using the 'no_fwh_detect' option.\n";
35730
35731 if (no_fwh_detect)
35732 return -ENODEV;
35733 - printk(warning);
35734 + printk("%s", warning);
35735 return -EBUSY;
35736 }
35737
35738 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
35739 index 4445fa1..7c6de37 100644
35740 --- a/drivers/char/ipmi/ipmi_msghandler.c
35741 +++ b/drivers/char/ipmi/ipmi_msghandler.c
35742 @@ -420,7 +420,7 @@ struct ipmi_smi {
35743 struct proc_dir_entry *proc_dir;
35744 char proc_dir_name[10];
35745
35746 - atomic_t stats[IPMI_NUM_STATS];
35747 + atomic_unchecked_t stats[IPMI_NUM_STATS];
35748
35749 /*
35750 * run_to_completion duplicate of smb_info, smi_info
35751 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
35752
35753
35754 #define ipmi_inc_stat(intf, stat) \
35755 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
35756 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
35757 #define ipmi_get_stat(intf, stat) \
35758 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
35759 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
35760
35761 static int is_lan_addr(struct ipmi_addr *addr)
35762 {
35763 @@ -2883,7 +2883,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
35764 INIT_LIST_HEAD(&intf->cmd_rcvrs);
35765 init_waitqueue_head(&intf->waitq);
35766 for (i = 0; i < IPMI_NUM_STATS; i++)
35767 - atomic_set(&intf->stats[i], 0);
35768 + atomic_set_unchecked(&intf->stats[i], 0);
35769
35770 intf->proc_dir = NULL;
35771
35772 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
35773 index af4b23f..79806fc 100644
35774 --- a/drivers/char/ipmi/ipmi_si_intf.c
35775 +++ b/drivers/char/ipmi/ipmi_si_intf.c
35776 @@ -275,7 +275,7 @@ struct smi_info {
35777 unsigned char slave_addr;
35778
35779 /* Counters and things for the proc filesystem. */
35780 - atomic_t stats[SI_NUM_STATS];
35781 + atomic_unchecked_t stats[SI_NUM_STATS];
35782
35783 struct task_struct *thread;
35784
35785 @@ -284,9 +284,9 @@ struct smi_info {
35786 };
35787
35788 #define smi_inc_stat(smi, stat) \
35789 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
35790 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
35791 #define smi_get_stat(smi, stat) \
35792 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
35793 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
35794
35795 #define SI_MAX_PARMS 4
35796
35797 @@ -3258,7 +3258,7 @@ static int try_smi_init(struct smi_info *new_smi)
35798 atomic_set(&new_smi->req_events, 0);
35799 new_smi->run_to_completion = 0;
35800 for (i = 0; i < SI_NUM_STATS; i++)
35801 - atomic_set(&new_smi->stats[i], 0);
35802 + atomic_set_unchecked(&new_smi->stats[i], 0);
35803
35804 new_smi->interrupt_disabled = 1;
35805 atomic_set(&new_smi->stop_operation, 0);
35806 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
35807 index 1ccbe94..6ad651a 100644
35808 --- a/drivers/char/mem.c
35809 +++ b/drivers/char/mem.c
35810 @@ -18,6 +18,7 @@
35811 #include <linux/raw.h>
35812 #include <linux/tty.h>
35813 #include <linux/capability.h>
35814 +#include <linux/security.h>
35815 #include <linux/ptrace.h>
35816 #include <linux/device.h>
35817 #include <linux/highmem.h>
35818 @@ -38,6 +39,10 @@
35819
35820 #define DEVPORT_MINOR 4
35821
35822 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
35823 +extern const struct file_operations grsec_fops;
35824 +#endif
35825 +
35826 static inline unsigned long size_inside_page(unsigned long start,
35827 unsigned long size)
35828 {
35829 @@ -69,9 +74,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
35830
35831 while (cursor < to) {
35832 if (!devmem_is_allowed(pfn)) {
35833 +#ifdef CONFIG_GRKERNSEC_KMEM
35834 + gr_handle_mem_readwrite(from, to);
35835 +#else
35836 printk(KERN_INFO
35837 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
35838 current->comm, from, to);
35839 +#endif
35840 return 0;
35841 }
35842 cursor += PAGE_SIZE;
35843 @@ -79,6 +88,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
35844 }
35845 return 1;
35846 }
35847 +#elif defined(CONFIG_GRKERNSEC_KMEM)
35848 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
35849 +{
35850 + return 0;
35851 +}
35852 #else
35853 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
35854 {
35855 @@ -121,6 +135,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
35856
35857 while (count > 0) {
35858 unsigned long remaining;
35859 + char *temp;
35860
35861 sz = size_inside_page(p, count);
35862
35863 @@ -136,7 +151,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
35864 if (!ptr)
35865 return -EFAULT;
35866
35867 - remaining = copy_to_user(buf, ptr, sz);
35868 +#ifdef CONFIG_PAX_USERCOPY
35869 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
35870 + if (!temp) {
35871 + unxlate_dev_mem_ptr(p, ptr);
35872 + return -ENOMEM;
35873 + }
35874 + memcpy(temp, ptr, sz);
35875 +#else
35876 + temp = ptr;
35877 +#endif
35878 +
35879 + remaining = copy_to_user(buf, temp, sz);
35880 +
35881 +#ifdef CONFIG_PAX_USERCOPY
35882 + kfree(temp);
35883 +#endif
35884 +
35885 unxlate_dev_mem_ptr(p, ptr);
35886 if (remaining)
35887 return -EFAULT;
35888 @@ -379,7 +410,7 @@ static ssize_t read_oldmem(struct file *file, char __user *buf,
35889 else
35890 csize = count;
35891
35892 - rc = copy_oldmem_page(pfn, buf, csize, offset, 1);
35893 + rc = copy_oldmem_page(pfn, (char __force_kernel *)buf, csize, offset, 1);
35894 if (rc < 0)
35895 return rc;
35896 buf += csize;
35897 @@ -399,9 +430,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
35898 size_t count, loff_t *ppos)
35899 {
35900 unsigned long p = *ppos;
35901 - ssize_t low_count, read, sz;
35902 + ssize_t low_count, read, sz, err = 0;
35903 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
35904 - int err = 0;
35905
35906 read = 0;
35907 if (p < (unsigned long) high_memory) {
35908 @@ -423,6 +453,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
35909 }
35910 #endif
35911 while (low_count > 0) {
35912 + char *temp;
35913 +
35914 sz = size_inside_page(p, low_count);
35915
35916 /*
35917 @@ -432,7 +464,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
35918 */
35919 kbuf = xlate_dev_kmem_ptr((char *)p);
35920
35921 - if (copy_to_user(buf, kbuf, sz))
35922 +#ifdef CONFIG_PAX_USERCOPY
35923 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
35924 + if (!temp)
35925 + return -ENOMEM;
35926 + memcpy(temp, kbuf, sz);
35927 +#else
35928 + temp = kbuf;
35929 +#endif
35930 +
35931 + err = copy_to_user(buf, temp, sz);
35932 +
35933 +#ifdef CONFIG_PAX_USERCOPY
35934 + kfree(temp);
35935 +#endif
35936 +
35937 + if (err)
35938 return -EFAULT;
35939 buf += sz;
35940 p += sz;
35941 @@ -869,6 +916,9 @@ static const struct memdev {
35942 #ifdef CONFIG_CRASH_DUMP
35943 [12] = { "oldmem", 0, &oldmem_fops, NULL },
35944 #endif
35945 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
35946 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
35947 +#endif
35948 };
35949
35950 static int memory_open(struct inode *inode, struct file *filp)
35951 @@ -940,7 +990,7 @@ static int __init chr_dev_init(void)
35952 continue;
35953
35954 device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor),
35955 - NULL, devlist[minor].name);
35956 + NULL, "%s", devlist[minor].name);
35957 }
35958
35959 return tty_init();
35960 diff --git a/drivers/char/mwave/tp3780i.c b/drivers/char/mwave/tp3780i.c
35961 index c689697..04e6d6a2 100644
35962 --- a/drivers/char/mwave/tp3780i.c
35963 +++ b/drivers/char/mwave/tp3780i.c
35964 @@ -479,6 +479,7 @@ int tp3780I_QueryAbilities(THINKPAD_BD_DATA * pBDData, MW_ABILITIES * pAbilities
35965 PRINTK_2(TRACE_TP3780I,
35966 "tp3780i::tp3780I_QueryAbilities entry pBDData %p\n", pBDData);
35967
35968 + memset(pAbilities, 0, sizeof(*pAbilities));
35969 /* fill out standard constant fields */
35970 pAbilities->instr_per_sec = pBDData->rDspSettings.uIps;
35971 pAbilities->data_size = pBDData->rDspSettings.uDStoreSize;
35972 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
35973 index 9df78e2..01ba9ae 100644
35974 --- a/drivers/char/nvram.c
35975 +++ b/drivers/char/nvram.c
35976 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
35977
35978 spin_unlock_irq(&rtc_lock);
35979
35980 - if (copy_to_user(buf, contents, tmp - contents))
35981 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
35982 return -EFAULT;
35983
35984 *ppos = i;
35985 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
35986 index 5c5cc00..ac9edb7 100644
35987 --- a/drivers/char/pcmcia/synclink_cs.c
35988 +++ b/drivers/char/pcmcia/synclink_cs.c
35989 @@ -2345,9 +2345,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
35990
35991 if (debug_level >= DEBUG_LEVEL_INFO)
35992 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
35993 - __FILE__, __LINE__, info->device_name, port->count);
35994 + __FILE__, __LINE__, info->device_name, atomic_read(&port->count));
35995
35996 - WARN_ON(!port->count);
35997 + WARN_ON(!atomic_read(&port->count));
35998
35999 if (tty_port_close_start(port, tty, filp) == 0)
36000 goto cleanup;
36001 @@ -2365,7 +2365,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
36002 cleanup:
36003 if (debug_level >= DEBUG_LEVEL_INFO)
36004 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__, __LINE__,
36005 - tty->driver->name, port->count);
36006 + tty->driver->name, atomic_read(&port->count));
36007 }
36008
36009 /* Wait until the transmitter is empty.
36010 @@ -2507,7 +2507,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
36011
36012 if (debug_level >= DEBUG_LEVEL_INFO)
36013 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
36014 - __FILE__, __LINE__, tty->driver->name, port->count);
36015 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
36016
36017 /* If port is closing, signal caller to try again */
36018 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
36019 @@ -2527,11 +2527,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
36020 goto cleanup;
36021 }
36022 spin_lock(&port->lock);
36023 - port->count++;
36024 + atomic_inc(&port->count);
36025 spin_unlock(&port->lock);
36026 spin_unlock_irqrestore(&info->netlock, flags);
36027
36028 - if (port->count == 1) {
36029 + if (atomic_read(&port->count) == 1) {
36030 /* 1st open on this device, init hardware */
36031 retval = startup(info, tty);
36032 if (retval < 0)
36033 @@ -3920,7 +3920,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
36034 unsigned short new_crctype;
36035
36036 /* return error if TTY interface open */
36037 - if (info->port.count)
36038 + if (atomic_read(&info->port.count))
36039 return -EBUSY;
36040
36041 switch (encoding)
36042 @@ -4024,7 +4024,7 @@ static int hdlcdev_open(struct net_device *dev)
36043
36044 /* arbitrate between network and tty opens */
36045 spin_lock_irqsave(&info->netlock, flags);
36046 - if (info->port.count != 0 || info->netcount != 0) {
36047 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
36048 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
36049 spin_unlock_irqrestore(&info->netlock, flags);
36050 return -EBUSY;
36051 @@ -4114,7 +4114,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
36052 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name);
36053
36054 /* return error if TTY interface open */
36055 - if (info->port.count)
36056 + if (atomic_read(&info->port.count))
36057 return -EBUSY;
36058
36059 if (cmd != SIOCWANDEV)
36060 diff --git a/drivers/char/random.c b/drivers/char/random.c
36061 index 35487e8..dac8bd1 100644
36062 --- a/drivers/char/random.c
36063 +++ b/drivers/char/random.c
36064 @@ -272,8 +272,13 @@
36065 /*
36066 * Configuration information
36067 */
36068 +#ifdef CONFIG_GRKERNSEC_RANDNET
36069 +#define INPUT_POOL_WORDS 512
36070 +#define OUTPUT_POOL_WORDS 128
36071 +#else
36072 #define INPUT_POOL_WORDS 128
36073 #define OUTPUT_POOL_WORDS 32
36074 +#endif
36075 #define SEC_XFER_SIZE 512
36076 #define EXTRACT_SIZE 10
36077
36078 @@ -313,10 +318,17 @@ static struct poolinfo {
36079 int poolwords;
36080 int tap1, tap2, tap3, tap4, tap5;
36081 } poolinfo_table[] = {
36082 +#ifdef CONFIG_GRKERNSEC_RANDNET
36083 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
36084 + { 512, 411, 308, 208, 104, 1 },
36085 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
36086 + { 128, 103, 76, 51, 25, 1 },
36087 +#else
36088 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
36089 { 128, 103, 76, 51, 25, 1 },
36090 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
36091 { 32, 26, 20, 14, 7, 1 },
36092 +#endif
36093 #if 0
36094 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
36095 { 2048, 1638, 1231, 819, 411, 1 },
36096 @@ -524,8 +536,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
36097 input_rotate += i ? 7 : 14;
36098 }
36099
36100 - ACCESS_ONCE(r->input_rotate) = input_rotate;
36101 - ACCESS_ONCE(r->add_ptr) = i;
36102 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
36103 + ACCESS_ONCE_RW(r->add_ptr) = i;
36104 smp_wmb();
36105
36106 if (out)
36107 @@ -1032,7 +1044,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
36108
36109 extract_buf(r, tmp);
36110 i = min_t(int, nbytes, EXTRACT_SIZE);
36111 - if (copy_to_user(buf, tmp, i)) {
36112 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
36113 ret = -EFAULT;
36114 break;
36115 }
36116 @@ -1368,7 +1380,7 @@ EXPORT_SYMBOL(generate_random_uuid);
36117 #include <linux/sysctl.h>
36118
36119 static int min_read_thresh = 8, min_write_thresh;
36120 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
36121 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
36122 static int max_write_thresh = INPUT_POOL_WORDS * 32;
36123 static char sysctl_bootid[16];
36124
36125 @@ -1384,7 +1396,7 @@ static char sysctl_bootid[16];
36126 static int proc_do_uuid(ctl_table *table, int write,
36127 void __user *buffer, size_t *lenp, loff_t *ppos)
36128 {
36129 - ctl_table fake_table;
36130 + ctl_table_no_const fake_table;
36131 unsigned char buf[64], tmp_uuid[16], *uuid;
36132
36133 uuid = table->data;
36134 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
36135 index bf2349db..5456d53 100644
36136 --- a/drivers/char/sonypi.c
36137 +++ b/drivers/char/sonypi.c
36138 @@ -54,6 +54,7 @@
36139
36140 #include <asm/uaccess.h>
36141 #include <asm/io.h>
36142 +#include <asm/local.h>
36143
36144 #include <linux/sonypi.h>
36145
36146 @@ -490,7 +491,7 @@ static struct sonypi_device {
36147 spinlock_t fifo_lock;
36148 wait_queue_head_t fifo_proc_list;
36149 struct fasync_struct *fifo_async;
36150 - int open_count;
36151 + local_t open_count;
36152 int model;
36153 struct input_dev *input_jog_dev;
36154 struct input_dev *input_key_dev;
36155 @@ -897,7 +898,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
36156 static int sonypi_misc_release(struct inode *inode, struct file *file)
36157 {
36158 mutex_lock(&sonypi_device.lock);
36159 - sonypi_device.open_count--;
36160 + local_dec(&sonypi_device.open_count);
36161 mutex_unlock(&sonypi_device.lock);
36162 return 0;
36163 }
36164 @@ -906,9 +907,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
36165 {
36166 mutex_lock(&sonypi_device.lock);
36167 /* Flush input queue on first open */
36168 - if (!sonypi_device.open_count)
36169 + if (!local_read(&sonypi_device.open_count))
36170 kfifo_reset(&sonypi_device.fifo);
36171 - sonypi_device.open_count++;
36172 + local_inc(&sonypi_device.open_count);
36173 mutex_unlock(&sonypi_device.lock);
36174
36175 return 0;
36176 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
36177 index 64420b3..5c40b56 100644
36178 --- a/drivers/char/tpm/tpm_acpi.c
36179 +++ b/drivers/char/tpm/tpm_acpi.c
36180 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
36181 virt = acpi_os_map_memory(start, len);
36182 if (!virt) {
36183 kfree(log->bios_event_log);
36184 + log->bios_event_log = NULL;
36185 printk("%s: ERROR - Unable to map memory\n", __func__);
36186 return -EIO;
36187 }
36188
36189 - memcpy_fromio(log->bios_event_log, virt, len);
36190 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
36191
36192 acpi_os_unmap_memory(virt, len);
36193 return 0;
36194 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
36195 index 84ddc55..1d32f1e 100644
36196 --- a/drivers/char/tpm/tpm_eventlog.c
36197 +++ b/drivers/char/tpm/tpm_eventlog.c
36198 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
36199 event = addr;
36200
36201 if ((event->event_type == 0 && event->event_size == 0) ||
36202 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
36203 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
36204 return NULL;
36205
36206 return addr;
36207 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
36208 return NULL;
36209
36210 if ((event->event_type == 0 && event->event_size == 0) ||
36211 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
36212 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
36213 return NULL;
36214
36215 (*pos)++;
36216 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
36217 int i;
36218
36219 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
36220 - seq_putc(m, data[i]);
36221 + if (!seq_putc(m, data[i]))
36222 + return -EFAULT;
36223
36224 return 0;
36225 }
36226 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
36227 index fc45567..fa2a590 100644
36228 --- a/drivers/char/virtio_console.c
36229 +++ b/drivers/char/virtio_console.c
36230 @@ -682,7 +682,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
36231 if (to_user) {
36232 ssize_t ret;
36233
36234 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
36235 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
36236 if (ret)
36237 return -EFAULT;
36238 } else {
36239 @@ -785,7 +785,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
36240 if (!port_has_data(port) && !port->host_connected)
36241 return 0;
36242
36243 - return fill_readbuf(port, ubuf, count, true);
36244 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
36245 }
36246
36247 static int wait_port_writable(struct port *port, bool nonblock)
36248 diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
36249 index a33f46f..a720eed 100644
36250 --- a/drivers/clk/clk-composite.c
36251 +++ b/drivers/clk/clk-composite.c
36252 @@ -122,7 +122,7 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
36253 struct clk *clk;
36254 struct clk_init_data init;
36255 struct clk_composite *composite;
36256 - struct clk_ops *clk_composite_ops;
36257 + clk_ops_no_const *clk_composite_ops;
36258
36259 composite = kzalloc(sizeof(*composite), GFP_KERNEL);
36260 if (!composite) {
36261 diff --git a/drivers/clk/socfpga/clk.c b/drivers/clk/socfpga/clk.c
36262 index bd11315..7f87098 100644
36263 --- a/drivers/clk/socfpga/clk.c
36264 +++ b/drivers/clk/socfpga/clk.c
36265 @@ -22,6 +22,7 @@
36266 #include <linux/clk-provider.h>
36267 #include <linux/io.h>
36268 #include <linux/of.h>
36269 +#include <asm/pgtable.h>
36270
36271 /* Clock Manager offsets */
36272 #define CLKMGR_CTRL 0x0
36273 @@ -135,8 +136,10 @@ static __init struct clk *socfpga_clk_init(struct device_node *node,
36274 if (strcmp(clk_name, "main_pll") || strcmp(clk_name, "periph_pll") ||
36275 strcmp(clk_name, "sdram_pll")) {
36276 socfpga_clk->hw.bit_idx = SOCFPGA_PLL_EXT_ENA;
36277 - clk_pll_ops.enable = clk_gate_ops.enable;
36278 - clk_pll_ops.disable = clk_gate_ops.disable;
36279 + pax_open_kernel();
36280 + *(void **)&clk_pll_ops.enable = clk_gate_ops.enable;
36281 + *(void **)&clk_pll_ops.disable = clk_gate_ops.disable;
36282 + pax_close_kernel();
36283 }
36284
36285 clk = clk_register(NULL, &socfpga_clk->hw.hw);
36286 diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
36287 index a2b2541..bc1e7ff 100644
36288 --- a/drivers/clocksource/arm_arch_timer.c
36289 +++ b/drivers/clocksource/arm_arch_timer.c
36290 @@ -264,7 +264,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
36291 return NOTIFY_OK;
36292 }
36293
36294 -static struct notifier_block arch_timer_cpu_nb __cpuinitdata = {
36295 +static struct notifier_block arch_timer_cpu_nb = {
36296 .notifier_call = arch_timer_cpu_notify,
36297 };
36298
36299 diff --git a/drivers/clocksource/bcm_kona_timer.c b/drivers/clocksource/bcm_kona_timer.c
36300 index 350f493..489479e 100644
36301 --- a/drivers/clocksource/bcm_kona_timer.c
36302 +++ b/drivers/clocksource/bcm_kona_timer.c
36303 @@ -199,7 +199,7 @@ static struct irqaction kona_timer_irq = {
36304 .handler = kona_timer_interrupt,
36305 };
36306
36307 -static void __init kona_timer_init(void)
36308 +static void __init kona_timer_init(struct device_node *np)
36309 {
36310 kona_timers_init();
36311 kona_timer_clockevents_init();
36312 diff --git a/drivers/clocksource/metag_generic.c b/drivers/clocksource/metag_generic.c
36313 index ade7513..069445f 100644
36314 --- a/drivers/clocksource/metag_generic.c
36315 +++ b/drivers/clocksource/metag_generic.c
36316 @@ -169,7 +169,7 @@ static int __cpuinit arch_timer_cpu_notify(struct notifier_block *self,
36317 return NOTIFY_OK;
36318 }
36319
36320 -static struct notifier_block __cpuinitdata arch_timer_cpu_nb = {
36321 +static struct notifier_block arch_timer_cpu_nb = {
36322 .notifier_call = arch_timer_cpu_notify,
36323 };
36324
36325 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
36326 index edc089e..bc7c0bc 100644
36327 --- a/drivers/cpufreq/acpi-cpufreq.c
36328 +++ b/drivers/cpufreq/acpi-cpufreq.c
36329 @@ -172,7 +172,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
36330 return sprintf(buf, "%u\n", boost_enabled);
36331 }
36332
36333 -static struct global_attr global_boost = __ATTR(boost, 0644,
36334 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
36335 show_global_boost,
36336 store_global_boost);
36337
36338 @@ -705,8 +705,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
36339 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
36340 per_cpu(acfreq_data, cpu) = data;
36341
36342 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
36343 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
36344 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
36345 + pax_open_kernel();
36346 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
36347 + pax_close_kernel();
36348 + }
36349
36350 result = acpi_processor_register_performance(data->acpi_data, cpu);
36351 if (result)
36352 @@ -832,7 +835,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
36353 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
36354 break;
36355 case ACPI_ADR_SPACE_FIXED_HARDWARE:
36356 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
36357 + pax_open_kernel();
36358 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
36359 + pax_close_kernel();
36360 policy->cur = get_cur_freq_on_cpu(cpu);
36361 break;
36362 default:
36363 @@ -843,8 +848,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
36364 acpi_processor_notify_smm(THIS_MODULE);
36365
36366 /* Check for APERF/MPERF support in hardware */
36367 - if (boot_cpu_has(X86_FEATURE_APERFMPERF))
36368 - acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
36369 + if (boot_cpu_has(X86_FEATURE_APERFMPERF)) {
36370 + pax_open_kernel();
36371 + *(void **)&acpi_cpufreq_driver.getavg = cpufreq_get_measured_perf;
36372 + pax_close_kernel();
36373 + }
36374
36375 pr_debug("CPU%u - ACPI performance management activated.\n", cpu);
36376 for (i = 0; i < perf->state_count; i++)
36377 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
36378 index 6485547..477033e 100644
36379 --- a/drivers/cpufreq/cpufreq.c
36380 +++ b/drivers/cpufreq/cpufreq.c
36381 @@ -1854,7 +1854,7 @@ static int __cpuinit cpufreq_cpu_callback(struct notifier_block *nfb,
36382 return NOTIFY_OK;
36383 }
36384
36385 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
36386 +static struct notifier_block cpufreq_cpu_notifier = {
36387 .notifier_call = cpufreq_cpu_callback,
36388 };
36389
36390 @@ -1886,8 +1886,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
36391
36392 pr_debug("trying to register driver %s\n", driver_data->name);
36393
36394 - if (driver_data->setpolicy)
36395 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
36396 + if (driver_data->setpolicy) {
36397 + pax_open_kernel();
36398 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
36399 + pax_close_kernel();
36400 + }
36401
36402 write_lock_irqsave(&cpufreq_driver_lock, flags);
36403 if (cpufreq_driver) {
36404 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
36405 index a86ff72..aad2b03 100644
36406 --- a/drivers/cpufreq/cpufreq_governor.c
36407 +++ b/drivers/cpufreq/cpufreq_governor.c
36408 @@ -235,7 +235,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
36409 struct dbs_data *dbs_data;
36410 struct od_cpu_dbs_info_s *od_dbs_info = NULL;
36411 struct cs_cpu_dbs_info_s *cs_dbs_info = NULL;
36412 - struct od_ops *od_ops = NULL;
36413 + const struct od_ops *od_ops = NULL;
36414 struct od_dbs_tuners *od_tuners = NULL;
36415 struct cs_dbs_tuners *cs_tuners = NULL;
36416 struct cpu_dbs_common_info *cpu_cdbs;
36417 @@ -298,7 +298,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
36418
36419 if ((cdata->governor == GOV_CONSERVATIVE) &&
36420 (!policy->governor->initialized)) {
36421 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
36422 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
36423
36424 cpufreq_register_notifier(cs_ops->notifier_block,
36425 CPUFREQ_TRANSITION_NOTIFIER);
36426 @@ -315,7 +315,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
36427
36428 if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) &&
36429 (policy->governor->initialized == 1)) {
36430 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
36431 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
36432
36433 cpufreq_unregister_notifier(cs_ops->notifier_block,
36434 CPUFREQ_TRANSITION_NOTIFIER);
36435 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
36436 index 0d9e6be..461fd3b 100644
36437 --- a/drivers/cpufreq/cpufreq_governor.h
36438 +++ b/drivers/cpufreq/cpufreq_governor.h
36439 @@ -204,7 +204,7 @@ struct common_dbs_data {
36440 void (*exit)(struct dbs_data *dbs_data);
36441
36442 /* Governor specific ops, see below */
36443 - void *gov_ops;
36444 + const void *gov_ops;
36445 };
36446
36447 /* Governer Per policy data */
36448 diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
36449 index c087347..dad6268 100644
36450 --- a/drivers/cpufreq/cpufreq_ondemand.c
36451 +++ b/drivers/cpufreq/cpufreq_ondemand.c
36452 @@ -615,14 +615,18 @@ void od_register_powersave_bias_handler(unsigned int (*f)
36453 (struct cpufreq_policy *, unsigned int, unsigned int),
36454 unsigned int powersave_bias)
36455 {
36456 - od_ops.powersave_bias_target = f;
36457 + pax_open_kernel();
36458 + *(void **)&od_ops.powersave_bias_target = f;
36459 + pax_close_kernel();
36460 od_set_powersave_bias(powersave_bias);
36461 }
36462 EXPORT_SYMBOL_GPL(od_register_powersave_bias_handler);
36463
36464 void od_unregister_powersave_bias_handler(void)
36465 {
36466 - od_ops.powersave_bias_target = generic_powersave_bias_target;
36467 + pax_open_kernel();
36468 + *(void **)&od_ops.powersave_bias_target = generic_powersave_bias_target;
36469 + pax_close_kernel();
36470 od_set_powersave_bias(0);
36471 }
36472 EXPORT_SYMBOL_GPL(od_unregister_powersave_bias_handler);
36473 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
36474 index bfd6273..e39dd63 100644
36475 --- a/drivers/cpufreq/cpufreq_stats.c
36476 +++ b/drivers/cpufreq/cpufreq_stats.c
36477 @@ -365,7 +365,7 @@ static int __cpuinit cpufreq_stat_cpu_callback(struct notifier_block *nfb,
36478 }
36479
36480 /* priority=1 so this will get called before cpufreq_remove_dev */
36481 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
36482 +static struct notifier_block cpufreq_stat_cpu_notifier = {
36483 .notifier_call = cpufreq_stat_cpu_callback,
36484 .priority = 1,
36485 };
36486 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
36487 index 421ef37..e708530c 100644
36488 --- a/drivers/cpufreq/p4-clockmod.c
36489 +++ b/drivers/cpufreq/p4-clockmod.c
36490 @@ -160,10 +160,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
36491 case 0x0F: /* Core Duo */
36492 case 0x16: /* Celeron Core */
36493 case 0x1C: /* Atom */
36494 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
36495 + pax_open_kernel();
36496 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
36497 + pax_close_kernel();
36498 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
36499 case 0x0D: /* Pentium M (Dothan) */
36500 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
36501 + pax_open_kernel();
36502 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
36503 + pax_close_kernel();
36504 /* fall through */
36505 case 0x09: /* Pentium M (Banias) */
36506 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
36507 @@ -175,7 +179,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
36508
36509 /* on P-4s, the TSC runs with constant frequency independent whether
36510 * throttling is active or not. */
36511 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
36512 + pax_open_kernel();
36513 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
36514 + pax_close_kernel();
36515
36516 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
36517 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
36518 diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
36519 index c71ee14..7c2e183 100644
36520 --- a/drivers/cpufreq/sparc-us3-cpufreq.c
36521 +++ b/drivers/cpufreq/sparc-us3-cpufreq.c
36522 @@ -18,14 +18,12 @@
36523 #include <asm/head.h>
36524 #include <asm/timer.h>
36525
36526 -static struct cpufreq_driver *cpufreq_us3_driver;
36527 -
36528 struct us3_freq_percpu_info {
36529 struct cpufreq_frequency_table table[4];
36530 };
36531
36532 /* Indexed by cpu number. */
36533 -static struct us3_freq_percpu_info *us3_freq_table;
36534 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
36535
36536 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
36537 * in the Safari config register.
36538 @@ -186,12 +184,25 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
36539
36540 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
36541 {
36542 - if (cpufreq_us3_driver)
36543 - us3_set_cpu_divider_index(policy, 0);
36544 + us3_set_cpu_divider_index(policy->cpu, 0);
36545
36546 return 0;
36547 }
36548
36549 +static int __init us3_freq_init(void);
36550 +static void __exit us3_freq_exit(void);
36551 +
36552 +static struct cpufreq_driver cpufreq_us3_driver = {
36553 + .init = us3_freq_cpu_init,
36554 + .verify = us3_freq_verify,
36555 + .target = us3_freq_target,
36556 + .get = us3_freq_get,
36557 + .exit = us3_freq_cpu_exit,
36558 + .owner = THIS_MODULE,
36559 + .name = "UltraSPARC-III",
36560 +
36561 +};
36562 +
36563 static int __init us3_freq_init(void)
36564 {
36565 unsigned long manuf, impl, ver;
36566 @@ -208,57 +219,15 @@ static int __init us3_freq_init(void)
36567 (impl == CHEETAH_IMPL ||
36568 impl == CHEETAH_PLUS_IMPL ||
36569 impl == JAGUAR_IMPL ||
36570 - impl == PANTHER_IMPL)) {
36571 - struct cpufreq_driver *driver;
36572 -
36573 - ret = -ENOMEM;
36574 - driver = kzalloc(sizeof(struct cpufreq_driver), GFP_KERNEL);
36575 - if (!driver)
36576 - goto err_out;
36577 -
36578 - us3_freq_table = kzalloc(
36579 - (NR_CPUS * sizeof(struct us3_freq_percpu_info)),
36580 - GFP_KERNEL);
36581 - if (!us3_freq_table)
36582 - goto err_out;
36583 -
36584 - driver->init = us3_freq_cpu_init;
36585 - driver->verify = us3_freq_verify;
36586 - driver->target = us3_freq_target;
36587 - driver->get = us3_freq_get;
36588 - driver->exit = us3_freq_cpu_exit;
36589 - driver->owner = THIS_MODULE,
36590 - strcpy(driver->name, "UltraSPARC-III");
36591 -
36592 - cpufreq_us3_driver = driver;
36593 - ret = cpufreq_register_driver(driver);
36594 - if (ret)
36595 - goto err_out;
36596 -
36597 - return 0;
36598 -
36599 -err_out:
36600 - if (driver) {
36601 - kfree(driver);
36602 - cpufreq_us3_driver = NULL;
36603 - }
36604 - kfree(us3_freq_table);
36605 - us3_freq_table = NULL;
36606 - return ret;
36607 - }
36608 + impl == PANTHER_IMPL))
36609 + return cpufreq_register_driver(&cpufreq_us3_driver);
36610
36611 return -ENODEV;
36612 }
36613
36614 static void __exit us3_freq_exit(void)
36615 {
36616 - if (cpufreq_us3_driver) {
36617 - cpufreq_unregister_driver(cpufreq_us3_driver);
36618 - kfree(cpufreq_us3_driver);
36619 - cpufreq_us3_driver = NULL;
36620 - kfree(us3_freq_table);
36621 - us3_freq_table = NULL;
36622 - }
36623 + cpufreq_unregister_driver(&cpufreq_us3_driver);
36624 }
36625
36626 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
36627 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
36628 index 618e6f4..e89d915 100644
36629 --- a/drivers/cpufreq/speedstep-centrino.c
36630 +++ b/drivers/cpufreq/speedstep-centrino.c
36631 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
36632 !cpu_has(cpu, X86_FEATURE_EST))
36633 return -ENODEV;
36634
36635 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
36636 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
36637 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
36638 + pax_open_kernel();
36639 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
36640 + pax_close_kernel();
36641 + }
36642
36643 if (policy->cpu != 0)
36644 return -ENODEV;
36645 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
36646 index c3a93fe..e808f24 100644
36647 --- a/drivers/cpuidle/cpuidle.c
36648 +++ b/drivers/cpuidle/cpuidle.c
36649 @@ -254,7 +254,7 @@ static int poll_idle(struct cpuidle_device *dev,
36650
36651 static void poll_idle_init(struct cpuidle_driver *drv)
36652 {
36653 - struct cpuidle_state *state = &drv->states[0];
36654 + cpuidle_state_no_const *state = &drv->states[0];
36655
36656 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
36657 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
36658 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
36659 index ea2f8e7..70ac501 100644
36660 --- a/drivers/cpuidle/governor.c
36661 +++ b/drivers/cpuidle/governor.c
36662 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
36663 mutex_lock(&cpuidle_lock);
36664 if (__cpuidle_find_governor(gov->name) == NULL) {
36665 ret = 0;
36666 - list_add_tail(&gov->governor_list, &cpuidle_governors);
36667 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
36668 if (!cpuidle_curr_governor ||
36669 cpuidle_curr_governor->rating < gov->rating)
36670 cpuidle_switch_governor(gov);
36671 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
36672 new_gov = cpuidle_replace_governor(gov->rating);
36673 cpuidle_switch_governor(new_gov);
36674 }
36675 - list_del(&gov->governor_list);
36676 + pax_list_del((struct list_head *)&gov->governor_list);
36677 mutex_unlock(&cpuidle_lock);
36678 }
36679
36680 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
36681 index 428754a..8bdf9cc 100644
36682 --- a/drivers/cpuidle/sysfs.c
36683 +++ b/drivers/cpuidle/sysfs.c
36684 @@ -131,7 +131,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
36685 NULL
36686 };
36687
36688 -static struct attribute_group cpuidle_attr_group = {
36689 +static attribute_group_no_const cpuidle_attr_group = {
36690 .attrs = cpuidle_default_attrs,
36691 .name = "cpuidle",
36692 };
36693 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
36694 index 3b36797..db0b0c0 100644
36695 --- a/drivers/devfreq/devfreq.c
36696 +++ b/drivers/devfreq/devfreq.c
36697 @@ -477,7 +477,7 @@ struct devfreq *devfreq_add_device(struct device *dev,
36698 GFP_KERNEL);
36699 devfreq->last_stat_updated = jiffies;
36700
36701 - dev_set_name(&devfreq->dev, dev_name(dev));
36702 + dev_set_name(&devfreq->dev, "%s", dev_name(dev));
36703 err = device_register(&devfreq->dev);
36704 if (err) {
36705 put_device(&devfreq->dev);
36706 @@ -588,7 +588,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
36707 goto err_out;
36708 }
36709
36710 - list_add(&governor->node, &devfreq_governor_list);
36711 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
36712
36713 list_for_each_entry(devfreq, &devfreq_list, node) {
36714 int ret = 0;
36715 @@ -676,7 +676,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
36716 }
36717 }
36718
36719 - list_del(&governor->node);
36720 + pax_list_del((struct list_head *)&governor->node);
36721 err_out:
36722 mutex_unlock(&devfreq_list_lock);
36723
36724 diff --git a/drivers/dma/sh/shdma.c b/drivers/dma/sh/shdma.c
36725 index b70709b..1d8d02a 100644
36726 --- a/drivers/dma/sh/shdma.c
36727 +++ b/drivers/dma/sh/shdma.c
36728 @@ -476,7 +476,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
36729 return ret;
36730 }
36731
36732 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
36733 +static struct notifier_block sh_dmae_nmi_notifier = {
36734 .notifier_call = sh_dmae_nmi_handler,
36735
36736 /* Run before NMI debug handler and KGDB */
36737 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
36738 index c4d700a..0b57abd 100644
36739 --- a/drivers/edac/edac_mc_sysfs.c
36740 +++ b/drivers/edac/edac_mc_sysfs.c
36741 @@ -148,7 +148,7 @@ static const char * const edac_caps[] = {
36742 struct dev_ch_attribute {
36743 struct device_attribute attr;
36744 int channel;
36745 -};
36746 +} __do_const;
36747
36748 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
36749 struct dev_ch_attribute dev_attr_legacy_##_name = \
36750 @@ -1005,14 +1005,16 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
36751 }
36752
36753 if (mci->set_sdram_scrub_rate || mci->get_sdram_scrub_rate) {
36754 + pax_open_kernel();
36755 if (mci->get_sdram_scrub_rate) {
36756 - dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
36757 - dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
36758 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
36759 + *(void **)&dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
36760 }
36761 if (mci->set_sdram_scrub_rate) {
36762 - dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
36763 - dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
36764 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
36765 + *(void **)&dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
36766 }
36767 + pax_close_kernel();
36768 err = device_create_file(&mci->dev,
36769 &dev_attr_sdram_scrub_rate);
36770 if (err) {
36771 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
36772 index e8658e4..22746d6 100644
36773 --- a/drivers/edac/edac_pci_sysfs.c
36774 +++ b/drivers/edac/edac_pci_sysfs.c
36775 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
36776 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
36777 static int edac_pci_poll_msec = 1000; /* one second workq period */
36778
36779 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
36780 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
36781 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
36782 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
36783
36784 static struct kobject *edac_pci_top_main_kobj;
36785 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
36786 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
36787 void *value;
36788 ssize_t(*show) (void *, char *);
36789 ssize_t(*store) (void *, const char *, size_t);
36790 -};
36791 +} __do_const;
36792
36793 /* Set of show/store abstract level functions for PCI Parity object */
36794 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
36795 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
36796 edac_printk(KERN_CRIT, EDAC_PCI,
36797 "Signaled System Error on %s\n",
36798 pci_name(dev));
36799 - atomic_inc(&pci_nonparity_count);
36800 + atomic_inc_unchecked(&pci_nonparity_count);
36801 }
36802
36803 if (status & (PCI_STATUS_PARITY)) {
36804 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
36805 "Master Data Parity Error on %s\n",
36806 pci_name(dev));
36807
36808 - atomic_inc(&pci_parity_count);
36809 + atomic_inc_unchecked(&pci_parity_count);
36810 }
36811
36812 if (status & (PCI_STATUS_DETECTED_PARITY)) {
36813 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
36814 "Detected Parity Error on %s\n",
36815 pci_name(dev));
36816
36817 - atomic_inc(&pci_parity_count);
36818 + atomic_inc_unchecked(&pci_parity_count);
36819 }
36820 }
36821
36822 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
36823 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
36824 "Signaled System Error on %s\n",
36825 pci_name(dev));
36826 - atomic_inc(&pci_nonparity_count);
36827 + atomic_inc_unchecked(&pci_nonparity_count);
36828 }
36829
36830 if (status & (PCI_STATUS_PARITY)) {
36831 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
36832 "Master Data Parity Error on "
36833 "%s\n", pci_name(dev));
36834
36835 - atomic_inc(&pci_parity_count);
36836 + atomic_inc_unchecked(&pci_parity_count);
36837 }
36838
36839 if (status & (PCI_STATUS_DETECTED_PARITY)) {
36840 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
36841 "Detected Parity Error on %s\n",
36842 pci_name(dev));
36843
36844 - atomic_inc(&pci_parity_count);
36845 + atomic_inc_unchecked(&pci_parity_count);
36846 }
36847 }
36848 }
36849 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
36850 if (!check_pci_errors)
36851 return;
36852
36853 - before_count = atomic_read(&pci_parity_count);
36854 + before_count = atomic_read_unchecked(&pci_parity_count);
36855
36856 /* scan all PCI devices looking for a Parity Error on devices and
36857 * bridges.
36858 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
36859 /* Only if operator has selected panic on PCI Error */
36860 if (edac_pci_get_panic_on_pe()) {
36861 /* If the count is different 'after' from 'before' */
36862 - if (before_count != atomic_read(&pci_parity_count))
36863 + if (before_count != atomic_read_unchecked(&pci_parity_count))
36864 panic("EDAC: PCI Parity Error");
36865 }
36866 }
36867 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
36868 index 51b7e3a..aa8a3e8 100644
36869 --- a/drivers/edac/mce_amd.h
36870 +++ b/drivers/edac/mce_amd.h
36871 @@ -77,7 +77,7 @@ struct amd_decoder_ops {
36872 bool (*mc0_mce)(u16, u8);
36873 bool (*mc1_mce)(u16, u8);
36874 bool (*mc2_mce)(u16, u8);
36875 -};
36876 +} __no_const;
36877
36878 void amd_report_gart_errors(bool);
36879 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
36880 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
36881 index 57ea7f4..789e3c3 100644
36882 --- a/drivers/firewire/core-card.c
36883 +++ b/drivers/firewire/core-card.c
36884 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
36885
36886 void fw_core_remove_card(struct fw_card *card)
36887 {
36888 - struct fw_card_driver dummy_driver = dummy_driver_template;
36889 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
36890
36891 card->driver->update_phy_reg(card, 4,
36892 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
36893 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
36894 index 664a6ff..af13580 100644
36895 --- a/drivers/firewire/core-device.c
36896 +++ b/drivers/firewire/core-device.c
36897 @@ -232,7 +232,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
36898 struct config_rom_attribute {
36899 struct device_attribute attr;
36900 u32 key;
36901 -};
36902 +} __do_const;
36903
36904 static ssize_t show_immediate(struct device *dev,
36905 struct device_attribute *dattr, char *buf)
36906 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
36907 index 28a94c7..58da63a 100644
36908 --- a/drivers/firewire/core-transaction.c
36909 +++ b/drivers/firewire/core-transaction.c
36910 @@ -38,6 +38,7 @@
36911 #include <linux/timer.h>
36912 #include <linux/types.h>
36913 #include <linux/workqueue.h>
36914 +#include <linux/sched.h>
36915
36916 #include <asm/byteorder.h>
36917
36918 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
36919 index 515a42c..5ecf3ba 100644
36920 --- a/drivers/firewire/core.h
36921 +++ b/drivers/firewire/core.h
36922 @@ -111,6 +111,7 @@ struct fw_card_driver {
36923
36924 int (*stop_iso)(struct fw_iso_context *ctx);
36925 };
36926 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
36927
36928 void fw_card_initialize(struct fw_card *card,
36929 const struct fw_card_driver *driver, struct device *device);
36930 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
36931 index 94a58a0..f5eba42 100644
36932 --- a/drivers/firmware/dmi-id.c
36933 +++ b/drivers/firmware/dmi-id.c
36934 @@ -16,7 +16,7 @@
36935 struct dmi_device_attribute{
36936 struct device_attribute dev_attr;
36937 int field;
36938 -};
36939 +} __do_const;
36940 #define to_dmi_dev_attr(_dev_attr) \
36941 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
36942
36943 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
36944 index b95159b..841ae55 100644
36945 --- a/drivers/firmware/dmi_scan.c
36946 +++ b/drivers/firmware/dmi_scan.c
36947 @@ -497,11 +497,6 @@ void __init dmi_scan_machine(void)
36948 }
36949 }
36950 else {
36951 - /*
36952 - * no iounmap() for that ioremap(); it would be a no-op, but
36953 - * it's so early in setup that sucker gets confused into doing
36954 - * what it shouldn't if we actually call it.
36955 - */
36956 p = dmi_ioremap(0xF0000, 0x10000);
36957 if (p == NULL)
36958 goto error;
36959 @@ -786,7 +781,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
36960 if (buf == NULL)
36961 return -1;
36962
36963 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
36964 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
36965
36966 iounmap(buf);
36967 return 0;
36968 diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
36969 index 5145fa3..0d3babd 100644
36970 --- a/drivers/firmware/efi/efi.c
36971 +++ b/drivers/firmware/efi/efi.c
36972 @@ -65,14 +65,16 @@ static struct attribute_group efi_subsys_attr_group = {
36973 };
36974
36975 static struct efivars generic_efivars;
36976 -static struct efivar_operations generic_ops;
36977 +static efivar_operations_no_const generic_ops __read_only;
36978
36979 static int generic_ops_register(void)
36980 {
36981 - generic_ops.get_variable = efi.get_variable;
36982 - generic_ops.set_variable = efi.set_variable;
36983 - generic_ops.get_next_variable = efi.get_next_variable;
36984 - generic_ops.query_variable_store = efi_query_variable_store;
36985 + pax_open_kernel();
36986 + *(void **)&generic_ops.get_variable = efi.get_variable;
36987 + *(void **)&generic_ops.set_variable = efi.set_variable;
36988 + *(void **)&generic_ops.get_next_variable = efi.get_next_variable;
36989 + *(void **)&generic_ops.query_variable_store = efi_query_variable_store;
36990 + pax_close_kernel();
36991
36992 return efivars_register(&generic_efivars, &generic_ops, efi_kobj);
36993 }
36994 diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
36995 index 8bd1bb6..c48b0c6 100644
36996 --- a/drivers/firmware/efi/efivars.c
36997 +++ b/drivers/firmware/efi/efivars.c
36998 @@ -452,7 +452,7 @@ efivar_create_sysfs_entry(struct efivar_entry *new_var)
36999 static int
37000 create_efivars_bin_attributes(void)
37001 {
37002 - struct bin_attribute *attr;
37003 + bin_attribute_no_const *attr;
37004 int error;
37005
37006 /* new_var */
37007 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
37008 index 2a90ba6..07f3733 100644
37009 --- a/drivers/firmware/google/memconsole.c
37010 +++ b/drivers/firmware/google/memconsole.c
37011 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
37012 if (!found_memconsole())
37013 return -ENODEV;
37014
37015 - memconsole_bin_attr.size = memconsole_length;
37016 + pax_open_kernel();
37017 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
37018 + pax_close_kernel();
37019
37020 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
37021
37022 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
37023 index e16d932..f0206ef 100644
37024 --- a/drivers/gpio/gpio-ich.c
37025 +++ b/drivers/gpio/gpio-ich.c
37026 @@ -69,7 +69,7 @@ struct ichx_desc {
37027 /* Some chipsets have quirks, let these use their own request/get */
37028 int (*request)(struct gpio_chip *chip, unsigned offset);
37029 int (*get)(struct gpio_chip *chip, unsigned offset);
37030 -};
37031 +} __do_const;
37032
37033 static struct {
37034 spinlock_t lock;
37035 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
37036 index 9902732..64b62dd 100644
37037 --- a/drivers/gpio/gpio-vr41xx.c
37038 +++ b/drivers/gpio/gpio-vr41xx.c
37039 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
37040 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
37041 maskl, pendl, maskh, pendh);
37042
37043 - atomic_inc(&irq_err_count);
37044 + atomic_inc_unchecked(&irq_err_count);
37045
37046 return -EINVAL;
37047 }
37048 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
37049 index ed1334e..ee0dd42 100644
37050 --- a/drivers/gpu/drm/drm_crtc_helper.c
37051 +++ b/drivers/gpu/drm/drm_crtc_helper.c
37052 @@ -321,7 +321,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
37053 struct drm_crtc *tmp;
37054 int crtc_mask = 1;
37055
37056 - WARN(!crtc, "checking null crtc?\n");
37057 + BUG_ON(!crtc);
37058
37059 dev = crtc->dev;
37060
37061 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
37062 index 9cc247f..36aa285 100644
37063 --- a/drivers/gpu/drm/drm_drv.c
37064 +++ b/drivers/gpu/drm/drm_drv.c
37065 @@ -306,7 +306,7 @@ module_exit(drm_core_exit);
37066 /**
37067 * Copy and IOCTL return string to user space
37068 */
37069 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
37070 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
37071 {
37072 int len;
37073
37074 @@ -376,7 +376,7 @@ long drm_ioctl(struct file *filp,
37075 struct drm_file *file_priv = filp->private_data;
37076 struct drm_device *dev;
37077 const struct drm_ioctl_desc *ioctl = NULL;
37078 - drm_ioctl_t *func;
37079 + drm_ioctl_no_const_t func;
37080 unsigned int nr = DRM_IOCTL_NR(cmd);
37081 int retcode = -EINVAL;
37082 char stack_kdata[128];
37083 @@ -389,7 +389,7 @@ long drm_ioctl(struct file *filp,
37084 return -ENODEV;
37085
37086 atomic_inc(&dev->ioctl_count);
37087 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
37088 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
37089 ++file_priv->ioctl_count;
37090
37091 if ((nr >= DRM_CORE_IOCTL_COUNT) &&
37092 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
37093 index 429e07d..e681a2c 100644
37094 --- a/drivers/gpu/drm/drm_fops.c
37095 +++ b/drivers/gpu/drm/drm_fops.c
37096 @@ -71,7 +71,7 @@ static int drm_setup(struct drm_device * dev)
37097 }
37098
37099 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
37100 - atomic_set(&dev->counts[i], 0);
37101 + atomic_set_unchecked(&dev->counts[i], 0);
37102
37103 dev->sigdata.lock = NULL;
37104
37105 @@ -135,7 +135,7 @@ int drm_open(struct inode *inode, struct file *filp)
37106 if (drm_device_is_unplugged(dev))
37107 return -ENODEV;
37108
37109 - if (!dev->open_count++)
37110 + if (local_inc_return(&dev->open_count) == 1)
37111 need_setup = 1;
37112 mutex_lock(&dev->struct_mutex);
37113 old_imapping = inode->i_mapping;
37114 @@ -151,7 +151,7 @@ int drm_open(struct inode *inode, struct file *filp)
37115 retcode = drm_open_helper(inode, filp, dev);
37116 if (retcode)
37117 goto err_undo;
37118 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
37119 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
37120 if (need_setup) {
37121 retcode = drm_setup(dev);
37122 if (retcode)
37123 @@ -166,7 +166,7 @@ err_undo:
37124 iput(container_of(dev->dev_mapping, struct inode, i_data));
37125 dev->dev_mapping = old_mapping;
37126 mutex_unlock(&dev->struct_mutex);
37127 - dev->open_count--;
37128 + local_dec(&dev->open_count);
37129 return retcode;
37130 }
37131 EXPORT_SYMBOL(drm_open);
37132 @@ -441,7 +441,7 @@ int drm_release(struct inode *inode, struct file *filp)
37133
37134 mutex_lock(&drm_global_mutex);
37135
37136 - DRM_DEBUG("open_count = %d\n", dev->open_count);
37137 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
37138
37139 if (dev->driver->preclose)
37140 dev->driver->preclose(dev, file_priv);
37141 @@ -450,10 +450,10 @@ int drm_release(struct inode *inode, struct file *filp)
37142 * Begin inline drm_release
37143 */
37144
37145 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
37146 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
37147 task_pid_nr(current),
37148 (long)old_encode_dev(file_priv->minor->device),
37149 - dev->open_count);
37150 + local_read(&dev->open_count));
37151
37152 /* Release any auth tokens that might point to this file_priv,
37153 (do that under the drm_global_mutex) */
37154 @@ -550,8 +550,8 @@ int drm_release(struct inode *inode, struct file *filp)
37155 * End inline drm_release
37156 */
37157
37158 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
37159 - if (!--dev->open_count) {
37160 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
37161 + if (local_dec_and_test(&dev->open_count)) {
37162 if (atomic_read(&dev->ioctl_count)) {
37163 DRM_ERROR("Device busy: %d\n",
37164 atomic_read(&dev->ioctl_count));
37165 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
37166 index f731116..629842c 100644
37167 --- a/drivers/gpu/drm/drm_global.c
37168 +++ b/drivers/gpu/drm/drm_global.c
37169 @@ -36,7 +36,7 @@
37170 struct drm_global_item {
37171 struct mutex mutex;
37172 void *object;
37173 - int refcount;
37174 + atomic_t refcount;
37175 };
37176
37177 static struct drm_global_item glob[DRM_GLOBAL_NUM];
37178 @@ -49,7 +49,7 @@ void drm_global_init(void)
37179 struct drm_global_item *item = &glob[i];
37180 mutex_init(&item->mutex);
37181 item->object = NULL;
37182 - item->refcount = 0;
37183 + atomic_set(&item->refcount, 0);
37184 }
37185 }
37186
37187 @@ -59,7 +59,7 @@ void drm_global_release(void)
37188 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
37189 struct drm_global_item *item = &glob[i];
37190 BUG_ON(item->object != NULL);
37191 - BUG_ON(item->refcount != 0);
37192 + BUG_ON(atomic_read(&item->refcount) != 0);
37193 }
37194 }
37195
37196 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
37197 void *object;
37198
37199 mutex_lock(&item->mutex);
37200 - if (item->refcount == 0) {
37201 + if (atomic_read(&item->refcount) == 0) {
37202 item->object = kzalloc(ref->size, GFP_KERNEL);
37203 if (unlikely(item->object == NULL)) {
37204 ret = -ENOMEM;
37205 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
37206 goto out_err;
37207
37208 }
37209 - ++item->refcount;
37210 + atomic_inc(&item->refcount);
37211 ref->object = item->object;
37212 object = item->object;
37213 mutex_unlock(&item->mutex);
37214 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
37215 struct drm_global_item *item = &glob[ref->global_type];
37216
37217 mutex_lock(&item->mutex);
37218 - BUG_ON(item->refcount == 0);
37219 + BUG_ON(atomic_read(&item->refcount) == 0);
37220 BUG_ON(ref->object != item->object);
37221 - if (--item->refcount == 0) {
37222 + if (atomic_dec_and_test(&item->refcount)) {
37223 ref->release(ref);
37224 item->object = NULL;
37225 }
37226 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
37227 index d4b20ce..77a8d41 100644
37228 --- a/drivers/gpu/drm/drm_info.c
37229 +++ b/drivers/gpu/drm/drm_info.c
37230 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
37231 struct drm_local_map *map;
37232 struct drm_map_list *r_list;
37233
37234 - /* Hardcoded from _DRM_FRAME_BUFFER,
37235 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
37236 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
37237 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
37238 + static const char * const types[] = {
37239 + [_DRM_FRAME_BUFFER] = "FB",
37240 + [_DRM_REGISTERS] = "REG",
37241 + [_DRM_SHM] = "SHM",
37242 + [_DRM_AGP] = "AGP",
37243 + [_DRM_SCATTER_GATHER] = "SG",
37244 + [_DRM_CONSISTENT] = "PCI",
37245 + [_DRM_GEM] = "GEM" };
37246 const char *type;
37247 int i;
37248
37249 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
37250 map = r_list->map;
37251 if (!map)
37252 continue;
37253 - if (map->type < 0 || map->type > 5)
37254 + if (map->type >= ARRAY_SIZE(types))
37255 type = "??";
37256 else
37257 type = types[map->type];
37258 @@ -253,7 +257,11 @@ int drm_vma_info(struct seq_file *m, void *data)
37259 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
37260 vma->vm_flags & VM_LOCKED ? 'l' : '-',
37261 vma->vm_flags & VM_IO ? 'i' : '-',
37262 +#ifdef CONFIG_GRKERNSEC_HIDESYM
37263 + 0);
37264 +#else
37265 vma->vm_pgoff);
37266 +#endif
37267
37268 #if defined(__i386__)
37269 pgprot = pgprot_val(vma->vm_page_prot);
37270 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
37271 index 2f4c434..dd12cd2 100644
37272 --- a/drivers/gpu/drm/drm_ioc32.c
37273 +++ b/drivers/gpu/drm/drm_ioc32.c
37274 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
37275 request = compat_alloc_user_space(nbytes);
37276 if (!access_ok(VERIFY_WRITE, request, nbytes))
37277 return -EFAULT;
37278 - list = (struct drm_buf_desc *) (request + 1);
37279 + list = (struct drm_buf_desc __user *) (request + 1);
37280
37281 if (__put_user(count, &request->count)
37282 || __put_user(list, &request->list))
37283 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
37284 request = compat_alloc_user_space(nbytes);
37285 if (!access_ok(VERIFY_WRITE, request, nbytes))
37286 return -EFAULT;
37287 - list = (struct drm_buf_pub *) (request + 1);
37288 + list = (struct drm_buf_pub __user *) (request + 1);
37289
37290 if (__put_user(count, &request->count)
37291 || __put_user(list, &request->list))
37292 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
37293 return 0;
37294 }
37295
37296 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
37297 +drm_ioctl_compat_t drm_compat_ioctls[] = {
37298 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
37299 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
37300 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
37301 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
37302 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
37303 {
37304 unsigned int nr = DRM_IOCTL_NR(cmd);
37305 - drm_ioctl_compat_t *fn;
37306 int ret;
37307
37308 /* Assume that ioctls without an explicit compat routine will just
37309 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
37310 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
37311 return drm_ioctl(filp, cmd, arg);
37312
37313 - fn = drm_compat_ioctls[nr];
37314 -
37315 - if (fn != NULL)
37316 - ret = (*fn) (filp, cmd, arg);
37317 + if (drm_compat_ioctls[nr] != NULL)
37318 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
37319 else
37320 ret = drm_ioctl(filp, cmd, arg);
37321
37322 diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
37323 index e77bd8b..1571b85 100644
37324 --- a/drivers/gpu/drm/drm_ioctl.c
37325 +++ b/drivers/gpu/drm/drm_ioctl.c
37326 @@ -252,7 +252,7 @@ int drm_getstats(struct drm_device *dev, void *data,
37327 stats->data[i].value =
37328 (file_priv->master->lock.hw_lock ? file_priv->master->lock.hw_lock->lock : 0);
37329 else
37330 - stats->data[i].value = atomic_read(&dev->counts[i]);
37331 + stats->data[i].value = atomic_read_unchecked(&dev->counts[i]);
37332 stats->data[i].type = dev->types[i];
37333 }
37334
37335 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
37336 index d752c96..fe08455 100644
37337 --- a/drivers/gpu/drm/drm_lock.c
37338 +++ b/drivers/gpu/drm/drm_lock.c
37339 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
37340 if (drm_lock_take(&master->lock, lock->context)) {
37341 master->lock.file_priv = file_priv;
37342 master->lock.lock_time = jiffies;
37343 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
37344 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
37345 break; /* Got lock */
37346 }
37347
37348 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
37349 return -EINVAL;
37350 }
37351
37352 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
37353 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
37354
37355 if (drm_lock_free(&master->lock, lock->context)) {
37356 /* FIXME: Should really bail out here. */
37357 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
37358 index 16f3ec5..b28f9ca 100644
37359 --- a/drivers/gpu/drm/drm_stub.c
37360 +++ b/drivers/gpu/drm/drm_stub.c
37361 @@ -501,7 +501,7 @@ void drm_unplug_dev(struct drm_device *dev)
37362
37363 drm_device_set_unplugged(dev);
37364
37365 - if (dev->open_count == 0) {
37366 + if (local_read(&dev->open_count) == 0) {
37367 drm_put_dev(dev);
37368 }
37369 mutex_unlock(&drm_global_mutex);
37370 diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
37371 index 0229665..f61329c 100644
37372 --- a/drivers/gpu/drm/drm_sysfs.c
37373 +++ b/drivers/gpu/drm/drm_sysfs.c
37374 @@ -499,7 +499,7 @@ EXPORT_SYMBOL(drm_sysfs_hotplug_event);
37375 int drm_sysfs_device_add(struct drm_minor *minor)
37376 {
37377 int err;
37378 - char *minor_str;
37379 + const char *minor_str;
37380
37381 minor->kdev.parent = minor->dev->dev;
37382
37383 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
37384 index 004ecdf..db1f6e0 100644
37385 --- a/drivers/gpu/drm/i810/i810_dma.c
37386 +++ b/drivers/gpu/drm/i810/i810_dma.c
37387 @@ -945,8 +945,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
37388 dma->buflist[vertex->idx],
37389 vertex->discard, vertex->used);
37390
37391 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
37392 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
37393 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
37394 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
37395 sarea_priv->last_enqueue = dev_priv->counter - 1;
37396 sarea_priv->last_dispatch = (int)hw_status[5];
37397
37398 @@ -1106,8 +1106,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
37399 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
37400 mc->last_render);
37401
37402 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
37403 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
37404 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
37405 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
37406 sarea_priv->last_enqueue = dev_priv->counter - 1;
37407 sarea_priv->last_dispatch = (int)hw_status[5];
37408
37409 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
37410 index 6e0acad..93c8289 100644
37411 --- a/drivers/gpu/drm/i810/i810_drv.h
37412 +++ b/drivers/gpu/drm/i810/i810_drv.h
37413 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
37414 int page_flipping;
37415
37416 wait_queue_head_t irq_queue;
37417 - atomic_t irq_received;
37418 - atomic_t irq_emitted;
37419 + atomic_unchecked_t irq_received;
37420 + atomic_unchecked_t irq_emitted;
37421
37422 int front_offset;
37423 } drm_i810_private_t;
37424 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
37425 index e913d32..4d9b351 100644
37426 --- a/drivers/gpu/drm/i915/i915_debugfs.c
37427 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
37428 @@ -499,7 +499,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
37429 I915_READ(GTIMR));
37430 }
37431 seq_printf(m, "Interrupts received: %d\n",
37432 - atomic_read(&dev_priv->irq_received));
37433 + atomic_read_unchecked(&dev_priv->irq_received));
37434 for_each_ring(ring, dev_priv, i) {
37435 if (IS_GEN6(dev) || IS_GEN7(dev)) {
37436 seq_printf(m,
37437 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
37438 index 17d9b0b..860e6d9 100644
37439 --- a/drivers/gpu/drm/i915/i915_dma.c
37440 +++ b/drivers/gpu/drm/i915/i915_dma.c
37441 @@ -1259,7 +1259,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
37442 bool can_switch;
37443
37444 spin_lock(&dev->count_lock);
37445 - can_switch = (dev->open_count == 0);
37446 + can_switch = (local_read(&dev->open_count) == 0);
37447 spin_unlock(&dev->count_lock);
37448 return can_switch;
37449 }
37450 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
37451 index 47d8b68..52f5d8d 100644
37452 --- a/drivers/gpu/drm/i915/i915_drv.h
37453 +++ b/drivers/gpu/drm/i915/i915_drv.h
37454 @@ -916,7 +916,7 @@ typedef struct drm_i915_private {
37455 drm_dma_handle_t *status_page_dmah;
37456 struct resource mch_res;
37457
37458 - atomic_t irq_received;
37459 + atomic_unchecked_t irq_received;
37460
37461 /* protects the irq masks */
37462 spinlock_t irq_lock;
37463 @@ -1813,7 +1813,7 @@ extern struct i2c_adapter *intel_gmbus_get_adapter(
37464 struct drm_i915_private *dev_priv, unsigned port);
37465 extern void intel_gmbus_set_speed(struct i2c_adapter *adapter, int speed);
37466 extern void intel_gmbus_force_bit(struct i2c_adapter *adapter, bool force_bit);
37467 -extern inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
37468 +static inline bool intel_gmbus_is_forced_bit(struct i2c_adapter *adapter)
37469 {
37470 return container_of(adapter, struct intel_gmbus, adapter)->force_bit;
37471 }
37472 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
37473 index 117ce38..eefd237 100644
37474 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
37475 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
37476 @@ -727,9 +727,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
37477
37478 static int
37479 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
37480 - int count)
37481 + unsigned int count)
37482 {
37483 - int i;
37484 + unsigned int i;
37485 int relocs_total = 0;
37486 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
37487
37488 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
37489 index 3c59584..500f2e9 100644
37490 --- a/drivers/gpu/drm/i915/i915_ioc32.c
37491 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
37492 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
37493 (unsigned long)request);
37494 }
37495
37496 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
37497 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
37498 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
37499 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
37500 [DRM_I915_GETPARAM] = compat_i915_getparam,
37501 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
37502 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
37503 {
37504 unsigned int nr = DRM_IOCTL_NR(cmd);
37505 - drm_ioctl_compat_t *fn = NULL;
37506 int ret;
37507
37508 if (nr < DRM_COMMAND_BASE)
37509 return drm_compat_ioctl(filp, cmd, arg);
37510
37511 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
37512 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
37513 -
37514 - if (fn != NULL)
37515 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
37516 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
37517 ret = (*fn) (filp, cmd, arg);
37518 - else
37519 + } else
37520 ret = drm_ioctl(filp, cmd, arg);
37521
37522 return ret;
37523 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
37524 index e5e32869..1678f36 100644
37525 --- a/drivers/gpu/drm/i915/i915_irq.c
37526 +++ b/drivers/gpu/drm/i915/i915_irq.c
37527 @@ -670,7 +670,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
37528 int pipe;
37529 u32 pipe_stats[I915_MAX_PIPES];
37530
37531 - atomic_inc(&dev_priv->irq_received);
37532 + atomic_inc_unchecked(&dev_priv->irq_received);
37533
37534 while (true) {
37535 iir = I915_READ(VLV_IIR);
37536 @@ -835,7 +835,7 @@ static irqreturn_t ivybridge_irq_handler(int irq, void *arg)
37537 irqreturn_t ret = IRQ_NONE;
37538 int i;
37539
37540 - atomic_inc(&dev_priv->irq_received);
37541 + atomic_inc_unchecked(&dev_priv->irq_received);
37542
37543 /* disable master interrupt before clearing iir */
37544 de_ier = I915_READ(DEIER);
37545 @@ -925,7 +925,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
37546 int ret = IRQ_NONE;
37547 u32 de_iir, gt_iir, de_ier, pm_iir, sde_ier;
37548
37549 - atomic_inc(&dev_priv->irq_received);
37550 + atomic_inc_unchecked(&dev_priv->irq_received);
37551
37552 /* disable master interrupt before clearing iir */
37553 de_ier = I915_READ(DEIER);
37554 @@ -2089,7 +2089,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
37555 {
37556 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
37557
37558 - atomic_set(&dev_priv->irq_received, 0);
37559 + atomic_set_unchecked(&dev_priv->irq_received, 0);
37560
37561 I915_WRITE(HWSTAM, 0xeffe);
37562
37563 @@ -2124,7 +2124,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
37564 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
37565 int pipe;
37566
37567 - atomic_set(&dev_priv->irq_received, 0);
37568 + atomic_set_unchecked(&dev_priv->irq_received, 0);
37569
37570 /* VLV magic */
37571 I915_WRITE(VLV_IMR, 0);
37572 @@ -2411,7 +2411,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
37573 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
37574 int pipe;
37575
37576 - atomic_set(&dev_priv->irq_received, 0);
37577 + atomic_set_unchecked(&dev_priv->irq_received, 0);
37578
37579 for_each_pipe(pipe)
37580 I915_WRITE(PIPESTAT(pipe), 0);
37581 @@ -2490,7 +2490,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
37582 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
37583 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
37584
37585 - atomic_inc(&dev_priv->irq_received);
37586 + atomic_inc_unchecked(&dev_priv->irq_received);
37587
37588 iir = I915_READ16(IIR);
37589 if (iir == 0)
37590 @@ -2565,7 +2565,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
37591 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
37592 int pipe;
37593
37594 - atomic_set(&dev_priv->irq_received, 0);
37595 + atomic_set_unchecked(&dev_priv->irq_received, 0);
37596
37597 if (I915_HAS_HOTPLUG(dev)) {
37598 I915_WRITE(PORT_HOTPLUG_EN, 0);
37599 @@ -2664,7 +2664,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
37600 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
37601 int pipe, ret = IRQ_NONE;
37602
37603 - atomic_inc(&dev_priv->irq_received);
37604 + atomic_inc_unchecked(&dev_priv->irq_received);
37605
37606 iir = I915_READ(IIR);
37607 do {
37608 @@ -2791,7 +2791,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
37609 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
37610 int pipe;
37611
37612 - atomic_set(&dev_priv->irq_received, 0);
37613 + atomic_set_unchecked(&dev_priv->irq_received, 0);
37614
37615 I915_WRITE(PORT_HOTPLUG_EN, 0);
37616 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
37617 @@ -2898,7 +2898,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
37618 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
37619 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
37620
37621 - atomic_inc(&dev_priv->irq_received);
37622 + atomic_inc_unchecked(&dev_priv->irq_received);
37623
37624 iir = I915_READ(IIR);
37625
37626 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
37627 index eea5982..eeef407 100644
37628 --- a/drivers/gpu/drm/i915/intel_display.c
37629 +++ b/drivers/gpu/drm/i915/intel_display.c
37630 @@ -8935,13 +8935,13 @@ struct intel_quirk {
37631 int subsystem_vendor;
37632 int subsystem_device;
37633 void (*hook)(struct drm_device *dev);
37634 -};
37635 +} __do_const;
37636
37637 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
37638 struct intel_dmi_quirk {
37639 void (*hook)(struct drm_device *dev);
37640 const struct dmi_system_id (*dmi_id_list)[];
37641 -};
37642 +} __do_const;
37643
37644 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
37645 {
37646 @@ -8949,18 +8949,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
37647 return 1;
37648 }
37649
37650 -static const struct intel_dmi_quirk intel_dmi_quirks[] = {
37651 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
37652 {
37653 - .dmi_id_list = &(const struct dmi_system_id[]) {
37654 - {
37655 - .callback = intel_dmi_reverse_brightness,
37656 - .ident = "NCR Corporation",
37657 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
37658 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
37659 - },
37660 - },
37661 - { } /* terminating entry */
37662 + .callback = intel_dmi_reverse_brightness,
37663 + .ident = "NCR Corporation",
37664 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
37665 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
37666 },
37667 + },
37668 + { } /* terminating entry */
37669 +};
37670 +
37671 +static const struct intel_dmi_quirk intel_dmi_quirks[] = {
37672 + {
37673 + .dmi_id_list = &intel_dmi_quirks_table,
37674 .hook = quirk_invert_brightness,
37675 },
37676 };
37677 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
37678 index 54558a0..2d97005 100644
37679 --- a/drivers/gpu/drm/mga/mga_drv.h
37680 +++ b/drivers/gpu/drm/mga/mga_drv.h
37681 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
37682 u32 clear_cmd;
37683 u32 maccess;
37684
37685 - atomic_t vbl_received; /**< Number of vblanks received. */
37686 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
37687 wait_queue_head_t fence_queue;
37688 - atomic_t last_fence_retired;
37689 + atomic_unchecked_t last_fence_retired;
37690 u32 next_fence_to_post;
37691
37692 unsigned int fb_cpp;
37693 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
37694 index 709e90d..89a1c0d 100644
37695 --- a/drivers/gpu/drm/mga/mga_ioc32.c
37696 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
37697 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
37698 return 0;
37699 }
37700
37701 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
37702 +drm_ioctl_compat_t mga_compat_ioctls[] = {
37703 [DRM_MGA_INIT] = compat_mga_init,
37704 [DRM_MGA_GETPARAM] = compat_mga_getparam,
37705 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
37706 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
37707 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
37708 {
37709 unsigned int nr = DRM_IOCTL_NR(cmd);
37710 - drm_ioctl_compat_t *fn = NULL;
37711 int ret;
37712
37713 if (nr < DRM_COMMAND_BASE)
37714 return drm_compat_ioctl(filp, cmd, arg);
37715
37716 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
37717 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
37718 -
37719 - if (fn != NULL)
37720 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
37721 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
37722 ret = (*fn) (filp, cmd, arg);
37723 - else
37724 + } else
37725 ret = drm_ioctl(filp, cmd, arg);
37726
37727 return ret;
37728 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
37729 index 598c281..60d590e 100644
37730 --- a/drivers/gpu/drm/mga/mga_irq.c
37731 +++ b/drivers/gpu/drm/mga/mga_irq.c
37732 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
37733 if (crtc != 0)
37734 return 0;
37735
37736 - return atomic_read(&dev_priv->vbl_received);
37737 + return atomic_read_unchecked(&dev_priv->vbl_received);
37738 }
37739
37740
37741 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
37742 /* VBLANK interrupt */
37743 if (status & MGA_VLINEPEN) {
37744 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
37745 - atomic_inc(&dev_priv->vbl_received);
37746 + atomic_inc_unchecked(&dev_priv->vbl_received);
37747 drm_handle_vblank(dev, 0);
37748 handled = 1;
37749 }
37750 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
37751 if ((prim_start & ~0x03) != (prim_end & ~0x03))
37752 MGA_WRITE(MGA_PRIMEND, prim_end);
37753
37754 - atomic_inc(&dev_priv->last_fence_retired);
37755 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
37756 DRM_WAKEUP(&dev_priv->fence_queue);
37757 handled = 1;
37758 }
37759 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
37760 * using fences.
37761 */
37762 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
37763 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
37764 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
37765 - *sequence) <= (1 << 23)));
37766
37767 *sequence = cur_fence;
37768 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
37769 index 6aa2137..fe8dc55 100644
37770 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
37771 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
37772 @@ -965,7 +965,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
37773 struct bit_table {
37774 const char id;
37775 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
37776 -};
37777 +} __no_const;
37778
37779 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
37780
37781 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
37782 index f2b30f8..d0f9a95 100644
37783 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
37784 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
37785 @@ -92,7 +92,7 @@ struct nouveau_drm {
37786 struct drm_global_reference mem_global_ref;
37787 struct ttm_bo_global_ref bo_global_ref;
37788 struct ttm_bo_device bdev;
37789 - atomic_t validate_sequence;
37790 + atomic_unchecked_t validate_sequence;
37791 int (*move)(struct nouveau_channel *,
37792 struct ttm_buffer_object *,
37793 struct ttm_mem_reg *, struct ttm_mem_reg *);
37794 diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
37795 index b4b4d0c..b7edc15 100644
37796 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c
37797 +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
37798 @@ -322,7 +322,7 @@ validate_init(struct nouveau_channel *chan, struct drm_file *file_priv,
37799 int ret, i;
37800 struct nouveau_bo *res_bo = NULL;
37801
37802 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
37803 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
37804 retry:
37805 if (++trycnt > 100000) {
37806 NV_ERROR(cli, "%s failed and gave up.\n", __func__);
37807 @@ -359,7 +359,7 @@ retry:
37808 if (ret) {
37809 validate_fini(op, NULL);
37810 if (unlikely(ret == -EAGAIN)) {
37811 - sequence = atomic_add_return(1, &drm->ttm.validate_sequence);
37812 + sequence = atomic_add_return_unchecked(1, &drm->ttm.validate_sequence);
37813 ret = ttm_bo_reserve_slowpath(&nvbo->bo, true,
37814 sequence);
37815 if (!ret)
37816 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
37817 index 08214bc..9208577 100644
37818 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
37819 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
37820 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
37821 unsigned long arg)
37822 {
37823 unsigned int nr = DRM_IOCTL_NR(cmd);
37824 - drm_ioctl_compat_t *fn = NULL;
37825 + drm_ioctl_compat_t fn = NULL;
37826 int ret;
37827
37828 if (nr < DRM_COMMAND_BASE)
37829 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
37830 index 25d3495..d81aaf6 100644
37831 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
37832 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
37833 @@ -62,7 +62,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
37834 bool can_switch;
37835
37836 spin_lock(&dev->count_lock);
37837 - can_switch = (dev->open_count == 0);
37838 + can_switch = (local_read(&dev->open_count) == 0);
37839 spin_unlock(&dev->count_lock);
37840 return can_switch;
37841 }
37842 diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
37843 index 489cb8c..0b8d0d3 100644
37844 --- a/drivers/gpu/drm/qxl/qxl_ttm.c
37845 +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
37846 @@ -103,7 +103,7 @@ static void qxl_ttm_global_fini(struct qxl_device *qdev)
37847 }
37848 }
37849
37850 -static struct vm_operations_struct qxl_ttm_vm_ops;
37851 +static vm_operations_struct_no_const qxl_ttm_vm_ops __read_only;
37852 static const struct vm_operations_struct *ttm_vm_ops;
37853
37854 static int qxl_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
37855 @@ -147,8 +147,10 @@ int qxl_mmap(struct file *filp, struct vm_area_struct *vma)
37856 return r;
37857 if (unlikely(ttm_vm_ops == NULL)) {
37858 ttm_vm_ops = vma->vm_ops;
37859 + pax_open_kernel();
37860 qxl_ttm_vm_ops = *ttm_vm_ops;
37861 qxl_ttm_vm_ops.fault = &qxl_ttm_fault;
37862 + pax_close_kernel();
37863 }
37864 vma->vm_ops = &qxl_ttm_vm_ops;
37865 return 0;
37866 @@ -556,25 +558,23 @@ static int qxl_mm_dump_table(struct seq_file *m, void *data)
37867 static int qxl_ttm_debugfs_init(struct qxl_device *qdev)
37868 {
37869 #if defined(CONFIG_DEBUG_FS)
37870 - static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES];
37871 - static char qxl_mem_types_names[QXL_DEBUGFS_MEM_TYPES][32];
37872 - unsigned i;
37873 + static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES] = {
37874 + {
37875 + .name = "qxl_mem_mm",
37876 + .show = &qxl_mm_dump_table,
37877 + },
37878 + {
37879 + .name = "qxl_surf_mm",
37880 + .show = &qxl_mm_dump_table,
37881 + }
37882 + };
37883
37884 - for (i = 0; i < QXL_DEBUGFS_MEM_TYPES; i++) {
37885 - if (i == 0)
37886 - sprintf(qxl_mem_types_names[i], "qxl_mem_mm");
37887 - else
37888 - sprintf(qxl_mem_types_names[i], "qxl_surf_mm");
37889 - qxl_mem_types_list[i].name = qxl_mem_types_names[i];
37890 - qxl_mem_types_list[i].show = &qxl_mm_dump_table;
37891 - qxl_mem_types_list[i].driver_features = 0;
37892 - if (i == 0)
37893 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
37894 - else
37895 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
37896 + pax_open_kernel();
37897 + *(void **)&qxl_mem_types_list[0].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
37898 + *(void **)&qxl_mem_types_list[1].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
37899 + pax_close_kernel();
37900
37901 - }
37902 - return qxl_debugfs_add_files(qdev, qxl_mem_types_list, i);
37903 + return qxl_debugfs_add_files(qdev, qxl_mem_types_list, QXL_DEBUGFS_MEM_TYPES);
37904 #else
37905 return 0;
37906 #endif
37907 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
37908 index d4660cf..70dbe65 100644
37909 --- a/drivers/gpu/drm/r128/r128_cce.c
37910 +++ b/drivers/gpu/drm/r128/r128_cce.c
37911 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
37912
37913 /* GH: Simple idle check.
37914 */
37915 - atomic_set(&dev_priv->idle_count, 0);
37916 + atomic_set_unchecked(&dev_priv->idle_count, 0);
37917
37918 /* We don't support anything other than bus-mastering ring mode,
37919 * but the ring can be in either AGP or PCI space for the ring
37920 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
37921 index 930c71b..499aded 100644
37922 --- a/drivers/gpu/drm/r128/r128_drv.h
37923 +++ b/drivers/gpu/drm/r128/r128_drv.h
37924 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
37925 int is_pci;
37926 unsigned long cce_buffers_offset;
37927
37928 - atomic_t idle_count;
37929 + atomic_unchecked_t idle_count;
37930
37931 int page_flipping;
37932 int current_page;
37933 u32 crtc_offset;
37934 u32 crtc_offset_cntl;
37935
37936 - atomic_t vbl_received;
37937 + atomic_unchecked_t vbl_received;
37938
37939 u32 color_fmt;
37940 unsigned int front_offset;
37941 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
37942 index a954c54..9cc595c 100644
37943 --- a/drivers/gpu/drm/r128/r128_ioc32.c
37944 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
37945 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
37946 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
37947 }
37948
37949 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
37950 +drm_ioctl_compat_t r128_compat_ioctls[] = {
37951 [DRM_R128_INIT] = compat_r128_init,
37952 [DRM_R128_DEPTH] = compat_r128_depth,
37953 [DRM_R128_STIPPLE] = compat_r128_stipple,
37954 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
37955 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
37956 {
37957 unsigned int nr = DRM_IOCTL_NR(cmd);
37958 - drm_ioctl_compat_t *fn = NULL;
37959 int ret;
37960
37961 if (nr < DRM_COMMAND_BASE)
37962 return drm_compat_ioctl(filp, cmd, arg);
37963
37964 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
37965 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
37966 -
37967 - if (fn != NULL)
37968 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
37969 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
37970 ret = (*fn) (filp, cmd, arg);
37971 - else
37972 + } else
37973 ret = drm_ioctl(filp, cmd, arg);
37974
37975 return ret;
37976 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
37977 index 2ea4f09..d391371 100644
37978 --- a/drivers/gpu/drm/r128/r128_irq.c
37979 +++ b/drivers/gpu/drm/r128/r128_irq.c
37980 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
37981 if (crtc != 0)
37982 return 0;
37983
37984 - return atomic_read(&dev_priv->vbl_received);
37985 + return atomic_read_unchecked(&dev_priv->vbl_received);
37986 }
37987
37988 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
37989 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
37990 /* VBLANK interrupt */
37991 if (status & R128_CRTC_VBLANK_INT) {
37992 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
37993 - atomic_inc(&dev_priv->vbl_received);
37994 + atomic_inc_unchecked(&dev_priv->vbl_received);
37995 drm_handle_vblank(dev, 0);
37996 return IRQ_HANDLED;
37997 }
37998 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
37999 index 19bb7e6..de7e2a2 100644
38000 --- a/drivers/gpu/drm/r128/r128_state.c
38001 +++ b/drivers/gpu/drm/r128/r128_state.c
38002 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
38003
38004 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
38005 {
38006 - if (atomic_read(&dev_priv->idle_count) == 0)
38007 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
38008 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
38009 else
38010 - atomic_set(&dev_priv->idle_count, 0);
38011 + atomic_set_unchecked(&dev_priv->idle_count, 0);
38012 }
38013
38014 #endif
38015 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
38016 index 5a82b6b..9e69c73 100644
38017 --- a/drivers/gpu/drm/radeon/mkregtable.c
38018 +++ b/drivers/gpu/drm/radeon/mkregtable.c
38019 @@ -637,14 +637,14 @@ static int parser_auth(struct table *t, const char *filename)
38020 regex_t mask_rex;
38021 regmatch_t match[4];
38022 char buf[1024];
38023 - size_t end;
38024 + long end;
38025 int len;
38026 int done = 0;
38027 int r;
38028 unsigned o;
38029 struct offset *offset;
38030 char last_reg_s[10];
38031 - int last_reg;
38032 + unsigned long last_reg;
38033
38034 if (regcomp
38035 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
38036 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
38037 index b0dc0b6..a9bfe9c 100644
38038 --- a/drivers/gpu/drm/radeon/radeon_device.c
38039 +++ b/drivers/gpu/drm/radeon/radeon_device.c
38040 @@ -1014,7 +1014,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
38041 bool can_switch;
38042
38043 spin_lock(&dev->count_lock);
38044 - can_switch = (dev->open_count == 0);
38045 + can_switch = (local_read(&dev->open_count) == 0);
38046 spin_unlock(&dev->count_lock);
38047 return can_switch;
38048 }
38049 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
38050 index b369d42..8dd04eb 100644
38051 --- a/drivers/gpu/drm/radeon/radeon_drv.h
38052 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
38053 @@ -258,7 +258,7 @@ typedef struct drm_radeon_private {
38054
38055 /* SW interrupt */
38056 wait_queue_head_t swi_queue;
38057 - atomic_t swi_emitted;
38058 + atomic_unchecked_t swi_emitted;
38059 int vblank_crtc;
38060 uint32_t irq_enable_reg;
38061 uint32_t r500_disp_irq_reg;
38062 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
38063 index c180df8..5fd8186 100644
38064 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
38065 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
38066 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
38067 request = compat_alloc_user_space(sizeof(*request));
38068 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
38069 || __put_user(req32.param, &request->param)
38070 - || __put_user((void __user *)(unsigned long)req32.value,
38071 + || __put_user((unsigned long)req32.value,
38072 &request->value))
38073 return -EFAULT;
38074
38075 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
38076 #define compat_radeon_cp_setparam NULL
38077 #endif /* X86_64 || IA64 */
38078
38079 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
38080 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
38081 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
38082 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
38083 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
38084 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
38085 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38086 {
38087 unsigned int nr = DRM_IOCTL_NR(cmd);
38088 - drm_ioctl_compat_t *fn = NULL;
38089 int ret;
38090
38091 if (nr < DRM_COMMAND_BASE)
38092 return drm_compat_ioctl(filp, cmd, arg);
38093
38094 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
38095 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
38096 -
38097 - if (fn != NULL)
38098 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
38099 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
38100 ret = (*fn) (filp, cmd, arg);
38101 - else
38102 + } else
38103 ret = drm_ioctl(filp, cmd, arg);
38104
38105 return ret;
38106 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
38107 index 8d68e97..9dcfed8 100644
38108 --- a/drivers/gpu/drm/radeon/radeon_irq.c
38109 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
38110 @@ -226,8 +226,8 @@ static int radeon_emit_irq(struct drm_device * dev)
38111 unsigned int ret;
38112 RING_LOCALS;
38113
38114 - atomic_inc(&dev_priv->swi_emitted);
38115 - ret = atomic_read(&dev_priv->swi_emitted);
38116 + atomic_inc_unchecked(&dev_priv->swi_emitted);
38117 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
38118
38119 BEGIN_RING(4);
38120 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
38121 @@ -353,7 +353,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
38122 drm_radeon_private_t *dev_priv =
38123 (drm_radeon_private_t *) dev->dev_private;
38124
38125 - atomic_set(&dev_priv->swi_emitted, 0);
38126 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
38127 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
38128
38129 dev->max_vblank_count = 0x001fffff;
38130 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
38131 index 4d20910..6726b6d 100644
38132 --- a/drivers/gpu/drm/radeon/radeon_state.c
38133 +++ b/drivers/gpu/drm/radeon/radeon_state.c
38134 @@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
38135 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
38136 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
38137
38138 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
38139 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
38140 sarea_priv->nbox * sizeof(depth_boxes[0])))
38141 return -EFAULT;
38142
38143 @@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
38144 {
38145 drm_radeon_private_t *dev_priv = dev->dev_private;
38146 drm_radeon_getparam_t *param = data;
38147 - int value;
38148 + int value = 0;
38149
38150 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
38151
38152 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
38153 index 6c0ce89..57a2529 100644
38154 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
38155 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
38156 @@ -782,7 +782,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
38157 man->size = size >> PAGE_SHIFT;
38158 }
38159
38160 -static struct vm_operations_struct radeon_ttm_vm_ops;
38161 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
38162 static const struct vm_operations_struct *ttm_vm_ops = NULL;
38163
38164 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
38165 @@ -823,8 +823,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
38166 }
38167 if (unlikely(ttm_vm_ops == NULL)) {
38168 ttm_vm_ops = vma->vm_ops;
38169 + pax_open_kernel();
38170 radeon_ttm_vm_ops = *ttm_vm_ops;
38171 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
38172 + pax_close_kernel();
38173 }
38174 vma->vm_ops = &radeon_ttm_vm_ops;
38175 return 0;
38176 @@ -853,38 +855,33 @@ static int radeon_mm_dump_table(struct seq_file *m, void *data)
38177 static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
38178 {
38179 #if defined(CONFIG_DEBUG_FS)
38180 - static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2];
38181 - static char radeon_mem_types_names[RADEON_DEBUGFS_MEM_TYPES+2][32];
38182 + static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2] = {
38183 + {
38184 + .name = "radeon_vram_mm",
38185 + .show = &radeon_mm_dump_table,
38186 + },
38187 + {
38188 + .name = "radeon_gtt_mm",
38189 + .show = &radeon_mm_dump_table,
38190 + },
38191 + {
38192 + .name = "ttm_page_pool",
38193 + .show = &ttm_page_alloc_debugfs,
38194 + },
38195 + {
38196 + .name = "ttm_dma_page_pool",
38197 + .show = &ttm_dma_page_alloc_debugfs,
38198 + },
38199 + };
38200 unsigned i;
38201
38202 - for (i = 0; i < RADEON_DEBUGFS_MEM_TYPES; i++) {
38203 - if (i == 0)
38204 - sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
38205 - else
38206 - sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
38207 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
38208 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
38209 - radeon_mem_types_list[i].driver_features = 0;
38210 - if (i == 0)
38211 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
38212 - else
38213 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
38214 -
38215 - }
38216 - /* Add ttm page pool to debugfs */
38217 - sprintf(radeon_mem_types_names[i], "ttm_page_pool");
38218 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
38219 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
38220 - radeon_mem_types_list[i].driver_features = 0;
38221 - radeon_mem_types_list[i++].data = NULL;
38222 + pax_open_kernel();
38223 + *(void **)&radeon_mem_types_list[0].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
38224 + *(void **)&radeon_mem_types_list[1].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
38225 + pax_close_kernel();
38226 #ifdef CONFIG_SWIOTLB
38227 - if (swiotlb_nr_tbl()) {
38228 - sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
38229 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
38230 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
38231 - radeon_mem_types_list[i].driver_features = 0;
38232 - radeon_mem_types_list[i++].data = NULL;
38233 - }
38234 + if (swiotlb_nr_tbl())
38235 + i++;
38236 #endif
38237 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
38238
38239 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
38240 index 55880d5..9e95342 100644
38241 --- a/drivers/gpu/drm/radeon/rs690.c
38242 +++ b/drivers/gpu/drm/radeon/rs690.c
38243 @@ -327,9 +327,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
38244 if (rdev->pm.max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
38245 rdev->pm.sideport_bandwidth.full)
38246 rdev->pm.max_bandwidth = rdev->pm.sideport_bandwidth;
38247 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
38248 + read_delay_latency.full = dfixed_const(800 * 1000);
38249 read_delay_latency.full = dfixed_div(read_delay_latency,
38250 rdev->pm.igp_sideport_mclk);
38251 + a.full = dfixed_const(370);
38252 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
38253 } else {
38254 if (rdev->pm.max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
38255 rdev->pm.k8_bandwidth.full)
38256 diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
38257 index dbc2def..0a9f710 100644
38258 --- a/drivers/gpu/drm/ttm/ttm_memory.c
38259 +++ b/drivers/gpu/drm/ttm/ttm_memory.c
38260 @@ -264,7 +264,7 @@ static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob,
38261 zone->glob = glob;
38262 glob->zone_kernel = zone;
38263 ret = kobject_init_and_add(
38264 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
38265 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
38266 if (unlikely(ret != 0)) {
38267 kobject_put(&zone->kobj);
38268 return ret;
38269 @@ -347,7 +347,7 @@ static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob,
38270 zone->glob = glob;
38271 glob->zone_dma32 = zone;
38272 ret = kobject_init_and_add(
38273 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
38274 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
38275 if (unlikely(ret != 0)) {
38276 kobject_put(&zone->kobj);
38277 return ret;
38278 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
38279 index bd2a3b4..122d9ad 100644
38280 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
38281 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
38282 @@ -394,9 +394,9 @@ static int ttm_pool_get_num_unused_pages(void)
38283 static int ttm_pool_mm_shrink(struct shrinker *shrink,
38284 struct shrink_control *sc)
38285 {
38286 - static atomic_t start_pool = ATOMIC_INIT(0);
38287 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
38288 unsigned i;
38289 - unsigned pool_offset = atomic_add_return(1, &start_pool);
38290 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
38291 struct ttm_page_pool *pool;
38292 int shrink_pages = sc->nr_to_scan;
38293
38294 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
38295 index dc0c065..58a0782 100644
38296 --- a/drivers/gpu/drm/udl/udl_fb.c
38297 +++ b/drivers/gpu/drm/udl/udl_fb.c
38298 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
38299 fb_deferred_io_cleanup(info);
38300 kfree(info->fbdefio);
38301 info->fbdefio = NULL;
38302 - info->fbops->fb_mmap = udl_fb_mmap;
38303 }
38304
38305 pr_warn("released /dev/fb%d user=%d count=%d\n",
38306 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
38307 index 893a650..6190d3b 100644
38308 --- a/drivers/gpu/drm/via/via_drv.h
38309 +++ b/drivers/gpu/drm/via/via_drv.h
38310 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
38311 typedef uint32_t maskarray_t[5];
38312
38313 typedef struct drm_via_irq {
38314 - atomic_t irq_received;
38315 + atomic_unchecked_t irq_received;
38316 uint32_t pending_mask;
38317 uint32_t enable_mask;
38318 wait_queue_head_t irq_queue;
38319 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
38320 struct timeval last_vblank;
38321 int last_vblank_valid;
38322 unsigned usec_per_vblank;
38323 - atomic_t vbl_received;
38324 + atomic_unchecked_t vbl_received;
38325 drm_via_state_t hc_state;
38326 char pci_buf[VIA_PCI_BUF_SIZE];
38327 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
38328 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
38329 index ac98964..5dbf512 100644
38330 --- a/drivers/gpu/drm/via/via_irq.c
38331 +++ b/drivers/gpu/drm/via/via_irq.c
38332 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
38333 if (crtc != 0)
38334 return 0;
38335
38336 - return atomic_read(&dev_priv->vbl_received);
38337 + return atomic_read_unchecked(&dev_priv->vbl_received);
38338 }
38339
38340 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
38341 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
38342
38343 status = VIA_READ(VIA_REG_INTERRUPT);
38344 if (status & VIA_IRQ_VBLANK_PENDING) {
38345 - atomic_inc(&dev_priv->vbl_received);
38346 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
38347 + atomic_inc_unchecked(&dev_priv->vbl_received);
38348 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
38349 do_gettimeofday(&cur_vblank);
38350 if (dev_priv->last_vblank_valid) {
38351 dev_priv->usec_per_vblank =
38352 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
38353 dev_priv->last_vblank = cur_vblank;
38354 dev_priv->last_vblank_valid = 1;
38355 }
38356 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
38357 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
38358 DRM_DEBUG("US per vblank is: %u\n",
38359 dev_priv->usec_per_vblank);
38360 }
38361 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
38362
38363 for (i = 0; i < dev_priv->num_irqs; ++i) {
38364 if (status & cur_irq->pending_mask) {
38365 - atomic_inc(&cur_irq->irq_received);
38366 + atomic_inc_unchecked(&cur_irq->irq_received);
38367 DRM_WAKEUP(&cur_irq->irq_queue);
38368 handled = 1;
38369 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
38370 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
38371 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
38372 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
38373 masks[irq][4]));
38374 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
38375 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
38376 } else {
38377 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
38378 (((cur_irq_sequence =
38379 - atomic_read(&cur_irq->irq_received)) -
38380 + atomic_read_unchecked(&cur_irq->irq_received)) -
38381 *sequence) <= (1 << 23)));
38382 }
38383 *sequence = cur_irq_sequence;
38384 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
38385 }
38386
38387 for (i = 0; i < dev_priv->num_irqs; ++i) {
38388 - atomic_set(&cur_irq->irq_received, 0);
38389 + atomic_set_unchecked(&cur_irq->irq_received, 0);
38390 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
38391 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
38392 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
38393 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
38394 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
38395 case VIA_IRQ_RELATIVE:
38396 irqwait->request.sequence +=
38397 - atomic_read(&cur_irq->irq_received);
38398 + atomic_read_unchecked(&cur_irq->irq_received);
38399 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
38400 case VIA_IRQ_ABSOLUTE:
38401 break;
38402 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
38403 index 13aeda7..4a952d1 100644
38404 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
38405 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
38406 @@ -290,7 +290,7 @@ struct vmw_private {
38407 * Fencing and IRQs.
38408 */
38409
38410 - atomic_t marker_seq;
38411 + atomic_unchecked_t marker_seq;
38412 wait_queue_head_t fence_queue;
38413 wait_queue_head_t fifo_queue;
38414 int fence_queue_waiters; /* Protected by hw_mutex */
38415 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
38416 index 3eb1486..0a47ee9 100644
38417 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
38418 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
38419 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
38420 (unsigned int) min,
38421 (unsigned int) fifo->capabilities);
38422
38423 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
38424 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
38425 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
38426 vmw_marker_queue_init(&fifo->marker_queue);
38427 return vmw_fifo_send_fence(dev_priv, &dummy);
38428 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
38429 if (reserveable)
38430 iowrite32(bytes, fifo_mem +
38431 SVGA_FIFO_RESERVED);
38432 - return fifo_mem + (next_cmd >> 2);
38433 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
38434 } else {
38435 need_bounce = true;
38436 }
38437 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
38438
38439 fm = vmw_fifo_reserve(dev_priv, bytes);
38440 if (unlikely(fm == NULL)) {
38441 - *seqno = atomic_read(&dev_priv->marker_seq);
38442 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
38443 ret = -ENOMEM;
38444 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
38445 false, 3*HZ);
38446 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
38447 }
38448
38449 do {
38450 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
38451 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
38452 } while (*seqno == 0);
38453
38454 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
38455 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
38456 index c509d40..3b640c3 100644
38457 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
38458 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
38459 @@ -138,7 +138,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
38460 int ret;
38461
38462 num_clips = arg->num_clips;
38463 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
38464 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
38465
38466 if (unlikely(num_clips == 0))
38467 return 0;
38468 @@ -222,7 +222,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
38469 int ret;
38470
38471 num_clips = arg->num_clips;
38472 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
38473 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
38474
38475 if (unlikely(num_clips == 0))
38476 return 0;
38477 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
38478 index 4640adb..e1384ed 100644
38479 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
38480 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
38481 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
38482 * emitted. Then the fence is stale and signaled.
38483 */
38484
38485 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
38486 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
38487 > VMW_FENCE_WRAP);
38488
38489 return ret;
38490 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
38491
38492 if (fifo_idle)
38493 down_read(&fifo_state->rwsem);
38494 - signal_seq = atomic_read(&dev_priv->marker_seq);
38495 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
38496 ret = 0;
38497
38498 for (;;) {
38499 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
38500 index 8a8725c2..afed796 100644
38501 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
38502 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
38503 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
38504 while (!vmw_lag_lt(queue, us)) {
38505 spin_lock(&queue->lock);
38506 if (list_empty(&queue->head))
38507 - seqno = atomic_read(&dev_priv->marker_seq);
38508 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
38509 else {
38510 marker = list_first_entry(&queue->head,
38511 struct vmw_marker, head);
38512 diff --git a/drivers/gpu/host1x/drm/dc.c b/drivers/gpu/host1x/drm/dc.c
38513 index 8c04943..4370ed9 100644
38514 --- a/drivers/gpu/host1x/drm/dc.c
38515 +++ b/drivers/gpu/host1x/drm/dc.c
38516 @@ -999,7 +999,7 @@ static int tegra_dc_debugfs_init(struct tegra_dc *dc, struct drm_minor *minor)
38517 }
38518
38519 for (i = 0; i < ARRAY_SIZE(debugfs_files); i++)
38520 - dc->debugfs_files[i].data = dc;
38521 + *(void **)&dc->debugfs_files[i].data = dc;
38522
38523 err = drm_debugfs_create_files(dc->debugfs_files,
38524 ARRAY_SIZE(debugfs_files),
38525 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
38526 index 402f486..f862d7e 100644
38527 --- a/drivers/hid/hid-core.c
38528 +++ b/drivers/hid/hid-core.c
38529 @@ -2275,7 +2275,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
38530
38531 int hid_add_device(struct hid_device *hdev)
38532 {
38533 - static atomic_t id = ATOMIC_INIT(0);
38534 + static atomic_unchecked_t id = ATOMIC_INIT(0);
38535 int ret;
38536
38537 if (WARN_ON(hdev->status & HID_STAT_ADDED))
38538 @@ -2309,7 +2309,7 @@ int hid_add_device(struct hid_device *hdev)
38539 /* XXX hack, any other cleaner solution after the driver core
38540 * is converted to allow more than 20 bytes as the device name? */
38541 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
38542 - hdev->vendor, hdev->product, atomic_inc_return(&id));
38543 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
38544
38545 hid_debug_register(hdev, dev_name(&hdev->dev));
38546 ret = device_add(&hdev->dev);
38547 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
38548 index 90124ff..3761764 100644
38549 --- a/drivers/hid/hid-wiimote-debug.c
38550 +++ b/drivers/hid/hid-wiimote-debug.c
38551 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
38552 else if (size == 0)
38553 return -EIO;
38554
38555 - if (copy_to_user(u, buf, size))
38556 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
38557 return -EFAULT;
38558
38559 *off += size;
38560 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
38561 index 0b122f8..b1d8160 100644
38562 --- a/drivers/hv/channel.c
38563 +++ b/drivers/hv/channel.c
38564 @@ -394,8 +394,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
38565 int ret = 0;
38566 int t;
38567
38568 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
38569 - atomic_inc(&vmbus_connection.next_gpadl_handle);
38570 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
38571 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
38572
38573 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
38574 if (ret)
38575 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
38576 index ae49237..380d4c9 100644
38577 --- a/drivers/hv/hv.c
38578 +++ b/drivers/hv/hv.c
38579 @@ -112,7 +112,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
38580 u64 output_address = (output) ? virt_to_phys(output) : 0;
38581 u32 output_address_hi = output_address >> 32;
38582 u32 output_address_lo = output_address & 0xFFFFFFFF;
38583 - void *hypercall_page = hv_context.hypercall_page;
38584 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
38585
38586 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
38587 "=a"(hv_status_lo) : "d" (control_hi),
38588 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
38589 index 12f2f9e..679603c 100644
38590 --- a/drivers/hv/hyperv_vmbus.h
38591 +++ b/drivers/hv/hyperv_vmbus.h
38592 @@ -591,7 +591,7 @@ enum vmbus_connect_state {
38593 struct vmbus_connection {
38594 enum vmbus_connect_state conn_state;
38595
38596 - atomic_t next_gpadl_handle;
38597 + atomic_unchecked_t next_gpadl_handle;
38598
38599 /*
38600 * Represents channel interrupts. Each bit position represents a
38601 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
38602 index 4004e54..c2de226 100644
38603 --- a/drivers/hv/vmbus_drv.c
38604 +++ b/drivers/hv/vmbus_drv.c
38605 @@ -668,10 +668,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
38606 {
38607 int ret = 0;
38608
38609 - static atomic_t device_num = ATOMIC_INIT(0);
38610 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
38611
38612 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
38613 - atomic_inc_return(&device_num));
38614 + atomic_inc_return_unchecked(&device_num));
38615
38616 child_device_obj->device.bus = &hv_bus;
38617 child_device_obj->device.parent = &hv_acpi_dev->dev;
38618 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
38619 index 6351aba..dc4aaf4 100644
38620 --- a/drivers/hwmon/acpi_power_meter.c
38621 +++ b/drivers/hwmon/acpi_power_meter.c
38622 @@ -117,7 +117,7 @@ struct sensor_template {
38623 struct device_attribute *devattr,
38624 const char *buf, size_t count);
38625 int index;
38626 -};
38627 +} __do_const;
38628
38629 /* Averaging interval */
38630 static int update_avg_interval(struct acpi_power_meter_resource *resource)
38631 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
38632 struct sensor_template *attrs)
38633 {
38634 struct device *dev = &resource->acpi_dev->dev;
38635 - struct sensor_device_attribute *sensors =
38636 + sensor_device_attribute_no_const *sensors =
38637 &resource->sensors[resource->num_sensors];
38638 int res = 0;
38639
38640 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
38641 index 62c2e32..8f2859a 100644
38642 --- a/drivers/hwmon/applesmc.c
38643 +++ b/drivers/hwmon/applesmc.c
38644 @@ -1084,7 +1084,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
38645 {
38646 struct applesmc_node_group *grp;
38647 struct applesmc_dev_attr *node;
38648 - struct attribute *attr;
38649 + attribute_no_const *attr;
38650 int ret, i;
38651
38652 for (grp = groups; grp->format; grp++) {
38653 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
38654 index b25c643..a13460d 100644
38655 --- a/drivers/hwmon/asus_atk0110.c
38656 +++ b/drivers/hwmon/asus_atk0110.c
38657 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
38658 struct atk_sensor_data {
38659 struct list_head list;
38660 struct atk_data *data;
38661 - struct device_attribute label_attr;
38662 - struct device_attribute input_attr;
38663 - struct device_attribute limit1_attr;
38664 - struct device_attribute limit2_attr;
38665 + device_attribute_no_const label_attr;
38666 + device_attribute_no_const input_attr;
38667 + device_attribute_no_const limit1_attr;
38668 + device_attribute_no_const limit2_attr;
38669 char label_attr_name[ATTR_NAME_SIZE];
38670 char input_attr_name[ATTR_NAME_SIZE];
38671 char limit1_attr_name[ATTR_NAME_SIZE];
38672 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
38673 static struct device_attribute atk_name_attr =
38674 __ATTR(name, 0444, atk_name_show, NULL);
38675
38676 -static void atk_init_attribute(struct device_attribute *attr, char *name,
38677 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
38678 sysfs_show_func show)
38679 {
38680 sysfs_attr_init(&attr->attr);
38681 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
38682 index 658ce3a..0d0c2f3 100644
38683 --- a/drivers/hwmon/coretemp.c
38684 +++ b/drivers/hwmon/coretemp.c
38685 @@ -790,7 +790,7 @@ static int __cpuinit coretemp_cpu_callback(struct notifier_block *nfb,
38686 return NOTIFY_OK;
38687 }
38688
38689 -static struct notifier_block coretemp_cpu_notifier __refdata = {
38690 +static struct notifier_block coretemp_cpu_notifier = {
38691 .notifier_call = coretemp_cpu_callback,
38692 };
38693
38694 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
38695 index 1429f6e..ee03d59 100644
38696 --- a/drivers/hwmon/ibmaem.c
38697 +++ b/drivers/hwmon/ibmaem.c
38698 @@ -926,7 +926,7 @@ static int aem_register_sensors(struct aem_data *data,
38699 struct aem_rw_sensor_template *rw)
38700 {
38701 struct device *dev = &data->pdev->dev;
38702 - struct sensor_device_attribute *sensors = data->sensors;
38703 + sensor_device_attribute_no_const *sensors = data->sensors;
38704 int err;
38705
38706 /* Set up read-only sensors */
38707 diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
38708 index 52b77af..aed1ddf 100644
38709 --- a/drivers/hwmon/iio_hwmon.c
38710 +++ b/drivers/hwmon/iio_hwmon.c
38711 @@ -73,7 +73,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
38712 {
38713 struct device *dev = &pdev->dev;
38714 struct iio_hwmon_state *st;
38715 - struct sensor_device_attribute *a;
38716 + sensor_device_attribute_no_const *a;
38717 int ret, i;
38718 int in_i = 1, temp_i = 1, curr_i = 1;
38719 enum iio_chan_type type;
38720 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
38721 index 9add6092..ee7ba3f 100644
38722 --- a/drivers/hwmon/pmbus/pmbus_core.c
38723 +++ b/drivers/hwmon/pmbus/pmbus_core.c
38724 @@ -781,7 +781,7 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
38725 return 0;
38726 }
38727
38728 -static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
38729 +static void pmbus_dev_attr_init(device_attribute_no_const *dev_attr,
38730 const char *name,
38731 umode_t mode,
38732 ssize_t (*show)(struct device *dev,
38733 @@ -798,7 +798,7 @@ static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
38734 dev_attr->store = store;
38735 }
38736
38737 -static void pmbus_attr_init(struct sensor_device_attribute *a,
38738 +static void pmbus_attr_init(sensor_device_attribute_no_const *a,
38739 const char *name,
38740 umode_t mode,
38741 ssize_t (*show)(struct device *dev,
38742 @@ -820,7 +820,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
38743 u16 reg, u8 mask)
38744 {
38745 struct pmbus_boolean *boolean;
38746 - struct sensor_device_attribute *a;
38747 + sensor_device_attribute_no_const *a;
38748
38749 boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL);
38750 if (!boolean)
38751 @@ -845,7 +845,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
38752 bool update, bool readonly)
38753 {
38754 struct pmbus_sensor *sensor;
38755 - struct device_attribute *a;
38756 + device_attribute_no_const *a;
38757
38758 sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL);
38759 if (!sensor)
38760 @@ -876,7 +876,7 @@ static int pmbus_add_label(struct pmbus_data *data,
38761 const char *lstring, int index)
38762 {
38763 struct pmbus_label *label;
38764 - struct device_attribute *a;
38765 + device_attribute_no_const *a;
38766
38767 label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL);
38768 if (!label)
38769 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
38770 index 2507f90..1645765 100644
38771 --- a/drivers/hwmon/sht15.c
38772 +++ b/drivers/hwmon/sht15.c
38773 @@ -169,7 +169,7 @@ struct sht15_data {
38774 int supply_uv;
38775 bool supply_uv_valid;
38776 struct work_struct update_supply_work;
38777 - atomic_t interrupt_handled;
38778 + atomic_unchecked_t interrupt_handled;
38779 };
38780
38781 /**
38782 @@ -542,13 +542,13 @@ static int sht15_measurement(struct sht15_data *data,
38783 ret = gpio_direction_input(data->pdata->gpio_data);
38784 if (ret)
38785 return ret;
38786 - atomic_set(&data->interrupt_handled, 0);
38787 + atomic_set_unchecked(&data->interrupt_handled, 0);
38788
38789 enable_irq(gpio_to_irq(data->pdata->gpio_data));
38790 if (gpio_get_value(data->pdata->gpio_data) == 0) {
38791 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
38792 /* Only relevant if the interrupt hasn't occurred. */
38793 - if (!atomic_read(&data->interrupt_handled))
38794 + if (!atomic_read_unchecked(&data->interrupt_handled))
38795 schedule_work(&data->read_work);
38796 }
38797 ret = wait_event_timeout(data->wait_queue,
38798 @@ -820,7 +820,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
38799
38800 /* First disable the interrupt */
38801 disable_irq_nosync(irq);
38802 - atomic_inc(&data->interrupt_handled);
38803 + atomic_inc_unchecked(&data->interrupt_handled);
38804 /* Then schedule a reading work struct */
38805 if (data->state != SHT15_READING_NOTHING)
38806 schedule_work(&data->read_work);
38807 @@ -842,11 +842,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
38808 * If not, then start the interrupt again - care here as could
38809 * have gone low in meantime so verify it hasn't!
38810 */
38811 - atomic_set(&data->interrupt_handled, 0);
38812 + atomic_set_unchecked(&data->interrupt_handled, 0);
38813 enable_irq(gpio_to_irq(data->pdata->gpio_data));
38814 /* If still not occurred or another handler was scheduled */
38815 if (gpio_get_value(data->pdata->gpio_data)
38816 - || atomic_read(&data->interrupt_handled))
38817 + || atomic_read_unchecked(&data->interrupt_handled))
38818 return;
38819 }
38820
38821 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
38822 index 76f157b..9c0db1b 100644
38823 --- a/drivers/hwmon/via-cputemp.c
38824 +++ b/drivers/hwmon/via-cputemp.c
38825 @@ -296,7 +296,7 @@ static int __cpuinit via_cputemp_cpu_callback(struct notifier_block *nfb,
38826 return NOTIFY_OK;
38827 }
38828
38829 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
38830 +static struct notifier_block via_cputemp_cpu_notifier = {
38831 .notifier_call = via_cputemp_cpu_callback,
38832 };
38833
38834 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
38835 index 07f01ac..d79ad3d 100644
38836 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
38837 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
38838 @@ -43,7 +43,7 @@
38839 extern struct i2c_adapter amd756_smbus;
38840
38841 static struct i2c_adapter *s4882_adapter;
38842 -static struct i2c_algorithm *s4882_algo;
38843 +static i2c_algorithm_no_const *s4882_algo;
38844
38845 /* Wrapper access functions for multiplexed SMBus */
38846 static DEFINE_MUTEX(amd756_lock);
38847 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
38848 index 2ca268d..c6acbdf 100644
38849 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
38850 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
38851 @@ -41,7 +41,7 @@
38852 extern struct i2c_adapter *nforce2_smbus;
38853
38854 static struct i2c_adapter *s4985_adapter;
38855 -static struct i2c_algorithm *s4985_algo;
38856 +static i2c_algorithm_no_const *s4985_algo;
38857
38858 /* Wrapper access functions for multiplexed SMBus */
38859 static DEFINE_MUTEX(nforce2_lock);
38860 diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
38861 index c3ccdea..5b3dc1a 100644
38862 --- a/drivers/i2c/i2c-dev.c
38863 +++ b/drivers/i2c/i2c-dev.c
38864 @@ -271,7 +271,7 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client,
38865 break;
38866 }
38867
38868 - data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
38869 + data_ptrs[i] = (u8 __force_user *)rdwr_pa[i].buf;
38870 rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len);
38871 if (IS_ERR(rdwr_pa[i].buf)) {
38872 res = PTR_ERR(rdwr_pa[i].buf);
38873 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
38874 index 2ff6204..218c16e 100644
38875 --- a/drivers/ide/ide-cd.c
38876 +++ b/drivers/ide/ide-cd.c
38877 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
38878 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
38879 if ((unsigned long)buf & alignment
38880 || blk_rq_bytes(rq) & q->dma_pad_mask
38881 - || object_is_on_stack(buf))
38882 + || object_starts_on_stack(buf))
38883 drive->dma = 0;
38884 }
38885 }
38886 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
38887 index e145931..08bfc59 100644
38888 --- a/drivers/iio/industrialio-core.c
38889 +++ b/drivers/iio/industrialio-core.c
38890 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
38891 }
38892
38893 static
38894 -int __iio_device_attr_init(struct device_attribute *dev_attr,
38895 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
38896 const char *postfix,
38897 struct iio_chan_spec const *chan,
38898 ssize_t (*readfunc)(struct device *dev,
38899 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
38900 index 784b97c..c9ceadf 100644
38901 --- a/drivers/infiniband/core/cm.c
38902 +++ b/drivers/infiniband/core/cm.c
38903 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
38904
38905 struct cm_counter_group {
38906 struct kobject obj;
38907 - atomic_long_t counter[CM_ATTR_COUNT];
38908 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
38909 };
38910
38911 struct cm_counter_attribute {
38912 @@ -1395,7 +1395,7 @@ static void cm_dup_req_handler(struct cm_work *work,
38913 struct ib_mad_send_buf *msg = NULL;
38914 int ret;
38915
38916 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
38917 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
38918 counter[CM_REQ_COUNTER]);
38919
38920 /* Quick state check to discard duplicate REQs. */
38921 @@ -1779,7 +1779,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
38922 if (!cm_id_priv)
38923 return;
38924
38925 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
38926 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
38927 counter[CM_REP_COUNTER]);
38928 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
38929 if (ret)
38930 @@ -1946,7 +1946,7 @@ static int cm_rtu_handler(struct cm_work *work)
38931 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
38932 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
38933 spin_unlock_irq(&cm_id_priv->lock);
38934 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
38935 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
38936 counter[CM_RTU_COUNTER]);
38937 goto out;
38938 }
38939 @@ -2129,7 +2129,7 @@ static int cm_dreq_handler(struct cm_work *work)
38940 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
38941 dreq_msg->local_comm_id);
38942 if (!cm_id_priv) {
38943 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
38944 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
38945 counter[CM_DREQ_COUNTER]);
38946 cm_issue_drep(work->port, work->mad_recv_wc);
38947 return -EINVAL;
38948 @@ -2154,7 +2154,7 @@ static int cm_dreq_handler(struct cm_work *work)
38949 case IB_CM_MRA_REP_RCVD:
38950 break;
38951 case IB_CM_TIMEWAIT:
38952 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
38953 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
38954 counter[CM_DREQ_COUNTER]);
38955 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
38956 goto unlock;
38957 @@ -2168,7 +2168,7 @@ static int cm_dreq_handler(struct cm_work *work)
38958 cm_free_msg(msg);
38959 goto deref;
38960 case IB_CM_DREQ_RCVD:
38961 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
38962 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
38963 counter[CM_DREQ_COUNTER]);
38964 goto unlock;
38965 default:
38966 @@ -2535,7 +2535,7 @@ static int cm_mra_handler(struct cm_work *work)
38967 ib_modify_mad(cm_id_priv->av.port->mad_agent,
38968 cm_id_priv->msg, timeout)) {
38969 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
38970 - atomic_long_inc(&work->port->
38971 + atomic_long_inc_unchecked(&work->port->
38972 counter_group[CM_RECV_DUPLICATES].
38973 counter[CM_MRA_COUNTER]);
38974 goto out;
38975 @@ -2544,7 +2544,7 @@ static int cm_mra_handler(struct cm_work *work)
38976 break;
38977 case IB_CM_MRA_REQ_RCVD:
38978 case IB_CM_MRA_REP_RCVD:
38979 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
38980 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
38981 counter[CM_MRA_COUNTER]);
38982 /* fall through */
38983 default:
38984 @@ -2706,7 +2706,7 @@ static int cm_lap_handler(struct cm_work *work)
38985 case IB_CM_LAP_IDLE:
38986 break;
38987 case IB_CM_MRA_LAP_SENT:
38988 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
38989 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
38990 counter[CM_LAP_COUNTER]);
38991 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
38992 goto unlock;
38993 @@ -2722,7 +2722,7 @@ static int cm_lap_handler(struct cm_work *work)
38994 cm_free_msg(msg);
38995 goto deref;
38996 case IB_CM_LAP_RCVD:
38997 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
38998 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
38999 counter[CM_LAP_COUNTER]);
39000 goto unlock;
39001 default:
39002 @@ -3006,7 +3006,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
39003 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
39004 if (cur_cm_id_priv) {
39005 spin_unlock_irq(&cm.lock);
39006 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
39007 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
39008 counter[CM_SIDR_REQ_COUNTER]);
39009 goto out; /* Duplicate message. */
39010 }
39011 @@ -3218,10 +3218,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
39012 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
39013 msg->retries = 1;
39014
39015 - atomic_long_add(1 + msg->retries,
39016 + atomic_long_add_unchecked(1 + msg->retries,
39017 &port->counter_group[CM_XMIT].counter[attr_index]);
39018 if (msg->retries)
39019 - atomic_long_add(msg->retries,
39020 + atomic_long_add_unchecked(msg->retries,
39021 &port->counter_group[CM_XMIT_RETRIES].
39022 counter[attr_index]);
39023
39024 @@ -3431,7 +3431,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
39025 }
39026
39027 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
39028 - atomic_long_inc(&port->counter_group[CM_RECV].
39029 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
39030 counter[attr_id - CM_ATTR_ID_OFFSET]);
39031
39032 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
39033 @@ -3636,7 +3636,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
39034 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
39035
39036 return sprintf(buf, "%ld\n",
39037 - atomic_long_read(&group->counter[cm_attr->index]));
39038 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
39039 }
39040
39041 static const struct sysfs_ops cm_counter_ops = {
39042 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
39043 index 9f5ad7c..588cd84 100644
39044 --- a/drivers/infiniband/core/fmr_pool.c
39045 +++ b/drivers/infiniband/core/fmr_pool.c
39046 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
39047
39048 struct task_struct *thread;
39049
39050 - atomic_t req_ser;
39051 - atomic_t flush_ser;
39052 + atomic_unchecked_t req_ser;
39053 + atomic_unchecked_t flush_ser;
39054
39055 wait_queue_head_t force_wait;
39056 };
39057 @@ -179,10 +179,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
39058 struct ib_fmr_pool *pool = pool_ptr;
39059
39060 do {
39061 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
39062 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
39063 ib_fmr_batch_release(pool);
39064
39065 - atomic_inc(&pool->flush_ser);
39066 + atomic_inc_unchecked(&pool->flush_ser);
39067 wake_up_interruptible(&pool->force_wait);
39068
39069 if (pool->flush_function)
39070 @@ -190,7 +190,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
39071 }
39072
39073 set_current_state(TASK_INTERRUPTIBLE);
39074 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
39075 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
39076 !kthread_should_stop())
39077 schedule();
39078 __set_current_state(TASK_RUNNING);
39079 @@ -282,8 +282,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
39080 pool->dirty_watermark = params->dirty_watermark;
39081 pool->dirty_len = 0;
39082 spin_lock_init(&pool->pool_lock);
39083 - atomic_set(&pool->req_ser, 0);
39084 - atomic_set(&pool->flush_ser, 0);
39085 + atomic_set_unchecked(&pool->req_ser, 0);
39086 + atomic_set_unchecked(&pool->flush_ser, 0);
39087 init_waitqueue_head(&pool->force_wait);
39088
39089 pool->thread = kthread_run(ib_fmr_cleanup_thread,
39090 @@ -411,11 +411,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
39091 }
39092 spin_unlock_irq(&pool->pool_lock);
39093
39094 - serial = atomic_inc_return(&pool->req_ser);
39095 + serial = atomic_inc_return_unchecked(&pool->req_ser);
39096 wake_up_process(pool->thread);
39097
39098 if (wait_event_interruptible(pool->force_wait,
39099 - atomic_read(&pool->flush_ser) - serial >= 0))
39100 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
39101 return -EINTR;
39102
39103 return 0;
39104 @@ -525,7 +525,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
39105 } else {
39106 list_add_tail(&fmr->list, &pool->dirty_list);
39107 if (++pool->dirty_len >= pool->dirty_watermark) {
39108 - atomic_inc(&pool->req_ser);
39109 + atomic_inc_unchecked(&pool->req_ser);
39110 wake_up_process(pool->thread);
39111 }
39112 }
39113 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
39114 index 4cb8eb2..146bf60 100644
39115 --- a/drivers/infiniband/hw/cxgb4/mem.c
39116 +++ b/drivers/infiniband/hw/cxgb4/mem.c
39117 @@ -249,7 +249,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
39118 int err;
39119 struct fw_ri_tpte tpt;
39120 u32 stag_idx;
39121 - static atomic_t key;
39122 + static atomic_unchecked_t key;
39123
39124 if (c4iw_fatal_error(rdev))
39125 return -EIO;
39126 @@ -266,7 +266,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
39127 if (rdev->stats.stag.cur > rdev->stats.stag.max)
39128 rdev->stats.stag.max = rdev->stats.stag.cur;
39129 mutex_unlock(&rdev->stats.lock);
39130 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
39131 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
39132 }
39133 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
39134 __func__, stag_state, type, pdid, stag_idx);
39135 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
39136 index 79b3dbc..96e5fcc 100644
39137 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
39138 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
39139 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
39140 struct ib_atomic_eth *ateth;
39141 struct ipath_ack_entry *e;
39142 u64 vaddr;
39143 - atomic64_t *maddr;
39144 + atomic64_unchecked_t *maddr;
39145 u64 sdata;
39146 u32 rkey;
39147 u8 next;
39148 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
39149 IB_ACCESS_REMOTE_ATOMIC)))
39150 goto nack_acc_unlck;
39151 /* Perform atomic OP and save result. */
39152 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
39153 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
39154 sdata = be64_to_cpu(ateth->swap_data);
39155 e = &qp->s_ack_queue[qp->r_head_ack_queue];
39156 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
39157 - (u64) atomic64_add_return(sdata, maddr) - sdata :
39158 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
39159 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
39160 be64_to_cpu(ateth->compare_data),
39161 sdata);
39162 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
39163 index 1f95bba..9530f87 100644
39164 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
39165 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
39166 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
39167 unsigned long flags;
39168 struct ib_wc wc;
39169 u64 sdata;
39170 - atomic64_t *maddr;
39171 + atomic64_unchecked_t *maddr;
39172 enum ib_wc_status send_status;
39173
39174 /*
39175 @@ -382,11 +382,11 @@ again:
39176 IB_ACCESS_REMOTE_ATOMIC)))
39177 goto acc_err;
39178 /* Perform atomic OP and save result. */
39179 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
39180 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
39181 sdata = wqe->wr.wr.atomic.compare_add;
39182 *(u64 *) sqp->s_sge.sge.vaddr =
39183 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
39184 - (u64) atomic64_add_return(sdata, maddr) - sdata :
39185 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
39186 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
39187 sdata, wqe->wr.wr.atomic.swap);
39188 goto send_comp;
39189 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
39190 index 9d3e5c1..d9afe4a 100644
39191 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
39192 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
39193 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
39194 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
39195 }
39196
39197 -int mthca_QUERY_FW(struct mthca_dev *dev)
39198 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
39199 {
39200 struct mthca_mailbox *mailbox;
39201 u32 *outbox;
39202 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
39203 index ed9a989..e0c5871 100644
39204 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
39205 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
39206 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
39207 return key;
39208 }
39209
39210 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
39211 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
39212 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
39213 {
39214 struct mthca_mailbox *mailbox;
39215 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
39216 index 4291410..d2ab1fb 100644
39217 --- a/drivers/infiniband/hw/nes/nes.c
39218 +++ b/drivers/infiniband/hw/nes/nes.c
39219 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
39220 LIST_HEAD(nes_adapter_list);
39221 static LIST_HEAD(nes_dev_list);
39222
39223 -atomic_t qps_destroyed;
39224 +atomic_unchecked_t qps_destroyed;
39225
39226 static unsigned int ee_flsh_adapter;
39227 static unsigned int sysfs_nonidx_addr;
39228 @@ -269,7 +269,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
39229 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
39230 struct nes_adapter *nesadapter = nesdev->nesadapter;
39231
39232 - atomic_inc(&qps_destroyed);
39233 + atomic_inc_unchecked(&qps_destroyed);
39234
39235 /* Free the control structures */
39236
39237 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
39238 index 33cc589..3bd6538 100644
39239 --- a/drivers/infiniband/hw/nes/nes.h
39240 +++ b/drivers/infiniband/hw/nes/nes.h
39241 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
39242 extern unsigned int wqm_quanta;
39243 extern struct list_head nes_adapter_list;
39244
39245 -extern atomic_t cm_connects;
39246 -extern atomic_t cm_accepts;
39247 -extern atomic_t cm_disconnects;
39248 -extern atomic_t cm_closes;
39249 -extern atomic_t cm_connecteds;
39250 -extern atomic_t cm_connect_reqs;
39251 -extern atomic_t cm_rejects;
39252 -extern atomic_t mod_qp_timouts;
39253 -extern atomic_t qps_created;
39254 -extern atomic_t qps_destroyed;
39255 -extern atomic_t sw_qps_destroyed;
39256 +extern atomic_unchecked_t cm_connects;
39257 +extern atomic_unchecked_t cm_accepts;
39258 +extern atomic_unchecked_t cm_disconnects;
39259 +extern atomic_unchecked_t cm_closes;
39260 +extern atomic_unchecked_t cm_connecteds;
39261 +extern atomic_unchecked_t cm_connect_reqs;
39262 +extern atomic_unchecked_t cm_rejects;
39263 +extern atomic_unchecked_t mod_qp_timouts;
39264 +extern atomic_unchecked_t qps_created;
39265 +extern atomic_unchecked_t qps_destroyed;
39266 +extern atomic_unchecked_t sw_qps_destroyed;
39267 extern u32 mh_detected;
39268 extern u32 mh_pauses_sent;
39269 extern u32 cm_packets_sent;
39270 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
39271 extern u32 cm_packets_received;
39272 extern u32 cm_packets_dropped;
39273 extern u32 cm_packets_retrans;
39274 -extern atomic_t cm_listens_created;
39275 -extern atomic_t cm_listens_destroyed;
39276 +extern atomic_unchecked_t cm_listens_created;
39277 +extern atomic_unchecked_t cm_listens_destroyed;
39278 extern u32 cm_backlog_drops;
39279 -extern atomic_t cm_loopbacks;
39280 -extern atomic_t cm_nodes_created;
39281 -extern atomic_t cm_nodes_destroyed;
39282 -extern atomic_t cm_accel_dropped_pkts;
39283 -extern atomic_t cm_resets_recvd;
39284 -extern atomic_t pau_qps_created;
39285 -extern atomic_t pau_qps_destroyed;
39286 +extern atomic_unchecked_t cm_loopbacks;
39287 +extern atomic_unchecked_t cm_nodes_created;
39288 +extern atomic_unchecked_t cm_nodes_destroyed;
39289 +extern atomic_unchecked_t cm_accel_dropped_pkts;
39290 +extern atomic_unchecked_t cm_resets_recvd;
39291 +extern atomic_unchecked_t pau_qps_created;
39292 +extern atomic_unchecked_t pau_qps_destroyed;
39293
39294 extern u32 int_mod_timer_init;
39295 extern u32 int_mod_cq_depth_256;
39296 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
39297 index 24b9f1a..00fd004 100644
39298 --- a/drivers/infiniband/hw/nes/nes_cm.c
39299 +++ b/drivers/infiniband/hw/nes/nes_cm.c
39300 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
39301 u32 cm_packets_retrans;
39302 u32 cm_packets_created;
39303 u32 cm_packets_received;
39304 -atomic_t cm_listens_created;
39305 -atomic_t cm_listens_destroyed;
39306 +atomic_unchecked_t cm_listens_created;
39307 +atomic_unchecked_t cm_listens_destroyed;
39308 u32 cm_backlog_drops;
39309 -atomic_t cm_loopbacks;
39310 -atomic_t cm_nodes_created;
39311 -atomic_t cm_nodes_destroyed;
39312 -atomic_t cm_accel_dropped_pkts;
39313 -atomic_t cm_resets_recvd;
39314 +atomic_unchecked_t cm_loopbacks;
39315 +atomic_unchecked_t cm_nodes_created;
39316 +atomic_unchecked_t cm_nodes_destroyed;
39317 +atomic_unchecked_t cm_accel_dropped_pkts;
39318 +atomic_unchecked_t cm_resets_recvd;
39319
39320 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
39321 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
39322 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
39323
39324 static struct nes_cm_core *g_cm_core;
39325
39326 -atomic_t cm_connects;
39327 -atomic_t cm_accepts;
39328 -atomic_t cm_disconnects;
39329 -atomic_t cm_closes;
39330 -atomic_t cm_connecteds;
39331 -atomic_t cm_connect_reqs;
39332 -atomic_t cm_rejects;
39333 +atomic_unchecked_t cm_connects;
39334 +atomic_unchecked_t cm_accepts;
39335 +atomic_unchecked_t cm_disconnects;
39336 +atomic_unchecked_t cm_closes;
39337 +atomic_unchecked_t cm_connecteds;
39338 +atomic_unchecked_t cm_connect_reqs;
39339 +atomic_unchecked_t cm_rejects;
39340
39341 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
39342 {
39343 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
39344 kfree(listener);
39345 listener = NULL;
39346 ret = 0;
39347 - atomic_inc(&cm_listens_destroyed);
39348 + atomic_inc_unchecked(&cm_listens_destroyed);
39349 } else {
39350 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
39351 }
39352 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
39353 cm_node->rem_mac);
39354
39355 add_hte_node(cm_core, cm_node);
39356 - atomic_inc(&cm_nodes_created);
39357 + atomic_inc_unchecked(&cm_nodes_created);
39358
39359 return cm_node;
39360 }
39361 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
39362 }
39363
39364 atomic_dec(&cm_core->node_cnt);
39365 - atomic_inc(&cm_nodes_destroyed);
39366 + atomic_inc_unchecked(&cm_nodes_destroyed);
39367 nesqp = cm_node->nesqp;
39368 if (nesqp) {
39369 nesqp->cm_node = NULL;
39370 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
39371
39372 static void drop_packet(struct sk_buff *skb)
39373 {
39374 - atomic_inc(&cm_accel_dropped_pkts);
39375 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
39376 dev_kfree_skb_any(skb);
39377 }
39378
39379 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
39380 {
39381
39382 int reset = 0; /* whether to send reset in case of err.. */
39383 - atomic_inc(&cm_resets_recvd);
39384 + atomic_inc_unchecked(&cm_resets_recvd);
39385 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
39386 " refcnt=%d\n", cm_node, cm_node->state,
39387 atomic_read(&cm_node->ref_count));
39388 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
39389 rem_ref_cm_node(cm_node->cm_core, cm_node);
39390 return NULL;
39391 }
39392 - atomic_inc(&cm_loopbacks);
39393 + atomic_inc_unchecked(&cm_loopbacks);
39394 loopbackremotenode->loopbackpartner = cm_node;
39395 loopbackremotenode->tcp_cntxt.rcv_wscale =
39396 NES_CM_DEFAULT_RCV_WND_SCALE;
39397 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
39398 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
39399 else {
39400 rem_ref_cm_node(cm_core, cm_node);
39401 - atomic_inc(&cm_accel_dropped_pkts);
39402 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
39403 dev_kfree_skb_any(skb);
39404 }
39405 break;
39406 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
39407
39408 if ((cm_id) && (cm_id->event_handler)) {
39409 if (issue_disconn) {
39410 - atomic_inc(&cm_disconnects);
39411 + atomic_inc_unchecked(&cm_disconnects);
39412 cm_event.event = IW_CM_EVENT_DISCONNECT;
39413 cm_event.status = disconn_status;
39414 cm_event.local_addr = cm_id->local_addr;
39415 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
39416 }
39417
39418 if (issue_close) {
39419 - atomic_inc(&cm_closes);
39420 + atomic_inc_unchecked(&cm_closes);
39421 nes_disconnect(nesqp, 1);
39422
39423 cm_id->provider_data = nesqp;
39424 @@ -3033,7 +3033,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
39425
39426 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
39427 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
39428 - atomic_inc(&cm_accepts);
39429 + atomic_inc_unchecked(&cm_accepts);
39430
39431 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
39432 netdev_refcnt_read(nesvnic->netdev));
39433 @@ -3228,7 +3228,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
39434 struct nes_cm_core *cm_core;
39435 u8 *start_buff;
39436
39437 - atomic_inc(&cm_rejects);
39438 + atomic_inc_unchecked(&cm_rejects);
39439 cm_node = (struct nes_cm_node *)cm_id->provider_data;
39440 loopback = cm_node->loopbackpartner;
39441 cm_core = cm_node->cm_core;
39442 @@ -3288,7 +3288,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
39443 ntohl(cm_id->local_addr.sin_addr.s_addr),
39444 ntohs(cm_id->local_addr.sin_port));
39445
39446 - atomic_inc(&cm_connects);
39447 + atomic_inc_unchecked(&cm_connects);
39448 nesqp->active_conn = 1;
39449
39450 /* cache the cm_id in the qp */
39451 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
39452 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
39453 return err;
39454 }
39455 - atomic_inc(&cm_listens_created);
39456 + atomic_inc_unchecked(&cm_listens_created);
39457 }
39458
39459 cm_id->add_ref(cm_id);
39460 @@ -3499,7 +3499,7 @@ static void cm_event_connected(struct nes_cm_event *event)
39461
39462 if (nesqp->destroyed)
39463 return;
39464 - atomic_inc(&cm_connecteds);
39465 + atomic_inc_unchecked(&cm_connecteds);
39466 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
39467 " local port 0x%04X. jiffies = %lu.\n",
39468 nesqp->hwqp.qp_id,
39469 @@ -3679,7 +3679,7 @@ static void cm_event_reset(struct nes_cm_event *event)
39470
39471 cm_id->add_ref(cm_id);
39472 ret = cm_id->event_handler(cm_id, &cm_event);
39473 - atomic_inc(&cm_closes);
39474 + atomic_inc_unchecked(&cm_closes);
39475 cm_event.event = IW_CM_EVENT_CLOSE;
39476 cm_event.status = 0;
39477 cm_event.provider_data = cm_id->provider_data;
39478 @@ -3715,7 +3715,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
39479 return;
39480 cm_id = cm_node->cm_id;
39481
39482 - atomic_inc(&cm_connect_reqs);
39483 + atomic_inc_unchecked(&cm_connect_reqs);
39484 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
39485 cm_node, cm_id, jiffies);
39486
39487 @@ -3755,7 +3755,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
39488 return;
39489 cm_id = cm_node->cm_id;
39490
39491 - atomic_inc(&cm_connect_reqs);
39492 + atomic_inc_unchecked(&cm_connect_reqs);
39493 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
39494 cm_node, cm_id, jiffies);
39495
39496 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
39497 index 4166452..fc952c3 100644
39498 --- a/drivers/infiniband/hw/nes/nes_mgt.c
39499 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
39500 @@ -40,8 +40,8 @@
39501 #include "nes.h"
39502 #include "nes_mgt.h"
39503
39504 -atomic_t pau_qps_created;
39505 -atomic_t pau_qps_destroyed;
39506 +atomic_unchecked_t pau_qps_created;
39507 +atomic_unchecked_t pau_qps_destroyed;
39508
39509 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
39510 {
39511 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
39512 {
39513 struct sk_buff *skb;
39514 unsigned long flags;
39515 - atomic_inc(&pau_qps_destroyed);
39516 + atomic_inc_unchecked(&pau_qps_destroyed);
39517
39518 /* Free packets that have not yet been forwarded */
39519 /* Lock is acquired by skb_dequeue when removing the skb */
39520 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
39521 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
39522 skb_queue_head_init(&nesqp->pau_list);
39523 spin_lock_init(&nesqp->pau_lock);
39524 - atomic_inc(&pau_qps_created);
39525 + atomic_inc_unchecked(&pau_qps_created);
39526 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
39527 }
39528
39529 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
39530 index 49eb511..a774366 100644
39531 --- a/drivers/infiniband/hw/nes/nes_nic.c
39532 +++ b/drivers/infiniband/hw/nes/nes_nic.c
39533 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
39534 target_stat_values[++index] = mh_detected;
39535 target_stat_values[++index] = mh_pauses_sent;
39536 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
39537 - target_stat_values[++index] = atomic_read(&cm_connects);
39538 - target_stat_values[++index] = atomic_read(&cm_accepts);
39539 - target_stat_values[++index] = atomic_read(&cm_disconnects);
39540 - target_stat_values[++index] = atomic_read(&cm_connecteds);
39541 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
39542 - target_stat_values[++index] = atomic_read(&cm_rejects);
39543 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
39544 - target_stat_values[++index] = atomic_read(&qps_created);
39545 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
39546 - target_stat_values[++index] = atomic_read(&qps_destroyed);
39547 - target_stat_values[++index] = atomic_read(&cm_closes);
39548 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
39549 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
39550 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
39551 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
39552 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
39553 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
39554 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
39555 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
39556 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
39557 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
39558 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
39559 target_stat_values[++index] = cm_packets_sent;
39560 target_stat_values[++index] = cm_packets_bounced;
39561 target_stat_values[++index] = cm_packets_created;
39562 target_stat_values[++index] = cm_packets_received;
39563 target_stat_values[++index] = cm_packets_dropped;
39564 target_stat_values[++index] = cm_packets_retrans;
39565 - target_stat_values[++index] = atomic_read(&cm_listens_created);
39566 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
39567 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
39568 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
39569 target_stat_values[++index] = cm_backlog_drops;
39570 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
39571 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
39572 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
39573 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
39574 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
39575 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
39576 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
39577 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
39578 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
39579 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
39580 target_stat_values[++index] = nesadapter->free_4kpbl;
39581 target_stat_values[++index] = nesadapter->free_256pbl;
39582 target_stat_values[++index] = int_mod_timer_init;
39583 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
39584 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
39585 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
39586 - target_stat_values[++index] = atomic_read(&pau_qps_created);
39587 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
39588 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
39589 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
39590 }
39591
39592 /**
39593 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
39594 index 8f67fe2..8960859 100644
39595 --- a/drivers/infiniband/hw/nes/nes_verbs.c
39596 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
39597 @@ -46,9 +46,9 @@
39598
39599 #include <rdma/ib_umem.h>
39600
39601 -atomic_t mod_qp_timouts;
39602 -atomic_t qps_created;
39603 -atomic_t sw_qps_destroyed;
39604 +atomic_unchecked_t mod_qp_timouts;
39605 +atomic_unchecked_t qps_created;
39606 +atomic_unchecked_t sw_qps_destroyed;
39607
39608 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
39609
39610 @@ -1134,7 +1134,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
39611 if (init_attr->create_flags)
39612 return ERR_PTR(-EINVAL);
39613
39614 - atomic_inc(&qps_created);
39615 + atomic_inc_unchecked(&qps_created);
39616 switch (init_attr->qp_type) {
39617 case IB_QPT_RC:
39618 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
39619 @@ -1465,7 +1465,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
39620 struct iw_cm_event cm_event;
39621 int ret = 0;
39622
39623 - atomic_inc(&sw_qps_destroyed);
39624 + atomic_inc_unchecked(&sw_qps_destroyed);
39625 nesqp->destroyed = 1;
39626
39627 /* Blow away the connection if it exists. */
39628 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
39629 index 4d11575..3e890e5 100644
39630 --- a/drivers/infiniband/hw/qib/qib.h
39631 +++ b/drivers/infiniband/hw/qib/qib.h
39632 @@ -51,6 +51,7 @@
39633 #include <linux/completion.h>
39634 #include <linux/kref.h>
39635 #include <linux/sched.h>
39636 +#include <linux/slab.h>
39637
39638 #include "qib_common.h"
39639 #include "qib_verbs.h"
39640 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
39641 index da739d9..da1c7f4 100644
39642 --- a/drivers/input/gameport/gameport.c
39643 +++ b/drivers/input/gameport/gameport.c
39644 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
39645 */
39646 static void gameport_init_port(struct gameport *gameport)
39647 {
39648 - static atomic_t gameport_no = ATOMIC_INIT(0);
39649 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
39650
39651 __module_get(THIS_MODULE);
39652
39653 mutex_init(&gameport->drv_mutex);
39654 device_initialize(&gameport->dev);
39655 dev_set_name(&gameport->dev, "gameport%lu",
39656 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
39657 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
39658 gameport->dev.bus = &gameport_bus;
39659 gameport->dev.release = gameport_release_port;
39660 if (gameport->parent)
39661 diff --git a/drivers/input/input.c b/drivers/input/input.c
39662 index c044699..174d71a 100644
39663 --- a/drivers/input/input.c
39664 +++ b/drivers/input/input.c
39665 @@ -2019,7 +2019,7 @@ static void devm_input_device_unregister(struct device *dev, void *res)
39666 */
39667 int input_register_device(struct input_dev *dev)
39668 {
39669 - static atomic_t input_no = ATOMIC_INIT(0);
39670 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
39671 struct input_devres *devres = NULL;
39672 struct input_handler *handler;
39673 unsigned int packet_size;
39674 @@ -2074,7 +2074,7 @@ int input_register_device(struct input_dev *dev)
39675 dev->setkeycode = input_default_setkeycode;
39676
39677 dev_set_name(&dev->dev, "input%ld",
39678 - (unsigned long) atomic_inc_return(&input_no) - 1);
39679 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
39680
39681 error = device_add(&dev->dev);
39682 if (error)
39683 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
39684 index 04c69af..5f92d00 100644
39685 --- a/drivers/input/joystick/sidewinder.c
39686 +++ b/drivers/input/joystick/sidewinder.c
39687 @@ -30,6 +30,7 @@
39688 #include <linux/kernel.h>
39689 #include <linux/module.h>
39690 #include <linux/slab.h>
39691 +#include <linux/sched.h>
39692 #include <linux/init.h>
39693 #include <linux/input.h>
39694 #include <linux/gameport.h>
39695 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
39696 index fa061d4..4a6957c 100644
39697 --- a/drivers/input/joystick/xpad.c
39698 +++ b/drivers/input/joystick/xpad.c
39699 @@ -735,7 +735,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
39700
39701 static int xpad_led_probe(struct usb_xpad *xpad)
39702 {
39703 - static atomic_t led_seq = ATOMIC_INIT(0);
39704 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
39705 long led_no;
39706 struct xpad_led *led;
39707 struct led_classdev *led_cdev;
39708 @@ -748,7 +748,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
39709 if (!led)
39710 return -ENOMEM;
39711
39712 - led_no = (long)atomic_inc_return(&led_seq) - 1;
39713 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
39714
39715 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
39716 led->xpad = xpad;
39717 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
39718 index 2f0b39d..7370f13 100644
39719 --- a/drivers/input/mouse/psmouse.h
39720 +++ b/drivers/input/mouse/psmouse.h
39721 @@ -116,7 +116,7 @@ struct psmouse_attribute {
39722 ssize_t (*set)(struct psmouse *psmouse, void *data,
39723 const char *buf, size_t count);
39724 bool protect;
39725 -};
39726 +} __do_const;
39727 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
39728
39729 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
39730 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
39731 index 4c842c3..590b0bf 100644
39732 --- a/drivers/input/mousedev.c
39733 +++ b/drivers/input/mousedev.c
39734 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
39735
39736 spin_unlock_irq(&client->packet_lock);
39737
39738 - if (copy_to_user(buffer, data, count))
39739 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
39740 return -EFAULT;
39741
39742 return count;
39743 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
39744 index 25fc597..558bf3b3 100644
39745 --- a/drivers/input/serio/serio.c
39746 +++ b/drivers/input/serio/serio.c
39747 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
39748 */
39749 static void serio_init_port(struct serio *serio)
39750 {
39751 - static atomic_t serio_no = ATOMIC_INIT(0);
39752 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
39753
39754 __module_get(THIS_MODULE);
39755
39756 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
39757 mutex_init(&serio->drv_mutex);
39758 device_initialize(&serio->dev);
39759 dev_set_name(&serio->dev, "serio%ld",
39760 - (long)atomic_inc_return(&serio_no) - 1);
39761 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
39762 serio->dev.bus = &serio_bus;
39763 serio->dev.release = serio_release_port;
39764 serio->dev.groups = serio_device_attr_groups;
39765 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
39766 index d8f98b1..f62a640 100644
39767 --- a/drivers/iommu/iommu.c
39768 +++ b/drivers/iommu/iommu.c
39769 @@ -583,7 +583,7 @@ static struct notifier_block iommu_bus_nb = {
39770 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
39771 {
39772 bus_register_notifier(bus, &iommu_bus_nb);
39773 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
39774 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
39775 }
39776
39777 /**
39778 diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
39779 index dcfea4e..f4226b2 100644
39780 --- a/drivers/iommu/irq_remapping.c
39781 +++ b/drivers/iommu/irq_remapping.c
39782 @@ -354,7 +354,7 @@ int setup_hpet_msi_remapped(unsigned int irq, unsigned int id)
39783 void panic_if_irq_remap(const char *msg)
39784 {
39785 if (irq_remapping_enabled)
39786 - panic(msg);
39787 + panic("%s", msg);
39788 }
39789
39790 static void ir_ack_apic_edge(struct irq_data *data)
39791 @@ -375,10 +375,12 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
39792
39793 void irq_remap_modify_chip_defaults(struct irq_chip *chip)
39794 {
39795 - chip->irq_print_chip = ir_print_prefix;
39796 - chip->irq_ack = ir_ack_apic_edge;
39797 - chip->irq_eoi = ir_ack_apic_level;
39798 - chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
39799 + pax_open_kernel();
39800 + *(void **)&chip->irq_print_chip = ir_print_prefix;
39801 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
39802 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
39803 + *(void **)&chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
39804 + pax_close_kernel();
39805 }
39806
39807 bool setup_remapped_irq(int irq, struct irq_cfg *cfg, struct irq_chip *chip)
39808 diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
39809 index 19ceaa6..3625818 100644
39810 --- a/drivers/irqchip/irq-gic.c
39811 +++ b/drivers/irqchip/irq-gic.c
39812 @@ -84,7 +84,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
39813 * Supported arch specific GIC irq extension.
39814 * Default make them NULL.
39815 */
39816 -struct irq_chip gic_arch_extn = {
39817 +irq_chip_no_const gic_arch_extn = {
39818 .irq_eoi = NULL,
39819 .irq_mask = NULL,
39820 .irq_unmask = NULL,
39821 @@ -333,7 +333,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
39822 chained_irq_exit(chip, desc);
39823 }
39824
39825 -static struct irq_chip gic_chip = {
39826 +static irq_chip_no_const gic_chip __read_only = {
39827 .name = "GIC",
39828 .irq_mask = gic_mask_irq,
39829 .irq_unmask = gic_unmask_irq,
39830 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
39831 index ac6f72b..81150f2 100644
39832 --- a/drivers/isdn/capi/capi.c
39833 +++ b/drivers/isdn/capi/capi.c
39834 @@ -81,8 +81,8 @@ struct capiminor {
39835
39836 struct capi20_appl *ap;
39837 u32 ncci;
39838 - atomic_t datahandle;
39839 - atomic_t msgid;
39840 + atomic_unchecked_t datahandle;
39841 + atomic_unchecked_t msgid;
39842
39843 struct tty_port port;
39844 int ttyinstop;
39845 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
39846 capimsg_setu16(s, 2, mp->ap->applid);
39847 capimsg_setu8 (s, 4, CAPI_DATA_B3);
39848 capimsg_setu8 (s, 5, CAPI_RESP);
39849 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
39850 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
39851 capimsg_setu32(s, 8, mp->ncci);
39852 capimsg_setu16(s, 12, datahandle);
39853 }
39854 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
39855 mp->outbytes -= len;
39856 spin_unlock_bh(&mp->outlock);
39857
39858 - datahandle = atomic_inc_return(&mp->datahandle);
39859 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
39860 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
39861 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
39862 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
39863 capimsg_setu16(skb->data, 2, mp->ap->applid);
39864 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
39865 capimsg_setu8 (skb->data, 5, CAPI_REQ);
39866 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
39867 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
39868 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
39869 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
39870 capimsg_setu16(skb->data, 16, len); /* Data length */
39871 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
39872 index 600c79b..3752bab 100644
39873 --- a/drivers/isdn/gigaset/interface.c
39874 +++ b/drivers/isdn/gigaset/interface.c
39875 @@ -130,9 +130,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
39876 }
39877 tty->driver_data = cs;
39878
39879 - ++cs->port.count;
39880 + atomic_inc(&cs->port.count);
39881
39882 - if (cs->port.count == 1) {
39883 + if (atomic_read(&cs->port.count) == 1) {
39884 tty_port_tty_set(&cs->port, tty);
39885 cs->port.low_latency = 1;
39886 }
39887 @@ -156,9 +156,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
39888
39889 if (!cs->connected)
39890 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
39891 - else if (!cs->port.count)
39892 + else if (!atomic_read(&cs->port.count))
39893 dev_warn(cs->dev, "%s: device not opened\n", __func__);
39894 - else if (!--cs->port.count)
39895 + else if (!atomic_dec_return(&cs->port.count))
39896 tty_port_tty_set(&cs->port, NULL);
39897
39898 mutex_unlock(&cs->mutex);
39899 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
39900 index 4d9b195..455075c 100644
39901 --- a/drivers/isdn/hardware/avm/b1.c
39902 +++ b/drivers/isdn/hardware/avm/b1.c
39903 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
39904 }
39905 if (left) {
39906 if (t4file->user) {
39907 - if (copy_from_user(buf, dp, left))
39908 + if (left > sizeof buf || copy_from_user(buf, dp, left))
39909 return -EFAULT;
39910 } else {
39911 memcpy(buf, dp, left);
39912 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
39913 }
39914 if (left) {
39915 if (config->user) {
39916 - if (copy_from_user(buf, dp, left))
39917 + if (left > sizeof buf || copy_from_user(buf, dp, left))
39918 return -EFAULT;
39919 } else {
39920 memcpy(buf, dp, left);
39921 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
39922 index 3c5f249..5fac4d0 100644
39923 --- a/drivers/isdn/i4l/isdn_tty.c
39924 +++ b/drivers/isdn/i4l/isdn_tty.c
39925 @@ -1508,9 +1508,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
39926
39927 #ifdef ISDN_DEBUG_MODEM_OPEN
39928 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
39929 - port->count);
39930 + atomic_read(&port->count));
39931 #endif
39932 - port->count++;
39933 + atomic_inc(&port->count);
39934 port->tty = tty;
39935 /*
39936 * Start up serial port
39937 @@ -1554,7 +1554,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
39938 #endif
39939 return;
39940 }
39941 - if ((tty->count == 1) && (port->count != 1)) {
39942 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
39943 /*
39944 * Uh, oh. tty->count is 1, which means that the tty
39945 * structure will be freed. Info->count should always
39946 @@ -1563,15 +1563,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
39947 * serial port won't be shutdown.
39948 */
39949 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
39950 - "info->count is %d\n", port->count);
39951 - port->count = 1;
39952 + "info->count is %d\n", atomic_read(&port->count));
39953 + atomic_set(&port->count, 1);
39954 }
39955 - if (--port->count < 0) {
39956 + if (atomic_dec_return(&port->count) < 0) {
39957 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
39958 - info->line, port->count);
39959 - port->count = 0;
39960 + info->line, atomic_read(&port->count));
39961 + atomic_set(&port->count, 0);
39962 }
39963 - if (port->count) {
39964 + if (atomic_read(&port->count)) {
39965 #ifdef ISDN_DEBUG_MODEM_OPEN
39966 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
39967 #endif
39968 @@ -1625,7 +1625,7 @@ isdn_tty_hangup(struct tty_struct *tty)
39969 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
39970 return;
39971 isdn_tty_shutdown(info);
39972 - port->count = 0;
39973 + atomic_set(&port->count, 0);
39974 port->flags &= ~ASYNC_NORMAL_ACTIVE;
39975 port->tty = NULL;
39976 wake_up_interruptible(&port->open_wait);
39977 @@ -1970,7 +1970,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
39978 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
39979 modem_info *info = &dev->mdm.info[i];
39980
39981 - if (info->port.count == 0)
39982 + if (atomic_read(&info->port.count) == 0)
39983 continue;
39984 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
39985 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
39986 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
39987 index e74df7c..03a03ba 100644
39988 --- a/drivers/isdn/icn/icn.c
39989 +++ b/drivers/isdn/icn/icn.c
39990 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
39991 if (count > len)
39992 count = len;
39993 if (user) {
39994 - if (copy_from_user(msg, buf, count))
39995 + if (count > sizeof msg || copy_from_user(msg, buf, count))
39996 return -EFAULT;
39997 } else
39998 memcpy(msg, buf, count);
39999 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
40000 index 6a8405d..0bd1c7e 100644
40001 --- a/drivers/leds/leds-clevo-mail.c
40002 +++ b/drivers/leds/leds-clevo-mail.c
40003 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
40004 * detected as working, but in reality it is not) as low as
40005 * possible.
40006 */
40007 -static struct dmi_system_id __initdata clevo_mail_led_dmi_table[] = {
40008 +static const struct dmi_system_id __initconst clevo_mail_led_dmi_table[] = {
40009 {
40010 .callback = clevo_mail_led_dmi_callback,
40011 .ident = "Clevo D410J",
40012 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
40013 index 64e204e..c6bf189 100644
40014 --- a/drivers/leds/leds-ss4200.c
40015 +++ b/drivers/leds/leds-ss4200.c
40016 @@ -91,7 +91,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
40017 * detected as working, but in reality it is not) as low as
40018 * possible.
40019 */
40020 -static struct dmi_system_id __initdata nas_led_whitelist[] = {
40021 +static const struct dmi_system_id __initconst nas_led_whitelist[] = {
40022 {
40023 .callback = ss4200_led_dmi_callback,
40024 .ident = "Intel SS4200-E",
40025 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
40026 index 0bf1e4e..b4bf44e 100644
40027 --- a/drivers/lguest/core.c
40028 +++ b/drivers/lguest/core.c
40029 @@ -97,9 +97,17 @@ static __init int map_switcher(void)
40030 * The end address needs +1 because __get_vm_area allocates an
40031 * extra guard page, so we need space for that.
40032 */
40033 +
40034 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
40035 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
40036 + VM_ALLOC | VM_KERNEXEC, switcher_addr, switcher_addr
40037 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
40038 +#else
40039 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
40040 VM_ALLOC, switcher_addr, switcher_addr
40041 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
40042 +#endif
40043 +
40044 if (!switcher_vma) {
40045 err = -ENOMEM;
40046 printk("lguest: could not map switcher pages high\n");
40047 @@ -124,7 +132,7 @@ static __init int map_switcher(void)
40048 * Now the Switcher is mapped at the right address, we can't fail!
40049 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
40050 */
40051 - memcpy(switcher_vma->addr, start_switcher_text,
40052 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
40053 end_switcher_text - start_switcher_text);
40054
40055 printk(KERN_INFO "lguest: mapped switcher at %p\n",
40056 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
40057 index 5b9ac32..2ef4f26 100644
40058 --- a/drivers/lguest/page_tables.c
40059 +++ b/drivers/lguest/page_tables.c
40060 @@ -559,7 +559,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
40061 /*:*/
40062
40063 #ifdef CONFIG_X86_PAE
40064 -static void release_pmd(pmd_t *spmd)
40065 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
40066 {
40067 /* If the entry's not present, there's nothing to release. */
40068 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
40069 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
40070 index f0a3347..f6608b2 100644
40071 --- a/drivers/lguest/x86/core.c
40072 +++ b/drivers/lguest/x86/core.c
40073 @@ -59,7 +59,7 @@ static struct {
40074 /* Offset from where switcher.S was compiled to where we've copied it */
40075 static unsigned long switcher_offset(void)
40076 {
40077 - return switcher_addr - (unsigned long)start_switcher_text;
40078 + return switcher_addr - (unsigned long)ktla_ktva(start_switcher_text);
40079 }
40080
40081 /* This cpu's struct lguest_pages (after the Switcher text page) */
40082 @@ -99,7 +99,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
40083 * These copies are pretty cheap, so we do them unconditionally: */
40084 /* Save the current Host top-level page directory.
40085 */
40086 +
40087 +#ifdef CONFIG_PAX_PER_CPU_PGD
40088 + pages->state.host_cr3 = read_cr3();
40089 +#else
40090 pages->state.host_cr3 = __pa(current->mm->pgd);
40091 +#endif
40092 +
40093 /*
40094 * Set up the Guest's page tables to see this CPU's pages (and no
40095 * other CPU's pages).
40096 @@ -475,7 +481,7 @@ void __init lguest_arch_host_init(void)
40097 * compiled-in switcher code and the high-mapped copy we just made.
40098 */
40099 for (i = 0; i < IDT_ENTRIES; i++)
40100 - default_idt_entries[i] += switcher_offset();
40101 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
40102
40103 /*
40104 * Set up the Switcher's per-cpu areas.
40105 @@ -558,7 +564,7 @@ void __init lguest_arch_host_init(void)
40106 * it will be undisturbed when we switch. To change %cs and jump we
40107 * need this structure to feed to Intel's "lcall" instruction.
40108 */
40109 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
40110 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
40111 lguest_entry.segment = LGUEST_CS;
40112
40113 /*
40114 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
40115 index 40634b0..4f5855e 100644
40116 --- a/drivers/lguest/x86/switcher_32.S
40117 +++ b/drivers/lguest/x86/switcher_32.S
40118 @@ -87,6 +87,7 @@
40119 #include <asm/page.h>
40120 #include <asm/segment.h>
40121 #include <asm/lguest.h>
40122 +#include <asm/processor-flags.h>
40123
40124 // We mark the start of the code to copy
40125 // It's placed in .text tho it's never run here
40126 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
40127 // Changes type when we load it: damn Intel!
40128 // For after we switch over our page tables
40129 // That entry will be read-only: we'd crash.
40130 +
40131 +#ifdef CONFIG_PAX_KERNEXEC
40132 + mov %cr0, %edx
40133 + xor $X86_CR0_WP, %edx
40134 + mov %edx, %cr0
40135 +#endif
40136 +
40137 movl $(GDT_ENTRY_TSS*8), %edx
40138 ltr %dx
40139
40140 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
40141 // Let's clear it again for our return.
40142 // The GDT descriptor of the Host
40143 // Points to the table after two "size" bytes
40144 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
40145 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
40146 // Clear "used" from type field (byte 5, bit 2)
40147 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
40148 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
40149 +
40150 +#ifdef CONFIG_PAX_KERNEXEC
40151 + mov %cr0, %eax
40152 + xor $X86_CR0_WP, %eax
40153 + mov %eax, %cr0
40154 +#endif
40155
40156 // Once our page table's switched, the Guest is live!
40157 // The Host fades as we run this final step.
40158 @@ -295,13 +309,12 @@ deliver_to_host:
40159 // I consulted gcc, and it gave
40160 // These instructions, which I gladly credit:
40161 leal (%edx,%ebx,8), %eax
40162 - movzwl (%eax),%edx
40163 - movl 4(%eax), %eax
40164 - xorw %ax, %ax
40165 - orl %eax, %edx
40166 + movl 4(%eax), %edx
40167 + movw (%eax), %dx
40168 // Now the address of the handler's in %edx
40169 // We call it now: its "iret" drops us home.
40170 - jmp *%edx
40171 + ljmp $__KERNEL_CS, $1f
40172 +1: jmp *%edx
40173
40174 // Every interrupt can come to us here
40175 // But we must truly tell each apart.
40176 diff --git a/drivers/md/bcache/closure.h b/drivers/md/bcache/closure.h
40177 index 0003992..854bbce 100644
40178 --- a/drivers/md/bcache/closure.h
40179 +++ b/drivers/md/bcache/closure.h
40180 @@ -622,7 +622,7 @@ static inline void closure_wake_up(struct closure_waitlist *list)
40181 static inline void set_closure_fn(struct closure *cl, closure_fn *fn,
40182 struct workqueue_struct *wq)
40183 {
40184 - BUG_ON(object_is_on_stack(cl));
40185 + BUG_ON(object_starts_on_stack(cl));
40186 closure_set_ip(cl);
40187 cl->fn = fn;
40188 cl->wq = wq;
40189 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
40190 index 5a2c754..0fa55db 100644
40191 --- a/drivers/md/bitmap.c
40192 +++ b/drivers/md/bitmap.c
40193 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
40194 chunk_kb ? "KB" : "B");
40195 if (bitmap->storage.file) {
40196 seq_printf(seq, ", file: ");
40197 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
40198 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
40199 }
40200
40201 seq_printf(seq, "\n");
40202 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
40203 index 81a79b7..87a0f73 100644
40204 --- a/drivers/md/dm-ioctl.c
40205 +++ b/drivers/md/dm-ioctl.c
40206 @@ -1697,7 +1697,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
40207 cmd == DM_LIST_VERSIONS_CMD)
40208 return 0;
40209
40210 - if ((cmd == DM_DEV_CREATE_CMD)) {
40211 + if (cmd == DM_DEV_CREATE_CMD) {
40212 if (!*param->name) {
40213 DMWARN("name not supplied when creating device");
40214 return -EINVAL;
40215 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
40216 index 699b5be..eac0a15 100644
40217 --- a/drivers/md/dm-raid1.c
40218 +++ b/drivers/md/dm-raid1.c
40219 @@ -40,7 +40,7 @@ enum dm_raid1_error {
40220
40221 struct mirror {
40222 struct mirror_set *ms;
40223 - atomic_t error_count;
40224 + atomic_unchecked_t error_count;
40225 unsigned long error_type;
40226 struct dm_dev *dev;
40227 sector_t offset;
40228 @@ -186,7 +186,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
40229 struct mirror *m;
40230
40231 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
40232 - if (!atomic_read(&m->error_count))
40233 + if (!atomic_read_unchecked(&m->error_count))
40234 return m;
40235
40236 return NULL;
40237 @@ -218,7 +218,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
40238 * simple way to tell if a device has encountered
40239 * errors.
40240 */
40241 - atomic_inc(&m->error_count);
40242 + atomic_inc_unchecked(&m->error_count);
40243
40244 if (test_and_set_bit(error_type, &m->error_type))
40245 return;
40246 @@ -409,7 +409,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
40247 struct mirror *m = get_default_mirror(ms);
40248
40249 do {
40250 - if (likely(!atomic_read(&m->error_count)))
40251 + if (likely(!atomic_read_unchecked(&m->error_count)))
40252 return m;
40253
40254 if (m-- == ms->mirror)
40255 @@ -423,7 +423,7 @@ static int default_ok(struct mirror *m)
40256 {
40257 struct mirror *default_mirror = get_default_mirror(m->ms);
40258
40259 - return !atomic_read(&default_mirror->error_count);
40260 + return !atomic_read_unchecked(&default_mirror->error_count);
40261 }
40262
40263 static int mirror_available(struct mirror_set *ms, struct bio *bio)
40264 @@ -560,7 +560,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
40265 */
40266 if (likely(region_in_sync(ms, region, 1)))
40267 m = choose_mirror(ms, bio->bi_sector);
40268 - else if (m && atomic_read(&m->error_count))
40269 + else if (m && atomic_read_unchecked(&m->error_count))
40270 m = NULL;
40271
40272 if (likely(m))
40273 @@ -927,7 +927,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
40274 }
40275
40276 ms->mirror[mirror].ms = ms;
40277 - atomic_set(&(ms->mirror[mirror].error_count), 0);
40278 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
40279 ms->mirror[mirror].error_type = 0;
40280 ms->mirror[mirror].offset = offset;
40281
40282 @@ -1340,7 +1340,7 @@ static void mirror_resume(struct dm_target *ti)
40283 */
40284 static char device_status_char(struct mirror *m)
40285 {
40286 - if (!atomic_read(&(m->error_count)))
40287 + if (!atomic_read_unchecked(&(m->error_count)))
40288 return 'A';
40289
40290 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
40291 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
40292 index d907ca6..cfb8384 100644
40293 --- a/drivers/md/dm-stripe.c
40294 +++ b/drivers/md/dm-stripe.c
40295 @@ -20,7 +20,7 @@ struct stripe {
40296 struct dm_dev *dev;
40297 sector_t physical_start;
40298
40299 - atomic_t error_count;
40300 + atomic_unchecked_t error_count;
40301 };
40302
40303 struct stripe_c {
40304 @@ -185,7 +185,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
40305 kfree(sc);
40306 return r;
40307 }
40308 - atomic_set(&(sc->stripe[i].error_count), 0);
40309 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
40310 }
40311
40312 ti->private = sc;
40313 @@ -326,7 +326,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
40314 DMEMIT("%d ", sc->stripes);
40315 for (i = 0; i < sc->stripes; i++) {
40316 DMEMIT("%s ", sc->stripe[i].dev->name);
40317 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
40318 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
40319 'D' : 'A';
40320 }
40321 buffer[i] = '\0';
40322 @@ -371,8 +371,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
40323 */
40324 for (i = 0; i < sc->stripes; i++)
40325 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
40326 - atomic_inc(&(sc->stripe[i].error_count));
40327 - if (atomic_read(&(sc->stripe[i].error_count)) <
40328 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
40329 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
40330 DM_IO_ERROR_THRESHOLD)
40331 schedule_work(&sc->trigger_event);
40332 }
40333 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
40334 index 1ff252a..ee384c1 100644
40335 --- a/drivers/md/dm-table.c
40336 +++ b/drivers/md/dm-table.c
40337 @@ -389,7 +389,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
40338 if (!dev_size)
40339 return 0;
40340
40341 - if ((start >= dev_size) || (start + len > dev_size)) {
40342 + if ((start >= dev_size) || (len > dev_size - start)) {
40343 DMWARN("%s: %s too small for target: "
40344 "start=%llu, len=%llu, dev_size=%llu",
40345 dm_device_name(ti->table->md), bdevname(bdev, b),
40346 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
40347 index 60bce43..9b997d0 100644
40348 --- a/drivers/md/dm-thin-metadata.c
40349 +++ b/drivers/md/dm-thin-metadata.c
40350 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
40351 {
40352 pmd->info.tm = pmd->tm;
40353 pmd->info.levels = 2;
40354 - pmd->info.value_type.context = pmd->data_sm;
40355 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
40356 pmd->info.value_type.size = sizeof(__le64);
40357 pmd->info.value_type.inc = data_block_inc;
40358 pmd->info.value_type.dec = data_block_dec;
40359 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
40360
40361 pmd->bl_info.tm = pmd->tm;
40362 pmd->bl_info.levels = 1;
40363 - pmd->bl_info.value_type.context = pmd->data_sm;
40364 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
40365 pmd->bl_info.value_type.size = sizeof(__le64);
40366 pmd->bl_info.value_type.inc = data_block_inc;
40367 pmd->bl_info.value_type.dec = data_block_dec;
40368 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
40369 index 33f2010..23fb84c 100644
40370 --- a/drivers/md/dm.c
40371 +++ b/drivers/md/dm.c
40372 @@ -169,9 +169,9 @@ struct mapped_device {
40373 /*
40374 * Event handling.
40375 */
40376 - atomic_t event_nr;
40377 + atomic_unchecked_t event_nr;
40378 wait_queue_head_t eventq;
40379 - atomic_t uevent_seq;
40380 + atomic_unchecked_t uevent_seq;
40381 struct list_head uevent_list;
40382 spinlock_t uevent_lock; /* Protect access to uevent_list */
40383
40384 @@ -1884,8 +1884,8 @@ static struct mapped_device *alloc_dev(int minor)
40385 rwlock_init(&md->map_lock);
40386 atomic_set(&md->holders, 1);
40387 atomic_set(&md->open_count, 0);
40388 - atomic_set(&md->event_nr, 0);
40389 - atomic_set(&md->uevent_seq, 0);
40390 + atomic_set_unchecked(&md->event_nr, 0);
40391 + atomic_set_unchecked(&md->uevent_seq, 0);
40392 INIT_LIST_HEAD(&md->uevent_list);
40393 spin_lock_init(&md->uevent_lock);
40394
40395 @@ -2033,7 +2033,7 @@ static void event_callback(void *context)
40396
40397 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
40398
40399 - atomic_inc(&md->event_nr);
40400 + atomic_inc_unchecked(&md->event_nr);
40401 wake_up(&md->eventq);
40402 }
40403
40404 @@ -2690,18 +2690,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
40405
40406 uint32_t dm_next_uevent_seq(struct mapped_device *md)
40407 {
40408 - return atomic_add_return(1, &md->uevent_seq);
40409 + return atomic_add_return_unchecked(1, &md->uevent_seq);
40410 }
40411
40412 uint32_t dm_get_event_nr(struct mapped_device *md)
40413 {
40414 - return atomic_read(&md->event_nr);
40415 + return atomic_read_unchecked(&md->event_nr);
40416 }
40417
40418 int dm_wait_event(struct mapped_device *md, int event_nr)
40419 {
40420 return wait_event_interruptible(md->eventq,
40421 - (event_nr != atomic_read(&md->event_nr)));
40422 + (event_nr != atomic_read_unchecked(&md->event_nr)));
40423 }
40424
40425 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
40426 diff --git a/drivers/md/md.c b/drivers/md/md.c
40427 index 51f0345..c77810e 100644
40428 --- a/drivers/md/md.c
40429 +++ b/drivers/md/md.c
40430 @@ -234,10 +234,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
40431 * start build, activate spare
40432 */
40433 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
40434 -static atomic_t md_event_count;
40435 +static atomic_unchecked_t md_event_count;
40436 void md_new_event(struct mddev *mddev)
40437 {
40438 - atomic_inc(&md_event_count);
40439 + atomic_inc_unchecked(&md_event_count);
40440 wake_up(&md_event_waiters);
40441 }
40442 EXPORT_SYMBOL_GPL(md_new_event);
40443 @@ -247,7 +247,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
40444 */
40445 static void md_new_event_inintr(struct mddev *mddev)
40446 {
40447 - atomic_inc(&md_event_count);
40448 + atomic_inc_unchecked(&md_event_count);
40449 wake_up(&md_event_waiters);
40450 }
40451
40452 @@ -1501,7 +1501,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
40453 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
40454 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
40455 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
40456 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
40457 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
40458
40459 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
40460 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
40461 @@ -1745,7 +1745,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
40462 else
40463 sb->resync_offset = cpu_to_le64(0);
40464
40465 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
40466 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
40467
40468 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
40469 sb->size = cpu_to_le64(mddev->dev_sectors);
40470 @@ -2750,7 +2750,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
40471 static ssize_t
40472 errors_show(struct md_rdev *rdev, char *page)
40473 {
40474 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
40475 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
40476 }
40477
40478 static ssize_t
40479 @@ -2759,7 +2759,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
40480 char *e;
40481 unsigned long n = simple_strtoul(buf, &e, 10);
40482 if (*buf && (*e == 0 || *e == '\n')) {
40483 - atomic_set(&rdev->corrected_errors, n);
40484 + atomic_set_unchecked(&rdev->corrected_errors, n);
40485 return len;
40486 }
40487 return -EINVAL;
40488 @@ -3207,8 +3207,8 @@ int md_rdev_init(struct md_rdev *rdev)
40489 rdev->sb_loaded = 0;
40490 rdev->bb_page = NULL;
40491 atomic_set(&rdev->nr_pending, 0);
40492 - atomic_set(&rdev->read_errors, 0);
40493 - atomic_set(&rdev->corrected_errors, 0);
40494 + atomic_set_unchecked(&rdev->read_errors, 0);
40495 + atomic_set_unchecked(&rdev->corrected_errors, 0);
40496
40497 INIT_LIST_HEAD(&rdev->same_set);
40498 init_waitqueue_head(&rdev->blocked_wait);
40499 @@ -7009,7 +7009,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
40500
40501 spin_unlock(&pers_lock);
40502 seq_printf(seq, "\n");
40503 - seq->poll_event = atomic_read(&md_event_count);
40504 + seq->poll_event = atomic_read_unchecked(&md_event_count);
40505 return 0;
40506 }
40507 if (v == (void*)2) {
40508 @@ -7112,7 +7112,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
40509 return error;
40510
40511 seq = file->private_data;
40512 - seq->poll_event = atomic_read(&md_event_count);
40513 + seq->poll_event = atomic_read_unchecked(&md_event_count);
40514 return error;
40515 }
40516
40517 @@ -7126,7 +7126,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
40518 /* always allow read */
40519 mask = POLLIN | POLLRDNORM;
40520
40521 - if (seq->poll_event != atomic_read(&md_event_count))
40522 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
40523 mask |= POLLERR | POLLPRI;
40524 return mask;
40525 }
40526 @@ -7170,7 +7170,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
40527 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
40528 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
40529 (int)part_stat_read(&disk->part0, sectors[1]) -
40530 - atomic_read(&disk->sync_io);
40531 + atomic_read_unchecked(&disk->sync_io);
40532 /* sync IO will cause sync_io to increase before the disk_stats
40533 * as sync_io is counted when a request starts, and
40534 * disk_stats is counted when it completes.
40535 diff --git a/drivers/md/md.h b/drivers/md/md.h
40536 index 653f992b6..6af6c40 100644
40537 --- a/drivers/md/md.h
40538 +++ b/drivers/md/md.h
40539 @@ -94,13 +94,13 @@ struct md_rdev {
40540 * only maintained for arrays that
40541 * support hot removal
40542 */
40543 - atomic_t read_errors; /* number of consecutive read errors that
40544 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
40545 * we have tried to ignore.
40546 */
40547 struct timespec last_read_error; /* monotonic time since our
40548 * last read error
40549 */
40550 - atomic_t corrected_errors; /* number of corrected read errors,
40551 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
40552 * for reporting to userspace and storing
40553 * in superblock.
40554 */
40555 @@ -434,7 +434,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
40556
40557 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
40558 {
40559 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
40560 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
40561 }
40562
40563 struct md_personality
40564 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
40565 index 3e6d115..ffecdeb 100644
40566 --- a/drivers/md/persistent-data/dm-space-map.h
40567 +++ b/drivers/md/persistent-data/dm-space-map.h
40568 @@ -71,6 +71,7 @@ struct dm_space_map {
40569 dm_sm_threshold_fn fn,
40570 void *context);
40571 };
40572 +typedef struct dm_space_map __no_const dm_space_map_no_const;
40573
40574 /*----------------------------------------------------------------*/
40575
40576 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
40577 index 6f48244..7d29145 100644
40578 --- a/drivers/md/raid1.c
40579 +++ b/drivers/md/raid1.c
40580 @@ -1822,7 +1822,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
40581 if (r1_sync_page_io(rdev, sect, s,
40582 bio->bi_io_vec[idx].bv_page,
40583 READ) != 0)
40584 - atomic_add(s, &rdev->corrected_errors);
40585 + atomic_add_unchecked(s, &rdev->corrected_errors);
40586 }
40587 sectors -= s;
40588 sect += s;
40589 @@ -2049,7 +2049,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
40590 test_bit(In_sync, &rdev->flags)) {
40591 if (r1_sync_page_io(rdev, sect, s,
40592 conf->tmppage, READ)) {
40593 - atomic_add(s, &rdev->corrected_errors);
40594 + atomic_add_unchecked(s, &rdev->corrected_errors);
40595 printk(KERN_INFO
40596 "md/raid1:%s: read error corrected "
40597 "(%d sectors at %llu on %s)\n",
40598 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
40599 index 081bb33..3c4b287 100644
40600 --- a/drivers/md/raid10.c
40601 +++ b/drivers/md/raid10.c
40602 @@ -1940,7 +1940,7 @@ static void end_sync_read(struct bio *bio, int error)
40603 /* The write handler will notice the lack of
40604 * R10BIO_Uptodate and record any errors etc
40605 */
40606 - atomic_add(r10_bio->sectors,
40607 + atomic_add_unchecked(r10_bio->sectors,
40608 &conf->mirrors[d].rdev->corrected_errors);
40609
40610 /* for reconstruct, we always reschedule after a read.
40611 @@ -2298,7 +2298,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
40612 {
40613 struct timespec cur_time_mon;
40614 unsigned long hours_since_last;
40615 - unsigned int read_errors = atomic_read(&rdev->read_errors);
40616 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
40617
40618 ktime_get_ts(&cur_time_mon);
40619
40620 @@ -2320,9 +2320,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
40621 * overflowing the shift of read_errors by hours_since_last.
40622 */
40623 if (hours_since_last >= 8 * sizeof(read_errors))
40624 - atomic_set(&rdev->read_errors, 0);
40625 + atomic_set_unchecked(&rdev->read_errors, 0);
40626 else
40627 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
40628 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
40629 }
40630
40631 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
40632 @@ -2376,8 +2376,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
40633 return;
40634
40635 check_decay_read_errors(mddev, rdev);
40636 - atomic_inc(&rdev->read_errors);
40637 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
40638 + atomic_inc_unchecked(&rdev->read_errors);
40639 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
40640 char b[BDEVNAME_SIZE];
40641 bdevname(rdev->bdev, b);
40642
40643 @@ -2385,7 +2385,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
40644 "md/raid10:%s: %s: Raid device exceeded "
40645 "read_error threshold [cur %d:max %d]\n",
40646 mdname(mddev), b,
40647 - atomic_read(&rdev->read_errors), max_read_errors);
40648 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
40649 printk(KERN_NOTICE
40650 "md/raid10:%s: %s: Failing raid device\n",
40651 mdname(mddev), b);
40652 @@ -2540,7 +2540,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
40653 sect +
40654 choose_data_offset(r10_bio, rdev)),
40655 bdevname(rdev->bdev, b));
40656 - atomic_add(s, &rdev->corrected_errors);
40657 + atomic_add_unchecked(s, &rdev->corrected_errors);
40658 }
40659
40660 rdev_dec_pending(rdev, mddev);
40661 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
40662 index a35b846..e295c6d 100644
40663 --- a/drivers/md/raid5.c
40664 +++ b/drivers/md/raid5.c
40665 @@ -1764,21 +1764,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
40666 mdname(conf->mddev), STRIPE_SECTORS,
40667 (unsigned long long)s,
40668 bdevname(rdev->bdev, b));
40669 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
40670 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
40671 clear_bit(R5_ReadError, &sh->dev[i].flags);
40672 clear_bit(R5_ReWrite, &sh->dev[i].flags);
40673 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
40674 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
40675
40676 - if (atomic_read(&rdev->read_errors))
40677 - atomic_set(&rdev->read_errors, 0);
40678 + if (atomic_read_unchecked(&rdev->read_errors))
40679 + atomic_set_unchecked(&rdev->read_errors, 0);
40680 } else {
40681 const char *bdn = bdevname(rdev->bdev, b);
40682 int retry = 0;
40683 int set_bad = 0;
40684
40685 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
40686 - atomic_inc(&rdev->read_errors);
40687 + atomic_inc_unchecked(&rdev->read_errors);
40688 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
40689 printk_ratelimited(
40690 KERN_WARNING
40691 @@ -1806,7 +1806,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
40692 mdname(conf->mddev),
40693 (unsigned long long)s,
40694 bdn);
40695 - } else if (atomic_read(&rdev->read_errors)
40696 + } else if (atomic_read_unchecked(&rdev->read_errors)
40697 > conf->max_nr_stripes)
40698 printk(KERN_WARNING
40699 "md/raid:%s: Too many read errors, failing device %s.\n",
40700 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
40701 index 401ef64..836e563 100644
40702 --- a/drivers/media/dvb-core/dvbdev.c
40703 +++ b/drivers/media/dvb-core/dvbdev.c
40704 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
40705 const struct dvb_device *template, void *priv, int type)
40706 {
40707 struct dvb_device *dvbdev;
40708 - struct file_operations *dvbdevfops;
40709 + file_operations_no_const *dvbdevfops;
40710 struct device *clsdev;
40711 int minor;
40712 int id;
40713 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
40714 index 9b6c3bb..baeb5c7 100644
40715 --- a/drivers/media/dvb-frontends/dib3000.h
40716 +++ b/drivers/media/dvb-frontends/dib3000.h
40717 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
40718 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
40719 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
40720 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
40721 -};
40722 +} __no_const;
40723
40724 #if IS_ENABLED(CONFIG_DVB_DIB3000MB)
40725 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
40726 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
40727 index c7a9be1..683f6f8 100644
40728 --- a/drivers/media/pci/cx88/cx88-video.c
40729 +++ b/drivers/media/pci/cx88/cx88-video.c
40730 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
40731
40732 /* ------------------------------------------------------------------ */
40733
40734 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
40735 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
40736 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
40737 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
40738 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
40739 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
40740
40741 module_param_array(video_nr, int, NULL, 0444);
40742 module_param_array(vbi_nr, int, NULL, 0444);
40743 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
40744 index d338b19..aae4f9e 100644
40745 --- a/drivers/media/platform/omap/omap_vout.c
40746 +++ b/drivers/media/platform/omap/omap_vout.c
40747 @@ -63,7 +63,6 @@ enum omap_vout_channels {
40748 OMAP_VIDEO2,
40749 };
40750
40751 -static struct videobuf_queue_ops video_vbq_ops;
40752 /* Variables configurable through module params*/
40753 static u32 video1_numbuffers = 3;
40754 static u32 video2_numbuffers = 3;
40755 @@ -1015,6 +1014,12 @@ static int omap_vout_open(struct file *file)
40756 {
40757 struct videobuf_queue *q;
40758 struct omap_vout_device *vout = NULL;
40759 + static struct videobuf_queue_ops video_vbq_ops = {
40760 + .buf_setup = omap_vout_buffer_setup,
40761 + .buf_prepare = omap_vout_buffer_prepare,
40762 + .buf_release = omap_vout_buffer_release,
40763 + .buf_queue = omap_vout_buffer_queue,
40764 + };
40765
40766 vout = video_drvdata(file);
40767 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
40768 @@ -1032,10 +1037,6 @@ static int omap_vout_open(struct file *file)
40769 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
40770
40771 q = &vout->vbq;
40772 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
40773 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
40774 - video_vbq_ops.buf_release = omap_vout_buffer_release;
40775 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
40776 spin_lock_init(&vout->vbq_lock);
40777
40778 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
40779 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
40780 index 04e6490..2df65bf 100644
40781 --- a/drivers/media/platform/s5p-tv/mixer.h
40782 +++ b/drivers/media/platform/s5p-tv/mixer.h
40783 @@ -156,7 +156,7 @@ struct mxr_layer {
40784 /** layer index (unique identifier) */
40785 int idx;
40786 /** callbacks for layer methods */
40787 - struct mxr_layer_ops ops;
40788 + struct mxr_layer_ops *ops;
40789 /** format array */
40790 const struct mxr_format **fmt_array;
40791 /** size of format array */
40792 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
40793 index b93a21f..2535195 100644
40794 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
40795 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
40796 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
40797 {
40798 struct mxr_layer *layer;
40799 int ret;
40800 - struct mxr_layer_ops ops = {
40801 + static struct mxr_layer_ops ops = {
40802 .release = mxr_graph_layer_release,
40803 .buffer_set = mxr_graph_buffer_set,
40804 .stream_set = mxr_graph_stream_set,
40805 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
40806 index b713403..53cb5ad 100644
40807 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
40808 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
40809 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
40810 layer->update_buf = next;
40811 }
40812
40813 - layer->ops.buffer_set(layer, layer->update_buf);
40814 + layer->ops->buffer_set(layer, layer->update_buf);
40815
40816 if (done && done != layer->shadow_buf)
40817 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
40818 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
40819 index ef0efdf..8c78eb6 100644
40820 --- a/drivers/media/platform/s5p-tv/mixer_video.c
40821 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
40822 @@ -209,7 +209,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
40823 layer->geo.src.height = layer->geo.src.full_height;
40824
40825 mxr_geometry_dump(mdev, &layer->geo);
40826 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
40827 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
40828 mxr_geometry_dump(mdev, &layer->geo);
40829 }
40830
40831 @@ -227,7 +227,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
40832 layer->geo.dst.full_width = mbus_fmt.width;
40833 layer->geo.dst.full_height = mbus_fmt.height;
40834 layer->geo.dst.field = mbus_fmt.field;
40835 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
40836 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
40837
40838 mxr_geometry_dump(mdev, &layer->geo);
40839 }
40840 @@ -333,7 +333,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
40841 /* set source size to highest accepted value */
40842 geo->src.full_width = max(geo->dst.full_width, pix->width);
40843 geo->src.full_height = max(geo->dst.full_height, pix->height);
40844 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
40845 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
40846 mxr_geometry_dump(mdev, &layer->geo);
40847 /* set cropping to total visible screen */
40848 geo->src.width = pix->width;
40849 @@ -341,12 +341,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
40850 geo->src.x_offset = 0;
40851 geo->src.y_offset = 0;
40852 /* assure consistency of geometry */
40853 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
40854 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
40855 mxr_geometry_dump(mdev, &layer->geo);
40856 /* set full size to lowest possible value */
40857 geo->src.full_width = 0;
40858 geo->src.full_height = 0;
40859 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
40860 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
40861 mxr_geometry_dump(mdev, &layer->geo);
40862
40863 /* returning results */
40864 @@ -473,7 +473,7 @@ static int mxr_s_selection(struct file *file, void *fh,
40865 target->width = s->r.width;
40866 target->height = s->r.height;
40867
40868 - layer->ops.fix_geometry(layer, stage, s->flags);
40869 + layer->ops->fix_geometry(layer, stage, s->flags);
40870
40871 /* retrieve update selection rectangle */
40872 res.left = target->x_offset;
40873 @@ -954,13 +954,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
40874 mxr_output_get(mdev);
40875
40876 mxr_layer_update_output(layer);
40877 - layer->ops.format_set(layer);
40878 + layer->ops->format_set(layer);
40879 /* enabling layer in hardware */
40880 spin_lock_irqsave(&layer->enq_slock, flags);
40881 layer->state = MXR_LAYER_STREAMING;
40882 spin_unlock_irqrestore(&layer->enq_slock, flags);
40883
40884 - layer->ops.stream_set(layer, MXR_ENABLE);
40885 + layer->ops->stream_set(layer, MXR_ENABLE);
40886 mxr_streamer_get(mdev);
40887
40888 return 0;
40889 @@ -1030,7 +1030,7 @@ static int stop_streaming(struct vb2_queue *vq)
40890 spin_unlock_irqrestore(&layer->enq_slock, flags);
40891
40892 /* disabling layer in hardware */
40893 - layer->ops.stream_set(layer, MXR_DISABLE);
40894 + layer->ops->stream_set(layer, MXR_DISABLE);
40895 /* remove one streamer */
40896 mxr_streamer_put(mdev);
40897 /* allow changes in output configuration */
40898 @@ -1069,8 +1069,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
40899
40900 void mxr_layer_release(struct mxr_layer *layer)
40901 {
40902 - if (layer->ops.release)
40903 - layer->ops.release(layer);
40904 + if (layer->ops->release)
40905 + layer->ops->release(layer);
40906 }
40907
40908 void mxr_base_layer_release(struct mxr_layer *layer)
40909 @@ -1096,7 +1096,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
40910
40911 layer->mdev = mdev;
40912 layer->idx = idx;
40913 - layer->ops = *ops;
40914 + layer->ops = ops;
40915
40916 spin_lock_init(&layer->enq_slock);
40917 INIT_LIST_HEAD(&layer->enq_list);
40918 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
40919 index 3d13a63..da31bf1 100644
40920 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
40921 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
40922 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
40923 {
40924 struct mxr_layer *layer;
40925 int ret;
40926 - struct mxr_layer_ops ops = {
40927 + static struct mxr_layer_ops ops = {
40928 .release = mxr_vp_layer_release,
40929 .buffer_set = mxr_vp_buffer_set,
40930 .stream_set = mxr_vp_stream_set,
40931 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
40932 index 545c04c..a14bded 100644
40933 --- a/drivers/media/radio/radio-cadet.c
40934 +++ b/drivers/media/radio/radio-cadet.c
40935 @@ -324,6 +324,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
40936 unsigned char readbuf[RDS_BUFFER];
40937 int i = 0;
40938
40939 + if (count > RDS_BUFFER)
40940 + return -EFAULT;
40941 mutex_lock(&dev->lock);
40942 if (dev->rdsstat == 0)
40943 cadet_start_rds(dev);
40944 @@ -339,7 +341,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
40945 while (i < count && dev->rdsin != dev->rdsout)
40946 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
40947
40948 - if (i && copy_to_user(data, readbuf, i))
40949 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
40950 i = -EFAULT;
40951 unlock:
40952 mutex_unlock(&dev->lock);
40953 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
40954 index 3940bb0..fb3952a 100644
40955 --- a/drivers/media/usb/dvb-usb/cxusb.c
40956 +++ b/drivers/media/usb/dvb-usb/cxusb.c
40957 @@ -1068,7 +1068,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
40958
40959 struct dib0700_adapter_state {
40960 int (*set_param_save) (struct dvb_frontend *);
40961 -};
40962 +} __no_const;
40963
40964 static int dib7070_set_param_override(struct dvb_frontend *fe)
40965 {
40966 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
40967 index 6e237b6..dc25556 100644
40968 --- a/drivers/media/usb/dvb-usb/dw2102.c
40969 +++ b/drivers/media/usb/dvb-usb/dw2102.c
40970 @@ -118,7 +118,7 @@ struct su3000_state {
40971
40972 struct s6x0_state {
40973 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
40974 -};
40975 +} __no_const;
40976
40977 /* debug */
40978 static int dvb_usb_dw2102_debug;
40979 diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
40980 index f129551..ecf6514 100644
40981 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
40982 +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
40983 @@ -326,7 +326,7 @@ struct v4l2_buffer32 {
40984 __u32 reserved;
40985 };
40986
40987 -static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
40988 +static int get_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
40989 enum v4l2_memory memory)
40990 {
40991 void __user *up_pln;
40992 @@ -355,7 +355,7 @@ static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
40993 return 0;
40994 }
40995
40996 -static int put_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
40997 +static int put_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
40998 enum v4l2_memory memory)
40999 {
41000 if (copy_in_user(up32, up, 2 * sizeof(__u32)) ||
41001 @@ -772,7 +772,7 @@ static int put_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subde
41002 put_user(kp->start_block, &up->start_block) ||
41003 put_user(kp->blocks, &up->blocks) ||
41004 put_user(tmp, &up->edid) ||
41005 - copy_to_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
41006 + copy_to_user(up->reserved, kp->reserved, sizeof(kp->reserved)))
41007 return -EFAULT;
41008 return 0;
41009 }
41010 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
41011 index 7658586..1079260 100644
41012 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
41013 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
41014 @@ -1995,7 +1995,8 @@ struct v4l2_ioctl_info {
41015 struct file *file, void *fh, void *p);
41016 } u;
41017 void (*debug)(const void *arg, bool write_only);
41018 -};
41019 +} __do_const;
41020 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
41021
41022 /* This control needs a priority check */
41023 #define INFO_FL_PRIO (1 << 0)
41024 @@ -2177,7 +2178,7 @@ static long __video_do_ioctl(struct file *file,
41025 struct video_device *vfd = video_devdata(file);
41026 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
41027 bool write_only = false;
41028 - struct v4l2_ioctl_info default_info;
41029 + v4l2_ioctl_info_no_const default_info;
41030 const struct v4l2_ioctl_info *info;
41031 void *fh = file->private_data;
41032 struct v4l2_fh *vfh = NULL;
41033 @@ -2251,7 +2252,7 @@ done:
41034 }
41035
41036 static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
41037 - void * __user *user_ptr, void ***kernel_ptr)
41038 + void __user **user_ptr, void ***kernel_ptr)
41039 {
41040 int ret = 0;
41041
41042 @@ -2267,7 +2268,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
41043 ret = -EINVAL;
41044 break;
41045 }
41046 - *user_ptr = (void __user *)buf->m.planes;
41047 + *user_ptr = (void __force_user *)buf->m.planes;
41048 *kernel_ptr = (void *)&buf->m.planes;
41049 *array_size = sizeof(struct v4l2_plane) * buf->length;
41050 ret = 1;
41051 @@ -2302,7 +2303,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
41052 ret = -EINVAL;
41053 break;
41054 }
41055 - *user_ptr = (void __user *)ctrls->controls;
41056 + *user_ptr = (void __force_user *)ctrls->controls;
41057 *kernel_ptr = (void *)&ctrls->controls;
41058 *array_size = sizeof(struct v4l2_ext_control)
41059 * ctrls->count;
41060 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
41061 index 767ff4d..c69d259 100644
41062 --- a/drivers/message/fusion/mptbase.c
41063 +++ b/drivers/message/fusion/mptbase.c
41064 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
41065 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
41066 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
41067
41068 +#ifdef CONFIG_GRKERNSEC_HIDESYM
41069 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
41070 +#else
41071 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
41072 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
41073 +#endif
41074 +
41075 /*
41076 * Rounding UP to nearest 4-kB boundary here...
41077 */
41078 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
41079 ioc->facts.GlobalCredits);
41080
41081 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
41082 +#ifdef CONFIG_GRKERNSEC_HIDESYM
41083 + NULL, NULL);
41084 +#else
41085 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
41086 +#endif
41087 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
41088 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
41089 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
41090 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
41091 index dd239bd..689c4f7 100644
41092 --- a/drivers/message/fusion/mptsas.c
41093 +++ b/drivers/message/fusion/mptsas.c
41094 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
41095 return 0;
41096 }
41097
41098 +static inline void
41099 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
41100 +{
41101 + if (phy_info->port_details) {
41102 + phy_info->port_details->rphy = rphy;
41103 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
41104 + ioc->name, rphy));
41105 + }
41106 +
41107 + if (rphy) {
41108 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
41109 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
41110 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
41111 + ioc->name, rphy, rphy->dev.release));
41112 + }
41113 +}
41114 +
41115 /* no mutex */
41116 static void
41117 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
41118 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
41119 return NULL;
41120 }
41121
41122 -static inline void
41123 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
41124 -{
41125 - if (phy_info->port_details) {
41126 - phy_info->port_details->rphy = rphy;
41127 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
41128 - ioc->name, rphy));
41129 - }
41130 -
41131 - if (rphy) {
41132 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
41133 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
41134 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
41135 - ioc->name, rphy, rphy->dev.release));
41136 - }
41137 -}
41138 -
41139 static inline struct sas_port *
41140 mptsas_get_port(struct mptsas_phyinfo *phy_info)
41141 {
41142 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
41143 index 727819c..ad74694 100644
41144 --- a/drivers/message/fusion/mptscsih.c
41145 +++ b/drivers/message/fusion/mptscsih.c
41146 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
41147
41148 h = shost_priv(SChost);
41149
41150 - if (h) {
41151 - if (h->info_kbuf == NULL)
41152 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
41153 - return h->info_kbuf;
41154 - h->info_kbuf[0] = '\0';
41155 + if (!h)
41156 + return NULL;
41157
41158 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
41159 - h->info_kbuf[size-1] = '\0';
41160 - }
41161 + if (h->info_kbuf == NULL)
41162 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
41163 + return h->info_kbuf;
41164 + h->info_kbuf[0] = '\0';
41165 +
41166 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
41167 + h->info_kbuf[size-1] = '\0';
41168
41169 return h->info_kbuf;
41170 }
41171 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
41172 index b7d87cd..9890039 100644
41173 --- a/drivers/message/i2o/i2o_proc.c
41174 +++ b/drivers/message/i2o/i2o_proc.c
41175 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
41176 "Array Controller Device"
41177 };
41178
41179 -static char *chtostr(char *tmp, u8 *chars, int n)
41180 -{
41181 - tmp[0] = 0;
41182 - return strncat(tmp, (char *)chars, n);
41183 -}
41184 -
41185 static int i2o_report_query_status(struct seq_file *seq, int block_status,
41186 char *group)
41187 {
41188 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
41189 } *result;
41190
41191 i2o_exec_execute_ddm_table ddm_table;
41192 - char tmp[28 + 1];
41193
41194 result = kmalloc(sizeof(*result), GFP_KERNEL);
41195 if (!result)
41196 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
41197
41198 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
41199 seq_printf(seq, "%-#8x", ddm_table.module_id);
41200 - seq_printf(seq, "%-29s",
41201 - chtostr(tmp, ddm_table.module_name_version, 28));
41202 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
41203 seq_printf(seq, "%9d ", ddm_table.data_size);
41204 seq_printf(seq, "%8d", ddm_table.code_size);
41205
41206 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
41207
41208 i2o_driver_result_table *result;
41209 i2o_driver_store_table *dst;
41210 - char tmp[28 + 1];
41211
41212 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
41213 if (result == NULL)
41214 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
41215
41216 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
41217 seq_printf(seq, "%-#8x", dst->module_id);
41218 - seq_printf(seq, "%-29s",
41219 - chtostr(tmp, dst->module_name_version, 28));
41220 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
41221 + seq_printf(seq, "%-.28s", dst->module_name_version);
41222 + seq_printf(seq, "%-.8s", dst->date);
41223 seq_printf(seq, "%8d ", dst->module_size);
41224 seq_printf(seq, "%8d ", dst->mpb_size);
41225 seq_printf(seq, "0x%04x", dst->module_flags);
41226 @@ -1250,7 +1240,6 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
41227 // == (allow) 512d bytes (max)
41228 static u16 *work16 = (u16 *) work32;
41229 int token;
41230 - char tmp[16 + 1];
41231
41232 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
41233
41234 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
41235 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
41236 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
41237 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
41238 - seq_printf(seq, "Vendor info : %s\n",
41239 - chtostr(tmp, (u8 *) (work32 + 2), 16));
41240 - seq_printf(seq, "Product info : %s\n",
41241 - chtostr(tmp, (u8 *) (work32 + 6), 16));
41242 - seq_printf(seq, "Description : %s\n",
41243 - chtostr(tmp, (u8 *) (work32 + 10), 16));
41244 - seq_printf(seq, "Product rev. : %s\n",
41245 - chtostr(tmp, (u8 *) (work32 + 14), 8));
41246 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
41247 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
41248 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
41249 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
41250
41251 seq_printf(seq, "Serial number : ");
41252 print_serial_number(seq, (u8 *) (work32 + 16),
41253 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
41254 u8 pad[256]; // allow up to 256 byte (max) serial number
41255 } result;
41256
41257 - char tmp[24 + 1];
41258 -
41259 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
41260
41261 if (token < 0) {
41262 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
41263 }
41264
41265 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
41266 - seq_printf(seq, "Module name : %s\n",
41267 - chtostr(tmp, result.module_name, 24));
41268 - seq_printf(seq, "Module revision : %s\n",
41269 - chtostr(tmp, result.module_rev, 8));
41270 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
41271 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
41272
41273 seq_printf(seq, "Serial number : ");
41274 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
41275 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
41276 u8 instance_number[4];
41277 } result;
41278
41279 - char tmp[64 + 1];
41280 -
41281 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
41282
41283 if (token < 0) {
41284 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
41285 return 0;
41286 }
41287
41288 - seq_printf(seq, "Device name : %s\n",
41289 - chtostr(tmp, result.device_name, 64));
41290 - seq_printf(seq, "Service name : %s\n",
41291 - chtostr(tmp, result.service_name, 64));
41292 - seq_printf(seq, "Physical name : %s\n",
41293 - chtostr(tmp, result.physical_location, 64));
41294 - seq_printf(seq, "Instance number : %s\n",
41295 - chtostr(tmp, result.instance_number, 4));
41296 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
41297 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
41298 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
41299 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
41300
41301 return 0;
41302 }
41303 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
41304 index a8c08f3..155fe3d 100644
41305 --- a/drivers/message/i2o/iop.c
41306 +++ b/drivers/message/i2o/iop.c
41307 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
41308
41309 spin_lock_irqsave(&c->context_list_lock, flags);
41310
41311 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
41312 - atomic_inc(&c->context_list_counter);
41313 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
41314 + atomic_inc_unchecked(&c->context_list_counter);
41315
41316 - entry->context = atomic_read(&c->context_list_counter);
41317 + entry->context = atomic_read_unchecked(&c->context_list_counter);
41318
41319 list_add(&entry->list, &c->context_list);
41320
41321 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
41322
41323 #if BITS_PER_LONG == 64
41324 spin_lock_init(&c->context_list_lock);
41325 - atomic_set(&c->context_list_counter, 0);
41326 + atomic_set_unchecked(&c->context_list_counter, 0);
41327 INIT_LIST_HEAD(&c->context_list);
41328 #endif
41329
41330 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
41331 index 45ece11..8efa218 100644
41332 --- a/drivers/mfd/janz-cmodio.c
41333 +++ b/drivers/mfd/janz-cmodio.c
41334 @@ -13,6 +13,7 @@
41335
41336 #include <linux/kernel.h>
41337 #include <linux/module.h>
41338 +#include <linux/slab.h>
41339 #include <linux/init.h>
41340 #include <linux/pci.h>
41341 #include <linux/interrupt.h>
41342 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
41343 index a5f9888..1c0ed56 100644
41344 --- a/drivers/mfd/twl4030-irq.c
41345 +++ b/drivers/mfd/twl4030-irq.c
41346 @@ -35,6 +35,7 @@
41347 #include <linux/of.h>
41348 #include <linux/irqdomain.h>
41349 #include <linux/i2c/twl.h>
41350 +#include <asm/pgtable.h>
41351
41352 #include "twl-core.h"
41353
41354 @@ -728,10 +729,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
41355 * Install an irq handler for each of the SIH modules;
41356 * clone dummy irq_chip since PIH can't *do* anything
41357 */
41358 - twl4030_irq_chip = dummy_irq_chip;
41359 - twl4030_irq_chip.name = "twl4030";
41360 + pax_open_kernel();
41361 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
41362 + *(const char **)&twl4030_irq_chip.name = "twl4030";
41363
41364 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
41365 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
41366 + pax_close_kernel();
41367
41368 for (i = irq_base; i < irq_end; i++) {
41369 irq_set_chip_and_handler(i, &twl4030_irq_chip,
41370 diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
41371 index 277a8db..0e0b754 100644
41372 --- a/drivers/mfd/twl6030-irq.c
41373 +++ b/drivers/mfd/twl6030-irq.c
41374 @@ -387,10 +387,12 @@ int twl6030_init_irq(struct device *dev, int irq_num)
41375 * install an irq handler for each of the modules;
41376 * clone dummy irq_chip since PIH can't *do* anything
41377 */
41378 - twl6030_irq_chip = dummy_irq_chip;
41379 - twl6030_irq_chip.name = "twl6030";
41380 - twl6030_irq_chip.irq_set_type = NULL;
41381 - twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
41382 + pax_open_kernel();
41383 + memcpy((void *)&twl6030_irq_chip, &dummy_irq_chip, sizeof twl6030_irq_chip);
41384 + *(const char **)&twl6030_irq_chip.name = "twl6030";
41385 + *(void **)&twl6030_irq_chip.irq_set_type = NULL;
41386 + *(void **)&twl6030_irq_chip.irq_set_wake = twl6030_irq_set_wake;
41387 + pax_close_kernel();
41388
41389 for (i = irq_base; i < irq_end; i++) {
41390 irq_set_chip_and_handler(i, &twl6030_irq_chip,
41391 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
41392 index f32550a..e3e52a2 100644
41393 --- a/drivers/misc/c2port/core.c
41394 +++ b/drivers/misc/c2port/core.c
41395 @@ -920,7 +920,9 @@ struct c2port_device *c2port_device_register(char *name,
41396 mutex_init(&c2dev->mutex);
41397
41398 /* Create binary file */
41399 - c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
41400 + pax_open_kernel();
41401 + *(size_t *)&c2port_bin_attrs.size = ops->blocks_num * ops->block_size;
41402 + pax_close_kernel();
41403 ret = device_create_bin_file(c2dev->dev, &c2port_bin_attrs);
41404 if (unlikely(ret))
41405 goto error_device_create_bin_file;
41406 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
41407 index 36f5d52..32311c3 100644
41408 --- a/drivers/misc/kgdbts.c
41409 +++ b/drivers/misc/kgdbts.c
41410 @@ -834,7 +834,7 @@ static void run_plant_and_detach_test(int is_early)
41411 char before[BREAK_INSTR_SIZE];
41412 char after[BREAK_INSTR_SIZE];
41413
41414 - probe_kernel_read(before, (char *)kgdbts_break_test,
41415 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
41416 BREAK_INSTR_SIZE);
41417 init_simple_test();
41418 ts.tst = plant_and_detach_test;
41419 @@ -842,7 +842,7 @@ static void run_plant_and_detach_test(int is_early)
41420 /* Activate test with initial breakpoint */
41421 if (!is_early)
41422 kgdb_breakpoint();
41423 - probe_kernel_read(after, (char *)kgdbts_break_test,
41424 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
41425 BREAK_INSTR_SIZE);
41426 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
41427 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
41428 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
41429 index 4cd4a3d..b48cbc7 100644
41430 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
41431 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
41432 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
41433 * the lid is closed. This leads to interrupts as soon as a little move
41434 * is done.
41435 */
41436 - atomic_inc(&lis3->count);
41437 + atomic_inc_unchecked(&lis3->count);
41438
41439 wake_up_interruptible(&lis3->misc_wait);
41440 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
41441 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
41442 if (lis3->pm_dev)
41443 pm_runtime_get_sync(lis3->pm_dev);
41444
41445 - atomic_set(&lis3->count, 0);
41446 + atomic_set_unchecked(&lis3->count, 0);
41447 return 0;
41448 }
41449
41450 @@ -616,7 +616,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
41451 add_wait_queue(&lis3->misc_wait, &wait);
41452 while (true) {
41453 set_current_state(TASK_INTERRUPTIBLE);
41454 - data = atomic_xchg(&lis3->count, 0);
41455 + data = atomic_xchg_unchecked(&lis3->count, 0);
41456 if (data)
41457 break;
41458
41459 @@ -657,7 +657,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
41460 struct lis3lv02d, miscdev);
41461
41462 poll_wait(file, &lis3->misc_wait, wait);
41463 - if (atomic_read(&lis3->count))
41464 + if (atomic_read_unchecked(&lis3->count))
41465 return POLLIN | POLLRDNORM;
41466 return 0;
41467 }
41468 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
41469 index c439c82..1f20f57 100644
41470 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
41471 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
41472 @@ -297,7 +297,7 @@ struct lis3lv02d {
41473 struct input_polled_dev *idev; /* input device */
41474 struct platform_device *pdev; /* platform device */
41475 struct regulator_bulk_data regulators[2];
41476 - atomic_t count; /* interrupt count after last read */
41477 + atomic_unchecked_t count; /* interrupt count after last read */
41478 union axis_conversion ac; /* hw -> logical axis */
41479 int mapped_btns[3];
41480
41481 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
41482 index 2f30bad..c4c13d0 100644
41483 --- a/drivers/misc/sgi-gru/gruhandles.c
41484 +++ b/drivers/misc/sgi-gru/gruhandles.c
41485 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
41486 unsigned long nsec;
41487
41488 nsec = CLKS2NSEC(clks);
41489 - atomic_long_inc(&mcs_op_statistics[op].count);
41490 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
41491 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
41492 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
41493 if (mcs_op_statistics[op].max < nsec)
41494 mcs_op_statistics[op].max = nsec;
41495 }
41496 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
41497 index 797d796..ae8f01e 100644
41498 --- a/drivers/misc/sgi-gru/gruprocfs.c
41499 +++ b/drivers/misc/sgi-gru/gruprocfs.c
41500 @@ -32,9 +32,9 @@
41501
41502 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
41503
41504 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
41505 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
41506 {
41507 - unsigned long val = atomic_long_read(v);
41508 + unsigned long val = atomic_long_read_unchecked(v);
41509
41510 seq_printf(s, "%16lu %s\n", val, id);
41511 }
41512 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
41513
41514 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
41515 for (op = 0; op < mcsop_last; op++) {
41516 - count = atomic_long_read(&mcs_op_statistics[op].count);
41517 - total = atomic_long_read(&mcs_op_statistics[op].total);
41518 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
41519 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
41520 max = mcs_op_statistics[op].max;
41521 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
41522 count ? total / count : 0, max);
41523 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
41524 index 5c3ce24..4915ccb 100644
41525 --- a/drivers/misc/sgi-gru/grutables.h
41526 +++ b/drivers/misc/sgi-gru/grutables.h
41527 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
41528 * GRU statistics.
41529 */
41530 struct gru_stats_s {
41531 - atomic_long_t vdata_alloc;
41532 - atomic_long_t vdata_free;
41533 - atomic_long_t gts_alloc;
41534 - atomic_long_t gts_free;
41535 - atomic_long_t gms_alloc;
41536 - atomic_long_t gms_free;
41537 - atomic_long_t gts_double_allocate;
41538 - atomic_long_t assign_context;
41539 - atomic_long_t assign_context_failed;
41540 - atomic_long_t free_context;
41541 - atomic_long_t load_user_context;
41542 - atomic_long_t load_kernel_context;
41543 - atomic_long_t lock_kernel_context;
41544 - atomic_long_t unlock_kernel_context;
41545 - atomic_long_t steal_user_context;
41546 - atomic_long_t steal_kernel_context;
41547 - atomic_long_t steal_context_failed;
41548 - atomic_long_t nopfn;
41549 - atomic_long_t asid_new;
41550 - atomic_long_t asid_next;
41551 - atomic_long_t asid_wrap;
41552 - atomic_long_t asid_reuse;
41553 - atomic_long_t intr;
41554 - atomic_long_t intr_cbr;
41555 - atomic_long_t intr_tfh;
41556 - atomic_long_t intr_spurious;
41557 - atomic_long_t intr_mm_lock_failed;
41558 - atomic_long_t call_os;
41559 - atomic_long_t call_os_wait_queue;
41560 - atomic_long_t user_flush_tlb;
41561 - atomic_long_t user_unload_context;
41562 - atomic_long_t user_exception;
41563 - atomic_long_t set_context_option;
41564 - atomic_long_t check_context_retarget_intr;
41565 - atomic_long_t check_context_unload;
41566 - atomic_long_t tlb_dropin;
41567 - atomic_long_t tlb_preload_page;
41568 - atomic_long_t tlb_dropin_fail_no_asid;
41569 - atomic_long_t tlb_dropin_fail_upm;
41570 - atomic_long_t tlb_dropin_fail_invalid;
41571 - atomic_long_t tlb_dropin_fail_range_active;
41572 - atomic_long_t tlb_dropin_fail_idle;
41573 - atomic_long_t tlb_dropin_fail_fmm;
41574 - atomic_long_t tlb_dropin_fail_no_exception;
41575 - atomic_long_t tfh_stale_on_fault;
41576 - atomic_long_t mmu_invalidate_range;
41577 - atomic_long_t mmu_invalidate_page;
41578 - atomic_long_t flush_tlb;
41579 - atomic_long_t flush_tlb_gru;
41580 - atomic_long_t flush_tlb_gru_tgh;
41581 - atomic_long_t flush_tlb_gru_zero_asid;
41582 + atomic_long_unchecked_t vdata_alloc;
41583 + atomic_long_unchecked_t vdata_free;
41584 + atomic_long_unchecked_t gts_alloc;
41585 + atomic_long_unchecked_t gts_free;
41586 + atomic_long_unchecked_t gms_alloc;
41587 + atomic_long_unchecked_t gms_free;
41588 + atomic_long_unchecked_t gts_double_allocate;
41589 + atomic_long_unchecked_t assign_context;
41590 + atomic_long_unchecked_t assign_context_failed;
41591 + atomic_long_unchecked_t free_context;
41592 + atomic_long_unchecked_t load_user_context;
41593 + atomic_long_unchecked_t load_kernel_context;
41594 + atomic_long_unchecked_t lock_kernel_context;
41595 + atomic_long_unchecked_t unlock_kernel_context;
41596 + atomic_long_unchecked_t steal_user_context;
41597 + atomic_long_unchecked_t steal_kernel_context;
41598 + atomic_long_unchecked_t steal_context_failed;
41599 + atomic_long_unchecked_t nopfn;
41600 + atomic_long_unchecked_t asid_new;
41601 + atomic_long_unchecked_t asid_next;
41602 + atomic_long_unchecked_t asid_wrap;
41603 + atomic_long_unchecked_t asid_reuse;
41604 + atomic_long_unchecked_t intr;
41605 + atomic_long_unchecked_t intr_cbr;
41606 + atomic_long_unchecked_t intr_tfh;
41607 + atomic_long_unchecked_t intr_spurious;
41608 + atomic_long_unchecked_t intr_mm_lock_failed;
41609 + atomic_long_unchecked_t call_os;
41610 + atomic_long_unchecked_t call_os_wait_queue;
41611 + atomic_long_unchecked_t user_flush_tlb;
41612 + atomic_long_unchecked_t user_unload_context;
41613 + atomic_long_unchecked_t user_exception;
41614 + atomic_long_unchecked_t set_context_option;
41615 + atomic_long_unchecked_t check_context_retarget_intr;
41616 + atomic_long_unchecked_t check_context_unload;
41617 + atomic_long_unchecked_t tlb_dropin;
41618 + atomic_long_unchecked_t tlb_preload_page;
41619 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
41620 + atomic_long_unchecked_t tlb_dropin_fail_upm;
41621 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
41622 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
41623 + atomic_long_unchecked_t tlb_dropin_fail_idle;
41624 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
41625 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
41626 + atomic_long_unchecked_t tfh_stale_on_fault;
41627 + atomic_long_unchecked_t mmu_invalidate_range;
41628 + atomic_long_unchecked_t mmu_invalidate_page;
41629 + atomic_long_unchecked_t flush_tlb;
41630 + atomic_long_unchecked_t flush_tlb_gru;
41631 + atomic_long_unchecked_t flush_tlb_gru_tgh;
41632 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
41633
41634 - atomic_long_t copy_gpa;
41635 - atomic_long_t read_gpa;
41636 + atomic_long_unchecked_t copy_gpa;
41637 + atomic_long_unchecked_t read_gpa;
41638
41639 - atomic_long_t mesq_receive;
41640 - atomic_long_t mesq_receive_none;
41641 - atomic_long_t mesq_send;
41642 - atomic_long_t mesq_send_failed;
41643 - atomic_long_t mesq_noop;
41644 - atomic_long_t mesq_send_unexpected_error;
41645 - atomic_long_t mesq_send_lb_overflow;
41646 - atomic_long_t mesq_send_qlimit_reached;
41647 - atomic_long_t mesq_send_amo_nacked;
41648 - atomic_long_t mesq_send_put_nacked;
41649 - atomic_long_t mesq_page_overflow;
41650 - atomic_long_t mesq_qf_locked;
41651 - atomic_long_t mesq_qf_noop_not_full;
41652 - atomic_long_t mesq_qf_switch_head_failed;
41653 - atomic_long_t mesq_qf_unexpected_error;
41654 - atomic_long_t mesq_noop_unexpected_error;
41655 - atomic_long_t mesq_noop_lb_overflow;
41656 - atomic_long_t mesq_noop_qlimit_reached;
41657 - atomic_long_t mesq_noop_amo_nacked;
41658 - atomic_long_t mesq_noop_put_nacked;
41659 - atomic_long_t mesq_noop_page_overflow;
41660 + atomic_long_unchecked_t mesq_receive;
41661 + atomic_long_unchecked_t mesq_receive_none;
41662 + atomic_long_unchecked_t mesq_send;
41663 + atomic_long_unchecked_t mesq_send_failed;
41664 + atomic_long_unchecked_t mesq_noop;
41665 + atomic_long_unchecked_t mesq_send_unexpected_error;
41666 + atomic_long_unchecked_t mesq_send_lb_overflow;
41667 + atomic_long_unchecked_t mesq_send_qlimit_reached;
41668 + atomic_long_unchecked_t mesq_send_amo_nacked;
41669 + atomic_long_unchecked_t mesq_send_put_nacked;
41670 + atomic_long_unchecked_t mesq_page_overflow;
41671 + atomic_long_unchecked_t mesq_qf_locked;
41672 + atomic_long_unchecked_t mesq_qf_noop_not_full;
41673 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
41674 + atomic_long_unchecked_t mesq_qf_unexpected_error;
41675 + atomic_long_unchecked_t mesq_noop_unexpected_error;
41676 + atomic_long_unchecked_t mesq_noop_lb_overflow;
41677 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
41678 + atomic_long_unchecked_t mesq_noop_amo_nacked;
41679 + atomic_long_unchecked_t mesq_noop_put_nacked;
41680 + atomic_long_unchecked_t mesq_noop_page_overflow;
41681
41682 };
41683
41684 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
41685 tghop_invalidate, mcsop_last};
41686
41687 struct mcs_op_statistic {
41688 - atomic_long_t count;
41689 - atomic_long_t total;
41690 + atomic_long_unchecked_t count;
41691 + atomic_long_unchecked_t total;
41692 unsigned long max;
41693 };
41694
41695 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
41696
41697 #define STAT(id) do { \
41698 if (gru_options & OPT_STATS) \
41699 - atomic_long_inc(&gru_stats.id); \
41700 + atomic_long_inc_unchecked(&gru_stats.id); \
41701 } while (0)
41702
41703 #ifdef CONFIG_SGI_GRU_DEBUG
41704 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
41705 index c862cd4..0d176fe 100644
41706 --- a/drivers/misc/sgi-xp/xp.h
41707 +++ b/drivers/misc/sgi-xp/xp.h
41708 @@ -288,7 +288,7 @@ struct xpc_interface {
41709 xpc_notify_func, void *);
41710 void (*received) (short, int, void *);
41711 enum xp_retval (*partid_to_nasids) (short, void *);
41712 -};
41713 +} __no_const;
41714
41715 extern struct xpc_interface xpc_interface;
41716
41717 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
41718 index b94d5f7..7f494c5 100644
41719 --- a/drivers/misc/sgi-xp/xpc.h
41720 +++ b/drivers/misc/sgi-xp/xpc.h
41721 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
41722 void (*received_payload) (struct xpc_channel *, void *);
41723 void (*notify_senders_of_disconnect) (struct xpc_channel *);
41724 };
41725 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
41726
41727 /* struct xpc_partition act_state values (for XPC HB) */
41728
41729 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
41730 /* found in xpc_main.c */
41731 extern struct device *xpc_part;
41732 extern struct device *xpc_chan;
41733 -extern struct xpc_arch_operations xpc_arch_ops;
41734 +extern xpc_arch_operations_no_const xpc_arch_ops;
41735 extern int xpc_disengage_timelimit;
41736 extern int xpc_disengage_timedout;
41737 extern int xpc_activate_IRQ_rcvd;
41738 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
41739 index d971817..33bdca5 100644
41740 --- a/drivers/misc/sgi-xp/xpc_main.c
41741 +++ b/drivers/misc/sgi-xp/xpc_main.c
41742 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
41743 .notifier_call = xpc_system_die,
41744 };
41745
41746 -struct xpc_arch_operations xpc_arch_ops;
41747 +xpc_arch_operations_no_const xpc_arch_ops;
41748
41749 /*
41750 * Timer function to enforce the timelimit on the partition disengage.
41751 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
41752
41753 if (((die_args->trapnr == X86_TRAP_MF) ||
41754 (die_args->trapnr == X86_TRAP_XF)) &&
41755 - !user_mode_vm(die_args->regs))
41756 + !user_mode(die_args->regs))
41757 xpc_die_deactivate();
41758
41759 break;
41760 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
41761 index 49f04bc..65660c2 100644
41762 --- a/drivers/mmc/core/mmc_ops.c
41763 +++ b/drivers/mmc/core/mmc_ops.c
41764 @@ -247,7 +247,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
41765 void *data_buf;
41766 int is_on_stack;
41767
41768 - is_on_stack = object_is_on_stack(buf);
41769 + is_on_stack = object_starts_on_stack(buf);
41770 if (is_on_stack) {
41771 /*
41772 * dma onto stack is unsafe/nonportable, but callers to this
41773 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
41774 index 0b74189..818358f 100644
41775 --- a/drivers/mmc/host/dw_mmc.h
41776 +++ b/drivers/mmc/host/dw_mmc.h
41777 @@ -202,5 +202,5 @@ struct dw_mci_drv_data {
41778 void (*prepare_command)(struct dw_mci *host, u32 *cmdr);
41779 void (*set_ios)(struct dw_mci *host, struct mmc_ios *ios);
41780 int (*parse_dt)(struct dw_mci *host);
41781 -};
41782 +} __do_const;
41783 #endif /* _DW_MMC_H_ */
41784 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
41785 index c6f6246..60760a8 100644
41786 --- a/drivers/mmc/host/sdhci-s3c.c
41787 +++ b/drivers/mmc/host/sdhci-s3c.c
41788 @@ -664,9 +664,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
41789 * we can use overriding functions instead of default.
41790 */
41791 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
41792 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
41793 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
41794 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
41795 + pax_open_kernel();
41796 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
41797 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
41798 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
41799 + pax_close_kernel();
41800 }
41801
41802 /* It supports additional host capabilities if needed */
41803 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
41804 index 0c8bb6b..6f35deb 100644
41805 --- a/drivers/mtd/nand/denali.c
41806 +++ b/drivers/mtd/nand/denali.c
41807 @@ -24,6 +24,7 @@
41808 #include <linux/slab.h>
41809 #include <linux/mtd/mtd.h>
41810 #include <linux/module.h>
41811 +#include <linux/slab.h>
41812
41813 #include "denali.h"
41814
41815 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
41816 index 51b9d6a..52af9a7 100644
41817 --- a/drivers/mtd/nftlmount.c
41818 +++ b/drivers/mtd/nftlmount.c
41819 @@ -24,6 +24,7 @@
41820 #include <asm/errno.h>
41821 #include <linux/delay.h>
41822 #include <linux/slab.h>
41823 +#include <linux/sched.h>
41824 #include <linux/mtd/mtd.h>
41825 #include <linux/mtd/nand.h>
41826 #include <linux/mtd/nftl.h>
41827 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
41828 index f9d5615..99dd95f 100644
41829 --- a/drivers/mtd/sm_ftl.c
41830 +++ b/drivers/mtd/sm_ftl.c
41831 @@ -56,7 +56,7 @@ ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
41832 #define SM_CIS_VENDOR_OFFSET 0x59
41833 struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
41834 {
41835 - struct attribute_group *attr_group;
41836 + attribute_group_no_const *attr_group;
41837 struct attribute **attributes;
41838 struct sm_sysfs_attribute *vendor_attribute;
41839
41840 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
41841 index f975696..4597e21 100644
41842 --- a/drivers/net/bonding/bond_main.c
41843 +++ b/drivers/net/bonding/bond_main.c
41844 @@ -4870,7 +4870,7 @@ static unsigned int bond_get_num_tx_queues(void)
41845 return tx_queues;
41846 }
41847
41848 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
41849 +static struct rtnl_link_ops bond_link_ops = {
41850 .kind = "bond",
41851 .priv_size = sizeof(struct bonding),
41852 .setup = bond_setup,
41853 @@ -4995,8 +4995,8 @@ static void __exit bonding_exit(void)
41854
41855 bond_destroy_debugfs();
41856
41857 - rtnl_link_unregister(&bond_link_ops);
41858 unregister_pernet_subsys(&bond_net_ops);
41859 + rtnl_link_unregister(&bond_link_ops);
41860
41861 #ifdef CONFIG_NET_POLL_CONTROLLER
41862 /*
41863 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
41864 index e1d2643..7f4133b 100644
41865 --- a/drivers/net/ethernet/8390/ax88796.c
41866 +++ b/drivers/net/ethernet/8390/ax88796.c
41867 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
41868 if (ax->plat->reg_offsets)
41869 ei_local->reg_offset = ax->plat->reg_offsets;
41870 else {
41871 + resource_size_t _mem_size = mem_size;
41872 + do_div(_mem_size, 0x18);
41873 ei_local->reg_offset = ax->reg_offsets;
41874 for (ret = 0; ret < 0x18; ret++)
41875 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
41876 + ax->reg_offsets[ret] = _mem_size * ret;
41877 }
41878
41879 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
41880 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
41881 index 151675d..0139a9d 100644
41882 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
41883 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
41884 @@ -1112,7 +1112,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
41885 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
41886 {
41887 /* RX_MODE controlling object */
41888 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
41889 + bnx2x_init_rx_mode_obj(bp);
41890
41891 /* multicast configuration controlling object */
41892 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
41893 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
41894 index ce1a916..10b52b0 100644
41895 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
41896 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c
41897 @@ -960,6 +960,9 @@ static int bnx2x_set_dump(struct net_device *dev, struct ethtool_dump *val)
41898 struct bnx2x *bp = netdev_priv(dev);
41899
41900 /* Use the ethtool_dump "flag" field as the dump preset index */
41901 + if (val->flag < 1 || val->flag > DUMP_MAX_PRESETS)
41902 + return -EINVAL;
41903 +
41904 bp->dump_preset_idx = val->flag;
41905 return 0;
41906 }
41907 @@ -986,8 +989,6 @@ static int bnx2x_get_dump_data(struct net_device *dev,
41908 struct bnx2x *bp = netdev_priv(dev);
41909 struct dump_header dump_hdr = {0};
41910
41911 - memset(p, 0, dump->len);
41912 -
41913 /* Disable parity attentions as long as following dump may
41914 * cause false alarms by reading never written registers. We
41915 * will re-enable parity attentions right after the dump.
41916 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
41917 index b4c9dea..2a9927f 100644
41918 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
41919 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
41920 @@ -11497,6 +11497,8 @@ static int bnx2x_init_bp(struct bnx2x *bp)
41921 bp->min_msix_vec_cnt = 2;
41922 BNX2X_DEV_INFO("bp->min_msix_vec_cnt %d", bp->min_msix_vec_cnt);
41923
41924 + bp->dump_preset_idx = 1;
41925 +
41926 return rc;
41927 }
41928
41929 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
41930 index 32a9609..0b1c53a 100644
41931 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
41932 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
41933 @@ -2387,15 +2387,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
41934 return rc;
41935 }
41936
41937 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
41938 - struct bnx2x_rx_mode_obj *o)
41939 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
41940 {
41941 if (CHIP_IS_E1x(bp)) {
41942 - o->wait_comp = bnx2x_empty_rx_mode_wait;
41943 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
41944 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
41945 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
41946 } else {
41947 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
41948 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
41949 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
41950 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
41951 }
41952 }
41953
41954 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
41955 index 43c00bc..dd1d03d 100644
41956 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
41957 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
41958 @@ -1321,8 +1321,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
41959
41960 /********************* RX MODE ****************/
41961
41962 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
41963 - struct bnx2x_rx_mode_obj *o);
41964 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
41965
41966 /**
41967 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
41968 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
41969 index ff6e30e..87e8452 100644
41970 --- a/drivers/net/ethernet/broadcom/tg3.h
41971 +++ b/drivers/net/ethernet/broadcom/tg3.h
41972 @@ -147,6 +147,7 @@
41973 #define CHIPREV_ID_5750_A0 0x4000
41974 #define CHIPREV_ID_5750_A1 0x4001
41975 #define CHIPREV_ID_5750_A3 0x4003
41976 +#define CHIPREV_ID_5750_C1 0x4201
41977 #define CHIPREV_ID_5750_C2 0x4202
41978 #define CHIPREV_ID_5752_A0_HW 0x5000
41979 #define CHIPREV_ID_5752_A0 0x6000
41980 diff --git a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
41981 index 71497e8..b650951 100644
41982 --- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
41983 +++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
41984 @@ -3037,7 +3037,9 @@ static void t3_io_resume(struct pci_dev *pdev)
41985 CH_ALERT(adapter, "adapter recovering, PEX ERR 0x%x\n",
41986 t3_read_reg(adapter, A_PCIE_PEX_ERR));
41987
41988 + rtnl_lock();
41989 t3_resume_ports(adapter);
41990 + rtnl_unlock();
41991 }
41992
41993 static const struct pci_error_handlers t3_err_handler = {
41994 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
41995 index 8cffcdf..aadf043 100644
41996 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
41997 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
41998 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
41999 */
42000 struct l2t_skb_cb {
42001 arp_failure_handler_func arp_failure_handler;
42002 -};
42003 +} __no_const;
42004
42005 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
42006
42007 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
42008 index 4c83003..2a2a5b9 100644
42009 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
42010 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
42011 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
42012 for (i=0; i<ETH_ALEN; i++) {
42013 tmp.addr[i] = dev->dev_addr[i];
42014 }
42015 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
42016 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
42017 break;
42018
42019 case DE4X5_SET_HWADDR: /* Set the hardware address */
42020 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
42021 spin_lock_irqsave(&lp->lock, flags);
42022 memcpy(&statbuf, &lp->pktStats, ioc->len);
42023 spin_unlock_irqrestore(&lp->lock, flags);
42024 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
42025 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
42026 return -EFAULT;
42027 break;
42028 }
42029 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
42030 index 6e43426..1bd8365 100644
42031 --- a/drivers/net/ethernet/emulex/benet/be_main.c
42032 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
42033 @@ -469,7 +469,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
42034
42035 if (wrapped)
42036 newacc += 65536;
42037 - ACCESS_ONCE(*acc) = newacc;
42038 + ACCESS_ONCE_RW(*acc) = newacc;
42039 }
42040
42041 void populate_erx_stats(struct be_adapter *adapter,
42042 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
42043 index 21b85fb..b49e5fc 100644
42044 --- a/drivers/net/ethernet/faraday/ftgmac100.c
42045 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
42046 @@ -31,6 +31,8 @@
42047 #include <linux/netdevice.h>
42048 #include <linux/phy.h>
42049 #include <linux/platform_device.h>
42050 +#include <linux/interrupt.h>
42051 +#include <linux/irqreturn.h>
42052 #include <net/ip.h>
42053
42054 #include "ftgmac100.h"
42055 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
42056 index a6eda8d..935d273 100644
42057 --- a/drivers/net/ethernet/faraday/ftmac100.c
42058 +++ b/drivers/net/ethernet/faraday/ftmac100.c
42059 @@ -31,6 +31,8 @@
42060 #include <linux/module.h>
42061 #include <linux/netdevice.h>
42062 #include <linux/platform_device.h>
42063 +#include <linux/interrupt.h>
42064 +#include <linux/irqreturn.h>
42065
42066 #include "ftmac100.h"
42067
42068 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
42069 index 331987d..3be1135 100644
42070 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
42071 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
42072 @@ -776,7 +776,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
42073 }
42074
42075 /* update the base incval used to calculate frequency adjustment */
42076 - ACCESS_ONCE(adapter->base_incval) = incval;
42077 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
42078 smp_mb();
42079
42080 /* need lock to prevent incorrect read while modifying cyclecounter */
42081 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
42082 index fbe5363..266b4e3 100644
42083 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
42084 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
42085 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
42086 struct __vxge_hw_fifo *fifo;
42087 struct vxge_hw_fifo_config *config;
42088 u32 txdl_size, txdl_per_memblock;
42089 - struct vxge_hw_mempool_cbs fifo_mp_callback;
42090 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
42091 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
42092 + };
42093 +
42094 struct __vxge_hw_virtualpath *vpath;
42095
42096 if ((vp == NULL) || (attr == NULL)) {
42097 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
42098 goto exit;
42099 }
42100
42101 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
42102 -
42103 fifo->mempool =
42104 __vxge_hw_mempool_create(vpath->hldev,
42105 fifo->config->memblock_size,
42106 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
42107 index 5e7fb1d..f8d1810 100644
42108 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
42109 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
42110 @@ -1948,7 +1948,9 @@ int qlcnic_83xx_config_default_opmode(struct qlcnic_adapter *adapter)
42111 op_mode = QLC_83XX_DEFAULT_OPMODE;
42112
42113 if (op_mode == QLC_83XX_DEFAULT_OPMODE) {
42114 - adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
42115 + pax_open_kernel();
42116 + *(void **)&adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
42117 + pax_close_kernel();
42118 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
42119 } else {
42120 return -EIO;
42121 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
42122 index b0c3de9..fc5857e 100644
42123 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
42124 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
42125 @@ -200,15 +200,21 @@ int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
42126 if (priv_level == QLCNIC_NON_PRIV_FUNC) {
42127 ahw->op_mode = QLCNIC_NON_PRIV_FUNC;
42128 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
42129 - nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
42130 + pax_open_kernel();
42131 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
42132 + pax_close_kernel();
42133 } else if (priv_level == QLCNIC_PRIV_FUNC) {
42134 ahw->op_mode = QLCNIC_PRIV_FUNC;
42135 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
42136 - nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
42137 + pax_open_kernel();
42138 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
42139 + pax_close_kernel();
42140 } else if (priv_level == QLCNIC_MGMT_FUNC) {
42141 ahw->op_mode = QLCNIC_MGMT_FUNC;
42142 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
42143 - nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
42144 + pax_open_kernel();
42145 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
42146 + pax_close_kernel();
42147 } else {
42148 return -EIO;
42149 }
42150 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c
42151 index 6acf82b..14b097e 100644
42152 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c
42153 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c
42154 @@ -206,10 +206,10 @@ int qlcnic_fw_cmd_set_drv_version(struct qlcnic_adapter *adapter)
42155 if (err) {
42156 dev_info(&adapter->pdev->dev,
42157 "Failed to set driver version in firmware\n");
42158 - return -EIO;
42159 + err = -EIO;
42160 }
42161 -
42162 - return 0;
42163 + qlcnic_free_mbx_args(&cmd);
42164 + return err;
42165 }
42166
42167 int
42168 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
42169 index d3f8797..82a03d3 100644
42170 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
42171 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_io.c
42172 @@ -262,7 +262,7 @@ void qlcnic_82xx_change_filter(struct qlcnic_adapter *adapter, u64 *uaddr,
42173
42174 mac_req = (struct qlcnic_mac_req *)&(req->words[0]);
42175 mac_req->op = vlan_id ? QLCNIC_MAC_VLAN_ADD : QLCNIC_MAC_ADD;
42176 - memcpy(mac_req->mac_addr, &uaddr, ETH_ALEN);
42177 + memcpy(mac_req->mac_addr, uaddr, ETH_ALEN);
42178
42179 vlan_req = (struct qlcnic_vlan_req *)&req->words[1];
42180 vlan_req->vlan_id = cpu_to_le16(vlan_id);
42181 diff --git a/drivers/net/ethernet/realtek/8139cp.c b/drivers/net/ethernet/realtek/8139cp.c
42182 index 887aebe..9095ff9 100644
42183 --- a/drivers/net/ethernet/realtek/8139cp.c
42184 +++ b/drivers/net/ethernet/realtek/8139cp.c
42185 @@ -524,6 +524,7 @@ rx_status_loop:
42186 PCI_DMA_FROMDEVICE);
42187 if (dma_mapping_error(&cp->pdev->dev, new_mapping)) {
42188 dev->stats.rx_dropped++;
42189 + kfree_skb(new_skb);
42190 goto rx_next;
42191 }
42192
42193 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
42194 index 393f961..d343034 100644
42195 --- a/drivers/net/ethernet/realtek/r8169.c
42196 +++ b/drivers/net/ethernet/realtek/r8169.c
42197 @@ -753,22 +753,22 @@ struct rtl8169_private {
42198 struct mdio_ops {
42199 void (*write)(struct rtl8169_private *, int, int);
42200 int (*read)(struct rtl8169_private *, int);
42201 - } mdio_ops;
42202 + } __no_const mdio_ops;
42203
42204 struct pll_power_ops {
42205 void (*down)(struct rtl8169_private *);
42206 void (*up)(struct rtl8169_private *);
42207 - } pll_power_ops;
42208 + } __no_const pll_power_ops;
42209
42210 struct jumbo_ops {
42211 void (*enable)(struct rtl8169_private *);
42212 void (*disable)(struct rtl8169_private *);
42213 - } jumbo_ops;
42214 + } __no_const jumbo_ops;
42215
42216 struct csi_ops {
42217 void (*write)(struct rtl8169_private *, int, int);
42218 u32 (*read)(struct rtl8169_private *, int);
42219 - } csi_ops;
42220 + } __no_const csi_ops;
42221
42222 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
42223 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
42224 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
42225 index 9a95abf..36df7f9 100644
42226 --- a/drivers/net/ethernet/sfc/ptp.c
42227 +++ b/drivers/net/ethernet/sfc/ptp.c
42228 @@ -535,7 +535,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
42229 (u32)((u64)ptp->start.dma_addr >> 32));
42230
42231 /* Clear flag that signals MC ready */
42232 - ACCESS_ONCE(*start) = 0;
42233 + ACCESS_ONCE_RW(*start) = 0;
42234 efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
42235 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
42236
42237 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
42238 index 50617c5..b13724c 100644
42239 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
42240 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
42241 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
42242
42243 writel(value, ioaddr + MMC_CNTRL);
42244
42245 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
42246 - MMC_CNTRL, value);
42247 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
42248 +// MMC_CNTRL, value);
42249 }
42250
42251 /* To mask all all interrupts.*/
42252 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
42253 index e6fe0d8..2b7d752 100644
42254 --- a/drivers/net/hyperv/hyperv_net.h
42255 +++ b/drivers/net/hyperv/hyperv_net.h
42256 @@ -101,7 +101,7 @@ struct rndis_device {
42257
42258 enum rndis_device_state state;
42259 bool link_state;
42260 - atomic_t new_req_id;
42261 + atomic_unchecked_t new_req_id;
42262
42263 spinlock_t request_lock;
42264 struct list_head req_list;
42265 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
42266 index 0775f0a..d4fb316 100644
42267 --- a/drivers/net/hyperv/rndis_filter.c
42268 +++ b/drivers/net/hyperv/rndis_filter.c
42269 @@ -104,7 +104,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
42270 * template
42271 */
42272 set = &rndis_msg->msg.set_req;
42273 - set->req_id = atomic_inc_return(&dev->new_req_id);
42274 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
42275
42276 /* Add to the request list */
42277 spin_lock_irqsave(&dev->request_lock, flags);
42278 @@ -752,7 +752,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
42279
42280 /* Setup the rndis set */
42281 halt = &request->request_msg.msg.halt_req;
42282 - halt->req_id = atomic_inc_return(&dev->new_req_id);
42283 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
42284
42285 /* Ignore return since this msg is optional. */
42286 rndis_filter_send_request(dev, request);
42287 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
42288 index bf0d55e..82bcfbd1 100644
42289 --- a/drivers/net/ieee802154/fakehard.c
42290 +++ b/drivers/net/ieee802154/fakehard.c
42291 @@ -364,7 +364,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
42292 phy->transmit_power = 0xbf;
42293
42294 dev->netdev_ops = &fake_ops;
42295 - dev->ml_priv = &fake_mlme;
42296 + dev->ml_priv = (void *)&fake_mlme;
42297
42298 priv = netdev_priv(dev);
42299 priv->phy = phy;
42300 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
42301 index 6e91931..2b0ebe7 100644
42302 --- a/drivers/net/macvlan.c
42303 +++ b/drivers/net/macvlan.c
42304 @@ -905,13 +905,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
42305 int macvlan_link_register(struct rtnl_link_ops *ops)
42306 {
42307 /* common fields */
42308 - ops->priv_size = sizeof(struct macvlan_dev);
42309 - ops->validate = macvlan_validate;
42310 - ops->maxtype = IFLA_MACVLAN_MAX;
42311 - ops->policy = macvlan_policy;
42312 - ops->changelink = macvlan_changelink;
42313 - ops->get_size = macvlan_get_size;
42314 - ops->fill_info = macvlan_fill_info;
42315 + pax_open_kernel();
42316 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
42317 + *(void **)&ops->validate = macvlan_validate;
42318 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
42319 + *(const void **)&ops->policy = macvlan_policy;
42320 + *(void **)&ops->changelink = macvlan_changelink;
42321 + *(void **)&ops->get_size = macvlan_get_size;
42322 + *(void **)&ops->fill_info = macvlan_fill_info;
42323 + pax_close_kernel();
42324
42325 return rtnl_link_register(ops);
42326 };
42327 @@ -967,7 +969,7 @@ static int macvlan_device_event(struct notifier_block *unused,
42328 return NOTIFY_DONE;
42329 }
42330
42331 -static struct notifier_block macvlan_notifier_block __read_mostly = {
42332 +static struct notifier_block macvlan_notifier_block = {
42333 .notifier_call = macvlan_device_event,
42334 };
42335
42336 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
42337 index 523d6b2..5e16aa1 100644
42338 --- a/drivers/net/macvtap.c
42339 +++ b/drivers/net/macvtap.c
42340 @@ -1110,7 +1110,7 @@ static int macvtap_device_event(struct notifier_block *unused,
42341 return NOTIFY_DONE;
42342 }
42343
42344 -static struct notifier_block macvtap_notifier_block __read_mostly = {
42345 +static struct notifier_block macvtap_notifier_block = {
42346 .notifier_call = macvtap_device_event,
42347 };
42348
42349 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
42350 index daec9b0..6428fcb 100644
42351 --- a/drivers/net/phy/mdio-bitbang.c
42352 +++ b/drivers/net/phy/mdio-bitbang.c
42353 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
42354 struct mdiobb_ctrl *ctrl = bus->priv;
42355
42356 module_put(ctrl->ops->owner);
42357 + mdiobus_unregister(bus);
42358 mdiobus_free(bus);
42359 }
42360 EXPORT_SYMBOL(free_mdio_bitbang);
42361 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
42362 index 72ff14b..11d442d 100644
42363 --- a/drivers/net/ppp/ppp_generic.c
42364 +++ b/drivers/net/ppp/ppp_generic.c
42365 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
42366 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
42367 struct ppp_stats stats;
42368 struct ppp_comp_stats cstats;
42369 - char *vers;
42370
42371 switch (cmd) {
42372 case SIOCGPPPSTATS:
42373 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
42374 break;
42375
42376 case SIOCGPPPVER:
42377 - vers = PPP_VERSION;
42378 - if (copy_to_user(addr, vers, strlen(vers) + 1))
42379 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
42380 break;
42381 err = 0;
42382 break;
42383 diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
42384 index 1252d9c..80e660b 100644
42385 --- a/drivers/net/slip/slhc.c
42386 +++ b/drivers/net/slip/slhc.c
42387 @@ -488,7 +488,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
42388 register struct tcphdr *thp;
42389 register struct iphdr *ip;
42390 register struct cstate *cs;
42391 - int len, hdrlen;
42392 + long len, hdrlen;
42393 unsigned char *cp = icp;
42394
42395 /* We've got a compressed packet; read the change byte */
42396 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
42397 index b305105..8ead6df 100644
42398 --- a/drivers/net/team/team.c
42399 +++ b/drivers/net/team/team.c
42400 @@ -2682,7 +2682,7 @@ static int team_device_event(struct notifier_block *unused,
42401 return NOTIFY_DONE;
42402 }
42403
42404 -static struct notifier_block team_notifier_block __read_mostly = {
42405 +static struct notifier_block team_notifier_block = {
42406 .notifier_call = team_device_event,
42407 };
42408
42409 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
42410 index 2491eb2..1a453eb 100644
42411 --- a/drivers/net/tun.c
42412 +++ b/drivers/net/tun.c
42413 @@ -1076,8 +1076,9 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
42414 u32 rxhash;
42415
42416 if (!(tun->flags & TUN_NO_PI)) {
42417 - if ((len -= sizeof(pi)) > total_len)
42418 + if (len < sizeof(pi))
42419 return -EINVAL;
42420 + len -= sizeof(pi);
42421
42422 if (memcpy_fromiovecend((void *)&pi, iv, 0, sizeof(pi)))
42423 return -EFAULT;
42424 @@ -1085,8 +1086,9 @@ static ssize_t tun_get_user(struct tun_struct *tun, struct tun_file *tfile,
42425 }
42426
42427 if (tun->flags & TUN_VNET_HDR) {
42428 - if ((len -= tun->vnet_hdr_sz) > total_len)
42429 + if (len < tun->vnet_hdr_sz)
42430 return -EINVAL;
42431 + len -= tun->vnet_hdr_sz;
42432
42433 if (memcpy_fromiovecend((void *)&gso, iv, offset, sizeof(gso)))
42434 return -EFAULT;
42435 @@ -1869,7 +1871,7 @@ unlock:
42436 }
42437
42438 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
42439 - unsigned long arg, int ifreq_len)
42440 + unsigned long arg, size_t ifreq_len)
42441 {
42442 struct tun_file *tfile = file->private_data;
42443 struct tun_struct *tun;
42444 @@ -1881,6 +1883,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
42445 int vnet_hdr_sz;
42446 int ret;
42447
42448 + if (ifreq_len > sizeof ifr)
42449 + return -EFAULT;
42450 +
42451 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
42452 if (copy_from_user(&ifr, argp, ifreq_len))
42453 return -EFAULT;
42454 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
42455 index cba1d46..f703766 100644
42456 --- a/drivers/net/usb/hso.c
42457 +++ b/drivers/net/usb/hso.c
42458 @@ -71,7 +71,7 @@
42459 #include <asm/byteorder.h>
42460 #include <linux/serial_core.h>
42461 #include <linux/serial.h>
42462 -
42463 +#include <asm/local.h>
42464
42465 #define MOD_AUTHOR "Option Wireless"
42466 #define MOD_DESCRIPTION "USB High Speed Option driver"
42467 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
42468 struct urb *urb;
42469
42470 urb = serial->rx_urb[0];
42471 - if (serial->port.count > 0) {
42472 + if (atomic_read(&serial->port.count) > 0) {
42473 count = put_rxbuf_data(urb, serial);
42474 if (count == -1)
42475 return;
42476 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
42477 DUMP1(urb->transfer_buffer, urb->actual_length);
42478
42479 /* Anyone listening? */
42480 - if (serial->port.count == 0)
42481 + if (atomic_read(&serial->port.count) == 0)
42482 return;
42483
42484 if (status == 0) {
42485 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
42486 tty_port_tty_set(&serial->port, tty);
42487
42488 /* check for port already opened, if not set the termios */
42489 - serial->port.count++;
42490 - if (serial->port.count == 1) {
42491 + if (atomic_inc_return(&serial->port.count) == 1) {
42492 serial->rx_state = RX_IDLE;
42493 /* Force default termio settings */
42494 _hso_serial_set_termios(tty, NULL);
42495 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
42496 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
42497 if (result) {
42498 hso_stop_serial_device(serial->parent);
42499 - serial->port.count--;
42500 + atomic_dec(&serial->port.count);
42501 kref_put(&serial->parent->ref, hso_serial_ref_free);
42502 }
42503 } else {
42504 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
42505
42506 /* reset the rts and dtr */
42507 /* do the actual close */
42508 - serial->port.count--;
42509 + atomic_dec(&serial->port.count);
42510
42511 - if (serial->port.count <= 0) {
42512 - serial->port.count = 0;
42513 + if (atomic_read(&serial->port.count) <= 0) {
42514 + atomic_set(&serial->port.count, 0);
42515 tty_port_tty_set(&serial->port, NULL);
42516 if (!usb_gone)
42517 hso_stop_serial_device(serial->parent);
42518 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
42519
42520 /* the actual setup */
42521 spin_lock_irqsave(&serial->serial_lock, flags);
42522 - if (serial->port.count)
42523 + if (atomic_read(&serial->port.count))
42524 _hso_serial_set_termios(tty, old);
42525 else
42526 tty->termios = *old;
42527 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
42528 D1("Pending read interrupt on port %d\n", i);
42529 spin_lock(&serial->serial_lock);
42530 if (serial->rx_state == RX_IDLE &&
42531 - serial->port.count > 0) {
42532 + atomic_read(&serial->port.count) > 0) {
42533 /* Setup and send a ctrl req read on
42534 * port i */
42535 if (!serial->rx_urb_filled[0]) {
42536 @@ -3057,7 +3056,7 @@ static int hso_resume(struct usb_interface *iface)
42537 /* Start all serial ports */
42538 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
42539 if (serial_table[i] && (serial_table[i]->interface == iface)) {
42540 - if (dev2ser(serial_table[i])->port.count) {
42541 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
42542 result =
42543 hso_start_serial_device(serial_table[i], GFP_NOIO);
42544 hso_kick_transmit(dev2ser(serial_table[i]));
42545 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
42546 index 57325f3..36b181f 100644
42547 --- a/drivers/net/vxlan.c
42548 +++ b/drivers/net/vxlan.c
42549 @@ -1579,7 +1579,7 @@ nla_put_failure:
42550 return -EMSGSIZE;
42551 }
42552
42553 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
42554 +static struct rtnl_link_ops vxlan_link_ops = {
42555 .kind = "vxlan",
42556 .maxtype = IFLA_VXLAN_MAX,
42557 .policy = vxlan_policy,
42558 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
42559 index 34c8a33..3261fdc 100644
42560 --- a/drivers/net/wireless/at76c50x-usb.c
42561 +++ b/drivers/net/wireless/at76c50x-usb.c
42562 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
42563 }
42564
42565 /* Convert timeout from the DFU status to jiffies */
42566 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
42567 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
42568 {
42569 return msecs_to_jiffies((s->poll_timeout[2] << 16)
42570 | (s->poll_timeout[1] << 8)
42571 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
42572 index 8d78253..bebbb68 100644
42573 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
42574 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
42575 @@ -184,8 +184,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
42576 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
42577 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
42578
42579 - ACCESS_ONCE(ads->ds_link) = i->link;
42580 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
42581 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
42582 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
42583
42584 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
42585 ctl6 = SM(i->keytype, AR_EncrType);
42586 @@ -199,26 +199,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
42587
42588 if ((i->is_first || i->is_last) &&
42589 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
42590 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
42591 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
42592 | set11nTries(i->rates, 1)
42593 | set11nTries(i->rates, 2)
42594 | set11nTries(i->rates, 3)
42595 | (i->dur_update ? AR_DurUpdateEna : 0)
42596 | SM(0, AR_BurstDur);
42597
42598 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
42599 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
42600 | set11nRate(i->rates, 1)
42601 | set11nRate(i->rates, 2)
42602 | set11nRate(i->rates, 3);
42603 } else {
42604 - ACCESS_ONCE(ads->ds_ctl2) = 0;
42605 - ACCESS_ONCE(ads->ds_ctl3) = 0;
42606 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
42607 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
42608 }
42609
42610 if (!i->is_first) {
42611 - ACCESS_ONCE(ads->ds_ctl0) = 0;
42612 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
42613 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
42614 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
42615 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
42616 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
42617 return;
42618 }
42619
42620 @@ -243,7 +243,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
42621 break;
42622 }
42623
42624 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
42625 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
42626 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
42627 | SM(i->txpower, AR_XmitPower)
42628 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
42629 @@ -253,19 +253,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
42630 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
42631 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
42632
42633 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
42634 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
42635 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
42636 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
42637
42638 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
42639 return;
42640
42641 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
42642 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
42643 | set11nPktDurRTSCTS(i->rates, 1);
42644
42645 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
42646 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
42647 | set11nPktDurRTSCTS(i->rates, 3);
42648
42649 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
42650 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
42651 | set11nRateFlags(i->rates, 1)
42652 | set11nRateFlags(i->rates, 2)
42653 | set11nRateFlags(i->rates, 3)
42654 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
42655 index 301bf72..3f5654f 100644
42656 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
42657 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
42658 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
42659 (i->qcu << AR_TxQcuNum_S) | desc_len;
42660
42661 checksum += val;
42662 - ACCESS_ONCE(ads->info) = val;
42663 + ACCESS_ONCE_RW(ads->info) = val;
42664
42665 checksum += i->link;
42666 - ACCESS_ONCE(ads->link) = i->link;
42667 + ACCESS_ONCE_RW(ads->link) = i->link;
42668
42669 checksum += i->buf_addr[0];
42670 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
42671 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
42672 checksum += i->buf_addr[1];
42673 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
42674 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
42675 checksum += i->buf_addr[2];
42676 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
42677 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
42678 checksum += i->buf_addr[3];
42679 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
42680 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
42681
42682 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
42683 - ACCESS_ONCE(ads->ctl3) = val;
42684 + ACCESS_ONCE_RW(ads->ctl3) = val;
42685 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
42686 - ACCESS_ONCE(ads->ctl5) = val;
42687 + ACCESS_ONCE_RW(ads->ctl5) = val;
42688 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
42689 - ACCESS_ONCE(ads->ctl7) = val;
42690 + ACCESS_ONCE_RW(ads->ctl7) = val;
42691 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
42692 - ACCESS_ONCE(ads->ctl9) = val;
42693 + ACCESS_ONCE_RW(ads->ctl9) = val;
42694
42695 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
42696 - ACCESS_ONCE(ads->ctl10) = checksum;
42697 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
42698
42699 if (i->is_first || i->is_last) {
42700 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
42701 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
42702 | set11nTries(i->rates, 1)
42703 | set11nTries(i->rates, 2)
42704 | set11nTries(i->rates, 3)
42705 | (i->dur_update ? AR_DurUpdateEna : 0)
42706 | SM(0, AR_BurstDur);
42707
42708 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
42709 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
42710 | set11nRate(i->rates, 1)
42711 | set11nRate(i->rates, 2)
42712 | set11nRate(i->rates, 3);
42713 } else {
42714 - ACCESS_ONCE(ads->ctl13) = 0;
42715 - ACCESS_ONCE(ads->ctl14) = 0;
42716 + ACCESS_ONCE_RW(ads->ctl13) = 0;
42717 + ACCESS_ONCE_RW(ads->ctl14) = 0;
42718 }
42719
42720 ads->ctl20 = 0;
42721 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
42722
42723 ctl17 = SM(i->keytype, AR_EncrType);
42724 if (!i->is_first) {
42725 - ACCESS_ONCE(ads->ctl11) = 0;
42726 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
42727 - ACCESS_ONCE(ads->ctl15) = 0;
42728 - ACCESS_ONCE(ads->ctl16) = 0;
42729 - ACCESS_ONCE(ads->ctl17) = ctl17;
42730 - ACCESS_ONCE(ads->ctl18) = 0;
42731 - ACCESS_ONCE(ads->ctl19) = 0;
42732 + ACCESS_ONCE_RW(ads->ctl11) = 0;
42733 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
42734 + ACCESS_ONCE_RW(ads->ctl15) = 0;
42735 + ACCESS_ONCE_RW(ads->ctl16) = 0;
42736 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
42737 + ACCESS_ONCE_RW(ads->ctl18) = 0;
42738 + ACCESS_ONCE_RW(ads->ctl19) = 0;
42739 return;
42740 }
42741
42742 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
42743 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
42744 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
42745 | SM(i->txpower, AR_XmitPower)
42746 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
42747 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
42748 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
42749 ctl12 |= SM(val, AR_PAPRDChainMask);
42750
42751 - ACCESS_ONCE(ads->ctl12) = ctl12;
42752 - ACCESS_ONCE(ads->ctl17) = ctl17;
42753 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
42754 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
42755
42756 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
42757 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
42758 | set11nPktDurRTSCTS(i->rates, 1);
42759
42760 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
42761 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
42762 | set11nPktDurRTSCTS(i->rates, 3);
42763
42764 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
42765 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
42766 | set11nRateFlags(i->rates, 1)
42767 | set11nRateFlags(i->rates, 2)
42768 | set11nRateFlags(i->rates, 3)
42769 | SM(i->rtscts_rate, AR_RTSCTSRate);
42770
42771 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
42772 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
42773 }
42774
42775 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
42776 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
42777 index ae30343..a117806 100644
42778 --- a/drivers/net/wireless/ath/ath9k/hw.h
42779 +++ b/drivers/net/wireless/ath/ath9k/hw.h
42780 @@ -652,7 +652,7 @@ struct ath_hw_private_ops {
42781
42782 /* ANI */
42783 void (*ani_cache_ini_regs)(struct ath_hw *ah);
42784 -};
42785 +} __no_const;
42786
42787 /**
42788 * struct ath_spec_scan - parameters for Atheros spectral scan
42789 @@ -721,7 +721,7 @@ struct ath_hw_ops {
42790 struct ath_spec_scan *param);
42791 void (*spectral_scan_trigger)(struct ath_hw *ah);
42792 void (*spectral_scan_wait)(struct ath_hw *ah);
42793 -};
42794 +} __no_const;
42795
42796 struct ath_nf_limits {
42797 s16 max;
42798 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
42799 index b37a582..680835d 100644
42800 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
42801 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
42802 @@ -3639,7 +3639,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
42803 */
42804 if (il3945_mod_params.disable_hw_scan) {
42805 D_INFO("Disabling hw_scan\n");
42806 - il3945_mac_ops.hw_scan = NULL;
42807 + pax_open_kernel();
42808 + *(void **)&il3945_mac_ops.hw_scan = NULL;
42809 + pax_close_kernel();
42810 }
42811
42812 D_INFO("*** LOAD DRIVER ***\n");
42813 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
42814 index d532948..e0d8bb1 100644
42815 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
42816 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
42817 @@ -203,7 +203,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
42818 {
42819 struct iwl_priv *priv = file->private_data;
42820 char buf[64];
42821 - int buf_size;
42822 + size_t buf_size;
42823 u32 offset, len;
42824
42825 memset(buf, 0, sizeof(buf));
42826 @@ -473,7 +473,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
42827 struct iwl_priv *priv = file->private_data;
42828
42829 char buf[8];
42830 - int buf_size;
42831 + size_t buf_size;
42832 u32 reset_flag;
42833
42834 memset(buf, 0, sizeof(buf));
42835 @@ -554,7 +554,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
42836 {
42837 struct iwl_priv *priv = file->private_data;
42838 char buf[8];
42839 - int buf_size;
42840 + size_t buf_size;
42841 int ht40;
42842
42843 memset(buf, 0, sizeof(buf));
42844 @@ -606,7 +606,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
42845 {
42846 struct iwl_priv *priv = file->private_data;
42847 char buf[8];
42848 - int buf_size;
42849 + size_t buf_size;
42850 int value;
42851
42852 memset(buf, 0, sizeof(buf));
42853 @@ -698,10 +698,10 @@ DEBUGFS_READ_FILE_OPS(temperature);
42854 DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
42855 DEBUGFS_READ_FILE_OPS(current_sleep_command);
42856
42857 -static const char *fmt_value = " %-30s %10u\n";
42858 -static const char *fmt_hex = " %-30s 0x%02X\n";
42859 -static const char *fmt_table = " %-30s %10u %10u %10u %10u\n";
42860 -static const char *fmt_header =
42861 +static const char fmt_value[] = " %-30s %10u\n";
42862 +static const char fmt_hex[] = " %-30s 0x%02X\n";
42863 +static const char fmt_table[] = " %-30s %10u %10u %10u %10u\n";
42864 +static const char fmt_header[] =
42865 "%-32s current cumulative delta max\n";
42866
42867 static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
42868 @@ -1871,7 +1871,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
42869 {
42870 struct iwl_priv *priv = file->private_data;
42871 char buf[8];
42872 - int buf_size;
42873 + size_t buf_size;
42874 int clear;
42875
42876 memset(buf, 0, sizeof(buf));
42877 @@ -1916,7 +1916,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
42878 {
42879 struct iwl_priv *priv = file->private_data;
42880 char buf[8];
42881 - int buf_size;
42882 + size_t buf_size;
42883 int trace;
42884
42885 memset(buf, 0, sizeof(buf));
42886 @@ -1987,7 +1987,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
42887 {
42888 struct iwl_priv *priv = file->private_data;
42889 char buf[8];
42890 - int buf_size;
42891 + size_t buf_size;
42892 int missed;
42893
42894 memset(buf, 0, sizeof(buf));
42895 @@ -2028,7 +2028,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
42896
42897 struct iwl_priv *priv = file->private_data;
42898 char buf[8];
42899 - int buf_size;
42900 + size_t buf_size;
42901 int plcp;
42902
42903 memset(buf, 0, sizeof(buf));
42904 @@ -2088,7 +2088,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
42905
42906 struct iwl_priv *priv = file->private_data;
42907 char buf[8];
42908 - int buf_size;
42909 + size_t buf_size;
42910 int flush;
42911
42912 memset(buf, 0, sizeof(buf));
42913 @@ -2178,7 +2178,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
42914
42915 struct iwl_priv *priv = file->private_data;
42916 char buf[8];
42917 - int buf_size;
42918 + size_t buf_size;
42919 int rts;
42920
42921 if (!priv->cfg->ht_params)
42922 @@ -2220,7 +2220,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
42923 {
42924 struct iwl_priv *priv = file->private_data;
42925 char buf[8];
42926 - int buf_size;
42927 + size_t buf_size;
42928
42929 memset(buf, 0, sizeof(buf));
42930 buf_size = min(count, sizeof(buf) - 1);
42931 @@ -2254,7 +2254,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
42932 struct iwl_priv *priv = file->private_data;
42933 u32 event_log_flag;
42934 char buf[8];
42935 - int buf_size;
42936 + size_t buf_size;
42937
42938 /* check that the interface is up */
42939 if (!iwl_is_ready(priv))
42940 @@ -2308,7 +2308,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
42941 struct iwl_priv *priv = file->private_data;
42942 char buf[8];
42943 u32 calib_disabled;
42944 - int buf_size;
42945 + size_t buf_size;
42946
42947 memset(buf, 0, sizeof(buf));
42948 buf_size = min(count, sizeof(buf) - 1);
42949 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
42950 index 50ba0a4..29424e7 100644
42951 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
42952 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
42953 @@ -1329,7 +1329,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
42954 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
42955
42956 char buf[8];
42957 - int buf_size;
42958 + size_t buf_size;
42959 u32 reset_flag;
42960
42961 memset(buf, 0, sizeof(buf));
42962 @@ -1350,7 +1350,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
42963 {
42964 struct iwl_trans *trans = file->private_data;
42965 char buf[8];
42966 - int buf_size;
42967 + size_t buf_size;
42968 int csr;
42969
42970 memset(buf, 0, sizeof(buf));
42971 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
42972 index cb34c78..9fec0dc 100644
42973 --- a/drivers/net/wireless/mac80211_hwsim.c
42974 +++ b/drivers/net/wireless/mac80211_hwsim.c
42975 @@ -2195,25 +2195,19 @@ static int __init init_mac80211_hwsim(void)
42976
42977 if (channels > 1) {
42978 hwsim_if_comb.num_different_channels = channels;
42979 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
42980 - mac80211_hwsim_ops.cancel_hw_scan =
42981 - mac80211_hwsim_cancel_hw_scan;
42982 - mac80211_hwsim_ops.sw_scan_start = NULL;
42983 - mac80211_hwsim_ops.sw_scan_complete = NULL;
42984 - mac80211_hwsim_ops.remain_on_channel =
42985 - mac80211_hwsim_roc;
42986 - mac80211_hwsim_ops.cancel_remain_on_channel =
42987 - mac80211_hwsim_croc;
42988 - mac80211_hwsim_ops.add_chanctx =
42989 - mac80211_hwsim_add_chanctx;
42990 - mac80211_hwsim_ops.remove_chanctx =
42991 - mac80211_hwsim_remove_chanctx;
42992 - mac80211_hwsim_ops.change_chanctx =
42993 - mac80211_hwsim_change_chanctx;
42994 - mac80211_hwsim_ops.assign_vif_chanctx =
42995 - mac80211_hwsim_assign_vif_chanctx;
42996 - mac80211_hwsim_ops.unassign_vif_chanctx =
42997 - mac80211_hwsim_unassign_vif_chanctx;
42998 + pax_open_kernel();
42999 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
43000 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
43001 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
43002 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
43003 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
43004 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
43005 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
43006 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
43007 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
43008 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
43009 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
43010 + pax_close_kernel();
43011 }
43012
43013 spin_lock_init(&hwsim_radio_lock);
43014 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
43015 index 8169a85..7fa3b47 100644
43016 --- a/drivers/net/wireless/rndis_wlan.c
43017 +++ b/drivers/net/wireless/rndis_wlan.c
43018 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
43019
43020 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
43021
43022 - if (rts_threshold < 0 || rts_threshold > 2347)
43023 + if (rts_threshold > 2347)
43024 rts_threshold = 2347;
43025
43026 tmp = cpu_to_le32(rts_threshold);
43027 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
43028 index 7510723..5ba37f5 100644
43029 --- a/drivers/net/wireless/rt2x00/rt2x00.h
43030 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
43031 @@ -386,7 +386,7 @@ struct rt2x00_intf {
43032 * for hardware which doesn't support hardware
43033 * sequence counting.
43034 */
43035 - atomic_t seqno;
43036 + atomic_unchecked_t seqno;
43037 };
43038
43039 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
43040 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
43041 index d955741..8730748 100644
43042 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
43043 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
43044 @@ -252,9 +252,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
43045 * sequence counter given by mac80211.
43046 */
43047 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
43048 - seqno = atomic_add_return(0x10, &intf->seqno);
43049 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
43050 else
43051 - seqno = atomic_read(&intf->seqno);
43052 + seqno = atomic_read_unchecked(&intf->seqno);
43053
43054 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
43055 hdr->seq_ctrl |= cpu_to_le16(seqno);
43056 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
43057 index e2b3d9c..67a5184 100644
43058 --- a/drivers/net/wireless/ti/wl1251/sdio.c
43059 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
43060 @@ -271,13 +271,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
43061
43062 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
43063
43064 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
43065 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
43066 + pax_open_kernel();
43067 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
43068 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
43069 + pax_close_kernel();
43070
43071 wl1251_info("using dedicated interrupt line");
43072 } else {
43073 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
43074 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
43075 + pax_open_kernel();
43076 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
43077 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
43078 + pax_close_kernel();
43079
43080 wl1251_info("using SDIO interrupt");
43081 }
43082 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
43083 index 1c627da..69f7d17 100644
43084 --- a/drivers/net/wireless/ti/wl12xx/main.c
43085 +++ b/drivers/net/wireless/ti/wl12xx/main.c
43086 @@ -656,7 +656,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
43087 sizeof(wl->conf.mem));
43088
43089 /* read data preparation is only needed by wl127x */
43090 - wl->ops->prepare_read = wl127x_prepare_read;
43091 + pax_open_kernel();
43092 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
43093 + pax_close_kernel();
43094
43095 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
43096 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
43097 @@ -681,7 +683,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
43098 sizeof(wl->conf.mem));
43099
43100 /* read data preparation is only needed by wl127x */
43101 - wl->ops->prepare_read = wl127x_prepare_read;
43102 + pax_open_kernel();
43103 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
43104 + pax_close_kernel();
43105
43106 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
43107 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
43108 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
43109 index 9fa692d..b31fee0 100644
43110 --- a/drivers/net/wireless/ti/wl18xx/main.c
43111 +++ b/drivers/net/wireless/ti/wl18xx/main.c
43112 @@ -1687,8 +1687,10 @@ static int wl18xx_setup(struct wl1271 *wl)
43113 }
43114
43115 if (!checksum_param) {
43116 - wl18xx_ops.set_rx_csum = NULL;
43117 - wl18xx_ops.init_vif = NULL;
43118 + pax_open_kernel();
43119 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
43120 + *(void **)&wl18xx_ops.init_vif = NULL;
43121 + pax_close_kernel();
43122 }
43123
43124 /* Enable 11a Band only if we have 5G antennas */
43125 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
43126 index 7ef0b4a..ff65c28 100644
43127 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
43128 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
43129 @@ -386,7 +386,7 @@ static inline void handle_regs_int(struct urb *urb)
43130 {
43131 struct zd_usb *usb = urb->context;
43132 struct zd_usb_interrupt *intr = &usb->intr;
43133 - int len;
43134 + unsigned int len;
43135 u16 int_num;
43136
43137 ZD_ASSERT(in_interrupt());
43138 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
43139 index d93b2b6..ae50401 100644
43140 --- a/drivers/oprofile/buffer_sync.c
43141 +++ b/drivers/oprofile/buffer_sync.c
43142 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
43143 if (cookie == NO_COOKIE)
43144 offset = pc;
43145 if (cookie == INVALID_COOKIE) {
43146 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
43147 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
43148 offset = pc;
43149 }
43150 if (cookie != last_cookie) {
43151 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
43152 /* add userspace sample */
43153
43154 if (!mm) {
43155 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
43156 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
43157 return 0;
43158 }
43159
43160 cookie = lookup_dcookie(mm, s->eip, &offset);
43161
43162 if (cookie == INVALID_COOKIE) {
43163 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
43164 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
43165 return 0;
43166 }
43167
43168 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
43169 /* ignore backtraces if failed to add a sample */
43170 if (state == sb_bt_start) {
43171 state = sb_bt_ignore;
43172 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
43173 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
43174 }
43175 }
43176 release_mm(mm);
43177 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
43178 index c0cc4e7..44d4e54 100644
43179 --- a/drivers/oprofile/event_buffer.c
43180 +++ b/drivers/oprofile/event_buffer.c
43181 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
43182 }
43183
43184 if (buffer_pos == buffer_size) {
43185 - atomic_inc(&oprofile_stats.event_lost_overflow);
43186 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
43187 return;
43188 }
43189
43190 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
43191 index ed2c3ec..deda85a 100644
43192 --- a/drivers/oprofile/oprof.c
43193 +++ b/drivers/oprofile/oprof.c
43194 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
43195 if (oprofile_ops.switch_events())
43196 return;
43197
43198 - atomic_inc(&oprofile_stats.multiplex_counter);
43199 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
43200 start_switch_worker();
43201 }
43202
43203 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
43204 index 84a208d..d61b0a1 100644
43205 --- a/drivers/oprofile/oprofile_files.c
43206 +++ b/drivers/oprofile/oprofile_files.c
43207 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
43208
43209 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
43210
43211 -static ssize_t timeout_read(struct file *file, char __user *buf,
43212 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
43213 size_t count, loff_t *offset)
43214 {
43215 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
43216 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
43217 index 917d28e..d62d981 100644
43218 --- a/drivers/oprofile/oprofile_stats.c
43219 +++ b/drivers/oprofile/oprofile_stats.c
43220 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
43221 cpu_buf->sample_invalid_eip = 0;
43222 }
43223
43224 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
43225 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
43226 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
43227 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
43228 - atomic_set(&oprofile_stats.multiplex_counter, 0);
43229 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
43230 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
43231 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
43232 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
43233 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
43234 }
43235
43236
43237 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
43238 index 38b6fc0..b5cbfce 100644
43239 --- a/drivers/oprofile/oprofile_stats.h
43240 +++ b/drivers/oprofile/oprofile_stats.h
43241 @@ -13,11 +13,11 @@
43242 #include <linux/atomic.h>
43243
43244 struct oprofile_stat_struct {
43245 - atomic_t sample_lost_no_mm;
43246 - atomic_t sample_lost_no_mapping;
43247 - atomic_t bt_lost_no_mapping;
43248 - atomic_t event_lost_overflow;
43249 - atomic_t multiplex_counter;
43250 + atomic_unchecked_t sample_lost_no_mm;
43251 + atomic_unchecked_t sample_lost_no_mapping;
43252 + atomic_unchecked_t bt_lost_no_mapping;
43253 + atomic_unchecked_t event_lost_overflow;
43254 + atomic_unchecked_t multiplex_counter;
43255 };
43256
43257 extern struct oprofile_stat_struct oprofile_stats;
43258 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
43259 index 7c12d9c..558bf3bb 100644
43260 --- a/drivers/oprofile/oprofilefs.c
43261 +++ b/drivers/oprofile/oprofilefs.c
43262 @@ -190,7 +190,7 @@ static const struct file_operations atomic_ro_fops = {
43263
43264
43265 int oprofilefs_create_ro_atomic(struct super_block *sb, struct dentry *root,
43266 - char const *name, atomic_t *val)
43267 + char const *name, atomic_unchecked_t *val)
43268 {
43269 return __oprofilefs_create_file(sb, root, name,
43270 &atomic_ro_fops, 0444, val);
43271 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
43272 index 93404f7..4a313d8 100644
43273 --- a/drivers/oprofile/timer_int.c
43274 +++ b/drivers/oprofile/timer_int.c
43275 @@ -93,7 +93,7 @@ static int __cpuinit oprofile_cpu_notify(struct notifier_block *self,
43276 return NOTIFY_OK;
43277 }
43278
43279 -static struct notifier_block __refdata oprofile_cpu_notifier = {
43280 +static struct notifier_block oprofile_cpu_notifier = {
43281 .notifier_call = oprofile_cpu_notify,
43282 };
43283
43284 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
43285 index 92ed045..62d39bd7 100644
43286 --- a/drivers/parport/procfs.c
43287 +++ b/drivers/parport/procfs.c
43288 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
43289
43290 *ppos += len;
43291
43292 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
43293 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
43294 }
43295
43296 #ifdef CONFIG_PARPORT_1284
43297 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
43298
43299 *ppos += len;
43300
43301 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
43302 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
43303 }
43304 #endif /* IEEE1284.3 support. */
43305
43306 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
43307 index c35e8ad..fc33beb 100644
43308 --- a/drivers/pci/hotplug/acpiphp_ibm.c
43309 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
43310 @@ -464,7 +464,9 @@ static int __init ibm_acpiphp_init(void)
43311 goto init_cleanup;
43312 }
43313
43314 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
43315 + pax_open_kernel();
43316 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
43317 + pax_close_kernel();
43318 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
43319
43320 return retval;
43321 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
43322 index a6a71c4..c91097b 100644
43323 --- a/drivers/pci/hotplug/cpcihp_generic.c
43324 +++ b/drivers/pci/hotplug/cpcihp_generic.c
43325 @@ -73,7 +73,6 @@ static u16 port;
43326 static unsigned int enum_bit;
43327 static u8 enum_mask;
43328
43329 -static struct cpci_hp_controller_ops generic_hpc_ops;
43330 static struct cpci_hp_controller generic_hpc;
43331
43332 static int __init validate_parameters(void)
43333 @@ -139,6 +138,10 @@ static int query_enum(void)
43334 return ((value & enum_mask) == enum_mask);
43335 }
43336
43337 +static struct cpci_hp_controller_ops generic_hpc_ops = {
43338 + .query_enum = query_enum,
43339 +};
43340 +
43341 static int __init cpcihp_generic_init(void)
43342 {
43343 int status;
43344 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
43345 pci_dev_put(dev);
43346
43347 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
43348 - generic_hpc_ops.query_enum = query_enum;
43349 generic_hpc.ops = &generic_hpc_ops;
43350
43351 status = cpci_hp_register_controller(&generic_hpc);
43352 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
43353 index 449b4bb..257e2e8 100644
43354 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
43355 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
43356 @@ -59,7 +59,6 @@
43357 /* local variables */
43358 static bool debug;
43359 static bool poll;
43360 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
43361 static struct cpci_hp_controller zt5550_hpc;
43362
43363 /* Primary cPCI bus bridge device */
43364 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
43365 return 0;
43366 }
43367
43368 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
43369 + .query_enum = zt5550_hc_query_enum,
43370 +};
43371 +
43372 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
43373 {
43374 int status;
43375 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
43376 dbg("returned from zt5550_hc_config");
43377
43378 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
43379 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
43380 zt5550_hpc.ops = &zt5550_hpc_ops;
43381 if(!poll) {
43382 zt5550_hpc.irq = hc_dev->irq;
43383 zt5550_hpc.irq_flags = IRQF_SHARED;
43384 zt5550_hpc.dev_id = hc_dev;
43385
43386 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
43387 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
43388 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
43389 + pax_open_kernel();
43390 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
43391 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
43392 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
43393 + pax_open_kernel();
43394 } else {
43395 info("using ENUM# polling mode");
43396 }
43397 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
43398 index 76ba8a1..20ca857 100644
43399 --- a/drivers/pci/hotplug/cpqphp_nvram.c
43400 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
43401 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
43402
43403 void compaq_nvram_init (void __iomem *rom_start)
43404 {
43405 +
43406 +#ifndef CONFIG_PAX_KERNEXEC
43407 if (rom_start) {
43408 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
43409 }
43410 +#endif
43411 +
43412 dbg("int15 entry = %p\n", compaq_int15_entry_point);
43413
43414 /* initialize our int15 lock */
43415 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
43416 index ec20f74..c1d961e 100644
43417 --- a/drivers/pci/hotplug/pci_hotplug_core.c
43418 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
43419 @@ -441,8 +441,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
43420 return -EINVAL;
43421 }
43422
43423 - slot->ops->owner = owner;
43424 - slot->ops->mod_name = mod_name;
43425 + pax_open_kernel();
43426 + *(struct module **)&slot->ops->owner = owner;
43427 + *(const char **)&slot->ops->mod_name = mod_name;
43428 + pax_close_kernel();
43429
43430 mutex_lock(&pci_hp_mutex);
43431 /*
43432 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
43433 index 7d72c5e..edce02c 100644
43434 --- a/drivers/pci/hotplug/pciehp_core.c
43435 +++ b/drivers/pci/hotplug/pciehp_core.c
43436 @@ -91,7 +91,7 @@ static int init_slot(struct controller *ctrl)
43437 struct slot *slot = ctrl->slot;
43438 struct hotplug_slot *hotplug = NULL;
43439 struct hotplug_slot_info *info = NULL;
43440 - struct hotplug_slot_ops *ops = NULL;
43441 + hotplug_slot_ops_no_const *ops = NULL;
43442 char name[SLOT_NAME_SIZE];
43443 int retval = -ENOMEM;
43444
43445 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
43446 index 5b4a9d9..cd5ac1f 100644
43447 --- a/drivers/pci/pci-sysfs.c
43448 +++ b/drivers/pci/pci-sysfs.c
43449 @@ -1071,7 +1071,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
43450 {
43451 /* allocate attribute structure, piggyback attribute name */
43452 int name_len = write_combine ? 13 : 10;
43453 - struct bin_attribute *res_attr;
43454 + bin_attribute_no_const *res_attr;
43455 int retval;
43456
43457 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
43458 @@ -1256,7 +1256,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
43459 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
43460 {
43461 int retval;
43462 - struct bin_attribute *attr;
43463 + bin_attribute_no_const *attr;
43464
43465 /* If the device has VPD, try to expose it in sysfs. */
43466 if (dev->vpd) {
43467 @@ -1303,7 +1303,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
43468 {
43469 int retval;
43470 int rom_size = 0;
43471 - struct bin_attribute *attr;
43472 + bin_attribute_no_const *attr;
43473
43474 if (!sysfs_initialized)
43475 return -EACCES;
43476 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
43477 index d1182c4..2a138ec 100644
43478 --- a/drivers/pci/pci.h
43479 +++ b/drivers/pci/pci.h
43480 @@ -92,7 +92,7 @@ struct pci_vpd_ops {
43481 struct pci_vpd {
43482 unsigned int len;
43483 const struct pci_vpd_ops *ops;
43484 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
43485 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
43486 };
43487
43488 int pci_vpd_pci22_init(struct pci_dev *dev);
43489 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
43490 index d320df6..ca9a8f6 100644
43491 --- a/drivers/pci/pcie/aspm.c
43492 +++ b/drivers/pci/pcie/aspm.c
43493 @@ -27,9 +27,9 @@
43494 #define MODULE_PARAM_PREFIX "pcie_aspm."
43495
43496 /* Note: those are not register definitions */
43497 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
43498 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
43499 -#define ASPM_STATE_L1 (4) /* L1 state */
43500 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
43501 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
43502 +#define ASPM_STATE_L1 (4U) /* L1 state */
43503 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
43504 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
43505
43506 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
43507 index ea37072..10e58e56 100644
43508 --- a/drivers/pci/probe.c
43509 +++ b/drivers/pci/probe.c
43510 @@ -173,7 +173,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
43511 struct pci_bus_region region;
43512 bool bar_too_big = false, bar_disabled = false;
43513
43514 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
43515 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
43516
43517 /* No printks while decoding is disabled! */
43518 if (!dev->mmio_always_on) {
43519 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
43520 index 0812608..b04018c4 100644
43521 --- a/drivers/pci/proc.c
43522 +++ b/drivers/pci/proc.c
43523 @@ -453,7 +453,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
43524 static int __init pci_proc_init(void)
43525 {
43526 struct pci_dev *dev = NULL;
43527 +
43528 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
43529 +#ifdef CONFIG_GRKERNSEC_PROC_USER
43530 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
43531 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
43532 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
43533 +#endif
43534 +#else
43535 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
43536 +#endif
43537 proc_create("devices", 0, proc_bus_pci_dir,
43538 &proc_bus_pci_dev_operations);
43539 proc_initialized = 1;
43540 diff --git a/drivers/platform/x86/chromeos_laptop.c b/drivers/platform/x86/chromeos_laptop.c
43541 index 3e5b4497..dcdfb70 100644
43542 --- a/drivers/platform/x86/chromeos_laptop.c
43543 +++ b/drivers/platform/x86/chromeos_laptop.c
43544 @@ -301,7 +301,7 @@ static int __init setup_tsl2563_als(const struct dmi_system_id *id)
43545 return 0;
43546 }
43547
43548 -static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = {
43549 +static struct dmi_system_id __initconst chromeos_laptop_dmi_table[] = {
43550 {
43551 .ident = "Samsung Series 5 550 - Touchpad",
43552 .matches = {
43553 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
43554 index 6b22938..bc9700e 100644
43555 --- a/drivers/platform/x86/msi-laptop.c
43556 +++ b/drivers/platform/x86/msi-laptop.c
43557 @@ -1000,12 +1000,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
43558
43559 if (!quirks->ec_read_only) {
43560 /* allow userland write sysfs file */
43561 - dev_attr_bluetooth.store = store_bluetooth;
43562 - dev_attr_wlan.store = store_wlan;
43563 - dev_attr_threeg.store = store_threeg;
43564 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
43565 - dev_attr_wlan.attr.mode |= S_IWUSR;
43566 - dev_attr_threeg.attr.mode |= S_IWUSR;
43567 + pax_open_kernel();
43568 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
43569 + *(void **)&dev_attr_wlan.store = store_wlan;
43570 + *(void **)&dev_attr_threeg.store = store_threeg;
43571 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
43572 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
43573 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
43574 + pax_close_kernel();
43575 }
43576
43577 /* disable hardware control by fn key */
43578 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
43579 index 2ac045f..39c443d 100644
43580 --- a/drivers/platform/x86/sony-laptop.c
43581 +++ b/drivers/platform/x86/sony-laptop.c
43582 @@ -2483,7 +2483,7 @@ static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
43583 }
43584
43585 /* High speed charging function */
43586 -static struct device_attribute *hsc_handle;
43587 +static device_attribute_no_const *hsc_handle;
43588
43589 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
43590 struct device_attribute *attr,
43591 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
43592 index 54d31c0..3f896d3 100644
43593 --- a/drivers/platform/x86/thinkpad_acpi.c
43594 +++ b/drivers/platform/x86/thinkpad_acpi.c
43595 @@ -2093,7 +2093,7 @@ static int hotkey_mask_get(void)
43596 return 0;
43597 }
43598
43599 -void static hotkey_mask_warn_incomplete_mask(void)
43600 +static void hotkey_mask_warn_incomplete_mask(void)
43601 {
43602 /* log only what the user can fix... */
43603 const u32 wantedmask = hotkey_driver_mask &
43604 @@ -2324,11 +2324,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
43605 }
43606 }
43607
43608 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
43609 - struct tp_nvram_state *newn,
43610 - const u32 event_mask)
43611 -{
43612 -
43613 #define TPACPI_COMPARE_KEY(__scancode, __member) \
43614 do { \
43615 if ((event_mask & (1 << __scancode)) && \
43616 @@ -2342,36 +2337,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
43617 tpacpi_hotkey_send_key(__scancode); \
43618 } while (0)
43619
43620 - void issue_volchange(const unsigned int oldvol,
43621 - const unsigned int newvol)
43622 - {
43623 - unsigned int i = oldvol;
43624 +static void issue_volchange(const unsigned int oldvol,
43625 + const unsigned int newvol,
43626 + const u32 event_mask)
43627 +{
43628 + unsigned int i = oldvol;
43629
43630 - while (i > newvol) {
43631 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
43632 - i--;
43633 - }
43634 - while (i < newvol) {
43635 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
43636 - i++;
43637 - }
43638 + while (i > newvol) {
43639 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
43640 + i--;
43641 }
43642 + while (i < newvol) {
43643 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
43644 + i++;
43645 + }
43646 +}
43647
43648 - void issue_brightnesschange(const unsigned int oldbrt,
43649 - const unsigned int newbrt)
43650 - {
43651 - unsigned int i = oldbrt;
43652 +static void issue_brightnesschange(const unsigned int oldbrt,
43653 + const unsigned int newbrt,
43654 + const u32 event_mask)
43655 +{
43656 + unsigned int i = oldbrt;
43657
43658 - while (i > newbrt) {
43659 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
43660 - i--;
43661 - }
43662 - while (i < newbrt) {
43663 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
43664 - i++;
43665 - }
43666 + while (i > newbrt) {
43667 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
43668 + i--;
43669 + }
43670 + while (i < newbrt) {
43671 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
43672 + i++;
43673 }
43674 +}
43675
43676 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
43677 + struct tp_nvram_state *newn,
43678 + const u32 event_mask)
43679 +{
43680 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
43681 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
43682 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
43683 @@ -2405,7 +2406,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
43684 oldn->volume_level != newn->volume_level) {
43685 /* recently muted, or repeated mute keypress, or
43686 * multiple presses ending in mute */
43687 - issue_volchange(oldn->volume_level, newn->volume_level);
43688 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
43689 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
43690 }
43691 } else {
43692 @@ -2415,7 +2416,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
43693 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
43694 }
43695 if (oldn->volume_level != newn->volume_level) {
43696 - issue_volchange(oldn->volume_level, newn->volume_level);
43697 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
43698 } else if (oldn->volume_toggle != newn->volume_toggle) {
43699 /* repeated vol up/down keypress at end of scale ? */
43700 if (newn->volume_level == 0)
43701 @@ -2428,7 +2429,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
43702 /* handle brightness */
43703 if (oldn->brightness_level != newn->brightness_level) {
43704 issue_brightnesschange(oldn->brightness_level,
43705 - newn->brightness_level);
43706 + newn->brightness_level,
43707 + event_mask);
43708 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
43709 /* repeated key presses that didn't change state */
43710 if (newn->brightness_level == 0)
43711 @@ -2437,10 +2439,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
43712 && !tp_features.bright_unkfw)
43713 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
43714 }
43715 +}
43716
43717 #undef TPACPI_COMPARE_KEY
43718 #undef TPACPI_MAY_SEND_KEY
43719 -}
43720
43721 /*
43722 * Polling driver
43723 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
43724 index 769d265..a3a05ca 100644
43725 --- a/drivers/pnp/pnpbios/bioscalls.c
43726 +++ b/drivers/pnp/pnpbios/bioscalls.c
43727 @@ -58,7 +58,7 @@ do { \
43728 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
43729 } while(0)
43730
43731 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
43732 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
43733 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
43734
43735 /*
43736 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
43737
43738 cpu = get_cpu();
43739 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
43740 +
43741 + pax_open_kernel();
43742 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
43743 + pax_close_kernel();
43744
43745 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
43746 spin_lock_irqsave(&pnp_bios_lock, flags);
43747 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
43748 :"memory");
43749 spin_unlock_irqrestore(&pnp_bios_lock, flags);
43750
43751 + pax_open_kernel();
43752 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
43753 + pax_close_kernel();
43754 +
43755 put_cpu();
43756
43757 /* If we get here and this is set then the PnP BIOS faulted on us. */
43758 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
43759 return status;
43760 }
43761
43762 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
43763 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
43764 {
43765 int i;
43766
43767 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
43768 pnp_bios_callpoint.offset = header->fields.pm16offset;
43769 pnp_bios_callpoint.segment = PNP_CS16;
43770
43771 + pax_open_kernel();
43772 +
43773 for_each_possible_cpu(i) {
43774 struct desc_struct *gdt = get_cpu_gdt_table(i);
43775 if (!gdt)
43776 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
43777 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
43778 (unsigned long)__va(header->fields.pm16dseg));
43779 }
43780 +
43781 + pax_close_kernel();
43782 }
43783 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
43784 index 3e6db1c..1fbbdae 100644
43785 --- a/drivers/pnp/resource.c
43786 +++ b/drivers/pnp/resource.c
43787 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
43788 return 1;
43789
43790 /* check if the resource is valid */
43791 - if (*irq < 0 || *irq > 15)
43792 + if (*irq > 15)
43793 return 0;
43794
43795 /* check if the resource is reserved */
43796 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
43797 return 1;
43798
43799 /* check if the resource is valid */
43800 - if (*dma < 0 || *dma == 4 || *dma > 7)
43801 + if (*dma == 4 || *dma > 7)
43802 return 0;
43803
43804 /* check if the resource is reserved */
43805 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
43806 index 0c52e2a..3421ab7 100644
43807 --- a/drivers/power/pda_power.c
43808 +++ b/drivers/power/pda_power.c
43809 @@ -37,7 +37,11 @@ static int polling;
43810
43811 #if IS_ENABLED(CONFIG_USB_PHY)
43812 static struct usb_phy *transceiver;
43813 -static struct notifier_block otg_nb;
43814 +static int otg_handle_notification(struct notifier_block *nb,
43815 + unsigned long event, void *unused);
43816 +static struct notifier_block otg_nb = {
43817 + .notifier_call = otg_handle_notification
43818 +};
43819 #endif
43820
43821 static struct regulator *ac_draw;
43822 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
43823
43824 #if IS_ENABLED(CONFIG_USB_PHY)
43825 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
43826 - otg_nb.notifier_call = otg_handle_notification;
43827 ret = usb_register_notifier(transceiver, &otg_nb);
43828 if (ret) {
43829 dev_err(dev, "failure to register otg notifier\n");
43830 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
43831 index cc439fd..8fa30df 100644
43832 --- a/drivers/power/power_supply.h
43833 +++ b/drivers/power/power_supply.h
43834 @@ -16,12 +16,12 @@ struct power_supply;
43835
43836 #ifdef CONFIG_SYSFS
43837
43838 -extern void power_supply_init_attrs(struct device_type *dev_type);
43839 +extern void power_supply_init_attrs(void);
43840 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
43841
43842 #else
43843
43844 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
43845 +static inline void power_supply_init_attrs(void) {}
43846 #define power_supply_uevent NULL
43847
43848 #endif /* CONFIG_SYSFS */
43849 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
43850 index 1c517c3..ffa2f17 100644
43851 --- a/drivers/power/power_supply_core.c
43852 +++ b/drivers/power/power_supply_core.c
43853 @@ -24,7 +24,10 @@
43854 struct class *power_supply_class;
43855 EXPORT_SYMBOL_GPL(power_supply_class);
43856
43857 -static struct device_type power_supply_dev_type;
43858 +extern const struct attribute_group *power_supply_attr_groups[];
43859 +static struct device_type power_supply_dev_type = {
43860 + .groups = power_supply_attr_groups,
43861 +};
43862
43863 static bool __power_supply_is_supplied_by(struct power_supply *supplier,
43864 struct power_supply *supply)
43865 @@ -554,7 +557,7 @@ static int __init power_supply_class_init(void)
43866 return PTR_ERR(power_supply_class);
43867
43868 power_supply_class->dev_uevent = power_supply_uevent;
43869 - power_supply_init_attrs(&power_supply_dev_type);
43870 + power_supply_init_attrs();
43871
43872 return 0;
43873 }
43874 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
43875 index 29178f7..c65f324 100644
43876 --- a/drivers/power/power_supply_sysfs.c
43877 +++ b/drivers/power/power_supply_sysfs.c
43878 @@ -230,17 +230,15 @@ static struct attribute_group power_supply_attr_group = {
43879 .is_visible = power_supply_attr_is_visible,
43880 };
43881
43882 -static const struct attribute_group *power_supply_attr_groups[] = {
43883 +const struct attribute_group *power_supply_attr_groups[] = {
43884 &power_supply_attr_group,
43885 NULL,
43886 };
43887
43888 -void power_supply_init_attrs(struct device_type *dev_type)
43889 +void power_supply_init_attrs(void)
43890 {
43891 int i;
43892
43893 - dev_type->groups = power_supply_attr_groups;
43894 -
43895 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
43896 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
43897 }
43898 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
43899 index d428ef9..fdc0357 100644
43900 --- a/drivers/regulator/max8660.c
43901 +++ b/drivers/regulator/max8660.c
43902 @@ -333,8 +333,10 @@ static int max8660_probe(struct i2c_client *client,
43903 max8660->shadow_regs[MAX8660_OVER1] = 5;
43904 } else {
43905 /* Otherwise devices can be toggled via software */
43906 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
43907 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
43908 + pax_open_kernel();
43909 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
43910 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
43911 + pax_close_kernel();
43912 }
43913
43914 /*
43915 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
43916 index adb1414..c13e0ce 100644
43917 --- a/drivers/regulator/max8973-regulator.c
43918 +++ b/drivers/regulator/max8973-regulator.c
43919 @@ -401,9 +401,11 @@ static int max8973_probe(struct i2c_client *client,
43920 if (!pdata->enable_ext_control) {
43921 max->desc.enable_reg = MAX8973_VOUT;
43922 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
43923 - max8973_dcdc_ops.enable = regulator_enable_regmap;
43924 - max8973_dcdc_ops.disable = regulator_disable_regmap;
43925 - max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
43926 + pax_open_kernel();
43927 + *(void **)&max8973_dcdc_ops.enable = regulator_enable_regmap;
43928 + *(void **)&max8973_dcdc_ops.disable = regulator_disable_regmap;
43929 + *(void **)&max8973_dcdc_ops.is_enabled = regulator_is_enabled_regmap;
43930 + pax_close_kernel();
43931 }
43932
43933 max->enable_external_control = pdata->enable_ext_control;
43934 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
43935 index b716283..3cc4349 100644
43936 --- a/drivers/regulator/mc13892-regulator.c
43937 +++ b/drivers/regulator/mc13892-regulator.c
43938 @@ -582,10 +582,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
43939 }
43940 mc13xxx_unlock(mc13892);
43941
43942 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
43943 + pax_open_kernel();
43944 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
43945 = mc13892_vcam_set_mode;
43946 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
43947 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
43948 = mc13892_vcam_get_mode;
43949 + pax_close_kernel();
43950
43951 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
43952 ARRAY_SIZE(mc13892_regulators));
43953 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
43954 index f1cb706..4c7832a 100644
43955 --- a/drivers/rtc/rtc-cmos.c
43956 +++ b/drivers/rtc/rtc-cmos.c
43957 @@ -724,7 +724,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
43958 hpet_rtc_timer_init();
43959
43960 /* export at least the first block of NVRAM */
43961 - nvram.size = address_space - NVRAM_OFFSET;
43962 + pax_open_kernel();
43963 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
43964 + pax_close_kernel();
43965 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
43966 if (retval < 0) {
43967 dev_dbg(dev, "can't create nvram file? %d\n", retval);
43968 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
43969 index d049393..bb20be0 100644
43970 --- a/drivers/rtc/rtc-dev.c
43971 +++ b/drivers/rtc/rtc-dev.c
43972 @@ -16,6 +16,7 @@
43973 #include <linux/module.h>
43974 #include <linux/rtc.h>
43975 #include <linux/sched.h>
43976 +#include <linux/grsecurity.h>
43977 #include "rtc-core.h"
43978
43979 static dev_t rtc_devt;
43980 @@ -347,6 +348,8 @@ static long rtc_dev_ioctl(struct file *file,
43981 if (copy_from_user(&tm, uarg, sizeof(tm)))
43982 return -EFAULT;
43983
43984 + gr_log_timechange();
43985 +
43986 return rtc_set_time(rtc, &tm);
43987
43988 case RTC_PIE_ON:
43989 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
43990 index b53992a..776df84 100644
43991 --- a/drivers/rtc/rtc-ds1307.c
43992 +++ b/drivers/rtc/rtc-ds1307.c
43993 @@ -107,7 +107,7 @@ struct ds1307 {
43994 u8 offset; /* register's offset */
43995 u8 regs[11];
43996 u16 nvram_offset;
43997 - struct bin_attribute *nvram;
43998 + bin_attribute_no_const *nvram;
43999 enum ds_type type;
44000 unsigned long flags;
44001 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
44002 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
44003 index 130f29a..6179d03 100644
44004 --- a/drivers/rtc/rtc-m48t59.c
44005 +++ b/drivers/rtc/rtc-m48t59.c
44006 @@ -482,7 +482,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
44007 goto out;
44008 }
44009
44010 - m48t59_nvram_attr.size = pdata->offset;
44011 + pax_open_kernel();
44012 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
44013 + pax_close_kernel();
44014
44015 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
44016 if (ret) {
44017 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
44018 index e693af6..2e525b6 100644
44019 --- a/drivers/scsi/bfa/bfa_fcpim.h
44020 +++ b/drivers/scsi/bfa/bfa_fcpim.h
44021 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
44022
44023 struct bfa_itn_s {
44024 bfa_isr_func_t isr;
44025 -};
44026 +} __no_const;
44027
44028 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
44029 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
44030 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
44031 index 23a90e7..9cf04ee 100644
44032 --- a/drivers/scsi/bfa/bfa_ioc.h
44033 +++ b/drivers/scsi/bfa/bfa_ioc.h
44034 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
44035 bfa_ioc_disable_cbfn_t disable_cbfn;
44036 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
44037 bfa_ioc_reset_cbfn_t reset_cbfn;
44038 -};
44039 +} __no_const;
44040
44041 /*
44042 * IOC event notification mechanism.
44043 @@ -346,7 +346,7 @@ struct bfa_ioc_hwif_s {
44044 void (*ioc_sync_ack) (struct bfa_ioc_s *ioc);
44045 bfa_boolean_t (*ioc_sync_complete) (struct bfa_ioc_s *ioc);
44046 bfa_boolean_t (*ioc_lpu_read_stat) (struct bfa_ioc_s *ioc);
44047 -};
44048 +} __no_const;
44049
44050 /*
44051 * Queue element to wait for room in request queue. FIFO order is
44052 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
44053 index df0c3c7..b00e1d0 100644
44054 --- a/drivers/scsi/hosts.c
44055 +++ b/drivers/scsi/hosts.c
44056 @@ -42,7 +42,7 @@
44057 #include "scsi_logging.h"
44058
44059
44060 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
44061 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
44062
44063
44064 static void scsi_host_cls_release(struct device *dev)
44065 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
44066 * subtract one because we increment first then return, but we need to
44067 * know what the next host number was before increment
44068 */
44069 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
44070 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
44071 shost->dma_channel = 0xff;
44072
44073 /* These three are default values which can be overridden */
44074 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
44075 index 7f4f790..b75b92a 100644
44076 --- a/drivers/scsi/hpsa.c
44077 +++ b/drivers/scsi/hpsa.c
44078 @@ -554,7 +554,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
44079 unsigned long flags;
44080
44081 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
44082 - return h->access.command_completed(h, q);
44083 + return h->access->command_completed(h, q);
44084
44085 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
44086 a = rq->head[rq->current_entry];
44087 @@ -3422,7 +3422,7 @@ static void start_io(struct ctlr_info *h)
44088 while (!list_empty(&h->reqQ)) {
44089 c = list_entry(h->reqQ.next, struct CommandList, list);
44090 /* can't do anything if fifo is full */
44091 - if ((h->access.fifo_full(h))) {
44092 + if ((h->access->fifo_full(h))) {
44093 dev_warn(&h->pdev->dev, "fifo full\n");
44094 break;
44095 }
44096 @@ -3444,7 +3444,7 @@ static void start_io(struct ctlr_info *h)
44097
44098 /* Tell the controller execute command */
44099 spin_unlock_irqrestore(&h->lock, flags);
44100 - h->access.submit_command(h, c);
44101 + h->access->submit_command(h, c);
44102 spin_lock_irqsave(&h->lock, flags);
44103 }
44104 spin_unlock_irqrestore(&h->lock, flags);
44105 @@ -3452,17 +3452,17 @@ static void start_io(struct ctlr_info *h)
44106
44107 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
44108 {
44109 - return h->access.command_completed(h, q);
44110 + return h->access->command_completed(h, q);
44111 }
44112
44113 static inline bool interrupt_pending(struct ctlr_info *h)
44114 {
44115 - return h->access.intr_pending(h);
44116 + return h->access->intr_pending(h);
44117 }
44118
44119 static inline long interrupt_not_for_us(struct ctlr_info *h)
44120 {
44121 - return (h->access.intr_pending(h) == 0) ||
44122 + return (h->access->intr_pending(h) == 0) ||
44123 (h->interrupts_enabled == 0);
44124 }
44125
44126 @@ -4364,7 +4364,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
44127 if (prod_index < 0)
44128 return -ENODEV;
44129 h->product_name = products[prod_index].product_name;
44130 - h->access = *(products[prod_index].access);
44131 + h->access = products[prod_index].access;
44132
44133 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
44134 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
44135 @@ -4646,7 +4646,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
44136
44137 assert_spin_locked(&lockup_detector_lock);
44138 remove_ctlr_from_lockup_detector_list(h);
44139 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
44140 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
44141 spin_lock_irqsave(&h->lock, flags);
44142 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
44143 spin_unlock_irqrestore(&h->lock, flags);
44144 @@ -4823,7 +4823,7 @@ reinit_after_soft_reset:
44145 }
44146
44147 /* make sure the board interrupts are off */
44148 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
44149 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
44150
44151 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
44152 goto clean2;
44153 @@ -4857,7 +4857,7 @@ reinit_after_soft_reset:
44154 * fake ones to scoop up any residual completions.
44155 */
44156 spin_lock_irqsave(&h->lock, flags);
44157 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
44158 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
44159 spin_unlock_irqrestore(&h->lock, flags);
44160 free_irqs(h);
44161 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
44162 @@ -4876,9 +4876,9 @@ reinit_after_soft_reset:
44163 dev_info(&h->pdev->dev, "Board READY.\n");
44164 dev_info(&h->pdev->dev,
44165 "Waiting for stale completions to drain.\n");
44166 - h->access.set_intr_mask(h, HPSA_INTR_ON);
44167 + h->access->set_intr_mask(h, HPSA_INTR_ON);
44168 msleep(10000);
44169 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
44170 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
44171
44172 rc = controller_reset_failed(h->cfgtable);
44173 if (rc)
44174 @@ -4899,7 +4899,7 @@ reinit_after_soft_reset:
44175 }
44176
44177 /* Turn the interrupts on so we can service requests */
44178 - h->access.set_intr_mask(h, HPSA_INTR_ON);
44179 + h->access->set_intr_mask(h, HPSA_INTR_ON);
44180
44181 hpsa_hba_inquiry(h);
44182 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
44183 @@ -4954,7 +4954,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
44184 * To write all data in the battery backed cache to disks
44185 */
44186 hpsa_flush_cache(h);
44187 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
44188 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
44189 hpsa_free_irqs_and_disable_msix(h);
44190 }
44191
44192 @@ -5122,7 +5122,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
44193 return;
44194 }
44195 /* Change the access methods to the performant access methods */
44196 - h->access = SA5_performant_access;
44197 + h->access = &SA5_performant_access;
44198 h->transMethod = CFGTBL_Trans_Performant;
44199 }
44200
44201 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
44202 index 9816479..c5d4e97 100644
44203 --- a/drivers/scsi/hpsa.h
44204 +++ b/drivers/scsi/hpsa.h
44205 @@ -79,7 +79,7 @@ struct ctlr_info {
44206 unsigned int msix_vector;
44207 unsigned int msi_vector;
44208 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
44209 - struct access_method access;
44210 + struct access_method *access;
44211
44212 /* queue and queue Info */
44213 struct list_head reqQ;
44214 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
44215 index 8b928c6..9c76300 100644
44216 --- a/drivers/scsi/libfc/fc_exch.c
44217 +++ b/drivers/scsi/libfc/fc_exch.c
44218 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
44219 u16 pool_max_index;
44220
44221 struct {
44222 - atomic_t no_free_exch;
44223 - atomic_t no_free_exch_xid;
44224 - atomic_t xid_not_found;
44225 - atomic_t xid_busy;
44226 - atomic_t seq_not_found;
44227 - atomic_t non_bls_resp;
44228 + atomic_unchecked_t no_free_exch;
44229 + atomic_unchecked_t no_free_exch_xid;
44230 + atomic_unchecked_t xid_not_found;
44231 + atomic_unchecked_t xid_busy;
44232 + atomic_unchecked_t seq_not_found;
44233 + atomic_unchecked_t non_bls_resp;
44234 } stats;
44235 };
44236
44237 @@ -736,7 +736,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
44238 /* allocate memory for exchange */
44239 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
44240 if (!ep) {
44241 - atomic_inc(&mp->stats.no_free_exch);
44242 + atomic_inc_unchecked(&mp->stats.no_free_exch);
44243 goto out;
44244 }
44245 memset(ep, 0, sizeof(*ep));
44246 @@ -797,7 +797,7 @@ out:
44247 return ep;
44248 err:
44249 spin_unlock_bh(&pool->lock);
44250 - atomic_inc(&mp->stats.no_free_exch_xid);
44251 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
44252 mempool_free(ep, mp->ep_pool);
44253 return NULL;
44254 }
44255 @@ -940,7 +940,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
44256 xid = ntohs(fh->fh_ox_id); /* we originated exch */
44257 ep = fc_exch_find(mp, xid);
44258 if (!ep) {
44259 - atomic_inc(&mp->stats.xid_not_found);
44260 + atomic_inc_unchecked(&mp->stats.xid_not_found);
44261 reject = FC_RJT_OX_ID;
44262 goto out;
44263 }
44264 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
44265 ep = fc_exch_find(mp, xid);
44266 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
44267 if (ep) {
44268 - atomic_inc(&mp->stats.xid_busy);
44269 + atomic_inc_unchecked(&mp->stats.xid_busy);
44270 reject = FC_RJT_RX_ID;
44271 goto rel;
44272 }
44273 @@ -981,7 +981,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
44274 }
44275 xid = ep->xid; /* get our XID */
44276 } else if (!ep) {
44277 - atomic_inc(&mp->stats.xid_not_found);
44278 + atomic_inc_unchecked(&mp->stats.xid_not_found);
44279 reject = FC_RJT_RX_ID; /* XID not found */
44280 goto out;
44281 }
44282 @@ -998,7 +998,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
44283 } else {
44284 sp = &ep->seq;
44285 if (sp->id != fh->fh_seq_id) {
44286 - atomic_inc(&mp->stats.seq_not_found);
44287 + atomic_inc_unchecked(&mp->stats.seq_not_found);
44288 if (f_ctl & FC_FC_END_SEQ) {
44289 /*
44290 * Update sequence_id based on incoming last
44291 @@ -1448,22 +1448,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
44292
44293 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
44294 if (!ep) {
44295 - atomic_inc(&mp->stats.xid_not_found);
44296 + atomic_inc_unchecked(&mp->stats.xid_not_found);
44297 goto out;
44298 }
44299 if (ep->esb_stat & ESB_ST_COMPLETE) {
44300 - atomic_inc(&mp->stats.xid_not_found);
44301 + atomic_inc_unchecked(&mp->stats.xid_not_found);
44302 goto rel;
44303 }
44304 if (ep->rxid == FC_XID_UNKNOWN)
44305 ep->rxid = ntohs(fh->fh_rx_id);
44306 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
44307 - atomic_inc(&mp->stats.xid_not_found);
44308 + atomic_inc_unchecked(&mp->stats.xid_not_found);
44309 goto rel;
44310 }
44311 if (ep->did != ntoh24(fh->fh_s_id) &&
44312 ep->did != FC_FID_FLOGI) {
44313 - atomic_inc(&mp->stats.xid_not_found);
44314 + atomic_inc_unchecked(&mp->stats.xid_not_found);
44315 goto rel;
44316 }
44317 sof = fr_sof(fp);
44318 @@ -1472,7 +1472,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
44319 sp->ssb_stat |= SSB_ST_RESP;
44320 sp->id = fh->fh_seq_id;
44321 } else if (sp->id != fh->fh_seq_id) {
44322 - atomic_inc(&mp->stats.seq_not_found);
44323 + atomic_inc_unchecked(&mp->stats.seq_not_found);
44324 goto rel;
44325 }
44326
44327 @@ -1536,9 +1536,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
44328 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
44329
44330 if (!sp)
44331 - atomic_inc(&mp->stats.xid_not_found);
44332 + atomic_inc_unchecked(&mp->stats.xid_not_found);
44333 else
44334 - atomic_inc(&mp->stats.non_bls_resp);
44335 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
44336
44337 fc_frame_free(fp);
44338 }
44339 @@ -2185,13 +2185,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
44340
44341 list_for_each_entry(ema, &lport->ema_list, ema_list) {
44342 mp = ema->mp;
44343 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
44344 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
44345 st->fc_no_free_exch_xid +=
44346 - atomic_read(&mp->stats.no_free_exch_xid);
44347 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
44348 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
44349 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
44350 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
44351 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
44352 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
44353 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
44354 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
44355 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
44356 }
44357 }
44358 EXPORT_SYMBOL(fc_exch_update_stats);
44359 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
44360 index 161c98e..6d563b3 100644
44361 --- a/drivers/scsi/libsas/sas_ata.c
44362 +++ b/drivers/scsi/libsas/sas_ata.c
44363 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
44364 .postreset = ata_std_postreset,
44365 .error_handler = ata_std_error_handler,
44366 .post_internal_cmd = sas_ata_post_internal,
44367 - .qc_defer = ata_std_qc_defer,
44368 + .qc_defer = ata_std_qc_defer,
44369 .qc_prep = ata_noop_qc_prep,
44370 .qc_issue = sas_ata_qc_issue,
44371 .qc_fill_rtf = sas_ata_qc_fill_rtf,
44372 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
44373 index bcc56ca..6f4174a 100644
44374 --- a/drivers/scsi/lpfc/lpfc.h
44375 +++ b/drivers/scsi/lpfc/lpfc.h
44376 @@ -431,7 +431,7 @@ struct lpfc_vport {
44377 struct dentry *debug_nodelist;
44378 struct dentry *vport_debugfs_root;
44379 struct lpfc_debugfs_trc *disc_trc;
44380 - atomic_t disc_trc_cnt;
44381 + atomic_unchecked_t disc_trc_cnt;
44382 #endif
44383 uint8_t stat_data_enabled;
44384 uint8_t stat_data_blocked;
44385 @@ -865,8 +865,8 @@ struct lpfc_hba {
44386 struct timer_list fabric_block_timer;
44387 unsigned long bit_flags;
44388 #define FABRIC_COMANDS_BLOCKED 0
44389 - atomic_t num_rsrc_err;
44390 - atomic_t num_cmd_success;
44391 + atomic_unchecked_t num_rsrc_err;
44392 + atomic_unchecked_t num_cmd_success;
44393 unsigned long last_rsrc_error_time;
44394 unsigned long last_ramp_down_time;
44395 unsigned long last_ramp_up_time;
44396 @@ -902,7 +902,7 @@ struct lpfc_hba {
44397
44398 struct dentry *debug_slow_ring_trc;
44399 struct lpfc_debugfs_trc *slow_ring_trc;
44400 - atomic_t slow_ring_trc_cnt;
44401 + atomic_unchecked_t slow_ring_trc_cnt;
44402 /* iDiag debugfs sub-directory */
44403 struct dentry *idiag_root;
44404 struct dentry *idiag_pci_cfg;
44405 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
44406 index f525ecb..32549a4 100644
44407 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
44408 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
44409 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
44410
44411 #include <linux/debugfs.h>
44412
44413 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
44414 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
44415 static unsigned long lpfc_debugfs_start_time = 0L;
44416
44417 /* iDiag */
44418 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
44419 lpfc_debugfs_enable = 0;
44420
44421 len = 0;
44422 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
44423 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
44424 (lpfc_debugfs_max_disc_trc - 1);
44425 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
44426 dtp = vport->disc_trc + i;
44427 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
44428 lpfc_debugfs_enable = 0;
44429
44430 len = 0;
44431 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
44432 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
44433 (lpfc_debugfs_max_slow_ring_trc - 1);
44434 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
44435 dtp = phba->slow_ring_trc + i;
44436 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
44437 !vport || !vport->disc_trc)
44438 return;
44439
44440 - index = atomic_inc_return(&vport->disc_trc_cnt) &
44441 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
44442 (lpfc_debugfs_max_disc_trc - 1);
44443 dtp = vport->disc_trc + index;
44444 dtp->fmt = fmt;
44445 dtp->data1 = data1;
44446 dtp->data2 = data2;
44447 dtp->data3 = data3;
44448 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
44449 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
44450 dtp->jif = jiffies;
44451 #endif
44452 return;
44453 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
44454 !phba || !phba->slow_ring_trc)
44455 return;
44456
44457 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
44458 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
44459 (lpfc_debugfs_max_slow_ring_trc - 1);
44460 dtp = phba->slow_ring_trc + index;
44461 dtp->fmt = fmt;
44462 dtp->data1 = data1;
44463 dtp->data2 = data2;
44464 dtp->data3 = data3;
44465 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
44466 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
44467 dtp->jif = jiffies;
44468 #endif
44469 return;
44470 @@ -4182,7 +4182,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
44471 "slow_ring buffer\n");
44472 goto debug_failed;
44473 }
44474 - atomic_set(&phba->slow_ring_trc_cnt, 0);
44475 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
44476 memset(phba->slow_ring_trc, 0,
44477 (sizeof(struct lpfc_debugfs_trc) *
44478 lpfc_debugfs_max_slow_ring_trc));
44479 @@ -4228,7 +4228,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
44480 "buffer\n");
44481 goto debug_failed;
44482 }
44483 - atomic_set(&vport->disc_trc_cnt, 0);
44484 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
44485
44486 snprintf(name, sizeof(name), "discovery_trace");
44487 vport->debug_disc_trc =
44488 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
44489 index cb465b2..2e7b25f 100644
44490 --- a/drivers/scsi/lpfc/lpfc_init.c
44491 +++ b/drivers/scsi/lpfc/lpfc_init.c
44492 @@ -10950,8 +10950,10 @@ lpfc_init(void)
44493 "misc_register returned with status %d", error);
44494
44495 if (lpfc_enable_npiv) {
44496 - lpfc_transport_functions.vport_create = lpfc_vport_create;
44497 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
44498 + pax_open_kernel();
44499 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
44500 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
44501 + pax_close_kernel();
44502 }
44503 lpfc_transport_template =
44504 fc_attach_transport(&lpfc_transport_functions);
44505 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
44506 index 8523b278e..ce1d812 100644
44507 --- a/drivers/scsi/lpfc/lpfc_scsi.c
44508 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
44509 @@ -331,7 +331,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
44510 uint32_t evt_posted;
44511
44512 spin_lock_irqsave(&phba->hbalock, flags);
44513 - atomic_inc(&phba->num_rsrc_err);
44514 + atomic_inc_unchecked(&phba->num_rsrc_err);
44515 phba->last_rsrc_error_time = jiffies;
44516
44517 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
44518 @@ -372,7 +372,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
44519 unsigned long flags;
44520 struct lpfc_hba *phba = vport->phba;
44521 uint32_t evt_posted;
44522 - atomic_inc(&phba->num_cmd_success);
44523 + atomic_inc_unchecked(&phba->num_cmd_success);
44524
44525 if (vport->cfg_lun_queue_depth <= queue_depth)
44526 return;
44527 @@ -416,8 +416,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
44528 unsigned long num_rsrc_err, num_cmd_success;
44529 int i;
44530
44531 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
44532 - num_cmd_success = atomic_read(&phba->num_cmd_success);
44533 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
44534 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
44535
44536 /*
44537 * The error and success command counters are global per
44538 @@ -445,8 +445,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
44539 }
44540 }
44541 lpfc_destroy_vport_work_array(phba, vports);
44542 - atomic_set(&phba->num_rsrc_err, 0);
44543 - atomic_set(&phba->num_cmd_success, 0);
44544 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
44545 + atomic_set_unchecked(&phba->num_cmd_success, 0);
44546 }
44547
44548 /**
44549 @@ -480,8 +480,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
44550 }
44551 }
44552 lpfc_destroy_vport_work_array(phba, vports);
44553 - atomic_set(&phba->num_rsrc_err, 0);
44554 - atomic_set(&phba->num_cmd_success, 0);
44555 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
44556 + atomic_set_unchecked(&phba->num_cmd_success, 0);
44557 }
44558
44559 /**
44560 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
44561 index 8e1b737..50ff510 100644
44562 --- a/drivers/scsi/pmcraid.c
44563 +++ b/drivers/scsi/pmcraid.c
44564 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
44565 res->scsi_dev = scsi_dev;
44566 scsi_dev->hostdata = res;
44567 res->change_detected = 0;
44568 - atomic_set(&res->read_failures, 0);
44569 - atomic_set(&res->write_failures, 0);
44570 + atomic_set_unchecked(&res->read_failures, 0);
44571 + atomic_set_unchecked(&res->write_failures, 0);
44572 rc = 0;
44573 }
44574 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
44575 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
44576
44577 /* If this was a SCSI read/write command keep count of errors */
44578 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
44579 - atomic_inc(&res->read_failures);
44580 + atomic_inc_unchecked(&res->read_failures);
44581 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
44582 - atomic_inc(&res->write_failures);
44583 + atomic_inc_unchecked(&res->write_failures);
44584
44585 if (!RES_IS_GSCSI(res->cfg_entry) &&
44586 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
44587 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
44588 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
44589 * hrrq_id assigned here in queuecommand
44590 */
44591 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
44592 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
44593 pinstance->num_hrrq;
44594 cmd->cmd_done = pmcraid_io_done;
44595
44596 @@ -3846,7 +3846,7 @@ static long pmcraid_ioctl_passthrough(
44597 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
44598 * hrrq_id assigned here in queuecommand
44599 */
44600 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
44601 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
44602 pinstance->num_hrrq;
44603
44604 if (request_size) {
44605 @@ -4483,7 +4483,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
44606
44607 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
44608 /* add resources only after host is added into system */
44609 - if (!atomic_read(&pinstance->expose_resources))
44610 + if (!atomic_read_unchecked(&pinstance->expose_resources))
44611 return;
44612
44613 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
44614 @@ -5310,8 +5310,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
44615 init_waitqueue_head(&pinstance->reset_wait_q);
44616
44617 atomic_set(&pinstance->outstanding_cmds, 0);
44618 - atomic_set(&pinstance->last_message_id, 0);
44619 - atomic_set(&pinstance->expose_resources, 0);
44620 + atomic_set_unchecked(&pinstance->last_message_id, 0);
44621 + atomic_set_unchecked(&pinstance->expose_resources, 0);
44622
44623 INIT_LIST_HEAD(&pinstance->free_res_q);
44624 INIT_LIST_HEAD(&pinstance->used_res_q);
44625 @@ -6024,7 +6024,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
44626 /* Schedule worker thread to handle CCN and take care of adding and
44627 * removing devices to OS
44628 */
44629 - atomic_set(&pinstance->expose_resources, 1);
44630 + atomic_set_unchecked(&pinstance->expose_resources, 1);
44631 schedule_work(&pinstance->worker_q);
44632 return rc;
44633
44634 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
44635 index e1d150f..6c6df44 100644
44636 --- a/drivers/scsi/pmcraid.h
44637 +++ b/drivers/scsi/pmcraid.h
44638 @@ -748,7 +748,7 @@ struct pmcraid_instance {
44639 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
44640
44641 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
44642 - atomic_t last_message_id;
44643 + atomic_unchecked_t last_message_id;
44644
44645 /* configuration table */
44646 struct pmcraid_config_table *cfg_table;
44647 @@ -777,7 +777,7 @@ struct pmcraid_instance {
44648 atomic_t outstanding_cmds;
44649
44650 /* should add/delete resources to mid-layer now ?*/
44651 - atomic_t expose_resources;
44652 + atomic_unchecked_t expose_resources;
44653
44654
44655
44656 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
44657 struct pmcraid_config_table_entry_ext cfg_entry_ext;
44658 };
44659 struct scsi_device *scsi_dev; /* Link scsi_device structure */
44660 - atomic_t read_failures; /* count of failed READ commands */
44661 - atomic_t write_failures; /* count of failed WRITE commands */
44662 + atomic_unchecked_t read_failures; /* count of failed READ commands */
44663 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
44664
44665 /* To indicate add/delete/modify during CCN */
44666 u8 change_detected;
44667 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
44668 index bf60c63..74d4dce 100644
44669 --- a/drivers/scsi/qla2xxx/qla_attr.c
44670 +++ b/drivers/scsi/qla2xxx/qla_attr.c
44671 @@ -2001,7 +2001,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
44672 return 0;
44673 }
44674
44675 -struct fc_function_template qla2xxx_transport_functions = {
44676 +fc_function_template_no_const qla2xxx_transport_functions = {
44677
44678 .show_host_node_name = 1,
44679 .show_host_port_name = 1,
44680 @@ -2048,7 +2048,7 @@ struct fc_function_template qla2xxx_transport_functions = {
44681 .bsg_timeout = qla24xx_bsg_timeout,
44682 };
44683
44684 -struct fc_function_template qla2xxx_transport_vport_functions = {
44685 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
44686
44687 .show_host_node_name = 1,
44688 .show_host_port_name = 1,
44689 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
44690 index 026bfde..90c4018 100644
44691 --- a/drivers/scsi/qla2xxx/qla_gbl.h
44692 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
44693 @@ -528,8 +528,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
44694 struct device_attribute;
44695 extern struct device_attribute *qla2x00_host_attrs[];
44696 struct fc_function_template;
44697 -extern struct fc_function_template qla2xxx_transport_functions;
44698 -extern struct fc_function_template qla2xxx_transport_vport_functions;
44699 +extern fc_function_template_no_const qla2xxx_transport_functions;
44700 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
44701 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
44702 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
44703 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
44704 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
44705 index ad72c1d..afc9a98 100644
44706 --- a/drivers/scsi/qla2xxx/qla_os.c
44707 +++ b/drivers/scsi/qla2xxx/qla_os.c
44708 @@ -1571,8 +1571,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
44709 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
44710 /* Ok, a 64bit DMA mask is applicable. */
44711 ha->flags.enable_64bit_addressing = 1;
44712 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
44713 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
44714 + pax_open_kernel();
44715 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
44716 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
44717 + pax_close_kernel();
44718 return;
44719 }
44720 }
44721 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
44722 index ddf16a8..80f4dd0 100644
44723 --- a/drivers/scsi/qla4xxx/ql4_def.h
44724 +++ b/drivers/scsi/qla4xxx/ql4_def.h
44725 @@ -291,7 +291,7 @@ struct ddb_entry {
44726 * (4000 only) */
44727 atomic_t relogin_timer; /* Max Time to wait for
44728 * relogin to complete */
44729 - atomic_t relogin_retry_count; /* Num of times relogin has been
44730 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
44731 * retried */
44732 uint32_t default_time2wait; /* Default Min time between
44733 * relogins (+aens) */
44734 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
44735 index 4d231c1..2892c37 100644
44736 --- a/drivers/scsi/qla4xxx/ql4_os.c
44737 +++ b/drivers/scsi/qla4xxx/ql4_os.c
44738 @@ -2971,12 +2971,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
44739 */
44740 if (!iscsi_is_session_online(cls_sess)) {
44741 /* Reset retry relogin timer */
44742 - atomic_inc(&ddb_entry->relogin_retry_count);
44743 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
44744 DEBUG2(ql4_printk(KERN_INFO, ha,
44745 "%s: index[%d] relogin timed out-retrying"
44746 " relogin (%d), retry (%d)\n", __func__,
44747 ddb_entry->fw_ddb_index,
44748 - atomic_read(&ddb_entry->relogin_retry_count),
44749 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
44750 ddb_entry->default_time2wait + 4));
44751 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
44752 atomic_set(&ddb_entry->retry_relogin_timer,
44753 @@ -5081,7 +5081,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
44754
44755 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
44756 atomic_set(&ddb_entry->relogin_timer, 0);
44757 - atomic_set(&ddb_entry->relogin_retry_count, 0);
44758 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
44759 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
44760 ddb_entry->default_relogin_timeout =
44761 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
44762 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
44763 index eaa808e..95f8841 100644
44764 --- a/drivers/scsi/scsi.c
44765 +++ b/drivers/scsi/scsi.c
44766 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
44767 unsigned long timeout;
44768 int rtn = 0;
44769
44770 - atomic_inc(&cmd->device->iorequest_cnt);
44771 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
44772
44773 /* check if the device is still usable */
44774 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
44775 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
44776 index 86d5220..f22c51a 100644
44777 --- a/drivers/scsi/scsi_lib.c
44778 +++ b/drivers/scsi/scsi_lib.c
44779 @@ -1458,7 +1458,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
44780 shost = sdev->host;
44781 scsi_init_cmd_errh(cmd);
44782 cmd->result = DID_NO_CONNECT << 16;
44783 - atomic_inc(&cmd->device->iorequest_cnt);
44784 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
44785
44786 /*
44787 * SCSI request completion path will do scsi_device_unbusy(),
44788 @@ -1484,9 +1484,9 @@ static void scsi_softirq_done(struct request *rq)
44789
44790 INIT_LIST_HEAD(&cmd->eh_entry);
44791
44792 - atomic_inc(&cmd->device->iodone_cnt);
44793 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
44794 if (cmd->result)
44795 - atomic_inc(&cmd->device->ioerr_cnt);
44796 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
44797
44798 disposition = scsi_decide_disposition(cmd);
44799 if (disposition != SUCCESS &&
44800 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
44801 index 931a7d9..0c2a754 100644
44802 --- a/drivers/scsi/scsi_sysfs.c
44803 +++ b/drivers/scsi/scsi_sysfs.c
44804 @@ -658,7 +658,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
44805 char *buf) \
44806 { \
44807 struct scsi_device *sdev = to_scsi_device(dev); \
44808 - unsigned long long count = atomic_read(&sdev->field); \
44809 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
44810 return snprintf(buf, 20, "0x%llx\n", count); \
44811 } \
44812 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
44813 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
44814 index 84a1fdf..693b0d6 100644
44815 --- a/drivers/scsi/scsi_tgt_lib.c
44816 +++ b/drivers/scsi/scsi_tgt_lib.c
44817 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
44818 int err;
44819
44820 dprintk("%lx %u\n", uaddr, len);
44821 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
44822 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
44823 if (err) {
44824 /*
44825 * TODO: need to fixup sg_tablesize, max_segment_size,
44826 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
44827 index e106c27..11a380e 100644
44828 --- a/drivers/scsi/scsi_transport_fc.c
44829 +++ b/drivers/scsi/scsi_transport_fc.c
44830 @@ -497,7 +497,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
44831 * Netlink Infrastructure
44832 */
44833
44834 -static atomic_t fc_event_seq;
44835 +static atomic_unchecked_t fc_event_seq;
44836
44837 /**
44838 * fc_get_event_number - Obtain the next sequential FC event number
44839 @@ -510,7 +510,7 @@ static atomic_t fc_event_seq;
44840 u32
44841 fc_get_event_number(void)
44842 {
44843 - return atomic_add_return(1, &fc_event_seq);
44844 + return atomic_add_return_unchecked(1, &fc_event_seq);
44845 }
44846 EXPORT_SYMBOL(fc_get_event_number);
44847
44848 @@ -654,7 +654,7 @@ static __init int fc_transport_init(void)
44849 {
44850 int error;
44851
44852 - atomic_set(&fc_event_seq, 0);
44853 + atomic_set_unchecked(&fc_event_seq, 0);
44854
44855 error = transport_class_register(&fc_host_class);
44856 if (error)
44857 @@ -844,7 +844,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
44858 char *cp;
44859
44860 *val = simple_strtoul(buf, &cp, 0);
44861 - if ((*cp && (*cp != '\n')) || (*val < 0))
44862 + if (*cp && (*cp != '\n'))
44863 return -EINVAL;
44864 /*
44865 * Check for overflow; dev_loss_tmo is u32
44866 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
44867 index 133926b..903000d 100644
44868 --- a/drivers/scsi/scsi_transport_iscsi.c
44869 +++ b/drivers/scsi/scsi_transport_iscsi.c
44870 @@ -80,7 +80,7 @@ struct iscsi_internal {
44871 struct transport_container session_cont;
44872 };
44873
44874 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
44875 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
44876 static struct workqueue_struct *iscsi_eh_timer_workq;
44877
44878 static DEFINE_IDA(iscsi_sess_ida);
44879 @@ -1738,7 +1738,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
44880 int err;
44881
44882 ihost = shost->shost_data;
44883 - session->sid = atomic_add_return(1, &iscsi_session_nr);
44884 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
44885
44886 if (target_id == ISCSI_MAX_TARGET) {
44887 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
44888 @@ -3944,7 +3944,7 @@ static __init int iscsi_transport_init(void)
44889 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
44890 ISCSI_TRANSPORT_VERSION);
44891
44892 - atomic_set(&iscsi_session_nr, 0);
44893 + atomic_set_unchecked(&iscsi_session_nr, 0);
44894
44895 err = class_register(&iscsi_transport_class);
44896 if (err)
44897 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
44898 index f379c7f..e8fc69c 100644
44899 --- a/drivers/scsi/scsi_transport_srp.c
44900 +++ b/drivers/scsi/scsi_transport_srp.c
44901 @@ -33,7 +33,7 @@
44902 #include "scsi_transport_srp_internal.h"
44903
44904 struct srp_host_attrs {
44905 - atomic_t next_port_id;
44906 + atomic_unchecked_t next_port_id;
44907 };
44908 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
44909
44910 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
44911 struct Scsi_Host *shost = dev_to_shost(dev);
44912 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
44913
44914 - atomic_set(&srp_host->next_port_id, 0);
44915 + atomic_set_unchecked(&srp_host->next_port_id, 0);
44916 return 0;
44917 }
44918
44919 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
44920 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
44921 rport->roles = ids->roles;
44922
44923 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
44924 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
44925 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
44926
44927 transport_setup_device(&rport->dev);
44928 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
44929 index 610417e..1544fa9 100644
44930 --- a/drivers/scsi/sd.c
44931 +++ b/drivers/scsi/sd.c
44932 @@ -2928,7 +2928,7 @@ static int sd_probe(struct device *dev)
44933 sdkp->disk = gd;
44934 sdkp->index = index;
44935 atomic_set(&sdkp->openers, 0);
44936 - atomic_set(&sdkp->device->ioerr_cnt, 0);
44937 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
44938
44939 if (!sdp->request_queue->rq_timeout) {
44940 if (sdp->type != TYPE_MOD)
44941 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
44942 index df5e961..df6b97f 100644
44943 --- a/drivers/scsi/sg.c
44944 +++ b/drivers/scsi/sg.c
44945 @@ -1102,7 +1102,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
44946 sdp->disk->disk_name,
44947 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
44948 NULL,
44949 - (char *)arg);
44950 + (char __user *)arg);
44951 case BLKTRACESTART:
44952 return blk_trace_startstop(sdp->device->request_queue, 1);
44953 case BLKTRACESTOP:
44954 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
44955 index 32b7bb1..2f1c4bd 100644
44956 --- a/drivers/spi/spi.c
44957 +++ b/drivers/spi/spi.c
44958 @@ -1631,7 +1631,7 @@ int spi_bus_unlock(struct spi_master *master)
44959 EXPORT_SYMBOL_GPL(spi_bus_unlock);
44960
44961 /* portable code must never pass more than 32 bytes */
44962 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
44963 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
44964
44965 static u8 *buf;
44966
44967 diff --git a/drivers/staging/media/solo6x10/solo6x10-core.c b/drivers/staging/media/solo6x10/solo6x10-core.c
44968 index 3675020..e80d92c 100644
44969 --- a/drivers/staging/media/solo6x10/solo6x10-core.c
44970 +++ b/drivers/staging/media/solo6x10/solo6x10-core.c
44971 @@ -434,7 +434,7 @@ static void solo_device_release(struct device *dev)
44972
44973 static int solo_sysfs_init(struct solo_dev *solo_dev)
44974 {
44975 - struct bin_attribute *sdram_attr = &solo_dev->sdram_attr;
44976 + bin_attribute_no_const *sdram_attr = &solo_dev->sdram_attr;
44977 struct device *dev = &solo_dev->dev;
44978 const char *driver;
44979 int i;
44980 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
44981 index 34afc16..ffe44dd 100644
44982 --- a/drivers/staging/octeon/ethernet-rx.c
44983 +++ b/drivers/staging/octeon/ethernet-rx.c
44984 @@ -421,11 +421,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
44985 /* Increment RX stats for virtual ports */
44986 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
44987 #ifdef CONFIG_64BIT
44988 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
44989 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
44990 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
44991 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
44992 #else
44993 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
44994 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
44995 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
44996 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
44997 #endif
44998 }
44999 netif_receive_skb(skb);
45000 @@ -437,9 +437,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
45001 dev->name);
45002 */
45003 #ifdef CONFIG_64BIT
45004 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
45005 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
45006 #else
45007 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
45008 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
45009 #endif
45010 dev_kfree_skb_irq(skb);
45011 }
45012 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
45013 index c3a90e7..023619a 100644
45014 --- a/drivers/staging/octeon/ethernet.c
45015 +++ b/drivers/staging/octeon/ethernet.c
45016 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
45017 * since the RX tasklet also increments it.
45018 */
45019 #ifdef CONFIG_64BIT
45020 - atomic64_add(rx_status.dropped_packets,
45021 - (atomic64_t *)&priv->stats.rx_dropped);
45022 + atomic64_add_unchecked(rx_status.dropped_packets,
45023 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
45024 #else
45025 - atomic_add(rx_status.dropped_packets,
45026 - (atomic_t *)&priv->stats.rx_dropped);
45027 + atomic_add_unchecked(rx_status.dropped_packets,
45028 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
45029 #endif
45030 }
45031
45032 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
45033 index dc23395..cf7e9b1 100644
45034 --- a/drivers/staging/rtl8712/rtl871x_io.h
45035 +++ b/drivers/staging/rtl8712/rtl871x_io.h
45036 @@ -108,7 +108,7 @@ struct _io_ops {
45037 u8 *pmem);
45038 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
45039 u8 *pmem);
45040 -};
45041 +} __no_const;
45042
45043 struct io_req {
45044 struct list_head list;
45045 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
45046 index 1f5088b..0e59820 100644
45047 --- a/drivers/staging/sbe-2t3e3/netdev.c
45048 +++ b/drivers/staging/sbe-2t3e3/netdev.c
45049 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
45050 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
45051
45052 if (rlen)
45053 - if (copy_to_user(data, &resp, rlen))
45054 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
45055 return -EFAULT;
45056
45057 return 0;
45058 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
45059 index a863a98..d272795 100644
45060 --- a/drivers/staging/usbip/vhci.h
45061 +++ b/drivers/staging/usbip/vhci.h
45062 @@ -83,7 +83,7 @@ struct vhci_hcd {
45063 unsigned resuming:1;
45064 unsigned long re_timeout;
45065
45066 - atomic_t seqnum;
45067 + atomic_unchecked_t seqnum;
45068
45069 /*
45070 * NOTE:
45071 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
45072 index d7974cb..d78076b 100644
45073 --- a/drivers/staging/usbip/vhci_hcd.c
45074 +++ b/drivers/staging/usbip/vhci_hcd.c
45075 @@ -441,7 +441,7 @@ static void vhci_tx_urb(struct urb *urb)
45076
45077 spin_lock(&vdev->priv_lock);
45078
45079 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
45080 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
45081 if (priv->seqnum == 0xffff)
45082 dev_info(&urb->dev->dev, "seqnum max\n");
45083
45084 @@ -687,7 +687,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
45085 return -ENOMEM;
45086 }
45087
45088 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
45089 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
45090 if (unlink->seqnum == 0xffff)
45091 pr_info("seqnum max\n");
45092
45093 @@ -891,7 +891,7 @@ static int vhci_start(struct usb_hcd *hcd)
45094 vdev->rhport = rhport;
45095 }
45096
45097 - atomic_set(&vhci->seqnum, 0);
45098 + atomic_set_unchecked(&vhci->seqnum, 0);
45099 spin_lock_init(&vhci->lock);
45100
45101 hcd->power_budget = 0; /* no limit */
45102 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
45103 index d07fcb5..358e1e1 100644
45104 --- a/drivers/staging/usbip/vhci_rx.c
45105 +++ b/drivers/staging/usbip/vhci_rx.c
45106 @@ -80,7 +80,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
45107 if (!urb) {
45108 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
45109 pr_info("max seqnum %d\n",
45110 - atomic_read(&the_controller->seqnum));
45111 + atomic_read_unchecked(&the_controller->seqnum));
45112 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
45113 return;
45114 }
45115 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
45116 index 8417c2f..ef5ebd6 100644
45117 --- a/drivers/staging/vt6655/hostap.c
45118 +++ b/drivers/staging/vt6655/hostap.c
45119 @@ -69,14 +69,13 @@ static int msglevel = MSG_LEVEL_INFO;
45120 *
45121 */
45122
45123 +static net_device_ops_no_const apdev_netdev_ops;
45124 +
45125 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
45126 {
45127 PSDevice apdev_priv;
45128 struct net_device *dev = pDevice->dev;
45129 int ret;
45130 - const struct net_device_ops apdev_netdev_ops = {
45131 - .ndo_start_xmit = pDevice->tx_80211,
45132 - };
45133
45134 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
45135
45136 @@ -88,6 +87,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
45137 *apdev_priv = *pDevice;
45138 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
45139
45140 + /* only half broken now */
45141 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
45142 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
45143
45144 pDevice->apdev->type = ARPHRD_IEEE80211;
45145 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
45146 index c699a30..b90a5fd 100644
45147 --- a/drivers/staging/vt6656/hostap.c
45148 +++ b/drivers/staging/vt6656/hostap.c
45149 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
45150 *
45151 */
45152
45153 +static net_device_ops_no_const apdev_netdev_ops;
45154 +
45155 static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
45156 {
45157 struct vnt_private *apdev_priv;
45158 struct net_device *dev = pDevice->dev;
45159 int ret;
45160 - const struct net_device_ops apdev_netdev_ops = {
45161 - .ndo_start_xmit = pDevice->tx_80211,
45162 - };
45163
45164 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
45165
45166 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
45167 *apdev_priv = *pDevice;
45168 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
45169
45170 + /* only half broken now */
45171 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
45172 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
45173
45174 pDevice->apdev->type = ARPHRD_IEEE80211;
45175 diff --git a/drivers/staging/zcache/tmem.h b/drivers/staging/zcache/tmem.h
45176 index d128ce2..fc1f9a1 100644
45177 --- a/drivers/staging/zcache/tmem.h
45178 +++ b/drivers/staging/zcache/tmem.h
45179 @@ -225,7 +225,7 @@ struct tmem_pamops {
45180 bool (*is_remote)(void *);
45181 int (*replace_in_obj)(void *, struct tmem_obj *);
45182 #endif
45183 -};
45184 +} __no_const;
45185 extern void tmem_register_pamops(struct tmem_pamops *m);
45186
45187 /* memory allocation methods provided by the host implementation */
45188 @@ -234,7 +234,7 @@ struct tmem_hostops {
45189 void (*obj_free)(struct tmem_obj *, struct tmem_pool *);
45190 struct tmem_objnode *(*objnode_alloc)(struct tmem_pool *);
45191 void (*objnode_free)(struct tmem_objnode *, struct tmem_pool *);
45192 -};
45193 +} __no_const;
45194 extern void tmem_register_hostops(struct tmem_hostops *m);
45195
45196 /* core tmem accessor functions */
45197 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
45198 index 4630481..c26782a 100644
45199 --- a/drivers/target/target_core_device.c
45200 +++ b/drivers/target/target_core_device.c
45201 @@ -1400,7 +1400,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
45202 spin_lock_init(&dev->se_port_lock);
45203 spin_lock_init(&dev->se_tmr_lock);
45204 spin_lock_init(&dev->qf_cmd_lock);
45205 - atomic_set(&dev->dev_ordered_id, 0);
45206 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
45207 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
45208 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
45209 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
45210 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
45211 index 21e3158..43c6004 100644
45212 --- a/drivers/target/target_core_transport.c
45213 +++ b/drivers/target/target_core_transport.c
45214 @@ -1080,7 +1080,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
45215 * Used to determine when ORDERED commands should go from
45216 * Dormant to Active status.
45217 */
45218 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
45219 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
45220 smp_mb__after_atomic_inc();
45221 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
45222 cmd->se_ordered_id, cmd->sam_task_attr,
45223 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
45224 index 33f83fe..d80f8e1 100644
45225 --- a/drivers/tty/cyclades.c
45226 +++ b/drivers/tty/cyclades.c
45227 @@ -1570,10 +1570,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
45228 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
45229 info->port.count);
45230 #endif
45231 - info->port.count++;
45232 + atomic_inc(&info->port.count);
45233 #ifdef CY_DEBUG_COUNT
45234 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
45235 - current->pid, info->port.count);
45236 + current->pid, atomic_read(&info->port.count));
45237 #endif
45238
45239 /*
45240 @@ -3972,7 +3972,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
45241 for (j = 0; j < cy_card[i].nports; j++) {
45242 info = &cy_card[i].ports[j];
45243
45244 - if (info->port.count) {
45245 + if (atomic_read(&info->port.count)) {
45246 /* XXX is the ldisc num worth this? */
45247 struct tty_struct *tty;
45248 struct tty_ldisc *ld;
45249 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
45250 index eb255e8..f637a57 100644
45251 --- a/drivers/tty/hvc/hvc_console.c
45252 +++ b/drivers/tty/hvc/hvc_console.c
45253 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
45254
45255 spin_lock_irqsave(&hp->port.lock, flags);
45256 /* Check and then increment for fast path open. */
45257 - if (hp->port.count++ > 0) {
45258 + if (atomic_inc_return(&hp->port.count) > 1) {
45259 spin_unlock_irqrestore(&hp->port.lock, flags);
45260 hvc_kick();
45261 return 0;
45262 @@ -388,7 +388,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
45263
45264 spin_lock_irqsave(&hp->port.lock, flags);
45265
45266 - if (--hp->port.count == 0) {
45267 + if (atomic_dec_return(&hp->port.count) == 0) {
45268 spin_unlock_irqrestore(&hp->port.lock, flags);
45269 /* We are done with the tty pointer now. */
45270 tty_port_tty_set(&hp->port, NULL);
45271 @@ -406,9 +406,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
45272 */
45273 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
45274 } else {
45275 - if (hp->port.count < 0)
45276 + if (atomic_read(&hp->port.count) < 0)
45277 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
45278 - hp->vtermno, hp->port.count);
45279 + hp->vtermno, atomic_read(&hp->port.count));
45280 spin_unlock_irqrestore(&hp->port.lock, flags);
45281 }
45282 }
45283 @@ -438,12 +438,12 @@ static void hvc_hangup(struct tty_struct *tty)
45284 * open->hangup case this can be called after the final close so prevent
45285 * that from happening for now.
45286 */
45287 - if (hp->port.count <= 0) {
45288 + if (atomic_read(&hp->port.count) <= 0) {
45289 spin_unlock_irqrestore(&hp->port.lock, flags);
45290 return;
45291 }
45292
45293 - hp->port.count = 0;
45294 + atomic_set(&hp->port.count, 0);
45295 spin_unlock_irqrestore(&hp->port.lock, flags);
45296 tty_port_tty_set(&hp->port, NULL);
45297
45298 @@ -491,7 +491,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
45299 return -EPIPE;
45300
45301 /* FIXME what's this (unprotected) check for? */
45302 - if (hp->port.count <= 0)
45303 + if (atomic_read(&hp->port.count) <= 0)
45304 return -EIO;
45305
45306 spin_lock_irqsave(&hp->lock, flags);
45307 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
45308 index 81e939e..95ead10 100644
45309 --- a/drivers/tty/hvc/hvcs.c
45310 +++ b/drivers/tty/hvc/hvcs.c
45311 @@ -83,6 +83,7 @@
45312 #include <asm/hvcserver.h>
45313 #include <asm/uaccess.h>
45314 #include <asm/vio.h>
45315 +#include <asm/local.h>
45316
45317 /*
45318 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
45319 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
45320
45321 spin_lock_irqsave(&hvcsd->lock, flags);
45322
45323 - if (hvcsd->port.count > 0) {
45324 + if (atomic_read(&hvcsd->port.count) > 0) {
45325 spin_unlock_irqrestore(&hvcsd->lock, flags);
45326 printk(KERN_INFO "HVCS: vterm state unchanged. "
45327 "The hvcs device node is still in use.\n");
45328 @@ -1127,7 +1128,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
45329 }
45330 }
45331
45332 - hvcsd->port.count = 0;
45333 + atomic_set(&hvcsd->port.count, 0);
45334 hvcsd->port.tty = tty;
45335 tty->driver_data = hvcsd;
45336
45337 @@ -1180,7 +1181,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
45338 unsigned long flags;
45339
45340 spin_lock_irqsave(&hvcsd->lock, flags);
45341 - hvcsd->port.count++;
45342 + atomic_inc(&hvcsd->port.count);
45343 hvcsd->todo_mask |= HVCS_SCHED_READ;
45344 spin_unlock_irqrestore(&hvcsd->lock, flags);
45345
45346 @@ -1216,7 +1217,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
45347 hvcsd = tty->driver_data;
45348
45349 spin_lock_irqsave(&hvcsd->lock, flags);
45350 - if (--hvcsd->port.count == 0) {
45351 + if (atomic_dec_and_test(&hvcsd->port.count)) {
45352
45353 vio_disable_interrupts(hvcsd->vdev);
45354
45355 @@ -1241,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
45356
45357 free_irq(irq, hvcsd);
45358 return;
45359 - } else if (hvcsd->port.count < 0) {
45360 + } else if (atomic_read(&hvcsd->port.count) < 0) {
45361 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
45362 " is missmanaged.\n",
45363 - hvcsd->vdev->unit_address, hvcsd->port.count);
45364 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
45365 }
45366
45367 spin_unlock_irqrestore(&hvcsd->lock, flags);
45368 @@ -1266,7 +1267,7 @@ static void hvcs_hangup(struct tty_struct * tty)
45369
45370 spin_lock_irqsave(&hvcsd->lock, flags);
45371 /* Preserve this so that we know how many kref refs to put */
45372 - temp_open_count = hvcsd->port.count;
45373 + temp_open_count = atomic_read(&hvcsd->port.count);
45374
45375 /*
45376 * Don't kref put inside the spinlock because the destruction
45377 @@ -1281,7 +1282,7 @@ static void hvcs_hangup(struct tty_struct * tty)
45378 tty->driver_data = NULL;
45379 hvcsd->port.tty = NULL;
45380
45381 - hvcsd->port.count = 0;
45382 + atomic_set(&hvcsd->port.count, 0);
45383
45384 /* This will drop any buffered data on the floor which is OK in a hangup
45385 * scenario. */
45386 @@ -1352,7 +1353,7 @@ static int hvcs_write(struct tty_struct *tty,
45387 * the middle of a write operation? This is a crummy place to do this
45388 * but we want to keep it all in the spinlock.
45389 */
45390 - if (hvcsd->port.count <= 0) {
45391 + if (atomic_read(&hvcsd->port.count) <= 0) {
45392 spin_unlock_irqrestore(&hvcsd->lock, flags);
45393 return -ENODEV;
45394 }
45395 @@ -1426,7 +1427,7 @@ static int hvcs_write_room(struct tty_struct *tty)
45396 {
45397 struct hvcs_struct *hvcsd = tty->driver_data;
45398
45399 - if (!hvcsd || hvcsd->port.count <= 0)
45400 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
45401 return 0;
45402
45403 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
45404 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
45405 index 8fd72ff..34a0bed 100644
45406 --- a/drivers/tty/ipwireless/tty.c
45407 +++ b/drivers/tty/ipwireless/tty.c
45408 @@ -29,6 +29,7 @@
45409 #include <linux/tty_driver.h>
45410 #include <linux/tty_flip.h>
45411 #include <linux/uaccess.h>
45412 +#include <asm/local.h>
45413
45414 #include "tty.h"
45415 #include "network.h"
45416 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
45417 mutex_unlock(&tty->ipw_tty_mutex);
45418 return -ENODEV;
45419 }
45420 - if (tty->port.count == 0)
45421 + if (atomic_read(&tty->port.count) == 0)
45422 tty->tx_bytes_queued = 0;
45423
45424 - tty->port.count++;
45425 + atomic_inc(&tty->port.count);
45426
45427 tty->port.tty = linux_tty;
45428 linux_tty->driver_data = tty;
45429 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
45430
45431 static void do_ipw_close(struct ipw_tty *tty)
45432 {
45433 - tty->port.count--;
45434 -
45435 - if (tty->port.count == 0) {
45436 + if (atomic_dec_return(&tty->port.count) == 0) {
45437 struct tty_struct *linux_tty = tty->port.tty;
45438
45439 if (linux_tty != NULL) {
45440 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
45441 return;
45442
45443 mutex_lock(&tty->ipw_tty_mutex);
45444 - if (tty->port.count == 0) {
45445 + if (atomic_read(&tty->port.count) == 0) {
45446 mutex_unlock(&tty->ipw_tty_mutex);
45447 return;
45448 }
45449 @@ -164,7 +163,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
45450
45451 mutex_lock(&tty->ipw_tty_mutex);
45452
45453 - if (!tty->port.count) {
45454 + if (!atomic_read(&tty->port.count)) {
45455 mutex_unlock(&tty->ipw_tty_mutex);
45456 return;
45457 }
45458 @@ -206,7 +205,7 @@ static int ipw_write(struct tty_struct *linux_tty,
45459 return -ENODEV;
45460
45461 mutex_lock(&tty->ipw_tty_mutex);
45462 - if (!tty->port.count) {
45463 + if (!atomic_read(&tty->port.count)) {
45464 mutex_unlock(&tty->ipw_tty_mutex);
45465 return -EINVAL;
45466 }
45467 @@ -246,7 +245,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
45468 if (!tty)
45469 return -ENODEV;
45470
45471 - if (!tty->port.count)
45472 + if (!atomic_read(&tty->port.count))
45473 return -EINVAL;
45474
45475 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
45476 @@ -288,7 +287,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
45477 if (!tty)
45478 return 0;
45479
45480 - if (!tty->port.count)
45481 + if (!atomic_read(&tty->port.count))
45482 return 0;
45483
45484 return tty->tx_bytes_queued;
45485 @@ -369,7 +368,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
45486 if (!tty)
45487 return -ENODEV;
45488
45489 - if (!tty->port.count)
45490 + if (!atomic_read(&tty->port.count))
45491 return -EINVAL;
45492
45493 return get_control_lines(tty);
45494 @@ -385,7 +384,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
45495 if (!tty)
45496 return -ENODEV;
45497
45498 - if (!tty->port.count)
45499 + if (!atomic_read(&tty->port.count))
45500 return -EINVAL;
45501
45502 return set_control_lines(tty, set, clear);
45503 @@ -399,7 +398,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
45504 if (!tty)
45505 return -ENODEV;
45506
45507 - if (!tty->port.count)
45508 + if (!atomic_read(&tty->port.count))
45509 return -EINVAL;
45510
45511 /* FIXME: Exactly how is the tty object locked here .. */
45512 @@ -555,7 +554,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
45513 * are gone */
45514 mutex_lock(&ttyj->ipw_tty_mutex);
45515 }
45516 - while (ttyj->port.count)
45517 + while (atomic_read(&ttyj->port.count))
45518 do_ipw_close(ttyj);
45519 ipwireless_disassociate_network_ttys(network,
45520 ttyj->channel_idx);
45521 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
45522 index 1deaca4..c8582d4 100644
45523 --- a/drivers/tty/moxa.c
45524 +++ b/drivers/tty/moxa.c
45525 @@ -1189,7 +1189,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
45526 }
45527
45528 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
45529 - ch->port.count++;
45530 + atomic_inc(&ch->port.count);
45531 tty->driver_data = ch;
45532 tty_port_tty_set(&ch->port, tty);
45533 mutex_lock(&ch->port.mutex);
45534 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
45535 index 6422390..49003ac8 100644
45536 --- a/drivers/tty/n_gsm.c
45537 +++ b/drivers/tty/n_gsm.c
45538 @@ -1632,7 +1632,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
45539 spin_lock_init(&dlci->lock);
45540 mutex_init(&dlci->mutex);
45541 dlci->fifo = &dlci->_fifo;
45542 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
45543 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
45544 kfree(dlci);
45545 return NULL;
45546 }
45547 @@ -2932,7 +2932,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
45548 struct gsm_dlci *dlci = tty->driver_data;
45549 struct tty_port *port = &dlci->port;
45550
45551 - port->count++;
45552 + atomic_inc(&port->count);
45553 dlci_get(dlci);
45554 dlci_get(dlci->gsm->dlci[0]);
45555 mux_get(dlci->gsm);
45556 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
45557 index 6c7fe90..9241dab 100644
45558 --- a/drivers/tty/n_tty.c
45559 +++ b/drivers/tty/n_tty.c
45560 @@ -2203,6 +2203,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
45561 {
45562 *ops = tty_ldisc_N_TTY;
45563 ops->owner = NULL;
45564 - ops->refcount = ops->flags = 0;
45565 + atomic_set(&ops->refcount, 0);
45566 + ops->flags = 0;
45567 }
45568 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
45569 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
45570 index abfd990..5ab5da9 100644
45571 --- a/drivers/tty/pty.c
45572 +++ b/drivers/tty/pty.c
45573 @@ -796,8 +796,10 @@ static void __init unix98_pty_init(void)
45574 panic("Couldn't register Unix98 pts driver");
45575
45576 /* Now create the /dev/ptmx special device */
45577 + pax_open_kernel();
45578 tty_default_fops(&ptmx_fops);
45579 - ptmx_fops.open = ptmx_open;
45580 + *(void **)&ptmx_fops.open = ptmx_open;
45581 + pax_close_kernel();
45582
45583 cdev_init(&ptmx_cdev, &ptmx_fops);
45584 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
45585 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
45586 index 354564e..fe50d9a 100644
45587 --- a/drivers/tty/rocket.c
45588 +++ b/drivers/tty/rocket.c
45589 @@ -914,7 +914,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
45590 tty->driver_data = info;
45591 tty_port_tty_set(port, tty);
45592
45593 - if (port->count++ == 0) {
45594 + if (atomic_inc_return(&port->count) == 1) {
45595 atomic_inc(&rp_num_ports_open);
45596
45597 #ifdef ROCKET_DEBUG_OPEN
45598 @@ -923,7 +923,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
45599 #endif
45600 }
45601 #ifdef ROCKET_DEBUG_OPEN
45602 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
45603 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
45604 #endif
45605
45606 /*
45607 @@ -1515,7 +1515,7 @@ static void rp_hangup(struct tty_struct *tty)
45608 spin_unlock_irqrestore(&info->port.lock, flags);
45609 return;
45610 }
45611 - if (info->port.count)
45612 + if (atomic_read(&info->port.count))
45613 atomic_dec(&rp_num_ports_open);
45614 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
45615 spin_unlock_irqrestore(&info->port.lock, flags);
45616 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
45617 index 1002054..dd644a8 100644
45618 --- a/drivers/tty/serial/kgdboc.c
45619 +++ b/drivers/tty/serial/kgdboc.c
45620 @@ -24,8 +24,9 @@
45621 #define MAX_CONFIG_LEN 40
45622
45623 static struct kgdb_io kgdboc_io_ops;
45624 +static struct kgdb_io kgdboc_io_ops_console;
45625
45626 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
45627 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
45628 static int configured = -1;
45629
45630 static char config[MAX_CONFIG_LEN];
45631 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
45632 kgdboc_unregister_kbd();
45633 if (configured == 1)
45634 kgdb_unregister_io_module(&kgdboc_io_ops);
45635 + else if (configured == 2)
45636 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
45637 }
45638
45639 static int configure_kgdboc(void)
45640 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
45641 int err;
45642 char *cptr = config;
45643 struct console *cons;
45644 + int is_console = 0;
45645
45646 err = kgdboc_option_setup(config);
45647 if (err || !strlen(config) || isspace(config[0]))
45648 goto noconfig;
45649
45650 err = -ENODEV;
45651 - kgdboc_io_ops.is_console = 0;
45652 kgdb_tty_driver = NULL;
45653
45654 kgdboc_use_kms = 0;
45655 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
45656 int idx;
45657 if (cons->device && cons->device(cons, &idx) == p &&
45658 idx == tty_line) {
45659 - kgdboc_io_ops.is_console = 1;
45660 + is_console = 1;
45661 break;
45662 }
45663 cons = cons->next;
45664 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
45665 kgdb_tty_line = tty_line;
45666
45667 do_register:
45668 - err = kgdb_register_io_module(&kgdboc_io_ops);
45669 + if (is_console) {
45670 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
45671 + configured = 2;
45672 + } else {
45673 + err = kgdb_register_io_module(&kgdboc_io_ops);
45674 + configured = 1;
45675 + }
45676 if (err)
45677 goto noconfig;
45678
45679 @@ -205,8 +214,6 @@ do_register:
45680 if (err)
45681 goto nmi_con_failed;
45682
45683 - configured = 1;
45684 -
45685 return 0;
45686
45687 nmi_con_failed:
45688 @@ -223,7 +230,7 @@ noconfig:
45689 static int __init init_kgdboc(void)
45690 {
45691 /* Already configured? */
45692 - if (configured == 1)
45693 + if (configured >= 1)
45694 return 0;
45695
45696 return configure_kgdboc();
45697 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
45698 if (config[len - 1] == '\n')
45699 config[len - 1] = '\0';
45700
45701 - if (configured == 1)
45702 + if (configured >= 1)
45703 cleanup_kgdboc();
45704
45705 /* Go and configure with the new params. */
45706 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
45707 .post_exception = kgdboc_post_exp_handler,
45708 };
45709
45710 +static struct kgdb_io kgdboc_io_ops_console = {
45711 + .name = "kgdboc",
45712 + .read_char = kgdboc_get_char,
45713 + .write_char = kgdboc_put_char,
45714 + .pre_exception = kgdboc_pre_exp_handler,
45715 + .post_exception = kgdboc_post_exp_handler,
45716 + .is_console = 1
45717 +};
45718 +
45719 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
45720 /* This is only available if kgdboc is a built in for early debugging */
45721 static int __init kgdboc_early_init(char *opt)
45722 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
45723 index 0c8a9fa..234a95f 100644
45724 --- a/drivers/tty/serial/samsung.c
45725 +++ b/drivers/tty/serial/samsung.c
45726 @@ -453,11 +453,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
45727 }
45728 }
45729
45730 +static int s3c64xx_serial_startup(struct uart_port *port);
45731 static int s3c24xx_serial_startup(struct uart_port *port)
45732 {
45733 struct s3c24xx_uart_port *ourport = to_ourport(port);
45734 int ret;
45735
45736 + /* Startup sequence is different for s3c64xx and higher SoC's */
45737 + if (s3c24xx_serial_has_interrupt_mask(port))
45738 + return s3c64xx_serial_startup(port);
45739 +
45740 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
45741 port->mapbase, port->membase);
45742
45743 @@ -1124,10 +1129,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
45744 /* setup info for port */
45745 port->dev = &platdev->dev;
45746
45747 - /* Startup sequence is different for s3c64xx and higher SoC's */
45748 - if (s3c24xx_serial_has_interrupt_mask(port))
45749 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
45750 -
45751 port->uartclk = 1;
45752
45753 if (cfg->uart_flags & UPF_CONS_FLOW) {
45754 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
45755 index f87dbfd..42ad4b1 100644
45756 --- a/drivers/tty/serial/serial_core.c
45757 +++ b/drivers/tty/serial/serial_core.c
45758 @@ -1454,7 +1454,7 @@ static void uart_hangup(struct tty_struct *tty)
45759 uart_flush_buffer(tty);
45760 uart_shutdown(tty, state);
45761 spin_lock_irqsave(&port->lock, flags);
45762 - port->count = 0;
45763 + atomic_set(&port->count, 0);
45764 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
45765 spin_unlock_irqrestore(&port->lock, flags);
45766 tty_port_tty_set(port, NULL);
45767 @@ -1550,7 +1550,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
45768 goto end;
45769 }
45770
45771 - port->count++;
45772 + atomic_inc(&port->count);
45773 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
45774 retval = -ENXIO;
45775 goto err_dec_count;
45776 @@ -1578,7 +1578,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
45777 /*
45778 * Make sure the device is in D0 state.
45779 */
45780 - if (port->count == 1)
45781 + if (atomic_read(&port->count) == 1)
45782 uart_change_pm(state, UART_PM_STATE_ON);
45783
45784 /*
45785 @@ -1596,7 +1596,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
45786 end:
45787 return retval;
45788 err_dec_count:
45789 - port->count--;
45790 + atomic_inc(&port->count);
45791 mutex_unlock(&port->mutex);
45792 goto end;
45793 }
45794 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
45795 index 8eaf1ab..85c030d 100644
45796 --- a/drivers/tty/synclink.c
45797 +++ b/drivers/tty/synclink.c
45798 @@ -3090,7 +3090,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
45799
45800 if (debug_level >= DEBUG_LEVEL_INFO)
45801 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
45802 - __FILE__,__LINE__, info->device_name, info->port.count);
45803 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
45804
45805 if (tty_port_close_start(&info->port, tty, filp) == 0)
45806 goto cleanup;
45807 @@ -3108,7 +3108,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
45808 cleanup:
45809 if (debug_level >= DEBUG_LEVEL_INFO)
45810 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
45811 - tty->driver->name, info->port.count);
45812 + tty->driver->name, atomic_read(&info->port.count));
45813
45814 } /* end of mgsl_close() */
45815
45816 @@ -3207,8 +3207,8 @@ static void mgsl_hangup(struct tty_struct *tty)
45817
45818 mgsl_flush_buffer(tty);
45819 shutdown(info);
45820 -
45821 - info->port.count = 0;
45822 +
45823 + atomic_set(&info->port.count, 0);
45824 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
45825 info->port.tty = NULL;
45826
45827 @@ -3297,12 +3297,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
45828
45829 if (debug_level >= DEBUG_LEVEL_INFO)
45830 printk("%s(%d):block_til_ready before block on %s count=%d\n",
45831 - __FILE__,__LINE__, tty->driver->name, port->count );
45832 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
45833
45834 spin_lock_irqsave(&info->irq_spinlock, flags);
45835 if (!tty_hung_up_p(filp)) {
45836 extra_count = true;
45837 - port->count--;
45838 + atomic_dec(&port->count);
45839 }
45840 spin_unlock_irqrestore(&info->irq_spinlock, flags);
45841 port->blocked_open++;
45842 @@ -3331,7 +3331,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
45843
45844 if (debug_level >= DEBUG_LEVEL_INFO)
45845 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
45846 - __FILE__,__LINE__, tty->driver->name, port->count );
45847 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
45848
45849 tty_unlock(tty);
45850 schedule();
45851 @@ -3343,12 +3343,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
45852
45853 /* FIXME: Racy on hangup during close wait */
45854 if (extra_count)
45855 - port->count++;
45856 + atomic_inc(&port->count);
45857 port->blocked_open--;
45858
45859 if (debug_level >= DEBUG_LEVEL_INFO)
45860 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
45861 - __FILE__,__LINE__, tty->driver->name, port->count );
45862 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
45863
45864 if (!retval)
45865 port->flags |= ASYNC_NORMAL_ACTIVE;
45866 @@ -3400,7 +3400,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
45867
45868 if (debug_level >= DEBUG_LEVEL_INFO)
45869 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
45870 - __FILE__,__LINE__,tty->driver->name, info->port.count);
45871 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
45872
45873 /* If port is closing, signal caller to try again */
45874 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
45875 @@ -3419,10 +3419,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
45876 spin_unlock_irqrestore(&info->netlock, flags);
45877 goto cleanup;
45878 }
45879 - info->port.count++;
45880 + atomic_inc(&info->port.count);
45881 spin_unlock_irqrestore(&info->netlock, flags);
45882
45883 - if (info->port.count == 1) {
45884 + if (atomic_read(&info->port.count) == 1) {
45885 /* 1st open on this device, init hardware */
45886 retval = startup(info);
45887 if (retval < 0)
45888 @@ -3446,8 +3446,8 @@ cleanup:
45889 if (retval) {
45890 if (tty->count == 1)
45891 info->port.tty = NULL; /* tty layer will release tty struct */
45892 - if(info->port.count)
45893 - info->port.count--;
45894 + if (atomic_read(&info->port.count))
45895 + atomic_dec(&info->port.count);
45896 }
45897
45898 return retval;
45899 @@ -7665,7 +7665,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
45900 unsigned short new_crctype;
45901
45902 /* return error if TTY interface open */
45903 - if (info->port.count)
45904 + if (atomic_read(&info->port.count))
45905 return -EBUSY;
45906
45907 switch (encoding)
45908 @@ -7760,7 +7760,7 @@ static int hdlcdev_open(struct net_device *dev)
45909
45910 /* arbitrate between network and tty opens */
45911 spin_lock_irqsave(&info->netlock, flags);
45912 - if (info->port.count != 0 || info->netcount != 0) {
45913 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
45914 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
45915 spin_unlock_irqrestore(&info->netlock, flags);
45916 return -EBUSY;
45917 @@ -7846,7 +7846,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
45918 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
45919
45920 /* return error if TTY interface open */
45921 - if (info->port.count)
45922 + if (atomic_read(&info->port.count))
45923 return -EBUSY;
45924
45925 if (cmd != SIOCWANDEV)
45926 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
45927 index 1abf946..1ee34fc 100644
45928 --- a/drivers/tty/synclink_gt.c
45929 +++ b/drivers/tty/synclink_gt.c
45930 @@ -670,7 +670,7 @@ static int open(struct tty_struct *tty, struct file *filp)
45931 tty->driver_data = info;
45932 info->port.tty = tty;
45933
45934 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
45935 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
45936
45937 /* If port is closing, signal caller to try again */
45938 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
45939 @@ -691,10 +691,10 @@ static int open(struct tty_struct *tty, struct file *filp)
45940 mutex_unlock(&info->port.mutex);
45941 goto cleanup;
45942 }
45943 - info->port.count++;
45944 + atomic_inc(&info->port.count);
45945 spin_unlock_irqrestore(&info->netlock, flags);
45946
45947 - if (info->port.count == 1) {
45948 + if (atomic_read(&info->port.count) == 1) {
45949 /* 1st open on this device, init hardware */
45950 retval = startup(info);
45951 if (retval < 0) {
45952 @@ -715,8 +715,8 @@ cleanup:
45953 if (retval) {
45954 if (tty->count == 1)
45955 info->port.tty = NULL; /* tty layer will release tty struct */
45956 - if(info->port.count)
45957 - info->port.count--;
45958 + if(atomic_read(&info->port.count))
45959 + atomic_dec(&info->port.count);
45960 }
45961
45962 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
45963 @@ -729,7 +729,7 @@ static void close(struct tty_struct *tty, struct file *filp)
45964
45965 if (sanity_check(info, tty->name, "close"))
45966 return;
45967 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
45968 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
45969
45970 if (tty_port_close_start(&info->port, tty, filp) == 0)
45971 goto cleanup;
45972 @@ -746,7 +746,7 @@ static void close(struct tty_struct *tty, struct file *filp)
45973 tty_port_close_end(&info->port, tty);
45974 info->port.tty = NULL;
45975 cleanup:
45976 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
45977 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
45978 }
45979
45980 static void hangup(struct tty_struct *tty)
45981 @@ -764,7 +764,7 @@ static void hangup(struct tty_struct *tty)
45982 shutdown(info);
45983
45984 spin_lock_irqsave(&info->port.lock, flags);
45985 - info->port.count = 0;
45986 + atomic_set(&info->port.count, 0);
45987 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
45988 info->port.tty = NULL;
45989 spin_unlock_irqrestore(&info->port.lock, flags);
45990 @@ -1449,7 +1449,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
45991 unsigned short new_crctype;
45992
45993 /* return error if TTY interface open */
45994 - if (info->port.count)
45995 + if (atomic_read(&info->port.count))
45996 return -EBUSY;
45997
45998 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
45999 @@ -1544,7 +1544,7 @@ static int hdlcdev_open(struct net_device *dev)
46000
46001 /* arbitrate between network and tty opens */
46002 spin_lock_irqsave(&info->netlock, flags);
46003 - if (info->port.count != 0 || info->netcount != 0) {
46004 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
46005 DBGINFO(("%s hdlc_open busy\n", dev->name));
46006 spin_unlock_irqrestore(&info->netlock, flags);
46007 return -EBUSY;
46008 @@ -1629,7 +1629,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
46009 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
46010
46011 /* return error if TTY interface open */
46012 - if (info->port.count)
46013 + if (atomic_read(&info->port.count))
46014 return -EBUSY;
46015
46016 if (cmd != SIOCWANDEV)
46017 @@ -2413,7 +2413,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
46018 if (port == NULL)
46019 continue;
46020 spin_lock(&port->lock);
46021 - if ((port->port.count || port->netcount) &&
46022 + if ((atomic_read(&port->port.count) || port->netcount) &&
46023 port->pending_bh && !port->bh_running &&
46024 !port->bh_requested) {
46025 DBGISR(("%s bh queued\n", port->device_name));
46026 @@ -3302,7 +3302,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
46027 spin_lock_irqsave(&info->lock, flags);
46028 if (!tty_hung_up_p(filp)) {
46029 extra_count = true;
46030 - port->count--;
46031 + atomic_dec(&port->count);
46032 }
46033 spin_unlock_irqrestore(&info->lock, flags);
46034 port->blocked_open++;
46035 @@ -3339,7 +3339,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
46036 remove_wait_queue(&port->open_wait, &wait);
46037
46038 if (extra_count)
46039 - port->count++;
46040 + atomic_inc(&port->count);
46041 port->blocked_open--;
46042
46043 if (!retval)
46044 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
46045 index ff17138..e38b41e 100644
46046 --- a/drivers/tty/synclinkmp.c
46047 +++ b/drivers/tty/synclinkmp.c
46048 @@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
46049
46050 if (debug_level >= DEBUG_LEVEL_INFO)
46051 printk("%s(%d):%s open(), old ref count = %d\n",
46052 - __FILE__,__LINE__,tty->driver->name, info->port.count);
46053 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
46054
46055 /* If port is closing, signal caller to try again */
46056 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
46057 @@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
46058 spin_unlock_irqrestore(&info->netlock, flags);
46059 goto cleanup;
46060 }
46061 - info->port.count++;
46062 + atomic_inc(&info->port.count);
46063 spin_unlock_irqrestore(&info->netlock, flags);
46064
46065 - if (info->port.count == 1) {
46066 + if (atomic_read(&info->port.count) == 1) {
46067 /* 1st open on this device, init hardware */
46068 retval = startup(info);
46069 if (retval < 0)
46070 @@ -796,8 +796,8 @@ cleanup:
46071 if (retval) {
46072 if (tty->count == 1)
46073 info->port.tty = NULL; /* tty layer will release tty struct */
46074 - if(info->port.count)
46075 - info->port.count--;
46076 + if(atomic_read(&info->port.count))
46077 + atomic_dec(&info->port.count);
46078 }
46079
46080 return retval;
46081 @@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
46082
46083 if (debug_level >= DEBUG_LEVEL_INFO)
46084 printk("%s(%d):%s close() entry, count=%d\n",
46085 - __FILE__,__LINE__, info->device_name, info->port.count);
46086 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
46087
46088 if (tty_port_close_start(&info->port, tty, filp) == 0)
46089 goto cleanup;
46090 @@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
46091 cleanup:
46092 if (debug_level >= DEBUG_LEVEL_INFO)
46093 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
46094 - tty->driver->name, info->port.count);
46095 + tty->driver->name, atomic_read(&info->port.count));
46096 }
46097
46098 /* Called by tty_hangup() when a hangup is signaled.
46099 @@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
46100 shutdown(info);
46101
46102 spin_lock_irqsave(&info->port.lock, flags);
46103 - info->port.count = 0;
46104 + atomic_set(&info->port.count, 0);
46105 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
46106 info->port.tty = NULL;
46107 spin_unlock_irqrestore(&info->port.lock, flags);
46108 @@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
46109 unsigned short new_crctype;
46110
46111 /* return error if TTY interface open */
46112 - if (info->port.count)
46113 + if (atomic_read(&info->port.count))
46114 return -EBUSY;
46115
46116 switch (encoding)
46117 @@ -1660,7 +1660,7 @@ static int hdlcdev_open(struct net_device *dev)
46118
46119 /* arbitrate between network and tty opens */
46120 spin_lock_irqsave(&info->netlock, flags);
46121 - if (info->port.count != 0 || info->netcount != 0) {
46122 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
46123 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
46124 spin_unlock_irqrestore(&info->netlock, flags);
46125 return -EBUSY;
46126 @@ -1746,7 +1746,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
46127 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
46128
46129 /* return error if TTY interface open */
46130 - if (info->port.count)
46131 + if (atomic_read(&info->port.count))
46132 return -EBUSY;
46133
46134 if (cmd != SIOCWANDEV)
46135 @@ -2620,7 +2620,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
46136 * do not request bottom half processing if the
46137 * device is not open in a normal mode.
46138 */
46139 - if ( port && (port->port.count || port->netcount) &&
46140 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
46141 port->pending_bh && !port->bh_running &&
46142 !port->bh_requested ) {
46143 if ( debug_level >= DEBUG_LEVEL_ISR )
46144 @@ -3318,12 +3318,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
46145
46146 if (debug_level >= DEBUG_LEVEL_INFO)
46147 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
46148 - __FILE__,__LINE__, tty->driver->name, port->count );
46149 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
46150
46151 spin_lock_irqsave(&info->lock, flags);
46152 if (!tty_hung_up_p(filp)) {
46153 extra_count = true;
46154 - port->count--;
46155 + atomic_dec(&port->count);
46156 }
46157 spin_unlock_irqrestore(&info->lock, flags);
46158 port->blocked_open++;
46159 @@ -3352,7 +3352,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
46160
46161 if (debug_level >= DEBUG_LEVEL_INFO)
46162 printk("%s(%d):%s block_til_ready() count=%d\n",
46163 - __FILE__,__LINE__, tty->driver->name, port->count );
46164 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
46165
46166 tty_unlock(tty);
46167 schedule();
46168 @@ -3363,12 +3363,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
46169 remove_wait_queue(&port->open_wait, &wait);
46170
46171 if (extra_count)
46172 - port->count++;
46173 + atomic_inc(&port->count);
46174 port->blocked_open--;
46175
46176 if (debug_level >= DEBUG_LEVEL_INFO)
46177 printk("%s(%d):%s block_til_ready() after, count=%d\n",
46178 - __FILE__,__LINE__, tty->driver->name, port->count );
46179 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
46180
46181 if (!retval)
46182 port->flags |= ASYNC_NORMAL_ACTIVE;
46183 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
46184 index b51c154..17d55d1 100644
46185 --- a/drivers/tty/sysrq.c
46186 +++ b/drivers/tty/sysrq.c
46187 @@ -1022,7 +1022,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
46188 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
46189 size_t count, loff_t *ppos)
46190 {
46191 - if (count) {
46192 + if (count && capable(CAP_SYS_ADMIN)) {
46193 char c;
46194
46195 if (get_user(c, buf))
46196 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
46197 index 4476682..d77e748 100644
46198 --- a/drivers/tty/tty_io.c
46199 +++ b/drivers/tty/tty_io.c
46200 @@ -3466,7 +3466,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
46201
46202 void tty_default_fops(struct file_operations *fops)
46203 {
46204 - *fops = tty_fops;
46205 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
46206 }
46207
46208 /*
46209 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
46210 index 1afe192..73d2c20 100644
46211 --- a/drivers/tty/tty_ldisc.c
46212 +++ b/drivers/tty/tty_ldisc.c
46213 @@ -66,7 +66,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
46214 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
46215 tty_ldiscs[disc] = new_ldisc;
46216 new_ldisc->num = disc;
46217 - new_ldisc->refcount = 0;
46218 + atomic_set(&new_ldisc->refcount, 0);
46219 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
46220
46221 return ret;
46222 @@ -94,7 +94,7 @@ int tty_unregister_ldisc(int disc)
46223 return -EINVAL;
46224
46225 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
46226 - if (tty_ldiscs[disc]->refcount)
46227 + if (atomic_read(&tty_ldiscs[disc]->refcount))
46228 ret = -EBUSY;
46229 else
46230 tty_ldiscs[disc] = NULL;
46231 @@ -115,7 +115,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
46232 if (ldops) {
46233 ret = ERR_PTR(-EAGAIN);
46234 if (try_module_get(ldops->owner)) {
46235 - ldops->refcount++;
46236 + atomic_inc(&ldops->refcount);
46237 ret = ldops;
46238 }
46239 }
46240 @@ -128,7 +128,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
46241 unsigned long flags;
46242
46243 raw_spin_lock_irqsave(&tty_ldisc_lock, flags);
46244 - ldops->refcount--;
46245 + atomic_dec(&ldops->refcount);
46246 module_put(ldops->owner);
46247 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
46248 }
46249 @@ -196,7 +196,7 @@ static inline void tty_ldisc_put(struct tty_ldisc *ld)
46250 /* unreleased reader reference(s) will cause this WARN */
46251 WARN_ON(!atomic_dec_and_test(&ld->users));
46252
46253 - ld->ops->refcount--;
46254 + atomic_dec(&ld->ops->refcount);
46255 module_put(ld->ops->owner);
46256 kfree(ld);
46257 raw_spin_unlock_irqrestore(&tty_ldisc_lock, flags);
46258 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
46259 index f597e88..b7f68ed 100644
46260 --- a/drivers/tty/tty_port.c
46261 +++ b/drivers/tty/tty_port.c
46262 @@ -232,7 +232,7 @@ void tty_port_hangup(struct tty_port *port)
46263 unsigned long flags;
46264
46265 spin_lock_irqsave(&port->lock, flags);
46266 - port->count = 0;
46267 + atomic_set(&port->count, 0);
46268 port->flags &= ~ASYNC_NORMAL_ACTIVE;
46269 tty = port->tty;
46270 if (tty)
46271 @@ -390,7 +390,7 @@ int tty_port_block_til_ready(struct tty_port *port,
46272 /* The port lock protects the port counts */
46273 spin_lock_irqsave(&port->lock, flags);
46274 if (!tty_hung_up_p(filp))
46275 - port->count--;
46276 + atomic_dec(&port->count);
46277 port->blocked_open++;
46278 spin_unlock_irqrestore(&port->lock, flags);
46279
46280 @@ -432,7 +432,7 @@ int tty_port_block_til_ready(struct tty_port *port,
46281 we must not mess that up further */
46282 spin_lock_irqsave(&port->lock, flags);
46283 if (!tty_hung_up_p(filp))
46284 - port->count++;
46285 + atomic_inc(&port->count);
46286 port->blocked_open--;
46287 if (retval == 0)
46288 port->flags |= ASYNC_NORMAL_ACTIVE;
46289 @@ -466,19 +466,19 @@ int tty_port_close_start(struct tty_port *port,
46290 return 0;
46291 }
46292
46293 - if (tty->count == 1 && port->count != 1) {
46294 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
46295 printk(KERN_WARNING
46296 "tty_port_close_start: tty->count = 1 port count = %d.\n",
46297 - port->count);
46298 - port->count = 1;
46299 + atomic_read(&port->count));
46300 + atomic_set(&port->count, 1);
46301 }
46302 - if (--port->count < 0) {
46303 + if (atomic_dec_return(&port->count) < 0) {
46304 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
46305 - port->count);
46306 - port->count = 0;
46307 + atomic_read(&port->count));
46308 + atomic_set(&port->count, 0);
46309 }
46310
46311 - if (port->count) {
46312 + if (atomic_read(&port->count)) {
46313 spin_unlock_irqrestore(&port->lock, flags);
46314 if (port->ops->drop)
46315 port->ops->drop(port);
46316 @@ -564,7 +564,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
46317 {
46318 spin_lock_irq(&port->lock);
46319 if (!tty_hung_up_p(filp))
46320 - ++port->count;
46321 + atomic_inc(&port->count);
46322 spin_unlock_irq(&port->lock);
46323 tty_port_tty_set(port, tty);
46324
46325 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
46326 index a9af1b9a..1e08e7f 100644
46327 --- a/drivers/tty/vt/keyboard.c
46328 +++ b/drivers/tty/vt/keyboard.c
46329 @@ -647,6 +647,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
46330 kbd->kbdmode == VC_OFF) &&
46331 value != KVAL(K_SAK))
46332 return; /* SAK is allowed even in raw mode */
46333 +
46334 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
46335 + {
46336 + void *func = fn_handler[value];
46337 + if (func == fn_show_state || func == fn_show_ptregs ||
46338 + func == fn_show_mem)
46339 + return;
46340 + }
46341 +#endif
46342 +
46343 fn_handler[value](vc);
46344 }
46345
46346 @@ -1795,9 +1805,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
46347 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
46348 return -EFAULT;
46349
46350 - if (!capable(CAP_SYS_TTY_CONFIG))
46351 - perm = 0;
46352 -
46353 switch (cmd) {
46354 case KDGKBENT:
46355 /* Ensure another thread doesn't free it under us */
46356 @@ -1812,6 +1819,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
46357 spin_unlock_irqrestore(&kbd_event_lock, flags);
46358 return put_user(val, &user_kbe->kb_value);
46359 case KDSKBENT:
46360 + if (!capable(CAP_SYS_TTY_CONFIG))
46361 + perm = 0;
46362 +
46363 if (!perm)
46364 return -EPERM;
46365 if (!i && v == K_NOSUCHMAP) {
46366 @@ -1902,9 +1912,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
46367 int i, j, k;
46368 int ret;
46369
46370 - if (!capable(CAP_SYS_TTY_CONFIG))
46371 - perm = 0;
46372 -
46373 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
46374 if (!kbs) {
46375 ret = -ENOMEM;
46376 @@ -1938,6 +1945,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
46377 kfree(kbs);
46378 return ((p && *p) ? -EOVERFLOW : 0);
46379 case KDSKBSENT:
46380 + if (!capable(CAP_SYS_TTY_CONFIG))
46381 + perm = 0;
46382 +
46383 if (!perm) {
46384 ret = -EPERM;
46385 goto reterr;
46386 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
46387 index b645c47..a55c182 100644
46388 --- a/drivers/uio/uio.c
46389 +++ b/drivers/uio/uio.c
46390 @@ -25,6 +25,7 @@
46391 #include <linux/kobject.h>
46392 #include <linux/cdev.h>
46393 #include <linux/uio_driver.h>
46394 +#include <asm/local.h>
46395
46396 #define UIO_MAX_DEVICES (1U << MINORBITS)
46397
46398 @@ -32,10 +33,10 @@ struct uio_device {
46399 struct module *owner;
46400 struct device *dev;
46401 int minor;
46402 - atomic_t event;
46403 + atomic_unchecked_t event;
46404 struct fasync_struct *async_queue;
46405 wait_queue_head_t wait;
46406 - int vma_count;
46407 + local_t vma_count;
46408 struct uio_info *info;
46409 struct kobject *map_dir;
46410 struct kobject *portio_dir;
46411 @@ -242,7 +243,7 @@ static ssize_t show_event(struct device *dev,
46412 struct device_attribute *attr, char *buf)
46413 {
46414 struct uio_device *idev = dev_get_drvdata(dev);
46415 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
46416 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
46417 }
46418
46419 static struct device_attribute uio_class_attributes[] = {
46420 @@ -398,7 +399,7 @@ void uio_event_notify(struct uio_info *info)
46421 {
46422 struct uio_device *idev = info->uio_dev;
46423
46424 - atomic_inc(&idev->event);
46425 + atomic_inc_unchecked(&idev->event);
46426 wake_up_interruptible(&idev->wait);
46427 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
46428 }
46429 @@ -451,7 +452,7 @@ static int uio_open(struct inode *inode, struct file *filep)
46430 }
46431
46432 listener->dev = idev;
46433 - listener->event_count = atomic_read(&idev->event);
46434 + listener->event_count = atomic_read_unchecked(&idev->event);
46435 filep->private_data = listener;
46436
46437 if (idev->info->open) {
46438 @@ -502,7 +503,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
46439 return -EIO;
46440
46441 poll_wait(filep, &idev->wait, wait);
46442 - if (listener->event_count != atomic_read(&idev->event))
46443 + if (listener->event_count != atomic_read_unchecked(&idev->event))
46444 return POLLIN | POLLRDNORM;
46445 return 0;
46446 }
46447 @@ -527,7 +528,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
46448 do {
46449 set_current_state(TASK_INTERRUPTIBLE);
46450
46451 - event_count = atomic_read(&idev->event);
46452 + event_count = atomic_read_unchecked(&idev->event);
46453 if (event_count != listener->event_count) {
46454 if (copy_to_user(buf, &event_count, count))
46455 retval = -EFAULT;
46456 @@ -596,13 +597,13 @@ static int uio_find_mem_index(struct vm_area_struct *vma)
46457 static void uio_vma_open(struct vm_area_struct *vma)
46458 {
46459 struct uio_device *idev = vma->vm_private_data;
46460 - idev->vma_count++;
46461 + local_inc(&idev->vma_count);
46462 }
46463
46464 static void uio_vma_close(struct vm_area_struct *vma)
46465 {
46466 struct uio_device *idev = vma->vm_private_data;
46467 - idev->vma_count--;
46468 + local_dec(&idev->vma_count);
46469 }
46470
46471 static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
46472 @@ -809,7 +810,7 @@ int __uio_register_device(struct module *owner,
46473 idev->owner = owner;
46474 idev->info = info;
46475 init_waitqueue_head(&idev->wait);
46476 - atomic_set(&idev->event, 0);
46477 + atomic_set_unchecked(&idev->event, 0);
46478
46479 ret = uio_get_minor(idev);
46480 if (ret)
46481 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
46482 index 8a7eb77..c00402f 100644
46483 --- a/drivers/usb/atm/cxacru.c
46484 +++ b/drivers/usb/atm/cxacru.c
46485 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
46486 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
46487 if (ret < 2)
46488 return -EINVAL;
46489 - if (index < 0 || index > 0x7f)
46490 + if (index > 0x7f)
46491 return -EINVAL;
46492 pos += tmp;
46493
46494 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
46495 index d3527dd..26effa2 100644
46496 --- a/drivers/usb/atm/usbatm.c
46497 +++ b/drivers/usb/atm/usbatm.c
46498 @@ -333,7 +333,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
46499 if (printk_ratelimit())
46500 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
46501 __func__, vpi, vci);
46502 - atomic_inc(&vcc->stats->rx_err);
46503 + atomic_inc_unchecked(&vcc->stats->rx_err);
46504 return;
46505 }
46506
46507 @@ -361,7 +361,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
46508 if (length > ATM_MAX_AAL5_PDU) {
46509 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
46510 __func__, length, vcc);
46511 - atomic_inc(&vcc->stats->rx_err);
46512 + atomic_inc_unchecked(&vcc->stats->rx_err);
46513 goto out;
46514 }
46515
46516 @@ -370,14 +370,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
46517 if (sarb->len < pdu_length) {
46518 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
46519 __func__, pdu_length, sarb->len, vcc);
46520 - atomic_inc(&vcc->stats->rx_err);
46521 + atomic_inc_unchecked(&vcc->stats->rx_err);
46522 goto out;
46523 }
46524
46525 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
46526 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
46527 __func__, vcc);
46528 - atomic_inc(&vcc->stats->rx_err);
46529 + atomic_inc_unchecked(&vcc->stats->rx_err);
46530 goto out;
46531 }
46532
46533 @@ -389,7 +389,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
46534 if (printk_ratelimit())
46535 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
46536 __func__, length);
46537 - atomic_inc(&vcc->stats->rx_drop);
46538 + atomic_inc_unchecked(&vcc->stats->rx_drop);
46539 goto out;
46540 }
46541
46542 @@ -417,7 +417,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
46543
46544 vcc->push(vcc, skb);
46545
46546 - atomic_inc(&vcc->stats->rx);
46547 + atomic_inc_unchecked(&vcc->stats->rx);
46548 out:
46549 skb_trim(sarb, 0);
46550 }
46551 @@ -623,7 +623,7 @@ static void usbatm_tx_process(unsigned long data)
46552 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
46553
46554 usbatm_pop(vcc, skb);
46555 - atomic_inc(&vcc->stats->tx);
46556 + atomic_inc_unchecked(&vcc->stats->tx);
46557
46558 skb = skb_dequeue(&instance->sndqueue);
46559 }
46560 @@ -779,11 +779,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
46561 if (!left--)
46562 return sprintf(page,
46563 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
46564 - atomic_read(&atm_dev->stats.aal5.tx),
46565 - atomic_read(&atm_dev->stats.aal5.tx_err),
46566 - atomic_read(&atm_dev->stats.aal5.rx),
46567 - atomic_read(&atm_dev->stats.aal5.rx_err),
46568 - atomic_read(&atm_dev->stats.aal5.rx_drop));
46569 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
46570 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
46571 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
46572 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
46573 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
46574
46575 if (!left--) {
46576 if (instance->disconnected)
46577 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
46578 index 2a3bbdf..91d72cf 100644
46579 --- a/drivers/usb/core/devices.c
46580 +++ b/drivers/usb/core/devices.c
46581 @@ -126,7 +126,7 @@ static const char format_endpt[] =
46582 * time it gets called.
46583 */
46584 static struct device_connect_event {
46585 - atomic_t count;
46586 + atomic_unchecked_t count;
46587 wait_queue_head_t wait;
46588 } device_event = {
46589 .count = ATOMIC_INIT(1),
46590 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
46591
46592 void usbfs_conn_disc_event(void)
46593 {
46594 - atomic_add(2, &device_event.count);
46595 + atomic_add_unchecked(2, &device_event.count);
46596 wake_up(&device_event.wait);
46597 }
46598
46599 @@ -652,7 +652,7 @@ static unsigned int usb_device_poll(struct file *file,
46600
46601 poll_wait(file, &device_event.wait, wait);
46602
46603 - event_count = atomic_read(&device_event.count);
46604 + event_count = atomic_read_unchecked(&device_event.count);
46605 if (file->f_version != event_count) {
46606 file->f_version = event_count;
46607 return POLLIN | POLLRDNORM;
46608 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
46609 index d53547d..6a22d02 100644
46610 --- a/drivers/usb/core/hcd.c
46611 +++ b/drivers/usb/core/hcd.c
46612 @@ -1526,7 +1526,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
46613 */
46614 usb_get_urb(urb);
46615 atomic_inc(&urb->use_count);
46616 - atomic_inc(&urb->dev->urbnum);
46617 + atomic_inc_unchecked(&urb->dev->urbnum);
46618 usbmon_urb_submit(&hcd->self, urb);
46619
46620 /* NOTE requirements on root-hub callers (usbfs and the hub
46621 @@ -1553,7 +1553,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
46622 urb->hcpriv = NULL;
46623 INIT_LIST_HEAD(&urb->urb_list);
46624 atomic_dec(&urb->use_count);
46625 - atomic_dec(&urb->dev->urbnum);
46626 + atomic_dec_unchecked(&urb->dev->urbnum);
46627 if (atomic_read(&urb->reject))
46628 wake_up(&usb_kill_urb_queue);
46629 usb_put_urb(urb);
46630 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
46631 index 444d30e..f15c850 100644
46632 --- a/drivers/usb/core/message.c
46633 +++ b/drivers/usb/core/message.c
46634 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
46635 * method can wait for it to complete. Since you don't have a handle on the
46636 * URB used, you can't cancel the request.
46637 */
46638 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
46639 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
46640 __u8 requesttype, __u16 value, __u16 index, void *data,
46641 __u16 size, int timeout)
46642 {
46643 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
46644 index aa38db4..0a08682 100644
46645 --- a/drivers/usb/core/sysfs.c
46646 +++ b/drivers/usb/core/sysfs.c
46647 @@ -239,7 +239,7 @@ show_urbnum(struct device *dev, struct device_attribute *attr, char *buf)
46648 struct usb_device *udev;
46649
46650 udev = to_usb_device(dev);
46651 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
46652 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
46653 }
46654 static DEVICE_ATTR(urbnum, S_IRUGO, show_urbnum, NULL);
46655
46656 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
46657 index b10da72..43aa0b2 100644
46658 --- a/drivers/usb/core/usb.c
46659 +++ b/drivers/usb/core/usb.c
46660 @@ -389,7 +389,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
46661 set_dev_node(&dev->dev, dev_to_node(bus->controller));
46662 dev->state = USB_STATE_ATTACHED;
46663 dev->lpm_disable_count = 1;
46664 - atomic_set(&dev->urbnum, 0);
46665 + atomic_set_unchecked(&dev->urbnum, 0);
46666
46667 INIT_LIST_HEAD(&dev->ep0.urb_list);
46668 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
46669 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
46670 index 5e29dde..eca992f 100644
46671 --- a/drivers/usb/early/ehci-dbgp.c
46672 +++ b/drivers/usb/early/ehci-dbgp.c
46673 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
46674
46675 #ifdef CONFIG_KGDB
46676 static struct kgdb_io kgdbdbgp_io_ops;
46677 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
46678 +static struct kgdb_io kgdbdbgp_io_ops_console;
46679 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
46680 #else
46681 #define dbgp_kgdb_mode (0)
46682 #endif
46683 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
46684 .write_char = kgdbdbgp_write_char,
46685 };
46686
46687 +static struct kgdb_io kgdbdbgp_io_ops_console = {
46688 + .name = "kgdbdbgp",
46689 + .read_char = kgdbdbgp_read_char,
46690 + .write_char = kgdbdbgp_write_char,
46691 + .is_console = 1
46692 +};
46693 +
46694 static int kgdbdbgp_wait_time;
46695
46696 static int __init kgdbdbgp_parse_config(char *str)
46697 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
46698 ptr++;
46699 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
46700 }
46701 - kgdb_register_io_module(&kgdbdbgp_io_ops);
46702 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
46703 + if (early_dbgp_console.index != -1)
46704 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
46705 + else
46706 + kgdb_register_io_module(&kgdbdbgp_io_ops);
46707
46708 return 0;
46709 }
46710 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
46711 index b369292..9f3ba40 100644
46712 --- a/drivers/usb/gadget/u_serial.c
46713 +++ b/drivers/usb/gadget/u_serial.c
46714 @@ -733,9 +733,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
46715 spin_lock_irq(&port->port_lock);
46716
46717 /* already open? Great. */
46718 - if (port->port.count) {
46719 + if (atomic_read(&port->port.count)) {
46720 status = 0;
46721 - port->port.count++;
46722 + atomic_inc(&port->port.count);
46723
46724 /* currently opening/closing? wait ... */
46725 } else if (port->openclose) {
46726 @@ -794,7 +794,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
46727 tty->driver_data = port;
46728 port->port.tty = tty;
46729
46730 - port->port.count = 1;
46731 + atomic_set(&port->port.count, 1);
46732 port->openclose = false;
46733
46734 /* if connected, start the I/O stream */
46735 @@ -836,11 +836,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
46736
46737 spin_lock_irq(&port->port_lock);
46738
46739 - if (port->port.count != 1) {
46740 - if (port->port.count == 0)
46741 + if (atomic_read(&port->port.count) != 1) {
46742 + if (atomic_read(&port->port.count) == 0)
46743 WARN_ON(1);
46744 else
46745 - --port->port.count;
46746 + atomic_dec(&port->port.count);
46747 goto exit;
46748 }
46749
46750 @@ -850,7 +850,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
46751 * and sleep if necessary
46752 */
46753 port->openclose = true;
46754 - port->port.count = 0;
46755 + atomic_set(&port->port.count, 0);
46756
46757 gser = port->port_usb;
46758 if (gser && gser->disconnect)
46759 @@ -1066,7 +1066,7 @@ static int gs_closed(struct gs_port *port)
46760 int cond;
46761
46762 spin_lock_irq(&port->port_lock);
46763 - cond = (port->port.count == 0) && !port->openclose;
46764 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
46765 spin_unlock_irq(&port->port_lock);
46766 return cond;
46767 }
46768 @@ -1209,7 +1209,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
46769 /* if it's already open, start I/O ... and notify the serial
46770 * protocol about open/close status (connect/disconnect).
46771 */
46772 - if (port->port.count) {
46773 + if (atomic_read(&port->port.count)) {
46774 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
46775 gs_start_io(port);
46776 if (gser->connect)
46777 @@ -1256,7 +1256,7 @@ void gserial_disconnect(struct gserial *gser)
46778
46779 port->port_usb = NULL;
46780 gser->ioport = NULL;
46781 - if (port->port.count > 0 || port->openclose) {
46782 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
46783 wake_up_interruptible(&port->drain_wait);
46784 if (port->port.tty)
46785 tty_hangup(port->port.tty);
46786 @@ -1272,7 +1272,7 @@ void gserial_disconnect(struct gserial *gser)
46787
46788 /* finally, free any unused/unusable I/O buffers */
46789 spin_lock_irqsave(&port->port_lock, flags);
46790 - if (port->port.count == 0 && !port->openclose)
46791 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
46792 gs_buf_free(&port->port_write_buf);
46793 gs_free_requests(gser->out, &port->read_pool, NULL);
46794 gs_free_requests(gser->out, &port->read_queue, NULL);
46795 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
46796 index 5f3bcd3..bfca43f 100644
46797 --- a/drivers/usb/serial/console.c
46798 +++ b/drivers/usb/serial/console.c
46799 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
46800
46801 info->port = port;
46802
46803 - ++port->port.count;
46804 + atomic_inc(&port->port.count);
46805 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
46806 if (serial->type->set_termios) {
46807 /*
46808 @@ -174,7 +174,7 @@ static int usb_console_setup(struct console *co, char *options)
46809 }
46810 /* Now that any required fake tty operations are completed restore
46811 * the tty port count */
46812 - --port->port.count;
46813 + atomic_dec(&port->port.count);
46814 /* The console is special in terms of closing the device so
46815 * indicate this port is now acting as a system console. */
46816 port->port.console = 1;
46817 @@ -187,7 +187,7 @@ static int usb_console_setup(struct console *co, char *options)
46818 free_tty:
46819 kfree(tty);
46820 reset_open_count:
46821 - port->port.count = 0;
46822 + atomic_set(&port->port.count, 0);
46823 usb_autopm_put_interface(serial->interface);
46824 error_get_interface:
46825 usb_serial_put(serial);
46826 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
46827 index 75f70f0..d467e1a 100644
46828 --- a/drivers/usb/storage/usb.h
46829 +++ b/drivers/usb/storage/usb.h
46830 @@ -63,7 +63,7 @@ struct us_unusual_dev {
46831 __u8 useProtocol;
46832 __u8 useTransport;
46833 int (*initFunction)(struct us_data *);
46834 -};
46835 +} __do_const;
46836
46837
46838 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
46839 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
46840 index d6bea3e..60b250e 100644
46841 --- a/drivers/usb/wusbcore/wa-hc.h
46842 +++ b/drivers/usb/wusbcore/wa-hc.h
46843 @@ -192,7 +192,7 @@ struct wahc {
46844 struct list_head xfer_delayed_list;
46845 spinlock_t xfer_list_lock;
46846 struct work_struct xfer_work;
46847 - atomic_t xfer_id_count;
46848 + atomic_unchecked_t xfer_id_count;
46849 };
46850
46851
46852 @@ -246,7 +246,7 @@ static inline void wa_init(struct wahc *wa)
46853 INIT_LIST_HEAD(&wa->xfer_delayed_list);
46854 spin_lock_init(&wa->xfer_list_lock);
46855 INIT_WORK(&wa->xfer_work, wa_urb_enqueue_run);
46856 - atomic_set(&wa->xfer_id_count, 1);
46857 + atomic_set_unchecked(&wa->xfer_id_count, 1);
46858 }
46859
46860 /**
46861 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
46862 index 028fc83..65bb105 100644
46863 --- a/drivers/usb/wusbcore/wa-xfer.c
46864 +++ b/drivers/usb/wusbcore/wa-xfer.c
46865 @@ -296,7 +296,7 @@ out:
46866 */
46867 static void wa_xfer_id_init(struct wa_xfer *xfer)
46868 {
46869 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
46870 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
46871 }
46872
46873 /*
46874 diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
46875 index 5174eba..86e764a 100644
46876 --- a/drivers/vhost/vringh.c
46877 +++ b/drivers/vhost/vringh.c
46878 @@ -800,7 +800,7 @@ static inline int getu16_kern(u16 *val, const u16 *p)
46879
46880 static inline int putu16_kern(u16 *p, u16 val)
46881 {
46882 - ACCESS_ONCE(*p) = val;
46883 + ACCESS_ONCE_RW(*p) = val;
46884 return 0;
46885 }
46886
46887 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
46888 index 8c55011..eed4ae1a 100644
46889 --- a/drivers/video/aty/aty128fb.c
46890 +++ b/drivers/video/aty/aty128fb.c
46891 @@ -149,7 +149,7 @@ enum {
46892 };
46893
46894 /* Must match above enum */
46895 -static char * const r128_family[] = {
46896 +static const char * const r128_family[] = {
46897 "AGP",
46898 "PCI",
46899 "PRO AGP",
46900 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
46901 index 4f27fdc..d3537e6 100644
46902 --- a/drivers/video/aty/atyfb_base.c
46903 +++ b/drivers/video/aty/atyfb_base.c
46904 @@ -1325,10 +1325,14 @@ static int atyfb_set_par(struct fb_info *info)
46905 par->accel_flags = var->accel_flags; /* hack */
46906
46907 if (var->accel_flags) {
46908 - info->fbops->fb_sync = atyfb_sync;
46909 + pax_open_kernel();
46910 + *(void **)&info->fbops->fb_sync = atyfb_sync;
46911 + pax_close_kernel();
46912 info->flags &= ~FBINFO_HWACCEL_DISABLED;
46913 } else {
46914 - info->fbops->fb_sync = NULL;
46915 + pax_open_kernel();
46916 + *(void **)&info->fbops->fb_sync = NULL;
46917 + pax_close_kernel();
46918 info->flags |= FBINFO_HWACCEL_DISABLED;
46919 }
46920
46921 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
46922 index 95ec042..e6affdd 100644
46923 --- a/drivers/video/aty/mach64_cursor.c
46924 +++ b/drivers/video/aty/mach64_cursor.c
46925 @@ -7,6 +7,7 @@
46926 #include <linux/string.h>
46927
46928 #include <asm/io.h>
46929 +#include <asm/pgtable.h>
46930
46931 #ifdef __sparc__
46932 #include <asm/fbio.h>
46933 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
46934 info->sprite.buf_align = 16; /* and 64 lines tall. */
46935 info->sprite.flags = FB_PIXMAP_IO;
46936
46937 - info->fbops->fb_cursor = atyfb_cursor;
46938 + pax_open_kernel();
46939 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
46940 + pax_close_kernel();
46941
46942 return 0;
46943 }
46944 diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
46945 index c74e7aa..e3c2790 100644
46946 --- a/drivers/video/backlight/backlight.c
46947 +++ b/drivers/video/backlight/backlight.c
46948 @@ -304,7 +304,7 @@ struct backlight_device *backlight_device_register(const char *name,
46949 new_bd->dev.class = backlight_class;
46950 new_bd->dev.parent = parent;
46951 new_bd->dev.release = bl_device_release;
46952 - dev_set_name(&new_bd->dev, name);
46953 + dev_set_name(&new_bd->dev, "%s", name);
46954 dev_set_drvdata(&new_bd->dev, devdata);
46955
46956 /* Set default properties */
46957 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
46958 index bca6ccc..252107e 100644
46959 --- a/drivers/video/backlight/kb3886_bl.c
46960 +++ b/drivers/video/backlight/kb3886_bl.c
46961 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
46962 static unsigned long kb3886bl_flags;
46963 #define KB3886BL_SUSPENDED 0x01
46964
46965 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
46966 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
46967 {
46968 .ident = "Sahara Touch-iT",
46969 .matches = {
46970 diff --git a/drivers/video/backlight/lcd.c b/drivers/video/backlight/lcd.c
46971 index 34fb6bd..3649fd9 100644
46972 --- a/drivers/video/backlight/lcd.c
46973 +++ b/drivers/video/backlight/lcd.c
46974 @@ -219,7 +219,7 @@ struct lcd_device *lcd_device_register(const char *name, struct device *parent,
46975 new_ld->dev.class = lcd_class;
46976 new_ld->dev.parent = parent;
46977 new_ld->dev.release = lcd_device_release;
46978 - dev_set_name(&new_ld->dev, name);
46979 + dev_set_name(&new_ld->dev, "%s", name);
46980 dev_set_drvdata(&new_ld->dev, devdata);
46981
46982 rc = device_register(&new_ld->dev);
46983 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
46984 index 900aa4e..6d49418 100644
46985 --- a/drivers/video/fb_defio.c
46986 +++ b/drivers/video/fb_defio.c
46987 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
46988
46989 BUG_ON(!fbdefio);
46990 mutex_init(&fbdefio->lock);
46991 - info->fbops->fb_mmap = fb_deferred_io_mmap;
46992 + pax_open_kernel();
46993 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
46994 + pax_close_kernel();
46995 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
46996 INIT_LIST_HEAD(&fbdefio->pagelist);
46997 if (fbdefio->delay == 0) /* set a default of 1 s */
46998 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
46999 page->mapping = NULL;
47000 }
47001
47002 - info->fbops->fb_mmap = NULL;
47003 + *(void **)&info->fbops->fb_mmap = NULL;
47004 mutex_destroy(&fbdefio->lock);
47005 }
47006 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
47007 diff --git a/drivers/video/fbcmap.c b/drivers/video/fbcmap.c
47008 index 5c3960d..15cf8fc 100644
47009 --- a/drivers/video/fbcmap.c
47010 +++ b/drivers/video/fbcmap.c
47011 @@ -285,8 +285,7 @@ int fb_set_user_cmap(struct fb_cmap_user *cmap, struct fb_info *info)
47012 rc = -ENODEV;
47013 goto out;
47014 }
47015 - if (cmap->start < 0 || (!info->fbops->fb_setcolreg &&
47016 - !info->fbops->fb_setcmap)) {
47017 + if (!info->fbops->fb_setcolreg && !info->fbops->fb_setcmap) {
47018 rc = -EINVAL;
47019 goto out1;
47020 }
47021 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
47022 index 098bfc6..796841d 100644
47023 --- a/drivers/video/fbmem.c
47024 +++ b/drivers/video/fbmem.c
47025 @@ -428,7 +428,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
47026 image->dx += image->width + 8;
47027 }
47028 } else if (rotate == FB_ROTATE_UD) {
47029 - for (x = 0; x < num && image->dx >= 0; x++) {
47030 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
47031 info->fbops->fb_imageblit(info, image);
47032 image->dx -= image->width + 8;
47033 }
47034 @@ -440,7 +440,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
47035 image->dy += image->height + 8;
47036 }
47037 } else if (rotate == FB_ROTATE_CCW) {
47038 - for (x = 0; x < num && image->dy >= 0; x++) {
47039 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
47040 info->fbops->fb_imageblit(info, image);
47041 image->dy -= image->height + 8;
47042 }
47043 @@ -1166,7 +1166,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
47044 return -EFAULT;
47045 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
47046 return -EINVAL;
47047 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
47048 + if (con2fb.framebuffer >= FB_MAX)
47049 return -EINVAL;
47050 if (!registered_fb[con2fb.framebuffer])
47051 request_module("fb%d", con2fb.framebuffer);
47052 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
47053 index 7672d2e..b56437f 100644
47054 --- a/drivers/video/i810/i810_accel.c
47055 +++ b/drivers/video/i810/i810_accel.c
47056 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
47057 }
47058 }
47059 printk("ringbuffer lockup!!!\n");
47060 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
47061 i810_report_error(mmio);
47062 par->dev_flags |= LOCKUP;
47063 info->pixmap.scan_align = 1;
47064 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
47065 index 3c14e43..eafa544 100644
47066 --- a/drivers/video/logo/logo_linux_clut224.ppm
47067 +++ b/drivers/video/logo/logo_linux_clut224.ppm
47068 @@ -1,1604 +1,1123 @@
47069 P3
47070 -# Standard 224-color Linux logo
47071 80 80
47072 255
47073 - 0 0 0 0 0 0 0 0 0 0 0 0
47074 - 0 0 0 0 0 0 0 0 0 0 0 0
47075 - 0 0 0 0 0 0 0 0 0 0 0 0
47076 - 0 0 0 0 0 0 0 0 0 0 0 0
47077 - 0 0 0 0 0 0 0 0 0 0 0 0
47078 - 0 0 0 0 0 0 0 0 0 0 0 0
47079 - 0 0 0 0 0 0 0 0 0 0 0 0
47080 - 0 0 0 0 0 0 0 0 0 0 0 0
47081 - 0 0 0 0 0 0 0 0 0 0 0 0
47082 - 6 6 6 6 6 6 10 10 10 10 10 10
47083 - 10 10 10 6 6 6 6 6 6 6 6 6
47084 - 0 0 0 0 0 0 0 0 0 0 0 0
47085 - 0 0 0 0 0 0 0 0 0 0 0 0
47086 - 0 0 0 0 0 0 0 0 0 0 0 0
47087 - 0 0 0 0 0 0 0 0 0 0 0 0
47088 - 0 0 0 0 0 0 0 0 0 0 0 0
47089 - 0 0 0 0 0 0 0 0 0 0 0 0
47090 - 0 0 0 0 0 0 0 0 0 0 0 0
47091 - 0 0 0 0 0 0 0 0 0 0 0 0
47092 - 0 0 0 0 0 0 0 0 0 0 0 0
47093 - 0 0 0 0 0 0 0 0 0 0 0 0
47094 - 0 0 0 0 0 0 0 0 0 0 0 0
47095 - 0 0 0 0 0 0 0 0 0 0 0 0
47096 - 0 0 0 0 0 0 0 0 0 0 0 0
47097 - 0 0 0 0 0 0 0 0 0 0 0 0
47098 - 0 0 0 0 0 0 0 0 0 0 0 0
47099 - 0 0 0 0 0 0 0 0 0 0 0 0
47100 - 0 0 0 0 0 0 0 0 0 0 0 0
47101 - 0 0 0 6 6 6 10 10 10 14 14 14
47102 - 22 22 22 26 26 26 30 30 30 34 34 34
47103 - 30 30 30 30 30 30 26 26 26 18 18 18
47104 - 14 14 14 10 10 10 6 6 6 0 0 0
47105 - 0 0 0 0 0 0 0 0 0 0 0 0
47106 - 0 0 0 0 0 0 0 0 0 0 0 0
47107 - 0 0 0 0 0 0 0 0 0 0 0 0
47108 - 0 0 0 0 0 0 0 0 0 0 0 0
47109 - 0 0 0 0 0 0 0 0 0 0 0 0
47110 - 0 0 0 0 0 0 0 0 0 0 0 0
47111 - 0 0 0 0 0 0 0 0 0 0 0 0
47112 - 0 0 0 0 0 0 0 0 0 0 0 0
47113 - 0 0 0 0 0 0 0 0 0 0 0 0
47114 - 0 0 0 0 0 1 0 0 1 0 0 0
47115 - 0 0 0 0 0 0 0 0 0 0 0 0
47116 - 0 0 0 0 0 0 0 0 0 0 0 0
47117 - 0 0 0 0 0 0 0 0 0 0 0 0
47118 - 0 0 0 0 0 0 0 0 0 0 0 0
47119 - 0 0 0 0 0 0 0 0 0 0 0 0
47120 - 0 0 0 0 0 0 0 0 0 0 0 0
47121 - 6 6 6 14 14 14 26 26 26 42 42 42
47122 - 54 54 54 66 66 66 78 78 78 78 78 78
47123 - 78 78 78 74 74 74 66 66 66 54 54 54
47124 - 42 42 42 26 26 26 18 18 18 10 10 10
47125 - 6 6 6 0 0 0 0 0 0 0 0 0
47126 - 0 0 0 0 0 0 0 0 0 0 0 0
47127 - 0 0 0 0 0 0 0 0 0 0 0 0
47128 - 0 0 0 0 0 0 0 0 0 0 0 0
47129 - 0 0 0 0 0 0 0 0 0 0 0 0
47130 - 0 0 0 0 0 0 0 0 0 0 0 0
47131 - 0 0 0 0 0 0 0 0 0 0 0 0
47132 - 0 0 0 0 0 0 0 0 0 0 0 0
47133 - 0 0 0 0 0 0 0 0 0 0 0 0
47134 - 0 0 1 0 0 0 0 0 0 0 0 0
47135 - 0 0 0 0 0 0 0 0 0 0 0 0
47136 - 0 0 0 0 0 0 0 0 0 0 0 0
47137 - 0 0 0 0 0 0 0 0 0 0 0 0
47138 - 0 0 0 0 0 0 0 0 0 0 0 0
47139 - 0 0 0 0 0 0 0 0 0 0 0 0
47140 - 0 0 0 0 0 0 0 0 0 10 10 10
47141 - 22 22 22 42 42 42 66 66 66 86 86 86
47142 - 66 66 66 38 38 38 38 38 38 22 22 22
47143 - 26 26 26 34 34 34 54 54 54 66 66 66
47144 - 86 86 86 70 70 70 46 46 46 26 26 26
47145 - 14 14 14 6 6 6 0 0 0 0 0 0
47146 - 0 0 0 0 0 0 0 0 0 0 0 0
47147 - 0 0 0 0 0 0 0 0 0 0 0 0
47148 - 0 0 0 0 0 0 0 0 0 0 0 0
47149 - 0 0 0 0 0 0 0 0 0 0 0 0
47150 - 0 0 0 0 0 0 0 0 0 0 0 0
47151 - 0 0 0 0 0 0 0 0 0 0 0 0
47152 - 0 0 0 0 0 0 0 0 0 0 0 0
47153 - 0 0 0 0 0 0 0 0 0 0 0 0
47154 - 0 0 1 0 0 1 0 0 1 0 0 0
47155 - 0 0 0 0 0 0 0 0 0 0 0 0
47156 - 0 0 0 0 0 0 0 0 0 0 0 0
47157 - 0 0 0 0 0 0 0 0 0 0 0 0
47158 - 0 0 0 0 0 0 0 0 0 0 0 0
47159 - 0 0 0 0 0 0 0 0 0 0 0 0
47160 - 0 0 0 0 0 0 10 10 10 26 26 26
47161 - 50 50 50 82 82 82 58 58 58 6 6 6
47162 - 2 2 6 2 2 6 2 2 6 2 2 6
47163 - 2 2 6 2 2 6 2 2 6 2 2 6
47164 - 6 6 6 54 54 54 86 86 86 66 66 66
47165 - 38 38 38 18 18 18 6 6 6 0 0 0
47166 - 0 0 0 0 0 0 0 0 0 0 0 0
47167 - 0 0 0 0 0 0 0 0 0 0 0 0
47168 - 0 0 0 0 0 0 0 0 0 0 0 0
47169 - 0 0 0 0 0 0 0 0 0 0 0 0
47170 - 0 0 0 0 0 0 0 0 0 0 0 0
47171 - 0 0 0 0 0 0 0 0 0 0 0 0
47172 - 0 0 0 0 0 0 0 0 0 0 0 0
47173 - 0 0 0 0 0 0 0 0 0 0 0 0
47174 - 0 0 0 0 0 0 0 0 0 0 0 0
47175 - 0 0 0 0 0 0 0 0 0 0 0 0
47176 - 0 0 0 0 0 0 0 0 0 0 0 0
47177 - 0 0 0 0 0 0 0 0 0 0 0 0
47178 - 0 0 0 0 0 0 0 0 0 0 0 0
47179 - 0 0 0 0 0 0 0 0 0 0 0 0
47180 - 0 0 0 6 6 6 22 22 22 50 50 50
47181 - 78 78 78 34 34 34 2 2 6 2 2 6
47182 - 2 2 6 2 2 6 2 2 6 2 2 6
47183 - 2 2 6 2 2 6 2 2 6 2 2 6
47184 - 2 2 6 2 2 6 6 6 6 70 70 70
47185 - 78 78 78 46 46 46 22 22 22 6 6 6
47186 - 0 0 0 0 0 0 0 0 0 0 0 0
47187 - 0 0 0 0 0 0 0 0 0 0 0 0
47188 - 0 0 0 0 0 0 0 0 0 0 0 0
47189 - 0 0 0 0 0 0 0 0 0 0 0 0
47190 - 0 0 0 0 0 0 0 0 0 0 0 0
47191 - 0 0 0 0 0 0 0 0 0 0 0 0
47192 - 0 0 0 0 0 0 0 0 0 0 0 0
47193 - 0 0 0 0 0 0 0 0 0 0 0 0
47194 - 0 0 1 0 0 1 0 0 1 0 0 0
47195 - 0 0 0 0 0 0 0 0 0 0 0 0
47196 - 0 0 0 0 0 0 0 0 0 0 0 0
47197 - 0 0 0 0 0 0 0 0 0 0 0 0
47198 - 0 0 0 0 0 0 0 0 0 0 0 0
47199 - 0 0 0 0 0 0 0 0 0 0 0 0
47200 - 6 6 6 18 18 18 42 42 42 82 82 82
47201 - 26 26 26 2 2 6 2 2 6 2 2 6
47202 - 2 2 6 2 2 6 2 2 6 2 2 6
47203 - 2 2 6 2 2 6 2 2 6 14 14 14
47204 - 46 46 46 34 34 34 6 6 6 2 2 6
47205 - 42 42 42 78 78 78 42 42 42 18 18 18
47206 - 6 6 6 0 0 0 0 0 0 0 0 0
47207 - 0 0 0 0 0 0 0 0 0 0 0 0
47208 - 0 0 0 0 0 0 0 0 0 0 0 0
47209 - 0 0 0 0 0 0 0 0 0 0 0 0
47210 - 0 0 0 0 0 0 0 0 0 0 0 0
47211 - 0 0 0 0 0 0 0 0 0 0 0 0
47212 - 0 0 0 0 0 0 0 0 0 0 0 0
47213 - 0 0 0 0 0 0 0 0 0 0 0 0
47214 - 0 0 1 0 0 0 0 0 1 0 0 0
47215 - 0 0 0 0 0 0 0 0 0 0 0 0
47216 - 0 0 0 0 0 0 0 0 0 0 0 0
47217 - 0 0 0 0 0 0 0 0 0 0 0 0
47218 - 0 0 0 0 0 0 0 0 0 0 0 0
47219 - 0 0 0 0 0 0 0 0 0 0 0 0
47220 - 10 10 10 30 30 30 66 66 66 58 58 58
47221 - 2 2 6 2 2 6 2 2 6 2 2 6
47222 - 2 2 6 2 2 6 2 2 6 2 2 6
47223 - 2 2 6 2 2 6 2 2 6 26 26 26
47224 - 86 86 86 101 101 101 46 46 46 10 10 10
47225 - 2 2 6 58 58 58 70 70 70 34 34 34
47226 - 10 10 10 0 0 0 0 0 0 0 0 0
47227 - 0 0 0 0 0 0 0 0 0 0 0 0
47228 - 0 0 0 0 0 0 0 0 0 0 0 0
47229 - 0 0 0 0 0 0 0 0 0 0 0 0
47230 - 0 0 0 0 0 0 0 0 0 0 0 0
47231 - 0 0 0 0 0 0 0 0 0 0 0 0
47232 - 0 0 0 0 0 0 0 0 0 0 0 0
47233 - 0 0 0 0 0 0 0 0 0 0 0 0
47234 - 0 0 1 0 0 1 0 0 1 0 0 0
47235 - 0 0 0 0 0 0 0 0 0 0 0 0
47236 - 0 0 0 0 0 0 0 0 0 0 0 0
47237 - 0 0 0 0 0 0 0 0 0 0 0 0
47238 - 0 0 0 0 0 0 0 0 0 0 0 0
47239 - 0 0 0 0 0 0 0 0 0 0 0 0
47240 - 14 14 14 42 42 42 86 86 86 10 10 10
47241 - 2 2 6 2 2 6 2 2 6 2 2 6
47242 - 2 2 6 2 2 6 2 2 6 2 2 6
47243 - 2 2 6 2 2 6 2 2 6 30 30 30
47244 - 94 94 94 94 94 94 58 58 58 26 26 26
47245 - 2 2 6 6 6 6 78 78 78 54 54 54
47246 - 22 22 22 6 6 6 0 0 0 0 0 0
47247 - 0 0 0 0 0 0 0 0 0 0 0 0
47248 - 0 0 0 0 0 0 0 0 0 0 0 0
47249 - 0 0 0 0 0 0 0 0 0 0 0 0
47250 - 0 0 0 0 0 0 0 0 0 0 0 0
47251 - 0 0 0 0 0 0 0 0 0 0 0 0
47252 - 0 0 0 0 0 0 0 0 0 0 0 0
47253 - 0 0 0 0 0 0 0 0 0 0 0 0
47254 - 0 0 0 0 0 0 0 0 0 0 0 0
47255 - 0 0 0 0 0 0 0 0 0 0 0 0
47256 - 0 0 0 0 0 0 0 0 0 0 0 0
47257 - 0 0 0 0 0 0 0 0 0 0 0 0
47258 - 0 0 0 0 0 0 0 0 0 0 0 0
47259 - 0 0 0 0 0 0 0 0 0 6 6 6
47260 - 22 22 22 62 62 62 62 62 62 2 2 6
47261 - 2 2 6 2 2 6 2 2 6 2 2 6
47262 - 2 2 6 2 2 6 2 2 6 2 2 6
47263 - 2 2 6 2 2 6 2 2 6 26 26 26
47264 - 54 54 54 38 38 38 18 18 18 10 10 10
47265 - 2 2 6 2 2 6 34 34 34 82 82 82
47266 - 38 38 38 14 14 14 0 0 0 0 0 0
47267 - 0 0 0 0 0 0 0 0 0 0 0 0
47268 - 0 0 0 0 0 0 0 0 0 0 0 0
47269 - 0 0 0 0 0 0 0 0 0 0 0 0
47270 - 0 0 0 0 0 0 0 0 0 0 0 0
47271 - 0 0 0 0 0 0 0 0 0 0 0 0
47272 - 0 0 0 0 0 0 0 0 0 0 0 0
47273 - 0 0 0 0 0 0 0 0 0 0 0 0
47274 - 0 0 0 0 0 1 0 0 1 0 0 0
47275 - 0 0 0 0 0 0 0 0 0 0 0 0
47276 - 0 0 0 0 0 0 0 0 0 0 0 0
47277 - 0 0 0 0 0 0 0 0 0 0 0 0
47278 - 0 0 0 0 0 0 0 0 0 0 0 0
47279 - 0 0 0 0 0 0 0 0 0 6 6 6
47280 - 30 30 30 78 78 78 30 30 30 2 2 6
47281 - 2 2 6 2 2 6 2 2 6 2 2 6
47282 - 2 2 6 2 2 6 2 2 6 2 2 6
47283 - 2 2 6 2 2 6 2 2 6 10 10 10
47284 - 10 10 10 2 2 6 2 2 6 2 2 6
47285 - 2 2 6 2 2 6 2 2 6 78 78 78
47286 - 50 50 50 18 18 18 6 6 6 0 0 0
47287 - 0 0 0 0 0 0 0 0 0 0 0 0
47288 - 0 0 0 0 0 0 0 0 0 0 0 0
47289 - 0 0 0 0 0 0 0 0 0 0 0 0
47290 - 0 0 0 0 0 0 0 0 0 0 0 0
47291 - 0 0 0 0 0 0 0 0 0 0 0 0
47292 - 0 0 0 0 0 0 0 0 0 0 0 0
47293 - 0 0 0 0 0 0 0 0 0 0 0 0
47294 - 0 0 1 0 0 0 0 0 0 0 0 0
47295 - 0 0 0 0 0 0 0 0 0 0 0 0
47296 - 0 0 0 0 0 0 0 0 0 0 0 0
47297 - 0 0 0 0 0 0 0 0 0 0 0 0
47298 - 0 0 0 0 0 0 0 0 0 0 0 0
47299 - 0 0 0 0 0 0 0 0 0 10 10 10
47300 - 38 38 38 86 86 86 14 14 14 2 2 6
47301 - 2 2 6 2 2 6 2 2 6 2 2 6
47302 - 2 2 6 2 2 6 2 2 6 2 2 6
47303 - 2 2 6 2 2 6 2 2 6 2 2 6
47304 - 2 2 6 2 2 6 2 2 6 2 2 6
47305 - 2 2 6 2 2 6 2 2 6 54 54 54
47306 - 66 66 66 26 26 26 6 6 6 0 0 0
47307 - 0 0 0 0 0 0 0 0 0 0 0 0
47308 - 0 0 0 0 0 0 0 0 0 0 0 0
47309 - 0 0 0 0 0 0 0 0 0 0 0 0
47310 - 0 0 0 0 0 0 0 0 0 0 0 0
47311 - 0 0 0 0 0 0 0 0 0 0 0 0
47312 - 0 0 0 0 0 0 0 0 0 0 0 0
47313 - 0 0 0 0 0 0 0 0 0 0 0 0
47314 - 0 0 0 0 0 1 0 0 1 0 0 0
47315 - 0 0 0 0 0 0 0 0 0 0 0 0
47316 - 0 0 0 0 0 0 0 0 0 0 0 0
47317 - 0 0 0 0 0 0 0 0 0 0 0 0
47318 - 0 0 0 0 0 0 0 0 0 0 0 0
47319 - 0 0 0 0 0 0 0 0 0 14 14 14
47320 - 42 42 42 82 82 82 2 2 6 2 2 6
47321 - 2 2 6 6 6 6 10 10 10 2 2 6
47322 - 2 2 6 2 2 6 2 2 6 2 2 6
47323 - 2 2 6 2 2 6 2 2 6 6 6 6
47324 - 14 14 14 10 10 10 2 2 6 2 2 6
47325 - 2 2 6 2 2 6 2 2 6 18 18 18
47326 - 82 82 82 34 34 34 10 10 10 0 0 0
47327 - 0 0 0 0 0 0 0 0 0 0 0 0
47328 - 0 0 0 0 0 0 0 0 0 0 0 0
47329 - 0 0 0 0 0 0 0 0 0 0 0 0
47330 - 0 0 0 0 0 0 0 0 0 0 0 0
47331 - 0 0 0 0 0 0 0 0 0 0 0 0
47332 - 0 0 0 0 0 0 0 0 0 0 0 0
47333 - 0 0 0 0 0 0 0 0 0 0 0 0
47334 - 0 0 1 0 0 0 0 0 0 0 0 0
47335 - 0 0 0 0 0 0 0 0 0 0 0 0
47336 - 0 0 0 0 0 0 0 0 0 0 0 0
47337 - 0 0 0 0 0 0 0 0 0 0 0 0
47338 - 0 0 0 0 0 0 0 0 0 0 0 0
47339 - 0 0 0 0 0 0 0 0 0 14 14 14
47340 - 46 46 46 86 86 86 2 2 6 2 2 6
47341 - 6 6 6 6 6 6 22 22 22 34 34 34
47342 - 6 6 6 2 2 6 2 2 6 2 2 6
47343 - 2 2 6 2 2 6 18 18 18 34 34 34
47344 - 10 10 10 50 50 50 22 22 22 2 2 6
47345 - 2 2 6 2 2 6 2 2 6 10 10 10
47346 - 86 86 86 42 42 42 14 14 14 0 0 0
47347 - 0 0 0 0 0 0 0 0 0 0 0 0
47348 - 0 0 0 0 0 0 0 0 0 0 0 0
47349 - 0 0 0 0 0 0 0 0 0 0 0 0
47350 - 0 0 0 0 0 0 0 0 0 0 0 0
47351 - 0 0 0 0 0 0 0 0 0 0 0 0
47352 - 0 0 0 0 0 0 0 0 0 0 0 0
47353 - 0 0 0 0 0 0 0 0 0 0 0 0
47354 - 0 0 1 0 0 1 0 0 1 0 0 0
47355 - 0 0 0 0 0 0 0 0 0 0 0 0
47356 - 0 0 0 0 0 0 0 0 0 0 0 0
47357 - 0 0 0 0 0 0 0 0 0 0 0 0
47358 - 0 0 0 0 0 0 0 0 0 0 0 0
47359 - 0 0 0 0 0 0 0 0 0 14 14 14
47360 - 46 46 46 86 86 86 2 2 6 2 2 6
47361 - 38 38 38 116 116 116 94 94 94 22 22 22
47362 - 22 22 22 2 2 6 2 2 6 2 2 6
47363 - 14 14 14 86 86 86 138 138 138 162 162 162
47364 -154 154 154 38 38 38 26 26 26 6 6 6
47365 - 2 2 6 2 2 6 2 2 6 2 2 6
47366 - 86 86 86 46 46 46 14 14 14 0 0 0
47367 - 0 0 0 0 0 0 0 0 0 0 0 0
47368 - 0 0 0 0 0 0 0 0 0 0 0 0
47369 - 0 0 0 0 0 0 0 0 0 0 0 0
47370 - 0 0 0 0 0 0 0 0 0 0 0 0
47371 - 0 0 0 0 0 0 0 0 0 0 0 0
47372 - 0 0 0 0 0 0 0 0 0 0 0 0
47373 - 0 0 0 0 0 0 0 0 0 0 0 0
47374 - 0 0 0 0 0 0 0 0 0 0 0 0
47375 - 0 0 0 0 0 0 0 0 0 0 0 0
47376 - 0 0 0 0 0 0 0 0 0 0 0 0
47377 - 0 0 0 0 0 0 0 0 0 0 0 0
47378 - 0 0 0 0 0 0 0 0 0 0 0 0
47379 - 0 0 0 0 0 0 0 0 0 14 14 14
47380 - 46 46 46 86 86 86 2 2 6 14 14 14
47381 -134 134 134 198 198 198 195 195 195 116 116 116
47382 - 10 10 10 2 2 6 2 2 6 6 6 6
47383 -101 98 89 187 187 187 210 210 210 218 218 218
47384 -214 214 214 134 134 134 14 14 14 6 6 6
47385 - 2 2 6 2 2 6 2 2 6 2 2 6
47386 - 86 86 86 50 50 50 18 18 18 6 6 6
47387 - 0 0 0 0 0 0 0 0 0 0 0 0
47388 - 0 0 0 0 0 0 0 0 0 0 0 0
47389 - 0 0 0 0 0 0 0 0 0 0 0 0
47390 - 0 0 0 0 0 0 0 0 0 0 0 0
47391 - 0 0 0 0 0 0 0 0 0 0 0 0
47392 - 0 0 0 0 0 0 0 0 0 0 0 0
47393 - 0 0 0 0 0 0 0 0 1 0 0 0
47394 - 0 0 1 0 0 1 0 0 1 0 0 0
47395 - 0 0 0 0 0 0 0 0 0 0 0 0
47396 - 0 0 0 0 0 0 0 0 0 0 0 0
47397 - 0 0 0 0 0 0 0 0 0 0 0 0
47398 - 0 0 0 0 0 0 0 0 0 0 0 0
47399 - 0 0 0 0 0 0 0 0 0 14 14 14
47400 - 46 46 46 86 86 86 2 2 6 54 54 54
47401 -218 218 218 195 195 195 226 226 226 246 246 246
47402 - 58 58 58 2 2 6 2 2 6 30 30 30
47403 -210 210 210 253 253 253 174 174 174 123 123 123
47404 -221 221 221 234 234 234 74 74 74 2 2 6
47405 - 2 2 6 2 2 6 2 2 6 2 2 6
47406 - 70 70 70 58 58 58 22 22 22 6 6 6
47407 - 0 0 0 0 0 0 0 0 0 0 0 0
47408 - 0 0 0 0 0 0 0 0 0 0 0 0
47409 - 0 0 0 0 0 0 0 0 0 0 0 0
47410 - 0 0 0 0 0 0 0 0 0 0 0 0
47411 - 0 0 0 0 0 0 0 0 0 0 0 0
47412 - 0 0 0 0 0 0 0 0 0 0 0 0
47413 - 0 0 0 0 0 0 0 0 0 0 0 0
47414 - 0 0 0 0 0 0 0 0 0 0 0 0
47415 - 0 0 0 0 0 0 0 0 0 0 0 0
47416 - 0 0 0 0 0 0 0 0 0 0 0 0
47417 - 0 0 0 0 0 0 0 0 0 0 0 0
47418 - 0 0 0 0 0 0 0 0 0 0 0 0
47419 - 0 0 0 0 0 0 0 0 0 14 14 14
47420 - 46 46 46 82 82 82 2 2 6 106 106 106
47421 -170 170 170 26 26 26 86 86 86 226 226 226
47422 -123 123 123 10 10 10 14 14 14 46 46 46
47423 -231 231 231 190 190 190 6 6 6 70 70 70
47424 - 90 90 90 238 238 238 158 158 158 2 2 6
47425 - 2 2 6 2 2 6 2 2 6 2 2 6
47426 - 70 70 70 58 58 58 22 22 22 6 6 6
47427 - 0 0 0 0 0 0 0 0 0 0 0 0
47428 - 0 0 0 0 0 0 0 0 0 0 0 0
47429 - 0 0 0 0 0 0 0 0 0 0 0 0
47430 - 0 0 0 0 0 0 0 0 0 0 0 0
47431 - 0 0 0 0 0 0 0 0 0 0 0 0
47432 - 0 0 0 0 0 0 0 0 0 0 0 0
47433 - 0 0 0 0 0 0 0 0 1 0 0 0
47434 - 0 0 1 0 0 1 0 0 1 0 0 0
47435 - 0 0 0 0 0 0 0 0 0 0 0 0
47436 - 0 0 0 0 0 0 0 0 0 0 0 0
47437 - 0 0 0 0 0 0 0 0 0 0 0 0
47438 - 0 0 0 0 0 0 0 0 0 0 0 0
47439 - 0 0 0 0 0 0 0 0 0 14 14 14
47440 - 42 42 42 86 86 86 6 6 6 116 116 116
47441 -106 106 106 6 6 6 70 70 70 149 149 149
47442 -128 128 128 18 18 18 38 38 38 54 54 54
47443 -221 221 221 106 106 106 2 2 6 14 14 14
47444 - 46 46 46 190 190 190 198 198 198 2 2 6
47445 - 2 2 6 2 2 6 2 2 6 2 2 6
47446 - 74 74 74 62 62 62 22 22 22 6 6 6
47447 - 0 0 0 0 0 0 0 0 0 0 0 0
47448 - 0 0 0 0 0 0 0 0 0 0 0 0
47449 - 0 0 0 0 0 0 0 0 0 0 0 0
47450 - 0 0 0 0 0 0 0 0 0 0 0 0
47451 - 0 0 0 0 0 0 0 0 0 0 0 0
47452 - 0 0 0 0 0 0 0 0 0 0 0 0
47453 - 0 0 0 0 0 0 0 0 1 0 0 0
47454 - 0 0 1 0 0 0 0 0 1 0 0 0
47455 - 0 0 0 0 0 0 0 0 0 0 0 0
47456 - 0 0 0 0 0 0 0 0 0 0 0 0
47457 - 0 0 0 0 0 0 0 0 0 0 0 0
47458 - 0 0 0 0 0 0 0 0 0 0 0 0
47459 - 0 0 0 0 0 0 0 0 0 14 14 14
47460 - 42 42 42 94 94 94 14 14 14 101 101 101
47461 -128 128 128 2 2 6 18 18 18 116 116 116
47462 -118 98 46 121 92 8 121 92 8 98 78 10
47463 -162 162 162 106 106 106 2 2 6 2 2 6
47464 - 2 2 6 195 195 195 195 195 195 6 6 6
47465 - 2 2 6 2 2 6 2 2 6 2 2 6
47466 - 74 74 74 62 62 62 22 22 22 6 6 6
47467 - 0 0 0 0 0 0 0 0 0 0 0 0
47468 - 0 0 0 0 0 0 0 0 0 0 0 0
47469 - 0 0 0 0 0 0 0 0 0 0 0 0
47470 - 0 0 0 0 0 0 0 0 0 0 0 0
47471 - 0 0 0 0 0 0 0 0 0 0 0 0
47472 - 0 0 0 0 0 0 0 0 0 0 0 0
47473 - 0 0 0 0 0 0 0 0 1 0 0 1
47474 - 0 0 1 0 0 0 0 0 1 0 0 0
47475 - 0 0 0 0 0 0 0 0 0 0 0 0
47476 - 0 0 0 0 0 0 0 0 0 0 0 0
47477 - 0 0 0 0 0 0 0 0 0 0 0 0
47478 - 0 0 0 0 0 0 0 0 0 0 0 0
47479 - 0 0 0 0 0 0 0 0 0 10 10 10
47480 - 38 38 38 90 90 90 14 14 14 58 58 58
47481 -210 210 210 26 26 26 54 38 6 154 114 10
47482 -226 170 11 236 186 11 225 175 15 184 144 12
47483 -215 174 15 175 146 61 37 26 9 2 2 6
47484 - 70 70 70 246 246 246 138 138 138 2 2 6
47485 - 2 2 6 2 2 6 2 2 6 2 2 6
47486 - 70 70 70 66 66 66 26 26 26 6 6 6
47487 - 0 0 0 0 0 0 0 0 0 0 0 0
47488 - 0 0 0 0 0 0 0 0 0 0 0 0
47489 - 0 0 0 0 0 0 0 0 0 0 0 0
47490 - 0 0 0 0 0 0 0 0 0 0 0 0
47491 - 0 0 0 0 0 0 0 0 0 0 0 0
47492 - 0 0 0 0 0 0 0 0 0 0 0 0
47493 - 0 0 0 0 0 0 0 0 0 0 0 0
47494 - 0 0 0 0 0 0 0 0 0 0 0 0
47495 - 0 0 0 0 0 0 0 0 0 0 0 0
47496 - 0 0 0 0 0 0 0 0 0 0 0 0
47497 - 0 0 0 0 0 0 0 0 0 0 0 0
47498 - 0 0 0 0 0 0 0 0 0 0 0 0
47499 - 0 0 0 0 0 0 0 0 0 10 10 10
47500 - 38 38 38 86 86 86 14 14 14 10 10 10
47501 -195 195 195 188 164 115 192 133 9 225 175 15
47502 -239 182 13 234 190 10 232 195 16 232 200 30
47503 -245 207 45 241 208 19 232 195 16 184 144 12
47504 -218 194 134 211 206 186 42 42 42 2 2 6
47505 - 2 2 6 2 2 6 2 2 6 2 2 6
47506 - 50 50 50 74 74 74 30 30 30 6 6 6
47507 - 0 0 0 0 0 0 0 0 0 0 0 0
47508 - 0 0 0 0 0 0 0 0 0 0 0 0
47509 - 0 0 0 0 0 0 0 0 0 0 0 0
47510 - 0 0 0 0 0 0 0 0 0 0 0 0
47511 - 0 0 0 0 0 0 0 0 0 0 0 0
47512 - 0 0 0 0 0 0 0 0 0 0 0 0
47513 - 0 0 0 0 0 0 0 0 0 0 0 0
47514 - 0 0 0 0 0 0 0 0 0 0 0 0
47515 - 0 0 0 0 0 0 0 0 0 0 0 0
47516 - 0 0 0 0 0 0 0 0 0 0 0 0
47517 - 0 0 0 0 0 0 0 0 0 0 0 0
47518 - 0 0 0 0 0 0 0 0 0 0 0 0
47519 - 0 0 0 0 0 0 0 0 0 10 10 10
47520 - 34 34 34 86 86 86 14 14 14 2 2 6
47521 -121 87 25 192 133 9 219 162 10 239 182 13
47522 -236 186 11 232 195 16 241 208 19 244 214 54
47523 -246 218 60 246 218 38 246 215 20 241 208 19
47524 -241 208 19 226 184 13 121 87 25 2 2 6
47525 - 2 2 6 2 2 6 2 2 6 2 2 6
47526 - 50 50 50 82 82 82 34 34 34 10 10 10
47527 - 0 0 0 0 0 0 0 0 0 0 0 0
47528 - 0 0 0 0 0 0 0 0 0 0 0 0
47529 - 0 0 0 0 0 0 0 0 0 0 0 0
47530 - 0 0 0 0 0 0 0 0 0 0 0 0
47531 - 0 0 0 0 0 0 0 0 0 0 0 0
47532 - 0 0 0 0 0 0 0 0 0 0 0 0
47533 - 0 0 0 0 0 0 0 0 0 0 0 0
47534 - 0 0 0 0 0 0 0 0 0 0 0 0
47535 - 0 0 0 0 0 0 0 0 0 0 0 0
47536 - 0 0 0 0 0 0 0 0 0 0 0 0
47537 - 0 0 0 0 0 0 0 0 0 0 0 0
47538 - 0 0 0 0 0 0 0 0 0 0 0 0
47539 - 0 0 0 0 0 0 0 0 0 10 10 10
47540 - 34 34 34 82 82 82 30 30 30 61 42 6
47541 -180 123 7 206 145 10 230 174 11 239 182 13
47542 -234 190 10 238 202 15 241 208 19 246 218 74
47543 -246 218 38 246 215 20 246 215 20 246 215 20
47544 -226 184 13 215 174 15 184 144 12 6 6 6
47545 - 2 2 6 2 2 6 2 2 6 2 2 6
47546 - 26 26 26 94 94 94 42 42 42 14 14 14
47547 - 0 0 0 0 0 0 0 0 0 0 0 0
47548 - 0 0 0 0 0 0 0 0 0 0 0 0
47549 - 0 0 0 0 0 0 0 0 0 0 0 0
47550 - 0 0 0 0 0 0 0 0 0 0 0 0
47551 - 0 0 0 0 0 0 0 0 0 0 0 0
47552 - 0 0 0 0 0 0 0 0 0 0 0 0
47553 - 0 0 0 0 0 0 0 0 0 0 0 0
47554 - 0 0 0 0 0 0 0 0 0 0 0 0
47555 - 0 0 0 0 0 0 0 0 0 0 0 0
47556 - 0 0 0 0 0 0 0 0 0 0 0 0
47557 - 0 0 0 0 0 0 0 0 0 0 0 0
47558 - 0 0 0 0 0 0 0 0 0 0 0 0
47559 - 0 0 0 0 0 0 0 0 0 10 10 10
47560 - 30 30 30 78 78 78 50 50 50 104 69 6
47561 -192 133 9 216 158 10 236 178 12 236 186 11
47562 -232 195 16 241 208 19 244 214 54 245 215 43
47563 -246 215 20 246 215 20 241 208 19 198 155 10
47564 -200 144 11 216 158 10 156 118 10 2 2 6
47565 - 2 2 6 2 2 6 2 2 6 2 2 6
47566 - 6 6 6 90 90 90 54 54 54 18 18 18
47567 - 6 6 6 0 0 0 0 0 0 0 0 0
47568 - 0 0 0 0 0 0 0 0 0 0 0 0
47569 - 0 0 0 0 0 0 0 0 0 0 0 0
47570 - 0 0 0 0 0 0 0 0 0 0 0 0
47571 - 0 0 0 0 0 0 0 0 0 0 0 0
47572 - 0 0 0 0 0 0 0 0 0 0 0 0
47573 - 0 0 0 0 0 0 0 0 0 0 0 0
47574 - 0 0 0 0 0 0 0 0 0 0 0 0
47575 - 0 0 0 0 0 0 0 0 0 0 0 0
47576 - 0 0 0 0 0 0 0 0 0 0 0 0
47577 - 0 0 0 0 0 0 0 0 0 0 0 0
47578 - 0 0 0 0 0 0 0 0 0 0 0 0
47579 - 0 0 0 0 0 0 0 0 0 10 10 10
47580 - 30 30 30 78 78 78 46 46 46 22 22 22
47581 -137 92 6 210 162 10 239 182 13 238 190 10
47582 -238 202 15 241 208 19 246 215 20 246 215 20
47583 -241 208 19 203 166 17 185 133 11 210 150 10
47584 -216 158 10 210 150 10 102 78 10 2 2 6
47585 - 6 6 6 54 54 54 14 14 14 2 2 6
47586 - 2 2 6 62 62 62 74 74 74 30 30 30
47587 - 10 10 10 0 0 0 0 0 0 0 0 0
47588 - 0 0 0 0 0 0 0 0 0 0 0 0
47589 - 0 0 0 0 0 0 0 0 0 0 0 0
47590 - 0 0 0 0 0 0 0 0 0 0 0 0
47591 - 0 0 0 0 0 0 0 0 0 0 0 0
47592 - 0 0 0 0 0 0 0 0 0 0 0 0
47593 - 0 0 0 0 0 0 0 0 0 0 0 0
47594 - 0 0 0 0 0 0 0 0 0 0 0 0
47595 - 0 0 0 0 0 0 0 0 0 0 0 0
47596 - 0 0 0 0 0 0 0 0 0 0 0 0
47597 - 0 0 0 0 0 0 0 0 0 0 0 0
47598 - 0 0 0 0 0 0 0 0 0 0 0 0
47599 - 0 0 0 0 0 0 0 0 0 10 10 10
47600 - 34 34 34 78 78 78 50 50 50 6 6 6
47601 - 94 70 30 139 102 15 190 146 13 226 184 13
47602 -232 200 30 232 195 16 215 174 15 190 146 13
47603 -168 122 10 192 133 9 210 150 10 213 154 11
47604 -202 150 34 182 157 106 101 98 89 2 2 6
47605 - 2 2 6 78 78 78 116 116 116 58 58 58
47606 - 2 2 6 22 22 22 90 90 90 46 46 46
47607 - 18 18 18 6 6 6 0 0 0 0 0 0
47608 - 0 0 0 0 0 0 0 0 0 0 0 0
47609 - 0 0 0 0 0 0 0 0 0 0 0 0
47610 - 0 0 0 0 0 0 0 0 0 0 0 0
47611 - 0 0 0 0 0 0 0 0 0 0 0 0
47612 - 0 0 0 0 0 0 0 0 0 0 0 0
47613 - 0 0 0 0 0 0 0 0 0 0 0 0
47614 - 0 0 0 0 0 0 0 0 0 0 0 0
47615 - 0 0 0 0 0 0 0 0 0 0 0 0
47616 - 0 0 0 0 0 0 0 0 0 0 0 0
47617 - 0 0 0 0 0 0 0 0 0 0 0 0
47618 - 0 0 0 0 0 0 0 0 0 0 0 0
47619 - 0 0 0 0 0 0 0 0 0 10 10 10
47620 - 38 38 38 86 86 86 50 50 50 6 6 6
47621 -128 128 128 174 154 114 156 107 11 168 122 10
47622 -198 155 10 184 144 12 197 138 11 200 144 11
47623 -206 145 10 206 145 10 197 138 11 188 164 115
47624 -195 195 195 198 198 198 174 174 174 14 14 14
47625 - 2 2 6 22 22 22 116 116 116 116 116 116
47626 - 22 22 22 2 2 6 74 74 74 70 70 70
47627 - 30 30 30 10 10 10 0 0 0 0 0 0
47628 - 0 0 0 0 0 0 0 0 0 0 0 0
47629 - 0 0 0 0 0 0 0 0 0 0 0 0
47630 - 0 0 0 0 0 0 0 0 0 0 0 0
47631 - 0 0 0 0 0 0 0 0 0 0 0 0
47632 - 0 0 0 0 0 0 0 0 0 0 0 0
47633 - 0 0 0 0 0 0 0 0 0 0 0 0
47634 - 0 0 0 0 0 0 0 0 0 0 0 0
47635 - 0 0 0 0 0 0 0 0 0 0 0 0
47636 - 0 0 0 0 0 0 0 0 0 0 0 0
47637 - 0 0 0 0 0 0 0 0 0 0 0 0
47638 - 0 0 0 0 0 0 0 0 0 0 0 0
47639 - 0 0 0 0 0 0 6 6 6 18 18 18
47640 - 50 50 50 101 101 101 26 26 26 10 10 10
47641 -138 138 138 190 190 190 174 154 114 156 107 11
47642 -197 138 11 200 144 11 197 138 11 192 133 9
47643 -180 123 7 190 142 34 190 178 144 187 187 187
47644 -202 202 202 221 221 221 214 214 214 66 66 66
47645 - 2 2 6 2 2 6 50 50 50 62 62 62
47646 - 6 6 6 2 2 6 10 10 10 90 90 90
47647 - 50 50 50 18 18 18 6 6 6 0 0 0
47648 - 0 0 0 0 0 0 0 0 0 0 0 0
47649 - 0 0 0 0 0 0 0 0 0 0 0 0
47650 - 0 0 0 0 0 0 0 0 0 0 0 0
47651 - 0 0 0 0 0 0 0 0 0 0 0 0
47652 - 0 0 0 0 0 0 0 0 0 0 0 0
47653 - 0 0 0 0 0 0 0 0 0 0 0 0
47654 - 0 0 0 0 0 0 0 0 0 0 0 0
47655 - 0 0 0 0 0 0 0 0 0 0 0 0
47656 - 0 0 0 0 0 0 0 0 0 0 0 0
47657 - 0 0 0 0 0 0 0 0 0 0 0 0
47658 - 0 0 0 0 0 0 0 0 0 0 0 0
47659 - 0 0 0 0 0 0 10 10 10 34 34 34
47660 - 74 74 74 74 74 74 2 2 6 6 6 6
47661 -144 144 144 198 198 198 190 190 190 178 166 146
47662 -154 121 60 156 107 11 156 107 11 168 124 44
47663 -174 154 114 187 187 187 190 190 190 210 210 210
47664 -246 246 246 253 253 253 253 253 253 182 182 182
47665 - 6 6 6 2 2 6 2 2 6 2 2 6
47666 - 2 2 6 2 2 6 2 2 6 62 62 62
47667 - 74 74 74 34 34 34 14 14 14 0 0 0
47668 - 0 0 0 0 0 0 0 0 0 0 0 0
47669 - 0 0 0 0 0 0 0 0 0 0 0 0
47670 - 0 0 0 0 0 0 0 0 0 0 0 0
47671 - 0 0 0 0 0 0 0 0 0 0 0 0
47672 - 0 0 0 0 0 0 0 0 0 0 0 0
47673 - 0 0 0 0 0 0 0 0 0 0 0 0
47674 - 0 0 0 0 0 0 0 0 0 0 0 0
47675 - 0 0 0 0 0 0 0 0 0 0 0 0
47676 - 0 0 0 0 0 0 0 0 0 0 0 0
47677 - 0 0 0 0 0 0 0 0 0 0 0 0
47678 - 0 0 0 0 0 0 0 0 0 0 0 0
47679 - 0 0 0 10 10 10 22 22 22 54 54 54
47680 - 94 94 94 18 18 18 2 2 6 46 46 46
47681 -234 234 234 221 221 221 190 190 190 190 190 190
47682 -190 190 190 187 187 187 187 187 187 190 190 190
47683 -190 190 190 195 195 195 214 214 214 242 242 242
47684 -253 253 253 253 253 253 253 253 253 253 253 253
47685 - 82 82 82 2 2 6 2 2 6 2 2 6
47686 - 2 2 6 2 2 6 2 2 6 14 14 14
47687 - 86 86 86 54 54 54 22 22 22 6 6 6
47688 - 0 0 0 0 0 0 0 0 0 0 0 0
47689 - 0 0 0 0 0 0 0 0 0 0 0 0
47690 - 0 0 0 0 0 0 0 0 0 0 0 0
47691 - 0 0 0 0 0 0 0 0 0 0 0 0
47692 - 0 0 0 0 0 0 0 0 0 0 0 0
47693 - 0 0 0 0 0 0 0 0 0 0 0 0
47694 - 0 0 0 0 0 0 0 0 0 0 0 0
47695 - 0 0 0 0 0 0 0 0 0 0 0 0
47696 - 0 0 0 0 0 0 0 0 0 0 0 0
47697 - 0 0 0 0 0 0 0 0 0 0 0 0
47698 - 0 0 0 0 0 0 0 0 0 0 0 0
47699 - 6 6 6 18 18 18 46 46 46 90 90 90
47700 - 46 46 46 18 18 18 6 6 6 182 182 182
47701 -253 253 253 246 246 246 206 206 206 190 190 190
47702 -190 190 190 190 190 190 190 190 190 190 190 190
47703 -206 206 206 231 231 231 250 250 250 253 253 253
47704 -253 253 253 253 253 253 253 253 253 253 253 253
47705 -202 202 202 14 14 14 2 2 6 2 2 6
47706 - 2 2 6 2 2 6 2 2 6 2 2 6
47707 - 42 42 42 86 86 86 42 42 42 18 18 18
47708 - 6 6 6 0 0 0 0 0 0 0 0 0
47709 - 0 0 0 0 0 0 0 0 0 0 0 0
47710 - 0 0 0 0 0 0 0 0 0 0 0 0
47711 - 0 0 0 0 0 0 0 0 0 0 0 0
47712 - 0 0 0 0 0 0 0 0 0 0 0 0
47713 - 0 0 0 0 0 0 0 0 0 0 0 0
47714 - 0 0 0 0 0 0 0 0 0 0 0 0
47715 - 0 0 0 0 0 0 0 0 0 0 0 0
47716 - 0 0 0 0 0 0 0 0 0 0 0 0
47717 - 0 0 0 0 0 0 0 0 0 0 0 0
47718 - 0 0 0 0 0 0 0 0 0 6 6 6
47719 - 14 14 14 38 38 38 74 74 74 66 66 66
47720 - 2 2 6 6 6 6 90 90 90 250 250 250
47721 -253 253 253 253 253 253 238 238 238 198 198 198
47722 -190 190 190 190 190 190 195 195 195 221 221 221
47723 -246 246 246 253 253 253 253 253 253 253 253 253
47724 -253 253 253 253 253 253 253 253 253 253 253 253
47725 -253 253 253 82 82 82 2 2 6 2 2 6
47726 - 2 2 6 2 2 6 2 2 6 2 2 6
47727 - 2 2 6 78 78 78 70 70 70 34 34 34
47728 - 14 14 14 6 6 6 0 0 0 0 0 0
47729 - 0 0 0 0 0 0 0 0 0 0 0 0
47730 - 0 0 0 0 0 0 0 0 0 0 0 0
47731 - 0 0 0 0 0 0 0 0 0 0 0 0
47732 - 0 0 0 0 0 0 0 0 0 0 0 0
47733 - 0 0 0 0 0 0 0 0 0 0 0 0
47734 - 0 0 0 0 0 0 0 0 0 0 0 0
47735 - 0 0 0 0 0 0 0 0 0 0 0 0
47736 - 0 0 0 0 0 0 0 0 0 0 0 0
47737 - 0 0 0 0 0 0 0 0 0 0 0 0
47738 - 0 0 0 0 0 0 0 0 0 14 14 14
47739 - 34 34 34 66 66 66 78 78 78 6 6 6
47740 - 2 2 6 18 18 18 218 218 218 253 253 253
47741 -253 253 253 253 253 253 253 253 253 246 246 246
47742 -226 226 226 231 231 231 246 246 246 253 253 253
47743 -253 253 253 253 253 253 253 253 253 253 253 253
47744 -253 253 253 253 253 253 253 253 253 253 253 253
47745 -253 253 253 178 178 178 2 2 6 2 2 6
47746 - 2 2 6 2 2 6 2 2 6 2 2 6
47747 - 2 2 6 18 18 18 90 90 90 62 62 62
47748 - 30 30 30 10 10 10 0 0 0 0 0 0
47749 - 0 0 0 0 0 0 0 0 0 0 0 0
47750 - 0 0 0 0 0 0 0 0 0 0 0 0
47751 - 0 0 0 0 0 0 0 0 0 0 0 0
47752 - 0 0 0 0 0 0 0 0 0 0 0 0
47753 - 0 0 0 0 0 0 0 0 0 0 0 0
47754 - 0 0 0 0 0 0 0 0 0 0 0 0
47755 - 0 0 0 0 0 0 0 0 0 0 0 0
47756 - 0 0 0 0 0 0 0 0 0 0 0 0
47757 - 0 0 0 0 0 0 0 0 0 0 0 0
47758 - 0 0 0 0 0 0 10 10 10 26 26 26
47759 - 58 58 58 90 90 90 18 18 18 2 2 6
47760 - 2 2 6 110 110 110 253 253 253 253 253 253
47761 -253 253 253 253 253 253 253 253 253 253 253 253
47762 -250 250 250 253 253 253 253 253 253 253 253 253
47763 -253 253 253 253 253 253 253 253 253 253 253 253
47764 -253 253 253 253 253 253 253 253 253 253 253 253
47765 -253 253 253 231 231 231 18 18 18 2 2 6
47766 - 2 2 6 2 2 6 2 2 6 2 2 6
47767 - 2 2 6 2 2 6 18 18 18 94 94 94
47768 - 54 54 54 26 26 26 10 10 10 0 0 0
47769 - 0 0 0 0 0 0 0 0 0 0 0 0
47770 - 0 0 0 0 0 0 0 0 0 0 0 0
47771 - 0 0 0 0 0 0 0 0 0 0 0 0
47772 - 0 0 0 0 0 0 0 0 0 0 0 0
47773 - 0 0 0 0 0 0 0 0 0 0 0 0
47774 - 0 0 0 0 0 0 0 0 0 0 0 0
47775 - 0 0 0 0 0 0 0 0 0 0 0 0
47776 - 0 0 0 0 0 0 0 0 0 0 0 0
47777 - 0 0 0 0 0 0 0 0 0 0 0 0
47778 - 0 0 0 6 6 6 22 22 22 50 50 50
47779 - 90 90 90 26 26 26 2 2 6 2 2 6
47780 - 14 14 14 195 195 195 250 250 250 253 253 253
47781 -253 253 253 253 253 253 253 253 253 253 253 253
47782 -253 253 253 253 253 253 253 253 253 253 253 253
47783 -253 253 253 253 253 253 253 253 253 253 253 253
47784 -253 253 253 253 253 253 253 253 253 253 253 253
47785 -250 250 250 242 242 242 54 54 54 2 2 6
47786 - 2 2 6 2 2 6 2 2 6 2 2 6
47787 - 2 2 6 2 2 6 2 2 6 38 38 38
47788 - 86 86 86 50 50 50 22 22 22 6 6 6
47789 - 0 0 0 0 0 0 0 0 0 0 0 0
47790 - 0 0 0 0 0 0 0 0 0 0 0 0
47791 - 0 0 0 0 0 0 0 0 0 0 0 0
47792 - 0 0 0 0 0 0 0 0 0 0 0 0
47793 - 0 0 0 0 0 0 0 0 0 0 0 0
47794 - 0 0 0 0 0 0 0 0 0 0 0 0
47795 - 0 0 0 0 0 0 0 0 0 0 0 0
47796 - 0 0 0 0 0 0 0 0 0 0 0 0
47797 - 0 0 0 0 0 0 0 0 0 0 0 0
47798 - 6 6 6 14 14 14 38 38 38 82 82 82
47799 - 34 34 34 2 2 6 2 2 6 2 2 6
47800 - 42 42 42 195 195 195 246 246 246 253 253 253
47801 -253 253 253 253 253 253 253 253 253 250 250 250
47802 -242 242 242 242 242 242 250 250 250 253 253 253
47803 -253 253 253 253 253 253 253 253 253 253 253 253
47804 -253 253 253 250 250 250 246 246 246 238 238 238
47805 -226 226 226 231 231 231 101 101 101 6 6 6
47806 - 2 2 6 2 2 6 2 2 6 2 2 6
47807 - 2 2 6 2 2 6 2 2 6 2 2 6
47808 - 38 38 38 82 82 82 42 42 42 14 14 14
47809 - 6 6 6 0 0 0 0 0 0 0 0 0
47810 - 0 0 0 0 0 0 0 0 0 0 0 0
47811 - 0 0 0 0 0 0 0 0 0 0 0 0
47812 - 0 0 0 0 0 0 0 0 0 0 0 0
47813 - 0 0 0 0 0 0 0 0 0 0 0 0
47814 - 0 0 0 0 0 0 0 0 0 0 0 0
47815 - 0 0 0 0 0 0 0 0 0 0 0 0
47816 - 0 0 0 0 0 0 0 0 0 0 0 0
47817 - 0 0 0 0 0 0 0 0 0 0 0 0
47818 - 10 10 10 26 26 26 62 62 62 66 66 66
47819 - 2 2 6 2 2 6 2 2 6 6 6 6
47820 - 70 70 70 170 170 170 206 206 206 234 234 234
47821 -246 246 246 250 250 250 250 250 250 238 238 238
47822 -226 226 226 231 231 231 238 238 238 250 250 250
47823 -250 250 250 250 250 250 246 246 246 231 231 231
47824 -214 214 214 206 206 206 202 202 202 202 202 202
47825 -198 198 198 202 202 202 182 182 182 18 18 18
47826 - 2 2 6 2 2 6 2 2 6 2 2 6
47827 - 2 2 6 2 2 6 2 2 6 2 2 6
47828 - 2 2 6 62 62 62 66 66 66 30 30 30
47829 - 10 10 10 0 0 0 0 0 0 0 0 0
47830 - 0 0 0 0 0 0 0 0 0 0 0 0
47831 - 0 0 0 0 0 0 0 0 0 0 0 0
47832 - 0 0 0 0 0 0 0 0 0 0 0 0
47833 - 0 0 0 0 0 0 0 0 0 0 0 0
47834 - 0 0 0 0 0 0 0 0 0 0 0 0
47835 - 0 0 0 0 0 0 0 0 0 0 0 0
47836 - 0 0 0 0 0 0 0 0 0 0 0 0
47837 - 0 0 0 0 0 0 0 0 0 0 0 0
47838 - 14 14 14 42 42 42 82 82 82 18 18 18
47839 - 2 2 6 2 2 6 2 2 6 10 10 10
47840 - 94 94 94 182 182 182 218 218 218 242 242 242
47841 -250 250 250 253 253 253 253 253 253 250 250 250
47842 -234 234 234 253 253 253 253 253 253 253 253 253
47843 -253 253 253 253 253 253 253 253 253 246 246 246
47844 -238 238 238 226 226 226 210 210 210 202 202 202
47845 -195 195 195 195 195 195 210 210 210 158 158 158
47846 - 6 6 6 14 14 14 50 50 50 14 14 14
47847 - 2 2 6 2 2 6 2 2 6 2 2 6
47848 - 2 2 6 6 6 6 86 86 86 46 46 46
47849 - 18 18 18 6 6 6 0 0 0 0 0 0
47850 - 0 0 0 0 0 0 0 0 0 0 0 0
47851 - 0 0 0 0 0 0 0 0 0 0 0 0
47852 - 0 0 0 0 0 0 0 0 0 0 0 0
47853 - 0 0 0 0 0 0 0 0 0 0 0 0
47854 - 0 0 0 0 0 0 0 0 0 0 0 0
47855 - 0 0 0 0 0 0 0 0 0 0 0 0
47856 - 0 0 0 0 0 0 0 0 0 0 0 0
47857 - 0 0 0 0 0 0 0 0 0 6 6 6
47858 - 22 22 22 54 54 54 70 70 70 2 2 6
47859 - 2 2 6 10 10 10 2 2 6 22 22 22
47860 -166 166 166 231 231 231 250 250 250 253 253 253
47861 -253 253 253 253 253 253 253 253 253 250 250 250
47862 -242 242 242 253 253 253 253 253 253 253 253 253
47863 -253 253 253 253 253 253 253 253 253 253 253 253
47864 -253 253 253 253 253 253 253 253 253 246 246 246
47865 -231 231 231 206 206 206 198 198 198 226 226 226
47866 - 94 94 94 2 2 6 6 6 6 38 38 38
47867 - 30 30 30 2 2 6 2 2 6 2 2 6
47868 - 2 2 6 2 2 6 62 62 62 66 66 66
47869 - 26 26 26 10 10 10 0 0 0 0 0 0
47870 - 0 0 0 0 0 0 0 0 0 0 0 0
47871 - 0 0 0 0 0 0 0 0 0 0 0 0
47872 - 0 0 0 0 0 0 0 0 0 0 0 0
47873 - 0 0 0 0 0 0 0 0 0 0 0 0
47874 - 0 0 0 0 0 0 0 0 0 0 0 0
47875 - 0 0 0 0 0 0 0 0 0 0 0 0
47876 - 0 0 0 0 0 0 0 0 0 0 0 0
47877 - 0 0 0 0 0 0 0 0 0 10 10 10
47878 - 30 30 30 74 74 74 50 50 50 2 2 6
47879 - 26 26 26 26 26 26 2 2 6 106 106 106
47880 -238 238 238 253 253 253 253 253 253 253 253 253
47881 -253 253 253 253 253 253 253 253 253 253 253 253
47882 -253 253 253 253 253 253 253 253 253 253 253 253
47883 -253 253 253 253 253 253 253 253 253 253 253 253
47884 -253 253 253 253 253 253 253 253 253 253 253 253
47885 -253 253 253 246 246 246 218 218 218 202 202 202
47886 -210 210 210 14 14 14 2 2 6 2 2 6
47887 - 30 30 30 22 22 22 2 2 6 2 2 6
47888 - 2 2 6 2 2 6 18 18 18 86 86 86
47889 - 42 42 42 14 14 14 0 0 0 0 0 0
47890 - 0 0 0 0 0 0 0 0 0 0 0 0
47891 - 0 0 0 0 0 0 0 0 0 0 0 0
47892 - 0 0 0 0 0 0 0 0 0 0 0 0
47893 - 0 0 0 0 0 0 0 0 0 0 0 0
47894 - 0 0 0 0 0 0 0 0 0 0 0 0
47895 - 0 0 0 0 0 0 0 0 0 0 0 0
47896 - 0 0 0 0 0 0 0 0 0 0 0 0
47897 - 0 0 0 0 0 0 0 0 0 14 14 14
47898 - 42 42 42 90 90 90 22 22 22 2 2 6
47899 - 42 42 42 2 2 6 18 18 18 218 218 218
47900 -253 253 253 253 253 253 253 253 253 253 253 253
47901 -253 253 253 253 253 253 253 253 253 253 253 253
47902 -253 253 253 253 253 253 253 253 253 253 253 253
47903 -253 253 253 253 253 253 253 253 253 253 253 253
47904 -253 253 253 253 253 253 253 253 253 253 253 253
47905 -253 253 253 253 253 253 250 250 250 221 221 221
47906 -218 218 218 101 101 101 2 2 6 14 14 14
47907 - 18 18 18 38 38 38 10 10 10 2 2 6
47908 - 2 2 6 2 2 6 2 2 6 78 78 78
47909 - 58 58 58 22 22 22 6 6 6 0 0 0
47910 - 0 0 0 0 0 0 0 0 0 0 0 0
47911 - 0 0 0 0 0 0 0 0 0 0 0 0
47912 - 0 0 0 0 0 0 0 0 0 0 0 0
47913 - 0 0 0 0 0 0 0 0 0 0 0 0
47914 - 0 0 0 0 0 0 0 0 0 0 0 0
47915 - 0 0 0 0 0 0 0 0 0 0 0 0
47916 - 0 0 0 0 0 0 0 0 0 0 0 0
47917 - 0 0 0 0 0 0 6 6 6 18 18 18
47918 - 54 54 54 82 82 82 2 2 6 26 26 26
47919 - 22 22 22 2 2 6 123 123 123 253 253 253
47920 -253 253 253 253 253 253 253 253 253 253 253 253
47921 -253 253 253 253 253 253 253 253 253 253 253 253
47922 -253 253 253 253 253 253 253 253 253 253 253 253
47923 -253 253 253 253 253 253 253 253 253 253 253 253
47924 -253 253 253 253 253 253 253 253 253 253 253 253
47925 -253 253 253 253 253 253 253 253 253 250 250 250
47926 -238 238 238 198 198 198 6 6 6 38 38 38
47927 - 58 58 58 26 26 26 38 38 38 2 2 6
47928 - 2 2 6 2 2 6 2 2 6 46 46 46
47929 - 78 78 78 30 30 30 10 10 10 0 0 0
47930 - 0 0 0 0 0 0 0 0 0 0 0 0
47931 - 0 0 0 0 0 0 0 0 0 0 0 0
47932 - 0 0 0 0 0 0 0 0 0 0 0 0
47933 - 0 0 0 0 0 0 0 0 0 0 0 0
47934 - 0 0 0 0 0 0 0 0 0 0 0 0
47935 - 0 0 0 0 0 0 0 0 0 0 0 0
47936 - 0 0 0 0 0 0 0 0 0 0 0 0
47937 - 0 0 0 0 0 0 10 10 10 30 30 30
47938 - 74 74 74 58 58 58 2 2 6 42 42 42
47939 - 2 2 6 22 22 22 231 231 231 253 253 253
47940 -253 253 253 253 253 253 253 253 253 253 253 253
47941 -253 253 253 253 253 253 253 253 253 250 250 250
47942 -253 253 253 253 253 253 253 253 253 253 253 253
47943 -253 253 253 253 253 253 253 253 253 253 253 253
47944 -253 253 253 253 253 253 253 253 253 253 253 253
47945 -253 253 253 253 253 253 253 253 253 253 253 253
47946 -253 253 253 246 246 246 46 46 46 38 38 38
47947 - 42 42 42 14 14 14 38 38 38 14 14 14
47948 - 2 2 6 2 2 6 2 2 6 6 6 6
47949 - 86 86 86 46 46 46 14 14 14 0 0 0
47950 - 0 0 0 0 0 0 0 0 0 0 0 0
47951 - 0 0 0 0 0 0 0 0 0 0 0 0
47952 - 0 0 0 0 0 0 0 0 0 0 0 0
47953 - 0 0 0 0 0 0 0 0 0 0 0 0
47954 - 0 0 0 0 0 0 0 0 0 0 0 0
47955 - 0 0 0 0 0 0 0 0 0 0 0 0
47956 - 0 0 0 0 0 0 0 0 0 0 0 0
47957 - 0 0 0 6 6 6 14 14 14 42 42 42
47958 - 90 90 90 18 18 18 18 18 18 26 26 26
47959 - 2 2 6 116 116 116 253 253 253 253 253 253
47960 -253 253 253 253 253 253 253 253 253 253 253 253
47961 -253 253 253 253 253 253 250 250 250 238 238 238
47962 -253 253 253 253 253 253 253 253 253 253 253 253
47963 -253 253 253 253 253 253 253 253 253 253 253 253
47964 -253 253 253 253 253 253 253 253 253 253 253 253
47965 -253 253 253 253 253 253 253 253 253 253 253 253
47966 -253 253 253 253 253 253 94 94 94 6 6 6
47967 - 2 2 6 2 2 6 10 10 10 34 34 34
47968 - 2 2 6 2 2 6 2 2 6 2 2 6
47969 - 74 74 74 58 58 58 22 22 22 6 6 6
47970 - 0 0 0 0 0 0 0 0 0 0 0 0
47971 - 0 0 0 0 0 0 0 0 0 0 0 0
47972 - 0 0 0 0 0 0 0 0 0 0 0 0
47973 - 0 0 0 0 0 0 0 0 0 0 0 0
47974 - 0 0 0 0 0 0 0 0 0 0 0 0
47975 - 0 0 0 0 0 0 0 0 0 0 0 0
47976 - 0 0 0 0 0 0 0 0 0 0 0 0
47977 - 0 0 0 10 10 10 26 26 26 66 66 66
47978 - 82 82 82 2 2 6 38 38 38 6 6 6
47979 - 14 14 14 210 210 210 253 253 253 253 253 253
47980 -253 253 253 253 253 253 253 253 253 253 253 253
47981 -253 253 253 253 253 253 246 246 246 242 242 242
47982 -253 253 253 253 253 253 253 253 253 253 253 253
47983 -253 253 253 253 253 253 253 253 253 253 253 253
47984 -253 253 253 253 253 253 253 253 253 253 253 253
47985 -253 253 253 253 253 253 253 253 253 253 253 253
47986 -253 253 253 253 253 253 144 144 144 2 2 6
47987 - 2 2 6 2 2 6 2 2 6 46 46 46
47988 - 2 2 6 2 2 6 2 2 6 2 2 6
47989 - 42 42 42 74 74 74 30 30 30 10 10 10
47990 - 0 0 0 0 0 0 0 0 0 0 0 0
47991 - 0 0 0 0 0 0 0 0 0 0 0 0
47992 - 0 0 0 0 0 0 0 0 0 0 0 0
47993 - 0 0 0 0 0 0 0 0 0 0 0 0
47994 - 0 0 0 0 0 0 0 0 0 0 0 0
47995 - 0 0 0 0 0 0 0 0 0 0 0 0
47996 - 0 0 0 0 0 0 0 0 0 0 0 0
47997 - 6 6 6 14 14 14 42 42 42 90 90 90
47998 - 26 26 26 6 6 6 42 42 42 2 2 6
47999 - 74 74 74 250 250 250 253 253 253 253 253 253
48000 -253 253 253 253 253 253 253 253 253 253 253 253
48001 -253 253 253 253 253 253 242 242 242 242 242 242
48002 -253 253 253 253 253 253 253 253 253 253 253 253
48003 -253 253 253 253 253 253 253 253 253 253 253 253
48004 -253 253 253 253 253 253 253 253 253 253 253 253
48005 -253 253 253 253 253 253 253 253 253 253 253 253
48006 -253 253 253 253 253 253 182 182 182 2 2 6
48007 - 2 2 6 2 2 6 2 2 6 46 46 46
48008 - 2 2 6 2 2 6 2 2 6 2 2 6
48009 - 10 10 10 86 86 86 38 38 38 10 10 10
48010 - 0 0 0 0 0 0 0 0 0 0 0 0
48011 - 0 0 0 0 0 0 0 0 0 0 0 0
48012 - 0 0 0 0 0 0 0 0 0 0 0 0
48013 - 0 0 0 0 0 0 0 0 0 0 0 0
48014 - 0 0 0 0 0 0 0 0 0 0 0 0
48015 - 0 0 0 0 0 0 0 0 0 0 0 0
48016 - 0 0 0 0 0 0 0 0 0 0 0 0
48017 - 10 10 10 26 26 26 66 66 66 82 82 82
48018 - 2 2 6 22 22 22 18 18 18 2 2 6
48019 -149 149 149 253 253 253 253 253 253 253 253 253
48020 -253 253 253 253 253 253 253 253 253 253 253 253
48021 -253 253 253 253 253 253 234 234 234 242 242 242
48022 -253 253 253 253 253 253 253 253 253 253 253 253
48023 -253 253 253 253 253 253 253 253 253 253 253 253
48024 -253 253 253 253 253 253 253 253 253 253 253 253
48025 -253 253 253 253 253 253 253 253 253 253 253 253
48026 -253 253 253 253 253 253 206 206 206 2 2 6
48027 - 2 2 6 2 2 6 2 2 6 38 38 38
48028 - 2 2 6 2 2 6 2 2 6 2 2 6
48029 - 6 6 6 86 86 86 46 46 46 14 14 14
48030 - 0 0 0 0 0 0 0 0 0 0 0 0
48031 - 0 0 0 0 0 0 0 0 0 0 0 0
48032 - 0 0 0 0 0 0 0 0 0 0 0 0
48033 - 0 0 0 0 0 0 0 0 0 0 0 0
48034 - 0 0 0 0 0 0 0 0 0 0 0 0
48035 - 0 0 0 0 0 0 0 0 0 0 0 0
48036 - 0 0 0 0 0 0 0 0 0 6 6 6
48037 - 18 18 18 46 46 46 86 86 86 18 18 18
48038 - 2 2 6 34 34 34 10 10 10 6 6 6
48039 -210 210 210 253 253 253 253 253 253 253 253 253
48040 -253 253 253 253 253 253 253 253 253 253 253 253
48041 -253 253 253 253 253 253 234 234 234 242 242 242
48042 -253 253 253 253 253 253 253 253 253 253 253 253
48043 -253 253 253 253 253 253 253 253 253 253 253 253
48044 -253 253 253 253 253 253 253 253 253 253 253 253
48045 -253 253 253 253 253 253 253 253 253 253 253 253
48046 -253 253 253 253 253 253 221 221 221 6 6 6
48047 - 2 2 6 2 2 6 6 6 6 30 30 30
48048 - 2 2 6 2 2 6 2 2 6 2 2 6
48049 - 2 2 6 82 82 82 54 54 54 18 18 18
48050 - 6 6 6 0 0 0 0 0 0 0 0 0
48051 - 0 0 0 0 0 0 0 0 0 0 0 0
48052 - 0 0 0 0 0 0 0 0 0 0 0 0
48053 - 0 0 0 0 0 0 0 0 0 0 0 0
48054 - 0 0 0 0 0 0 0 0 0 0 0 0
48055 - 0 0 0 0 0 0 0 0 0 0 0 0
48056 - 0 0 0 0 0 0 0 0 0 10 10 10
48057 - 26 26 26 66 66 66 62 62 62 2 2 6
48058 - 2 2 6 38 38 38 10 10 10 26 26 26
48059 -238 238 238 253 253 253 253 253 253 253 253 253
48060 -253 253 253 253 253 253 253 253 253 253 253 253
48061 -253 253 253 253 253 253 231 231 231 238 238 238
48062 -253 253 253 253 253 253 253 253 253 253 253 253
48063 -253 253 253 253 253 253 253 253 253 253 253 253
48064 -253 253 253 253 253 253 253 253 253 253 253 253
48065 -253 253 253 253 253 253 253 253 253 253 253 253
48066 -253 253 253 253 253 253 231 231 231 6 6 6
48067 - 2 2 6 2 2 6 10 10 10 30 30 30
48068 - 2 2 6 2 2 6 2 2 6 2 2 6
48069 - 2 2 6 66 66 66 58 58 58 22 22 22
48070 - 6 6 6 0 0 0 0 0 0 0 0 0
48071 - 0 0 0 0 0 0 0 0 0 0 0 0
48072 - 0 0 0 0 0 0 0 0 0 0 0 0
48073 - 0 0 0 0 0 0 0 0 0 0 0 0
48074 - 0 0 0 0 0 0 0 0 0 0 0 0
48075 - 0 0 0 0 0 0 0 0 0 0 0 0
48076 - 0 0 0 0 0 0 0 0 0 10 10 10
48077 - 38 38 38 78 78 78 6 6 6 2 2 6
48078 - 2 2 6 46 46 46 14 14 14 42 42 42
48079 -246 246 246 253 253 253 253 253 253 253 253 253
48080 -253 253 253 253 253 253 253 253 253 253 253 253
48081 -253 253 253 253 253 253 231 231 231 242 242 242
48082 -253 253 253 253 253 253 253 253 253 253 253 253
48083 -253 253 253 253 253 253 253 253 253 253 253 253
48084 -253 253 253 253 253 253 253 253 253 253 253 253
48085 -253 253 253 253 253 253 253 253 253 253 253 253
48086 -253 253 253 253 253 253 234 234 234 10 10 10
48087 - 2 2 6 2 2 6 22 22 22 14 14 14
48088 - 2 2 6 2 2 6 2 2 6 2 2 6
48089 - 2 2 6 66 66 66 62 62 62 22 22 22
48090 - 6 6 6 0 0 0 0 0 0 0 0 0
48091 - 0 0 0 0 0 0 0 0 0 0 0 0
48092 - 0 0 0 0 0 0 0 0 0 0 0 0
48093 - 0 0 0 0 0 0 0 0 0 0 0 0
48094 - 0 0 0 0 0 0 0 0 0 0 0 0
48095 - 0 0 0 0 0 0 0 0 0 0 0 0
48096 - 0 0 0 0 0 0 6 6 6 18 18 18
48097 - 50 50 50 74 74 74 2 2 6 2 2 6
48098 - 14 14 14 70 70 70 34 34 34 62 62 62
48099 -250 250 250 253 253 253 253 253 253 253 253 253
48100 -253 253 253 253 253 253 253 253 253 253 253 253
48101 -253 253 253 253 253 253 231 231 231 246 246 246
48102 -253 253 253 253 253 253 253 253 253 253 253 253
48103 -253 253 253 253 253 253 253 253 253 253 253 253
48104 -253 253 253 253 253 253 253 253 253 253 253 253
48105 -253 253 253 253 253 253 253 253 253 253 253 253
48106 -253 253 253 253 253 253 234 234 234 14 14 14
48107 - 2 2 6 2 2 6 30 30 30 2 2 6
48108 - 2 2 6 2 2 6 2 2 6 2 2 6
48109 - 2 2 6 66 66 66 62 62 62 22 22 22
48110 - 6 6 6 0 0 0 0 0 0 0 0 0
48111 - 0 0 0 0 0 0 0 0 0 0 0 0
48112 - 0 0 0 0 0 0 0 0 0 0 0 0
48113 - 0 0 0 0 0 0 0 0 0 0 0 0
48114 - 0 0 0 0 0 0 0 0 0 0 0 0
48115 - 0 0 0 0 0 0 0 0 0 0 0 0
48116 - 0 0 0 0 0 0 6 6 6 18 18 18
48117 - 54 54 54 62 62 62 2 2 6 2 2 6
48118 - 2 2 6 30 30 30 46 46 46 70 70 70
48119 -250 250 250 253 253 253 253 253 253 253 253 253
48120 -253 253 253 253 253 253 253 253 253 253 253 253
48121 -253 253 253 253 253 253 231 231 231 246 246 246
48122 -253 253 253 253 253 253 253 253 253 253 253 253
48123 -253 253 253 253 253 253 253 253 253 253 253 253
48124 -253 253 253 253 253 253 253 253 253 253 253 253
48125 -253 253 253 253 253 253 253 253 253 253 253 253
48126 -253 253 253 253 253 253 226 226 226 10 10 10
48127 - 2 2 6 6 6 6 30 30 30 2 2 6
48128 - 2 2 6 2 2 6 2 2 6 2 2 6
48129 - 2 2 6 66 66 66 58 58 58 22 22 22
48130 - 6 6 6 0 0 0 0 0 0 0 0 0
48131 - 0 0 0 0 0 0 0 0 0 0 0 0
48132 - 0 0 0 0 0 0 0 0 0 0 0 0
48133 - 0 0 0 0 0 0 0 0 0 0 0 0
48134 - 0 0 0 0 0 0 0 0 0 0 0 0
48135 - 0 0 0 0 0 0 0 0 0 0 0 0
48136 - 0 0 0 0 0 0 6 6 6 22 22 22
48137 - 58 58 58 62 62 62 2 2 6 2 2 6
48138 - 2 2 6 2 2 6 30 30 30 78 78 78
48139 -250 250 250 253 253 253 253 253 253 253 253 253
48140 -253 253 253 253 253 253 253 253 253 253 253 253
48141 -253 253 253 253 253 253 231 231 231 246 246 246
48142 -253 253 253 253 253 253 253 253 253 253 253 253
48143 -253 253 253 253 253 253 253 253 253 253 253 253
48144 -253 253 253 253 253 253 253 253 253 253 253 253
48145 -253 253 253 253 253 253 253 253 253 253 253 253
48146 -253 253 253 253 253 253 206 206 206 2 2 6
48147 - 22 22 22 34 34 34 18 14 6 22 22 22
48148 - 26 26 26 18 18 18 6 6 6 2 2 6
48149 - 2 2 6 82 82 82 54 54 54 18 18 18
48150 - 6 6 6 0 0 0 0 0 0 0 0 0
48151 - 0 0 0 0 0 0 0 0 0 0 0 0
48152 - 0 0 0 0 0 0 0 0 0 0 0 0
48153 - 0 0 0 0 0 0 0 0 0 0 0 0
48154 - 0 0 0 0 0 0 0 0 0 0 0 0
48155 - 0 0 0 0 0 0 0 0 0 0 0 0
48156 - 0 0 0 0 0 0 6 6 6 26 26 26
48157 - 62 62 62 106 106 106 74 54 14 185 133 11
48158 -210 162 10 121 92 8 6 6 6 62 62 62
48159 -238 238 238 253 253 253 253 253 253 253 253 253
48160 -253 253 253 253 253 253 253 253 253 253 253 253
48161 -253 253 253 253 253 253 231 231 231 246 246 246
48162 -253 253 253 253 253 253 253 253 253 253 253 253
48163 -253 253 253 253 253 253 253 253 253 253 253 253
48164 -253 253 253 253 253 253 253 253 253 253 253 253
48165 -253 253 253 253 253 253 253 253 253 253 253 253
48166 -253 253 253 253 253 253 158 158 158 18 18 18
48167 - 14 14 14 2 2 6 2 2 6 2 2 6
48168 - 6 6 6 18 18 18 66 66 66 38 38 38
48169 - 6 6 6 94 94 94 50 50 50 18 18 18
48170 - 6 6 6 0 0 0 0 0 0 0 0 0
48171 - 0 0 0 0 0 0 0 0 0 0 0 0
48172 - 0 0 0 0 0 0 0 0 0 0 0 0
48173 - 0 0 0 0 0 0 0 0 0 0 0 0
48174 - 0 0 0 0 0 0 0 0 0 0 0 0
48175 - 0 0 0 0 0 0 0 0 0 6 6 6
48176 - 10 10 10 10 10 10 18 18 18 38 38 38
48177 - 78 78 78 142 134 106 216 158 10 242 186 14
48178 -246 190 14 246 190 14 156 118 10 10 10 10
48179 - 90 90 90 238 238 238 253 253 253 253 253 253
48180 -253 253 253 253 253 253 253 253 253 253 253 253
48181 -253 253 253 253 253 253 231 231 231 250 250 250
48182 -253 253 253 253 253 253 253 253 253 253 253 253
48183 -253 253 253 253 253 253 253 253 253 253 253 253
48184 -253 253 253 253 253 253 253 253 253 253 253 253
48185 -253 253 253 253 253 253 253 253 253 246 230 190
48186 -238 204 91 238 204 91 181 142 44 37 26 9
48187 - 2 2 6 2 2 6 2 2 6 2 2 6
48188 - 2 2 6 2 2 6 38 38 38 46 46 46
48189 - 26 26 26 106 106 106 54 54 54 18 18 18
48190 - 6 6 6 0 0 0 0 0 0 0 0 0
48191 - 0 0 0 0 0 0 0 0 0 0 0 0
48192 - 0 0 0 0 0 0 0 0 0 0 0 0
48193 - 0 0 0 0 0 0 0 0 0 0 0 0
48194 - 0 0 0 0 0 0 0 0 0 0 0 0
48195 - 0 0 0 6 6 6 14 14 14 22 22 22
48196 - 30 30 30 38 38 38 50 50 50 70 70 70
48197 -106 106 106 190 142 34 226 170 11 242 186 14
48198 -246 190 14 246 190 14 246 190 14 154 114 10
48199 - 6 6 6 74 74 74 226 226 226 253 253 253
48200 -253 253 253 253 253 253 253 253 253 253 253 253
48201 -253 253 253 253 253 253 231 231 231 250 250 250
48202 -253 253 253 253 253 253 253 253 253 253 253 253
48203 -253 253 253 253 253 253 253 253 253 253 253 253
48204 -253 253 253 253 253 253 253 253 253 253 253 253
48205 -253 253 253 253 253 253 253 253 253 228 184 62
48206 -241 196 14 241 208 19 232 195 16 38 30 10
48207 - 2 2 6 2 2 6 2 2 6 2 2 6
48208 - 2 2 6 6 6 6 30 30 30 26 26 26
48209 -203 166 17 154 142 90 66 66 66 26 26 26
48210 - 6 6 6 0 0 0 0 0 0 0 0 0
48211 - 0 0 0 0 0 0 0 0 0 0 0 0
48212 - 0 0 0 0 0 0 0 0 0 0 0 0
48213 - 0 0 0 0 0 0 0 0 0 0 0 0
48214 - 0 0 0 0 0 0 0 0 0 0 0 0
48215 - 6 6 6 18 18 18 38 38 38 58 58 58
48216 - 78 78 78 86 86 86 101 101 101 123 123 123
48217 -175 146 61 210 150 10 234 174 13 246 186 14
48218 -246 190 14 246 190 14 246 190 14 238 190 10
48219 -102 78 10 2 2 6 46 46 46 198 198 198
48220 -253 253 253 253 253 253 253 253 253 253 253 253
48221 -253 253 253 253 253 253 234 234 234 242 242 242
48222 -253 253 253 253 253 253 253 253 253 253 253 253
48223 -253 253 253 253 253 253 253 253 253 253 253 253
48224 -253 253 253 253 253 253 253 253 253 253 253 253
48225 -253 253 253 253 253 253 253 253 253 224 178 62
48226 -242 186 14 241 196 14 210 166 10 22 18 6
48227 - 2 2 6 2 2 6 2 2 6 2 2 6
48228 - 2 2 6 2 2 6 6 6 6 121 92 8
48229 -238 202 15 232 195 16 82 82 82 34 34 34
48230 - 10 10 10 0 0 0 0 0 0 0 0 0
48231 - 0 0 0 0 0 0 0 0 0 0 0 0
48232 - 0 0 0 0 0 0 0 0 0 0 0 0
48233 - 0 0 0 0 0 0 0 0 0 0 0 0
48234 - 0 0 0 0 0 0 0 0 0 0 0 0
48235 - 14 14 14 38 38 38 70 70 70 154 122 46
48236 -190 142 34 200 144 11 197 138 11 197 138 11
48237 -213 154 11 226 170 11 242 186 14 246 190 14
48238 -246 190 14 246 190 14 246 190 14 246 190 14
48239 -225 175 15 46 32 6 2 2 6 22 22 22
48240 -158 158 158 250 250 250 253 253 253 253 253 253
48241 -253 253 253 253 253 253 253 253 253 253 253 253
48242 -253 253 253 253 253 253 253 253 253 253 253 253
48243 -253 253 253 253 253 253 253 253 253 253 253 253
48244 -253 253 253 253 253 253 253 253 253 253 253 253
48245 -253 253 253 250 250 250 242 242 242 224 178 62
48246 -239 182 13 236 186 11 213 154 11 46 32 6
48247 - 2 2 6 2 2 6 2 2 6 2 2 6
48248 - 2 2 6 2 2 6 61 42 6 225 175 15
48249 -238 190 10 236 186 11 112 100 78 42 42 42
48250 - 14 14 14 0 0 0 0 0 0 0 0 0
48251 - 0 0 0 0 0 0 0 0 0 0 0 0
48252 - 0 0 0 0 0 0 0 0 0 0 0 0
48253 - 0 0 0 0 0 0 0 0 0 0 0 0
48254 - 0 0 0 0 0 0 0 0 0 6 6 6
48255 - 22 22 22 54 54 54 154 122 46 213 154 11
48256 -226 170 11 230 174 11 226 170 11 226 170 11
48257 -236 178 12 242 186 14 246 190 14 246 190 14
48258 -246 190 14 246 190 14 246 190 14 246 190 14
48259 -241 196 14 184 144 12 10 10 10 2 2 6
48260 - 6 6 6 116 116 116 242 242 242 253 253 253
48261 -253 253 253 253 253 253 253 253 253 253 253 253
48262 -253 253 253 253 253 253 253 253 253 253 253 253
48263 -253 253 253 253 253 253 253 253 253 253 253 253
48264 -253 253 253 253 253 253 253 253 253 253 253 253
48265 -253 253 253 231 231 231 198 198 198 214 170 54
48266 -236 178 12 236 178 12 210 150 10 137 92 6
48267 - 18 14 6 2 2 6 2 2 6 2 2 6
48268 - 6 6 6 70 47 6 200 144 11 236 178 12
48269 -239 182 13 239 182 13 124 112 88 58 58 58
48270 - 22 22 22 6 6 6 0 0 0 0 0 0
48271 - 0 0 0 0 0 0 0 0 0 0 0 0
48272 - 0 0 0 0 0 0 0 0 0 0 0 0
48273 - 0 0 0 0 0 0 0 0 0 0 0 0
48274 - 0 0 0 0 0 0 0 0 0 10 10 10
48275 - 30 30 30 70 70 70 180 133 36 226 170 11
48276 -239 182 13 242 186 14 242 186 14 246 186 14
48277 -246 190 14 246 190 14 246 190 14 246 190 14
48278 -246 190 14 246 190 14 246 190 14 246 190 14
48279 -246 190 14 232 195 16 98 70 6 2 2 6
48280 - 2 2 6 2 2 6 66 66 66 221 221 221
48281 -253 253 253 253 253 253 253 253 253 253 253 253
48282 -253 253 253 253 253 253 253 253 253 253 253 253
48283 -253 253 253 253 253 253 253 253 253 253 253 253
48284 -253 253 253 253 253 253 253 253 253 253 253 253
48285 -253 253 253 206 206 206 198 198 198 214 166 58
48286 -230 174 11 230 174 11 216 158 10 192 133 9
48287 -163 110 8 116 81 8 102 78 10 116 81 8
48288 -167 114 7 197 138 11 226 170 11 239 182 13
48289 -242 186 14 242 186 14 162 146 94 78 78 78
48290 - 34 34 34 14 14 14 6 6 6 0 0 0
48291 - 0 0 0 0 0 0 0 0 0 0 0 0
48292 - 0 0 0 0 0 0 0 0 0 0 0 0
48293 - 0 0 0 0 0 0 0 0 0 0 0 0
48294 - 0 0 0 0 0 0 0 0 0 6 6 6
48295 - 30 30 30 78 78 78 190 142 34 226 170 11
48296 -239 182 13 246 190 14 246 190 14 246 190 14
48297 -246 190 14 246 190 14 246 190 14 246 190 14
48298 -246 190 14 246 190 14 246 190 14 246 190 14
48299 -246 190 14 241 196 14 203 166 17 22 18 6
48300 - 2 2 6 2 2 6 2 2 6 38 38 38
48301 -218 218 218 253 253 253 253 253 253 253 253 253
48302 -253 253 253 253 253 253 253 253 253 253 253 253
48303 -253 253 253 253 253 253 253 253 253 253 253 253
48304 -253 253 253 253 253 253 253 253 253 253 253 253
48305 -250 250 250 206 206 206 198 198 198 202 162 69
48306 -226 170 11 236 178 12 224 166 10 210 150 10
48307 -200 144 11 197 138 11 192 133 9 197 138 11
48308 -210 150 10 226 170 11 242 186 14 246 190 14
48309 -246 190 14 246 186 14 225 175 15 124 112 88
48310 - 62 62 62 30 30 30 14 14 14 6 6 6
48311 - 0 0 0 0 0 0 0 0 0 0 0 0
48312 - 0 0 0 0 0 0 0 0 0 0 0 0
48313 - 0 0 0 0 0 0 0 0 0 0 0 0
48314 - 0 0 0 0 0 0 0 0 0 10 10 10
48315 - 30 30 30 78 78 78 174 135 50 224 166 10
48316 -239 182 13 246 190 14 246 190 14 246 190 14
48317 -246 190 14 246 190 14 246 190 14 246 190 14
48318 -246 190 14 246 190 14 246 190 14 246 190 14
48319 -246 190 14 246 190 14 241 196 14 139 102 15
48320 - 2 2 6 2 2 6 2 2 6 2 2 6
48321 - 78 78 78 250 250 250 253 253 253 253 253 253
48322 -253 253 253 253 253 253 253 253 253 253 253 253
48323 -253 253 253 253 253 253 253 253 253 253 253 253
48324 -253 253 253 253 253 253 253 253 253 253 253 253
48325 -250 250 250 214 214 214 198 198 198 190 150 46
48326 -219 162 10 236 178 12 234 174 13 224 166 10
48327 -216 158 10 213 154 11 213 154 11 216 158 10
48328 -226 170 11 239 182 13 246 190 14 246 190 14
48329 -246 190 14 246 190 14 242 186 14 206 162 42
48330 -101 101 101 58 58 58 30 30 30 14 14 14
48331 - 6 6 6 0 0 0 0 0 0 0 0 0
48332 - 0 0 0 0 0 0 0 0 0 0 0 0
48333 - 0 0 0 0 0 0 0 0 0 0 0 0
48334 - 0 0 0 0 0 0 0 0 0 10 10 10
48335 - 30 30 30 74 74 74 174 135 50 216 158 10
48336 -236 178 12 246 190 14 246 190 14 246 190 14
48337 -246 190 14 246 190 14 246 190 14 246 190 14
48338 -246 190 14 246 190 14 246 190 14 246 190 14
48339 -246 190 14 246 190 14 241 196 14 226 184 13
48340 - 61 42 6 2 2 6 2 2 6 2 2 6
48341 - 22 22 22 238 238 238 253 253 253 253 253 253
48342 -253 253 253 253 253 253 253 253 253 253 253 253
48343 -253 253 253 253 253 253 253 253 253 253 253 253
48344 -253 253 253 253 253 253 253 253 253 253 253 253
48345 -253 253 253 226 226 226 187 187 187 180 133 36
48346 -216 158 10 236 178 12 239 182 13 236 178 12
48347 -230 174 11 226 170 11 226 170 11 230 174 11
48348 -236 178 12 242 186 14 246 190 14 246 190 14
48349 -246 190 14 246 190 14 246 186 14 239 182 13
48350 -206 162 42 106 106 106 66 66 66 34 34 34
48351 - 14 14 14 6 6 6 0 0 0 0 0 0
48352 - 0 0 0 0 0 0 0 0 0 0 0 0
48353 - 0 0 0 0 0 0 0 0 0 0 0 0
48354 - 0 0 0 0 0 0 0 0 0 6 6 6
48355 - 26 26 26 70 70 70 163 133 67 213 154 11
48356 -236 178 12 246 190 14 246 190 14 246 190 14
48357 -246 190 14 246 190 14 246 190 14 246 190 14
48358 -246 190 14 246 190 14 246 190 14 246 190 14
48359 -246 190 14 246 190 14 246 190 14 241 196 14
48360 -190 146 13 18 14 6 2 2 6 2 2 6
48361 - 46 46 46 246 246 246 253 253 253 253 253 253
48362 -253 253 253 253 253 253 253 253 253 253 253 253
48363 -253 253 253 253 253 253 253 253 253 253 253 253
48364 -253 253 253 253 253 253 253 253 253 253 253 253
48365 -253 253 253 221 221 221 86 86 86 156 107 11
48366 -216 158 10 236 178 12 242 186 14 246 186 14
48367 -242 186 14 239 182 13 239 182 13 242 186 14
48368 -242 186 14 246 186 14 246 190 14 246 190 14
48369 -246 190 14 246 190 14 246 190 14 246 190 14
48370 -242 186 14 225 175 15 142 122 72 66 66 66
48371 - 30 30 30 10 10 10 0 0 0 0 0 0
48372 - 0 0 0 0 0 0 0 0 0 0 0 0
48373 - 0 0 0 0 0 0 0 0 0 0 0 0
48374 - 0 0 0 0 0 0 0 0 0 6 6 6
48375 - 26 26 26 70 70 70 163 133 67 210 150 10
48376 -236 178 12 246 190 14 246 190 14 246 190 14
48377 -246 190 14 246 190 14 246 190 14 246 190 14
48378 -246 190 14 246 190 14 246 190 14 246 190 14
48379 -246 190 14 246 190 14 246 190 14 246 190 14
48380 -232 195 16 121 92 8 34 34 34 106 106 106
48381 -221 221 221 253 253 253 253 253 253 253 253 253
48382 -253 253 253 253 253 253 253 253 253 253 253 253
48383 -253 253 253 253 253 253 253 253 253 253 253 253
48384 -253 253 253 253 253 253 253 253 253 253 253 253
48385 -242 242 242 82 82 82 18 14 6 163 110 8
48386 -216 158 10 236 178 12 242 186 14 246 190 14
48387 -246 190 14 246 190 14 246 190 14 246 190 14
48388 -246 190 14 246 190 14 246 190 14 246 190 14
48389 -246 190 14 246 190 14 246 190 14 246 190 14
48390 -246 190 14 246 190 14 242 186 14 163 133 67
48391 - 46 46 46 18 18 18 6 6 6 0 0 0
48392 - 0 0 0 0 0 0 0 0 0 0 0 0
48393 - 0 0 0 0 0 0 0 0 0 0 0 0
48394 - 0 0 0 0 0 0 0 0 0 10 10 10
48395 - 30 30 30 78 78 78 163 133 67 210 150 10
48396 -236 178 12 246 186 14 246 190 14 246 190 14
48397 -246 190 14 246 190 14 246 190 14 246 190 14
48398 -246 190 14 246 190 14 246 190 14 246 190 14
48399 -246 190 14 246 190 14 246 190 14 246 190 14
48400 -241 196 14 215 174 15 190 178 144 253 253 253
48401 -253 253 253 253 253 253 253 253 253 253 253 253
48402 -253 253 253 253 253 253 253 253 253 253 253 253
48403 -253 253 253 253 253 253 253 253 253 253 253 253
48404 -253 253 253 253 253 253 253 253 253 218 218 218
48405 - 58 58 58 2 2 6 22 18 6 167 114 7
48406 -216 158 10 236 178 12 246 186 14 246 190 14
48407 -246 190 14 246 190 14 246 190 14 246 190 14
48408 -246 190 14 246 190 14 246 190 14 246 190 14
48409 -246 190 14 246 190 14 246 190 14 246 190 14
48410 -246 190 14 246 186 14 242 186 14 190 150 46
48411 - 54 54 54 22 22 22 6 6 6 0 0 0
48412 - 0 0 0 0 0 0 0 0 0 0 0 0
48413 - 0 0 0 0 0 0 0 0 0 0 0 0
48414 - 0 0 0 0 0 0 0 0 0 14 14 14
48415 - 38 38 38 86 86 86 180 133 36 213 154 11
48416 -236 178 12 246 186 14 246 190 14 246 190 14
48417 -246 190 14 246 190 14 246 190 14 246 190 14
48418 -246 190 14 246 190 14 246 190 14 246 190 14
48419 -246 190 14 246 190 14 246 190 14 246 190 14
48420 -246 190 14 232 195 16 190 146 13 214 214 214
48421 -253 253 253 253 253 253 253 253 253 253 253 253
48422 -253 253 253 253 253 253 253 253 253 253 253 253
48423 -253 253 253 253 253 253 253 253 253 253 253 253
48424 -253 253 253 250 250 250 170 170 170 26 26 26
48425 - 2 2 6 2 2 6 37 26 9 163 110 8
48426 -219 162 10 239 182 13 246 186 14 246 190 14
48427 -246 190 14 246 190 14 246 190 14 246 190 14
48428 -246 190 14 246 190 14 246 190 14 246 190 14
48429 -246 190 14 246 190 14 246 190 14 246 190 14
48430 -246 186 14 236 178 12 224 166 10 142 122 72
48431 - 46 46 46 18 18 18 6 6 6 0 0 0
48432 - 0 0 0 0 0 0 0 0 0 0 0 0
48433 - 0 0 0 0 0 0 0 0 0 0 0 0
48434 - 0 0 0 0 0 0 6 6 6 18 18 18
48435 - 50 50 50 109 106 95 192 133 9 224 166 10
48436 -242 186 14 246 190 14 246 190 14 246 190 14
48437 -246 190 14 246 190 14 246 190 14 246 190 14
48438 -246 190 14 246 190 14 246 190 14 246 190 14
48439 -246 190 14 246 190 14 246 190 14 246 190 14
48440 -242 186 14 226 184 13 210 162 10 142 110 46
48441 -226 226 226 253 253 253 253 253 253 253 253 253
48442 -253 253 253 253 253 253 253 253 253 253 253 253
48443 -253 253 253 253 253 253 253 253 253 253 253 253
48444 -198 198 198 66 66 66 2 2 6 2 2 6
48445 - 2 2 6 2 2 6 50 34 6 156 107 11
48446 -219 162 10 239 182 13 246 186 14 246 190 14
48447 -246 190 14 246 190 14 246 190 14 246 190 14
48448 -246 190 14 246 190 14 246 190 14 246 190 14
48449 -246 190 14 246 190 14 246 190 14 242 186 14
48450 -234 174 13 213 154 11 154 122 46 66 66 66
48451 - 30 30 30 10 10 10 0 0 0 0 0 0
48452 - 0 0 0 0 0 0 0 0 0 0 0 0
48453 - 0 0 0 0 0 0 0 0 0 0 0 0
48454 - 0 0 0 0 0 0 6 6 6 22 22 22
48455 - 58 58 58 154 121 60 206 145 10 234 174 13
48456 -242 186 14 246 186 14 246 190 14 246 190 14
48457 -246 190 14 246 190 14 246 190 14 246 190 14
48458 -246 190 14 246 190 14 246 190 14 246 190 14
48459 -246 190 14 246 190 14 246 190 14 246 190 14
48460 -246 186 14 236 178 12 210 162 10 163 110 8
48461 - 61 42 6 138 138 138 218 218 218 250 250 250
48462 -253 253 253 253 253 253 253 253 253 250 250 250
48463 -242 242 242 210 210 210 144 144 144 66 66 66
48464 - 6 6 6 2 2 6 2 2 6 2 2 6
48465 - 2 2 6 2 2 6 61 42 6 163 110 8
48466 -216 158 10 236 178 12 246 190 14 246 190 14
48467 -246 190 14 246 190 14 246 190 14 246 190 14
48468 -246 190 14 246 190 14 246 190 14 246 190 14
48469 -246 190 14 239 182 13 230 174 11 216 158 10
48470 -190 142 34 124 112 88 70 70 70 38 38 38
48471 - 18 18 18 6 6 6 0 0 0 0 0 0
48472 - 0 0 0 0 0 0 0 0 0 0 0 0
48473 - 0 0 0 0 0 0 0 0 0 0 0 0
48474 - 0 0 0 0 0 0 6 6 6 22 22 22
48475 - 62 62 62 168 124 44 206 145 10 224 166 10
48476 -236 178 12 239 182 13 242 186 14 242 186 14
48477 -246 186 14 246 190 14 246 190 14 246 190 14
48478 -246 190 14 246 190 14 246 190 14 246 190 14
48479 -246 190 14 246 190 14 246 190 14 246 190 14
48480 -246 190 14 236 178 12 216 158 10 175 118 6
48481 - 80 54 7 2 2 6 6 6 6 30 30 30
48482 - 54 54 54 62 62 62 50 50 50 38 38 38
48483 - 14 14 14 2 2 6 2 2 6 2 2 6
48484 - 2 2 6 2 2 6 2 2 6 2 2 6
48485 - 2 2 6 6 6 6 80 54 7 167 114 7
48486 -213 154 11 236 178 12 246 190 14 246 190 14
48487 -246 190 14 246 190 14 246 190 14 246 190 14
48488 -246 190 14 242 186 14 239 182 13 239 182 13
48489 -230 174 11 210 150 10 174 135 50 124 112 88
48490 - 82 82 82 54 54 54 34 34 34 18 18 18
48491 - 6 6 6 0 0 0 0 0 0 0 0 0
48492 - 0 0 0 0 0 0 0 0 0 0 0 0
48493 - 0 0 0 0 0 0 0 0 0 0 0 0
48494 - 0 0 0 0 0 0 6 6 6 18 18 18
48495 - 50 50 50 158 118 36 192 133 9 200 144 11
48496 -216 158 10 219 162 10 224 166 10 226 170 11
48497 -230 174 11 236 178 12 239 182 13 239 182 13
48498 -242 186 14 246 186 14 246 190 14 246 190 14
48499 -246 190 14 246 190 14 246 190 14 246 190 14
48500 -246 186 14 230 174 11 210 150 10 163 110 8
48501 -104 69 6 10 10 10 2 2 6 2 2 6
48502 - 2 2 6 2 2 6 2 2 6 2 2 6
48503 - 2 2 6 2 2 6 2 2 6 2 2 6
48504 - 2 2 6 2 2 6 2 2 6 2 2 6
48505 - 2 2 6 6 6 6 91 60 6 167 114 7
48506 -206 145 10 230 174 11 242 186 14 246 190 14
48507 -246 190 14 246 190 14 246 186 14 242 186 14
48508 -239 182 13 230 174 11 224 166 10 213 154 11
48509 -180 133 36 124 112 88 86 86 86 58 58 58
48510 - 38 38 38 22 22 22 10 10 10 6 6 6
48511 - 0 0 0 0 0 0 0 0 0 0 0 0
48512 - 0 0 0 0 0 0 0 0 0 0 0 0
48513 - 0 0 0 0 0 0 0 0 0 0 0 0
48514 - 0 0 0 0 0 0 0 0 0 14 14 14
48515 - 34 34 34 70 70 70 138 110 50 158 118 36
48516 -167 114 7 180 123 7 192 133 9 197 138 11
48517 -200 144 11 206 145 10 213 154 11 219 162 10
48518 -224 166 10 230 174 11 239 182 13 242 186 14
48519 -246 186 14 246 186 14 246 186 14 246 186 14
48520 -239 182 13 216 158 10 185 133 11 152 99 6
48521 -104 69 6 18 14 6 2 2 6 2 2 6
48522 - 2 2 6 2 2 6 2 2 6 2 2 6
48523 - 2 2 6 2 2 6 2 2 6 2 2 6
48524 - 2 2 6 2 2 6 2 2 6 2 2 6
48525 - 2 2 6 6 6 6 80 54 7 152 99 6
48526 -192 133 9 219 162 10 236 178 12 239 182 13
48527 -246 186 14 242 186 14 239 182 13 236 178 12
48528 -224 166 10 206 145 10 192 133 9 154 121 60
48529 - 94 94 94 62 62 62 42 42 42 22 22 22
48530 - 14 14 14 6 6 6 0 0 0 0 0 0
48531 - 0 0 0 0 0 0 0 0 0 0 0 0
48532 - 0 0 0 0 0 0 0 0 0 0 0 0
48533 - 0 0 0 0 0 0 0 0 0 0 0 0
48534 - 0 0 0 0 0 0 0 0 0 6 6 6
48535 - 18 18 18 34 34 34 58 58 58 78 78 78
48536 -101 98 89 124 112 88 142 110 46 156 107 11
48537 -163 110 8 167 114 7 175 118 6 180 123 7
48538 -185 133 11 197 138 11 210 150 10 219 162 10
48539 -226 170 11 236 178 12 236 178 12 234 174 13
48540 -219 162 10 197 138 11 163 110 8 130 83 6
48541 - 91 60 6 10 10 10 2 2 6 2 2 6
48542 - 18 18 18 38 38 38 38 38 38 38 38 38
48543 - 38 38 38 38 38 38 38 38 38 38 38 38
48544 - 38 38 38 38 38 38 26 26 26 2 2 6
48545 - 2 2 6 6 6 6 70 47 6 137 92 6
48546 -175 118 6 200 144 11 219 162 10 230 174 11
48547 -234 174 13 230 174 11 219 162 10 210 150 10
48548 -192 133 9 163 110 8 124 112 88 82 82 82
48549 - 50 50 50 30 30 30 14 14 14 6 6 6
48550 - 0 0 0 0 0 0 0 0 0 0 0 0
48551 - 0 0 0 0 0 0 0 0 0 0 0 0
48552 - 0 0 0 0 0 0 0 0 0 0 0 0
48553 - 0 0 0 0 0 0 0 0 0 0 0 0
48554 - 0 0 0 0 0 0 0 0 0 0 0 0
48555 - 6 6 6 14 14 14 22 22 22 34 34 34
48556 - 42 42 42 58 58 58 74 74 74 86 86 86
48557 -101 98 89 122 102 70 130 98 46 121 87 25
48558 -137 92 6 152 99 6 163 110 8 180 123 7
48559 -185 133 11 197 138 11 206 145 10 200 144 11
48560 -180 123 7 156 107 11 130 83 6 104 69 6
48561 - 50 34 6 54 54 54 110 110 110 101 98 89
48562 - 86 86 86 82 82 82 78 78 78 78 78 78
48563 - 78 78 78 78 78 78 78 78 78 78 78 78
48564 - 78 78 78 82 82 82 86 86 86 94 94 94
48565 -106 106 106 101 101 101 86 66 34 124 80 6
48566 -156 107 11 180 123 7 192 133 9 200 144 11
48567 -206 145 10 200 144 11 192 133 9 175 118 6
48568 -139 102 15 109 106 95 70 70 70 42 42 42
48569 - 22 22 22 10 10 10 0 0 0 0 0 0
48570 - 0 0 0 0 0 0 0 0 0 0 0 0
48571 - 0 0 0 0 0 0 0 0 0 0 0 0
48572 - 0 0 0 0 0 0 0 0 0 0 0 0
48573 - 0 0 0 0 0 0 0 0 0 0 0 0
48574 - 0 0 0 0 0 0 0 0 0 0 0 0
48575 - 0 0 0 0 0 0 6 6 6 10 10 10
48576 - 14 14 14 22 22 22 30 30 30 38 38 38
48577 - 50 50 50 62 62 62 74 74 74 90 90 90
48578 -101 98 89 112 100 78 121 87 25 124 80 6
48579 -137 92 6 152 99 6 152 99 6 152 99 6
48580 -138 86 6 124 80 6 98 70 6 86 66 30
48581 -101 98 89 82 82 82 58 58 58 46 46 46
48582 - 38 38 38 34 34 34 34 34 34 34 34 34
48583 - 34 34 34 34 34 34 34 34 34 34 34 34
48584 - 34 34 34 34 34 34 38 38 38 42 42 42
48585 - 54 54 54 82 82 82 94 86 76 91 60 6
48586 -134 86 6 156 107 11 167 114 7 175 118 6
48587 -175 118 6 167 114 7 152 99 6 121 87 25
48588 -101 98 89 62 62 62 34 34 34 18 18 18
48589 - 6 6 6 0 0 0 0 0 0 0 0 0
48590 - 0 0 0 0 0 0 0 0 0 0 0 0
48591 - 0 0 0 0 0 0 0 0 0 0 0 0
48592 - 0 0 0 0 0 0 0 0 0 0 0 0
48593 - 0 0 0 0 0 0 0 0 0 0 0 0
48594 - 0 0 0 0 0 0 0 0 0 0 0 0
48595 - 0 0 0 0 0 0 0 0 0 0 0 0
48596 - 0 0 0 6 6 6 6 6 6 10 10 10
48597 - 18 18 18 22 22 22 30 30 30 42 42 42
48598 - 50 50 50 66 66 66 86 86 86 101 98 89
48599 -106 86 58 98 70 6 104 69 6 104 69 6
48600 -104 69 6 91 60 6 82 62 34 90 90 90
48601 - 62 62 62 38 38 38 22 22 22 14 14 14
48602 - 10 10 10 10 10 10 10 10 10 10 10 10
48603 - 10 10 10 10 10 10 6 6 6 10 10 10
48604 - 10 10 10 10 10 10 10 10 10 14 14 14
48605 - 22 22 22 42 42 42 70 70 70 89 81 66
48606 - 80 54 7 104 69 6 124 80 6 137 92 6
48607 -134 86 6 116 81 8 100 82 52 86 86 86
48608 - 58 58 58 30 30 30 14 14 14 6 6 6
48609 - 0 0 0 0 0 0 0 0 0 0 0 0
48610 - 0 0 0 0 0 0 0 0 0 0 0 0
48611 - 0 0 0 0 0 0 0 0 0 0 0 0
48612 - 0 0 0 0 0 0 0 0 0 0 0 0
48613 - 0 0 0 0 0 0 0 0 0 0 0 0
48614 - 0 0 0 0 0 0 0 0 0 0 0 0
48615 - 0 0 0 0 0 0 0 0 0 0 0 0
48616 - 0 0 0 0 0 0 0 0 0 0 0 0
48617 - 0 0 0 6 6 6 10 10 10 14 14 14
48618 - 18 18 18 26 26 26 38 38 38 54 54 54
48619 - 70 70 70 86 86 86 94 86 76 89 81 66
48620 - 89 81 66 86 86 86 74 74 74 50 50 50
48621 - 30 30 30 14 14 14 6 6 6 0 0 0
48622 - 0 0 0 0 0 0 0 0 0 0 0 0
48623 - 0 0 0 0 0 0 0 0 0 0 0 0
48624 - 0 0 0 0 0 0 0 0 0 0 0 0
48625 - 6 6 6 18 18 18 34 34 34 58 58 58
48626 - 82 82 82 89 81 66 89 81 66 89 81 66
48627 - 94 86 66 94 86 76 74 74 74 50 50 50
48628 - 26 26 26 14 14 14 6 6 6 0 0 0
48629 - 0 0 0 0 0 0 0 0 0 0 0 0
48630 - 0 0 0 0 0 0 0 0 0 0 0 0
48631 - 0 0 0 0 0 0 0 0 0 0 0 0
48632 - 0 0 0 0 0 0 0 0 0 0 0 0
48633 - 0 0 0 0 0 0 0 0 0 0 0 0
48634 - 0 0 0 0 0 0 0 0 0 0 0 0
48635 - 0 0 0 0 0 0 0 0 0 0 0 0
48636 - 0 0 0 0 0 0 0 0 0 0 0 0
48637 - 0 0 0 0 0 0 0 0 0 0 0 0
48638 - 6 6 6 6 6 6 14 14 14 18 18 18
48639 - 30 30 30 38 38 38 46 46 46 54 54 54
48640 - 50 50 50 42 42 42 30 30 30 18 18 18
48641 - 10 10 10 0 0 0 0 0 0 0 0 0
48642 - 0 0 0 0 0 0 0 0 0 0 0 0
48643 - 0 0 0 0 0 0 0 0 0 0 0 0
48644 - 0 0 0 0 0 0 0 0 0 0 0 0
48645 - 0 0 0 6 6 6 14 14 14 26 26 26
48646 - 38 38 38 50 50 50 58 58 58 58 58 58
48647 - 54 54 54 42 42 42 30 30 30 18 18 18
48648 - 10 10 10 0 0 0 0 0 0 0 0 0
48649 - 0 0 0 0 0 0 0 0 0 0 0 0
48650 - 0 0 0 0 0 0 0 0 0 0 0 0
48651 - 0 0 0 0 0 0 0 0 0 0 0 0
48652 - 0 0 0 0 0 0 0 0 0 0 0 0
48653 - 0 0 0 0 0 0 0 0 0 0 0 0
48654 - 0 0 0 0 0 0 0 0 0 0 0 0
48655 - 0 0 0 0 0 0 0 0 0 0 0 0
48656 - 0 0 0 0 0 0 0 0 0 0 0 0
48657 - 0 0 0 0 0 0 0 0 0 0 0 0
48658 - 0 0 0 0 0 0 0 0 0 6 6 6
48659 - 6 6 6 10 10 10 14 14 14 18 18 18
48660 - 18 18 18 14 14 14 10 10 10 6 6 6
48661 - 0 0 0 0 0 0 0 0 0 0 0 0
48662 - 0 0 0 0 0 0 0 0 0 0 0 0
48663 - 0 0 0 0 0 0 0 0 0 0 0 0
48664 - 0 0 0 0 0 0 0 0 0 0 0 0
48665 - 0 0 0 0 0 0 0 0 0 6 6 6
48666 - 14 14 14 18 18 18 22 22 22 22 22 22
48667 - 18 18 18 14 14 14 10 10 10 6 6 6
48668 - 0 0 0 0 0 0 0 0 0 0 0 0
48669 - 0 0 0 0 0 0 0 0 0 0 0 0
48670 - 0 0 0 0 0 0 0 0 0 0 0 0
48671 - 0 0 0 0 0 0 0 0 0 0 0 0
48672 - 0 0 0 0 0 0 0 0 0 0 0 0
48673 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48674 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48675 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48676 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48677 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48678 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48679 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48680 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48681 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48682 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48683 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48684 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48685 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48686 +4 4 4 4 4 4
48687 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48688 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48689 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48690 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48691 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48692 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48693 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48694 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48695 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48696 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48697 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48698 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48699 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48700 +4 4 4 4 4 4
48701 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48702 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48703 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48704 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48705 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48706 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48707 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48708 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48709 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48710 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48711 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48712 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48713 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48714 +4 4 4 4 4 4
48715 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48716 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48717 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48718 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48719 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48720 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48721 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48722 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48723 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48724 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48725 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48726 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48727 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48728 +4 4 4 4 4 4
48729 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48730 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48731 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48732 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48733 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48734 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48735 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48736 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48737 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48738 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48739 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48740 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48741 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48742 +4 4 4 4 4 4
48743 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48744 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48745 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48746 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48747 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48748 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48749 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48750 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48751 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48752 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48753 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48754 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48755 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48756 +4 4 4 4 4 4
48757 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48758 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48759 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48760 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48761 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
48762 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
48763 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48764 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48765 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48766 +4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
48767 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
48768 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
48769 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48770 +4 4 4 4 4 4
48771 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48772 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48773 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48774 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48775 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
48776 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
48777 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48778 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48779 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48780 +4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
48781 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
48782 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
48783 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48784 +4 4 4 4 4 4
48785 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48786 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48787 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48788 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48789 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
48790 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
48791 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
48792 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48793 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48794 +4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
48795 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
48796 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
48797 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
48798 +4 4 4 4 4 4
48799 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48800 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48801 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48802 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
48803 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
48804 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
48805 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
48806 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48807 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
48808 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
48809 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
48810 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
48811 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
48812 +4 4 4 4 4 4
48813 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48814 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48815 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48816 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
48817 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
48818 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
48819 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
48820 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
48821 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
48822 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
48823 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
48824 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
48825 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
48826 +4 4 4 4 4 4
48827 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48828 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48829 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
48830 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
48831 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
48832 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
48833 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
48834 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
48835 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
48836 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
48837 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
48838 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
48839 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
48840 +4 4 4 4 4 4
48841 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48842 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48843 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
48844 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
48845 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
48846 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
48847 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
48848 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
48849 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
48850 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
48851 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
48852 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
48853 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
48854 +4 4 4 4 4 4
48855 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48856 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48857 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
48858 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
48859 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
48860 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
48861 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
48862 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
48863 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
48864 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
48865 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
48866 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
48867 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
48868 +4 4 4 4 4 4
48869 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48870 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48871 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
48872 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
48873 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
48874 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
48875 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
48876 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
48877 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
48878 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
48879 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
48880 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
48881 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
48882 +4 4 4 4 4 4
48883 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48884 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48885 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
48886 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
48887 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
48888 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
48889 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
48890 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
48891 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
48892 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
48893 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
48894 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
48895 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
48896 +4 4 4 4 4 4
48897 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48898 +4 4 4 4 4 4 4 4 4 4 4 4 3 3 3 0 0 0
48899 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
48900 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
48901 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
48902 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
48903 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
48904 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
48905 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
48906 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
48907 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
48908 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
48909 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
48910 +4 4 4 4 4 4
48911 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
48912 +4 4 4 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
48913 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
48914 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
48915 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
48916 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
48917 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
48918 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
48919 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
48920 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
48921 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
48922 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
48923 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
48924 +0 0 0 4 4 4
48925 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
48926 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
48927 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
48928 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
48929 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
48930 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
48931 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
48932 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
48933 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
48934 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
48935 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
48936 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
48937 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
48938 +2 0 0 0 0 0
48939 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
48940 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
48941 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
48942 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
48943 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
48944 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
48945 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
48946 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
48947 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
48948 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
48949 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
48950 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
48951 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
48952 +37 38 37 0 0 0
48953 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
48954 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
48955 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
48956 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
48957 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
48958 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
48959 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
48960 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
48961 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
48962 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
48963 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
48964 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
48965 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
48966 +85 115 134 4 0 0
48967 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
48968 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
48969 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
48970 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
48971 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
48972 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
48973 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
48974 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
48975 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
48976 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
48977 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
48978 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
48979 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
48980 +60 73 81 4 0 0
48981 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
48982 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
48983 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
48984 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
48985 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
48986 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
48987 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
48988 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
48989 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
48990 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
48991 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
48992 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
48993 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
48994 +16 19 21 4 0 0
48995 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
48996 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
48997 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
48998 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
48999 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
49000 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
49001 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
49002 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
49003 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
49004 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
49005 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
49006 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
49007 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
49008 +4 0 0 4 3 3
49009 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
49010 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
49011 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
49012 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
49013 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
49014 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
49015 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
49016 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
49017 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
49018 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
49019 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
49020 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
49021 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
49022 +3 2 2 4 4 4
49023 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
49024 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
49025 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
49026 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
49027 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
49028 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
49029 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
49030 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
49031 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
49032 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
49033 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
49034 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
49035 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
49036 +4 4 4 4 4 4
49037 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
49038 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
49039 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
49040 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
49041 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
49042 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
49043 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
49044 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
49045 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
49046 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
49047 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
49048 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
49049 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
49050 +4 4 4 4 4 4
49051 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
49052 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
49053 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
49054 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
49055 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
49056 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
49057 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
49058 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
49059 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
49060 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
49061 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
49062 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
49063 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
49064 +5 5 5 5 5 5
49065 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
49066 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
49067 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
49068 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
49069 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
49070 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
49071 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
49072 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
49073 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
49074 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
49075 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
49076 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
49077 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
49078 +5 5 5 4 4 4
49079 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
49080 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
49081 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
49082 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
49083 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
49084 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
49085 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
49086 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
49087 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
49088 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
49089 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
49090 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
49091 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49092 +4 4 4 4 4 4
49093 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
49094 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
49095 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
49096 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
49097 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
49098 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
49099 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
49100 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
49101 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
49102 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
49103 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
49104 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
49105 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49106 +4 4 4 4 4 4
49107 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
49108 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
49109 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
49110 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
49111 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
49112 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
49113 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
49114 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
49115 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
49116 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
49117 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
49118 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49119 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49120 +4 4 4 4 4 4
49121 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
49122 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
49123 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
49124 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
49125 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
49126 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
49127 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
49128 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
49129 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
49130 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
49131 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
49132 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49133 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49134 +4 4 4 4 4 4
49135 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
49136 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
49137 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
49138 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
49139 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
49140 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
49141 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
49142 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
49143 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
49144 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
49145 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49146 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49147 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49148 +4 4 4 4 4 4
49149 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
49150 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
49151 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
49152 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
49153 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
49154 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
49155 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
49156 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
49157 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
49158 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
49159 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
49160 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49161 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49162 +4 4 4 4 4 4
49163 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
49164 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
49165 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
49166 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
49167 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
49168 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
49169 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
49170 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
49171 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
49172 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
49173 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
49174 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49175 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49176 +4 4 4 4 4 4
49177 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
49178 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
49179 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
49180 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
49181 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
49182 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
49183 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
49184 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
49185 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
49186 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
49187 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49188 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49189 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49190 +4 4 4 4 4 4
49191 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
49192 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
49193 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
49194 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
49195 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
49196 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
49197 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
49198 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
49199 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
49200 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
49201 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49202 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49203 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49204 +4 4 4 4 4 4
49205 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
49206 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
49207 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
49208 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
49209 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
49210 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
49211 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
49212 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
49213 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
49214 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
49215 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49216 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49217 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49218 +4 4 4 4 4 4
49219 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
49220 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
49221 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
49222 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
49223 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
49224 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
49225 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
49226 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
49227 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
49228 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
49229 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49230 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49231 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49232 +4 4 4 4 4 4
49233 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
49234 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
49235 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
49236 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
49237 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
49238 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
49239 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
49240 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
49241 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
49242 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
49243 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49244 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49245 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49246 +4 4 4 4 4 4
49247 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
49248 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
49249 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
49250 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
49251 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
49252 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
49253 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
49254 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
49255 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
49256 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
49257 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49258 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49259 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49260 +4 4 4 4 4 4
49261 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
49262 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
49263 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
49264 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
49265 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
49266 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
49267 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
49268 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
49269 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
49270 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
49271 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49272 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49273 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49274 +4 4 4 4 4 4
49275 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
49276 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
49277 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
49278 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
49279 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
49280 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
49281 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
49282 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
49283 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
49284 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
49285 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49286 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49287 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49288 +4 4 4 4 4 4
49289 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
49290 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
49291 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
49292 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
49293 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
49294 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
49295 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
49296 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
49297 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
49298 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
49299 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49300 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49301 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49302 +4 4 4 4 4 4
49303 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
49304 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
49305 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
49306 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
49307 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
49308 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
49309 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
49310 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
49311 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
49312 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
49313 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49314 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49315 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49316 +4 4 4 4 4 4
49317 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
49318 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
49319 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
49320 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
49321 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
49322 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
49323 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
49324 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
49325 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
49326 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
49327 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49328 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49329 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49330 +4 4 4 4 4 4
49331 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
49332 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
49333 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
49334 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
49335 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
49336 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
49337 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
49338 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
49339 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
49340 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
49341 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49342 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49343 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49344 +4 4 4 4 4 4
49345 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
49346 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
49347 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
49348 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
49349 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
49350 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
49351 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
49352 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
49353 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
49354 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
49355 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49356 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49357 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49358 +4 4 4 4 4 4
49359 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
49360 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
49361 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
49362 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
49363 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
49364 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
49365 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
49366 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
49367 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
49368 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
49369 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49370 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49371 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49372 +4 4 4 4 4 4
49373 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
49374 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
49375 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
49376 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
49377 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
49378 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
49379 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
49380 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
49381 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
49382 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
49383 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49384 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49385 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49386 +4 4 4 4 4 4
49387 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
49388 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
49389 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
49390 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
49391 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
49392 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
49393 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
49394 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
49395 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
49396 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
49397 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49398 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49399 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49400 +4 4 4 4 4 4
49401 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
49402 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
49403 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
49404 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
49405 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
49406 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
49407 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
49408 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
49409 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
49410 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
49411 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49412 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49413 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49414 +4 4 4 4 4 4
49415 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
49416 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
49417 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
49418 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
49419 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
49420 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
49421 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
49422 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
49423 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
49424 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
49425 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49426 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49427 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49428 +4 4 4 4 4 4
49429 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
49430 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
49431 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
49432 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
49433 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
49434 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
49435 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
49436 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
49437 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
49438 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
49439 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49440 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49441 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49442 +4 4 4 4 4 4
49443 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
49444 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
49445 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
49446 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
49447 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
49448 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
49449 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
49450 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
49451 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
49452 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
49453 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49454 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49455 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49456 +4 4 4 4 4 4
49457 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
49458 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
49459 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
49460 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
49461 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
49462 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
49463 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49464 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
49465 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
49466 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
49467 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
49468 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49469 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49470 +4 4 4 4 4 4
49471 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
49472 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
49473 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
49474 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
49475 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
49476 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
49477 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
49478 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
49479 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
49480 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
49481 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49482 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49483 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49484 +4 4 4 4 4 4
49485 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
49486 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
49487 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
49488 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
49489 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
49490 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
49491 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
49492 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
49493 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
49494 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
49495 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49496 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49497 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49498 +4 4 4 4 4 4
49499 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
49500 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
49501 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
49502 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
49503 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
49504 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
49505 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
49506 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
49507 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
49508 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
49509 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49510 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49511 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49512 +4 4 4 4 4 4
49513 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
49514 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
49515 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
49516 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
49517 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
49518 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
49519 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
49520 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
49521 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
49522 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
49523 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49524 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49525 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49526 +4 4 4 4 4 4
49527 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
49528 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
49529 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
49530 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
49531 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
49532 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
49533 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
49534 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
49535 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
49536 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
49537 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49538 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49539 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49540 +4 4 4 4 4 4
49541 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
49542 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
49543 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
49544 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
49545 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
49546 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
49547 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
49548 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
49549 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
49550 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49551 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49552 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49553 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49554 +4 4 4 4 4 4
49555 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
49556 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
49557 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
49558 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
49559 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
49560 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
49561 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
49562 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
49563 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
49564 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49565 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49566 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49567 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49568 +4 4 4 4 4 4
49569 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
49570 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
49571 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
49572 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
49573 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
49574 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
49575 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
49576 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
49577 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49578 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49579 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49580 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49581 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49582 +4 4 4 4 4 4
49583 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
49584 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
49585 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
49586 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
49587 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
49588 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
49589 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
49590 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
49591 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49592 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49593 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49594 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49595 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49596 +4 4 4 4 4 4
49597 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
49598 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
49599 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
49600 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
49601 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
49602 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
49603 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
49604 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
49605 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49606 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49607 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49608 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49609 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49610 +4 4 4 4 4 4
49611 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
49612 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
49613 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
49614 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
49615 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
49616 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
49617 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
49618 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
49619 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49620 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49621 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49622 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49623 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49624 +4 4 4 4 4 4
49625 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49626 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
49627 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
49628 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
49629 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
49630 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
49631 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
49632 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
49633 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49634 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49635 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49636 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49637 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49638 +4 4 4 4 4 4
49639 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49640 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
49641 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
49642 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
49643 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
49644 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
49645 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
49646 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
49647 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49648 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49649 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49650 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49651 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49652 +4 4 4 4 4 4
49653 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49654 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49655 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
49656 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
49657 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
49658 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
49659 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
49660 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
49661 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49662 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49663 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49664 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49665 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49666 +4 4 4 4 4 4
49667 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49668 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49669 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
49670 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
49671 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
49672 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
49673 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
49674 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49675 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49676 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49677 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49678 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49679 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49680 +4 4 4 4 4 4
49681 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49682 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49683 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49684 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
49685 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
49686 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
49687 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
49688 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49689 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49690 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49691 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49692 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49693 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49694 +4 4 4 4 4 4
49695 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49696 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49697 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49698 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
49699 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
49700 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
49701 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
49702 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49703 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49704 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49705 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49706 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49707 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49708 +4 4 4 4 4 4
49709 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49710 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49711 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49712 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
49713 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
49714 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
49715 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
49716 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49717 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49718 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49719 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49720 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49721 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49722 +4 4 4 4 4 4
49723 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49724 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49725 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49726 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
49727 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
49728 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
49729 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
49730 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49731 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49732 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49733 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49734 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49735 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49736 +4 4 4 4 4 4
49737 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49738 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49739 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49740 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49741 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
49742 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
49743 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
49744 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49745 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49746 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49747 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49748 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49749 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49750 +4 4 4 4 4 4
49751 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49752 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49753 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49754 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49755 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
49756 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
49757 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49758 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49759 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49760 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49761 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49762 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49763 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49764 +4 4 4 4 4 4
49765 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49766 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49767 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49768 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49769 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
49770 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
49771 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49772 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49773 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49774 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49775 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49776 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49777 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49778 +4 4 4 4 4 4
49779 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49780 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49781 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49782 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49783 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
49784 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
49785 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49786 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49787 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49788 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49789 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49790 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49791 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
49792 +4 4 4 4 4 4
49793 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
49794 index fe92eed..106e085 100644
49795 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
49796 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
49797 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
49798 struct mb862xxfb_par *par = info->par;
49799
49800 if (info->var.bits_per_pixel == 32) {
49801 - info->fbops->fb_fillrect = cfb_fillrect;
49802 - info->fbops->fb_copyarea = cfb_copyarea;
49803 - info->fbops->fb_imageblit = cfb_imageblit;
49804 + pax_open_kernel();
49805 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
49806 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
49807 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
49808 + pax_close_kernel();
49809 } else {
49810 outreg(disp, GC_L0EM, 3);
49811 - info->fbops->fb_fillrect = mb86290fb_fillrect;
49812 - info->fbops->fb_copyarea = mb86290fb_copyarea;
49813 - info->fbops->fb_imageblit = mb86290fb_imageblit;
49814 + pax_open_kernel();
49815 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
49816 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
49817 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
49818 + pax_close_kernel();
49819 }
49820 outreg(draw, GDC_REG_DRAW_BASE, 0);
49821 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
49822 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
49823 index ff22871..b129bed 100644
49824 --- a/drivers/video/nvidia/nvidia.c
49825 +++ b/drivers/video/nvidia/nvidia.c
49826 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
49827 info->fix.line_length = (info->var.xres_virtual *
49828 info->var.bits_per_pixel) >> 3;
49829 if (info->var.accel_flags) {
49830 - info->fbops->fb_imageblit = nvidiafb_imageblit;
49831 - info->fbops->fb_fillrect = nvidiafb_fillrect;
49832 - info->fbops->fb_copyarea = nvidiafb_copyarea;
49833 - info->fbops->fb_sync = nvidiafb_sync;
49834 + pax_open_kernel();
49835 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
49836 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
49837 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
49838 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
49839 + pax_close_kernel();
49840 info->pixmap.scan_align = 4;
49841 info->flags &= ~FBINFO_HWACCEL_DISABLED;
49842 info->flags |= FBINFO_READS_FAST;
49843 NVResetGraphics(info);
49844 } else {
49845 - info->fbops->fb_imageblit = cfb_imageblit;
49846 - info->fbops->fb_fillrect = cfb_fillrect;
49847 - info->fbops->fb_copyarea = cfb_copyarea;
49848 - info->fbops->fb_sync = NULL;
49849 + pax_open_kernel();
49850 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
49851 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
49852 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
49853 + *(void **)&info->fbops->fb_sync = NULL;
49854 + pax_close_kernel();
49855 info->pixmap.scan_align = 1;
49856 info->flags |= FBINFO_HWACCEL_DISABLED;
49857 info->flags &= ~FBINFO_READS_FAST;
49858 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
49859 info->pixmap.size = 8 * 1024;
49860 info->pixmap.flags = FB_PIXMAP_SYSTEM;
49861
49862 - if (!hwcur)
49863 - info->fbops->fb_cursor = NULL;
49864 + if (!hwcur) {
49865 + pax_open_kernel();
49866 + *(void **)&info->fbops->fb_cursor = NULL;
49867 + pax_close_kernel();
49868 + }
49869
49870 info->var.accel_flags = (!noaccel);
49871
49872 diff --git a/drivers/video/output.c b/drivers/video/output.c
49873 index 0d6f2cd..6285b97 100644
49874 --- a/drivers/video/output.c
49875 +++ b/drivers/video/output.c
49876 @@ -97,7 +97,7 @@ struct output_device *video_output_register(const char *name,
49877 new_dev->props = op;
49878 new_dev->dev.class = &video_output_class;
49879 new_dev->dev.parent = dev;
49880 - dev_set_name(&new_dev->dev, name);
49881 + dev_set_name(&new_dev->dev, "%s", name);
49882 dev_set_drvdata(&new_dev->dev, devdata);
49883 ret_code = device_register(&new_dev->dev);
49884 if (ret_code) {
49885 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
49886 index 05c2dc3..ea1f391 100644
49887 --- a/drivers/video/s1d13xxxfb.c
49888 +++ b/drivers/video/s1d13xxxfb.c
49889 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
49890
49891 switch(prod_id) {
49892 case S1D13506_PROD_ID: /* activate acceleration */
49893 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
49894 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
49895 + pax_open_kernel();
49896 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
49897 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
49898 + pax_close_kernel();
49899 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
49900 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
49901 break;
49902 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
49903 index b2b33fc..f9f4658 100644
49904 --- a/drivers/video/smscufx.c
49905 +++ b/drivers/video/smscufx.c
49906 @@ -1175,7 +1175,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
49907 fb_deferred_io_cleanup(info);
49908 kfree(info->fbdefio);
49909 info->fbdefio = NULL;
49910 - info->fbops->fb_mmap = ufx_ops_mmap;
49911 + pax_open_kernel();
49912 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
49913 + pax_close_kernel();
49914 }
49915
49916 pr_debug("released /dev/fb%d user=%d count=%d",
49917 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
49918 index ec03e72..f578436 100644
49919 --- a/drivers/video/udlfb.c
49920 +++ b/drivers/video/udlfb.c
49921 @@ -623,11 +623,11 @@ int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
49922 dlfb_urb_completion(urb);
49923
49924 error:
49925 - atomic_add(bytes_sent, &dev->bytes_sent);
49926 - atomic_add(bytes_identical, &dev->bytes_identical);
49927 - atomic_add(width*height*2, &dev->bytes_rendered);
49928 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
49929 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
49930 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
49931 end_cycles = get_cycles();
49932 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
49933 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
49934 >> 10)), /* Kcycles */
49935 &dev->cpu_kcycles_used);
49936
49937 @@ -748,11 +748,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
49938 dlfb_urb_completion(urb);
49939
49940 error:
49941 - atomic_add(bytes_sent, &dev->bytes_sent);
49942 - atomic_add(bytes_identical, &dev->bytes_identical);
49943 - atomic_add(bytes_rendered, &dev->bytes_rendered);
49944 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
49945 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
49946 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
49947 end_cycles = get_cycles();
49948 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
49949 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
49950 >> 10)), /* Kcycles */
49951 &dev->cpu_kcycles_used);
49952 }
49953 @@ -993,7 +993,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
49954 fb_deferred_io_cleanup(info);
49955 kfree(info->fbdefio);
49956 info->fbdefio = NULL;
49957 - info->fbops->fb_mmap = dlfb_ops_mmap;
49958 + pax_open_kernel();
49959 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
49960 + pax_close_kernel();
49961 }
49962
49963 pr_warn("released /dev/fb%d user=%d count=%d\n",
49964 @@ -1376,7 +1378,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
49965 struct fb_info *fb_info = dev_get_drvdata(fbdev);
49966 struct dlfb_data *dev = fb_info->par;
49967 return snprintf(buf, PAGE_SIZE, "%u\n",
49968 - atomic_read(&dev->bytes_rendered));
49969 + atomic_read_unchecked(&dev->bytes_rendered));
49970 }
49971
49972 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
49973 @@ -1384,7 +1386,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
49974 struct fb_info *fb_info = dev_get_drvdata(fbdev);
49975 struct dlfb_data *dev = fb_info->par;
49976 return snprintf(buf, PAGE_SIZE, "%u\n",
49977 - atomic_read(&dev->bytes_identical));
49978 + atomic_read_unchecked(&dev->bytes_identical));
49979 }
49980
49981 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
49982 @@ -1392,7 +1394,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
49983 struct fb_info *fb_info = dev_get_drvdata(fbdev);
49984 struct dlfb_data *dev = fb_info->par;
49985 return snprintf(buf, PAGE_SIZE, "%u\n",
49986 - atomic_read(&dev->bytes_sent));
49987 + atomic_read_unchecked(&dev->bytes_sent));
49988 }
49989
49990 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
49991 @@ -1400,7 +1402,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
49992 struct fb_info *fb_info = dev_get_drvdata(fbdev);
49993 struct dlfb_data *dev = fb_info->par;
49994 return snprintf(buf, PAGE_SIZE, "%u\n",
49995 - atomic_read(&dev->cpu_kcycles_used));
49996 + atomic_read_unchecked(&dev->cpu_kcycles_used));
49997 }
49998
49999 static ssize_t edid_show(
50000 @@ -1460,10 +1462,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
50001 struct fb_info *fb_info = dev_get_drvdata(fbdev);
50002 struct dlfb_data *dev = fb_info->par;
50003
50004 - atomic_set(&dev->bytes_rendered, 0);
50005 - atomic_set(&dev->bytes_identical, 0);
50006 - atomic_set(&dev->bytes_sent, 0);
50007 - atomic_set(&dev->cpu_kcycles_used, 0);
50008 + atomic_set_unchecked(&dev->bytes_rendered, 0);
50009 + atomic_set_unchecked(&dev->bytes_identical, 0);
50010 + atomic_set_unchecked(&dev->bytes_sent, 0);
50011 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
50012
50013 return count;
50014 }
50015 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
50016 index e328a61..1b08ecb 100644
50017 --- a/drivers/video/uvesafb.c
50018 +++ b/drivers/video/uvesafb.c
50019 @@ -19,6 +19,7 @@
50020 #include <linux/io.h>
50021 #include <linux/mutex.h>
50022 #include <linux/slab.h>
50023 +#include <linux/moduleloader.h>
50024 #include <video/edid.h>
50025 #include <video/uvesafb.h>
50026 #ifdef CONFIG_X86
50027 @@ -569,10 +570,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
50028 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
50029 par->pmi_setpal = par->ypan = 0;
50030 } else {
50031 +
50032 +#ifdef CONFIG_PAX_KERNEXEC
50033 +#ifdef CONFIG_MODULES
50034 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
50035 +#endif
50036 + if (!par->pmi_code) {
50037 + par->pmi_setpal = par->ypan = 0;
50038 + return 0;
50039 + }
50040 +#endif
50041 +
50042 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
50043 + task->t.regs.edi);
50044 +
50045 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
50046 + pax_open_kernel();
50047 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
50048 + pax_close_kernel();
50049 +
50050 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
50051 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
50052 +#else
50053 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
50054 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
50055 +#endif
50056 +
50057 printk(KERN_INFO "uvesafb: protected mode interface info at "
50058 "%04x:%04x\n",
50059 (u16)task->t.regs.es, (u16)task->t.regs.edi);
50060 @@ -817,13 +840,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
50061 par->ypan = ypan;
50062
50063 if (par->pmi_setpal || par->ypan) {
50064 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
50065 if (__supported_pte_mask & _PAGE_NX) {
50066 par->pmi_setpal = par->ypan = 0;
50067 printk(KERN_WARNING "uvesafb: NX protection is actively."
50068 "We have better not to use the PMI.\n");
50069 - } else {
50070 + } else
50071 +#endif
50072 uvesafb_vbe_getpmi(task, par);
50073 - }
50074 }
50075 #else
50076 /* The protected mode interface is not available on non-x86. */
50077 @@ -1457,8 +1481,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
50078 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
50079
50080 /* Disable blanking if the user requested so. */
50081 - if (!blank)
50082 - info->fbops->fb_blank = NULL;
50083 + if (!blank) {
50084 + pax_open_kernel();
50085 + *(void **)&info->fbops->fb_blank = NULL;
50086 + pax_close_kernel();
50087 + }
50088
50089 /*
50090 * Find out how much IO memory is required for the mode with
50091 @@ -1534,8 +1561,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
50092 info->flags = FBINFO_FLAG_DEFAULT |
50093 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
50094
50095 - if (!par->ypan)
50096 - info->fbops->fb_pan_display = NULL;
50097 + if (!par->ypan) {
50098 + pax_open_kernel();
50099 + *(void **)&info->fbops->fb_pan_display = NULL;
50100 + pax_close_kernel();
50101 + }
50102 }
50103
50104 static void uvesafb_init_mtrr(struct fb_info *info)
50105 @@ -1836,6 +1866,11 @@ out:
50106 if (par->vbe_modes)
50107 kfree(par->vbe_modes);
50108
50109 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
50110 + if (par->pmi_code)
50111 + module_free_exec(NULL, par->pmi_code);
50112 +#endif
50113 +
50114 framebuffer_release(info);
50115 return err;
50116 }
50117 @@ -1862,6 +1897,12 @@ static int uvesafb_remove(struct platform_device *dev)
50118 kfree(par->vbe_state_orig);
50119 if (par->vbe_state_saved)
50120 kfree(par->vbe_state_saved);
50121 +
50122 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
50123 + if (par->pmi_code)
50124 + module_free_exec(NULL, par->pmi_code);
50125 +#endif
50126 +
50127 }
50128
50129 framebuffer_release(info);
50130 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
50131 index 501b340..d80aa17 100644
50132 --- a/drivers/video/vesafb.c
50133 +++ b/drivers/video/vesafb.c
50134 @@ -9,6 +9,7 @@
50135 */
50136
50137 #include <linux/module.h>
50138 +#include <linux/moduleloader.h>
50139 #include <linux/kernel.h>
50140 #include <linux/errno.h>
50141 #include <linux/string.h>
50142 @@ -52,8 +53,8 @@ static int vram_remap __initdata; /* Set amount of memory to be used */
50143 static int vram_total __initdata; /* Set total amount of memory */
50144 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
50145 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
50146 -static void (*pmi_start)(void) __read_mostly;
50147 -static void (*pmi_pal) (void) __read_mostly;
50148 +static void (*pmi_start)(void) __read_only;
50149 +static void (*pmi_pal) (void) __read_only;
50150 static int depth __read_mostly;
50151 static int vga_compat __read_mostly;
50152 /* --------------------------------------------------------------------- */
50153 @@ -233,6 +234,7 @@ static int __init vesafb_probe(struct platform_device *dev)
50154 unsigned int size_vmode;
50155 unsigned int size_remap;
50156 unsigned int size_total;
50157 + void *pmi_code = NULL;
50158
50159 if (screen_info.orig_video_isVGA != VIDEO_TYPE_VLFB)
50160 return -ENODEV;
50161 @@ -275,10 +277,6 @@ static int __init vesafb_probe(struct platform_device *dev)
50162 size_remap = size_total;
50163 vesafb_fix.smem_len = size_remap;
50164
50165 -#ifndef __i386__
50166 - screen_info.vesapm_seg = 0;
50167 -#endif
50168 -
50169 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
50170 printk(KERN_WARNING
50171 "vesafb: cannot reserve video memory at 0x%lx\n",
50172 @@ -307,9 +305,21 @@ static int __init vesafb_probe(struct platform_device *dev)
50173 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
50174 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
50175
50176 +#ifdef __i386__
50177 +
50178 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
50179 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
50180 + if (!pmi_code)
50181 +#elif !defined(CONFIG_PAX_KERNEXEC)
50182 + if (0)
50183 +#endif
50184 +
50185 +#endif
50186 + screen_info.vesapm_seg = 0;
50187 +
50188 if (screen_info.vesapm_seg) {
50189 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
50190 - screen_info.vesapm_seg,screen_info.vesapm_off);
50191 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
50192 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
50193 }
50194
50195 if (screen_info.vesapm_seg < 0xc000)
50196 @@ -317,9 +327,25 @@ static int __init vesafb_probe(struct platform_device *dev)
50197
50198 if (ypan || pmi_setpal) {
50199 unsigned short *pmi_base;
50200 +
50201 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
50202 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
50203 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
50204 +
50205 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
50206 + pax_open_kernel();
50207 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
50208 +#else
50209 + pmi_code = pmi_base;
50210 +#endif
50211 +
50212 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
50213 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
50214 +
50215 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
50216 + pmi_start = ktva_ktla(pmi_start);
50217 + pmi_pal = ktva_ktla(pmi_pal);
50218 + pax_close_kernel();
50219 +#endif
50220 +
50221 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
50222 if (pmi_base[3]) {
50223 printk(KERN_INFO "vesafb: pmi: ports = ");
50224 @@ -472,8 +498,11 @@ static int __init vesafb_probe(struct platform_device *dev)
50225 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
50226 (ypan ? FBINFO_HWACCEL_YPAN : 0);
50227
50228 - if (!ypan)
50229 - info->fbops->fb_pan_display = NULL;
50230 + if (!ypan) {
50231 + pax_open_kernel();
50232 + *(void **)&info->fbops->fb_pan_display = NULL;
50233 + pax_close_kernel();
50234 + }
50235
50236 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
50237 err = -ENOMEM;
50238 @@ -488,6 +517,11 @@ static int __init vesafb_probe(struct platform_device *dev)
50239 info->node, info->fix.id);
50240 return 0;
50241 err:
50242 +
50243 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
50244 + module_free_exec(NULL, pmi_code);
50245 +#endif
50246 +
50247 if (info->screen_base)
50248 iounmap(info->screen_base);
50249 framebuffer_release(info);
50250 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
50251 index 88714ae..16c2e11 100644
50252 --- a/drivers/video/via/via_clock.h
50253 +++ b/drivers/video/via/via_clock.h
50254 @@ -56,7 +56,7 @@ struct via_clock {
50255
50256 void (*set_engine_pll_state)(u8 state);
50257 void (*set_engine_pll)(struct via_pll_config config);
50258 -};
50259 +} __no_const;
50260
50261
50262 static inline u32 get_pll_internal_frequency(u32 ref_freq,
50263 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
50264 index fef20db..d28b1ab 100644
50265 --- a/drivers/xen/xenfs/xenstored.c
50266 +++ b/drivers/xen/xenfs/xenstored.c
50267 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
50268 static int xsd_kva_open(struct inode *inode, struct file *file)
50269 {
50270 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
50271 +#ifdef CONFIG_GRKERNSEC_HIDESYM
50272 + NULL);
50273 +#else
50274 xen_store_interface);
50275 +#endif
50276 +
50277 if (!file->private_data)
50278 return -ENOMEM;
50279 return 0;
50280 diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
50281 index 055562c..fdfb10d 100644
50282 --- a/fs/9p/vfs_addr.c
50283 +++ b/fs/9p/vfs_addr.c
50284 @@ -186,7 +186,7 @@ static int v9fs_vfs_writepage_locked(struct page *page)
50285
50286 retval = v9fs_file_write_internal(inode,
50287 v9inode->writeback_fid,
50288 - (__force const char __user *)buffer,
50289 + (const char __force_user *)buffer,
50290 len, &offset, 0);
50291 if (retval > 0)
50292 retval = 0;
50293 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
50294 index d86edc8..40ff2fb 100644
50295 --- a/fs/9p/vfs_inode.c
50296 +++ b/fs/9p/vfs_inode.c
50297 @@ -1314,7 +1314,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
50298 void
50299 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
50300 {
50301 - char *s = nd_get_link(nd);
50302 + const char *s = nd_get_link(nd);
50303
50304 p9_debug(P9_DEBUG_VFS, " %s %s\n",
50305 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
50306 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
50307 index 370b24c..ff0be7b 100644
50308 --- a/fs/Kconfig.binfmt
50309 +++ b/fs/Kconfig.binfmt
50310 @@ -103,7 +103,7 @@ config HAVE_AOUT
50311
50312 config BINFMT_AOUT
50313 tristate "Kernel support for a.out and ECOFF binaries"
50314 - depends on HAVE_AOUT
50315 + depends on HAVE_AOUT && BROKEN
50316 ---help---
50317 A.out (Assembler.OUTput) is a set of formats for libraries and
50318 executables used in the earliest versions of UNIX. Linux used
50319 diff --git a/fs/aio.c b/fs/aio.c
50320 index 2bbcacf..8614116 100644
50321 --- a/fs/aio.c
50322 +++ b/fs/aio.c
50323 @@ -160,7 +160,7 @@ static int aio_setup_ring(struct kioctx *ctx)
50324 size += sizeof(struct io_event) * nr_events;
50325 nr_pages = (size + PAGE_SIZE-1) >> PAGE_SHIFT;
50326
50327 - if (nr_pages < 0)
50328 + if (nr_pages <= 0)
50329 return -EINVAL;
50330
50331 nr_events = (PAGE_SIZE * nr_pages - sizeof(struct aio_ring)) / sizeof(struct io_event);
50332 @@ -950,6 +950,7 @@ static ssize_t aio_rw_vect_retry(struct kiocb *iocb, int rw, aio_rw_op *rw_op)
50333 static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat)
50334 {
50335 ssize_t ret;
50336 + struct iovec iovstack;
50337
50338 kiocb->ki_nr_segs = kiocb->ki_nbytes;
50339
50340 @@ -957,17 +958,22 @@ static ssize_t aio_setup_vectored_rw(int rw, struct kiocb *kiocb, bool compat)
50341 if (compat)
50342 ret = compat_rw_copy_check_uvector(rw,
50343 (struct compat_iovec __user *)kiocb->ki_buf,
50344 - kiocb->ki_nr_segs, 1, &kiocb->ki_inline_vec,
50345 + kiocb->ki_nr_segs, 1, &iovstack,
50346 &kiocb->ki_iovec);
50347 else
50348 #endif
50349 ret = rw_copy_check_uvector(rw,
50350 (struct iovec __user *)kiocb->ki_buf,
50351 - kiocb->ki_nr_segs, 1, &kiocb->ki_inline_vec,
50352 + kiocb->ki_nr_segs, 1, &iovstack,
50353 &kiocb->ki_iovec);
50354 if (ret < 0)
50355 return ret;
50356
50357 + if (kiocb->ki_iovec == &iovstack) {
50358 + kiocb->ki_inline_vec = iovstack;
50359 + kiocb->ki_iovec = &kiocb->ki_inline_vec;
50360 + }
50361 +
50362 /* ki_nbytes now reflect bytes instead of segs */
50363 kiocb->ki_nbytes = ret;
50364 return 0;
50365 diff --git a/fs/attr.c b/fs/attr.c
50366 index 1449adb..a2038c2 100644
50367 --- a/fs/attr.c
50368 +++ b/fs/attr.c
50369 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
50370 unsigned long limit;
50371
50372 limit = rlimit(RLIMIT_FSIZE);
50373 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
50374 if (limit != RLIM_INFINITY && offset > limit)
50375 goto out_sig;
50376 if (offset > inode->i_sb->s_maxbytes)
50377 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
50378 index 3db70da..7aeec5b 100644
50379 --- a/fs/autofs4/waitq.c
50380 +++ b/fs/autofs4/waitq.c
50381 @@ -59,7 +59,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
50382 {
50383 unsigned long sigpipe, flags;
50384 mm_segment_t fs;
50385 - const char *data = (const char *)addr;
50386 + const char __user *data = (const char __force_user *)addr;
50387 ssize_t wr = 0;
50388
50389 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
50390 @@ -346,6 +346,10 @@ static int validate_request(struct autofs_wait_queue **wait,
50391 return 1;
50392 }
50393
50394 +#ifdef CONFIG_GRKERNSEC_HIDESYM
50395 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
50396 +#endif
50397 +
50398 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
50399 enum autofs_notify notify)
50400 {
50401 @@ -379,7 +383,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
50402
50403 /* If this is a direct mount request create a dummy name */
50404 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
50405 +#ifdef CONFIG_GRKERNSEC_HIDESYM
50406 + /* this name does get written to userland via autofs4_write() */
50407 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
50408 +#else
50409 qstr.len = sprintf(name, "%p", dentry);
50410 +#endif
50411 else {
50412 qstr.len = autofs4_getpath(sbi, dentry, &name);
50413 if (!qstr.len) {
50414 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
50415 index 2722387..c8dd2a7 100644
50416 --- a/fs/befs/endian.h
50417 +++ b/fs/befs/endian.h
50418 @@ -11,7 +11,7 @@
50419
50420 #include <asm/byteorder.h>
50421
50422 -static inline u64
50423 +static inline u64 __intentional_overflow(-1)
50424 fs64_to_cpu(const struct super_block *sb, fs64 n)
50425 {
50426 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
50427 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
50428 return (__force fs64)cpu_to_be64(n);
50429 }
50430
50431 -static inline u32
50432 +static inline u32 __intentional_overflow(-1)
50433 fs32_to_cpu(const struct super_block *sb, fs32 n)
50434 {
50435 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
50436 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
50437 index f95dddc..b1e2c1c 100644
50438 --- a/fs/befs/linuxvfs.c
50439 +++ b/fs/befs/linuxvfs.c
50440 @@ -510,7 +510,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
50441 {
50442 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
50443 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
50444 - char *link = nd_get_link(nd);
50445 + const char *link = nd_get_link(nd);
50446 if (!IS_ERR(link))
50447 kfree(link);
50448 }
50449 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
50450 index bce8769..7fc7544 100644
50451 --- a/fs/binfmt_aout.c
50452 +++ b/fs/binfmt_aout.c
50453 @@ -16,6 +16,7 @@
50454 #include <linux/string.h>
50455 #include <linux/fs.h>
50456 #include <linux/file.h>
50457 +#include <linux/security.h>
50458 #include <linux/stat.h>
50459 #include <linux/fcntl.h>
50460 #include <linux/ptrace.h>
50461 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
50462 #endif
50463 # define START_STACK(u) ((void __user *)u.start_stack)
50464
50465 + memset(&dump, 0, sizeof(dump));
50466 +
50467 fs = get_fs();
50468 set_fs(KERNEL_DS);
50469 has_dumped = 1;
50470 @@ -69,10 +72,12 @@ static int aout_core_dump(struct coredump_params *cprm)
50471
50472 /* If the size of the dump file exceeds the rlimit, then see what would happen
50473 if we wrote the stack, but not the data area. */
50474 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
50475 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
50476 dump.u_dsize = 0;
50477
50478 /* Make sure we have enough room to write the stack and data areas. */
50479 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
50480 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
50481 dump.u_ssize = 0;
50482
50483 @@ -233,6 +238,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
50484 rlim = rlimit(RLIMIT_DATA);
50485 if (rlim >= RLIM_INFINITY)
50486 rlim = ~0;
50487 +
50488 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
50489 if (ex.a_data + ex.a_bss > rlim)
50490 return -ENOMEM;
50491
50492 @@ -267,6 +274,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
50493
50494 install_exec_creds(bprm);
50495
50496 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
50497 + current->mm->pax_flags = 0UL;
50498 +#endif
50499 +
50500 +#ifdef CONFIG_PAX_PAGEEXEC
50501 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
50502 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
50503 +
50504 +#ifdef CONFIG_PAX_EMUTRAMP
50505 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
50506 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
50507 +#endif
50508 +
50509 +#ifdef CONFIG_PAX_MPROTECT
50510 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
50511 + current->mm->pax_flags |= MF_PAX_MPROTECT;
50512 +#endif
50513 +
50514 + }
50515 +#endif
50516 +
50517 if (N_MAGIC(ex) == OMAGIC) {
50518 unsigned long text_addr, map_size;
50519 loff_t pos;
50520 @@ -324,7 +352,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
50521 }
50522
50523 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
50524 - PROT_READ | PROT_WRITE | PROT_EXEC,
50525 + PROT_READ | PROT_WRITE,
50526 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
50527 fd_offset + ex.a_text);
50528 if (error != N_DATADDR(ex)) {
50529 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
50530 index f8a0b0e..6f036ed 100644
50531 --- a/fs/binfmt_elf.c
50532 +++ b/fs/binfmt_elf.c
50533 @@ -34,6 +34,7 @@
50534 #include <linux/utsname.h>
50535 #include <linux/coredump.h>
50536 #include <linux/sched.h>
50537 +#include <linux/xattr.h>
50538 #include <asm/uaccess.h>
50539 #include <asm/param.h>
50540 #include <asm/page.h>
50541 @@ -60,6 +61,14 @@ static int elf_core_dump(struct coredump_params *cprm);
50542 #define elf_core_dump NULL
50543 #endif
50544
50545 +#ifdef CONFIG_PAX_MPROTECT
50546 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
50547 +#endif
50548 +
50549 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
50550 +static void elf_handle_mmap(struct file *file);
50551 +#endif
50552 +
50553 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
50554 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
50555 #else
50556 @@ -79,6 +88,15 @@ static struct linux_binfmt elf_format = {
50557 .load_binary = load_elf_binary,
50558 .load_shlib = load_elf_library,
50559 .core_dump = elf_core_dump,
50560 +
50561 +#ifdef CONFIG_PAX_MPROTECT
50562 + .handle_mprotect= elf_handle_mprotect,
50563 +#endif
50564 +
50565 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
50566 + .handle_mmap = elf_handle_mmap,
50567 +#endif
50568 +
50569 .min_coredump = ELF_EXEC_PAGESIZE,
50570 };
50571
50572 @@ -86,6 +104,8 @@ static struct linux_binfmt elf_format = {
50573
50574 static int set_brk(unsigned long start, unsigned long end)
50575 {
50576 + unsigned long e = end;
50577 +
50578 start = ELF_PAGEALIGN(start);
50579 end = ELF_PAGEALIGN(end);
50580 if (end > start) {
50581 @@ -94,7 +114,7 @@ static int set_brk(unsigned long start, unsigned long end)
50582 if (BAD_ADDR(addr))
50583 return addr;
50584 }
50585 - current->mm->start_brk = current->mm->brk = end;
50586 + current->mm->start_brk = current->mm->brk = e;
50587 return 0;
50588 }
50589
50590 @@ -155,12 +175,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
50591 elf_addr_t __user *u_rand_bytes;
50592 const char *k_platform = ELF_PLATFORM;
50593 const char *k_base_platform = ELF_BASE_PLATFORM;
50594 - unsigned char k_rand_bytes[16];
50595 + u32 k_rand_bytes[4];
50596 int items;
50597 elf_addr_t *elf_info;
50598 int ei_index = 0;
50599 const struct cred *cred = current_cred();
50600 struct vm_area_struct *vma;
50601 + unsigned long saved_auxv[AT_VECTOR_SIZE];
50602
50603 /*
50604 * In some cases (e.g. Hyper-Threading), we want to avoid L1
50605 @@ -202,8 +223,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
50606 * Generate 16 random bytes for userspace PRNG seeding.
50607 */
50608 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
50609 - u_rand_bytes = (elf_addr_t __user *)
50610 - STACK_ALLOC(p, sizeof(k_rand_bytes));
50611 + prandom_seed(k_rand_bytes[0] ^ prandom_u32());
50612 + prandom_seed(k_rand_bytes[1] ^ prandom_u32());
50613 + prandom_seed(k_rand_bytes[2] ^ prandom_u32());
50614 + prandom_seed(k_rand_bytes[3] ^ prandom_u32());
50615 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
50616 + u_rand_bytes = (elf_addr_t __user *) p;
50617 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
50618 return -EFAULT;
50619
50620 @@ -318,9 +343,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
50621 return -EFAULT;
50622 current->mm->env_end = p;
50623
50624 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
50625 +
50626 /* Put the elf_info on the stack in the right place. */
50627 sp = (elf_addr_t __user *)envp + 1;
50628 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
50629 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
50630 return -EFAULT;
50631 return 0;
50632 }
50633 @@ -388,15 +415,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
50634 an ELF header */
50635
50636 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
50637 - struct file *interpreter, unsigned long *interp_map_addr,
50638 - unsigned long no_base)
50639 + struct file *interpreter, unsigned long no_base)
50640 {
50641 struct elf_phdr *elf_phdata;
50642 struct elf_phdr *eppnt;
50643 - unsigned long load_addr = 0;
50644 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
50645 int load_addr_set = 0;
50646 unsigned long last_bss = 0, elf_bss = 0;
50647 - unsigned long error = ~0UL;
50648 + unsigned long error = -EINVAL;
50649 unsigned long total_size;
50650 int retval, i, size;
50651
50652 @@ -442,6 +468,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
50653 goto out_close;
50654 }
50655
50656 +#ifdef CONFIG_PAX_SEGMEXEC
50657 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
50658 + pax_task_size = SEGMEXEC_TASK_SIZE;
50659 +#endif
50660 +
50661 eppnt = elf_phdata;
50662 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
50663 if (eppnt->p_type == PT_LOAD) {
50664 @@ -465,8 +496,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
50665 map_addr = elf_map(interpreter, load_addr + vaddr,
50666 eppnt, elf_prot, elf_type, total_size);
50667 total_size = 0;
50668 - if (!*interp_map_addr)
50669 - *interp_map_addr = map_addr;
50670 error = map_addr;
50671 if (BAD_ADDR(map_addr))
50672 goto out_close;
50673 @@ -485,8 +514,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
50674 k = load_addr + eppnt->p_vaddr;
50675 if (BAD_ADDR(k) ||
50676 eppnt->p_filesz > eppnt->p_memsz ||
50677 - eppnt->p_memsz > TASK_SIZE ||
50678 - TASK_SIZE - eppnt->p_memsz < k) {
50679 + eppnt->p_memsz > pax_task_size ||
50680 + pax_task_size - eppnt->p_memsz < k) {
50681 error = -ENOMEM;
50682 goto out_close;
50683 }
50684 @@ -538,6 +567,315 @@ out:
50685 return error;
50686 }
50687
50688 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
50689 +#ifdef CONFIG_PAX_SOFTMODE
50690 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
50691 +{
50692 + unsigned long pax_flags = 0UL;
50693 +
50694 +#ifdef CONFIG_PAX_PAGEEXEC
50695 + if (elf_phdata->p_flags & PF_PAGEEXEC)
50696 + pax_flags |= MF_PAX_PAGEEXEC;
50697 +#endif
50698 +
50699 +#ifdef CONFIG_PAX_SEGMEXEC
50700 + if (elf_phdata->p_flags & PF_SEGMEXEC)
50701 + pax_flags |= MF_PAX_SEGMEXEC;
50702 +#endif
50703 +
50704 +#ifdef CONFIG_PAX_EMUTRAMP
50705 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
50706 + pax_flags |= MF_PAX_EMUTRAMP;
50707 +#endif
50708 +
50709 +#ifdef CONFIG_PAX_MPROTECT
50710 + if (elf_phdata->p_flags & PF_MPROTECT)
50711 + pax_flags |= MF_PAX_MPROTECT;
50712 +#endif
50713 +
50714 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
50715 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
50716 + pax_flags |= MF_PAX_RANDMMAP;
50717 +#endif
50718 +
50719 + return pax_flags;
50720 +}
50721 +#endif
50722 +
50723 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
50724 +{
50725 + unsigned long pax_flags = 0UL;
50726 +
50727 +#ifdef CONFIG_PAX_PAGEEXEC
50728 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
50729 + pax_flags |= MF_PAX_PAGEEXEC;
50730 +#endif
50731 +
50732 +#ifdef CONFIG_PAX_SEGMEXEC
50733 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
50734 + pax_flags |= MF_PAX_SEGMEXEC;
50735 +#endif
50736 +
50737 +#ifdef CONFIG_PAX_EMUTRAMP
50738 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
50739 + pax_flags |= MF_PAX_EMUTRAMP;
50740 +#endif
50741 +
50742 +#ifdef CONFIG_PAX_MPROTECT
50743 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
50744 + pax_flags |= MF_PAX_MPROTECT;
50745 +#endif
50746 +
50747 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
50748 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
50749 + pax_flags |= MF_PAX_RANDMMAP;
50750 +#endif
50751 +
50752 + return pax_flags;
50753 +}
50754 +#endif
50755 +
50756 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
50757 +#ifdef CONFIG_PAX_SOFTMODE
50758 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
50759 +{
50760 + unsigned long pax_flags = 0UL;
50761 +
50762 +#ifdef CONFIG_PAX_PAGEEXEC
50763 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
50764 + pax_flags |= MF_PAX_PAGEEXEC;
50765 +#endif
50766 +
50767 +#ifdef CONFIG_PAX_SEGMEXEC
50768 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
50769 + pax_flags |= MF_PAX_SEGMEXEC;
50770 +#endif
50771 +
50772 +#ifdef CONFIG_PAX_EMUTRAMP
50773 + if ((pax_flags_softmode & MF_PAX_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
50774 + pax_flags |= MF_PAX_EMUTRAMP;
50775 +#endif
50776 +
50777 +#ifdef CONFIG_PAX_MPROTECT
50778 + if (pax_flags_softmode & MF_PAX_MPROTECT)
50779 + pax_flags |= MF_PAX_MPROTECT;
50780 +#endif
50781 +
50782 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
50783 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
50784 + pax_flags |= MF_PAX_RANDMMAP;
50785 +#endif
50786 +
50787 + return pax_flags;
50788 +}
50789 +#endif
50790 +
50791 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
50792 +{
50793 + unsigned long pax_flags = 0UL;
50794 +
50795 +#ifdef CONFIG_PAX_PAGEEXEC
50796 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
50797 + pax_flags |= MF_PAX_PAGEEXEC;
50798 +#endif
50799 +
50800 +#ifdef CONFIG_PAX_SEGMEXEC
50801 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
50802 + pax_flags |= MF_PAX_SEGMEXEC;
50803 +#endif
50804 +
50805 +#ifdef CONFIG_PAX_EMUTRAMP
50806 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
50807 + pax_flags |= MF_PAX_EMUTRAMP;
50808 +#endif
50809 +
50810 +#ifdef CONFIG_PAX_MPROTECT
50811 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
50812 + pax_flags |= MF_PAX_MPROTECT;
50813 +#endif
50814 +
50815 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
50816 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
50817 + pax_flags |= MF_PAX_RANDMMAP;
50818 +#endif
50819 +
50820 + return pax_flags;
50821 +}
50822 +#endif
50823 +
50824 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
50825 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
50826 +{
50827 + unsigned long pax_flags = 0UL;
50828 +
50829 +#ifdef CONFIG_PAX_EI_PAX
50830 +
50831 +#ifdef CONFIG_PAX_PAGEEXEC
50832 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
50833 + pax_flags |= MF_PAX_PAGEEXEC;
50834 +#endif
50835 +
50836 +#ifdef CONFIG_PAX_SEGMEXEC
50837 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
50838 + pax_flags |= MF_PAX_SEGMEXEC;
50839 +#endif
50840 +
50841 +#ifdef CONFIG_PAX_EMUTRAMP
50842 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
50843 + pax_flags |= MF_PAX_EMUTRAMP;
50844 +#endif
50845 +
50846 +#ifdef CONFIG_PAX_MPROTECT
50847 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
50848 + pax_flags |= MF_PAX_MPROTECT;
50849 +#endif
50850 +
50851 +#ifdef CONFIG_PAX_ASLR
50852 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
50853 + pax_flags |= MF_PAX_RANDMMAP;
50854 +#endif
50855 +
50856 +#else
50857 +
50858 +#ifdef CONFIG_PAX_PAGEEXEC
50859 + pax_flags |= MF_PAX_PAGEEXEC;
50860 +#endif
50861 +
50862 +#ifdef CONFIG_PAX_SEGMEXEC
50863 + pax_flags |= MF_PAX_SEGMEXEC;
50864 +#endif
50865 +
50866 +#ifdef CONFIG_PAX_MPROTECT
50867 + pax_flags |= MF_PAX_MPROTECT;
50868 +#endif
50869 +
50870 +#ifdef CONFIG_PAX_RANDMMAP
50871 + if (randomize_va_space)
50872 + pax_flags |= MF_PAX_RANDMMAP;
50873 +#endif
50874 +
50875 +#endif
50876 +
50877 + return pax_flags;
50878 +}
50879 +
50880 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
50881 +{
50882 +
50883 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
50884 + unsigned long i;
50885 +
50886 + for (i = 0UL; i < elf_ex->e_phnum; i++)
50887 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
50888 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
50889 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
50890 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
50891 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
50892 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
50893 + return ~0UL;
50894 +
50895 +#ifdef CONFIG_PAX_SOFTMODE
50896 + if (pax_softmode)
50897 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
50898 + else
50899 +#endif
50900 +
50901 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
50902 + break;
50903 + }
50904 +#endif
50905 +
50906 + return ~0UL;
50907 +}
50908 +
50909 +static unsigned long pax_parse_xattr_pax(struct file * const file)
50910 +{
50911 +
50912 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
50913 + ssize_t xattr_size, i;
50914 + unsigned char xattr_value[sizeof("pemrs") - 1];
50915 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
50916 +
50917 + xattr_size = pax_getxattr(file->f_path.dentry, xattr_value, sizeof xattr_value);
50918 + if (xattr_size <= 0 || xattr_size > sizeof xattr_value)
50919 + return ~0UL;
50920 +
50921 + for (i = 0; i < xattr_size; i++)
50922 + switch (xattr_value[i]) {
50923 + default:
50924 + return ~0UL;
50925 +
50926 +#define parse_flag(option1, option2, flag) \
50927 + case option1: \
50928 + if (pax_flags_hardmode & MF_PAX_##flag) \
50929 + return ~0UL; \
50930 + pax_flags_hardmode |= MF_PAX_##flag; \
50931 + break; \
50932 + case option2: \
50933 + if (pax_flags_softmode & MF_PAX_##flag) \
50934 + return ~0UL; \
50935 + pax_flags_softmode |= MF_PAX_##flag; \
50936 + break;
50937 +
50938 + parse_flag('p', 'P', PAGEEXEC);
50939 + parse_flag('e', 'E', EMUTRAMP);
50940 + parse_flag('m', 'M', MPROTECT);
50941 + parse_flag('r', 'R', RANDMMAP);
50942 + parse_flag('s', 'S', SEGMEXEC);
50943 +
50944 +#undef parse_flag
50945 + }
50946 +
50947 + if (pax_flags_hardmode & pax_flags_softmode)
50948 + return ~0UL;
50949 +
50950 +#ifdef CONFIG_PAX_SOFTMODE
50951 + if (pax_softmode)
50952 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
50953 + else
50954 +#endif
50955 +
50956 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
50957 +#else
50958 + return ~0UL;
50959 +#endif
50960 +
50961 +}
50962 +
50963 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
50964 +{
50965 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
50966 +
50967 + pax_flags = pax_parse_ei_pax(elf_ex);
50968 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
50969 + xattr_pax_flags = pax_parse_xattr_pax(file);
50970 +
50971 + if (pt_pax_flags == ~0UL)
50972 + pt_pax_flags = xattr_pax_flags;
50973 + else if (xattr_pax_flags == ~0UL)
50974 + xattr_pax_flags = pt_pax_flags;
50975 + if (pt_pax_flags != xattr_pax_flags)
50976 + return -EINVAL;
50977 + if (pt_pax_flags != ~0UL)
50978 + pax_flags = pt_pax_flags;
50979 +
50980 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
50981 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
50982 + if ((__supported_pte_mask & _PAGE_NX))
50983 + pax_flags &= ~MF_PAX_SEGMEXEC;
50984 + else
50985 + pax_flags &= ~MF_PAX_PAGEEXEC;
50986 + }
50987 +#endif
50988 +
50989 + if (0 > pax_check_flags(&pax_flags))
50990 + return -EINVAL;
50991 +
50992 + current->mm->pax_flags = pax_flags;
50993 + return 0;
50994 +}
50995 +#endif
50996 +
50997 /*
50998 * These are the functions used to load ELF style executables and shared
50999 * libraries. There is no binary dependent code anywhere else.
51000 @@ -554,6 +892,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
51001 {
51002 unsigned int random_variable = 0;
51003
51004 +#ifdef CONFIG_PAX_RANDUSTACK
51005 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
51006 + return stack_top - current->mm->delta_stack;
51007 +#endif
51008 +
51009 if ((current->flags & PF_RANDOMIZE) &&
51010 !(current->personality & ADDR_NO_RANDOMIZE)) {
51011 random_variable = get_random_int() & STACK_RND_MASK;
51012 @@ -572,7 +915,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
51013 unsigned long load_addr = 0, load_bias = 0;
51014 int load_addr_set = 0;
51015 char * elf_interpreter = NULL;
51016 - unsigned long error;
51017 + unsigned long error = 0;
51018 struct elf_phdr *elf_ppnt, *elf_phdata;
51019 unsigned long elf_bss, elf_brk;
51020 int retval, i;
51021 @@ -582,12 +925,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
51022 unsigned long start_code, end_code, start_data, end_data;
51023 unsigned long reloc_func_desc __maybe_unused = 0;
51024 int executable_stack = EXSTACK_DEFAULT;
51025 - unsigned long def_flags = 0;
51026 struct pt_regs *regs = current_pt_regs();
51027 struct {
51028 struct elfhdr elf_ex;
51029 struct elfhdr interp_elf_ex;
51030 } *loc;
51031 + unsigned long pax_task_size = TASK_SIZE;
51032
51033 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
51034 if (!loc) {
51035 @@ -723,11 +1066,81 @@ static int load_elf_binary(struct linux_binprm *bprm)
51036 goto out_free_dentry;
51037
51038 /* OK, This is the point of no return */
51039 - current->mm->def_flags = def_flags;
51040 +
51041 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
51042 + current->mm->pax_flags = 0UL;
51043 +#endif
51044 +
51045 +#ifdef CONFIG_PAX_DLRESOLVE
51046 + current->mm->call_dl_resolve = 0UL;
51047 +#endif
51048 +
51049 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
51050 + current->mm->call_syscall = 0UL;
51051 +#endif
51052 +
51053 +#ifdef CONFIG_PAX_ASLR
51054 + current->mm->delta_mmap = 0UL;
51055 + current->mm->delta_stack = 0UL;
51056 +#endif
51057 +
51058 + current->mm->def_flags = 0;
51059 +
51060 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
51061 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
51062 + send_sig(SIGKILL, current, 0);
51063 + goto out_free_dentry;
51064 + }
51065 +#endif
51066 +
51067 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
51068 + pax_set_initial_flags(bprm);
51069 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
51070 + if (pax_set_initial_flags_func)
51071 + (pax_set_initial_flags_func)(bprm);
51072 +#endif
51073 +
51074 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
51075 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
51076 + current->mm->context.user_cs_limit = PAGE_SIZE;
51077 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
51078 + }
51079 +#endif
51080 +
51081 +#ifdef CONFIG_PAX_SEGMEXEC
51082 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
51083 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
51084 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
51085 + pax_task_size = SEGMEXEC_TASK_SIZE;
51086 + current->mm->def_flags |= VM_NOHUGEPAGE;
51087 + }
51088 +#endif
51089 +
51090 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
51091 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
51092 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
51093 + put_cpu();
51094 + }
51095 +#endif
51096
51097 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
51098 may depend on the personality. */
51099 SET_PERSONALITY(loc->elf_ex);
51100 +
51101 +#ifdef CONFIG_PAX_ASLR
51102 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
51103 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
51104 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
51105 + }
51106 +#endif
51107 +
51108 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
51109 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
51110 + executable_stack = EXSTACK_DISABLE_X;
51111 + current->personality &= ~READ_IMPLIES_EXEC;
51112 + } else
51113 +#endif
51114 +
51115 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
51116 current->personality |= READ_IMPLIES_EXEC;
51117
51118 @@ -819,6 +1232,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
51119 #else
51120 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
51121 #endif
51122 +
51123 +#ifdef CONFIG_PAX_RANDMMAP
51124 + /* PaX: randomize base address at the default exe base if requested */
51125 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
51126 +#ifdef CONFIG_SPARC64
51127 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
51128 +#else
51129 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
51130 +#endif
51131 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
51132 + elf_flags |= MAP_FIXED;
51133 + }
51134 +#endif
51135 +
51136 }
51137
51138 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
51139 @@ -851,9 +1278,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
51140 * allowed task size. Note that p_filesz must always be
51141 * <= p_memsz so it is only necessary to check p_memsz.
51142 */
51143 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
51144 - elf_ppnt->p_memsz > TASK_SIZE ||
51145 - TASK_SIZE - elf_ppnt->p_memsz < k) {
51146 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
51147 + elf_ppnt->p_memsz > pax_task_size ||
51148 + pax_task_size - elf_ppnt->p_memsz < k) {
51149 /* set_brk can never work. Avoid overflows. */
51150 send_sig(SIGKILL, current, 0);
51151 retval = -EINVAL;
51152 @@ -892,17 +1319,45 @@ static int load_elf_binary(struct linux_binprm *bprm)
51153 goto out_free_dentry;
51154 }
51155 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
51156 - send_sig(SIGSEGV, current, 0);
51157 - retval = -EFAULT; /* Nobody gets to see this, but.. */
51158 - goto out_free_dentry;
51159 + /*
51160 + * This bss-zeroing can fail if the ELF
51161 + * file specifies odd protections. So
51162 + * we don't check the return value
51163 + */
51164 }
51165
51166 +#ifdef CONFIG_PAX_RANDMMAP
51167 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
51168 + unsigned long start, size, flags;
51169 + vm_flags_t vm_flags;
51170 +
51171 + start = ELF_PAGEALIGN(elf_brk);
51172 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
51173 + flags = MAP_FIXED | MAP_PRIVATE;
51174 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
51175 +
51176 + down_write(&current->mm->mmap_sem);
51177 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
51178 + retval = -ENOMEM;
51179 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
51180 +// if (current->personality & ADDR_NO_RANDOMIZE)
51181 +// vm_flags |= VM_READ | VM_MAYREAD;
51182 + start = mmap_region(NULL, start, PAGE_ALIGN(size), vm_flags, 0);
51183 + retval = IS_ERR_VALUE(start) ? start : 0;
51184 + }
51185 + up_write(&current->mm->mmap_sem);
51186 + if (retval == 0)
51187 + retval = set_brk(start + size, start + size + PAGE_SIZE);
51188 + if (retval < 0) {
51189 + send_sig(SIGKILL, current, 0);
51190 + goto out_free_dentry;
51191 + }
51192 + }
51193 +#endif
51194 +
51195 if (elf_interpreter) {
51196 - unsigned long interp_map_addr = 0;
51197 -
51198 elf_entry = load_elf_interp(&loc->interp_elf_ex,
51199 interpreter,
51200 - &interp_map_addr,
51201 load_bias);
51202 if (!IS_ERR((void *)elf_entry)) {
51203 /*
51204 @@ -1124,7 +1579,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
51205 * Decide what to dump of a segment, part, all or none.
51206 */
51207 static unsigned long vma_dump_size(struct vm_area_struct *vma,
51208 - unsigned long mm_flags)
51209 + unsigned long mm_flags, long signr)
51210 {
51211 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
51212
51213 @@ -1162,7 +1617,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
51214 if (vma->vm_file == NULL)
51215 return 0;
51216
51217 - if (FILTER(MAPPED_PRIVATE))
51218 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
51219 goto whole;
51220
51221 /*
51222 @@ -1387,9 +1842,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
51223 {
51224 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
51225 int i = 0;
51226 - do
51227 + do {
51228 i += 2;
51229 - while (auxv[i - 2] != AT_NULL);
51230 + } while (auxv[i - 2] != AT_NULL);
51231 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
51232 }
51233
51234 @@ -1398,7 +1853,7 @@ static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
51235 {
51236 mm_segment_t old_fs = get_fs();
51237 set_fs(KERNEL_DS);
51238 - copy_siginfo_to_user((user_siginfo_t __user *) csigdata, siginfo);
51239 + copy_siginfo_to_user((user_siginfo_t __force_user *) csigdata, siginfo);
51240 set_fs(old_fs);
51241 fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata);
51242 }
51243 @@ -2019,14 +2474,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
51244 }
51245
51246 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
51247 - unsigned long mm_flags)
51248 + struct coredump_params *cprm)
51249 {
51250 struct vm_area_struct *vma;
51251 size_t size = 0;
51252
51253 for (vma = first_vma(current, gate_vma); vma != NULL;
51254 vma = next_vma(vma, gate_vma))
51255 - size += vma_dump_size(vma, mm_flags);
51256 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
51257 return size;
51258 }
51259
51260 @@ -2119,7 +2574,7 @@ static int elf_core_dump(struct coredump_params *cprm)
51261
51262 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
51263
51264 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
51265 + offset += elf_core_vma_data_size(gate_vma, cprm);
51266 offset += elf_core_extra_data_size();
51267 e_shoff = offset;
51268
51269 @@ -2133,10 +2588,12 @@ static int elf_core_dump(struct coredump_params *cprm)
51270 offset = dataoff;
51271
51272 size += sizeof(*elf);
51273 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
51274 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
51275 goto end_coredump;
51276
51277 size += sizeof(*phdr4note);
51278 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
51279 if (size > cprm->limit
51280 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
51281 goto end_coredump;
51282 @@ -2150,7 +2607,7 @@ static int elf_core_dump(struct coredump_params *cprm)
51283 phdr.p_offset = offset;
51284 phdr.p_vaddr = vma->vm_start;
51285 phdr.p_paddr = 0;
51286 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
51287 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
51288 phdr.p_memsz = vma->vm_end - vma->vm_start;
51289 offset += phdr.p_filesz;
51290 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
51291 @@ -2161,6 +2618,7 @@ static int elf_core_dump(struct coredump_params *cprm)
51292 phdr.p_align = ELF_EXEC_PAGESIZE;
51293
51294 size += sizeof(phdr);
51295 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
51296 if (size > cprm->limit
51297 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
51298 goto end_coredump;
51299 @@ -2185,7 +2643,7 @@ static int elf_core_dump(struct coredump_params *cprm)
51300 unsigned long addr;
51301 unsigned long end;
51302
51303 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
51304 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
51305
51306 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
51307 struct page *page;
51308 @@ -2194,6 +2652,7 @@ static int elf_core_dump(struct coredump_params *cprm)
51309 page = get_dump_page(addr);
51310 if (page) {
51311 void *kaddr = kmap(page);
51312 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
51313 stop = ((size += PAGE_SIZE) > cprm->limit) ||
51314 !dump_write(cprm->file, kaddr,
51315 PAGE_SIZE);
51316 @@ -2211,6 +2670,7 @@ static int elf_core_dump(struct coredump_params *cprm)
51317
51318 if (e_phnum == PN_XNUM) {
51319 size += sizeof(*shdr4extnum);
51320 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
51321 if (size > cprm->limit
51322 || !dump_write(cprm->file, shdr4extnum,
51323 sizeof(*shdr4extnum)))
51324 @@ -2231,6 +2691,167 @@ out:
51325
51326 #endif /* CONFIG_ELF_CORE */
51327
51328 +#ifdef CONFIG_PAX_MPROTECT
51329 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
51330 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
51331 + * we'll remove VM_MAYWRITE for good on RELRO segments.
51332 + *
51333 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
51334 + * basis because we want to allow the common case and not the special ones.
51335 + */
51336 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
51337 +{
51338 + struct elfhdr elf_h;
51339 + struct elf_phdr elf_p;
51340 + unsigned long i;
51341 + unsigned long oldflags;
51342 + bool is_textrel_rw, is_textrel_rx, is_relro;
51343 +
51344 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT) || !vma->vm_file)
51345 + return;
51346 +
51347 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
51348 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
51349 +
51350 +#ifdef CONFIG_PAX_ELFRELOCS
51351 + /* possible TEXTREL */
51352 + is_textrel_rw = !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
51353 + is_textrel_rx = vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_WRITE | VM_READ) && newflags == (VM_EXEC | VM_READ);
51354 +#else
51355 + is_textrel_rw = false;
51356 + is_textrel_rx = false;
51357 +#endif
51358 +
51359 + /* possible RELRO */
51360 + is_relro = vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
51361 +
51362 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
51363 + return;
51364 +
51365 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
51366 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
51367 +
51368 +#ifdef CONFIG_PAX_ETEXECRELOCS
51369 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
51370 +#else
51371 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
51372 +#endif
51373 +
51374 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
51375 + !elf_check_arch(&elf_h) ||
51376 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
51377 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
51378 + return;
51379 +
51380 + for (i = 0UL; i < elf_h.e_phnum; i++) {
51381 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
51382 + return;
51383 + switch (elf_p.p_type) {
51384 + case PT_DYNAMIC:
51385 + if (!is_textrel_rw && !is_textrel_rx)
51386 + continue;
51387 + i = 0UL;
51388 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
51389 + elf_dyn dyn;
51390 +
51391 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
51392 + break;
51393 + if (dyn.d_tag == DT_NULL)
51394 + break;
51395 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
51396 + gr_log_textrel(vma);
51397 + if (is_textrel_rw)
51398 + vma->vm_flags |= VM_MAYWRITE;
51399 + else
51400 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
51401 + vma->vm_flags &= ~VM_MAYWRITE;
51402 + break;
51403 + }
51404 + i++;
51405 + }
51406 + is_textrel_rw = false;
51407 + is_textrel_rx = false;
51408 + continue;
51409 +
51410 + case PT_GNU_RELRO:
51411 + if (!is_relro)
51412 + continue;
51413 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
51414 + vma->vm_flags &= ~VM_MAYWRITE;
51415 + is_relro = false;
51416 + continue;
51417 +
51418 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
51419 + case PT_PAX_FLAGS: {
51420 + const char *msg_mprotect = "", *msg_emutramp = "";
51421 + char *buffer_lib, *buffer_exe;
51422 +
51423 + if (elf_p.p_flags & PF_NOMPROTECT)
51424 + msg_mprotect = "MPROTECT disabled";
51425 +
51426 +#ifdef CONFIG_PAX_EMUTRAMP
51427 + if (!(vma->vm_mm->pax_flags & MF_PAX_EMUTRAMP) && !(elf_p.p_flags & PF_NOEMUTRAMP))
51428 + msg_emutramp = "EMUTRAMP enabled";
51429 +#endif
51430 +
51431 + if (!msg_mprotect[0] && !msg_emutramp[0])
51432 + continue;
51433 +
51434 + if (!printk_ratelimit())
51435 + continue;
51436 +
51437 + buffer_lib = (char *)__get_free_page(GFP_KERNEL);
51438 + buffer_exe = (char *)__get_free_page(GFP_KERNEL);
51439 + if (buffer_lib && buffer_exe) {
51440 + char *path_lib, *path_exe;
51441 +
51442 + path_lib = pax_get_path(&vma->vm_file->f_path, buffer_lib, PAGE_SIZE);
51443 + path_exe = pax_get_path(&vma->vm_mm->exe_file->f_path, buffer_exe, PAGE_SIZE);
51444 +
51445 + pr_info("PAX: %s wants %s%s%s on %s\n", path_lib, msg_mprotect,
51446 + (msg_mprotect[0] && msg_emutramp[0] ? " and " : ""), msg_emutramp, path_exe);
51447 +
51448 + }
51449 + free_page((unsigned long)buffer_exe);
51450 + free_page((unsigned long)buffer_lib);
51451 + continue;
51452 + }
51453 +#endif
51454 +
51455 + }
51456 + }
51457 +}
51458 +#endif
51459 +
51460 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
51461 +
51462 +extern int grsec_enable_log_rwxmaps;
51463 +
51464 +static void elf_handle_mmap(struct file *file)
51465 +{
51466 + struct elfhdr elf_h;
51467 + struct elf_phdr elf_p;
51468 + unsigned long i;
51469 +
51470 + if (!grsec_enable_log_rwxmaps)
51471 + return;
51472 +
51473 + if (sizeof(elf_h) != kernel_read(file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
51474 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
51475 + (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC) || !elf_check_arch(&elf_h) ||
51476 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
51477 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
51478 + return;
51479 +
51480 + for (i = 0UL; i < elf_h.e_phnum; i++) {
51481 + if (sizeof(elf_p) != kernel_read(file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
51482 + return;
51483 + if (elf_p.p_type == PT_GNU_STACK && (elf_p.p_flags & PF_X))
51484 + gr_log_ptgnustack(file);
51485 + }
51486 +}
51487 +#endif
51488 +
51489 static int __init init_elf_binfmt(void)
51490 {
51491 register_binfmt(&elf_format);
51492 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
51493 index d50bbe5..af3b649 100644
51494 --- a/fs/binfmt_flat.c
51495 +++ b/fs/binfmt_flat.c
51496 @@ -566,7 +566,9 @@ static int load_flat_file(struct linux_binprm * bprm,
51497 realdatastart = (unsigned long) -ENOMEM;
51498 printk("Unable to allocate RAM for process data, errno %d\n",
51499 (int)-realdatastart);
51500 + down_write(&current->mm->mmap_sem);
51501 vm_munmap(textpos, text_len);
51502 + up_write(&current->mm->mmap_sem);
51503 ret = realdatastart;
51504 goto err;
51505 }
51506 @@ -590,8 +592,10 @@ static int load_flat_file(struct linux_binprm * bprm,
51507 }
51508 if (IS_ERR_VALUE(result)) {
51509 printk("Unable to read data+bss, errno %d\n", (int)-result);
51510 + down_write(&current->mm->mmap_sem);
51511 vm_munmap(textpos, text_len);
51512 vm_munmap(realdatastart, len);
51513 + up_write(&current->mm->mmap_sem);
51514 ret = result;
51515 goto err;
51516 }
51517 @@ -653,8 +657,10 @@ static int load_flat_file(struct linux_binprm * bprm,
51518 }
51519 if (IS_ERR_VALUE(result)) {
51520 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
51521 + down_write(&current->mm->mmap_sem);
51522 vm_munmap(textpos, text_len + data_len + extra +
51523 MAX_SHARED_LIBS * sizeof(unsigned long));
51524 + up_write(&current->mm->mmap_sem);
51525 ret = result;
51526 goto err;
51527 }
51528 diff --git a/fs/bio.c b/fs/bio.c
51529 index 94bbc04..6fe78a4 100644
51530 --- a/fs/bio.c
51531 +++ b/fs/bio.c
51532 @@ -1096,7 +1096,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
51533 /*
51534 * Overflow, abort
51535 */
51536 - if (end < start)
51537 + if (end < start || end - start > INT_MAX - nr_pages)
51538 return ERR_PTR(-EINVAL);
51539
51540 nr_pages += end - start;
51541 @@ -1230,7 +1230,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
51542 /*
51543 * Overflow, abort
51544 */
51545 - if (end < start)
51546 + if (end < start || end - start > INT_MAX - nr_pages)
51547 return ERR_PTR(-EINVAL);
51548
51549 nr_pages += end - start;
51550 @@ -1492,7 +1492,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
51551 const int read = bio_data_dir(bio) == READ;
51552 struct bio_map_data *bmd = bio->bi_private;
51553 int i;
51554 - char *p = bmd->sgvecs[0].iov_base;
51555 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
51556
51557 bio_for_each_segment_all(bvec, bio, i) {
51558 char *addr = page_address(bvec->bv_page);
51559 diff --git a/fs/block_dev.c b/fs/block_dev.c
51560 index 85f5c85..d6f0b1a 100644
51561 --- a/fs/block_dev.c
51562 +++ b/fs/block_dev.c
51563 @@ -658,7 +658,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
51564 else if (bdev->bd_contains == bdev)
51565 return true; /* is a whole device which isn't held */
51566
51567 - else if (whole->bd_holder == bd_may_claim)
51568 + else if (whole->bd_holder == (void *)bd_may_claim)
51569 return true; /* is a partition of a device that is being partitioned */
51570 else if (whole->bd_holder != NULL)
51571 return false; /* is a partition of a held device */
51572 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
51573 index 7fb054b..ad36c67 100644
51574 --- a/fs/btrfs/ctree.c
51575 +++ b/fs/btrfs/ctree.c
51576 @@ -1076,9 +1076,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
51577 free_extent_buffer(buf);
51578 add_root_to_dirty_list(root);
51579 } else {
51580 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
51581 - parent_start = parent->start;
51582 - else
51583 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
51584 + if (parent)
51585 + parent_start = parent->start;
51586 + else
51587 + parent_start = 0;
51588 + } else
51589 parent_start = 0;
51590
51591 WARN_ON(trans->transid != btrfs_header_generation(parent));
51592 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
51593 index 0f81d67..0ad55fe 100644
51594 --- a/fs/btrfs/ioctl.c
51595 +++ b/fs/btrfs/ioctl.c
51596 @@ -3084,9 +3084,12 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
51597 for (i = 0; i < num_types; i++) {
51598 struct btrfs_space_info *tmp;
51599
51600 + /* Don't copy in more than we allocated */
51601 if (!slot_count)
51602 break;
51603
51604 + slot_count--;
51605 +
51606 info = NULL;
51607 rcu_read_lock();
51608 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
51609 @@ -3108,10 +3111,7 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
51610 memcpy(dest, &space, sizeof(space));
51611 dest++;
51612 space_args.total_spaces++;
51613 - slot_count--;
51614 }
51615 - if (!slot_count)
51616 - break;
51617 }
51618 up_read(&info->groups_sem);
51619 }
51620 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
51621 index f0857e0..e7023c5 100644
51622 --- a/fs/btrfs/super.c
51623 +++ b/fs/btrfs/super.c
51624 @@ -265,7 +265,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
51625 function, line, errstr);
51626 return;
51627 }
51628 - ACCESS_ONCE(trans->transaction->aborted) = errno;
51629 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
51630 __btrfs_std_error(root->fs_info, function, line, errno, NULL);
51631 }
51632 /*
51633 diff --git a/fs/buffer.c b/fs/buffer.c
51634 index d2a4d1b..df798ca 100644
51635 --- a/fs/buffer.c
51636 +++ b/fs/buffer.c
51637 @@ -3367,7 +3367,7 @@ void __init buffer_init(void)
51638 bh_cachep = kmem_cache_create("buffer_head",
51639 sizeof(struct buffer_head), 0,
51640 (SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|
51641 - SLAB_MEM_SPREAD),
51642 + SLAB_MEM_SPREAD|SLAB_NO_SANITIZE),
51643 NULL);
51644
51645 /*
51646 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
51647 index 622f469..e8d2d55 100644
51648 --- a/fs/cachefiles/bind.c
51649 +++ b/fs/cachefiles/bind.c
51650 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
51651 args);
51652
51653 /* start by checking things over */
51654 - ASSERT(cache->fstop_percent >= 0 &&
51655 - cache->fstop_percent < cache->fcull_percent &&
51656 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
51657 cache->fcull_percent < cache->frun_percent &&
51658 cache->frun_percent < 100);
51659
51660 - ASSERT(cache->bstop_percent >= 0 &&
51661 - cache->bstop_percent < cache->bcull_percent &&
51662 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
51663 cache->bcull_percent < cache->brun_percent &&
51664 cache->brun_percent < 100);
51665
51666 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
51667 index 0a1467b..6a53245 100644
51668 --- a/fs/cachefiles/daemon.c
51669 +++ b/fs/cachefiles/daemon.c
51670 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
51671 if (n > buflen)
51672 return -EMSGSIZE;
51673
51674 - if (copy_to_user(_buffer, buffer, n) != 0)
51675 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
51676 return -EFAULT;
51677
51678 return n;
51679 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
51680 if (test_bit(CACHEFILES_DEAD, &cache->flags))
51681 return -EIO;
51682
51683 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
51684 + if (datalen > PAGE_SIZE - 1)
51685 return -EOPNOTSUPP;
51686
51687 /* drag the command string into the kernel so we can parse it */
51688 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
51689 if (args[0] != '%' || args[1] != '\0')
51690 return -EINVAL;
51691
51692 - if (fstop < 0 || fstop >= cache->fcull_percent)
51693 + if (fstop >= cache->fcull_percent)
51694 return cachefiles_daemon_range_error(cache, args);
51695
51696 cache->fstop_percent = fstop;
51697 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
51698 if (args[0] != '%' || args[1] != '\0')
51699 return -EINVAL;
51700
51701 - if (bstop < 0 || bstop >= cache->bcull_percent)
51702 + if (bstop >= cache->bcull_percent)
51703 return cachefiles_daemon_range_error(cache, args);
51704
51705 cache->bstop_percent = bstop;
51706 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
51707 index 4938251..7e01445 100644
51708 --- a/fs/cachefiles/internal.h
51709 +++ b/fs/cachefiles/internal.h
51710 @@ -59,7 +59,7 @@ struct cachefiles_cache {
51711 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
51712 struct rb_root active_nodes; /* active nodes (can't be culled) */
51713 rwlock_t active_lock; /* lock for active_nodes */
51714 - atomic_t gravecounter; /* graveyard uniquifier */
51715 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
51716 unsigned frun_percent; /* when to stop culling (% files) */
51717 unsigned fcull_percent; /* when to start culling (% files) */
51718 unsigned fstop_percent; /* when to stop allocating (% files) */
51719 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
51720 * proc.c
51721 */
51722 #ifdef CONFIG_CACHEFILES_HISTOGRAM
51723 -extern atomic_t cachefiles_lookup_histogram[HZ];
51724 -extern atomic_t cachefiles_mkdir_histogram[HZ];
51725 -extern atomic_t cachefiles_create_histogram[HZ];
51726 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
51727 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
51728 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
51729
51730 extern int __init cachefiles_proc_init(void);
51731 extern void cachefiles_proc_cleanup(void);
51732 static inline
51733 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
51734 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
51735 {
51736 unsigned long jif = jiffies - start_jif;
51737 if (jif >= HZ)
51738 jif = HZ - 1;
51739 - atomic_inc(&histogram[jif]);
51740 + atomic_inc_unchecked(&histogram[jif]);
51741 }
51742
51743 #else
51744 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
51745 index 8c01c5fc..15f982e 100644
51746 --- a/fs/cachefiles/namei.c
51747 +++ b/fs/cachefiles/namei.c
51748 @@ -317,7 +317,7 @@ try_again:
51749 /* first step is to make up a grave dentry in the graveyard */
51750 sprintf(nbuffer, "%08x%08x",
51751 (uint32_t) get_seconds(),
51752 - (uint32_t) atomic_inc_return(&cache->gravecounter));
51753 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
51754
51755 /* do the multiway lock magic */
51756 trap = lock_rename(cache->graveyard, dir);
51757 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
51758 index eccd339..4c1d995 100644
51759 --- a/fs/cachefiles/proc.c
51760 +++ b/fs/cachefiles/proc.c
51761 @@ -14,9 +14,9 @@
51762 #include <linux/seq_file.h>
51763 #include "internal.h"
51764
51765 -atomic_t cachefiles_lookup_histogram[HZ];
51766 -atomic_t cachefiles_mkdir_histogram[HZ];
51767 -atomic_t cachefiles_create_histogram[HZ];
51768 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
51769 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
51770 +atomic_unchecked_t cachefiles_create_histogram[HZ];
51771
51772 /*
51773 * display the latency histogram
51774 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
51775 return 0;
51776 default:
51777 index = (unsigned long) v - 3;
51778 - x = atomic_read(&cachefiles_lookup_histogram[index]);
51779 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
51780 - z = atomic_read(&cachefiles_create_histogram[index]);
51781 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
51782 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
51783 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
51784 if (x == 0 && y == 0 && z == 0)
51785 return 0;
51786
51787 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
51788 index 317f9ee..3d24511 100644
51789 --- a/fs/cachefiles/rdwr.c
51790 +++ b/fs/cachefiles/rdwr.c
51791 @@ -966,7 +966,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
51792 old_fs = get_fs();
51793 set_fs(KERNEL_DS);
51794 ret = file->f_op->write(
51795 - file, (const void __user *) data, len, &pos);
51796 + file, (const void __force_user *) data, len, &pos);
51797 set_fs(old_fs);
51798 kunmap(page);
51799 file_end_write(file);
51800 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
51801 index f02d82b..2632cf86 100644
51802 --- a/fs/ceph/dir.c
51803 +++ b/fs/ceph/dir.c
51804 @@ -243,7 +243,7 @@ static int ceph_readdir(struct file *filp, void *dirent, filldir_t filldir)
51805 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
51806 struct ceph_mds_client *mdsc = fsc->mdsc;
51807 unsigned frag = fpos_frag(filp->f_pos);
51808 - int off = fpos_off(filp->f_pos);
51809 + unsigned int off = fpos_off(filp->f_pos);
51810 int err;
51811 u32 ftype;
51812 struct ceph_mds_reply_info_parsed *rinfo;
51813 diff --git a/fs/ceph/super.c b/fs/ceph/super.c
51814 index 7d377c9..3fb6559 100644
51815 --- a/fs/ceph/super.c
51816 +++ b/fs/ceph/super.c
51817 @@ -839,7 +839,7 @@ static int ceph_compare_super(struct super_block *sb, void *data)
51818 /*
51819 * construct our own bdi so we can control readahead, etc.
51820 */
51821 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
51822 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
51823
51824 static int ceph_register_bdi(struct super_block *sb,
51825 struct ceph_fs_client *fsc)
51826 @@ -856,7 +856,7 @@ static int ceph_register_bdi(struct super_block *sb,
51827 default_backing_dev_info.ra_pages;
51828
51829 err = bdi_register(&fsc->backing_dev_info, NULL, "ceph-%ld",
51830 - atomic_long_inc_return(&bdi_seq));
51831 + atomic_long_inc_return_unchecked(&bdi_seq));
51832 if (!err)
51833 sb->s_bdi = &fsc->backing_dev_info;
51834 return err;
51835 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
51836 index d597483..747901b 100644
51837 --- a/fs/cifs/cifs_debug.c
51838 +++ b/fs/cifs/cifs_debug.c
51839 @@ -284,8 +284,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
51840
51841 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
51842 #ifdef CONFIG_CIFS_STATS2
51843 - atomic_set(&totBufAllocCount, 0);
51844 - atomic_set(&totSmBufAllocCount, 0);
51845 + atomic_set_unchecked(&totBufAllocCount, 0);
51846 + atomic_set_unchecked(&totSmBufAllocCount, 0);
51847 #endif /* CONFIG_CIFS_STATS2 */
51848 spin_lock(&cifs_tcp_ses_lock);
51849 list_for_each(tmp1, &cifs_tcp_ses_list) {
51850 @@ -298,7 +298,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
51851 tcon = list_entry(tmp3,
51852 struct cifs_tcon,
51853 tcon_list);
51854 - atomic_set(&tcon->num_smbs_sent, 0);
51855 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
51856 if (server->ops->clear_stats)
51857 server->ops->clear_stats(tcon);
51858 }
51859 @@ -330,8 +330,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
51860 smBufAllocCount.counter, cifs_min_small);
51861 #ifdef CONFIG_CIFS_STATS2
51862 seq_printf(m, "Total Large %d Small %d Allocations\n",
51863 - atomic_read(&totBufAllocCount),
51864 - atomic_read(&totSmBufAllocCount));
51865 + atomic_read_unchecked(&totBufAllocCount),
51866 + atomic_read_unchecked(&totSmBufAllocCount));
51867 #endif /* CONFIG_CIFS_STATS2 */
51868
51869 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
51870 @@ -360,7 +360,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
51871 if (tcon->need_reconnect)
51872 seq_puts(m, "\tDISCONNECTED ");
51873 seq_printf(m, "\nSMBs: %d",
51874 - atomic_read(&tcon->num_smbs_sent));
51875 + atomic_read_unchecked(&tcon->num_smbs_sent));
51876 if (server->ops->print_stats)
51877 server->ops->print_stats(m, tcon);
51878 }
51879 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
51880 index 3752b9f..8db5569 100644
51881 --- a/fs/cifs/cifsfs.c
51882 +++ b/fs/cifs/cifsfs.c
51883 @@ -1035,7 +1035,7 @@ cifs_init_request_bufs(void)
51884 */
51885 cifs_req_cachep = kmem_cache_create("cifs_request",
51886 CIFSMaxBufSize + max_hdr_size, 0,
51887 - SLAB_HWCACHE_ALIGN, NULL);
51888 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
51889 if (cifs_req_cachep == NULL)
51890 return -ENOMEM;
51891
51892 @@ -1062,7 +1062,7 @@ cifs_init_request_bufs(void)
51893 efficient to alloc 1 per page off the slab compared to 17K (5page)
51894 alloc of large cifs buffers even when page debugging is on */
51895 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
51896 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
51897 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
51898 NULL);
51899 if (cifs_sm_req_cachep == NULL) {
51900 mempool_destroy(cifs_req_poolp);
51901 @@ -1147,8 +1147,8 @@ init_cifs(void)
51902 atomic_set(&bufAllocCount, 0);
51903 atomic_set(&smBufAllocCount, 0);
51904 #ifdef CONFIG_CIFS_STATS2
51905 - atomic_set(&totBufAllocCount, 0);
51906 - atomic_set(&totSmBufAllocCount, 0);
51907 + atomic_set_unchecked(&totBufAllocCount, 0);
51908 + atomic_set_unchecked(&totSmBufAllocCount, 0);
51909 #endif /* CONFIG_CIFS_STATS2 */
51910
51911 atomic_set(&midCount, 0);
51912 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
51913 index ea3a0b3..0194e39 100644
51914 --- a/fs/cifs/cifsglob.h
51915 +++ b/fs/cifs/cifsglob.h
51916 @@ -752,35 +752,35 @@ struct cifs_tcon {
51917 __u16 Flags; /* optional support bits */
51918 enum statusEnum tidStatus;
51919 #ifdef CONFIG_CIFS_STATS
51920 - atomic_t num_smbs_sent;
51921 + atomic_unchecked_t num_smbs_sent;
51922 union {
51923 struct {
51924 - atomic_t num_writes;
51925 - atomic_t num_reads;
51926 - atomic_t num_flushes;
51927 - atomic_t num_oplock_brks;
51928 - atomic_t num_opens;
51929 - atomic_t num_closes;
51930 - atomic_t num_deletes;
51931 - atomic_t num_mkdirs;
51932 - atomic_t num_posixopens;
51933 - atomic_t num_posixmkdirs;
51934 - atomic_t num_rmdirs;
51935 - atomic_t num_renames;
51936 - atomic_t num_t2renames;
51937 - atomic_t num_ffirst;
51938 - atomic_t num_fnext;
51939 - atomic_t num_fclose;
51940 - atomic_t num_hardlinks;
51941 - atomic_t num_symlinks;
51942 - atomic_t num_locks;
51943 - atomic_t num_acl_get;
51944 - atomic_t num_acl_set;
51945 + atomic_unchecked_t num_writes;
51946 + atomic_unchecked_t num_reads;
51947 + atomic_unchecked_t num_flushes;
51948 + atomic_unchecked_t num_oplock_brks;
51949 + atomic_unchecked_t num_opens;
51950 + atomic_unchecked_t num_closes;
51951 + atomic_unchecked_t num_deletes;
51952 + atomic_unchecked_t num_mkdirs;
51953 + atomic_unchecked_t num_posixopens;
51954 + atomic_unchecked_t num_posixmkdirs;
51955 + atomic_unchecked_t num_rmdirs;
51956 + atomic_unchecked_t num_renames;
51957 + atomic_unchecked_t num_t2renames;
51958 + atomic_unchecked_t num_ffirst;
51959 + atomic_unchecked_t num_fnext;
51960 + atomic_unchecked_t num_fclose;
51961 + atomic_unchecked_t num_hardlinks;
51962 + atomic_unchecked_t num_symlinks;
51963 + atomic_unchecked_t num_locks;
51964 + atomic_unchecked_t num_acl_get;
51965 + atomic_unchecked_t num_acl_set;
51966 } cifs_stats;
51967 #ifdef CONFIG_CIFS_SMB2
51968 struct {
51969 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
51970 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
51971 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
51972 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
51973 } smb2_stats;
51974 #endif /* CONFIG_CIFS_SMB2 */
51975 } stats;
51976 @@ -1081,7 +1081,7 @@ convert_delimiter(char *path, char delim)
51977 }
51978
51979 #ifdef CONFIG_CIFS_STATS
51980 -#define cifs_stats_inc atomic_inc
51981 +#define cifs_stats_inc atomic_inc_unchecked
51982
51983 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
51984 unsigned int bytes)
51985 @@ -1446,8 +1446,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
51986 /* Various Debug counters */
51987 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
51988 #ifdef CONFIG_CIFS_STATS2
51989 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
51990 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
51991 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
51992 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
51993 #endif
51994 GLOBAL_EXTERN atomic_t smBufAllocCount;
51995 GLOBAL_EXTERN atomic_t midCount;
51996 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
51997 index b83c3f5..6437caa 100644
51998 --- a/fs/cifs/link.c
51999 +++ b/fs/cifs/link.c
52000 @@ -616,7 +616,7 @@ symlink_exit:
52001
52002 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
52003 {
52004 - char *p = nd_get_link(nd);
52005 + const char *p = nd_get_link(nd);
52006 if (!IS_ERR(p))
52007 kfree(p);
52008 }
52009 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
52010 index 1bec014..f329411 100644
52011 --- a/fs/cifs/misc.c
52012 +++ b/fs/cifs/misc.c
52013 @@ -169,7 +169,7 @@ cifs_buf_get(void)
52014 memset(ret_buf, 0, buf_size + 3);
52015 atomic_inc(&bufAllocCount);
52016 #ifdef CONFIG_CIFS_STATS2
52017 - atomic_inc(&totBufAllocCount);
52018 + atomic_inc_unchecked(&totBufAllocCount);
52019 #endif /* CONFIG_CIFS_STATS2 */
52020 }
52021
52022 @@ -204,7 +204,7 @@ cifs_small_buf_get(void)
52023 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
52024 atomic_inc(&smBufAllocCount);
52025 #ifdef CONFIG_CIFS_STATS2
52026 - atomic_inc(&totSmBufAllocCount);
52027 + atomic_inc_unchecked(&totSmBufAllocCount);
52028 #endif /* CONFIG_CIFS_STATS2 */
52029
52030 }
52031 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
52032 index 3efdb9d..e845a5e 100644
52033 --- a/fs/cifs/smb1ops.c
52034 +++ b/fs/cifs/smb1ops.c
52035 @@ -591,27 +591,27 @@ static void
52036 cifs_clear_stats(struct cifs_tcon *tcon)
52037 {
52038 #ifdef CONFIG_CIFS_STATS
52039 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
52040 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
52041 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
52042 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
52043 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
52044 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
52045 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
52046 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
52047 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
52048 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
52049 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
52050 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
52051 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
52052 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
52053 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
52054 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
52055 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
52056 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
52057 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
52058 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
52059 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
52060 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
52061 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
52062 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
52063 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
52064 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
52065 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
52066 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
52067 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
52068 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
52069 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
52070 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
52071 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
52072 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
52073 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
52074 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
52075 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
52076 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
52077 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
52078 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
52079 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
52080 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
52081 #endif
52082 }
52083
52084 @@ -620,36 +620,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
52085 {
52086 #ifdef CONFIG_CIFS_STATS
52087 seq_printf(m, " Oplocks breaks: %d",
52088 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
52089 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
52090 seq_printf(m, "\nReads: %d Bytes: %llu",
52091 - atomic_read(&tcon->stats.cifs_stats.num_reads),
52092 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
52093 (long long)(tcon->bytes_read));
52094 seq_printf(m, "\nWrites: %d Bytes: %llu",
52095 - atomic_read(&tcon->stats.cifs_stats.num_writes),
52096 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
52097 (long long)(tcon->bytes_written));
52098 seq_printf(m, "\nFlushes: %d",
52099 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
52100 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
52101 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
52102 - atomic_read(&tcon->stats.cifs_stats.num_locks),
52103 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
52104 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
52105 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
52106 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
52107 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
52108 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
52109 - atomic_read(&tcon->stats.cifs_stats.num_opens),
52110 - atomic_read(&tcon->stats.cifs_stats.num_closes),
52111 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
52112 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
52113 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
52114 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
52115 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
52116 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
52117 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
52118 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
52119 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
52120 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
52121 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
52122 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
52123 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
52124 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
52125 seq_printf(m, "\nRenames: %d T2 Renames %d",
52126 - atomic_read(&tcon->stats.cifs_stats.num_renames),
52127 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
52128 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
52129 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
52130 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
52131 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
52132 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
52133 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
52134 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
52135 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
52136 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
52137 #endif
52138 }
52139
52140 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
52141 index f2e76f3..c44fac7 100644
52142 --- a/fs/cifs/smb2ops.c
52143 +++ b/fs/cifs/smb2ops.c
52144 @@ -274,8 +274,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
52145 #ifdef CONFIG_CIFS_STATS
52146 int i;
52147 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
52148 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
52149 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
52150 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
52151 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
52152 }
52153 #endif
52154 }
52155 @@ -284,66 +284,66 @@ static void
52156 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
52157 {
52158 #ifdef CONFIG_CIFS_STATS
52159 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
52160 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
52161 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
52162 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
52163 seq_printf(m, "\nNegotiates: %d sent %d failed",
52164 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
52165 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
52166 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
52167 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
52168 seq_printf(m, "\nSessionSetups: %d sent %d failed",
52169 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
52170 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
52171 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
52172 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
52173 #define SMB2LOGOFF 0x0002 /* trivial request/resp */
52174 seq_printf(m, "\nLogoffs: %d sent %d failed",
52175 - atomic_read(&sent[SMB2_LOGOFF_HE]),
52176 - atomic_read(&failed[SMB2_LOGOFF_HE]));
52177 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
52178 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
52179 seq_printf(m, "\nTreeConnects: %d sent %d failed",
52180 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
52181 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
52182 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
52183 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
52184 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
52185 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
52186 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
52187 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
52188 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
52189 seq_printf(m, "\nCreates: %d sent %d failed",
52190 - atomic_read(&sent[SMB2_CREATE_HE]),
52191 - atomic_read(&failed[SMB2_CREATE_HE]));
52192 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
52193 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
52194 seq_printf(m, "\nCloses: %d sent %d failed",
52195 - atomic_read(&sent[SMB2_CLOSE_HE]),
52196 - atomic_read(&failed[SMB2_CLOSE_HE]));
52197 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
52198 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
52199 seq_printf(m, "\nFlushes: %d sent %d failed",
52200 - atomic_read(&sent[SMB2_FLUSH_HE]),
52201 - atomic_read(&failed[SMB2_FLUSH_HE]));
52202 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
52203 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
52204 seq_printf(m, "\nReads: %d sent %d failed",
52205 - atomic_read(&sent[SMB2_READ_HE]),
52206 - atomic_read(&failed[SMB2_READ_HE]));
52207 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
52208 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
52209 seq_printf(m, "\nWrites: %d sent %d failed",
52210 - atomic_read(&sent[SMB2_WRITE_HE]),
52211 - atomic_read(&failed[SMB2_WRITE_HE]));
52212 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
52213 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
52214 seq_printf(m, "\nLocks: %d sent %d failed",
52215 - atomic_read(&sent[SMB2_LOCK_HE]),
52216 - atomic_read(&failed[SMB2_LOCK_HE]));
52217 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
52218 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
52219 seq_printf(m, "\nIOCTLs: %d sent %d failed",
52220 - atomic_read(&sent[SMB2_IOCTL_HE]),
52221 - atomic_read(&failed[SMB2_IOCTL_HE]));
52222 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
52223 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
52224 seq_printf(m, "\nCancels: %d sent %d failed",
52225 - atomic_read(&sent[SMB2_CANCEL_HE]),
52226 - atomic_read(&failed[SMB2_CANCEL_HE]));
52227 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
52228 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
52229 seq_printf(m, "\nEchos: %d sent %d failed",
52230 - atomic_read(&sent[SMB2_ECHO_HE]),
52231 - atomic_read(&failed[SMB2_ECHO_HE]));
52232 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
52233 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
52234 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
52235 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
52236 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
52237 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
52238 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
52239 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
52240 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
52241 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
52242 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
52243 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
52244 seq_printf(m, "\nQueryInfos: %d sent %d failed",
52245 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
52246 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
52247 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
52248 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
52249 seq_printf(m, "\nSetInfos: %d sent %d failed",
52250 - atomic_read(&sent[SMB2_SET_INFO_HE]),
52251 - atomic_read(&failed[SMB2_SET_INFO_HE]));
52252 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
52253 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
52254 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
52255 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
52256 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
52257 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
52258 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
52259 #endif
52260 }
52261
52262 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
52263 index 2b95ce2..d079d75 100644
52264 --- a/fs/cifs/smb2pdu.c
52265 +++ b/fs/cifs/smb2pdu.c
52266 @@ -1760,8 +1760,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
52267 default:
52268 cifs_dbg(VFS, "info level %u isn't supported\n",
52269 srch_inf->info_level);
52270 - rc = -EINVAL;
52271 - goto qdir_exit;
52272 + return -EINVAL;
52273 }
52274
52275 req->FileIndex = cpu_to_le32(index);
52276 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
52277 index 1da168c..8bc7ff6 100644
52278 --- a/fs/coda/cache.c
52279 +++ b/fs/coda/cache.c
52280 @@ -24,7 +24,7 @@
52281 #include "coda_linux.h"
52282 #include "coda_cache.h"
52283
52284 -static atomic_t permission_epoch = ATOMIC_INIT(0);
52285 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
52286
52287 /* replace or extend an acl cache hit */
52288 void coda_cache_enter(struct inode *inode, int mask)
52289 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
52290 struct coda_inode_info *cii = ITOC(inode);
52291
52292 spin_lock(&cii->c_lock);
52293 - cii->c_cached_epoch = atomic_read(&permission_epoch);
52294 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
52295 if (!uid_eq(cii->c_uid, current_fsuid())) {
52296 cii->c_uid = current_fsuid();
52297 cii->c_cached_perm = mask;
52298 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
52299 {
52300 struct coda_inode_info *cii = ITOC(inode);
52301 spin_lock(&cii->c_lock);
52302 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
52303 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
52304 spin_unlock(&cii->c_lock);
52305 }
52306
52307 /* remove all acl caches */
52308 void coda_cache_clear_all(struct super_block *sb)
52309 {
52310 - atomic_inc(&permission_epoch);
52311 + atomic_inc_unchecked(&permission_epoch);
52312 }
52313
52314
52315 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
52316 spin_lock(&cii->c_lock);
52317 hit = (mask & cii->c_cached_perm) == mask &&
52318 uid_eq(cii->c_uid, current_fsuid()) &&
52319 - cii->c_cached_epoch == atomic_read(&permission_epoch);
52320 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
52321 spin_unlock(&cii->c_lock);
52322
52323 return hit;
52324 diff --git a/fs/compat.c b/fs/compat.c
52325 index fc3b55d..7b568ae 100644
52326 --- a/fs/compat.c
52327 +++ b/fs/compat.c
52328 @@ -54,7 +54,7 @@
52329 #include <asm/ioctls.h>
52330 #include "internal.h"
52331
52332 -int compat_log = 1;
52333 +int compat_log = 0;
52334
52335 int compat_printk(const char *fmt, ...)
52336 {
52337 @@ -488,7 +488,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
52338
52339 set_fs(KERNEL_DS);
52340 /* The __user pointer cast is valid because of the set_fs() */
52341 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
52342 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
52343 set_fs(oldfs);
52344 /* truncating is ok because it's a user address */
52345 if (!ret)
52346 @@ -546,7 +546,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
52347 goto out;
52348
52349 ret = -EINVAL;
52350 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
52351 + if (nr_segs > UIO_MAXIOV)
52352 goto out;
52353 if (nr_segs > fast_segs) {
52354 ret = -ENOMEM;
52355 @@ -833,6 +833,7 @@ struct compat_old_linux_dirent {
52356
52357 struct compat_readdir_callback {
52358 struct compat_old_linux_dirent __user *dirent;
52359 + struct file * file;
52360 int result;
52361 };
52362
52363 @@ -850,6 +851,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
52364 buf->result = -EOVERFLOW;
52365 return -EOVERFLOW;
52366 }
52367 +
52368 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
52369 + return 0;
52370 +
52371 buf->result++;
52372 dirent = buf->dirent;
52373 if (!access_ok(VERIFY_WRITE, dirent,
52374 @@ -880,6 +885,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
52375
52376 buf.result = 0;
52377 buf.dirent = dirent;
52378 + buf.file = f.file;
52379
52380 error = vfs_readdir(f.file, compat_fillonedir, &buf);
52381 if (buf.result)
52382 @@ -899,6 +905,7 @@ struct compat_linux_dirent {
52383 struct compat_getdents_callback {
52384 struct compat_linux_dirent __user *current_dir;
52385 struct compat_linux_dirent __user *previous;
52386 + struct file * file;
52387 int count;
52388 int error;
52389 };
52390 @@ -920,6 +927,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
52391 buf->error = -EOVERFLOW;
52392 return -EOVERFLOW;
52393 }
52394 +
52395 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
52396 + return 0;
52397 +
52398 dirent = buf->previous;
52399 if (dirent) {
52400 if (__put_user(offset, &dirent->d_off))
52401 @@ -965,6 +976,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
52402 buf.previous = NULL;
52403 buf.count = count;
52404 buf.error = 0;
52405 + buf.file = f.file;
52406
52407 error = vfs_readdir(f.file, compat_filldir, &buf);
52408 if (error >= 0)
52409 @@ -985,6 +997,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
52410 struct compat_getdents_callback64 {
52411 struct linux_dirent64 __user *current_dir;
52412 struct linux_dirent64 __user *previous;
52413 + struct file * file;
52414 int count;
52415 int error;
52416 };
52417 @@ -1001,6 +1014,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
52418 buf->error = -EINVAL; /* only used if we fail.. */
52419 if (reclen > buf->count)
52420 return -EINVAL;
52421 +
52422 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
52423 + return 0;
52424 +
52425 dirent = buf->previous;
52426
52427 if (dirent) {
52428 @@ -1050,13 +1067,14 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
52429 buf.previous = NULL;
52430 buf.count = count;
52431 buf.error = 0;
52432 + buf.file = f.file;
52433
52434 error = vfs_readdir(f.file, compat_filldir64, &buf);
52435 if (error >= 0)
52436 error = buf.error;
52437 lastdirent = buf.previous;
52438 if (lastdirent) {
52439 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
52440 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
52441 if (__put_user_unaligned(d_off, &lastdirent->d_off))
52442 error = -EFAULT;
52443 else
52444 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
52445 index a81147e..20bf2b5 100644
52446 --- a/fs/compat_binfmt_elf.c
52447 +++ b/fs/compat_binfmt_elf.c
52448 @@ -30,11 +30,13 @@
52449 #undef elf_phdr
52450 #undef elf_shdr
52451 #undef elf_note
52452 +#undef elf_dyn
52453 #undef elf_addr_t
52454 #define elfhdr elf32_hdr
52455 #define elf_phdr elf32_phdr
52456 #define elf_shdr elf32_shdr
52457 #define elf_note elf32_note
52458 +#define elf_dyn Elf32_Dyn
52459 #define elf_addr_t Elf32_Addr
52460
52461 /*
52462 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
52463 index 996cdc5..15e2f33 100644
52464 --- a/fs/compat_ioctl.c
52465 +++ b/fs/compat_ioctl.c
52466 @@ -622,7 +622,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
52467 return -EFAULT;
52468 if (__get_user(udata, &ss32->iomem_base))
52469 return -EFAULT;
52470 - ss.iomem_base = compat_ptr(udata);
52471 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
52472 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
52473 __get_user(ss.port_high, &ss32->port_high))
52474 return -EFAULT;
52475 @@ -703,8 +703,8 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
52476 for (i = 0; i < nmsgs; i++) {
52477 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
52478 return -EFAULT;
52479 - if (get_user(datap, &umsgs[i].buf) ||
52480 - put_user(compat_ptr(datap), &tmsgs[i].buf))
52481 + if (get_user(datap, (u8 __user * __user *)&umsgs[i].buf) ||
52482 + put_user(compat_ptr(datap), (u8 __user * __user *)&tmsgs[i].buf))
52483 return -EFAULT;
52484 }
52485 return sys_ioctl(fd, cmd, (unsigned long)tdata);
52486 @@ -797,7 +797,7 @@ static int compat_ioctl_preallocate(struct file *file,
52487 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
52488 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
52489 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
52490 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
52491 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
52492 return -EFAULT;
52493
52494 return ioctl_preallocate(file, p);
52495 @@ -1619,8 +1619,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
52496 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
52497 {
52498 unsigned int a, b;
52499 - a = *(unsigned int *)p;
52500 - b = *(unsigned int *)q;
52501 + a = *(const unsigned int *)p;
52502 + b = *(const unsigned int *)q;
52503 if (a > b)
52504 return 1;
52505 if (a < b)
52506 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
52507 index 7aabc6a..34c1197 100644
52508 --- a/fs/configfs/dir.c
52509 +++ b/fs/configfs/dir.c
52510 @@ -1565,7 +1565,8 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
52511 }
52512 for (p=q->next; p!= &parent_sd->s_children; p=p->next) {
52513 struct configfs_dirent *next;
52514 - const char * name;
52515 + const unsigned char * name;
52516 + char d_name[sizeof(next->s_dentry->d_iname)];
52517 int len;
52518 struct inode *inode = NULL;
52519
52520 @@ -1575,7 +1576,12 @@ static int configfs_readdir(struct file * filp, void * dirent, filldir_t filldir
52521 continue;
52522
52523 name = configfs_get_name(next);
52524 - len = strlen(name);
52525 + if (next->s_dentry && name == next->s_dentry->d_iname) {
52526 + len = next->s_dentry->d_name.len;
52527 + memcpy(d_name, name, len);
52528 + name = d_name;
52529 + } else
52530 + len = strlen(name);
52531
52532 /*
52533 * We'll have a dentry and an inode for
52534 diff --git a/fs/coredump.c b/fs/coredump.c
52535 index dafafba..10b3b27 100644
52536 --- a/fs/coredump.c
52537 +++ b/fs/coredump.c
52538 @@ -52,7 +52,7 @@ struct core_name {
52539 char *corename;
52540 int used, size;
52541 };
52542 -static atomic_t call_count = ATOMIC_INIT(1);
52543 +static atomic_unchecked_t call_count = ATOMIC_INIT(1);
52544
52545 /* The maximal length of core_pattern is also specified in sysctl.c */
52546
52547 @@ -60,7 +60,7 @@ static int expand_corename(struct core_name *cn)
52548 {
52549 char *old_corename = cn->corename;
52550
52551 - cn->size = CORENAME_MAX_SIZE * atomic_inc_return(&call_count);
52552 + cn->size = CORENAME_MAX_SIZE * atomic_inc_return_unchecked(&call_count);
52553 cn->corename = krealloc(old_corename, cn->size, GFP_KERNEL);
52554
52555 if (!cn->corename) {
52556 @@ -157,7 +157,7 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
52557 int pid_in_pattern = 0;
52558 int err = 0;
52559
52560 - cn->size = CORENAME_MAX_SIZE * atomic_read(&call_count);
52561 + cn->size = CORENAME_MAX_SIZE * atomic_read_unchecked(&call_count);
52562 cn->corename = kmalloc(cn->size, GFP_KERNEL);
52563 cn->used = 0;
52564
52565 @@ -435,8 +435,8 @@ static void wait_for_dump_helpers(struct file *file)
52566 struct pipe_inode_info *pipe = file->private_data;
52567
52568 pipe_lock(pipe);
52569 - pipe->readers++;
52570 - pipe->writers--;
52571 + atomic_inc(&pipe->readers);
52572 + atomic_dec(&pipe->writers);
52573 wake_up_interruptible_sync(&pipe->wait);
52574 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
52575 pipe_unlock(pipe);
52576 @@ -445,11 +445,11 @@ static void wait_for_dump_helpers(struct file *file)
52577 * We actually want wait_event_freezable() but then we need
52578 * to clear TIF_SIGPENDING and improve dump_interrupted().
52579 */
52580 - wait_event_interruptible(pipe->wait, pipe->readers == 1);
52581 + wait_event_interruptible(pipe->wait, atomic_read(&pipe->readers) == 1);
52582
52583 pipe_lock(pipe);
52584 - pipe->readers--;
52585 - pipe->writers++;
52586 + atomic_dec(&pipe->readers);
52587 + atomic_inc(&pipe->writers);
52588 pipe_unlock(pipe);
52589 }
52590
52591 @@ -496,7 +496,8 @@ void do_coredump(siginfo_t *siginfo)
52592 struct files_struct *displaced;
52593 bool need_nonrelative = false;
52594 bool core_dumped = false;
52595 - static atomic_t core_dump_count = ATOMIC_INIT(0);
52596 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
52597 + long signr = siginfo->si_signo;
52598 struct coredump_params cprm = {
52599 .siginfo = siginfo,
52600 .regs = signal_pt_regs(),
52601 @@ -509,7 +510,10 @@ void do_coredump(siginfo_t *siginfo)
52602 .mm_flags = mm->flags,
52603 };
52604
52605 - audit_core_dumps(siginfo->si_signo);
52606 + audit_core_dumps(signr);
52607 +
52608 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
52609 + gr_handle_brute_attach(cprm.mm_flags);
52610
52611 binfmt = mm->binfmt;
52612 if (!binfmt || !binfmt->core_dump)
52613 @@ -533,7 +537,7 @@ void do_coredump(siginfo_t *siginfo)
52614 need_nonrelative = true;
52615 }
52616
52617 - retval = coredump_wait(siginfo->si_signo, &core_state);
52618 + retval = coredump_wait(signr, &core_state);
52619 if (retval < 0)
52620 goto fail_creds;
52621
52622 @@ -576,7 +580,7 @@ void do_coredump(siginfo_t *siginfo)
52623 }
52624 cprm.limit = RLIM_INFINITY;
52625
52626 - dump_count = atomic_inc_return(&core_dump_count);
52627 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
52628 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
52629 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
52630 task_tgid_vnr(current), current->comm);
52631 @@ -608,6 +612,8 @@ void do_coredump(siginfo_t *siginfo)
52632 } else {
52633 struct inode *inode;
52634
52635 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
52636 +
52637 if (cprm.limit < binfmt->min_coredump)
52638 goto fail_unlock;
52639
52640 @@ -666,7 +672,7 @@ close_fail:
52641 filp_close(cprm.file, NULL);
52642 fail_dropcount:
52643 if (ispipe)
52644 - atomic_dec(&core_dump_count);
52645 + atomic_dec_unchecked(&core_dump_count);
52646 fail_unlock:
52647 kfree(cn.corename);
52648 fail_corename:
52649 @@ -687,7 +693,7 @@ int dump_write(struct file *file, const void *addr, int nr)
52650 {
52651 return !dump_interrupted() &&
52652 access_ok(VERIFY_READ, addr, nr) &&
52653 - file->f_op->write(file, addr, nr, &file->f_pos) == nr;
52654 + file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
52655 }
52656 EXPORT_SYMBOL(dump_write);
52657
52658 diff --git a/fs/dcache.c b/fs/dcache.c
52659 index f09b908..04b9690 100644
52660 --- a/fs/dcache.c
52661 +++ b/fs/dcache.c
52662 @@ -3086,7 +3086,8 @@ void __init vfs_caches_init(unsigned long mempages)
52663 mempages -= reserve;
52664
52665 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
52666 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
52667 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY|
52668 + SLAB_NO_SANITIZE, NULL);
52669
52670 dcache_init();
52671 inode_init();
52672 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
52673 index c7c83ff..bda9461 100644
52674 --- a/fs/debugfs/inode.c
52675 +++ b/fs/debugfs/inode.c
52676 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
52677 */
52678 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
52679 {
52680 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
52681 + return __create_file(name, S_IFDIR | S_IRWXU,
52682 +#else
52683 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
52684 +#endif
52685 parent, NULL, NULL);
52686 }
52687 EXPORT_SYMBOL_GPL(debugfs_create_dir);
52688 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
52689 index 5eab400..810a3f5 100644
52690 --- a/fs/ecryptfs/inode.c
52691 +++ b/fs/ecryptfs/inode.c
52692 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
52693 old_fs = get_fs();
52694 set_fs(get_ds());
52695 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
52696 - (char __user *)lower_buf,
52697 + (char __force_user *)lower_buf,
52698 PATH_MAX);
52699 set_fs(old_fs);
52700 if (rc < 0)
52701 @@ -706,7 +706,7 @@ out:
52702 static void
52703 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
52704 {
52705 - char *buf = nd_get_link(nd);
52706 + const char *buf = nd_get_link(nd);
52707 if (!IS_ERR(buf)) {
52708 /* Free the char* */
52709 kfree(buf);
52710 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
52711 index e4141f2..d8263e8 100644
52712 --- a/fs/ecryptfs/miscdev.c
52713 +++ b/fs/ecryptfs/miscdev.c
52714 @@ -304,7 +304,7 @@ check_list:
52715 goto out_unlock_msg_ctx;
52716 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
52717 if (msg_ctx->msg) {
52718 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
52719 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
52720 goto out_unlock_msg_ctx;
52721 i += packet_length_size;
52722 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
52723 diff --git a/fs/exec.c b/fs/exec.c
52724 index 1f44670..3c84660 100644
52725 --- a/fs/exec.c
52726 +++ b/fs/exec.c
52727 @@ -55,8 +55,20 @@
52728 #include <linux/pipe_fs_i.h>
52729 #include <linux/oom.h>
52730 #include <linux/compat.h>
52731 +#include <linux/random.h>
52732 +#include <linux/seq_file.h>
52733 +#include <linux/coredump.h>
52734 +#include <linux/mman.h>
52735 +
52736 +#ifdef CONFIG_PAX_REFCOUNT
52737 +#include <linux/kallsyms.h>
52738 +#include <linux/kdebug.h>
52739 +#endif
52740 +
52741 +#include <trace/events/fs.h>
52742
52743 #include <asm/uaccess.h>
52744 +#include <asm/sections.h>
52745 #include <asm/mmu_context.h>
52746 #include <asm/tlb.h>
52747
52748 @@ -66,17 +78,32 @@
52749
52750 #include <trace/events/sched.h>
52751
52752 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
52753 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
52754 +{
52755 + 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");
52756 +}
52757 +#endif
52758 +
52759 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
52760 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
52761 +EXPORT_SYMBOL(pax_set_initial_flags_func);
52762 +#endif
52763 +
52764 int suid_dumpable = 0;
52765
52766 static LIST_HEAD(formats);
52767 static DEFINE_RWLOCK(binfmt_lock);
52768
52769 +extern int gr_process_kernel_exec_ban(void);
52770 +extern int gr_process_suid_exec_ban(const struct linux_binprm *bprm);
52771 +
52772 void __register_binfmt(struct linux_binfmt * fmt, int insert)
52773 {
52774 BUG_ON(!fmt);
52775 write_lock(&binfmt_lock);
52776 - insert ? list_add(&fmt->lh, &formats) :
52777 - list_add_tail(&fmt->lh, &formats);
52778 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
52779 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
52780 write_unlock(&binfmt_lock);
52781 }
52782
52783 @@ -85,7 +112,7 @@ EXPORT_SYMBOL(__register_binfmt);
52784 void unregister_binfmt(struct linux_binfmt * fmt)
52785 {
52786 write_lock(&binfmt_lock);
52787 - list_del(&fmt->lh);
52788 + pax_list_del((struct list_head *)&fmt->lh);
52789 write_unlock(&binfmt_lock);
52790 }
52791
52792 @@ -180,18 +207,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
52793 int write)
52794 {
52795 struct page *page;
52796 - int ret;
52797
52798 -#ifdef CONFIG_STACK_GROWSUP
52799 - if (write) {
52800 - ret = expand_downwards(bprm->vma, pos);
52801 - if (ret < 0)
52802 - return NULL;
52803 - }
52804 -#endif
52805 - ret = get_user_pages(current, bprm->mm, pos,
52806 - 1, write, 1, &page, NULL);
52807 - if (ret <= 0)
52808 + if (0 > expand_downwards(bprm->vma, pos))
52809 + return NULL;
52810 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
52811 return NULL;
52812
52813 if (write) {
52814 @@ -207,6 +226,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
52815 if (size <= ARG_MAX)
52816 return page;
52817
52818 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
52819 + // only allow 512KB for argv+env on suid/sgid binaries
52820 + // to prevent easy ASLR exhaustion
52821 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
52822 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
52823 + (size > (512 * 1024))) {
52824 + put_page(page);
52825 + return NULL;
52826 + }
52827 +#endif
52828 +
52829 /*
52830 * Limit to 1/4-th the stack size for the argv+env strings.
52831 * This ensures that:
52832 @@ -266,6 +296,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
52833 vma->vm_end = STACK_TOP_MAX;
52834 vma->vm_start = vma->vm_end - PAGE_SIZE;
52835 vma->vm_flags = VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
52836 +
52837 +#ifdef CONFIG_PAX_SEGMEXEC
52838 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
52839 +#endif
52840 +
52841 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
52842 INIT_LIST_HEAD(&vma->anon_vma_chain);
52843
52844 @@ -276,6 +311,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
52845 mm->stack_vm = mm->total_vm = 1;
52846 up_write(&mm->mmap_sem);
52847 bprm->p = vma->vm_end - sizeof(void *);
52848 +
52849 +#ifdef CONFIG_PAX_RANDUSTACK
52850 + if (randomize_va_space)
52851 + bprm->p ^= prandom_u32() & ~PAGE_MASK;
52852 +#endif
52853 +
52854 return 0;
52855 err:
52856 up_write(&mm->mmap_sem);
52857 @@ -396,7 +437,7 @@ struct user_arg_ptr {
52858 } ptr;
52859 };
52860
52861 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
52862 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
52863 {
52864 const char __user *native;
52865
52866 @@ -405,14 +446,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
52867 compat_uptr_t compat;
52868
52869 if (get_user(compat, argv.ptr.compat + nr))
52870 - return ERR_PTR(-EFAULT);
52871 + return (const char __force_user *)ERR_PTR(-EFAULT);
52872
52873 return compat_ptr(compat);
52874 }
52875 #endif
52876
52877 if (get_user(native, argv.ptr.native + nr))
52878 - return ERR_PTR(-EFAULT);
52879 + return (const char __force_user *)ERR_PTR(-EFAULT);
52880
52881 return native;
52882 }
52883 @@ -431,7 +472,7 @@ static int count(struct user_arg_ptr argv, int max)
52884 if (!p)
52885 break;
52886
52887 - if (IS_ERR(p))
52888 + if (IS_ERR((const char __force_kernel *)p))
52889 return -EFAULT;
52890
52891 if (i >= max)
52892 @@ -466,7 +507,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
52893
52894 ret = -EFAULT;
52895 str = get_user_arg_ptr(argv, argc);
52896 - if (IS_ERR(str))
52897 + if (IS_ERR((const char __force_kernel *)str))
52898 goto out;
52899
52900 len = strnlen_user(str, MAX_ARG_STRLEN);
52901 @@ -548,7 +589,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
52902 int r;
52903 mm_segment_t oldfs = get_fs();
52904 struct user_arg_ptr argv = {
52905 - .ptr.native = (const char __user *const __user *)__argv,
52906 + .ptr.native = (const char __force_user * const __force_user *)__argv,
52907 };
52908
52909 set_fs(KERNEL_DS);
52910 @@ -583,7 +624,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
52911 unsigned long new_end = old_end - shift;
52912 struct mmu_gather tlb;
52913
52914 - BUG_ON(new_start > new_end);
52915 + if (new_start >= new_end || new_start < mmap_min_addr)
52916 + return -ENOMEM;
52917
52918 /*
52919 * ensure there are no vmas between where we want to go
52920 @@ -592,6 +634,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
52921 if (vma != find_vma(mm, new_start))
52922 return -EFAULT;
52923
52924 +#ifdef CONFIG_PAX_SEGMEXEC
52925 + BUG_ON(pax_find_mirror_vma(vma));
52926 +#endif
52927 +
52928 /*
52929 * cover the whole range: [new_start, old_end)
52930 */
52931 @@ -672,10 +718,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
52932 stack_top = arch_align_stack(stack_top);
52933 stack_top = PAGE_ALIGN(stack_top);
52934
52935 - if (unlikely(stack_top < mmap_min_addr) ||
52936 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
52937 - return -ENOMEM;
52938 -
52939 stack_shift = vma->vm_end - stack_top;
52940
52941 bprm->p -= stack_shift;
52942 @@ -687,8 +729,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
52943 bprm->exec -= stack_shift;
52944
52945 down_write(&mm->mmap_sem);
52946 +
52947 + /* Move stack pages down in memory. */
52948 + if (stack_shift) {
52949 + ret = shift_arg_pages(vma, stack_shift);
52950 + if (ret)
52951 + goto out_unlock;
52952 + }
52953 +
52954 vm_flags = VM_STACK_FLAGS;
52955
52956 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
52957 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
52958 + vm_flags &= ~VM_EXEC;
52959 +
52960 +#ifdef CONFIG_PAX_MPROTECT
52961 + if (mm->pax_flags & MF_PAX_MPROTECT)
52962 + vm_flags &= ~VM_MAYEXEC;
52963 +#endif
52964 +
52965 + }
52966 +#endif
52967 +
52968 /*
52969 * Adjust stack execute permissions; explicitly enable for
52970 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
52971 @@ -707,13 +769,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
52972 goto out_unlock;
52973 BUG_ON(prev != vma);
52974
52975 - /* Move stack pages down in memory. */
52976 - if (stack_shift) {
52977 - ret = shift_arg_pages(vma, stack_shift);
52978 - if (ret)
52979 - goto out_unlock;
52980 - }
52981 -
52982 /* mprotect_fixup is overkill to remove the temporary stack flags */
52983 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
52984
52985 @@ -737,6 +792,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
52986 #endif
52987 current->mm->start_stack = bprm->p;
52988 ret = expand_stack(vma, stack_base);
52989 +
52990 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
52991 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
52992 + unsigned long size;
52993 + vm_flags_t vm_flags;
52994 +
52995 + size = STACK_TOP - vma->vm_end;
52996 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
52997 +
52998 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, vm_flags, 0);
52999 +
53000 +#ifdef CONFIG_X86
53001 + if (!ret) {
53002 + size = PAGE_SIZE + mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
53003 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), vm_flags, 0);
53004 + }
53005 +#endif
53006 +
53007 + }
53008 +#endif
53009 +
53010 if (ret)
53011 ret = -EFAULT;
53012
53013 @@ -772,6 +848,8 @@ struct file *open_exec(const char *name)
53014
53015 fsnotify_open(file);
53016
53017 + trace_open_exec(name);
53018 +
53019 err = deny_write_access(file);
53020 if (err)
53021 goto exit;
53022 @@ -795,7 +873,7 @@ int kernel_read(struct file *file, loff_t offset,
53023 old_fs = get_fs();
53024 set_fs(get_ds());
53025 /* The cast to a user pointer is valid due to the set_fs() */
53026 - result = vfs_read(file, (void __user *)addr, count, &pos);
53027 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
53028 set_fs(old_fs);
53029 return result;
53030 }
53031 @@ -1251,7 +1329,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
53032 }
53033 rcu_read_unlock();
53034
53035 - if (p->fs->users > n_fs) {
53036 + if (atomic_read(&p->fs->users) > n_fs) {
53037 bprm->unsafe |= LSM_UNSAFE_SHARE;
53038 } else {
53039 res = -EAGAIN;
53040 @@ -1451,6 +1529,31 @@ int search_binary_handler(struct linux_binprm *bprm)
53041
53042 EXPORT_SYMBOL(search_binary_handler);
53043
53044 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
53045 +static DEFINE_PER_CPU(u64, exec_counter);
53046 +static int __init init_exec_counters(void)
53047 +{
53048 + unsigned int cpu;
53049 +
53050 + for_each_possible_cpu(cpu) {
53051 + per_cpu(exec_counter, cpu) = (u64)cpu;
53052 + }
53053 +
53054 + return 0;
53055 +}
53056 +early_initcall(init_exec_counters);
53057 +static inline void increment_exec_counter(void)
53058 +{
53059 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
53060 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
53061 +}
53062 +#else
53063 +static inline void increment_exec_counter(void) {}
53064 +#endif
53065 +
53066 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
53067 + struct user_arg_ptr argv);
53068 +
53069 /*
53070 * sys_execve() executes a new program.
53071 */
53072 @@ -1458,6 +1561,11 @@ static int do_execve_common(const char *filename,
53073 struct user_arg_ptr argv,
53074 struct user_arg_ptr envp)
53075 {
53076 +#ifdef CONFIG_GRKERNSEC
53077 + struct file *old_exec_file;
53078 + struct acl_subject_label *old_acl;
53079 + struct rlimit old_rlim[RLIM_NLIMITS];
53080 +#endif
53081 struct linux_binprm *bprm;
53082 struct file *file;
53083 struct files_struct *displaced;
53084 @@ -1465,6 +1573,8 @@ static int do_execve_common(const char *filename,
53085 int retval;
53086 const struct cred *cred = current_cred();
53087
53088 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&cred->user->processes), 1);
53089 +
53090 /*
53091 * We move the actual failure in case of RLIMIT_NPROC excess from
53092 * set*uid() to execve() because too many poorly written programs
53093 @@ -1505,12 +1615,22 @@ static int do_execve_common(const char *filename,
53094 if (IS_ERR(file))
53095 goto out_unmark;
53096
53097 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
53098 + retval = -EPERM;
53099 + goto out_file;
53100 + }
53101 +
53102 sched_exec();
53103
53104 bprm->file = file;
53105 bprm->filename = filename;
53106 bprm->interp = filename;
53107
53108 + if (!gr_acl_handle_execve(file->f_path.dentry, file->f_path.mnt)) {
53109 + retval = -EACCES;
53110 + goto out_file;
53111 + }
53112 +
53113 retval = bprm_mm_init(bprm);
53114 if (retval)
53115 goto out_file;
53116 @@ -1527,24 +1647,70 @@ static int do_execve_common(const char *filename,
53117 if (retval < 0)
53118 goto out;
53119
53120 +#ifdef CONFIG_GRKERNSEC
53121 + old_acl = current->acl;
53122 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
53123 + old_exec_file = current->exec_file;
53124 + get_file(file);
53125 + current->exec_file = file;
53126 +#endif
53127 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
53128 + /* limit suid stack to 8MB
53129 + * we saved the old limits above and will restore them if this exec fails
53130 + */
53131 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
53132 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
53133 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
53134 +#endif
53135 +
53136 + if (gr_process_kernel_exec_ban() || gr_process_suid_exec_ban(bprm)) {
53137 + retval = -EPERM;
53138 + goto out_fail;
53139 + }
53140 +
53141 + if (!gr_tpe_allow(file)) {
53142 + retval = -EACCES;
53143 + goto out_fail;
53144 + }
53145 +
53146 + if (gr_check_crash_exec(file)) {
53147 + retval = -EACCES;
53148 + goto out_fail;
53149 + }
53150 +
53151 + retval = gr_set_proc_label(file->f_path.dentry, file->f_path.mnt,
53152 + bprm->unsafe);
53153 + if (retval < 0)
53154 + goto out_fail;
53155 +
53156 retval = copy_strings_kernel(1, &bprm->filename, bprm);
53157 if (retval < 0)
53158 - goto out;
53159 + goto out_fail;
53160
53161 bprm->exec = bprm->p;
53162 retval = copy_strings(bprm->envc, envp, bprm);
53163 if (retval < 0)
53164 - goto out;
53165 + goto out_fail;
53166
53167 retval = copy_strings(bprm->argc, argv, bprm);
53168 if (retval < 0)
53169 - goto out;
53170 + goto out_fail;
53171 +
53172 + gr_log_chroot_exec(file->f_path.dentry, file->f_path.mnt);
53173 +
53174 + gr_handle_exec_args(bprm, argv);
53175
53176 retval = search_binary_handler(bprm);
53177 if (retval < 0)
53178 - goto out;
53179 + goto out_fail;
53180 +#ifdef CONFIG_GRKERNSEC
53181 + if (old_exec_file)
53182 + fput(old_exec_file);
53183 +#endif
53184
53185 /* execve succeeded */
53186 +
53187 + increment_exec_counter();
53188 current->fs->in_exec = 0;
53189 current->in_execve = 0;
53190 acct_update_integrals(current);
53191 @@ -1553,6 +1719,14 @@ static int do_execve_common(const char *filename,
53192 put_files_struct(displaced);
53193 return retval;
53194
53195 +out_fail:
53196 +#ifdef CONFIG_GRKERNSEC
53197 + current->acl = old_acl;
53198 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
53199 + fput(current->exec_file);
53200 + current->exec_file = old_exec_file;
53201 +#endif
53202 +
53203 out:
53204 if (bprm->mm) {
53205 acct_arg_size(bprm, 0);
53206 @@ -1701,3 +1875,287 @@ asmlinkage long compat_sys_execve(const char __user * filename,
53207 return error;
53208 }
53209 #endif
53210 +
53211 +int pax_check_flags(unsigned long *flags)
53212 +{
53213 + int retval = 0;
53214 +
53215 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
53216 + if (*flags & MF_PAX_SEGMEXEC)
53217 + {
53218 + *flags &= ~MF_PAX_SEGMEXEC;
53219 + retval = -EINVAL;
53220 + }
53221 +#endif
53222 +
53223 + if ((*flags & MF_PAX_PAGEEXEC)
53224 +
53225 +#ifdef CONFIG_PAX_PAGEEXEC
53226 + && (*flags & MF_PAX_SEGMEXEC)
53227 +#endif
53228 +
53229 + )
53230 + {
53231 + *flags &= ~MF_PAX_PAGEEXEC;
53232 + retval = -EINVAL;
53233 + }
53234 +
53235 + if ((*flags & MF_PAX_MPROTECT)
53236 +
53237 +#ifdef CONFIG_PAX_MPROTECT
53238 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
53239 +#endif
53240 +
53241 + )
53242 + {
53243 + *flags &= ~MF_PAX_MPROTECT;
53244 + retval = -EINVAL;
53245 + }
53246 +
53247 + if ((*flags & MF_PAX_EMUTRAMP)
53248 +
53249 +#ifdef CONFIG_PAX_EMUTRAMP
53250 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
53251 +#endif
53252 +
53253 + )
53254 + {
53255 + *flags &= ~MF_PAX_EMUTRAMP;
53256 + retval = -EINVAL;
53257 + }
53258 +
53259 + return retval;
53260 +}
53261 +
53262 +EXPORT_SYMBOL(pax_check_flags);
53263 +
53264 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
53265 +char *pax_get_path(const struct path *path, char *buf, int buflen)
53266 +{
53267 + char *pathname = d_path(path, buf, buflen);
53268 +
53269 + if (IS_ERR(pathname))
53270 + goto toolong;
53271 +
53272 + pathname = mangle_path(buf, pathname, "\t\n\\");
53273 + if (!pathname)
53274 + goto toolong;
53275 +
53276 + *pathname = 0;
53277 + return buf;
53278 +
53279 +toolong:
53280 + return "<path too long>";
53281 +}
53282 +EXPORT_SYMBOL(pax_get_path);
53283 +
53284 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
53285 +{
53286 + struct task_struct *tsk = current;
53287 + struct mm_struct *mm = current->mm;
53288 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
53289 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
53290 + char *path_exec = NULL;
53291 + char *path_fault = NULL;
53292 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
53293 + siginfo_t info = { };
53294 +
53295 + if (buffer_exec && buffer_fault) {
53296 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
53297 +
53298 + down_read(&mm->mmap_sem);
53299 + vma = mm->mmap;
53300 + while (vma && (!vma_exec || !vma_fault)) {
53301 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
53302 + vma_exec = vma;
53303 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
53304 + vma_fault = vma;
53305 + vma = vma->vm_next;
53306 + }
53307 + if (vma_exec)
53308 + path_exec = pax_get_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
53309 + if (vma_fault) {
53310 + start = vma_fault->vm_start;
53311 + end = vma_fault->vm_end;
53312 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
53313 + if (vma_fault->vm_file)
53314 + path_fault = pax_get_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
53315 + else if ((unsigned long)pc >= mm->start_brk && (unsigned long)pc < mm->brk)
53316 + path_fault = "<heap>";
53317 + else if (vma_fault->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
53318 + path_fault = "<stack>";
53319 + else
53320 + path_fault = "<anonymous mapping>";
53321 + }
53322 + up_read(&mm->mmap_sem);
53323 + }
53324 + if (tsk->signal->curr_ip)
53325 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
53326 + else
53327 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
53328 + 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),
53329 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
53330 + free_page((unsigned long)buffer_exec);
53331 + free_page((unsigned long)buffer_fault);
53332 + pax_report_insns(regs, pc, sp);
53333 + info.si_signo = SIGKILL;
53334 + info.si_errno = 0;
53335 + info.si_code = SI_KERNEL;
53336 + info.si_pid = 0;
53337 + info.si_uid = 0;
53338 + do_coredump(&info);
53339 +}
53340 +#endif
53341 +
53342 +#ifdef CONFIG_PAX_REFCOUNT
53343 +void pax_report_refcount_overflow(struct pt_regs *regs)
53344 +{
53345 + if (current->signal->curr_ip)
53346 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
53347 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
53348 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
53349 + else
53350 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
53351 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
53352 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
53353 + preempt_disable();
53354 + show_regs(regs);
53355 + preempt_enable();
53356 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
53357 +}
53358 +#endif
53359 +
53360 +#ifdef CONFIG_PAX_USERCOPY
53361 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
53362 +static noinline int check_stack_object(const void *obj, unsigned long len)
53363 +{
53364 + const void * const stack = task_stack_page(current);
53365 + const void * const stackend = stack + THREAD_SIZE;
53366 +
53367 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
53368 + const void *frame = NULL;
53369 + const void *oldframe;
53370 +#endif
53371 +
53372 + if (obj + len < obj)
53373 + return -1;
53374 +
53375 + if (obj + len <= stack || stackend <= obj)
53376 + return 0;
53377 +
53378 + if (obj < stack || stackend < obj + len)
53379 + return -1;
53380 +
53381 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
53382 + oldframe = __builtin_frame_address(1);
53383 + if (oldframe)
53384 + frame = __builtin_frame_address(2);
53385 + /*
53386 + low ----------------------------------------------> high
53387 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
53388 + ^----------------^
53389 + allow copies only within here
53390 + */
53391 + while (stack <= frame && frame < stackend) {
53392 + /* if obj + len extends past the last frame, this
53393 + check won't pass and the next frame will be 0,
53394 + causing us to bail out and correctly report
53395 + the copy as invalid
53396 + */
53397 + if (obj + len <= frame)
53398 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
53399 + oldframe = frame;
53400 + frame = *(const void * const *)frame;
53401 + }
53402 + return -1;
53403 +#else
53404 + return 1;
53405 +#endif
53406 +}
53407 +
53408 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
53409 +{
53410 + if (current->signal->curr_ip)
53411 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
53412 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
53413 + else
53414 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
53415 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
53416 + dump_stack();
53417 + gr_handle_kernel_exploit();
53418 + do_group_exit(SIGKILL);
53419 +}
53420 +#endif
53421 +
53422 +#ifdef CONFIG_PAX_USERCOPY
53423 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
53424 +{
53425 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
53426 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
53427 +#ifdef CONFIG_MODULES
53428 + unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
53429 +#else
53430 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
53431 +#endif
53432 +
53433 +#else
53434 + unsigned long textlow = (unsigned long)_stext;
53435 + unsigned long texthigh = (unsigned long)_etext;
53436 +#endif
53437 +
53438 + if (high <= textlow || low > texthigh)
53439 + return false;
53440 + else
53441 + return true;
53442 +}
53443 +#endif
53444 +
53445 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
53446 +{
53447 +
53448 +#ifdef CONFIG_PAX_USERCOPY
53449 + const char *type;
53450 +
53451 + if (!n)
53452 + return;
53453 +
53454 + type = check_heap_object(ptr, n);
53455 + if (!type) {
53456 + int ret = check_stack_object(ptr, n);
53457 + if (ret == 1 || ret == 2)
53458 + return;
53459 + if (ret == 0) {
53460 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
53461 + type = "<kernel text>";
53462 + else
53463 + return;
53464 + } else
53465 + type = "<process stack>";
53466 + }
53467 +
53468 + pax_report_usercopy(ptr, n, to_user, type);
53469 +#endif
53470 +
53471 +}
53472 +EXPORT_SYMBOL(__check_object_size);
53473 +
53474 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
53475 +void pax_track_stack(void)
53476 +{
53477 + unsigned long sp = (unsigned long)&sp;
53478 + if (sp < current_thread_info()->lowest_stack &&
53479 + sp > (unsigned long)task_stack_page(current))
53480 + current_thread_info()->lowest_stack = sp;
53481 +}
53482 +EXPORT_SYMBOL(pax_track_stack);
53483 +#endif
53484 +
53485 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
53486 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
53487 +{
53488 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
53489 + dump_stack();
53490 + do_group_exit(SIGKILL);
53491 +}
53492 +EXPORT_SYMBOL(report_size_overflow);
53493 +#endif
53494 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
53495 index 9f9992b..8b59411 100644
53496 --- a/fs/ext2/balloc.c
53497 +++ b/fs/ext2/balloc.c
53498 @@ -1184,10 +1184,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
53499
53500 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
53501 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
53502 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
53503 + if (free_blocks < root_blocks + 1 &&
53504 !uid_eq(sbi->s_resuid, current_fsuid()) &&
53505 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
53506 - !in_group_p (sbi->s_resgid))) {
53507 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
53508 return 0;
53509 }
53510 return 1;
53511 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
53512 index 22548f5..41521d8 100644
53513 --- a/fs/ext3/balloc.c
53514 +++ b/fs/ext3/balloc.c
53515 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
53516
53517 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
53518 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
53519 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
53520 + if (free_blocks < root_blocks + 1 &&
53521 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
53522 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
53523 - !in_group_p (sbi->s_resgid))) {
53524 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
53525 return 0;
53526 }
53527 return 1;
53528 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
53529 index 3742e4c..69a797f 100644
53530 --- a/fs/ext4/balloc.c
53531 +++ b/fs/ext4/balloc.c
53532 @@ -528,8 +528,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
53533 /* Hm, nope. Are (enough) root reserved clusters available? */
53534 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
53535 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
53536 - capable(CAP_SYS_RESOURCE) ||
53537 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
53538 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
53539 + capable_nolog(CAP_SYS_RESOURCE)) {
53540
53541 if (free_clusters >= (nclusters + dirty_clusters +
53542 resv_clusters))
53543 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
53544 index 5aae3d1..b5da7f8 100644
53545 --- a/fs/ext4/ext4.h
53546 +++ b/fs/ext4/ext4.h
53547 @@ -1252,19 +1252,19 @@ struct ext4_sb_info {
53548 unsigned long s_mb_last_start;
53549
53550 /* stats for buddy allocator */
53551 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
53552 - atomic_t s_bal_success; /* we found long enough chunks */
53553 - atomic_t s_bal_allocated; /* in blocks */
53554 - atomic_t s_bal_ex_scanned; /* total extents scanned */
53555 - atomic_t s_bal_goals; /* goal hits */
53556 - atomic_t s_bal_breaks; /* too long searches */
53557 - atomic_t s_bal_2orders; /* 2^order hits */
53558 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
53559 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
53560 + atomic_unchecked_t s_bal_allocated; /* in blocks */
53561 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
53562 + atomic_unchecked_t s_bal_goals; /* goal hits */
53563 + atomic_unchecked_t s_bal_breaks; /* too long searches */
53564 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
53565 spinlock_t s_bal_lock;
53566 unsigned long s_mb_buddies_generated;
53567 unsigned long long s_mb_generation_time;
53568 - atomic_t s_mb_lost_chunks;
53569 - atomic_t s_mb_preallocated;
53570 - atomic_t s_mb_discarded;
53571 + atomic_unchecked_t s_mb_lost_chunks;
53572 + atomic_unchecked_t s_mb_preallocated;
53573 + atomic_unchecked_t s_mb_discarded;
53574 atomic_t s_lock_busy;
53575
53576 /* locality groups */
53577 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
53578 index 59c6750..a549154 100644
53579 --- a/fs/ext4/mballoc.c
53580 +++ b/fs/ext4/mballoc.c
53581 @@ -1865,7 +1865,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
53582 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
53583
53584 if (EXT4_SB(sb)->s_mb_stats)
53585 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
53586 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
53587
53588 break;
53589 }
53590 @@ -2170,7 +2170,7 @@ repeat:
53591 ac->ac_status = AC_STATUS_CONTINUE;
53592 ac->ac_flags |= EXT4_MB_HINT_FIRST;
53593 cr = 3;
53594 - atomic_inc(&sbi->s_mb_lost_chunks);
53595 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
53596 goto repeat;
53597 }
53598 }
53599 @@ -2678,25 +2678,25 @@ int ext4_mb_release(struct super_block *sb)
53600 if (sbi->s_mb_stats) {
53601 ext4_msg(sb, KERN_INFO,
53602 "mballoc: %u blocks %u reqs (%u success)",
53603 - atomic_read(&sbi->s_bal_allocated),
53604 - atomic_read(&sbi->s_bal_reqs),
53605 - atomic_read(&sbi->s_bal_success));
53606 + atomic_read_unchecked(&sbi->s_bal_allocated),
53607 + atomic_read_unchecked(&sbi->s_bal_reqs),
53608 + atomic_read_unchecked(&sbi->s_bal_success));
53609 ext4_msg(sb, KERN_INFO,
53610 "mballoc: %u extents scanned, %u goal hits, "
53611 "%u 2^N hits, %u breaks, %u lost",
53612 - atomic_read(&sbi->s_bal_ex_scanned),
53613 - atomic_read(&sbi->s_bal_goals),
53614 - atomic_read(&sbi->s_bal_2orders),
53615 - atomic_read(&sbi->s_bal_breaks),
53616 - atomic_read(&sbi->s_mb_lost_chunks));
53617 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
53618 + atomic_read_unchecked(&sbi->s_bal_goals),
53619 + atomic_read_unchecked(&sbi->s_bal_2orders),
53620 + atomic_read_unchecked(&sbi->s_bal_breaks),
53621 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
53622 ext4_msg(sb, KERN_INFO,
53623 "mballoc: %lu generated and it took %Lu",
53624 sbi->s_mb_buddies_generated,
53625 sbi->s_mb_generation_time);
53626 ext4_msg(sb, KERN_INFO,
53627 "mballoc: %u preallocated, %u discarded",
53628 - atomic_read(&sbi->s_mb_preallocated),
53629 - atomic_read(&sbi->s_mb_discarded));
53630 + atomic_read_unchecked(&sbi->s_mb_preallocated),
53631 + atomic_read_unchecked(&sbi->s_mb_discarded));
53632 }
53633
53634 free_percpu(sbi->s_locality_groups);
53635 @@ -3150,16 +3150,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
53636 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
53637
53638 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
53639 - atomic_inc(&sbi->s_bal_reqs);
53640 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
53641 + atomic_inc_unchecked(&sbi->s_bal_reqs);
53642 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
53643 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
53644 - atomic_inc(&sbi->s_bal_success);
53645 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
53646 + atomic_inc_unchecked(&sbi->s_bal_success);
53647 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
53648 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
53649 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
53650 - atomic_inc(&sbi->s_bal_goals);
53651 + atomic_inc_unchecked(&sbi->s_bal_goals);
53652 if (ac->ac_found > sbi->s_mb_max_to_scan)
53653 - atomic_inc(&sbi->s_bal_breaks);
53654 + atomic_inc_unchecked(&sbi->s_bal_breaks);
53655 }
53656
53657 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
53658 @@ -3559,7 +3559,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
53659 trace_ext4_mb_new_inode_pa(ac, pa);
53660
53661 ext4_mb_use_inode_pa(ac, pa);
53662 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
53663 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
53664
53665 ei = EXT4_I(ac->ac_inode);
53666 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
53667 @@ -3619,7 +3619,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
53668 trace_ext4_mb_new_group_pa(ac, pa);
53669
53670 ext4_mb_use_group_pa(ac, pa);
53671 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
53672 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
53673
53674 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
53675 lg = ac->ac_lg;
53676 @@ -3708,7 +3708,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
53677 * from the bitmap and continue.
53678 */
53679 }
53680 - atomic_add(free, &sbi->s_mb_discarded);
53681 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
53682
53683 return err;
53684 }
53685 @@ -3726,7 +3726,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
53686 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
53687 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
53688 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
53689 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
53690 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
53691 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
53692
53693 return 0;
53694 diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
53695 index 214461e..3614c89 100644
53696 --- a/fs/ext4/mmp.c
53697 +++ b/fs/ext4/mmp.c
53698 @@ -113,7 +113,7 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
53699 void __dump_mmp_msg(struct super_block *sb, struct mmp_struct *mmp,
53700 const char *function, unsigned int line, const char *msg)
53701 {
53702 - __ext4_warning(sb, function, line, msg);
53703 + __ext4_warning(sb, function, line, "%s", msg);
53704 __ext4_warning(sb, function, line,
53705 "MMP failure info: last update time: %llu, last update "
53706 "node: %s, last update device: %s\n",
53707 diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c
53708 index 49d3c01..9579efd 100644
53709 --- a/fs/ext4/resize.c
53710 +++ b/fs/ext4/resize.c
53711 @@ -79,12 +79,20 @@ static int verify_group_input(struct super_block *sb,
53712 ext4_fsblk_t end = start + input->blocks_count;
53713 ext4_group_t group = input->group;
53714 ext4_fsblk_t itend = input->inode_table + sbi->s_itb_per_group;
53715 - unsigned overhead = ext4_group_overhead_blocks(sb, group);
53716 - ext4_fsblk_t metaend = start + overhead;
53717 + unsigned overhead;
53718 + ext4_fsblk_t metaend;
53719 struct buffer_head *bh = NULL;
53720 ext4_grpblk_t free_blocks_count, offset;
53721 int err = -EINVAL;
53722
53723 + if (group != sbi->s_groups_count) {
53724 + ext4_warning(sb, "Cannot add at group %u (only %u groups)",
53725 + input->group, sbi->s_groups_count);
53726 + return -EINVAL;
53727 + }
53728 +
53729 + overhead = ext4_group_overhead_blocks(sb, group);
53730 + metaend = start + overhead;
53731 input->free_blocks_count = free_blocks_count =
53732 input->blocks_count - 2 - overhead - sbi->s_itb_per_group;
53733
53734 @@ -96,10 +104,7 @@ static int verify_group_input(struct super_block *sb,
53735 free_blocks_count, input->reserved_blocks);
53736
53737 ext4_get_group_no_and_offset(sb, start, NULL, &offset);
53738 - if (group != sbi->s_groups_count)
53739 - ext4_warning(sb, "Cannot add at group %u (only %u groups)",
53740 - input->group, sbi->s_groups_count);
53741 - else if (offset != 0)
53742 + if (offset != 0)
53743 ext4_warning(sb, "Last group not full");
53744 else if (input->reserved_blocks > input->blocks_count / 5)
53745 ext4_warning(sb, "Reserved blocks too high (%u)",
53746 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
53747 index 3f7c39e..227f24f 100644
53748 --- a/fs/ext4/super.c
53749 +++ b/fs/ext4/super.c
53750 @@ -1236,7 +1236,7 @@ static ext4_fsblk_t get_sb_block(void **data)
53751 }
53752
53753 #define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
53754 -static char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
53755 +static const char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
53756 "Contact linux-ext4@vger.kernel.org if you think we should keep it.\n";
53757
53758 #ifdef CONFIG_QUOTA
53759 @@ -2372,7 +2372,7 @@ struct ext4_attr {
53760 ssize_t (*store)(struct ext4_attr *, struct ext4_sb_info *,
53761 const char *, size_t);
53762 int offset;
53763 -};
53764 +} __do_const;
53765
53766 static int parse_strtoull(const char *buf,
53767 unsigned long long max, unsigned long long *value)
53768 diff --git a/fs/fcntl.c b/fs/fcntl.c
53769 index 6599222..e7bf0de 100644
53770 --- a/fs/fcntl.c
53771 +++ b/fs/fcntl.c
53772 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
53773 if (err)
53774 return err;
53775
53776 + if (gr_handle_chroot_fowner(pid, type))
53777 + return -ENOENT;
53778 + if (gr_check_protected_task_fowner(pid, type))
53779 + return -EACCES;
53780 +
53781 f_modown(filp, pid, type, force);
53782 return 0;
53783 }
53784 diff --git a/fs/fhandle.c b/fs/fhandle.c
53785 index 999ff5c..41f4109 100644
53786 --- a/fs/fhandle.c
53787 +++ b/fs/fhandle.c
53788 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
53789 } else
53790 retval = 0;
53791 /* copy the mount id */
53792 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
53793 - sizeof(*mnt_id)) ||
53794 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
53795 copy_to_user(ufh, handle,
53796 sizeof(struct file_handle) + handle_bytes))
53797 retval = -EFAULT;
53798 diff --git a/fs/file.c b/fs/file.c
53799 index 4a78f98..9447397 100644
53800 --- a/fs/file.c
53801 +++ b/fs/file.c
53802 @@ -16,6 +16,7 @@
53803 #include <linux/slab.h>
53804 #include <linux/vmalloc.h>
53805 #include <linux/file.h>
53806 +#include <linux/security.h>
53807 #include <linux/fdtable.h>
53808 #include <linux/bitops.h>
53809 #include <linux/interrupt.h>
53810 @@ -828,6 +829,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
53811 if (!file)
53812 return __close_fd(files, fd);
53813
53814 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
53815 if (fd >= rlimit(RLIMIT_NOFILE))
53816 return -EBADF;
53817
53818 @@ -854,6 +856,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
53819 if (unlikely(oldfd == newfd))
53820 return -EINVAL;
53821
53822 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
53823 if (newfd >= rlimit(RLIMIT_NOFILE))
53824 return -EBADF;
53825
53826 @@ -909,6 +912,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
53827 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
53828 {
53829 int err;
53830 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
53831 if (from >= rlimit(RLIMIT_NOFILE))
53832 return -EINVAL;
53833 err = alloc_fd(from, flags);
53834 diff --git a/fs/filesystems.c b/fs/filesystems.c
53835 index 92567d9..fcd8cbf 100644
53836 --- a/fs/filesystems.c
53837 +++ b/fs/filesystems.c
53838 @@ -273,7 +273,11 @@ struct file_system_type *get_fs_type(const char *name)
53839 int len = dot ? dot - name : strlen(name);
53840
53841 fs = __get_fs_type(name, len);
53842 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
53843 + if (!fs && (___request_module(true, "grsec_modharden_fs", "fs-%.*s", len, name) == 0))
53844 +#else
53845 if (!fs && (request_module("fs-%.*s", len, name) == 0))
53846 +#endif
53847 fs = __get_fs_type(name, len);
53848
53849 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
53850 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
53851 index d8ac61d..79a36f0 100644
53852 --- a/fs/fs_struct.c
53853 +++ b/fs/fs_struct.c
53854 @@ -4,6 +4,7 @@
53855 #include <linux/path.h>
53856 #include <linux/slab.h>
53857 #include <linux/fs_struct.h>
53858 +#include <linux/grsecurity.h>
53859 #include "internal.h"
53860
53861 /*
53862 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, const struct path *path)
53863 write_seqcount_begin(&fs->seq);
53864 old_root = fs->root;
53865 fs->root = *path;
53866 + gr_set_chroot_entries(current, path);
53867 write_seqcount_end(&fs->seq);
53868 spin_unlock(&fs->lock);
53869 if (old_root.dentry)
53870 @@ -67,6 +69,10 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
53871 int hits = 0;
53872 spin_lock(&fs->lock);
53873 write_seqcount_begin(&fs->seq);
53874 + /* this root replacement is only done by pivot_root,
53875 + leave grsec's chroot tagging alone for this task
53876 + so that a pivoted root isn't treated as a chroot
53877 + */
53878 hits += replace_path(&fs->root, old_root, new_root);
53879 hits += replace_path(&fs->pwd, old_root, new_root);
53880 write_seqcount_end(&fs->seq);
53881 @@ -99,7 +105,8 @@ void exit_fs(struct task_struct *tsk)
53882 task_lock(tsk);
53883 spin_lock(&fs->lock);
53884 tsk->fs = NULL;
53885 - kill = !--fs->users;
53886 + gr_clear_chroot_entries(tsk);
53887 + kill = !atomic_dec_return(&fs->users);
53888 spin_unlock(&fs->lock);
53889 task_unlock(tsk);
53890 if (kill)
53891 @@ -112,7 +119,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
53892 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
53893 /* We don't need to lock fs - think why ;-) */
53894 if (fs) {
53895 - fs->users = 1;
53896 + atomic_set(&fs->users, 1);
53897 fs->in_exec = 0;
53898 spin_lock_init(&fs->lock);
53899 seqcount_init(&fs->seq);
53900 @@ -121,6 +128,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
53901 spin_lock(&old->lock);
53902 fs->root = old->root;
53903 path_get(&fs->root);
53904 + /* instead of calling gr_set_chroot_entries here,
53905 + we call it from every caller of this function
53906 + */
53907 fs->pwd = old->pwd;
53908 path_get(&fs->pwd);
53909 spin_unlock(&old->lock);
53910 @@ -139,8 +149,9 @@ int unshare_fs_struct(void)
53911
53912 task_lock(current);
53913 spin_lock(&fs->lock);
53914 - kill = !--fs->users;
53915 + kill = !atomic_dec_return(&fs->users);
53916 current->fs = new_fs;
53917 + gr_set_chroot_entries(current, &new_fs->root);
53918 spin_unlock(&fs->lock);
53919 task_unlock(current);
53920
53921 @@ -153,13 +164,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
53922
53923 int current_umask(void)
53924 {
53925 - return current->fs->umask;
53926 + return current->fs->umask | gr_acl_umask();
53927 }
53928 EXPORT_SYMBOL(current_umask);
53929
53930 /* to be mentioned only in INIT_TASK */
53931 struct fs_struct init_fs = {
53932 - .users = 1,
53933 + .users = ATOMIC_INIT(1),
53934 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
53935 .seq = SEQCNT_ZERO,
53936 .umask = 0022,
53937 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
53938 index e2cba1f..17a25bb 100644
53939 --- a/fs/fscache/cookie.c
53940 +++ b/fs/fscache/cookie.c
53941 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
53942 parent ? (char *) parent->def->name : "<no-parent>",
53943 def->name, netfs_data);
53944
53945 - fscache_stat(&fscache_n_acquires);
53946 + fscache_stat_unchecked(&fscache_n_acquires);
53947
53948 /* if there's no parent cookie, then we don't create one here either */
53949 if (!parent) {
53950 - fscache_stat(&fscache_n_acquires_null);
53951 + fscache_stat_unchecked(&fscache_n_acquires_null);
53952 _leave(" [no parent]");
53953 return NULL;
53954 }
53955 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
53956 /* allocate and initialise a cookie */
53957 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
53958 if (!cookie) {
53959 - fscache_stat(&fscache_n_acquires_oom);
53960 + fscache_stat_unchecked(&fscache_n_acquires_oom);
53961 _leave(" [ENOMEM]");
53962 return NULL;
53963 }
53964 @@ -109,13 +109,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
53965
53966 switch (cookie->def->type) {
53967 case FSCACHE_COOKIE_TYPE_INDEX:
53968 - fscache_stat(&fscache_n_cookie_index);
53969 + fscache_stat_unchecked(&fscache_n_cookie_index);
53970 break;
53971 case FSCACHE_COOKIE_TYPE_DATAFILE:
53972 - fscache_stat(&fscache_n_cookie_data);
53973 + fscache_stat_unchecked(&fscache_n_cookie_data);
53974 break;
53975 default:
53976 - fscache_stat(&fscache_n_cookie_special);
53977 + fscache_stat_unchecked(&fscache_n_cookie_special);
53978 break;
53979 }
53980
53981 @@ -126,13 +126,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
53982 if (fscache_acquire_non_index_cookie(cookie) < 0) {
53983 atomic_dec(&parent->n_children);
53984 __fscache_cookie_put(cookie);
53985 - fscache_stat(&fscache_n_acquires_nobufs);
53986 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
53987 _leave(" = NULL");
53988 return NULL;
53989 }
53990 }
53991
53992 - fscache_stat(&fscache_n_acquires_ok);
53993 + fscache_stat_unchecked(&fscache_n_acquires_ok);
53994 _leave(" = %p", cookie);
53995 return cookie;
53996 }
53997 @@ -168,7 +168,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
53998 cache = fscache_select_cache_for_object(cookie->parent);
53999 if (!cache) {
54000 up_read(&fscache_addremove_sem);
54001 - fscache_stat(&fscache_n_acquires_no_cache);
54002 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
54003 _leave(" = -ENOMEDIUM [no cache]");
54004 return -ENOMEDIUM;
54005 }
54006 @@ -255,12 +255,12 @@ static int fscache_alloc_object(struct fscache_cache *cache,
54007 object = cache->ops->alloc_object(cache, cookie);
54008 fscache_stat_d(&fscache_n_cop_alloc_object);
54009 if (IS_ERR(object)) {
54010 - fscache_stat(&fscache_n_object_no_alloc);
54011 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
54012 ret = PTR_ERR(object);
54013 goto error;
54014 }
54015
54016 - fscache_stat(&fscache_n_object_alloc);
54017 + fscache_stat_unchecked(&fscache_n_object_alloc);
54018
54019 object->debug_id = atomic_inc_return(&fscache_object_debug_id);
54020
54021 @@ -376,7 +376,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
54022
54023 _enter("{%s}", cookie->def->name);
54024
54025 - fscache_stat(&fscache_n_invalidates);
54026 + fscache_stat_unchecked(&fscache_n_invalidates);
54027
54028 /* Only permit invalidation of data files. Invalidating an index will
54029 * require the caller to release all its attachments to the tree rooted
54030 @@ -434,10 +434,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
54031 {
54032 struct fscache_object *object;
54033
54034 - fscache_stat(&fscache_n_updates);
54035 + fscache_stat_unchecked(&fscache_n_updates);
54036
54037 if (!cookie) {
54038 - fscache_stat(&fscache_n_updates_null);
54039 + fscache_stat_unchecked(&fscache_n_updates_null);
54040 _leave(" [no cookie]");
54041 return;
54042 }
54043 @@ -471,12 +471,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
54044 struct fscache_object *object;
54045 unsigned long event;
54046
54047 - fscache_stat(&fscache_n_relinquishes);
54048 + fscache_stat_unchecked(&fscache_n_relinquishes);
54049 if (retire)
54050 - fscache_stat(&fscache_n_relinquishes_retire);
54051 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
54052
54053 if (!cookie) {
54054 - fscache_stat(&fscache_n_relinquishes_null);
54055 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
54056 _leave(" [no cookie]");
54057 return;
54058 }
54059 @@ -492,7 +492,7 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
54060
54061 /* wait for the cookie to finish being instantiated (or to fail) */
54062 if (test_bit(FSCACHE_COOKIE_CREATING, &cookie->flags)) {
54063 - fscache_stat(&fscache_n_relinquishes_waitcrt);
54064 + fscache_stat_unchecked(&fscache_n_relinquishes_waitcrt);
54065 wait_on_bit(&cookie->flags, FSCACHE_COOKIE_CREATING,
54066 fscache_wait_bit, TASK_UNINTERRUPTIBLE);
54067 }
54068 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
54069 index ee38fef..0a326d4 100644
54070 --- a/fs/fscache/internal.h
54071 +++ b/fs/fscache/internal.h
54072 @@ -148,101 +148,101 @@ extern void fscache_proc_cleanup(void);
54073 * stats.c
54074 */
54075 #ifdef CONFIG_FSCACHE_STATS
54076 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
54077 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
54078 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
54079 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
54080
54081 -extern atomic_t fscache_n_op_pend;
54082 -extern atomic_t fscache_n_op_run;
54083 -extern atomic_t fscache_n_op_enqueue;
54084 -extern atomic_t fscache_n_op_deferred_release;
54085 -extern atomic_t fscache_n_op_release;
54086 -extern atomic_t fscache_n_op_gc;
54087 -extern atomic_t fscache_n_op_cancelled;
54088 -extern atomic_t fscache_n_op_rejected;
54089 +extern atomic_unchecked_t fscache_n_op_pend;
54090 +extern atomic_unchecked_t fscache_n_op_run;
54091 +extern atomic_unchecked_t fscache_n_op_enqueue;
54092 +extern atomic_unchecked_t fscache_n_op_deferred_release;
54093 +extern atomic_unchecked_t fscache_n_op_release;
54094 +extern atomic_unchecked_t fscache_n_op_gc;
54095 +extern atomic_unchecked_t fscache_n_op_cancelled;
54096 +extern atomic_unchecked_t fscache_n_op_rejected;
54097
54098 -extern atomic_t fscache_n_attr_changed;
54099 -extern atomic_t fscache_n_attr_changed_ok;
54100 -extern atomic_t fscache_n_attr_changed_nobufs;
54101 -extern atomic_t fscache_n_attr_changed_nomem;
54102 -extern atomic_t fscache_n_attr_changed_calls;
54103 +extern atomic_unchecked_t fscache_n_attr_changed;
54104 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
54105 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
54106 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
54107 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
54108
54109 -extern atomic_t fscache_n_allocs;
54110 -extern atomic_t fscache_n_allocs_ok;
54111 -extern atomic_t fscache_n_allocs_wait;
54112 -extern atomic_t fscache_n_allocs_nobufs;
54113 -extern atomic_t fscache_n_allocs_intr;
54114 -extern atomic_t fscache_n_allocs_object_dead;
54115 -extern atomic_t fscache_n_alloc_ops;
54116 -extern atomic_t fscache_n_alloc_op_waits;
54117 +extern atomic_unchecked_t fscache_n_allocs;
54118 +extern atomic_unchecked_t fscache_n_allocs_ok;
54119 +extern atomic_unchecked_t fscache_n_allocs_wait;
54120 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
54121 +extern atomic_unchecked_t fscache_n_allocs_intr;
54122 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
54123 +extern atomic_unchecked_t fscache_n_alloc_ops;
54124 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
54125
54126 -extern atomic_t fscache_n_retrievals;
54127 -extern atomic_t fscache_n_retrievals_ok;
54128 -extern atomic_t fscache_n_retrievals_wait;
54129 -extern atomic_t fscache_n_retrievals_nodata;
54130 -extern atomic_t fscache_n_retrievals_nobufs;
54131 -extern atomic_t fscache_n_retrievals_intr;
54132 -extern atomic_t fscache_n_retrievals_nomem;
54133 -extern atomic_t fscache_n_retrievals_object_dead;
54134 -extern atomic_t fscache_n_retrieval_ops;
54135 -extern atomic_t fscache_n_retrieval_op_waits;
54136 +extern atomic_unchecked_t fscache_n_retrievals;
54137 +extern atomic_unchecked_t fscache_n_retrievals_ok;
54138 +extern atomic_unchecked_t fscache_n_retrievals_wait;
54139 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
54140 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
54141 +extern atomic_unchecked_t fscache_n_retrievals_intr;
54142 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
54143 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
54144 +extern atomic_unchecked_t fscache_n_retrieval_ops;
54145 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
54146
54147 -extern atomic_t fscache_n_stores;
54148 -extern atomic_t fscache_n_stores_ok;
54149 -extern atomic_t fscache_n_stores_again;
54150 -extern atomic_t fscache_n_stores_nobufs;
54151 -extern atomic_t fscache_n_stores_oom;
54152 -extern atomic_t fscache_n_store_ops;
54153 -extern atomic_t fscache_n_store_calls;
54154 -extern atomic_t fscache_n_store_pages;
54155 -extern atomic_t fscache_n_store_radix_deletes;
54156 -extern atomic_t fscache_n_store_pages_over_limit;
54157 +extern atomic_unchecked_t fscache_n_stores;
54158 +extern atomic_unchecked_t fscache_n_stores_ok;
54159 +extern atomic_unchecked_t fscache_n_stores_again;
54160 +extern atomic_unchecked_t fscache_n_stores_nobufs;
54161 +extern atomic_unchecked_t fscache_n_stores_oom;
54162 +extern atomic_unchecked_t fscache_n_store_ops;
54163 +extern atomic_unchecked_t fscache_n_store_calls;
54164 +extern atomic_unchecked_t fscache_n_store_pages;
54165 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
54166 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
54167
54168 -extern atomic_t fscache_n_store_vmscan_not_storing;
54169 -extern atomic_t fscache_n_store_vmscan_gone;
54170 -extern atomic_t fscache_n_store_vmscan_busy;
54171 -extern atomic_t fscache_n_store_vmscan_cancelled;
54172 -extern atomic_t fscache_n_store_vmscan_wait;
54173 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
54174 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
54175 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
54176 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
54177 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
54178
54179 -extern atomic_t fscache_n_marks;
54180 -extern atomic_t fscache_n_uncaches;
54181 +extern atomic_unchecked_t fscache_n_marks;
54182 +extern atomic_unchecked_t fscache_n_uncaches;
54183
54184 -extern atomic_t fscache_n_acquires;
54185 -extern atomic_t fscache_n_acquires_null;
54186 -extern atomic_t fscache_n_acquires_no_cache;
54187 -extern atomic_t fscache_n_acquires_ok;
54188 -extern atomic_t fscache_n_acquires_nobufs;
54189 -extern atomic_t fscache_n_acquires_oom;
54190 +extern atomic_unchecked_t fscache_n_acquires;
54191 +extern atomic_unchecked_t fscache_n_acquires_null;
54192 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
54193 +extern atomic_unchecked_t fscache_n_acquires_ok;
54194 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
54195 +extern atomic_unchecked_t fscache_n_acquires_oom;
54196
54197 -extern atomic_t fscache_n_invalidates;
54198 -extern atomic_t fscache_n_invalidates_run;
54199 +extern atomic_unchecked_t fscache_n_invalidates;
54200 +extern atomic_unchecked_t fscache_n_invalidates_run;
54201
54202 -extern atomic_t fscache_n_updates;
54203 -extern atomic_t fscache_n_updates_null;
54204 -extern atomic_t fscache_n_updates_run;
54205 +extern atomic_unchecked_t fscache_n_updates;
54206 +extern atomic_unchecked_t fscache_n_updates_null;
54207 +extern atomic_unchecked_t fscache_n_updates_run;
54208
54209 -extern atomic_t fscache_n_relinquishes;
54210 -extern atomic_t fscache_n_relinquishes_null;
54211 -extern atomic_t fscache_n_relinquishes_waitcrt;
54212 -extern atomic_t fscache_n_relinquishes_retire;
54213 +extern atomic_unchecked_t fscache_n_relinquishes;
54214 +extern atomic_unchecked_t fscache_n_relinquishes_null;
54215 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
54216 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
54217
54218 -extern atomic_t fscache_n_cookie_index;
54219 -extern atomic_t fscache_n_cookie_data;
54220 -extern atomic_t fscache_n_cookie_special;
54221 +extern atomic_unchecked_t fscache_n_cookie_index;
54222 +extern atomic_unchecked_t fscache_n_cookie_data;
54223 +extern atomic_unchecked_t fscache_n_cookie_special;
54224
54225 -extern atomic_t fscache_n_object_alloc;
54226 -extern atomic_t fscache_n_object_no_alloc;
54227 -extern atomic_t fscache_n_object_lookups;
54228 -extern atomic_t fscache_n_object_lookups_negative;
54229 -extern atomic_t fscache_n_object_lookups_positive;
54230 -extern atomic_t fscache_n_object_lookups_timed_out;
54231 -extern atomic_t fscache_n_object_created;
54232 -extern atomic_t fscache_n_object_avail;
54233 -extern atomic_t fscache_n_object_dead;
54234 +extern atomic_unchecked_t fscache_n_object_alloc;
54235 +extern atomic_unchecked_t fscache_n_object_no_alloc;
54236 +extern atomic_unchecked_t fscache_n_object_lookups;
54237 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
54238 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
54239 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
54240 +extern atomic_unchecked_t fscache_n_object_created;
54241 +extern atomic_unchecked_t fscache_n_object_avail;
54242 +extern atomic_unchecked_t fscache_n_object_dead;
54243
54244 -extern atomic_t fscache_n_checkaux_none;
54245 -extern atomic_t fscache_n_checkaux_okay;
54246 -extern atomic_t fscache_n_checkaux_update;
54247 -extern atomic_t fscache_n_checkaux_obsolete;
54248 +extern atomic_unchecked_t fscache_n_checkaux_none;
54249 +extern atomic_unchecked_t fscache_n_checkaux_okay;
54250 +extern atomic_unchecked_t fscache_n_checkaux_update;
54251 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
54252
54253 extern atomic_t fscache_n_cop_alloc_object;
54254 extern atomic_t fscache_n_cop_lookup_object;
54255 @@ -267,6 +267,11 @@ static inline void fscache_stat(atomic_t *stat)
54256 atomic_inc(stat);
54257 }
54258
54259 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
54260 +{
54261 + atomic_inc_unchecked(stat);
54262 +}
54263 +
54264 static inline void fscache_stat_d(atomic_t *stat)
54265 {
54266 atomic_dec(stat);
54267 @@ -279,6 +284,7 @@ extern const struct file_operations fscache_stats_fops;
54268
54269 #define __fscache_stat(stat) (NULL)
54270 #define fscache_stat(stat) do {} while (0)
54271 +#define fscache_stat_unchecked(stat) do {} while (0)
54272 #define fscache_stat_d(stat) do {} while (0)
54273 #endif
54274
54275 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
54276 index 50d41c1..10ee117 100644
54277 --- a/fs/fscache/object.c
54278 +++ b/fs/fscache/object.c
54279 @@ -143,7 +143,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
54280 /* Invalidate an object on disk */
54281 case FSCACHE_OBJECT_INVALIDATING:
54282 clear_bit(FSCACHE_OBJECT_EV_INVALIDATE, &object->events);
54283 - fscache_stat(&fscache_n_invalidates_run);
54284 + fscache_stat_unchecked(&fscache_n_invalidates_run);
54285 fscache_stat(&fscache_n_cop_invalidate_object);
54286 fscache_invalidate_object(object);
54287 fscache_stat_d(&fscache_n_cop_invalidate_object);
54288 @@ -153,7 +153,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
54289 /* update the object metadata on disk */
54290 case FSCACHE_OBJECT_UPDATING:
54291 clear_bit(FSCACHE_OBJECT_EV_UPDATE, &object->events);
54292 - fscache_stat(&fscache_n_updates_run);
54293 + fscache_stat_unchecked(&fscache_n_updates_run);
54294 fscache_stat(&fscache_n_cop_update_object);
54295 object->cache->ops->update_object(object);
54296 fscache_stat_d(&fscache_n_cop_update_object);
54297 @@ -242,7 +242,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
54298 spin_lock(&object->lock);
54299 object->state = FSCACHE_OBJECT_DEAD;
54300 spin_unlock(&object->lock);
54301 - fscache_stat(&fscache_n_object_dead);
54302 + fscache_stat_unchecked(&fscache_n_object_dead);
54303 goto terminal_transit;
54304
54305 /* handle the parent cache of this object being withdrawn from
54306 @@ -257,7 +257,7 @@ static void fscache_object_state_machine(struct fscache_object *object)
54307 spin_lock(&object->lock);
54308 object->state = FSCACHE_OBJECT_DEAD;
54309 spin_unlock(&object->lock);
54310 - fscache_stat(&fscache_n_object_dead);
54311 + fscache_stat_unchecked(&fscache_n_object_dead);
54312 goto terminal_transit;
54313
54314 /* complain about the object being woken up once it is
54315 @@ -495,7 +495,7 @@ static void fscache_lookup_object(struct fscache_object *object)
54316 parent->cookie->def->name, cookie->def->name,
54317 object->cache->tag->name);
54318
54319 - fscache_stat(&fscache_n_object_lookups);
54320 + fscache_stat_unchecked(&fscache_n_object_lookups);
54321 fscache_stat(&fscache_n_cop_lookup_object);
54322 ret = object->cache->ops->lookup_object(object);
54323 fscache_stat_d(&fscache_n_cop_lookup_object);
54324 @@ -506,7 +506,7 @@ static void fscache_lookup_object(struct fscache_object *object)
54325 if (ret == -ETIMEDOUT) {
54326 /* probably stuck behind another object, so move this one to
54327 * the back of the queue */
54328 - fscache_stat(&fscache_n_object_lookups_timed_out);
54329 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
54330 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
54331 }
54332
54333 @@ -529,7 +529,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
54334
54335 spin_lock(&object->lock);
54336 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
54337 - fscache_stat(&fscache_n_object_lookups_negative);
54338 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
54339
54340 /* transit here to allow write requests to begin stacking up
54341 * and read requests to begin returning ENODATA */
54342 @@ -575,7 +575,7 @@ void fscache_obtained_object(struct fscache_object *object)
54343 * result, in which case there may be data available */
54344 spin_lock(&object->lock);
54345 if (object->state == FSCACHE_OBJECT_LOOKING_UP) {
54346 - fscache_stat(&fscache_n_object_lookups_positive);
54347 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
54348
54349 clear_bit(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
54350
54351 @@ -589,7 +589,7 @@ void fscache_obtained_object(struct fscache_object *object)
54352 set_bit(FSCACHE_OBJECT_EV_REQUEUE, &object->events);
54353 } else {
54354 ASSERTCMP(object->state, ==, FSCACHE_OBJECT_CREATING);
54355 - fscache_stat(&fscache_n_object_created);
54356 + fscache_stat_unchecked(&fscache_n_object_created);
54357
54358 object->state = FSCACHE_OBJECT_AVAILABLE;
54359 spin_unlock(&object->lock);
54360 @@ -634,7 +634,7 @@ static void fscache_object_available(struct fscache_object *object)
54361 fscache_enqueue_dependents(object);
54362
54363 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
54364 - fscache_stat(&fscache_n_object_avail);
54365 + fscache_stat_unchecked(&fscache_n_object_avail);
54366
54367 _leave("");
54368 }
54369 @@ -894,7 +894,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
54370 enum fscache_checkaux result;
54371
54372 if (!object->cookie->def->check_aux) {
54373 - fscache_stat(&fscache_n_checkaux_none);
54374 + fscache_stat_unchecked(&fscache_n_checkaux_none);
54375 return FSCACHE_CHECKAUX_OKAY;
54376 }
54377
54378 @@ -903,17 +903,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
54379 switch (result) {
54380 /* entry okay as is */
54381 case FSCACHE_CHECKAUX_OKAY:
54382 - fscache_stat(&fscache_n_checkaux_okay);
54383 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
54384 break;
54385
54386 /* entry requires update */
54387 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
54388 - fscache_stat(&fscache_n_checkaux_update);
54389 + fscache_stat_unchecked(&fscache_n_checkaux_update);
54390 break;
54391
54392 /* entry requires deletion */
54393 case FSCACHE_CHECKAUX_OBSOLETE:
54394 - fscache_stat(&fscache_n_checkaux_obsolete);
54395 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
54396 break;
54397
54398 default:
54399 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
54400 index 762a9ec..2023284 100644
54401 --- a/fs/fscache/operation.c
54402 +++ b/fs/fscache/operation.c
54403 @@ -17,7 +17,7 @@
54404 #include <linux/slab.h>
54405 #include "internal.h"
54406
54407 -atomic_t fscache_op_debug_id;
54408 +atomic_unchecked_t fscache_op_debug_id;
54409 EXPORT_SYMBOL(fscache_op_debug_id);
54410
54411 /**
54412 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
54413 ASSERTCMP(atomic_read(&op->usage), >, 0);
54414 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
54415
54416 - fscache_stat(&fscache_n_op_enqueue);
54417 + fscache_stat_unchecked(&fscache_n_op_enqueue);
54418 switch (op->flags & FSCACHE_OP_TYPE) {
54419 case FSCACHE_OP_ASYNC:
54420 _debug("queue async");
54421 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
54422 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
54423 if (op->processor)
54424 fscache_enqueue_operation(op);
54425 - fscache_stat(&fscache_n_op_run);
54426 + fscache_stat_unchecked(&fscache_n_op_run);
54427 }
54428
54429 /*
54430 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
54431 if (object->n_in_progress > 0) {
54432 atomic_inc(&op->usage);
54433 list_add_tail(&op->pend_link, &object->pending_ops);
54434 - fscache_stat(&fscache_n_op_pend);
54435 + fscache_stat_unchecked(&fscache_n_op_pend);
54436 } else if (!list_empty(&object->pending_ops)) {
54437 atomic_inc(&op->usage);
54438 list_add_tail(&op->pend_link, &object->pending_ops);
54439 - fscache_stat(&fscache_n_op_pend);
54440 + fscache_stat_unchecked(&fscache_n_op_pend);
54441 fscache_start_operations(object);
54442 } else {
54443 ASSERTCMP(object->n_in_progress, ==, 0);
54444 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
54445 object->n_exclusive++; /* reads and writes must wait */
54446 atomic_inc(&op->usage);
54447 list_add_tail(&op->pend_link, &object->pending_ops);
54448 - fscache_stat(&fscache_n_op_pend);
54449 + fscache_stat_unchecked(&fscache_n_op_pend);
54450 ret = 0;
54451 } else {
54452 /* If we're in any other state, there must have been an I/O
54453 @@ -215,11 +215,11 @@ int fscache_submit_op(struct fscache_object *object,
54454 if (object->n_exclusive > 0) {
54455 atomic_inc(&op->usage);
54456 list_add_tail(&op->pend_link, &object->pending_ops);
54457 - fscache_stat(&fscache_n_op_pend);
54458 + fscache_stat_unchecked(&fscache_n_op_pend);
54459 } else if (!list_empty(&object->pending_ops)) {
54460 atomic_inc(&op->usage);
54461 list_add_tail(&op->pend_link, &object->pending_ops);
54462 - fscache_stat(&fscache_n_op_pend);
54463 + fscache_stat_unchecked(&fscache_n_op_pend);
54464 fscache_start_operations(object);
54465 } else {
54466 ASSERTCMP(object->n_exclusive, ==, 0);
54467 @@ -231,12 +231,12 @@ int fscache_submit_op(struct fscache_object *object,
54468 object->n_ops++;
54469 atomic_inc(&op->usage);
54470 list_add_tail(&op->pend_link, &object->pending_ops);
54471 - fscache_stat(&fscache_n_op_pend);
54472 + fscache_stat_unchecked(&fscache_n_op_pend);
54473 ret = 0;
54474 } else if (object->state == FSCACHE_OBJECT_DYING ||
54475 object->state == FSCACHE_OBJECT_LC_DYING ||
54476 object->state == FSCACHE_OBJECT_WITHDRAWING) {
54477 - fscache_stat(&fscache_n_op_rejected);
54478 + fscache_stat_unchecked(&fscache_n_op_rejected);
54479 op->state = FSCACHE_OP_ST_CANCELLED;
54480 ret = -ENOBUFS;
54481 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
54482 @@ -315,7 +315,7 @@ int fscache_cancel_op(struct fscache_operation *op,
54483 ret = -EBUSY;
54484 if (op->state == FSCACHE_OP_ST_PENDING) {
54485 ASSERT(!list_empty(&op->pend_link));
54486 - fscache_stat(&fscache_n_op_cancelled);
54487 + fscache_stat_unchecked(&fscache_n_op_cancelled);
54488 list_del_init(&op->pend_link);
54489 if (do_cancel)
54490 do_cancel(op);
54491 @@ -347,7 +347,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
54492 while (!list_empty(&object->pending_ops)) {
54493 op = list_entry(object->pending_ops.next,
54494 struct fscache_operation, pend_link);
54495 - fscache_stat(&fscache_n_op_cancelled);
54496 + fscache_stat_unchecked(&fscache_n_op_cancelled);
54497 list_del_init(&op->pend_link);
54498
54499 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
54500 @@ -419,7 +419,7 @@ void fscache_put_operation(struct fscache_operation *op)
54501 op->state, ==, FSCACHE_OP_ST_CANCELLED);
54502 op->state = FSCACHE_OP_ST_DEAD;
54503
54504 - fscache_stat(&fscache_n_op_release);
54505 + fscache_stat_unchecked(&fscache_n_op_release);
54506
54507 if (op->release) {
54508 op->release(op);
54509 @@ -442,7 +442,7 @@ void fscache_put_operation(struct fscache_operation *op)
54510 * lock, and defer it otherwise */
54511 if (!spin_trylock(&object->lock)) {
54512 _debug("defer put");
54513 - fscache_stat(&fscache_n_op_deferred_release);
54514 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
54515
54516 cache = object->cache;
54517 spin_lock(&cache->op_gc_list_lock);
54518 @@ -495,7 +495,7 @@ void fscache_operation_gc(struct work_struct *work)
54519
54520 _debug("GC DEFERRED REL OBJ%x OP%x",
54521 object->debug_id, op->debug_id);
54522 - fscache_stat(&fscache_n_op_gc);
54523 + fscache_stat_unchecked(&fscache_n_op_gc);
54524
54525 ASSERTCMP(atomic_read(&op->usage), ==, 0);
54526 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
54527 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
54528 index ff000e5..c44ec6d 100644
54529 --- a/fs/fscache/page.c
54530 +++ b/fs/fscache/page.c
54531 @@ -61,7 +61,7 @@ try_again:
54532 val = radix_tree_lookup(&cookie->stores, page->index);
54533 if (!val) {
54534 rcu_read_unlock();
54535 - fscache_stat(&fscache_n_store_vmscan_not_storing);
54536 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
54537 __fscache_uncache_page(cookie, page);
54538 return true;
54539 }
54540 @@ -91,11 +91,11 @@ try_again:
54541 spin_unlock(&cookie->stores_lock);
54542
54543 if (xpage) {
54544 - fscache_stat(&fscache_n_store_vmscan_cancelled);
54545 - fscache_stat(&fscache_n_store_radix_deletes);
54546 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
54547 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
54548 ASSERTCMP(xpage, ==, page);
54549 } else {
54550 - fscache_stat(&fscache_n_store_vmscan_gone);
54551 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
54552 }
54553
54554 wake_up_bit(&cookie->flags, 0);
54555 @@ -110,11 +110,11 @@ page_busy:
54556 * sleeping on memory allocation, so we may need to impose a timeout
54557 * too. */
54558 if (!(gfp & __GFP_WAIT)) {
54559 - fscache_stat(&fscache_n_store_vmscan_busy);
54560 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
54561 return false;
54562 }
54563
54564 - fscache_stat(&fscache_n_store_vmscan_wait);
54565 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
54566 __fscache_wait_on_page_write(cookie, page);
54567 gfp &= ~__GFP_WAIT;
54568 goto try_again;
54569 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
54570 FSCACHE_COOKIE_STORING_TAG);
54571 if (!radix_tree_tag_get(&cookie->stores, page->index,
54572 FSCACHE_COOKIE_PENDING_TAG)) {
54573 - fscache_stat(&fscache_n_store_radix_deletes);
54574 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
54575 xpage = radix_tree_delete(&cookie->stores, page->index);
54576 }
54577 spin_unlock(&cookie->stores_lock);
54578 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
54579
54580 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
54581
54582 - fscache_stat(&fscache_n_attr_changed_calls);
54583 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
54584
54585 if (fscache_object_is_active(object)) {
54586 fscache_stat(&fscache_n_cop_attr_changed);
54587 @@ -187,11 +187,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
54588
54589 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
54590
54591 - fscache_stat(&fscache_n_attr_changed);
54592 + fscache_stat_unchecked(&fscache_n_attr_changed);
54593
54594 op = kzalloc(sizeof(*op), GFP_KERNEL);
54595 if (!op) {
54596 - fscache_stat(&fscache_n_attr_changed_nomem);
54597 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
54598 _leave(" = -ENOMEM");
54599 return -ENOMEM;
54600 }
54601 @@ -209,7 +209,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
54602 if (fscache_submit_exclusive_op(object, op) < 0)
54603 goto nobufs;
54604 spin_unlock(&cookie->lock);
54605 - fscache_stat(&fscache_n_attr_changed_ok);
54606 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
54607 fscache_put_operation(op);
54608 _leave(" = 0");
54609 return 0;
54610 @@ -217,7 +217,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
54611 nobufs:
54612 spin_unlock(&cookie->lock);
54613 kfree(op);
54614 - fscache_stat(&fscache_n_attr_changed_nobufs);
54615 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
54616 _leave(" = %d", -ENOBUFS);
54617 return -ENOBUFS;
54618 }
54619 @@ -255,7 +255,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
54620 /* allocate a retrieval operation and attempt to submit it */
54621 op = kzalloc(sizeof(*op), GFP_NOIO);
54622 if (!op) {
54623 - fscache_stat(&fscache_n_retrievals_nomem);
54624 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
54625 return NULL;
54626 }
54627
54628 @@ -283,13 +283,13 @@ static int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
54629 return 0;
54630 }
54631
54632 - fscache_stat(&fscache_n_retrievals_wait);
54633 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
54634
54635 jif = jiffies;
54636 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
54637 fscache_wait_bit_interruptible,
54638 TASK_INTERRUPTIBLE) != 0) {
54639 - fscache_stat(&fscache_n_retrievals_intr);
54640 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
54641 _leave(" = -ERESTARTSYS");
54642 return -ERESTARTSYS;
54643 }
54644 @@ -318,8 +318,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
54645 */
54646 static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
54647 struct fscache_retrieval *op,
54648 - atomic_t *stat_op_waits,
54649 - atomic_t *stat_object_dead)
54650 + atomic_unchecked_t *stat_op_waits,
54651 + atomic_unchecked_t *stat_object_dead)
54652 {
54653 int ret;
54654
54655 @@ -327,7 +327,7 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
54656 goto check_if_dead;
54657
54658 _debug(">>> WT");
54659 - fscache_stat(stat_op_waits);
54660 + fscache_stat_unchecked(stat_op_waits);
54661 if (wait_on_bit(&op->op.flags, FSCACHE_OP_WAITING,
54662 fscache_wait_bit_interruptible,
54663 TASK_INTERRUPTIBLE) != 0) {
54664 @@ -344,14 +344,14 @@ static int fscache_wait_for_retrieval_activation(struct fscache_object *object,
54665
54666 check_if_dead:
54667 if (op->op.state == FSCACHE_OP_ST_CANCELLED) {
54668 - fscache_stat(stat_object_dead);
54669 + fscache_stat_unchecked(stat_object_dead);
54670 _leave(" = -ENOBUFS [cancelled]");
54671 return -ENOBUFS;
54672 }
54673 if (unlikely(fscache_object_is_dead(object))) {
54674 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->op.state);
54675 fscache_cancel_op(&op->op, fscache_do_cancel_retrieval);
54676 - fscache_stat(stat_object_dead);
54677 + fscache_stat_unchecked(stat_object_dead);
54678 return -ENOBUFS;
54679 }
54680 return 0;
54681 @@ -378,7 +378,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
54682
54683 _enter("%p,%p,,,", cookie, page);
54684
54685 - fscache_stat(&fscache_n_retrievals);
54686 + fscache_stat_unchecked(&fscache_n_retrievals);
54687
54688 if (hlist_empty(&cookie->backing_objects))
54689 goto nobufs;
54690 @@ -417,7 +417,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
54691 goto nobufs_unlock_dec;
54692 spin_unlock(&cookie->lock);
54693
54694 - fscache_stat(&fscache_n_retrieval_ops);
54695 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
54696
54697 /* pin the netfs read context in case we need to do the actual netfs
54698 * read because we've encountered a cache read failure */
54699 @@ -447,15 +447,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
54700
54701 error:
54702 if (ret == -ENOMEM)
54703 - fscache_stat(&fscache_n_retrievals_nomem);
54704 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
54705 else if (ret == -ERESTARTSYS)
54706 - fscache_stat(&fscache_n_retrievals_intr);
54707 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
54708 else if (ret == -ENODATA)
54709 - fscache_stat(&fscache_n_retrievals_nodata);
54710 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
54711 else if (ret < 0)
54712 - fscache_stat(&fscache_n_retrievals_nobufs);
54713 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
54714 else
54715 - fscache_stat(&fscache_n_retrievals_ok);
54716 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
54717
54718 fscache_put_retrieval(op);
54719 _leave(" = %d", ret);
54720 @@ -467,7 +467,7 @@ nobufs_unlock:
54721 spin_unlock(&cookie->lock);
54722 kfree(op);
54723 nobufs:
54724 - fscache_stat(&fscache_n_retrievals_nobufs);
54725 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
54726 _leave(" = -ENOBUFS");
54727 return -ENOBUFS;
54728 }
54729 @@ -505,7 +505,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
54730
54731 _enter("%p,,%d,,,", cookie, *nr_pages);
54732
54733 - fscache_stat(&fscache_n_retrievals);
54734 + fscache_stat_unchecked(&fscache_n_retrievals);
54735
54736 if (hlist_empty(&cookie->backing_objects))
54737 goto nobufs;
54738 @@ -541,7 +541,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
54739 goto nobufs_unlock_dec;
54740 spin_unlock(&cookie->lock);
54741
54742 - fscache_stat(&fscache_n_retrieval_ops);
54743 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
54744
54745 /* pin the netfs read context in case we need to do the actual netfs
54746 * read because we've encountered a cache read failure */
54747 @@ -571,15 +571,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
54748
54749 error:
54750 if (ret == -ENOMEM)
54751 - fscache_stat(&fscache_n_retrievals_nomem);
54752 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
54753 else if (ret == -ERESTARTSYS)
54754 - fscache_stat(&fscache_n_retrievals_intr);
54755 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
54756 else if (ret == -ENODATA)
54757 - fscache_stat(&fscache_n_retrievals_nodata);
54758 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
54759 else if (ret < 0)
54760 - fscache_stat(&fscache_n_retrievals_nobufs);
54761 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
54762 else
54763 - fscache_stat(&fscache_n_retrievals_ok);
54764 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
54765
54766 fscache_put_retrieval(op);
54767 _leave(" = %d", ret);
54768 @@ -591,7 +591,7 @@ nobufs_unlock:
54769 spin_unlock(&cookie->lock);
54770 kfree(op);
54771 nobufs:
54772 - fscache_stat(&fscache_n_retrievals_nobufs);
54773 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
54774 _leave(" = -ENOBUFS");
54775 return -ENOBUFS;
54776 }
54777 @@ -615,7 +615,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
54778
54779 _enter("%p,%p,,,", cookie, page);
54780
54781 - fscache_stat(&fscache_n_allocs);
54782 + fscache_stat_unchecked(&fscache_n_allocs);
54783
54784 if (hlist_empty(&cookie->backing_objects))
54785 goto nobufs;
54786 @@ -647,7 +647,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
54787 goto nobufs_unlock;
54788 spin_unlock(&cookie->lock);
54789
54790 - fscache_stat(&fscache_n_alloc_ops);
54791 + fscache_stat_unchecked(&fscache_n_alloc_ops);
54792
54793 ret = fscache_wait_for_retrieval_activation(
54794 object, op,
54795 @@ -663,11 +663,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
54796
54797 error:
54798 if (ret == -ERESTARTSYS)
54799 - fscache_stat(&fscache_n_allocs_intr);
54800 + fscache_stat_unchecked(&fscache_n_allocs_intr);
54801 else if (ret < 0)
54802 - fscache_stat(&fscache_n_allocs_nobufs);
54803 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
54804 else
54805 - fscache_stat(&fscache_n_allocs_ok);
54806 + fscache_stat_unchecked(&fscache_n_allocs_ok);
54807
54808 fscache_put_retrieval(op);
54809 _leave(" = %d", ret);
54810 @@ -677,7 +677,7 @@ nobufs_unlock:
54811 spin_unlock(&cookie->lock);
54812 kfree(op);
54813 nobufs:
54814 - fscache_stat(&fscache_n_allocs_nobufs);
54815 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
54816 _leave(" = -ENOBUFS");
54817 return -ENOBUFS;
54818 }
54819 @@ -736,7 +736,7 @@ static void fscache_write_op(struct fscache_operation *_op)
54820
54821 spin_lock(&cookie->stores_lock);
54822
54823 - fscache_stat(&fscache_n_store_calls);
54824 + fscache_stat_unchecked(&fscache_n_store_calls);
54825
54826 /* find a page to store */
54827 page = NULL;
54828 @@ -747,7 +747,7 @@ static void fscache_write_op(struct fscache_operation *_op)
54829 page = results[0];
54830 _debug("gang %d [%lx]", n, page->index);
54831 if (page->index > op->store_limit) {
54832 - fscache_stat(&fscache_n_store_pages_over_limit);
54833 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
54834 goto superseded;
54835 }
54836
54837 @@ -759,7 +759,7 @@ static void fscache_write_op(struct fscache_operation *_op)
54838 spin_unlock(&cookie->stores_lock);
54839 spin_unlock(&object->lock);
54840
54841 - fscache_stat(&fscache_n_store_pages);
54842 + fscache_stat_unchecked(&fscache_n_store_pages);
54843 fscache_stat(&fscache_n_cop_write_page);
54844 ret = object->cache->ops->write_page(op, page);
54845 fscache_stat_d(&fscache_n_cop_write_page);
54846 @@ -860,7 +860,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
54847 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
54848 ASSERT(PageFsCache(page));
54849
54850 - fscache_stat(&fscache_n_stores);
54851 + fscache_stat_unchecked(&fscache_n_stores);
54852
54853 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
54854 _leave(" = -ENOBUFS [invalidating]");
54855 @@ -916,7 +916,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
54856 spin_unlock(&cookie->stores_lock);
54857 spin_unlock(&object->lock);
54858
54859 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
54860 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
54861 op->store_limit = object->store_limit;
54862
54863 if (fscache_submit_op(object, &op->op) < 0)
54864 @@ -924,8 +924,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
54865
54866 spin_unlock(&cookie->lock);
54867 radix_tree_preload_end();
54868 - fscache_stat(&fscache_n_store_ops);
54869 - fscache_stat(&fscache_n_stores_ok);
54870 + fscache_stat_unchecked(&fscache_n_store_ops);
54871 + fscache_stat_unchecked(&fscache_n_stores_ok);
54872
54873 /* the work queue now carries its own ref on the object */
54874 fscache_put_operation(&op->op);
54875 @@ -933,14 +933,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
54876 return 0;
54877
54878 already_queued:
54879 - fscache_stat(&fscache_n_stores_again);
54880 + fscache_stat_unchecked(&fscache_n_stores_again);
54881 already_pending:
54882 spin_unlock(&cookie->stores_lock);
54883 spin_unlock(&object->lock);
54884 spin_unlock(&cookie->lock);
54885 radix_tree_preload_end();
54886 kfree(op);
54887 - fscache_stat(&fscache_n_stores_ok);
54888 + fscache_stat_unchecked(&fscache_n_stores_ok);
54889 _leave(" = 0");
54890 return 0;
54891
54892 @@ -959,14 +959,14 @@ nobufs:
54893 spin_unlock(&cookie->lock);
54894 radix_tree_preload_end();
54895 kfree(op);
54896 - fscache_stat(&fscache_n_stores_nobufs);
54897 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
54898 _leave(" = -ENOBUFS");
54899 return -ENOBUFS;
54900
54901 nomem_free:
54902 kfree(op);
54903 nomem:
54904 - fscache_stat(&fscache_n_stores_oom);
54905 + fscache_stat_unchecked(&fscache_n_stores_oom);
54906 _leave(" = -ENOMEM");
54907 return -ENOMEM;
54908 }
54909 @@ -984,7 +984,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
54910 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
54911 ASSERTCMP(page, !=, NULL);
54912
54913 - fscache_stat(&fscache_n_uncaches);
54914 + fscache_stat_unchecked(&fscache_n_uncaches);
54915
54916 /* cache withdrawal may beat us to it */
54917 if (!PageFsCache(page))
54918 @@ -1035,7 +1035,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
54919 struct fscache_cookie *cookie = op->op.object->cookie;
54920
54921 #ifdef CONFIG_FSCACHE_STATS
54922 - atomic_inc(&fscache_n_marks);
54923 + atomic_inc_unchecked(&fscache_n_marks);
54924 #endif
54925
54926 _debug("- mark %p{%lx}", page, page->index);
54927 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
54928 index 40d13c7..ddf52b9 100644
54929 --- a/fs/fscache/stats.c
54930 +++ b/fs/fscache/stats.c
54931 @@ -18,99 +18,99 @@
54932 /*
54933 * operation counters
54934 */
54935 -atomic_t fscache_n_op_pend;
54936 -atomic_t fscache_n_op_run;
54937 -atomic_t fscache_n_op_enqueue;
54938 -atomic_t fscache_n_op_requeue;
54939 -atomic_t fscache_n_op_deferred_release;
54940 -atomic_t fscache_n_op_release;
54941 -atomic_t fscache_n_op_gc;
54942 -atomic_t fscache_n_op_cancelled;
54943 -atomic_t fscache_n_op_rejected;
54944 +atomic_unchecked_t fscache_n_op_pend;
54945 +atomic_unchecked_t fscache_n_op_run;
54946 +atomic_unchecked_t fscache_n_op_enqueue;
54947 +atomic_unchecked_t fscache_n_op_requeue;
54948 +atomic_unchecked_t fscache_n_op_deferred_release;
54949 +atomic_unchecked_t fscache_n_op_release;
54950 +atomic_unchecked_t fscache_n_op_gc;
54951 +atomic_unchecked_t fscache_n_op_cancelled;
54952 +atomic_unchecked_t fscache_n_op_rejected;
54953
54954 -atomic_t fscache_n_attr_changed;
54955 -atomic_t fscache_n_attr_changed_ok;
54956 -atomic_t fscache_n_attr_changed_nobufs;
54957 -atomic_t fscache_n_attr_changed_nomem;
54958 -atomic_t fscache_n_attr_changed_calls;
54959 +atomic_unchecked_t fscache_n_attr_changed;
54960 +atomic_unchecked_t fscache_n_attr_changed_ok;
54961 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
54962 +atomic_unchecked_t fscache_n_attr_changed_nomem;
54963 +atomic_unchecked_t fscache_n_attr_changed_calls;
54964
54965 -atomic_t fscache_n_allocs;
54966 -atomic_t fscache_n_allocs_ok;
54967 -atomic_t fscache_n_allocs_wait;
54968 -atomic_t fscache_n_allocs_nobufs;
54969 -atomic_t fscache_n_allocs_intr;
54970 -atomic_t fscache_n_allocs_object_dead;
54971 -atomic_t fscache_n_alloc_ops;
54972 -atomic_t fscache_n_alloc_op_waits;
54973 +atomic_unchecked_t fscache_n_allocs;
54974 +atomic_unchecked_t fscache_n_allocs_ok;
54975 +atomic_unchecked_t fscache_n_allocs_wait;
54976 +atomic_unchecked_t fscache_n_allocs_nobufs;
54977 +atomic_unchecked_t fscache_n_allocs_intr;
54978 +atomic_unchecked_t fscache_n_allocs_object_dead;
54979 +atomic_unchecked_t fscache_n_alloc_ops;
54980 +atomic_unchecked_t fscache_n_alloc_op_waits;
54981
54982 -atomic_t fscache_n_retrievals;
54983 -atomic_t fscache_n_retrievals_ok;
54984 -atomic_t fscache_n_retrievals_wait;
54985 -atomic_t fscache_n_retrievals_nodata;
54986 -atomic_t fscache_n_retrievals_nobufs;
54987 -atomic_t fscache_n_retrievals_intr;
54988 -atomic_t fscache_n_retrievals_nomem;
54989 -atomic_t fscache_n_retrievals_object_dead;
54990 -atomic_t fscache_n_retrieval_ops;
54991 -atomic_t fscache_n_retrieval_op_waits;
54992 +atomic_unchecked_t fscache_n_retrievals;
54993 +atomic_unchecked_t fscache_n_retrievals_ok;
54994 +atomic_unchecked_t fscache_n_retrievals_wait;
54995 +atomic_unchecked_t fscache_n_retrievals_nodata;
54996 +atomic_unchecked_t fscache_n_retrievals_nobufs;
54997 +atomic_unchecked_t fscache_n_retrievals_intr;
54998 +atomic_unchecked_t fscache_n_retrievals_nomem;
54999 +atomic_unchecked_t fscache_n_retrievals_object_dead;
55000 +atomic_unchecked_t fscache_n_retrieval_ops;
55001 +atomic_unchecked_t fscache_n_retrieval_op_waits;
55002
55003 -atomic_t fscache_n_stores;
55004 -atomic_t fscache_n_stores_ok;
55005 -atomic_t fscache_n_stores_again;
55006 -atomic_t fscache_n_stores_nobufs;
55007 -atomic_t fscache_n_stores_oom;
55008 -atomic_t fscache_n_store_ops;
55009 -atomic_t fscache_n_store_calls;
55010 -atomic_t fscache_n_store_pages;
55011 -atomic_t fscache_n_store_radix_deletes;
55012 -atomic_t fscache_n_store_pages_over_limit;
55013 +atomic_unchecked_t fscache_n_stores;
55014 +atomic_unchecked_t fscache_n_stores_ok;
55015 +atomic_unchecked_t fscache_n_stores_again;
55016 +atomic_unchecked_t fscache_n_stores_nobufs;
55017 +atomic_unchecked_t fscache_n_stores_oom;
55018 +atomic_unchecked_t fscache_n_store_ops;
55019 +atomic_unchecked_t fscache_n_store_calls;
55020 +atomic_unchecked_t fscache_n_store_pages;
55021 +atomic_unchecked_t fscache_n_store_radix_deletes;
55022 +atomic_unchecked_t fscache_n_store_pages_over_limit;
55023
55024 -atomic_t fscache_n_store_vmscan_not_storing;
55025 -atomic_t fscache_n_store_vmscan_gone;
55026 -atomic_t fscache_n_store_vmscan_busy;
55027 -atomic_t fscache_n_store_vmscan_cancelled;
55028 -atomic_t fscache_n_store_vmscan_wait;
55029 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
55030 +atomic_unchecked_t fscache_n_store_vmscan_gone;
55031 +atomic_unchecked_t fscache_n_store_vmscan_busy;
55032 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
55033 +atomic_unchecked_t fscache_n_store_vmscan_wait;
55034
55035 -atomic_t fscache_n_marks;
55036 -atomic_t fscache_n_uncaches;
55037 +atomic_unchecked_t fscache_n_marks;
55038 +atomic_unchecked_t fscache_n_uncaches;
55039
55040 -atomic_t fscache_n_acquires;
55041 -atomic_t fscache_n_acquires_null;
55042 -atomic_t fscache_n_acquires_no_cache;
55043 -atomic_t fscache_n_acquires_ok;
55044 -atomic_t fscache_n_acquires_nobufs;
55045 -atomic_t fscache_n_acquires_oom;
55046 +atomic_unchecked_t fscache_n_acquires;
55047 +atomic_unchecked_t fscache_n_acquires_null;
55048 +atomic_unchecked_t fscache_n_acquires_no_cache;
55049 +atomic_unchecked_t fscache_n_acquires_ok;
55050 +atomic_unchecked_t fscache_n_acquires_nobufs;
55051 +atomic_unchecked_t fscache_n_acquires_oom;
55052
55053 -atomic_t fscache_n_invalidates;
55054 -atomic_t fscache_n_invalidates_run;
55055 +atomic_unchecked_t fscache_n_invalidates;
55056 +atomic_unchecked_t fscache_n_invalidates_run;
55057
55058 -atomic_t fscache_n_updates;
55059 -atomic_t fscache_n_updates_null;
55060 -atomic_t fscache_n_updates_run;
55061 +atomic_unchecked_t fscache_n_updates;
55062 +atomic_unchecked_t fscache_n_updates_null;
55063 +atomic_unchecked_t fscache_n_updates_run;
55064
55065 -atomic_t fscache_n_relinquishes;
55066 -atomic_t fscache_n_relinquishes_null;
55067 -atomic_t fscache_n_relinquishes_waitcrt;
55068 -atomic_t fscache_n_relinquishes_retire;
55069 +atomic_unchecked_t fscache_n_relinquishes;
55070 +atomic_unchecked_t fscache_n_relinquishes_null;
55071 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
55072 +atomic_unchecked_t fscache_n_relinquishes_retire;
55073
55074 -atomic_t fscache_n_cookie_index;
55075 -atomic_t fscache_n_cookie_data;
55076 -atomic_t fscache_n_cookie_special;
55077 +atomic_unchecked_t fscache_n_cookie_index;
55078 +atomic_unchecked_t fscache_n_cookie_data;
55079 +atomic_unchecked_t fscache_n_cookie_special;
55080
55081 -atomic_t fscache_n_object_alloc;
55082 -atomic_t fscache_n_object_no_alloc;
55083 -atomic_t fscache_n_object_lookups;
55084 -atomic_t fscache_n_object_lookups_negative;
55085 -atomic_t fscache_n_object_lookups_positive;
55086 -atomic_t fscache_n_object_lookups_timed_out;
55087 -atomic_t fscache_n_object_created;
55088 -atomic_t fscache_n_object_avail;
55089 -atomic_t fscache_n_object_dead;
55090 +atomic_unchecked_t fscache_n_object_alloc;
55091 +atomic_unchecked_t fscache_n_object_no_alloc;
55092 +atomic_unchecked_t fscache_n_object_lookups;
55093 +atomic_unchecked_t fscache_n_object_lookups_negative;
55094 +atomic_unchecked_t fscache_n_object_lookups_positive;
55095 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
55096 +atomic_unchecked_t fscache_n_object_created;
55097 +atomic_unchecked_t fscache_n_object_avail;
55098 +atomic_unchecked_t fscache_n_object_dead;
55099
55100 -atomic_t fscache_n_checkaux_none;
55101 -atomic_t fscache_n_checkaux_okay;
55102 -atomic_t fscache_n_checkaux_update;
55103 -atomic_t fscache_n_checkaux_obsolete;
55104 +atomic_unchecked_t fscache_n_checkaux_none;
55105 +atomic_unchecked_t fscache_n_checkaux_okay;
55106 +atomic_unchecked_t fscache_n_checkaux_update;
55107 +atomic_unchecked_t fscache_n_checkaux_obsolete;
55108
55109 atomic_t fscache_n_cop_alloc_object;
55110 atomic_t fscache_n_cop_lookup_object;
55111 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
55112 seq_puts(m, "FS-Cache statistics\n");
55113
55114 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
55115 - atomic_read(&fscache_n_cookie_index),
55116 - atomic_read(&fscache_n_cookie_data),
55117 - atomic_read(&fscache_n_cookie_special));
55118 + atomic_read_unchecked(&fscache_n_cookie_index),
55119 + atomic_read_unchecked(&fscache_n_cookie_data),
55120 + atomic_read_unchecked(&fscache_n_cookie_special));
55121
55122 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
55123 - atomic_read(&fscache_n_object_alloc),
55124 - atomic_read(&fscache_n_object_no_alloc),
55125 - atomic_read(&fscache_n_object_avail),
55126 - atomic_read(&fscache_n_object_dead));
55127 + atomic_read_unchecked(&fscache_n_object_alloc),
55128 + atomic_read_unchecked(&fscache_n_object_no_alloc),
55129 + atomic_read_unchecked(&fscache_n_object_avail),
55130 + atomic_read_unchecked(&fscache_n_object_dead));
55131 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
55132 - atomic_read(&fscache_n_checkaux_none),
55133 - atomic_read(&fscache_n_checkaux_okay),
55134 - atomic_read(&fscache_n_checkaux_update),
55135 - atomic_read(&fscache_n_checkaux_obsolete));
55136 + atomic_read_unchecked(&fscache_n_checkaux_none),
55137 + atomic_read_unchecked(&fscache_n_checkaux_okay),
55138 + atomic_read_unchecked(&fscache_n_checkaux_update),
55139 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
55140
55141 seq_printf(m, "Pages : mrk=%u unc=%u\n",
55142 - atomic_read(&fscache_n_marks),
55143 - atomic_read(&fscache_n_uncaches));
55144 + atomic_read_unchecked(&fscache_n_marks),
55145 + atomic_read_unchecked(&fscache_n_uncaches));
55146
55147 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
55148 " oom=%u\n",
55149 - atomic_read(&fscache_n_acquires),
55150 - atomic_read(&fscache_n_acquires_null),
55151 - atomic_read(&fscache_n_acquires_no_cache),
55152 - atomic_read(&fscache_n_acquires_ok),
55153 - atomic_read(&fscache_n_acquires_nobufs),
55154 - atomic_read(&fscache_n_acquires_oom));
55155 + atomic_read_unchecked(&fscache_n_acquires),
55156 + atomic_read_unchecked(&fscache_n_acquires_null),
55157 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
55158 + atomic_read_unchecked(&fscache_n_acquires_ok),
55159 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
55160 + atomic_read_unchecked(&fscache_n_acquires_oom));
55161
55162 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
55163 - atomic_read(&fscache_n_object_lookups),
55164 - atomic_read(&fscache_n_object_lookups_negative),
55165 - atomic_read(&fscache_n_object_lookups_positive),
55166 - atomic_read(&fscache_n_object_created),
55167 - atomic_read(&fscache_n_object_lookups_timed_out));
55168 + atomic_read_unchecked(&fscache_n_object_lookups),
55169 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
55170 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
55171 + atomic_read_unchecked(&fscache_n_object_created),
55172 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
55173
55174 seq_printf(m, "Invals : n=%u run=%u\n",
55175 - atomic_read(&fscache_n_invalidates),
55176 - atomic_read(&fscache_n_invalidates_run));
55177 + atomic_read_unchecked(&fscache_n_invalidates),
55178 + atomic_read_unchecked(&fscache_n_invalidates_run));
55179
55180 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
55181 - atomic_read(&fscache_n_updates),
55182 - atomic_read(&fscache_n_updates_null),
55183 - atomic_read(&fscache_n_updates_run));
55184 + atomic_read_unchecked(&fscache_n_updates),
55185 + atomic_read_unchecked(&fscache_n_updates_null),
55186 + atomic_read_unchecked(&fscache_n_updates_run));
55187
55188 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
55189 - atomic_read(&fscache_n_relinquishes),
55190 - atomic_read(&fscache_n_relinquishes_null),
55191 - atomic_read(&fscache_n_relinquishes_waitcrt),
55192 - atomic_read(&fscache_n_relinquishes_retire));
55193 + atomic_read_unchecked(&fscache_n_relinquishes),
55194 + atomic_read_unchecked(&fscache_n_relinquishes_null),
55195 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
55196 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
55197
55198 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
55199 - atomic_read(&fscache_n_attr_changed),
55200 - atomic_read(&fscache_n_attr_changed_ok),
55201 - atomic_read(&fscache_n_attr_changed_nobufs),
55202 - atomic_read(&fscache_n_attr_changed_nomem),
55203 - atomic_read(&fscache_n_attr_changed_calls));
55204 + atomic_read_unchecked(&fscache_n_attr_changed),
55205 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
55206 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
55207 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
55208 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
55209
55210 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
55211 - atomic_read(&fscache_n_allocs),
55212 - atomic_read(&fscache_n_allocs_ok),
55213 - atomic_read(&fscache_n_allocs_wait),
55214 - atomic_read(&fscache_n_allocs_nobufs),
55215 - atomic_read(&fscache_n_allocs_intr));
55216 + atomic_read_unchecked(&fscache_n_allocs),
55217 + atomic_read_unchecked(&fscache_n_allocs_ok),
55218 + atomic_read_unchecked(&fscache_n_allocs_wait),
55219 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
55220 + atomic_read_unchecked(&fscache_n_allocs_intr));
55221 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
55222 - atomic_read(&fscache_n_alloc_ops),
55223 - atomic_read(&fscache_n_alloc_op_waits),
55224 - atomic_read(&fscache_n_allocs_object_dead));
55225 + atomic_read_unchecked(&fscache_n_alloc_ops),
55226 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
55227 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
55228
55229 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
55230 " int=%u oom=%u\n",
55231 - atomic_read(&fscache_n_retrievals),
55232 - atomic_read(&fscache_n_retrievals_ok),
55233 - atomic_read(&fscache_n_retrievals_wait),
55234 - atomic_read(&fscache_n_retrievals_nodata),
55235 - atomic_read(&fscache_n_retrievals_nobufs),
55236 - atomic_read(&fscache_n_retrievals_intr),
55237 - atomic_read(&fscache_n_retrievals_nomem));
55238 + atomic_read_unchecked(&fscache_n_retrievals),
55239 + atomic_read_unchecked(&fscache_n_retrievals_ok),
55240 + atomic_read_unchecked(&fscache_n_retrievals_wait),
55241 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
55242 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
55243 + atomic_read_unchecked(&fscache_n_retrievals_intr),
55244 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
55245 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
55246 - atomic_read(&fscache_n_retrieval_ops),
55247 - atomic_read(&fscache_n_retrieval_op_waits),
55248 - atomic_read(&fscache_n_retrievals_object_dead));
55249 + atomic_read_unchecked(&fscache_n_retrieval_ops),
55250 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
55251 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
55252
55253 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
55254 - atomic_read(&fscache_n_stores),
55255 - atomic_read(&fscache_n_stores_ok),
55256 - atomic_read(&fscache_n_stores_again),
55257 - atomic_read(&fscache_n_stores_nobufs),
55258 - atomic_read(&fscache_n_stores_oom));
55259 + atomic_read_unchecked(&fscache_n_stores),
55260 + atomic_read_unchecked(&fscache_n_stores_ok),
55261 + atomic_read_unchecked(&fscache_n_stores_again),
55262 + atomic_read_unchecked(&fscache_n_stores_nobufs),
55263 + atomic_read_unchecked(&fscache_n_stores_oom));
55264 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
55265 - atomic_read(&fscache_n_store_ops),
55266 - atomic_read(&fscache_n_store_calls),
55267 - atomic_read(&fscache_n_store_pages),
55268 - atomic_read(&fscache_n_store_radix_deletes),
55269 - atomic_read(&fscache_n_store_pages_over_limit));
55270 + atomic_read_unchecked(&fscache_n_store_ops),
55271 + atomic_read_unchecked(&fscache_n_store_calls),
55272 + atomic_read_unchecked(&fscache_n_store_pages),
55273 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
55274 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
55275
55276 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
55277 - atomic_read(&fscache_n_store_vmscan_not_storing),
55278 - atomic_read(&fscache_n_store_vmscan_gone),
55279 - atomic_read(&fscache_n_store_vmscan_busy),
55280 - atomic_read(&fscache_n_store_vmscan_cancelled),
55281 - atomic_read(&fscache_n_store_vmscan_wait));
55282 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
55283 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
55284 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
55285 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
55286 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
55287
55288 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
55289 - atomic_read(&fscache_n_op_pend),
55290 - atomic_read(&fscache_n_op_run),
55291 - atomic_read(&fscache_n_op_enqueue),
55292 - atomic_read(&fscache_n_op_cancelled),
55293 - atomic_read(&fscache_n_op_rejected));
55294 + atomic_read_unchecked(&fscache_n_op_pend),
55295 + atomic_read_unchecked(&fscache_n_op_run),
55296 + atomic_read_unchecked(&fscache_n_op_enqueue),
55297 + atomic_read_unchecked(&fscache_n_op_cancelled),
55298 + atomic_read_unchecked(&fscache_n_op_rejected));
55299 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
55300 - atomic_read(&fscache_n_op_deferred_release),
55301 - atomic_read(&fscache_n_op_release),
55302 - atomic_read(&fscache_n_op_gc));
55303 + atomic_read_unchecked(&fscache_n_op_deferred_release),
55304 + atomic_read_unchecked(&fscache_n_op_release),
55305 + atomic_read_unchecked(&fscache_n_op_gc));
55306
55307 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
55308 atomic_read(&fscache_n_cop_alloc_object),
55309 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
55310 index aef34b1..59bfd7b 100644
55311 --- a/fs/fuse/cuse.c
55312 +++ b/fs/fuse/cuse.c
55313 @@ -600,10 +600,12 @@ static int __init cuse_init(void)
55314 INIT_LIST_HEAD(&cuse_conntbl[i]);
55315
55316 /* inherit and extend fuse_dev_operations */
55317 - cuse_channel_fops = fuse_dev_operations;
55318 - cuse_channel_fops.owner = THIS_MODULE;
55319 - cuse_channel_fops.open = cuse_channel_open;
55320 - cuse_channel_fops.release = cuse_channel_release;
55321 + pax_open_kernel();
55322 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
55323 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
55324 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
55325 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
55326 + pax_close_kernel();
55327
55328 cuse_class = class_create(THIS_MODULE, "cuse");
55329 if (IS_ERR(cuse_class))
55330 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
55331 index 1d55f94..088da65 100644
55332 --- a/fs/fuse/dev.c
55333 +++ b/fs/fuse/dev.c
55334 @@ -1339,7 +1339,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
55335 ret = 0;
55336 pipe_lock(pipe);
55337
55338 - if (!pipe->readers) {
55339 + if (!atomic_read(&pipe->readers)) {
55340 send_sig(SIGPIPE, current, 0);
55341 if (!ret)
55342 ret = -EPIPE;
55343 @@ -1364,7 +1364,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
55344 page_nr++;
55345 ret += buf->len;
55346
55347 - if (pipe->files)
55348 + if (atomic_read(&pipe->files))
55349 do_wakeup = 1;
55350 }
55351
55352 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
55353 index 5b12746..b481b03 100644
55354 --- a/fs/fuse/dir.c
55355 +++ b/fs/fuse/dir.c
55356 @@ -1437,7 +1437,7 @@ static char *read_link(struct dentry *dentry)
55357 return link;
55358 }
55359
55360 -static void free_link(char *link)
55361 +static void free_link(const char *link)
55362 {
55363 if (!IS_ERR(link))
55364 free_page((unsigned long) link);
55365 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
55366 index 62b484e..0f9a140 100644
55367 --- a/fs/gfs2/inode.c
55368 +++ b/fs/gfs2/inode.c
55369 @@ -1441,7 +1441,7 @@ out:
55370
55371 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
55372 {
55373 - char *s = nd_get_link(nd);
55374 + const char *s = nd_get_link(nd);
55375 if (!IS_ERR(s))
55376 kfree(s);
55377 }
55378 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
55379 index a3f868a..bb308ae 100644
55380 --- a/fs/hugetlbfs/inode.c
55381 +++ b/fs/hugetlbfs/inode.c
55382 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
55383 struct mm_struct *mm = current->mm;
55384 struct vm_area_struct *vma;
55385 struct hstate *h = hstate_file(file);
55386 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
55387 struct vm_unmapped_area_info info;
55388
55389 if (len & ~huge_page_mask(h))
55390 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
55391 return addr;
55392 }
55393
55394 +#ifdef CONFIG_PAX_RANDMMAP
55395 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
55396 +#endif
55397 +
55398 if (addr) {
55399 addr = ALIGN(addr, huge_page_size(h));
55400 vma = find_vma(mm, addr);
55401 - if (TASK_SIZE - len >= addr &&
55402 - (!vma || addr + len <= vma->vm_start))
55403 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
55404 return addr;
55405 }
55406
55407 info.flags = 0;
55408 info.length = len;
55409 info.low_limit = TASK_UNMAPPED_BASE;
55410 +
55411 +#ifdef CONFIG_PAX_RANDMMAP
55412 + if (mm->pax_flags & MF_PAX_RANDMMAP)
55413 + info.low_limit += mm->delta_mmap;
55414 +#endif
55415 +
55416 info.high_limit = TASK_SIZE;
55417 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
55418 info.align_offset = 0;
55419 @@ -898,7 +908,7 @@ static struct file_system_type hugetlbfs_fs_type = {
55420 };
55421 MODULE_ALIAS_FS("hugetlbfs");
55422
55423 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
55424 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
55425
55426 static int can_do_hugetlb_shm(void)
55427 {
55428 diff --git a/fs/inode.c b/fs/inode.c
55429 index 00d5fc3..98ce7d7 100644
55430 --- a/fs/inode.c
55431 +++ b/fs/inode.c
55432 @@ -878,8 +878,8 @@ unsigned int get_next_ino(void)
55433
55434 #ifdef CONFIG_SMP
55435 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
55436 - static atomic_t shared_last_ino;
55437 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
55438 + static atomic_unchecked_t shared_last_ino;
55439 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
55440
55441 res = next - LAST_INO_BATCH;
55442 }
55443 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
55444 index 4a6cf28..d3a29d3 100644
55445 --- a/fs/jffs2/erase.c
55446 +++ b/fs/jffs2/erase.c
55447 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
55448 struct jffs2_unknown_node marker = {
55449 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
55450 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
55451 - .totlen = cpu_to_je32(c->cleanmarker_size)
55452 + .totlen = cpu_to_je32(c->cleanmarker_size),
55453 + .hdr_crc = cpu_to_je32(0)
55454 };
55455
55456 jffs2_prealloc_raw_node_refs(c, jeb, 1);
55457 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
55458 index a6597d6..41b30ec 100644
55459 --- a/fs/jffs2/wbuf.c
55460 +++ b/fs/jffs2/wbuf.c
55461 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
55462 {
55463 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
55464 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
55465 - .totlen = constant_cpu_to_je32(8)
55466 + .totlen = constant_cpu_to_je32(8),
55467 + .hdr_crc = constant_cpu_to_je32(0)
55468 };
55469
55470 /*
55471 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
55472 index 788e0a9..8433098 100644
55473 --- a/fs/jfs/super.c
55474 +++ b/fs/jfs/super.c
55475 @@ -878,7 +878,7 @@ static int __init init_jfs_fs(void)
55476
55477 jfs_inode_cachep =
55478 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
55479 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
55480 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
55481 init_once);
55482 if (jfs_inode_cachep == NULL)
55483 return -ENOMEM;
55484 diff --git a/fs/libfs.c b/fs/libfs.c
55485 index 916da8c..1588998 100644
55486 --- a/fs/libfs.c
55487 +++ b/fs/libfs.c
55488 @@ -165,6 +165,9 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
55489
55490 for (p=q->next; p != &dentry->d_subdirs; p=p->next) {
55491 struct dentry *next;
55492 + char d_name[sizeof(next->d_iname)];
55493 + const unsigned char *name;
55494 +
55495 next = list_entry(p, struct dentry, d_u.d_child);
55496 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
55497 if (!simple_positive(next)) {
55498 @@ -174,7 +177,12 @@ int dcache_readdir(struct file * filp, void * dirent, filldir_t filldir)
55499
55500 spin_unlock(&next->d_lock);
55501 spin_unlock(&dentry->d_lock);
55502 - if (filldir(dirent, next->d_name.name,
55503 + name = next->d_name.name;
55504 + if (name == next->d_iname) {
55505 + memcpy(d_name, name, next->d_name.len);
55506 + name = d_name;
55507 + }
55508 + if (filldir(dirent, name,
55509 next->d_name.len, filp->f_pos,
55510 next->d_inode->i_ino,
55511 dt_type(next->d_inode)) < 0)
55512 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
55513 index acd3947..1f896e2 100644
55514 --- a/fs/lockd/clntproc.c
55515 +++ b/fs/lockd/clntproc.c
55516 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
55517 /*
55518 * Cookie counter for NLM requests
55519 */
55520 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
55521 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
55522
55523 void nlmclnt_next_cookie(struct nlm_cookie *c)
55524 {
55525 - u32 cookie = atomic_inc_return(&nlm_cookie);
55526 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
55527
55528 memcpy(c->data, &cookie, 4);
55529 c->len=4;
55530 diff --git a/fs/lockd/svc.c b/fs/lockd/svc.c
55531 index a2aa97d..10d6c41 100644
55532 --- a/fs/lockd/svc.c
55533 +++ b/fs/lockd/svc.c
55534 @@ -305,7 +305,7 @@ static int lockd_start_svc(struct svc_serv *serv)
55535 svc_sock_update_bufs(serv);
55536 serv->sv_maxconn = nlm_max_connections;
55537
55538 - nlmsvc_task = kthread_run(lockd, nlmsvc_rqst, serv->sv_name);
55539 + nlmsvc_task = kthread_run(lockd, nlmsvc_rqst, "%s", serv->sv_name);
55540 if (IS_ERR(nlmsvc_task)) {
55541 error = PTR_ERR(nlmsvc_task);
55542 printk(KERN_WARNING
55543 diff --git a/fs/locks.c b/fs/locks.c
55544 index cb424a4..850e4dd 100644
55545 --- a/fs/locks.c
55546 +++ b/fs/locks.c
55547 @@ -2064,16 +2064,16 @@ void locks_remove_flock(struct file *filp)
55548 return;
55549
55550 if (filp->f_op && filp->f_op->flock) {
55551 - struct file_lock fl = {
55552 + struct file_lock flock = {
55553 .fl_pid = current->tgid,
55554 .fl_file = filp,
55555 .fl_flags = FL_FLOCK,
55556 .fl_type = F_UNLCK,
55557 .fl_end = OFFSET_MAX,
55558 };
55559 - filp->f_op->flock(filp, F_SETLKW, &fl);
55560 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
55561 - fl.fl_ops->fl_release_private(&fl);
55562 + filp->f_op->flock(filp, F_SETLKW, &flock);
55563 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
55564 + flock.fl_ops->fl_release_private(&flock);
55565 }
55566
55567 lock_flocks();
55568 diff --git a/fs/namei.c b/fs/namei.c
55569 index 9ed9361..2b72db1 100644
55570 --- a/fs/namei.c
55571 +++ b/fs/namei.c
55572 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
55573 if (ret != -EACCES)
55574 return ret;
55575
55576 +#ifdef CONFIG_GRKERNSEC
55577 + /* we'll block if we have to log due to a denied capability use */
55578 + if (mask & MAY_NOT_BLOCK)
55579 + return -ECHILD;
55580 +#endif
55581 +
55582 if (S_ISDIR(inode->i_mode)) {
55583 /* DACs are overridable for directories */
55584 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
55585 - return 0;
55586 if (!(mask & MAY_WRITE))
55587 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
55588 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
55589 + inode_capable(inode, CAP_DAC_READ_SEARCH))
55590 return 0;
55591 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
55592 + return 0;
55593 return -EACCES;
55594 }
55595 /*
55596 + * Searching includes executable on directories, else just read.
55597 + */
55598 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
55599 + if (mask == MAY_READ)
55600 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
55601 + inode_capable(inode, CAP_DAC_READ_SEARCH))
55602 + return 0;
55603 +
55604 + /*
55605 * Read/write DACs are always overridable.
55606 * Executable DACs are overridable when there is
55607 * at least one exec bit set.
55608 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
55609 if (inode_capable(inode, CAP_DAC_OVERRIDE))
55610 return 0;
55611
55612 - /*
55613 - * Searching includes executable on directories, else just read.
55614 - */
55615 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
55616 - if (mask == MAY_READ)
55617 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
55618 - return 0;
55619 -
55620 return -EACCES;
55621 }
55622
55623 @@ -820,7 +828,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
55624 {
55625 struct dentry *dentry = link->dentry;
55626 int error;
55627 - char *s;
55628 + const char *s;
55629
55630 BUG_ON(nd->flags & LOOKUP_RCU);
55631
55632 @@ -841,6 +849,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
55633 if (error)
55634 goto out_put_nd_path;
55635
55636 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
55637 + dentry->d_inode, dentry, nd->path.mnt)) {
55638 + error = -EACCES;
55639 + goto out_put_nd_path;
55640 + }
55641 +
55642 nd->last_type = LAST_BIND;
55643 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
55644 error = PTR_ERR(*p);
55645 @@ -1588,6 +1602,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
55646 if (res)
55647 break;
55648 res = walk_component(nd, path, LOOKUP_FOLLOW);
55649 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
55650 + res = -EACCES;
55651 put_link(nd, &link, cookie);
55652 } while (res > 0);
55653
55654 @@ -1686,7 +1702,7 @@ EXPORT_SYMBOL(full_name_hash);
55655 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
55656 {
55657 unsigned long a, b, adata, bdata, mask, hash, len;
55658 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
55659 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
55660
55661 hash = a = 0;
55662 len = -sizeof(unsigned long);
55663 @@ -1968,6 +1984,8 @@ static int path_lookupat(int dfd, const char *name,
55664 if (err)
55665 break;
55666 err = lookup_last(nd, &path);
55667 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
55668 + err = -EACCES;
55669 put_link(nd, &link, cookie);
55670 }
55671 }
55672 @@ -1975,6 +1993,13 @@ static int path_lookupat(int dfd, const char *name,
55673 if (!err)
55674 err = complete_walk(nd);
55675
55676 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
55677 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
55678 + path_put(&nd->path);
55679 + err = -ENOENT;
55680 + }
55681 + }
55682 +
55683 if (!err && nd->flags & LOOKUP_DIRECTORY) {
55684 if (!can_lookup(nd->inode)) {
55685 path_put(&nd->path);
55686 @@ -2002,8 +2027,15 @@ static int filename_lookup(int dfd, struct filename *name,
55687 retval = path_lookupat(dfd, name->name,
55688 flags | LOOKUP_REVAL, nd);
55689
55690 - if (likely(!retval))
55691 + if (likely(!retval)) {
55692 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
55693 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
55694 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
55695 + path_put(&nd->path);
55696 + return -ENOENT;
55697 + }
55698 + }
55699 + }
55700 return retval;
55701 }
55702
55703 @@ -2381,6 +2413,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
55704 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
55705 return -EPERM;
55706
55707 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
55708 + return -EPERM;
55709 + if (gr_handle_rawio(inode))
55710 + return -EPERM;
55711 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
55712 + return -EACCES;
55713 +
55714 return 0;
55715 }
55716
55717 @@ -2602,7 +2641,7 @@ looked_up:
55718 * cleared otherwise prior to returning.
55719 */
55720 static int lookup_open(struct nameidata *nd, struct path *path,
55721 - struct file *file,
55722 + struct path *link, struct file *file,
55723 const struct open_flags *op,
55724 bool got_write, int *opened)
55725 {
55726 @@ -2637,6 +2676,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
55727 /* Negative dentry, just create the file */
55728 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
55729 umode_t mode = op->mode;
55730 +
55731 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
55732 + error = -EACCES;
55733 + goto out_dput;
55734 + }
55735 +
55736 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
55737 + error = -EACCES;
55738 + goto out_dput;
55739 + }
55740 +
55741 if (!IS_POSIXACL(dir->d_inode))
55742 mode &= ~current_umask();
55743 /*
55744 @@ -2658,6 +2708,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
55745 nd->flags & LOOKUP_EXCL);
55746 if (error)
55747 goto out_dput;
55748 + else
55749 + gr_handle_create(dentry, nd->path.mnt);
55750 }
55751 out_no_open:
55752 path->dentry = dentry;
55753 @@ -2672,7 +2724,7 @@ out_dput:
55754 /*
55755 * Handle the last step of open()
55756 */
55757 -static int do_last(struct nameidata *nd, struct path *path,
55758 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
55759 struct file *file, const struct open_flags *op,
55760 int *opened, struct filename *name)
55761 {
55762 @@ -2701,16 +2753,32 @@ static int do_last(struct nameidata *nd, struct path *path,
55763 error = complete_walk(nd);
55764 if (error)
55765 return error;
55766 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
55767 + error = -ENOENT;
55768 + goto out;
55769 + }
55770 audit_inode(name, nd->path.dentry, 0);
55771 if (open_flag & O_CREAT) {
55772 error = -EISDIR;
55773 goto out;
55774 }
55775 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
55776 + error = -EACCES;
55777 + goto out;
55778 + }
55779 goto finish_open;
55780 case LAST_BIND:
55781 error = complete_walk(nd);
55782 if (error)
55783 return error;
55784 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
55785 + error = -ENOENT;
55786 + goto out;
55787 + }
55788 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
55789 + error = -EACCES;
55790 + goto out;
55791 + }
55792 audit_inode(name, dir, 0);
55793 goto finish_open;
55794 }
55795 @@ -2759,7 +2827,7 @@ retry_lookup:
55796 */
55797 }
55798 mutex_lock(&dir->d_inode->i_mutex);
55799 - error = lookup_open(nd, path, file, op, got_write, opened);
55800 + error = lookup_open(nd, path, link, file, op, got_write, opened);
55801 mutex_unlock(&dir->d_inode->i_mutex);
55802
55803 if (error <= 0) {
55804 @@ -2783,11 +2851,28 @@ retry_lookup:
55805 goto finish_open_created;
55806 }
55807
55808 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
55809 + error = -ENOENT;
55810 + goto exit_dput;
55811 + }
55812 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
55813 + error = -EACCES;
55814 + goto exit_dput;
55815 + }
55816 +
55817 /*
55818 * create/update audit record if it already exists.
55819 */
55820 - if (path->dentry->d_inode)
55821 + if (path->dentry->d_inode) {
55822 + /* only check if O_CREAT is specified, all other checks need to go
55823 + into may_open */
55824 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
55825 + error = -EACCES;
55826 + goto exit_dput;
55827 + }
55828 +
55829 audit_inode(name, path->dentry, 0);
55830 + }
55831
55832 /*
55833 * If atomic_open() acquired write access it is dropped now due to
55834 @@ -2828,6 +2913,11 @@ finish_lookup:
55835 }
55836 }
55837 BUG_ON(inode != path->dentry->d_inode);
55838 + /* if we're resolving a symlink to another symlink */
55839 + if (link && gr_handle_symlink_owner(link, inode)) {
55840 + error = -EACCES;
55841 + goto out;
55842 + }
55843 return 1;
55844 }
55845
55846 @@ -2837,7 +2927,6 @@ finish_lookup:
55847 save_parent.dentry = nd->path.dentry;
55848 save_parent.mnt = mntget(path->mnt);
55849 nd->path.dentry = path->dentry;
55850 -
55851 }
55852 nd->inode = inode;
55853 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
55854 @@ -2846,6 +2935,16 @@ finish_lookup:
55855 path_put(&save_parent);
55856 return error;
55857 }
55858 +
55859 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
55860 + error = -ENOENT;
55861 + goto out;
55862 + }
55863 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
55864 + error = -EACCES;
55865 + goto out;
55866 + }
55867 +
55868 error = -EISDIR;
55869 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
55870 goto out;
55871 @@ -2944,7 +3043,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
55872 if (unlikely(error))
55873 goto out;
55874
55875 - error = do_last(nd, &path, file, op, &opened, pathname);
55876 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
55877 while (unlikely(error > 0)) { /* trailing symlink */
55878 struct path link = path;
55879 void *cookie;
55880 @@ -2962,7 +3061,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
55881 error = follow_link(&link, nd, &cookie);
55882 if (unlikely(error))
55883 break;
55884 - error = do_last(nd, &path, file, op, &opened, pathname);
55885 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
55886 put_link(nd, &link, cookie);
55887 }
55888 out:
55889 @@ -3062,8 +3161,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
55890 goto unlock;
55891
55892 error = -EEXIST;
55893 - if (dentry->d_inode)
55894 + if (dentry->d_inode) {
55895 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
55896 + error = -ENOENT;
55897 + }
55898 goto fail;
55899 + }
55900 /*
55901 * Special case - lookup gave negative, but... we had foo/bar/
55902 * From the vfs_mknod() POV we just have a negative dentry -
55903 @@ -3115,6 +3218,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
55904 }
55905 EXPORT_SYMBOL(user_path_create);
55906
55907 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
55908 +{
55909 + struct filename *tmp = getname(pathname);
55910 + struct dentry *res;
55911 + if (IS_ERR(tmp))
55912 + return ERR_CAST(tmp);
55913 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
55914 + if (IS_ERR(res))
55915 + putname(tmp);
55916 + else
55917 + *to = tmp;
55918 + return res;
55919 +}
55920 +
55921 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
55922 {
55923 int error = may_create(dir, dentry);
55924 @@ -3177,6 +3294,17 @@ retry:
55925
55926 if (!IS_POSIXACL(path.dentry->d_inode))
55927 mode &= ~current_umask();
55928 +
55929 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
55930 + error = -EPERM;
55931 + goto out;
55932 + }
55933 +
55934 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
55935 + error = -EACCES;
55936 + goto out;
55937 + }
55938 +
55939 error = security_path_mknod(&path, dentry, mode, dev);
55940 if (error)
55941 goto out;
55942 @@ -3193,6 +3321,8 @@ retry:
55943 break;
55944 }
55945 out:
55946 + if (!error)
55947 + gr_handle_create(dentry, path.mnt);
55948 done_path_create(&path, dentry);
55949 if (retry_estale(error, lookup_flags)) {
55950 lookup_flags |= LOOKUP_REVAL;
55951 @@ -3245,9 +3375,16 @@ retry:
55952
55953 if (!IS_POSIXACL(path.dentry->d_inode))
55954 mode &= ~current_umask();
55955 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
55956 + error = -EACCES;
55957 + goto out;
55958 + }
55959 error = security_path_mkdir(&path, dentry, mode);
55960 if (!error)
55961 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
55962 + if (!error)
55963 + gr_handle_create(dentry, path.mnt);
55964 +out:
55965 done_path_create(&path, dentry);
55966 if (retry_estale(error, lookup_flags)) {
55967 lookup_flags |= LOOKUP_REVAL;
55968 @@ -3328,6 +3465,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
55969 struct filename *name;
55970 struct dentry *dentry;
55971 struct nameidata nd;
55972 + ino_t saved_ino = 0;
55973 + dev_t saved_dev = 0;
55974 unsigned int lookup_flags = 0;
55975 retry:
55976 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
55977 @@ -3360,10 +3499,21 @@ retry:
55978 error = -ENOENT;
55979 goto exit3;
55980 }
55981 +
55982 + saved_ino = dentry->d_inode->i_ino;
55983 + saved_dev = gr_get_dev_from_dentry(dentry);
55984 +
55985 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
55986 + error = -EACCES;
55987 + goto exit3;
55988 + }
55989 +
55990 error = security_path_rmdir(&nd.path, dentry);
55991 if (error)
55992 goto exit3;
55993 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
55994 + if (!error && (saved_dev || saved_ino))
55995 + gr_handle_delete(saved_ino, saved_dev);
55996 exit3:
55997 dput(dentry);
55998 exit2:
55999 @@ -3429,6 +3579,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
56000 struct dentry *dentry;
56001 struct nameidata nd;
56002 struct inode *inode = NULL;
56003 + ino_t saved_ino = 0;
56004 + dev_t saved_dev = 0;
56005 unsigned int lookup_flags = 0;
56006 retry:
56007 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
56008 @@ -3455,10 +3607,22 @@ retry:
56009 if (!inode)
56010 goto slashes;
56011 ihold(inode);
56012 +
56013 + if (inode->i_nlink <= 1) {
56014 + saved_ino = inode->i_ino;
56015 + saved_dev = gr_get_dev_from_dentry(dentry);
56016 + }
56017 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
56018 + error = -EACCES;
56019 + goto exit2;
56020 + }
56021 +
56022 error = security_path_unlink(&nd.path, dentry);
56023 if (error)
56024 goto exit2;
56025 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
56026 + if (!error && (saved_ino || saved_dev))
56027 + gr_handle_delete(saved_ino, saved_dev);
56028 exit2:
56029 dput(dentry);
56030 }
56031 @@ -3536,9 +3700,17 @@ retry:
56032 if (IS_ERR(dentry))
56033 goto out_putname;
56034
56035 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
56036 + error = -EACCES;
56037 + goto out;
56038 + }
56039 +
56040 error = security_path_symlink(&path, dentry, from->name);
56041 if (!error)
56042 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
56043 + if (!error)
56044 + gr_handle_create(dentry, path.mnt);
56045 +out:
56046 done_path_create(&path, dentry);
56047 if (retry_estale(error, lookup_flags)) {
56048 lookup_flags |= LOOKUP_REVAL;
56049 @@ -3612,6 +3784,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
56050 {
56051 struct dentry *new_dentry;
56052 struct path old_path, new_path;
56053 + struct filename *to = NULL;
56054 int how = 0;
56055 int error;
56056
56057 @@ -3635,7 +3808,7 @@ retry:
56058 if (error)
56059 return error;
56060
56061 - new_dentry = user_path_create(newdfd, newname, &new_path,
56062 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
56063 (how & LOOKUP_REVAL));
56064 error = PTR_ERR(new_dentry);
56065 if (IS_ERR(new_dentry))
56066 @@ -3647,11 +3820,28 @@ retry:
56067 error = may_linkat(&old_path);
56068 if (unlikely(error))
56069 goto out_dput;
56070 +
56071 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
56072 + old_path.dentry->d_inode,
56073 + old_path.dentry->d_inode->i_mode, to)) {
56074 + error = -EACCES;
56075 + goto out_dput;
56076 + }
56077 +
56078 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
56079 + old_path.dentry, old_path.mnt, to)) {
56080 + error = -EACCES;
56081 + goto out_dput;
56082 + }
56083 +
56084 error = security_path_link(old_path.dentry, &new_path, new_dentry);
56085 if (error)
56086 goto out_dput;
56087 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
56088 + if (!error)
56089 + gr_handle_create(new_dentry, new_path.mnt);
56090 out_dput:
56091 + putname(to);
56092 done_path_create(&new_path, new_dentry);
56093 if (retry_estale(error, how)) {
56094 how |= LOOKUP_REVAL;
56095 @@ -3897,12 +4087,21 @@ retry:
56096 if (new_dentry == trap)
56097 goto exit5;
56098
56099 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
56100 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
56101 + to);
56102 + if (error)
56103 + goto exit5;
56104 +
56105 error = security_path_rename(&oldnd.path, old_dentry,
56106 &newnd.path, new_dentry);
56107 if (error)
56108 goto exit5;
56109 error = vfs_rename(old_dir->d_inode, old_dentry,
56110 new_dir->d_inode, new_dentry);
56111 + if (!error)
56112 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
56113 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
56114 exit5:
56115 dput(new_dentry);
56116 exit4:
56117 @@ -3934,6 +4133,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
56118
56119 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
56120 {
56121 + char tmpbuf[64];
56122 + const char *newlink;
56123 int len;
56124
56125 len = PTR_ERR(link);
56126 @@ -3943,7 +4144,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
56127 len = strlen(link);
56128 if (len > (unsigned) buflen)
56129 len = buflen;
56130 - if (copy_to_user(buffer, link, len))
56131 +
56132 + if (len < sizeof(tmpbuf)) {
56133 + memcpy(tmpbuf, link, len);
56134 + newlink = tmpbuf;
56135 + } else
56136 + newlink = link;
56137 +
56138 + if (copy_to_user(buffer, newlink, len))
56139 len = -EFAULT;
56140 out:
56141 return len;
56142 diff --git a/fs/namespace.c b/fs/namespace.c
56143 index 7b1ca9b..6faeccf 100644
56144 --- a/fs/namespace.c
56145 +++ b/fs/namespace.c
56146 @@ -1265,6 +1265,9 @@ static int do_umount(struct mount *mnt, int flags)
56147 if (!(sb->s_flags & MS_RDONLY))
56148 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
56149 up_write(&sb->s_umount);
56150 +
56151 + gr_log_remount(mnt->mnt_devname, retval);
56152 +
56153 return retval;
56154 }
56155
56156 @@ -1283,6 +1286,9 @@ static int do_umount(struct mount *mnt, int flags)
56157 }
56158 br_write_unlock(&vfsmount_lock);
56159 namespace_unlock();
56160 +
56161 + gr_log_unmount(mnt->mnt_devname, retval);
56162 +
56163 return retval;
56164 }
56165
56166 @@ -1302,7 +1308,7 @@ static inline bool may_mount(void)
56167 * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
56168 */
56169
56170 -SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
56171 +SYSCALL_DEFINE2(umount, const char __user *, name, int, flags)
56172 {
56173 struct path path;
56174 struct mount *mnt;
56175 @@ -1342,7 +1348,7 @@ out:
56176 /*
56177 * The 2.0 compatible umount. No flags.
56178 */
56179 -SYSCALL_DEFINE1(oldumount, char __user *, name)
56180 +SYSCALL_DEFINE1(oldumount, const char __user *, name)
56181 {
56182 return sys_umount(name, 0);
56183 }
56184 @@ -2313,6 +2319,16 @@ long do_mount(const char *dev_name, const char *dir_name,
56185 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
56186 MS_STRICTATIME);
56187
56188 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
56189 + retval = -EPERM;
56190 + goto dput_out;
56191 + }
56192 +
56193 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
56194 + retval = -EPERM;
56195 + goto dput_out;
56196 + }
56197 +
56198 if (flags & MS_REMOUNT)
56199 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
56200 data_page);
56201 @@ -2327,6 +2343,9 @@ long do_mount(const char *dev_name, const char *dir_name,
56202 dev_name, data_page);
56203 dput_out:
56204 path_put(&path);
56205 +
56206 + gr_log_mount(dev_name, dir_name, retval);
56207 +
56208 return retval;
56209 }
56210
56211 @@ -2500,8 +2519,8 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
56212 }
56213 EXPORT_SYMBOL(mount_subtree);
56214
56215 -SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
56216 - char __user *, type, unsigned long, flags, void __user *, data)
56217 +SYSCALL_DEFINE5(mount, const char __user *, dev_name, const char __user *, dir_name,
56218 + const char __user *, type, unsigned long, flags, void __user *, data)
56219 {
56220 int ret;
56221 char *kernel_type;
56222 @@ -2614,6 +2633,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
56223 if (error)
56224 goto out2;
56225
56226 + if (gr_handle_chroot_pivot()) {
56227 + error = -EPERM;
56228 + goto out2;
56229 + }
56230 +
56231 get_fs_root(current->fs, &root);
56232 old_mp = lock_mount(&old);
56233 error = PTR_ERR(old_mp);
56234 @@ -2864,7 +2888,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
56235 !nsown_capable(CAP_SYS_ADMIN))
56236 return -EPERM;
56237
56238 - if (fs->users != 1)
56239 + if (atomic_read(&fs->users) != 1)
56240 return -EINVAL;
56241
56242 get_mnt_ns(mnt_ns);
56243 diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c
56244 index cff089a..4c3d57a 100644
56245 --- a/fs/nfs/callback.c
56246 +++ b/fs/nfs/callback.c
56247 @@ -211,7 +211,6 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt,
56248 struct svc_rqst *rqstp;
56249 int (*callback_svc)(void *vrqstp);
56250 struct nfs_callback_data *cb_info = &nfs_callback_info[minorversion];
56251 - char svc_name[12];
56252 int ret;
56253
56254 nfs_callback_bc_serv(minorversion, xprt, serv);
56255 @@ -235,10 +234,9 @@ static int nfs_callback_start_svc(int minorversion, struct rpc_xprt *xprt,
56256
56257 svc_sock_update_bufs(serv);
56258
56259 - sprintf(svc_name, "nfsv4.%u-svc", minorversion);
56260 cb_info->serv = serv;
56261 cb_info->rqst = rqstp;
56262 - cb_info->task = kthread_run(callback_svc, cb_info->rqst, svc_name);
56263 + cb_info->task = kthread_run(callback_svc, cb_info->rqst, "nfsv4.%u-svc", minorversion);
56264 if (IS_ERR(cb_info->task)) {
56265 ret = PTR_ERR(cb_info->task);
56266 svc_exit_thread(cb_info->rqst);
56267 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
56268 index a35582c..ebbdcd5 100644
56269 --- a/fs/nfs/callback_xdr.c
56270 +++ b/fs/nfs/callback_xdr.c
56271 @@ -51,7 +51,7 @@ struct callback_op {
56272 callback_decode_arg_t decode_args;
56273 callback_encode_res_t encode_res;
56274 long res_maxsize;
56275 -};
56276 +} __do_const;
56277
56278 static struct callback_op callback_ops[];
56279
56280 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
56281 index c1c7a9d..7afa0b8 100644
56282 --- a/fs/nfs/inode.c
56283 +++ b/fs/nfs/inode.c
56284 @@ -1043,16 +1043,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
56285 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
56286 }
56287
56288 -static atomic_long_t nfs_attr_generation_counter;
56289 +static atomic_long_unchecked_t nfs_attr_generation_counter;
56290
56291 static unsigned long nfs_read_attr_generation_counter(void)
56292 {
56293 - return atomic_long_read(&nfs_attr_generation_counter);
56294 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
56295 }
56296
56297 unsigned long nfs_inc_attr_generation_counter(void)
56298 {
56299 - return atomic_long_inc_return(&nfs_attr_generation_counter);
56300 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
56301 }
56302
56303 void nfs_fattr_init(struct nfs_fattr *fattr)
56304 diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
56305 index 2c37442..9b9538b 100644
56306 --- a/fs/nfs/nfs4state.c
56307 +++ b/fs/nfs/nfs4state.c
56308 @@ -1193,7 +1193,7 @@ void nfs4_schedule_state_manager(struct nfs_client *clp)
56309 snprintf(buf, sizeof(buf), "%s-manager",
56310 rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR));
56311 rcu_read_unlock();
56312 - task = kthread_run(nfs4_run_state_manager, clp, buf);
56313 + task = kthread_run(nfs4_run_state_manager, clp, "%s", buf);
56314 if (IS_ERR(task)) {
56315 printk(KERN_ERR "%s: kthread_run: %ld\n",
56316 __func__, PTR_ERR(task));
56317 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
56318 index 27d74a2..c4c2a73 100644
56319 --- a/fs/nfsd/nfs4proc.c
56320 +++ b/fs/nfsd/nfs4proc.c
56321 @@ -1126,7 +1126,7 @@ struct nfsd4_operation {
56322 nfsd4op_rsize op_rsize_bop;
56323 stateid_getter op_get_currentstateid;
56324 stateid_setter op_set_currentstateid;
56325 -};
56326 +} __do_const;
56327
56328 static struct nfsd4_operation nfsd4_ops[];
56329
56330 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
56331 index 582321a..0224663 100644
56332 --- a/fs/nfsd/nfs4xdr.c
56333 +++ b/fs/nfsd/nfs4xdr.c
56334 @@ -1458,7 +1458,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
56335
56336 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
56337
56338 -static nfsd4_dec nfsd4_dec_ops[] = {
56339 +static const nfsd4_dec nfsd4_dec_ops[] = {
56340 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
56341 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
56342 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
56343 @@ -1498,7 +1498,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
56344 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
56345 };
56346
56347 -static nfsd4_dec nfsd41_dec_ops[] = {
56348 +static const nfsd4_dec nfsd41_dec_ops[] = {
56349 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
56350 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
56351 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
56352 @@ -1560,7 +1560,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
56353 };
56354
56355 struct nfsd4_minorversion_ops {
56356 - nfsd4_dec *decoders;
56357 + const nfsd4_dec *decoders;
56358 int nops;
56359 };
56360
56361 diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
56362 index e76244e..9fe8f2f1 100644
56363 --- a/fs/nfsd/nfscache.c
56364 +++ b/fs/nfsd/nfscache.c
56365 @@ -526,14 +526,17 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
56366 {
56367 struct svc_cacherep *rp = rqstp->rq_cacherep;
56368 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
56369 - int len;
56370 + long len;
56371 size_t bufsize = 0;
56372
56373 if (!rp)
56374 return;
56375
56376 - len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
56377 - len >>= 2;
56378 + if (statp) {
56379 + len = (char*)statp - (char*)resv->iov_base;
56380 + len = resv->iov_len - len;
56381 + len >>= 2;
56382 + }
56383
56384 /* Don't cache excessive amounts of data and XDR failures */
56385 if (!statp || len > (256 >> 2)) {
56386 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
56387 index baf149a..76b86ad 100644
56388 --- a/fs/nfsd/vfs.c
56389 +++ b/fs/nfsd/vfs.c
56390 @@ -940,7 +940,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
56391 } else {
56392 oldfs = get_fs();
56393 set_fs(KERNEL_DS);
56394 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
56395 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
56396 set_fs(oldfs);
56397 }
56398
56399 @@ -1027,7 +1027,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
56400
56401 /* Write the data. */
56402 oldfs = get_fs(); set_fs(KERNEL_DS);
56403 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
56404 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
56405 set_fs(oldfs);
56406 if (host_err < 0)
56407 goto out_nfserr;
56408 @@ -1573,7 +1573,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
56409 */
56410
56411 oldfs = get_fs(); set_fs(KERNEL_DS);
56412 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
56413 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
56414 set_fs(oldfs);
56415
56416 if (host_err < 0)
56417 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
56418 index fea6bd5..8ee9d81 100644
56419 --- a/fs/nls/nls_base.c
56420 +++ b/fs/nls/nls_base.c
56421 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
56422
56423 int register_nls(struct nls_table * nls)
56424 {
56425 - struct nls_table ** tmp = &tables;
56426 + struct nls_table *tmp = tables;
56427
56428 if (nls->next)
56429 return -EBUSY;
56430
56431 spin_lock(&nls_lock);
56432 - while (*tmp) {
56433 - if (nls == *tmp) {
56434 + while (tmp) {
56435 + if (nls == tmp) {
56436 spin_unlock(&nls_lock);
56437 return -EBUSY;
56438 }
56439 - tmp = &(*tmp)->next;
56440 + tmp = tmp->next;
56441 }
56442 - nls->next = tables;
56443 + pax_open_kernel();
56444 + *(struct nls_table **)&nls->next = tables;
56445 + pax_close_kernel();
56446 tables = nls;
56447 spin_unlock(&nls_lock);
56448 return 0;
56449 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
56450
56451 int unregister_nls(struct nls_table * nls)
56452 {
56453 - struct nls_table ** tmp = &tables;
56454 + struct nls_table * const * tmp = &tables;
56455
56456 spin_lock(&nls_lock);
56457 while (*tmp) {
56458 if (nls == *tmp) {
56459 - *tmp = nls->next;
56460 + pax_open_kernel();
56461 + *(struct nls_table **)tmp = nls->next;
56462 + pax_close_kernel();
56463 spin_unlock(&nls_lock);
56464 return 0;
56465 }
56466 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
56467 index 7424929..35f6be5 100644
56468 --- a/fs/nls/nls_euc-jp.c
56469 +++ b/fs/nls/nls_euc-jp.c
56470 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
56471 p_nls = load_nls("cp932");
56472
56473 if (p_nls) {
56474 - table.charset2upper = p_nls->charset2upper;
56475 - table.charset2lower = p_nls->charset2lower;
56476 + pax_open_kernel();
56477 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
56478 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
56479 + pax_close_kernel();
56480 return register_nls(&table);
56481 }
56482
56483 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
56484 index e7bc1d7..06bd4bb 100644
56485 --- a/fs/nls/nls_koi8-ru.c
56486 +++ b/fs/nls/nls_koi8-ru.c
56487 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
56488 p_nls = load_nls("koi8-u");
56489
56490 if (p_nls) {
56491 - table.charset2upper = p_nls->charset2upper;
56492 - table.charset2lower = p_nls->charset2lower;
56493 + pax_open_kernel();
56494 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
56495 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
56496 + pax_close_kernel();
56497 return register_nls(&table);
56498 }
56499
56500 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
56501 index 77cc85d..a1e6299 100644
56502 --- a/fs/notify/fanotify/fanotify_user.c
56503 +++ b/fs/notify/fanotify/fanotify_user.c
56504 @@ -253,8 +253,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
56505
56506 fd = fanotify_event_metadata.fd;
56507 ret = -EFAULT;
56508 - if (copy_to_user(buf, &fanotify_event_metadata,
56509 - fanotify_event_metadata.event_len))
56510 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
56511 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
56512 goto out_close_fd;
56513
56514 ret = prepare_for_access_response(group, event, fd);
56515 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
56516 index 7b51b05..5ea5ef6 100644
56517 --- a/fs/notify/notification.c
56518 +++ b/fs/notify/notification.c
56519 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
56520 * get set to 0 so it will never get 'freed'
56521 */
56522 static struct fsnotify_event *q_overflow_event;
56523 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
56524 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
56525
56526 /**
56527 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
56528 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
56529 */
56530 u32 fsnotify_get_cookie(void)
56531 {
56532 - return atomic_inc_return(&fsnotify_sync_cookie);
56533 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
56534 }
56535 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
56536
56537 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
56538 index aa411c3..c260a84 100644
56539 --- a/fs/ntfs/dir.c
56540 +++ b/fs/ntfs/dir.c
56541 @@ -1329,7 +1329,7 @@ find_next_index_buffer:
56542 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
56543 ~(s64)(ndir->itype.index.block_size - 1)));
56544 /* Bounds checks. */
56545 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
56546 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
56547 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
56548 "inode 0x%lx or driver bug.", vdir->i_ino);
56549 goto err_out;
56550 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
56551 index c5670b8..01a3656 100644
56552 --- a/fs/ntfs/file.c
56553 +++ b/fs/ntfs/file.c
56554 @@ -2241,6 +2241,6 @@ const struct inode_operations ntfs_file_inode_ops = {
56555 #endif /* NTFS_RW */
56556 };
56557
56558 -const struct file_operations ntfs_empty_file_ops = {};
56559 +const struct file_operations ntfs_empty_file_ops __read_only;
56560
56561 -const struct inode_operations ntfs_empty_inode_ops = {};
56562 +const struct inode_operations ntfs_empty_inode_ops __read_only;
56563 diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
56564 index 20dfec7..e238cb7 100644
56565 --- a/fs/ocfs2/aops.c
56566 +++ b/fs/ocfs2/aops.c
56567 @@ -1756,7 +1756,7 @@ try_again:
56568 goto out;
56569 } else if (ret == 1) {
56570 clusters_need = wc->w_clen;
56571 - ret = ocfs2_refcount_cow(inode, filp, di_bh,
56572 + ret = ocfs2_refcount_cow(inode, di_bh,
56573 wc->w_cpos, wc->w_clen, UINT_MAX);
56574 if (ret) {
56575 mlog_errno(ret);
56576 diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
56577 index ff54014..ff125fd 100644
56578 --- a/fs/ocfs2/file.c
56579 +++ b/fs/ocfs2/file.c
56580 @@ -370,7 +370,7 @@ static int ocfs2_cow_file_pos(struct inode *inode,
56581 if (!(ext_flags & OCFS2_EXT_REFCOUNTED))
56582 goto out;
56583
56584 - return ocfs2_refcount_cow(inode, NULL, fe_bh, cpos, 1, cpos+1);
56585 + return ocfs2_refcount_cow(inode, fe_bh, cpos, 1, cpos+1);
56586
56587 out:
56588 return status;
56589 @@ -899,7 +899,7 @@ static int ocfs2_zero_extend_get_range(struct inode *inode,
56590 zero_clusters = last_cpos - zero_cpos;
56591
56592 if (needs_cow) {
56593 - rc = ocfs2_refcount_cow(inode, NULL, di_bh, zero_cpos,
56594 + rc = ocfs2_refcount_cow(inode, di_bh, zero_cpos,
56595 zero_clusters, UINT_MAX);
56596 if (rc) {
56597 mlog_errno(rc);
56598 @@ -2078,7 +2078,7 @@ static int ocfs2_prepare_inode_for_refcount(struct inode *inode,
56599
56600 *meta_level = 1;
56601
56602 - ret = ocfs2_refcount_cow(inode, file, di_bh, cpos, clusters, UINT_MAX);
56603 + ret = ocfs2_refcount_cow(inode, di_bh, cpos, clusters, UINT_MAX);
56604 if (ret)
56605 mlog_errno(ret);
56606 out:
56607 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
56608 index aebeacd..0dcdd26 100644
56609 --- a/fs/ocfs2/localalloc.c
56610 +++ b/fs/ocfs2/localalloc.c
56611 @@ -1278,7 +1278,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
56612 goto bail;
56613 }
56614
56615 - atomic_inc(&osb->alloc_stats.moves);
56616 + atomic_inc_unchecked(&osb->alloc_stats.moves);
56617
56618 bail:
56619 if (handle)
56620 diff --git a/fs/ocfs2/move_extents.c b/fs/ocfs2/move_extents.c
56621 index f1fc172..452068b 100644
56622 --- a/fs/ocfs2/move_extents.c
56623 +++ b/fs/ocfs2/move_extents.c
56624 @@ -69,7 +69,7 @@ static int __ocfs2_move_extent(handle_t *handle,
56625 u64 ino = ocfs2_metadata_cache_owner(context->et.et_ci);
56626 u64 old_blkno = ocfs2_clusters_to_blocks(inode->i_sb, p_cpos);
56627
56628 - ret = ocfs2_duplicate_clusters_by_page(handle, context->file, cpos,
56629 + ret = ocfs2_duplicate_clusters_by_page(handle, inode, cpos,
56630 p_cpos, new_p_cpos, len);
56631 if (ret) {
56632 mlog_errno(ret);
56633 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
56634 index d355e6e..578d905 100644
56635 --- a/fs/ocfs2/ocfs2.h
56636 +++ b/fs/ocfs2/ocfs2.h
56637 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
56638
56639 struct ocfs2_alloc_stats
56640 {
56641 - atomic_t moves;
56642 - atomic_t local_data;
56643 - atomic_t bitmap_data;
56644 - atomic_t bg_allocs;
56645 - atomic_t bg_extends;
56646 + atomic_unchecked_t moves;
56647 + atomic_unchecked_t local_data;
56648 + atomic_unchecked_t bitmap_data;
56649 + atomic_unchecked_t bg_allocs;
56650 + atomic_unchecked_t bg_extends;
56651 };
56652
56653 enum ocfs2_local_alloc_state
56654 diff --git a/fs/ocfs2/refcounttree.c b/fs/ocfs2/refcounttree.c
56655 index 998b17e..aefe414 100644
56656 --- a/fs/ocfs2/refcounttree.c
56657 +++ b/fs/ocfs2/refcounttree.c
56658 @@ -49,7 +49,6 @@
56659
56660 struct ocfs2_cow_context {
56661 struct inode *inode;
56662 - struct file *file;
56663 u32 cow_start;
56664 u32 cow_len;
56665 struct ocfs2_extent_tree data_et;
56666 @@ -66,7 +65,7 @@ struct ocfs2_cow_context {
56667 u32 *num_clusters,
56668 unsigned int *extent_flags);
56669 int (*cow_duplicate_clusters)(handle_t *handle,
56670 - struct file *file,
56671 + struct inode *inode,
56672 u32 cpos, u32 old_cluster,
56673 u32 new_cluster, u32 new_len);
56674 };
56675 @@ -2922,14 +2921,12 @@ static int ocfs2_clear_cow_buffer(handle_t *handle, struct buffer_head *bh)
56676 }
56677
56678 int ocfs2_duplicate_clusters_by_page(handle_t *handle,
56679 - struct file *file,
56680 + struct inode *inode,
56681 u32 cpos, u32 old_cluster,
56682 u32 new_cluster, u32 new_len)
56683 {
56684 int ret = 0, partial;
56685 - struct inode *inode = file_inode(file);
56686 - struct ocfs2_caching_info *ci = INODE_CACHE(inode);
56687 - struct super_block *sb = ocfs2_metadata_cache_get_super(ci);
56688 + struct super_block *sb = inode->i_sb;
56689 u64 new_block = ocfs2_clusters_to_blocks(sb, new_cluster);
56690 struct page *page;
56691 pgoff_t page_index;
56692 @@ -2973,13 +2970,6 @@ int ocfs2_duplicate_clusters_by_page(handle_t *handle,
56693 if (PAGE_CACHE_SIZE <= OCFS2_SB(sb)->s_clustersize)
56694 BUG_ON(PageDirty(page));
56695
56696 - if (PageReadahead(page)) {
56697 - page_cache_async_readahead(mapping,
56698 - &file->f_ra, file,
56699 - page, page_index,
56700 - readahead_pages);
56701 - }
56702 -
56703 if (!PageUptodate(page)) {
56704 ret = block_read_full_page(page, ocfs2_get_block);
56705 if (ret) {
56706 @@ -2999,7 +2989,8 @@ int ocfs2_duplicate_clusters_by_page(handle_t *handle,
56707 }
56708 }
56709
56710 - ocfs2_map_and_dirty_page(inode, handle, from, to,
56711 + ocfs2_map_and_dirty_page(inode,
56712 + handle, from, to,
56713 page, 0, &new_block);
56714 mark_page_accessed(page);
56715 unlock:
56716 @@ -3015,12 +3006,11 @@ unlock:
56717 }
56718
56719 int ocfs2_duplicate_clusters_by_jbd(handle_t *handle,
56720 - struct file *file,
56721 + struct inode *inode,
56722 u32 cpos, u32 old_cluster,
56723 u32 new_cluster, u32 new_len)
56724 {
56725 int ret = 0;
56726 - struct inode *inode = file_inode(file);
56727 struct super_block *sb = inode->i_sb;
56728 struct ocfs2_caching_info *ci = INODE_CACHE(inode);
56729 int i, blocks = ocfs2_clusters_to_blocks(sb, new_len);
56730 @@ -3145,7 +3135,7 @@ static int ocfs2_replace_clusters(handle_t *handle,
56731
56732 /*If the old clusters is unwritten, no need to duplicate. */
56733 if (!(ext_flags & OCFS2_EXT_UNWRITTEN)) {
56734 - ret = context->cow_duplicate_clusters(handle, context->file,
56735 + ret = context->cow_duplicate_clusters(handle, context->inode,
56736 cpos, old, new, len);
56737 if (ret) {
56738 mlog_errno(ret);
56739 @@ -3423,35 +3413,12 @@ static int ocfs2_replace_cow(struct ocfs2_cow_context *context)
56740 return ret;
56741 }
56742
56743 -static void ocfs2_readahead_for_cow(struct inode *inode,
56744 - struct file *file,
56745 - u32 start, u32 len)
56746 -{
56747 - struct address_space *mapping;
56748 - pgoff_t index;
56749 - unsigned long num_pages;
56750 - int cs_bits = OCFS2_SB(inode->i_sb)->s_clustersize_bits;
56751 -
56752 - if (!file)
56753 - return;
56754 -
56755 - mapping = file->f_mapping;
56756 - num_pages = (len << cs_bits) >> PAGE_CACHE_SHIFT;
56757 - if (!num_pages)
56758 - num_pages = 1;
56759 -
56760 - index = ((loff_t)start << cs_bits) >> PAGE_CACHE_SHIFT;
56761 - page_cache_sync_readahead(mapping, &file->f_ra, file,
56762 - index, num_pages);
56763 -}
56764 -
56765 /*
56766 * Starting at cpos, try to CoW write_len clusters. Don't CoW
56767 * past max_cpos. This will stop when it runs into a hole or an
56768 * unrefcounted extent.
56769 */
56770 static int ocfs2_refcount_cow_hunk(struct inode *inode,
56771 - struct file *file,
56772 struct buffer_head *di_bh,
56773 u32 cpos, u32 write_len, u32 max_cpos)
56774 {
56775 @@ -3480,8 +3447,6 @@ static int ocfs2_refcount_cow_hunk(struct inode *inode,
56776
56777 BUG_ON(cow_len == 0);
56778
56779 - ocfs2_readahead_for_cow(inode, file, cow_start, cow_len);
56780 -
56781 context = kzalloc(sizeof(struct ocfs2_cow_context), GFP_NOFS);
56782 if (!context) {
56783 ret = -ENOMEM;
56784 @@ -3503,7 +3468,6 @@ static int ocfs2_refcount_cow_hunk(struct inode *inode,
56785 context->ref_root_bh = ref_root_bh;
56786 context->cow_duplicate_clusters = ocfs2_duplicate_clusters_by_page;
56787 context->get_clusters = ocfs2_di_get_clusters;
56788 - context->file = file;
56789
56790 ocfs2_init_dinode_extent_tree(&context->data_et,
56791 INODE_CACHE(inode), di_bh);
56792 @@ -3532,7 +3496,6 @@ out:
56793 * clusters between cpos and cpos+write_len are safe to modify.
56794 */
56795 int ocfs2_refcount_cow(struct inode *inode,
56796 - struct file *file,
56797 struct buffer_head *di_bh,
56798 u32 cpos, u32 write_len, u32 max_cpos)
56799 {
56800 @@ -3552,7 +3515,7 @@ int ocfs2_refcount_cow(struct inode *inode,
56801 num_clusters = write_len;
56802
56803 if (ext_flags & OCFS2_EXT_REFCOUNTED) {
56804 - ret = ocfs2_refcount_cow_hunk(inode, file, di_bh, cpos,
56805 + ret = ocfs2_refcount_cow_hunk(inode, di_bh, cpos,
56806 num_clusters, max_cpos);
56807 if (ret) {
56808 mlog_errno(ret);
56809 diff --git a/fs/ocfs2/refcounttree.h b/fs/ocfs2/refcounttree.h
56810 index 7754608..6422bbcdb 100644
56811 --- a/fs/ocfs2/refcounttree.h
56812 +++ b/fs/ocfs2/refcounttree.h
56813 @@ -53,7 +53,7 @@ int ocfs2_prepare_refcount_change_for_del(struct inode *inode,
56814 int *credits,
56815 int *ref_blocks);
56816 int ocfs2_refcount_cow(struct inode *inode,
56817 - struct file *filep, struct buffer_head *di_bh,
56818 + struct buffer_head *di_bh,
56819 u32 cpos, u32 write_len, u32 max_cpos);
56820
56821 typedef int (ocfs2_post_refcount_func)(struct inode *inode,
56822 @@ -85,11 +85,11 @@ int ocfs2_refcount_cow_xattr(struct inode *inode,
56823 u32 cpos, u32 write_len,
56824 struct ocfs2_post_refcount *post);
56825 int ocfs2_duplicate_clusters_by_page(handle_t *handle,
56826 - struct file *file,
56827 + struct inode *inode,
56828 u32 cpos, u32 old_cluster,
56829 u32 new_cluster, u32 new_len);
56830 int ocfs2_duplicate_clusters_by_jbd(handle_t *handle,
56831 - struct file *file,
56832 + struct inode *inode,
56833 u32 cpos, u32 old_cluster,
56834 u32 new_cluster, u32 new_len);
56835 int ocfs2_cow_sync_writeback(struct super_block *sb,
56836 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
56837 index b7e74b5..19c6536 100644
56838 --- a/fs/ocfs2/suballoc.c
56839 +++ b/fs/ocfs2/suballoc.c
56840 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
56841 mlog_errno(status);
56842 goto bail;
56843 }
56844 - atomic_inc(&osb->alloc_stats.bg_extends);
56845 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
56846
56847 /* You should never ask for this much metadata */
56848 BUG_ON(bits_wanted >
56849 @@ -2007,7 +2007,7 @@ int ocfs2_claim_metadata(handle_t *handle,
56850 mlog_errno(status);
56851 goto bail;
56852 }
56853 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
56854 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
56855
56856 *suballoc_loc = res.sr_bg_blkno;
56857 *suballoc_bit_start = res.sr_bit_offset;
56858 @@ -2171,7 +2171,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
56859 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
56860 res->sr_bits);
56861
56862 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
56863 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
56864
56865 BUG_ON(res->sr_bits != 1);
56866
56867 @@ -2213,7 +2213,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
56868 mlog_errno(status);
56869 goto bail;
56870 }
56871 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
56872 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
56873
56874 BUG_ON(res.sr_bits != 1);
56875
56876 @@ -2317,7 +2317,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
56877 cluster_start,
56878 num_clusters);
56879 if (!status)
56880 - atomic_inc(&osb->alloc_stats.local_data);
56881 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
56882 } else {
56883 if (min_clusters > (osb->bitmap_cpg - 1)) {
56884 /* The only paths asking for contiguousness
56885 @@ -2343,7 +2343,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
56886 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
56887 res.sr_bg_blkno,
56888 res.sr_bit_offset);
56889 - atomic_inc(&osb->alloc_stats.bitmap_data);
56890 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
56891 *num_clusters = res.sr_bits;
56892 }
56893 }
56894 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
56895 index 01b8516..579c4df 100644
56896 --- a/fs/ocfs2/super.c
56897 +++ b/fs/ocfs2/super.c
56898 @@ -301,11 +301,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
56899 "%10s => GlobalAllocs: %d LocalAllocs: %d "
56900 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
56901 "Stats",
56902 - atomic_read(&osb->alloc_stats.bitmap_data),
56903 - atomic_read(&osb->alloc_stats.local_data),
56904 - atomic_read(&osb->alloc_stats.bg_allocs),
56905 - atomic_read(&osb->alloc_stats.moves),
56906 - atomic_read(&osb->alloc_stats.bg_extends));
56907 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
56908 + atomic_read_unchecked(&osb->alloc_stats.local_data),
56909 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
56910 + atomic_read_unchecked(&osb->alloc_stats.moves),
56911 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
56912
56913 out += snprintf(buf + out, len - out,
56914 "%10s => State: %u Descriptor: %llu Size: %u bits "
56915 @@ -2122,11 +2122,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
56916 spin_lock_init(&osb->osb_xattr_lock);
56917 ocfs2_init_steal_slots(osb);
56918
56919 - atomic_set(&osb->alloc_stats.moves, 0);
56920 - atomic_set(&osb->alloc_stats.local_data, 0);
56921 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
56922 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
56923 - atomic_set(&osb->alloc_stats.bg_extends, 0);
56924 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
56925 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
56926 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
56927 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
56928 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
56929
56930 /* Copy the blockcheck stats from the superblock probe */
56931 osb->osb_ecc_stats = *stats;
56932 diff --git a/fs/open.c b/fs/open.c
56933 index 8c74100..4239c48 100644
56934 --- a/fs/open.c
56935 +++ b/fs/open.c
56936 @@ -32,6 +32,8 @@
56937 #include <linux/dnotify.h>
56938 #include <linux/compat.h>
56939
56940 +#define CREATE_TRACE_POINTS
56941 +#include <trace/events/fs.h>
56942 #include "internal.h"
56943
56944 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
56945 @@ -102,6 +104,8 @@ long vfs_truncate(struct path *path, loff_t length)
56946 error = locks_verify_truncate(inode, NULL, length);
56947 if (!error)
56948 error = security_path_truncate(path);
56949 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
56950 + error = -EACCES;
56951 if (!error)
56952 error = do_truncate(path->dentry, length, 0, NULL);
56953
56954 @@ -186,6 +190,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
56955 error = locks_verify_truncate(inode, f.file, length);
56956 if (!error)
56957 error = security_path_truncate(&f.file->f_path);
56958 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
56959 + error = -EACCES;
56960 if (!error)
56961 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
56962 sb_end_write(inode->i_sb);
56963 @@ -360,6 +366,9 @@ retry:
56964 if (__mnt_is_readonly(path.mnt))
56965 res = -EROFS;
56966
56967 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
56968 + res = -EACCES;
56969 +
56970 out_path_release:
56971 path_put(&path);
56972 if (retry_estale(res, lookup_flags)) {
56973 @@ -391,6 +400,8 @@ retry:
56974 if (error)
56975 goto dput_and_out;
56976
56977 + gr_log_chdir(path.dentry, path.mnt);
56978 +
56979 set_fs_pwd(current->fs, &path);
56980
56981 dput_and_out:
56982 @@ -420,6 +431,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
56983 goto out_putf;
56984
56985 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
56986 +
56987 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
56988 + error = -EPERM;
56989 +
56990 + if (!error)
56991 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
56992 +
56993 if (!error)
56994 set_fs_pwd(current->fs, &f.file->f_path);
56995 out_putf:
56996 @@ -449,7 +467,13 @@ retry:
56997 if (error)
56998 goto dput_and_out;
56999
57000 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
57001 + goto dput_and_out;
57002 +
57003 set_fs_root(current->fs, &path);
57004 +
57005 + gr_handle_chroot_chdir(&path);
57006 +
57007 error = 0;
57008 dput_and_out:
57009 path_put(&path);
57010 @@ -471,6 +495,16 @@ static int chmod_common(struct path *path, umode_t mode)
57011 if (error)
57012 return error;
57013 mutex_lock(&inode->i_mutex);
57014 +
57015 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
57016 + error = -EACCES;
57017 + goto out_unlock;
57018 + }
57019 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
57020 + error = -EACCES;
57021 + goto out_unlock;
57022 + }
57023 +
57024 error = security_path_chmod(path, mode);
57025 if (error)
57026 goto out_unlock;
57027 @@ -531,6 +565,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
57028 uid = make_kuid(current_user_ns(), user);
57029 gid = make_kgid(current_user_ns(), group);
57030
57031 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
57032 + return -EACCES;
57033 +
57034 newattrs.ia_valid = ATTR_CTIME;
57035 if (user != (uid_t) -1) {
57036 if (!uid_valid(uid))
57037 @@ -946,6 +983,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
57038 } else {
57039 fsnotify_open(f);
57040 fd_install(fd, f);
57041 + trace_do_sys_open(tmp->name, flags, mode);
57042 }
57043 }
57044 putname(tmp);
57045 diff --git a/fs/pipe.c b/fs/pipe.c
57046 index d2c45e1..009fe1c 100644
57047 --- a/fs/pipe.c
57048 +++ b/fs/pipe.c
57049 @@ -56,7 +56,7 @@ unsigned int pipe_min_size = PAGE_SIZE;
57050
57051 static void pipe_lock_nested(struct pipe_inode_info *pipe, int subclass)
57052 {
57053 - if (pipe->files)
57054 + if (atomic_read(&pipe->files))
57055 mutex_lock_nested(&pipe->mutex, subclass);
57056 }
57057
57058 @@ -71,7 +71,7 @@ EXPORT_SYMBOL(pipe_lock);
57059
57060 void pipe_unlock(struct pipe_inode_info *pipe)
57061 {
57062 - if (pipe->files)
57063 + if (atomic_read(&pipe->files))
57064 mutex_unlock(&pipe->mutex);
57065 }
57066 EXPORT_SYMBOL(pipe_unlock);
57067 @@ -449,9 +449,9 @@ redo:
57068 }
57069 if (bufs) /* More to do? */
57070 continue;
57071 - if (!pipe->writers)
57072 + if (!atomic_read(&pipe->writers))
57073 break;
57074 - if (!pipe->waiting_writers) {
57075 + if (!atomic_read(&pipe->waiting_writers)) {
57076 /* syscall merging: Usually we must not sleep
57077 * if O_NONBLOCK is set, or if we got some data.
57078 * But if a writer sleeps in kernel space, then
57079 @@ -513,7 +513,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
57080 ret = 0;
57081 __pipe_lock(pipe);
57082
57083 - if (!pipe->readers) {
57084 + if (!atomic_read(&pipe->readers)) {
57085 send_sig(SIGPIPE, current, 0);
57086 ret = -EPIPE;
57087 goto out;
57088 @@ -562,7 +562,7 @@ redo1:
57089 for (;;) {
57090 int bufs;
57091
57092 - if (!pipe->readers) {
57093 + if (!atomic_read(&pipe->readers)) {
57094 send_sig(SIGPIPE, current, 0);
57095 if (!ret)
57096 ret = -EPIPE;
57097 @@ -653,9 +653,9 @@ redo2:
57098 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
57099 do_wakeup = 0;
57100 }
57101 - pipe->waiting_writers++;
57102 + atomic_inc(&pipe->waiting_writers);
57103 pipe_wait(pipe);
57104 - pipe->waiting_writers--;
57105 + atomic_dec(&pipe->waiting_writers);
57106 }
57107 out:
57108 __pipe_unlock(pipe);
57109 @@ -709,7 +709,7 @@ pipe_poll(struct file *filp, poll_table *wait)
57110 mask = 0;
57111 if (filp->f_mode & FMODE_READ) {
57112 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
57113 - if (!pipe->writers && filp->f_version != pipe->w_counter)
57114 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
57115 mask |= POLLHUP;
57116 }
57117
57118 @@ -719,7 +719,7 @@ pipe_poll(struct file *filp, poll_table *wait)
57119 * Most Unices do not set POLLERR for FIFOs but on Linux they
57120 * behave exactly like pipes for poll().
57121 */
57122 - if (!pipe->readers)
57123 + if (!atomic_read(&pipe->readers))
57124 mask |= POLLERR;
57125 }
57126
57127 @@ -734,17 +734,17 @@ pipe_release(struct inode *inode, struct file *file)
57128
57129 __pipe_lock(pipe);
57130 if (file->f_mode & FMODE_READ)
57131 - pipe->readers--;
57132 + atomic_dec(&pipe->readers);
57133 if (file->f_mode & FMODE_WRITE)
57134 - pipe->writers--;
57135 + atomic_dec(&pipe->writers);
57136
57137 - if (pipe->readers || pipe->writers) {
57138 + if (atomic_read(&pipe->readers) || atomic_read(&pipe->writers)) {
57139 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
57140 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
57141 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
57142 }
57143 spin_lock(&inode->i_lock);
57144 - if (!--pipe->files) {
57145 + if (atomic_dec_and_test(&pipe->files)) {
57146 inode->i_pipe = NULL;
57147 kill = 1;
57148 }
57149 @@ -811,7 +811,7 @@ void free_pipe_info(struct pipe_inode_info *pipe)
57150 kfree(pipe);
57151 }
57152
57153 -static struct vfsmount *pipe_mnt __read_mostly;
57154 +struct vfsmount *pipe_mnt __read_mostly;
57155
57156 /*
57157 * pipefs_dname() is called from d_path().
57158 @@ -841,8 +841,9 @@ static struct inode * get_pipe_inode(void)
57159 goto fail_iput;
57160
57161 inode->i_pipe = pipe;
57162 - pipe->files = 2;
57163 - pipe->readers = pipe->writers = 1;
57164 + atomic_set(&pipe->files, 2);
57165 + atomic_set(&pipe->readers, 1);
57166 + atomic_set(&pipe->writers, 1);
57167 inode->i_fop = &pipefifo_fops;
57168
57169 /*
57170 @@ -1022,17 +1023,17 @@ static int fifo_open(struct inode *inode, struct file *filp)
57171 spin_lock(&inode->i_lock);
57172 if (inode->i_pipe) {
57173 pipe = inode->i_pipe;
57174 - pipe->files++;
57175 + atomic_inc(&pipe->files);
57176 spin_unlock(&inode->i_lock);
57177 } else {
57178 spin_unlock(&inode->i_lock);
57179 pipe = alloc_pipe_info();
57180 if (!pipe)
57181 return -ENOMEM;
57182 - pipe->files = 1;
57183 + atomic_set(&pipe->files, 1);
57184 spin_lock(&inode->i_lock);
57185 if (unlikely(inode->i_pipe)) {
57186 - inode->i_pipe->files++;
57187 + atomic_inc(&inode->i_pipe->files);
57188 spin_unlock(&inode->i_lock);
57189 free_pipe_info(pipe);
57190 pipe = inode->i_pipe;
57191 @@ -1057,10 +1058,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
57192 * opened, even when there is no process writing the FIFO.
57193 */
57194 pipe->r_counter++;
57195 - if (pipe->readers++ == 0)
57196 + if (atomic_inc_return(&pipe->readers) == 1)
57197 wake_up_partner(pipe);
57198
57199 - if (!is_pipe && !pipe->writers) {
57200 + if (!is_pipe && !atomic_read(&pipe->writers)) {
57201 if ((filp->f_flags & O_NONBLOCK)) {
57202 /* suppress POLLHUP until we have
57203 * seen a writer */
57204 @@ -1079,14 +1080,14 @@ static int fifo_open(struct inode *inode, struct file *filp)
57205 * errno=ENXIO when there is no process reading the FIFO.
57206 */
57207 ret = -ENXIO;
57208 - if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !pipe->readers)
57209 + if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
57210 goto err;
57211
57212 pipe->w_counter++;
57213 - if (!pipe->writers++)
57214 + if (atomic_inc_return(&pipe->writers) == 1)
57215 wake_up_partner(pipe);
57216
57217 - if (!is_pipe && !pipe->readers) {
57218 + if (!is_pipe && !atomic_read(&pipe->readers)) {
57219 if (wait_for_partner(pipe, &pipe->r_counter))
57220 goto err_wr;
57221 }
57222 @@ -1100,11 +1101,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
57223 * the process can at least talk to itself.
57224 */
57225
57226 - pipe->readers++;
57227 - pipe->writers++;
57228 + atomic_inc(&pipe->readers);
57229 + atomic_inc(&pipe->writers);
57230 pipe->r_counter++;
57231 pipe->w_counter++;
57232 - if (pipe->readers == 1 || pipe->writers == 1)
57233 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
57234 wake_up_partner(pipe);
57235 break;
57236
57237 @@ -1118,20 +1119,20 @@ static int fifo_open(struct inode *inode, struct file *filp)
57238 return 0;
57239
57240 err_rd:
57241 - if (!--pipe->readers)
57242 + if (atomic_dec_and_test(&pipe->readers))
57243 wake_up_interruptible(&pipe->wait);
57244 ret = -ERESTARTSYS;
57245 goto err;
57246
57247 err_wr:
57248 - if (!--pipe->writers)
57249 + if (atomic_dec_and_test(&pipe->writers))
57250 wake_up_interruptible(&pipe->wait);
57251 ret = -ERESTARTSYS;
57252 goto err;
57253
57254 err:
57255 spin_lock(&inode->i_lock);
57256 - if (!--pipe->files) {
57257 + if (atomic_dec_and_test(&pipe->files)) {
57258 inode->i_pipe = NULL;
57259 kill = 1;
57260 }
57261 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
57262 index 15af622..0e9f4467 100644
57263 --- a/fs/proc/Kconfig
57264 +++ b/fs/proc/Kconfig
57265 @@ -30,12 +30,12 @@ config PROC_FS
57266
57267 config PROC_KCORE
57268 bool "/proc/kcore support" if !ARM
57269 - depends on PROC_FS && MMU
57270 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
57271
57272 config PROC_VMCORE
57273 bool "/proc/vmcore support"
57274 - depends on PROC_FS && CRASH_DUMP
57275 - default y
57276 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
57277 + default n
57278 help
57279 Exports the dump image of crashed kernel in ELF format.
57280
57281 @@ -59,8 +59,8 @@ config PROC_SYSCTL
57282 limited in memory.
57283
57284 config PROC_PAGE_MONITOR
57285 - default y
57286 - depends on PROC_FS && MMU
57287 + default n
57288 + depends on PROC_FS && MMU && !GRKERNSEC
57289 bool "Enable /proc page monitoring" if EXPERT
57290 help
57291 Various /proc files exist to monitor process memory utilization:
57292 diff --git a/fs/proc/array.c b/fs/proc/array.c
57293 index cbd0f1b..adec3f0 100644
57294 --- a/fs/proc/array.c
57295 +++ b/fs/proc/array.c
57296 @@ -60,6 +60,7 @@
57297 #include <linux/tty.h>
57298 #include <linux/string.h>
57299 #include <linux/mman.h>
57300 +#include <linux/grsecurity.h>
57301 #include <linux/proc_fs.h>
57302 #include <linux/ioport.h>
57303 #include <linux/uaccess.h>
57304 @@ -363,6 +364,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
57305 seq_putc(m, '\n');
57306 }
57307
57308 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
57309 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
57310 +{
57311 + if (p->mm)
57312 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
57313 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
57314 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
57315 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
57316 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
57317 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
57318 + else
57319 + seq_printf(m, "PaX:\t-----\n");
57320 +}
57321 +#endif
57322 +
57323 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
57324 struct pid *pid, struct task_struct *task)
57325 {
57326 @@ -381,9 +397,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
57327 task_cpus_allowed(m, task);
57328 cpuset_task_status_allowed(m, task);
57329 task_context_switch_counts(m, task);
57330 +
57331 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
57332 + task_pax(m, task);
57333 +#endif
57334 +
57335 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
57336 + task_grsec_rbac(m, task);
57337 +#endif
57338 +
57339 return 0;
57340 }
57341
57342 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
57343 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
57344 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
57345 + _mm->pax_flags & MF_PAX_SEGMEXEC))
57346 +#endif
57347 +
57348 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
57349 struct pid *pid, struct task_struct *task, int whole)
57350 {
57351 @@ -405,6 +436,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
57352 char tcomm[sizeof(task->comm)];
57353 unsigned long flags;
57354
57355 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
57356 + if (current->exec_id != m->exec_id) {
57357 + gr_log_badprocpid("stat");
57358 + return 0;
57359 + }
57360 +#endif
57361 +
57362 state = *get_task_state(task);
57363 vsize = eip = esp = 0;
57364 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
57365 @@ -476,6 +514,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
57366 gtime = task_gtime(task);
57367 }
57368
57369 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
57370 + if (PAX_RAND_FLAGS(mm)) {
57371 + eip = 0;
57372 + esp = 0;
57373 + wchan = 0;
57374 + }
57375 +#endif
57376 +#ifdef CONFIG_GRKERNSEC_HIDESYM
57377 + wchan = 0;
57378 + eip =0;
57379 + esp =0;
57380 +#endif
57381 +
57382 /* scale priority and nice values from timeslices to -20..20 */
57383 /* to make it look like a "normal" Unix priority/nice value */
57384 priority = task_prio(task);
57385 @@ -512,9 +563,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
57386 seq_put_decimal_ull(m, ' ', vsize);
57387 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
57388 seq_put_decimal_ull(m, ' ', rsslim);
57389 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
57390 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
57391 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
57392 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
57393 +#else
57394 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
57395 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
57396 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
57397 +#endif
57398 seq_put_decimal_ull(m, ' ', esp);
57399 seq_put_decimal_ull(m, ' ', eip);
57400 /* The signal information here is obsolete.
57401 @@ -536,7 +593,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
57402 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
57403 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
57404
57405 - if (mm && permitted) {
57406 + if (mm && permitted
57407 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
57408 + && !PAX_RAND_FLAGS(mm)
57409 +#endif
57410 + ) {
57411 seq_put_decimal_ull(m, ' ', mm->start_data);
57412 seq_put_decimal_ull(m, ' ', mm->end_data);
57413 seq_put_decimal_ull(m, ' ', mm->start_brk);
57414 @@ -574,8 +635,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
57415 struct pid *pid, struct task_struct *task)
57416 {
57417 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
57418 - struct mm_struct *mm = get_task_mm(task);
57419 + struct mm_struct *mm;
57420
57421 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
57422 + if (current->exec_id != m->exec_id) {
57423 + gr_log_badprocpid("statm");
57424 + return 0;
57425 + }
57426 +#endif
57427 + mm = get_task_mm(task);
57428 if (mm) {
57429 size = task_statm(mm, &shared, &text, &data, &resident);
57430 mmput(mm);
57431 @@ -598,6 +666,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
57432 return 0;
57433 }
57434
57435 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
57436 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
57437 +{
57438 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
57439 +}
57440 +#endif
57441 +
57442 #ifdef CONFIG_CHECKPOINT_RESTORE
57443 static struct pid *
57444 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
57445 diff --git a/fs/proc/base.c b/fs/proc/base.c
57446 index c3834da..b402b2b 100644
57447 --- a/fs/proc/base.c
57448 +++ b/fs/proc/base.c
57449 @@ -113,6 +113,14 @@ struct pid_entry {
57450 union proc_op op;
57451 };
57452
57453 +struct getdents_callback {
57454 + struct linux_dirent __user * current_dir;
57455 + struct linux_dirent __user * previous;
57456 + struct file * file;
57457 + int count;
57458 + int error;
57459 +};
57460 +
57461 #define NOD(NAME, MODE, IOP, FOP, OP) { \
57462 .name = (NAME), \
57463 .len = sizeof(NAME) - 1, \
57464 @@ -210,6 +218,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
57465 if (!mm->arg_end)
57466 goto out_mm; /* Shh! No looking before we're done */
57467
57468 + if (gr_acl_handle_procpidmem(task))
57469 + goto out_mm;
57470 +
57471 len = mm->arg_end - mm->arg_start;
57472
57473 if (len > PAGE_SIZE)
57474 @@ -237,12 +248,28 @@ out:
57475 return res;
57476 }
57477
57478 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
57479 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
57480 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
57481 + _mm->pax_flags & MF_PAX_SEGMEXEC))
57482 +#endif
57483 +
57484 static int proc_pid_auxv(struct task_struct *task, char *buffer)
57485 {
57486 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
57487 int res = PTR_ERR(mm);
57488 if (mm && !IS_ERR(mm)) {
57489 unsigned int nwords = 0;
57490 +
57491 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
57492 + /* allow if we're currently ptracing this task */
57493 + if (PAX_RAND_FLAGS(mm) &&
57494 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
57495 + mmput(mm);
57496 + return 0;
57497 + }
57498 +#endif
57499 +
57500 do {
57501 nwords += 2;
57502 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
57503 @@ -256,7 +283,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
57504 }
57505
57506
57507 -#ifdef CONFIG_KALLSYMS
57508 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
57509 /*
57510 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
57511 * Returns the resolved symbol. If that fails, simply return the address.
57512 @@ -295,7 +322,7 @@ static void unlock_trace(struct task_struct *task)
57513 mutex_unlock(&task->signal->cred_guard_mutex);
57514 }
57515
57516 -#ifdef CONFIG_STACKTRACE
57517 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
57518
57519 #define MAX_STACK_TRACE_DEPTH 64
57520
57521 @@ -518,7 +545,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
57522 return count;
57523 }
57524
57525 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
57526 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
57527 static int proc_pid_syscall(struct task_struct *task, char *buffer)
57528 {
57529 long nr;
57530 @@ -547,7 +574,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
57531 /************************************************************************/
57532
57533 /* permission checks */
57534 -static int proc_fd_access_allowed(struct inode *inode)
57535 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
57536 {
57537 struct task_struct *task;
57538 int allowed = 0;
57539 @@ -557,7 +584,10 @@ static int proc_fd_access_allowed(struct inode *inode)
57540 */
57541 task = get_proc_task(inode);
57542 if (task) {
57543 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
57544 + if (log)
57545 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
57546 + else
57547 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
57548 put_task_struct(task);
57549 }
57550 return allowed;
57551 @@ -588,10 +618,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
57552 struct task_struct *task,
57553 int hide_pid_min)
57554 {
57555 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
57556 + return false;
57557 +
57558 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
57559 + rcu_read_lock();
57560 + {
57561 + const struct cred *tmpcred = current_cred();
57562 + const struct cred *cred = __task_cred(task);
57563 +
57564 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
57565 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
57566 + || in_group_p(grsec_proc_gid)
57567 +#endif
57568 + ) {
57569 + rcu_read_unlock();
57570 + return true;
57571 + }
57572 + }
57573 + rcu_read_unlock();
57574 +
57575 + if (!pid->hide_pid)
57576 + return false;
57577 +#endif
57578 +
57579 if (pid->hide_pid < hide_pid_min)
57580 return true;
57581 if (in_group_p(pid->pid_gid))
57582 return true;
57583 +
57584 return ptrace_may_access(task, PTRACE_MODE_READ);
57585 }
57586
57587 @@ -609,7 +664,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
57588 put_task_struct(task);
57589
57590 if (!has_perms) {
57591 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
57592 + {
57593 +#else
57594 if (pid->hide_pid == 2) {
57595 +#endif
57596 /*
57597 * Let's make getdents(), stat(), and open()
57598 * consistent with each other. If a process
57599 @@ -707,6 +766,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
57600 if (!task)
57601 return -ESRCH;
57602
57603 + if (gr_acl_handle_procpidmem(task)) {
57604 + put_task_struct(task);
57605 + return -EPERM;
57606 + }
57607 +
57608 mm = mm_access(task, mode);
57609 put_task_struct(task);
57610
57611 @@ -722,6 +786,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
57612
57613 file->private_data = mm;
57614
57615 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
57616 + file->f_version = current->exec_id;
57617 +#endif
57618 +
57619 return 0;
57620 }
57621
57622 @@ -743,6 +811,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
57623 ssize_t copied;
57624 char *page;
57625
57626 +#ifdef CONFIG_GRKERNSEC
57627 + if (write)
57628 + return -EPERM;
57629 +#endif
57630 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
57631 + if (file->f_version != current->exec_id) {
57632 + gr_log_badprocpid("mem");
57633 + return 0;
57634 + }
57635 +#endif
57636 +
57637 if (!mm)
57638 return 0;
57639
57640 @@ -755,7 +834,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
57641 goto free;
57642
57643 while (count > 0) {
57644 - int this_len = min_t(int, count, PAGE_SIZE);
57645 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
57646
57647 if (write && copy_from_user(page, buf, this_len)) {
57648 copied = -EFAULT;
57649 @@ -847,6 +926,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
57650 if (!mm)
57651 return 0;
57652
57653 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
57654 + if (file->f_version != current->exec_id) {
57655 + gr_log_badprocpid("environ");
57656 + return 0;
57657 + }
57658 +#endif
57659 +
57660 page = (char *)__get_free_page(GFP_TEMPORARY);
57661 if (!page)
57662 return -ENOMEM;
57663 @@ -856,7 +942,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
57664 goto free;
57665 while (count > 0) {
57666 size_t this_len, max_len;
57667 - int retval;
57668 + ssize_t retval;
57669
57670 if (src >= (mm->env_end - mm->env_start))
57671 break;
57672 @@ -1461,7 +1547,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
57673 int error = -EACCES;
57674
57675 /* Are we allowed to snoop on the tasks file descriptors? */
57676 - if (!proc_fd_access_allowed(inode))
57677 + if (!proc_fd_access_allowed(inode, 0))
57678 goto out;
57679
57680 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
57681 @@ -1505,8 +1591,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
57682 struct path path;
57683
57684 /* Are we allowed to snoop on the tasks file descriptors? */
57685 - if (!proc_fd_access_allowed(inode))
57686 - goto out;
57687 + /* logging this is needed for learning on chromium to work properly,
57688 + but we don't want to flood the logs from 'ps' which does a readlink
57689 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
57690 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
57691 + */
57692 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
57693 + if (!proc_fd_access_allowed(inode,0))
57694 + goto out;
57695 + } else {
57696 + if (!proc_fd_access_allowed(inode,1))
57697 + goto out;
57698 + }
57699
57700 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
57701 if (error)
57702 @@ -1556,7 +1652,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
57703 rcu_read_lock();
57704 cred = __task_cred(task);
57705 inode->i_uid = cred->euid;
57706 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
57707 + inode->i_gid = grsec_proc_gid;
57708 +#else
57709 inode->i_gid = cred->egid;
57710 +#endif
57711 rcu_read_unlock();
57712 }
57713 security_task_to_inode(task, inode);
57714 @@ -1592,10 +1692,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
57715 return -ENOENT;
57716 }
57717 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
57718 +#ifdef CONFIG_GRKERNSEC_PROC_USER
57719 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
57720 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
57721 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
57722 +#endif
57723 task_dumpable(task)) {
57724 cred = __task_cred(task);
57725 stat->uid = cred->euid;
57726 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
57727 + stat->gid = grsec_proc_gid;
57728 +#else
57729 stat->gid = cred->egid;
57730 +#endif
57731 }
57732 }
57733 rcu_read_unlock();
57734 @@ -1633,11 +1742,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
57735
57736 if (task) {
57737 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
57738 +#ifdef CONFIG_GRKERNSEC_PROC_USER
57739 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
57740 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
57741 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
57742 +#endif
57743 task_dumpable(task)) {
57744 rcu_read_lock();
57745 cred = __task_cred(task);
57746 inode->i_uid = cred->euid;
57747 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
57748 + inode->i_gid = grsec_proc_gid;
57749 +#else
57750 inode->i_gid = cred->egid;
57751 +#endif
57752 rcu_read_unlock();
57753 } else {
57754 inode->i_uid = GLOBAL_ROOT_UID;
57755 @@ -2196,6 +2314,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
57756 if (!task)
57757 goto out_no_task;
57758
57759 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
57760 + goto out;
57761 +
57762 /*
57763 * Yes, it does not scale. And it should not. Don't add
57764 * new entries into /proc/<tgid>/ without very good reasons.
57765 @@ -2240,6 +2361,9 @@ static int proc_pident_readdir(struct file *filp,
57766 if (!task)
57767 goto out_no_task;
57768
57769 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
57770 + goto out;
57771 +
57772 ret = 0;
57773 i = filp->f_pos;
57774 switch (i) {
57775 @@ -2653,7 +2777,7 @@ static const struct pid_entry tgid_base_stuff[] = {
57776 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
57777 #endif
57778 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
57779 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
57780 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
57781 INF("syscall", S_IRUGO, proc_pid_syscall),
57782 #endif
57783 INF("cmdline", S_IRUGO, proc_pid_cmdline),
57784 @@ -2678,10 +2802,10 @@ static const struct pid_entry tgid_base_stuff[] = {
57785 #ifdef CONFIG_SECURITY
57786 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
57787 #endif
57788 -#ifdef CONFIG_KALLSYMS
57789 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
57790 INF("wchan", S_IRUGO, proc_pid_wchan),
57791 #endif
57792 -#ifdef CONFIG_STACKTRACE
57793 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
57794 ONE("stack", S_IRUGO, proc_pid_stack),
57795 #endif
57796 #ifdef CONFIG_SCHEDSTATS
57797 @@ -2715,6 +2839,9 @@ static const struct pid_entry tgid_base_stuff[] = {
57798 #ifdef CONFIG_HARDWALL
57799 INF("hardwall", S_IRUGO, proc_pid_hardwall),
57800 #endif
57801 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
57802 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
57803 +#endif
57804 #ifdef CONFIG_USER_NS
57805 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
57806 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
57807 @@ -2847,7 +2974,14 @@ static struct dentry *proc_pid_instantiate(struct inode *dir,
57808 if (!inode)
57809 goto out;
57810
57811 +#ifdef CONFIG_GRKERNSEC_PROC_USER
57812 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
57813 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
57814 + inode->i_gid = grsec_proc_gid;
57815 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
57816 +#else
57817 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
57818 +#endif
57819 inode->i_op = &proc_tgid_base_inode_operations;
57820 inode->i_fop = &proc_tgid_base_operations;
57821 inode->i_flags|=S_IMMUTABLE;
57822 @@ -2885,7 +3019,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
57823 if (!task)
57824 goto out;
57825
57826 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
57827 + goto out_put_task;
57828 +
57829 result = proc_pid_instantiate(dir, dentry, task, NULL);
57830 +out_put_task:
57831 put_task_struct(task);
57832 out:
57833 return result;
57834 @@ -2948,6 +3086,8 @@ static int proc_pid_fill_cache(struct file *filp, void *dirent, filldir_t filldi
57835 static int fake_filldir(void *buf, const char *name, int namelen,
57836 loff_t offset, u64 ino, unsigned d_type)
57837 {
57838 + struct getdents_callback * __buf = (struct getdents_callback *) buf;
57839 + __buf->error = -EINVAL;
57840 return 0;
57841 }
57842
57843 @@ -3007,7 +3147,7 @@ static const struct pid_entry tid_base_stuff[] = {
57844 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
57845 #endif
57846 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
57847 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
57848 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
57849 INF("syscall", S_IRUGO, proc_pid_syscall),
57850 #endif
57851 INF("cmdline", S_IRUGO, proc_pid_cmdline),
57852 @@ -3034,10 +3174,10 @@ static const struct pid_entry tid_base_stuff[] = {
57853 #ifdef CONFIG_SECURITY
57854 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
57855 #endif
57856 -#ifdef CONFIG_KALLSYMS
57857 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
57858 INF("wchan", S_IRUGO, proc_pid_wchan),
57859 #endif
57860 -#ifdef CONFIG_STACKTRACE
57861 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
57862 ONE("stack", S_IRUGO, proc_pid_stack),
57863 #endif
57864 #ifdef CONFIG_SCHEDSTATS
57865 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
57866 index 82676e3..5f8518a 100644
57867 --- a/fs/proc/cmdline.c
57868 +++ b/fs/proc/cmdline.c
57869 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
57870
57871 static int __init proc_cmdline_init(void)
57872 {
57873 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
57874 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
57875 +#else
57876 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
57877 +#endif
57878 return 0;
57879 }
57880 module_init(proc_cmdline_init);
57881 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
57882 index b143471..bb105e5 100644
57883 --- a/fs/proc/devices.c
57884 +++ b/fs/proc/devices.c
57885 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
57886
57887 static int __init proc_devices_init(void)
57888 {
57889 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
57890 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
57891 +#else
57892 proc_create("devices", 0, NULL, &proc_devinfo_operations);
57893 +#endif
57894 return 0;
57895 }
57896 module_init(proc_devices_init);
57897 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
57898 index d7a4a28..0201742 100644
57899 --- a/fs/proc/fd.c
57900 +++ b/fs/proc/fd.c
57901 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
57902 if (!task)
57903 return -ENOENT;
57904
57905 - files = get_files_struct(task);
57906 + if (!gr_acl_handle_procpidmem(task))
57907 + files = get_files_struct(task);
57908 put_task_struct(task);
57909
57910 if (files) {
57911 @@ -302,11 +303,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
57912 */
57913 int proc_fd_permission(struct inode *inode, int mask)
57914 {
57915 + struct task_struct *task;
57916 int rv = generic_permission(inode, mask);
57917 - if (rv == 0)
57918 - return 0;
57919 +
57920 if (task_pid(current) == proc_pid(inode))
57921 rv = 0;
57922 +
57923 + task = get_proc_task(inode);
57924 + if (task == NULL)
57925 + return rv;
57926 +
57927 + if (gr_acl_handle_procpidmem(task))
57928 + rv = -EACCES;
57929 +
57930 + put_task_struct(task);
57931 +
57932 return rv;
57933 }
57934
57935 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
57936 index 073aea6..0630370 100644
57937 --- a/fs/proc/inode.c
57938 +++ b/fs/proc/inode.c
57939 @@ -23,11 +23,17 @@
57940 #include <linux/slab.h>
57941 #include <linux/mount.h>
57942 #include <linux/magic.h>
57943 +#include <linux/grsecurity.h>
57944
57945 #include <asm/uaccess.h>
57946
57947 #include "internal.h"
57948
57949 +#ifdef CONFIG_PROC_SYSCTL
57950 +extern const struct inode_operations proc_sys_inode_operations;
57951 +extern const struct inode_operations proc_sys_dir_operations;
57952 +#endif
57953 +
57954 static void proc_evict_inode(struct inode *inode)
57955 {
57956 struct proc_dir_entry *de;
57957 @@ -55,6 +61,13 @@ static void proc_evict_inode(struct inode *inode)
57958 ns = PROC_I(inode)->ns.ns;
57959 if (ns_ops && ns)
57960 ns_ops->put(ns);
57961 +
57962 +#ifdef CONFIG_PROC_SYSCTL
57963 + if (inode->i_op == &proc_sys_inode_operations ||
57964 + inode->i_op == &proc_sys_dir_operations)
57965 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
57966 +#endif
57967 +
57968 }
57969
57970 static struct kmem_cache * proc_inode_cachep;
57971 @@ -385,7 +398,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
57972 if (de->mode) {
57973 inode->i_mode = de->mode;
57974 inode->i_uid = de->uid;
57975 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
57976 + inode->i_gid = grsec_proc_gid;
57977 +#else
57978 inode->i_gid = de->gid;
57979 +#endif
57980 }
57981 if (de->size)
57982 inode->i_size = de->size;
57983 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
57984 index d600fb0..3b495fe 100644
57985 --- a/fs/proc/internal.h
57986 +++ b/fs/proc/internal.h
57987 @@ -155,6 +155,9 @@ extern int proc_pid_status(struct seq_file *, struct pid_namespace *,
57988 struct pid *, struct task_struct *);
57989 extern int proc_pid_statm(struct seq_file *, struct pid_namespace *,
57990 struct pid *, struct task_struct *);
57991 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
57992 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
57993 +#endif
57994
57995 /*
57996 * base.c
57997 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
57998 index 0a22194..a9fc8c1 100644
57999 --- a/fs/proc/kcore.c
58000 +++ b/fs/proc/kcore.c
58001 @@ -484,9 +484,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
58002 * the addresses in the elf_phdr on our list.
58003 */
58004 start = kc_offset_to_vaddr(*fpos - elf_buflen);
58005 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
58006 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
58007 + if (tsz > buflen)
58008 tsz = buflen;
58009 -
58010 +
58011 while (buflen) {
58012 struct kcore_list *m;
58013
58014 @@ -515,20 +516,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
58015 kfree(elf_buf);
58016 } else {
58017 if (kern_addr_valid(start)) {
58018 - unsigned long n;
58019 + char *elf_buf;
58020 + mm_segment_t oldfs;
58021
58022 - n = copy_to_user(buffer, (char *)start, tsz);
58023 - /*
58024 - * We cannot distinguish between fault on source
58025 - * and fault on destination. When this happens
58026 - * we clear too and hope it will trigger the
58027 - * EFAULT again.
58028 - */
58029 - if (n) {
58030 - if (clear_user(buffer + tsz - n,
58031 - n))
58032 + elf_buf = kmalloc(tsz, GFP_KERNEL);
58033 + if (!elf_buf)
58034 + return -ENOMEM;
58035 + oldfs = get_fs();
58036 + set_fs(KERNEL_DS);
58037 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
58038 + set_fs(oldfs);
58039 + if (copy_to_user(buffer, elf_buf, tsz)) {
58040 + kfree(elf_buf);
58041 return -EFAULT;
58042 + }
58043 }
58044 + set_fs(oldfs);
58045 + kfree(elf_buf);
58046 } else {
58047 if (clear_user(buffer, tsz))
58048 return -EFAULT;
58049 @@ -548,6 +552,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
58050
58051 static int open_kcore(struct inode *inode, struct file *filp)
58052 {
58053 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
58054 + return -EPERM;
58055 +#endif
58056 if (!capable(CAP_SYS_RAWIO))
58057 return -EPERM;
58058 if (kcore_need_update)
58059 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
58060 index 5aa847a..f77c8d4 100644
58061 --- a/fs/proc/meminfo.c
58062 +++ b/fs/proc/meminfo.c
58063 @@ -159,7 +159,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
58064 vmi.used >> 10,
58065 vmi.largest_chunk >> 10
58066 #ifdef CONFIG_MEMORY_FAILURE
58067 - ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
58068 + ,atomic_long_read_unchecked(&num_poisoned_pages) << (PAGE_SHIFT - 10)
58069 #endif
58070 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
58071 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
58072 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
58073 index ccfd99b..1b7e255 100644
58074 --- a/fs/proc/nommu.c
58075 +++ b/fs/proc/nommu.c
58076 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
58077 if (len < 1)
58078 len = 1;
58079 seq_printf(m, "%*c", len, ' ');
58080 - seq_path(m, &file->f_path, "");
58081 + seq_path(m, &file->f_path, "\n\\");
58082 }
58083
58084 seq_putc(m, '\n');
58085 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
58086 index 986e832..6e8e859 100644
58087 --- a/fs/proc/proc_net.c
58088 +++ b/fs/proc/proc_net.c
58089 @@ -23,6 +23,7 @@
58090 #include <linux/nsproxy.h>
58091 #include <net/net_namespace.h>
58092 #include <linux/seq_file.h>
58093 +#include <linux/grsecurity.h>
58094
58095 #include "internal.h"
58096
58097 @@ -109,6 +110,17 @@ static struct net *get_proc_task_net(struct inode *dir)
58098 struct task_struct *task;
58099 struct nsproxy *ns;
58100 struct net *net = NULL;
58101 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
58102 + const struct cred *cred = current_cred();
58103 +#endif
58104 +
58105 +#ifdef CONFIG_GRKERNSEC_PROC_USER
58106 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
58107 + return net;
58108 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
58109 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
58110 + return net;
58111 +#endif
58112
58113 rcu_read_lock();
58114 task = pid_task(proc_pid(dir), PIDTYPE_PID);
58115 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
58116 index ac05f33..1e6dc7e 100644
58117 --- a/fs/proc/proc_sysctl.c
58118 +++ b/fs/proc/proc_sysctl.c
58119 @@ -13,11 +13,15 @@
58120 #include <linux/module.h>
58121 #include "internal.h"
58122
58123 +extern int gr_handle_chroot_sysctl(const int op);
58124 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
58125 + const int op);
58126 +
58127 static const struct dentry_operations proc_sys_dentry_operations;
58128 static const struct file_operations proc_sys_file_operations;
58129 -static const struct inode_operations proc_sys_inode_operations;
58130 +const struct inode_operations proc_sys_inode_operations;
58131 static const struct file_operations proc_sys_dir_file_operations;
58132 -static const struct inode_operations proc_sys_dir_operations;
58133 +const struct inode_operations proc_sys_dir_operations;
58134
58135 void proc_sys_poll_notify(struct ctl_table_poll *poll)
58136 {
58137 @@ -467,6 +471,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
58138
58139 err = NULL;
58140 d_set_d_op(dentry, &proc_sys_dentry_operations);
58141 +
58142 + gr_handle_proc_create(dentry, inode);
58143 +
58144 d_add(dentry, inode);
58145
58146 out:
58147 @@ -482,6 +489,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
58148 struct inode *inode = file_inode(filp);
58149 struct ctl_table_header *head = grab_header(inode);
58150 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
58151 + int op = write ? MAY_WRITE : MAY_READ;
58152 ssize_t error;
58153 size_t res;
58154
58155 @@ -493,7 +501,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
58156 * and won't be until we finish.
58157 */
58158 error = -EPERM;
58159 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
58160 + if (sysctl_perm(head, table, op))
58161 goto out;
58162
58163 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
58164 @@ -501,6 +509,22 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
58165 if (!table->proc_handler)
58166 goto out;
58167
58168 +#ifdef CONFIG_GRKERNSEC
58169 + error = -EPERM;
58170 + if (gr_handle_chroot_sysctl(op))
58171 + goto out;
58172 + dget(filp->f_path.dentry);
58173 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
58174 + dput(filp->f_path.dentry);
58175 + goto out;
58176 + }
58177 + dput(filp->f_path.dentry);
58178 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
58179 + goto out;
58180 + if (write && !capable(CAP_SYS_ADMIN))
58181 + goto out;
58182 +#endif
58183 +
58184 /* careful: calling conventions are nasty here */
58185 res = count;
58186 error = table->proc_handler(table, write, buf, &res, ppos);
58187 @@ -598,6 +622,9 @@ static int proc_sys_fill_cache(struct file *filp, void *dirent,
58188 return -ENOMEM;
58189 } else {
58190 d_set_d_op(child, &proc_sys_dentry_operations);
58191 +
58192 + gr_handle_proc_create(child, inode);
58193 +
58194 d_add(child, inode);
58195 }
58196 } else {
58197 @@ -641,6 +668,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
58198 if ((*pos)++ < file->f_pos)
58199 return 0;
58200
58201 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
58202 + return 0;
58203 +
58204 if (unlikely(S_ISLNK(table->mode)))
58205 res = proc_sys_link_fill_cache(file, dirent, filldir, head, table);
58206 else
58207 @@ -751,6 +781,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
58208 if (IS_ERR(head))
58209 return PTR_ERR(head);
58210
58211 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
58212 + return -ENOENT;
58213 +
58214 generic_fillattr(inode, stat);
58215 if (table)
58216 stat->mode = (stat->mode & S_IFMT) | table->mode;
58217 @@ -773,13 +806,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
58218 .llseek = generic_file_llseek,
58219 };
58220
58221 -static const struct inode_operations proc_sys_inode_operations = {
58222 +const struct inode_operations proc_sys_inode_operations = {
58223 .permission = proc_sys_permission,
58224 .setattr = proc_sys_setattr,
58225 .getattr = proc_sys_getattr,
58226 };
58227
58228 -static const struct inode_operations proc_sys_dir_operations = {
58229 +const struct inode_operations proc_sys_dir_operations = {
58230 .lookup = proc_sys_lookup,
58231 .permission = proc_sys_permission,
58232 .setattr = proc_sys_setattr,
58233 @@ -855,7 +888,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
58234 static struct ctl_dir *new_dir(struct ctl_table_set *set,
58235 const char *name, int namelen)
58236 {
58237 - struct ctl_table *table;
58238 + ctl_table_no_const *table;
58239 struct ctl_dir *new;
58240 struct ctl_node *node;
58241 char *new_name;
58242 @@ -867,7 +900,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
58243 return NULL;
58244
58245 node = (struct ctl_node *)(new + 1);
58246 - table = (struct ctl_table *)(node + 1);
58247 + table = (ctl_table_no_const *)(node + 1);
58248 new_name = (char *)(table + 2);
58249 memcpy(new_name, name, namelen);
58250 new_name[namelen] = '\0';
58251 @@ -1036,7 +1069,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
58252 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
58253 struct ctl_table_root *link_root)
58254 {
58255 - struct ctl_table *link_table, *entry, *link;
58256 + ctl_table_no_const *link_table, *link;
58257 + struct ctl_table *entry;
58258 struct ctl_table_header *links;
58259 struct ctl_node *node;
58260 char *link_name;
58261 @@ -1059,7 +1093,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
58262 return NULL;
58263
58264 node = (struct ctl_node *)(links + 1);
58265 - link_table = (struct ctl_table *)(node + nr_entries);
58266 + link_table = (ctl_table_no_const *)(node + nr_entries);
58267 link_name = (char *)&link_table[nr_entries + 1];
58268
58269 for (link = link_table, entry = table; entry->procname; link++, entry++) {
58270 @@ -1307,8 +1341,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
58271 struct ctl_table_header ***subheader, struct ctl_table_set *set,
58272 struct ctl_table *table)
58273 {
58274 - struct ctl_table *ctl_table_arg = NULL;
58275 - struct ctl_table *entry, *files;
58276 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
58277 + struct ctl_table *entry;
58278 int nr_files = 0;
58279 int nr_dirs = 0;
58280 int err = -ENOMEM;
58281 @@ -1320,10 +1354,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
58282 nr_files++;
58283 }
58284
58285 - files = table;
58286 /* If there are mixed files and directories we need a new table */
58287 if (nr_dirs && nr_files) {
58288 - struct ctl_table *new;
58289 + ctl_table_no_const *new;
58290 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
58291 GFP_KERNEL);
58292 if (!files)
58293 @@ -1341,7 +1374,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
58294 /* Register everything except a directory full of subdirectories */
58295 if (nr_files || !nr_dirs) {
58296 struct ctl_table_header *header;
58297 - header = __register_sysctl_table(set, path, files);
58298 + header = __register_sysctl_table(set, path, files ? files : table);
58299 if (!header) {
58300 kfree(ctl_table_arg);
58301 goto out;
58302 diff --git a/fs/proc/root.c b/fs/proc/root.c
58303 index 41a6ea9..23eaa92 100644
58304 --- a/fs/proc/root.c
58305 +++ b/fs/proc/root.c
58306 @@ -182,7 +182,15 @@ void __init proc_root_init(void)
58307 #ifdef CONFIG_PROC_DEVICETREE
58308 proc_device_tree_init();
58309 #endif
58310 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
58311 +#ifdef CONFIG_GRKERNSEC_PROC_USER
58312 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
58313 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
58314 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
58315 +#endif
58316 +#else
58317 proc_mkdir("bus", NULL);
58318 +#endif
58319 proc_sys_init();
58320 }
58321
58322 diff --git a/fs/proc/self.c b/fs/proc/self.c
58323 index 6b6a993..807cccc 100644
58324 --- a/fs/proc/self.c
58325 +++ b/fs/proc/self.c
58326 @@ -39,7 +39,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
58327 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
58328 void *cookie)
58329 {
58330 - char *s = nd_get_link(nd);
58331 + const char *s = nd_get_link(nd);
58332 if (!IS_ERR(s))
58333 kfree(s);
58334 }
58335 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
58336 index 65fc60a..350cc48 100644
58337 --- a/fs/proc/task_mmu.c
58338 +++ b/fs/proc/task_mmu.c
58339 @@ -11,12 +11,19 @@
58340 #include <linux/rmap.h>
58341 #include <linux/swap.h>
58342 #include <linux/swapops.h>
58343 +#include <linux/grsecurity.h>
58344
58345 #include <asm/elf.h>
58346 #include <asm/uaccess.h>
58347 #include <asm/tlbflush.h>
58348 #include "internal.h"
58349
58350 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58351 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
58352 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
58353 + _mm->pax_flags & MF_PAX_SEGMEXEC))
58354 +#endif
58355 +
58356 void task_mem(struct seq_file *m, struct mm_struct *mm)
58357 {
58358 unsigned long data, text, lib, swap;
58359 @@ -52,8 +59,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
58360 "VmExe:\t%8lu kB\n"
58361 "VmLib:\t%8lu kB\n"
58362 "VmPTE:\t%8lu kB\n"
58363 - "VmSwap:\t%8lu kB\n",
58364 - hiwater_vm << (PAGE_SHIFT-10),
58365 + "VmSwap:\t%8lu kB\n"
58366 +
58367 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
58368 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
58369 +#endif
58370 +
58371 + ,hiwater_vm << (PAGE_SHIFT-10),
58372 total_vm << (PAGE_SHIFT-10),
58373 mm->locked_vm << (PAGE_SHIFT-10),
58374 mm->pinned_vm << (PAGE_SHIFT-10),
58375 @@ -62,7 +74,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
58376 data << (PAGE_SHIFT-10),
58377 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
58378 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
58379 - swap << (PAGE_SHIFT-10));
58380 + swap << (PAGE_SHIFT-10)
58381 +
58382 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
58383 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58384 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
58385 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
58386 +#else
58387 + , mm->context.user_cs_base
58388 + , mm->context.user_cs_limit
58389 +#endif
58390 +#endif
58391 +
58392 + );
58393 }
58394
58395 unsigned long task_vsize(struct mm_struct *mm)
58396 @@ -277,13 +301,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
58397 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
58398 }
58399
58400 - /* We don't show the stack guard page in /proc/maps */
58401 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58402 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
58403 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
58404 +#else
58405 start = vma->vm_start;
58406 - if (stack_guard_page_start(vma, start))
58407 - start += PAGE_SIZE;
58408 end = vma->vm_end;
58409 - if (stack_guard_page_end(vma, end))
58410 - end -= PAGE_SIZE;
58411 +#endif
58412
58413 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
58414 start,
58415 @@ -292,7 +316,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
58416 flags & VM_WRITE ? 'w' : '-',
58417 flags & VM_EXEC ? 'x' : '-',
58418 flags & VM_MAYSHARE ? 's' : 'p',
58419 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58420 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
58421 +#else
58422 pgoff,
58423 +#endif
58424 MAJOR(dev), MINOR(dev), ino, &len);
58425
58426 /*
58427 @@ -301,7 +329,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
58428 */
58429 if (file) {
58430 pad_len_spaces(m, len);
58431 - seq_path(m, &file->f_path, "\n");
58432 + seq_path(m, &file->f_path, "\n\\");
58433 goto done;
58434 }
58435
58436 @@ -327,8 +355,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
58437 * Thread stack in /proc/PID/task/TID/maps or
58438 * the main process stack.
58439 */
58440 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
58441 - vma->vm_end >= mm->start_stack)) {
58442 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
58443 + (vma->vm_start <= mm->start_stack &&
58444 + vma->vm_end >= mm->start_stack)) {
58445 name = "[stack]";
58446 } else {
58447 /* Thread stack in /proc/PID/maps */
58448 @@ -352,6 +381,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
58449 struct proc_maps_private *priv = m->private;
58450 struct task_struct *task = priv->task;
58451
58452 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58453 + if (current->exec_id != m->exec_id) {
58454 + gr_log_badprocpid("maps");
58455 + return 0;
58456 + }
58457 +#endif
58458 +
58459 show_map_vma(m, vma, is_pid);
58460
58461 if (m->count < m->size) /* vma is copied successfully */
58462 @@ -589,12 +625,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
58463 .private = &mss,
58464 };
58465
58466 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58467 + if (current->exec_id != m->exec_id) {
58468 + gr_log_badprocpid("smaps");
58469 + return 0;
58470 + }
58471 +#endif
58472 memset(&mss, 0, sizeof mss);
58473 - mss.vma = vma;
58474 - /* mmap_sem is held in m_start */
58475 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
58476 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
58477 -
58478 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58479 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
58480 +#endif
58481 + mss.vma = vma;
58482 + /* mmap_sem is held in m_start */
58483 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
58484 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
58485 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58486 + }
58487 +#endif
58488 show_map_vma(m, vma, is_pid);
58489
58490 seq_printf(m,
58491 @@ -612,7 +659,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
58492 "KernelPageSize: %8lu kB\n"
58493 "MMUPageSize: %8lu kB\n"
58494 "Locked: %8lu kB\n",
58495 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58496 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
58497 +#else
58498 (vma->vm_end - vma->vm_start) >> 10,
58499 +#endif
58500 mss.resident >> 10,
58501 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
58502 mss.shared_clean >> 10,
58503 @@ -1264,6 +1315,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
58504 int n;
58505 char buffer[50];
58506
58507 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58508 + if (current->exec_id != m->exec_id) {
58509 + gr_log_badprocpid("numa_maps");
58510 + return 0;
58511 + }
58512 +#endif
58513 +
58514 if (!mm)
58515 return 0;
58516
58517 @@ -1281,11 +1339,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
58518 mpol_to_str(buffer, sizeof(buffer), pol);
58519 mpol_cond_put(pol);
58520
58521 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58522 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
58523 +#else
58524 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
58525 +#endif
58526
58527 if (file) {
58528 seq_printf(m, " file=");
58529 - seq_path(m, &file->f_path, "\n\t= ");
58530 + seq_path(m, &file->f_path, "\n\t\\= ");
58531 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
58532 seq_printf(m, " heap");
58533 } else {
58534 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
58535 index 56123a6..5a2f6ec 100644
58536 --- a/fs/proc/task_nommu.c
58537 +++ b/fs/proc/task_nommu.c
58538 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
58539 else
58540 bytes += kobjsize(mm);
58541
58542 - if (current->fs && current->fs->users > 1)
58543 + if (current->fs && atomic_read(&current->fs->users) > 1)
58544 sbytes += kobjsize(current->fs);
58545 else
58546 bytes += kobjsize(current->fs);
58547 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
58548
58549 if (file) {
58550 pad_len_spaces(m, len);
58551 - seq_path(m, &file->f_path, "");
58552 + seq_path(m, &file->f_path, "\n\\");
58553 } else if (mm) {
58554 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
58555
58556 diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
58557 index 17f7e08..e4b1529 100644
58558 --- a/fs/proc/vmcore.c
58559 +++ b/fs/proc/vmcore.c
58560 @@ -99,9 +99,13 @@ static ssize_t read_from_oldmem(char *buf, size_t count,
58561 nr_bytes = count;
58562
58563 /* If pfn is not ram, return zeros for sparse dump files */
58564 - if (pfn_is_ram(pfn) == 0)
58565 - memset(buf, 0, nr_bytes);
58566 - else {
58567 + if (pfn_is_ram(pfn) == 0) {
58568 + if (userbuf) {
58569 + if (clear_user((char __force_user *)buf, nr_bytes))
58570 + return -EFAULT;
58571 + } else
58572 + memset(buf, 0, nr_bytes);
58573 + } else {
58574 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
58575 offset, userbuf);
58576 if (tmp < 0)
58577 @@ -186,7 +190,7 @@ static ssize_t read_vmcore(struct file *file, char __user *buffer,
58578 if (tsz > nr_bytes)
58579 tsz = nr_bytes;
58580
58581 - tmp = read_from_oldmem(buffer, tsz, &start, 1);
58582 + tmp = read_from_oldmem((char __force_kernel *)buffer, tsz, &start, 1);
58583 if (tmp < 0)
58584 return tmp;
58585 buflen -= tsz;
58586 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
58587 index b00fcc9..e0c6381 100644
58588 --- a/fs/qnx6/qnx6.h
58589 +++ b/fs/qnx6/qnx6.h
58590 @@ -74,7 +74,7 @@ enum {
58591 BYTESEX_BE,
58592 };
58593
58594 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
58595 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
58596 {
58597 if (sbi->s_bytesex == BYTESEX_LE)
58598 return le64_to_cpu((__force __le64)n);
58599 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
58600 return (__force __fs64)cpu_to_be64(n);
58601 }
58602
58603 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
58604 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
58605 {
58606 if (sbi->s_bytesex == BYTESEX_LE)
58607 return le32_to_cpu((__force __le32)n);
58608 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
58609 index 16e8abb..2dcf914 100644
58610 --- a/fs/quota/netlink.c
58611 +++ b/fs/quota/netlink.c
58612 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
58613 void quota_send_warning(struct kqid qid, dev_t dev,
58614 const char warntype)
58615 {
58616 - static atomic_t seq;
58617 + static atomic_unchecked_t seq;
58618 struct sk_buff *skb;
58619 void *msg_head;
58620 int ret;
58621 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
58622 "VFS: Not enough memory to send quota warning.\n");
58623 return;
58624 }
58625 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
58626 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
58627 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
58628 if (!msg_head) {
58629 printk(KERN_ERR
58630 diff --git a/fs/read_write.c b/fs/read_write.c
58631 index 2cefa41..c7e2fe0 100644
58632 --- a/fs/read_write.c
58633 +++ b/fs/read_write.c
58634 @@ -411,7 +411,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
58635
58636 old_fs = get_fs();
58637 set_fs(get_ds());
58638 - p = (__force const char __user *)buf;
58639 + p = (const char __force_user *)buf;
58640 if (count > MAX_RW_COUNT)
58641 count = MAX_RW_COUNT;
58642 if (file->f_op->write)
58643 diff --git a/fs/readdir.c b/fs/readdir.c
58644 index fee38e0..12fdf47 100644
58645 --- a/fs/readdir.c
58646 +++ b/fs/readdir.c
58647 @@ -17,6 +17,7 @@
58648 #include <linux/security.h>
58649 #include <linux/syscalls.h>
58650 #include <linux/unistd.h>
58651 +#include <linux/namei.h>
58652
58653 #include <asm/uaccess.h>
58654
58655 @@ -67,6 +68,7 @@ struct old_linux_dirent {
58656
58657 struct readdir_callback {
58658 struct old_linux_dirent __user * dirent;
58659 + struct file * file;
58660 int result;
58661 };
58662
58663 @@ -84,6 +86,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
58664 buf->result = -EOVERFLOW;
58665 return -EOVERFLOW;
58666 }
58667 +
58668 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
58669 + return 0;
58670 +
58671 buf->result++;
58672 dirent = buf->dirent;
58673 if (!access_ok(VERIFY_WRITE, dirent,
58674 @@ -114,6 +120,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
58675
58676 buf.result = 0;
58677 buf.dirent = dirent;
58678 + buf.file = f.file;
58679
58680 error = vfs_readdir(f.file, fillonedir, &buf);
58681 if (buf.result)
58682 @@ -139,6 +146,7 @@ struct linux_dirent {
58683 struct getdents_callback {
58684 struct linux_dirent __user * current_dir;
58685 struct linux_dirent __user * previous;
58686 + struct file * file;
58687 int count;
58688 int error;
58689 };
58690 @@ -160,6 +168,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
58691 buf->error = -EOVERFLOW;
58692 return -EOVERFLOW;
58693 }
58694 +
58695 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
58696 + return 0;
58697 +
58698 dirent = buf->previous;
58699 if (dirent) {
58700 if (__put_user(offset, &dirent->d_off))
58701 @@ -205,6 +217,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
58702 buf.previous = NULL;
58703 buf.count = count;
58704 buf.error = 0;
58705 + buf.file = f.file;
58706
58707 error = vfs_readdir(f.file, filldir, &buf);
58708 if (error >= 0)
58709 @@ -223,6 +236,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
58710 struct getdents_callback64 {
58711 struct linux_dirent64 __user * current_dir;
58712 struct linux_dirent64 __user * previous;
58713 + struct file *file;
58714 int count;
58715 int error;
58716 };
58717 @@ -238,6 +252,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
58718 buf->error = -EINVAL; /* only used if we fail.. */
58719 if (reclen > buf->count)
58720 return -EINVAL;
58721 +
58722 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
58723 + return 0;
58724 +
58725 dirent = buf->previous;
58726 if (dirent) {
58727 if (__put_user(offset, &dirent->d_off))
58728 @@ -283,6 +301,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
58729
58730 buf.current_dir = dirent;
58731 buf.previous = NULL;
58732 + buf.file = f.file;
58733 buf.count = count;
58734 buf.error = 0;
58735
58736 @@ -291,7 +310,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
58737 error = buf.error;
58738 lastdirent = buf.previous;
58739 if (lastdirent) {
58740 - typeof(lastdirent->d_off) d_off = f.file->f_pos;
58741 + typeof(((struct linux_dirent64 *)0)->d_off) d_off = f.file->f_pos;
58742 if (__put_user(d_off, &lastdirent->d_off))
58743 error = -EFAULT;
58744 else
58745 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
58746 index 2b7882b..1c5ef48 100644
58747 --- a/fs/reiserfs/do_balan.c
58748 +++ b/fs/reiserfs/do_balan.c
58749 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
58750 return;
58751 }
58752
58753 - atomic_inc(&(fs_generation(tb->tb_sb)));
58754 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
58755 do_balance_starts(tb);
58756
58757 /* balance leaf returns 0 except if combining L R and S into
58758 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
58759 index 1d48974..2f8f4e0 100644
58760 --- a/fs/reiserfs/procfs.c
58761 +++ b/fs/reiserfs/procfs.c
58762 @@ -114,7 +114,7 @@ static int show_super(struct seq_file *m, void *unused)
58763 "SMALL_TAILS " : "NO_TAILS ",
58764 replay_only(sb) ? "REPLAY_ONLY " : "",
58765 convert_reiserfs(sb) ? "CONV " : "",
58766 - atomic_read(&r->s_generation_counter),
58767 + atomic_read_unchecked(&r->s_generation_counter),
58768 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
58769 SF(s_do_balance), SF(s_unneeded_left_neighbor),
58770 SF(s_good_search_by_key_reada), SF(s_bmaps),
58771 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
58772 index 157e474..65a6114 100644
58773 --- a/fs/reiserfs/reiserfs.h
58774 +++ b/fs/reiserfs/reiserfs.h
58775 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
58776 /* Comment? -Hans */
58777 wait_queue_head_t s_wait;
58778 /* To be obsoleted soon by per buffer seals.. -Hans */
58779 - atomic_t s_generation_counter; // increased by one every time the
58780 + atomic_unchecked_t s_generation_counter; // increased by one every time the
58781 // tree gets re-balanced
58782 unsigned long s_properties; /* File system properties. Currently holds
58783 on-disk FS format */
58784 @@ -1978,7 +1978,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
58785 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
58786
58787 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
58788 -#define get_generation(s) atomic_read (&fs_generation(s))
58789 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
58790 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
58791 #define __fs_changed(gen,s) (gen != get_generation (s))
58792 #define fs_changed(gen,s) \
58793 diff --git a/fs/select.c b/fs/select.c
58794 index 8c1c96c..a0f9b6d 100644
58795 --- a/fs/select.c
58796 +++ b/fs/select.c
58797 @@ -20,6 +20,7 @@
58798 #include <linux/export.h>
58799 #include <linux/slab.h>
58800 #include <linux/poll.h>
58801 +#include <linux/security.h>
58802 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
58803 #include <linux/file.h>
58804 #include <linux/fdtable.h>
58805 @@ -827,6 +828,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
58806 struct poll_list *walk = head;
58807 unsigned long todo = nfds;
58808
58809 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
58810 if (nfds > rlimit(RLIMIT_NOFILE))
58811 return -EINVAL;
58812
58813 diff --git a/fs/seq_file.c b/fs/seq_file.c
58814 index 774c1eb..b67582a 100644
58815 --- a/fs/seq_file.c
58816 +++ b/fs/seq_file.c
58817 @@ -10,6 +10,7 @@
58818 #include <linux/seq_file.h>
58819 #include <linux/slab.h>
58820 #include <linux/cred.h>
58821 +#include <linux/sched.h>
58822
58823 #include <asm/uaccess.h>
58824 #include <asm/page.h>
58825 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
58826 #ifdef CONFIG_USER_NS
58827 p->user_ns = file->f_cred->user_ns;
58828 #endif
58829 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
58830 + p->exec_id = current->exec_id;
58831 +#endif
58832
58833 /*
58834 * Wrappers around seq_open(e.g. swaps_open) need to be
58835 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
58836 return 0;
58837 }
58838 if (!m->buf) {
58839 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
58840 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
58841 if (!m->buf)
58842 return -ENOMEM;
58843 }
58844 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
58845 Eoverflow:
58846 m->op->stop(m, p);
58847 kfree(m->buf);
58848 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
58849 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
58850 return !m->buf ? -ENOMEM : -EAGAIN;
58851 }
58852
58853 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
58854
58855 /* grab buffer if we didn't have one */
58856 if (!m->buf) {
58857 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
58858 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
58859 if (!m->buf)
58860 goto Enomem;
58861 }
58862 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
58863 goto Fill;
58864 m->op->stop(m, p);
58865 kfree(m->buf);
58866 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
58867 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
58868 if (!m->buf)
58869 goto Enomem;
58870 m->count = 0;
58871 @@ -581,7 +585,7 @@ static void single_stop(struct seq_file *p, void *v)
58872 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
58873 void *data)
58874 {
58875 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
58876 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
58877 int res = -ENOMEM;
58878
58879 if (op) {
58880 diff --git a/fs/splice.c b/fs/splice.c
58881 index d37431d..81c3044 100644
58882 --- a/fs/splice.c
58883 +++ b/fs/splice.c
58884 @@ -196,7 +196,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
58885 pipe_lock(pipe);
58886
58887 for (;;) {
58888 - if (!pipe->readers) {
58889 + if (!atomic_read(&pipe->readers)) {
58890 send_sig(SIGPIPE, current, 0);
58891 if (!ret)
58892 ret = -EPIPE;
58893 @@ -219,7 +219,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
58894 page_nr++;
58895 ret += buf->len;
58896
58897 - if (pipe->files)
58898 + if (atomic_read(&pipe->files))
58899 do_wakeup = 1;
58900
58901 if (!--spd->nr_pages)
58902 @@ -250,9 +250,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
58903 do_wakeup = 0;
58904 }
58905
58906 - pipe->waiting_writers++;
58907 + atomic_inc(&pipe->waiting_writers);
58908 pipe_wait(pipe);
58909 - pipe->waiting_writers--;
58910 + atomic_dec(&pipe->waiting_writers);
58911 }
58912
58913 pipe_unlock(pipe);
58914 @@ -565,7 +565,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
58915 old_fs = get_fs();
58916 set_fs(get_ds());
58917 /* The cast to a user pointer is valid due to the set_fs() */
58918 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
58919 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
58920 set_fs(old_fs);
58921
58922 return res;
58923 @@ -580,7 +580,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
58924 old_fs = get_fs();
58925 set_fs(get_ds());
58926 /* The cast to a user pointer is valid due to the set_fs() */
58927 - res = vfs_write(file, (__force const char __user *)buf, count, &pos);
58928 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
58929 set_fs(old_fs);
58930
58931 return res;
58932 @@ -633,7 +633,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
58933 goto err;
58934
58935 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
58936 - vec[i].iov_base = (void __user *) page_address(page);
58937 + vec[i].iov_base = (void __force_user *) page_address(page);
58938 vec[i].iov_len = this_len;
58939 spd.pages[i] = page;
58940 spd.nr_pages++;
58941 @@ -829,7 +829,7 @@ int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_desc *sd,
58942 ops->release(pipe, buf);
58943 pipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1);
58944 pipe->nrbufs--;
58945 - if (pipe->files)
58946 + if (atomic_read(&pipe->files))
58947 sd->need_wakeup = true;
58948 }
58949
58950 @@ -854,10 +854,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
58951 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
58952 {
58953 while (!pipe->nrbufs) {
58954 - if (!pipe->writers)
58955 + if (!atomic_read(&pipe->writers))
58956 return 0;
58957
58958 - if (!pipe->waiting_writers && sd->num_spliced)
58959 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
58960 return 0;
58961
58962 if (sd->flags & SPLICE_F_NONBLOCK)
58963 @@ -1193,7 +1193,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
58964 * out of the pipe right after the splice_to_pipe(). So set
58965 * PIPE_READERS appropriately.
58966 */
58967 - pipe->readers = 1;
58968 + atomic_set(&pipe->readers, 1);
58969
58970 current->splice_pipe = pipe;
58971 }
58972 @@ -1769,9 +1769,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
58973 ret = -ERESTARTSYS;
58974 break;
58975 }
58976 - if (!pipe->writers)
58977 + if (!atomic_read(&pipe->writers))
58978 break;
58979 - if (!pipe->waiting_writers) {
58980 + if (!atomic_read(&pipe->waiting_writers)) {
58981 if (flags & SPLICE_F_NONBLOCK) {
58982 ret = -EAGAIN;
58983 break;
58984 @@ -1803,7 +1803,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
58985 pipe_lock(pipe);
58986
58987 while (pipe->nrbufs >= pipe->buffers) {
58988 - if (!pipe->readers) {
58989 + if (!atomic_read(&pipe->readers)) {
58990 send_sig(SIGPIPE, current, 0);
58991 ret = -EPIPE;
58992 break;
58993 @@ -1816,9 +1816,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
58994 ret = -ERESTARTSYS;
58995 break;
58996 }
58997 - pipe->waiting_writers++;
58998 + atomic_inc(&pipe->waiting_writers);
58999 pipe_wait(pipe);
59000 - pipe->waiting_writers--;
59001 + atomic_dec(&pipe->waiting_writers);
59002 }
59003
59004 pipe_unlock(pipe);
59005 @@ -1854,14 +1854,14 @@ retry:
59006 pipe_double_lock(ipipe, opipe);
59007
59008 do {
59009 - if (!opipe->readers) {
59010 + if (!atomic_read(&opipe->readers)) {
59011 send_sig(SIGPIPE, current, 0);
59012 if (!ret)
59013 ret = -EPIPE;
59014 break;
59015 }
59016
59017 - if (!ipipe->nrbufs && !ipipe->writers)
59018 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
59019 break;
59020
59021 /*
59022 @@ -1958,7 +1958,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
59023 pipe_double_lock(ipipe, opipe);
59024
59025 do {
59026 - if (!opipe->readers) {
59027 + if (!atomic_read(&opipe->readers)) {
59028 send_sig(SIGPIPE, current, 0);
59029 if (!ret)
59030 ret = -EPIPE;
59031 @@ -2003,7 +2003,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
59032 * return EAGAIN if we have the potential of some data in the
59033 * future, otherwise just return 0
59034 */
59035 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
59036 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
59037 ret = -EAGAIN;
59038
59039 pipe_unlock(ipipe);
59040 diff --git a/fs/stat.c b/fs/stat.c
59041 index 04ce1ac..a13dd1e 100644
59042 --- a/fs/stat.c
59043 +++ b/fs/stat.c
59044 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
59045 stat->gid = inode->i_gid;
59046 stat->rdev = inode->i_rdev;
59047 stat->size = i_size_read(inode);
59048 - stat->atime = inode->i_atime;
59049 - stat->mtime = inode->i_mtime;
59050 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
59051 + stat->atime = inode->i_ctime;
59052 + stat->mtime = inode->i_ctime;
59053 + } else {
59054 + stat->atime = inode->i_atime;
59055 + stat->mtime = inode->i_mtime;
59056 + }
59057 stat->ctime = inode->i_ctime;
59058 stat->blksize = (1 << inode->i_blkbits);
59059 stat->blocks = inode->i_blocks;
59060 @@ -46,8 +51,14 @@ int vfs_getattr(struct path *path, struct kstat *stat)
59061 if (retval)
59062 return retval;
59063
59064 - if (inode->i_op->getattr)
59065 - return inode->i_op->getattr(path->mnt, path->dentry, stat);
59066 + if (inode->i_op->getattr) {
59067 + retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
59068 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
59069 + stat->atime = stat->ctime;
59070 + stat->mtime = stat->ctime;
59071 + }
59072 + return retval;
59073 + }
59074
59075 generic_fillattr(inode, stat);
59076 return 0;
59077 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
59078 index 15c68f9..36a8b3e 100644
59079 --- a/fs/sysfs/bin.c
59080 +++ b/fs/sysfs/bin.c
59081 @@ -235,13 +235,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
59082 return ret;
59083 }
59084
59085 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
59086 - void *buf, int len, int write)
59087 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
59088 + void *buf, size_t len, int write)
59089 {
59090 struct file *file = vma->vm_file;
59091 struct bin_buffer *bb = file->private_data;
59092 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
59093 - int ret;
59094 + ssize_t ret;
59095
59096 if (!bb->vm_ops)
59097 return -EINVAL;
59098 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
59099 index e8e0e71..79c28ac5 100644
59100 --- a/fs/sysfs/dir.c
59101 +++ b/fs/sysfs/dir.c
59102 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
59103 *
59104 * Returns 31 bit hash of ns + name (so it fits in an off_t )
59105 */
59106 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
59107 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
59108 {
59109 unsigned long hash = init_name_hash();
59110 unsigned int len = strlen(name);
59111 @@ -679,6 +679,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
59112 struct sysfs_dirent *sd;
59113 int rc;
59114
59115 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
59116 + const char *parent_name = parent_sd->s_name;
59117 +
59118 + mode = S_IFDIR | S_IRWXU;
59119 +
59120 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
59121 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
59122 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse") || !strcmp(name, "ecryptfs"))) ||
59123 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
59124 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
59125 +#endif
59126 +
59127 /* allocate */
59128 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
59129 if (!sd)
59130 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
59131 index 602f56d..6853db8 100644
59132 --- a/fs/sysfs/file.c
59133 +++ b/fs/sysfs/file.c
59134 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
59135
59136 struct sysfs_open_dirent {
59137 atomic_t refcnt;
59138 - atomic_t event;
59139 + atomic_unchecked_t event;
59140 wait_queue_head_t poll;
59141 struct list_head buffers; /* goes through sysfs_buffer.list */
59142 };
59143 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
59144 if (!sysfs_get_active(attr_sd))
59145 return -ENODEV;
59146
59147 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
59148 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
59149 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
59150
59151 sysfs_put_active(attr_sd);
59152 @@ -287,7 +287,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
59153 return -ENOMEM;
59154
59155 atomic_set(&new_od->refcnt, 0);
59156 - atomic_set(&new_od->event, 1);
59157 + atomic_set_unchecked(&new_od->event, 1);
59158 init_waitqueue_head(&new_od->poll);
59159 INIT_LIST_HEAD(&new_od->buffers);
59160 goto retry;
59161 @@ -432,7 +432,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
59162
59163 sysfs_put_active(attr_sd);
59164
59165 - if (buffer->event != atomic_read(&od->event))
59166 + if (buffer->event != atomic_read_unchecked(&od->event))
59167 goto trigger;
59168
59169 return DEFAULT_POLLMASK;
59170 @@ -451,7 +451,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
59171
59172 od = sd->s_attr.open;
59173 if (od) {
59174 - atomic_inc(&od->event);
59175 + atomic_inc_unchecked(&od->event);
59176 wake_up_interruptible(&od->poll);
59177 }
59178
59179 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
59180 index 8c940df..25b733e 100644
59181 --- a/fs/sysfs/symlink.c
59182 +++ b/fs/sysfs/symlink.c
59183 @@ -305,7 +305,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
59184
59185 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
59186 {
59187 - char *page = nd_get_link(nd);
59188 + const char *page = nd_get_link(nd);
59189 if (!IS_ERR(page))
59190 free_page((unsigned long)page);
59191 }
59192 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
59193 index 69d4889..a810bd4 100644
59194 --- a/fs/sysv/sysv.h
59195 +++ b/fs/sysv/sysv.h
59196 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
59197 #endif
59198 }
59199
59200 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
59201 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
59202 {
59203 if (sbi->s_bytesex == BYTESEX_PDP)
59204 return PDP_swab((__force __u32)n);
59205 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
59206 index e18b988..f1d4ad0f 100644
59207 --- a/fs/ubifs/io.c
59208 +++ b/fs/ubifs/io.c
59209 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
59210 return err;
59211 }
59212
59213 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
59214 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
59215 {
59216 int err;
59217
59218 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
59219 index c175b4d..8f36a16 100644
59220 --- a/fs/udf/misc.c
59221 +++ b/fs/udf/misc.c
59222 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
59223
59224 u8 udf_tag_checksum(const struct tag *t)
59225 {
59226 - u8 *data = (u8 *)t;
59227 + const u8 *data = (const u8 *)t;
59228 u8 checksum = 0;
59229 int i;
59230 for (i = 0; i < sizeof(struct tag); ++i)
59231 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
59232 index 8d974c4..b82f6ec 100644
59233 --- a/fs/ufs/swab.h
59234 +++ b/fs/ufs/swab.h
59235 @@ -22,7 +22,7 @@ enum {
59236 BYTESEX_BE
59237 };
59238
59239 -static inline u64
59240 +static inline u64 __intentional_overflow(-1)
59241 fs64_to_cpu(struct super_block *sbp, __fs64 n)
59242 {
59243 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
59244 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
59245 return (__force __fs64)cpu_to_be64(n);
59246 }
59247
59248 -static inline u32
59249 +static inline u32 __intentional_overflow(-1)
59250 fs32_to_cpu(struct super_block *sbp, __fs32 n)
59251 {
59252 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
59253 diff --git a/fs/utimes.c b/fs/utimes.c
59254 index f4fb7ec..3fe03c0 100644
59255 --- a/fs/utimes.c
59256 +++ b/fs/utimes.c
59257 @@ -1,6 +1,7 @@
59258 #include <linux/compiler.h>
59259 #include <linux/file.h>
59260 #include <linux/fs.h>
59261 +#include <linux/security.h>
59262 #include <linux/linkage.h>
59263 #include <linux/mount.h>
59264 #include <linux/namei.h>
59265 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
59266 goto mnt_drop_write_and_out;
59267 }
59268 }
59269 +
59270 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
59271 + error = -EACCES;
59272 + goto mnt_drop_write_and_out;
59273 + }
59274 +
59275 mutex_lock(&inode->i_mutex);
59276 error = notify_change(path->dentry, &newattrs);
59277 mutex_unlock(&inode->i_mutex);
59278 diff --git a/fs/xattr.c b/fs/xattr.c
59279 index 3377dff..4d074d9 100644
59280 --- a/fs/xattr.c
59281 +++ b/fs/xattr.c
59282 @@ -227,6 +227,27 @@ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
59283 return rc;
59284 }
59285
59286 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
59287 +ssize_t
59288 +pax_getxattr(struct dentry *dentry, void *value, size_t size)
59289 +{
59290 + struct inode *inode = dentry->d_inode;
59291 + ssize_t error;
59292 +
59293 + error = inode_permission(inode, MAY_EXEC);
59294 + if (error)
59295 + return error;
59296 +
59297 + if (inode->i_op->getxattr)
59298 + error = inode->i_op->getxattr(dentry, XATTR_NAME_PAX_FLAGS, value, size);
59299 + else
59300 + error = -EOPNOTSUPP;
59301 +
59302 + return error;
59303 +}
59304 +EXPORT_SYMBOL(pax_getxattr);
59305 +#endif
59306 +
59307 ssize_t
59308 vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
59309 {
59310 @@ -319,7 +340,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
59311 * Extended attribute SET operations
59312 */
59313 static long
59314 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
59315 +setxattr(struct path *path, const char __user *name, const void __user *value,
59316 size_t size, int flags)
59317 {
59318 int error;
59319 @@ -355,7 +376,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
59320 posix_acl_fix_xattr_from_user(kvalue, size);
59321 }
59322
59323 - error = vfs_setxattr(d, kname, kvalue, size, flags);
59324 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
59325 + error = -EACCES;
59326 + goto out;
59327 + }
59328 +
59329 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
59330 out:
59331 if (vvalue)
59332 vfree(vvalue);
59333 @@ -377,7 +403,7 @@ retry:
59334 return error;
59335 error = mnt_want_write(path.mnt);
59336 if (!error) {
59337 - error = setxattr(path.dentry, name, value, size, flags);
59338 + error = setxattr(&path, name, value, size, flags);
59339 mnt_drop_write(path.mnt);
59340 }
59341 path_put(&path);
59342 @@ -401,7 +427,7 @@ retry:
59343 return error;
59344 error = mnt_want_write(path.mnt);
59345 if (!error) {
59346 - error = setxattr(path.dentry, name, value, size, flags);
59347 + error = setxattr(&path, name, value, size, flags);
59348 mnt_drop_write(path.mnt);
59349 }
59350 path_put(&path);
59351 @@ -416,16 +442,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
59352 const void __user *,value, size_t, size, int, flags)
59353 {
59354 struct fd f = fdget(fd);
59355 - struct dentry *dentry;
59356 int error = -EBADF;
59357
59358 if (!f.file)
59359 return error;
59360 - dentry = f.file->f_path.dentry;
59361 - audit_inode(NULL, dentry, 0);
59362 + audit_inode(NULL, f.file->f_path.dentry, 0);
59363 error = mnt_want_write_file(f.file);
59364 if (!error) {
59365 - error = setxattr(dentry, name, value, size, flags);
59366 + error = setxattr(&f.file->f_path, name, value, size, flags);
59367 mnt_drop_write_file(f.file);
59368 }
59369 fdput(f);
59370 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
59371 index 9fbea87..6b19972 100644
59372 --- a/fs/xattr_acl.c
59373 +++ b/fs/xattr_acl.c
59374 @@ -76,8 +76,8 @@ struct posix_acl *
59375 posix_acl_from_xattr(struct user_namespace *user_ns,
59376 const void *value, size_t size)
59377 {
59378 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
59379 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
59380 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
59381 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
59382 int count;
59383 struct posix_acl *acl;
59384 struct posix_acl_entry *acl_e;
59385 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
59386 index 8904284..ee0e14b 100644
59387 --- a/fs/xfs/xfs_bmap.c
59388 +++ b/fs/xfs/xfs_bmap.c
59389 @@ -765,7 +765,7 @@ xfs_bmap_validate_ret(
59390
59391 #else
59392 #define xfs_bmap_check_leaf_extents(cur, ip, whichfork) do { } while (0)
59393 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
59394 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do { } while (0)
59395 #endif /* DEBUG */
59396
59397 /*
59398 diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
59399 index 6157424..ac98f6d 100644
59400 --- a/fs/xfs/xfs_dir2_sf.c
59401 +++ b/fs/xfs/xfs_dir2_sf.c
59402 @@ -851,7 +851,15 @@ xfs_dir2_sf_getdents(
59403 }
59404
59405 ino = xfs_dir2_sfe_get_ino(sfp, sfep);
59406 - if (filldir(dirent, (char *)sfep->name, sfep->namelen,
59407 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
59408 + char name[sfep->namelen];
59409 + memcpy(name, sfep->name, sfep->namelen);
59410 + if (filldir(dirent, name, sfep->namelen,
59411 + off & 0x7fffffff, ino, DT_UNKNOWN)) {
59412 + *offset = off & 0x7fffffff;
59413 + return 0;
59414 + }
59415 + } else if (filldir(dirent, (char *)sfep->name, sfep->namelen,
59416 off & 0x7fffffff, ino, DT_UNKNOWN)) {
59417 *offset = off & 0x7fffffff;
59418 return 0;
59419 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
59420 index 5e99968..45bd327 100644
59421 --- a/fs/xfs/xfs_ioctl.c
59422 +++ b/fs/xfs/xfs_ioctl.c
59423 @@ -127,7 +127,7 @@ xfs_find_handle(
59424 }
59425
59426 error = -EFAULT;
59427 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
59428 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
59429 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
59430 goto out_put;
59431
59432 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
59433 index ca9ecaa..60100c7 100644
59434 --- a/fs/xfs/xfs_iops.c
59435 +++ b/fs/xfs/xfs_iops.c
59436 @@ -395,7 +395,7 @@ xfs_vn_put_link(
59437 struct nameidata *nd,
59438 void *p)
59439 {
59440 - char *s = nd_get_link(nd);
59441 + const char *s = nd_get_link(nd);
59442
59443 if (!IS_ERR(s))
59444 kfree(s);
59445 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
59446 new file mode 100644
59447 index 0000000..712a85d
59448 --- /dev/null
59449 +++ b/grsecurity/Kconfig
59450 @@ -0,0 +1,1043 @@
59451 +#
59452 +# grecurity configuration
59453 +#
59454 +menu "Memory Protections"
59455 +depends on GRKERNSEC
59456 +
59457 +config GRKERNSEC_KMEM
59458 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
59459 + default y if GRKERNSEC_CONFIG_AUTO
59460 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
59461 + help
59462 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
59463 + be written to or read from to modify or leak the contents of the running
59464 + kernel. /dev/port will also not be allowed to be opened and support
59465 + for /dev/cpu/*/msr will be removed. If you have module
59466 + support disabled, enabling this will close up five ways that are
59467 + currently used to insert malicious code into the running kernel.
59468 +
59469 + Even with all these features enabled, we still highly recommend that
59470 + you use the RBAC system, as it is still possible for an attacker to
59471 + modify the running kernel through privileged I/O granted by ioperm/iopl.
59472 +
59473 + If you are not using XFree86, you may be able to stop this additional
59474 + case by enabling the 'Disable privileged I/O' option. Though nothing
59475 + legitimately writes to /dev/kmem, XFree86 does need to write to /dev/mem,
59476 + but only to video memory, which is the only writing we allow in this
59477 + case. If /dev/kmem or /dev/mem are mmaped without PROT_WRITE, they will
59478 + not be allowed to mprotect it with PROT_WRITE later.
59479 + Enabling this feature will prevent the "cpupower" and "powertop" tools
59480 + from working.
59481 +
59482 + It is highly recommended that you say Y here if you meet all the
59483 + conditions above.
59484 +
59485 +config GRKERNSEC_VM86
59486 + bool "Restrict VM86 mode"
59487 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
59488 + depends on X86_32
59489 +
59490 + help
59491 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
59492 + make use of a special execution mode on 32bit x86 processors called
59493 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
59494 + video cards and will still work with this option enabled. The purpose
59495 + of the option is to prevent exploitation of emulation errors in
59496 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
59497 + Nearly all users should be able to enable this option.
59498 +
59499 +config GRKERNSEC_IO
59500 + bool "Disable privileged I/O"
59501 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
59502 + depends on X86
59503 + select RTC_CLASS
59504 + select RTC_INTF_DEV
59505 + select RTC_DRV_CMOS
59506 +
59507 + help
59508 + If you say Y here, all ioperm and iopl calls will return an error.
59509 + Ioperm and iopl can be used to modify the running kernel.
59510 + Unfortunately, some programs need this access to operate properly,
59511 + the most notable of which are XFree86 and hwclock. hwclock can be
59512 + remedied by having RTC support in the kernel, so real-time
59513 + clock support is enabled if this option is enabled, to ensure
59514 + that hwclock operates correctly. XFree86 still will not
59515 + operate correctly with this option enabled, so DO NOT CHOOSE Y
59516 + IF YOU USE XFree86. If you use XFree86 and you still want to
59517 + protect your kernel against modification, use the RBAC system.
59518 +
59519 +config GRKERNSEC_JIT_HARDEN
59520 + bool "Harden BPF JIT against spray attacks"
59521 + default y if GRKERNSEC_CONFIG_AUTO
59522 + depends on BPF_JIT
59523 + help
59524 + If you say Y here, the native code generated by the kernel's Berkeley
59525 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
59526 + attacks that attempt to fit attacker-beneficial instructions in
59527 + 32bit immediate fields of JIT-generated native instructions. The
59528 + attacker will generally aim to cause an unintended instruction sequence
59529 + of JIT-generated native code to execute by jumping into the middle of
59530 + a generated instruction. This feature effectively randomizes the 32bit
59531 + immediate constants present in the generated code to thwart such attacks.
59532 +
59533 + If you're using KERNEXEC, it's recommended that you enable this option
59534 + to supplement the hardening of the kernel.
59535 +
59536 +config GRKERNSEC_PERF_HARDEN
59537 + bool "Disable unprivileged PERF_EVENTS usage by default"
59538 + default y if GRKERNSEC_CONFIG_AUTO
59539 + depends on PERF_EVENTS
59540 + help
59541 + If you say Y here, the range of acceptable values for the
59542 + /proc/sys/kernel/perf_event_paranoid sysctl will be expanded to allow and
59543 + default to a new value: 3. When the sysctl is set to this value, no
59544 + unprivileged use of the PERF_EVENTS syscall interface will be permitted.
59545 +
59546 + Though PERF_EVENTS can be used legitimately for performance monitoring
59547 + and low-level application profiling, it is forced on regardless of
59548 + configuration, has been at fault for several vulnerabilities, and
59549 + creates new opportunities for side channels and other information leaks.
59550 +
59551 + This feature puts PERF_EVENTS into a secure default state and permits
59552 + the administrator to change out of it temporarily if unprivileged
59553 + application profiling is needed.
59554 +
59555 +config GRKERNSEC_RAND_THREADSTACK
59556 + bool "Insert random gaps between thread stacks"
59557 + default y if GRKERNSEC_CONFIG_AUTO
59558 + depends on PAX_RANDMMAP && !PPC
59559 + help
59560 + If you say Y here, a random-sized gap will be enforced between allocated
59561 + thread stacks. Glibc's NPTL and other threading libraries that
59562 + pass MAP_STACK to the kernel for thread stack allocation are supported.
59563 + The implementation currently provides 8 bits of entropy for the gap.
59564 +
59565 + Many distributions do not compile threaded remote services with the
59566 + -fstack-check argument to GCC, causing the variable-sized stack-based
59567 + allocator, alloca(), to not probe the stack on allocation. This
59568 + permits an unbounded alloca() to skip over any guard page and potentially
59569 + modify another thread's stack reliably. An enforced random gap
59570 + reduces the reliability of such an attack and increases the chance
59571 + that such a read/write to another thread's stack instead lands in
59572 + an unmapped area, causing a crash and triggering grsecurity's
59573 + anti-bruteforcing logic.
59574 +
59575 +config GRKERNSEC_PROC_MEMMAP
59576 + bool "Harden ASLR against information leaks and entropy reduction"
59577 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
59578 + depends on PAX_NOEXEC || PAX_ASLR
59579 + help
59580 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
59581 + give no information about the addresses of its mappings if
59582 + PaX features that rely on random addresses are enabled on the task.
59583 + In addition to sanitizing this information and disabling other
59584 + dangerous sources of information, this option causes reads of sensitive
59585 + /proc/<pid> entries where the file descriptor was opened in a different
59586 + task than the one performing the read. Such attempts are logged.
59587 + This option also limits argv/env strings for suid/sgid binaries
59588 + to 512KB to prevent a complete exhaustion of the stack entropy provided
59589 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
59590 + binaries to prevent alternative mmap layouts from being abused.
59591 +
59592 + If you use PaX it is essential that you say Y here as it closes up
59593 + several holes that make full ASLR useless locally.
59594 +
59595 +config GRKERNSEC_BRUTE
59596 + bool "Deter exploit bruteforcing"
59597 + default y if GRKERNSEC_CONFIG_AUTO
59598 + help
59599 + If you say Y here, attempts to bruteforce exploits against forking
59600 + daemons such as apache or sshd, as well as against suid/sgid binaries
59601 + will be deterred. When a child of a forking daemon is killed by PaX
59602 + or crashes due to an illegal instruction or other suspicious signal,
59603 + the parent process will be delayed 30 seconds upon every subsequent
59604 + fork until the administrator is able to assess the situation and
59605 + restart the daemon.
59606 + In the suid/sgid case, the attempt is logged, the user has all their
59607 + existing instances of the suid/sgid binary terminated and will
59608 + be unable to execute any suid/sgid binaries for 15 minutes.
59609 +
59610 + It is recommended that you also enable signal logging in the auditing
59611 + section so that logs are generated when a process triggers a suspicious
59612 + signal.
59613 + If the sysctl option is enabled, a sysctl option with name
59614 + "deter_bruteforce" is created.
59615 +
59616 +
59617 +config GRKERNSEC_MODHARDEN
59618 + bool "Harden module auto-loading"
59619 + default y if GRKERNSEC_CONFIG_AUTO
59620 + depends on MODULES
59621 + help
59622 + If you say Y here, module auto-loading in response to use of some
59623 + feature implemented by an unloaded module will be restricted to
59624 + root users. Enabling this option helps defend against attacks
59625 + by unprivileged users who abuse the auto-loading behavior to
59626 + cause a vulnerable module to load that is then exploited.
59627 +
59628 + If this option prevents a legitimate use of auto-loading for a
59629 + non-root user, the administrator can execute modprobe manually
59630 + with the exact name of the module mentioned in the alert log.
59631 + Alternatively, the administrator can add the module to the list
59632 + of modules loaded at boot by modifying init scripts.
59633 +
59634 + Modification of init scripts will most likely be needed on
59635 + Ubuntu servers with encrypted home directory support enabled,
59636 + as the first non-root user logging in will cause the ecb(aes),
59637 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
59638 +
59639 +config GRKERNSEC_HIDESYM
59640 + bool "Hide kernel symbols"
59641 + default y if GRKERNSEC_CONFIG_AUTO
59642 + select PAX_USERCOPY_SLABS
59643 + help
59644 + If you say Y here, getting information on loaded modules, and
59645 + displaying all kernel symbols through a syscall will be restricted
59646 + to users with CAP_SYS_MODULE. For software compatibility reasons,
59647 + /proc/kallsyms will be restricted to the root user. The RBAC
59648 + system can hide that entry even from root.
59649 +
59650 + This option also prevents leaking of kernel addresses through
59651 + several /proc entries.
59652 +
59653 + Note that this option is only effective provided the following
59654 + conditions are met:
59655 + 1) The kernel using grsecurity is not precompiled by some distribution
59656 + 2) You have also enabled GRKERNSEC_DMESG
59657 + 3) You are using the RBAC system and hiding other files such as your
59658 + kernel image and System.map. Alternatively, enabling this option
59659 + causes the permissions on /boot, /lib/modules, and the kernel
59660 + source directory to change at compile time to prevent
59661 + reading by non-root users.
59662 + If the above conditions are met, this option will aid in providing a
59663 + useful protection against local kernel exploitation of overflows
59664 + and arbitrary read/write vulnerabilities.
59665 +
59666 + It is highly recommended that you enable GRKERNSEC_PERF_HARDEN
59667 + in addition to this feature.
59668 +
59669 +config GRKERNSEC_KERN_LOCKOUT
59670 + bool "Active kernel exploit response"
59671 + default y if GRKERNSEC_CONFIG_AUTO
59672 + depends on X86 || ARM || PPC || SPARC
59673 + help
59674 + If you say Y here, when a PaX alert is triggered due to suspicious
59675 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
59676 + or an OOPS occurs due to bad memory accesses, instead of just
59677 + terminating the offending process (and potentially allowing
59678 + a subsequent exploit from the same user), we will take one of two
59679 + actions:
59680 + If the user was root, we will panic the system
59681 + If the user was non-root, we will log the attempt, terminate
59682 + all processes owned by the user, then prevent them from creating
59683 + any new processes until the system is restarted
59684 + This deters repeated kernel exploitation/bruteforcing attempts
59685 + and is useful for later forensics.
59686 +
59687 +endmenu
59688 +menu "Role Based Access Control Options"
59689 +depends on GRKERNSEC
59690 +
59691 +config GRKERNSEC_RBAC_DEBUG
59692 + bool
59693 +
59694 +config GRKERNSEC_NO_RBAC
59695 + bool "Disable RBAC system"
59696 + help
59697 + If you say Y here, the /dev/grsec device will be removed from the kernel,
59698 + preventing the RBAC system from being enabled. You should only say Y
59699 + here if you have no intention of using the RBAC system, so as to prevent
59700 + an attacker with root access from misusing the RBAC system to hide files
59701 + and processes when loadable module support and /dev/[k]mem have been
59702 + locked down.
59703 +
59704 +config GRKERNSEC_ACL_HIDEKERN
59705 + bool "Hide kernel processes"
59706 + help
59707 + If you say Y here, all kernel threads will be hidden to all
59708 + processes but those whose subject has the "view hidden processes"
59709 + flag.
59710 +
59711 +config GRKERNSEC_ACL_MAXTRIES
59712 + int "Maximum tries before password lockout"
59713 + default 3
59714 + help
59715 + This option enforces the maximum number of times a user can attempt
59716 + to authorize themselves with the grsecurity RBAC system before being
59717 + denied the ability to attempt authorization again for a specified time.
59718 + The lower the number, the harder it will be to brute-force a password.
59719 +
59720 +config GRKERNSEC_ACL_TIMEOUT
59721 + int "Time to wait after max password tries, in seconds"
59722 + default 30
59723 + help
59724 + This option specifies the time the user must wait after attempting to
59725 + authorize to the RBAC system with the maximum number of invalid
59726 + passwords. The higher the number, the harder it will be to brute-force
59727 + a password.
59728 +
59729 +endmenu
59730 +menu "Filesystem Protections"
59731 +depends on GRKERNSEC
59732 +
59733 +config GRKERNSEC_PROC
59734 + bool "Proc restrictions"
59735 + default y if GRKERNSEC_CONFIG_AUTO
59736 + help
59737 + If you say Y here, the permissions of the /proc filesystem
59738 + will be altered to enhance system security and privacy. You MUST
59739 + choose either a user only restriction or a user and group restriction.
59740 + Depending upon the option you choose, you can either restrict users to
59741 + see only the processes they themselves run, or choose a group that can
59742 + view all processes and files normally restricted to root if you choose
59743 + the "restrict to user only" option. NOTE: If you're running identd or
59744 + ntpd as a non-root user, you will have to run it as the group you
59745 + specify here.
59746 +
59747 +config GRKERNSEC_PROC_USER
59748 + bool "Restrict /proc to user only"
59749 + depends on GRKERNSEC_PROC
59750 + help
59751 + If you say Y here, non-root users will only be able to view their own
59752 + processes, and restricts them from viewing network-related information,
59753 + and viewing kernel symbol and module information.
59754 +
59755 +config GRKERNSEC_PROC_USERGROUP
59756 + bool "Allow special group"
59757 + default y if GRKERNSEC_CONFIG_AUTO
59758 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
59759 + help
59760 + If you say Y here, you will be able to select a group that will be
59761 + able to view all processes and network-related information. If you've
59762 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
59763 + remain hidden. This option is useful if you want to run identd as
59764 + a non-root user. The group you select may also be chosen at boot time
59765 + via "grsec_proc_gid=" on the kernel commandline.
59766 +
59767 +config GRKERNSEC_PROC_GID
59768 + int "GID for special group"
59769 + depends on GRKERNSEC_PROC_USERGROUP
59770 + default 1001
59771 +
59772 +config GRKERNSEC_PROC_ADD
59773 + bool "Additional restrictions"
59774 + default y if GRKERNSEC_CONFIG_AUTO
59775 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
59776 + help
59777 + If you say Y here, additional restrictions will be placed on
59778 + /proc that keep normal users from viewing device information and
59779 + slabinfo information that could be useful for exploits.
59780 +
59781 +config GRKERNSEC_LINK
59782 + bool "Linking restrictions"
59783 + default y if GRKERNSEC_CONFIG_AUTO
59784 + help
59785 + If you say Y here, /tmp race exploits will be prevented, since users
59786 + will no longer be able to follow symlinks owned by other users in
59787 + world-writable +t directories (e.g. /tmp), unless the owner of the
59788 + symlink is the owner of the directory. users will also not be
59789 + able to hardlink to files they do not own. If the sysctl option is
59790 + enabled, a sysctl option with name "linking_restrictions" is created.
59791 +
59792 +config GRKERNSEC_SYMLINKOWN
59793 + bool "Kernel-enforced SymlinksIfOwnerMatch"
59794 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
59795 + help
59796 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
59797 + that prevents it from being used as a security feature. As Apache
59798 + verifies the symlink by performing a stat() against the target of
59799 + the symlink before it is followed, an attacker can setup a symlink
59800 + to point to a same-owned file, then replace the symlink with one
59801 + that targets another user's file just after Apache "validates" the
59802 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
59803 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
59804 + will be in place for the group you specify. If the sysctl option
59805 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
59806 + created.
59807 +
59808 +config GRKERNSEC_SYMLINKOWN_GID
59809 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
59810 + depends on GRKERNSEC_SYMLINKOWN
59811 + default 1006
59812 + help
59813 + Setting this GID determines what group kernel-enforced
59814 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
59815 + is enabled, a sysctl option with name "symlinkown_gid" is created.
59816 +
59817 +config GRKERNSEC_FIFO
59818 + bool "FIFO restrictions"
59819 + default y if GRKERNSEC_CONFIG_AUTO
59820 + help
59821 + If you say Y here, users will not be able to write to FIFOs they don't
59822 + own in world-writable +t directories (e.g. /tmp), unless the owner of
59823 + the FIFO is the same owner of the directory it's held in. If the sysctl
59824 + option is enabled, a sysctl option with name "fifo_restrictions" is
59825 + created.
59826 +
59827 +config GRKERNSEC_SYSFS_RESTRICT
59828 + bool "Sysfs/debugfs restriction"
59829 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
59830 + depends on SYSFS
59831 + help
59832 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
59833 + any filesystem normally mounted under it (e.g. debugfs) will be
59834 + mostly accessible only by root. These filesystems generally provide access
59835 + to hardware and debug information that isn't appropriate for unprivileged
59836 + users of the system. Sysfs and debugfs have also become a large source
59837 + of new vulnerabilities, ranging from infoleaks to local compromise.
59838 + There has been very little oversight with an eye toward security involved
59839 + in adding new exporters of information to these filesystems, so their
59840 + use is discouraged.
59841 + For reasons of compatibility, a few directories have been whitelisted
59842 + for access by non-root users:
59843 + /sys/fs/selinux
59844 + /sys/fs/fuse
59845 + /sys/devices/system/cpu
59846 +
59847 +config GRKERNSEC_ROFS
59848 + bool "Runtime read-only mount protection"
59849 + help
59850 + If you say Y here, a sysctl option with name "romount_protect" will
59851 + be created. By setting this option to 1 at runtime, filesystems
59852 + will be protected in the following ways:
59853 + * No new writable mounts will be allowed
59854 + * Existing read-only mounts won't be able to be remounted read/write
59855 + * Write operations will be denied on all block devices
59856 + This option acts independently of grsec_lock: once it is set to 1,
59857 + it cannot be turned off. Therefore, please be mindful of the resulting
59858 + behavior if this option is enabled in an init script on a read-only
59859 + filesystem. This feature is mainly intended for secure embedded systems.
59860 +
59861 +config GRKERNSEC_DEVICE_SIDECHANNEL
59862 + bool "Eliminate stat/notify-based device sidechannels"
59863 + default y if GRKERNSEC_CONFIG_AUTO
59864 + help
59865 + If you say Y here, timing analyses on block or character
59866 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
59867 + will be thwarted for unprivileged users. If a process without
59868 + CAP_MKNOD stats such a device, the last access and last modify times
59869 + will match the device's create time. No access or modify events
59870 + will be triggered through inotify/dnotify/fanotify for such devices.
59871 + This feature will prevent attacks that may at a minimum
59872 + allow an attacker to determine the administrator's password length.
59873 +
59874 +config GRKERNSEC_CHROOT
59875 + bool "Chroot jail restrictions"
59876 + default y if GRKERNSEC_CONFIG_AUTO
59877 + help
59878 + If you say Y here, you will be able to choose several options that will
59879 + make breaking out of a chrooted jail much more difficult. If you
59880 + encounter no software incompatibilities with the following options, it
59881 + is recommended that you enable each one.
59882 +
59883 +config GRKERNSEC_CHROOT_MOUNT
59884 + bool "Deny mounts"
59885 + default y if GRKERNSEC_CONFIG_AUTO
59886 + depends on GRKERNSEC_CHROOT
59887 + help
59888 + If you say Y here, processes inside a chroot will not be able to
59889 + mount or remount filesystems. If the sysctl option is enabled, a
59890 + sysctl option with name "chroot_deny_mount" is created.
59891 +
59892 +config GRKERNSEC_CHROOT_DOUBLE
59893 + bool "Deny double-chroots"
59894 + default y if GRKERNSEC_CONFIG_AUTO
59895 + depends on GRKERNSEC_CHROOT
59896 + help
59897 + If you say Y here, processes inside a chroot will not be able to chroot
59898 + again outside the chroot. This is a widely used method of breaking
59899 + out of a chroot jail and should not be allowed. If the sysctl
59900 + option is enabled, a sysctl option with name
59901 + "chroot_deny_chroot" is created.
59902 +
59903 +config GRKERNSEC_CHROOT_PIVOT
59904 + bool "Deny pivot_root in chroot"
59905 + default y if GRKERNSEC_CONFIG_AUTO
59906 + depends on GRKERNSEC_CHROOT
59907 + help
59908 + If you say Y here, processes inside a chroot will not be able to use
59909 + a function called pivot_root() that was introduced in Linux 2.3.41. It
59910 + works similar to chroot in that it changes the root filesystem. This
59911 + function could be misused in a chrooted process to attempt to break out
59912 + of the chroot, and therefore should not be allowed. If the sysctl
59913 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
59914 + created.
59915 +
59916 +config GRKERNSEC_CHROOT_CHDIR
59917 + bool "Enforce chdir(\"/\") on all chroots"
59918 + default y if GRKERNSEC_CONFIG_AUTO
59919 + depends on GRKERNSEC_CHROOT
59920 + help
59921 + If you say Y here, the current working directory of all newly-chrooted
59922 + applications will be set to the the root directory of the chroot.
59923 + The man page on chroot(2) states:
59924 + Note that this call does not change the current working
59925 + directory, so that `.' can be outside the tree rooted at
59926 + `/'. In particular, the super-user can escape from a
59927 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
59928 +
59929 + It is recommended that you say Y here, since it's not known to break
59930 + any software. If the sysctl option is enabled, a sysctl option with
59931 + name "chroot_enforce_chdir" is created.
59932 +
59933 +config GRKERNSEC_CHROOT_CHMOD
59934 + bool "Deny (f)chmod +s"
59935 + default y if GRKERNSEC_CONFIG_AUTO
59936 + depends on GRKERNSEC_CHROOT
59937 + help
59938 + If you say Y here, processes inside a chroot will not be able to chmod
59939 + or fchmod files to make them have suid or sgid bits. This protects
59940 + against another published method of breaking a chroot. If the sysctl
59941 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
59942 + created.
59943 +
59944 +config GRKERNSEC_CHROOT_FCHDIR
59945 + bool "Deny fchdir out of chroot"
59946 + default y if GRKERNSEC_CONFIG_AUTO
59947 + depends on GRKERNSEC_CHROOT
59948 + help
59949 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
59950 + to a file descriptor of the chrooting process that points to a directory
59951 + outside the filesystem will be stopped. If the sysctl option
59952 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
59953 +
59954 +config GRKERNSEC_CHROOT_MKNOD
59955 + bool "Deny mknod"
59956 + default y if GRKERNSEC_CONFIG_AUTO
59957 + depends on GRKERNSEC_CHROOT
59958 + help
59959 + If you say Y here, processes inside a chroot will not be allowed to
59960 + mknod. The problem with using mknod inside a chroot is that it
59961 + would allow an attacker to create a device entry that is the same
59962 + as one on the physical root of your system, which could range from
59963 + anything from the console device to a device for your harddrive (which
59964 + they could then use to wipe the drive or steal data). It is recommended
59965 + that you say Y here, unless you run into software incompatibilities.
59966 + If the sysctl option is enabled, a sysctl option with name
59967 + "chroot_deny_mknod" is created.
59968 +
59969 +config GRKERNSEC_CHROOT_SHMAT
59970 + bool "Deny shmat() out of chroot"
59971 + default y if GRKERNSEC_CONFIG_AUTO
59972 + depends on GRKERNSEC_CHROOT
59973 + help
59974 + If you say Y here, processes inside a chroot will not be able to attach
59975 + to shared memory segments that were created outside of the chroot jail.
59976 + It is recommended that you say Y here. If the sysctl option is enabled,
59977 + a sysctl option with name "chroot_deny_shmat" is created.
59978 +
59979 +config GRKERNSEC_CHROOT_UNIX
59980 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
59981 + default y if GRKERNSEC_CONFIG_AUTO
59982 + depends on GRKERNSEC_CHROOT
59983 + help
59984 + If you say Y here, processes inside a chroot will not be able to
59985 + connect to abstract (meaning not belonging to a filesystem) Unix
59986 + domain sockets that were bound outside of a chroot. It is recommended
59987 + that you say Y here. If the sysctl option is enabled, a sysctl option
59988 + with name "chroot_deny_unix" is created.
59989 +
59990 +config GRKERNSEC_CHROOT_FINDTASK
59991 + bool "Protect outside processes"
59992 + default y if GRKERNSEC_CONFIG_AUTO
59993 + depends on GRKERNSEC_CHROOT
59994 + help
59995 + If you say Y here, processes inside a chroot will not be able to
59996 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
59997 + getsid, or view any process outside of the chroot. If the sysctl
59998 + option is enabled, a sysctl option with name "chroot_findtask" is
59999 + created.
60000 +
60001 +config GRKERNSEC_CHROOT_NICE
60002 + bool "Restrict priority changes"
60003 + default y if GRKERNSEC_CONFIG_AUTO
60004 + depends on GRKERNSEC_CHROOT
60005 + help
60006 + If you say Y here, processes inside a chroot will not be able to raise
60007 + the priority of processes in the chroot, or alter the priority of
60008 + processes outside the chroot. This provides more security than simply
60009 + removing CAP_SYS_NICE from the process' capability set. If the
60010 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
60011 + is created.
60012 +
60013 +config GRKERNSEC_CHROOT_SYSCTL
60014 + bool "Deny sysctl writes"
60015 + default y if GRKERNSEC_CONFIG_AUTO
60016 + depends on GRKERNSEC_CHROOT
60017 + help
60018 + If you say Y here, an attacker in a chroot will not be able to
60019 + write to sysctl entries, either by sysctl(2) or through a /proc
60020 + interface. It is strongly recommended that you say Y here. If the
60021 + sysctl option is enabled, a sysctl option with name
60022 + "chroot_deny_sysctl" is created.
60023 +
60024 +config GRKERNSEC_CHROOT_CAPS
60025 + bool "Capability restrictions"
60026 + default y if GRKERNSEC_CONFIG_AUTO
60027 + depends on GRKERNSEC_CHROOT
60028 + help
60029 + If you say Y here, the capabilities on all processes within a
60030 + chroot jail will be lowered to stop module insertion, raw i/o,
60031 + system and net admin tasks, rebooting the system, modifying immutable
60032 + files, modifying IPC owned by another, and changing the system time.
60033 + This is left an option because it can break some apps. Disable this
60034 + if your chrooted apps are having problems performing those kinds of
60035 + tasks. If the sysctl option is enabled, a sysctl option with
60036 + name "chroot_caps" is created.
60037 +
60038 +config GRKERNSEC_CHROOT_INITRD
60039 + bool "Exempt initrd tasks from restrictions"
60040 + default y if GRKERNSEC_CONFIG_AUTO
60041 + depends on GRKERNSEC_CHROOT && BLK_DEV_RAM
60042 + help
60043 + If you say Y here, tasks started prior to init will be exempted from
60044 + grsecurity's chroot restrictions. This option is mainly meant to
60045 + resolve Plymouth's performing privileged operations unnecessarily
60046 + in a chroot.
60047 +
60048 +endmenu
60049 +menu "Kernel Auditing"
60050 +depends on GRKERNSEC
60051 +
60052 +config GRKERNSEC_AUDIT_GROUP
60053 + bool "Single group for auditing"
60054 + help
60055 + If you say Y here, the exec and chdir logging features will only operate
60056 + on a group you specify. This option is recommended if you only want to
60057 + watch certain users instead of having a large amount of logs from the
60058 + entire system. If the sysctl option is enabled, a sysctl option with
60059 + name "audit_group" is created.
60060 +
60061 +config GRKERNSEC_AUDIT_GID
60062 + int "GID for auditing"
60063 + depends on GRKERNSEC_AUDIT_GROUP
60064 + default 1007
60065 +
60066 +config GRKERNSEC_EXECLOG
60067 + bool "Exec logging"
60068 + help
60069 + If you say Y here, all execve() calls will be logged (since the
60070 + other exec*() calls are frontends to execve(), all execution
60071 + will be logged). Useful for shell-servers that like to keep track
60072 + of their users. If the sysctl option is enabled, a sysctl option with
60073 + name "exec_logging" is created.
60074 + WARNING: This option when enabled will produce a LOT of logs, especially
60075 + on an active system.
60076 +
60077 +config GRKERNSEC_RESLOG
60078 + bool "Resource logging"
60079 + default y if GRKERNSEC_CONFIG_AUTO
60080 + help
60081 + If you say Y here, all attempts to overstep resource limits will
60082 + be logged with the resource name, the requested size, and the current
60083 + limit. It is highly recommended that you say Y here. If the sysctl
60084 + option is enabled, a sysctl option with name "resource_logging" is
60085 + created. If the RBAC system is enabled, the sysctl value is ignored.
60086 +
60087 +config GRKERNSEC_CHROOT_EXECLOG
60088 + bool "Log execs within chroot"
60089 + help
60090 + If you say Y here, all executions inside a chroot jail will be logged
60091 + to syslog. This can cause a large amount of logs if certain
60092 + applications (eg. djb's daemontools) are installed on the system, and
60093 + is therefore left as an option. If the sysctl option is enabled, a
60094 + sysctl option with name "chroot_execlog" is created.
60095 +
60096 +config GRKERNSEC_AUDIT_PTRACE
60097 + bool "Ptrace logging"
60098 + help
60099 + If you say Y here, all attempts to attach to a process via ptrace
60100 + will be logged. If the sysctl option is enabled, a sysctl option
60101 + with name "audit_ptrace" is created.
60102 +
60103 +config GRKERNSEC_AUDIT_CHDIR
60104 + bool "Chdir logging"
60105 + help
60106 + If you say Y here, all chdir() calls will be logged. If the sysctl
60107 + option is enabled, a sysctl option with name "audit_chdir" is created.
60108 +
60109 +config GRKERNSEC_AUDIT_MOUNT
60110 + bool "(Un)Mount logging"
60111 + help
60112 + If you say Y here, all mounts and unmounts will be logged. If the
60113 + sysctl option is enabled, a sysctl option with name "audit_mount" is
60114 + created.
60115 +
60116 +config GRKERNSEC_SIGNAL
60117 + bool "Signal logging"
60118 + default y if GRKERNSEC_CONFIG_AUTO
60119 + help
60120 + If you say Y here, certain important signals will be logged, such as
60121 + SIGSEGV, which will as a result inform you of when a error in a program
60122 + occurred, which in some cases could mean a possible exploit attempt.
60123 + If the sysctl option is enabled, a sysctl option with name
60124 + "signal_logging" is created.
60125 +
60126 +config GRKERNSEC_FORKFAIL
60127 + bool "Fork failure logging"
60128 + help
60129 + If you say Y here, all failed fork() attempts will be logged.
60130 + This could suggest a fork bomb, or someone attempting to overstep
60131 + their process limit. If the sysctl option is enabled, a sysctl option
60132 + with name "forkfail_logging" is created.
60133 +
60134 +config GRKERNSEC_TIME
60135 + bool "Time change logging"
60136 + default y if GRKERNSEC_CONFIG_AUTO
60137 + help
60138 + If you say Y here, any changes of the system clock will be logged.
60139 + If the sysctl option is enabled, a sysctl option with name
60140 + "timechange_logging" is created.
60141 +
60142 +config GRKERNSEC_PROC_IPADDR
60143 + bool "/proc/<pid>/ipaddr support"
60144 + default y if GRKERNSEC_CONFIG_AUTO
60145 + help
60146 + If you say Y here, a new entry will be added to each /proc/<pid>
60147 + directory that contains the IP address of the person using the task.
60148 + The IP is carried across local TCP and AF_UNIX stream sockets.
60149 + This information can be useful for IDS/IPSes to perform remote response
60150 + to a local attack. The entry is readable by only the owner of the
60151 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
60152 + the RBAC system), and thus does not create privacy concerns.
60153 +
60154 +config GRKERNSEC_RWXMAP_LOG
60155 + bool 'Denied RWX mmap/mprotect logging'
60156 + default y if GRKERNSEC_CONFIG_AUTO
60157 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
60158 + help
60159 + If you say Y here, calls to mmap() and mprotect() with explicit
60160 + usage of PROT_WRITE and PROT_EXEC together will be logged when
60161 + denied by the PAX_MPROTECT feature. This feature will also
60162 + log other problematic scenarios that can occur when PAX_MPROTECT
60163 + is enabled on a binary, like textrels and PT_GNU_STACK. If the
60164 + sysctl option is enabled, a sysctl option with name "rwxmap_logging"
60165 + is created.
60166 +
60167 +endmenu
60168 +
60169 +menu "Executable Protections"
60170 +depends on GRKERNSEC
60171 +
60172 +config GRKERNSEC_DMESG
60173 + bool "Dmesg(8) restriction"
60174 + default y if GRKERNSEC_CONFIG_AUTO
60175 + help
60176 + If you say Y here, non-root users will not be able to use dmesg(8)
60177 + to view the contents of the kernel's circular log buffer.
60178 + The kernel's log buffer often contains kernel addresses and other
60179 + identifying information useful to an attacker in fingerprinting a
60180 + system for a targeted exploit.
60181 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
60182 + created.
60183 +
60184 +config GRKERNSEC_HARDEN_PTRACE
60185 + bool "Deter ptrace-based process snooping"
60186 + default y if GRKERNSEC_CONFIG_AUTO
60187 + help
60188 + If you say Y here, TTY sniffers and other malicious monitoring
60189 + programs implemented through ptrace will be defeated. If you
60190 + have been using the RBAC system, this option has already been
60191 + enabled for several years for all users, with the ability to make
60192 + fine-grained exceptions.
60193 +
60194 + This option only affects the ability of non-root users to ptrace
60195 + processes that are not a descendent of the ptracing process.
60196 + This means that strace ./binary and gdb ./binary will still work,
60197 + but attaching to arbitrary processes will not. If the sysctl
60198 + option is enabled, a sysctl option with name "harden_ptrace" is
60199 + created.
60200 +
60201 +config GRKERNSEC_PTRACE_READEXEC
60202 + bool "Require read access to ptrace sensitive binaries"
60203 + default y if GRKERNSEC_CONFIG_AUTO
60204 + help
60205 + If you say Y here, unprivileged users will not be able to ptrace unreadable
60206 + binaries. This option is useful in environments that
60207 + remove the read bits (e.g. file mode 4711) from suid binaries to
60208 + prevent infoleaking of their contents. This option adds
60209 + consistency to the use of that file mode, as the binary could normally
60210 + be read out when run without privileges while ptracing.
60211 +
60212 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
60213 + is created.
60214 +
60215 +config GRKERNSEC_SETXID
60216 + bool "Enforce consistent multithreaded privileges"
60217 + default y if GRKERNSEC_CONFIG_AUTO
60218 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
60219 + help
60220 + If you say Y here, a change from a root uid to a non-root uid
60221 + in a multithreaded application will cause the resulting uids,
60222 + gids, supplementary groups, and capabilities in that thread
60223 + to be propagated to the other threads of the process. In most
60224 + cases this is unnecessary, as glibc will emulate this behavior
60225 + on behalf of the application. Other libcs do not act in the
60226 + same way, allowing the other threads of the process to continue
60227 + running with root privileges. If the sysctl option is enabled,
60228 + a sysctl option with name "consistent_setxid" is created.
60229 +
60230 +config GRKERNSEC_TPE
60231 + bool "Trusted Path Execution (TPE)"
60232 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
60233 + help
60234 + If you say Y here, you will be able to choose a gid to add to the
60235 + supplementary groups of users you want to mark as "untrusted."
60236 + These users will not be able to execute any files that are not in
60237 + root-owned directories writable only by root. If the sysctl option
60238 + is enabled, a sysctl option with name "tpe" is created.
60239 +
60240 +config GRKERNSEC_TPE_ALL
60241 + bool "Partially restrict all non-root users"
60242 + depends on GRKERNSEC_TPE
60243 + help
60244 + If you say Y here, all non-root users will be covered under
60245 + a weaker TPE restriction. This is separate from, and in addition to,
60246 + the main TPE options that you have selected elsewhere. Thus, if a
60247 + "trusted" GID is chosen, this restriction applies to even that GID.
60248 + Under this restriction, all non-root users will only be allowed to
60249 + execute files in directories they own that are not group or
60250 + world-writable, or in directories owned by root and writable only by
60251 + root. If the sysctl option is enabled, a sysctl option with name
60252 + "tpe_restrict_all" is created.
60253 +
60254 +config GRKERNSEC_TPE_INVERT
60255 + bool "Invert GID option"
60256 + depends on GRKERNSEC_TPE
60257 + help
60258 + If you say Y here, the group you specify in the TPE configuration will
60259 + decide what group TPE restrictions will be *disabled* for. This
60260 + option is useful if you want TPE restrictions to be applied to most
60261 + users on the system. If the sysctl option is enabled, a sysctl option
60262 + with name "tpe_invert" is created. Unlike other sysctl options, this
60263 + entry will default to on for backward-compatibility.
60264 +
60265 +config GRKERNSEC_TPE_GID
60266 + int
60267 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
60268 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
60269 +
60270 +config GRKERNSEC_TPE_UNTRUSTED_GID
60271 + int "GID for TPE-untrusted users"
60272 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
60273 + default 1005
60274 + help
60275 + Setting this GID determines what group TPE restrictions will be
60276 + *enabled* for. If the sysctl option is enabled, a sysctl option
60277 + with name "tpe_gid" is created.
60278 +
60279 +config GRKERNSEC_TPE_TRUSTED_GID
60280 + int "GID for TPE-trusted users"
60281 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
60282 + default 1005
60283 + help
60284 + Setting this GID determines what group TPE restrictions will be
60285 + *disabled* for. If the sysctl option is enabled, a sysctl option
60286 + with name "tpe_gid" is created.
60287 +
60288 +endmenu
60289 +menu "Network Protections"
60290 +depends on GRKERNSEC
60291 +
60292 +config GRKERNSEC_RANDNET
60293 + bool "Larger entropy pools"
60294 + default y if GRKERNSEC_CONFIG_AUTO
60295 + help
60296 + If you say Y here, the entropy pools used for many features of Linux
60297 + and grsecurity will be doubled in size. Since several grsecurity
60298 + features use additional randomness, it is recommended that you say Y
60299 + here. Saying Y here has a similar effect as modifying
60300 + /proc/sys/kernel/random/poolsize.
60301 +
60302 +config GRKERNSEC_BLACKHOLE
60303 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
60304 + default y if GRKERNSEC_CONFIG_AUTO
60305 + depends on NET
60306 + help
60307 + If you say Y here, neither TCP resets nor ICMP
60308 + destination-unreachable packets will be sent in response to packets
60309 + sent to ports for which no associated listening process exists.
60310 + This feature supports both IPV4 and IPV6 and exempts the
60311 + loopback interface from blackholing. Enabling this feature
60312 + makes a host more resilient to DoS attacks and reduces network
60313 + visibility against scanners.
60314 +
60315 + The blackhole feature as-implemented is equivalent to the FreeBSD
60316 + blackhole feature, as it prevents RST responses to all packets, not
60317 + just SYNs. Under most application behavior this causes no
60318 + problems, but applications (like haproxy) may not close certain
60319 + connections in a way that cleanly terminates them on the remote
60320 + end, leaving the remote host in LAST_ACK state. Because of this
60321 + side-effect and to prevent intentional LAST_ACK DoSes, this
60322 + feature also adds automatic mitigation against such attacks.
60323 + The mitigation drastically reduces the amount of time a socket
60324 + can spend in LAST_ACK state. If you're using haproxy and not
60325 + all servers it connects to have this option enabled, consider
60326 + disabling this feature on the haproxy host.
60327 +
60328 + If the sysctl option is enabled, two sysctl options with names
60329 + "ip_blackhole" and "lastack_retries" will be created.
60330 + While "ip_blackhole" takes the standard zero/non-zero on/off
60331 + toggle, "lastack_retries" uses the same kinds of values as
60332 + "tcp_retries1" and "tcp_retries2". The default value of 4
60333 + prevents a socket from lasting more than 45 seconds in LAST_ACK
60334 + state.
60335 +
60336 +config GRKERNSEC_NO_SIMULT_CONNECT
60337 + bool "Disable TCP Simultaneous Connect"
60338 + default y if GRKERNSEC_CONFIG_AUTO
60339 + depends on NET
60340 + help
60341 + If you say Y here, a feature by Willy Tarreau will be enabled that
60342 + removes a weakness in Linux's strict implementation of TCP that
60343 + allows two clients to connect to each other without either entering
60344 + a listening state. The weakness allows an attacker to easily prevent
60345 + a client from connecting to a known server provided the source port
60346 + for the connection is guessed correctly.
60347 +
60348 + As the weakness could be used to prevent an antivirus or IPS from
60349 + fetching updates, or prevent an SSL gateway from fetching a CRL,
60350 + it should be eliminated by enabling this option. Though Linux is
60351 + one of few operating systems supporting simultaneous connect, it
60352 + has no legitimate use in practice and is rarely supported by firewalls.
60353 +
60354 +config GRKERNSEC_SOCKET
60355 + bool "Socket restrictions"
60356 + depends on NET
60357 + help
60358 + If you say Y here, you will be able to choose from several options.
60359 + If you assign a GID on your system and add it to the supplementary
60360 + groups of users you want to restrict socket access to, this patch
60361 + will perform up to three things, based on the option(s) you choose.
60362 +
60363 +config GRKERNSEC_SOCKET_ALL
60364 + bool "Deny any sockets to group"
60365 + depends on GRKERNSEC_SOCKET
60366 + help
60367 + If you say Y here, you will be able to choose a GID of whose users will
60368 + be unable to connect to other hosts from your machine or run server
60369 + applications from your machine. If the sysctl option is enabled, a
60370 + sysctl option with name "socket_all" is created.
60371 +
60372 +config GRKERNSEC_SOCKET_ALL_GID
60373 + int "GID to deny all sockets for"
60374 + depends on GRKERNSEC_SOCKET_ALL
60375 + default 1004
60376 + help
60377 + Here you can choose the GID to disable socket access for. Remember to
60378 + add the users you want socket access disabled for to the GID
60379 + specified here. If the sysctl option is enabled, a sysctl option
60380 + with name "socket_all_gid" is created.
60381 +
60382 +config GRKERNSEC_SOCKET_CLIENT
60383 + bool "Deny client sockets to group"
60384 + depends on GRKERNSEC_SOCKET
60385 + help
60386 + If you say Y here, you will be able to choose a GID of whose users will
60387 + be unable to connect to other hosts from your machine, but will be
60388 + able to run servers. If this option is enabled, all users in the group
60389 + you specify will have to use passive mode when initiating ftp transfers
60390 + from the shell on your machine. If the sysctl option is enabled, a
60391 + sysctl option with name "socket_client" is created.
60392 +
60393 +config GRKERNSEC_SOCKET_CLIENT_GID
60394 + int "GID to deny client sockets for"
60395 + depends on GRKERNSEC_SOCKET_CLIENT
60396 + default 1003
60397 + help
60398 + Here you can choose the GID to disable client socket access for.
60399 + Remember to add the users you want client socket access disabled for to
60400 + the GID specified here. If the sysctl option is enabled, a sysctl
60401 + option with name "socket_client_gid" is created.
60402 +
60403 +config GRKERNSEC_SOCKET_SERVER
60404 + bool "Deny server sockets to group"
60405 + depends on GRKERNSEC_SOCKET
60406 + help
60407 + If you say Y here, you will be able to choose a GID of whose users will
60408 + be unable to run server applications from your machine. If the sysctl
60409 + option is enabled, a sysctl option with name "socket_server" is created.
60410 +
60411 +config GRKERNSEC_SOCKET_SERVER_GID
60412 + int "GID to deny server sockets for"
60413 + depends on GRKERNSEC_SOCKET_SERVER
60414 + default 1002
60415 + help
60416 + Here you can choose the GID to disable server socket access for.
60417 + Remember to add the users you want server socket access disabled for to
60418 + the GID specified here. If the sysctl option is enabled, a sysctl
60419 + option with name "socket_server_gid" is created.
60420 +
60421 +endmenu
60422 +menu "Sysctl Support"
60423 +depends on GRKERNSEC && SYSCTL
60424 +
60425 +config GRKERNSEC_SYSCTL
60426 + bool "Sysctl support"
60427 + default y if GRKERNSEC_CONFIG_AUTO
60428 + help
60429 + If you say Y here, you will be able to change the options that
60430 + grsecurity runs with at bootup, without having to recompile your
60431 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
60432 + to enable (1) or disable (0) various features. All the sysctl entries
60433 + are mutable until the "grsec_lock" entry is set to a non-zero value.
60434 + All features enabled in the kernel configuration are disabled at boot
60435 + if you do not say Y to the "Turn on features by default" option.
60436 + All options should be set at startup, and the grsec_lock entry should
60437 + be set to a non-zero value after all the options are set.
60438 + *THIS IS EXTREMELY IMPORTANT*
60439 +
60440 +config GRKERNSEC_SYSCTL_DISTRO
60441 + bool "Extra sysctl support for distro makers (READ HELP)"
60442 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
60443 + help
60444 + If you say Y here, additional sysctl options will be created
60445 + for features that affect processes running as root. Therefore,
60446 + it is critical when using this option that the grsec_lock entry be
60447 + enabled after boot. Only distros with prebuilt kernel packages
60448 + with this option enabled that can ensure grsec_lock is enabled
60449 + after boot should use this option.
60450 + *Failure to set grsec_lock after boot makes all grsec features
60451 + this option covers useless*
60452 +
60453 + Currently this option creates the following sysctl entries:
60454 + "Disable Privileged I/O": "disable_priv_io"
60455 +
60456 +config GRKERNSEC_SYSCTL_ON
60457 + bool "Turn on features by default"
60458 + default y if GRKERNSEC_CONFIG_AUTO
60459 + depends on GRKERNSEC_SYSCTL
60460 + help
60461 + If you say Y here, instead of having all features enabled in the
60462 + kernel configuration disabled at boot time, the features will be
60463 + enabled at boot time. It is recommended you say Y here unless
60464 + there is some reason you would want all sysctl-tunable features to
60465 + be disabled by default. As mentioned elsewhere, it is important
60466 + to enable the grsec_lock entry once you have finished modifying
60467 + the sysctl entries.
60468 +
60469 +endmenu
60470 +menu "Logging Options"
60471 +depends on GRKERNSEC
60472 +
60473 +config GRKERNSEC_FLOODTIME
60474 + int "Seconds in between log messages (minimum)"
60475 + default 10
60476 + help
60477 + This option allows you to enforce the number of seconds between
60478 + grsecurity log messages. The default should be suitable for most
60479 + people, however, if you choose to change it, choose a value small enough
60480 + to allow informative logs to be produced, but large enough to
60481 + prevent flooding.
60482 +
60483 +config GRKERNSEC_FLOODBURST
60484 + int "Number of messages in a burst (maximum)"
60485 + default 6
60486 + help
60487 + This option allows you to choose the maximum number of messages allowed
60488 + within the flood time interval you chose in a separate option. The
60489 + default should be suitable for most people, however if you find that
60490 + many of your logs are being interpreted as flooding, you may want to
60491 + raise this value.
60492 +
60493 +endmenu
60494 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
60495 new file mode 100644
60496 index 0000000..36845aa
60497 --- /dev/null
60498 +++ b/grsecurity/Makefile
60499 @@ -0,0 +1,42 @@
60500 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
60501 +# during 2001-2009 it has been completely redesigned by Brad Spengler
60502 +# into an RBAC system
60503 +#
60504 +# All code in this directory and various hooks inserted throughout the kernel
60505 +# are copyright Brad Spengler - Open Source Security, Inc., and released
60506 +# under the GPL v2 or higher
60507 +
60508 +KBUILD_CFLAGS += -Werror
60509 +
60510 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
60511 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
60512 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o
60513 +
60514 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
60515 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
60516 + gracl_learn.o grsec_log.o
60517 +ifdef CONFIG_COMPAT
60518 +obj-$(CONFIG_GRKERNSEC) += gracl_compat.o
60519 +endif
60520 +
60521 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
60522 +
60523 +ifdef CONFIG_NET
60524 +obj-y += grsec_sock.o
60525 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
60526 +endif
60527 +
60528 +ifndef CONFIG_GRKERNSEC
60529 +obj-y += grsec_disabled.o
60530 +endif
60531 +
60532 +ifdef CONFIG_GRKERNSEC_HIDESYM
60533 +extra-y := grsec_hidesym.o
60534 +$(obj)/grsec_hidesym.o:
60535 + @-chmod -f 500 /boot
60536 + @-chmod -f 500 /lib/modules
60537 + @-chmod -f 500 /lib64/modules
60538 + @-chmod -f 500 /lib32/modules
60539 + @-chmod -f 700 .
60540 + @echo ' grsec: protected kernel image paths'
60541 +endif
60542 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
60543 new file mode 100644
60544 index 0000000..c0793fd
60545 --- /dev/null
60546 +++ b/grsecurity/gracl.c
60547 @@ -0,0 +1,4178 @@
60548 +#include <linux/kernel.h>
60549 +#include <linux/module.h>
60550 +#include <linux/sched.h>
60551 +#include <linux/mm.h>
60552 +#include <linux/file.h>
60553 +#include <linux/fs.h>
60554 +#include <linux/namei.h>
60555 +#include <linux/mount.h>
60556 +#include <linux/tty.h>
60557 +#include <linux/proc_fs.h>
60558 +#include <linux/lglock.h>
60559 +#include <linux/slab.h>
60560 +#include <linux/vmalloc.h>
60561 +#include <linux/types.h>
60562 +#include <linux/sysctl.h>
60563 +#include <linux/netdevice.h>
60564 +#include <linux/ptrace.h>
60565 +#include <linux/gracl.h>
60566 +#include <linux/gralloc.h>
60567 +#include <linux/security.h>
60568 +#include <linux/grinternal.h>
60569 +#include <linux/pid_namespace.h>
60570 +#include <linux/stop_machine.h>
60571 +#include <linux/fdtable.h>
60572 +#include <linux/percpu.h>
60573 +#include <linux/lglock.h>
60574 +#include <linux/hugetlb.h>
60575 +#include <linux/posix-timers.h>
60576 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
60577 +#include <linux/magic.h>
60578 +#include <linux/pagemap.h>
60579 +#include "../fs/btrfs/async-thread.h"
60580 +#include "../fs/btrfs/ctree.h"
60581 +#include "../fs/btrfs/btrfs_inode.h"
60582 +#endif
60583 +#include "../fs/mount.h"
60584 +
60585 +#include <asm/uaccess.h>
60586 +#include <asm/errno.h>
60587 +#include <asm/mman.h>
60588 +
60589 +extern struct lglock vfsmount_lock;
60590 +
60591 +static struct acl_role_db acl_role_set;
60592 +static struct name_db name_set;
60593 +static struct inodev_db inodev_set;
60594 +
60595 +/* for keeping track of userspace pointers used for subjects, so we
60596 + can share references in the kernel as well
60597 +*/
60598 +
60599 +static struct path real_root;
60600 +
60601 +static struct acl_subj_map_db subj_map_set;
60602 +
60603 +static struct acl_role_label *default_role;
60604 +
60605 +static struct acl_role_label *role_list;
60606 +
60607 +static u16 acl_sp_role_value;
60608 +
60609 +extern char *gr_shared_page[4];
60610 +static DEFINE_MUTEX(gr_dev_mutex);
60611 +DEFINE_RWLOCK(gr_inode_lock);
60612 +
60613 +struct gr_arg *gr_usermode;
60614 +
60615 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
60616 +
60617 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
60618 +extern void gr_clear_learn_entries(void);
60619 +
60620 +unsigned char *gr_system_salt;
60621 +unsigned char *gr_system_sum;
60622 +
60623 +static struct sprole_pw **acl_special_roles = NULL;
60624 +static __u16 num_sprole_pws = 0;
60625 +
60626 +static struct acl_role_label *kernel_role = NULL;
60627 +
60628 +static unsigned int gr_auth_attempts = 0;
60629 +static unsigned long gr_auth_expires = 0UL;
60630 +
60631 +#ifdef CONFIG_NET
60632 +extern struct vfsmount *sock_mnt;
60633 +#endif
60634 +
60635 +extern struct vfsmount *pipe_mnt;
60636 +extern struct vfsmount *shm_mnt;
60637 +
60638 +#ifdef CONFIG_HUGETLBFS
60639 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
60640 +#endif
60641 +
60642 +static struct acl_object_label *fakefs_obj_rw;
60643 +static struct acl_object_label *fakefs_obj_rwx;
60644 +
60645 +extern int gr_init_uidset(void);
60646 +extern void gr_free_uidset(void);
60647 +extern void gr_remove_uid(uid_t uid);
60648 +extern int gr_find_uid(uid_t uid);
60649 +
60650 +static int copy_acl_object_label_normal(struct acl_object_label *obj, const struct acl_object_label *userp)
60651 +{
60652 + if (copy_from_user(obj, userp, sizeof(struct acl_object_label)))
60653 + return -EFAULT;
60654 +
60655 + return 0;
60656 +}
60657 +
60658 +static int copy_acl_ip_label_normal(struct acl_ip_label *ip, const struct acl_ip_label *userp)
60659 +{
60660 + if (copy_from_user(ip, userp, sizeof(struct acl_ip_label)))
60661 + return -EFAULT;
60662 +
60663 + return 0;
60664 +}
60665 +
60666 +static int copy_acl_subject_label_normal(struct acl_subject_label *subj, const struct acl_subject_label *userp)
60667 +{
60668 + if (copy_from_user(subj, userp, sizeof(struct acl_subject_label)))
60669 + return -EFAULT;
60670 +
60671 + return 0;
60672 +}
60673 +
60674 +static int copy_acl_role_label_normal(struct acl_role_label *role, const struct acl_role_label *userp)
60675 +{
60676 + if (copy_from_user(role, userp, sizeof(struct acl_role_label)))
60677 + return -EFAULT;
60678 +
60679 + return 0;
60680 +}
60681 +
60682 +static int copy_role_allowed_ip_normal(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
60683 +{
60684 + if (copy_from_user(roleip, userp, sizeof(struct role_allowed_ip)))
60685 + return -EFAULT;
60686 +
60687 + return 0;
60688 +}
60689 +
60690 +static int copy_sprole_pw_normal(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
60691 +{
60692 + if (copy_from_user(pw, userp + idx, sizeof(struct sprole_pw)))
60693 + return -EFAULT;
60694 +
60695 + return 0;
60696 +}
60697 +
60698 +static int copy_gr_hash_struct_normal(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
60699 +{
60700 + if (copy_from_user(hash, userp, sizeof(struct gr_hash_struct)))
60701 + return -EFAULT;
60702 +
60703 + return 0;
60704 +}
60705 +
60706 +static int copy_role_transition_normal(struct role_transition *trans, const struct role_transition *userp)
60707 +{
60708 + if (copy_from_user(trans, userp, sizeof(struct role_transition)))
60709 + return -EFAULT;
60710 +
60711 + return 0;
60712 +}
60713 +
60714 +int copy_pointer_from_array_normal(void *ptr, unsigned long idx, const void *userp)
60715 +{
60716 + if (copy_from_user(ptr, userp + (idx * sizeof(void *)), sizeof(void *)))
60717 + return -EFAULT;
60718 +
60719 + return 0;
60720 +}
60721 +
60722 +static int copy_gr_arg_wrapper_normal(const char __user *buf, struct gr_arg_wrapper *uwrap)
60723 +{
60724 + if (copy_from_user(uwrap, buf, sizeof (struct gr_arg_wrapper)))
60725 + return -EFAULT;
60726 +
60727 + if ((uwrap->version != GRSECURITY_VERSION) || (uwrap->size != sizeof(struct gr_arg)))
60728 + return -EINVAL;
60729 +
60730 + return 0;
60731 +}
60732 +
60733 +static int copy_gr_arg_normal(const struct gr_arg __user *buf, struct gr_arg *arg)
60734 +{
60735 + if (copy_from_user(arg, buf, sizeof (struct gr_arg)))
60736 + return -EFAULT;
60737 +
60738 + return 0;
60739 +}
60740 +
60741 +static size_t get_gr_arg_wrapper_size_normal(void)
60742 +{
60743 + return sizeof(struct gr_arg_wrapper);
60744 +}
60745 +
60746 +#ifdef CONFIG_COMPAT
60747 +extern int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap);
60748 +extern int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg);
60749 +extern int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp);
60750 +extern int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp);
60751 +extern int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp);
60752 +extern int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp);
60753 +extern int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp);
60754 +extern int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp);
60755 +extern int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp);
60756 +extern int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp);
60757 +extern int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp);
60758 +extern size_t get_gr_arg_wrapper_size_compat(void);
60759 +
60760 +int (* copy_gr_arg_wrapper)(const char *buf, struct gr_arg_wrapper *uwrap) __read_only;
60761 +int (* copy_gr_arg)(const struct gr_arg *buf, struct gr_arg *arg) __read_only;
60762 +int (* copy_acl_object_label)(struct acl_object_label *obj, const struct acl_object_label *userp) __read_only;
60763 +int (* copy_acl_subject_label)(struct acl_subject_label *subj, const struct acl_subject_label *userp) __read_only;
60764 +int (* copy_acl_role_label)(struct acl_role_label *role, const struct acl_role_label *userp) __read_only;
60765 +int (* copy_acl_ip_label)(struct acl_ip_label *ip, const struct acl_ip_label *userp) __read_only;
60766 +int (* copy_pointer_from_array)(void *ptr, unsigned long idx, const void *userp) __read_only;
60767 +int (* copy_sprole_pw)(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp) __read_only;
60768 +int (* copy_gr_hash_struct)(struct gr_hash_struct *hash, const struct gr_hash_struct *userp) __read_only;
60769 +int (* copy_role_transition)(struct role_transition *trans, const struct role_transition *userp) __read_only;
60770 +int (* copy_role_allowed_ip)(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp) __read_only;
60771 +size_t (* get_gr_arg_wrapper_size)(void) __read_only;
60772 +
60773 +#else
60774 +#define copy_gr_arg_wrapper copy_gr_arg_wrapper_normal
60775 +#define copy_gr_arg copy_gr_arg_normal
60776 +#define copy_gr_hash_struct copy_gr_hash_struct_normal
60777 +#define copy_acl_object_label copy_acl_object_label_normal
60778 +#define copy_acl_subject_label copy_acl_subject_label_normal
60779 +#define copy_acl_role_label copy_acl_role_label_normal
60780 +#define copy_acl_ip_label copy_acl_ip_label_normal
60781 +#define copy_pointer_from_array copy_pointer_from_array_normal
60782 +#define copy_sprole_pw copy_sprole_pw_normal
60783 +#define copy_role_transition copy_role_transition_normal
60784 +#define copy_role_allowed_ip copy_role_allowed_ip_normal
60785 +#define get_gr_arg_wrapper_size get_gr_arg_wrapper_size_normal
60786 +#endif
60787 +
60788 +__inline__ int
60789 +gr_acl_is_enabled(void)
60790 +{
60791 + return (gr_status & GR_READY);
60792 +}
60793 +
60794 +static inline dev_t __get_dev(const struct dentry *dentry)
60795 +{
60796 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
60797 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
60798 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
60799 + else
60800 +#endif
60801 + return dentry->d_sb->s_dev;
60802 +}
60803 +
60804 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
60805 +{
60806 + return __get_dev(dentry);
60807 +}
60808 +
60809 +static char gr_task_roletype_to_char(struct task_struct *task)
60810 +{
60811 + switch (task->role->roletype &
60812 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
60813 + GR_ROLE_SPECIAL)) {
60814 + case GR_ROLE_DEFAULT:
60815 + return 'D';
60816 + case GR_ROLE_USER:
60817 + return 'U';
60818 + case GR_ROLE_GROUP:
60819 + return 'G';
60820 + case GR_ROLE_SPECIAL:
60821 + return 'S';
60822 + }
60823 +
60824 + return 'X';
60825 +}
60826 +
60827 +char gr_roletype_to_char(void)
60828 +{
60829 + return gr_task_roletype_to_char(current);
60830 +}
60831 +
60832 +__inline__ int
60833 +gr_acl_tpe_check(void)
60834 +{
60835 + if (unlikely(!(gr_status & GR_READY)))
60836 + return 0;
60837 + if (current->role->roletype & GR_ROLE_TPE)
60838 + return 1;
60839 + else
60840 + return 0;
60841 +}
60842 +
60843 +int
60844 +gr_handle_rawio(const struct inode *inode)
60845 +{
60846 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
60847 + if (inode && S_ISBLK(inode->i_mode) &&
60848 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
60849 + !capable(CAP_SYS_RAWIO))
60850 + return 1;
60851 +#endif
60852 + return 0;
60853 +}
60854 +
60855 +static int
60856 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
60857 +{
60858 + if (likely(lena != lenb))
60859 + return 0;
60860 +
60861 + return !memcmp(a, b, lena);
60862 +}
60863 +
60864 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
60865 +{
60866 + *buflen -= namelen;
60867 + if (*buflen < 0)
60868 + return -ENAMETOOLONG;
60869 + *buffer -= namelen;
60870 + memcpy(*buffer, str, namelen);
60871 + return 0;
60872 +}
60873 +
60874 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
60875 +{
60876 + return prepend(buffer, buflen, name->name, name->len);
60877 +}
60878 +
60879 +static int prepend_path(const struct path *path, struct path *root,
60880 + char **buffer, int *buflen)
60881 +{
60882 + struct dentry *dentry = path->dentry;
60883 + struct vfsmount *vfsmnt = path->mnt;
60884 + struct mount *mnt = real_mount(vfsmnt);
60885 + bool slash = false;
60886 + int error = 0;
60887 +
60888 + while (dentry != root->dentry || vfsmnt != root->mnt) {
60889 + struct dentry * parent;
60890 +
60891 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
60892 + /* Global root? */
60893 + if (!mnt_has_parent(mnt)) {
60894 + goto out;
60895 + }
60896 + dentry = mnt->mnt_mountpoint;
60897 + mnt = mnt->mnt_parent;
60898 + vfsmnt = &mnt->mnt;
60899 + continue;
60900 + }
60901 + parent = dentry->d_parent;
60902 + prefetch(parent);
60903 + spin_lock(&dentry->d_lock);
60904 + error = prepend_name(buffer, buflen, &dentry->d_name);
60905 + spin_unlock(&dentry->d_lock);
60906 + if (!error)
60907 + error = prepend(buffer, buflen, "/", 1);
60908 + if (error)
60909 + break;
60910 +
60911 + slash = true;
60912 + dentry = parent;
60913 + }
60914 +
60915 +out:
60916 + if (!error && !slash)
60917 + error = prepend(buffer, buflen, "/", 1);
60918 +
60919 + return error;
60920 +}
60921 +
60922 +/* this must be called with vfsmount_lock and rename_lock held */
60923 +
60924 +static char *__our_d_path(const struct path *path, struct path *root,
60925 + char *buf, int buflen)
60926 +{
60927 + char *res = buf + buflen;
60928 + int error;
60929 +
60930 + prepend(&res, &buflen, "\0", 1);
60931 + error = prepend_path(path, root, &res, &buflen);
60932 + if (error)
60933 + return ERR_PTR(error);
60934 +
60935 + return res;
60936 +}
60937 +
60938 +static char *
60939 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
60940 +{
60941 + char *retval;
60942 +
60943 + retval = __our_d_path(path, root, buf, buflen);
60944 + if (unlikely(IS_ERR(retval)))
60945 + retval = strcpy(buf, "<path too long>");
60946 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
60947 + retval[1] = '\0';
60948 +
60949 + return retval;
60950 +}
60951 +
60952 +static char *
60953 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
60954 + char *buf, int buflen)
60955 +{
60956 + struct path path;
60957 + char *res;
60958 +
60959 + path.dentry = (struct dentry *)dentry;
60960 + path.mnt = (struct vfsmount *)vfsmnt;
60961 +
60962 + /* we can use real_root.dentry, real_root.mnt, because this is only called
60963 + by the RBAC system */
60964 + res = gen_full_path(&path, &real_root, buf, buflen);
60965 +
60966 + return res;
60967 +}
60968 +
60969 +static char *
60970 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
60971 + char *buf, int buflen)
60972 +{
60973 + char *res;
60974 + struct path path;
60975 + struct path root;
60976 + struct task_struct *reaper = init_pid_ns.child_reaper;
60977 +
60978 + path.dentry = (struct dentry *)dentry;
60979 + path.mnt = (struct vfsmount *)vfsmnt;
60980 +
60981 + /* we can't use real_root.dentry, real_root.mnt, because they belong only to the RBAC system */
60982 + get_fs_root(reaper->fs, &root);
60983 +
60984 + br_read_lock(&vfsmount_lock);
60985 + write_seqlock(&rename_lock);
60986 + res = gen_full_path(&path, &root, buf, buflen);
60987 + write_sequnlock(&rename_lock);
60988 + br_read_unlock(&vfsmount_lock);
60989 +
60990 + path_put(&root);
60991 + return res;
60992 +}
60993 +
60994 +static char *
60995 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
60996 +{
60997 + char *ret;
60998 + br_read_lock(&vfsmount_lock);
60999 + write_seqlock(&rename_lock);
61000 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
61001 + PAGE_SIZE);
61002 + write_sequnlock(&rename_lock);
61003 + br_read_unlock(&vfsmount_lock);
61004 + return ret;
61005 +}
61006 +
61007 +static char *
61008 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
61009 +{
61010 + char *ret;
61011 + char *buf;
61012 + int buflen;
61013 +
61014 + br_read_lock(&vfsmount_lock);
61015 + write_seqlock(&rename_lock);
61016 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
61017 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
61018 + buflen = (int)(ret - buf);
61019 + if (buflen >= 5)
61020 + prepend(&ret, &buflen, "/proc", 5);
61021 + else
61022 + ret = strcpy(buf, "<path too long>");
61023 + write_sequnlock(&rename_lock);
61024 + br_read_unlock(&vfsmount_lock);
61025 + return ret;
61026 +}
61027 +
61028 +char *
61029 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
61030 +{
61031 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
61032 + PAGE_SIZE);
61033 +}
61034 +
61035 +char *
61036 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
61037 +{
61038 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
61039 + PAGE_SIZE);
61040 +}
61041 +
61042 +char *
61043 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
61044 +{
61045 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
61046 + PAGE_SIZE);
61047 +}
61048 +
61049 +char *
61050 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
61051 +{
61052 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
61053 + PAGE_SIZE);
61054 +}
61055 +
61056 +char *
61057 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
61058 +{
61059 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
61060 + PAGE_SIZE);
61061 +}
61062 +
61063 +__inline__ __u32
61064 +to_gr_audit(const __u32 reqmode)
61065 +{
61066 + /* masks off auditable permission flags, then shifts them to create
61067 + auditing flags, and adds the special case of append auditing if
61068 + we're requesting write */
61069 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
61070 +}
61071 +
61072 +struct acl_subject_label *
61073 +lookup_subject_map(const struct acl_subject_label *userp)
61074 +{
61075 + unsigned int index = gr_shash(userp, subj_map_set.s_size);
61076 + struct subject_map *match;
61077 +
61078 + match = subj_map_set.s_hash[index];
61079 +
61080 + while (match && match->user != userp)
61081 + match = match->next;
61082 +
61083 + if (match != NULL)
61084 + return match->kernel;
61085 + else
61086 + return NULL;
61087 +}
61088 +
61089 +static void
61090 +insert_subj_map_entry(struct subject_map *subjmap)
61091 +{
61092 + unsigned int index = gr_shash(subjmap->user, subj_map_set.s_size);
61093 + struct subject_map **curr;
61094 +
61095 + subjmap->prev = NULL;
61096 +
61097 + curr = &subj_map_set.s_hash[index];
61098 + if (*curr != NULL)
61099 + (*curr)->prev = subjmap;
61100 +
61101 + subjmap->next = *curr;
61102 + *curr = subjmap;
61103 +
61104 + return;
61105 +}
61106 +
61107 +static struct acl_role_label *
61108 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
61109 + const gid_t gid)
61110 +{
61111 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, acl_role_set.r_size);
61112 + struct acl_role_label *match;
61113 + struct role_allowed_ip *ipp;
61114 + unsigned int x;
61115 + u32 curr_ip = task->signal->curr_ip;
61116 +
61117 + task->signal->saved_ip = curr_ip;
61118 +
61119 + match = acl_role_set.r_hash[index];
61120 +
61121 + while (match) {
61122 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
61123 + for (x = 0; x < match->domain_child_num; x++) {
61124 + if (match->domain_children[x] == uid)
61125 + goto found;
61126 + }
61127 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
61128 + break;
61129 + match = match->next;
61130 + }
61131 +found:
61132 + if (match == NULL) {
61133 + try_group:
61134 + index = gr_rhash(gid, GR_ROLE_GROUP, acl_role_set.r_size);
61135 + match = acl_role_set.r_hash[index];
61136 +
61137 + while (match) {
61138 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
61139 + for (x = 0; x < match->domain_child_num; x++) {
61140 + if (match->domain_children[x] == gid)
61141 + goto found2;
61142 + }
61143 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
61144 + break;
61145 + match = match->next;
61146 + }
61147 +found2:
61148 + if (match == NULL)
61149 + match = default_role;
61150 + if (match->allowed_ips == NULL)
61151 + return match;
61152 + else {
61153 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
61154 + if (likely
61155 + ((ntohl(curr_ip) & ipp->netmask) ==
61156 + (ntohl(ipp->addr) & ipp->netmask)))
61157 + return match;
61158 + }
61159 + match = default_role;
61160 + }
61161 + } else if (match->allowed_ips == NULL) {
61162 + return match;
61163 + } else {
61164 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
61165 + if (likely
61166 + ((ntohl(curr_ip) & ipp->netmask) ==
61167 + (ntohl(ipp->addr) & ipp->netmask)))
61168 + return match;
61169 + }
61170 + goto try_group;
61171 + }
61172 +
61173 + return match;
61174 +}
61175 +
61176 +struct acl_subject_label *
61177 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
61178 + const struct acl_role_label *role)
61179 +{
61180 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
61181 + struct acl_subject_label *match;
61182 +
61183 + match = role->subj_hash[index];
61184 +
61185 + while (match && (match->inode != ino || match->device != dev ||
61186 + (match->mode & GR_DELETED))) {
61187 + match = match->next;
61188 + }
61189 +
61190 + if (match && !(match->mode & GR_DELETED))
61191 + return match;
61192 + else
61193 + return NULL;
61194 +}
61195 +
61196 +struct acl_subject_label *
61197 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
61198 + const struct acl_role_label *role)
61199 +{
61200 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
61201 + struct acl_subject_label *match;
61202 +
61203 + match = role->subj_hash[index];
61204 +
61205 + while (match && (match->inode != ino || match->device != dev ||
61206 + !(match->mode & GR_DELETED))) {
61207 + match = match->next;
61208 + }
61209 +
61210 + if (match && (match->mode & GR_DELETED))
61211 + return match;
61212 + else
61213 + return NULL;
61214 +}
61215 +
61216 +static struct acl_object_label *
61217 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
61218 + const struct acl_subject_label *subj)
61219 +{
61220 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
61221 + struct acl_object_label *match;
61222 +
61223 + match = subj->obj_hash[index];
61224 +
61225 + while (match && (match->inode != ino || match->device != dev ||
61226 + (match->mode & GR_DELETED))) {
61227 + match = match->next;
61228 + }
61229 +
61230 + if (match && !(match->mode & GR_DELETED))
61231 + return match;
61232 + else
61233 + return NULL;
61234 +}
61235 +
61236 +static struct acl_object_label *
61237 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
61238 + const struct acl_subject_label *subj)
61239 +{
61240 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
61241 + struct acl_object_label *match;
61242 +
61243 + match = subj->obj_hash[index];
61244 +
61245 + while (match && (match->inode != ino || match->device != dev ||
61246 + !(match->mode & GR_DELETED))) {
61247 + match = match->next;
61248 + }
61249 +
61250 + if (match && (match->mode & GR_DELETED))
61251 + return match;
61252 +
61253 + match = subj->obj_hash[index];
61254 +
61255 + while (match && (match->inode != ino || match->device != dev ||
61256 + (match->mode & GR_DELETED))) {
61257 + match = match->next;
61258 + }
61259 +
61260 + if (match && !(match->mode & GR_DELETED))
61261 + return match;
61262 + else
61263 + return NULL;
61264 +}
61265 +
61266 +static struct name_entry *
61267 +lookup_name_entry(const char *name)
61268 +{
61269 + unsigned int len = strlen(name);
61270 + unsigned int key = full_name_hash(name, len);
61271 + unsigned int index = key % name_set.n_size;
61272 + struct name_entry *match;
61273 +
61274 + match = name_set.n_hash[index];
61275 +
61276 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
61277 + match = match->next;
61278 +
61279 + return match;
61280 +}
61281 +
61282 +static struct name_entry *
61283 +lookup_name_entry_create(const char *name)
61284 +{
61285 + unsigned int len = strlen(name);
61286 + unsigned int key = full_name_hash(name, len);
61287 + unsigned int index = key % name_set.n_size;
61288 + struct name_entry *match;
61289 +
61290 + match = name_set.n_hash[index];
61291 +
61292 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
61293 + !match->deleted))
61294 + match = match->next;
61295 +
61296 + if (match && match->deleted)
61297 + return match;
61298 +
61299 + match = name_set.n_hash[index];
61300 +
61301 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
61302 + match->deleted))
61303 + match = match->next;
61304 +
61305 + if (match && !match->deleted)
61306 + return match;
61307 + else
61308 + return NULL;
61309 +}
61310 +
61311 +static struct inodev_entry *
61312 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
61313 +{
61314 + unsigned int index = gr_fhash(ino, dev, inodev_set.i_size);
61315 + struct inodev_entry *match;
61316 +
61317 + match = inodev_set.i_hash[index];
61318 +
61319 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
61320 + match = match->next;
61321 +
61322 + return match;
61323 +}
61324 +
61325 +static void
61326 +insert_inodev_entry(struct inodev_entry *entry)
61327 +{
61328 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
61329 + inodev_set.i_size);
61330 + struct inodev_entry **curr;
61331 +
61332 + entry->prev = NULL;
61333 +
61334 + curr = &inodev_set.i_hash[index];
61335 + if (*curr != NULL)
61336 + (*curr)->prev = entry;
61337 +
61338 + entry->next = *curr;
61339 + *curr = entry;
61340 +
61341 + return;
61342 +}
61343 +
61344 +static void
61345 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
61346 +{
61347 + unsigned int index =
61348 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), acl_role_set.r_size);
61349 + struct acl_role_label **curr;
61350 + struct acl_role_label *tmp, *tmp2;
61351 +
61352 + curr = &acl_role_set.r_hash[index];
61353 +
61354 + /* simple case, slot is empty, just set it to our role */
61355 + if (*curr == NULL) {
61356 + *curr = role;
61357 + } else {
61358 + /* example:
61359 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
61360 + 2 -> 3
61361 + */
61362 + /* first check to see if we can already be reached via this slot */
61363 + tmp = *curr;
61364 + while (tmp && tmp != role)
61365 + tmp = tmp->next;
61366 + if (tmp == role) {
61367 + /* we don't need to add ourselves to this slot's chain */
61368 + return;
61369 + }
61370 + /* we need to add ourselves to this chain, two cases */
61371 + if (role->next == NULL) {
61372 + /* simple case, append the current chain to our role */
61373 + role->next = *curr;
61374 + *curr = role;
61375 + } else {
61376 + /* 1 -> 2 -> 3 -> 4
61377 + 2 -> 3 -> 4
61378 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
61379 + */
61380 + /* trickier case: walk our role's chain until we find
61381 + the role for the start of the current slot's chain */
61382 + tmp = role;
61383 + tmp2 = *curr;
61384 + while (tmp->next && tmp->next != tmp2)
61385 + tmp = tmp->next;
61386 + if (tmp->next == tmp2) {
61387 + /* from example above, we found 3, so just
61388 + replace this slot's chain with ours */
61389 + *curr = role;
61390 + } else {
61391 + /* we didn't find a subset of our role's chain
61392 + in the current slot's chain, so append their
61393 + chain to ours, and set us as the first role in
61394 + the slot's chain
61395 +
61396 + we could fold this case with the case above,
61397 + but making it explicit for clarity
61398 + */
61399 + tmp->next = tmp2;
61400 + *curr = role;
61401 + }
61402 + }
61403 + }
61404 +
61405 + return;
61406 +}
61407 +
61408 +static void
61409 +insert_acl_role_label(struct acl_role_label *role)
61410 +{
61411 + int i;
61412 +
61413 + if (role_list == NULL) {
61414 + role_list = role;
61415 + role->prev = NULL;
61416 + } else {
61417 + role->prev = role_list;
61418 + role_list = role;
61419 + }
61420 +
61421 + /* used for hash chains */
61422 + role->next = NULL;
61423 +
61424 + if (role->roletype & GR_ROLE_DOMAIN) {
61425 + for (i = 0; i < role->domain_child_num; i++)
61426 + __insert_acl_role_label(role, role->domain_children[i]);
61427 + } else
61428 + __insert_acl_role_label(role, role->uidgid);
61429 +}
61430 +
61431 +static int
61432 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
61433 +{
61434 + struct name_entry **curr, *nentry;
61435 + struct inodev_entry *ientry;
61436 + unsigned int len = strlen(name);
61437 + unsigned int key = full_name_hash(name, len);
61438 + unsigned int index = key % name_set.n_size;
61439 +
61440 + curr = &name_set.n_hash[index];
61441 +
61442 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
61443 + curr = &((*curr)->next);
61444 +
61445 + if (*curr != NULL)
61446 + return 1;
61447 +
61448 + nentry = acl_alloc(sizeof (struct name_entry));
61449 + if (nentry == NULL)
61450 + return 0;
61451 + ientry = acl_alloc(sizeof (struct inodev_entry));
61452 + if (ientry == NULL)
61453 + return 0;
61454 + ientry->nentry = nentry;
61455 +
61456 + nentry->key = key;
61457 + nentry->name = name;
61458 + nentry->inode = inode;
61459 + nentry->device = device;
61460 + nentry->len = len;
61461 + nentry->deleted = deleted;
61462 +
61463 + nentry->prev = NULL;
61464 + curr = &name_set.n_hash[index];
61465 + if (*curr != NULL)
61466 + (*curr)->prev = nentry;
61467 + nentry->next = *curr;
61468 + *curr = nentry;
61469 +
61470 + /* insert us into the table searchable by inode/dev */
61471 + insert_inodev_entry(ientry);
61472 +
61473 + return 1;
61474 +}
61475 +
61476 +static void
61477 +insert_acl_obj_label(struct acl_object_label *obj,
61478 + struct acl_subject_label *subj)
61479 +{
61480 + unsigned int index =
61481 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
61482 + struct acl_object_label **curr;
61483 +
61484 +
61485 + obj->prev = NULL;
61486 +
61487 + curr = &subj->obj_hash[index];
61488 + if (*curr != NULL)
61489 + (*curr)->prev = obj;
61490 +
61491 + obj->next = *curr;
61492 + *curr = obj;
61493 +
61494 + return;
61495 +}
61496 +
61497 +static void
61498 +insert_acl_subj_label(struct acl_subject_label *obj,
61499 + struct acl_role_label *role)
61500 +{
61501 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
61502 + struct acl_subject_label **curr;
61503 +
61504 + obj->prev = NULL;
61505 +
61506 + curr = &role->subj_hash[index];
61507 + if (*curr != NULL)
61508 + (*curr)->prev = obj;
61509 +
61510 + obj->next = *curr;
61511 + *curr = obj;
61512 +
61513 + return;
61514 +}
61515 +
61516 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
61517 +
61518 +static void *
61519 +create_table(__u32 * len, int elementsize)
61520 +{
61521 + unsigned int table_sizes[] = {
61522 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
61523 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
61524 + 4194301, 8388593, 16777213, 33554393, 67108859
61525 + };
61526 + void *newtable = NULL;
61527 + unsigned int pwr = 0;
61528 +
61529 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
61530 + table_sizes[pwr] <= *len)
61531 + pwr++;
61532 +
61533 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
61534 + return newtable;
61535 +
61536 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
61537 + newtable =
61538 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
61539 + else
61540 + newtable = vmalloc(table_sizes[pwr] * elementsize);
61541 +
61542 + *len = table_sizes[pwr];
61543 +
61544 + return newtable;
61545 +}
61546 +
61547 +static int
61548 +init_variables(const struct gr_arg *arg)
61549 +{
61550 + struct task_struct *reaper = init_pid_ns.child_reaper;
61551 + unsigned int stacksize;
61552 +
61553 + subj_map_set.s_size = arg->role_db.num_subjects;
61554 + acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
61555 + name_set.n_size = arg->role_db.num_objects;
61556 + inodev_set.i_size = arg->role_db.num_objects;
61557 +
61558 + if (!subj_map_set.s_size || !acl_role_set.r_size ||
61559 + !name_set.n_size || !inodev_set.i_size)
61560 + return 1;
61561 +
61562 + if (!gr_init_uidset())
61563 + return 1;
61564 +
61565 + /* set up the stack that holds allocation info */
61566 +
61567 + stacksize = arg->role_db.num_pointers + 5;
61568 +
61569 + if (!acl_alloc_stack_init(stacksize))
61570 + return 1;
61571 +
61572 + /* grab reference for the real root dentry and vfsmount */
61573 + get_fs_root(reaper->fs, &real_root);
61574 +
61575 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
61576 + printk(KERN_ALERT "Obtained real root device=%d, inode=%lu\n", __get_dev(real_root.dentry), real_root.dentry->d_inode->i_ino);
61577 +#endif
61578 +
61579 + fakefs_obj_rw = acl_alloc(sizeof(struct acl_object_label));
61580 + if (fakefs_obj_rw == NULL)
61581 + return 1;
61582 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
61583 +
61584 + fakefs_obj_rwx = acl_alloc(sizeof(struct acl_object_label));
61585 + if (fakefs_obj_rwx == NULL)
61586 + return 1;
61587 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
61588 +
61589 + subj_map_set.s_hash =
61590 + (struct subject_map **) create_table(&subj_map_set.s_size, sizeof(void *));
61591 + acl_role_set.r_hash =
61592 + (struct acl_role_label **) create_table(&acl_role_set.r_size, sizeof(void *));
61593 + name_set.n_hash = (struct name_entry **) create_table(&name_set.n_size, sizeof(void *));
61594 + inodev_set.i_hash =
61595 + (struct inodev_entry **) create_table(&inodev_set.i_size, sizeof(void *));
61596 +
61597 + if (!subj_map_set.s_hash || !acl_role_set.r_hash ||
61598 + !name_set.n_hash || !inodev_set.i_hash)
61599 + return 1;
61600 +
61601 + memset(subj_map_set.s_hash, 0,
61602 + sizeof(struct subject_map *) * subj_map_set.s_size);
61603 + memset(acl_role_set.r_hash, 0,
61604 + sizeof (struct acl_role_label *) * acl_role_set.r_size);
61605 + memset(name_set.n_hash, 0,
61606 + sizeof (struct name_entry *) * name_set.n_size);
61607 + memset(inodev_set.i_hash, 0,
61608 + sizeof (struct inodev_entry *) * inodev_set.i_size);
61609 +
61610 + return 0;
61611 +}
61612 +
61613 +/* free information not needed after startup
61614 + currently contains user->kernel pointer mappings for subjects
61615 +*/
61616 +
61617 +static void
61618 +free_init_variables(void)
61619 +{
61620 + __u32 i;
61621 +
61622 + if (subj_map_set.s_hash) {
61623 + for (i = 0; i < subj_map_set.s_size; i++) {
61624 + if (subj_map_set.s_hash[i]) {
61625 + kfree(subj_map_set.s_hash[i]);
61626 + subj_map_set.s_hash[i] = NULL;
61627 + }
61628 + }
61629 +
61630 + if ((subj_map_set.s_size * sizeof (struct subject_map *)) <=
61631 + PAGE_SIZE)
61632 + kfree(subj_map_set.s_hash);
61633 + else
61634 + vfree(subj_map_set.s_hash);
61635 + }
61636 +
61637 + return;
61638 +}
61639 +
61640 +static void
61641 +free_variables(void)
61642 +{
61643 + struct acl_subject_label *s;
61644 + struct acl_role_label *r;
61645 + struct task_struct *task, *task2;
61646 + unsigned int x;
61647 +
61648 + gr_clear_learn_entries();
61649 +
61650 + read_lock(&tasklist_lock);
61651 + do_each_thread(task2, task) {
61652 + task->acl_sp_role = 0;
61653 + task->acl_role_id = 0;
61654 + task->acl = NULL;
61655 + task->role = NULL;
61656 + } while_each_thread(task2, task);
61657 + read_unlock(&tasklist_lock);
61658 +
61659 + /* release the reference to the real root dentry and vfsmount */
61660 + path_put(&real_root);
61661 + memset(&real_root, 0, sizeof(real_root));
61662 +
61663 + /* free all object hash tables */
61664 +
61665 + FOR_EACH_ROLE_START(r)
61666 + if (r->subj_hash == NULL)
61667 + goto next_role;
61668 + FOR_EACH_SUBJECT_START(r, s, x)
61669 + if (s->obj_hash == NULL)
61670 + break;
61671 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
61672 + kfree(s->obj_hash);
61673 + else
61674 + vfree(s->obj_hash);
61675 + FOR_EACH_SUBJECT_END(s, x)
61676 + FOR_EACH_NESTED_SUBJECT_START(r, s)
61677 + if (s->obj_hash == NULL)
61678 + break;
61679 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
61680 + kfree(s->obj_hash);
61681 + else
61682 + vfree(s->obj_hash);
61683 + FOR_EACH_NESTED_SUBJECT_END(s)
61684 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
61685 + kfree(r->subj_hash);
61686 + else
61687 + vfree(r->subj_hash);
61688 + r->subj_hash = NULL;
61689 +next_role:
61690 + FOR_EACH_ROLE_END(r)
61691 +
61692 + acl_free_all();
61693 +
61694 + if (acl_role_set.r_hash) {
61695 + if ((acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
61696 + PAGE_SIZE)
61697 + kfree(acl_role_set.r_hash);
61698 + else
61699 + vfree(acl_role_set.r_hash);
61700 + }
61701 + if (name_set.n_hash) {
61702 + if ((name_set.n_size * sizeof (struct name_entry *)) <=
61703 + PAGE_SIZE)
61704 + kfree(name_set.n_hash);
61705 + else
61706 + vfree(name_set.n_hash);
61707 + }
61708 +
61709 + if (inodev_set.i_hash) {
61710 + if ((inodev_set.i_size * sizeof (struct inodev_entry *)) <=
61711 + PAGE_SIZE)
61712 + kfree(inodev_set.i_hash);
61713 + else
61714 + vfree(inodev_set.i_hash);
61715 + }
61716 +
61717 + gr_free_uidset();
61718 +
61719 + memset(&name_set, 0, sizeof (struct name_db));
61720 + memset(&inodev_set, 0, sizeof (struct inodev_db));
61721 + memset(&acl_role_set, 0, sizeof (struct acl_role_db));
61722 + memset(&subj_map_set, 0, sizeof (struct acl_subj_map_db));
61723 +
61724 + default_role = NULL;
61725 + kernel_role = NULL;
61726 + role_list = NULL;
61727 +
61728 + return;
61729 +}
61730 +
61731 +static struct acl_subject_label *
61732 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
61733 +
61734 +static int alloc_and_copy_string(char **name, unsigned int maxlen)
61735 +{
61736 + unsigned int len = strnlen_user(*name, maxlen);
61737 + char *tmp;
61738 +
61739 + if (!len || len >= maxlen)
61740 + return -EINVAL;
61741 +
61742 + if ((tmp = (char *) acl_alloc(len)) == NULL)
61743 + return -ENOMEM;
61744 +
61745 + if (copy_from_user(tmp, *name, len))
61746 + return -EFAULT;
61747 +
61748 + tmp[len-1] = '\0';
61749 + *name = tmp;
61750 +
61751 + return 0;
61752 +}
61753 +
61754 +static int
61755 +copy_user_glob(struct acl_object_label *obj)
61756 +{
61757 + struct acl_object_label *g_tmp, **guser;
61758 + int error;
61759 +
61760 + if (obj->globbed == NULL)
61761 + return 0;
61762 +
61763 + guser = &obj->globbed;
61764 + while (*guser) {
61765 + g_tmp = (struct acl_object_label *)
61766 + acl_alloc(sizeof (struct acl_object_label));
61767 + if (g_tmp == NULL)
61768 + return -ENOMEM;
61769 +
61770 + if (copy_acl_object_label(g_tmp, *guser))
61771 + return -EFAULT;
61772 +
61773 + error = alloc_and_copy_string(&g_tmp->filename, PATH_MAX);
61774 + if (error)
61775 + return error;
61776 +
61777 + *guser = g_tmp;
61778 + guser = &(g_tmp->next);
61779 + }
61780 +
61781 + return 0;
61782 +}
61783 +
61784 +static int
61785 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
61786 + struct acl_role_label *role)
61787 +{
61788 + struct acl_object_label *o_tmp;
61789 + int ret;
61790 +
61791 + while (userp) {
61792 + if ((o_tmp = (struct acl_object_label *)
61793 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
61794 + return -ENOMEM;
61795 +
61796 + if (copy_acl_object_label(o_tmp, userp))
61797 + return -EFAULT;
61798 +
61799 + userp = o_tmp->prev;
61800 +
61801 + ret = alloc_and_copy_string(&o_tmp->filename, PATH_MAX);
61802 + if (ret)
61803 + return ret;
61804 +
61805 + insert_acl_obj_label(o_tmp, subj);
61806 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
61807 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
61808 + return -ENOMEM;
61809 +
61810 + ret = copy_user_glob(o_tmp);
61811 + if (ret)
61812 + return ret;
61813 +
61814 + if (o_tmp->nested) {
61815 + int already_copied;
61816 +
61817 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
61818 + if (IS_ERR(o_tmp->nested))
61819 + return PTR_ERR(o_tmp->nested);
61820 +
61821 + /* insert into nested subject list if we haven't copied this one yet
61822 + to prevent duplicate entries */
61823 + if (!already_copied) {
61824 + o_tmp->nested->next = role->hash->first;
61825 + role->hash->first = o_tmp->nested;
61826 + }
61827 + }
61828 + }
61829 +
61830 + return 0;
61831 +}
61832 +
61833 +static __u32
61834 +count_user_subjs(struct acl_subject_label *userp)
61835 +{
61836 + struct acl_subject_label s_tmp;
61837 + __u32 num = 0;
61838 +
61839 + while (userp) {
61840 + if (copy_acl_subject_label(&s_tmp, userp))
61841 + break;
61842 +
61843 + userp = s_tmp.prev;
61844 + }
61845 +
61846 + return num;
61847 +}
61848 +
61849 +static int
61850 +copy_user_allowedips(struct acl_role_label *rolep)
61851 +{
61852 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
61853 +
61854 + ruserip = rolep->allowed_ips;
61855 +
61856 + while (ruserip) {
61857 + rlast = rtmp;
61858 +
61859 + if ((rtmp = (struct role_allowed_ip *)
61860 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
61861 + return -ENOMEM;
61862 +
61863 + if (copy_role_allowed_ip(rtmp, ruserip))
61864 + return -EFAULT;
61865 +
61866 + ruserip = rtmp->prev;
61867 +
61868 + if (!rlast) {
61869 + rtmp->prev = NULL;
61870 + rolep->allowed_ips = rtmp;
61871 + } else {
61872 + rlast->next = rtmp;
61873 + rtmp->prev = rlast;
61874 + }
61875 +
61876 + if (!ruserip)
61877 + rtmp->next = NULL;
61878 + }
61879 +
61880 + return 0;
61881 +}
61882 +
61883 +static int
61884 +copy_user_transitions(struct acl_role_label *rolep)
61885 +{
61886 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
61887 + int error;
61888 +
61889 + rusertp = rolep->transitions;
61890 +
61891 + while (rusertp) {
61892 + rlast = rtmp;
61893 +
61894 + if ((rtmp = (struct role_transition *)
61895 + acl_alloc(sizeof (struct role_transition))) == NULL)
61896 + return -ENOMEM;
61897 +
61898 + if (copy_role_transition(rtmp, rusertp))
61899 + return -EFAULT;
61900 +
61901 + rusertp = rtmp->prev;
61902 +
61903 + error = alloc_and_copy_string(&rtmp->rolename, GR_SPROLE_LEN);
61904 + if (error)
61905 + return error;
61906 +
61907 + if (!rlast) {
61908 + rtmp->prev = NULL;
61909 + rolep->transitions = rtmp;
61910 + } else {
61911 + rlast->next = rtmp;
61912 + rtmp->prev = rlast;
61913 + }
61914 +
61915 + if (!rusertp)
61916 + rtmp->next = NULL;
61917 + }
61918 +
61919 + return 0;
61920 +}
61921 +
61922 +static __u32 count_user_objs(const struct acl_object_label __user *userp)
61923 +{
61924 + struct acl_object_label o_tmp;
61925 + __u32 num = 0;
61926 +
61927 + while (userp) {
61928 + if (copy_acl_object_label(&o_tmp, userp))
61929 + break;
61930 +
61931 + userp = o_tmp.prev;
61932 + num++;
61933 + }
61934 +
61935 + return num;
61936 +}
61937 +
61938 +static struct acl_subject_label *
61939 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
61940 +{
61941 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
61942 + __u32 num_objs;
61943 + struct acl_ip_label **i_tmp, *i_utmp2;
61944 + struct gr_hash_struct ghash;
61945 + struct subject_map *subjmap;
61946 + unsigned int i_num;
61947 + int err;
61948 +
61949 + if (already_copied != NULL)
61950 + *already_copied = 0;
61951 +
61952 + s_tmp = lookup_subject_map(userp);
61953 +
61954 + /* we've already copied this subject into the kernel, just return
61955 + the reference to it, and don't copy it over again
61956 + */
61957 + if (s_tmp) {
61958 + if (already_copied != NULL)
61959 + *already_copied = 1;
61960 + return(s_tmp);
61961 + }
61962 +
61963 + if ((s_tmp = (struct acl_subject_label *)
61964 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
61965 + return ERR_PTR(-ENOMEM);
61966 +
61967 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
61968 + if (subjmap == NULL)
61969 + return ERR_PTR(-ENOMEM);
61970 +
61971 + subjmap->user = userp;
61972 + subjmap->kernel = s_tmp;
61973 + insert_subj_map_entry(subjmap);
61974 +
61975 + if (copy_acl_subject_label(s_tmp, userp))
61976 + return ERR_PTR(-EFAULT);
61977 +
61978 + err = alloc_and_copy_string(&s_tmp->filename, PATH_MAX);
61979 + if (err)
61980 + return ERR_PTR(err);
61981 +
61982 + if (!strcmp(s_tmp->filename, "/"))
61983 + role->root_label = s_tmp;
61984 +
61985 + if (copy_gr_hash_struct(&ghash, s_tmp->hash))
61986 + return ERR_PTR(-EFAULT);
61987 +
61988 + /* copy user and group transition tables */
61989 +
61990 + if (s_tmp->user_trans_num) {
61991 + uid_t *uidlist;
61992 +
61993 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
61994 + if (uidlist == NULL)
61995 + return ERR_PTR(-ENOMEM);
61996 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
61997 + return ERR_PTR(-EFAULT);
61998 +
61999 + s_tmp->user_transitions = uidlist;
62000 + }
62001 +
62002 + if (s_tmp->group_trans_num) {
62003 + gid_t *gidlist;
62004 +
62005 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
62006 + if (gidlist == NULL)
62007 + return ERR_PTR(-ENOMEM);
62008 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
62009 + return ERR_PTR(-EFAULT);
62010 +
62011 + s_tmp->group_transitions = gidlist;
62012 + }
62013 +
62014 + /* set up object hash table */
62015 + num_objs = count_user_objs(ghash.first);
62016 +
62017 + s_tmp->obj_hash_size = num_objs;
62018 + s_tmp->obj_hash =
62019 + (struct acl_object_label **)
62020 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
62021 +
62022 + if (!s_tmp->obj_hash)
62023 + return ERR_PTR(-ENOMEM);
62024 +
62025 + memset(s_tmp->obj_hash, 0,
62026 + s_tmp->obj_hash_size *
62027 + sizeof (struct acl_object_label *));
62028 +
62029 + /* add in objects */
62030 + err = copy_user_objs(ghash.first, s_tmp, role);
62031 +
62032 + if (err)
62033 + return ERR_PTR(err);
62034 +
62035 + /* set pointer for parent subject */
62036 + if (s_tmp->parent_subject) {
62037 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
62038 +
62039 + if (IS_ERR(s_tmp2))
62040 + return s_tmp2;
62041 +
62042 + s_tmp->parent_subject = s_tmp2;
62043 + }
62044 +
62045 + /* add in ip acls */
62046 +
62047 + if (!s_tmp->ip_num) {
62048 + s_tmp->ips = NULL;
62049 + goto insert;
62050 + }
62051 +
62052 + i_tmp =
62053 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
62054 + sizeof (struct acl_ip_label *));
62055 +
62056 + if (!i_tmp)
62057 + return ERR_PTR(-ENOMEM);
62058 +
62059 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
62060 + *(i_tmp + i_num) =
62061 + (struct acl_ip_label *)
62062 + acl_alloc(sizeof (struct acl_ip_label));
62063 + if (!*(i_tmp + i_num))
62064 + return ERR_PTR(-ENOMEM);
62065 +
62066 + if (copy_pointer_from_array(&i_utmp2, i_num, s_tmp->ips))
62067 + return ERR_PTR(-EFAULT);
62068 +
62069 + if (copy_acl_ip_label(*(i_tmp + i_num), i_utmp2))
62070 + return ERR_PTR(-EFAULT);
62071 +
62072 + if ((*(i_tmp + i_num))->iface == NULL)
62073 + continue;
62074 +
62075 + err = alloc_and_copy_string(&(*(i_tmp + i_num))->iface, IFNAMSIZ);
62076 + if (err)
62077 + return ERR_PTR(err);
62078 + }
62079 +
62080 + s_tmp->ips = i_tmp;
62081 +
62082 +insert:
62083 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
62084 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
62085 + return ERR_PTR(-ENOMEM);
62086 +
62087 + return s_tmp;
62088 +}
62089 +
62090 +static int
62091 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
62092 +{
62093 + struct acl_subject_label s_pre;
62094 + struct acl_subject_label * ret;
62095 + int err;
62096 +
62097 + while (userp) {
62098 + if (copy_acl_subject_label(&s_pre, userp))
62099 + return -EFAULT;
62100 +
62101 + ret = do_copy_user_subj(userp, role, NULL);
62102 +
62103 + err = PTR_ERR(ret);
62104 + if (IS_ERR(ret))
62105 + return err;
62106 +
62107 + insert_acl_subj_label(ret, role);
62108 +
62109 + userp = s_pre.prev;
62110 + }
62111 +
62112 + return 0;
62113 +}
62114 +
62115 +static int
62116 +copy_user_acl(struct gr_arg *arg)
62117 +{
62118 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
62119 + struct acl_subject_label *subj_list;
62120 + struct sprole_pw *sptmp;
62121 + struct gr_hash_struct *ghash;
62122 + uid_t *domainlist;
62123 + unsigned int r_num;
62124 + int err = 0;
62125 + __u16 i;
62126 + __u32 num_subjs;
62127 +
62128 + /* we need a default and kernel role */
62129 + if (arg->role_db.num_roles < 2)
62130 + return -EINVAL;
62131 +
62132 + /* copy special role authentication info from userspace */
62133 +
62134 + num_sprole_pws = arg->num_sprole_pws;
62135 + acl_special_roles = (struct sprole_pw **) acl_alloc_num(num_sprole_pws, sizeof(struct sprole_pw *));
62136 +
62137 + if (!acl_special_roles && num_sprole_pws)
62138 + return -ENOMEM;
62139 +
62140 + for (i = 0; i < num_sprole_pws; i++) {
62141 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
62142 + if (!sptmp)
62143 + return -ENOMEM;
62144 + if (copy_sprole_pw(sptmp, i, arg->sprole_pws))
62145 + return -EFAULT;
62146 +
62147 + err = alloc_and_copy_string((char **)&sptmp->rolename, GR_SPROLE_LEN);
62148 + if (err)
62149 + return err;
62150 +
62151 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
62152 + printk(KERN_ALERT "Copying special role %s\n", sptmp->rolename);
62153 +#endif
62154 +
62155 + acl_special_roles[i] = sptmp;
62156 + }
62157 +
62158 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
62159 +
62160 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
62161 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
62162 +
62163 + if (!r_tmp)
62164 + return -ENOMEM;
62165 +
62166 + if (copy_pointer_from_array(&r_utmp2, r_num, r_utmp))
62167 + return -EFAULT;
62168 +
62169 + if (copy_acl_role_label(r_tmp, r_utmp2))
62170 + return -EFAULT;
62171 +
62172 + err = alloc_and_copy_string(&r_tmp->rolename, GR_SPROLE_LEN);
62173 + if (err)
62174 + return err;
62175 +
62176 + if (!strcmp(r_tmp->rolename, "default")
62177 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
62178 + default_role = r_tmp;
62179 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
62180 + kernel_role = r_tmp;
62181 + }
62182 +
62183 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
62184 + return -ENOMEM;
62185 +
62186 + if (copy_gr_hash_struct(ghash, r_tmp->hash))
62187 + return -EFAULT;
62188 +
62189 + r_tmp->hash = ghash;
62190 +
62191 + num_subjs = count_user_subjs(r_tmp->hash->first);
62192 +
62193 + r_tmp->subj_hash_size = num_subjs;
62194 + r_tmp->subj_hash =
62195 + (struct acl_subject_label **)
62196 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
62197 +
62198 + if (!r_tmp->subj_hash)
62199 + return -ENOMEM;
62200 +
62201 + err = copy_user_allowedips(r_tmp);
62202 + if (err)
62203 + return err;
62204 +
62205 + /* copy domain info */
62206 + if (r_tmp->domain_children != NULL) {
62207 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
62208 + if (domainlist == NULL)
62209 + return -ENOMEM;
62210 +
62211 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
62212 + return -EFAULT;
62213 +
62214 + r_tmp->domain_children = domainlist;
62215 + }
62216 +
62217 + err = copy_user_transitions(r_tmp);
62218 + if (err)
62219 + return err;
62220 +
62221 + memset(r_tmp->subj_hash, 0,
62222 + r_tmp->subj_hash_size *
62223 + sizeof (struct acl_subject_label *));
62224 +
62225 + /* acquire the list of subjects, then NULL out
62226 + the list prior to parsing the subjects for this role,
62227 + as during this parsing the list is replaced with a list
62228 + of *nested* subjects for the role
62229 + */
62230 + subj_list = r_tmp->hash->first;
62231 +
62232 + /* set nested subject list to null */
62233 + r_tmp->hash->first = NULL;
62234 +
62235 + err = copy_user_subjs(subj_list, r_tmp);
62236 +
62237 + if (err)
62238 + return err;
62239 +
62240 + insert_acl_role_label(r_tmp);
62241 + }
62242 +
62243 + if (default_role == NULL || kernel_role == NULL)
62244 + return -EINVAL;
62245 +
62246 + return err;
62247 +}
62248 +
62249 +static int
62250 +gracl_init(struct gr_arg *args)
62251 +{
62252 + int error = 0;
62253 +
62254 + memcpy(gr_system_salt, args->salt, GR_SALT_LEN);
62255 + memcpy(gr_system_sum, args->sum, GR_SHA_LEN);
62256 +
62257 + if (init_variables(args)) {
62258 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
62259 + error = -ENOMEM;
62260 + free_variables();
62261 + goto out;
62262 + }
62263 +
62264 + error = copy_user_acl(args);
62265 + free_init_variables();
62266 + if (error) {
62267 + free_variables();
62268 + goto out;
62269 + }
62270 +
62271 + if ((error = gr_set_acls(0))) {
62272 + free_variables();
62273 + goto out;
62274 + }
62275 +
62276 + pax_open_kernel();
62277 + gr_status |= GR_READY;
62278 + pax_close_kernel();
62279 +
62280 + out:
62281 + return error;
62282 +}
62283 +
62284 +/* derived from glibc fnmatch() 0: match, 1: no match*/
62285 +
62286 +static int
62287 +glob_match(const char *p, const char *n)
62288 +{
62289 + char c;
62290 +
62291 + while ((c = *p++) != '\0') {
62292 + switch (c) {
62293 + case '?':
62294 + if (*n == '\0')
62295 + return 1;
62296 + else if (*n == '/')
62297 + return 1;
62298 + break;
62299 + case '\\':
62300 + if (*n != c)
62301 + return 1;
62302 + break;
62303 + case '*':
62304 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
62305 + if (*n == '/')
62306 + return 1;
62307 + else if (c == '?') {
62308 + if (*n == '\0')
62309 + return 1;
62310 + else
62311 + ++n;
62312 + }
62313 + }
62314 + if (c == '\0') {
62315 + return 0;
62316 + } else {
62317 + const char *endp;
62318 +
62319 + if ((endp = strchr(n, '/')) == NULL)
62320 + endp = n + strlen(n);
62321 +
62322 + if (c == '[') {
62323 + for (--p; n < endp; ++n)
62324 + if (!glob_match(p, n))
62325 + return 0;
62326 + } else if (c == '/') {
62327 + while (*n != '\0' && *n != '/')
62328 + ++n;
62329 + if (*n == '/' && !glob_match(p, n + 1))
62330 + return 0;
62331 + } else {
62332 + for (--p; n < endp; ++n)
62333 + if (*n == c && !glob_match(p, n))
62334 + return 0;
62335 + }
62336 +
62337 + return 1;
62338 + }
62339 + case '[':
62340 + {
62341 + int not;
62342 + char cold;
62343 +
62344 + if (*n == '\0' || *n == '/')
62345 + return 1;
62346 +
62347 + not = (*p == '!' || *p == '^');
62348 + if (not)
62349 + ++p;
62350 +
62351 + c = *p++;
62352 + for (;;) {
62353 + unsigned char fn = (unsigned char)*n;
62354 +
62355 + if (c == '\0')
62356 + return 1;
62357 + else {
62358 + if (c == fn)
62359 + goto matched;
62360 + cold = c;
62361 + c = *p++;
62362 +
62363 + if (c == '-' && *p != ']') {
62364 + unsigned char cend = *p++;
62365 +
62366 + if (cend == '\0')
62367 + return 1;
62368 +
62369 + if (cold <= fn && fn <= cend)
62370 + goto matched;
62371 +
62372 + c = *p++;
62373 + }
62374 + }
62375 +
62376 + if (c == ']')
62377 + break;
62378 + }
62379 + if (!not)
62380 + return 1;
62381 + break;
62382 + matched:
62383 + while (c != ']') {
62384 + if (c == '\0')
62385 + return 1;
62386 +
62387 + c = *p++;
62388 + }
62389 + if (not)
62390 + return 1;
62391 + }
62392 + break;
62393 + default:
62394 + if (c != *n)
62395 + return 1;
62396 + }
62397 +
62398 + ++n;
62399 + }
62400 +
62401 + if (*n == '\0')
62402 + return 0;
62403 +
62404 + if (*n == '/')
62405 + return 0;
62406 +
62407 + return 1;
62408 +}
62409 +
62410 +static struct acl_object_label *
62411 +chk_glob_label(struct acl_object_label *globbed,
62412 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
62413 +{
62414 + struct acl_object_label *tmp;
62415 +
62416 + if (*path == NULL)
62417 + *path = gr_to_filename_nolock(dentry, mnt);
62418 +
62419 + tmp = globbed;
62420 +
62421 + while (tmp) {
62422 + if (!glob_match(tmp->filename, *path))
62423 + return tmp;
62424 + tmp = tmp->next;
62425 + }
62426 +
62427 + return NULL;
62428 +}
62429 +
62430 +static struct acl_object_label *
62431 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
62432 + const ino_t curr_ino, const dev_t curr_dev,
62433 + const struct acl_subject_label *subj, char **path, const int checkglob)
62434 +{
62435 + struct acl_subject_label *tmpsubj;
62436 + struct acl_object_label *retval;
62437 + struct acl_object_label *retval2;
62438 +
62439 + tmpsubj = (struct acl_subject_label *) subj;
62440 + read_lock(&gr_inode_lock);
62441 + do {
62442 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
62443 + if (retval) {
62444 + if (checkglob && retval->globbed) {
62445 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
62446 + if (retval2)
62447 + retval = retval2;
62448 + }
62449 + break;
62450 + }
62451 + } while ((tmpsubj = tmpsubj->parent_subject));
62452 + read_unlock(&gr_inode_lock);
62453 +
62454 + return retval;
62455 +}
62456 +
62457 +static __inline__ struct acl_object_label *
62458 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
62459 + struct dentry *curr_dentry,
62460 + const struct acl_subject_label *subj, char **path, const int checkglob)
62461 +{
62462 + int newglob = checkglob;
62463 + ino_t inode;
62464 + dev_t device;
62465 +
62466 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
62467 + as we don't want a / * rule to match instead of the / object
62468 + don't do this for create lookups that call this function though, since they're looking up
62469 + on the parent and thus need globbing checks on all paths
62470 + */
62471 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
62472 + newglob = GR_NO_GLOB;
62473 +
62474 + spin_lock(&curr_dentry->d_lock);
62475 + inode = curr_dentry->d_inode->i_ino;
62476 + device = __get_dev(curr_dentry);
62477 + spin_unlock(&curr_dentry->d_lock);
62478 +
62479 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
62480 +}
62481 +
62482 +#ifdef CONFIG_HUGETLBFS
62483 +static inline bool
62484 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
62485 +{
62486 + int i;
62487 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
62488 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
62489 + return true;
62490 + }
62491 +
62492 + return false;
62493 +}
62494 +#endif
62495 +
62496 +static struct acl_object_label *
62497 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
62498 + const struct acl_subject_label *subj, char *path, const int checkglob)
62499 +{
62500 + struct dentry *dentry = (struct dentry *) l_dentry;
62501 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
62502 + struct mount *real_mnt = real_mount(mnt);
62503 + struct acl_object_label *retval;
62504 + struct dentry *parent;
62505 +
62506 + br_read_lock(&vfsmount_lock);
62507 + write_seqlock(&rename_lock);
62508 +
62509 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
62510 +#ifdef CONFIG_NET
62511 + mnt == sock_mnt ||
62512 +#endif
62513 +#ifdef CONFIG_HUGETLBFS
62514 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
62515 +#endif
62516 + /* ignore Eric Biederman */
62517 + IS_PRIVATE(l_dentry->d_inode))) {
62518 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
62519 + goto out;
62520 + }
62521 +
62522 + for (;;) {
62523 + if (dentry == real_root.dentry && mnt == real_root.mnt)
62524 + break;
62525 +
62526 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
62527 + if (!mnt_has_parent(real_mnt))
62528 + break;
62529 +
62530 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
62531 + if (retval != NULL)
62532 + goto out;
62533 +
62534 + dentry = real_mnt->mnt_mountpoint;
62535 + real_mnt = real_mnt->mnt_parent;
62536 + mnt = &real_mnt->mnt;
62537 + continue;
62538 + }
62539 +
62540 + parent = dentry->d_parent;
62541 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
62542 + if (retval != NULL)
62543 + goto out;
62544 +
62545 + dentry = parent;
62546 + }
62547 +
62548 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
62549 +
62550 + /* real_root is pinned so we don't have to hold a reference */
62551 + if (retval == NULL)
62552 + retval = full_lookup(l_dentry, l_mnt, real_root.dentry, subj, &path, checkglob);
62553 +out:
62554 + write_sequnlock(&rename_lock);
62555 + br_read_unlock(&vfsmount_lock);
62556 +
62557 + BUG_ON(retval == NULL);
62558 +
62559 + return retval;
62560 +}
62561 +
62562 +static __inline__ struct acl_object_label *
62563 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
62564 + const struct acl_subject_label *subj)
62565 +{
62566 + char *path = NULL;
62567 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
62568 +}
62569 +
62570 +static __inline__ struct acl_object_label *
62571 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
62572 + const struct acl_subject_label *subj)
62573 +{
62574 + char *path = NULL;
62575 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
62576 +}
62577 +
62578 +static __inline__ struct acl_object_label *
62579 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
62580 + const struct acl_subject_label *subj, char *path)
62581 +{
62582 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
62583 +}
62584 +
62585 +static struct acl_subject_label *
62586 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
62587 + const struct acl_role_label *role)
62588 +{
62589 + struct dentry *dentry = (struct dentry *) l_dentry;
62590 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
62591 + struct mount *real_mnt = real_mount(mnt);
62592 + struct acl_subject_label *retval;
62593 + struct dentry *parent;
62594 +
62595 + br_read_lock(&vfsmount_lock);
62596 + write_seqlock(&rename_lock);
62597 +
62598 + for (;;) {
62599 + if (dentry == real_root.dentry && mnt == real_root.mnt)
62600 + break;
62601 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
62602 + if (!mnt_has_parent(real_mnt))
62603 + break;
62604 +
62605 + spin_lock(&dentry->d_lock);
62606 + read_lock(&gr_inode_lock);
62607 + retval =
62608 + lookup_acl_subj_label(dentry->d_inode->i_ino,
62609 + __get_dev(dentry), role);
62610 + read_unlock(&gr_inode_lock);
62611 + spin_unlock(&dentry->d_lock);
62612 + if (retval != NULL)
62613 + goto out;
62614 +
62615 + dentry = real_mnt->mnt_mountpoint;
62616 + real_mnt = real_mnt->mnt_parent;
62617 + mnt = &real_mnt->mnt;
62618 + continue;
62619 + }
62620 +
62621 + spin_lock(&dentry->d_lock);
62622 + read_lock(&gr_inode_lock);
62623 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
62624 + __get_dev(dentry), role);
62625 + read_unlock(&gr_inode_lock);
62626 + parent = dentry->d_parent;
62627 + spin_unlock(&dentry->d_lock);
62628 +
62629 + if (retval != NULL)
62630 + goto out;
62631 +
62632 + dentry = parent;
62633 + }
62634 +
62635 + spin_lock(&dentry->d_lock);
62636 + read_lock(&gr_inode_lock);
62637 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
62638 + __get_dev(dentry), role);
62639 + read_unlock(&gr_inode_lock);
62640 + spin_unlock(&dentry->d_lock);
62641 +
62642 + if (unlikely(retval == NULL)) {
62643 + /* real_root is pinned, we don't need to hold a reference */
62644 + read_lock(&gr_inode_lock);
62645 + retval = lookup_acl_subj_label(real_root.dentry->d_inode->i_ino,
62646 + __get_dev(real_root.dentry), role);
62647 + read_unlock(&gr_inode_lock);
62648 + }
62649 +out:
62650 + write_sequnlock(&rename_lock);
62651 + br_read_unlock(&vfsmount_lock);
62652 +
62653 + BUG_ON(retval == NULL);
62654 +
62655 + return retval;
62656 +}
62657 +
62658 +static void
62659 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
62660 +{
62661 + struct task_struct *task = current;
62662 + const struct cred *cred = current_cred();
62663 +
62664 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
62665 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
62666 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
62667 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
62668 +
62669 + return;
62670 +}
62671 +
62672 +static void
62673 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
62674 +{
62675 + struct task_struct *task = current;
62676 + const struct cred *cred = current_cred();
62677 +
62678 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
62679 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
62680 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
62681 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
62682 +
62683 + return;
62684 +}
62685 +
62686 +static void
62687 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
62688 +{
62689 + struct task_struct *task = current;
62690 + const struct cred *cred = current_cred();
62691 +
62692 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
62693 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
62694 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
62695 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
62696 +
62697 + return;
62698 +}
62699 +
62700 +__u32
62701 +gr_search_file(const struct dentry * dentry, const __u32 mode,
62702 + const struct vfsmount * mnt)
62703 +{
62704 + __u32 retval = mode;
62705 + struct acl_subject_label *curracl;
62706 + struct acl_object_label *currobj;
62707 +
62708 + if (unlikely(!(gr_status & GR_READY)))
62709 + return (mode & ~GR_AUDITS);
62710 +
62711 + curracl = current->acl;
62712 +
62713 + currobj = chk_obj_label(dentry, mnt, curracl);
62714 + retval = currobj->mode & mode;
62715 +
62716 + /* if we're opening a specified transfer file for writing
62717 + (e.g. /dev/initctl), then transfer our role to init
62718 + */
62719 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
62720 + current->role->roletype & GR_ROLE_PERSIST)) {
62721 + struct task_struct *task = init_pid_ns.child_reaper;
62722 +
62723 + if (task->role != current->role) {
62724 + task->acl_sp_role = 0;
62725 + task->acl_role_id = current->acl_role_id;
62726 + task->role = current->role;
62727 + rcu_read_lock();
62728 + read_lock(&grsec_exec_file_lock);
62729 + gr_apply_subject_to_task(task);
62730 + read_unlock(&grsec_exec_file_lock);
62731 + rcu_read_unlock();
62732 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
62733 + }
62734 + }
62735 +
62736 + if (unlikely
62737 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
62738 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
62739 + __u32 new_mode = mode;
62740 +
62741 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
62742 +
62743 + retval = new_mode;
62744 +
62745 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
62746 + new_mode |= GR_INHERIT;
62747 +
62748 + if (!(mode & GR_NOLEARN))
62749 + gr_log_learn(dentry, mnt, new_mode);
62750 + }
62751 +
62752 + return retval;
62753 +}
62754 +
62755 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
62756 + const struct dentry *parent,
62757 + const struct vfsmount *mnt)
62758 +{
62759 + struct name_entry *match;
62760 + struct acl_object_label *matchpo;
62761 + struct acl_subject_label *curracl;
62762 + char *path;
62763 +
62764 + if (unlikely(!(gr_status & GR_READY)))
62765 + return NULL;
62766 +
62767 + preempt_disable();
62768 + path = gr_to_filename_rbac(new_dentry, mnt);
62769 + match = lookup_name_entry_create(path);
62770 +
62771 + curracl = current->acl;
62772 +
62773 + if (match) {
62774 + read_lock(&gr_inode_lock);
62775 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
62776 + read_unlock(&gr_inode_lock);
62777 +
62778 + if (matchpo) {
62779 + preempt_enable();
62780 + return matchpo;
62781 + }
62782 + }
62783 +
62784 + // lookup parent
62785 +
62786 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
62787 +
62788 + preempt_enable();
62789 + return matchpo;
62790 +}
62791 +
62792 +__u32
62793 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
62794 + const struct vfsmount * mnt, const __u32 mode)
62795 +{
62796 + struct acl_object_label *matchpo;
62797 + __u32 retval;
62798 +
62799 + if (unlikely(!(gr_status & GR_READY)))
62800 + return (mode & ~GR_AUDITS);
62801 +
62802 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
62803 +
62804 + retval = matchpo->mode & mode;
62805 +
62806 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
62807 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
62808 + __u32 new_mode = mode;
62809 +
62810 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
62811 +
62812 + gr_log_learn(new_dentry, mnt, new_mode);
62813 + return new_mode;
62814 + }
62815 +
62816 + return retval;
62817 +}
62818 +
62819 +__u32
62820 +gr_check_link(const struct dentry * new_dentry,
62821 + const struct dentry * parent_dentry,
62822 + const struct vfsmount * parent_mnt,
62823 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
62824 +{
62825 + struct acl_object_label *obj;
62826 + __u32 oldmode, newmode;
62827 + __u32 needmode;
62828 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
62829 + GR_DELETE | GR_INHERIT;
62830 +
62831 + if (unlikely(!(gr_status & GR_READY)))
62832 + return (GR_CREATE | GR_LINK);
62833 +
62834 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
62835 + oldmode = obj->mode;
62836 +
62837 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
62838 + newmode = obj->mode;
62839 +
62840 + needmode = newmode & checkmodes;
62841 +
62842 + // old name for hardlink must have at least the permissions of the new name
62843 + if ((oldmode & needmode) != needmode)
62844 + goto bad;
62845 +
62846 + // if old name had restrictions/auditing, make sure the new name does as well
62847 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
62848 +
62849 + // don't allow hardlinking of suid/sgid/fcapped files without permission
62850 + if (is_privileged_binary(old_dentry))
62851 + needmode |= GR_SETID;
62852 +
62853 + if ((newmode & needmode) != needmode)
62854 + goto bad;
62855 +
62856 + // enforce minimum permissions
62857 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
62858 + return newmode;
62859 +bad:
62860 + needmode = oldmode;
62861 + if (is_privileged_binary(old_dentry))
62862 + needmode |= GR_SETID;
62863 +
62864 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
62865 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
62866 + return (GR_CREATE | GR_LINK);
62867 + } else if (newmode & GR_SUPPRESS)
62868 + return GR_SUPPRESS;
62869 + else
62870 + return 0;
62871 +}
62872 +
62873 +int
62874 +gr_check_hidden_task(const struct task_struct *task)
62875 +{
62876 + if (unlikely(!(gr_status & GR_READY)))
62877 + return 0;
62878 +
62879 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
62880 + return 1;
62881 +
62882 + return 0;
62883 +}
62884 +
62885 +int
62886 +gr_check_protected_task(const struct task_struct *task)
62887 +{
62888 + if (unlikely(!(gr_status & GR_READY) || !task))
62889 + return 0;
62890 +
62891 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
62892 + task->acl != current->acl)
62893 + return 1;
62894 +
62895 + return 0;
62896 +}
62897 +
62898 +int
62899 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
62900 +{
62901 + struct task_struct *p;
62902 + int ret = 0;
62903 +
62904 + if (unlikely(!(gr_status & GR_READY) || !pid))
62905 + return ret;
62906 +
62907 + read_lock(&tasklist_lock);
62908 + do_each_pid_task(pid, type, p) {
62909 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
62910 + p->acl != current->acl) {
62911 + ret = 1;
62912 + goto out;
62913 + }
62914 + } while_each_pid_task(pid, type, p);
62915 +out:
62916 + read_unlock(&tasklist_lock);
62917 +
62918 + return ret;
62919 +}
62920 +
62921 +void
62922 +gr_copy_label(struct task_struct *tsk)
62923 +{
62924 + tsk->signal->used_accept = 0;
62925 + tsk->acl_sp_role = 0;
62926 + tsk->acl_role_id = current->acl_role_id;
62927 + tsk->acl = current->acl;
62928 + tsk->role = current->role;
62929 + tsk->signal->curr_ip = current->signal->curr_ip;
62930 + tsk->signal->saved_ip = current->signal->saved_ip;
62931 + if (current->exec_file)
62932 + get_file(current->exec_file);
62933 + tsk->exec_file = current->exec_file;
62934 + tsk->is_writable = current->is_writable;
62935 + if (unlikely(current->signal->used_accept)) {
62936 + current->signal->curr_ip = 0;
62937 + current->signal->saved_ip = 0;
62938 + }
62939 +
62940 + return;
62941 +}
62942 +
62943 +static void
62944 +gr_set_proc_res(struct task_struct *task)
62945 +{
62946 + struct acl_subject_label *proc;
62947 + unsigned short i;
62948 +
62949 + proc = task->acl;
62950 +
62951 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
62952 + return;
62953 +
62954 + for (i = 0; i < RLIM_NLIMITS; i++) {
62955 + if (!(proc->resmask & (1U << i)))
62956 + continue;
62957 +
62958 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
62959 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
62960 +
62961 + if (i == RLIMIT_CPU)
62962 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
62963 + }
62964 +
62965 + return;
62966 +}
62967 +
62968 +extern int gr_process_kernel_setuid_ban(struct user_struct *user);
62969 +
62970 +int
62971 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
62972 +{
62973 + unsigned int i;
62974 + __u16 num;
62975 + uid_t *uidlist;
62976 + uid_t curuid;
62977 + int realok = 0;
62978 + int effectiveok = 0;
62979 + int fsok = 0;
62980 + uid_t globalreal, globaleffective, globalfs;
62981 +
62982 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT)
62983 + struct user_struct *user;
62984 +
62985 + if (!uid_valid(real))
62986 + goto skipit;
62987 +
62988 + /* find user based on global namespace */
62989 +
62990 + globalreal = GR_GLOBAL_UID(real);
62991 +
62992 + user = find_user(make_kuid(&init_user_ns, globalreal));
62993 + if (user == NULL)
62994 + goto skipit;
62995 +
62996 + if (gr_process_kernel_setuid_ban(user)) {
62997 + /* for find_user */
62998 + free_uid(user);
62999 + return 1;
63000 + }
63001 +
63002 + /* for find_user */
63003 + free_uid(user);
63004 +
63005 +skipit:
63006 +#endif
63007 +
63008 + if (unlikely(!(gr_status & GR_READY)))
63009 + return 0;
63010 +
63011 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
63012 + gr_log_learn_uid_change(real, effective, fs);
63013 +
63014 + num = current->acl->user_trans_num;
63015 + uidlist = current->acl->user_transitions;
63016 +
63017 + if (uidlist == NULL)
63018 + return 0;
63019 +
63020 + if (!uid_valid(real)) {
63021 + realok = 1;
63022 + globalreal = (uid_t)-1;
63023 + } else {
63024 + globalreal = GR_GLOBAL_UID(real);
63025 + }
63026 + if (!uid_valid(effective)) {
63027 + effectiveok = 1;
63028 + globaleffective = (uid_t)-1;
63029 + } else {
63030 + globaleffective = GR_GLOBAL_UID(effective);
63031 + }
63032 + if (!uid_valid(fs)) {
63033 + fsok = 1;
63034 + globalfs = (uid_t)-1;
63035 + } else {
63036 + globalfs = GR_GLOBAL_UID(fs);
63037 + }
63038 +
63039 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
63040 + for (i = 0; i < num; i++) {
63041 + curuid = uidlist[i];
63042 + if (globalreal == curuid)
63043 + realok = 1;
63044 + if (globaleffective == curuid)
63045 + effectiveok = 1;
63046 + if (globalfs == curuid)
63047 + fsok = 1;
63048 + }
63049 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
63050 + for (i = 0; i < num; i++) {
63051 + curuid = uidlist[i];
63052 + if (globalreal == curuid)
63053 + break;
63054 + if (globaleffective == curuid)
63055 + break;
63056 + if (globalfs == curuid)
63057 + break;
63058 + }
63059 + /* not in deny list */
63060 + if (i == num) {
63061 + realok = 1;
63062 + effectiveok = 1;
63063 + fsok = 1;
63064 + }
63065 + }
63066 +
63067 + if (realok && effectiveok && fsok)
63068 + return 0;
63069 + else {
63070 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
63071 + return 1;
63072 + }
63073 +}
63074 +
63075 +int
63076 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
63077 +{
63078 + unsigned int i;
63079 + __u16 num;
63080 + gid_t *gidlist;
63081 + gid_t curgid;
63082 + int realok = 0;
63083 + int effectiveok = 0;
63084 + int fsok = 0;
63085 + gid_t globalreal, globaleffective, globalfs;
63086 +
63087 + if (unlikely(!(gr_status & GR_READY)))
63088 + return 0;
63089 +
63090 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
63091 + gr_log_learn_gid_change(real, effective, fs);
63092 +
63093 + num = current->acl->group_trans_num;
63094 + gidlist = current->acl->group_transitions;
63095 +
63096 + if (gidlist == NULL)
63097 + return 0;
63098 +
63099 + if (!gid_valid(real)) {
63100 + realok = 1;
63101 + globalreal = (gid_t)-1;
63102 + } else {
63103 + globalreal = GR_GLOBAL_GID(real);
63104 + }
63105 + if (!gid_valid(effective)) {
63106 + effectiveok = 1;
63107 + globaleffective = (gid_t)-1;
63108 + } else {
63109 + globaleffective = GR_GLOBAL_GID(effective);
63110 + }
63111 + if (!gid_valid(fs)) {
63112 + fsok = 1;
63113 + globalfs = (gid_t)-1;
63114 + } else {
63115 + globalfs = GR_GLOBAL_GID(fs);
63116 + }
63117 +
63118 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
63119 + for (i = 0; i < num; i++) {
63120 + curgid = gidlist[i];
63121 + if (globalreal == curgid)
63122 + realok = 1;
63123 + if (globaleffective == curgid)
63124 + effectiveok = 1;
63125 + if (globalfs == curgid)
63126 + fsok = 1;
63127 + }
63128 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
63129 + for (i = 0; i < num; i++) {
63130 + curgid = gidlist[i];
63131 + if (globalreal == curgid)
63132 + break;
63133 + if (globaleffective == curgid)
63134 + break;
63135 + if (globalfs == curgid)
63136 + break;
63137 + }
63138 + /* not in deny list */
63139 + if (i == num) {
63140 + realok = 1;
63141 + effectiveok = 1;
63142 + fsok = 1;
63143 + }
63144 + }
63145 +
63146 + if (realok && effectiveok && fsok)
63147 + return 0;
63148 + else {
63149 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
63150 + return 1;
63151 + }
63152 +}
63153 +
63154 +extern int gr_acl_is_capable(const int cap);
63155 +
63156 +void
63157 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
63158 +{
63159 + struct acl_role_label *role = task->role;
63160 + struct acl_subject_label *subj = NULL;
63161 + struct acl_object_label *obj;
63162 + struct file *filp;
63163 + uid_t uid;
63164 + gid_t gid;
63165 +
63166 + if (unlikely(!(gr_status & GR_READY)))
63167 + return;
63168 +
63169 + uid = GR_GLOBAL_UID(kuid);
63170 + gid = GR_GLOBAL_GID(kgid);
63171 +
63172 + filp = task->exec_file;
63173 +
63174 + /* kernel process, we'll give them the kernel role */
63175 + if (unlikely(!filp)) {
63176 + task->role = kernel_role;
63177 + task->acl = kernel_role->root_label;
63178 + return;
63179 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL))
63180 + role = lookup_acl_role_label(task, uid, gid);
63181 +
63182 + /* don't change the role if we're not a privileged process */
63183 + if (role && task->role != role &&
63184 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
63185 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
63186 + return;
63187 +
63188 + /* perform subject lookup in possibly new role
63189 + we can use this result below in the case where role == task->role
63190 + */
63191 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
63192 +
63193 + /* if we changed uid/gid, but result in the same role
63194 + and are using inheritance, don't lose the inherited subject
63195 + if current subject is other than what normal lookup
63196 + would result in, we arrived via inheritance, don't
63197 + lose subject
63198 + */
63199 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
63200 + (subj == task->acl)))
63201 + task->acl = subj;
63202 +
63203 + task->role = role;
63204 +
63205 + task->is_writable = 0;
63206 +
63207 + /* ignore additional mmap checks for processes that are writable
63208 + by the default ACL */
63209 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
63210 + if (unlikely(obj->mode & GR_WRITE))
63211 + task->is_writable = 1;
63212 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
63213 + if (unlikely(obj->mode & GR_WRITE))
63214 + task->is_writable = 1;
63215 +
63216 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
63217 + 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);
63218 +#endif
63219 +
63220 + gr_set_proc_res(task);
63221 +
63222 + return;
63223 +}
63224 +
63225 +int
63226 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
63227 + const int unsafe_flags)
63228 +{
63229 + struct task_struct *task = current;
63230 + struct acl_subject_label *newacl;
63231 + struct acl_object_label *obj;
63232 + __u32 retmode;
63233 +
63234 + if (unlikely(!(gr_status & GR_READY)))
63235 + return 0;
63236 +
63237 + newacl = chk_subj_label(dentry, mnt, task->role);
63238 +
63239 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
63240 + did an exec
63241 + */
63242 + rcu_read_lock();
63243 + read_lock(&tasklist_lock);
63244 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
63245 + (task->parent->acl->mode & GR_POVERRIDE))) {
63246 + read_unlock(&tasklist_lock);
63247 + rcu_read_unlock();
63248 + goto skip_check;
63249 + }
63250 + read_unlock(&tasklist_lock);
63251 + rcu_read_unlock();
63252 +
63253 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
63254 + !(task->role->roletype & GR_ROLE_GOD) &&
63255 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
63256 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
63257 + if (unsafe_flags & LSM_UNSAFE_SHARE)
63258 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
63259 + else
63260 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
63261 + return -EACCES;
63262 + }
63263 +
63264 +skip_check:
63265 +
63266 + obj = chk_obj_label(dentry, mnt, task->acl);
63267 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
63268 +
63269 + if (!(task->acl->mode & GR_INHERITLEARN) &&
63270 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
63271 + if (obj->nested)
63272 + task->acl = obj->nested;
63273 + else
63274 + task->acl = newacl;
63275 + } else if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
63276 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
63277 +
63278 + task->is_writable = 0;
63279 +
63280 + /* ignore additional mmap checks for processes that are writable
63281 + by the default ACL */
63282 + obj = chk_obj_label(dentry, mnt, default_role->root_label);
63283 + if (unlikely(obj->mode & GR_WRITE))
63284 + task->is_writable = 1;
63285 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
63286 + if (unlikely(obj->mode & GR_WRITE))
63287 + task->is_writable = 1;
63288 +
63289 + gr_set_proc_res(task);
63290 +
63291 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
63292 + 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);
63293 +#endif
63294 + return 0;
63295 +}
63296 +
63297 +/* always called with valid inodev ptr */
63298 +static void
63299 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
63300 +{
63301 + struct acl_object_label *matchpo;
63302 + struct acl_subject_label *matchps;
63303 + struct acl_subject_label *subj;
63304 + struct acl_role_label *role;
63305 + unsigned int x;
63306 +
63307 + FOR_EACH_ROLE_START(role)
63308 + FOR_EACH_SUBJECT_START(role, subj, x)
63309 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
63310 + matchpo->mode |= GR_DELETED;
63311 + FOR_EACH_SUBJECT_END(subj,x)
63312 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
63313 + /* nested subjects aren't in the role's subj_hash table */
63314 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
63315 + matchpo->mode |= GR_DELETED;
63316 + FOR_EACH_NESTED_SUBJECT_END(subj)
63317 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
63318 + matchps->mode |= GR_DELETED;
63319 + FOR_EACH_ROLE_END(role)
63320 +
63321 + inodev->nentry->deleted = 1;
63322 +
63323 + return;
63324 +}
63325 +
63326 +void
63327 +gr_handle_delete(const ino_t ino, const dev_t dev)
63328 +{
63329 + struct inodev_entry *inodev;
63330 +
63331 + if (unlikely(!(gr_status & GR_READY)))
63332 + return;
63333 +
63334 + write_lock(&gr_inode_lock);
63335 + inodev = lookup_inodev_entry(ino, dev);
63336 + if (inodev != NULL)
63337 + do_handle_delete(inodev, ino, dev);
63338 + write_unlock(&gr_inode_lock);
63339 +
63340 + return;
63341 +}
63342 +
63343 +static void
63344 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
63345 + const ino_t newinode, const dev_t newdevice,
63346 + struct acl_subject_label *subj)
63347 +{
63348 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
63349 + struct acl_object_label *match;
63350 +
63351 + match = subj->obj_hash[index];
63352 +
63353 + while (match && (match->inode != oldinode ||
63354 + match->device != olddevice ||
63355 + !(match->mode & GR_DELETED)))
63356 + match = match->next;
63357 +
63358 + if (match && (match->inode == oldinode)
63359 + && (match->device == olddevice)
63360 + && (match->mode & GR_DELETED)) {
63361 + if (match->prev == NULL) {
63362 + subj->obj_hash[index] = match->next;
63363 + if (match->next != NULL)
63364 + match->next->prev = NULL;
63365 + } else {
63366 + match->prev->next = match->next;
63367 + if (match->next != NULL)
63368 + match->next->prev = match->prev;
63369 + }
63370 + match->prev = NULL;
63371 + match->next = NULL;
63372 + match->inode = newinode;
63373 + match->device = newdevice;
63374 + match->mode &= ~GR_DELETED;
63375 +
63376 + insert_acl_obj_label(match, subj);
63377 + }
63378 +
63379 + return;
63380 +}
63381 +
63382 +static void
63383 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
63384 + const ino_t newinode, const dev_t newdevice,
63385 + struct acl_role_label *role)
63386 +{
63387 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
63388 + struct acl_subject_label *match;
63389 +
63390 + match = role->subj_hash[index];
63391 +
63392 + while (match && (match->inode != oldinode ||
63393 + match->device != olddevice ||
63394 + !(match->mode & GR_DELETED)))
63395 + match = match->next;
63396 +
63397 + if (match && (match->inode == oldinode)
63398 + && (match->device == olddevice)
63399 + && (match->mode & GR_DELETED)) {
63400 + if (match->prev == NULL) {
63401 + role->subj_hash[index] = match->next;
63402 + if (match->next != NULL)
63403 + match->next->prev = NULL;
63404 + } else {
63405 + match->prev->next = match->next;
63406 + if (match->next != NULL)
63407 + match->next->prev = match->prev;
63408 + }
63409 + match->prev = NULL;
63410 + match->next = NULL;
63411 + match->inode = newinode;
63412 + match->device = newdevice;
63413 + match->mode &= ~GR_DELETED;
63414 +
63415 + insert_acl_subj_label(match, role);
63416 + }
63417 +
63418 + return;
63419 +}
63420 +
63421 +static void
63422 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
63423 + const ino_t newinode, const dev_t newdevice)
63424 +{
63425 + unsigned int index = gr_fhash(oldinode, olddevice, inodev_set.i_size);
63426 + struct inodev_entry *match;
63427 +
63428 + match = inodev_set.i_hash[index];
63429 +
63430 + while (match && (match->nentry->inode != oldinode ||
63431 + match->nentry->device != olddevice || !match->nentry->deleted))
63432 + match = match->next;
63433 +
63434 + if (match && (match->nentry->inode == oldinode)
63435 + && (match->nentry->device == olddevice) &&
63436 + match->nentry->deleted) {
63437 + if (match->prev == NULL) {
63438 + inodev_set.i_hash[index] = match->next;
63439 + if (match->next != NULL)
63440 + match->next->prev = NULL;
63441 + } else {
63442 + match->prev->next = match->next;
63443 + if (match->next != NULL)
63444 + match->next->prev = match->prev;
63445 + }
63446 + match->prev = NULL;
63447 + match->next = NULL;
63448 + match->nentry->inode = newinode;
63449 + match->nentry->device = newdevice;
63450 + match->nentry->deleted = 0;
63451 +
63452 + insert_inodev_entry(match);
63453 + }
63454 +
63455 + return;
63456 +}
63457 +
63458 +static void
63459 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
63460 +{
63461 + struct acl_subject_label *subj;
63462 + struct acl_role_label *role;
63463 + unsigned int x;
63464 +
63465 + FOR_EACH_ROLE_START(role)
63466 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
63467 +
63468 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
63469 + if ((subj->inode == ino) && (subj->device == dev)) {
63470 + subj->inode = ino;
63471 + subj->device = dev;
63472 + }
63473 + /* nested subjects aren't in the role's subj_hash table */
63474 + update_acl_obj_label(matchn->inode, matchn->device,
63475 + ino, dev, subj);
63476 + FOR_EACH_NESTED_SUBJECT_END(subj)
63477 + FOR_EACH_SUBJECT_START(role, subj, x)
63478 + update_acl_obj_label(matchn->inode, matchn->device,
63479 + ino, dev, subj);
63480 + FOR_EACH_SUBJECT_END(subj,x)
63481 + FOR_EACH_ROLE_END(role)
63482 +
63483 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
63484 +
63485 + return;
63486 +}
63487 +
63488 +static void
63489 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
63490 + const struct vfsmount *mnt)
63491 +{
63492 + ino_t ino = dentry->d_inode->i_ino;
63493 + dev_t dev = __get_dev(dentry);
63494 +
63495 + __do_handle_create(matchn, ino, dev);
63496 +
63497 + return;
63498 +}
63499 +
63500 +void
63501 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
63502 +{
63503 + struct name_entry *matchn;
63504 +
63505 + if (unlikely(!(gr_status & GR_READY)))
63506 + return;
63507 +
63508 + preempt_disable();
63509 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
63510 +
63511 + if (unlikely((unsigned long)matchn)) {
63512 + write_lock(&gr_inode_lock);
63513 + do_handle_create(matchn, dentry, mnt);
63514 + write_unlock(&gr_inode_lock);
63515 + }
63516 + preempt_enable();
63517 +
63518 + return;
63519 +}
63520 +
63521 +void
63522 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
63523 +{
63524 + struct name_entry *matchn;
63525 +
63526 + if (unlikely(!(gr_status & GR_READY)))
63527 + return;
63528 +
63529 + preempt_disable();
63530 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
63531 +
63532 + if (unlikely((unsigned long)matchn)) {
63533 + write_lock(&gr_inode_lock);
63534 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
63535 + write_unlock(&gr_inode_lock);
63536 + }
63537 + preempt_enable();
63538 +
63539 + return;
63540 +}
63541 +
63542 +void
63543 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
63544 + struct dentry *old_dentry,
63545 + struct dentry *new_dentry,
63546 + struct vfsmount *mnt, const __u8 replace)
63547 +{
63548 + struct name_entry *matchn;
63549 + struct inodev_entry *inodev;
63550 + struct inode *inode = new_dentry->d_inode;
63551 + ino_t old_ino = old_dentry->d_inode->i_ino;
63552 + dev_t old_dev = __get_dev(old_dentry);
63553 +
63554 + /* vfs_rename swaps the name and parent link for old_dentry and
63555 + new_dentry
63556 + at this point, old_dentry has the new name, parent link, and inode
63557 + for the renamed file
63558 + if a file is being replaced by a rename, new_dentry has the inode
63559 + and name for the replaced file
63560 + */
63561 +
63562 + if (unlikely(!(gr_status & GR_READY)))
63563 + return;
63564 +
63565 + preempt_disable();
63566 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
63567 +
63568 + /* we wouldn't have to check d_inode if it weren't for
63569 + NFS silly-renaming
63570 + */
63571 +
63572 + write_lock(&gr_inode_lock);
63573 + if (unlikely(replace && inode)) {
63574 + ino_t new_ino = inode->i_ino;
63575 + dev_t new_dev = __get_dev(new_dentry);
63576 +
63577 + inodev = lookup_inodev_entry(new_ino, new_dev);
63578 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
63579 + do_handle_delete(inodev, new_ino, new_dev);
63580 + }
63581 +
63582 + inodev = lookup_inodev_entry(old_ino, old_dev);
63583 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
63584 + do_handle_delete(inodev, old_ino, old_dev);
63585 +
63586 + if (unlikely((unsigned long)matchn))
63587 + do_handle_create(matchn, old_dentry, mnt);
63588 +
63589 + write_unlock(&gr_inode_lock);
63590 + preempt_enable();
63591 +
63592 + return;
63593 +}
63594 +
63595 +static int
63596 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
63597 + unsigned char **sum)
63598 +{
63599 + struct acl_role_label *r;
63600 + struct role_allowed_ip *ipp;
63601 + struct role_transition *trans;
63602 + unsigned int i;
63603 + int found = 0;
63604 + u32 curr_ip = current->signal->curr_ip;
63605 +
63606 + current->signal->saved_ip = curr_ip;
63607 +
63608 + /* check transition table */
63609 +
63610 + for (trans = current->role->transitions; trans; trans = trans->next) {
63611 + if (!strcmp(rolename, trans->rolename)) {
63612 + found = 1;
63613 + break;
63614 + }
63615 + }
63616 +
63617 + if (!found)
63618 + return 0;
63619 +
63620 + /* handle special roles that do not require authentication
63621 + and check ip */
63622 +
63623 + FOR_EACH_ROLE_START(r)
63624 + if (!strcmp(rolename, r->rolename) &&
63625 + (r->roletype & GR_ROLE_SPECIAL)) {
63626 + found = 0;
63627 + if (r->allowed_ips != NULL) {
63628 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
63629 + if ((ntohl(curr_ip) & ipp->netmask) ==
63630 + (ntohl(ipp->addr) & ipp->netmask))
63631 + found = 1;
63632 + }
63633 + } else
63634 + found = 2;
63635 + if (!found)
63636 + return 0;
63637 +
63638 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
63639 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
63640 + *salt = NULL;
63641 + *sum = NULL;
63642 + return 1;
63643 + }
63644 + }
63645 + FOR_EACH_ROLE_END(r)
63646 +
63647 + for (i = 0; i < num_sprole_pws; i++) {
63648 + if (!strcmp(rolename, acl_special_roles[i]->rolename)) {
63649 + *salt = acl_special_roles[i]->salt;
63650 + *sum = acl_special_roles[i]->sum;
63651 + return 1;
63652 + }
63653 + }
63654 +
63655 + return 0;
63656 +}
63657 +
63658 +static void
63659 +assign_special_role(char *rolename)
63660 +{
63661 + struct acl_object_label *obj;
63662 + struct acl_role_label *r;
63663 + struct acl_role_label *assigned = NULL;
63664 + struct task_struct *tsk;
63665 + struct file *filp;
63666 +
63667 + FOR_EACH_ROLE_START(r)
63668 + if (!strcmp(rolename, r->rolename) &&
63669 + (r->roletype & GR_ROLE_SPECIAL)) {
63670 + assigned = r;
63671 + break;
63672 + }
63673 + FOR_EACH_ROLE_END(r)
63674 +
63675 + if (!assigned)
63676 + return;
63677 +
63678 + read_lock(&tasklist_lock);
63679 + read_lock(&grsec_exec_file_lock);
63680 +
63681 + tsk = current->real_parent;
63682 + if (tsk == NULL)
63683 + goto out_unlock;
63684 +
63685 + filp = tsk->exec_file;
63686 + if (filp == NULL)
63687 + goto out_unlock;
63688 +
63689 + tsk->is_writable = 0;
63690 +
63691 + tsk->acl_sp_role = 1;
63692 + tsk->acl_role_id = ++acl_sp_role_value;
63693 + tsk->role = assigned;
63694 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
63695 +
63696 + /* ignore additional mmap checks for processes that are writable
63697 + by the default ACL */
63698 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
63699 + if (unlikely(obj->mode & GR_WRITE))
63700 + tsk->is_writable = 1;
63701 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
63702 + if (unlikely(obj->mode & GR_WRITE))
63703 + tsk->is_writable = 1;
63704 +
63705 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
63706 + 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));
63707 +#endif
63708 +
63709 +out_unlock:
63710 + read_unlock(&grsec_exec_file_lock);
63711 + read_unlock(&tasklist_lock);
63712 + return;
63713 +}
63714 +
63715 +int gr_check_secure_terminal(struct task_struct *task)
63716 +{
63717 + struct task_struct *p, *p2, *p3;
63718 + struct files_struct *files;
63719 + struct fdtable *fdt;
63720 + struct file *our_file = NULL, *file;
63721 + int i;
63722 +
63723 + if (task->signal->tty == NULL)
63724 + return 1;
63725 +
63726 + files = get_files_struct(task);
63727 + if (files != NULL) {
63728 + rcu_read_lock();
63729 + fdt = files_fdtable(files);
63730 + for (i=0; i < fdt->max_fds; i++) {
63731 + file = fcheck_files(files, i);
63732 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
63733 + get_file(file);
63734 + our_file = file;
63735 + }
63736 + }
63737 + rcu_read_unlock();
63738 + put_files_struct(files);
63739 + }
63740 +
63741 + if (our_file == NULL)
63742 + return 1;
63743 +
63744 + read_lock(&tasklist_lock);
63745 + do_each_thread(p2, p) {
63746 + files = get_files_struct(p);
63747 + if (files == NULL ||
63748 + (p->signal && p->signal->tty == task->signal->tty)) {
63749 + if (files != NULL)
63750 + put_files_struct(files);
63751 + continue;
63752 + }
63753 + rcu_read_lock();
63754 + fdt = files_fdtable(files);
63755 + for (i=0; i < fdt->max_fds; i++) {
63756 + file = fcheck_files(files, i);
63757 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
63758 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
63759 + p3 = task;
63760 + while (task_pid_nr(p3) > 0) {
63761 + if (p3 == p)
63762 + break;
63763 + p3 = p3->real_parent;
63764 + }
63765 + if (p3 == p)
63766 + break;
63767 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
63768 + gr_handle_alertkill(p);
63769 + rcu_read_unlock();
63770 + put_files_struct(files);
63771 + read_unlock(&tasklist_lock);
63772 + fput(our_file);
63773 + return 0;
63774 + }
63775 + }
63776 + rcu_read_unlock();
63777 + put_files_struct(files);
63778 + } while_each_thread(p2, p);
63779 + read_unlock(&tasklist_lock);
63780 +
63781 + fput(our_file);
63782 + return 1;
63783 +}
63784 +
63785 +static int gr_rbac_disable(void *unused)
63786 +{
63787 + pax_open_kernel();
63788 + gr_status &= ~GR_READY;
63789 + pax_close_kernel();
63790 +
63791 + return 0;
63792 +}
63793 +
63794 +ssize_t
63795 +write_grsec_handler(struct file *file, const char __user * buf, size_t count, loff_t *ppos)
63796 +{
63797 + struct gr_arg_wrapper uwrap;
63798 + unsigned char *sprole_salt = NULL;
63799 + unsigned char *sprole_sum = NULL;
63800 + int error = 0;
63801 + int error2 = 0;
63802 + size_t req_count = 0;
63803 +
63804 + mutex_lock(&gr_dev_mutex);
63805 +
63806 + if ((gr_status & GR_READY) && !(current->acl->mode & GR_KERNELAUTH)) {
63807 + error = -EPERM;
63808 + goto out;
63809 + }
63810 +
63811 +#ifdef CONFIG_COMPAT
63812 + pax_open_kernel();
63813 + if (is_compat_task()) {
63814 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_compat;
63815 + copy_gr_arg = &copy_gr_arg_compat;
63816 + copy_acl_object_label = &copy_acl_object_label_compat;
63817 + copy_acl_subject_label = &copy_acl_subject_label_compat;
63818 + copy_acl_role_label = &copy_acl_role_label_compat;
63819 + copy_acl_ip_label = &copy_acl_ip_label_compat;
63820 + copy_role_allowed_ip = &copy_role_allowed_ip_compat;
63821 + copy_role_transition = &copy_role_transition_compat;
63822 + copy_sprole_pw = &copy_sprole_pw_compat;
63823 + copy_gr_hash_struct = &copy_gr_hash_struct_compat;
63824 + copy_pointer_from_array = &copy_pointer_from_array_compat;
63825 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_compat;
63826 + } else {
63827 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_normal;
63828 + copy_gr_arg = &copy_gr_arg_normal;
63829 + copy_acl_object_label = &copy_acl_object_label_normal;
63830 + copy_acl_subject_label = &copy_acl_subject_label_normal;
63831 + copy_acl_role_label = &copy_acl_role_label_normal;
63832 + copy_acl_ip_label = &copy_acl_ip_label_normal;
63833 + copy_role_allowed_ip = &copy_role_allowed_ip_normal;
63834 + copy_role_transition = &copy_role_transition_normal;
63835 + copy_sprole_pw = &copy_sprole_pw_normal;
63836 + copy_gr_hash_struct = &copy_gr_hash_struct_normal;
63837 + copy_pointer_from_array = &copy_pointer_from_array_normal;
63838 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_normal;
63839 + }
63840 + pax_close_kernel();
63841 +#endif
63842 +
63843 + req_count = get_gr_arg_wrapper_size();
63844 +
63845 + if (count != req_count) {
63846 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)req_count);
63847 + error = -EINVAL;
63848 + goto out;
63849 + }
63850 +
63851 +
63852 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
63853 + gr_auth_expires = 0;
63854 + gr_auth_attempts = 0;
63855 + }
63856 +
63857 + error = copy_gr_arg_wrapper(buf, &uwrap);
63858 + if (error)
63859 + goto out;
63860 +
63861 + error = copy_gr_arg(uwrap.arg, gr_usermode);
63862 + if (error)
63863 + goto out;
63864 +
63865 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_SPROLEPAM &&
63866 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
63867 + time_after(gr_auth_expires, get_seconds())) {
63868 + error = -EBUSY;
63869 + goto out;
63870 + }
63871 +
63872 + /* if non-root trying to do anything other than use a special role,
63873 + do not attempt authentication, do not count towards authentication
63874 + locking
63875 + */
63876 +
63877 + if (gr_usermode->mode != GR_SPROLE && gr_usermode->mode != GR_STATUS &&
63878 + gr_usermode->mode != GR_UNSPROLE && gr_usermode->mode != GR_SPROLEPAM &&
63879 + gr_is_global_nonroot(current_uid())) {
63880 + error = -EPERM;
63881 + goto out;
63882 + }
63883 +
63884 + /* ensure pw and special role name are null terminated */
63885 +
63886 + gr_usermode->pw[GR_PW_LEN - 1] = '\0';
63887 + gr_usermode->sp_role[GR_SPROLE_LEN - 1] = '\0';
63888 +
63889 + /* Okay.
63890 + * We have our enough of the argument structure..(we have yet
63891 + * to copy_from_user the tables themselves) . Copy the tables
63892 + * only if we need them, i.e. for loading operations. */
63893 +
63894 + switch (gr_usermode->mode) {
63895 + case GR_STATUS:
63896 + if (gr_status & GR_READY) {
63897 + error = 1;
63898 + if (!gr_check_secure_terminal(current))
63899 + error = 3;
63900 + } else
63901 + error = 2;
63902 + goto out;
63903 + case GR_SHUTDOWN:
63904 + if ((gr_status & GR_READY)
63905 + && !(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
63906 + stop_machine(gr_rbac_disable, NULL, NULL);
63907 + free_variables();
63908 + memset(gr_usermode, 0, sizeof (struct gr_arg));
63909 + memset(gr_system_salt, 0, GR_SALT_LEN);
63910 + memset(gr_system_sum, 0, GR_SHA_LEN);
63911 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
63912 + } else if (gr_status & GR_READY) {
63913 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
63914 + error = -EPERM;
63915 + } else {
63916 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
63917 + error = -EAGAIN;
63918 + }
63919 + break;
63920 + case GR_ENABLE:
63921 + if (!(gr_status & GR_READY) && !(error2 = gracl_init(gr_usermode)))
63922 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
63923 + else {
63924 + if (gr_status & GR_READY)
63925 + error = -EAGAIN;
63926 + else
63927 + error = error2;
63928 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
63929 + }
63930 + break;
63931 + case GR_RELOAD:
63932 + if (!(gr_status & GR_READY)) {
63933 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
63934 + error = -EAGAIN;
63935 + } else if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
63936 + stop_machine(gr_rbac_disable, NULL, NULL);
63937 + free_variables();
63938 + error2 = gracl_init(gr_usermode);
63939 + if (!error2)
63940 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
63941 + else {
63942 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
63943 + error = error2;
63944 + }
63945 + } else {
63946 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
63947 + error = -EPERM;
63948 + }
63949 + break;
63950 + case GR_SEGVMOD:
63951 + if (unlikely(!(gr_status & GR_READY))) {
63952 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
63953 + error = -EAGAIN;
63954 + break;
63955 + }
63956 +
63957 + if (!(chkpw(gr_usermode, gr_system_salt, gr_system_sum))) {
63958 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
63959 + if (gr_usermode->segv_device && gr_usermode->segv_inode) {
63960 + struct acl_subject_label *segvacl;
63961 + segvacl =
63962 + lookup_acl_subj_label(gr_usermode->segv_inode,
63963 + gr_usermode->segv_device,
63964 + current->role);
63965 + if (segvacl) {
63966 + segvacl->crashes = 0;
63967 + segvacl->expires = 0;
63968 + }
63969 + } else if (gr_find_uid(gr_usermode->segv_uid) >= 0) {
63970 + gr_remove_uid(gr_usermode->segv_uid);
63971 + }
63972 + } else {
63973 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
63974 + error = -EPERM;
63975 + }
63976 + break;
63977 + case GR_SPROLE:
63978 + case GR_SPROLEPAM:
63979 + if (unlikely(!(gr_status & GR_READY))) {
63980 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
63981 + error = -EAGAIN;
63982 + break;
63983 + }
63984 +
63985 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
63986 + current->role->expires = 0;
63987 + current->role->auth_attempts = 0;
63988 + }
63989 +
63990 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
63991 + time_after(current->role->expires, get_seconds())) {
63992 + error = -EBUSY;
63993 + goto out;
63994 + }
63995 +
63996 + if (lookup_special_role_auth
63997 + (gr_usermode->mode, gr_usermode->sp_role, &sprole_salt, &sprole_sum)
63998 + && ((!sprole_salt && !sprole_sum)
63999 + || !(chkpw(gr_usermode, sprole_salt, sprole_sum)))) {
64000 + char *p = "";
64001 + assign_special_role(gr_usermode->sp_role);
64002 + read_lock(&tasklist_lock);
64003 + if (current->real_parent)
64004 + p = current->real_parent->role->rolename;
64005 + read_unlock(&tasklist_lock);
64006 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
64007 + p, acl_sp_role_value);
64008 + } else {
64009 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode->sp_role);
64010 + error = -EPERM;
64011 + if(!(current->role->auth_attempts++))
64012 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
64013 +
64014 + goto out;
64015 + }
64016 + break;
64017 + case GR_UNSPROLE:
64018 + if (unlikely(!(gr_status & GR_READY))) {
64019 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
64020 + error = -EAGAIN;
64021 + break;
64022 + }
64023 +
64024 + if (current->role->roletype & GR_ROLE_SPECIAL) {
64025 + char *p = "";
64026 + int i = 0;
64027 +
64028 + read_lock(&tasklist_lock);
64029 + if (current->real_parent) {
64030 + p = current->real_parent->role->rolename;
64031 + i = current->real_parent->acl_role_id;
64032 + }
64033 + read_unlock(&tasklist_lock);
64034 +
64035 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
64036 + gr_set_acls(1);
64037 + } else {
64038 + error = -EPERM;
64039 + goto out;
64040 + }
64041 + break;
64042 + default:
64043 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode->mode);
64044 + error = -EINVAL;
64045 + break;
64046 + }
64047 +
64048 + if (error != -EPERM)
64049 + goto out;
64050 +
64051 + if(!(gr_auth_attempts++))
64052 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
64053 +
64054 + out:
64055 + mutex_unlock(&gr_dev_mutex);
64056 +
64057 + if (!error)
64058 + error = req_count;
64059 +
64060 + return error;
64061 +}
64062 +
64063 +/* must be called with
64064 + rcu_read_lock();
64065 + read_lock(&tasklist_lock);
64066 + read_lock(&grsec_exec_file_lock);
64067 +*/
64068 +int gr_apply_subject_to_task(struct task_struct *task)
64069 +{
64070 + struct acl_object_label *obj;
64071 + char *tmpname;
64072 + struct acl_subject_label *tmpsubj;
64073 + struct file *filp;
64074 + struct name_entry *nmatch;
64075 +
64076 + filp = task->exec_file;
64077 + if (filp == NULL)
64078 + return 0;
64079 +
64080 + /* the following is to apply the correct subject
64081 + on binaries running when the RBAC system
64082 + is enabled, when the binaries have been
64083 + replaced or deleted since their execution
64084 + -----
64085 + when the RBAC system starts, the inode/dev
64086 + from exec_file will be one the RBAC system
64087 + is unaware of. It only knows the inode/dev
64088 + of the present file on disk, or the absence
64089 + of it.
64090 + */
64091 + preempt_disable();
64092 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
64093 +
64094 + nmatch = lookup_name_entry(tmpname);
64095 + preempt_enable();
64096 + tmpsubj = NULL;
64097 + if (nmatch) {
64098 + if (nmatch->deleted)
64099 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
64100 + else
64101 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
64102 + if (tmpsubj != NULL)
64103 + task->acl = tmpsubj;
64104 + }
64105 + if (tmpsubj == NULL)
64106 + task->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt,
64107 + task->role);
64108 + if (task->acl) {
64109 + task->is_writable = 0;
64110 + /* ignore additional mmap checks for processes that are writable
64111 + by the default ACL */
64112 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
64113 + if (unlikely(obj->mode & GR_WRITE))
64114 + task->is_writable = 1;
64115 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
64116 + if (unlikely(obj->mode & GR_WRITE))
64117 + task->is_writable = 1;
64118 +
64119 + gr_set_proc_res(task);
64120 +
64121 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
64122 + 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);
64123 +#endif
64124 + } else {
64125 + return 1;
64126 + }
64127 +
64128 + return 0;
64129 +}
64130 +
64131 +int
64132 +gr_set_acls(const int type)
64133 +{
64134 + struct task_struct *task, *task2;
64135 + struct acl_role_label *role = current->role;
64136 + __u16 acl_role_id = current->acl_role_id;
64137 + const struct cred *cred;
64138 + int ret;
64139 +
64140 + rcu_read_lock();
64141 + read_lock(&tasklist_lock);
64142 + read_lock(&grsec_exec_file_lock);
64143 + do_each_thread(task2, task) {
64144 + /* check to see if we're called from the exit handler,
64145 + if so, only replace ACLs that have inherited the admin
64146 + ACL */
64147 +
64148 + if (type && (task->role != role ||
64149 + task->acl_role_id != acl_role_id))
64150 + continue;
64151 +
64152 + task->acl_role_id = 0;
64153 + task->acl_sp_role = 0;
64154 +
64155 + if (task->exec_file) {
64156 + cred = __task_cred(task);
64157 + task->role = lookup_acl_role_label(task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
64158 + ret = gr_apply_subject_to_task(task);
64159 + if (ret) {
64160 + read_unlock(&grsec_exec_file_lock);
64161 + read_unlock(&tasklist_lock);
64162 + rcu_read_unlock();
64163 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
64164 + return ret;
64165 + }
64166 + } else {
64167 + // it's a kernel process
64168 + task->role = kernel_role;
64169 + task->acl = kernel_role->root_label;
64170 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
64171 + task->acl->mode &= ~GR_PROCFIND;
64172 +#endif
64173 + }
64174 + } while_each_thread(task2, task);
64175 + read_unlock(&grsec_exec_file_lock);
64176 + read_unlock(&tasklist_lock);
64177 + rcu_read_unlock();
64178 +
64179 + return 0;
64180 +}
64181 +
64182 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
64183 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
64184 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
64185 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
64186 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
64187 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
64188 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
64189 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
64190 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
64191 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
64192 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
64193 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
64194 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
64195 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
64196 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
64197 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
64198 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
64199 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
64200 +};
64201 +
64202 +void
64203 +gr_learn_resource(const struct task_struct *task,
64204 + const int res, const unsigned long wanted, const int gt)
64205 +{
64206 + struct acl_subject_label *acl;
64207 + const struct cred *cred;
64208 +
64209 + if (unlikely((gr_status & GR_READY) &&
64210 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
64211 + goto skip_reslog;
64212 +
64213 + gr_log_resource(task, res, wanted, gt);
64214 +skip_reslog:
64215 +
64216 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
64217 + return;
64218 +
64219 + acl = task->acl;
64220 +
64221 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
64222 + !(acl->resmask & (1U << (unsigned short) res))))
64223 + return;
64224 +
64225 + if (wanted >= acl->res[res].rlim_cur) {
64226 + unsigned long res_add;
64227 +
64228 + res_add = wanted + res_learn_bumps[res];
64229 +
64230 + acl->res[res].rlim_cur = res_add;
64231 +
64232 + if (wanted > acl->res[res].rlim_max)
64233 + acl->res[res].rlim_max = res_add;
64234 +
64235 + /* only log the subject filename, since resource logging is supported for
64236 + single-subject learning only */
64237 + rcu_read_lock();
64238 + cred = __task_cred(task);
64239 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
64240 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
64241 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
64242 + "", (unsigned long) res, &task->signal->saved_ip);
64243 + rcu_read_unlock();
64244 + }
64245 +
64246 + return;
64247 +}
64248 +EXPORT_SYMBOL(gr_learn_resource);
64249 +#endif
64250 +
64251 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
64252 +void
64253 +pax_set_initial_flags(struct linux_binprm *bprm)
64254 +{
64255 + struct task_struct *task = current;
64256 + struct acl_subject_label *proc;
64257 + unsigned long flags;
64258 +
64259 + if (unlikely(!(gr_status & GR_READY)))
64260 + return;
64261 +
64262 + flags = pax_get_flags(task);
64263 +
64264 + proc = task->acl;
64265 +
64266 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
64267 + flags &= ~MF_PAX_PAGEEXEC;
64268 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
64269 + flags &= ~MF_PAX_SEGMEXEC;
64270 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
64271 + flags &= ~MF_PAX_RANDMMAP;
64272 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
64273 + flags &= ~MF_PAX_EMUTRAMP;
64274 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
64275 + flags &= ~MF_PAX_MPROTECT;
64276 +
64277 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
64278 + flags |= MF_PAX_PAGEEXEC;
64279 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
64280 + flags |= MF_PAX_SEGMEXEC;
64281 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
64282 + flags |= MF_PAX_RANDMMAP;
64283 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
64284 + flags |= MF_PAX_EMUTRAMP;
64285 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
64286 + flags |= MF_PAX_MPROTECT;
64287 +
64288 + pax_set_flags(task, flags);
64289 +
64290 + return;
64291 +}
64292 +#endif
64293 +
64294 +int
64295 +gr_handle_proc_ptrace(struct task_struct *task)
64296 +{
64297 + struct file *filp;
64298 + struct task_struct *tmp = task;
64299 + struct task_struct *curtemp = current;
64300 + __u32 retmode;
64301 +
64302 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
64303 + if (unlikely(!(gr_status & GR_READY)))
64304 + return 0;
64305 +#endif
64306 +
64307 + read_lock(&tasklist_lock);
64308 + read_lock(&grsec_exec_file_lock);
64309 + filp = task->exec_file;
64310 +
64311 + while (task_pid_nr(tmp) > 0) {
64312 + if (tmp == curtemp)
64313 + break;
64314 + tmp = tmp->real_parent;
64315 + }
64316 +
64317 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
64318 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
64319 + read_unlock(&grsec_exec_file_lock);
64320 + read_unlock(&tasklist_lock);
64321 + return 1;
64322 + }
64323 +
64324 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
64325 + if (!(gr_status & GR_READY)) {
64326 + read_unlock(&grsec_exec_file_lock);
64327 + read_unlock(&tasklist_lock);
64328 + return 0;
64329 + }
64330 +#endif
64331 +
64332 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
64333 + read_unlock(&grsec_exec_file_lock);
64334 + read_unlock(&tasklist_lock);
64335 +
64336 + if (retmode & GR_NOPTRACE)
64337 + return 1;
64338 +
64339 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
64340 + && (current->acl != task->acl || (current->acl != current->role->root_label
64341 + && task_pid_nr(current) != task_pid_nr(task))))
64342 + return 1;
64343 +
64344 + return 0;
64345 +}
64346 +
64347 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
64348 +{
64349 + if (unlikely(!(gr_status & GR_READY)))
64350 + return;
64351 +
64352 + if (!(current->role->roletype & GR_ROLE_GOD))
64353 + return;
64354 +
64355 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
64356 + p->role->rolename, gr_task_roletype_to_char(p),
64357 + p->acl->filename);
64358 +}
64359 +
64360 +int
64361 +gr_handle_ptrace(struct task_struct *task, const long request)
64362 +{
64363 + struct task_struct *tmp = task;
64364 + struct task_struct *curtemp = current;
64365 + __u32 retmode;
64366 +
64367 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
64368 + if (unlikely(!(gr_status & GR_READY)))
64369 + return 0;
64370 +#endif
64371 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
64372 + read_lock(&tasklist_lock);
64373 + while (task_pid_nr(tmp) > 0) {
64374 + if (tmp == curtemp)
64375 + break;
64376 + tmp = tmp->real_parent;
64377 + }
64378 +
64379 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
64380 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
64381 + read_unlock(&tasklist_lock);
64382 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
64383 + return 1;
64384 + }
64385 + read_unlock(&tasklist_lock);
64386 + }
64387 +
64388 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
64389 + if (!(gr_status & GR_READY))
64390 + return 0;
64391 +#endif
64392 +
64393 + read_lock(&grsec_exec_file_lock);
64394 + if (unlikely(!task->exec_file)) {
64395 + read_unlock(&grsec_exec_file_lock);
64396 + return 0;
64397 + }
64398 +
64399 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
64400 + read_unlock(&grsec_exec_file_lock);
64401 +
64402 + if (retmode & GR_NOPTRACE) {
64403 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
64404 + return 1;
64405 + }
64406 +
64407 + if (retmode & GR_PTRACERD) {
64408 + switch (request) {
64409 + case PTRACE_SEIZE:
64410 + case PTRACE_POKETEXT:
64411 + case PTRACE_POKEDATA:
64412 + case PTRACE_POKEUSR:
64413 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
64414 + case PTRACE_SETREGS:
64415 + case PTRACE_SETFPREGS:
64416 +#endif
64417 +#ifdef CONFIG_X86
64418 + case PTRACE_SETFPXREGS:
64419 +#endif
64420 +#ifdef CONFIG_ALTIVEC
64421 + case PTRACE_SETVRREGS:
64422 +#endif
64423 + return 1;
64424 + default:
64425 + return 0;
64426 + }
64427 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
64428 + !(current->role->roletype & GR_ROLE_GOD) &&
64429 + (current->acl != task->acl)) {
64430 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
64431 + return 1;
64432 + }
64433 +
64434 + return 0;
64435 +}
64436 +
64437 +static int is_writable_mmap(const struct file *filp)
64438 +{
64439 + struct task_struct *task = current;
64440 + struct acl_object_label *obj, *obj2;
64441 +
64442 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
64443 + !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))) {
64444 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, default_role->root_label);
64445 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
64446 + task->role->root_label);
64447 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
64448 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
64449 + return 1;
64450 + }
64451 + }
64452 + return 0;
64453 +}
64454 +
64455 +int
64456 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
64457 +{
64458 + __u32 mode;
64459 +
64460 + if (unlikely(!file || !(prot & PROT_EXEC)))
64461 + return 1;
64462 +
64463 + if (is_writable_mmap(file))
64464 + return 0;
64465 +
64466 + mode =
64467 + gr_search_file(file->f_path.dentry,
64468 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
64469 + file->f_path.mnt);
64470 +
64471 + if (!gr_tpe_allow(file))
64472 + return 0;
64473 +
64474 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
64475 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
64476 + return 0;
64477 + } else if (unlikely(!(mode & GR_EXEC))) {
64478 + return 0;
64479 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
64480 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
64481 + return 1;
64482 + }
64483 +
64484 + return 1;
64485 +}
64486 +
64487 +int
64488 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
64489 +{
64490 + __u32 mode;
64491 +
64492 + if (unlikely(!file || !(prot & PROT_EXEC)))
64493 + return 1;
64494 +
64495 + if (is_writable_mmap(file))
64496 + return 0;
64497 +
64498 + mode =
64499 + gr_search_file(file->f_path.dentry,
64500 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
64501 + file->f_path.mnt);
64502 +
64503 + if (!gr_tpe_allow(file))
64504 + return 0;
64505 +
64506 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
64507 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
64508 + return 0;
64509 + } else if (unlikely(!(mode & GR_EXEC))) {
64510 + return 0;
64511 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
64512 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
64513 + return 1;
64514 + }
64515 +
64516 + return 1;
64517 +}
64518 +
64519 +void
64520 +gr_acl_handle_psacct(struct task_struct *task, const long code)
64521 +{
64522 + unsigned long runtime;
64523 + unsigned long cputime;
64524 + unsigned int wday, cday;
64525 + __u8 whr, chr;
64526 + __u8 wmin, cmin;
64527 + __u8 wsec, csec;
64528 + struct timespec timeval;
64529 +
64530 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
64531 + !(task->acl->mode & GR_PROCACCT)))
64532 + return;
64533 +
64534 + do_posix_clock_monotonic_gettime(&timeval);
64535 + runtime = timeval.tv_sec - task->start_time.tv_sec;
64536 + wday = runtime / (3600 * 24);
64537 + runtime -= wday * (3600 * 24);
64538 + whr = runtime / 3600;
64539 + runtime -= whr * 3600;
64540 + wmin = runtime / 60;
64541 + runtime -= wmin * 60;
64542 + wsec = runtime;
64543 +
64544 + cputime = (task->utime + task->stime) / HZ;
64545 + cday = cputime / (3600 * 24);
64546 + cputime -= cday * (3600 * 24);
64547 + chr = cputime / 3600;
64548 + cputime -= chr * 3600;
64549 + cmin = cputime / 60;
64550 + cputime -= cmin * 60;
64551 + csec = cputime;
64552 +
64553 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
64554 +
64555 + return;
64556 +}
64557 +
64558 +void gr_set_kernel_label(struct task_struct *task)
64559 +{
64560 + if (gr_status & GR_READY) {
64561 + task->role = kernel_role;
64562 + task->acl = kernel_role->root_label;
64563 + }
64564 + return;
64565 +}
64566 +
64567 +#ifdef CONFIG_TASKSTATS
64568 +int gr_is_taskstats_denied(int pid)
64569 +{
64570 + struct task_struct *task;
64571 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
64572 + const struct cred *cred;
64573 +#endif
64574 + int ret = 0;
64575 +
64576 + /* restrict taskstats viewing to un-chrooted root users
64577 + who have the 'view' subject flag if the RBAC system is enabled
64578 + */
64579 +
64580 + rcu_read_lock();
64581 + read_lock(&tasklist_lock);
64582 + task = find_task_by_vpid(pid);
64583 + if (task) {
64584 +#ifdef CONFIG_GRKERNSEC_CHROOT
64585 + if (proc_is_chrooted(task))
64586 + ret = -EACCES;
64587 +#endif
64588 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
64589 + cred = __task_cred(task);
64590 +#ifdef CONFIG_GRKERNSEC_PROC_USER
64591 + if (gr_is_global_nonroot(cred->uid))
64592 + ret = -EACCES;
64593 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
64594 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
64595 + ret = -EACCES;
64596 +#endif
64597 +#endif
64598 + if (gr_status & GR_READY) {
64599 + if (!(task->acl->mode & GR_VIEW))
64600 + ret = -EACCES;
64601 + }
64602 + } else
64603 + ret = -ENOENT;
64604 +
64605 + read_unlock(&tasklist_lock);
64606 + rcu_read_unlock();
64607 +
64608 + return ret;
64609 +}
64610 +#endif
64611 +
64612 +/* AUXV entries are filled via a descendant of search_binary_handler
64613 + after we've already applied the subject for the target
64614 +*/
64615 +int gr_acl_enable_at_secure(void)
64616 +{
64617 + if (unlikely(!(gr_status & GR_READY)))
64618 + return 0;
64619 +
64620 + if (current->acl->mode & GR_ATSECURE)
64621 + return 1;
64622 +
64623 + return 0;
64624 +}
64625 +
64626 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
64627 +{
64628 + struct task_struct *task = current;
64629 + struct dentry *dentry = file->f_path.dentry;
64630 + struct vfsmount *mnt = file->f_path.mnt;
64631 + struct acl_object_label *obj, *tmp;
64632 + struct acl_subject_label *subj;
64633 + unsigned int bufsize;
64634 + int is_not_root;
64635 + char *path;
64636 + dev_t dev = __get_dev(dentry);
64637 +
64638 + if (unlikely(!(gr_status & GR_READY)))
64639 + return 1;
64640 +
64641 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
64642 + return 1;
64643 +
64644 + /* ignore Eric Biederman */
64645 + if (IS_PRIVATE(dentry->d_inode))
64646 + return 1;
64647 +
64648 + subj = task->acl;
64649 + read_lock(&gr_inode_lock);
64650 + do {
64651 + obj = lookup_acl_obj_label(ino, dev, subj);
64652 + if (obj != NULL) {
64653 + read_unlock(&gr_inode_lock);
64654 + return (obj->mode & GR_FIND) ? 1 : 0;
64655 + }
64656 + } while ((subj = subj->parent_subject));
64657 + read_unlock(&gr_inode_lock);
64658 +
64659 + /* this is purely an optimization since we're looking for an object
64660 + for the directory we're doing a readdir on
64661 + if it's possible for any globbed object to match the entry we're
64662 + filling into the directory, then the object we find here will be
64663 + an anchor point with attached globbed objects
64664 + */
64665 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
64666 + if (obj->globbed == NULL)
64667 + return (obj->mode & GR_FIND) ? 1 : 0;
64668 +
64669 + is_not_root = ((obj->filename[0] == '/') &&
64670 + (obj->filename[1] == '\0')) ? 0 : 1;
64671 + bufsize = PAGE_SIZE - namelen - is_not_root;
64672 +
64673 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
64674 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
64675 + return 1;
64676 +
64677 + preempt_disable();
64678 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
64679 + bufsize);
64680 +
64681 + bufsize = strlen(path);
64682 +
64683 + /* if base is "/", don't append an additional slash */
64684 + if (is_not_root)
64685 + *(path + bufsize) = '/';
64686 + memcpy(path + bufsize + is_not_root, name, namelen);
64687 + *(path + bufsize + namelen + is_not_root) = '\0';
64688 +
64689 + tmp = obj->globbed;
64690 + while (tmp) {
64691 + if (!glob_match(tmp->filename, path)) {
64692 + preempt_enable();
64693 + return (tmp->mode & GR_FIND) ? 1 : 0;
64694 + }
64695 + tmp = tmp->next;
64696 + }
64697 + preempt_enable();
64698 + return (obj->mode & GR_FIND) ? 1 : 0;
64699 +}
64700 +
64701 +void gr_put_exec_file(struct task_struct *task)
64702 +{
64703 + struct file *filp;
64704 +
64705 + write_lock(&grsec_exec_file_lock);
64706 + filp = task->exec_file;
64707 + task->exec_file = NULL;
64708 + write_unlock(&grsec_exec_file_lock);
64709 +
64710 + if (filp)
64711 + fput(filp);
64712 +
64713 + return;
64714 +}
64715 +
64716 +
64717 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
64718 +EXPORT_SYMBOL(gr_acl_is_enabled);
64719 +#endif
64720 +EXPORT_SYMBOL(gr_set_kernel_label);
64721 +#ifdef CONFIG_SECURITY
64722 +EXPORT_SYMBOL(gr_check_user_change);
64723 +EXPORT_SYMBOL(gr_check_group_change);
64724 +#endif
64725 +
64726 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
64727 new file mode 100644
64728 index 0000000..34fefda
64729 --- /dev/null
64730 +++ b/grsecurity/gracl_alloc.c
64731 @@ -0,0 +1,105 @@
64732 +#include <linux/kernel.h>
64733 +#include <linux/mm.h>
64734 +#include <linux/slab.h>
64735 +#include <linux/vmalloc.h>
64736 +#include <linux/gracl.h>
64737 +#include <linux/grsecurity.h>
64738 +
64739 +static unsigned long alloc_stack_next = 1;
64740 +static unsigned long alloc_stack_size = 1;
64741 +static void **alloc_stack;
64742 +
64743 +static __inline__ int
64744 +alloc_pop(void)
64745 +{
64746 + if (alloc_stack_next == 1)
64747 + return 0;
64748 +
64749 + kfree(alloc_stack[alloc_stack_next - 2]);
64750 +
64751 + alloc_stack_next--;
64752 +
64753 + return 1;
64754 +}
64755 +
64756 +static __inline__ int
64757 +alloc_push(void *buf)
64758 +{
64759 + if (alloc_stack_next >= alloc_stack_size)
64760 + return 1;
64761 +
64762 + alloc_stack[alloc_stack_next - 1] = buf;
64763 +
64764 + alloc_stack_next++;
64765 +
64766 + return 0;
64767 +}
64768 +
64769 +void *
64770 +acl_alloc(unsigned long len)
64771 +{
64772 + void *ret = NULL;
64773 +
64774 + if (!len || len > PAGE_SIZE)
64775 + goto out;
64776 +
64777 + ret = kmalloc(len, GFP_KERNEL);
64778 +
64779 + if (ret) {
64780 + if (alloc_push(ret)) {
64781 + kfree(ret);
64782 + ret = NULL;
64783 + }
64784 + }
64785 +
64786 +out:
64787 + return ret;
64788 +}
64789 +
64790 +void *
64791 +acl_alloc_num(unsigned long num, unsigned long len)
64792 +{
64793 + if (!len || (num > (PAGE_SIZE / len)))
64794 + return NULL;
64795 +
64796 + return acl_alloc(num * len);
64797 +}
64798 +
64799 +void
64800 +acl_free_all(void)
64801 +{
64802 + if (gr_acl_is_enabled() || !alloc_stack)
64803 + return;
64804 +
64805 + while (alloc_pop()) ;
64806 +
64807 + if (alloc_stack) {
64808 + if ((alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
64809 + kfree(alloc_stack);
64810 + else
64811 + vfree(alloc_stack);
64812 + }
64813 +
64814 + alloc_stack = NULL;
64815 + alloc_stack_size = 1;
64816 + alloc_stack_next = 1;
64817 +
64818 + return;
64819 +}
64820 +
64821 +int
64822 +acl_alloc_stack_init(unsigned long size)
64823 +{
64824 + if ((size * sizeof (void *)) <= PAGE_SIZE)
64825 + alloc_stack =
64826 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
64827 + else
64828 + alloc_stack = (void **) vmalloc(size * sizeof (void *));
64829 +
64830 + alloc_stack_size = size;
64831 +
64832 + if (!alloc_stack)
64833 + return 0;
64834 + else
64835 + return 1;
64836 +}
64837 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
64838 new file mode 100644
64839 index 0000000..bdd51ea
64840 --- /dev/null
64841 +++ b/grsecurity/gracl_cap.c
64842 @@ -0,0 +1,110 @@
64843 +#include <linux/kernel.h>
64844 +#include <linux/module.h>
64845 +#include <linux/sched.h>
64846 +#include <linux/gracl.h>
64847 +#include <linux/grsecurity.h>
64848 +#include <linux/grinternal.h>
64849 +
64850 +extern const char *captab_log[];
64851 +extern int captab_log_entries;
64852 +
64853 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
64854 +{
64855 + struct acl_subject_label *curracl;
64856 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
64857 + kernel_cap_t cap_audit = __cap_empty_set;
64858 +
64859 + if (!gr_acl_is_enabled())
64860 + return 1;
64861 +
64862 + curracl = task->acl;
64863 +
64864 + cap_drop = curracl->cap_lower;
64865 + cap_mask = curracl->cap_mask;
64866 + cap_audit = curracl->cap_invert_audit;
64867 +
64868 + while ((curracl = curracl->parent_subject)) {
64869 + /* if the cap isn't specified in the current computed mask but is specified in the
64870 + current level subject, and is lowered in the current level subject, then add
64871 + it to the set of dropped capabilities
64872 + otherwise, add the current level subject's mask to the current computed mask
64873 + */
64874 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
64875 + cap_raise(cap_mask, cap);
64876 + if (cap_raised(curracl->cap_lower, cap))
64877 + cap_raise(cap_drop, cap);
64878 + if (cap_raised(curracl->cap_invert_audit, cap))
64879 + cap_raise(cap_audit, cap);
64880 + }
64881 + }
64882 +
64883 + if (!cap_raised(cap_drop, cap)) {
64884 + if (cap_raised(cap_audit, cap))
64885 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
64886 + return 1;
64887 + }
64888 +
64889 + curracl = task->acl;
64890 +
64891 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
64892 + && cap_raised(cred->cap_effective, cap)) {
64893 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
64894 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
64895 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
64896 + gr_to_filename(task->exec_file->f_path.dentry,
64897 + task->exec_file->f_path.mnt) : curracl->filename,
64898 + curracl->filename, 0UL,
64899 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
64900 + return 1;
64901 + }
64902 +
64903 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
64904 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
64905 +
64906 + return 0;
64907 +}
64908 +
64909 +int
64910 +gr_acl_is_capable(const int cap)
64911 +{
64912 + return gr_task_acl_is_capable(current, current_cred(), cap);
64913 +}
64914 +
64915 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
64916 +{
64917 + struct acl_subject_label *curracl;
64918 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
64919 +
64920 + if (!gr_acl_is_enabled())
64921 + return 1;
64922 +
64923 + curracl = task->acl;
64924 +
64925 + cap_drop = curracl->cap_lower;
64926 + cap_mask = curracl->cap_mask;
64927 +
64928 + while ((curracl = curracl->parent_subject)) {
64929 + /* if the cap isn't specified in the current computed mask but is specified in the
64930 + current level subject, and is lowered in the current level subject, then add
64931 + it to the set of dropped capabilities
64932 + otherwise, add the current level subject's mask to the current computed mask
64933 + */
64934 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
64935 + cap_raise(cap_mask, cap);
64936 + if (cap_raised(curracl->cap_lower, cap))
64937 + cap_raise(cap_drop, cap);
64938 + }
64939 + }
64940 +
64941 + if (!cap_raised(cap_drop, cap))
64942 + return 1;
64943 +
64944 + return 0;
64945 +}
64946 +
64947 +int
64948 +gr_acl_is_capable_nolog(const int cap)
64949 +{
64950 + return gr_task_acl_is_capable_nolog(current, cap);
64951 +}
64952 +
64953 diff --git a/grsecurity/gracl_compat.c b/grsecurity/gracl_compat.c
64954 new file mode 100644
64955 index 0000000..a43dd06
64956 --- /dev/null
64957 +++ b/grsecurity/gracl_compat.c
64958 @@ -0,0 +1,269 @@
64959 +#include <linux/kernel.h>
64960 +#include <linux/gracl.h>
64961 +#include <linux/compat.h>
64962 +#include <linux/gracl_compat.h>
64963 +
64964 +#include <asm/uaccess.h>
64965 +
64966 +int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap)
64967 +{
64968 + struct gr_arg_wrapper_compat uwrapcompat;
64969 +
64970 + if (copy_from_user(&uwrapcompat, buf, sizeof(uwrapcompat)))
64971 + return -EFAULT;
64972 +
64973 + if ((uwrapcompat.version != GRSECURITY_VERSION) ||
64974 + (uwrapcompat.size != sizeof(struct gr_arg_compat)))
64975 + return -EINVAL;
64976 +
64977 + uwrap->arg = compat_ptr(uwrapcompat.arg);
64978 + uwrap->version = uwrapcompat.version;
64979 + uwrap->size = sizeof(struct gr_arg);
64980 +
64981 + return 0;
64982 +}
64983 +
64984 +int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg)
64985 +{
64986 + struct gr_arg_compat argcompat;
64987 +
64988 + if (copy_from_user(&argcompat, buf, sizeof(argcompat)))
64989 + return -EFAULT;
64990 +
64991 + arg->role_db.r_table = compat_ptr(argcompat.role_db.r_table);
64992 + arg->role_db.num_pointers = argcompat.role_db.num_pointers;
64993 + arg->role_db.num_roles = argcompat.role_db.num_roles;
64994 + arg->role_db.num_domain_children = argcompat.role_db.num_domain_children;
64995 + arg->role_db.num_subjects = argcompat.role_db.num_subjects;
64996 + arg->role_db.num_objects = argcompat.role_db.num_objects;
64997 +
64998 + memcpy(&arg->pw, &argcompat.pw, sizeof(arg->pw));
64999 + memcpy(&arg->salt, &argcompat.salt, sizeof(arg->salt));
65000 + memcpy(&arg->sum, &argcompat.sum, sizeof(arg->sum));
65001 + memcpy(&arg->sp_role, &argcompat.sp_role, sizeof(arg->sp_role));
65002 + arg->sprole_pws = compat_ptr(argcompat.sprole_pws);
65003 + arg->segv_device = argcompat.segv_device;
65004 + arg->segv_inode = argcompat.segv_inode;
65005 + arg->segv_uid = argcompat.segv_uid;
65006 + arg->num_sprole_pws = argcompat.num_sprole_pws;
65007 + arg->mode = argcompat.mode;
65008 +
65009 + return 0;
65010 +}
65011 +
65012 +int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp)
65013 +{
65014 + struct acl_object_label_compat objcompat;
65015 +
65016 + if (copy_from_user(&objcompat, userp, sizeof(objcompat)))
65017 + return -EFAULT;
65018 +
65019 + obj->filename = compat_ptr(objcompat.filename);
65020 + obj->inode = objcompat.inode;
65021 + obj->device = objcompat.device;
65022 + obj->mode = objcompat.mode;
65023 +
65024 + obj->nested = compat_ptr(objcompat.nested);
65025 + obj->globbed = compat_ptr(objcompat.globbed);
65026 +
65027 + obj->prev = compat_ptr(objcompat.prev);
65028 + obj->next = compat_ptr(objcompat.next);
65029 +
65030 + return 0;
65031 +}
65032 +
65033 +int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp)
65034 +{
65035 + unsigned int i;
65036 + struct acl_subject_label_compat subjcompat;
65037 +
65038 + if (copy_from_user(&subjcompat, userp, sizeof(subjcompat)))
65039 + return -EFAULT;
65040 +
65041 + subj->filename = compat_ptr(subjcompat.filename);
65042 + subj->inode = subjcompat.inode;
65043 + subj->device = subjcompat.device;
65044 + subj->mode = subjcompat.mode;
65045 + subj->cap_mask = subjcompat.cap_mask;
65046 + subj->cap_lower = subjcompat.cap_lower;
65047 + subj->cap_invert_audit = subjcompat.cap_invert_audit;
65048 +
65049 + for (i = 0; i < GR_NLIMITS; i++) {
65050 + if (subjcompat.res[i].rlim_cur == COMPAT_RLIM_INFINITY)
65051 + subj->res[i].rlim_cur = RLIM_INFINITY;
65052 + else
65053 + subj->res[i].rlim_cur = subjcompat.res[i].rlim_cur;
65054 + if (subjcompat.res[i].rlim_max == COMPAT_RLIM_INFINITY)
65055 + subj->res[i].rlim_max = RLIM_INFINITY;
65056 + else
65057 + subj->res[i].rlim_max = subjcompat.res[i].rlim_max;
65058 + }
65059 + subj->resmask = subjcompat.resmask;
65060 +
65061 + subj->user_trans_type = subjcompat.user_trans_type;
65062 + subj->group_trans_type = subjcompat.group_trans_type;
65063 + subj->user_transitions = compat_ptr(subjcompat.user_transitions);
65064 + subj->group_transitions = compat_ptr(subjcompat.group_transitions);
65065 + subj->user_trans_num = subjcompat.user_trans_num;
65066 + subj->group_trans_num = subjcompat.group_trans_num;
65067 +
65068 + memcpy(&subj->sock_families, &subjcompat.sock_families, sizeof(subj->sock_families));
65069 + memcpy(&subj->ip_proto, &subjcompat.ip_proto, sizeof(subj->ip_proto));
65070 + subj->ip_type = subjcompat.ip_type;
65071 + subj->ips = compat_ptr(subjcompat.ips);
65072 + subj->ip_num = subjcompat.ip_num;
65073 + subj->inaddr_any_override = subjcompat.inaddr_any_override;
65074 +
65075 + subj->crashes = subjcompat.crashes;
65076 + subj->expires = subjcompat.expires;
65077 +
65078 + subj->parent_subject = compat_ptr(subjcompat.parent_subject);
65079 + subj->hash = compat_ptr(subjcompat.hash);
65080 + subj->prev = compat_ptr(subjcompat.prev);
65081 + subj->next = compat_ptr(subjcompat.next);
65082 +
65083 + subj->obj_hash = compat_ptr(subjcompat.obj_hash);
65084 + subj->obj_hash_size = subjcompat.obj_hash_size;
65085 + subj->pax_flags = subjcompat.pax_flags;
65086 +
65087 + return 0;
65088 +}
65089 +
65090 +int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp)
65091 +{
65092 + struct acl_role_label_compat rolecompat;
65093 +
65094 + if (copy_from_user(&rolecompat, userp, sizeof(rolecompat)))
65095 + return -EFAULT;
65096 +
65097 + role->rolename = compat_ptr(rolecompat.rolename);
65098 + role->uidgid = rolecompat.uidgid;
65099 + role->roletype = rolecompat.roletype;
65100 +
65101 + role->auth_attempts = rolecompat.auth_attempts;
65102 + role->expires = rolecompat.expires;
65103 +
65104 + role->root_label = compat_ptr(rolecompat.root_label);
65105 + role->hash = compat_ptr(rolecompat.hash);
65106 +
65107 + role->prev = compat_ptr(rolecompat.prev);
65108 + role->next = compat_ptr(rolecompat.next);
65109 +
65110 + role->transitions = compat_ptr(rolecompat.transitions);
65111 + role->allowed_ips = compat_ptr(rolecompat.allowed_ips);
65112 + role->domain_children = compat_ptr(rolecompat.domain_children);
65113 + role->domain_child_num = rolecompat.domain_child_num;
65114 +
65115 + role->umask = rolecompat.umask;
65116 +
65117 + role->subj_hash = compat_ptr(rolecompat.subj_hash);
65118 + role->subj_hash_size = rolecompat.subj_hash_size;
65119 +
65120 + return 0;
65121 +}
65122 +
65123 +int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
65124 +{
65125 + struct role_allowed_ip_compat roleip_compat;
65126 +
65127 + if (copy_from_user(&roleip_compat, userp, sizeof(roleip_compat)))
65128 + return -EFAULT;
65129 +
65130 + roleip->addr = roleip_compat.addr;
65131 + roleip->netmask = roleip_compat.netmask;
65132 +
65133 + roleip->prev = compat_ptr(roleip_compat.prev);
65134 + roleip->next = compat_ptr(roleip_compat.next);
65135 +
65136 + return 0;
65137 +}
65138 +
65139 +int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp)
65140 +{
65141 + struct role_transition_compat trans_compat;
65142 +
65143 + if (copy_from_user(&trans_compat, userp, sizeof(trans_compat)))
65144 + return -EFAULT;
65145 +
65146 + trans->rolename = compat_ptr(trans_compat.rolename);
65147 +
65148 + trans->prev = compat_ptr(trans_compat.prev);
65149 + trans->next = compat_ptr(trans_compat.next);
65150 +
65151 + return 0;
65152 +
65153 +}
65154 +
65155 +int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
65156 +{
65157 + struct gr_hash_struct_compat hash_compat;
65158 +
65159 + if (copy_from_user(&hash_compat, userp, sizeof(hash_compat)))
65160 + return -EFAULT;
65161 +
65162 + hash->table = compat_ptr(hash_compat.table);
65163 + hash->nametable = compat_ptr(hash_compat.nametable);
65164 + hash->first = compat_ptr(hash_compat.first);
65165 +
65166 + hash->table_size = hash_compat.table_size;
65167 + hash->used_size = hash_compat.used_size;
65168 +
65169 + hash->type = hash_compat.type;
65170 +
65171 + return 0;
65172 +}
65173 +
65174 +int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp)
65175 +{
65176 + compat_uptr_t ptrcompat;
65177 +
65178 + if (copy_from_user(&ptrcompat, userp + (idx * sizeof(ptrcompat)), sizeof(ptrcompat)))
65179 + return -EFAULT;
65180 +
65181 + *(void **)ptr = compat_ptr(ptrcompat);
65182 +
65183 + return 0;
65184 +}
65185 +
65186 +int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp)
65187 +{
65188 + struct acl_ip_label_compat ip_compat;
65189 +
65190 + if (copy_from_user(&ip_compat, userp, sizeof(ip_compat)))
65191 + return -EFAULT;
65192 +
65193 + ip->iface = compat_ptr(ip_compat.iface);
65194 + ip->addr = ip_compat.addr;
65195 + ip->netmask = ip_compat.netmask;
65196 + ip->low = ip_compat.low;
65197 + ip->high = ip_compat.high;
65198 + ip->mode = ip_compat.mode;
65199 + ip->type = ip_compat.type;
65200 +
65201 + memcpy(&ip->proto, &ip_compat.proto, sizeof(ip->proto));
65202 +
65203 + ip->prev = compat_ptr(ip_compat.prev);
65204 + ip->next = compat_ptr(ip_compat.next);
65205 +
65206 + return 0;
65207 +}
65208 +
65209 +int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
65210 +{
65211 + struct sprole_pw_compat pw_compat;
65212 +
65213 + if (copy_from_user(&pw_compat, (const void *)userp + (sizeof(pw_compat) * idx), sizeof(pw_compat)))
65214 + return -EFAULT;
65215 +
65216 + pw->rolename = compat_ptr(pw_compat.rolename);
65217 + memcpy(&pw->salt, pw_compat.salt, sizeof(pw->salt));
65218 + memcpy(&pw->sum, pw_compat.sum, sizeof(pw->sum));
65219 +
65220 + return 0;
65221 +}
65222 +
65223 +size_t get_gr_arg_wrapper_size_compat(void)
65224 +{
65225 + return sizeof(struct gr_arg_wrapper_compat);
65226 +}
65227 +
65228 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
65229 new file mode 100644
65230 index 0000000..a340c17
65231 --- /dev/null
65232 +++ b/grsecurity/gracl_fs.c
65233 @@ -0,0 +1,431 @@
65234 +#include <linux/kernel.h>
65235 +#include <linux/sched.h>
65236 +#include <linux/types.h>
65237 +#include <linux/fs.h>
65238 +#include <linux/file.h>
65239 +#include <linux/stat.h>
65240 +#include <linux/grsecurity.h>
65241 +#include <linux/grinternal.h>
65242 +#include <linux/gracl.h>
65243 +
65244 +umode_t
65245 +gr_acl_umask(void)
65246 +{
65247 + if (unlikely(!gr_acl_is_enabled()))
65248 + return 0;
65249 +
65250 + return current->role->umask;
65251 +}
65252 +
65253 +__u32
65254 +gr_acl_handle_hidden_file(const struct dentry * dentry,
65255 + const struct vfsmount * mnt)
65256 +{
65257 + __u32 mode;
65258 +
65259 + if (unlikely(!dentry->d_inode))
65260 + return GR_FIND;
65261 +
65262 + mode =
65263 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
65264 +
65265 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
65266 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
65267 + return mode;
65268 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
65269 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
65270 + return 0;
65271 + } else if (unlikely(!(mode & GR_FIND)))
65272 + return 0;
65273 +
65274 + return GR_FIND;
65275 +}
65276 +
65277 +__u32
65278 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
65279 + int acc_mode)
65280 +{
65281 + __u32 reqmode = GR_FIND;
65282 + __u32 mode;
65283 +
65284 + if (unlikely(!dentry->d_inode))
65285 + return reqmode;
65286 +
65287 + if (acc_mode & MAY_APPEND)
65288 + reqmode |= GR_APPEND;
65289 + else if (acc_mode & MAY_WRITE)
65290 + reqmode |= GR_WRITE;
65291 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
65292 + reqmode |= GR_READ;
65293 +
65294 + mode =
65295 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
65296 + mnt);
65297 +
65298 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
65299 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
65300 + reqmode & GR_READ ? " reading" : "",
65301 + reqmode & GR_WRITE ? " writing" : reqmode &
65302 + GR_APPEND ? " appending" : "");
65303 + return reqmode;
65304 + } else
65305 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
65306 + {
65307 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
65308 + reqmode & GR_READ ? " reading" : "",
65309 + reqmode & GR_WRITE ? " writing" : reqmode &
65310 + GR_APPEND ? " appending" : "");
65311 + return 0;
65312 + } else if (unlikely((mode & reqmode) != reqmode))
65313 + return 0;
65314 +
65315 + return reqmode;
65316 +}
65317 +
65318 +__u32
65319 +gr_acl_handle_creat(const struct dentry * dentry,
65320 + const struct dentry * p_dentry,
65321 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
65322 + const int imode)
65323 +{
65324 + __u32 reqmode = GR_WRITE | GR_CREATE;
65325 + __u32 mode;
65326 +
65327 + if (acc_mode & MAY_APPEND)
65328 + reqmode |= GR_APPEND;
65329 + // if a directory was required or the directory already exists, then
65330 + // don't count this open as a read
65331 + if ((acc_mode & MAY_READ) &&
65332 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
65333 + reqmode |= GR_READ;
65334 + if ((open_flags & O_CREAT) &&
65335 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
65336 + reqmode |= GR_SETID;
65337 +
65338 + mode =
65339 + gr_check_create(dentry, p_dentry, p_mnt,
65340 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
65341 +
65342 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
65343 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
65344 + reqmode & GR_READ ? " reading" : "",
65345 + reqmode & GR_WRITE ? " writing" : reqmode &
65346 + GR_APPEND ? " appending" : "");
65347 + return reqmode;
65348 + } else
65349 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
65350 + {
65351 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
65352 + reqmode & GR_READ ? " reading" : "",
65353 + reqmode & GR_WRITE ? " writing" : reqmode &
65354 + GR_APPEND ? " appending" : "");
65355 + return 0;
65356 + } else if (unlikely((mode & reqmode) != reqmode))
65357 + return 0;
65358 +
65359 + return reqmode;
65360 +}
65361 +
65362 +__u32
65363 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
65364 + const int fmode)
65365 +{
65366 + __u32 mode, reqmode = GR_FIND;
65367 +
65368 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
65369 + reqmode |= GR_EXEC;
65370 + if (fmode & S_IWOTH)
65371 + reqmode |= GR_WRITE;
65372 + if (fmode & S_IROTH)
65373 + reqmode |= GR_READ;
65374 +
65375 + mode =
65376 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
65377 + mnt);
65378 +
65379 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
65380 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
65381 + reqmode & GR_READ ? " reading" : "",
65382 + reqmode & GR_WRITE ? " writing" : "",
65383 + reqmode & GR_EXEC ? " executing" : "");
65384 + return reqmode;
65385 + } else
65386 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
65387 + {
65388 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
65389 + reqmode & GR_READ ? " reading" : "",
65390 + reqmode & GR_WRITE ? " writing" : "",
65391 + reqmode & GR_EXEC ? " executing" : "");
65392 + return 0;
65393 + } else if (unlikely((mode & reqmode) != reqmode))
65394 + return 0;
65395 +
65396 + return reqmode;
65397 +}
65398 +
65399 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
65400 +{
65401 + __u32 mode;
65402 +
65403 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
65404 +
65405 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
65406 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
65407 + return mode;
65408 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
65409 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
65410 + return 0;
65411 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
65412 + return 0;
65413 +
65414 + return (reqmode);
65415 +}
65416 +
65417 +__u32
65418 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
65419 +{
65420 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
65421 +}
65422 +
65423 +__u32
65424 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
65425 +{
65426 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
65427 +}
65428 +
65429 +__u32
65430 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
65431 +{
65432 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
65433 +}
65434 +
65435 +__u32
65436 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
65437 +{
65438 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
65439 +}
65440 +
65441 +__u32
65442 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
65443 + umode_t *modeptr)
65444 +{
65445 + umode_t mode;
65446 +
65447 + *modeptr &= ~gr_acl_umask();
65448 + mode = *modeptr;
65449 +
65450 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
65451 + return 1;
65452 +
65453 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
65454 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
65455 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
65456 + GR_CHMOD_ACL_MSG);
65457 + } else {
65458 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
65459 + }
65460 +}
65461 +
65462 +__u32
65463 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
65464 +{
65465 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
65466 +}
65467 +
65468 +__u32
65469 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
65470 +{
65471 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
65472 +}
65473 +
65474 +__u32
65475 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
65476 +{
65477 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
65478 +}
65479 +
65480 +__u32
65481 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
65482 +{
65483 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
65484 + GR_UNIXCONNECT_ACL_MSG);
65485 +}
65486 +
65487 +/* hardlinks require at minimum create and link permission,
65488 + any additional privilege required is based on the
65489 + privilege of the file being linked to
65490 +*/
65491 +__u32
65492 +gr_acl_handle_link(const struct dentry * new_dentry,
65493 + const struct dentry * parent_dentry,
65494 + const struct vfsmount * parent_mnt,
65495 + const struct dentry * old_dentry,
65496 + const struct vfsmount * old_mnt, const struct filename *to)
65497 +{
65498 + __u32 mode;
65499 + __u32 needmode = GR_CREATE | GR_LINK;
65500 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
65501 +
65502 + mode =
65503 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
65504 + old_mnt);
65505 +
65506 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
65507 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
65508 + return mode;
65509 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
65510 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
65511 + return 0;
65512 + } else if (unlikely((mode & needmode) != needmode))
65513 + return 0;
65514 +
65515 + return 1;
65516 +}
65517 +
65518 +__u32
65519 +gr_acl_handle_symlink(const struct dentry * new_dentry,
65520 + const struct dentry * parent_dentry,
65521 + const struct vfsmount * parent_mnt, const struct filename *from)
65522 +{
65523 + __u32 needmode = GR_WRITE | GR_CREATE;
65524 + __u32 mode;
65525 +
65526 + mode =
65527 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
65528 + GR_CREATE | GR_AUDIT_CREATE |
65529 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
65530 +
65531 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
65532 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
65533 + return mode;
65534 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
65535 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
65536 + return 0;
65537 + } else if (unlikely((mode & needmode) != needmode))
65538 + return 0;
65539 +
65540 + return (GR_WRITE | GR_CREATE);
65541 +}
65542 +
65543 +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)
65544 +{
65545 + __u32 mode;
65546 +
65547 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
65548 +
65549 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
65550 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
65551 + return mode;
65552 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
65553 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
65554 + return 0;
65555 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
65556 + return 0;
65557 +
65558 + return (reqmode);
65559 +}
65560 +
65561 +__u32
65562 +gr_acl_handle_mknod(const struct dentry * new_dentry,
65563 + const struct dentry * parent_dentry,
65564 + const struct vfsmount * parent_mnt,
65565 + const int mode)
65566 +{
65567 + __u32 reqmode = GR_WRITE | GR_CREATE;
65568 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
65569 + reqmode |= GR_SETID;
65570 +
65571 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
65572 + reqmode, GR_MKNOD_ACL_MSG);
65573 +}
65574 +
65575 +__u32
65576 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
65577 + const struct dentry *parent_dentry,
65578 + const struct vfsmount *parent_mnt)
65579 +{
65580 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
65581 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
65582 +}
65583 +
65584 +#define RENAME_CHECK_SUCCESS(old, new) \
65585 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
65586 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
65587 +
65588 +int
65589 +gr_acl_handle_rename(struct dentry *new_dentry,
65590 + struct dentry *parent_dentry,
65591 + const struct vfsmount *parent_mnt,
65592 + struct dentry *old_dentry,
65593 + struct inode *old_parent_inode,
65594 + struct vfsmount *old_mnt, const struct filename *newname)
65595 +{
65596 + __u32 comp1, comp2;
65597 + int error = 0;
65598 +
65599 + if (unlikely(!gr_acl_is_enabled()))
65600 + return 0;
65601 +
65602 + if (!new_dentry->d_inode) {
65603 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
65604 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
65605 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
65606 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
65607 + GR_DELETE | GR_AUDIT_DELETE |
65608 + GR_AUDIT_READ | GR_AUDIT_WRITE |
65609 + GR_SUPPRESS, old_mnt);
65610 + } else {
65611 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
65612 + GR_CREATE | GR_DELETE |
65613 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
65614 + GR_AUDIT_READ | GR_AUDIT_WRITE |
65615 + GR_SUPPRESS, parent_mnt);
65616 + comp2 =
65617 + gr_search_file(old_dentry,
65618 + GR_READ | GR_WRITE | GR_AUDIT_READ |
65619 + GR_DELETE | GR_AUDIT_DELETE |
65620 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
65621 + }
65622 +
65623 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
65624 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
65625 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
65626 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
65627 + && !(comp2 & GR_SUPPRESS)) {
65628 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
65629 + error = -EACCES;
65630 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
65631 + error = -EACCES;
65632 +
65633 + return error;
65634 +}
65635 +
65636 +void
65637 +gr_acl_handle_exit(void)
65638 +{
65639 + u16 id;
65640 + char *rolename;
65641 +
65642 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
65643 + !(current->role->roletype & GR_ROLE_PERSIST))) {
65644 + id = current->acl_role_id;
65645 + rolename = current->role->rolename;
65646 + gr_set_acls(1);
65647 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
65648 + }
65649 +
65650 + gr_put_exec_file(current);
65651 + return;
65652 +}
65653 +
65654 +int
65655 +gr_acl_handle_procpidmem(const struct task_struct *task)
65656 +{
65657 + if (unlikely(!gr_acl_is_enabled()))
65658 + return 0;
65659 +
65660 + if (task != current && task->acl->mode & GR_PROTPROCFD)
65661 + return -EACCES;
65662 +
65663 + return 0;
65664 +}
65665 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
65666 new file mode 100644
65667 index 0000000..8132048
65668 --- /dev/null
65669 +++ b/grsecurity/gracl_ip.c
65670 @@ -0,0 +1,387 @@
65671 +#include <linux/kernel.h>
65672 +#include <asm/uaccess.h>
65673 +#include <asm/errno.h>
65674 +#include <net/sock.h>
65675 +#include <linux/file.h>
65676 +#include <linux/fs.h>
65677 +#include <linux/net.h>
65678 +#include <linux/in.h>
65679 +#include <linux/skbuff.h>
65680 +#include <linux/ip.h>
65681 +#include <linux/udp.h>
65682 +#include <linux/types.h>
65683 +#include <linux/sched.h>
65684 +#include <linux/netdevice.h>
65685 +#include <linux/inetdevice.h>
65686 +#include <linux/gracl.h>
65687 +#include <linux/grsecurity.h>
65688 +#include <linux/grinternal.h>
65689 +
65690 +#define GR_BIND 0x01
65691 +#define GR_CONNECT 0x02
65692 +#define GR_INVERT 0x04
65693 +#define GR_BINDOVERRIDE 0x08
65694 +#define GR_CONNECTOVERRIDE 0x10
65695 +#define GR_SOCK_FAMILY 0x20
65696 +
65697 +static const char * gr_protocols[IPPROTO_MAX] = {
65698 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
65699 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
65700 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
65701 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
65702 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
65703 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
65704 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
65705 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
65706 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
65707 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
65708 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
65709 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
65710 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
65711 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
65712 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
65713 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
65714 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
65715 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
65716 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
65717 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
65718 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
65719 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
65720 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
65721 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
65722 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
65723 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
65724 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
65725 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
65726 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
65727 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
65728 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
65729 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
65730 + };
65731 +
65732 +static const char * gr_socktypes[SOCK_MAX] = {
65733 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
65734 + "unknown:7", "unknown:8", "unknown:9", "packet"
65735 + };
65736 +
65737 +static const char * gr_sockfamilies[AF_MAX+1] = {
65738 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
65739 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
65740 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
65741 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
65742 + };
65743 +
65744 +const char *
65745 +gr_proto_to_name(unsigned char proto)
65746 +{
65747 + return gr_protocols[proto];
65748 +}
65749 +
65750 +const char *
65751 +gr_socktype_to_name(unsigned char type)
65752 +{
65753 + return gr_socktypes[type];
65754 +}
65755 +
65756 +const char *
65757 +gr_sockfamily_to_name(unsigned char family)
65758 +{
65759 + return gr_sockfamilies[family];
65760 +}
65761 +
65762 +int
65763 +gr_search_socket(const int domain, const int type, const int protocol)
65764 +{
65765 + struct acl_subject_label *curr;
65766 + const struct cred *cred = current_cred();
65767 +
65768 + if (unlikely(!gr_acl_is_enabled()))
65769 + goto exit;
65770 +
65771 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
65772 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
65773 + goto exit; // let the kernel handle it
65774 +
65775 + curr = current->acl;
65776 +
65777 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
65778 + /* the family is allowed, if this is PF_INET allow it only if
65779 + the extra sock type/protocol checks pass */
65780 + if (domain == PF_INET)
65781 + goto inet_check;
65782 + goto exit;
65783 + } else {
65784 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
65785 + __u32 fakeip = 0;
65786 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
65787 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
65788 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
65789 + gr_to_filename(current->exec_file->f_path.dentry,
65790 + current->exec_file->f_path.mnt) :
65791 + curr->filename, curr->filename,
65792 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
65793 + &current->signal->saved_ip);
65794 + goto exit;
65795 + }
65796 + goto exit_fail;
65797 + }
65798 +
65799 +inet_check:
65800 + /* the rest of this checking is for IPv4 only */
65801 + if (!curr->ips)
65802 + goto exit;
65803 +
65804 + if ((curr->ip_type & (1U << type)) &&
65805 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
65806 + goto exit;
65807 +
65808 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
65809 + /* we don't place acls on raw sockets , and sometimes
65810 + dgram/ip sockets are opened for ioctl and not
65811 + bind/connect, so we'll fake a bind learn log */
65812 + if (type == SOCK_RAW || type == SOCK_PACKET) {
65813 + __u32 fakeip = 0;
65814 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
65815 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
65816 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
65817 + gr_to_filename(current->exec_file->f_path.dentry,
65818 + current->exec_file->f_path.mnt) :
65819 + curr->filename, curr->filename,
65820 + &fakeip, 0, type,
65821 + protocol, GR_CONNECT, &current->signal->saved_ip);
65822 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
65823 + __u32 fakeip = 0;
65824 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
65825 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
65826 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
65827 + gr_to_filename(current->exec_file->f_path.dentry,
65828 + current->exec_file->f_path.mnt) :
65829 + curr->filename, curr->filename,
65830 + &fakeip, 0, type,
65831 + protocol, GR_BIND, &current->signal->saved_ip);
65832 + }
65833 + /* we'll log when they use connect or bind */
65834 + goto exit;
65835 + }
65836 +
65837 +exit_fail:
65838 + if (domain == PF_INET)
65839 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
65840 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
65841 + else
65842 +#ifndef CONFIG_IPV6
65843 + if (domain != PF_INET6)
65844 +#endif
65845 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
65846 + gr_socktype_to_name(type), protocol);
65847 +
65848 + return 0;
65849 +exit:
65850 + return 1;
65851 +}
65852 +
65853 +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)
65854 +{
65855 + if ((ip->mode & mode) &&
65856 + (ip_port >= ip->low) &&
65857 + (ip_port <= ip->high) &&
65858 + ((ntohl(ip_addr) & our_netmask) ==
65859 + (ntohl(our_addr) & our_netmask))
65860 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
65861 + && (ip->type & (1U << type))) {
65862 + if (ip->mode & GR_INVERT)
65863 + return 2; // specifically denied
65864 + else
65865 + return 1; // allowed
65866 + }
65867 +
65868 + return 0; // not specifically allowed, may continue parsing
65869 +}
65870 +
65871 +static int
65872 +gr_search_connectbind(const int full_mode, struct sock *sk,
65873 + struct sockaddr_in *addr, const int type)
65874 +{
65875 + char iface[IFNAMSIZ] = {0};
65876 + struct acl_subject_label *curr;
65877 + struct acl_ip_label *ip;
65878 + struct inet_sock *isk;
65879 + struct net_device *dev;
65880 + struct in_device *idev;
65881 + unsigned long i;
65882 + int ret;
65883 + int mode = full_mode & (GR_BIND | GR_CONNECT);
65884 + __u32 ip_addr = 0;
65885 + __u32 our_addr;
65886 + __u32 our_netmask;
65887 + char *p;
65888 + __u16 ip_port = 0;
65889 + const struct cred *cred = current_cred();
65890 +
65891 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
65892 + return 0;
65893 +
65894 + curr = current->acl;
65895 + isk = inet_sk(sk);
65896 +
65897 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
65898 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
65899 + addr->sin_addr.s_addr = curr->inaddr_any_override;
65900 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
65901 + struct sockaddr_in saddr;
65902 + int err;
65903 +
65904 + saddr.sin_family = AF_INET;
65905 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
65906 + saddr.sin_port = isk->inet_sport;
65907 +
65908 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
65909 + if (err)
65910 + return err;
65911 +
65912 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
65913 + if (err)
65914 + return err;
65915 + }
65916 +
65917 + if (!curr->ips)
65918 + return 0;
65919 +
65920 + ip_addr = addr->sin_addr.s_addr;
65921 + ip_port = ntohs(addr->sin_port);
65922 +
65923 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
65924 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
65925 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
65926 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
65927 + gr_to_filename(current->exec_file->f_path.dentry,
65928 + current->exec_file->f_path.mnt) :
65929 + curr->filename, curr->filename,
65930 + &ip_addr, ip_port, type,
65931 + sk->sk_protocol, mode, &current->signal->saved_ip);
65932 + return 0;
65933 + }
65934 +
65935 + for (i = 0; i < curr->ip_num; i++) {
65936 + ip = *(curr->ips + i);
65937 + if (ip->iface != NULL) {
65938 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
65939 + p = strchr(iface, ':');
65940 + if (p != NULL)
65941 + *p = '\0';
65942 + dev = dev_get_by_name(sock_net(sk), iface);
65943 + if (dev == NULL)
65944 + continue;
65945 + idev = in_dev_get(dev);
65946 + if (idev == NULL) {
65947 + dev_put(dev);
65948 + continue;
65949 + }
65950 + rcu_read_lock();
65951 + for_ifa(idev) {
65952 + if (!strcmp(ip->iface, ifa->ifa_label)) {
65953 + our_addr = ifa->ifa_address;
65954 + our_netmask = 0xffffffff;
65955 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
65956 + if (ret == 1) {
65957 + rcu_read_unlock();
65958 + in_dev_put(idev);
65959 + dev_put(dev);
65960 + return 0;
65961 + } else if (ret == 2) {
65962 + rcu_read_unlock();
65963 + in_dev_put(idev);
65964 + dev_put(dev);
65965 + goto denied;
65966 + }
65967 + }
65968 + } endfor_ifa(idev);
65969 + rcu_read_unlock();
65970 + in_dev_put(idev);
65971 + dev_put(dev);
65972 + } else {
65973 + our_addr = ip->addr;
65974 + our_netmask = ip->netmask;
65975 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
65976 + if (ret == 1)
65977 + return 0;
65978 + else if (ret == 2)
65979 + goto denied;
65980 + }
65981 + }
65982 +
65983 +denied:
65984 + if (mode == GR_BIND)
65985 + 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));
65986 + else if (mode == GR_CONNECT)
65987 + 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));
65988 +
65989 + return -EACCES;
65990 +}
65991 +
65992 +int
65993 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
65994 +{
65995 + /* always allow disconnection of dgram sockets with connect */
65996 + if (addr->sin_family == AF_UNSPEC)
65997 + return 0;
65998 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
65999 +}
66000 +
66001 +int
66002 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
66003 +{
66004 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
66005 +}
66006 +
66007 +int gr_search_listen(struct socket *sock)
66008 +{
66009 + struct sock *sk = sock->sk;
66010 + struct sockaddr_in addr;
66011 +
66012 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
66013 + addr.sin_port = inet_sk(sk)->inet_sport;
66014 +
66015 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
66016 +}
66017 +
66018 +int gr_search_accept(struct socket *sock)
66019 +{
66020 + struct sock *sk = sock->sk;
66021 + struct sockaddr_in addr;
66022 +
66023 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
66024 + addr.sin_port = inet_sk(sk)->inet_sport;
66025 +
66026 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
66027 +}
66028 +
66029 +int
66030 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
66031 +{
66032 + if (addr)
66033 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
66034 + else {
66035 + struct sockaddr_in sin;
66036 + const struct inet_sock *inet = inet_sk(sk);
66037 +
66038 + sin.sin_addr.s_addr = inet->inet_daddr;
66039 + sin.sin_port = inet->inet_dport;
66040 +
66041 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
66042 + }
66043 +}
66044 +
66045 +int
66046 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
66047 +{
66048 + struct sockaddr_in sin;
66049 +
66050 + if (unlikely(skb->len < sizeof (struct udphdr)))
66051 + return 0; // skip this packet
66052 +
66053 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
66054 + sin.sin_port = udp_hdr(skb)->source;
66055 +
66056 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
66057 +}
66058 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
66059 new file mode 100644
66060 index 0000000..25f54ef
66061 --- /dev/null
66062 +++ b/grsecurity/gracl_learn.c
66063 @@ -0,0 +1,207 @@
66064 +#include <linux/kernel.h>
66065 +#include <linux/mm.h>
66066 +#include <linux/sched.h>
66067 +#include <linux/poll.h>
66068 +#include <linux/string.h>
66069 +#include <linux/file.h>
66070 +#include <linux/types.h>
66071 +#include <linux/vmalloc.h>
66072 +#include <linux/grinternal.h>
66073 +
66074 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
66075 + size_t count, loff_t *ppos);
66076 +extern int gr_acl_is_enabled(void);
66077 +
66078 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
66079 +static int gr_learn_attached;
66080 +
66081 +/* use a 512k buffer */
66082 +#define LEARN_BUFFER_SIZE (512 * 1024)
66083 +
66084 +static DEFINE_SPINLOCK(gr_learn_lock);
66085 +static DEFINE_MUTEX(gr_learn_user_mutex);
66086 +
66087 +/* we need to maintain two buffers, so that the kernel context of grlearn
66088 + uses a semaphore around the userspace copying, and the other kernel contexts
66089 + use a spinlock when copying into the buffer, since they cannot sleep
66090 +*/
66091 +static char *learn_buffer;
66092 +static char *learn_buffer_user;
66093 +static int learn_buffer_len;
66094 +static int learn_buffer_user_len;
66095 +
66096 +static ssize_t
66097 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
66098 +{
66099 + DECLARE_WAITQUEUE(wait, current);
66100 + ssize_t retval = 0;
66101 +
66102 + add_wait_queue(&learn_wait, &wait);
66103 + set_current_state(TASK_INTERRUPTIBLE);
66104 + do {
66105 + mutex_lock(&gr_learn_user_mutex);
66106 + spin_lock(&gr_learn_lock);
66107 + if (learn_buffer_len)
66108 + break;
66109 + spin_unlock(&gr_learn_lock);
66110 + mutex_unlock(&gr_learn_user_mutex);
66111 + if (file->f_flags & O_NONBLOCK) {
66112 + retval = -EAGAIN;
66113 + goto out;
66114 + }
66115 + if (signal_pending(current)) {
66116 + retval = -ERESTARTSYS;
66117 + goto out;
66118 + }
66119 +
66120 + schedule();
66121 + } while (1);
66122 +
66123 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
66124 + learn_buffer_user_len = learn_buffer_len;
66125 + retval = learn_buffer_len;
66126 + learn_buffer_len = 0;
66127 +
66128 + spin_unlock(&gr_learn_lock);
66129 +
66130 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
66131 + retval = -EFAULT;
66132 +
66133 + mutex_unlock(&gr_learn_user_mutex);
66134 +out:
66135 + set_current_state(TASK_RUNNING);
66136 + remove_wait_queue(&learn_wait, &wait);
66137 + return retval;
66138 +}
66139 +
66140 +static unsigned int
66141 +poll_learn(struct file * file, poll_table * wait)
66142 +{
66143 + poll_wait(file, &learn_wait, wait);
66144 +
66145 + if (learn_buffer_len)
66146 + return (POLLIN | POLLRDNORM);
66147 +
66148 + return 0;
66149 +}
66150 +
66151 +void
66152 +gr_clear_learn_entries(void)
66153 +{
66154 + char *tmp;
66155 +
66156 + mutex_lock(&gr_learn_user_mutex);
66157 + spin_lock(&gr_learn_lock);
66158 + tmp = learn_buffer;
66159 + learn_buffer = NULL;
66160 + spin_unlock(&gr_learn_lock);
66161 + if (tmp)
66162 + vfree(tmp);
66163 + if (learn_buffer_user != NULL) {
66164 + vfree(learn_buffer_user);
66165 + learn_buffer_user = NULL;
66166 + }
66167 + learn_buffer_len = 0;
66168 + mutex_unlock(&gr_learn_user_mutex);
66169 +
66170 + return;
66171 +}
66172 +
66173 +void
66174 +gr_add_learn_entry(const char *fmt, ...)
66175 +{
66176 + va_list args;
66177 + unsigned int len;
66178 +
66179 + if (!gr_learn_attached)
66180 + return;
66181 +
66182 + spin_lock(&gr_learn_lock);
66183 +
66184 + /* leave a gap at the end so we know when it's "full" but don't have to
66185 + compute the exact length of the string we're trying to append
66186 + */
66187 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
66188 + spin_unlock(&gr_learn_lock);
66189 + wake_up_interruptible(&learn_wait);
66190 + return;
66191 + }
66192 + if (learn_buffer == NULL) {
66193 + spin_unlock(&gr_learn_lock);
66194 + return;
66195 + }
66196 +
66197 + va_start(args, fmt);
66198 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
66199 + va_end(args);
66200 +
66201 + learn_buffer_len += len + 1;
66202 +
66203 + spin_unlock(&gr_learn_lock);
66204 + wake_up_interruptible(&learn_wait);
66205 +
66206 + return;
66207 +}
66208 +
66209 +static int
66210 +open_learn(struct inode *inode, struct file *file)
66211 +{
66212 + if (file->f_mode & FMODE_READ && gr_learn_attached)
66213 + return -EBUSY;
66214 + if (file->f_mode & FMODE_READ) {
66215 + int retval = 0;
66216 + mutex_lock(&gr_learn_user_mutex);
66217 + if (learn_buffer == NULL)
66218 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
66219 + if (learn_buffer_user == NULL)
66220 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
66221 + if (learn_buffer == NULL) {
66222 + retval = -ENOMEM;
66223 + goto out_error;
66224 + }
66225 + if (learn_buffer_user == NULL) {
66226 + retval = -ENOMEM;
66227 + goto out_error;
66228 + }
66229 + learn_buffer_len = 0;
66230 + learn_buffer_user_len = 0;
66231 + gr_learn_attached = 1;
66232 +out_error:
66233 + mutex_unlock(&gr_learn_user_mutex);
66234 + return retval;
66235 + }
66236 + return 0;
66237 +}
66238 +
66239 +static int
66240 +close_learn(struct inode *inode, struct file *file)
66241 +{
66242 + if (file->f_mode & FMODE_READ) {
66243 + char *tmp = NULL;
66244 + mutex_lock(&gr_learn_user_mutex);
66245 + spin_lock(&gr_learn_lock);
66246 + tmp = learn_buffer;
66247 + learn_buffer = NULL;
66248 + spin_unlock(&gr_learn_lock);
66249 + if (tmp)
66250 + vfree(tmp);
66251 + if (learn_buffer_user != NULL) {
66252 + vfree(learn_buffer_user);
66253 + learn_buffer_user = NULL;
66254 + }
66255 + learn_buffer_len = 0;
66256 + learn_buffer_user_len = 0;
66257 + gr_learn_attached = 0;
66258 + mutex_unlock(&gr_learn_user_mutex);
66259 + }
66260 +
66261 + return 0;
66262 +}
66263 +
66264 +const struct file_operations grsec_fops = {
66265 + .read = read_learn,
66266 + .write = write_grsec_handler,
66267 + .open = open_learn,
66268 + .release = close_learn,
66269 + .poll = poll_learn,
66270 +};
66271 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
66272 new file mode 100644
66273 index 0000000..39645c9
66274 --- /dev/null
66275 +++ b/grsecurity/gracl_res.c
66276 @@ -0,0 +1,68 @@
66277 +#include <linux/kernel.h>
66278 +#include <linux/sched.h>
66279 +#include <linux/gracl.h>
66280 +#include <linux/grinternal.h>
66281 +
66282 +static const char *restab_log[] = {
66283 + [RLIMIT_CPU] = "RLIMIT_CPU",
66284 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
66285 + [RLIMIT_DATA] = "RLIMIT_DATA",
66286 + [RLIMIT_STACK] = "RLIMIT_STACK",
66287 + [RLIMIT_CORE] = "RLIMIT_CORE",
66288 + [RLIMIT_RSS] = "RLIMIT_RSS",
66289 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
66290 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
66291 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
66292 + [RLIMIT_AS] = "RLIMIT_AS",
66293 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
66294 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
66295 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
66296 + [RLIMIT_NICE] = "RLIMIT_NICE",
66297 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
66298 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
66299 + [GR_CRASH_RES] = "RLIMIT_CRASH"
66300 +};
66301 +
66302 +void
66303 +gr_log_resource(const struct task_struct *task,
66304 + const int res, const unsigned long wanted, const int gt)
66305 +{
66306 + const struct cred *cred;
66307 + unsigned long rlim;
66308 +
66309 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
66310 + return;
66311 +
66312 + // not yet supported resource
66313 + if (unlikely(!restab_log[res]))
66314 + return;
66315 +
66316 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
66317 + rlim = task_rlimit_max(task, res);
66318 + else
66319 + rlim = task_rlimit(task, res);
66320 +
66321 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
66322 + return;
66323 +
66324 + rcu_read_lock();
66325 + cred = __task_cred(task);
66326 +
66327 + if (res == RLIMIT_NPROC &&
66328 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
66329 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
66330 + goto out_rcu_unlock;
66331 + else if (res == RLIMIT_MEMLOCK &&
66332 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
66333 + goto out_rcu_unlock;
66334 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
66335 + goto out_rcu_unlock;
66336 + rcu_read_unlock();
66337 +
66338 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
66339 +
66340 + return;
66341 +out_rcu_unlock:
66342 + rcu_read_unlock();
66343 + return;
66344 +}
66345 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
66346 new file mode 100644
66347 index 0000000..3c38bfe
66348 --- /dev/null
66349 +++ b/grsecurity/gracl_segv.c
66350 @@ -0,0 +1,305 @@
66351 +#include <linux/kernel.h>
66352 +#include <linux/mm.h>
66353 +#include <asm/uaccess.h>
66354 +#include <asm/errno.h>
66355 +#include <asm/mman.h>
66356 +#include <net/sock.h>
66357 +#include <linux/file.h>
66358 +#include <linux/fs.h>
66359 +#include <linux/net.h>
66360 +#include <linux/in.h>
66361 +#include <linux/slab.h>
66362 +#include <linux/types.h>
66363 +#include <linux/sched.h>
66364 +#include <linux/timer.h>
66365 +#include <linux/gracl.h>
66366 +#include <linux/grsecurity.h>
66367 +#include <linux/grinternal.h>
66368 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
66369 +#include <linux/magic.h>
66370 +#include <linux/pagemap.h>
66371 +#include "../fs/btrfs/async-thread.h"
66372 +#include "../fs/btrfs/ctree.h"
66373 +#include "../fs/btrfs/btrfs_inode.h"
66374 +#endif
66375 +
66376 +static struct crash_uid *uid_set;
66377 +static unsigned short uid_used;
66378 +static DEFINE_SPINLOCK(gr_uid_lock);
66379 +extern rwlock_t gr_inode_lock;
66380 +extern struct acl_subject_label *
66381 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
66382 + struct acl_role_label *role);
66383 +
66384 +static inline dev_t __get_dev(const struct dentry *dentry)
66385 +{
66386 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
66387 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
66388 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
66389 + else
66390 +#endif
66391 + return dentry->d_sb->s_dev;
66392 +}
66393 +
66394 +int
66395 +gr_init_uidset(void)
66396 +{
66397 + uid_set =
66398 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
66399 + uid_used = 0;
66400 +
66401 + return uid_set ? 1 : 0;
66402 +}
66403 +
66404 +void
66405 +gr_free_uidset(void)
66406 +{
66407 + if (uid_set)
66408 + kfree(uid_set);
66409 +
66410 + return;
66411 +}
66412 +
66413 +int
66414 +gr_find_uid(const uid_t uid)
66415 +{
66416 + struct crash_uid *tmp = uid_set;
66417 + uid_t buid;
66418 + int low = 0, high = uid_used - 1, mid;
66419 +
66420 + while (high >= low) {
66421 + mid = (low + high) >> 1;
66422 + buid = tmp[mid].uid;
66423 + if (buid == uid)
66424 + return mid;
66425 + if (buid > uid)
66426 + high = mid - 1;
66427 + if (buid < uid)
66428 + low = mid + 1;
66429 + }
66430 +
66431 + return -1;
66432 +}
66433 +
66434 +static __inline__ void
66435 +gr_insertsort(void)
66436 +{
66437 + unsigned short i, j;
66438 + struct crash_uid index;
66439 +
66440 + for (i = 1; i < uid_used; i++) {
66441 + index = uid_set[i];
66442 + j = i;
66443 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
66444 + uid_set[j] = uid_set[j - 1];
66445 + j--;
66446 + }
66447 + uid_set[j] = index;
66448 + }
66449 +
66450 + return;
66451 +}
66452 +
66453 +static __inline__ void
66454 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
66455 +{
66456 + int loc;
66457 + uid_t uid = GR_GLOBAL_UID(kuid);
66458 +
66459 + if (uid_used == GR_UIDTABLE_MAX)
66460 + return;
66461 +
66462 + loc = gr_find_uid(uid);
66463 +
66464 + if (loc >= 0) {
66465 + uid_set[loc].expires = expires;
66466 + return;
66467 + }
66468 +
66469 + uid_set[uid_used].uid = uid;
66470 + uid_set[uid_used].expires = expires;
66471 + uid_used++;
66472 +
66473 + gr_insertsort();
66474 +
66475 + return;
66476 +}
66477 +
66478 +void
66479 +gr_remove_uid(const unsigned short loc)
66480 +{
66481 + unsigned short i;
66482 +
66483 + for (i = loc + 1; i < uid_used; i++)
66484 + uid_set[i - 1] = uid_set[i];
66485 +
66486 + uid_used--;
66487 +
66488 + return;
66489 +}
66490 +
66491 +int
66492 +gr_check_crash_uid(const kuid_t kuid)
66493 +{
66494 + int loc;
66495 + int ret = 0;
66496 + uid_t uid;
66497 +
66498 + if (unlikely(!gr_acl_is_enabled()))
66499 + return 0;
66500 +
66501 + uid = GR_GLOBAL_UID(kuid);
66502 +
66503 + spin_lock(&gr_uid_lock);
66504 + loc = gr_find_uid(uid);
66505 +
66506 + if (loc < 0)
66507 + goto out_unlock;
66508 +
66509 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
66510 + gr_remove_uid(loc);
66511 + else
66512 + ret = 1;
66513 +
66514 +out_unlock:
66515 + spin_unlock(&gr_uid_lock);
66516 + return ret;
66517 +}
66518 +
66519 +static __inline__ int
66520 +proc_is_setxid(const struct cred *cred)
66521 +{
66522 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
66523 + !uid_eq(cred->uid, cred->fsuid))
66524 + return 1;
66525 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
66526 + !gid_eq(cred->gid, cred->fsgid))
66527 + return 1;
66528 +
66529 + return 0;
66530 +}
66531 +
66532 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
66533 +
66534 +void
66535 +gr_handle_crash(struct task_struct *task, const int sig)
66536 +{
66537 + struct acl_subject_label *curr;
66538 + struct task_struct *tsk, *tsk2;
66539 + const struct cred *cred;
66540 + const struct cred *cred2;
66541 +
66542 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
66543 + return;
66544 +
66545 + if (unlikely(!gr_acl_is_enabled()))
66546 + return;
66547 +
66548 + curr = task->acl;
66549 +
66550 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
66551 + return;
66552 +
66553 + if (time_before_eq(curr->expires, get_seconds())) {
66554 + curr->expires = 0;
66555 + curr->crashes = 0;
66556 + }
66557 +
66558 + curr->crashes++;
66559 +
66560 + if (!curr->expires)
66561 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
66562 +
66563 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
66564 + time_after(curr->expires, get_seconds())) {
66565 + rcu_read_lock();
66566 + cred = __task_cred(task);
66567 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
66568 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
66569 + spin_lock(&gr_uid_lock);
66570 + gr_insert_uid(cred->uid, curr->expires);
66571 + spin_unlock(&gr_uid_lock);
66572 + curr->expires = 0;
66573 + curr->crashes = 0;
66574 + read_lock(&tasklist_lock);
66575 + do_each_thread(tsk2, tsk) {
66576 + cred2 = __task_cred(tsk);
66577 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
66578 + gr_fake_force_sig(SIGKILL, tsk);
66579 + } while_each_thread(tsk2, tsk);
66580 + read_unlock(&tasklist_lock);
66581 + } else {
66582 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
66583 + read_lock(&tasklist_lock);
66584 + read_lock(&grsec_exec_file_lock);
66585 + do_each_thread(tsk2, tsk) {
66586 + if (likely(tsk != task)) {
66587 + // if this thread has the same subject as the one that triggered
66588 + // RES_CRASH and it's the same binary, kill it
66589 + if (tsk->acl == task->acl && gr_is_same_file(tsk->exec_file, task->exec_file))
66590 + gr_fake_force_sig(SIGKILL, tsk);
66591 + }
66592 + } while_each_thread(tsk2, tsk);
66593 + read_unlock(&grsec_exec_file_lock);
66594 + read_unlock(&tasklist_lock);
66595 + }
66596 + rcu_read_unlock();
66597 + }
66598 +
66599 + return;
66600 +}
66601 +
66602 +int
66603 +gr_check_crash_exec(const struct file *filp)
66604 +{
66605 + struct acl_subject_label *curr;
66606 +
66607 + if (unlikely(!gr_acl_is_enabled()))
66608 + return 0;
66609 +
66610 + read_lock(&gr_inode_lock);
66611 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
66612 + __get_dev(filp->f_path.dentry),
66613 + current->role);
66614 + read_unlock(&gr_inode_lock);
66615 +
66616 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
66617 + (!curr->crashes && !curr->expires))
66618 + return 0;
66619 +
66620 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
66621 + time_after(curr->expires, get_seconds()))
66622 + return 1;
66623 + else if (time_before_eq(curr->expires, get_seconds())) {
66624 + curr->crashes = 0;
66625 + curr->expires = 0;
66626 + }
66627 +
66628 + return 0;
66629 +}
66630 +
66631 +void
66632 +gr_handle_alertkill(struct task_struct *task)
66633 +{
66634 + struct acl_subject_label *curracl;
66635 + __u32 curr_ip;
66636 + struct task_struct *p, *p2;
66637 +
66638 + if (unlikely(!gr_acl_is_enabled()))
66639 + return;
66640 +
66641 + curracl = task->acl;
66642 + curr_ip = task->signal->curr_ip;
66643 +
66644 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
66645 + read_lock(&tasklist_lock);
66646 + do_each_thread(p2, p) {
66647 + if (p->signal->curr_ip == curr_ip)
66648 + gr_fake_force_sig(SIGKILL, p);
66649 + } while_each_thread(p2, p);
66650 + read_unlock(&tasklist_lock);
66651 + } else if (curracl->mode & GR_KILLPROC)
66652 + gr_fake_force_sig(SIGKILL, task);
66653 +
66654 + return;
66655 +}
66656 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
66657 new file mode 100644
66658 index 0000000..98011b0
66659 --- /dev/null
66660 +++ b/grsecurity/gracl_shm.c
66661 @@ -0,0 +1,40 @@
66662 +#include <linux/kernel.h>
66663 +#include <linux/mm.h>
66664 +#include <linux/sched.h>
66665 +#include <linux/file.h>
66666 +#include <linux/ipc.h>
66667 +#include <linux/gracl.h>
66668 +#include <linux/grsecurity.h>
66669 +#include <linux/grinternal.h>
66670 +
66671 +int
66672 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
66673 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
66674 +{
66675 + struct task_struct *task;
66676 +
66677 + if (!gr_acl_is_enabled())
66678 + return 1;
66679 +
66680 + rcu_read_lock();
66681 + read_lock(&tasklist_lock);
66682 +
66683 + task = find_task_by_vpid(shm_cprid);
66684 +
66685 + if (unlikely(!task))
66686 + task = find_task_by_vpid(shm_lapid);
66687 +
66688 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
66689 + (task_pid_nr(task) == shm_lapid)) &&
66690 + (task->acl->mode & GR_PROTSHM) &&
66691 + (task->acl != current->acl))) {
66692 + read_unlock(&tasklist_lock);
66693 + rcu_read_unlock();
66694 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
66695 + return 0;
66696 + }
66697 + read_unlock(&tasklist_lock);
66698 + rcu_read_unlock();
66699 +
66700 + return 1;
66701 +}
66702 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
66703 new file mode 100644
66704 index 0000000..bc0be01
66705 --- /dev/null
66706 +++ b/grsecurity/grsec_chdir.c
66707 @@ -0,0 +1,19 @@
66708 +#include <linux/kernel.h>
66709 +#include <linux/sched.h>
66710 +#include <linux/fs.h>
66711 +#include <linux/file.h>
66712 +#include <linux/grsecurity.h>
66713 +#include <linux/grinternal.h>
66714 +
66715 +void
66716 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
66717 +{
66718 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
66719 + if ((grsec_enable_chdir && grsec_enable_group &&
66720 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
66721 + !grsec_enable_group)) {
66722 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
66723 + }
66724 +#endif
66725 + return;
66726 +}
66727 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
66728 new file mode 100644
66729 index 0000000..bd6e105
66730 --- /dev/null
66731 +++ b/grsecurity/grsec_chroot.c
66732 @@ -0,0 +1,370 @@
66733 +#include <linux/kernel.h>
66734 +#include <linux/module.h>
66735 +#include <linux/sched.h>
66736 +#include <linux/file.h>
66737 +#include <linux/fs.h>
66738 +#include <linux/mount.h>
66739 +#include <linux/types.h>
66740 +#include "../fs/mount.h"
66741 +#include <linux/grsecurity.h>
66742 +#include <linux/grinternal.h>
66743 +
66744 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
66745 +static int gr_init_ran;
66746 +#endif
66747 +
66748 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path)
66749 +{
66750 +#ifdef CONFIG_GRKERNSEC
66751 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
66752 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
66753 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
66754 + && gr_init_ran
66755 +#endif
66756 + )
66757 + task->gr_is_chrooted = 1;
66758 + else {
66759 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
66760 + if (task_pid_nr(task) == 1 && !gr_init_ran)
66761 + gr_init_ran = 1;
66762 +#endif
66763 + task->gr_is_chrooted = 0;
66764 + }
66765 +
66766 + task->gr_chroot_dentry = path->dentry;
66767 +#endif
66768 + return;
66769 +}
66770 +
66771 +void gr_clear_chroot_entries(struct task_struct *task)
66772 +{
66773 +#ifdef CONFIG_GRKERNSEC
66774 + task->gr_is_chrooted = 0;
66775 + task->gr_chroot_dentry = NULL;
66776 +#endif
66777 + return;
66778 +}
66779 +
66780 +int
66781 +gr_handle_chroot_unix(const pid_t pid)
66782 +{
66783 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
66784 + struct task_struct *p;
66785 +
66786 + if (unlikely(!grsec_enable_chroot_unix))
66787 + return 1;
66788 +
66789 + if (likely(!proc_is_chrooted(current)))
66790 + return 1;
66791 +
66792 + rcu_read_lock();
66793 + read_lock(&tasklist_lock);
66794 + p = find_task_by_vpid_unrestricted(pid);
66795 + if (unlikely(p && !have_same_root(current, p))) {
66796 + read_unlock(&tasklist_lock);
66797 + rcu_read_unlock();
66798 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
66799 + return 0;
66800 + }
66801 + read_unlock(&tasklist_lock);
66802 + rcu_read_unlock();
66803 +#endif
66804 + return 1;
66805 +}
66806 +
66807 +int
66808 +gr_handle_chroot_nice(void)
66809 +{
66810 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
66811 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
66812 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
66813 + return -EPERM;
66814 + }
66815 +#endif
66816 + return 0;
66817 +}
66818 +
66819 +int
66820 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
66821 +{
66822 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
66823 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
66824 + && proc_is_chrooted(current)) {
66825 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
66826 + return -EACCES;
66827 + }
66828 +#endif
66829 + return 0;
66830 +}
66831 +
66832 +int
66833 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
66834 +{
66835 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
66836 + struct task_struct *p;
66837 + int ret = 0;
66838 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
66839 + return ret;
66840 +
66841 + read_lock(&tasklist_lock);
66842 + do_each_pid_task(pid, type, p) {
66843 + if (!have_same_root(current, p)) {
66844 + ret = 1;
66845 + goto out;
66846 + }
66847 + } while_each_pid_task(pid, type, p);
66848 +out:
66849 + read_unlock(&tasklist_lock);
66850 + return ret;
66851 +#endif
66852 + return 0;
66853 +}
66854 +
66855 +int
66856 +gr_pid_is_chrooted(struct task_struct *p)
66857 +{
66858 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
66859 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
66860 + return 0;
66861 +
66862 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
66863 + !have_same_root(current, p)) {
66864 + return 1;
66865 + }
66866 +#endif
66867 + return 0;
66868 +}
66869 +
66870 +EXPORT_SYMBOL(gr_pid_is_chrooted);
66871 +
66872 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
66873 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
66874 +{
66875 + struct path path, currentroot;
66876 + int ret = 0;
66877 +
66878 + path.dentry = (struct dentry *)u_dentry;
66879 + path.mnt = (struct vfsmount *)u_mnt;
66880 + get_fs_root(current->fs, &currentroot);
66881 + if (path_is_under(&path, &currentroot))
66882 + ret = 1;
66883 + path_put(&currentroot);
66884 +
66885 + return ret;
66886 +}
66887 +#endif
66888 +
66889 +int
66890 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
66891 +{
66892 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
66893 + if (!grsec_enable_chroot_fchdir)
66894 + return 1;
66895 +
66896 + if (!proc_is_chrooted(current))
66897 + return 1;
66898 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
66899 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
66900 + return 0;
66901 + }
66902 +#endif
66903 + return 1;
66904 +}
66905 +
66906 +int
66907 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
66908 + const time_t shm_createtime)
66909 +{
66910 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
66911 + struct task_struct *p;
66912 + time_t starttime;
66913 +
66914 + if (unlikely(!grsec_enable_chroot_shmat))
66915 + return 1;
66916 +
66917 + if (likely(!proc_is_chrooted(current)))
66918 + return 1;
66919 +
66920 + rcu_read_lock();
66921 + read_lock(&tasklist_lock);
66922 +
66923 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
66924 + starttime = p->start_time.tv_sec;
66925 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
66926 + if (have_same_root(current, p)) {
66927 + goto allow;
66928 + } else {
66929 + read_unlock(&tasklist_lock);
66930 + rcu_read_unlock();
66931 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
66932 + return 0;
66933 + }
66934 + }
66935 + /* creator exited, pid reuse, fall through to next check */
66936 + }
66937 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
66938 + if (unlikely(!have_same_root(current, p))) {
66939 + read_unlock(&tasklist_lock);
66940 + rcu_read_unlock();
66941 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
66942 + return 0;
66943 + }
66944 + }
66945 +
66946 +allow:
66947 + read_unlock(&tasklist_lock);
66948 + rcu_read_unlock();
66949 +#endif
66950 + return 1;
66951 +}
66952 +
66953 +void
66954 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
66955 +{
66956 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
66957 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
66958 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
66959 +#endif
66960 + return;
66961 +}
66962 +
66963 +int
66964 +gr_handle_chroot_mknod(const struct dentry *dentry,
66965 + const struct vfsmount *mnt, const int mode)
66966 +{
66967 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
66968 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
66969 + proc_is_chrooted(current)) {
66970 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
66971 + return -EPERM;
66972 + }
66973 +#endif
66974 + return 0;
66975 +}
66976 +
66977 +int
66978 +gr_handle_chroot_mount(const struct dentry *dentry,
66979 + const struct vfsmount *mnt, const char *dev_name)
66980 +{
66981 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
66982 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
66983 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
66984 + return -EPERM;
66985 + }
66986 +#endif
66987 + return 0;
66988 +}
66989 +
66990 +int
66991 +gr_handle_chroot_pivot(void)
66992 +{
66993 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
66994 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
66995 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
66996 + return -EPERM;
66997 + }
66998 +#endif
66999 + return 0;
67000 +}
67001 +
67002 +int
67003 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
67004 +{
67005 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
67006 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
67007 + !gr_is_outside_chroot(dentry, mnt)) {
67008 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
67009 + return -EPERM;
67010 + }
67011 +#endif
67012 + return 0;
67013 +}
67014 +
67015 +extern const char *captab_log[];
67016 +extern int captab_log_entries;
67017 +
67018 +int
67019 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
67020 +{
67021 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
67022 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
67023 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
67024 + if (cap_raised(chroot_caps, cap)) {
67025 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
67026 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
67027 + }
67028 + return 0;
67029 + }
67030 + }
67031 +#endif
67032 + return 1;
67033 +}
67034 +
67035 +int
67036 +gr_chroot_is_capable(const int cap)
67037 +{
67038 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
67039 + return gr_task_chroot_is_capable(current, current_cred(), cap);
67040 +#endif
67041 + return 1;
67042 +}
67043 +
67044 +int
67045 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
67046 +{
67047 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
67048 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
67049 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
67050 + if (cap_raised(chroot_caps, cap)) {
67051 + return 0;
67052 + }
67053 + }
67054 +#endif
67055 + return 1;
67056 +}
67057 +
67058 +int
67059 +gr_chroot_is_capable_nolog(const int cap)
67060 +{
67061 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
67062 + return gr_task_chroot_is_capable_nolog(current, cap);
67063 +#endif
67064 + return 1;
67065 +}
67066 +
67067 +int
67068 +gr_handle_chroot_sysctl(const int op)
67069 +{
67070 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
67071 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
67072 + proc_is_chrooted(current))
67073 + return -EACCES;
67074 +#endif
67075 + return 0;
67076 +}
67077 +
67078 +void
67079 +gr_handle_chroot_chdir(const struct path *path)
67080 +{
67081 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
67082 + if (grsec_enable_chroot_chdir)
67083 + set_fs_pwd(current->fs, path);
67084 +#endif
67085 + return;
67086 +}
67087 +
67088 +int
67089 +gr_handle_chroot_chmod(const struct dentry *dentry,
67090 + const struct vfsmount *mnt, const int mode)
67091 +{
67092 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
67093 + /* allow chmod +s on directories, but not files */
67094 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
67095 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
67096 + proc_is_chrooted(current)) {
67097 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
67098 + return -EPERM;
67099 + }
67100 +#endif
67101 + return 0;
67102 +}
67103 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
67104 new file mode 100644
67105 index 0000000..ce65ceb
67106 --- /dev/null
67107 +++ b/grsecurity/grsec_disabled.c
67108 @@ -0,0 +1,434 @@
67109 +#include <linux/kernel.h>
67110 +#include <linux/module.h>
67111 +#include <linux/sched.h>
67112 +#include <linux/file.h>
67113 +#include <linux/fs.h>
67114 +#include <linux/kdev_t.h>
67115 +#include <linux/net.h>
67116 +#include <linux/in.h>
67117 +#include <linux/ip.h>
67118 +#include <linux/skbuff.h>
67119 +#include <linux/sysctl.h>
67120 +
67121 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
67122 +void
67123 +pax_set_initial_flags(struct linux_binprm *bprm)
67124 +{
67125 + return;
67126 +}
67127 +#endif
67128 +
67129 +#ifdef CONFIG_SYSCTL
67130 +__u32
67131 +gr_handle_sysctl(const struct ctl_table * table, const int op)
67132 +{
67133 + return 0;
67134 +}
67135 +#endif
67136 +
67137 +#ifdef CONFIG_TASKSTATS
67138 +int gr_is_taskstats_denied(int pid)
67139 +{
67140 + return 0;
67141 +}
67142 +#endif
67143 +
67144 +int
67145 +gr_acl_is_enabled(void)
67146 +{
67147 + return 0;
67148 +}
67149 +
67150 +void
67151 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
67152 +{
67153 + return;
67154 +}
67155 +
67156 +int
67157 +gr_handle_rawio(const struct inode *inode)
67158 +{
67159 + return 0;
67160 +}
67161 +
67162 +void
67163 +gr_acl_handle_psacct(struct task_struct *task, const long code)
67164 +{
67165 + return;
67166 +}
67167 +
67168 +int
67169 +gr_handle_ptrace(struct task_struct *task, const long request)
67170 +{
67171 + return 0;
67172 +}
67173 +
67174 +int
67175 +gr_handle_proc_ptrace(struct task_struct *task)
67176 +{
67177 + return 0;
67178 +}
67179 +
67180 +int
67181 +gr_set_acls(const int type)
67182 +{
67183 + return 0;
67184 +}
67185 +
67186 +int
67187 +gr_check_hidden_task(const struct task_struct *tsk)
67188 +{
67189 + return 0;
67190 +}
67191 +
67192 +int
67193 +gr_check_protected_task(const struct task_struct *task)
67194 +{
67195 + return 0;
67196 +}
67197 +
67198 +int
67199 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
67200 +{
67201 + return 0;
67202 +}
67203 +
67204 +void
67205 +gr_copy_label(struct task_struct *tsk)
67206 +{
67207 + return;
67208 +}
67209 +
67210 +void
67211 +gr_set_pax_flags(struct task_struct *task)
67212 +{
67213 + return;
67214 +}
67215 +
67216 +int
67217 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
67218 + const int unsafe_share)
67219 +{
67220 + return 0;
67221 +}
67222 +
67223 +void
67224 +gr_handle_delete(const ino_t ino, const dev_t dev)
67225 +{
67226 + return;
67227 +}
67228 +
67229 +void
67230 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
67231 +{
67232 + return;
67233 +}
67234 +
67235 +void
67236 +gr_handle_crash(struct task_struct *task, const int sig)
67237 +{
67238 + return;
67239 +}
67240 +
67241 +int
67242 +gr_check_crash_exec(const struct file *filp)
67243 +{
67244 + return 0;
67245 +}
67246 +
67247 +int
67248 +gr_check_crash_uid(const kuid_t uid)
67249 +{
67250 + return 0;
67251 +}
67252 +
67253 +void
67254 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
67255 + struct dentry *old_dentry,
67256 + struct dentry *new_dentry,
67257 + struct vfsmount *mnt, const __u8 replace)
67258 +{
67259 + return;
67260 +}
67261 +
67262 +int
67263 +gr_search_socket(const int family, const int type, const int protocol)
67264 +{
67265 + return 1;
67266 +}
67267 +
67268 +int
67269 +gr_search_connectbind(const int mode, const struct socket *sock,
67270 + const struct sockaddr_in *addr)
67271 +{
67272 + return 0;
67273 +}
67274 +
67275 +void
67276 +gr_handle_alertkill(struct task_struct *task)
67277 +{
67278 + return;
67279 +}
67280 +
67281 +__u32
67282 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
67283 +{
67284 + return 1;
67285 +}
67286 +
67287 +__u32
67288 +gr_acl_handle_hidden_file(const struct dentry * dentry,
67289 + const struct vfsmount * mnt)
67290 +{
67291 + return 1;
67292 +}
67293 +
67294 +__u32
67295 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
67296 + int acc_mode)
67297 +{
67298 + return 1;
67299 +}
67300 +
67301 +__u32
67302 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
67303 +{
67304 + return 1;
67305 +}
67306 +
67307 +__u32
67308 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
67309 +{
67310 + return 1;
67311 +}
67312 +
67313 +int
67314 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
67315 + unsigned int *vm_flags)
67316 +{
67317 + return 1;
67318 +}
67319 +
67320 +__u32
67321 +gr_acl_handle_truncate(const struct dentry * dentry,
67322 + const struct vfsmount * mnt)
67323 +{
67324 + return 1;
67325 +}
67326 +
67327 +__u32
67328 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
67329 +{
67330 + return 1;
67331 +}
67332 +
67333 +__u32
67334 +gr_acl_handle_access(const struct dentry * dentry,
67335 + const struct vfsmount * mnt, const int fmode)
67336 +{
67337 + return 1;
67338 +}
67339 +
67340 +__u32
67341 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
67342 + umode_t *mode)
67343 +{
67344 + return 1;
67345 +}
67346 +
67347 +__u32
67348 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
67349 +{
67350 + return 1;
67351 +}
67352 +
67353 +__u32
67354 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
67355 +{
67356 + return 1;
67357 +}
67358 +
67359 +void
67360 +grsecurity_init(void)
67361 +{
67362 + return;
67363 +}
67364 +
67365 +umode_t gr_acl_umask(void)
67366 +{
67367 + return 0;
67368 +}
67369 +
67370 +__u32
67371 +gr_acl_handle_mknod(const struct dentry * new_dentry,
67372 + const struct dentry * parent_dentry,
67373 + const struct vfsmount * parent_mnt,
67374 + const int mode)
67375 +{
67376 + return 1;
67377 +}
67378 +
67379 +__u32
67380 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
67381 + const struct dentry * parent_dentry,
67382 + const struct vfsmount * parent_mnt)
67383 +{
67384 + return 1;
67385 +}
67386 +
67387 +__u32
67388 +gr_acl_handle_symlink(const struct dentry * new_dentry,
67389 + const struct dentry * parent_dentry,
67390 + const struct vfsmount * parent_mnt, const struct filename *from)
67391 +{
67392 + return 1;
67393 +}
67394 +
67395 +__u32
67396 +gr_acl_handle_link(const struct dentry * new_dentry,
67397 + const struct dentry * parent_dentry,
67398 + const struct vfsmount * parent_mnt,
67399 + const struct dentry * old_dentry,
67400 + const struct vfsmount * old_mnt, const struct filename *to)
67401 +{
67402 + return 1;
67403 +}
67404 +
67405 +int
67406 +gr_acl_handle_rename(const struct dentry *new_dentry,
67407 + const struct dentry *parent_dentry,
67408 + const struct vfsmount *parent_mnt,
67409 + const struct dentry *old_dentry,
67410 + const struct inode *old_parent_inode,
67411 + const struct vfsmount *old_mnt, const struct filename *newname)
67412 +{
67413 + return 0;
67414 +}
67415 +
67416 +int
67417 +gr_acl_handle_filldir(const struct file *file, const char *name,
67418 + const int namelen, const ino_t ino)
67419 +{
67420 + return 1;
67421 +}
67422 +
67423 +int
67424 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
67425 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
67426 +{
67427 + return 1;
67428 +}
67429 +
67430 +int
67431 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
67432 +{
67433 + return 0;
67434 +}
67435 +
67436 +int
67437 +gr_search_accept(const struct socket *sock)
67438 +{
67439 + return 0;
67440 +}
67441 +
67442 +int
67443 +gr_search_listen(const struct socket *sock)
67444 +{
67445 + return 0;
67446 +}
67447 +
67448 +int
67449 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
67450 +{
67451 + return 0;
67452 +}
67453 +
67454 +__u32
67455 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
67456 +{
67457 + return 1;
67458 +}
67459 +
67460 +__u32
67461 +gr_acl_handle_creat(const struct dentry * dentry,
67462 + const struct dentry * p_dentry,
67463 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
67464 + const int imode)
67465 +{
67466 + return 1;
67467 +}
67468 +
67469 +void
67470 +gr_acl_handle_exit(void)
67471 +{
67472 + return;
67473 +}
67474 +
67475 +int
67476 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
67477 +{
67478 + return 1;
67479 +}
67480 +
67481 +void
67482 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
67483 +{
67484 + return;
67485 +}
67486 +
67487 +int
67488 +gr_acl_handle_procpidmem(const struct task_struct *task)
67489 +{
67490 + return 0;
67491 +}
67492 +
67493 +int
67494 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
67495 +{
67496 + return 0;
67497 +}
67498 +
67499 +int
67500 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
67501 +{
67502 + return 0;
67503 +}
67504 +
67505 +void
67506 +gr_set_kernel_label(struct task_struct *task)
67507 +{
67508 + return;
67509 +}
67510 +
67511 +int
67512 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
67513 +{
67514 + return 0;
67515 +}
67516 +
67517 +int
67518 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
67519 +{
67520 + return 0;
67521 +}
67522 +
67523 +int gr_acl_enable_at_secure(void)
67524 +{
67525 + return 0;
67526 +}
67527 +
67528 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
67529 +{
67530 + return dentry->d_sb->s_dev;
67531 +}
67532 +
67533 +void gr_put_exec_file(struct task_struct *task)
67534 +{
67535 + return;
67536 +}
67537 +
67538 +EXPORT_SYMBOL(gr_set_kernel_label);
67539 +#ifdef CONFIG_SECURITY
67540 +EXPORT_SYMBOL(gr_check_user_change);
67541 +EXPORT_SYMBOL(gr_check_group_change);
67542 +#endif
67543 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
67544 new file mode 100644
67545 index 0000000..387032b
67546 --- /dev/null
67547 +++ b/grsecurity/grsec_exec.c
67548 @@ -0,0 +1,187 @@
67549 +#include <linux/kernel.h>
67550 +#include <linux/sched.h>
67551 +#include <linux/file.h>
67552 +#include <linux/binfmts.h>
67553 +#include <linux/fs.h>
67554 +#include <linux/types.h>
67555 +#include <linux/grdefs.h>
67556 +#include <linux/grsecurity.h>
67557 +#include <linux/grinternal.h>
67558 +#include <linux/capability.h>
67559 +#include <linux/module.h>
67560 +#include <linux/compat.h>
67561 +
67562 +#include <asm/uaccess.h>
67563 +
67564 +#ifdef CONFIG_GRKERNSEC_EXECLOG
67565 +static char gr_exec_arg_buf[132];
67566 +static DEFINE_MUTEX(gr_exec_arg_mutex);
67567 +#endif
67568 +
67569 +struct user_arg_ptr {
67570 +#ifdef CONFIG_COMPAT
67571 + bool is_compat;
67572 +#endif
67573 + union {
67574 + const char __user *const __user *native;
67575 +#ifdef CONFIG_COMPAT
67576 + const compat_uptr_t __user *compat;
67577 +#endif
67578 + } ptr;
67579 +};
67580 +
67581 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
67582 +
67583 +void
67584 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
67585 +{
67586 +#ifdef CONFIG_GRKERNSEC_EXECLOG
67587 + char *grarg = gr_exec_arg_buf;
67588 + unsigned int i, x, execlen = 0;
67589 + char c;
67590 +
67591 + if (!((grsec_enable_execlog && grsec_enable_group &&
67592 + in_group_p(grsec_audit_gid))
67593 + || (grsec_enable_execlog && !grsec_enable_group)))
67594 + return;
67595 +
67596 + mutex_lock(&gr_exec_arg_mutex);
67597 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
67598 +
67599 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
67600 + const char __user *p;
67601 + unsigned int len;
67602 +
67603 + p = get_user_arg_ptr(argv, i);
67604 + if (IS_ERR(p))
67605 + goto log;
67606 +
67607 + len = strnlen_user(p, 128 - execlen);
67608 + if (len > 128 - execlen)
67609 + len = 128 - execlen;
67610 + else if (len > 0)
67611 + len--;
67612 + if (copy_from_user(grarg + execlen, p, len))
67613 + goto log;
67614 +
67615 + /* rewrite unprintable characters */
67616 + for (x = 0; x < len; x++) {
67617 + c = *(grarg + execlen + x);
67618 + if (c < 32 || c > 126)
67619 + *(grarg + execlen + x) = ' ';
67620 + }
67621 +
67622 + execlen += len;
67623 + *(grarg + execlen) = ' ';
67624 + *(grarg + execlen + 1) = '\0';
67625 + execlen++;
67626 + }
67627 +
67628 + log:
67629 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
67630 + bprm->file->f_path.mnt, grarg);
67631 + mutex_unlock(&gr_exec_arg_mutex);
67632 +#endif
67633 + return;
67634 +}
67635 +
67636 +#ifdef CONFIG_GRKERNSEC
67637 +extern int gr_acl_is_capable(const int cap);
67638 +extern int gr_acl_is_capable_nolog(const int cap);
67639 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
67640 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
67641 +extern int gr_chroot_is_capable(const int cap);
67642 +extern int gr_chroot_is_capable_nolog(const int cap);
67643 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
67644 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
67645 +#endif
67646 +
67647 +const char *captab_log[] = {
67648 + "CAP_CHOWN",
67649 + "CAP_DAC_OVERRIDE",
67650 + "CAP_DAC_READ_SEARCH",
67651 + "CAP_FOWNER",
67652 + "CAP_FSETID",
67653 + "CAP_KILL",
67654 + "CAP_SETGID",
67655 + "CAP_SETUID",
67656 + "CAP_SETPCAP",
67657 + "CAP_LINUX_IMMUTABLE",
67658 + "CAP_NET_BIND_SERVICE",
67659 + "CAP_NET_BROADCAST",
67660 + "CAP_NET_ADMIN",
67661 + "CAP_NET_RAW",
67662 + "CAP_IPC_LOCK",
67663 + "CAP_IPC_OWNER",
67664 + "CAP_SYS_MODULE",
67665 + "CAP_SYS_RAWIO",
67666 + "CAP_SYS_CHROOT",
67667 + "CAP_SYS_PTRACE",
67668 + "CAP_SYS_PACCT",
67669 + "CAP_SYS_ADMIN",
67670 + "CAP_SYS_BOOT",
67671 + "CAP_SYS_NICE",
67672 + "CAP_SYS_RESOURCE",
67673 + "CAP_SYS_TIME",
67674 + "CAP_SYS_TTY_CONFIG",
67675 + "CAP_MKNOD",
67676 + "CAP_LEASE",
67677 + "CAP_AUDIT_WRITE",
67678 + "CAP_AUDIT_CONTROL",
67679 + "CAP_SETFCAP",
67680 + "CAP_MAC_OVERRIDE",
67681 + "CAP_MAC_ADMIN",
67682 + "CAP_SYSLOG",
67683 + "CAP_WAKE_ALARM"
67684 +};
67685 +
67686 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
67687 +
67688 +int gr_is_capable(const int cap)
67689 +{
67690 +#ifdef CONFIG_GRKERNSEC
67691 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
67692 + return 1;
67693 + return 0;
67694 +#else
67695 + return 1;
67696 +#endif
67697 +}
67698 +
67699 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
67700 +{
67701 +#ifdef CONFIG_GRKERNSEC
67702 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
67703 + return 1;
67704 + return 0;
67705 +#else
67706 + return 1;
67707 +#endif
67708 +}
67709 +
67710 +int gr_is_capable_nolog(const int cap)
67711 +{
67712 +#ifdef CONFIG_GRKERNSEC
67713 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
67714 + return 1;
67715 + return 0;
67716 +#else
67717 + return 1;
67718 +#endif
67719 +}
67720 +
67721 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
67722 +{
67723 +#ifdef CONFIG_GRKERNSEC
67724 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
67725 + return 1;
67726 + return 0;
67727 +#else
67728 + return 1;
67729 +#endif
67730 +}
67731 +
67732 +EXPORT_SYMBOL(gr_is_capable);
67733 +EXPORT_SYMBOL(gr_is_capable_nolog);
67734 +EXPORT_SYMBOL(gr_task_is_capable);
67735 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
67736 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
67737 new file mode 100644
67738 index 0000000..06cc6ea
67739 --- /dev/null
67740 +++ b/grsecurity/grsec_fifo.c
67741 @@ -0,0 +1,24 @@
67742 +#include <linux/kernel.h>
67743 +#include <linux/sched.h>
67744 +#include <linux/fs.h>
67745 +#include <linux/file.h>
67746 +#include <linux/grinternal.h>
67747 +
67748 +int
67749 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
67750 + const struct dentry *dir, const int flag, const int acc_mode)
67751 +{
67752 +#ifdef CONFIG_GRKERNSEC_FIFO
67753 + const struct cred *cred = current_cred();
67754 +
67755 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
67756 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
67757 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
67758 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
67759 + if (!inode_permission(dentry->d_inode, acc_mode))
67760 + 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));
67761 + return -EACCES;
67762 + }
67763 +#endif
67764 + return 0;
67765 +}
67766 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
67767 new file mode 100644
67768 index 0000000..8ca18bf
67769 --- /dev/null
67770 +++ b/grsecurity/grsec_fork.c
67771 @@ -0,0 +1,23 @@
67772 +#include <linux/kernel.h>
67773 +#include <linux/sched.h>
67774 +#include <linux/grsecurity.h>
67775 +#include <linux/grinternal.h>
67776 +#include <linux/errno.h>
67777 +
67778 +void
67779 +gr_log_forkfail(const int retval)
67780 +{
67781 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
67782 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
67783 + switch (retval) {
67784 + case -EAGAIN:
67785 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
67786 + break;
67787 + case -ENOMEM:
67788 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
67789 + break;
67790 + }
67791 + }
67792 +#endif
67793 + return;
67794 +}
67795 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
67796 new file mode 100644
67797 index 0000000..ab2d875
67798 --- /dev/null
67799 +++ b/grsecurity/grsec_init.c
67800 @@ -0,0 +1,279 @@
67801 +#include <linux/kernel.h>
67802 +#include <linux/sched.h>
67803 +#include <linux/mm.h>
67804 +#include <linux/gracl.h>
67805 +#include <linux/slab.h>
67806 +#include <linux/vmalloc.h>
67807 +#include <linux/percpu.h>
67808 +#include <linux/module.h>
67809 +
67810 +int grsec_enable_ptrace_readexec;
67811 +int grsec_enable_setxid;
67812 +int grsec_enable_symlinkown;
67813 +kgid_t grsec_symlinkown_gid;
67814 +int grsec_enable_brute;
67815 +int grsec_enable_link;
67816 +int grsec_enable_dmesg;
67817 +int grsec_enable_harden_ptrace;
67818 +int grsec_enable_fifo;
67819 +int grsec_enable_execlog;
67820 +int grsec_enable_signal;
67821 +int grsec_enable_forkfail;
67822 +int grsec_enable_audit_ptrace;
67823 +int grsec_enable_time;
67824 +int grsec_enable_group;
67825 +kgid_t grsec_audit_gid;
67826 +int grsec_enable_chdir;
67827 +int grsec_enable_mount;
67828 +int grsec_enable_rofs;
67829 +int grsec_enable_chroot_findtask;
67830 +int grsec_enable_chroot_mount;
67831 +int grsec_enable_chroot_shmat;
67832 +int grsec_enable_chroot_fchdir;
67833 +int grsec_enable_chroot_double;
67834 +int grsec_enable_chroot_pivot;
67835 +int grsec_enable_chroot_chdir;
67836 +int grsec_enable_chroot_chmod;
67837 +int grsec_enable_chroot_mknod;
67838 +int grsec_enable_chroot_nice;
67839 +int grsec_enable_chroot_execlog;
67840 +int grsec_enable_chroot_caps;
67841 +int grsec_enable_chroot_sysctl;
67842 +int grsec_enable_chroot_unix;
67843 +int grsec_enable_tpe;
67844 +kgid_t grsec_tpe_gid;
67845 +int grsec_enable_blackhole;
67846 +#ifdef CONFIG_IPV6_MODULE
67847 +EXPORT_SYMBOL(grsec_enable_blackhole);
67848 +#endif
67849 +int grsec_lastack_retries;
67850 +int grsec_enable_tpe_all;
67851 +int grsec_enable_tpe_invert;
67852 +int grsec_enable_socket_all;
67853 +kgid_t grsec_socket_all_gid;
67854 +int grsec_enable_socket_client;
67855 +kgid_t grsec_socket_client_gid;
67856 +int grsec_enable_socket_server;
67857 +kgid_t grsec_socket_server_gid;
67858 +int grsec_resource_logging;
67859 +int grsec_disable_privio;
67860 +int grsec_enable_log_rwxmaps;
67861 +int grsec_lock;
67862 +
67863 +DEFINE_SPINLOCK(grsec_alert_lock);
67864 +unsigned long grsec_alert_wtime = 0;
67865 +unsigned long grsec_alert_fyet = 0;
67866 +
67867 +DEFINE_SPINLOCK(grsec_audit_lock);
67868 +
67869 +DEFINE_RWLOCK(grsec_exec_file_lock);
67870 +
67871 +char *gr_shared_page[4];
67872 +
67873 +char *gr_alert_log_fmt;
67874 +char *gr_audit_log_fmt;
67875 +char *gr_alert_log_buf;
67876 +char *gr_audit_log_buf;
67877 +
67878 +extern struct gr_arg *gr_usermode;
67879 +extern unsigned char *gr_system_salt;
67880 +extern unsigned char *gr_system_sum;
67881 +
67882 +void __init
67883 +grsecurity_init(void)
67884 +{
67885 + int j;
67886 + /* create the per-cpu shared pages */
67887 +
67888 +#ifdef CONFIG_X86
67889 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
67890 +#endif
67891 +
67892 + for (j = 0; j < 4; j++) {
67893 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
67894 + if (gr_shared_page[j] == NULL) {
67895 + panic("Unable to allocate grsecurity shared page");
67896 + return;
67897 + }
67898 + }
67899 +
67900 + /* allocate log buffers */
67901 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
67902 + if (!gr_alert_log_fmt) {
67903 + panic("Unable to allocate grsecurity alert log format buffer");
67904 + return;
67905 + }
67906 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
67907 + if (!gr_audit_log_fmt) {
67908 + panic("Unable to allocate grsecurity audit log format buffer");
67909 + return;
67910 + }
67911 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
67912 + if (!gr_alert_log_buf) {
67913 + panic("Unable to allocate grsecurity alert log buffer");
67914 + return;
67915 + }
67916 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
67917 + if (!gr_audit_log_buf) {
67918 + panic("Unable to allocate grsecurity audit log buffer");
67919 + return;
67920 + }
67921 +
67922 + /* allocate memory for authentication structure */
67923 + gr_usermode = kmalloc(sizeof(struct gr_arg), GFP_KERNEL);
67924 + gr_system_salt = kmalloc(GR_SALT_LEN, GFP_KERNEL);
67925 + gr_system_sum = kmalloc(GR_SHA_LEN, GFP_KERNEL);
67926 +
67927 + if (!gr_usermode || !gr_system_salt || !gr_system_sum) {
67928 + panic("Unable to allocate grsecurity authentication structure");
67929 + return;
67930 + }
67931 +
67932 +
67933 +#ifdef CONFIG_GRKERNSEC_IO
67934 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
67935 + grsec_disable_privio = 1;
67936 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
67937 + grsec_disable_privio = 1;
67938 +#else
67939 + grsec_disable_privio = 0;
67940 +#endif
67941 +#endif
67942 +
67943 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
67944 + /* for backward compatibility, tpe_invert always defaults to on if
67945 + enabled in the kernel
67946 + */
67947 + grsec_enable_tpe_invert = 1;
67948 +#endif
67949 +
67950 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
67951 +#ifndef CONFIG_GRKERNSEC_SYSCTL
67952 + grsec_lock = 1;
67953 +#endif
67954 +
67955 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
67956 + grsec_enable_log_rwxmaps = 1;
67957 +#endif
67958 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
67959 + grsec_enable_group = 1;
67960 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
67961 +#endif
67962 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
67963 + grsec_enable_ptrace_readexec = 1;
67964 +#endif
67965 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
67966 + grsec_enable_chdir = 1;
67967 +#endif
67968 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
67969 + grsec_enable_harden_ptrace = 1;
67970 +#endif
67971 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
67972 + grsec_enable_mount = 1;
67973 +#endif
67974 +#ifdef CONFIG_GRKERNSEC_LINK
67975 + grsec_enable_link = 1;
67976 +#endif
67977 +#ifdef CONFIG_GRKERNSEC_BRUTE
67978 + grsec_enable_brute = 1;
67979 +#endif
67980 +#ifdef CONFIG_GRKERNSEC_DMESG
67981 + grsec_enable_dmesg = 1;
67982 +#endif
67983 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
67984 + grsec_enable_blackhole = 1;
67985 + grsec_lastack_retries = 4;
67986 +#endif
67987 +#ifdef CONFIG_GRKERNSEC_FIFO
67988 + grsec_enable_fifo = 1;
67989 +#endif
67990 +#ifdef CONFIG_GRKERNSEC_EXECLOG
67991 + grsec_enable_execlog = 1;
67992 +#endif
67993 +#ifdef CONFIG_GRKERNSEC_SETXID
67994 + grsec_enable_setxid = 1;
67995 +#endif
67996 +#ifdef CONFIG_GRKERNSEC_SIGNAL
67997 + grsec_enable_signal = 1;
67998 +#endif
67999 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
68000 + grsec_enable_forkfail = 1;
68001 +#endif
68002 +#ifdef CONFIG_GRKERNSEC_TIME
68003 + grsec_enable_time = 1;
68004 +#endif
68005 +#ifdef CONFIG_GRKERNSEC_RESLOG
68006 + grsec_resource_logging = 1;
68007 +#endif
68008 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
68009 + grsec_enable_chroot_findtask = 1;
68010 +#endif
68011 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
68012 + grsec_enable_chroot_unix = 1;
68013 +#endif
68014 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
68015 + grsec_enable_chroot_mount = 1;
68016 +#endif
68017 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
68018 + grsec_enable_chroot_fchdir = 1;
68019 +#endif
68020 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
68021 + grsec_enable_chroot_shmat = 1;
68022 +#endif
68023 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
68024 + grsec_enable_audit_ptrace = 1;
68025 +#endif
68026 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
68027 + grsec_enable_chroot_double = 1;
68028 +#endif
68029 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
68030 + grsec_enable_chroot_pivot = 1;
68031 +#endif
68032 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
68033 + grsec_enable_chroot_chdir = 1;
68034 +#endif
68035 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
68036 + grsec_enable_chroot_chmod = 1;
68037 +#endif
68038 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
68039 + grsec_enable_chroot_mknod = 1;
68040 +#endif
68041 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
68042 + grsec_enable_chroot_nice = 1;
68043 +#endif
68044 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
68045 + grsec_enable_chroot_execlog = 1;
68046 +#endif
68047 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
68048 + grsec_enable_chroot_caps = 1;
68049 +#endif
68050 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
68051 + grsec_enable_chroot_sysctl = 1;
68052 +#endif
68053 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
68054 + grsec_enable_symlinkown = 1;
68055 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
68056 +#endif
68057 +#ifdef CONFIG_GRKERNSEC_TPE
68058 + grsec_enable_tpe = 1;
68059 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
68060 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
68061 + grsec_enable_tpe_all = 1;
68062 +#endif
68063 +#endif
68064 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
68065 + grsec_enable_socket_all = 1;
68066 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
68067 +#endif
68068 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
68069 + grsec_enable_socket_client = 1;
68070 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
68071 +#endif
68072 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
68073 + grsec_enable_socket_server = 1;
68074 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
68075 +#endif
68076 +#endif
68077 +
68078 + return;
68079 +}
68080 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
68081 new file mode 100644
68082 index 0000000..5e05e20
68083 --- /dev/null
68084 +++ b/grsecurity/grsec_link.c
68085 @@ -0,0 +1,58 @@
68086 +#include <linux/kernel.h>
68087 +#include <linux/sched.h>
68088 +#include <linux/fs.h>
68089 +#include <linux/file.h>
68090 +#include <linux/grinternal.h>
68091 +
68092 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
68093 +{
68094 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
68095 + const struct inode *link_inode = link->dentry->d_inode;
68096 +
68097 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
68098 + /* ignore root-owned links, e.g. /proc/self */
68099 + gr_is_global_nonroot(link_inode->i_uid) && target &&
68100 + !uid_eq(link_inode->i_uid, target->i_uid)) {
68101 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
68102 + return 1;
68103 + }
68104 +#endif
68105 + return 0;
68106 +}
68107 +
68108 +int
68109 +gr_handle_follow_link(const struct inode *parent,
68110 + const struct inode *inode,
68111 + const struct dentry *dentry, const struct vfsmount *mnt)
68112 +{
68113 +#ifdef CONFIG_GRKERNSEC_LINK
68114 + const struct cred *cred = current_cred();
68115 +
68116 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
68117 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
68118 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
68119 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
68120 + return -EACCES;
68121 + }
68122 +#endif
68123 + return 0;
68124 +}
68125 +
68126 +int
68127 +gr_handle_hardlink(const struct dentry *dentry,
68128 + const struct vfsmount *mnt,
68129 + struct inode *inode, const int mode, const struct filename *to)
68130 +{
68131 +#ifdef CONFIG_GRKERNSEC_LINK
68132 + const struct cred *cred = current_cred();
68133 +
68134 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
68135 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
68136 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
68137 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
68138 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
68139 + return -EPERM;
68140 + }
68141 +#endif
68142 + return 0;
68143 +}
68144 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
68145 new file mode 100644
68146 index 0000000..dbe0a6b
68147 --- /dev/null
68148 +++ b/grsecurity/grsec_log.c
68149 @@ -0,0 +1,341 @@
68150 +#include <linux/kernel.h>
68151 +#include <linux/sched.h>
68152 +#include <linux/file.h>
68153 +#include <linux/tty.h>
68154 +#include <linux/fs.h>
68155 +#include <linux/mm.h>
68156 +#include <linux/grinternal.h>
68157 +
68158 +#ifdef CONFIG_TREE_PREEMPT_RCU
68159 +#define DISABLE_PREEMPT() preempt_disable()
68160 +#define ENABLE_PREEMPT() preempt_enable()
68161 +#else
68162 +#define DISABLE_PREEMPT()
68163 +#define ENABLE_PREEMPT()
68164 +#endif
68165 +
68166 +#define BEGIN_LOCKS(x) \
68167 + DISABLE_PREEMPT(); \
68168 + rcu_read_lock(); \
68169 + read_lock(&tasklist_lock); \
68170 + read_lock(&grsec_exec_file_lock); \
68171 + if (x != GR_DO_AUDIT) \
68172 + spin_lock(&grsec_alert_lock); \
68173 + else \
68174 + spin_lock(&grsec_audit_lock)
68175 +
68176 +#define END_LOCKS(x) \
68177 + if (x != GR_DO_AUDIT) \
68178 + spin_unlock(&grsec_alert_lock); \
68179 + else \
68180 + spin_unlock(&grsec_audit_lock); \
68181 + read_unlock(&grsec_exec_file_lock); \
68182 + read_unlock(&tasklist_lock); \
68183 + rcu_read_unlock(); \
68184 + ENABLE_PREEMPT(); \
68185 + if (x == GR_DONT_AUDIT) \
68186 + gr_handle_alertkill(current)
68187 +
68188 +enum {
68189 + FLOODING,
68190 + NO_FLOODING
68191 +};
68192 +
68193 +extern char *gr_alert_log_fmt;
68194 +extern char *gr_audit_log_fmt;
68195 +extern char *gr_alert_log_buf;
68196 +extern char *gr_audit_log_buf;
68197 +
68198 +static int gr_log_start(int audit)
68199 +{
68200 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
68201 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
68202 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
68203 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
68204 + unsigned long curr_secs = get_seconds();
68205 +
68206 + if (audit == GR_DO_AUDIT)
68207 + goto set_fmt;
68208 +
68209 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
68210 + grsec_alert_wtime = curr_secs;
68211 + grsec_alert_fyet = 0;
68212 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
68213 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
68214 + grsec_alert_fyet++;
68215 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
68216 + grsec_alert_wtime = curr_secs;
68217 + grsec_alert_fyet++;
68218 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
68219 + return FLOODING;
68220 + }
68221 + else return FLOODING;
68222 +
68223 +set_fmt:
68224 +#endif
68225 + memset(buf, 0, PAGE_SIZE);
68226 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
68227 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
68228 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
68229 + } else if (current->signal->curr_ip) {
68230 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
68231 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
68232 + } else if (gr_acl_is_enabled()) {
68233 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
68234 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
68235 + } else {
68236 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
68237 + strcpy(buf, fmt);
68238 + }
68239 +
68240 + return NO_FLOODING;
68241 +}
68242 +
68243 +static void gr_log_middle(int audit, const char *msg, va_list ap)
68244 + __attribute__ ((format (printf, 2, 0)));
68245 +
68246 +static void gr_log_middle(int audit, const char *msg, va_list ap)
68247 +{
68248 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
68249 + unsigned int len = strlen(buf);
68250 +
68251 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
68252 +
68253 + return;
68254 +}
68255 +
68256 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
68257 + __attribute__ ((format (printf, 2, 3)));
68258 +
68259 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
68260 +{
68261 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
68262 + unsigned int len = strlen(buf);
68263 + va_list ap;
68264 +
68265 + va_start(ap, msg);
68266 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
68267 + va_end(ap);
68268 +
68269 + return;
68270 +}
68271 +
68272 +static void gr_log_end(int audit, int append_default)
68273 +{
68274 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
68275 + if (append_default) {
68276 + struct task_struct *task = current;
68277 + struct task_struct *parent = task->real_parent;
68278 + const struct cred *cred = __task_cred(task);
68279 + const struct cred *pcred = __task_cred(parent);
68280 + unsigned int len = strlen(buf);
68281 +
68282 + 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));
68283 + }
68284 +
68285 + printk("%s\n", buf);
68286 +
68287 + return;
68288 +}
68289 +
68290 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
68291 +{
68292 + int logtype;
68293 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
68294 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
68295 + void *voidptr = NULL;
68296 + int num1 = 0, num2 = 0;
68297 + unsigned long ulong1 = 0, ulong2 = 0;
68298 + struct dentry *dentry = NULL;
68299 + struct vfsmount *mnt = NULL;
68300 + struct file *file = NULL;
68301 + struct task_struct *task = NULL;
68302 + struct vm_area_struct *vma = NULL;
68303 + const struct cred *cred, *pcred;
68304 + va_list ap;
68305 +
68306 + BEGIN_LOCKS(audit);
68307 + logtype = gr_log_start(audit);
68308 + if (logtype == FLOODING) {
68309 + END_LOCKS(audit);
68310 + return;
68311 + }
68312 + va_start(ap, argtypes);
68313 + switch (argtypes) {
68314 + case GR_TTYSNIFF:
68315 + task = va_arg(ap, struct task_struct *);
68316 + 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));
68317 + break;
68318 + case GR_SYSCTL_HIDDEN:
68319 + str1 = va_arg(ap, char *);
68320 + gr_log_middle_varargs(audit, msg, result, str1);
68321 + break;
68322 + case GR_RBAC:
68323 + dentry = va_arg(ap, struct dentry *);
68324 + mnt = va_arg(ap, struct vfsmount *);
68325 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
68326 + break;
68327 + case GR_RBAC_STR:
68328 + dentry = va_arg(ap, struct dentry *);
68329 + mnt = va_arg(ap, struct vfsmount *);
68330 + str1 = va_arg(ap, char *);
68331 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
68332 + break;
68333 + case GR_STR_RBAC:
68334 + str1 = va_arg(ap, char *);
68335 + dentry = va_arg(ap, struct dentry *);
68336 + mnt = va_arg(ap, struct vfsmount *);
68337 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
68338 + break;
68339 + case GR_RBAC_MODE2:
68340 + dentry = va_arg(ap, struct dentry *);
68341 + mnt = va_arg(ap, struct vfsmount *);
68342 + str1 = va_arg(ap, char *);
68343 + str2 = va_arg(ap, char *);
68344 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
68345 + break;
68346 + case GR_RBAC_MODE3:
68347 + dentry = va_arg(ap, struct dentry *);
68348 + mnt = va_arg(ap, struct vfsmount *);
68349 + str1 = va_arg(ap, char *);
68350 + str2 = va_arg(ap, char *);
68351 + str3 = va_arg(ap, char *);
68352 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
68353 + break;
68354 + case GR_FILENAME:
68355 + dentry = va_arg(ap, struct dentry *);
68356 + mnt = va_arg(ap, struct vfsmount *);
68357 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
68358 + break;
68359 + case GR_STR_FILENAME:
68360 + str1 = va_arg(ap, char *);
68361 + dentry = va_arg(ap, struct dentry *);
68362 + mnt = va_arg(ap, struct vfsmount *);
68363 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
68364 + break;
68365 + case GR_FILENAME_STR:
68366 + dentry = va_arg(ap, struct dentry *);
68367 + mnt = va_arg(ap, struct vfsmount *);
68368 + str1 = va_arg(ap, char *);
68369 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
68370 + break;
68371 + case GR_FILENAME_TWO_INT:
68372 + dentry = va_arg(ap, struct dentry *);
68373 + mnt = va_arg(ap, struct vfsmount *);
68374 + num1 = va_arg(ap, int);
68375 + num2 = va_arg(ap, int);
68376 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
68377 + break;
68378 + case GR_FILENAME_TWO_INT_STR:
68379 + dentry = va_arg(ap, struct dentry *);
68380 + mnt = va_arg(ap, struct vfsmount *);
68381 + num1 = va_arg(ap, int);
68382 + num2 = va_arg(ap, int);
68383 + str1 = va_arg(ap, char *);
68384 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
68385 + break;
68386 + case GR_TEXTREL:
68387 + file = va_arg(ap, struct file *);
68388 + ulong1 = va_arg(ap, unsigned long);
68389 + ulong2 = va_arg(ap, unsigned long);
68390 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
68391 + break;
68392 + case GR_PTRACE:
68393 + task = va_arg(ap, struct task_struct *);
68394 + 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));
68395 + break;
68396 + case GR_RESOURCE:
68397 + task = va_arg(ap, struct task_struct *);
68398 + cred = __task_cred(task);
68399 + pcred = __task_cred(task->real_parent);
68400 + ulong1 = va_arg(ap, unsigned long);
68401 + str1 = va_arg(ap, char *);
68402 + ulong2 = va_arg(ap, unsigned long);
68403 + 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));
68404 + break;
68405 + case GR_CAP:
68406 + task = va_arg(ap, struct task_struct *);
68407 + cred = __task_cred(task);
68408 + pcred = __task_cred(task->real_parent);
68409 + str1 = va_arg(ap, char *);
68410 + 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));
68411 + break;
68412 + case GR_SIG:
68413 + str1 = va_arg(ap, char *);
68414 + voidptr = va_arg(ap, void *);
68415 + gr_log_middle_varargs(audit, msg, str1, voidptr);
68416 + break;
68417 + case GR_SIG2:
68418 + task = va_arg(ap, struct task_struct *);
68419 + cred = __task_cred(task);
68420 + pcred = __task_cred(task->real_parent);
68421 + num1 = va_arg(ap, int);
68422 + 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));
68423 + break;
68424 + case GR_CRASH1:
68425 + task = va_arg(ap, struct task_struct *);
68426 + cred = __task_cred(task);
68427 + pcred = __task_cred(task->real_parent);
68428 + ulong1 = va_arg(ap, unsigned long);
68429 + 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);
68430 + break;
68431 + case GR_CRASH2:
68432 + task = va_arg(ap, struct task_struct *);
68433 + cred = __task_cred(task);
68434 + pcred = __task_cred(task->real_parent);
68435 + ulong1 = va_arg(ap, unsigned long);
68436 + 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);
68437 + break;
68438 + case GR_RWXMAP:
68439 + file = va_arg(ap, struct file *);
68440 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
68441 + break;
68442 + case GR_RWXMAPVMA:
68443 + vma = va_arg(ap, struct vm_area_struct *);
68444 + if (vma->vm_file)
68445 + str1 = gr_to_filename(vma->vm_file->f_path.dentry, vma->vm_file->f_path.mnt);
68446 + else if (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
68447 + str1 = "<stack>";
68448 + else if (vma->vm_start <= current->mm->brk &&
68449 + vma->vm_end >= current->mm->start_brk)
68450 + str1 = "<heap>";
68451 + else
68452 + str1 = "<anonymous mapping>";
68453 + gr_log_middle_varargs(audit, msg, str1);
68454 + break;
68455 + case GR_PSACCT:
68456 + {
68457 + unsigned int wday, cday;
68458 + __u8 whr, chr;
68459 + __u8 wmin, cmin;
68460 + __u8 wsec, csec;
68461 + char cur_tty[64] = { 0 };
68462 + char parent_tty[64] = { 0 };
68463 +
68464 + task = va_arg(ap, struct task_struct *);
68465 + wday = va_arg(ap, unsigned int);
68466 + cday = va_arg(ap, unsigned int);
68467 + whr = va_arg(ap, int);
68468 + chr = va_arg(ap, int);
68469 + wmin = va_arg(ap, int);
68470 + cmin = va_arg(ap, int);
68471 + wsec = va_arg(ap, int);
68472 + csec = va_arg(ap, int);
68473 + ulong1 = va_arg(ap, unsigned long);
68474 + cred = __task_cred(task);
68475 + pcred = __task_cred(task->real_parent);
68476 +
68477 + 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));
68478 + }
68479 + break;
68480 + default:
68481 + gr_log_middle(audit, msg, ap);
68482 + }
68483 + va_end(ap);
68484 + // these don't need DEFAULTSECARGS printed on the end
68485 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
68486 + gr_log_end(audit, 0);
68487 + else
68488 + gr_log_end(audit, 1);
68489 + END_LOCKS(audit);
68490 +}
68491 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
68492 new file mode 100644
68493 index 0000000..f536303
68494 --- /dev/null
68495 +++ b/grsecurity/grsec_mem.c
68496 @@ -0,0 +1,40 @@
68497 +#include <linux/kernel.h>
68498 +#include <linux/sched.h>
68499 +#include <linux/mm.h>
68500 +#include <linux/mman.h>
68501 +#include <linux/grinternal.h>
68502 +
68503 +void
68504 +gr_handle_ioperm(void)
68505 +{
68506 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
68507 + return;
68508 +}
68509 +
68510 +void
68511 +gr_handle_iopl(void)
68512 +{
68513 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
68514 + return;
68515 +}
68516 +
68517 +void
68518 +gr_handle_mem_readwrite(u64 from, u64 to)
68519 +{
68520 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
68521 + return;
68522 +}
68523 +
68524 +void
68525 +gr_handle_vm86(void)
68526 +{
68527 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
68528 + return;
68529 +}
68530 +
68531 +void
68532 +gr_log_badprocpid(const char *entry)
68533 +{
68534 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
68535 + return;
68536 +}
68537 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
68538 new file mode 100644
68539 index 0000000..2131422
68540 --- /dev/null
68541 +++ b/grsecurity/grsec_mount.c
68542 @@ -0,0 +1,62 @@
68543 +#include <linux/kernel.h>
68544 +#include <linux/sched.h>
68545 +#include <linux/mount.h>
68546 +#include <linux/grsecurity.h>
68547 +#include <linux/grinternal.h>
68548 +
68549 +void
68550 +gr_log_remount(const char *devname, const int retval)
68551 +{
68552 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
68553 + if (grsec_enable_mount && (retval >= 0))
68554 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
68555 +#endif
68556 + return;
68557 +}
68558 +
68559 +void
68560 +gr_log_unmount(const char *devname, const int retval)
68561 +{
68562 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
68563 + if (grsec_enable_mount && (retval >= 0))
68564 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
68565 +#endif
68566 + return;
68567 +}
68568 +
68569 +void
68570 +gr_log_mount(const char *from, const char *to, const int retval)
68571 +{
68572 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
68573 + if (grsec_enable_mount && (retval >= 0))
68574 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
68575 +#endif
68576 + return;
68577 +}
68578 +
68579 +int
68580 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
68581 +{
68582 +#ifdef CONFIG_GRKERNSEC_ROFS
68583 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
68584 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
68585 + return -EPERM;
68586 + } else
68587 + return 0;
68588 +#endif
68589 + return 0;
68590 +}
68591 +
68592 +int
68593 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
68594 +{
68595 +#ifdef CONFIG_GRKERNSEC_ROFS
68596 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
68597 + dentry->d_inode && S_ISBLK(dentry->d_inode->i_mode)) {
68598 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
68599 + return -EPERM;
68600 + } else
68601 + return 0;
68602 +#endif
68603 + return 0;
68604 +}
68605 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
68606 new file mode 100644
68607 index 0000000..6ee9d50
68608 --- /dev/null
68609 +++ b/grsecurity/grsec_pax.c
68610 @@ -0,0 +1,45 @@
68611 +#include <linux/kernel.h>
68612 +#include <linux/sched.h>
68613 +#include <linux/mm.h>
68614 +#include <linux/file.h>
68615 +#include <linux/grinternal.h>
68616 +#include <linux/grsecurity.h>
68617 +
68618 +void
68619 +gr_log_textrel(struct vm_area_struct * vma)
68620 +{
68621 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
68622 + if (grsec_enable_log_rwxmaps)
68623 + gr_log_textrel_ulong_ulong(GR_DONT_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
68624 +#endif
68625 + return;
68626 +}
68627 +
68628 +void gr_log_ptgnustack(struct file *file)
68629 +{
68630 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
68631 + if (grsec_enable_log_rwxmaps)
68632 + gr_log_rwxmap(GR_DONT_AUDIT, GR_PTGNUSTACK_MSG, file);
68633 +#endif
68634 + return;
68635 +}
68636 +
68637 +void
68638 +gr_log_rwxmmap(struct file *file)
68639 +{
68640 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
68641 + if (grsec_enable_log_rwxmaps)
68642 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
68643 +#endif
68644 + return;
68645 +}
68646 +
68647 +void
68648 +gr_log_rwxmprotect(struct vm_area_struct *vma)
68649 +{
68650 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
68651 + if (grsec_enable_log_rwxmaps)
68652 + gr_log_rwxmap_vma(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, vma);
68653 +#endif
68654 + return;
68655 +}
68656 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
68657 new file mode 100644
68658 index 0000000..f7f29aa
68659 --- /dev/null
68660 +++ b/grsecurity/grsec_ptrace.c
68661 @@ -0,0 +1,30 @@
68662 +#include <linux/kernel.h>
68663 +#include <linux/sched.h>
68664 +#include <linux/grinternal.h>
68665 +#include <linux/security.h>
68666 +
68667 +void
68668 +gr_audit_ptrace(struct task_struct *task)
68669 +{
68670 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
68671 + if (grsec_enable_audit_ptrace)
68672 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
68673 +#endif
68674 + return;
68675 +}
68676 +
68677 +int
68678 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
68679 +{
68680 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
68681 + const struct dentry *dentry = file->f_path.dentry;
68682 + const struct vfsmount *mnt = file->f_path.mnt;
68683 +
68684 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
68685 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
68686 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
68687 + return -EACCES;
68688 + }
68689 +#endif
68690 + return 0;
68691 +}
68692 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
68693 new file mode 100644
68694 index 0000000..4e29cc7
68695 --- /dev/null
68696 +++ b/grsecurity/grsec_sig.c
68697 @@ -0,0 +1,246 @@
68698 +#include <linux/kernel.h>
68699 +#include <linux/sched.h>
68700 +#include <linux/fs.h>
68701 +#include <linux/delay.h>
68702 +#include <linux/grsecurity.h>
68703 +#include <linux/grinternal.h>
68704 +#include <linux/hardirq.h>
68705 +
68706 +char *signames[] = {
68707 + [SIGSEGV] = "Segmentation fault",
68708 + [SIGILL] = "Illegal instruction",
68709 + [SIGABRT] = "Abort",
68710 + [SIGBUS] = "Invalid alignment/Bus error"
68711 +};
68712 +
68713 +void
68714 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
68715 +{
68716 +#ifdef CONFIG_GRKERNSEC_SIGNAL
68717 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
68718 + (sig == SIGABRT) || (sig == SIGBUS))) {
68719 + if (task_pid_nr(t) == task_pid_nr(current)) {
68720 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
68721 + } else {
68722 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
68723 + }
68724 + }
68725 +#endif
68726 + return;
68727 +}
68728 +
68729 +int
68730 +gr_handle_signal(const struct task_struct *p, const int sig)
68731 +{
68732 +#ifdef CONFIG_GRKERNSEC
68733 + /* ignore the 0 signal for protected task checks */
68734 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
68735 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
68736 + return -EPERM;
68737 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
68738 + return -EPERM;
68739 + }
68740 +#endif
68741 + return 0;
68742 +}
68743 +
68744 +#ifdef CONFIG_GRKERNSEC
68745 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
68746 +
68747 +int gr_fake_force_sig(int sig, struct task_struct *t)
68748 +{
68749 + unsigned long int flags;
68750 + int ret, blocked, ignored;
68751 + struct k_sigaction *action;
68752 +
68753 + spin_lock_irqsave(&t->sighand->siglock, flags);
68754 + action = &t->sighand->action[sig-1];
68755 + ignored = action->sa.sa_handler == SIG_IGN;
68756 + blocked = sigismember(&t->blocked, sig);
68757 + if (blocked || ignored) {
68758 + action->sa.sa_handler = SIG_DFL;
68759 + if (blocked) {
68760 + sigdelset(&t->blocked, sig);
68761 + recalc_sigpending_and_wake(t);
68762 + }
68763 + }
68764 + if (action->sa.sa_handler == SIG_DFL)
68765 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
68766 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
68767 +
68768 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
68769 +
68770 + return ret;
68771 +}
68772 +#endif
68773 +
68774 +#ifdef CONFIG_GRKERNSEC_BRUTE
68775 +#define GR_USER_BAN_TIME (15 * 60)
68776 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
68777 +
68778 +static int __get_dumpable(unsigned long mm_flags)
68779 +{
68780 + int ret;
68781 +
68782 + ret = mm_flags & MMF_DUMPABLE_MASK;
68783 + return (ret >= 2) ? 2 : ret;
68784 +}
68785 +#endif
68786 +
68787 +void gr_handle_brute_attach(unsigned long mm_flags)
68788 +{
68789 +#ifdef CONFIG_GRKERNSEC_BRUTE
68790 + struct task_struct *p = current;
68791 + kuid_t uid = GLOBAL_ROOT_UID;
68792 + int daemon = 0;
68793 +
68794 + if (!grsec_enable_brute)
68795 + return;
68796 +
68797 + rcu_read_lock();
68798 + read_lock(&tasklist_lock);
68799 + read_lock(&grsec_exec_file_lock);
68800 + if (p->real_parent && gr_is_same_file(p->real_parent->exec_file, p->exec_file)) {
68801 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
68802 + p->real_parent->brute = 1;
68803 + daemon = 1;
68804 + } else {
68805 + const struct cred *cred = __task_cred(p), *cred2;
68806 + struct task_struct *tsk, *tsk2;
68807 +
68808 + if (!__get_dumpable(mm_flags) && gr_is_global_nonroot(cred->uid)) {
68809 + struct user_struct *user;
68810 +
68811 + uid = cred->uid;
68812 +
68813 + /* this is put upon execution past expiration */
68814 + user = find_user(uid);
68815 + if (user == NULL)
68816 + goto unlock;
68817 + user->suid_banned = 1;
68818 + user->suid_ban_expires = get_seconds() + GR_USER_BAN_TIME;
68819 + if (user->suid_ban_expires == ~0UL)
68820 + user->suid_ban_expires--;
68821 +
68822 + /* only kill other threads of the same binary, from the same user */
68823 + do_each_thread(tsk2, tsk) {
68824 + cred2 = __task_cred(tsk);
68825 + if (tsk != p && uid_eq(cred2->uid, uid) && gr_is_same_file(tsk->exec_file, p->exec_file))
68826 + gr_fake_force_sig(SIGKILL, tsk);
68827 + } while_each_thread(tsk2, tsk);
68828 + }
68829 + }
68830 +unlock:
68831 + read_unlock(&grsec_exec_file_lock);
68832 + read_unlock(&tasklist_lock);
68833 + rcu_read_unlock();
68834 +
68835 + if (gr_is_global_nonroot(uid))
68836 + 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);
68837 + else if (daemon)
68838 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
68839 +
68840 +#endif
68841 + return;
68842 +}
68843 +
68844 +void gr_handle_brute_check(void)
68845 +{
68846 +#ifdef CONFIG_GRKERNSEC_BRUTE
68847 + struct task_struct *p = current;
68848 +
68849 + if (unlikely(p->brute)) {
68850 + if (!grsec_enable_brute)
68851 + p->brute = 0;
68852 + else if (time_before(get_seconds(), p->brute_expires))
68853 + msleep(30 * 1000);
68854 + }
68855 +#endif
68856 + return;
68857 +}
68858 +
68859 +void gr_handle_kernel_exploit(void)
68860 +{
68861 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
68862 + const struct cred *cred;
68863 + struct task_struct *tsk, *tsk2;
68864 + struct user_struct *user;
68865 + kuid_t uid;
68866 +
68867 + if (in_irq() || in_serving_softirq() || in_nmi())
68868 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
68869 +
68870 + uid = current_uid();
68871 +
68872 + if (gr_is_global_root(uid))
68873 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
68874 + else {
68875 + /* kill all the processes of this user, hold a reference
68876 + to their creds struct, and prevent them from creating
68877 + another process until system reset
68878 + */
68879 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
68880 + GR_GLOBAL_UID(uid));
68881 + /* we intentionally leak this ref */
68882 + user = get_uid(current->cred->user);
68883 + if (user)
68884 + user->kernel_banned = 1;
68885 +
68886 + /* kill all processes of this user */
68887 + read_lock(&tasklist_lock);
68888 + do_each_thread(tsk2, tsk) {
68889 + cred = __task_cred(tsk);
68890 + if (uid_eq(cred->uid, uid))
68891 + gr_fake_force_sig(SIGKILL, tsk);
68892 + } while_each_thread(tsk2, tsk);
68893 + read_unlock(&tasklist_lock);
68894 + }
68895 +#endif
68896 +}
68897 +
68898 +#ifdef CONFIG_GRKERNSEC_BRUTE
68899 +static bool suid_ban_expired(struct user_struct *user)
68900 +{
68901 + if (user->suid_ban_expires != ~0UL && time_after_eq(get_seconds(), user->suid_ban_expires)) {
68902 + user->suid_banned = 0;
68903 + user->suid_ban_expires = 0;
68904 + free_uid(user);
68905 + return true;
68906 + }
68907 +
68908 + return false;
68909 +}
68910 +#endif
68911 +
68912 +int gr_process_kernel_exec_ban(void)
68913 +{
68914 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
68915 + if (unlikely(current->cred->user->kernel_banned))
68916 + return -EPERM;
68917 +#endif
68918 + return 0;
68919 +}
68920 +
68921 +int gr_process_kernel_setuid_ban(struct user_struct *user)
68922 +{
68923 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
68924 + if (unlikely(user->kernel_banned))
68925 + gr_fake_force_sig(SIGKILL, current);
68926 +#endif
68927 + return 0;
68928 +}
68929 +
68930 +int gr_process_suid_exec_ban(const struct linux_binprm *bprm)
68931 +{
68932 +#ifdef CONFIG_GRKERNSEC_BRUTE
68933 + struct user_struct *user = current->cred->user;
68934 + if (unlikely(user->suid_banned)) {
68935 + if (suid_ban_expired(user))
68936 + return 0;
68937 + /* disallow execution of suid binaries only */
68938 + else if (!uid_eq(bprm->cred->euid, current->cred->uid))
68939 + return -EPERM;
68940 + }
68941 +#endif
68942 + return 0;
68943 +}
68944 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
68945 new file mode 100644
68946 index 0000000..4030d57
68947 --- /dev/null
68948 +++ b/grsecurity/grsec_sock.c
68949 @@ -0,0 +1,244 @@
68950 +#include <linux/kernel.h>
68951 +#include <linux/module.h>
68952 +#include <linux/sched.h>
68953 +#include <linux/file.h>
68954 +#include <linux/net.h>
68955 +#include <linux/in.h>
68956 +#include <linux/ip.h>
68957 +#include <net/sock.h>
68958 +#include <net/inet_sock.h>
68959 +#include <linux/grsecurity.h>
68960 +#include <linux/grinternal.h>
68961 +#include <linux/gracl.h>
68962 +
68963 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
68964 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
68965 +
68966 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
68967 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
68968 +
68969 +#ifdef CONFIG_UNIX_MODULE
68970 +EXPORT_SYMBOL(gr_acl_handle_unix);
68971 +EXPORT_SYMBOL(gr_acl_handle_mknod);
68972 +EXPORT_SYMBOL(gr_handle_chroot_unix);
68973 +EXPORT_SYMBOL(gr_handle_create);
68974 +#endif
68975 +
68976 +#ifdef CONFIG_GRKERNSEC
68977 +#define gr_conn_table_size 32749
68978 +struct conn_table_entry {
68979 + struct conn_table_entry *next;
68980 + struct signal_struct *sig;
68981 +};
68982 +
68983 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
68984 +DEFINE_SPINLOCK(gr_conn_table_lock);
68985 +
68986 +extern const char * gr_socktype_to_name(unsigned char type);
68987 +extern const char * gr_proto_to_name(unsigned char proto);
68988 +extern const char * gr_sockfamily_to_name(unsigned char family);
68989 +
68990 +static __inline__ int
68991 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
68992 +{
68993 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
68994 +}
68995 +
68996 +static __inline__ int
68997 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
68998 + __u16 sport, __u16 dport)
68999 +{
69000 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
69001 + sig->gr_sport == sport && sig->gr_dport == dport))
69002 + return 1;
69003 + else
69004 + return 0;
69005 +}
69006 +
69007 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
69008 +{
69009 + struct conn_table_entry **match;
69010 + unsigned int index;
69011 +
69012 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
69013 + sig->gr_sport, sig->gr_dport,
69014 + gr_conn_table_size);
69015 +
69016 + newent->sig = sig;
69017 +
69018 + match = &gr_conn_table[index];
69019 + newent->next = *match;
69020 + *match = newent;
69021 +
69022 + return;
69023 +}
69024 +
69025 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
69026 +{
69027 + struct conn_table_entry *match, *last = NULL;
69028 + unsigned int index;
69029 +
69030 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
69031 + sig->gr_sport, sig->gr_dport,
69032 + gr_conn_table_size);
69033 +
69034 + match = gr_conn_table[index];
69035 + while (match && !conn_match(match->sig,
69036 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
69037 + sig->gr_dport)) {
69038 + last = match;
69039 + match = match->next;
69040 + }
69041 +
69042 + if (match) {
69043 + if (last)
69044 + last->next = match->next;
69045 + else
69046 + gr_conn_table[index] = NULL;
69047 + kfree(match);
69048 + }
69049 +
69050 + return;
69051 +}
69052 +
69053 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
69054 + __u16 sport, __u16 dport)
69055 +{
69056 + struct conn_table_entry *match;
69057 + unsigned int index;
69058 +
69059 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
69060 +
69061 + match = gr_conn_table[index];
69062 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
69063 + match = match->next;
69064 +
69065 + if (match)
69066 + return match->sig;
69067 + else
69068 + return NULL;
69069 +}
69070 +
69071 +#endif
69072 +
69073 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
69074 +{
69075 +#ifdef CONFIG_GRKERNSEC
69076 + struct signal_struct *sig = task->signal;
69077 + struct conn_table_entry *newent;
69078 +
69079 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
69080 + if (newent == NULL)
69081 + return;
69082 + /* no bh lock needed since we are called with bh disabled */
69083 + spin_lock(&gr_conn_table_lock);
69084 + gr_del_task_from_ip_table_nolock(sig);
69085 + sig->gr_saddr = inet->inet_rcv_saddr;
69086 + sig->gr_daddr = inet->inet_daddr;
69087 + sig->gr_sport = inet->inet_sport;
69088 + sig->gr_dport = inet->inet_dport;
69089 + gr_add_to_task_ip_table_nolock(sig, newent);
69090 + spin_unlock(&gr_conn_table_lock);
69091 +#endif
69092 + return;
69093 +}
69094 +
69095 +void gr_del_task_from_ip_table(struct task_struct *task)
69096 +{
69097 +#ifdef CONFIG_GRKERNSEC
69098 + spin_lock_bh(&gr_conn_table_lock);
69099 + gr_del_task_from_ip_table_nolock(task->signal);
69100 + spin_unlock_bh(&gr_conn_table_lock);
69101 +#endif
69102 + return;
69103 +}
69104 +
69105 +void
69106 +gr_attach_curr_ip(const struct sock *sk)
69107 +{
69108 +#ifdef CONFIG_GRKERNSEC
69109 + struct signal_struct *p, *set;
69110 + const struct inet_sock *inet = inet_sk(sk);
69111 +
69112 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
69113 + return;
69114 +
69115 + set = current->signal;
69116 +
69117 + spin_lock_bh(&gr_conn_table_lock);
69118 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
69119 + inet->inet_dport, inet->inet_sport);
69120 + if (unlikely(p != NULL)) {
69121 + set->curr_ip = p->curr_ip;
69122 + set->used_accept = 1;
69123 + gr_del_task_from_ip_table_nolock(p);
69124 + spin_unlock_bh(&gr_conn_table_lock);
69125 + return;
69126 + }
69127 + spin_unlock_bh(&gr_conn_table_lock);
69128 +
69129 + set->curr_ip = inet->inet_daddr;
69130 + set->used_accept = 1;
69131 +#endif
69132 + return;
69133 +}
69134 +
69135 +int
69136 +gr_handle_sock_all(const int family, const int type, const int protocol)
69137 +{
69138 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
69139 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
69140 + (family != AF_UNIX)) {
69141 + if (family == AF_INET)
69142 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
69143 + else
69144 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
69145 + return -EACCES;
69146 + }
69147 +#endif
69148 + return 0;
69149 +}
69150 +
69151 +int
69152 +gr_handle_sock_server(const struct sockaddr *sck)
69153 +{
69154 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
69155 + if (grsec_enable_socket_server &&
69156 + in_group_p(grsec_socket_server_gid) &&
69157 + sck && (sck->sa_family != AF_UNIX) &&
69158 + (sck->sa_family != AF_LOCAL)) {
69159 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
69160 + return -EACCES;
69161 + }
69162 +#endif
69163 + return 0;
69164 +}
69165 +
69166 +int
69167 +gr_handle_sock_server_other(const struct sock *sck)
69168 +{
69169 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
69170 + if (grsec_enable_socket_server &&
69171 + in_group_p(grsec_socket_server_gid) &&
69172 + sck && (sck->sk_family != AF_UNIX) &&
69173 + (sck->sk_family != AF_LOCAL)) {
69174 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
69175 + return -EACCES;
69176 + }
69177 +#endif
69178 + return 0;
69179 +}
69180 +
69181 +int
69182 +gr_handle_sock_client(const struct sockaddr *sck)
69183 +{
69184 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
69185 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
69186 + sck && (sck->sa_family != AF_UNIX) &&
69187 + (sck->sa_family != AF_LOCAL)) {
69188 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
69189 + return -EACCES;
69190 + }
69191 +#endif
69192 + return 0;
69193 +}
69194 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
69195 new file mode 100644
69196 index 0000000..7624d1c
69197 --- /dev/null
69198 +++ b/grsecurity/grsec_sysctl.c
69199 @@ -0,0 +1,460 @@
69200 +#include <linux/kernel.h>
69201 +#include <linux/sched.h>
69202 +#include <linux/sysctl.h>
69203 +#include <linux/grsecurity.h>
69204 +#include <linux/grinternal.h>
69205 +
69206 +int
69207 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
69208 +{
69209 +#ifdef CONFIG_GRKERNSEC_SYSCTL
69210 + if (dirname == NULL || name == NULL)
69211 + return 0;
69212 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
69213 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
69214 + return -EACCES;
69215 + }
69216 +#endif
69217 + return 0;
69218 +}
69219 +
69220 +#ifdef CONFIG_GRKERNSEC_ROFS
69221 +static int __maybe_unused one = 1;
69222 +#endif
69223 +
69224 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
69225 +struct ctl_table grsecurity_table[] = {
69226 +#ifdef CONFIG_GRKERNSEC_SYSCTL
69227 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
69228 +#ifdef CONFIG_GRKERNSEC_IO
69229 + {
69230 + .procname = "disable_priv_io",
69231 + .data = &grsec_disable_privio,
69232 + .maxlen = sizeof(int),
69233 + .mode = 0600,
69234 + .proc_handler = &proc_dointvec,
69235 + },
69236 +#endif
69237 +#endif
69238 +#ifdef CONFIG_GRKERNSEC_LINK
69239 + {
69240 + .procname = "linking_restrictions",
69241 + .data = &grsec_enable_link,
69242 + .maxlen = sizeof(int),
69243 + .mode = 0600,
69244 + .proc_handler = &proc_dointvec,
69245 + },
69246 +#endif
69247 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
69248 + {
69249 + .procname = "enforce_symlinksifowner",
69250 + .data = &grsec_enable_symlinkown,
69251 + .maxlen = sizeof(int),
69252 + .mode = 0600,
69253 + .proc_handler = &proc_dointvec,
69254 + },
69255 + {
69256 + .procname = "symlinkown_gid",
69257 + .data = &grsec_symlinkown_gid,
69258 + .maxlen = sizeof(int),
69259 + .mode = 0600,
69260 + .proc_handler = &proc_dointvec,
69261 + },
69262 +#endif
69263 +#ifdef CONFIG_GRKERNSEC_BRUTE
69264 + {
69265 + .procname = "deter_bruteforce",
69266 + .data = &grsec_enable_brute,
69267 + .maxlen = sizeof(int),
69268 + .mode = 0600,
69269 + .proc_handler = &proc_dointvec,
69270 + },
69271 +#endif
69272 +#ifdef CONFIG_GRKERNSEC_FIFO
69273 + {
69274 + .procname = "fifo_restrictions",
69275 + .data = &grsec_enable_fifo,
69276 + .maxlen = sizeof(int),
69277 + .mode = 0600,
69278 + .proc_handler = &proc_dointvec,
69279 + },
69280 +#endif
69281 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
69282 + {
69283 + .procname = "ptrace_readexec",
69284 + .data = &grsec_enable_ptrace_readexec,
69285 + .maxlen = sizeof(int),
69286 + .mode = 0600,
69287 + .proc_handler = &proc_dointvec,
69288 + },
69289 +#endif
69290 +#ifdef CONFIG_GRKERNSEC_SETXID
69291 + {
69292 + .procname = "consistent_setxid",
69293 + .data = &grsec_enable_setxid,
69294 + .maxlen = sizeof(int),
69295 + .mode = 0600,
69296 + .proc_handler = &proc_dointvec,
69297 + },
69298 +#endif
69299 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
69300 + {
69301 + .procname = "ip_blackhole",
69302 + .data = &grsec_enable_blackhole,
69303 + .maxlen = sizeof(int),
69304 + .mode = 0600,
69305 + .proc_handler = &proc_dointvec,
69306 + },
69307 + {
69308 + .procname = "lastack_retries",
69309 + .data = &grsec_lastack_retries,
69310 + .maxlen = sizeof(int),
69311 + .mode = 0600,
69312 + .proc_handler = &proc_dointvec,
69313 + },
69314 +#endif
69315 +#ifdef CONFIG_GRKERNSEC_EXECLOG
69316 + {
69317 + .procname = "exec_logging",
69318 + .data = &grsec_enable_execlog,
69319 + .maxlen = sizeof(int),
69320 + .mode = 0600,
69321 + .proc_handler = &proc_dointvec,
69322 + },
69323 +#endif
69324 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
69325 + {
69326 + .procname = "rwxmap_logging",
69327 + .data = &grsec_enable_log_rwxmaps,
69328 + .maxlen = sizeof(int),
69329 + .mode = 0600,
69330 + .proc_handler = &proc_dointvec,
69331 + },
69332 +#endif
69333 +#ifdef CONFIG_GRKERNSEC_SIGNAL
69334 + {
69335 + .procname = "signal_logging",
69336 + .data = &grsec_enable_signal,
69337 + .maxlen = sizeof(int),
69338 + .mode = 0600,
69339 + .proc_handler = &proc_dointvec,
69340 + },
69341 +#endif
69342 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
69343 + {
69344 + .procname = "forkfail_logging",
69345 + .data = &grsec_enable_forkfail,
69346 + .maxlen = sizeof(int),
69347 + .mode = 0600,
69348 + .proc_handler = &proc_dointvec,
69349 + },
69350 +#endif
69351 +#ifdef CONFIG_GRKERNSEC_TIME
69352 + {
69353 + .procname = "timechange_logging",
69354 + .data = &grsec_enable_time,
69355 + .maxlen = sizeof(int),
69356 + .mode = 0600,
69357 + .proc_handler = &proc_dointvec,
69358 + },
69359 +#endif
69360 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
69361 + {
69362 + .procname = "chroot_deny_shmat",
69363 + .data = &grsec_enable_chroot_shmat,
69364 + .maxlen = sizeof(int),
69365 + .mode = 0600,
69366 + .proc_handler = &proc_dointvec,
69367 + },
69368 +#endif
69369 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
69370 + {
69371 + .procname = "chroot_deny_unix",
69372 + .data = &grsec_enable_chroot_unix,
69373 + .maxlen = sizeof(int),
69374 + .mode = 0600,
69375 + .proc_handler = &proc_dointvec,
69376 + },
69377 +#endif
69378 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
69379 + {
69380 + .procname = "chroot_deny_mount",
69381 + .data = &grsec_enable_chroot_mount,
69382 + .maxlen = sizeof(int),
69383 + .mode = 0600,
69384 + .proc_handler = &proc_dointvec,
69385 + },
69386 +#endif
69387 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
69388 + {
69389 + .procname = "chroot_deny_fchdir",
69390 + .data = &grsec_enable_chroot_fchdir,
69391 + .maxlen = sizeof(int),
69392 + .mode = 0600,
69393 + .proc_handler = &proc_dointvec,
69394 + },
69395 +#endif
69396 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
69397 + {
69398 + .procname = "chroot_deny_chroot",
69399 + .data = &grsec_enable_chroot_double,
69400 + .maxlen = sizeof(int),
69401 + .mode = 0600,
69402 + .proc_handler = &proc_dointvec,
69403 + },
69404 +#endif
69405 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
69406 + {
69407 + .procname = "chroot_deny_pivot",
69408 + .data = &grsec_enable_chroot_pivot,
69409 + .maxlen = sizeof(int),
69410 + .mode = 0600,
69411 + .proc_handler = &proc_dointvec,
69412 + },
69413 +#endif
69414 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
69415 + {
69416 + .procname = "chroot_enforce_chdir",
69417 + .data = &grsec_enable_chroot_chdir,
69418 + .maxlen = sizeof(int),
69419 + .mode = 0600,
69420 + .proc_handler = &proc_dointvec,
69421 + },
69422 +#endif
69423 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
69424 + {
69425 + .procname = "chroot_deny_chmod",
69426 + .data = &grsec_enable_chroot_chmod,
69427 + .maxlen = sizeof(int),
69428 + .mode = 0600,
69429 + .proc_handler = &proc_dointvec,
69430 + },
69431 +#endif
69432 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
69433 + {
69434 + .procname = "chroot_deny_mknod",
69435 + .data = &grsec_enable_chroot_mknod,
69436 + .maxlen = sizeof(int),
69437 + .mode = 0600,
69438 + .proc_handler = &proc_dointvec,
69439 + },
69440 +#endif
69441 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
69442 + {
69443 + .procname = "chroot_restrict_nice",
69444 + .data = &grsec_enable_chroot_nice,
69445 + .maxlen = sizeof(int),
69446 + .mode = 0600,
69447 + .proc_handler = &proc_dointvec,
69448 + },
69449 +#endif
69450 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
69451 + {
69452 + .procname = "chroot_execlog",
69453 + .data = &grsec_enable_chroot_execlog,
69454 + .maxlen = sizeof(int),
69455 + .mode = 0600,
69456 + .proc_handler = &proc_dointvec,
69457 + },
69458 +#endif
69459 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
69460 + {
69461 + .procname = "chroot_caps",
69462 + .data = &grsec_enable_chroot_caps,
69463 + .maxlen = sizeof(int),
69464 + .mode = 0600,
69465 + .proc_handler = &proc_dointvec,
69466 + },
69467 +#endif
69468 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
69469 + {
69470 + .procname = "chroot_deny_sysctl",
69471 + .data = &grsec_enable_chroot_sysctl,
69472 + .maxlen = sizeof(int),
69473 + .mode = 0600,
69474 + .proc_handler = &proc_dointvec,
69475 + },
69476 +#endif
69477 +#ifdef CONFIG_GRKERNSEC_TPE
69478 + {
69479 + .procname = "tpe",
69480 + .data = &grsec_enable_tpe,
69481 + .maxlen = sizeof(int),
69482 + .mode = 0600,
69483 + .proc_handler = &proc_dointvec,
69484 + },
69485 + {
69486 + .procname = "tpe_gid",
69487 + .data = &grsec_tpe_gid,
69488 + .maxlen = sizeof(int),
69489 + .mode = 0600,
69490 + .proc_handler = &proc_dointvec,
69491 + },
69492 +#endif
69493 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
69494 + {
69495 + .procname = "tpe_invert",
69496 + .data = &grsec_enable_tpe_invert,
69497 + .maxlen = sizeof(int),
69498 + .mode = 0600,
69499 + .proc_handler = &proc_dointvec,
69500 + },
69501 +#endif
69502 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
69503 + {
69504 + .procname = "tpe_restrict_all",
69505 + .data = &grsec_enable_tpe_all,
69506 + .maxlen = sizeof(int),
69507 + .mode = 0600,
69508 + .proc_handler = &proc_dointvec,
69509 + },
69510 +#endif
69511 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
69512 + {
69513 + .procname = "socket_all",
69514 + .data = &grsec_enable_socket_all,
69515 + .maxlen = sizeof(int),
69516 + .mode = 0600,
69517 + .proc_handler = &proc_dointvec,
69518 + },
69519 + {
69520 + .procname = "socket_all_gid",
69521 + .data = &grsec_socket_all_gid,
69522 + .maxlen = sizeof(int),
69523 + .mode = 0600,
69524 + .proc_handler = &proc_dointvec,
69525 + },
69526 +#endif
69527 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
69528 + {
69529 + .procname = "socket_client",
69530 + .data = &grsec_enable_socket_client,
69531 + .maxlen = sizeof(int),
69532 + .mode = 0600,
69533 + .proc_handler = &proc_dointvec,
69534 + },
69535 + {
69536 + .procname = "socket_client_gid",
69537 + .data = &grsec_socket_client_gid,
69538 + .maxlen = sizeof(int),
69539 + .mode = 0600,
69540 + .proc_handler = &proc_dointvec,
69541 + },
69542 +#endif
69543 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
69544 + {
69545 + .procname = "socket_server",
69546 + .data = &grsec_enable_socket_server,
69547 + .maxlen = sizeof(int),
69548 + .mode = 0600,
69549 + .proc_handler = &proc_dointvec,
69550 + },
69551 + {
69552 + .procname = "socket_server_gid",
69553 + .data = &grsec_socket_server_gid,
69554 + .maxlen = sizeof(int),
69555 + .mode = 0600,
69556 + .proc_handler = &proc_dointvec,
69557 + },
69558 +#endif
69559 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
69560 + {
69561 + .procname = "audit_group",
69562 + .data = &grsec_enable_group,
69563 + .maxlen = sizeof(int),
69564 + .mode = 0600,
69565 + .proc_handler = &proc_dointvec,
69566 + },
69567 + {
69568 + .procname = "audit_gid",
69569 + .data = &grsec_audit_gid,
69570 + .maxlen = sizeof(int),
69571 + .mode = 0600,
69572 + .proc_handler = &proc_dointvec,
69573 + },
69574 +#endif
69575 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
69576 + {
69577 + .procname = "audit_chdir",
69578 + .data = &grsec_enable_chdir,
69579 + .maxlen = sizeof(int),
69580 + .mode = 0600,
69581 + .proc_handler = &proc_dointvec,
69582 + },
69583 +#endif
69584 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
69585 + {
69586 + .procname = "audit_mount",
69587 + .data = &grsec_enable_mount,
69588 + .maxlen = sizeof(int),
69589 + .mode = 0600,
69590 + .proc_handler = &proc_dointvec,
69591 + },
69592 +#endif
69593 +#ifdef CONFIG_GRKERNSEC_DMESG
69594 + {
69595 + .procname = "dmesg",
69596 + .data = &grsec_enable_dmesg,
69597 + .maxlen = sizeof(int),
69598 + .mode = 0600,
69599 + .proc_handler = &proc_dointvec,
69600 + },
69601 +#endif
69602 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
69603 + {
69604 + .procname = "chroot_findtask",
69605 + .data = &grsec_enable_chroot_findtask,
69606 + .maxlen = sizeof(int),
69607 + .mode = 0600,
69608 + .proc_handler = &proc_dointvec,
69609 + },
69610 +#endif
69611 +#ifdef CONFIG_GRKERNSEC_RESLOG
69612 + {
69613 + .procname = "resource_logging",
69614 + .data = &grsec_resource_logging,
69615 + .maxlen = sizeof(int),
69616 + .mode = 0600,
69617 + .proc_handler = &proc_dointvec,
69618 + },
69619 +#endif
69620 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
69621 + {
69622 + .procname = "audit_ptrace",
69623 + .data = &grsec_enable_audit_ptrace,
69624 + .maxlen = sizeof(int),
69625 + .mode = 0600,
69626 + .proc_handler = &proc_dointvec,
69627 + },
69628 +#endif
69629 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
69630 + {
69631 + .procname = "harden_ptrace",
69632 + .data = &grsec_enable_harden_ptrace,
69633 + .maxlen = sizeof(int),
69634 + .mode = 0600,
69635 + .proc_handler = &proc_dointvec,
69636 + },
69637 +#endif
69638 + {
69639 + .procname = "grsec_lock",
69640 + .data = &grsec_lock,
69641 + .maxlen = sizeof(int),
69642 + .mode = 0600,
69643 + .proc_handler = &proc_dointvec,
69644 + },
69645 +#endif
69646 +#ifdef CONFIG_GRKERNSEC_ROFS
69647 + {
69648 + .procname = "romount_protect",
69649 + .data = &grsec_enable_rofs,
69650 + .maxlen = sizeof(int),
69651 + .mode = 0600,
69652 + .proc_handler = &proc_dointvec_minmax,
69653 + .extra1 = &one,
69654 + .extra2 = &one,
69655 + },
69656 +#endif
69657 + { }
69658 +};
69659 +#endif
69660 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
69661 new file mode 100644
69662 index 0000000..0dc13c3
69663 --- /dev/null
69664 +++ b/grsecurity/grsec_time.c
69665 @@ -0,0 +1,16 @@
69666 +#include <linux/kernel.h>
69667 +#include <linux/sched.h>
69668 +#include <linux/grinternal.h>
69669 +#include <linux/module.h>
69670 +
69671 +void
69672 +gr_log_timechange(void)
69673 +{
69674 +#ifdef CONFIG_GRKERNSEC_TIME
69675 + if (grsec_enable_time)
69676 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
69677 +#endif
69678 + return;
69679 +}
69680 +
69681 +EXPORT_SYMBOL(gr_log_timechange);
69682 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
69683 new file mode 100644
69684 index 0000000..ee57dcf
69685 --- /dev/null
69686 +++ b/grsecurity/grsec_tpe.c
69687 @@ -0,0 +1,73 @@
69688 +#include <linux/kernel.h>
69689 +#include <linux/sched.h>
69690 +#include <linux/file.h>
69691 +#include <linux/fs.h>
69692 +#include <linux/grinternal.h>
69693 +
69694 +extern int gr_acl_tpe_check(void);
69695 +
69696 +int
69697 +gr_tpe_allow(const struct file *file)
69698 +{
69699 +#ifdef CONFIG_GRKERNSEC
69700 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
69701 + const struct cred *cred = current_cred();
69702 + char *msg = NULL;
69703 + char *msg2 = NULL;
69704 +
69705 + // never restrict root
69706 + if (gr_is_global_root(cred->uid))
69707 + return 1;
69708 +
69709 + if (grsec_enable_tpe) {
69710 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
69711 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
69712 + msg = "not being in trusted group";
69713 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
69714 + msg = "being in untrusted group";
69715 +#else
69716 + if (in_group_p(grsec_tpe_gid))
69717 + msg = "being in untrusted group";
69718 +#endif
69719 + }
69720 + if (!msg && gr_acl_tpe_check())
69721 + msg = "being in untrusted role";
69722 +
69723 + // not in any affected group/role
69724 + if (!msg)
69725 + goto next_check;
69726 +
69727 + if (gr_is_global_nonroot(inode->i_uid))
69728 + msg2 = "file in non-root-owned directory";
69729 + else if (inode->i_mode & S_IWOTH)
69730 + msg2 = "file in world-writable directory";
69731 + else if (inode->i_mode & S_IWGRP)
69732 + msg2 = "file in group-writable directory";
69733 +
69734 + if (msg && msg2) {
69735 + char fullmsg[70] = {0};
69736 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
69737 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
69738 + return 0;
69739 + }
69740 + msg = NULL;
69741 +next_check:
69742 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
69743 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
69744 + return 1;
69745 +
69746 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
69747 + msg = "directory not owned by user";
69748 + else if (inode->i_mode & S_IWOTH)
69749 + msg = "file in world-writable directory";
69750 + else if (inode->i_mode & S_IWGRP)
69751 + msg = "file in group-writable directory";
69752 +
69753 + if (msg) {
69754 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
69755 + return 0;
69756 + }
69757 +#endif
69758 +#endif
69759 + return 1;
69760 +}
69761 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
69762 new file mode 100644
69763 index 0000000..9f7b1ac
69764 --- /dev/null
69765 +++ b/grsecurity/grsum.c
69766 @@ -0,0 +1,61 @@
69767 +#include <linux/err.h>
69768 +#include <linux/kernel.h>
69769 +#include <linux/sched.h>
69770 +#include <linux/mm.h>
69771 +#include <linux/scatterlist.h>
69772 +#include <linux/crypto.h>
69773 +#include <linux/gracl.h>
69774 +
69775 +
69776 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
69777 +#error "crypto and sha256 must be built into the kernel"
69778 +#endif
69779 +
69780 +int
69781 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
69782 +{
69783 + char *p;
69784 + struct crypto_hash *tfm;
69785 + struct hash_desc desc;
69786 + struct scatterlist sg;
69787 + unsigned char temp_sum[GR_SHA_LEN];
69788 + volatile int retval = 0;
69789 + volatile int dummy = 0;
69790 + unsigned int i;
69791 +
69792 + sg_init_table(&sg, 1);
69793 +
69794 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
69795 + if (IS_ERR(tfm)) {
69796 + /* should never happen, since sha256 should be built in */
69797 + return 1;
69798 + }
69799 +
69800 + desc.tfm = tfm;
69801 + desc.flags = 0;
69802 +
69803 + crypto_hash_init(&desc);
69804 +
69805 + p = salt;
69806 + sg_set_buf(&sg, p, GR_SALT_LEN);
69807 + crypto_hash_update(&desc, &sg, sg.length);
69808 +
69809 + p = entry->pw;
69810 + sg_set_buf(&sg, p, strlen(p));
69811 +
69812 + crypto_hash_update(&desc, &sg, sg.length);
69813 +
69814 + crypto_hash_final(&desc, temp_sum);
69815 +
69816 + memset(entry->pw, 0, GR_PW_LEN);
69817 +
69818 + for (i = 0; i < GR_SHA_LEN; i++)
69819 + if (sum[i] != temp_sum[i])
69820 + retval = 1;
69821 + else
69822 + dummy = 1; // waste a cycle
69823 +
69824 + crypto_free_hash(tfm);
69825 +
69826 + return retval;
69827 +}
69828 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
69829 index 77ff547..181834f 100644
69830 --- a/include/asm-generic/4level-fixup.h
69831 +++ b/include/asm-generic/4level-fixup.h
69832 @@ -13,8 +13,10 @@
69833 #define pmd_alloc(mm, pud, address) \
69834 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
69835 NULL: pmd_offset(pud, address))
69836 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
69837
69838 #define pud_alloc(mm, pgd, address) (pgd)
69839 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
69840 #define pud_offset(pgd, start) (pgd)
69841 #define pud_none(pud) 0
69842 #define pud_bad(pud) 0
69843 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
69844 index b7babf0..04ad282 100644
69845 --- a/include/asm-generic/atomic-long.h
69846 +++ b/include/asm-generic/atomic-long.h
69847 @@ -22,6 +22,12 @@
69848
69849 typedef atomic64_t atomic_long_t;
69850
69851 +#ifdef CONFIG_PAX_REFCOUNT
69852 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
69853 +#else
69854 +typedef atomic64_t atomic_long_unchecked_t;
69855 +#endif
69856 +
69857 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
69858
69859 static inline long atomic_long_read(atomic_long_t *l)
69860 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
69861 return (long)atomic64_read(v);
69862 }
69863
69864 +#ifdef CONFIG_PAX_REFCOUNT
69865 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
69866 +{
69867 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
69868 +
69869 + return (long)atomic64_read_unchecked(v);
69870 +}
69871 +#endif
69872 +
69873 static inline void atomic_long_set(atomic_long_t *l, long i)
69874 {
69875 atomic64_t *v = (atomic64_t *)l;
69876 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
69877 atomic64_set(v, i);
69878 }
69879
69880 +#ifdef CONFIG_PAX_REFCOUNT
69881 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
69882 +{
69883 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
69884 +
69885 + atomic64_set_unchecked(v, i);
69886 +}
69887 +#endif
69888 +
69889 static inline void atomic_long_inc(atomic_long_t *l)
69890 {
69891 atomic64_t *v = (atomic64_t *)l;
69892 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
69893 atomic64_inc(v);
69894 }
69895
69896 +#ifdef CONFIG_PAX_REFCOUNT
69897 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
69898 +{
69899 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
69900 +
69901 + atomic64_inc_unchecked(v);
69902 +}
69903 +#endif
69904 +
69905 static inline void atomic_long_dec(atomic_long_t *l)
69906 {
69907 atomic64_t *v = (atomic64_t *)l;
69908 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
69909 atomic64_dec(v);
69910 }
69911
69912 +#ifdef CONFIG_PAX_REFCOUNT
69913 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
69914 +{
69915 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
69916 +
69917 + atomic64_dec_unchecked(v);
69918 +}
69919 +#endif
69920 +
69921 static inline void atomic_long_add(long i, atomic_long_t *l)
69922 {
69923 atomic64_t *v = (atomic64_t *)l;
69924 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
69925 atomic64_add(i, v);
69926 }
69927
69928 +#ifdef CONFIG_PAX_REFCOUNT
69929 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
69930 +{
69931 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
69932 +
69933 + atomic64_add_unchecked(i, v);
69934 +}
69935 +#endif
69936 +
69937 static inline void atomic_long_sub(long i, atomic_long_t *l)
69938 {
69939 atomic64_t *v = (atomic64_t *)l;
69940 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
69941 atomic64_sub(i, v);
69942 }
69943
69944 +#ifdef CONFIG_PAX_REFCOUNT
69945 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
69946 +{
69947 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
69948 +
69949 + atomic64_sub_unchecked(i, v);
69950 +}
69951 +#endif
69952 +
69953 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
69954 {
69955 atomic64_t *v = (atomic64_t *)l;
69956 @@ -101,6 +161,15 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
69957 return (long)atomic64_add_return(i, v);
69958 }
69959
69960 +#ifdef CONFIG_PAX_REFCOUNT
69961 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
69962 +{
69963 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
69964 +
69965 + return (long)atomic64_add_return_unchecked(i, v);
69966 +}
69967 +#endif
69968 +
69969 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
69970 {
69971 atomic64_t *v = (atomic64_t *)l;
69972 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
69973 return (long)atomic64_inc_return(v);
69974 }
69975
69976 +#ifdef CONFIG_PAX_REFCOUNT
69977 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
69978 +{
69979 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
69980 +
69981 + return (long)atomic64_inc_return_unchecked(v);
69982 +}
69983 +#endif
69984 +
69985 static inline long atomic_long_dec_return(atomic_long_t *l)
69986 {
69987 atomic64_t *v = (atomic64_t *)l;
69988 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
69989
69990 typedef atomic_t atomic_long_t;
69991
69992 +#ifdef CONFIG_PAX_REFCOUNT
69993 +typedef atomic_unchecked_t atomic_long_unchecked_t;
69994 +#else
69995 +typedef atomic_t atomic_long_unchecked_t;
69996 +#endif
69997 +
69998 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
69999 static inline long atomic_long_read(atomic_long_t *l)
70000 {
70001 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
70002 return (long)atomic_read(v);
70003 }
70004
70005 +#ifdef CONFIG_PAX_REFCOUNT
70006 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
70007 +{
70008 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
70009 +
70010 + return (long)atomic_read_unchecked(v);
70011 +}
70012 +#endif
70013 +
70014 static inline void atomic_long_set(atomic_long_t *l, long i)
70015 {
70016 atomic_t *v = (atomic_t *)l;
70017 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
70018 atomic_set(v, i);
70019 }
70020
70021 +#ifdef CONFIG_PAX_REFCOUNT
70022 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
70023 +{
70024 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
70025 +
70026 + atomic_set_unchecked(v, i);
70027 +}
70028 +#endif
70029 +
70030 static inline void atomic_long_inc(atomic_long_t *l)
70031 {
70032 atomic_t *v = (atomic_t *)l;
70033 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
70034 atomic_inc(v);
70035 }
70036
70037 +#ifdef CONFIG_PAX_REFCOUNT
70038 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
70039 +{
70040 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
70041 +
70042 + atomic_inc_unchecked(v);
70043 +}
70044 +#endif
70045 +
70046 static inline void atomic_long_dec(atomic_long_t *l)
70047 {
70048 atomic_t *v = (atomic_t *)l;
70049 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
70050 atomic_dec(v);
70051 }
70052
70053 +#ifdef CONFIG_PAX_REFCOUNT
70054 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
70055 +{
70056 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
70057 +
70058 + atomic_dec_unchecked(v);
70059 +}
70060 +#endif
70061 +
70062 static inline void atomic_long_add(long i, atomic_long_t *l)
70063 {
70064 atomic_t *v = (atomic_t *)l;
70065 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
70066 atomic_add(i, v);
70067 }
70068
70069 +#ifdef CONFIG_PAX_REFCOUNT
70070 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
70071 +{
70072 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
70073 +
70074 + atomic_add_unchecked(i, v);
70075 +}
70076 +#endif
70077 +
70078 static inline void atomic_long_sub(long i, atomic_long_t *l)
70079 {
70080 atomic_t *v = (atomic_t *)l;
70081 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
70082 atomic_sub(i, v);
70083 }
70084
70085 +#ifdef CONFIG_PAX_REFCOUNT
70086 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
70087 +{
70088 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
70089 +
70090 + atomic_sub_unchecked(i, v);
70091 +}
70092 +#endif
70093 +
70094 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
70095 {
70096 atomic_t *v = (atomic_t *)l;
70097 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
70098 return (long)atomic_add_return(i, v);
70099 }
70100
70101 +#ifdef CONFIG_PAX_REFCOUNT
70102 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
70103 +{
70104 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
70105 +
70106 + return (long)atomic_add_return_unchecked(i, v);
70107 +}
70108 +
70109 +#endif
70110 +
70111 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
70112 {
70113 atomic_t *v = (atomic_t *)l;
70114 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
70115 return (long)atomic_inc_return(v);
70116 }
70117
70118 +#ifdef CONFIG_PAX_REFCOUNT
70119 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
70120 +{
70121 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
70122 +
70123 + return (long)atomic_inc_return_unchecked(v);
70124 +}
70125 +#endif
70126 +
70127 static inline long atomic_long_dec_return(atomic_long_t *l)
70128 {
70129 atomic_t *v = (atomic_t *)l;
70130 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
70131
70132 #endif /* BITS_PER_LONG == 64 */
70133
70134 +#ifdef CONFIG_PAX_REFCOUNT
70135 +static inline void pax_refcount_needs_these_functions(void)
70136 +{
70137 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
70138 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
70139 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
70140 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
70141 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
70142 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
70143 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
70144 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
70145 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
70146 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
70147 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
70148 +#ifdef CONFIG_X86
70149 + atomic_clear_mask_unchecked(0, NULL);
70150 + atomic_set_mask_unchecked(0, NULL);
70151 +#endif
70152 +
70153 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
70154 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
70155 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
70156 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
70157 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
70158 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
70159 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
70160 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
70161 +}
70162 +#else
70163 +#define atomic_read_unchecked(v) atomic_read(v)
70164 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
70165 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
70166 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
70167 +#define atomic_inc_unchecked(v) atomic_inc(v)
70168 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
70169 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
70170 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
70171 +#define atomic_dec_unchecked(v) atomic_dec(v)
70172 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
70173 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
70174 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
70175 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
70176 +
70177 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
70178 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
70179 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
70180 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
70181 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
70182 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
70183 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
70184 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
70185 +#endif
70186 +
70187 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
70188 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
70189 index 33bd2de..f31bff97 100644
70190 --- a/include/asm-generic/atomic.h
70191 +++ b/include/asm-generic/atomic.h
70192 @@ -153,7 +153,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
70193 * Atomically clears the bits set in @mask from @v
70194 */
70195 #ifndef atomic_clear_mask
70196 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
70197 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
70198 {
70199 unsigned long flags;
70200
70201 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
70202 index b18ce4f..2ee2843 100644
70203 --- a/include/asm-generic/atomic64.h
70204 +++ b/include/asm-generic/atomic64.h
70205 @@ -16,6 +16,8 @@ typedef struct {
70206 long long counter;
70207 } atomic64_t;
70208
70209 +typedef atomic64_t atomic64_unchecked_t;
70210 +
70211 #define ATOMIC64_INIT(i) { (i) }
70212
70213 extern long long atomic64_read(const atomic64_t *v);
70214 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
70215 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
70216 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
70217
70218 +#define atomic64_read_unchecked(v) atomic64_read(v)
70219 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
70220 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
70221 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
70222 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
70223 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
70224 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
70225 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
70226 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
70227 +
70228 #endif /* _ASM_GENERIC_ATOMIC64_H */
70229 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
70230 index 1bfcfe5..e04c5c9 100644
70231 --- a/include/asm-generic/cache.h
70232 +++ b/include/asm-generic/cache.h
70233 @@ -6,7 +6,7 @@
70234 * cache lines need to provide their own cache.h.
70235 */
70236
70237 -#define L1_CACHE_SHIFT 5
70238 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
70239 +#define L1_CACHE_SHIFT 5UL
70240 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
70241
70242 #endif /* __ASM_GENERIC_CACHE_H */
70243 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
70244 index 0d68a1e..b74a761 100644
70245 --- a/include/asm-generic/emergency-restart.h
70246 +++ b/include/asm-generic/emergency-restart.h
70247 @@ -1,7 +1,7 @@
70248 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
70249 #define _ASM_GENERIC_EMERGENCY_RESTART_H
70250
70251 -static inline void machine_emergency_restart(void)
70252 +static inline __noreturn void machine_emergency_restart(void)
70253 {
70254 machine_restart(NULL);
70255 }
70256 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
70257 index 90f99c7..00ce236 100644
70258 --- a/include/asm-generic/kmap_types.h
70259 +++ b/include/asm-generic/kmap_types.h
70260 @@ -2,9 +2,9 @@
70261 #define _ASM_GENERIC_KMAP_TYPES_H
70262
70263 #ifdef __WITH_KM_FENCE
70264 -# define KM_TYPE_NR 41
70265 +# define KM_TYPE_NR 42
70266 #else
70267 -# define KM_TYPE_NR 20
70268 +# define KM_TYPE_NR 21
70269 #endif
70270
70271 #endif
70272 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
70273 index 9ceb03b..62b0b8f 100644
70274 --- a/include/asm-generic/local.h
70275 +++ b/include/asm-generic/local.h
70276 @@ -23,24 +23,37 @@ typedef struct
70277 atomic_long_t a;
70278 } local_t;
70279
70280 +typedef struct {
70281 + atomic_long_unchecked_t a;
70282 +} local_unchecked_t;
70283 +
70284 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
70285
70286 #define local_read(l) atomic_long_read(&(l)->a)
70287 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
70288 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
70289 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
70290 #define local_inc(l) atomic_long_inc(&(l)->a)
70291 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
70292 #define local_dec(l) atomic_long_dec(&(l)->a)
70293 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
70294 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
70295 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
70296 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
70297 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
70298
70299 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
70300 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
70301 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
70302 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
70303 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
70304 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
70305 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
70306 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
70307 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
70308
70309 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
70310 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
70311 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
70312 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
70313 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
70314 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
70315 index 725612b..9cc513a 100644
70316 --- a/include/asm-generic/pgtable-nopmd.h
70317 +++ b/include/asm-generic/pgtable-nopmd.h
70318 @@ -1,14 +1,19 @@
70319 #ifndef _PGTABLE_NOPMD_H
70320 #define _PGTABLE_NOPMD_H
70321
70322 -#ifndef __ASSEMBLY__
70323 -
70324 #include <asm-generic/pgtable-nopud.h>
70325
70326 -struct mm_struct;
70327 -
70328 #define __PAGETABLE_PMD_FOLDED
70329
70330 +#define PMD_SHIFT PUD_SHIFT
70331 +#define PTRS_PER_PMD 1
70332 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
70333 +#define PMD_MASK (~(PMD_SIZE-1))
70334 +
70335 +#ifndef __ASSEMBLY__
70336 +
70337 +struct mm_struct;
70338 +
70339 /*
70340 * Having the pmd type consist of a pud gets the size right, and allows
70341 * us to conceptually access the pud entry that this pmd is folded into
70342 @@ -16,11 +21,6 @@ struct mm_struct;
70343 */
70344 typedef struct { pud_t pud; } pmd_t;
70345
70346 -#define PMD_SHIFT PUD_SHIFT
70347 -#define PTRS_PER_PMD 1
70348 -#define PMD_SIZE (1UL << PMD_SHIFT)
70349 -#define PMD_MASK (~(PMD_SIZE-1))
70350 -
70351 /*
70352 * The "pud_xxx()" functions here are trivial for a folded two-level
70353 * setup: the pmd is never bad, and a pmd always exists (as it's folded
70354 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
70355 index 810431d..0ec4804f 100644
70356 --- a/include/asm-generic/pgtable-nopud.h
70357 +++ b/include/asm-generic/pgtable-nopud.h
70358 @@ -1,10 +1,15 @@
70359 #ifndef _PGTABLE_NOPUD_H
70360 #define _PGTABLE_NOPUD_H
70361
70362 -#ifndef __ASSEMBLY__
70363 -
70364 #define __PAGETABLE_PUD_FOLDED
70365
70366 +#define PUD_SHIFT PGDIR_SHIFT
70367 +#define PTRS_PER_PUD 1
70368 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
70369 +#define PUD_MASK (~(PUD_SIZE-1))
70370 +
70371 +#ifndef __ASSEMBLY__
70372 +
70373 /*
70374 * Having the pud type consist of a pgd gets the size right, and allows
70375 * us to conceptually access the pgd entry that this pud is folded into
70376 @@ -12,11 +17,6 @@
70377 */
70378 typedef struct { pgd_t pgd; } pud_t;
70379
70380 -#define PUD_SHIFT PGDIR_SHIFT
70381 -#define PTRS_PER_PUD 1
70382 -#define PUD_SIZE (1UL << PUD_SHIFT)
70383 -#define PUD_MASK (~(PUD_SIZE-1))
70384 -
70385 /*
70386 * The "pgd_xxx()" functions here are trivial for a folded two-level
70387 * setup: the pud is never bad, and a pud always exists (as it's folded
70388 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
70389 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
70390
70391 #define pgd_populate(mm, pgd, pud) do { } while (0)
70392 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
70393 /*
70394 * (puds are folded into pgds so this doesn't get actually called,
70395 * but the define is needed for a generic inline function.)
70396 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
70397 index a59ff51..2594a70 100644
70398 --- a/include/asm-generic/pgtable.h
70399 +++ b/include/asm-generic/pgtable.h
70400 @@ -688,6 +688,14 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
70401 }
70402 #endif /* CONFIG_NUMA_BALANCING */
70403
70404 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
70405 +static inline unsigned long pax_open_kernel(void) { return 0; }
70406 +#endif
70407 +
70408 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
70409 +static inline unsigned long pax_close_kernel(void) { return 0; }
70410 +#endif
70411 +
70412 #endif /* CONFIG_MMU */
70413
70414 #endif /* !__ASSEMBLY__ */
70415 diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
70416 index c184aa8..d049942 100644
70417 --- a/include/asm-generic/uaccess.h
70418 +++ b/include/asm-generic/uaccess.h
70419 @@ -343,4 +343,12 @@ clear_user(void __user *to, unsigned long n)
70420 return __clear_user(to, n);
70421 }
70422
70423 +#ifndef __HAVE_ARCH_PAX_OPEN_USERLAND
70424 +//static inline unsigned long pax_open_userland(void) { return 0; }
70425 +#endif
70426 +
70427 +#ifndef __HAVE_ARCH_PAX_CLOSE_USERLAND
70428 +//static inline unsigned long pax_close_userland(void) { return 0; }
70429 +#endif
70430 +
70431 #endif /* __ASM_GENERIC_UACCESS_H */
70432 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
70433 index eb58d2d..df131bf 100644
70434 --- a/include/asm-generic/vmlinux.lds.h
70435 +++ b/include/asm-generic/vmlinux.lds.h
70436 @@ -239,6 +239,7 @@
70437 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
70438 VMLINUX_SYMBOL(__start_rodata) = .; \
70439 *(.rodata) *(.rodata.*) \
70440 + *(.data..read_only) \
70441 *(__vermagic) /* Kernel version magic */ \
70442 . = ALIGN(8); \
70443 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
70444 @@ -749,17 +750,18 @@
70445 * section in the linker script will go there too. @phdr should have
70446 * a leading colon.
70447 *
70448 - * Note that this macros defines __per_cpu_load as an absolute symbol.
70449 + * Note that this macros defines per_cpu_load as an absolute symbol.
70450 * If there is no need to put the percpu section at a predetermined
70451 * address, use PERCPU_SECTION.
70452 */
70453 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
70454 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
70455 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
70456 + per_cpu_load = .; \
70457 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
70458 - LOAD_OFFSET) { \
70459 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
70460 PERCPU_INPUT(cacheline) \
70461 } phdr \
70462 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
70463 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
70464
70465 /**
70466 * PERCPU_SECTION - define output section for percpu area, simple version
70467 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
70468 index 418d270..bfd2794 100644
70469 --- a/include/crypto/algapi.h
70470 +++ b/include/crypto/algapi.h
70471 @@ -34,7 +34,7 @@ struct crypto_type {
70472 unsigned int maskclear;
70473 unsigned int maskset;
70474 unsigned int tfmsize;
70475 -};
70476 +} __do_const;
70477
70478 struct crypto_instance {
70479 struct crypto_alg alg;
70480 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
70481 index 63d17ee..716de2b 100644
70482 --- a/include/drm/drmP.h
70483 +++ b/include/drm/drmP.h
70484 @@ -72,6 +72,7 @@
70485 #include <linux/workqueue.h>
70486 #include <linux/poll.h>
70487 #include <asm/pgalloc.h>
70488 +#include <asm/local.h>
70489 #include <drm/drm.h>
70490 #include <drm/drm_sarea.h>
70491
70492 @@ -296,10 +297,12 @@ do { \
70493 * \param cmd command.
70494 * \param arg argument.
70495 */
70496 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
70497 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
70498 + struct drm_file *file_priv);
70499 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
70500 struct drm_file *file_priv);
70501
70502 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
70503 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
70504 unsigned long arg);
70505
70506 #define DRM_IOCTL_NR(n) _IOC_NR(n)
70507 @@ -314,10 +317,10 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
70508 struct drm_ioctl_desc {
70509 unsigned int cmd;
70510 int flags;
70511 - drm_ioctl_t *func;
70512 + drm_ioctl_t func;
70513 unsigned int cmd_drv;
70514 const char *name;
70515 -};
70516 +} __do_const;
70517
70518 /**
70519 * Creates a driver or general drm_ioctl_desc array entry for the given
70520 @@ -1015,7 +1018,7 @@ struct drm_info_list {
70521 int (*show)(struct seq_file*, void*); /** show callback */
70522 u32 driver_features; /**< Required driver features for this entry */
70523 void *data;
70524 -};
70525 +} __do_const;
70526
70527 /**
70528 * debugfs node structure. This structure represents a debugfs file.
70529 @@ -1088,7 +1091,7 @@ struct drm_device {
70530
70531 /** \name Usage Counters */
70532 /*@{ */
70533 - int open_count; /**< Outstanding files open */
70534 + local_t open_count; /**< Outstanding files open */
70535 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
70536 atomic_t vma_count; /**< Outstanding vma areas open */
70537 int buf_use; /**< Buffers in use -- cannot alloc */
70538 @@ -1099,7 +1102,7 @@ struct drm_device {
70539 /*@{ */
70540 unsigned long counters;
70541 enum drm_stat_type types[15];
70542 - atomic_t counts[15];
70543 + atomic_unchecked_t counts[15];
70544 /*@} */
70545
70546 struct list_head filelist;
70547 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
70548 index f43d556..94d9343 100644
70549 --- a/include/drm/drm_crtc_helper.h
70550 +++ b/include/drm/drm_crtc_helper.h
70551 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
70552 struct drm_connector *connector);
70553 /* disable encoder when not in use - more explicit than dpms off */
70554 void (*disable)(struct drm_encoder *encoder);
70555 -};
70556 +} __no_const;
70557
70558 /**
70559 * drm_connector_helper_funcs - helper operations for connectors
70560 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
70561 index 72dcbe8..8db58d7 100644
70562 --- a/include/drm/ttm/ttm_memory.h
70563 +++ b/include/drm/ttm/ttm_memory.h
70564 @@ -48,7 +48,7 @@
70565
70566 struct ttm_mem_shrink {
70567 int (*do_shrink) (struct ttm_mem_shrink *);
70568 -};
70569 +} __no_const;
70570
70571 /**
70572 * struct ttm_mem_global - Global memory accounting structure.
70573 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
70574 index 4b840e8..155d235 100644
70575 --- a/include/keys/asymmetric-subtype.h
70576 +++ b/include/keys/asymmetric-subtype.h
70577 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
70578 /* Verify the signature on a key of this subtype (optional) */
70579 int (*verify_signature)(const struct key *key,
70580 const struct public_key_signature *sig);
70581 -};
70582 +} __do_const;
70583
70584 /**
70585 * asymmetric_key_subtype - Get the subtype from an asymmetric key
70586 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
70587 index c1da539..1dcec55 100644
70588 --- a/include/linux/atmdev.h
70589 +++ b/include/linux/atmdev.h
70590 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
70591 #endif
70592
70593 struct k_atm_aal_stats {
70594 -#define __HANDLE_ITEM(i) atomic_t i
70595 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
70596 __AAL_STAT_ITEMS
70597 #undef __HANDLE_ITEM
70598 };
70599 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
70600 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
70601 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
70602 struct module *owner;
70603 -};
70604 +} __do_const ;
70605
70606 struct atmphy_ops {
70607 int (*start)(struct atm_dev *dev);
70608 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
70609 index 70cf138..0418ee2 100644
70610 --- a/include/linux/binfmts.h
70611 +++ b/include/linux/binfmts.h
70612 @@ -73,8 +73,10 @@ struct linux_binfmt {
70613 int (*load_binary)(struct linux_binprm *);
70614 int (*load_shlib)(struct file *);
70615 int (*core_dump)(struct coredump_params *cprm);
70616 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
70617 + void (*handle_mmap)(struct file *);
70618 unsigned long min_coredump; /* minimal dump size */
70619 -};
70620 +} __do_const;
70621
70622 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
70623
70624 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
70625 index 2fdb4a4..54aad7e 100644
70626 --- a/include/linux/blkdev.h
70627 +++ b/include/linux/blkdev.h
70628 @@ -1526,7 +1526,7 @@ struct block_device_operations {
70629 /* this callback is with swap_lock and sometimes page table lock held */
70630 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
70631 struct module *owner;
70632 -};
70633 +} __do_const;
70634
70635 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
70636 unsigned long);
70637 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
70638 index 7c2e030..b72475d 100644
70639 --- a/include/linux/blktrace_api.h
70640 +++ b/include/linux/blktrace_api.h
70641 @@ -23,7 +23,7 @@ struct blk_trace {
70642 struct dentry *dir;
70643 struct dentry *dropped_file;
70644 struct dentry *msg_file;
70645 - atomic_t dropped;
70646 + atomic_unchecked_t dropped;
70647 };
70648
70649 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
70650 diff --git a/include/linux/cache.h b/include/linux/cache.h
70651 index 4c57065..4307975 100644
70652 --- a/include/linux/cache.h
70653 +++ b/include/linux/cache.h
70654 @@ -16,6 +16,10 @@
70655 #define __read_mostly
70656 #endif
70657
70658 +#ifndef __read_only
70659 +#define __read_only __read_mostly
70660 +#endif
70661 +
70662 #ifndef ____cacheline_aligned
70663 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
70664 #endif
70665 diff --git a/include/linux/capability.h b/include/linux/capability.h
70666 index d9a4f7f4..19f77d6 100644
70667 --- a/include/linux/capability.h
70668 +++ b/include/linux/capability.h
70669 @@ -213,8 +213,13 @@ extern bool ns_capable(struct user_namespace *ns, int cap);
70670 extern bool nsown_capable(int cap);
70671 extern bool inode_capable(const struct inode *inode, int cap);
70672 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
70673 +extern bool capable_nolog(int cap);
70674 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
70675 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
70676
70677 /* audit system wants to get cap info from files as well */
70678 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
70679
70680 +extern int is_privileged_binary(const struct dentry *dentry);
70681 +
70682 #endif /* !_LINUX_CAPABILITY_H */
70683 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
70684 index 8609d57..86e4d79 100644
70685 --- a/include/linux/cdrom.h
70686 +++ b/include/linux/cdrom.h
70687 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
70688
70689 /* driver specifications */
70690 const int capability; /* capability flags */
70691 - int n_minors; /* number of active minor devices */
70692 /* handle uniform packets for scsi type devices (scsi,atapi) */
70693 int (*generic_packet) (struct cdrom_device_info *,
70694 struct packet_command *);
70695 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
70696 index 4ce9056..86caac6 100644
70697 --- a/include/linux/cleancache.h
70698 +++ b/include/linux/cleancache.h
70699 @@ -31,7 +31,7 @@ struct cleancache_ops {
70700 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
70701 void (*invalidate_inode)(int, struct cleancache_filekey);
70702 void (*invalidate_fs)(int);
70703 -};
70704 +} __no_const;
70705
70706 extern struct cleancache_ops *
70707 cleancache_register_ops(struct cleancache_ops *ops);
70708 diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
70709 index 1186098..f87e53d 100644
70710 --- a/include/linux/clk-provider.h
70711 +++ b/include/linux/clk-provider.h
70712 @@ -132,6 +132,7 @@ struct clk_ops {
70713 unsigned long);
70714 void (*init)(struct clk_hw *hw);
70715 };
70716 +typedef struct clk_ops __no_const clk_ops_no_const;
70717
70718 /**
70719 * struct clk_init_data - holds init data that's common to all clocks and is
70720 diff --git a/include/linux/compat.h b/include/linux/compat.h
70721 index 7f0c1dd..206ac34 100644
70722 --- a/include/linux/compat.h
70723 +++ b/include/linux/compat.h
70724 @@ -312,7 +312,7 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
70725 compat_size_t __user *len_ptr);
70726
70727 asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32);
70728 -asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
70729 +asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
70730 asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
70731 asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp,
70732 compat_ssize_t msgsz, int msgflg);
70733 @@ -419,7 +419,7 @@ extern int compat_ptrace_request(struct task_struct *child,
70734 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
70735 compat_ulong_t addr, compat_ulong_t data);
70736 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
70737 - compat_long_t addr, compat_long_t data);
70738 + compat_ulong_t addr, compat_ulong_t data);
70739
70740 asmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, size_t);
70741 /*
70742 @@ -669,6 +669,7 @@ asmlinkage long compat_sys_sigaltstack(const compat_stack_t __user *uss_ptr,
70743
70744 int compat_restore_altstack(const compat_stack_t __user *uss);
70745 int __compat_save_altstack(compat_stack_t __user *, unsigned long);
70746 +void __compat_save_altstack_ex(compat_stack_t __user *, unsigned long);
70747
70748 asmlinkage long compat_sys_sched_rr_get_interval(compat_pid_t pid,
70749 struct compat_timespec __user *interval);
70750 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
70751 index 842de22..7f3a41f 100644
70752 --- a/include/linux/compiler-gcc4.h
70753 +++ b/include/linux/compiler-gcc4.h
70754 @@ -39,9 +39,29 @@
70755 # define __compiletime_warning(message) __attribute__((warning(message)))
70756 # define __compiletime_error(message) __attribute__((error(message)))
70757 #endif /* __CHECKER__ */
70758 +
70759 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
70760 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
70761 +#define __bos0(ptr) __bos((ptr), 0)
70762 +#define __bos1(ptr) __bos((ptr), 1)
70763 #endif /* GCC_VERSION >= 40300 */
70764
70765 #if GCC_VERSION >= 40500
70766 +
70767 +#ifdef CONSTIFY_PLUGIN
70768 +#define __no_const __attribute__((no_const))
70769 +#define __do_const __attribute__((do_const))
70770 +#endif
70771 +
70772 +#ifdef SIZE_OVERFLOW_PLUGIN
70773 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
70774 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
70775 +#endif
70776 +
70777 +#ifdef LATENT_ENTROPY_PLUGIN
70778 +#define __latent_entropy __attribute__((latent_entropy))
70779 +#endif
70780 +
70781 /*
70782 * Mark a position in code as unreachable. This can be used to
70783 * suppress control flow warnings after asm blocks that transfer
70784 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
70785 index 92669cd..1771a15 100644
70786 --- a/include/linux/compiler.h
70787 +++ b/include/linux/compiler.h
70788 @@ -5,11 +5,14 @@
70789
70790 #ifdef __CHECKER__
70791 # define __user __attribute__((noderef, address_space(1)))
70792 +# define __force_user __force __user
70793 # define __kernel __attribute__((address_space(0)))
70794 +# define __force_kernel __force __kernel
70795 # define __safe __attribute__((safe))
70796 # define __force __attribute__((force))
70797 # define __nocast __attribute__((nocast))
70798 # define __iomem __attribute__((noderef, address_space(2)))
70799 +# define __force_iomem __force __iomem
70800 # define __must_hold(x) __attribute__((context(x,1,1)))
70801 # define __acquires(x) __attribute__((context(x,0,1)))
70802 # define __releases(x) __attribute__((context(x,1,0)))
70803 @@ -17,20 +20,37 @@
70804 # define __release(x) __context__(x,-1)
70805 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
70806 # define __percpu __attribute__((noderef, address_space(3)))
70807 +# define __force_percpu __force __percpu
70808 #ifdef CONFIG_SPARSE_RCU_POINTER
70809 # define __rcu __attribute__((noderef, address_space(4)))
70810 +# define __force_rcu __force __rcu
70811 #else
70812 # define __rcu
70813 +# define __force_rcu
70814 #endif
70815 extern void __chk_user_ptr(const volatile void __user *);
70816 extern void __chk_io_ptr(const volatile void __iomem *);
70817 #else
70818 -# define __user
70819 -# define __kernel
70820 +# ifdef CHECKER_PLUGIN
70821 +//# define __user
70822 +//# define __force_user
70823 +//# define __kernel
70824 +//# define __force_kernel
70825 +# else
70826 +# ifdef STRUCTLEAK_PLUGIN
70827 +# define __user __attribute__((user))
70828 +# else
70829 +# define __user
70830 +# endif
70831 +# define __force_user
70832 +# define __kernel
70833 +# define __force_kernel
70834 +# endif
70835 # define __safe
70836 # define __force
70837 # define __nocast
70838 # define __iomem
70839 +# define __force_iomem
70840 # define __chk_user_ptr(x) (void)0
70841 # define __chk_io_ptr(x) (void)0
70842 # define __builtin_warning(x, y...) (1)
70843 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
70844 # define __release(x) (void)0
70845 # define __cond_lock(x,c) (c)
70846 # define __percpu
70847 +# define __force_percpu
70848 # define __rcu
70849 +# define __force_rcu
70850 #endif
70851
70852 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
70853 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
70854 # define __attribute_const__ /* unimplemented */
70855 #endif
70856
70857 +#ifndef __no_const
70858 +# define __no_const
70859 +#endif
70860 +
70861 +#ifndef __do_const
70862 +# define __do_const
70863 +#endif
70864 +
70865 +#ifndef __size_overflow
70866 +# define __size_overflow(...)
70867 +#endif
70868 +
70869 +#ifndef __intentional_overflow
70870 +# define __intentional_overflow(...)
70871 +#endif
70872 +
70873 +#ifndef __latent_entropy
70874 +# define __latent_entropy
70875 +#endif
70876 +
70877 /*
70878 * Tell gcc if a function is cold. The compiler will assume any path
70879 * directly leading to the call is unlikely.
70880 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
70881 #define __cold
70882 #endif
70883
70884 +#ifndef __alloc_size
70885 +#define __alloc_size(...)
70886 +#endif
70887 +
70888 +#ifndef __bos
70889 +#define __bos(ptr, arg)
70890 +#endif
70891 +
70892 +#ifndef __bos0
70893 +#define __bos0(ptr)
70894 +#endif
70895 +
70896 +#ifndef __bos1
70897 +#define __bos1(ptr)
70898 +#endif
70899 +
70900 /* Simple shorthand for a section definition */
70901 #ifndef __section
70902 # define __section(S) __attribute__ ((__section__(#S)))
70903 @@ -349,7 +407,8 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
70904 * use is to mediate communication between process-level code and irq/NMI
70905 * handlers, all running on the same CPU.
70906 */
70907 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
70908 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
70909 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
70910
70911 /* Ignore/forbid kprobes attach on very low level functions marked by this attribute: */
70912 #ifdef CONFIG_KPROBES
70913 diff --git a/include/linux/completion.h b/include/linux/completion.h
70914 index 33f0280..35c6568 100644
70915 --- a/include/linux/completion.h
70916 +++ b/include/linux/completion.h
70917 @@ -79,15 +79,15 @@ static inline void init_completion(struct completion *x)
70918 extern void wait_for_completion(struct completion *);
70919 extern void wait_for_completion_io(struct completion *);
70920 extern int wait_for_completion_interruptible(struct completion *x);
70921 -extern int wait_for_completion_killable(struct completion *x);
70922 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
70923 extern unsigned long wait_for_completion_timeout(struct completion *x,
70924 unsigned long timeout);
70925 extern unsigned long wait_for_completion_io_timeout(struct completion *x,
70926 unsigned long timeout);
70927 extern long wait_for_completion_interruptible_timeout(
70928 - struct completion *x, unsigned long timeout);
70929 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
70930 extern long wait_for_completion_killable_timeout(
70931 - struct completion *x, unsigned long timeout);
70932 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
70933 extern bool try_wait_for_completion(struct completion *x);
70934 extern bool completion_done(struct completion *x);
70935
70936 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
70937 index 34025df..d94bbbc 100644
70938 --- a/include/linux/configfs.h
70939 +++ b/include/linux/configfs.h
70940 @@ -125,7 +125,7 @@ struct configfs_attribute {
70941 const char *ca_name;
70942 struct module *ca_owner;
70943 umode_t ca_mode;
70944 -};
70945 +} __do_const;
70946
70947 /*
70948 * Users often need to create attribute structures for their configurable
70949 diff --git a/include/linux/cpu.h b/include/linux/cpu.h
70950 index 9f3c7e8..a18c7b6 100644
70951 --- a/include/linux/cpu.h
70952 +++ b/include/linux/cpu.h
70953 @@ -115,7 +115,7 @@ enum {
70954 /* Need to know about CPUs going up/down? */
70955 #if defined(CONFIG_HOTPLUG_CPU) || !defined(MODULE)
70956 #define cpu_notifier(fn, pri) { \
70957 - static struct notifier_block fn##_nb __cpuinitdata = \
70958 + static struct notifier_block fn##_nb = \
70959 { .notifier_call = fn, .priority = pri }; \
70960 register_cpu_notifier(&fn##_nb); \
70961 }
70962 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
70963 index 037d36a..ca5fe6e 100644
70964 --- a/include/linux/cpufreq.h
70965 +++ b/include/linux/cpufreq.h
70966 @@ -262,7 +262,7 @@ struct cpufreq_driver {
70967 int (*suspend) (struct cpufreq_policy *policy);
70968 int (*resume) (struct cpufreq_policy *policy);
70969 struct freq_attr **attr;
70970 -};
70971 +} __do_const;
70972
70973 /* flags */
70974
70975 @@ -321,6 +321,7 @@ struct global_attr {
70976 ssize_t (*store)(struct kobject *a, struct attribute *b,
70977 const char *c, size_t count);
70978 };
70979 +typedef struct global_attr __no_const global_attr_no_const;
70980
70981 #define define_one_global_ro(_name) \
70982 static struct global_attr _name = \
70983 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
70984 index 8f04062..900239a 100644
70985 --- a/include/linux/cpuidle.h
70986 +++ b/include/linux/cpuidle.h
70987 @@ -52,7 +52,8 @@ struct cpuidle_state {
70988 int index);
70989
70990 int (*enter_dead) (struct cpuidle_device *dev, int index);
70991 -};
70992 +} __do_const;
70993 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
70994
70995 /* Idle State Flags */
70996 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
70997 @@ -191,7 +192,7 @@ struct cpuidle_governor {
70998 void (*reflect) (struct cpuidle_device *dev, int index);
70999
71000 struct module *owner;
71001 -};
71002 +} __do_const;
71003
71004 #ifdef CONFIG_CPU_IDLE
71005
71006 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
71007 index d08e4d2..95fad61 100644
71008 --- a/include/linux/cpumask.h
71009 +++ b/include/linux/cpumask.h
71010 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
71011 }
71012
71013 /* Valid inputs for n are -1 and 0. */
71014 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
71015 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
71016 {
71017 return n+1;
71018 }
71019
71020 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
71021 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
71022 {
71023 return n+1;
71024 }
71025
71026 -static inline unsigned int cpumask_next_and(int n,
71027 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
71028 const struct cpumask *srcp,
71029 const struct cpumask *andp)
71030 {
71031 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
71032 *
71033 * Returns >= nr_cpu_ids if no further cpus set.
71034 */
71035 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
71036 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
71037 {
71038 /* -1 is a legal arg here. */
71039 if (n != -1)
71040 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
71041 *
71042 * Returns >= nr_cpu_ids if no further cpus unset.
71043 */
71044 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
71045 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
71046 {
71047 /* -1 is a legal arg here. */
71048 if (n != -1)
71049 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
71050 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
71051 }
71052
71053 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
71054 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
71055 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
71056
71057 /**
71058 diff --git a/include/linux/cred.h b/include/linux/cred.h
71059 index 04421e8..6bce4ef 100644
71060 --- a/include/linux/cred.h
71061 +++ b/include/linux/cred.h
71062 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
71063 static inline void validate_process_creds(void)
71064 {
71065 }
71066 +static inline void validate_task_creds(struct task_struct *task)
71067 +{
71068 +}
71069 #endif
71070
71071 /**
71072 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
71073 index b92eadf..b4ecdc1 100644
71074 --- a/include/linux/crypto.h
71075 +++ b/include/linux/crypto.h
71076 @@ -373,7 +373,7 @@ struct cipher_tfm {
71077 const u8 *key, unsigned int keylen);
71078 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
71079 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
71080 -};
71081 +} __no_const;
71082
71083 struct hash_tfm {
71084 int (*init)(struct hash_desc *desc);
71085 @@ -394,13 +394,13 @@ struct compress_tfm {
71086 int (*cot_decompress)(struct crypto_tfm *tfm,
71087 const u8 *src, unsigned int slen,
71088 u8 *dst, unsigned int *dlen);
71089 -};
71090 +} __no_const;
71091
71092 struct rng_tfm {
71093 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
71094 unsigned int dlen);
71095 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
71096 -};
71097 +} __no_const;
71098
71099 #define crt_ablkcipher crt_u.ablkcipher
71100 #define crt_aead crt_u.aead
71101 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
71102 index 653589e..4ef254a 100644
71103 --- a/include/linux/ctype.h
71104 +++ b/include/linux/ctype.h
71105 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
71106 * Fast implementation of tolower() for internal usage. Do not use in your
71107 * code.
71108 */
71109 -static inline char _tolower(const char c)
71110 +static inline unsigned char _tolower(const unsigned char c)
71111 {
71112 return c | 0x20;
71113 }
71114 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
71115 index 7925bf0..d5143d2 100644
71116 --- a/include/linux/decompress/mm.h
71117 +++ b/include/linux/decompress/mm.h
71118 @@ -77,7 +77,7 @@ static void free(void *where)
71119 * warnings when not needed (indeed large_malloc / large_free are not
71120 * needed by inflate */
71121
71122 -#define malloc(a) kmalloc(a, GFP_KERNEL)
71123 +#define malloc(a) kmalloc((a), GFP_KERNEL)
71124 #define free(a) kfree(a)
71125
71126 #define large_malloc(a) vmalloc(a)
71127 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
71128 index fe8c447..bdc1f33 100644
71129 --- a/include/linux/devfreq.h
71130 +++ b/include/linux/devfreq.h
71131 @@ -114,7 +114,7 @@ struct devfreq_governor {
71132 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
71133 int (*event_handler)(struct devfreq *devfreq,
71134 unsigned int event, void *data);
71135 -};
71136 +} __do_const;
71137
71138 /**
71139 * struct devfreq - Device devfreq structure
71140 diff --git a/include/linux/device.h b/include/linux/device.h
71141 index c0a1261..dba7569 100644
71142 --- a/include/linux/device.h
71143 +++ b/include/linux/device.h
71144 @@ -290,7 +290,7 @@ struct subsys_interface {
71145 struct list_head node;
71146 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
71147 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
71148 -};
71149 +} __do_const;
71150
71151 int subsys_interface_register(struct subsys_interface *sif);
71152 void subsys_interface_unregister(struct subsys_interface *sif);
71153 @@ -473,7 +473,7 @@ struct device_type {
71154 void (*release)(struct device *dev);
71155
71156 const struct dev_pm_ops *pm;
71157 -};
71158 +} __do_const;
71159
71160 /* interface for exporting device attributes */
71161 struct device_attribute {
71162 @@ -483,11 +483,12 @@ struct device_attribute {
71163 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
71164 const char *buf, size_t count);
71165 };
71166 +typedef struct device_attribute __no_const device_attribute_no_const;
71167
71168 struct dev_ext_attribute {
71169 struct device_attribute attr;
71170 void *var;
71171 -};
71172 +} __do_const;
71173
71174 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
71175 char *buf);
71176 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
71177 index 94af418..b1ca7a2 100644
71178 --- a/include/linux/dma-mapping.h
71179 +++ b/include/linux/dma-mapping.h
71180 @@ -54,7 +54,7 @@ struct dma_map_ops {
71181 u64 (*get_required_mask)(struct device *dev);
71182 #endif
71183 int is_phys;
71184 -};
71185 +} __do_const;
71186
71187 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
71188
71189 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
71190 index 96d3e4a..dc36433 100644
71191 --- a/include/linux/dmaengine.h
71192 +++ b/include/linux/dmaengine.h
71193 @@ -1035,9 +1035,9 @@ struct dma_pinned_list {
71194 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
71195 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
71196
71197 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
71198 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
71199 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
71200 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
71201 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
71202 struct dma_pinned_list *pinned_list, struct page *page,
71203 unsigned int offset, size_t len);
71204
71205 diff --git a/include/linux/efi.h b/include/linux/efi.h
71206 index 2bc0ad7..3f7b006 100644
71207 --- a/include/linux/efi.h
71208 +++ b/include/linux/efi.h
71209 @@ -745,6 +745,7 @@ struct efivar_operations {
71210 efi_set_variable_t *set_variable;
71211 efi_query_variable_store_t *query_variable_store;
71212 };
71213 +typedef struct efivar_operations __no_const efivar_operations_no_const;
71214
71215 struct efivars {
71216 /*
71217 diff --git a/include/linux/elf.h b/include/linux/elf.h
71218 index 40a3c0e..4c45a38 100644
71219 --- a/include/linux/elf.h
71220 +++ b/include/linux/elf.h
71221 @@ -24,6 +24,7 @@ extern Elf32_Dyn _DYNAMIC [];
71222 #define elf_note elf32_note
71223 #define elf_addr_t Elf32_Off
71224 #define Elf_Half Elf32_Half
71225 +#define elf_dyn Elf32_Dyn
71226
71227 #else
71228
71229 @@ -34,6 +35,7 @@ extern Elf64_Dyn _DYNAMIC [];
71230 #define elf_note elf64_note
71231 #define elf_addr_t Elf64_Off
71232 #define Elf_Half Elf64_Half
71233 +#define elf_dyn Elf64_Dyn
71234
71235 #endif
71236
71237 diff --git a/include/linux/err.h b/include/linux/err.h
71238 index f2edce2..cc2082c 100644
71239 --- a/include/linux/err.h
71240 +++ b/include/linux/err.h
71241 @@ -19,12 +19,12 @@
71242
71243 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
71244
71245 -static inline void * __must_check ERR_PTR(long error)
71246 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
71247 {
71248 return (void *) error;
71249 }
71250
71251 -static inline long __must_check PTR_ERR(const void *ptr)
71252 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(const void *ptr)
71253 {
71254 return (long) ptr;
71255 }
71256 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
71257 index fcb51c8..bdafcf6 100644
71258 --- a/include/linux/extcon.h
71259 +++ b/include/linux/extcon.h
71260 @@ -134,7 +134,7 @@ struct extcon_dev {
71261 /* /sys/class/extcon/.../mutually_exclusive/... */
71262 struct attribute_group attr_g_muex;
71263 struct attribute **attrs_muex;
71264 - struct device_attribute *d_attrs_muex;
71265 + device_attribute_no_const *d_attrs_muex;
71266 };
71267
71268 /**
71269 diff --git a/include/linux/fb.h b/include/linux/fb.h
71270 index d49c60f..2834fbe 100644
71271 --- a/include/linux/fb.h
71272 +++ b/include/linux/fb.h
71273 @@ -304,7 +304,7 @@ struct fb_ops {
71274 /* called at KDB enter and leave time to prepare the console */
71275 int (*fb_debug_enter)(struct fb_info *info);
71276 int (*fb_debug_leave)(struct fb_info *info);
71277 -};
71278 +} __do_const;
71279
71280 #ifdef CONFIG_FB_TILEBLITTING
71281 #define FB_TILE_CURSOR_NONE 0
71282 diff --git a/include/linux/filter.h b/include/linux/filter.h
71283 index f65f5a6..2f4f93a 100644
71284 --- a/include/linux/filter.h
71285 +++ b/include/linux/filter.h
71286 @@ -20,6 +20,7 @@ struct compat_sock_fprog {
71287
71288 struct sk_buff;
71289 struct sock;
71290 +struct bpf_jit_work;
71291
71292 struct sk_filter
71293 {
71294 @@ -27,6 +28,9 @@ struct sk_filter
71295 unsigned int len; /* Number of filter blocks */
71296 unsigned int (*bpf_func)(const struct sk_buff *skb,
71297 const struct sock_filter *filter);
71298 +#ifdef CONFIG_BPF_JIT
71299 + struct bpf_jit_work *work;
71300 +#endif
71301 struct rcu_head rcu;
71302 struct sock_filter insns[0];
71303 };
71304 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
71305 index 8293262..2b3b8bd 100644
71306 --- a/include/linux/frontswap.h
71307 +++ b/include/linux/frontswap.h
71308 @@ -11,7 +11,7 @@ struct frontswap_ops {
71309 int (*load)(unsigned, pgoff_t, struct page *);
71310 void (*invalidate_page)(unsigned, pgoff_t);
71311 void (*invalidate_area)(unsigned);
71312 -};
71313 +} __no_const;
71314
71315 extern bool frontswap_enabled;
71316 extern struct frontswap_ops *
71317 diff --git a/include/linux/fs.h b/include/linux/fs.h
71318 index 65c2be2..4c53f6e 100644
71319 --- a/include/linux/fs.h
71320 +++ b/include/linux/fs.h
71321 @@ -1543,7 +1543,8 @@ struct file_operations {
71322 long (*fallocate)(struct file *file, int mode, loff_t offset,
71323 loff_t len);
71324 int (*show_fdinfo)(struct seq_file *m, struct file *f);
71325 -};
71326 +} __do_const;
71327 +typedef struct file_operations __no_const file_operations_no_const;
71328
71329 struct inode_operations {
71330 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
71331 @@ -2688,4 +2689,14 @@ static inline void inode_has_no_xattr(struct inode *inode)
71332 inode->i_flags |= S_NOSEC;
71333 }
71334
71335 +static inline bool is_sidechannel_device(const struct inode *inode)
71336 +{
71337 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
71338 + umode_t mode = inode->i_mode;
71339 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
71340 +#else
71341 + return false;
71342 +#endif
71343 +}
71344 +
71345 #endif /* _LINUX_FS_H */
71346 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
71347 index 2b93a9a..855d94a 100644
71348 --- a/include/linux/fs_struct.h
71349 +++ b/include/linux/fs_struct.h
71350 @@ -6,7 +6,7 @@
71351 #include <linux/seqlock.h>
71352
71353 struct fs_struct {
71354 - int users;
71355 + atomic_t users;
71356 spinlock_t lock;
71357 seqcount_t seq;
71358 int umask;
71359 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
71360 index 5dfa0aa..6acf322 100644
71361 --- a/include/linux/fscache-cache.h
71362 +++ b/include/linux/fscache-cache.h
71363 @@ -112,7 +112,7 @@ struct fscache_operation {
71364 fscache_operation_release_t release;
71365 };
71366
71367 -extern atomic_t fscache_op_debug_id;
71368 +extern atomic_unchecked_t fscache_op_debug_id;
71369 extern void fscache_op_work_func(struct work_struct *work);
71370
71371 extern void fscache_enqueue_operation(struct fscache_operation *);
71372 @@ -134,7 +134,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
71373 INIT_WORK(&op->work, fscache_op_work_func);
71374 atomic_set(&op->usage, 1);
71375 op->state = FSCACHE_OP_ST_INITIALISED;
71376 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
71377 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
71378 op->processor = processor;
71379 op->release = release;
71380 INIT_LIST_HEAD(&op->pend_link);
71381 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
71382 index 7a08623..4c07b0f 100644
71383 --- a/include/linux/fscache.h
71384 +++ b/include/linux/fscache.h
71385 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
71386 * - this is mandatory for any object that may have data
71387 */
71388 void (*now_uncached)(void *cookie_netfs_data);
71389 -};
71390 +} __do_const;
71391
71392 /*
71393 * fscache cached network filesystem type
71394 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
71395 index a78680a..87bd73e 100644
71396 --- a/include/linux/fsnotify.h
71397 +++ b/include/linux/fsnotify.h
71398 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
71399 struct inode *inode = path->dentry->d_inode;
71400 __u32 mask = FS_ACCESS;
71401
71402 + if (is_sidechannel_device(inode))
71403 + return;
71404 +
71405 if (S_ISDIR(inode->i_mode))
71406 mask |= FS_ISDIR;
71407
71408 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
71409 struct inode *inode = path->dentry->d_inode;
71410 __u32 mask = FS_MODIFY;
71411
71412 + if (is_sidechannel_device(inode))
71413 + return;
71414 +
71415 if (S_ISDIR(inode->i_mode))
71416 mask |= FS_ISDIR;
71417
71418 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
71419 */
71420 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
71421 {
71422 - return kstrdup(name, GFP_KERNEL);
71423 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
71424 }
71425
71426 /*
71427 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
71428 index 9f3c275..911b591 100644
71429 --- a/include/linux/genhd.h
71430 +++ b/include/linux/genhd.h
71431 @@ -194,7 +194,7 @@ struct gendisk {
71432 struct kobject *slave_dir;
71433
71434 struct timer_rand_state *random;
71435 - atomic_t sync_io; /* RAID */
71436 + atomic_unchecked_t sync_io; /* RAID */
71437 struct disk_events *ev;
71438 #ifdef CONFIG_BLK_DEV_INTEGRITY
71439 struct blk_integrity *integrity;
71440 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
71441 index 023bc34..b02b46a 100644
71442 --- a/include/linux/genl_magic_func.h
71443 +++ b/include/linux/genl_magic_func.h
71444 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
71445 },
71446
71447 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
71448 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
71449 +static struct genl_ops ZZZ_genl_ops[] = {
71450 #include GENL_MAGIC_INCLUDE_FILE
71451 };
71452
71453 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
71454 index 0f615eb..5c3832f 100644
71455 --- a/include/linux/gfp.h
71456 +++ b/include/linux/gfp.h
71457 @@ -35,6 +35,13 @@ struct vm_area_struct;
71458 #define ___GFP_NO_KSWAPD 0x400000u
71459 #define ___GFP_OTHER_NODE 0x800000u
71460 #define ___GFP_WRITE 0x1000000u
71461 +
71462 +#ifdef CONFIG_PAX_USERCOPY_SLABS
71463 +#define ___GFP_USERCOPY 0x2000000u
71464 +#else
71465 +#define ___GFP_USERCOPY 0
71466 +#endif
71467 +
71468 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
71469
71470 /*
71471 @@ -92,6 +99,7 @@ struct vm_area_struct;
71472 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
71473 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
71474 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
71475 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
71476
71477 /*
71478 * This may seem redundant, but it's a way of annotating false positives vs.
71479 @@ -99,7 +107,7 @@ struct vm_area_struct;
71480 */
71481 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
71482
71483 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
71484 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
71485 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
71486
71487 /* This equals 0, but use constants in case they ever change */
71488 @@ -153,6 +161,8 @@ struct vm_area_struct;
71489 /* 4GB DMA on some platforms */
71490 #define GFP_DMA32 __GFP_DMA32
71491
71492 +#define GFP_USERCOPY __GFP_USERCOPY
71493 +
71494 /* Convert GFP flags to their corresponding migrate type */
71495 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
71496 {
71497 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
71498 new file mode 100644
71499 index 0000000..ebe6d72
71500 --- /dev/null
71501 +++ b/include/linux/gracl.h
71502 @@ -0,0 +1,319 @@
71503 +#ifndef GR_ACL_H
71504 +#define GR_ACL_H
71505 +
71506 +#include <linux/grdefs.h>
71507 +#include <linux/resource.h>
71508 +#include <linux/capability.h>
71509 +#include <linux/dcache.h>
71510 +#include <asm/resource.h>
71511 +
71512 +/* Major status information */
71513 +
71514 +#define GR_VERSION "grsecurity 2.9.1"
71515 +#define GRSECURITY_VERSION 0x2901
71516 +
71517 +enum {
71518 + GR_SHUTDOWN = 0,
71519 + GR_ENABLE = 1,
71520 + GR_SPROLE = 2,
71521 + GR_RELOAD = 3,
71522 + GR_SEGVMOD = 4,
71523 + GR_STATUS = 5,
71524 + GR_UNSPROLE = 6,
71525 + GR_PASSSET = 7,
71526 + GR_SPROLEPAM = 8,
71527 +};
71528 +
71529 +/* Password setup definitions
71530 + * kernel/grhash.c */
71531 +enum {
71532 + GR_PW_LEN = 128,
71533 + GR_SALT_LEN = 16,
71534 + GR_SHA_LEN = 32,
71535 +};
71536 +
71537 +enum {
71538 + GR_SPROLE_LEN = 64,
71539 +};
71540 +
71541 +enum {
71542 + GR_NO_GLOB = 0,
71543 + GR_REG_GLOB,
71544 + GR_CREATE_GLOB
71545 +};
71546 +
71547 +#define GR_NLIMITS 32
71548 +
71549 +/* Begin Data Structures */
71550 +
71551 +struct sprole_pw {
71552 + unsigned char *rolename;
71553 + unsigned char salt[GR_SALT_LEN];
71554 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
71555 +};
71556 +
71557 +struct name_entry {
71558 + __u32 key;
71559 + ino_t inode;
71560 + dev_t device;
71561 + char *name;
71562 + __u16 len;
71563 + __u8 deleted;
71564 + struct name_entry *prev;
71565 + struct name_entry *next;
71566 +};
71567 +
71568 +struct inodev_entry {
71569 + struct name_entry *nentry;
71570 + struct inodev_entry *prev;
71571 + struct inodev_entry *next;
71572 +};
71573 +
71574 +struct acl_role_db {
71575 + struct acl_role_label **r_hash;
71576 + __u32 r_size;
71577 +};
71578 +
71579 +struct inodev_db {
71580 + struct inodev_entry **i_hash;
71581 + __u32 i_size;
71582 +};
71583 +
71584 +struct name_db {
71585 + struct name_entry **n_hash;
71586 + __u32 n_size;
71587 +};
71588 +
71589 +struct crash_uid {
71590 + uid_t uid;
71591 + unsigned long expires;
71592 +};
71593 +
71594 +struct gr_hash_struct {
71595 + void **table;
71596 + void **nametable;
71597 + void *first;
71598 + __u32 table_size;
71599 + __u32 used_size;
71600 + int type;
71601 +};
71602 +
71603 +/* Userspace Grsecurity ACL data structures */
71604 +
71605 +struct acl_subject_label {
71606 + char *filename;
71607 + ino_t inode;
71608 + dev_t device;
71609 + __u32 mode;
71610 + kernel_cap_t cap_mask;
71611 + kernel_cap_t cap_lower;
71612 + kernel_cap_t cap_invert_audit;
71613 +
71614 + struct rlimit res[GR_NLIMITS];
71615 + __u32 resmask;
71616 +
71617 + __u8 user_trans_type;
71618 + __u8 group_trans_type;
71619 + uid_t *user_transitions;
71620 + gid_t *group_transitions;
71621 + __u16 user_trans_num;
71622 + __u16 group_trans_num;
71623 +
71624 + __u32 sock_families[2];
71625 + __u32 ip_proto[8];
71626 + __u32 ip_type;
71627 + struct acl_ip_label **ips;
71628 + __u32 ip_num;
71629 + __u32 inaddr_any_override;
71630 +
71631 + __u32 crashes;
71632 + unsigned long expires;
71633 +
71634 + struct acl_subject_label *parent_subject;
71635 + struct gr_hash_struct *hash;
71636 + struct acl_subject_label *prev;
71637 + struct acl_subject_label *next;
71638 +
71639 + struct acl_object_label **obj_hash;
71640 + __u32 obj_hash_size;
71641 + __u16 pax_flags;
71642 +};
71643 +
71644 +struct role_allowed_ip {
71645 + __u32 addr;
71646 + __u32 netmask;
71647 +
71648 + struct role_allowed_ip *prev;
71649 + struct role_allowed_ip *next;
71650 +};
71651 +
71652 +struct role_transition {
71653 + char *rolename;
71654 +
71655 + struct role_transition *prev;
71656 + struct role_transition *next;
71657 +};
71658 +
71659 +struct acl_role_label {
71660 + char *rolename;
71661 + uid_t uidgid;
71662 + __u16 roletype;
71663 +
71664 + __u16 auth_attempts;
71665 + unsigned long expires;
71666 +
71667 + struct acl_subject_label *root_label;
71668 + struct gr_hash_struct *hash;
71669 +
71670 + struct acl_role_label *prev;
71671 + struct acl_role_label *next;
71672 +
71673 + struct role_transition *transitions;
71674 + struct role_allowed_ip *allowed_ips;
71675 + uid_t *domain_children;
71676 + __u16 domain_child_num;
71677 +
71678 + umode_t umask;
71679 +
71680 + struct acl_subject_label **subj_hash;
71681 + __u32 subj_hash_size;
71682 +};
71683 +
71684 +struct user_acl_role_db {
71685 + struct acl_role_label **r_table;
71686 + __u32 num_pointers; /* Number of allocations to track */
71687 + __u32 num_roles; /* Number of roles */
71688 + __u32 num_domain_children; /* Number of domain children */
71689 + __u32 num_subjects; /* Number of subjects */
71690 + __u32 num_objects; /* Number of objects */
71691 +};
71692 +
71693 +struct acl_object_label {
71694 + char *filename;
71695 + ino_t inode;
71696 + dev_t device;
71697 + __u32 mode;
71698 +
71699 + struct acl_subject_label *nested;
71700 + struct acl_object_label *globbed;
71701 +
71702 + /* next two structures not used */
71703 +
71704 + struct acl_object_label *prev;
71705 + struct acl_object_label *next;
71706 +};
71707 +
71708 +struct acl_ip_label {
71709 + char *iface;
71710 + __u32 addr;
71711 + __u32 netmask;
71712 + __u16 low, high;
71713 + __u8 mode;
71714 + __u32 type;
71715 + __u32 proto[8];
71716 +
71717 + /* next two structures not used */
71718 +
71719 + struct acl_ip_label *prev;
71720 + struct acl_ip_label *next;
71721 +};
71722 +
71723 +struct gr_arg {
71724 + struct user_acl_role_db role_db;
71725 + unsigned char pw[GR_PW_LEN];
71726 + unsigned char salt[GR_SALT_LEN];
71727 + unsigned char sum[GR_SHA_LEN];
71728 + unsigned char sp_role[GR_SPROLE_LEN];
71729 + struct sprole_pw *sprole_pws;
71730 + dev_t segv_device;
71731 + ino_t segv_inode;
71732 + uid_t segv_uid;
71733 + __u16 num_sprole_pws;
71734 + __u16 mode;
71735 +};
71736 +
71737 +struct gr_arg_wrapper {
71738 + struct gr_arg *arg;
71739 + __u32 version;
71740 + __u32 size;
71741 +};
71742 +
71743 +struct subject_map {
71744 + struct acl_subject_label *user;
71745 + struct acl_subject_label *kernel;
71746 + struct subject_map *prev;
71747 + struct subject_map *next;
71748 +};
71749 +
71750 +struct acl_subj_map_db {
71751 + struct subject_map **s_hash;
71752 + __u32 s_size;
71753 +};
71754 +
71755 +/* End Data Structures Section */
71756 +
71757 +/* Hash functions generated by empirical testing by Brad Spengler
71758 + Makes good use of the low bits of the inode. Generally 0-1 times
71759 + in loop for successful match. 0-3 for unsuccessful match.
71760 + Shift/add algorithm with modulus of table size and an XOR*/
71761 +
71762 +static __inline__ unsigned int
71763 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
71764 +{
71765 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
71766 +}
71767 +
71768 + static __inline__ unsigned int
71769 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
71770 +{
71771 + return ((const unsigned long)userp % sz);
71772 +}
71773 +
71774 +static __inline__ unsigned int
71775 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
71776 +{
71777 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
71778 +}
71779 +
71780 +static __inline__ unsigned int
71781 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
71782 +{
71783 + return full_name_hash((const unsigned char *)name, len) % sz;
71784 +}
71785 +
71786 +#define FOR_EACH_ROLE_START(role) \
71787 + role = role_list; \
71788 + while (role) {
71789 +
71790 +#define FOR_EACH_ROLE_END(role) \
71791 + role = role->prev; \
71792 + }
71793 +
71794 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
71795 + subj = NULL; \
71796 + iter = 0; \
71797 + while (iter < role->subj_hash_size) { \
71798 + if (subj == NULL) \
71799 + subj = role->subj_hash[iter]; \
71800 + if (subj == NULL) { \
71801 + iter++; \
71802 + continue; \
71803 + }
71804 +
71805 +#define FOR_EACH_SUBJECT_END(subj,iter) \
71806 + subj = subj->next; \
71807 + if (subj == NULL) \
71808 + iter++; \
71809 + }
71810 +
71811 +
71812 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
71813 + subj = role->hash->first; \
71814 + while (subj != NULL) {
71815 +
71816 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
71817 + subj = subj->next; \
71818 + }
71819 +
71820 +#endif
71821 +
71822 diff --git a/include/linux/gracl_compat.h b/include/linux/gracl_compat.h
71823 new file mode 100644
71824 index 0000000..33ebd1f
71825 --- /dev/null
71826 +++ b/include/linux/gracl_compat.h
71827 @@ -0,0 +1,156 @@
71828 +#ifndef GR_ACL_COMPAT_H
71829 +#define GR_ACL_COMPAT_H
71830 +
71831 +#include <linux/resource.h>
71832 +#include <asm/resource.h>
71833 +
71834 +struct sprole_pw_compat {
71835 + compat_uptr_t rolename;
71836 + unsigned char salt[GR_SALT_LEN];
71837 + unsigned char sum[GR_SHA_LEN];
71838 +};
71839 +
71840 +struct gr_hash_struct_compat {
71841 + compat_uptr_t table;
71842 + compat_uptr_t nametable;
71843 + compat_uptr_t first;
71844 + __u32 table_size;
71845 + __u32 used_size;
71846 + int type;
71847 +};
71848 +
71849 +struct acl_subject_label_compat {
71850 + compat_uptr_t filename;
71851 + compat_ino_t inode;
71852 + __u32 device;
71853 + __u32 mode;
71854 + kernel_cap_t cap_mask;
71855 + kernel_cap_t cap_lower;
71856 + kernel_cap_t cap_invert_audit;
71857 +
71858 + struct compat_rlimit res[GR_NLIMITS];
71859 + __u32 resmask;
71860 +
71861 + __u8 user_trans_type;
71862 + __u8 group_trans_type;
71863 + compat_uptr_t user_transitions;
71864 + compat_uptr_t group_transitions;
71865 + __u16 user_trans_num;
71866 + __u16 group_trans_num;
71867 +
71868 + __u32 sock_families[2];
71869 + __u32 ip_proto[8];
71870 + __u32 ip_type;
71871 + compat_uptr_t ips;
71872 + __u32 ip_num;
71873 + __u32 inaddr_any_override;
71874 +
71875 + __u32 crashes;
71876 + compat_ulong_t expires;
71877 +
71878 + compat_uptr_t parent_subject;
71879 + compat_uptr_t hash;
71880 + compat_uptr_t prev;
71881 + compat_uptr_t next;
71882 +
71883 + compat_uptr_t obj_hash;
71884 + __u32 obj_hash_size;
71885 + __u16 pax_flags;
71886 +};
71887 +
71888 +struct role_allowed_ip_compat {
71889 + __u32 addr;
71890 + __u32 netmask;
71891 +
71892 + compat_uptr_t prev;
71893 + compat_uptr_t next;
71894 +};
71895 +
71896 +struct role_transition_compat {
71897 + compat_uptr_t rolename;
71898 +
71899 + compat_uptr_t prev;
71900 + compat_uptr_t next;
71901 +};
71902 +
71903 +struct acl_role_label_compat {
71904 + compat_uptr_t rolename;
71905 + uid_t uidgid;
71906 + __u16 roletype;
71907 +
71908 + __u16 auth_attempts;
71909 + compat_ulong_t expires;
71910 +
71911 + compat_uptr_t root_label;
71912 + compat_uptr_t hash;
71913 +
71914 + compat_uptr_t prev;
71915 + compat_uptr_t next;
71916 +
71917 + compat_uptr_t transitions;
71918 + compat_uptr_t allowed_ips;
71919 + compat_uptr_t domain_children;
71920 + __u16 domain_child_num;
71921 +
71922 + umode_t umask;
71923 +
71924 + compat_uptr_t subj_hash;
71925 + __u32 subj_hash_size;
71926 +};
71927 +
71928 +struct user_acl_role_db_compat {
71929 + compat_uptr_t r_table;
71930 + __u32 num_pointers;
71931 + __u32 num_roles;
71932 + __u32 num_domain_children;
71933 + __u32 num_subjects;
71934 + __u32 num_objects;
71935 +};
71936 +
71937 +struct acl_object_label_compat {
71938 + compat_uptr_t filename;
71939 + compat_ino_t inode;
71940 + __u32 device;
71941 + __u32 mode;
71942 +
71943 + compat_uptr_t nested;
71944 + compat_uptr_t globbed;
71945 +
71946 + compat_uptr_t prev;
71947 + compat_uptr_t next;
71948 +};
71949 +
71950 +struct acl_ip_label_compat {
71951 + compat_uptr_t iface;
71952 + __u32 addr;
71953 + __u32 netmask;
71954 + __u16 low, high;
71955 + __u8 mode;
71956 + __u32 type;
71957 + __u32 proto[8];
71958 +
71959 + compat_uptr_t prev;
71960 + compat_uptr_t next;
71961 +};
71962 +
71963 +struct gr_arg_compat {
71964 + struct user_acl_role_db_compat role_db;
71965 + unsigned char pw[GR_PW_LEN];
71966 + unsigned char salt[GR_SALT_LEN];
71967 + unsigned char sum[GR_SHA_LEN];
71968 + unsigned char sp_role[GR_SPROLE_LEN];
71969 + compat_uptr_t sprole_pws;
71970 + __u32 segv_device;
71971 + compat_ino_t segv_inode;
71972 + uid_t segv_uid;
71973 + __u16 num_sprole_pws;
71974 + __u16 mode;
71975 +};
71976 +
71977 +struct gr_arg_wrapper_compat {
71978 + compat_uptr_t arg;
71979 + __u32 version;
71980 + __u32 size;
71981 +};
71982 +
71983 +#endif
71984 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
71985 new file mode 100644
71986 index 0000000..323ecf2
71987 --- /dev/null
71988 +++ b/include/linux/gralloc.h
71989 @@ -0,0 +1,9 @@
71990 +#ifndef __GRALLOC_H
71991 +#define __GRALLOC_H
71992 +
71993 +void acl_free_all(void);
71994 +int acl_alloc_stack_init(unsigned long size);
71995 +void *acl_alloc(unsigned long len);
71996 +void *acl_alloc_num(unsigned long num, unsigned long len);
71997 +
71998 +#endif
71999 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
72000 new file mode 100644
72001 index 0000000..be66033
72002 --- /dev/null
72003 +++ b/include/linux/grdefs.h
72004 @@ -0,0 +1,140 @@
72005 +#ifndef GRDEFS_H
72006 +#define GRDEFS_H
72007 +
72008 +/* Begin grsecurity status declarations */
72009 +
72010 +enum {
72011 + GR_READY = 0x01,
72012 + GR_STATUS_INIT = 0x00 // disabled state
72013 +};
72014 +
72015 +/* Begin ACL declarations */
72016 +
72017 +/* Role flags */
72018 +
72019 +enum {
72020 + GR_ROLE_USER = 0x0001,
72021 + GR_ROLE_GROUP = 0x0002,
72022 + GR_ROLE_DEFAULT = 0x0004,
72023 + GR_ROLE_SPECIAL = 0x0008,
72024 + GR_ROLE_AUTH = 0x0010,
72025 + GR_ROLE_NOPW = 0x0020,
72026 + GR_ROLE_GOD = 0x0040,
72027 + GR_ROLE_LEARN = 0x0080,
72028 + GR_ROLE_TPE = 0x0100,
72029 + GR_ROLE_DOMAIN = 0x0200,
72030 + GR_ROLE_PAM = 0x0400,
72031 + GR_ROLE_PERSIST = 0x0800
72032 +};
72033 +
72034 +/* ACL Subject and Object mode flags */
72035 +enum {
72036 + GR_DELETED = 0x80000000
72037 +};
72038 +
72039 +/* ACL Object-only mode flags */
72040 +enum {
72041 + GR_READ = 0x00000001,
72042 + GR_APPEND = 0x00000002,
72043 + GR_WRITE = 0x00000004,
72044 + GR_EXEC = 0x00000008,
72045 + GR_FIND = 0x00000010,
72046 + GR_INHERIT = 0x00000020,
72047 + GR_SETID = 0x00000040,
72048 + GR_CREATE = 0x00000080,
72049 + GR_DELETE = 0x00000100,
72050 + GR_LINK = 0x00000200,
72051 + GR_AUDIT_READ = 0x00000400,
72052 + GR_AUDIT_APPEND = 0x00000800,
72053 + GR_AUDIT_WRITE = 0x00001000,
72054 + GR_AUDIT_EXEC = 0x00002000,
72055 + GR_AUDIT_FIND = 0x00004000,
72056 + GR_AUDIT_INHERIT= 0x00008000,
72057 + GR_AUDIT_SETID = 0x00010000,
72058 + GR_AUDIT_CREATE = 0x00020000,
72059 + GR_AUDIT_DELETE = 0x00040000,
72060 + GR_AUDIT_LINK = 0x00080000,
72061 + GR_PTRACERD = 0x00100000,
72062 + GR_NOPTRACE = 0x00200000,
72063 + GR_SUPPRESS = 0x00400000,
72064 + GR_NOLEARN = 0x00800000,
72065 + GR_INIT_TRANSFER= 0x01000000
72066 +};
72067 +
72068 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
72069 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
72070 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
72071 +
72072 +/* ACL subject-only mode flags */
72073 +enum {
72074 + GR_KILL = 0x00000001,
72075 + GR_VIEW = 0x00000002,
72076 + GR_PROTECTED = 0x00000004,
72077 + GR_LEARN = 0x00000008,
72078 + GR_OVERRIDE = 0x00000010,
72079 + /* just a placeholder, this mode is only used in userspace */
72080 + GR_DUMMY = 0x00000020,
72081 + GR_PROTSHM = 0x00000040,
72082 + GR_KILLPROC = 0x00000080,
72083 + GR_KILLIPPROC = 0x00000100,
72084 + /* just a placeholder, this mode is only used in userspace */
72085 + GR_NOTROJAN = 0x00000200,
72086 + GR_PROTPROCFD = 0x00000400,
72087 + GR_PROCACCT = 0x00000800,
72088 + GR_RELAXPTRACE = 0x00001000,
72089 + //GR_NESTED = 0x00002000,
72090 + GR_INHERITLEARN = 0x00004000,
72091 + GR_PROCFIND = 0x00008000,
72092 + GR_POVERRIDE = 0x00010000,
72093 + GR_KERNELAUTH = 0x00020000,
72094 + GR_ATSECURE = 0x00040000,
72095 + GR_SHMEXEC = 0x00080000
72096 +};
72097 +
72098 +enum {
72099 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
72100 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
72101 + GR_PAX_ENABLE_MPROTECT = 0x0004,
72102 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
72103 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
72104 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
72105 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
72106 + GR_PAX_DISABLE_MPROTECT = 0x0400,
72107 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
72108 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
72109 +};
72110 +
72111 +enum {
72112 + GR_ID_USER = 0x01,
72113 + GR_ID_GROUP = 0x02,
72114 +};
72115 +
72116 +enum {
72117 + GR_ID_ALLOW = 0x01,
72118 + GR_ID_DENY = 0x02,
72119 +};
72120 +
72121 +#define GR_CRASH_RES 31
72122 +#define GR_UIDTABLE_MAX 500
72123 +
72124 +/* begin resource learning section */
72125 +enum {
72126 + GR_RLIM_CPU_BUMP = 60,
72127 + GR_RLIM_FSIZE_BUMP = 50000,
72128 + GR_RLIM_DATA_BUMP = 10000,
72129 + GR_RLIM_STACK_BUMP = 1000,
72130 + GR_RLIM_CORE_BUMP = 10000,
72131 + GR_RLIM_RSS_BUMP = 500000,
72132 + GR_RLIM_NPROC_BUMP = 1,
72133 + GR_RLIM_NOFILE_BUMP = 5,
72134 + GR_RLIM_MEMLOCK_BUMP = 50000,
72135 + GR_RLIM_AS_BUMP = 500000,
72136 + GR_RLIM_LOCKS_BUMP = 2,
72137 + GR_RLIM_SIGPENDING_BUMP = 5,
72138 + GR_RLIM_MSGQUEUE_BUMP = 10000,
72139 + GR_RLIM_NICE_BUMP = 1,
72140 + GR_RLIM_RTPRIO_BUMP = 1,
72141 + GR_RLIM_RTTIME_BUMP = 1000000
72142 +};
72143 +
72144 +#endif
72145 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
72146 new file mode 100644
72147 index 0000000..fd8598b
72148 --- /dev/null
72149 +++ b/include/linux/grinternal.h
72150 @@ -0,0 +1,228 @@
72151 +#ifndef __GRINTERNAL_H
72152 +#define __GRINTERNAL_H
72153 +
72154 +#ifdef CONFIG_GRKERNSEC
72155 +
72156 +#include <linux/fs.h>
72157 +#include <linux/mnt_namespace.h>
72158 +#include <linux/nsproxy.h>
72159 +#include <linux/gracl.h>
72160 +#include <linux/grdefs.h>
72161 +#include <linux/grmsg.h>
72162 +
72163 +void gr_add_learn_entry(const char *fmt, ...)
72164 + __attribute__ ((format (printf, 1, 2)));
72165 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
72166 + const struct vfsmount *mnt);
72167 +__u32 gr_check_create(const struct dentry *new_dentry,
72168 + const struct dentry *parent,
72169 + const struct vfsmount *mnt, const __u32 mode);
72170 +int gr_check_protected_task(const struct task_struct *task);
72171 +__u32 to_gr_audit(const __u32 reqmode);
72172 +int gr_set_acls(const int type);
72173 +int gr_apply_subject_to_task(struct task_struct *task);
72174 +int gr_acl_is_enabled(void);
72175 +char gr_roletype_to_char(void);
72176 +
72177 +void gr_handle_alertkill(struct task_struct *task);
72178 +char *gr_to_filename(const struct dentry *dentry,
72179 + const struct vfsmount *mnt);
72180 +char *gr_to_filename1(const struct dentry *dentry,
72181 + const struct vfsmount *mnt);
72182 +char *gr_to_filename2(const struct dentry *dentry,
72183 + const struct vfsmount *mnt);
72184 +char *gr_to_filename3(const struct dentry *dentry,
72185 + const struct vfsmount *mnt);
72186 +
72187 +extern int grsec_enable_ptrace_readexec;
72188 +extern int grsec_enable_harden_ptrace;
72189 +extern int grsec_enable_link;
72190 +extern int grsec_enable_fifo;
72191 +extern int grsec_enable_execve;
72192 +extern int grsec_enable_shm;
72193 +extern int grsec_enable_execlog;
72194 +extern int grsec_enable_signal;
72195 +extern int grsec_enable_audit_ptrace;
72196 +extern int grsec_enable_forkfail;
72197 +extern int grsec_enable_time;
72198 +extern int grsec_enable_rofs;
72199 +extern int grsec_enable_chroot_shmat;
72200 +extern int grsec_enable_chroot_mount;
72201 +extern int grsec_enable_chroot_double;
72202 +extern int grsec_enable_chroot_pivot;
72203 +extern int grsec_enable_chroot_chdir;
72204 +extern int grsec_enable_chroot_chmod;
72205 +extern int grsec_enable_chroot_mknod;
72206 +extern int grsec_enable_chroot_fchdir;
72207 +extern int grsec_enable_chroot_nice;
72208 +extern int grsec_enable_chroot_execlog;
72209 +extern int grsec_enable_chroot_caps;
72210 +extern int grsec_enable_chroot_sysctl;
72211 +extern int grsec_enable_chroot_unix;
72212 +extern int grsec_enable_symlinkown;
72213 +extern kgid_t grsec_symlinkown_gid;
72214 +extern int grsec_enable_tpe;
72215 +extern kgid_t grsec_tpe_gid;
72216 +extern int grsec_enable_tpe_all;
72217 +extern int grsec_enable_tpe_invert;
72218 +extern int grsec_enable_socket_all;
72219 +extern kgid_t grsec_socket_all_gid;
72220 +extern int grsec_enable_socket_client;
72221 +extern kgid_t grsec_socket_client_gid;
72222 +extern int grsec_enable_socket_server;
72223 +extern kgid_t grsec_socket_server_gid;
72224 +extern kgid_t grsec_audit_gid;
72225 +extern int grsec_enable_group;
72226 +extern int grsec_enable_log_rwxmaps;
72227 +extern int grsec_enable_mount;
72228 +extern int grsec_enable_chdir;
72229 +extern int grsec_resource_logging;
72230 +extern int grsec_enable_blackhole;
72231 +extern int grsec_lastack_retries;
72232 +extern int grsec_enable_brute;
72233 +extern int grsec_lock;
72234 +
72235 +extern spinlock_t grsec_alert_lock;
72236 +extern unsigned long grsec_alert_wtime;
72237 +extern unsigned long grsec_alert_fyet;
72238 +
72239 +extern spinlock_t grsec_audit_lock;
72240 +
72241 +extern rwlock_t grsec_exec_file_lock;
72242 +
72243 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
72244 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
72245 + (tsk)->exec_file->f_path.mnt) : "/")
72246 +
72247 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
72248 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
72249 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
72250 +
72251 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
72252 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
72253 + (tsk)->exec_file->f_path.mnt) : "/")
72254 +
72255 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
72256 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
72257 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
72258 +
72259 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
72260 +
72261 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
72262 +
72263 +static inline bool gr_is_same_file(const struct file *file1, const struct file *file2)
72264 +{
72265 + if (file1 && file2) {
72266 + const struct inode *inode1 = file1->f_path.dentry->d_inode;
72267 + const struct inode *inode2 = file2->f_path.dentry->d_inode;
72268 + if (inode1->i_ino == inode2->i_ino && inode1->i_sb->s_dev == inode2->i_sb->s_dev)
72269 + return true;
72270 + }
72271 +
72272 + return false;
72273 +}
72274 +
72275 +#define GR_CHROOT_CAPS {{ \
72276 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
72277 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
72278 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
72279 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
72280 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
72281 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
72282 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
72283 +
72284 +#define security_learn(normal_msg,args...) \
72285 +({ \
72286 + read_lock(&grsec_exec_file_lock); \
72287 + gr_add_learn_entry(normal_msg "\n", ## args); \
72288 + read_unlock(&grsec_exec_file_lock); \
72289 +})
72290 +
72291 +enum {
72292 + GR_DO_AUDIT,
72293 + GR_DONT_AUDIT,
72294 + /* used for non-audit messages that we shouldn't kill the task on */
72295 + GR_DONT_AUDIT_GOOD
72296 +};
72297 +
72298 +enum {
72299 + GR_TTYSNIFF,
72300 + GR_RBAC,
72301 + GR_RBAC_STR,
72302 + GR_STR_RBAC,
72303 + GR_RBAC_MODE2,
72304 + GR_RBAC_MODE3,
72305 + GR_FILENAME,
72306 + GR_SYSCTL_HIDDEN,
72307 + GR_NOARGS,
72308 + GR_ONE_INT,
72309 + GR_ONE_INT_TWO_STR,
72310 + GR_ONE_STR,
72311 + GR_STR_INT,
72312 + GR_TWO_STR_INT,
72313 + GR_TWO_INT,
72314 + GR_TWO_U64,
72315 + GR_THREE_INT,
72316 + GR_FIVE_INT_TWO_STR,
72317 + GR_TWO_STR,
72318 + GR_THREE_STR,
72319 + GR_FOUR_STR,
72320 + GR_STR_FILENAME,
72321 + GR_FILENAME_STR,
72322 + GR_FILENAME_TWO_INT,
72323 + GR_FILENAME_TWO_INT_STR,
72324 + GR_TEXTREL,
72325 + GR_PTRACE,
72326 + GR_RESOURCE,
72327 + GR_CAP,
72328 + GR_SIG,
72329 + GR_SIG2,
72330 + GR_CRASH1,
72331 + GR_CRASH2,
72332 + GR_PSACCT,
72333 + GR_RWXMAP,
72334 + GR_RWXMAPVMA
72335 +};
72336 +
72337 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
72338 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
72339 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
72340 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
72341 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
72342 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
72343 +#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)
72344 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
72345 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
72346 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
72347 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
72348 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
72349 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
72350 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
72351 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
72352 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
72353 +#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)
72354 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
72355 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
72356 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
72357 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
72358 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
72359 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
72360 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
72361 +#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)
72362 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
72363 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
72364 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
72365 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
72366 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
72367 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
72368 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
72369 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
72370 +#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)
72371 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
72372 +#define gr_log_rwxmap_vma(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAPVMA, str)
72373 +
72374 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
72375 +
72376 +#endif
72377 +
72378 +#endif
72379 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
72380 new file mode 100644
72381 index 0000000..a4396b5
72382 --- /dev/null
72383 +++ b/include/linux/grmsg.h
72384 @@ -0,0 +1,113 @@
72385 +#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"
72386 +#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"
72387 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
72388 +#define GR_STOPMOD_MSG "denied modification of module state by "
72389 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
72390 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
72391 +#define GR_IOPERM_MSG "denied use of ioperm() by "
72392 +#define GR_IOPL_MSG "denied use of iopl() by "
72393 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
72394 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
72395 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
72396 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
72397 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
72398 +#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"
72399 +#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"
72400 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
72401 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
72402 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
72403 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
72404 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
72405 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
72406 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
72407 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
72408 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
72409 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
72410 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
72411 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
72412 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
72413 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
72414 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
72415 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
72416 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
72417 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
72418 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
72419 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
72420 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
72421 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
72422 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
72423 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
72424 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
72425 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
72426 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
72427 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
72428 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
72429 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
72430 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
72431 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
72432 +#define GR_SETXATTR_ACL_MSG "%s setting extended attributes of %.950s by "
72433 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
72434 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
72435 +#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"
72436 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
72437 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
72438 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
72439 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
72440 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
72441 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
72442 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
72443 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
72444 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
72445 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
72446 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
72447 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
72448 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
72449 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
72450 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
72451 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
72452 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
72453 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
72454 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
72455 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
72456 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
72457 +#define GR_NICE_CHROOT_MSG "denied priority change by "
72458 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
72459 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
72460 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
72461 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
72462 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
72463 +#define GR_TIME_MSG "time set by "
72464 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
72465 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
72466 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
72467 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
72468 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
72469 +#define GR_BIND_MSG "denied bind() by "
72470 +#define GR_CONNECT_MSG "denied connect() by "
72471 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
72472 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
72473 +#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"
72474 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
72475 +#define GR_CAP_ACL_MSG "use of %s denied for "
72476 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
72477 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
72478 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
72479 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
72480 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
72481 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
72482 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
72483 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
72484 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
72485 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
72486 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
72487 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
72488 +#define GR_TEXTREL_AUDIT_MSG "denied text relocation in %.950s, VMA:0x%08lx 0x%08lx by "
72489 +#define GR_PTGNUSTACK_MSG "denied marking stack executable as requested by PT_GNU_STACK marking in %.950s by "
72490 +#define GR_VM86_MSG "denied use of vm86 by "
72491 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
72492 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
72493 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
72494 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
72495 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
72496 +#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 "
72497 +#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 "
72498 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
72499 new file mode 100644
72500 index 0000000..3676b0b
72501 --- /dev/null
72502 +++ b/include/linux/grsecurity.h
72503 @@ -0,0 +1,242 @@
72504 +#ifndef GR_SECURITY_H
72505 +#define GR_SECURITY_H
72506 +#include <linux/fs.h>
72507 +#include <linux/fs_struct.h>
72508 +#include <linux/binfmts.h>
72509 +#include <linux/gracl.h>
72510 +
72511 +/* notify of brain-dead configs */
72512 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
72513 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
72514 +#endif
72515 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
72516 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
72517 +#endif
72518 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
72519 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
72520 +#endif
72521 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
72522 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
72523 +#endif
72524 +
72525 +void gr_handle_brute_attach(unsigned long mm_flags);
72526 +void gr_handle_brute_check(void);
72527 +void gr_handle_kernel_exploit(void);
72528 +
72529 +char gr_roletype_to_char(void);
72530 +
72531 +int gr_acl_enable_at_secure(void);
72532 +
72533 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
72534 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
72535 +
72536 +void gr_del_task_from_ip_table(struct task_struct *p);
72537 +
72538 +int gr_pid_is_chrooted(struct task_struct *p);
72539 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
72540 +int gr_handle_chroot_nice(void);
72541 +int gr_handle_chroot_sysctl(const int op);
72542 +int gr_handle_chroot_setpriority(struct task_struct *p,
72543 + const int niceval);
72544 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
72545 +int gr_handle_chroot_chroot(const struct dentry *dentry,
72546 + const struct vfsmount *mnt);
72547 +void gr_handle_chroot_chdir(const struct path *path);
72548 +int gr_handle_chroot_chmod(const struct dentry *dentry,
72549 + const struct vfsmount *mnt, const int mode);
72550 +int gr_handle_chroot_mknod(const struct dentry *dentry,
72551 + const struct vfsmount *mnt, const int mode);
72552 +int gr_handle_chroot_mount(const struct dentry *dentry,
72553 + const struct vfsmount *mnt,
72554 + const char *dev_name);
72555 +int gr_handle_chroot_pivot(void);
72556 +int gr_handle_chroot_unix(const pid_t pid);
72557 +
72558 +int gr_handle_rawio(const struct inode *inode);
72559 +
72560 +void gr_handle_ioperm(void);
72561 +void gr_handle_iopl(void);
72562 +
72563 +umode_t gr_acl_umask(void);
72564 +
72565 +int gr_tpe_allow(const struct file *file);
72566 +
72567 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path);
72568 +void gr_clear_chroot_entries(struct task_struct *task);
72569 +
72570 +void gr_log_forkfail(const int retval);
72571 +void gr_log_timechange(void);
72572 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
72573 +void gr_log_chdir(const struct dentry *dentry,
72574 + const struct vfsmount *mnt);
72575 +void gr_log_chroot_exec(const struct dentry *dentry,
72576 + const struct vfsmount *mnt);
72577 +void gr_log_remount(const char *devname, const int retval);
72578 +void gr_log_unmount(const char *devname, const int retval);
72579 +void gr_log_mount(const char *from, const char *to, const int retval);
72580 +void gr_log_textrel(struct vm_area_struct *vma);
72581 +void gr_log_ptgnustack(struct file *file);
72582 +void gr_log_rwxmmap(struct file *file);
72583 +void gr_log_rwxmprotect(struct vm_area_struct *vma);
72584 +
72585 +int gr_handle_follow_link(const struct inode *parent,
72586 + const struct inode *inode,
72587 + const struct dentry *dentry,
72588 + const struct vfsmount *mnt);
72589 +int gr_handle_fifo(const struct dentry *dentry,
72590 + const struct vfsmount *mnt,
72591 + const struct dentry *dir, const int flag,
72592 + const int acc_mode);
72593 +int gr_handle_hardlink(const struct dentry *dentry,
72594 + const struct vfsmount *mnt,
72595 + struct inode *inode,
72596 + const int mode, const struct filename *to);
72597 +
72598 +int gr_is_capable(const int cap);
72599 +int gr_is_capable_nolog(const int cap);
72600 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
72601 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
72602 +
72603 +void gr_copy_label(struct task_struct *tsk);
72604 +void gr_handle_crash(struct task_struct *task, const int sig);
72605 +int gr_handle_signal(const struct task_struct *p, const int sig);
72606 +int gr_check_crash_uid(const kuid_t uid);
72607 +int gr_check_protected_task(const struct task_struct *task);
72608 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
72609 +int gr_acl_handle_mmap(const struct file *file,
72610 + const unsigned long prot);
72611 +int gr_acl_handle_mprotect(const struct file *file,
72612 + const unsigned long prot);
72613 +int gr_check_hidden_task(const struct task_struct *tsk);
72614 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
72615 + const struct vfsmount *mnt);
72616 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
72617 + const struct vfsmount *mnt);
72618 +__u32 gr_acl_handle_access(const struct dentry *dentry,
72619 + const struct vfsmount *mnt, const int fmode);
72620 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
72621 + const struct vfsmount *mnt, umode_t *mode);
72622 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
72623 + const struct vfsmount *mnt);
72624 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
72625 + const struct vfsmount *mnt);
72626 +int gr_handle_ptrace(struct task_struct *task, const long request);
72627 +int gr_handle_proc_ptrace(struct task_struct *task);
72628 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
72629 + const struct vfsmount *mnt);
72630 +int gr_check_crash_exec(const struct file *filp);
72631 +int gr_acl_is_enabled(void);
72632 +void gr_set_kernel_label(struct task_struct *task);
72633 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
72634 + const kgid_t gid);
72635 +int gr_set_proc_label(const struct dentry *dentry,
72636 + const struct vfsmount *mnt,
72637 + const int unsafe_flags);
72638 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
72639 + const struct vfsmount *mnt);
72640 +__u32 gr_acl_handle_open(const struct dentry *dentry,
72641 + const struct vfsmount *mnt, int acc_mode);
72642 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
72643 + const struct dentry *p_dentry,
72644 + const struct vfsmount *p_mnt,
72645 + int open_flags, int acc_mode, const int imode);
72646 +void gr_handle_create(const struct dentry *dentry,
72647 + const struct vfsmount *mnt);
72648 +void gr_handle_proc_create(const struct dentry *dentry,
72649 + const struct inode *inode);
72650 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
72651 + const struct dentry *parent_dentry,
72652 + const struct vfsmount *parent_mnt,
72653 + const int mode);
72654 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
72655 + const struct dentry *parent_dentry,
72656 + const struct vfsmount *parent_mnt);
72657 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
72658 + const struct vfsmount *mnt);
72659 +void gr_handle_delete(const ino_t ino, const dev_t dev);
72660 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
72661 + const struct vfsmount *mnt);
72662 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
72663 + const struct dentry *parent_dentry,
72664 + const struct vfsmount *parent_mnt,
72665 + const struct filename *from);
72666 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
72667 + const struct dentry *parent_dentry,
72668 + const struct vfsmount *parent_mnt,
72669 + const struct dentry *old_dentry,
72670 + const struct vfsmount *old_mnt, const struct filename *to);
72671 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
72672 +int gr_acl_handle_rename(struct dentry *new_dentry,
72673 + struct dentry *parent_dentry,
72674 + const struct vfsmount *parent_mnt,
72675 + struct dentry *old_dentry,
72676 + struct inode *old_parent_inode,
72677 + struct vfsmount *old_mnt, const struct filename *newname);
72678 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
72679 + struct dentry *old_dentry,
72680 + struct dentry *new_dentry,
72681 + struct vfsmount *mnt, const __u8 replace);
72682 +__u32 gr_check_link(const struct dentry *new_dentry,
72683 + const struct dentry *parent_dentry,
72684 + const struct vfsmount *parent_mnt,
72685 + const struct dentry *old_dentry,
72686 + const struct vfsmount *old_mnt);
72687 +int gr_acl_handle_filldir(const struct file *file, const char *name,
72688 + const unsigned int namelen, const ino_t ino);
72689 +
72690 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
72691 + const struct vfsmount *mnt);
72692 +void gr_acl_handle_exit(void);
72693 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
72694 +int gr_acl_handle_procpidmem(const struct task_struct *task);
72695 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
72696 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
72697 +void gr_audit_ptrace(struct task_struct *task);
72698 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
72699 +void gr_put_exec_file(struct task_struct *task);
72700 +
72701 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
72702 +
72703 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
72704 +extern void gr_learn_resource(const struct task_struct *task, const int res,
72705 + const unsigned long wanted, const int gt);
72706 +#else
72707 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
72708 + const unsigned long wanted, const int gt)
72709 +{
72710 +}
72711 +#endif
72712 +
72713 +#ifdef CONFIG_GRKERNSEC_RESLOG
72714 +extern void gr_log_resource(const struct task_struct *task, const int res,
72715 + const unsigned long wanted, const int gt);
72716 +#else
72717 +static inline void gr_log_resource(const struct task_struct *task, const int res,
72718 + const unsigned long wanted, const int gt)
72719 +{
72720 +}
72721 +#endif
72722 +
72723 +#ifdef CONFIG_GRKERNSEC
72724 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
72725 +void gr_handle_vm86(void);
72726 +void gr_handle_mem_readwrite(u64 from, u64 to);
72727 +
72728 +void gr_log_badprocpid(const char *entry);
72729 +
72730 +extern int grsec_enable_dmesg;
72731 +extern int grsec_disable_privio;
72732 +
72733 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
72734 +extern kgid_t grsec_proc_gid;
72735 +#endif
72736 +
72737 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
72738 +extern int grsec_enable_chroot_findtask;
72739 +#endif
72740 +#ifdef CONFIG_GRKERNSEC_SETXID
72741 +extern int grsec_enable_setxid;
72742 +#endif
72743 +#endif
72744 +
72745 +#endif
72746 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
72747 new file mode 100644
72748 index 0000000..e7ffaaf
72749 --- /dev/null
72750 +++ b/include/linux/grsock.h
72751 @@ -0,0 +1,19 @@
72752 +#ifndef __GRSOCK_H
72753 +#define __GRSOCK_H
72754 +
72755 +extern void gr_attach_curr_ip(const struct sock *sk);
72756 +extern int gr_handle_sock_all(const int family, const int type,
72757 + const int protocol);
72758 +extern int gr_handle_sock_server(const struct sockaddr *sck);
72759 +extern int gr_handle_sock_server_other(const struct sock *sck);
72760 +extern int gr_handle_sock_client(const struct sockaddr *sck);
72761 +extern int gr_search_connect(struct socket * sock,
72762 + struct sockaddr_in * addr);
72763 +extern int gr_search_bind(struct socket * sock,
72764 + struct sockaddr_in * addr);
72765 +extern int gr_search_listen(struct socket * sock);
72766 +extern int gr_search_accept(struct socket * sock);
72767 +extern int gr_search_socket(const int domain, const int type,
72768 + const int protocol);
72769 +
72770 +#endif
72771 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
72772 index 7fb31da..08b5114 100644
72773 --- a/include/linux/highmem.h
72774 +++ b/include/linux/highmem.h
72775 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
72776 kunmap_atomic(kaddr);
72777 }
72778
72779 +static inline void sanitize_highpage(struct page *page)
72780 +{
72781 + void *kaddr;
72782 + unsigned long flags;
72783 +
72784 + local_irq_save(flags);
72785 + kaddr = kmap_atomic(page);
72786 + clear_page(kaddr);
72787 + kunmap_atomic(kaddr);
72788 + local_irq_restore(flags);
72789 +}
72790 +
72791 static inline void zero_user_segments(struct page *page,
72792 unsigned start1, unsigned end1,
72793 unsigned start2, unsigned end2)
72794 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
72795 index 1c7b89a..7f52502 100644
72796 --- a/include/linux/hwmon-sysfs.h
72797 +++ b/include/linux/hwmon-sysfs.h
72798 @@ -25,7 +25,8 @@
72799 struct sensor_device_attribute{
72800 struct device_attribute dev_attr;
72801 int index;
72802 -};
72803 +} __do_const;
72804 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
72805 #define to_sensor_dev_attr(_dev_attr) \
72806 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
72807
72808 @@ -41,7 +42,7 @@ struct sensor_device_attribute_2 {
72809 struct device_attribute dev_attr;
72810 u8 index;
72811 u8 nr;
72812 -};
72813 +} __do_const;
72814 #define to_sensor_dev_attr_2(_dev_attr) \
72815 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
72816
72817 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
72818 index e988fa9..ff9f17e 100644
72819 --- a/include/linux/i2c.h
72820 +++ b/include/linux/i2c.h
72821 @@ -366,6 +366,7 @@ struct i2c_algorithm {
72822 /* To determine what the adapter supports */
72823 u32 (*functionality) (struct i2c_adapter *);
72824 };
72825 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
72826
72827 /**
72828 * struct i2c_bus_recovery_info - I2C bus recovery information
72829 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
72830 index d23c3c2..eb63c81 100644
72831 --- a/include/linux/i2o.h
72832 +++ b/include/linux/i2o.h
72833 @@ -565,7 +565,7 @@ struct i2o_controller {
72834 struct i2o_device *exec; /* Executive */
72835 #if BITS_PER_LONG == 64
72836 spinlock_t context_list_lock; /* lock for context_list */
72837 - atomic_t context_list_counter; /* needed for unique contexts */
72838 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
72839 struct list_head context_list; /* list of context id's
72840 and pointers */
72841 #endif
72842 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
72843 index aff7ad8..3942bbd 100644
72844 --- a/include/linux/if_pppox.h
72845 +++ b/include/linux/if_pppox.h
72846 @@ -76,7 +76,7 @@ struct pppox_proto {
72847 int (*ioctl)(struct socket *sock, unsigned int cmd,
72848 unsigned long arg);
72849 struct module *owner;
72850 -};
72851 +} __do_const;
72852
72853 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
72854 extern void unregister_pppox_proto(int proto_num);
72855 diff --git a/include/linux/init.h b/include/linux/init.h
72856 index 8618147..0821126 100644
72857 --- a/include/linux/init.h
72858 +++ b/include/linux/init.h
72859 @@ -39,9 +39,36 @@
72860 * Also note, that this data cannot be "const".
72861 */
72862
72863 +#ifdef MODULE
72864 +#define add_init_latent_entropy
72865 +#define add_devinit_latent_entropy
72866 +#define add_cpuinit_latent_entropy
72867 +#define add_meminit_latent_entropy
72868 +#else
72869 +#define add_init_latent_entropy __latent_entropy
72870 +
72871 +#ifdef CONFIG_HOTPLUG
72872 +#define add_devinit_latent_entropy
72873 +#else
72874 +#define add_devinit_latent_entropy __latent_entropy
72875 +#endif
72876 +
72877 +#ifdef CONFIG_HOTPLUG_CPU
72878 +#define add_cpuinit_latent_entropy
72879 +#else
72880 +#define add_cpuinit_latent_entropy __latent_entropy
72881 +#endif
72882 +
72883 +#ifdef CONFIG_MEMORY_HOTPLUG
72884 +#define add_meminit_latent_entropy
72885 +#else
72886 +#define add_meminit_latent_entropy __latent_entropy
72887 +#endif
72888 +#endif
72889 +
72890 /* These are for everybody (although not all archs will actually
72891 discard it in modules) */
72892 -#define __init __section(.init.text) __cold notrace
72893 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
72894 #define __initdata __section(.init.data)
72895 #define __initconst __constsection(.init.rodata)
72896 #define __exitdata __section(.exit.data)
72897 @@ -94,7 +121,7 @@
72898 #define __exit __section(.exit.text) __exitused __cold notrace
72899
72900 /* Used for HOTPLUG_CPU */
72901 -#define __cpuinit __section(.cpuinit.text) __cold notrace
72902 +#define __cpuinit __section(.cpuinit.text) __cold notrace add_cpuinit_latent_entropy
72903 #define __cpuinitdata __section(.cpuinit.data)
72904 #define __cpuinitconst __constsection(.cpuinit.rodata)
72905 #define __cpuexit __section(.cpuexit.text) __exitused __cold notrace
72906 @@ -102,7 +129,7 @@
72907 #define __cpuexitconst __constsection(.cpuexit.rodata)
72908
72909 /* Used for MEMORY_HOTPLUG */
72910 -#define __meminit __section(.meminit.text) __cold notrace
72911 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
72912 #define __meminitdata __section(.meminit.data)
72913 #define __meminitconst __constsection(.meminit.rodata)
72914 #define __memexit __section(.memexit.text) __exitused __cold notrace
72915 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
72916 index 5cd0f09..c9f67cc 100644
72917 --- a/include/linux/init_task.h
72918 +++ b/include/linux/init_task.h
72919 @@ -154,6 +154,12 @@ extern struct task_group root_task_group;
72920
72921 #define INIT_TASK_COMM "swapper"
72922
72923 +#ifdef CONFIG_X86
72924 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
72925 +#else
72926 +#define INIT_TASK_THREAD_INFO
72927 +#endif
72928 +
72929 /*
72930 * INIT_TASK is used to set up the first task table, touch at
72931 * your own risk!. Base=0, limit=0x1fffff (=2MB)
72932 @@ -193,6 +199,7 @@ extern struct task_group root_task_group;
72933 RCU_POINTER_INITIALIZER(cred, &init_cred), \
72934 .comm = INIT_TASK_COMM, \
72935 .thread = INIT_THREAD, \
72936 + INIT_TASK_THREAD_INFO \
72937 .fs = &init_fs, \
72938 .files = &init_files, \
72939 .signal = &init_signals, \
72940 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
72941 index 5fa5afe..ac55b25 100644
72942 --- a/include/linux/interrupt.h
72943 +++ b/include/linux/interrupt.h
72944 @@ -430,7 +430,7 @@ enum
72945 /* map softirq index to softirq name. update 'softirq_to_name' in
72946 * kernel/softirq.c when adding a new softirq.
72947 */
72948 -extern char *softirq_to_name[NR_SOFTIRQS];
72949 +extern const char * const softirq_to_name[NR_SOFTIRQS];
72950
72951 /* softirq mask and active fields moved to irq_cpustat_t in
72952 * asm/hardirq.h to get better cache usage. KAO
72953 @@ -438,12 +438,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
72954
72955 struct softirq_action
72956 {
72957 - void (*action)(struct softirq_action *);
72958 -};
72959 + void (*action)(void);
72960 +} __no_const;
72961
72962 asmlinkage void do_softirq(void);
72963 asmlinkage void __do_softirq(void);
72964 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
72965 +extern void open_softirq(int nr, void (*action)(void));
72966 extern void softirq_init(void);
72967 extern void __raise_softirq_irqoff(unsigned int nr);
72968
72969 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
72970 index 3aeb730..2177f39 100644
72971 --- a/include/linux/iommu.h
72972 +++ b/include/linux/iommu.h
72973 @@ -113,7 +113,7 @@ struct iommu_ops {
72974 u32 (*domain_get_windows)(struct iommu_domain *domain);
72975
72976 unsigned long pgsize_bitmap;
72977 -};
72978 +} __do_const;
72979
72980 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
72981 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
72982 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
72983 index 89b7c24..382af74 100644
72984 --- a/include/linux/ioport.h
72985 +++ b/include/linux/ioport.h
72986 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
72987 int adjust_resource(struct resource *res, resource_size_t start,
72988 resource_size_t size);
72989 resource_size_t resource_alignment(struct resource *res);
72990 -static inline resource_size_t resource_size(const struct resource *res)
72991 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
72992 {
72993 return res->end - res->start + 1;
72994 }
72995 diff --git a/include/linux/irq.h b/include/linux/irq.h
72996 index bc4e066..50468a9 100644
72997 --- a/include/linux/irq.h
72998 +++ b/include/linux/irq.h
72999 @@ -328,7 +328,8 @@ struct irq_chip {
73000 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
73001
73002 unsigned long flags;
73003 -};
73004 +} __do_const;
73005 +typedef struct irq_chip __no_const irq_chip_no_const;
73006
73007 /*
73008 * irq_chip specific flags
73009 diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
73010 index 3e203eb..3fe68d0 100644
73011 --- a/include/linux/irqchip/arm-gic.h
73012 +++ b/include/linux/irqchip/arm-gic.h
73013 @@ -59,9 +59,11 @@
73014
73015 #ifndef __ASSEMBLY__
73016
73017 +#include <linux/irq.h>
73018 +
73019 struct device_node;
73020
73021 -extern struct irq_chip gic_arch_extn;
73022 +extern irq_chip_no_const gic_arch_extn;
73023
73024 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
73025 u32 offset, struct device_node *);
73026 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
73027 index 6883e19..e854fcb 100644
73028 --- a/include/linux/kallsyms.h
73029 +++ b/include/linux/kallsyms.h
73030 @@ -15,7 +15,8 @@
73031
73032 struct module;
73033
73034 -#ifdef CONFIG_KALLSYMS
73035 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
73036 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
73037 /* Lookup the address for a symbol. Returns 0 if not found. */
73038 unsigned long kallsyms_lookup_name(const char *name);
73039
73040 @@ -106,6 +107,21 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
73041 /* Stupid that this does nothing, but I didn't create this mess. */
73042 #define __print_symbol(fmt, addr)
73043 #endif /*CONFIG_KALLSYMS*/
73044 +#else /* when included by kallsyms.c, vsnprintf.c, kprobes.c, or
73045 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
73046 +extern unsigned long kallsyms_lookup_name(const char *name);
73047 +extern void __print_symbol(const char *fmt, unsigned long address);
73048 +extern int sprint_backtrace(char *buffer, unsigned long address);
73049 +extern int sprint_symbol(char *buffer, unsigned long address);
73050 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
73051 +const char *kallsyms_lookup(unsigned long addr,
73052 + unsigned long *symbolsize,
73053 + unsigned long *offset,
73054 + char **modname, char *namebuf);
73055 +extern int kallsyms_lookup_size_offset(unsigned long addr,
73056 + unsigned long *symbolsize,
73057 + unsigned long *offset);
73058 +#endif
73059
73060 /* This macro allows us to keep printk typechecking */
73061 static __printf(1, 2)
73062 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
73063 index 518a53a..5e28358 100644
73064 --- a/include/linux/key-type.h
73065 +++ b/include/linux/key-type.h
73066 @@ -125,7 +125,7 @@ struct key_type {
73067 /* internal fields */
73068 struct list_head link; /* link in types list */
73069 struct lock_class_key lock_class; /* key->sem lock class */
73070 -};
73071 +} __do_const;
73072
73073 extern struct key_type key_type_keyring;
73074
73075 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
73076 index c6e091b..a940adf 100644
73077 --- a/include/linux/kgdb.h
73078 +++ b/include/linux/kgdb.h
73079 @@ -52,7 +52,7 @@ extern int kgdb_connected;
73080 extern int kgdb_io_module_registered;
73081
73082 extern atomic_t kgdb_setting_breakpoint;
73083 -extern atomic_t kgdb_cpu_doing_single_step;
73084 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
73085
73086 extern struct task_struct *kgdb_usethread;
73087 extern struct task_struct *kgdb_contthread;
73088 @@ -254,7 +254,7 @@ struct kgdb_arch {
73089 void (*correct_hw_break)(void);
73090
73091 void (*enable_nmi)(bool on);
73092 -};
73093 +} __do_const;
73094
73095 /**
73096 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
73097 @@ -279,7 +279,7 @@ struct kgdb_io {
73098 void (*pre_exception) (void);
73099 void (*post_exception) (void);
73100 int is_console;
73101 -};
73102 +} __do_const;
73103
73104 extern struct kgdb_arch arch_kgdb_ops;
73105
73106 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
73107 index 0555cc6..b16a7a4 100644
73108 --- a/include/linux/kmod.h
73109 +++ b/include/linux/kmod.h
73110 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
73111 * usually useless though. */
73112 extern __printf(2, 3)
73113 int __request_module(bool wait, const char *name, ...);
73114 +extern __printf(3, 4)
73115 +int ___request_module(bool wait, char *param_name, const char *name, ...);
73116 #define request_module(mod...) __request_module(true, mod)
73117 #define request_module_nowait(mod...) __request_module(false, mod)
73118 #define try_then_request_module(x, mod...) \
73119 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
73120 index 939b112..ed6ed51 100644
73121 --- a/include/linux/kobject.h
73122 +++ b/include/linux/kobject.h
73123 @@ -111,7 +111,7 @@ struct kobj_type {
73124 struct attribute **default_attrs;
73125 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
73126 const void *(*namespace)(struct kobject *kobj);
73127 -};
73128 +} __do_const;
73129
73130 struct kobj_uevent_env {
73131 char *envp[UEVENT_NUM_ENVP];
73132 @@ -134,6 +134,7 @@ struct kobj_attribute {
73133 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
73134 const char *buf, size_t count);
73135 };
73136 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
73137
73138 extern const struct sysfs_ops kobj_sysfs_ops;
73139
73140 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
73141 index f66b065..c2c29b4 100644
73142 --- a/include/linux/kobject_ns.h
73143 +++ b/include/linux/kobject_ns.h
73144 @@ -43,7 +43,7 @@ struct kobj_ns_type_operations {
73145 const void *(*netlink_ns)(struct sock *sk);
73146 const void *(*initial_ns)(void);
73147 void (*drop_ns)(void *);
73148 -};
73149 +} __do_const;
73150
73151 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
73152 int kobj_ns_type_registered(enum kobj_ns_type type);
73153 diff --git a/include/linux/kref.h b/include/linux/kref.h
73154 index 484604d..0f6c5b6 100644
73155 --- a/include/linux/kref.h
73156 +++ b/include/linux/kref.h
73157 @@ -68,7 +68,7 @@ static inline void kref_get(struct kref *kref)
73158 static inline int kref_sub(struct kref *kref, unsigned int count,
73159 void (*release)(struct kref *kref))
73160 {
73161 - WARN_ON(release == NULL);
73162 + BUG_ON(release == NULL);
73163
73164 if (atomic_sub_and_test((int) count, &kref->refcount)) {
73165 release(kref);
73166 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
73167 index 8db53cf..c21121d 100644
73168 --- a/include/linux/kvm_host.h
73169 +++ b/include/linux/kvm_host.h
73170 @@ -444,7 +444,7 @@ static inline void kvm_irqfd_exit(void)
73171 {
73172 }
73173 #endif
73174 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
73175 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
73176 struct module *module);
73177 void kvm_exit(void);
73178
73179 @@ -616,7 +616,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
73180 struct kvm_guest_debug *dbg);
73181 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
73182
73183 -int kvm_arch_init(void *opaque);
73184 +int kvm_arch_init(const void *opaque);
73185 void kvm_arch_exit(void);
73186
73187 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
73188 diff --git a/include/linux/libata.h b/include/linux/libata.h
73189 index eae7a05..2cdd875 100644
73190 --- a/include/linux/libata.h
73191 +++ b/include/linux/libata.h
73192 @@ -919,7 +919,7 @@ struct ata_port_operations {
73193 * fields must be pointers.
73194 */
73195 const struct ata_port_operations *inherits;
73196 -};
73197 +} __do_const;
73198
73199 struct ata_port_info {
73200 unsigned long flags;
73201 diff --git a/include/linux/list.h b/include/linux/list.h
73202 index b83e565..baa6c1d 100644
73203 --- a/include/linux/list.h
73204 +++ b/include/linux/list.h
73205 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
73206 extern void list_del(struct list_head *entry);
73207 #endif
73208
73209 +extern void __pax_list_add(struct list_head *new,
73210 + struct list_head *prev,
73211 + struct list_head *next);
73212 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
73213 +{
73214 + __pax_list_add(new, head, head->next);
73215 +}
73216 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
73217 +{
73218 + __pax_list_add(new, head->prev, head);
73219 +}
73220 +extern void pax_list_del(struct list_head *entry);
73221 +
73222 /**
73223 * list_replace - replace old entry by new one
73224 * @old : the element to be replaced
73225 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
73226 INIT_LIST_HEAD(entry);
73227 }
73228
73229 +extern void pax_list_del_init(struct list_head *entry);
73230 +
73231 /**
73232 * list_move - delete from one list and add as another's head
73233 * @list: the entry to move
73234 diff --git a/include/linux/math64.h b/include/linux/math64.h
73235 index 2913b86..8dcbb1e 100644
73236 --- a/include/linux/math64.h
73237 +++ b/include/linux/math64.h
73238 @@ -15,7 +15,7 @@
73239 * This is commonly provided by 32bit archs to provide an optimized 64bit
73240 * divide.
73241 */
73242 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
73243 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
73244 {
73245 *remainder = dividend % divisor;
73246 return dividend / divisor;
73247 @@ -33,7 +33,7 @@ static inline s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
73248 /**
73249 * div64_u64 - unsigned 64bit divide with 64bit divisor
73250 */
73251 -static inline u64 div64_u64(u64 dividend, u64 divisor)
73252 +static inline u64 __intentional_overflow(0) div64_u64(u64 dividend, u64 divisor)
73253 {
73254 return dividend / divisor;
73255 }
73256 @@ -52,7 +52,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
73257 #define div64_ul(x, y) div_u64((x), (y))
73258
73259 #ifndef div_u64_rem
73260 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
73261 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
73262 {
73263 *remainder = do_div(dividend, divisor);
73264 return dividend;
73265 @@ -81,7 +81,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
73266 * divide.
73267 */
73268 #ifndef div_u64
73269 -static inline u64 div_u64(u64 dividend, u32 divisor)
73270 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
73271 {
73272 u32 remainder;
73273 return div_u64_rem(dividend, divisor, &remainder);
73274 diff --git a/include/linux/mm.h b/include/linux/mm.h
73275 index e0c8528..bcf0c29 100644
73276 --- a/include/linux/mm.h
73277 +++ b/include/linux/mm.h
73278 @@ -104,6 +104,11 @@ extern unsigned int kobjsize(const void *objp);
73279 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
73280 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
73281 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
73282 +
73283 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
73284 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
73285 +#endif
73286 +
73287 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
73288
73289 #define VM_MIXEDMAP 0x10000000 /* Can contain "struct page" and pure PFN pages */
73290 @@ -205,8 +210,8 @@ struct vm_operations_struct {
73291 /* called by access_process_vm when get_user_pages() fails, typically
73292 * for use by special VMAs that can switch between memory and hardware
73293 */
73294 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
73295 - void *buf, int len, int write);
73296 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
73297 + void *buf, size_t len, int write);
73298 #ifdef CONFIG_NUMA
73299 /*
73300 * set_policy() op must add a reference to any non-NULL @new mempolicy
73301 @@ -236,6 +241,7 @@ struct vm_operations_struct {
73302 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
73303 unsigned long size, pgoff_t pgoff);
73304 };
73305 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
73306
73307 struct mmu_gather;
73308 struct inode;
73309 @@ -980,8 +986,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
73310 unsigned long *pfn);
73311 int follow_phys(struct vm_area_struct *vma, unsigned long address,
73312 unsigned int flags, unsigned long *prot, resource_size_t *phys);
73313 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
73314 - void *buf, int len, int write);
73315 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
73316 + void *buf, size_t len, int write);
73317
73318 static inline void unmap_shared_mapping_range(struct address_space *mapping,
73319 loff_t const holebegin, loff_t const holelen)
73320 @@ -1020,9 +1026,9 @@ static inline int fixup_user_fault(struct task_struct *tsk,
73321 }
73322 #endif
73323
73324 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
73325 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
73326 - void *buf, int len, int write);
73327 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
73328 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
73329 + void *buf, size_t len, int write);
73330
73331 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
73332 unsigned long start, unsigned long nr_pages,
73333 @@ -1053,34 +1059,6 @@ int set_page_dirty(struct page *page);
73334 int set_page_dirty_lock(struct page *page);
73335 int clear_page_dirty_for_io(struct page *page);
73336
73337 -/* Is the vma a continuation of the stack vma above it? */
73338 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
73339 -{
73340 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
73341 -}
73342 -
73343 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
73344 - unsigned long addr)
73345 -{
73346 - return (vma->vm_flags & VM_GROWSDOWN) &&
73347 - (vma->vm_start == addr) &&
73348 - !vma_growsdown(vma->vm_prev, addr);
73349 -}
73350 -
73351 -/* Is the vma a continuation of the stack vma below it? */
73352 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
73353 -{
73354 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
73355 -}
73356 -
73357 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
73358 - unsigned long addr)
73359 -{
73360 - return (vma->vm_flags & VM_GROWSUP) &&
73361 - (vma->vm_end == addr) &&
73362 - !vma_growsup(vma->vm_next, addr);
73363 -}
73364 -
73365 extern pid_t
73366 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
73367
73368 @@ -1180,6 +1158,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
73369 }
73370 #endif
73371
73372 +#ifdef CONFIG_MMU
73373 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
73374 +#else
73375 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
73376 +{
73377 + return __pgprot(0);
73378 +}
73379 +#endif
73380 +
73381 int vma_wants_writenotify(struct vm_area_struct *vma);
73382
73383 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
73384 @@ -1198,8 +1185,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
73385 {
73386 return 0;
73387 }
73388 +
73389 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
73390 + unsigned long address)
73391 +{
73392 + return 0;
73393 +}
73394 #else
73395 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
73396 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
73397 #endif
73398
73399 #ifdef __PAGETABLE_PMD_FOLDED
73400 @@ -1208,8 +1202,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
73401 {
73402 return 0;
73403 }
73404 +
73405 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
73406 + unsigned long address)
73407 +{
73408 + return 0;
73409 +}
73410 #else
73411 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
73412 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
73413 #endif
73414
73415 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
73416 @@ -1227,11 +1228,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
73417 NULL: pud_offset(pgd, address);
73418 }
73419
73420 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
73421 +{
73422 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
73423 + NULL: pud_offset(pgd, address);
73424 +}
73425 +
73426 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
73427 {
73428 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
73429 NULL: pmd_offset(pud, address);
73430 }
73431 +
73432 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
73433 +{
73434 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
73435 + NULL: pmd_offset(pud, address);
73436 +}
73437 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
73438
73439 #if USE_SPLIT_PTLOCKS
73440 @@ -1517,6 +1530,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
73441 unsigned long len, unsigned long prot, unsigned long flags,
73442 unsigned long pgoff, unsigned long *populate);
73443 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
73444 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
73445
73446 #ifdef CONFIG_MMU
73447 extern int __mm_populate(unsigned long addr, unsigned long len,
73448 @@ -1545,10 +1559,11 @@ struct vm_unmapped_area_info {
73449 unsigned long high_limit;
73450 unsigned long align_mask;
73451 unsigned long align_offset;
73452 + unsigned long threadstack_offset;
73453 };
73454
73455 -extern unsigned long unmapped_area(struct vm_unmapped_area_info *info);
73456 -extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
73457 +extern unsigned long unmapped_area(const struct vm_unmapped_area_info *info);
73458 +extern unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info);
73459
73460 /*
73461 * Search for an unmapped address range.
73462 @@ -1560,7 +1575,7 @@ extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
73463 * - satisfies (begin_addr & align_mask) == (align_offset & align_mask)
73464 */
73465 static inline unsigned long
73466 -vm_unmapped_area(struct vm_unmapped_area_info *info)
73467 +vm_unmapped_area(const struct vm_unmapped_area_info *info)
73468 {
73469 if (!(info->flags & VM_UNMAPPED_AREA_TOPDOWN))
73470 return unmapped_area(info);
73471 @@ -1623,6 +1638,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
73472 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
73473 struct vm_area_struct **pprev);
73474
73475 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
73476 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
73477 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
73478 +
73479 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
73480 NULL if none. Assume start_addr < end_addr. */
73481 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
73482 @@ -1651,15 +1670,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
73483 return vma;
73484 }
73485
73486 -#ifdef CONFIG_MMU
73487 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
73488 -#else
73489 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
73490 -{
73491 - return __pgprot(0);
73492 -}
73493 -#endif
73494 -
73495 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
73496 unsigned long change_prot_numa(struct vm_area_struct *vma,
73497 unsigned long start, unsigned long end);
73498 @@ -1711,6 +1721,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
73499 static inline void vm_stat_account(struct mm_struct *mm,
73500 unsigned long flags, struct file *file, long pages)
73501 {
73502 +
73503 +#ifdef CONFIG_PAX_RANDMMAP
73504 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
73505 +#endif
73506 +
73507 mm->total_vm += pages;
73508 }
73509 #endif /* CONFIG_PROC_FS */
73510 @@ -1791,7 +1806,7 @@ extern int unpoison_memory(unsigned long pfn);
73511 extern int sysctl_memory_failure_early_kill;
73512 extern int sysctl_memory_failure_recovery;
73513 extern void shake_page(struct page *p, int access);
73514 -extern atomic_long_t num_poisoned_pages;
73515 +extern atomic_long_unchecked_t num_poisoned_pages;
73516 extern int soft_offline_page(struct page *page, int flags);
73517
73518 extern void dump_page(struct page *page);
73519 @@ -1828,5 +1843,11 @@ void __init setup_nr_node_ids(void);
73520 static inline void setup_nr_node_ids(void) {}
73521 #endif
73522
73523 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
73524 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
73525 +#else
73526 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
73527 +#endif
73528 +
73529 #endif /* __KERNEL__ */
73530 #endif /* _LINUX_MM_H */
73531 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
73532 index ace9a5f..81bdb59 100644
73533 --- a/include/linux/mm_types.h
73534 +++ b/include/linux/mm_types.h
73535 @@ -289,6 +289,8 @@ struct vm_area_struct {
73536 #ifdef CONFIG_NUMA
73537 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
73538 #endif
73539 +
73540 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
73541 };
73542
73543 struct core_thread {
73544 @@ -437,6 +439,24 @@ struct mm_struct {
73545 int first_nid;
73546 #endif
73547 struct uprobes_state uprobes_state;
73548 +
73549 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
73550 + unsigned long pax_flags;
73551 +#endif
73552 +
73553 +#ifdef CONFIG_PAX_DLRESOLVE
73554 + unsigned long call_dl_resolve;
73555 +#endif
73556 +
73557 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
73558 + unsigned long call_syscall;
73559 +#endif
73560 +
73561 +#ifdef CONFIG_PAX_ASLR
73562 + unsigned long delta_mmap; /* randomized offset */
73563 + unsigned long delta_stack; /* randomized offset */
73564 +#endif
73565 +
73566 };
73567
73568 /* first nid will either be a valid NID or one of these values */
73569 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
73570 index c5d5278..f0b68c8 100644
73571 --- a/include/linux/mmiotrace.h
73572 +++ b/include/linux/mmiotrace.h
73573 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
73574 /* Called from ioremap.c */
73575 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
73576 void __iomem *addr);
73577 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
73578 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
73579
73580 /* For anyone to insert markers. Remember trailing newline. */
73581 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
73582 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
73583 {
73584 }
73585
73586 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
73587 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
73588 {
73589 }
73590
73591 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
73592 index 5c76737..61f518e 100644
73593 --- a/include/linux/mmzone.h
73594 +++ b/include/linux/mmzone.h
73595 @@ -396,7 +396,7 @@ struct zone {
73596 unsigned long flags; /* zone flags, see below */
73597
73598 /* Zone statistics */
73599 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
73600 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
73601
73602 /*
73603 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
73604 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
73605 index b508016..237cfe5 100644
73606 --- a/include/linux/mod_devicetable.h
73607 +++ b/include/linux/mod_devicetable.h
73608 @@ -13,7 +13,7 @@
73609 typedef unsigned long kernel_ulong_t;
73610 #endif
73611
73612 -#define PCI_ANY_ID (~0)
73613 +#define PCI_ANY_ID ((__u16)~0)
73614
73615 struct pci_device_id {
73616 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
73617 @@ -139,7 +139,7 @@ struct usb_device_id {
73618 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
73619 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
73620
73621 -#define HID_ANY_ID (~0)
73622 +#define HID_ANY_ID (~0U)
73623 #define HID_BUS_ANY 0xffff
73624 #define HID_GROUP_ANY 0x0000
73625
73626 @@ -465,7 +465,7 @@ struct dmi_system_id {
73627 const char *ident;
73628 struct dmi_strmatch matches[4];
73629 void *driver_data;
73630 -};
73631 +} __do_const;
73632 /*
73633 * struct dmi_device_id appears during expansion of
73634 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
73635 diff --git a/include/linux/module.h b/include/linux/module.h
73636 index 46f1ea0..a34ca37 100644
73637 --- a/include/linux/module.h
73638 +++ b/include/linux/module.h
73639 @@ -17,9 +17,11 @@
73640 #include <linux/moduleparam.h>
73641 #include <linux/tracepoint.h>
73642 #include <linux/export.h>
73643 +#include <linux/fs.h>
73644
73645 #include <linux/percpu.h>
73646 #include <asm/module.h>
73647 +#include <asm/pgtable.h>
73648
73649 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
73650 #define MODULE_SIG_STRING "~Module signature appended~\n"
73651 @@ -54,12 +56,13 @@ struct module_attribute {
73652 int (*test)(struct module *);
73653 void (*free)(struct module *);
73654 };
73655 +typedef struct module_attribute __no_const module_attribute_no_const;
73656
73657 struct module_version_attribute {
73658 struct module_attribute mattr;
73659 const char *module_name;
73660 const char *version;
73661 -} __attribute__ ((__aligned__(sizeof(void *))));
73662 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
73663
73664 extern ssize_t __modver_version_show(struct module_attribute *,
73665 struct module_kobject *, char *);
73666 @@ -232,7 +235,7 @@ struct module
73667
73668 /* Sysfs stuff. */
73669 struct module_kobject mkobj;
73670 - struct module_attribute *modinfo_attrs;
73671 + module_attribute_no_const *modinfo_attrs;
73672 const char *version;
73673 const char *srcversion;
73674 struct kobject *holders_dir;
73675 @@ -281,19 +284,16 @@ struct module
73676 int (*init)(void);
73677
73678 /* If this is non-NULL, vfree after init() returns */
73679 - void *module_init;
73680 + void *module_init_rx, *module_init_rw;
73681
73682 /* Here is the actual code + data, vfree'd on unload. */
73683 - void *module_core;
73684 + void *module_core_rx, *module_core_rw;
73685
73686 /* Here are the sizes of the init and core sections */
73687 - unsigned int init_size, core_size;
73688 + unsigned int init_size_rw, core_size_rw;
73689
73690 /* The size of the executable code in each section. */
73691 - unsigned int init_text_size, core_text_size;
73692 -
73693 - /* Size of RO sections of the module (text+rodata) */
73694 - unsigned int init_ro_size, core_ro_size;
73695 + unsigned int init_size_rx, core_size_rx;
73696
73697 /* Arch-specific module values */
73698 struct mod_arch_specific arch;
73699 @@ -349,6 +349,10 @@ struct module
73700 #ifdef CONFIG_EVENT_TRACING
73701 struct ftrace_event_call **trace_events;
73702 unsigned int num_trace_events;
73703 + struct file_operations trace_id;
73704 + struct file_operations trace_enable;
73705 + struct file_operations trace_format;
73706 + struct file_operations trace_filter;
73707 #endif
73708 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
73709 unsigned int num_ftrace_callsites;
73710 @@ -396,16 +400,46 @@ bool is_module_address(unsigned long addr);
73711 bool is_module_percpu_address(unsigned long addr);
73712 bool is_module_text_address(unsigned long addr);
73713
73714 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
73715 +{
73716 +
73717 +#ifdef CONFIG_PAX_KERNEXEC
73718 + if (ktla_ktva(addr) >= (unsigned long)start &&
73719 + ktla_ktva(addr) < (unsigned long)start + size)
73720 + return 1;
73721 +#endif
73722 +
73723 + return ((void *)addr >= start && (void *)addr < start + size);
73724 +}
73725 +
73726 +static inline int within_module_core_rx(unsigned long addr, const struct module *mod)
73727 +{
73728 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
73729 +}
73730 +
73731 +static inline int within_module_core_rw(unsigned long addr, const struct module *mod)
73732 +{
73733 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
73734 +}
73735 +
73736 +static inline int within_module_init_rx(unsigned long addr, const struct module *mod)
73737 +{
73738 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
73739 +}
73740 +
73741 +static inline int within_module_init_rw(unsigned long addr, const struct module *mod)
73742 +{
73743 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
73744 +}
73745 +
73746 static inline int within_module_core(unsigned long addr, const struct module *mod)
73747 {
73748 - return (unsigned long)mod->module_core <= addr &&
73749 - addr < (unsigned long)mod->module_core + mod->core_size;
73750 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
73751 }
73752
73753 static inline int within_module_init(unsigned long addr, const struct module *mod)
73754 {
73755 - return (unsigned long)mod->module_init <= addr &&
73756 - addr < (unsigned long)mod->module_init + mod->init_size;
73757 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
73758 }
73759
73760 /* Search for module by name: must hold module_mutex. */
73761 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
73762 index 560ca53..ef621ef 100644
73763 --- a/include/linux/moduleloader.h
73764 +++ b/include/linux/moduleloader.h
73765 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
73766 sections. Returns NULL on failure. */
73767 void *module_alloc(unsigned long size);
73768
73769 +#ifdef CONFIG_PAX_KERNEXEC
73770 +void *module_alloc_exec(unsigned long size);
73771 +#else
73772 +#define module_alloc_exec(x) module_alloc(x)
73773 +#endif
73774 +
73775 /* Free memory returned from module_alloc. */
73776 void module_free(struct module *mod, void *module_region);
73777
73778 +#ifdef CONFIG_PAX_KERNEXEC
73779 +void module_free_exec(struct module *mod, void *module_region);
73780 +#else
73781 +#define module_free_exec(x, y) module_free((x), (y))
73782 +#endif
73783 +
73784 /*
73785 * Apply the given relocation to the (simplified) ELF. Return -error
73786 * or 0.
73787 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
73788 unsigned int relsec,
73789 struct module *me)
73790 {
73791 +#ifdef CONFIG_MODULES
73792 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
73793 +#endif
73794 return -ENOEXEC;
73795 }
73796 #endif
73797 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
73798 unsigned int relsec,
73799 struct module *me)
73800 {
73801 +#ifdef CONFIG_MODULES
73802 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
73803 +#endif
73804 return -ENOEXEC;
73805 }
73806 #endif
73807 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
73808 index 137b419..fe663ec 100644
73809 --- a/include/linux/moduleparam.h
73810 +++ b/include/linux/moduleparam.h
73811 @@ -284,7 +284,7 @@ static inline void __kernel_param_unlock(void)
73812 * @len is usually just sizeof(string).
73813 */
73814 #define module_param_string(name, string, len, perm) \
73815 - static const struct kparam_string __param_string_##name \
73816 + static const struct kparam_string __param_string_##name __used \
73817 = { len, string }; \
73818 __module_param_call(MODULE_PARAM_PREFIX, name, \
73819 &param_ops_string, \
73820 @@ -423,7 +423,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
73821 */
73822 #define module_param_array_named(name, array, type, nump, perm) \
73823 param_check_##type(name, &(array)[0]); \
73824 - static const struct kparam_array __param_arr_##name \
73825 + static const struct kparam_array __param_arr_##name __used \
73826 = { .max = ARRAY_SIZE(array), .num = nump, \
73827 .ops = &param_ops_##type, \
73828 .elemsize = sizeof(array[0]), .elem = array }; \
73829 diff --git a/include/linux/namei.h b/include/linux/namei.h
73830 index 5a5ff57..5ae5070 100644
73831 --- a/include/linux/namei.h
73832 +++ b/include/linux/namei.h
73833 @@ -19,7 +19,7 @@ struct nameidata {
73834 unsigned seq;
73835 int last_type;
73836 unsigned depth;
73837 - char *saved_names[MAX_NESTED_LINKS + 1];
73838 + const char *saved_names[MAX_NESTED_LINKS + 1];
73839 };
73840
73841 /*
73842 @@ -84,12 +84,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
73843
73844 extern void nd_jump_link(struct nameidata *nd, struct path *path);
73845
73846 -static inline void nd_set_link(struct nameidata *nd, char *path)
73847 +static inline void nd_set_link(struct nameidata *nd, const char *path)
73848 {
73849 nd->saved_names[nd->depth] = path;
73850 }
73851
73852 -static inline char *nd_get_link(struct nameidata *nd)
73853 +static inline const char *nd_get_link(const struct nameidata *nd)
73854 {
73855 return nd->saved_names[nd->depth];
73856 }
73857 diff --git a/include/linux/net.h b/include/linux/net.h
73858 index 99c9f0c..e1cf296 100644
73859 --- a/include/linux/net.h
73860 +++ b/include/linux/net.h
73861 @@ -183,7 +183,7 @@ struct net_proto_family {
73862 int (*create)(struct net *net, struct socket *sock,
73863 int protocol, int kern);
73864 struct module *owner;
73865 -};
73866 +} __do_const;
73867
73868 struct iovec;
73869 struct kvec;
73870 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
73871 index 96e4c21..9cc8278 100644
73872 --- a/include/linux/netdevice.h
73873 +++ b/include/linux/netdevice.h
73874 @@ -1026,6 +1026,7 @@ struct net_device_ops {
73875 int (*ndo_change_carrier)(struct net_device *dev,
73876 bool new_carrier);
73877 };
73878 +typedef struct net_device_ops __no_const net_device_ops_no_const;
73879
73880 /*
73881 * The DEVICE structure.
73882 @@ -1094,7 +1095,7 @@ struct net_device {
73883 int iflink;
73884
73885 struct net_device_stats stats;
73886 - atomic_long_t rx_dropped; /* dropped packets by core network
73887 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
73888 * Do not use this in drivers.
73889 */
73890
73891 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
73892 index 0060fde..481c6ae 100644
73893 --- a/include/linux/netfilter.h
73894 +++ b/include/linux/netfilter.h
73895 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
73896 #endif
73897 /* Use the module struct to lock set/get code in place */
73898 struct module *owner;
73899 -};
73900 +} __do_const;
73901
73902 /* Function to register/unregister hook points. */
73903 int nf_register_hook(struct nf_hook_ops *reg);
73904 diff --git a/include/linux/netfilter/ipset/ip_set.h b/include/linux/netfilter/ipset/ip_set.h
73905 index d80e275..c3510b8 100644
73906 --- a/include/linux/netfilter/ipset/ip_set.h
73907 +++ b/include/linux/netfilter/ipset/ip_set.h
73908 @@ -124,7 +124,7 @@ struct ip_set_type_variant {
73909 /* Return true if "b" set is the same as "a"
73910 * according to the create set parameters */
73911 bool (*same_set)(const struct ip_set *a, const struct ip_set *b);
73912 -};
73913 +} __do_const;
73914
73915 /* The core set type structure */
73916 struct ip_set_type {
73917 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
73918 index cadb740..d7c37c0 100644
73919 --- a/include/linux/netfilter/nfnetlink.h
73920 +++ b/include/linux/netfilter/nfnetlink.h
73921 @@ -16,7 +16,7 @@ struct nfnl_callback {
73922 const struct nlattr * const cda[]);
73923 const struct nla_policy *policy; /* netlink attribute policy */
73924 const u_int16_t attr_count; /* number of nlattr's */
73925 -};
73926 +} __do_const;
73927
73928 struct nfnetlink_subsystem {
73929 const char *name;
73930 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
73931 new file mode 100644
73932 index 0000000..33f4af8
73933 --- /dev/null
73934 +++ b/include/linux/netfilter/xt_gradm.h
73935 @@ -0,0 +1,9 @@
73936 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
73937 +#define _LINUX_NETFILTER_XT_GRADM_H 1
73938 +
73939 +struct xt_gradm_mtinfo {
73940 + __u16 flags;
73941 + __u16 invflags;
73942 +};
73943 +
73944 +#endif
73945 diff --git a/include/linux/nls.h b/include/linux/nls.h
73946 index 5dc635f..35f5e11 100644
73947 --- a/include/linux/nls.h
73948 +++ b/include/linux/nls.h
73949 @@ -31,7 +31,7 @@ struct nls_table {
73950 const unsigned char *charset2upper;
73951 struct module *owner;
73952 struct nls_table *next;
73953 -};
73954 +} __do_const;
73955
73956 /* this value hold the maximum octet of charset */
73957 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
73958 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
73959 index d14a4c3..a078786 100644
73960 --- a/include/linux/notifier.h
73961 +++ b/include/linux/notifier.h
73962 @@ -54,7 +54,8 @@ struct notifier_block {
73963 notifier_fn_t notifier_call;
73964 struct notifier_block __rcu *next;
73965 int priority;
73966 -};
73967 +} __do_const;
73968 +typedef struct notifier_block __no_const notifier_block_no_const;
73969
73970 struct atomic_notifier_head {
73971 spinlock_t lock;
73972 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
73973 index a4c5624..79d6d88 100644
73974 --- a/include/linux/oprofile.h
73975 +++ b/include/linux/oprofile.h
73976 @@ -139,9 +139,9 @@ int oprofilefs_create_ulong(struct super_block * sb, struct dentry * root,
73977 int oprofilefs_create_ro_ulong(struct super_block * sb, struct dentry * root,
73978 char const * name, ulong * val);
73979
73980 -/** Create a file for read-only access to an atomic_t. */
73981 +/** Create a file for read-only access to an atomic_unchecked_t. */
73982 int oprofilefs_create_ro_atomic(struct super_block * sb, struct dentry * root,
73983 - char const * name, atomic_t * val);
73984 + char const * name, atomic_unchecked_t * val);
73985
73986 /** create a directory */
73987 struct dentry * oprofilefs_mkdir(struct super_block * sb, struct dentry * root,
73988 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
73989 index 8db71dc..a76bf2c 100644
73990 --- a/include/linux/pci_hotplug.h
73991 +++ b/include/linux/pci_hotplug.h
73992 @@ -80,7 +80,8 @@ struct hotplug_slot_ops {
73993 int (*get_attention_status) (struct hotplug_slot *slot, u8 *value);
73994 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
73995 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
73996 -};
73997 +} __do_const;
73998 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
73999
74000 /**
74001 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
74002 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
74003 index c5b6dbf..b124155 100644
74004 --- a/include/linux/perf_event.h
74005 +++ b/include/linux/perf_event.h
74006 @@ -318,8 +318,8 @@ struct perf_event {
74007
74008 enum perf_event_active_state state;
74009 unsigned int attach_state;
74010 - local64_t count;
74011 - atomic64_t child_count;
74012 + local64_t count; /* PaX: fix it one day */
74013 + atomic64_unchecked_t child_count;
74014
74015 /*
74016 * These are the total time in nanoseconds that the event
74017 @@ -370,8 +370,8 @@ struct perf_event {
74018 * These accumulate total time (in nanoseconds) that children
74019 * events have been enabled and running, respectively.
74020 */
74021 - atomic64_t child_total_time_enabled;
74022 - atomic64_t child_total_time_running;
74023 + atomic64_unchecked_t child_total_time_enabled;
74024 + atomic64_unchecked_t child_total_time_running;
74025
74026 /*
74027 * Protect attach/detach and child_list:
74028 @@ -692,7 +692,7 @@ static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64
74029 entry->ip[entry->nr++] = ip;
74030 }
74031
74032 -extern int sysctl_perf_event_paranoid;
74033 +extern int sysctl_perf_event_legitimately_concerned;
74034 extern int sysctl_perf_event_mlock;
74035 extern int sysctl_perf_event_sample_rate;
74036
74037 @@ -700,19 +700,24 @@ extern int perf_proc_update_handler(struct ctl_table *table, int write,
74038 void __user *buffer, size_t *lenp,
74039 loff_t *ppos);
74040
74041 +static inline bool perf_paranoid_any(void)
74042 +{
74043 + return sysctl_perf_event_legitimately_concerned > 2;
74044 +}
74045 +
74046 static inline bool perf_paranoid_tracepoint_raw(void)
74047 {
74048 - return sysctl_perf_event_paranoid > -1;
74049 + return sysctl_perf_event_legitimately_concerned > -1;
74050 }
74051
74052 static inline bool perf_paranoid_cpu(void)
74053 {
74054 - return sysctl_perf_event_paranoid > 0;
74055 + return sysctl_perf_event_legitimately_concerned > 0;
74056 }
74057
74058 static inline bool perf_paranoid_kernel(void)
74059 {
74060 - return sysctl_perf_event_paranoid > 1;
74061 + return sysctl_perf_event_legitimately_concerned > 1;
74062 }
74063
74064 extern void perf_event_init(void);
74065 @@ -806,7 +811,7 @@ static inline void perf_restore_debug_store(void) { }
74066 */
74067 #define perf_cpu_notifier(fn) \
74068 do { \
74069 - static struct notifier_block fn##_nb __cpuinitdata = \
74070 + static struct notifier_block fn##_nb = \
74071 { .notifier_call = fn, .priority = CPU_PRI_PERF }; \
74072 unsigned long cpu = smp_processor_id(); \
74073 unsigned long flags; \
74074 @@ -826,7 +831,7 @@ struct perf_pmu_events_attr {
74075 struct device_attribute attr;
74076 u64 id;
74077 const char *event_str;
74078 -};
74079 +} __do_const;
74080
74081 #define PMU_EVENT_ATTR(_name, _var, _id, _show) \
74082 static struct perf_pmu_events_attr _var = { \
74083 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
74084 index b8809fe..ae4ccd0 100644
74085 --- a/include/linux/pipe_fs_i.h
74086 +++ b/include/linux/pipe_fs_i.h
74087 @@ -47,10 +47,10 @@ struct pipe_inode_info {
74088 struct mutex mutex;
74089 wait_queue_head_t wait;
74090 unsigned int nrbufs, curbuf, buffers;
74091 - unsigned int readers;
74092 - unsigned int writers;
74093 - unsigned int files;
74094 - unsigned int waiting_writers;
74095 + atomic_t readers;
74096 + atomic_t writers;
74097 + atomic_t files;
74098 + atomic_t waiting_writers;
74099 unsigned int r_counter;
74100 unsigned int w_counter;
74101 struct page *tmp_page;
74102 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
74103 index 5f28cae..3d23723 100644
74104 --- a/include/linux/platform_data/usb-ehci-s5p.h
74105 +++ b/include/linux/platform_data/usb-ehci-s5p.h
74106 @@ -14,7 +14,7 @@
74107 struct s5p_ehci_platdata {
74108 int (*phy_init)(struct platform_device *pdev, int type);
74109 int (*phy_exit)(struct platform_device *pdev, int type);
74110 -};
74111 +} __no_const;
74112
74113 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
74114
74115 diff --git a/include/linux/platform_data/usb-ohci-exynos.h b/include/linux/platform_data/usb-ohci-exynos.h
74116 index c256c59..8ea94c7 100644
74117 --- a/include/linux/platform_data/usb-ohci-exynos.h
74118 +++ b/include/linux/platform_data/usb-ohci-exynos.h
74119 @@ -14,7 +14,7 @@
74120 struct exynos4_ohci_platdata {
74121 int (*phy_init)(struct platform_device *pdev, int type);
74122 int (*phy_exit)(struct platform_device *pdev, int type);
74123 -};
74124 +} __no_const;
74125
74126 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
74127
74128 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
74129 index 7c1d252..c5c773e 100644
74130 --- a/include/linux/pm_domain.h
74131 +++ b/include/linux/pm_domain.h
74132 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
74133
74134 struct gpd_cpu_data {
74135 unsigned int saved_exit_latency;
74136 - struct cpuidle_state *idle_state;
74137 + cpuidle_state_no_const *idle_state;
74138 };
74139
74140 struct generic_pm_domain {
74141 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
74142 index 7d7e09e..8671ef8 100644
74143 --- a/include/linux/pm_runtime.h
74144 +++ b/include/linux/pm_runtime.h
74145 @@ -104,7 +104,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
74146
74147 static inline void pm_runtime_mark_last_busy(struct device *dev)
74148 {
74149 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
74150 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
74151 }
74152
74153 #else /* !CONFIG_PM_RUNTIME */
74154 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
74155 index 195aafc..49a7bc2 100644
74156 --- a/include/linux/pnp.h
74157 +++ b/include/linux/pnp.h
74158 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
74159 struct pnp_fixup {
74160 char id[7];
74161 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
74162 -};
74163 +} __do_const;
74164
74165 /* config parameters */
74166 #define PNP_CONFIG_NORMAL 0x0001
74167 diff --git a/include/linux/poison.h b/include/linux/poison.h
74168 index 2110a81..13a11bb 100644
74169 --- a/include/linux/poison.h
74170 +++ b/include/linux/poison.h
74171 @@ -19,8 +19,8 @@
74172 * under normal circumstances, used to verify that nobody uses
74173 * non-initialized list entries.
74174 */
74175 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
74176 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
74177 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
74178 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
74179
74180 /********** include/linux/timer.h **********/
74181 /*
74182 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
74183 index c0f44c2..1572583 100644
74184 --- a/include/linux/power/smartreflex.h
74185 +++ b/include/linux/power/smartreflex.h
74186 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
74187 int (*notify)(struct omap_sr *sr, u32 status);
74188 u8 notify_flags;
74189 u8 class_type;
74190 -};
74191 +} __do_const;
74192
74193 /**
74194 * struct omap_sr_nvalue_table - Smartreflex n-target value info
74195 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
74196 index 4ea1d37..80f4b33 100644
74197 --- a/include/linux/ppp-comp.h
74198 +++ b/include/linux/ppp-comp.h
74199 @@ -84,7 +84,7 @@ struct compressor {
74200 struct module *owner;
74201 /* Extra skb space needed by the compressor algorithm */
74202 unsigned int comp_extra;
74203 -};
74204 +} __do_const;
74205
74206 /*
74207 * The return value from decompress routine is the length of the
74208 diff --git a/include/linux/preempt.h b/include/linux/preempt.h
74209 index f5d4723..a6ea2fa 100644
74210 --- a/include/linux/preempt.h
74211 +++ b/include/linux/preempt.h
74212 @@ -18,8 +18,13 @@
74213 # define sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
74214 #endif
74215
74216 +#define raw_add_preempt_count(val) do { preempt_count() += (val); } while (0)
74217 +#define raw_sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
74218 +
74219 #define inc_preempt_count() add_preempt_count(1)
74220 +#define raw_inc_preempt_count() raw_add_preempt_count(1)
74221 #define dec_preempt_count() sub_preempt_count(1)
74222 +#define raw_dec_preempt_count() raw_sub_preempt_count(1)
74223
74224 #define preempt_count() (current_thread_info()->preempt_count)
74225
74226 @@ -64,6 +69,12 @@ do { \
74227 barrier(); \
74228 } while (0)
74229
74230 +#define raw_preempt_disable() \
74231 +do { \
74232 + raw_inc_preempt_count(); \
74233 + barrier(); \
74234 +} while (0)
74235 +
74236 #define sched_preempt_enable_no_resched() \
74237 do { \
74238 barrier(); \
74239 @@ -72,6 +83,12 @@ do { \
74240
74241 #define preempt_enable_no_resched() sched_preempt_enable_no_resched()
74242
74243 +#define raw_preempt_enable_no_resched() \
74244 +do { \
74245 + barrier(); \
74246 + raw_dec_preempt_count(); \
74247 +} while (0)
74248 +
74249 #define preempt_enable() \
74250 do { \
74251 preempt_enable_no_resched(); \
74252 @@ -116,8 +133,10 @@ do { \
74253 * region.
74254 */
74255 #define preempt_disable() barrier()
74256 +#define raw_preempt_disable() barrier()
74257 #define sched_preempt_enable_no_resched() barrier()
74258 #define preempt_enable_no_resched() barrier()
74259 +#define raw_preempt_enable_no_resched() barrier()
74260 #define preempt_enable() barrier()
74261
74262 #define preempt_disable_notrace() barrier()
74263 diff --git a/include/linux/printk.h b/include/linux/printk.h
74264 index 22c7052..ad3fa0a 100644
74265 --- a/include/linux/printk.h
74266 +++ b/include/linux/printk.h
74267 @@ -106,6 +106,8 @@ static inline __printf(1, 2) __cold
74268 void early_printk(const char *s, ...) { }
74269 #endif
74270
74271 +extern int kptr_restrict;
74272 +
74273 #ifdef CONFIG_PRINTK
74274 asmlinkage __printf(5, 0)
74275 int vprintk_emit(int facility, int level,
74276 @@ -140,7 +142,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
74277
74278 extern int printk_delay_msec;
74279 extern int dmesg_restrict;
74280 -extern int kptr_restrict;
74281
74282 extern void wake_up_klogd(void);
74283
74284 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
74285 index 608e60a..c26f864 100644
74286 --- a/include/linux/proc_fs.h
74287 +++ b/include/linux/proc_fs.h
74288 @@ -34,6 +34,19 @@ static inline struct proc_dir_entry *proc_create(
74289 return proc_create_data(name, mode, parent, proc_fops, NULL);
74290 }
74291
74292 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
74293 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
74294 +{
74295 +#ifdef CONFIG_GRKERNSEC_PROC_USER
74296 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
74297 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
74298 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
74299 +#else
74300 + return proc_create_data(name, mode, parent, proc_fops, NULL);
74301 +#endif
74302 +}
74303 +
74304 +
74305 extern void proc_set_size(struct proc_dir_entry *, loff_t);
74306 extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
74307 extern void *PDE_DATA(const struct inode *);
74308 diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
74309 index 34a1e10..03a6d03 100644
74310 --- a/include/linux/proc_ns.h
74311 +++ b/include/linux/proc_ns.h
74312 @@ -14,7 +14,7 @@ struct proc_ns_operations {
74313 void (*put)(void *ns);
74314 int (*install)(struct nsproxy *nsproxy, void *ns);
74315 unsigned int (*inum)(void *ns);
74316 -};
74317 +} __do_const;
74318
74319 struct proc_ns {
74320 void *ns;
74321 diff --git a/include/linux/random.h b/include/linux/random.h
74322 index 3b9377d..61b506a 100644
74323 --- a/include/linux/random.h
74324 +++ b/include/linux/random.h
74325 @@ -32,6 +32,11 @@ void prandom_seed(u32 seed);
74326 u32 prandom_u32_state(struct rnd_state *);
74327 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
74328
74329 +static inline unsigned long pax_get_random_long(void)
74330 +{
74331 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
74332 +}
74333 +
74334 /*
74335 * Handle minimum values for seeds
74336 */
74337 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
74338 index f4b1001..8ddb2b6 100644
74339 --- a/include/linux/rculist.h
74340 +++ b/include/linux/rculist.h
74341 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
74342 struct list_head *prev, struct list_head *next);
74343 #endif
74344
74345 +extern void __pax_list_add_rcu(struct list_head *new,
74346 + struct list_head *prev, struct list_head *next);
74347 +
74348 /**
74349 * list_add_rcu - add a new entry to rcu-protected list
74350 * @new: new entry to be added
74351 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
74352 __list_add_rcu(new, head, head->next);
74353 }
74354
74355 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
74356 +{
74357 + __pax_list_add_rcu(new, head, head->next);
74358 +}
74359 +
74360 /**
74361 * list_add_tail_rcu - add a new entry to rcu-protected list
74362 * @new: new entry to be added
74363 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
74364 __list_add_rcu(new, head->prev, head);
74365 }
74366
74367 +static inline void pax_list_add_tail_rcu(struct list_head *new,
74368 + struct list_head *head)
74369 +{
74370 + __pax_list_add_rcu(new, head->prev, head);
74371 +}
74372 +
74373 /**
74374 * list_del_rcu - deletes entry from list without re-initialization
74375 * @entry: the element to delete from the list.
74376 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
74377 entry->prev = LIST_POISON2;
74378 }
74379
74380 +extern void pax_list_del_rcu(struct list_head *entry);
74381 +
74382 /**
74383 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
74384 * @n: the element to delete from the hash list.
74385 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
74386 index 23b3630..e1bc12b 100644
74387 --- a/include/linux/reboot.h
74388 +++ b/include/linux/reboot.h
74389 @@ -18,9 +18,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
74390 * Architecture-specific implementations of sys_reboot commands.
74391 */
74392
74393 -extern void machine_restart(char *cmd);
74394 -extern void machine_halt(void);
74395 -extern void machine_power_off(void);
74396 +extern void machine_restart(char *cmd) __noreturn;
74397 +extern void machine_halt(void) __noreturn;
74398 +extern void machine_power_off(void) __noreturn;
74399
74400 extern void machine_shutdown(void);
74401 struct pt_regs;
74402 @@ -31,9 +31,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
74403 */
74404
74405 extern void kernel_restart_prepare(char *cmd);
74406 -extern void kernel_restart(char *cmd);
74407 -extern void kernel_halt(void);
74408 -extern void kernel_power_off(void);
74409 +extern void kernel_restart(char *cmd) __noreturn;
74410 +extern void kernel_halt(void) __noreturn;
74411 +extern void kernel_power_off(void) __noreturn;
74412
74413 extern int C_A_D; /* for sysctl */
74414 void ctrl_alt_del(void);
74415 @@ -47,7 +47,7 @@ extern int orderly_poweroff(bool force);
74416 * Emergency restart, callable from an interrupt handler.
74417 */
74418
74419 -extern void emergency_restart(void);
74420 +extern void emergency_restart(void) __noreturn;
74421 #include <asm/emergency-restart.h>
74422
74423 #endif /* _LINUX_REBOOT_H */
74424 diff --git a/include/linux/regset.h b/include/linux/regset.h
74425 index 8e0c9fe..ac4d221 100644
74426 --- a/include/linux/regset.h
74427 +++ b/include/linux/regset.h
74428 @@ -161,7 +161,8 @@ struct user_regset {
74429 unsigned int align;
74430 unsigned int bias;
74431 unsigned int core_note_type;
74432 -};
74433 +} __do_const;
74434 +typedef struct user_regset __no_const user_regset_no_const;
74435
74436 /**
74437 * struct user_regset_view - available regsets
74438 diff --git a/include/linux/relay.h b/include/linux/relay.h
74439 index d7c8359..818daf5 100644
74440 --- a/include/linux/relay.h
74441 +++ b/include/linux/relay.h
74442 @@ -157,7 +157,7 @@ struct rchan_callbacks
74443 * The callback should return 0 if successful, negative if not.
74444 */
74445 int (*remove_buf_file)(struct dentry *dentry);
74446 -};
74447 +} __no_const;
74448
74449 /*
74450 * CONFIG_RELAY kernel API, kernel/relay.c
74451 diff --git a/include/linux/rio.h b/include/linux/rio.h
74452 index 18e0993..8ab5b21 100644
74453 --- a/include/linux/rio.h
74454 +++ b/include/linux/rio.h
74455 @@ -345,7 +345,7 @@ struct rio_ops {
74456 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
74457 u64 rstart, u32 size, u32 flags);
74458 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
74459 -};
74460 +} __no_const;
74461
74462 #define RIO_RESOURCE_MEM 0x00000100
74463 #define RIO_RESOURCE_DOORBELL 0x00000200
74464 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
74465 index 6dacb93..6174423 100644
74466 --- a/include/linux/rmap.h
74467 +++ b/include/linux/rmap.h
74468 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
74469 void anon_vma_init(void); /* create anon_vma_cachep */
74470 int anon_vma_prepare(struct vm_area_struct *);
74471 void unlink_anon_vmas(struct vm_area_struct *);
74472 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
74473 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
74474 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
74475 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
74476
74477 static inline void anon_vma_merge(struct vm_area_struct *vma,
74478 struct vm_area_struct *next)
74479 diff --git a/include/linux/sched.h b/include/linux/sched.h
74480 index 3aeb14b..73816a6 100644
74481 --- a/include/linux/sched.h
74482 +++ b/include/linux/sched.h
74483 @@ -62,6 +62,7 @@ struct bio_list;
74484 struct fs_struct;
74485 struct perf_event_context;
74486 struct blk_plug;
74487 +struct linux_binprm;
74488
74489 /*
74490 * List of flags we want to share for kernel threads,
74491 @@ -303,7 +304,7 @@ extern char __sched_text_start[], __sched_text_end[];
74492 extern int in_sched_functions(unsigned long addr);
74493
74494 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
74495 -extern signed long schedule_timeout(signed long timeout);
74496 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
74497 extern signed long schedule_timeout_interruptible(signed long timeout);
74498 extern signed long schedule_timeout_killable(signed long timeout);
74499 extern signed long schedule_timeout_uninterruptible(signed long timeout);
74500 @@ -314,7 +315,19 @@ struct nsproxy;
74501 struct user_namespace;
74502
74503 #ifdef CONFIG_MMU
74504 -extern unsigned long mmap_legacy_base(void);
74505 +
74506 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
74507 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
74508 +#else
74509 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
74510 +{
74511 + return 0;
74512 +}
74513 +#endif
74514 +
74515 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
74516 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
74517 +extern unsigned long mmap_legacy_base(struct mm_struct *mm);
74518 extern void arch_pick_mmap_layout(struct mm_struct *mm);
74519 extern unsigned long
74520 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
74521 @@ -592,6 +605,17 @@ struct signal_struct {
74522 #ifdef CONFIG_TASKSTATS
74523 struct taskstats *stats;
74524 #endif
74525 +
74526 +#ifdef CONFIG_GRKERNSEC
74527 + u32 curr_ip;
74528 + u32 saved_ip;
74529 + u32 gr_saddr;
74530 + u32 gr_daddr;
74531 + u16 gr_sport;
74532 + u16 gr_dport;
74533 + u8 used_accept:1;
74534 +#endif
74535 +
74536 #ifdef CONFIG_AUDIT
74537 unsigned audit_tty;
74538 unsigned audit_tty_log_passwd;
74539 @@ -672,6 +696,14 @@ struct user_struct {
74540 struct key *session_keyring; /* UID's default session keyring */
74541 #endif
74542
74543 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
74544 + unsigned char kernel_banned;
74545 +#endif
74546 +#ifdef CONFIG_GRKERNSEC_BRUTE
74547 + unsigned char suid_banned;
74548 + unsigned long suid_ban_expires;
74549 +#endif
74550 +
74551 /* Hash table maintenance information */
74552 struct hlist_node uidhash_node;
74553 kuid_t uid;
74554 @@ -1159,8 +1191,8 @@ struct task_struct {
74555 struct list_head thread_group;
74556
74557 struct completion *vfork_done; /* for vfork() */
74558 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
74559 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
74560 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
74561 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
74562
74563 cputime_t utime, stime, utimescaled, stimescaled;
74564 cputime_t gtime;
74565 @@ -1185,11 +1217,6 @@ struct task_struct {
74566 struct task_cputime cputime_expires;
74567 struct list_head cpu_timers[3];
74568
74569 -/* process credentials */
74570 - const struct cred __rcu *real_cred; /* objective and real subjective task
74571 - * credentials (COW) */
74572 - const struct cred __rcu *cred; /* effective (overridable) subjective task
74573 - * credentials (COW) */
74574 char comm[TASK_COMM_LEN]; /* executable name excluding path
74575 - access with [gs]et_task_comm (which lock
74576 it with task_lock())
74577 @@ -1206,6 +1233,10 @@ struct task_struct {
74578 #endif
74579 /* CPU-specific state of this task */
74580 struct thread_struct thread;
74581 +/* thread_info moved to task_struct */
74582 +#ifdef CONFIG_X86
74583 + struct thread_info tinfo;
74584 +#endif
74585 /* filesystem information */
74586 struct fs_struct *fs;
74587 /* open file information */
74588 @@ -1279,6 +1310,10 @@ struct task_struct {
74589 gfp_t lockdep_reclaim_gfp;
74590 #endif
74591
74592 +/* process credentials */
74593 + const struct cred __rcu *real_cred; /* objective and real subjective task
74594 + * credentials (COW) */
74595 +
74596 /* journalling filesystem info */
74597 void *journal_info;
74598
74599 @@ -1317,6 +1352,10 @@ struct task_struct {
74600 /* cg_list protected by css_set_lock and tsk->alloc_lock */
74601 struct list_head cg_list;
74602 #endif
74603 +
74604 + const struct cred __rcu *cred; /* effective (overridable) subjective task
74605 + * credentials (COW) */
74606 +
74607 #ifdef CONFIG_FUTEX
74608 struct robust_list_head __user *robust_list;
74609 #ifdef CONFIG_COMPAT
74610 @@ -1417,8 +1456,76 @@ struct task_struct {
74611 unsigned int sequential_io;
74612 unsigned int sequential_io_avg;
74613 #endif
74614 +
74615 +#ifdef CONFIG_GRKERNSEC
74616 + /* grsecurity */
74617 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
74618 + u64 exec_id;
74619 +#endif
74620 +#ifdef CONFIG_GRKERNSEC_SETXID
74621 + const struct cred *delayed_cred;
74622 +#endif
74623 + struct dentry *gr_chroot_dentry;
74624 + struct acl_subject_label *acl;
74625 + struct acl_role_label *role;
74626 + struct file *exec_file;
74627 + unsigned long brute_expires;
74628 + u16 acl_role_id;
74629 + /* is this the task that authenticated to the special role */
74630 + u8 acl_sp_role;
74631 + u8 is_writable;
74632 + u8 brute;
74633 + u8 gr_is_chrooted;
74634 +#endif
74635 +
74636 };
74637
74638 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
74639 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
74640 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
74641 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
74642 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
74643 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
74644 +
74645 +#ifdef CONFIG_PAX_SOFTMODE
74646 +extern int pax_softmode;
74647 +#endif
74648 +
74649 +extern int pax_check_flags(unsigned long *);
74650 +
74651 +/* if tsk != current then task_lock must be held on it */
74652 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
74653 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
74654 +{
74655 + if (likely(tsk->mm))
74656 + return tsk->mm->pax_flags;
74657 + else
74658 + return 0UL;
74659 +}
74660 +
74661 +/* if tsk != current then task_lock must be held on it */
74662 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
74663 +{
74664 + if (likely(tsk->mm)) {
74665 + tsk->mm->pax_flags = flags;
74666 + return 0;
74667 + }
74668 + return -EINVAL;
74669 +}
74670 +#endif
74671 +
74672 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
74673 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
74674 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
74675 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
74676 +#endif
74677 +
74678 +struct path;
74679 +extern char *pax_get_path(const struct path *path, char *buf, int buflen);
74680 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
74681 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
74682 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
74683 +
74684 /* Future-safe accessor for struct task_struct's cpus_allowed. */
74685 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
74686
74687 @@ -1477,7 +1584,7 @@ struct pid_namespace;
74688 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
74689 struct pid_namespace *ns);
74690
74691 -static inline pid_t task_pid_nr(struct task_struct *tsk)
74692 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
74693 {
74694 return tsk->pid;
74695 }
74696 @@ -1920,7 +2027,9 @@ void yield(void);
74697 extern struct exec_domain default_exec_domain;
74698
74699 union thread_union {
74700 +#ifndef CONFIG_X86
74701 struct thread_info thread_info;
74702 +#endif
74703 unsigned long stack[THREAD_SIZE/sizeof(long)];
74704 };
74705
74706 @@ -1953,6 +2062,7 @@ extern struct pid_namespace init_pid_ns;
74707 */
74708
74709 extern struct task_struct *find_task_by_vpid(pid_t nr);
74710 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
74711 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
74712 struct pid_namespace *ns);
74713
74714 @@ -2119,7 +2229,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
74715 extern void exit_itimers(struct signal_struct *);
74716 extern void flush_itimer_signals(void);
74717
74718 -extern void do_group_exit(int);
74719 +extern __noreturn void do_group_exit(int);
74720
74721 extern int allow_signal(int);
74722 extern int disallow_signal(int);
74723 @@ -2310,9 +2420,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
74724
74725 #endif
74726
74727 -static inline int object_is_on_stack(void *obj)
74728 +static inline int object_starts_on_stack(void *obj)
74729 {
74730 - void *stack = task_stack_page(current);
74731 + const void *stack = task_stack_page(current);
74732
74733 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
74734 }
74735 diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
74736 index bf8086b..962b035 100644
74737 --- a/include/linux/sched/sysctl.h
74738 +++ b/include/linux/sched/sysctl.h
74739 @@ -30,6 +30,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };
74740 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
74741
74742 extern int sysctl_max_map_count;
74743 +extern unsigned long sysctl_heap_stack_gap;
74744
74745 extern unsigned int sysctl_sched_latency;
74746 extern unsigned int sysctl_sched_min_granularity;
74747 diff --git a/include/linux/security.h b/include/linux/security.h
74748 index 4686491..2bd210e 100644
74749 --- a/include/linux/security.h
74750 +++ b/include/linux/security.h
74751 @@ -26,6 +26,7 @@
74752 #include <linux/capability.h>
74753 #include <linux/slab.h>
74754 #include <linux/err.h>
74755 +#include <linux/grsecurity.h>
74756
74757 struct linux_binprm;
74758 struct cred;
74759 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
74760 index 2da29ac..aac448ec 100644
74761 --- a/include/linux/seq_file.h
74762 +++ b/include/linux/seq_file.h
74763 @@ -26,6 +26,9 @@ struct seq_file {
74764 struct mutex lock;
74765 const struct seq_operations *op;
74766 int poll_event;
74767 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
74768 + u64 exec_id;
74769 +#endif
74770 #ifdef CONFIG_USER_NS
74771 struct user_namespace *user_ns;
74772 #endif
74773 @@ -38,6 +41,7 @@ struct seq_operations {
74774 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
74775 int (*show) (struct seq_file *m, void *v);
74776 };
74777 +typedef struct seq_operations __no_const seq_operations_no_const;
74778
74779 #define SEQ_SKIP 1
74780
74781 diff --git a/include/linux/shm.h b/include/linux/shm.h
74782 index 429c199..4d42e38 100644
74783 --- a/include/linux/shm.h
74784 +++ b/include/linux/shm.h
74785 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
74786
74787 /* The task created the shm object. NULL if the task is dead. */
74788 struct task_struct *shm_creator;
74789 +#ifdef CONFIG_GRKERNSEC
74790 + time_t shm_createtime;
74791 + pid_t shm_lapid;
74792 +#endif
74793 };
74794
74795 /* shm_mode upper byte flags */
74796 diff --git a/include/linux/signal.h b/include/linux/signal.h
74797 index d897484..323ba98 100644
74798 --- a/include/linux/signal.h
74799 +++ b/include/linux/signal.h
74800 @@ -433,6 +433,7 @@ void signals_init(void);
74801
74802 int restore_altstack(const stack_t __user *);
74803 int __save_altstack(stack_t __user *, unsigned long);
74804 +void __save_altstack_ex(stack_t __user *, unsigned long);
74805
74806 #ifdef CONFIG_PROC_FS
74807 struct seq_file;
74808 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
74809 index dec1748..112c1f9 100644
74810 --- a/include/linux/skbuff.h
74811 +++ b/include/linux/skbuff.h
74812 @@ -640,7 +640,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
74813 extern struct sk_buff *__alloc_skb(unsigned int size,
74814 gfp_t priority, int flags, int node);
74815 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
74816 -static inline struct sk_buff *alloc_skb(unsigned int size,
74817 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
74818 gfp_t priority)
74819 {
74820 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
74821 @@ -756,7 +756,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
74822 */
74823 static inline int skb_queue_empty(const struct sk_buff_head *list)
74824 {
74825 - return list->next == (struct sk_buff *)list;
74826 + return list->next == (const struct sk_buff *)list;
74827 }
74828
74829 /**
74830 @@ -769,7 +769,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
74831 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
74832 const struct sk_buff *skb)
74833 {
74834 - return skb->next == (struct sk_buff *)list;
74835 + return skb->next == (const struct sk_buff *)list;
74836 }
74837
74838 /**
74839 @@ -782,7 +782,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
74840 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
74841 const struct sk_buff *skb)
74842 {
74843 - return skb->prev == (struct sk_buff *)list;
74844 + return skb->prev == (const struct sk_buff *)list;
74845 }
74846
74847 /**
74848 @@ -1848,7 +1848,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
74849 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
74850 */
74851 #ifndef NET_SKB_PAD
74852 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
74853 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
74854 #endif
74855
74856 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
74857 @@ -2443,7 +2443,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
74858 int noblock, int *err);
74859 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
74860 struct poll_table_struct *wait);
74861 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
74862 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
74863 int offset, struct iovec *to,
74864 int size);
74865 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
74866 @@ -2733,6 +2733,9 @@ static inline void nf_reset(struct sk_buff *skb)
74867 nf_bridge_put(skb->nf_bridge);
74868 skb->nf_bridge = NULL;
74869 #endif
74870 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
74871 + skb->nf_trace = 0;
74872 +#endif
74873 }
74874
74875 static inline void nf_reset_trace(struct sk_buff *skb)
74876 diff --git a/include/linux/slab.h b/include/linux/slab.h
74877 index 0c62175..f016ac1 100644
74878 --- a/include/linux/slab.h
74879 +++ b/include/linux/slab.h
74880 @@ -12,15 +12,29 @@
74881 #include <linux/gfp.h>
74882 #include <linux/types.h>
74883 #include <linux/workqueue.h>
74884 -
74885 +#include <linux/err.h>
74886
74887 /*
74888 * Flags to pass to kmem_cache_create().
74889 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
74890 */
74891 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
74892 +
74893 +#ifdef CONFIG_PAX_USERCOPY_SLABS
74894 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
74895 +#else
74896 +#define SLAB_USERCOPY 0x00000000UL
74897 +#endif
74898 +
74899 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
74900 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
74901 +
74902 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
74903 +#define SLAB_NO_SANITIZE 0x00001000UL /* PaX: Do not sanitize objs on free */
74904 +#else
74905 +#define SLAB_NO_SANITIZE 0x00000000UL
74906 +#endif
74907 +
74908 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
74909 #define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */
74910 #define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */
74911 @@ -89,10 +103,13 @@
74912 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
74913 * Both make kfree a no-op.
74914 */
74915 -#define ZERO_SIZE_PTR ((void *)16)
74916 +#define ZERO_SIZE_PTR \
74917 +({ \
74918 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
74919 + (void *)(-MAX_ERRNO-1L); \
74920 +})
74921
74922 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
74923 - (unsigned long)ZERO_SIZE_PTR)
74924 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
74925
74926
74927 struct mem_cgroup;
74928 @@ -132,6 +149,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
74929 void kfree(const void *);
74930 void kzfree(const void *);
74931 size_t ksize(const void *);
74932 +const char *check_heap_object(const void *ptr, unsigned long n);
74933 +bool is_usercopy_object(const void *ptr);
74934
74935 /*
74936 * Some archs want to perform DMA into kmalloc caches and need a guaranteed
74937 @@ -164,7 +183,7 @@ struct kmem_cache {
74938 unsigned int align; /* Alignment as calculated */
74939 unsigned long flags; /* Active flags on the slab */
74940 const char *name; /* Slab name for sysfs */
74941 - int refcount; /* Use counter */
74942 + atomic_t refcount; /* Use counter */
74943 void (*ctor)(void *); /* Called on object slot creation */
74944 struct list_head list; /* List of all slab caches on the system */
74945 };
74946 @@ -226,6 +245,10 @@ extern struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];
74947 extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
74948 #endif
74949
74950 +#ifdef CONFIG_PAX_USERCOPY_SLABS
74951 +extern struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
74952 +#endif
74953 +
74954 /*
74955 * Figure out which kmalloc slab an allocation of a certain size
74956 * belongs to.
74957 @@ -234,7 +257,7 @@ extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
74958 * 2 = 120 .. 192 bytes
74959 * n = 2^(n-1) .. 2^n -1
74960 */
74961 -static __always_inline int kmalloc_index(size_t size)
74962 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
74963 {
74964 if (!size)
74965 return 0;
74966 @@ -406,6 +429,7 @@ void print_slabinfo_header(struct seq_file *m);
74967 * for general use, and so are not documented here. For a full list of
74968 * potential flags, always refer to linux/gfp.h.
74969 */
74970 +
74971 static inline void *kmalloc_array(size_t n, size_t size, gfp_t flags)
74972 {
74973 if (size != 0 && n > SIZE_MAX / size)
74974 @@ -465,7 +489,7 @@ static inline void *kmem_cache_alloc_node(struct kmem_cache *cachep,
74975 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
74976 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
74977 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
74978 -extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
74979 +extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long) __size_overflow(1);
74980 #define kmalloc_track_caller(size, flags) \
74981 __kmalloc_track_caller(size, flags, _RET_IP_)
74982 #else
74983 @@ -485,7 +509,7 @@ extern void *__kmalloc_track_caller(size_t, gfp_t, unsigned long);
74984 #if defined(CONFIG_DEBUG_SLAB) || defined(CONFIG_SLUB) || \
74985 (defined(CONFIG_SLAB) && defined(CONFIG_TRACING)) || \
74986 (defined(CONFIG_SLOB) && defined(CONFIG_TRACING))
74987 -extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long);
74988 +extern void *__kmalloc_node_track_caller(size_t, gfp_t, int, unsigned long) __size_overflow(1);
74989 #define kmalloc_node_track_caller(size, flags, node) \
74990 __kmalloc_node_track_caller(size, flags, node, \
74991 _RET_IP_)
74992 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
74993 index cd40158..4e2f7af 100644
74994 --- a/include/linux/slab_def.h
74995 +++ b/include/linux/slab_def.h
74996 @@ -50,7 +50,7 @@ struct kmem_cache {
74997 /* 4) cache creation/removal */
74998 const char *name;
74999 struct list_head list;
75000 - int refcount;
75001 + atomic_t refcount;
75002 int object_size;
75003 int align;
75004
75005 @@ -66,10 +66,14 @@ struct kmem_cache {
75006 unsigned long node_allocs;
75007 unsigned long node_frees;
75008 unsigned long node_overflow;
75009 - atomic_t allochit;
75010 - atomic_t allocmiss;
75011 - atomic_t freehit;
75012 - atomic_t freemiss;
75013 + atomic_unchecked_t allochit;
75014 + atomic_unchecked_t allocmiss;
75015 + atomic_unchecked_t freehit;
75016 + atomic_unchecked_t freemiss;
75017 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
75018 + atomic_unchecked_t sanitized;
75019 + atomic_unchecked_t not_sanitized;
75020 +#endif
75021
75022 /*
75023 * If debugging is enabled, then the allocator can add additional
75024 @@ -103,7 +107,7 @@ struct kmem_cache {
75025 };
75026
75027 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
75028 -void *__kmalloc(size_t size, gfp_t flags);
75029 +void *__kmalloc(size_t size, gfp_t flags) __size_overflow(1);
75030
75031 #ifdef CONFIG_TRACING
75032 extern void *kmem_cache_alloc_trace(struct kmem_cache *, gfp_t, size_t);
75033 @@ -136,6 +140,13 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
75034 cachep = kmalloc_dma_caches[i];
75035 else
75036 #endif
75037 +
75038 +#ifdef CONFIG_PAX_USERCOPY_SLABS
75039 + if (flags & GFP_USERCOPY)
75040 + cachep = kmalloc_usercopy_caches[i];
75041 + else
75042 +#endif
75043 +
75044 cachep = kmalloc_caches[i];
75045
75046 ret = kmem_cache_alloc_trace(cachep, flags, size);
75047 @@ -146,7 +157,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
75048 }
75049
75050 #ifdef CONFIG_NUMA
75051 -extern void *__kmalloc_node(size_t size, gfp_t flags, int node);
75052 +extern void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
75053 extern void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
75054
75055 #ifdef CONFIG_TRACING
75056 @@ -185,6 +196,13 @@ static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
75057 cachep = kmalloc_dma_caches[i];
75058 else
75059 #endif
75060 +
75061 +#ifdef CONFIG_PAX_USERCOPY_SLABS
75062 + if (flags & GFP_USERCOPY)
75063 + cachep = kmalloc_usercopy_caches[i];
75064 + else
75065 +#endif
75066 +
75067 cachep = kmalloc_caches[i];
75068
75069 return kmem_cache_alloc_node_trace(cachep, flags, node, size);
75070 diff --git a/include/linux/slob_def.h b/include/linux/slob_def.h
75071 index f28e14a..7831211 100644
75072 --- a/include/linux/slob_def.h
75073 +++ b/include/linux/slob_def.h
75074 @@ -11,7 +11,7 @@ static __always_inline void *kmem_cache_alloc(struct kmem_cache *cachep,
75075 return kmem_cache_alloc_node(cachep, flags, NUMA_NO_NODE);
75076 }
75077
75078 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
75079 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
75080
75081 static __always_inline void *kmalloc_node(size_t size, gfp_t flags, int node)
75082 {
75083 @@ -31,7 +31,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
75084 return __kmalloc_node(size, flags, NUMA_NO_NODE);
75085 }
75086
75087 -static __always_inline void *__kmalloc(size_t size, gfp_t flags)
75088 +static __always_inline __size_overflow(1) void *__kmalloc(size_t size, gfp_t flags)
75089 {
75090 return kmalloc(size, flags);
75091 }
75092 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
75093 index 027276f..092bfe8 100644
75094 --- a/include/linux/slub_def.h
75095 +++ b/include/linux/slub_def.h
75096 @@ -80,7 +80,7 @@ struct kmem_cache {
75097 struct kmem_cache_order_objects max;
75098 struct kmem_cache_order_objects min;
75099 gfp_t allocflags; /* gfp flags to use on each alloc */
75100 - int refcount; /* Refcount for slab cache destroy */
75101 + atomic_t refcount; /* Refcount for slab cache destroy */
75102 void (*ctor)(void *);
75103 int inuse; /* Offset to metadata */
75104 int align; /* Alignment */
75105 @@ -105,7 +105,7 @@ struct kmem_cache {
75106 };
75107
75108 void *kmem_cache_alloc(struct kmem_cache *, gfp_t);
75109 -void *__kmalloc(size_t size, gfp_t flags);
75110 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1) __size_overflow(1);
75111
75112 static __always_inline void *
75113 kmalloc_order(size_t size, gfp_t flags, unsigned int order)
75114 @@ -149,7 +149,7 @@ kmalloc_order_trace(size_t size, gfp_t flags, unsigned int order)
75115 }
75116 #endif
75117
75118 -static __always_inline void *kmalloc_large(size_t size, gfp_t flags)
75119 +static __always_inline __size_overflow(1) void *kmalloc_large(size_t size, gfp_t flags)
75120 {
75121 unsigned int order = get_order(size);
75122 return kmalloc_order_trace(size, flags, order);
75123 @@ -175,7 +175,7 @@ static __always_inline void *kmalloc(size_t size, gfp_t flags)
75124 }
75125
75126 #ifdef CONFIG_NUMA
75127 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
75128 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __size_overflow(1);
75129 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
75130
75131 #ifdef CONFIG_TRACING
75132 diff --git a/include/linux/smp.h b/include/linux/smp.h
75133 index c848876..11e8a84 100644
75134 --- a/include/linux/smp.h
75135 +++ b/include/linux/smp.h
75136 @@ -221,7 +221,9 @@ static inline void kick_all_cpus_sync(void) { }
75137 #endif
75138
75139 #define get_cpu() ({ preempt_disable(); smp_processor_id(); })
75140 +#define raw_get_cpu() ({ raw_preempt_disable(); raw_smp_processor_id(); })
75141 #define put_cpu() preempt_enable()
75142 +#define raw_put_cpu_no_resched() raw_preempt_enable_no_resched()
75143
75144 /*
75145 * Callback to arch code if there's nosmp or maxcpus=0 on the
75146 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
75147 index 54f91d3..be2c379 100644
75148 --- a/include/linux/sock_diag.h
75149 +++ b/include/linux/sock_diag.h
75150 @@ -11,7 +11,7 @@ struct sock;
75151 struct sock_diag_handler {
75152 __u8 family;
75153 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
75154 -};
75155 +} __do_const;
75156
75157 int sock_diag_register(const struct sock_diag_handler *h);
75158 void sock_diag_unregister(const struct sock_diag_handler *h);
75159 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
75160 index 680f9a3..f13aeb0 100644
75161 --- a/include/linux/sonet.h
75162 +++ b/include/linux/sonet.h
75163 @@ -7,7 +7,7 @@
75164 #include <uapi/linux/sonet.h>
75165
75166 struct k_sonet_stats {
75167 -#define __HANDLE_ITEM(i) atomic_t i
75168 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
75169 __SONET_ITEMS
75170 #undef __HANDLE_ITEM
75171 };
75172 diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
75173 index 07d8e53..dc934c9 100644
75174 --- a/include/linux/sunrpc/addr.h
75175 +++ b/include/linux/sunrpc/addr.h
75176 @@ -23,9 +23,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
75177 {
75178 switch (sap->sa_family) {
75179 case AF_INET:
75180 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
75181 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
75182 case AF_INET6:
75183 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
75184 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
75185 }
75186 return 0;
75187 }
75188 @@ -58,7 +58,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
75189 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
75190 const struct sockaddr *src)
75191 {
75192 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
75193 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
75194 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
75195
75196 dsin->sin_family = ssin->sin_family;
75197 @@ -164,7 +164,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
75198 if (sa->sa_family != AF_INET6)
75199 return 0;
75200
75201 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
75202 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
75203 }
75204
75205 #endif /* _LINUX_SUNRPC_ADDR_H */
75206 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
75207 index bfe11be..12bc8c4 100644
75208 --- a/include/linux/sunrpc/clnt.h
75209 +++ b/include/linux/sunrpc/clnt.h
75210 @@ -96,7 +96,7 @@ struct rpc_procinfo {
75211 unsigned int p_timer; /* Which RTT timer to use */
75212 u32 p_statidx; /* Which procedure to account */
75213 const char * p_name; /* name of procedure */
75214 -};
75215 +} __do_const;
75216
75217 #ifdef __KERNEL__
75218
75219 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
75220 index 1f0216b..6a4fa50 100644
75221 --- a/include/linux/sunrpc/svc.h
75222 +++ b/include/linux/sunrpc/svc.h
75223 @@ -411,7 +411,7 @@ struct svc_procedure {
75224 unsigned int pc_count; /* call count */
75225 unsigned int pc_cachetype; /* cache info (NFS) */
75226 unsigned int pc_xdrressize; /* maximum size of XDR reply */
75227 -};
75228 +} __do_const;
75229
75230 /*
75231 * Function prototypes.
75232 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
75233 index 0b8e3e6..33e0a01 100644
75234 --- a/include/linux/sunrpc/svc_rdma.h
75235 +++ b/include/linux/sunrpc/svc_rdma.h
75236 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
75237 extern unsigned int svcrdma_max_requests;
75238 extern unsigned int svcrdma_max_req_size;
75239
75240 -extern atomic_t rdma_stat_recv;
75241 -extern atomic_t rdma_stat_read;
75242 -extern atomic_t rdma_stat_write;
75243 -extern atomic_t rdma_stat_sq_starve;
75244 -extern atomic_t rdma_stat_rq_starve;
75245 -extern atomic_t rdma_stat_rq_poll;
75246 -extern atomic_t rdma_stat_rq_prod;
75247 -extern atomic_t rdma_stat_sq_poll;
75248 -extern atomic_t rdma_stat_sq_prod;
75249 +extern atomic_unchecked_t rdma_stat_recv;
75250 +extern atomic_unchecked_t rdma_stat_read;
75251 +extern atomic_unchecked_t rdma_stat_write;
75252 +extern atomic_unchecked_t rdma_stat_sq_starve;
75253 +extern atomic_unchecked_t rdma_stat_rq_starve;
75254 +extern atomic_unchecked_t rdma_stat_rq_poll;
75255 +extern atomic_unchecked_t rdma_stat_rq_prod;
75256 +extern atomic_unchecked_t rdma_stat_sq_poll;
75257 +extern atomic_unchecked_t rdma_stat_sq_prod;
75258
75259 #define RPCRDMA_VERSION 1
75260
75261 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
75262 index ff374ab..7fd2ecb 100644
75263 --- a/include/linux/sunrpc/svcauth.h
75264 +++ b/include/linux/sunrpc/svcauth.h
75265 @@ -109,7 +109,7 @@ struct auth_ops {
75266 int (*release)(struct svc_rqst *rq);
75267 void (*domain_release)(struct auth_domain *);
75268 int (*set_client)(struct svc_rqst *rq);
75269 -};
75270 +} __do_const;
75271
75272 #define SVC_GARBAGE 1
75273 #define SVC_SYSERR 2
75274 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
75275 index a5ffd32..0935dea 100644
75276 --- a/include/linux/swiotlb.h
75277 +++ b/include/linux/swiotlb.h
75278 @@ -60,7 +60,8 @@ extern void
75279
75280 extern void
75281 swiotlb_free_coherent(struct device *hwdev, size_t size,
75282 - void *vaddr, dma_addr_t dma_handle);
75283 + void *vaddr, dma_addr_t dma_handle,
75284 + struct dma_attrs *attrs);
75285
75286 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
75287 unsigned long offset, size_t size,
75288 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
75289 index 84662ec..d8f8adb 100644
75290 --- a/include/linux/syscalls.h
75291 +++ b/include/linux/syscalls.h
75292 @@ -97,8 +97,12 @@ struct sigaltstack;
75293 #define __MAP(n,...) __MAP##n(__VA_ARGS__)
75294
75295 #define __SC_DECL(t, a) t a
75296 -#define __TYPE_IS_LL(t) (__same_type((t)0, 0LL) || __same_type((t)0, 0ULL))
75297 -#define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), 0LL, 0L)) a
75298 +#define __TYPE_IS_SL(t) (__same_type((t)0, 0L))
75299 +#define __TYPE_IS_UL(t) (__same_type((t)0, 0UL))
75300 +#define __TYPE_IS_SLL(t) (__same_type((t)0, 0LL))
75301 +#define __TYPE_IS_ULL(t) (__same_type((t)0, 0ULL))
75302 +#define __TYPE_IS_LL(t) (__TYPE_IS_SLL(t) || __TYPE_IS_ULL(t))
75303 +#define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), __builtin_choose_expr(__TYPE_IS_ULL(t), 0ULL, 0LL), __builtin_choose_expr(__TYPE_IS_UL(t), 0UL, 0L))) a
75304 #define __SC_CAST(t, a) (t) a
75305 #define __SC_ARGS(t, a) a
75306 #define __SC_TEST(t, a) (void)BUILD_BUG_ON_ZERO(!__TYPE_IS_LL(t) && sizeof(t) > sizeof(long))
75307 @@ -362,11 +366,11 @@ asmlinkage long sys_sync(void);
75308 asmlinkage long sys_fsync(unsigned int fd);
75309 asmlinkage long sys_fdatasync(unsigned int fd);
75310 asmlinkage long sys_bdflush(int func, long data);
75311 -asmlinkage long sys_mount(char __user *dev_name, char __user *dir_name,
75312 - char __user *type, unsigned long flags,
75313 +asmlinkage long sys_mount(const char __user *dev_name, const char __user *dir_name,
75314 + const char __user *type, unsigned long flags,
75315 void __user *data);
75316 -asmlinkage long sys_umount(char __user *name, int flags);
75317 -asmlinkage long sys_oldumount(char __user *name);
75318 +asmlinkage long sys_umount(const char __user *name, int flags);
75319 +asmlinkage long sys_oldumount(const char __user *name);
75320 asmlinkage long sys_truncate(const char __user *path, long length);
75321 asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
75322 asmlinkage long sys_stat(const char __user *filename,
75323 @@ -578,7 +582,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
75324 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
75325 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
75326 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
75327 - struct sockaddr __user *, int);
75328 + struct sockaddr __user *, int) __intentional_overflow(0);
75329 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
75330 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
75331 unsigned int vlen, unsigned flags);
75332 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
75333 index 27b3b0b..e093dd9 100644
75334 --- a/include/linux/syscore_ops.h
75335 +++ b/include/linux/syscore_ops.h
75336 @@ -16,7 +16,7 @@ struct syscore_ops {
75337 int (*suspend)(void);
75338 void (*resume)(void);
75339 void (*shutdown)(void);
75340 -};
75341 +} __do_const;
75342
75343 extern void register_syscore_ops(struct syscore_ops *ops);
75344 extern void unregister_syscore_ops(struct syscore_ops *ops);
75345 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
75346 index 14a8ff2..af52bad 100644
75347 --- a/include/linux/sysctl.h
75348 +++ b/include/linux/sysctl.h
75349 @@ -34,13 +34,13 @@ struct ctl_table_root;
75350 struct ctl_table_header;
75351 struct ctl_dir;
75352
75353 -typedef struct ctl_table ctl_table;
75354 -
75355 typedef int proc_handler (struct ctl_table *ctl, int write,
75356 void __user *buffer, size_t *lenp, loff_t *ppos);
75357
75358 extern int proc_dostring(struct ctl_table *, int,
75359 void __user *, size_t *, loff_t *);
75360 +extern int proc_dostring_modpriv(struct ctl_table *, int,
75361 + void __user *, size_t *, loff_t *);
75362 extern int proc_dointvec(struct ctl_table *, int,
75363 void __user *, size_t *, loff_t *);
75364 extern int proc_dointvec_minmax(struct ctl_table *, int,
75365 @@ -115,7 +115,9 @@ struct ctl_table
75366 struct ctl_table_poll *poll;
75367 void *extra1;
75368 void *extra2;
75369 -};
75370 +} __do_const;
75371 +typedef struct ctl_table __no_const ctl_table_no_const;
75372 +typedef struct ctl_table ctl_table;
75373
75374 struct ctl_node {
75375 struct rb_node node;
75376 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
75377 index e2cee22..3ddb921 100644
75378 --- a/include/linux/sysfs.h
75379 +++ b/include/linux/sysfs.h
75380 @@ -31,7 +31,8 @@ struct attribute {
75381 struct lock_class_key *key;
75382 struct lock_class_key skey;
75383 #endif
75384 -};
75385 +} __do_const;
75386 +typedef struct attribute __no_const attribute_no_const;
75387
75388 /**
75389 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
75390 @@ -59,8 +60,8 @@ struct attribute_group {
75391 umode_t (*is_visible)(struct kobject *,
75392 struct attribute *, int);
75393 struct attribute **attrs;
75394 -};
75395 -
75396 +} __do_const;
75397 +typedef struct attribute_group __no_const attribute_group_no_const;
75398
75399
75400 /**
75401 @@ -107,7 +108,8 @@ struct bin_attribute {
75402 char *, loff_t, size_t);
75403 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
75404 struct vm_area_struct *vma);
75405 -};
75406 +} __do_const;
75407 +typedef struct bin_attribute __no_const bin_attribute_no_const;
75408
75409 /**
75410 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
75411 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
75412 index 7faf933..9b85a0c 100644
75413 --- a/include/linux/sysrq.h
75414 +++ b/include/linux/sysrq.h
75415 @@ -16,6 +16,7 @@
75416
75417 #include <linux/errno.h>
75418 #include <linux/types.h>
75419 +#include <linux/compiler.h>
75420
75421 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
75422 #define SYSRQ_DEFAULT_ENABLE 1
75423 @@ -36,7 +37,7 @@ struct sysrq_key_op {
75424 char *help_msg;
75425 char *action_msg;
75426 int enable_mask;
75427 -};
75428 +} __do_const;
75429
75430 #ifdef CONFIG_MAGIC_SYSRQ
75431
75432 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
75433 index e7e0473..7989295 100644
75434 --- a/include/linux/thread_info.h
75435 +++ b/include/linux/thread_info.h
75436 @@ -148,6 +148,15 @@ static inline bool test_and_clear_restore_sigmask(void)
75437 #error "no set_restore_sigmask() provided and default one won't work"
75438 #endif
75439
75440 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
75441 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
75442 +{
75443 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
75444 + if (!__builtin_constant_p(n))
75445 +#endif
75446 + __check_object_size(ptr, n, to_user);
75447 +}
75448 +
75449 #endif /* __KERNEL__ */
75450
75451 #endif /* _LINUX_THREAD_INFO_H */
75452 diff --git a/include/linux/tty.h b/include/linux/tty.h
75453 index 8780bd2..d1ae08b 100644
75454 --- a/include/linux/tty.h
75455 +++ b/include/linux/tty.h
75456 @@ -194,7 +194,7 @@ struct tty_port {
75457 const struct tty_port_operations *ops; /* Port operations */
75458 spinlock_t lock; /* Lock protecting tty field */
75459 int blocked_open; /* Waiting to open */
75460 - int count; /* Usage count */
75461 + atomic_t count; /* Usage count */
75462 wait_queue_head_t open_wait; /* Open waiters */
75463 wait_queue_head_t close_wait; /* Close waiters */
75464 wait_queue_head_t delta_msr_wait; /* Modem status change */
75465 @@ -550,7 +550,7 @@ extern int tty_port_open(struct tty_port *port,
75466 struct tty_struct *tty, struct file *filp);
75467 static inline int tty_port_users(struct tty_port *port)
75468 {
75469 - return port->count + port->blocked_open;
75470 + return atomic_read(&port->count) + port->blocked_open;
75471 }
75472
75473 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
75474 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
75475 index 756a609..b302dd6 100644
75476 --- a/include/linux/tty_driver.h
75477 +++ b/include/linux/tty_driver.h
75478 @@ -285,7 +285,7 @@ struct tty_operations {
75479 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
75480 #endif
75481 const struct file_operations *proc_fops;
75482 -};
75483 +} __do_const;
75484
75485 struct tty_driver {
75486 int magic; /* magic number for this structure */
75487 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
75488 index 58390c7..95e214c 100644
75489 --- a/include/linux/tty_ldisc.h
75490 +++ b/include/linux/tty_ldisc.h
75491 @@ -146,7 +146,7 @@ struct tty_ldisc_ops {
75492
75493 struct module *owner;
75494
75495 - int refcount;
75496 + atomic_t refcount;
75497 };
75498
75499 struct tty_ldisc {
75500 diff --git a/include/linux/types.h b/include/linux/types.h
75501 index 4d118ba..c3ee9bf 100644
75502 --- a/include/linux/types.h
75503 +++ b/include/linux/types.h
75504 @@ -176,10 +176,26 @@ typedef struct {
75505 int counter;
75506 } atomic_t;
75507
75508 +#ifdef CONFIG_PAX_REFCOUNT
75509 +typedef struct {
75510 + int counter;
75511 +} atomic_unchecked_t;
75512 +#else
75513 +typedef atomic_t atomic_unchecked_t;
75514 +#endif
75515 +
75516 #ifdef CONFIG_64BIT
75517 typedef struct {
75518 long counter;
75519 } atomic64_t;
75520 +
75521 +#ifdef CONFIG_PAX_REFCOUNT
75522 +typedef struct {
75523 + long counter;
75524 +} atomic64_unchecked_t;
75525 +#else
75526 +typedef atomic64_t atomic64_unchecked_t;
75527 +#endif
75528 #endif
75529
75530 struct list_head {
75531 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
75532 index 5ca0951..ab496a5 100644
75533 --- a/include/linux/uaccess.h
75534 +++ b/include/linux/uaccess.h
75535 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
75536 long ret; \
75537 mm_segment_t old_fs = get_fs(); \
75538 \
75539 - set_fs(KERNEL_DS); \
75540 pagefault_disable(); \
75541 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
75542 - pagefault_enable(); \
75543 + set_fs(KERNEL_DS); \
75544 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
75545 set_fs(old_fs); \
75546 + pagefault_enable(); \
75547 ret; \
75548 })
75549
75550 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
75551 index 8e522cbc..aa8572d 100644
75552 --- a/include/linux/uidgid.h
75553 +++ b/include/linux/uidgid.h
75554 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
75555
75556 #endif /* CONFIG_USER_NS */
75557
75558 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
75559 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
75560 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
75561 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
75562 +
75563 #endif /* _LINUX_UIDGID_H */
75564 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
75565 index 99c1b4d..562e6f3 100644
75566 --- a/include/linux/unaligned/access_ok.h
75567 +++ b/include/linux/unaligned/access_ok.h
75568 @@ -4,34 +4,34 @@
75569 #include <linux/kernel.h>
75570 #include <asm/byteorder.h>
75571
75572 -static inline u16 get_unaligned_le16(const void *p)
75573 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
75574 {
75575 - return le16_to_cpup((__le16 *)p);
75576 + return le16_to_cpup((const __le16 *)p);
75577 }
75578
75579 -static inline u32 get_unaligned_le32(const void *p)
75580 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
75581 {
75582 - return le32_to_cpup((__le32 *)p);
75583 + return le32_to_cpup((const __le32 *)p);
75584 }
75585
75586 -static inline u64 get_unaligned_le64(const void *p)
75587 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
75588 {
75589 - return le64_to_cpup((__le64 *)p);
75590 + return le64_to_cpup((const __le64 *)p);
75591 }
75592
75593 -static inline u16 get_unaligned_be16(const void *p)
75594 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
75595 {
75596 - return be16_to_cpup((__be16 *)p);
75597 + return be16_to_cpup((const __be16 *)p);
75598 }
75599
75600 -static inline u32 get_unaligned_be32(const void *p)
75601 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
75602 {
75603 - return be32_to_cpup((__be32 *)p);
75604 + return be32_to_cpup((const __be32 *)p);
75605 }
75606
75607 -static inline u64 get_unaligned_be64(const void *p)
75608 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
75609 {
75610 - return be64_to_cpup((__be64 *)p);
75611 + return be64_to_cpup((const __be64 *)p);
75612 }
75613
75614 static inline void put_unaligned_le16(u16 val, void *p)
75615 diff --git a/include/linux/usb.h b/include/linux/usb.h
75616 index a0bee5a..5533a52 100644
75617 --- a/include/linux/usb.h
75618 +++ b/include/linux/usb.h
75619 @@ -552,7 +552,7 @@ struct usb_device {
75620 int maxchild;
75621
75622 u32 quirks;
75623 - atomic_t urbnum;
75624 + atomic_unchecked_t urbnum;
75625
75626 unsigned long active_duration;
75627
75628 @@ -1607,7 +1607,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
75629
75630 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
75631 __u8 request, __u8 requesttype, __u16 value, __u16 index,
75632 - void *data, __u16 size, int timeout);
75633 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
75634 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
75635 void *data, int len, int *actual_length, int timeout);
75636 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
75637 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
75638 index e452ba6..78f8e80 100644
75639 --- a/include/linux/usb/renesas_usbhs.h
75640 +++ b/include/linux/usb/renesas_usbhs.h
75641 @@ -39,7 +39,7 @@ enum {
75642 */
75643 struct renesas_usbhs_driver_callback {
75644 int (*notify_hotplug)(struct platform_device *pdev);
75645 -};
75646 +} __no_const;
75647
75648 /*
75649 * callback functions for platform
75650 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
75651 index 6f8fbcf..8259001 100644
75652 --- a/include/linux/vermagic.h
75653 +++ b/include/linux/vermagic.h
75654 @@ -25,9 +25,35 @@
75655 #define MODULE_ARCH_VERMAGIC ""
75656 #endif
75657
75658 +#ifdef CONFIG_PAX_REFCOUNT
75659 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
75660 +#else
75661 +#define MODULE_PAX_REFCOUNT ""
75662 +#endif
75663 +
75664 +#ifdef CONSTIFY_PLUGIN
75665 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
75666 +#else
75667 +#define MODULE_CONSTIFY_PLUGIN ""
75668 +#endif
75669 +
75670 +#ifdef STACKLEAK_PLUGIN
75671 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
75672 +#else
75673 +#define MODULE_STACKLEAK_PLUGIN ""
75674 +#endif
75675 +
75676 +#ifdef CONFIG_GRKERNSEC
75677 +#define MODULE_GRSEC "GRSEC "
75678 +#else
75679 +#define MODULE_GRSEC ""
75680 +#endif
75681 +
75682 #define VERMAGIC_STRING \
75683 UTS_RELEASE " " \
75684 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
75685 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
75686 - MODULE_ARCH_VERMAGIC
75687 + MODULE_ARCH_VERMAGIC \
75688 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
75689 + MODULE_GRSEC
75690
75691 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
75692 index 7d5773a..541c01c 100644
75693 --- a/include/linux/vmalloc.h
75694 +++ b/include/linux/vmalloc.h
75695 @@ -16,6 +16,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
75696 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
75697 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
75698 #define VM_UNLIST 0x00000020 /* vm_struct is not listed in vmlist */
75699 +
75700 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
75701 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
75702 +#endif
75703 +
75704 /* bits [20..32] reserved for arch specific ioremap internals */
75705
75706 /*
75707 @@ -75,7 +80,7 @@ extern void *vmalloc_32_user(unsigned long size);
75708 extern void *__vmalloc(unsigned long size, gfp_t gfp_mask, pgprot_t prot);
75709 extern void *__vmalloc_node_range(unsigned long size, unsigned long align,
75710 unsigned long start, unsigned long end, gfp_t gfp_mask,
75711 - pgprot_t prot, int node, const void *caller);
75712 + pgprot_t prot, int node, const void *caller) __size_overflow(1);
75713 extern void vfree(const void *addr);
75714
75715 extern void *vmap(struct page **pages, unsigned int count,
75716 @@ -137,8 +142,8 @@ extern struct vm_struct *alloc_vm_area(size_t size, pte_t **ptes);
75717 extern void free_vm_area(struct vm_struct *area);
75718
75719 /* for /dev/kmem */
75720 -extern long vread(char *buf, char *addr, unsigned long count);
75721 -extern long vwrite(char *buf, char *addr, unsigned long count);
75722 +extern long vread(char *buf, char *addr, unsigned long count) __size_overflow(3);
75723 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
75724
75725 /*
75726 * Internals. Dont't use..
75727 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
75728 index c586679..f06b389 100644
75729 --- a/include/linux/vmstat.h
75730 +++ b/include/linux/vmstat.h
75731 @@ -90,18 +90,18 @@ static inline void vm_events_fold_cpu(int cpu)
75732 /*
75733 * Zone based page accounting with per cpu differentials.
75734 */
75735 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
75736 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
75737
75738 static inline void zone_page_state_add(long x, struct zone *zone,
75739 enum zone_stat_item item)
75740 {
75741 - atomic_long_add(x, &zone->vm_stat[item]);
75742 - atomic_long_add(x, &vm_stat[item]);
75743 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
75744 + atomic_long_add_unchecked(x, &vm_stat[item]);
75745 }
75746
75747 static inline unsigned long global_page_state(enum zone_stat_item item)
75748 {
75749 - long x = atomic_long_read(&vm_stat[item]);
75750 + long x = atomic_long_read_unchecked(&vm_stat[item]);
75751 #ifdef CONFIG_SMP
75752 if (x < 0)
75753 x = 0;
75754 @@ -112,7 +112,7 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
75755 static inline unsigned long zone_page_state(struct zone *zone,
75756 enum zone_stat_item item)
75757 {
75758 - long x = atomic_long_read(&zone->vm_stat[item]);
75759 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
75760 #ifdef CONFIG_SMP
75761 if (x < 0)
75762 x = 0;
75763 @@ -129,7 +129,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
75764 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
75765 enum zone_stat_item item)
75766 {
75767 - long x = atomic_long_read(&zone->vm_stat[item]);
75768 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
75769
75770 #ifdef CONFIG_SMP
75771 int cpu;
75772 @@ -221,8 +221,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
75773
75774 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
75775 {
75776 - atomic_long_inc(&zone->vm_stat[item]);
75777 - atomic_long_inc(&vm_stat[item]);
75778 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
75779 + atomic_long_inc_unchecked(&vm_stat[item]);
75780 }
75781
75782 static inline void __inc_zone_page_state(struct page *page,
75783 @@ -233,8 +233,8 @@ static inline void __inc_zone_page_state(struct page *page,
75784
75785 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
75786 {
75787 - atomic_long_dec(&zone->vm_stat[item]);
75788 - atomic_long_dec(&vm_stat[item]);
75789 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
75790 + atomic_long_dec_unchecked(&vm_stat[item]);
75791 }
75792
75793 static inline void __dec_zone_page_state(struct page *page,
75794 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
75795 index fdbafc6..49dfe4f 100644
75796 --- a/include/linux/xattr.h
75797 +++ b/include/linux/xattr.h
75798 @@ -28,7 +28,7 @@ struct xattr_handler {
75799 size_t size, int handler_flags);
75800 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
75801 size_t size, int flags, int handler_flags);
75802 -};
75803 +} __do_const;
75804
75805 struct xattr {
75806 char *name;
75807 @@ -37,6 +37,9 @@ struct xattr {
75808 };
75809
75810 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
75811 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
75812 +ssize_t pax_getxattr(struct dentry *, void *, size_t);
75813 +#endif
75814 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
75815 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
75816 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
75817 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
75818 index 9c5a6b4..09c9438 100644
75819 --- a/include/linux/zlib.h
75820 +++ b/include/linux/zlib.h
75821 @@ -31,6 +31,7 @@
75822 #define _ZLIB_H
75823
75824 #include <linux/zconf.h>
75825 +#include <linux/compiler.h>
75826
75827 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
75828 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
75829 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
75830
75831 /* basic functions */
75832
75833 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
75834 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
75835 /*
75836 Returns the number of bytes that needs to be allocated for a per-
75837 stream workspace with the specified parameters. A pointer to this
75838 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
75839 index 95d1c91..6798cca 100644
75840 --- a/include/media/v4l2-dev.h
75841 +++ b/include/media/v4l2-dev.h
75842 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
75843 int (*mmap) (struct file *, struct vm_area_struct *);
75844 int (*open) (struct file *);
75845 int (*release) (struct file *);
75846 -};
75847 +} __do_const;
75848
75849 /*
75850 * Newer version of video_device, handled by videodev2.c
75851 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
75852 index adcbb20..62c2559 100644
75853 --- a/include/net/9p/transport.h
75854 +++ b/include/net/9p/transport.h
75855 @@ -57,7 +57,7 @@ struct p9_trans_module {
75856 int (*cancel) (struct p9_client *, struct p9_req_t *req);
75857 int (*zc_request)(struct p9_client *, struct p9_req_t *,
75858 char *, char *, int , int, int, int);
75859 -};
75860 +} __do_const;
75861
75862 void v9fs_register_trans(struct p9_trans_module *m);
75863 void v9fs_unregister_trans(struct p9_trans_module *m);
75864 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
75865 index fb94cf1..7c0c987 100644
75866 --- a/include/net/bluetooth/l2cap.h
75867 +++ b/include/net/bluetooth/l2cap.h
75868 @@ -551,7 +551,7 @@ struct l2cap_ops {
75869 void (*defer) (struct l2cap_chan *chan);
75870 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
75871 unsigned long len, int nb);
75872 -};
75873 +} __do_const;
75874
75875 struct l2cap_conn {
75876 struct hci_conn *hcon;
75877 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
75878 index f2ae33d..c457cf0 100644
75879 --- a/include/net/caif/cfctrl.h
75880 +++ b/include/net/caif/cfctrl.h
75881 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
75882 void (*radioset_rsp)(void);
75883 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
75884 struct cflayer *client_layer);
75885 -};
75886 +} __no_const;
75887
75888 /* Link Setup Parameters for CAIF-Links. */
75889 struct cfctrl_link_param {
75890 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
75891 struct cfctrl {
75892 struct cfsrvl serv;
75893 struct cfctrl_rsp res;
75894 - atomic_t req_seq_no;
75895 - atomic_t rsp_seq_no;
75896 + atomic_unchecked_t req_seq_no;
75897 + atomic_unchecked_t rsp_seq_no;
75898 struct list_head list;
75899 /* Protects from simultaneous access to first_req list */
75900 spinlock_t info_list_lock;
75901 diff --git a/include/net/flow.h b/include/net/flow.h
75902 index 628e11b..4c475df 100644
75903 --- a/include/net/flow.h
75904 +++ b/include/net/flow.h
75905 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
75906
75907 extern void flow_cache_flush(void);
75908 extern void flow_cache_flush_deferred(void);
75909 -extern atomic_t flow_cache_genid;
75910 +extern atomic_unchecked_t flow_cache_genid;
75911
75912 #endif
75913 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
75914 index 93024a4..eeb6b6e 100644
75915 --- a/include/net/genetlink.h
75916 +++ b/include/net/genetlink.h
75917 @@ -119,7 +119,7 @@ struct genl_ops {
75918 struct netlink_callback *cb);
75919 int (*done)(struct netlink_callback *cb);
75920 struct list_head ops_list;
75921 -};
75922 +} __do_const;
75923
75924 extern int genl_register_family(struct genl_family *family);
75925 extern int genl_register_family_with_ops(struct genl_family *family,
75926 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
75927 index 734d9b5..48a9a4b 100644
75928 --- a/include/net/gro_cells.h
75929 +++ b/include/net/gro_cells.h
75930 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
75931 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
75932
75933 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
75934 - atomic_long_inc(&dev->rx_dropped);
75935 + atomic_long_inc_unchecked(&dev->rx_dropped);
75936 kfree_skb(skb);
75937 return;
75938 }
75939 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
75940 index de2c785..0588a6b 100644
75941 --- a/include/net/inet_connection_sock.h
75942 +++ b/include/net/inet_connection_sock.h
75943 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
75944 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
75945 int (*bind_conflict)(const struct sock *sk,
75946 const struct inet_bind_bucket *tb, bool relax);
75947 -};
75948 +} __do_const;
75949
75950 /** inet_connection_sock - INET connection oriented sock
75951 *
75952 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
75953 index 53f464d..ba76aaa 100644
75954 --- a/include/net/inetpeer.h
75955 +++ b/include/net/inetpeer.h
75956 @@ -47,8 +47,8 @@ struct inet_peer {
75957 */
75958 union {
75959 struct {
75960 - atomic_t rid; /* Frag reception counter */
75961 - atomic_t ip_id_count; /* IP ID for the next packet */
75962 + atomic_unchecked_t rid; /* Frag reception counter */
75963 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
75964 };
75965 struct rcu_head rcu;
75966 struct inet_peer *gc_next;
75967 @@ -182,11 +182,11 @@ static inline int inet_getid(struct inet_peer *p, int more)
75968 more++;
75969 inet_peer_refcheck(p);
75970 do {
75971 - old = atomic_read(&p->ip_id_count);
75972 + old = atomic_read_unchecked(&p->ip_id_count);
75973 new = old + more;
75974 if (!new)
75975 new = 1;
75976 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
75977 + } while (atomic_cmpxchg_unchecked(&p->ip_id_count, old, new) != old);
75978 return new;
75979 }
75980
75981 diff --git a/include/net/ip.h b/include/net/ip.h
75982 index a68f838..74518ab 100644
75983 --- a/include/net/ip.h
75984 +++ b/include/net/ip.h
75985 @@ -202,7 +202,7 @@ extern struct local_ports {
75986 } sysctl_local_ports;
75987 extern void inet_get_local_port_range(int *low, int *high);
75988
75989 -extern unsigned long *sysctl_local_reserved_ports;
75990 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
75991 static inline int inet_is_reserved_local_port(int port)
75992 {
75993 return test_bit(port, sysctl_local_reserved_ports);
75994 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
75995 index e49db91..76a81de 100644
75996 --- a/include/net/ip_fib.h
75997 +++ b/include/net/ip_fib.h
75998 @@ -167,7 +167,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
75999
76000 #define FIB_RES_SADDR(net, res) \
76001 ((FIB_RES_NH(res).nh_saddr_genid == \
76002 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
76003 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
76004 FIB_RES_NH(res).nh_saddr : \
76005 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
76006 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
76007 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
76008 index 4c062cc..3562c31 100644
76009 --- a/include/net/ip_vs.h
76010 +++ b/include/net/ip_vs.h
76011 @@ -612,7 +612,7 @@ struct ip_vs_conn {
76012 struct ip_vs_conn *control; /* Master control connection */
76013 atomic_t n_control; /* Number of controlled ones */
76014 struct ip_vs_dest *dest; /* real server */
76015 - atomic_t in_pkts; /* incoming packet counter */
76016 + atomic_unchecked_t in_pkts; /* incoming packet counter */
76017
76018 /* packet transmitter for different forwarding methods. If it
76019 mangles the packet, it must return NF_DROP or better NF_STOLEN,
76020 @@ -761,7 +761,7 @@ struct ip_vs_dest {
76021 __be16 port; /* port number of the server */
76022 union nf_inet_addr addr; /* IP address of the server */
76023 volatile unsigned int flags; /* dest status flags */
76024 - atomic_t conn_flags; /* flags to copy to conn */
76025 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
76026 atomic_t weight; /* server weight */
76027
76028 atomic_t refcnt; /* reference counter */
76029 @@ -1013,11 +1013,11 @@ struct netns_ipvs {
76030 /* ip_vs_lblc */
76031 int sysctl_lblc_expiration;
76032 struct ctl_table_header *lblc_ctl_header;
76033 - struct ctl_table *lblc_ctl_table;
76034 + ctl_table_no_const *lblc_ctl_table;
76035 /* ip_vs_lblcr */
76036 int sysctl_lblcr_expiration;
76037 struct ctl_table_header *lblcr_ctl_header;
76038 - struct ctl_table *lblcr_ctl_table;
76039 + ctl_table_no_const *lblcr_ctl_table;
76040 /* ip_vs_est */
76041 struct list_head est_list; /* estimator list */
76042 spinlock_t est_lock;
76043 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
76044 index 80ffde3..968b0f4 100644
76045 --- a/include/net/irda/ircomm_tty.h
76046 +++ b/include/net/irda/ircomm_tty.h
76047 @@ -35,6 +35,7 @@
76048 #include <linux/termios.h>
76049 #include <linux/timer.h>
76050 #include <linux/tty.h> /* struct tty_struct */
76051 +#include <asm/local.h>
76052
76053 #include <net/irda/irias_object.h>
76054 #include <net/irda/ircomm_core.h>
76055 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
76056 index 714cc9a..ea05f3e 100644
76057 --- a/include/net/iucv/af_iucv.h
76058 +++ b/include/net/iucv/af_iucv.h
76059 @@ -149,7 +149,7 @@ struct iucv_skb_cb {
76060 struct iucv_sock_list {
76061 struct hlist_head head;
76062 rwlock_t lock;
76063 - atomic_t autobind_name;
76064 + atomic_unchecked_t autobind_name;
76065 };
76066
76067 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
76068 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
76069 index df83f69..9b640b8 100644
76070 --- a/include/net/llc_c_ac.h
76071 +++ b/include/net/llc_c_ac.h
76072 @@ -87,7 +87,7 @@
76073 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
76074 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
76075
76076 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
76077 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
76078
76079 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
76080 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
76081 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
76082 index 6ca3113..f8026dd 100644
76083 --- a/include/net/llc_c_ev.h
76084 +++ b/include/net/llc_c_ev.h
76085 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
76086 return (struct llc_conn_state_ev *)skb->cb;
76087 }
76088
76089 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
76090 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
76091 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
76092 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
76093
76094 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
76095 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
76096 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
76097 index 0e79cfb..f46db31 100644
76098 --- a/include/net/llc_c_st.h
76099 +++ b/include/net/llc_c_st.h
76100 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
76101 u8 next_state;
76102 llc_conn_ev_qfyr_t *ev_qualifiers;
76103 llc_conn_action_t *ev_actions;
76104 -};
76105 +} __do_const;
76106
76107 struct llc_conn_state {
76108 u8 current_state;
76109 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
76110 index 37a3bbd..55a4241 100644
76111 --- a/include/net/llc_s_ac.h
76112 +++ b/include/net/llc_s_ac.h
76113 @@ -23,7 +23,7 @@
76114 #define SAP_ACT_TEST_IND 9
76115
76116 /* All action functions must look like this */
76117 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
76118 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
76119
76120 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
76121 struct sk_buff *skb);
76122 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
76123 index 567c681..cd73ac0 100644
76124 --- a/include/net/llc_s_st.h
76125 +++ b/include/net/llc_s_st.h
76126 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
76127 llc_sap_ev_t ev;
76128 u8 next_state;
76129 llc_sap_action_t *ev_actions;
76130 -};
76131 +} __do_const;
76132
76133 struct llc_sap_state {
76134 u8 curr_state;
76135 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
76136 index 885898a..cdace34 100644
76137 --- a/include/net/mac80211.h
76138 +++ b/include/net/mac80211.h
76139 @@ -4205,7 +4205,7 @@ struct rate_control_ops {
76140 void (*add_sta_debugfs)(void *priv, void *priv_sta,
76141 struct dentry *dir);
76142 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
76143 -};
76144 +} __do_const;
76145
76146 static inline int rate_supported(struct ieee80211_sta *sta,
76147 enum ieee80211_band band,
76148 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
76149 index 7e748ad..5c6229b 100644
76150 --- a/include/net/neighbour.h
76151 +++ b/include/net/neighbour.h
76152 @@ -123,7 +123,7 @@ struct neigh_ops {
76153 void (*error_report)(struct neighbour *, struct sk_buff *);
76154 int (*output)(struct neighbour *, struct sk_buff *);
76155 int (*connected_output)(struct neighbour *, struct sk_buff *);
76156 -};
76157 +} __do_const;
76158
76159 struct pneigh_entry {
76160 struct pneigh_entry *next;
76161 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
76162 index b176978..ea169f4 100644
76163 --- a/include/net/net_namespace.h
76164 +++ b/include/net/net_namespace.h
76165 @@ -117,7 +117,7 @@ struct net {
76166 #endif
76167 struct netns_ipvs *ipvs;
76168 struct sock *diag_nlsk;
76169 - atomic_t rt_genid;
76170 + atomic_unchecked_t rt_genid;
76171 };
76172
76173 /*
76174 @@ -274,7 +274,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
76175 #define __net_init __init
76176 #define __net_exit __exit_refok
76177 #define __net_initdata __initdata
76178 +#ifdef CONSTIFY_PLUGIN
76179 #define __net_initconst __initconst
76180 +#else
76181 +#define __net_initconst __initdata
76182 +#endif
76183 #endif
76184
76185 struct pernet_operations {
76186 @@ -284,7 +288,7 @@ struct pernet_operations {
76187 void (*exit_batch)(struct list_head *net_exit_list);
76188 int *id;
76189 size_t size;
76190 -};
76191 +} __do_const;
76192
76193 /*
76194 * Use these carefully. If you implement a network device and it
76195 @@ -332,12 +336,12 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
76196
76197 static inline int rt_genid(struct net *net)
76198 {
76199 - return atomic_read(&net->rt_genid);
76200 + return atomic_read_unchecked(&net->rt_genid);
76201 }
76202
76203 static inline void rt_genid_bump(struct net *net)
76204 {
76205 - atomic_inc(&net->rt_genid);
76206 + atomic_inc_unchecked(&net->rt_genid);
76207 }
76208
76209 #endif /* __NET_NET_NAMESPACE_H */
76210 diff --git a/include/net/netdma.h b/include/net/netdma.h
76211 index 8ba8ce2..99b7fff 100644
76212 --- a/include/net/netdma.h
76213 +++ b/include/net/netdma.h
76214 @@ -24,7 +24,7 @@
76215 #include <linux/dmaengine.h>
76216 #include <linux/skbuff.h>
76217
76218 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
76219 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
76220 struct sk_buff *skb, int offset, struct iovec *to,
76221 size_t len, struct dma_pinned_list *pinned_list);
76222
76223 diff --git a/include/net/netlink.h b/include/net/netlink.h
76224 index 9690b0f..87aded7 100644
76225 --- a/include/net/netlink.h
76226 +++ b/include/net/netlink.h
76227 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
76228 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
76229 {
76230 if (mark)
76231 - skb_trim(skb, (unsigned char *) mark - skb->data);
76232 + skb_trim(skb, (const unsigned char *) mark - skb->data);
76233 }
76234
76235 /**
76236 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
76237 index c9c0c53..53f24c3 100644
76238 --- a/include/net/netns/conntrack.h
76239 +++ b/include/net/netns/conntrack.h
76240 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
76241 struct nf_proto_net {
76242 #ifdef CONFIG_SYSCTL
76243 struct ctl_table_header *ctl_table_header;
76244 - struct ctl_table *ctl_table;
76245 + ctl_table_no_const *ctl_table;
76246 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
76247 struct ctl_table_header *ctl_compat_header;
76248 - struct ctl_table *ctl_compat_table;
76249 + ctl_table_no_const *ctl_compat_table;
76250 #endif
76251 #endif
76252 unsigned int users;
76253 @@ -58,7 +58,7 @@ struct nf_ip_net {
76254 struct nf_icmp_net icmpv6;
76255 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
76256 struct ctl_table_header *ctl_table_header;
76257 - struct ctl_table *ctl_table;
76258 + ctl_table_no_const *ctl_table;
76259 #endif
76260 };
76261
76262 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
76263 index 2ba9de8..47bd6c7 100644
76264 --- a/include/net/netns/ipv4.h
76265 +++ b/include/net/netns/ipv4.h
76266 @@ -67,7 +67,7 @@ struct netns_ipv4 {
76267 kgid_t sysctl_ping_group_range[2];
76268 long sysctl_tcp_mem[3];
76269
76270 - atomic_t dev_addr_genid;
76271 + atomic_unchecked_t dev_addr_genid;
76272
76273 #ifdef CONFIG_IP_MROUTE
76274 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
76275 diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
76276 index 005e2c2..023d340 100644
76277 --- a/include/net/netns/ipv6.h
76278 +++ b/include/net/netns/ipv6.h
76279 @@ -71,7 +71,7 @@ struct netns_ipv6 {
76280 struct fib_rules_ops *mr6_rules_ops;
76281 #endif
76282 #endif
76283 - atomic_t dev_addr_genid;
76284 + atomic_unchecked_t dev_addr_genid;
76285 };
76286
76287 #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
76288 diff --git a/include/net/protocol.h b/include/net/protocol.h
76289 index 047c047..b9dad15 100644
76290 --- a/include/net/protocol.h
76291 +++ b/include/net/protocol.h
76292 @@ -44,7 +44,7 @@ struct net_protocol {
76293 void (*err_handler)(struct sk_buff *skb, u32 info);
76294 unsigned int no_policy:1,
76295 netns_ok:1;
76296 -};
76297 +} __do_const;
76298
76299 #if IS_ENABLED(CONFIG_IPV6)
76300 struct inet6_protocol {
76301 @@ -57,7 +57,7 @@ struct inet6_protocol {
76302 u8 type, u8 code, int offset,
76303 __be32 info);
76304 unsigned int flags; /* INET6_PROTO_xxx */
76305 -};
76306 +} __do_const;
76307
76308 #define INET6_PROTO_NOPOLICY 0x1
76309 #define INET6_PROTO_FINAL 0x2
76310 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
76311 index 7026648..584cc8c 100644
76312 --- a/include/net/rtnetlink.h
76313 +++ b/include/net/rtnetlink.h
76314 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
76315 const struct net_device *dev);
76316 unsigned int (*get_num_tx_queues)(void);
76317 unsigned int (*get_num_rx_queues)(void);
76318 -};
76319 +} __do_const;
76320
76321 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
76322 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
76323 diff --git a/include/net/sctp/sctp.h b/include/net/sctp/sctp.h
76324 index cd89510..d67810f 100644
76325 --- a/include/net/sctp/sctp.h
76326 +++ b/include/net/sctp/sctp.h
76327 @@ -330,9 +330,9 @@ do { \
76328
76329 #else /* SCTP_DEBUG */
76330
76331 -#define SCTP_DEBUG_PRINTK(whatever...)
76332 -#define SCTP_DEBUG_PRINTK_CONT(fmt, args...)
76333 -#define SCTP_DEBUG_PRINTK_IPADDR(whatever...)
76334 +#define SCTP_DEBUG_PRINTK(whatever...) do {} while (0)
76335 +#define SCTP_DEBUG_PRINTK_CONT(fmt, args...) do {} while (0)
76336 +#define SCTP_DEBUG_PRINTK_IPADDR(whatever...) do {} while (0)
76337 #define SCTP_ENABLE_DEBUG
76338 #define SCTP_DISABLE_DEBUG
76339 #define SCTP_ASSERT(expr, str, func)
76340 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
76341 index 2a82d13..62a31c2 100644
76342 --- a/include/net/sctp/sm.h
76343 +++ b/include/net/sctp/sm.h
76344 @@ -87,7 +87,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
76345 typedef struct {
76346 sctp_state_fn_t *fn;
76347 const char *name;
76348 -} sctp_sm_table_entry_t;
76349 +} __do_const sctp_sm_table_entry_t;
76350
76351 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
76352 * currently in use.
76353 @@ -299,7 +299,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
76354 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
76355
76356 /* Extern declarations for major data structures. */
76357 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
76358 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
76359
76360
76361 /* Get the size of a DATA chunk payload. */
76362 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
76363 index 1bd4c41..9250b5b 100644
76364 --- a/include/net/sctp/structs.h
76365 +++ b/include/net/sctp/structs.h
76366 @@ -516,7 +516,7 @@ struct sctp_pf {
76367 struct sctp_association *asoc);
76368 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
76369 struct sctp_af *af;
76370 -};
76371 +} __do_const;
76372
76373
76374 /* Structure to track chunk fragments that have been acked, but peer
76375 diff --git a/include/net/sock.h b/include/net/sock.h
76376 index 66772cf..25bc45b 100644
76377 --- a/include/net/sock.h
76378 +++ b/include/net/sock.h
76379 @@ -325,7 +325,7 @@ struct sock {
76380 #ifdef CONFIG_RPS
76381 __u32 sk_rxhash;
76382 #endif
76383 - atomic_t sk_drops;
76384 + atomic_unchecked_t sk_drops;
76385 int sk_rcvbuf;
76386
76387 struct sk_filter __rcu *sk_filter;
76388 @@ -1797,7 +1797,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
76389 }
76390
76391 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
76392 - char __user *from, char *to,
76393 + char __user *from, unsigned char *to,
76394 int copy, int offset)
76395 {
76396 if (skb->ip_summed == CHECKSUM_NONE) {
76397 @@ -2056,7 +2056,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
76398 }
76399 }
76400
76401 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
76402 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
76403
76404 /**
76405 * sk_page_frag - return an appropriate page_frag
76406 diff --git a/include/net/tcp.h b/include/net/tcp.h
76407 index 5bba80f..8520a82 100644
76408 --- a/include/net/tcp.h
76409 +++ b/include/net/tcp.h
76410 @@ -524,7 +524,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
76411 extern void tcp_xmit_retransmit_queue(struct sock *);
76412 extern void tcp_simple_retransmit(struct sock *);
76413 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
76414 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
76415 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
76416
76417 extern void tcp_send_probe0(struct sock *);
76418 extern void tcp_send_partial(struct sock *);
76419 @@ -697,8 +697,8 @@ struct tcp_skb_cb {
76420 struct inet6_skb_parm h6;
76421 #endif
76422 } header; /* For incoming frames */
76423 - __u32 seq; /* Starting sequence number */
76424 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
76425 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
76426 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
76427 __u32 when; /* used to compute rtt's */
76428 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
76429
76430 @@ -712,7 +712,7 @@ struct tcp_skb_cb {
76431
76432 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
76433 /* 1 byte hole */
76434 - __u32 ack_seq; /* Sequence number ACK'd */
76435 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
76436 };
76437
76438 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
76439 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
76440 index 94ce082..62b278d 100644
76441 --- a/include/net/xfrm.h
76442 +++ b/include/net/xfrm.h
76443 @@ -305,7 +305,7 @@ struct xfrm_policy_afinfo {
76444 struct net_device *dev,
76445 const struct flowi *fl);
76446 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
76447 -};
76448 +} __do_const;
76449
76450 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
76451 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
76452 @@ -341,7 +341,7 @@ struct xfrm_state_afinfo {
76453 struct sk_buff *skb);
76454 int (*transport_finish)(struct sk_buff *skb,
76455 int async);
76456 -};
76457 +} __do_const;
76458
76459 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
76460 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
76461 @@ -424,7 +424,7 @@ struct xfrm_mode {
76462 struct module *owner;
76463 unsigned int encap;
76464 int flags;
76465 -};
76466 +} __do_const;
76467
76468 /* Flags for xfrm_mode. */
76469 enum {
76470 @@ -521,7 +521,7 @@ struct xfrm_policy {
76471 struct timer_list timer;
76472
76473 struct flow_cache_object flo;
76474 - atomic_t genid;
76475 + atomic_unchecked_t genid;
76476 u32 priority;
76477 u32 index;
76478 struct xfrm_mark mark;
76479 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
76480 index 1a046b1..ee0bef0 100644
76481 --- a/include/rdma/iw_cm.h
76482 +++ b/include/rdma/iw_cm.h
76483 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
76484 int backlog);
76485
76486 int (*destroy_listen)(struct iw_cm_id *cm_id);
76487 -};
76488 +} __no_const;
76489
76490 /**
76491 * iw_create_cm_id - Create an IW CM identifier.
76492 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
76493 index e1379b4..67eafbe 100644
76494 --- a/include/scsi/libfc.h
76495 +++ b/include/scsi/libfc.h
76496 @@ -762,6 +762,7 @@ struct libfc_function_template {
76497 */
76498 void (*disc_stop_final) (struct fc_lport *);
76499 };
76500 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
76501
76502 /**
76503 * struct fc_disc - Discovery context
76504 @@ -866,7 +867,7 @@ struct fc_lport {
76505 struct fc_vport *vport;
76506
76507 /* Operational Information */
76508 - struct libfc_function_template tt;
76509 + libfc_function_template_no_const tt;
76510 u8 link_up;
76511 u8 qfull;
76512 enum fc_lport_state state;
76513 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
76514 index cc64587..608f523 100644
76515 --- a/include/scsi/scsi_device.h
76516 +++ b/include/scsi/scsi_device.h
76517 @@ -171,9 +171,9 @@ struct scsi_device {
76518 unsigned int max_device_blocked; /* what device_blocked counts down from */
76519 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
76520
76521 - atomic_t iorequest_cnt;
76522 - atomic_t iodone_cnt;
76523 - atomic_t ioerr_cnt;
76524 + atomic_unchecked_t iorequest_cnt;
76525 + atomic_unchecked_t iodone_cnt;
76526 + atomic_unchecked_t ioerr_cnt;
76527
76528 struct device sdev_gendev,
76529 sdev_dev;
76530 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
76531 index b797e8f..8e2c3aa 100644
76532 --- a/include/scsi/scsi_transport_fc.h
76533 +++ b/include/scsi/scsi_transport_fc.h
76534 @@ -751,7 +751,8 @@ struct fc_function_template {
76535 unsigned long show_host_system_hostname:1;
76536
76537 unsigned long disable_target_scan:1;
76538 -};
76539 +} __do_const;
76540 +typedef struct fc_function_template __no_const fc_function_template_no_const;
76541
76542
76543 /**
76544 diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
76545 index 9031a26..750d592 100644
76546 --- a/include/sound/compress_driver.h
76547 +++ b/include/sound/compress_driver.h
76548 @@ -128,7 +128,7 @@ struct snd_compr_ops {
76549 struct snd_compr_caps *caps);
76550 int (*get_codec_caps) (struct snd_compr_stream *stream,
76551 struct snd_compr_codec_caps *codec);
76552 -};
76553 +} __no_const;
76554
76555 /**
76556 * struct snd_compr: Compressed device
76557 diff --git a/include/sound/soc.h b/include/sound/soc.h
76558 index 85c1522..f44bad1 100644
76559 --- a/include/sound/soc.h
76560 +++ b/include/sound/soc.h
76561 @@ -781,7 +781,7 @@ struct snd_soc_codec_driver {
76562 /* probe ordering - for components with runtime dependencies */
76563 int probe_order;
76564 int remove_order;
76565 -};
76566 +} __do_const;
76567
76568 /* SoC platform interface */
76569 struct snd_soc_platform_driver {
76570 @@ -827,7 +827,7 @@ struct snd_soc_platform_driver {
76571 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
76572 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
76573 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
76574 -};
76575 +} __do_const;
76576
76577 struct snd_soc_platform {
76578 const char *name;
76579 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
76580 index 4ea4f98..a63629b 100644
76581 --- a/include/target/target_core_base.h
76582 +++ b/include/target/target_core_base.h
76583 @@ -653,7 +653,7 @@ struct se_device {
76584 spinlock_t stats_lock;
76585 /* Active commands on this virtual SE device */
76586 atomic_t simple_cmds;
76587 - atomic_t dev_ordered_id;
76588 + atomic_unchecked_t dev_ordered_id;
76589 atomic_t dev_ordered_sync;
76590 atomic_t dev_qf_count;
76591 int export_count;
76592 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
76593 new file mode 100644
76594 index 0000000..fb634b7
76595 --- /dev/null
76596 +++ b/include/trace/events/fs.h
76597 @@ -0,0 +1,53 @@
76598 +#undef TRACE_SYSTEM
76599 +#define TRACE_SYSTEM fs
76600 +
76601 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
76602 +#define _TRACE_FS_H
76603 +
76604 +#include <linux/fs.h>
76605 +#include <linux/tracepoint.h>
76606 +
76607 +TRACE_EVENT(do_sys_open,
76608 +
76609 + TP_PROTO(const char *filename, int flags, int mode),
76610 +
76611 + TP_ARGS(filename, flags, mode),
76612 +
76613 + TP_STRUCT__entry(
76614 + __string( filename, filename )
76615 + __field( int, flags )
76616 + __field( int, mode )
76617 + ),
76618 +
76619 + TP_fast_assign(
76620 + __assign_str(filename, filename);
76621 + __entry->flags = flags;
76622 + __entry->mode = mode;
76623 + ),
76624 +
76625 + TP_printk("\"%s\" %x %o",
76626 + __get_str(filename), __entry->flags, __entry->mode)
76627 +);
76628 +
76629 +TRACE_EVENT(open_exec,
76630 +
76631 + TP_PROTO(const char *filename),
76632 +
76633 + TP_ARGS(filename),
76634 +
76635 + TP_STRUCT__entry(
76636 + __string( filename, filename )
76637 + ),
76638 +
76639 + TP_fast_assign(
76640 + __assign_str(filename, filename);
76641 + ),
76642 +
76643 + TP_printk("\"%s\"",
76644 + __get_str(filename))
76645 +);
76646 +
76647 +#endif /* _TRACE_FS_H */
76648 +
76649 +/* This part must be outside protection */
76650 +#include <trace/define_trace.h>
76651 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
76652 index 1c09820..7f5ec79 100644
76653 --- a/include/trace/events/irq.h
76654 +++ b/include/trace/events/irq.h
76655 @@ -36,7 +36,7 @@ struct softirq_action;
76656 */
76657 TRACE_EVENT(irq_handler_entry,
76658
76659 - TP_PROTO(int irq, struct irqaction *action),
76660 + TP_PROTO(int irq, const struct irqaction *action),
76661
76662 TP_ARGS(irq, action),
76663
76664 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
76665 */
76666 TRACE_EVENT(irq_handler_exit,
76667
76668 - TP_PROTO(int irq, struct irqaction *action, int ret),
76669 + TP_PROTO(int irq, const struct irqaction *action, int ret),
76670
76671 TP_ARGS(irq, action, ret),
76672
76673 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
76674 index 7caf44c..23c6f27 100644
76675 --- a/include/uapi/linux/a.out.h
76676 +++ b/include/uapi/linux/a.out.h
76677 @@ -39,6 +39,14 @@ enum machine_type {
76678 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
76679 };
76680
76681 +/* Constants for the N_FLAGS field */
76682 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
76683 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
76684 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
76685 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
76686 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
76687 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
76688 +
76689 #if !defined (N_MAGIC)
76690 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
76691 #endif
76692 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
76693 index d876736..ccce5c0 100644
76694 --- a/include/uapi/linux/byteorder/little_endian.h
76695 +++ b/include/uapi/linux/byteorder/little_endian.h
76696 @@ -42,51 +42,51 @@
76697
76698 static inline __le64 __cpu_to_le64p(const __u64 *p)
76699 {
76700 - return (__force __le64)*p;
76701 + return (__force const __le64)*p;
76702 }
76703 -static inline __u64 __le64_to_cpup(const __le64 *p)
76704 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
76705 {
76706 - return (__force __u64)*p;
76707 + return (__force const __u64)*p;
76708 }
76709 static inline __le32 __cpu_to_le32p(const __u32 *p)
76710 {
76711 - return (__force __le32)*p;
76712 + return (__force const __le32)*p;
76713 }
76714 static inline __u32 __le32_to_cpup(const __le32 *p)
76715 {
76716 - return (__force __u32)*p;
76717 + return (__force const __u32)*p;
76718 }
76719 static inline __le16 __cpu_to_le16p(const __u16 *p)
76720 {
76721 - return (__force __le16)*p;
76722 + return (__force const __le16)*p;
76723 }
76724 static inline __u16 __le16_to_cpup(const __le16 *p)
76725 {
76726 - return (__force __u16)*p;
76727 + return (__force const __u16)*p;
76728 }
76729 static inline __be64 __cpu_to_be64p(const __u64 *p)
76730 {
76731 - return (__force __be64)__swab64p(p);
76732 + return (__force const __be64)__swab64p(p);
76733 }
76734 static inline __u64 __be64_to_cpup(const __be64 *p)
76735 {
76736 - return __swab64p((__u64 *)p);
76737 + return __swab64p((const __u64 *)p);
76738 }
76739 static inline __be32 __cpu_to_be32p(const __u32 *p)
76740 {
76741 - return (__force __be32)__swab32p(p);
76742 + return (__force const __be32)__swab32p(p);
76743 }
76744 -static inline __u32 __be32_to_cpup(const __be32 *p)
76745 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
76746 {
76747 - return __swab32p((__u32 *)p);
76748 + return __swab32p((const __u32 *)p);
76749 }
76750 static inline __be16 __cpu_to_be16p(const __u16 *p)
76751 {
76752 - return (__force __be16)__swab16p(p);
76753 + return (__force const __be16)__swab16p(p);
76754 }
76755 static inline __u16 __be16_to_cpup(const __be16 *p)
76756 {
76757 - return __swab16p((__u16 *)p);
76758 + return __swab16p((const __u16 *)p);
76759 }
76760 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
76761 #define __le64_to_cpus(x) do { (void)(x); } while (0)
76762 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
76763 index ef6103b..d4e65dd 100644
76764 --- a/include/uapi/linux/elf.h
76765 +++ b/include/uapi/linux/elf.h
76766 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
76767 #define PT_GNU_EH_FRAME 0x6474e550
76768
76769 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
76770 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
76771 +
76772 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
76773 +
76774 +/* Constants for the e_flags field */
76775 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
76776 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
76777 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
76778 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
76779 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
76780 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
76781
76782 /*
76783 * Extended Numbering
76784 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
76785 #define DT_DEBUG 21
76786 #define DT_TEXTREL 22
76787 #define DT_JMPREL 23
76788 +#define DT_FLAGS 30
76789 + #define DF_TEXTREL 0x00000004
76790 #define DT_ENCODING 32
76791 #define OLD_DT_LOOS 0x60000000
76792 #define DT_LOOS 0x6000000d
76793 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
76794 #define PF_W 0x2
76795 #define PF_X 0x1
76796
76797 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
76798 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
76799 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
76800 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
76801 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
76802 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
76803 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
76804 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
76805 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
76806 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
76807 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
76808 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
76809 +
76810 typedef struct elf32_phdr{
76811 Elf32_Word p_type;
76812 Elf32_Off p_offset;
76813 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
76814 #define EI_OSABI 7
76815 #define EI_PAD 8
76816
76817 +#define EI_PAX 14
76818 +
76819 #define ELFMAG0 0x7f /* EI_MAG */
76820 #define ELFMAG1 'E'
76821 #define ELFMAG2 'L'
76822 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
76823 index aa169c4..6a2771d 100644
76824 --- a/include/uapi/linux/personality.h
76825 +++ b/include/uapi/linux/personality.h
76826 @@ -30,6 +30,7 @@ enum {
76827 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
76828 ADDR_NO_RANDOMIZE | \
76829 ADDR_COMPAT_LAYOUT | \
76830 + ADDR_LIMIT_3GB | \
76831 MMAP_PAGE_ZERO)
76832
76833 /*
76834 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
76835 index 7530e74..e714828 100644
76836 --- a/include/uapi/linux/screen_info.h
76837 +++ b/include/uapi/linux/screen_info.h
76838 @@ -43,7 +43,8 @@ struct screen_info {
76839 __u16 pages; /* 0x32 */
76840 __u16 vesa_attributes; /* 0x34 */
76841 __u32 capabilities; /* 0x36 */
76842 - __u8 _reserved[6]; /* 0x3a */
76843 + __u16 vesapm_size; /* 0x3a */
76844 + __u8 _reserved[4]; /* 0x3c */
76845 } __attribute__((packed));
76846
76847 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
76848 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
76849 index 0e011eb..82681b1 100644
76850 --- a/include/uapi/linux/swab.h
76851 +++ b/include/uapi/linux/swab.h
76852 @@ -43,7 +43,7 @@
76853 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
76854 */
76855
76856 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
76857 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
76858 {
76859 #ifdef __HAVE_BUILTIN_BSWAP16__
76860 return __builtin_bswap16(val);
76861 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
76862 #endif
76863 }
76864
76865 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
76866 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
76867 {
76868 #ifdef __HAVE_BUILTIN_BSWAP32__
76869 return __builtin_bswap32(val);
76870 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
76871 #endif
76872 }
76873
76874 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
76875 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
76876 {
76877 #ifdef __HAVE_BUILTIN_BSWAP64__
76878 return __builtin_bswap64(val);
76879 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
76880 index 6d67213..8dab561 100644
76881 --- a/include/uapi/linux/sysctl.h
76882 +++ b/include/uapi/linux/sysctl.h
76883 @@ -155,7 +155,11 @@ enum
76884 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
76885 };
76886
76887 -
76888 +#ifdef CONFIG_PAX_SOFTMODE
76889 +enum {
76890 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
76891 +};
76892 +#endif
76893
76894 /* CTL_VM names: */
76895 enum
76896 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
76897 index e4629b9..6958086 100644
76898 --- a/include/uapi/linux/xattr.h
76899 +++ b/include/uapi/linux/xattr.h
76900 @@ -63,5 +63,9 @@
76901 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
76902 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
76903
76904 +/* User namespace */
76905 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
76906 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
76907 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
76908
76909 #endif /* _UAPI_LINUX_XATTR_H */
76910 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
76911 index f9466fa..f4e2b81 100644
76912 --- a/include/video/udlfb.h
76913 +++ b/include/video/udlfb.h
76914 @@ -53,10 +53,10 @@ struct dlfb_data {
76915 u32 pseudo_palette[256];
76916 int blank_mode; /*one of FB_BLANK_ */
76917 /* blit-only rendering path metrics, exposed through sysfs */
76918 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
76919 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
76920 - atomic_t bytes_sent; /* to usb, after compression including overhead */
76921 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
76922 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
76923 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
76924 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
76925 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
76926 };
76927
76928 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
76929 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
76930 index 1a91850..28573f8 100644
76931 --- a/include/video/uvesafb.h
76932 +++ b/include/video/uvesafb.h
76933 @@ -122,6 +122,7 @@ struct uvesafb_par {
76934 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
76935 u8 pmi_setpal; /* PMI for palette changes */
76936 u16 *pmi_base; /* protected mode interface location */
76937 + u8 *pmi_code; /* protected mode code location */
76938 void *pmi_start;
76939 void *pmi_pal;
76940 u8 *vbe_state_orig; /*
76941 diff --git a/init/Kconfig b/init/Kconfig
76942 index 2d9b831..ae4c8ac 100644
76943 --- a/init/Kconfig
76944 +++ b/init/Kconfig
76945 @@ -1029,6 +1029,7 @@ endif # CGROUPS
76946
76947 config CHECKPOINT_RESTORE
76948 bool "Checkpoint/restore support" if EXPERT
76949 + depends on !GRKERNSEC
76950 default n
76951 help
76952 Enables additional kernel features in a sake of checkpoint/restore.
76953 @@ -1516,7 +1517,7 @@ config SLUB_DEBUG
76954
76955 config COMPAT_BRK
76956 bool "Disable heap randomization"
76957 - default y
76958 + default n
76959 help
76960 Randomizing heap placement makes heap exploits harder, but it
76961 also breaks ancient binaries (including anything libc5 based).
76962 @@ -1779,7 +1780,7 @@ config INIT_ALL_POSSIBLE
76963 config STOP_MACHINE
76964 bool
76965 default y
76966 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
76967 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
76968 help
76969 Need stop_machine() primitive.
76970
76971 diff --git a/init/Makefile b/init/Makefile
76972 index 7bc47ee..6da2dc7 100644
76973 --- a/init/Makefile
76974 +++ b/init/Makefile
76975 @@ -2,6 +2,9 @@
76976 # Makefile for the linux kernel.
76977 #
76978
76979 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
76980 +asflags-y := $(GCC_PLUGINS_AFLAGS)
76981 +
76982 obj-y := main.o version.o mounts.o
76983 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
76984 obj-y += noinitramfs.o
76985 diff --git a/init/do_mounts.c b/init/do_mounts.c
76986 index a2b49f2..03a0e17c 100644
76987 --- a/init/do_mounts.c
76988 +++ b/init/do_mounts.c
76989 @@ -355,11 +355,11 @@ static void __init get_fs_names(char *page)
76990 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
76991 {
76992 struct super_block *s;
76993 - int err = sys_mount(name, "/root", fs, flags, data);
76994 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
76995 if (err)
76996 return err;
76997
76998 - sys_chdir("/root");
76999 + sys_chdir((const char __force_user *)"/root");
77000 s = current->fs->pwd.dentry->d_sb;
77001 ROOT_DEV = s->s_dev;
77002 printk(KERN_INFO
77003 @@ -480,18 +480,18 @@ void __init change_floppy(char *fmt, ...)
77004 va_start(args, fmt);
77005 vsprintf(buf, fmt, args);
77006 va_end(args);
77007 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
77008 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
77009 if (fd >= 0) {
77010 sys_ioctl(fd, FDEJECT, 0);
77011 sys_close(fd);
77012 }
77013 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
77014 - fd = sys_open("/dev/console", O_RDWR, 0);
77015 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
77016 if (fd >= 0) {
77017 sys_ioctl(fd, TCGETS, (long)&termios);
77018 termios.c_lflag &= ~ICANON;
77019 sys_ioctl(fd, TCSETSF, (long)&termios);
77020 - sys_read(fd, &c, 1);
77021 + sys_read(fd, (char __user *)&c, 1);
77022 termios.c_lflag |= ICANON;
77023 sys_ioctl(fd, TCSETSF, (long)&termios);
77024 sys_close(fd);
77025 @@ -585,6 +585,6 @@ void __init prepare_namespace(void)
77026 mount_root();
77027 out:
77028 devtmpfs_mount("dev");
77029 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
77030 - sys_chroot(".");
77031 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
77032 + sys_chroot((const char __force_user *)".");
77033 }
77034 diff --git a/init/do_mounts.h b/init/do_mounts.h
77035 index f5b978a..69dbfe8 100644
77036 --- a/init/do_mounts.h
77037 +++ b/init/do_mounts.h
77038 @@ -15,15 +15,15 @@ extern int root_mountflags;
77039
77040 static inline int create_dev(char *name, dev_t dev)
77041 {
77042 - sys_unlink(name);
77043 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
77044 + sys_unlink((char __force_user *)name);
77045 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
77046 }
77047
77048 #if BITS_PER_LONG == 32
77049 static inline u32 bstat(char *name)
77050 {
77051 struct stat64 stat;
77052 - if (sys_stat64(name, &stat) != 0)
77053 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
77054 return 0;
77055 if (!S_ISBLK(stat.st_mode))
77056 return 0;
77057 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
77058 static inline u32 bstat(char *name)
77059 {
77060 struct stat stat;
77061 - if (sys_newstat(name, &stat) != 0)
77062 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
77063 return 0;
77064 if (!S_ISBLK(stat.st_mode))
77065 return 0;
77066 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
77067 index 3e0878e..8a9d7a0 100644
77068 --- a/init/do_mounts_initrd.c
77069 +++ b/init/do_mounts_initrd.c
77070 @@ -37,13 +37,13 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)
77071 {
77072 sys_unshare(CLONE_FS | CLONE_FILES);
77073 /* stdin/stdout/stderr for /linuxrc */
77074 - sys_open("/dev/console", O_RDWR, 0);
77075 + sys_open((const char __force_user *)"/dev/console", O_RDWR, 0);
77076 sys_dup(0);
77077 sys_dup(0);
77078 /* move initrd over / and chdir/chroot in initrd root */
77079 - sys_chdir("/root");
77080 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
77081 - sys_chroot(".");
77082 + sys_chdir((const char __force_user *)"/root");
77083 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
77084 + sys_chroot((const char __force_user *)".");
77085 sys_setsid();
77086 return 0;
77087 }
77088 @@ -59,8 +59,8 @@ static void __init handle_initrd(void)
77089 create_dev("/dev/root.old", Root_RAM0);
77090 /* mount initrd on rootfs' /root */
77091 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
77092 - sys_mkdir("/old", 0700);
77093 - sys_chdir("/old");
77094 + sys_mkdir((const char __force_user *)"/old", 0700);
77095 + sys_chdir((const char __force_user *)"/old");
77096
77097 /* try loading default modules from initrd */
77098 load_default_modules();
77099 @@ -80,31 +80,31 @@ static void __init handle_initrd(void)
77100 current->flags &= ~PF_FREEZER_SKIP;
77101
77102 /* move initrd to rootfs' /old */
77103 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
77104 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
77105 /* switch root and cwd back to / of rootfs */
77106 - sys_chroot("..");
77107 + sys_chroot((const char __force_user *)"..");
77108
77109 if (new_decode_dev(real_root_dev) == Root_RAM0) {
77110 - sys_chdir("/old");
77111 + sys_chdir((const char __force_user *)"/old");
77112 return;
77113 }
77114
77115 - sys_chdir("/");
77116 + sys_chdir((const char __force_user *)"/");
77117 ROOT_DEV = new_decode_dev(real_root_dev);
77118 mount_root();
77119
77120 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
77121 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
77122 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
77123 if (!error)
77124 printk("okay\n");
77125 else {
77126 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
77127 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
77128 if (error == -ENOENT)
77129 printk("/initrd does not exist. Ignored.\n");
77130 else
77131 printk("failed\n");
77132 printk(KERN_NOTICE "Unmounting old root\n");
77133 - sys_umount("/old", MNT_DETACH);
77134 + sys_umount((char __force_user *)"/old", MNT_DETACH);
77135 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
77136 if (fd < 0) {
77137 error = fd;
77138 @@ -127,11 +127,11 @@ int __init initrd_load(void)
77139 * mounted in the normal path.
77140 */
77141 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
77142 - sys_unlink("/initrd.image");
77143 + sys_unlink((const char __force_user *)"/initrd.image");
77144 handle_initrd();
77145 return 1;
77146 }
77147 }
77148 - sys_unlink("/initrd.image");
77149 + sys_unlink((const char __force_user *)"/initrd.image");
77150 return 0;
77151 }
77152 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
77153 index 8cb6db5..d729f50 100644
77154 --- a/init/do_mounts_md.c
77155 +++ b/init/do_mounts_md.c
77156 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
77157 partitioned ? "_d" : "", minor,
77158 md_setup_args[ent].device_names);
77159
77160 - fd = sys_open(name, 0, 0);
77161 + fd = sys_open((char __force_user *)name, 0, 0);
77162 if (fd < 0) {
77163 printk(KERN_ERR "md: open failed - cannot start "
77164 "array %s\n", name);
77165 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
77166 * array without it
77167 */
77168 sys_close(fd);
77169 - fd = sys_open(name, 0, 0);
77170 + fd = sys_open((char __force_user *)name, 0, 0);
77171 sys_ioctl(fd, BLKRRPART, 0);
77172 }
77173 sys_close(fd);
77174 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
77175
77176 wait_for_device_probe();
77177
77178 - fd = sys_open("/dev/md0", 0, 0);
77179 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
77180 if (fd >= 0) {
77181 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
77182 sys_close(fd);
77183 diff --git a/init/init_task.c b/init/init_task.c
77184 index ba0a7f36..2bcf1d5 100644
77185 --- a/init/init_task.c
77186 +++ b/init/init_task.c
77187 @@ -22,5 +22,9 @@ EXPORT_SYMBOL(init_task);
77188 * Initial thread structure. Alignment of this is handled by a special
77189 * linker map entry.
77190 */
77191 +#ifdef CONFIG_X86
77192 +union thread_union init_thread_union __init_task_data;
77193 +#else
77194 union thread_union init_thread_union __init_task_data =
77195 { INIT_THREAD_INFO(init_task) };
77196 +#endif
77197 diff --git a/init/initramfs.c b/init/initramfs.c
77198 index a67ef9d..2d17ed9 100644
77199 --- a/init/initramfs.c
77200 +++ b/init/initramfs.c
77201 @@ -84,7 +84,7 @@ static void __init free_hash(void)
77202 }
77203 }
77204
77205 -static long __init do_utime(char *filename, time_t mtime)
77206 +static long __init do_utime(char __force_user *filename, time_t mtime)
77207 {
77208 struct timespec t[2];
77209
77210 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
77211 struct dir_entry *de, *tmp;
77212 list_for_each_entry_safe(de, tmp, &dir_list, list) {
77213 list_del(&de->list);
77214 - do_utime(de->name, de->mtime);
77215 + do_utime((char __force_user *)de->name, de->mtime);
77216 kfree(de->name);
77217 kfree(de);
77218 }
77219 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
77220 if (nlink >= 2) {
77221 char *old = find_link(major, minor, ino, mode, collected);
77222 if (old)
77223 - return (sys_link(old, collected) < 0) ? -1 : 1;
77224 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
77225 }
77226 return 0;
77227 }
77228 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
77229 {
77230 struct stat st;
77231
77232 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
77233 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
77234 if (S_ISDIR(st.st_mode))
77235 - sys_rmdir(path);
77236 + sys_rmdir((char __force_user *)path);
77237 else
77238 - sys_unlink(path);
77239 + sys_unlink((char __force_user *)path);
77240 }
77241 }
77242
77243 @@ -315,7 +315,7 @@ static int __init do_name(void)
77244 int openflags = O_WRONLY|O_CREAT;
77245 if (ml != 1)
77246 openflags |= O_TRUNC;
77247 - wfd = sys_open(collected, openflags, mode);
77248 + wfd = sys_open((char __force_user *)collected, openflags, mode);
77249
77250 if (wfd >= 0) {
77251 sys_fchown(wfd, uid, gid);
77252 @@ -327,17 +327,17 @@ static int __init do_name(void)
77253 }
77254 }
77255 } else if (S_ISDIR(mode)) {
77256 - sys_mkdir(collected, mode);
77257 - sys_chown(collected, uid, gid);
77258 - sys_chmod(collected, mode);
77259 + sys_mkdir((char __force_user *)collected, mode);
77260 + sys_chown((char __force_user *)collected, uid, gid);
77261 + sys_chmod((char __force_user *)collected, mode);
77262 dir_add(collected, mtime);
77263 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
77264 S_ISFIFO(mode) || S_ISSOCK(mode)) {
77265 if (maybe_link() == 0) {
77266 - sys_mknod(collected, mode, rdev);
77267 - sys_chown(collected, uid, gid);
77268 - sys_chmod(collected, mode);
77269 - do_utime(collected, mtime);
77270 + sys_mknod((char __force_user *)collected, mode, rdev);
77271 + sys_chown((char __force_user *)collected, uid, gid);
77272 + sys_chmod((char __force_user *)collected, mode);
77273 + do_utime((char __force_user *)collected, mtime);
77274 }
77275 }
77276 return 0;
77277 @@ -346,15 +346,15 @@ static int __init do_name(void)
77278 static int __init do_copy(void)
77279 {
77280 if (count >= body_len) {
77281 - sys_write(wfd, victim, body_len);
77282 + sys_write(wfd, (char __force_user *)victim, body_len);
77283 sys_close(wfd);
77284 - do_utime(vcollected, mtime);
77285 + do_utime((char __force_user *)vcollected, mtime);
77286 kfree(vcollected);
77287 eat(body_len);
77288 state = SkipIt;
77289 return 0;
77290 } else {
77291 - sys_write(wfd, victim, count);
77292 + sys_write(wfd, (char __force_user *)victim, count);
77293 body_len -= count;
77294 eat(count);
77295 return 1;
77296 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
77297 {
77298 collected[N_ALIGN(name_len) + body_len] = '\0';
77299 clean_path(collected, 0);
77300 - sys_symlink(collected + N_ALIGN(name_len), collected);
77301 - sys_lchown(collected, uid, gid);
77302 - do_utime(collected, mtime);
77303 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
77304 + sys_lchown((char __force_user *)collected, uid, gid);
77305 + do_utime((char __force_user *)collected, mtime);
77306 state = SkipIt;
77307 next_state = Reset;
77308 return 0;
77309 @@ -583,7 +583,7 @@ static int __init populate_rootfs(void)
77310 {
77311 char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
77312 if (err)
77313 - panic(err); /* Failed to decompress INTERNAL initramfs */
77314 + panic("%s", err); /* Failed to decompress INTERNAL initramfs */
77315 if (initrd_start) {
77316 #ifdef CONFIG_BLK_DEV_RAM
77317 int fd;
77318 diff --git a/init/main.c b/init/main.c
77319 index 9484f4b..0eac7c3 100644
77320 --- a/init/main.c
77321 +++ b/init/main.c
77322 @@ -100,6 +100,8 @@ static inline void mark_rodata_ro(void) { }
77323 extern void tc_init(void);
77324 #endif
77325
77326 +extern void grsecurity_init(void);
77327 +
77328 /*
77329 * Debug helper: via this flag we know that we are in 'early bootup code'
77330 * where only the boot processor is running with IRQ disabled. This means
77331 @@ -153,6 +155,74 @@ static int __init set_reset_devices(char *str)
77332
77333 __setup("reset_devices", set_reset_devices);
77334
77335 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
77336 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
77337 +static int __init setup_grsec_proc_gid(char *str)
77338 +{
77339 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
77340 + return 1;
77341 +}
77342 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
77343 +#endif
77344 +
77345 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
77346 +unsigned long pax_user_shadow_base __read_only;
77347 +EXPORT_SYMBOL(pax_user_shadow_base);
77348 +extern char pax_enter_kernel_user[];
77349 +extern char pax_exit_kernel_user[];
77350 +#endif
77351 +
77352 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
77353 +static int __init setup_pax_nouderef(char *str)
77354 +{
77355 +#ifdef CONFIG_X86_32
77356 + unsigned int cpu;
77357 + struct desc_struct *gdt;
77358 +
77359 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
77360 + gdt = get_cpu_gdt_table(cpu);
77361 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
77362 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
77363 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
77364 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
77365 + }
77366 + loadsegment(ds, __KERNEL_DS);
77367 + loadsegment(es, __KERNEL_DS);
77368 + loadsegment(ss, __KERNEL_DS);
77369 +#else
77370 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
77371 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
77372 + clone_pgd_mask = ~(pgdval_t)0UL;
77373 + pax_user_shadow_base = 0UL;
77374 + setup_clear_cpu_cap(X86_FEATURE_PCID);
77375 +#endif
77376 +
77377 + return 0;
77378 +}
77379 +early_param("pax_nouderef", setup_pax_nouderef);
77380 +
77381 +#ifdef CONFIG_X86_64
77382 +static int __init setup_pax_weakuderef(char *str)
77383 +{
77384 + if (clone_pgd_mask != ~(pgdval_t)0UL)
77385 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
77386 + return 1;
77387 +}
77388 +__setup("pax_weakuderef", setup_pax_weakuderef);
77389 +#endif
77390 +#endif
77391 +
77392 +#ifdef CONFIG_PAX_SOFTMODE
77393 +int pax_softmode;
77394 +
77395 +static int __init setup_pax_softmode(char *str)
77396 +{
77397 + get_option(&str, &pax_softmode);
77398 + return 1;
77399 +}
77400 +__setup("pax_softmode=", setup_pax_softmode);
77401 +#endif
77402 +
77403 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
77404 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
77405 static const char *panic_later, *panic_param;
77406 @@ -655,8 +725,6 @@ static void __init do_ctors(void)
77407 bool initcall_debug;
77408 core_param(initcall_debug, initcall_debug, bool, 0644);
77409
77410 -static char msgbuf[64];
77411 -
77412 static int __init_or_module do_one_initcall_debug(initcall_t fn)
77413 {
77414 ktime_t calltime, delta, rettime;
77415 @@ -679,23 +747,22 @@ int __init_or_module do_one_initcall(initcall_t fn)
77416 {
77417 int count = preempt_count();
77418 int ret;
77419 + const char *msg1 = "", *msg2 = "";
77420
77421 if (initcall_debug)
77422 ret = do_one_initcall_debug(fn);
77423 else
77424 ret = fn();
77425
77426 - msgbuf[0] = 0;
77427 -
77428 if (preempt_count() != count) {
77429 - sprintf(msgbuf, "preemption imbalance ");
77430 + msg1 = " preemption imbalance";
77431 preempt_count() = count;
77432 }
77433 if (irqs_disabled()) {
77434 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
77435 + msg2 = " disabled interrupts";
77436 local_irq_enable();
77437 }
77438 - WARN(msgbuf[0], "initcall %pF returned with %s\n", fn, msgbuf);
77439 + WARN(*msg1 || *msg2, "initcall %pF returned with%s%s\n", fn, msg1, msg2);
77440
77441 return ret;
77442 }
77443 @@ -748,8 +815,14 @@ static void __init do_initcall_level(int level)
77444 level, level,
77445 &repair_env_string);
77446
77447 - for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++)
77448 + for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++) {
77449 do_one_initcall(*fn);
77450 +
77451 +#ifdef LATENT_ENTROPY_PLUGIN
77452 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
77453 +#endif
77454 +
77455 + }
77456 }
77457
77458 static void __init do_initcalls(void)
77459 @@ -783,8 +856,14 @@ static void __init do_pre_smp_initcalls(void)
77460 {
77461 initcall_t *fn;
77462
77463 - for (fn = __initcall_start; fn < __initcall0_start; fn++)
77464 + for (fn = __initcall_start; fn < __initcall0_start; fn++) {
77465 do_one_initcall(*fn);
77466 +
77467 +#ifdef LATENT_ENTROPY_PLUGIN
77468 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
77469 +#endif
77470 +
77471 + }
77472 }
77473
77474 /*
77475 @@ -802,8 +881,8 @@ static int run_init_process(const char *init_filename)
77476 {
77477 argv_init[0] = init_filename;
77478 return do_execve(init_filename,
77479 - (const char __user *const __user *)argv_init,
77480 - (const char __user *const __user *)envp_init);
77481 + (const char __user *const __force_user *)argv_init,
77482 + (const char __user *const __force_user *)envp_init);
77483 }
77484
77485 static noinline void __init kernel_init_freeable(void);
77486 @@ -880,7 +959,7 @@ static noinline void __init kernel_init_freeable(void)
77487 do_basic_setup();
77488
77489 /* Open the /dev/console on the rootfs, this should never fail */
77490 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
77491 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
77492 pr_err("Warning: unable to open an initial console.\n");
77493
77494 (void) sys_dup(0);
77495 @@ -893,11 +972,13 @@ static noinline void __init kernel_init_freeable(void)
77496 if (!ramdisk_execute_command)
77497 ramdisk_execute_command = "/init";
77498
77499 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
77500 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
77501 ramdisk_execute_command = NULL;
77502 prepare_namespace();
77503 }
77504
77505 + grsecurity_init();
77506 +
77507 /*
77508 * Ok, we have completed the initial bootup, and
77509 * we're essentially up and running. Get rid of the
77510 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
77511 index 130dfec..cc88451 100644
77512 --- a/ipc/ipc_sysctl.c
77513 +++ b/ipc/ipc_sysctl.c
77514 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
77515 static int proc_ipc_dointvec(ctl_table *table, int write,
77516 void __user *buffer, size_t *lenp, loff_t *ppos)
77517 {
77518 - struct ctl_table ipc_table;
77519 + ctl_table_no_const ipc_table;
77520
77521 memcpy(&ipc_table, table, sizeof(ipc_table));
77522 ipc_table.data = get_ipc(table);
77523 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
77524 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
77525 void __user *buffer, size_t *lenp, loff_t *ppos)
77526 {
77527 - struct ctl_table ipc_table;
77528 + ctl_table_no_const ipc_table;
77529
77530 memcpy(&ipc_table, table, sizeof(ipc_table));
77531 ipc_table.data = get_ipc(table);
77532 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
77533 static int proc_ipc_callback_dointvec(ctl_table *table, int write,
77534 void __user *buffer, size_t *lenp, loff_t *ppos)
77535 {
77536 - struct ctl_table ipc_table;
77537 + ctl_table_no_const ipc_table;
77538 size_t lenp_bef = *lenp;
77539 int rc;
77540
77541 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec(ctl_table *table, int write,
77542 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
77543 void __user *buffer, size_t *lenp, loff_t *ppos)
77544 {
77545 - struct ctl_table ipc_table;
77546 + ctl_table_no_const ipc_table;
77547 memcpy(&ipc_table, table, sizeof(ipc_table));
77548 ipc_table.data = get_ipc(table);
77549
77550 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
77551 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
77552 void __user *buffer, size_t *lenp, loff_t *ppos)
77553 {
77554 - struct ctl_table ipc_table;
77555 + ctl_table_no_const ipc_table;
77556 size_t lenp_bef = *lenp;
77557 int oldval;
77558 int rc;
77559 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
77560 index 383d638..943fdbb 100644
77561 --- a/ipc/mq_sysctl.c
77562 +++ b/ipc/mq_sysctl.c
77563 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
77564 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
77565 void __user *buffer, size_t *lenp, loff_t *ppos)
77566 {
77567 - struct ctl_table mq_table;
77568 + ctl_table_no_const mq_table;
77569 memcpy(&mq_table, table, sizeof(mq_table));
77570 mq_table.data = get_mq(table);
77571
77572 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
77573 index e4e47f6..a85e0ad 100644
77574 --- a/ipc/mqueue.c
77575 +++ b/ipc/mqueue.c
77576 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
77577 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
77578 info->attr.mq_msgsize);
77579
77580 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
77581 spin_lock(&mq_lock);
77582 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
77583 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
77584 diff --git a/ipc/msg.c b/ipc/msg.c
77585 index d0c6d96..69a893c 100644
77586 --- a/ipc/msg.c
77587 +++ b/ipc/msg.c
77588 @@ -296,18 +296,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
77589 return security_msg_queue_associate(msq, msgflg);
77590 }
77591
77592 +static struct ipc_ops msg_ops = {
77593 + .getnew = newque,
77594 + .associate = msg_security,
77595 + .more_checks = NULL
77596 +};
77597 +
77598 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
77599 {
77600 struct ipc_namespace *ns;
77601 - struct ipc_ops msg_ops;
77602 struct ipc_params msg_params;
77603
77604 ns = current->nsproxy->ipc_ns;
77605
77606 - msg_ops.getnew = newque;
77607 - msg_ops.associate = msg_security;
77608 - msg_ops.more_checks = NULL;
77609 -
77610 msg_params.key = key;
77611 msg_params.flg = msgflg;
77612
77613 diff --git a/ipc/sem.c b/ipc/sem.c
77614 index 70480a3..f4e8262 100644
77615 --- a/ipc/sem.c
77616 +++ b/ipc/sem.c
77617 @@ -460,10 +460,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
77618 return 0;
77619 }
77620
77621 +static struct ipc_ops sem_ops = {
77622 + .getnew = newary,
77623 + .associate = sem_security,
77624 + .more_checks = sem_more_checks
77625 +};
77626 +
77627 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
77628 {
77629 struct ipc_namespace *ns;
77630 - struct ipc_ops sem_ops;
77631 struct ipc_params sem_params;
77632
77633 ns = current->nsproxy->ipc_ns;
77634 @@ -471,10 +476,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
77635 if (nsems < 0 || nsems > ns->sc_semmsl)
77636 return -EINVAL;
77637
77638 - sem_ops.getnew = newary;
77639 - sem_ops.associate = sem_security;
77640 - sem_ops.more_checks = sem_more_checks;
77641 -
77642 sem_params.key = key;
77643 sem_params.flg = semflg;
77644 sem_params.u.nsems = nsems;
77645 diff --git a/ipc/shm.c b/ipc/shm.c
77646 index 7e199fa..180a1ca 100644
77647 --- a/ipc/shm.c
77648 +++ b/ipc/shm.c
77649 @@ -69,6 +69,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
77650 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
77651 #endif
77652
77653 +#ifdef CONFIG_GRKERNSEC
77654 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
77655 + const time_t shm_createtime, const kuid_t cuid,
77656 + const int shmid);
77657 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
77658 + const time_t shm_createtime);
77659 +#endif
77660 +
77661 void shm_init_ns(struct ipc_namespace *ns)
77662 {
77663 ns->shm_ctlmax = SHMMAX;
77664 @@ -531,6 +539,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
77665 shp->shm_lprid = 0;
77666 shp->shm_atim = shp->shm_dtim = 0;
77667 shp->shm_ctim = get_seconds();
77668 +#ifdef CONFIG_GRKERNSEC
77669 + {
77670 + struct timespec timeval;
77671 + do_posix_clock_monotonic_gettime(&timeval);
77672 +
77673 + shp->shm_createtime = timeval.tv_sec;
77674 + }
77675 +#endif
77676 shp->shm_segsz = size;
77677 shp->shm_nattch = 0;
77678 shp->shm_file = file;
77679 @@ -582,18 +598,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
77680 return 0;
77681 }
77682
77683 +static struct ipc_ops shm_ops = {
77684 + .getnew = newseg,
77685 + .associate = shm_security,
77686 + .more_checks = shm_more_checks
77687 +};
77688 +
77689 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
77690 {
77691 struct ipc_namespace *ns;
77692 - struct ipc_ops shm_ops;
77693 struct ipc_params shm_params;
77694
77695 ns = current->nsproxy->ipc_ns;
77696
77697 - shm_ops.getnew = newseg;
77698 - shm_ops.associate = shm_security;
77699 - shm_ops.more_checks = shm_more_checks;
77700 -
77701 shm_params.key = key;
77702 shm_params.flg = shmflg;
77703 shm_params.u.size = size;
77704 @@ -1014,6 +1031,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
77705 f_mode = FMODE_READ | FMODE_WRITE;
77706 }
77707 if (shmflg & SHM_EXEC) {
77708 +
77709 +#ifdef CONFIG_PAX_MPROTECT
77710 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
77711 + goto out;
77712 +#endif
77713 +
77714 prot |= PROT_EXEC;
77715 acc_mode |= S_IXUGO;
77716 }
77717 @@ -1037,9 +1060,21 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
77718 if (err)
77719 goto out_unlock;
77720
77721 +#ifdef CONFIG_GRKERNSEC
77722 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
77723 + shp->shm_perm.cuid, shmid) ||
77724 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
77725 + err = -EACCES;
77726 + goto out_unlock;
77727 + }
77728 +#endif
77729 +
77730 path = shp->shm_file->f_path;
77731 path_get(&path);
77732 shp->shm_nattch++;
77733 +#ifdef CONFIG_GRKERNSEC
77734 + shp->shm_lapid = current->pid;
77735 +#endif
77736 size = i_size_read(path.dentry->d_inode);
77737 shm_unlock(shp);
77738
77739 diff --git a/kernel/acct.c b/kernel/acct.c
77740 index 8d6e145..33e0b1e 100644
77741 --- a/kernel/acct.c
77742 +++ b/kernel/acct.c
77743 @@ -556,7 +556,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
77744 */
77745 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
77746 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
77747 - file->f_op->write(file, (char *)&ac,
77748 + file->f_op->write(file, (char __force_user *)&ac,
77749 sizeof(acct_t), &file->f_pos);
77750 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
77751 set_fs(fs);
77752 diff --git a/kernel/audit.c b/kernel/audit.c
77753 index 91e53d0..d9e3ec4 100644
77754 --- a/kernel/audit.c
77755 +++ b/kernel/audit.c
77756 @@ -118,7 +118,7 @@ u32 audit_sig_sid = 0;
77757 3) suppressed due to audit_rate_limit
77758 4) suppressed due to audit_backlog_limit
77759 */
77760 -static atomic_t audit_lost = ATOMIC_INIT(0);
77761 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
77762
77763 /* The netlink socket. */
77764 static struct sock *audit_sock;
77765 @@ -240,7 +240,7 @@ void audit_log_lost(const char *message)
77766 unsigned long now;
77767 int print;
77768
77769 - atomic_inc(&audit_lost);
77770 + atomic_inc_unchecked(&audit_lost);
77771
77772 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
77773
77774 @@ -259,7 +259,7 @@ void audit_log_lost(const char *message)
77775 printk(KERN_WARNING
77776 "audit: audit_lost=%d audit_rate_limit=%d "
77777 "audit_backlog_limit=%d\n",
77778 - atomic_read(&audit_lost),
77779 + atomic_read_unchecked(&audit_lost),
77780 audit_rate_limit,
77781 audit_backlog_limit);
77782 audit_panic(message);
77783 @@ -664,7 +664,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
77784 status_set.pid = audit_pid;
77785 status_set.rate_limit = audit_rate_limit;
77786 status_set.backlog_limit = audit_backlog_limit;
77787 - status_set.lost = atomic_read(&audit_lost);
77788 + status_set.lost = atomic_read_unchecked(&audit_lost);
77789 status_set.backlog = skb_queue_len(&audit_skb_queue);
77790 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
77791 &status_set, sizeof(status_set));
77792 diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
77793 index 6bd4a90..0ee9eff 100644
77794 --- a/kernel/auditfilter.c
77795 +++ b/kernel/auditfilter.c
77796 @@ -423,7 +423,7 @@ static struct audit_entry *audit_data_to_entry(struct audit_rule_data *data,
77797 f->lsm_rule = NULL;
77798
77799 /* Support legacy tests for a valid loginuid */
77800 - if ((f->type == AUDIT_LOGINUID) && (f->val == 4294967295)) {
77801 + if ((f->type == AUDIT_LOGINUID) && (f->val == 4294967295U)) {
77802 f->type = AUDIT_LOGINUID_SET;
77803 f->val = 0;
77804 }
77805 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
77806 index 3c8a601..3a416f6 100644
77807 --- a/kernel/auditsc.c
77808 +++ b/kernel/auditsc.c
77809 @@ -1956,7 +1956,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
77810 }
77811
77812 /* global counter which is incremented every time something logs in */
77813 -static atomic_t session_id = ATOMIC_INIT(0);
77814 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
77815
77816 /**
77817 * audit_set_loginuid - set current task's audit_context loginuid
77818 @@ -1980,7 +1980,7 @@ int audit_set_loginuid(kuid_t loginuid)
77819 return -EPERM;
77820 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
77821
77822 - sessionid = atomic_inc_return(&session_id);
77823 + sessionid = atomic_inc_return_unchecked(&session_id);
77824 if (context && context->in_syscall) {
77825 struct audit_buffer *ab;
77826
77827 diff --git a/kernel/capability.c b/kernel/capability.c
77828 index f6c2ce5..982c0f9 100644
77829 --- a/kernel/capability.c
77830 +++ b/kernel/capability.c
77831 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
77832 * before modification is attempted and the application
77833 * fails.
77834 */
77835 + if (tocopy > ARRAY_SIZE(kdata))
77836 + return -EFAULT;
77837 +
77838 if (copy_to_user(dataptr, kdata, tocopy
77839 * sizeof(struct __user_cap_data_struct))) {
77840 return -EFAULT;
77841 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
77842 int ret;
77843
77844 rcu_read_lock();
77845 - ret = security_capable(__task_cred(t), ns, cap);
77846 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
77847 + gr_task_is_capable(t, __task_cred(t), cap);
77848 rcu_read_unlock();
77849
77850 - return (ret == 0);
77851 + return ret;
77852 }
77853
77854 /**
77855 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
77856 int ret;
77857
77858 rcu_read_lock();
77859 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
77860 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
77861 rcu_read_unlock();
77862
77863 - return (ret == 0);
77864 + return ret;
77865 }
77866
77867 /**
77868 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
77869 BUG();
77870 }
77871
77872 - if (security_capable(current_cred(), ns, cap) == 0) {
77873 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
77874 current->flags |= PF_SUPERPRIV;
77875 return true;
77876 }
77877 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
77878 }
77879 EXPORT_SYMBOL(ns_capable);
77880
77881 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
77882 +{
77883 + if (unlikely(!cap_valid(cap))) {
77884 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
77885 + BUG();
77886 + }
77887 +
77888 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
77889 + current->flags |= PF_SUPERPRIV;
77890 + return true;
77891 + }
77892 + return false;
77893 +}
77894 +EXPORT_SYMBOL(ns_capable_nolog);
77895 +
77896 /**
77897 * file_ns_capable - Determine if the file's opener had a capability in effect
77898 * @file: The file we want to check
77899 @@ -432,6 +451,12 @@ bool capable(int cap)
77900 }
77901 EXPORT_SYMBOL(capable);
77902
77903 +bool capable_nolog(int cap)
77904 +{
77905 + return ns_capable_nolog(&init_user_ns, cap);
77906 +}
77907 +EXPORT_SYMBOL(capable_nolog);
77908 +
77909 /**
77910 * nsown_capable - Check superior capability to one's own user_ns
77911 * @cap: The capability in question
77912 @@ -464,3 +489,10 @@ bool inode_capable(const struct inode *inode, int cap)
77913
77914 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
77915 }
77916 +
77917 +bool inode_capable_nolog(const struct inode *inode, int cap)
77918 +{
77919 + struct user_namespace *ns = current_user_ns();
77920 +
77921 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
77922 +}
77923 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
77924 index 2e9b387..61817b1 100644
77925 --- a/kernel/cgroup.c
77926 +++ b/kernel/cgroup.c
77927 @@ -5398,7 +5398,7 @@ static int cgroup_css_links_read(struct cgroup *cont,
77928 struct css_set *cg = link->cg;
77929 struct task_struct *task;
77930 int count = 0;
77931 - seq_printf(seq, "css_set %p\n", cg);
77932 + seq_printf(seq, "css_set %pK\n", cg);
77933 list_for_each_entry(task, &cg->tasks, cg_list) {
77934 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
77935 seq_puts(seq, " ...\n");
77936 diff --git a/kernel/compat.c b/kernel/compat.c
77937 index 0a09e48..f44f3f0 100644
77938 --- a/kernel/compat.c
77939 +++ b/kernel/compat.c
77940 @@ -13,6 +13,7 @@
77941
77942 #include <linux/linkage.h>
77943 #include <linux/compat.h>
77944 +#include <linux/module.h>
77945 #include <linux/errno.h>
77946 #include <linux/time.h>
77947 #include <linux/signal.h>
77948 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
77949 mm_segment_t oldfs;
77950 long ret;
77951
77952 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
77953 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
77954 oldfs = get_fs();
77955 set_fs(KERNEL_DS);
77956 ret = hrtimer_nanosleep_restart(restart);
77957 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
77958 oldfs = get_fs();
77959 set_fs(KERNEL_DS);
77960 ret = hrtimer_nanosleep(&tu,
77961 - rmtp ? (struct timespec __user *)&rmt : NULL,
77962 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
77963 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
77964 set_fs(oldfs);
77965
77966 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
77967 mm_segment_t old_fs = get_fs();
77968
77969 set_fs(KERNEL_DS);
77970 - ret = sys_sigpending((old_sigset_t __user *) &s);
77971 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
77972 set_fs(old_fs);
77973 if (ret == 0)
77974 ret = put_user(s, set);
77975 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
77976 mm_segment_t old_fs = get_fs();
77977
77978 set_fs(KERNEL_DS);
77979 - ret = sys_old_getrlimit(resource, &r);
77980 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
77981 set_fs(old_fs);
77982
77983 if (!ret) {
77984 @@ -533,8 +534,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
77985 set_fs (KERNEL_DS);
77986 ret = sys_wait4(pid,
77987 (stat_addr ?
77988 - (unsigned int __user *) &status : NULL),
77989 - options, (struct rusage __user *) &r);
77990 + (unsigned int __force_user *) &status : NULL),
77991 + options, (struct rusage __force_user *) &r);
77992 set_fs (old_fs);
77993
77994 if (ret > 0) {
77995 @@ -560,8 +561,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
77996 memset(&info, 0, sizeof(info));
77997
77998 set_fs(KERNEL_DS);
77999 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
78000 - uru ? (struct rusage __user *)&ru : NULL);
78001 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
78002 + uru ? (struct rusage __force_user *)&ru : NULL);
78003 set_fs(old_fs);
78004
78005 if ((ret < 0) || (info.si_signo == 0))
78006 @@ -695,8 +696,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
78007 oldfs = get_fs();
78008 set_fs(KERNEL_DS);
78009 err = sys_timer_settime(timer_id, flags,
78010 - (struct itimerspec __user *) &newts,
78011 - (struct itimerspec __user *) &oldts);
78012 + (struct itimerspec __force_user *) &newts,
78013 + (struct itimerspec __force_user *) &oldts);
78014 set_fs(oldfs);
78015 if (!err && old && put_compat_itimerspec(old, &oldts))
78016 return -EFAULT;
78017 @@ -713,7 +714,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
78018 oldfs = get_fs();
78019 set_fs(KERNEL_DS);
78020 err = sys_timer_gettime(timer_id,
78021 - (struct itimerspec __user *) &ts);
78022 + (struct itimerspec __force_user *) &ts);
78023 set_fs(oldfs);
78024 if (!err && put_compat_itimerspec(setting, &ts))
78025 return -EFAULT;
78026 @@ -732,7 +733,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
78027 oldfs = get_fs();
78028 set_fs(KERNEL_DS);
78029 err = sys_clock_settime(which_clock,
78030 - (struct timespec __user *) &ts);
78031 + (struct timespec __force_user *) &ts);
78032 set_fs(oldfs);
78033 return err;
78034 }
78035 @@ -747,7 +748,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
78036 oldfs = get_fs();
78037 set_fs(KERNEL_DS);
78038 err = sys_clock_gettime(which_clock,
78039 - (struct timespec __user *) &ts);
78040 + (struct timespec __force_user *) &ts);
78041 set_fs(oldfs);
78042 if (!err && put_compat_timespec(&ts, tp))
78043 return -EFAULT;
78044 @@ -767,7 +768,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
78045
78046 oldfs = get_fs();
78047 set_fs(KERNEL_DS);
78048 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
78049 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
78050 set_fs(oldfs);
78051
78052 err = compat_put_timex(utp, &txc);
78053 @@ -787,7 +788,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
78054 oldfs = get_fs();
78055 set_fs(KERNEL_DS);
78056 err = sys_clock_getres(which_clock,
78057 - (struct timespec __user *) &ts);
78058 + (struct timespec __force_user *) &ts);
78059 set_fs(oldfs);
78060 if (!err && tp && put_compat_timespec(&ts, tp))
78061 return -EFAULT;
78062 @@ -799,9 +800,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
78063 long err;
78064 mm_segment_t oldfs;
78065 struct timespec tu;
78066 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
78067 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
78068
78069 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
78070 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
78071 oldfs = get_fs();
78072 set_fs(KERNEL_DS);
78073 err = clock_nanosleep_restart(restart);
78074 @@ -833,8 +834,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
78075 oldfs = get_fs();
78076 set_fs(KERNEL_DS);
78077 err = sys_clock_nanosleep(which_clock, flags,
78078 - (struct timespec __user *) &in,
78079 - (struct timespec __user *) &out);
78080 + (struct timespec __force_user *) &in,
78081 + (struct timespec __force_user *) &out);
78082 set_fs(oldfs);
78083
78084 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
78085 diff --git a/kernel/configs.c b/kernel/configs.c
78086 index c18b1f1..b9a0132 100644
78087 --- a/kernel/configs.c
78088 +++ b/kernel/configs.c
78089 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
78090 struct proc_dir_entry *entry;
78091
78092 /* create the current config file */
78093 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
78094 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
78095 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
78096 + &ikconfig_file_ops);
78097 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
78098 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
78099 + &ikconfig_file_ops);
78100 +#endif
78101 +#else
78102 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
78103 &ikconfig_file_ops);
78104 +#endif
78105 +
78106 if (!entry)
78107 return -ENOMEM;
78108
78109 diff --git a/kernel/cred.c b/kernel/cred.c
78110 index e0573a4..3874e41 100644
78111 --- a/kernel/cred.c
78112 +++ b/kernel/cred.c
78113 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
78114 validate_creds(cred);
78115 alter_cred_subscribers(cred, -1);
78116 put_cred(cred);
78117 +
78118 +#ifdef CONFIG_GRKERNSEC_SETXID
78119 + cred = (struct cred *) tsk->delayed_cred;
78120 + if (cred != NULL) {
78121 + tsk->delayed_cred = NULL;
78122 + validate_creds(cred);
78123 + alter_cred_subscribers(cred, -1);
78124 + put_cred(cred);
78125 + }
78126 +#endif
78127 }
78128
78129 /**
78130 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
78131 * Always returns 0 thus allowing this function to be tail-called at the end
78132 * of, say, sys_setgid().
78133 */
78134 -int commit_creds(struct cred *new)
78135 +static int __commit_creds(struct cred *new)
78136 {
78137 struct task_struct *task = current;
78138 const struct cred *old = task->real_cred;
78139 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
78140
78141 get_cred(new); /* we will require a ref for the subj creds too */
78142
78143 + gr_set_role_label(task, new->uid, new->gid);
78144 +
78145 /* dumpability changes */
78146 if (!uid_eq(old->euid, new->euid) ||
78147 !gid_eq(old->egid, new->egid) ||
78148 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
78149 put_cred(old);
78150 return 0;
78151 }
78152 +#ifdef CONFIG_GRKERNSEC_SETXID
78153 +extern int set_user(struct cred *new);
78154 +
78155 +void gr_delayed_cred_worker(void)
78156 +{
78157 + const struct cred *new = current->delayed_cred;
78158 + struct cred *ncred;
78159 +
78160 + current->delayed_cred = NULL;
78161 +
78162 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
78163 + // from doing get_cred on it when queueing this
78164 + put_cred(new);
78165 + return;
78166 + } else if (new == NULL)
78167 + return;
78168 +
78169 + ncred = prepare_creds();
78170 + if (!ncred)
78171 + goto die;
78172 + // uids
78173 + ncred->uid = new->uid;
78174 + ncred->euid = new->euid;
78175 + ncred->suid = new->suid;
78176 + ncred->fsuid = new->fsuid;
78177 + // gids
78178 + ncred->gid = new->gid;
78179 + ncred->egid = new->egid;
78180 + ncred->sgid = new->sgid;
78181 + ncred->fsgid = new->fsgid;
78182 + // groups
78183 + if (set_groups(ncred, new->group_info) < 0) {
78184 + abort_creds(ncred);
78185 + goto die;
78186 + }
78187 + // caps
78188 + ncred->securebits = new->securebits;
78189 + ncred->cap_inheritable = new->cap_inheritable;
78190 + ncred->cap_permitted = new->cap_permitted;
78191 + ncred->cap_effective = new->cap_effective;
78192 + ncred->cap_bset = new->cap_bset;
78193 +
78194 + if (set_user(ncred)) {
78195 + abort_creds(ncred);
78196 + goto die;
78197 + }
78198 +
78199 + // from doing get_cred on it when queueing this
78200 + put_cred(new);
78201 +
78202 + __commit_creds(ncred);
78203 + return;
78204 +die:
78205 + // from doing get_cred on it when queueing this
78206 + put_cred(new);
78207 + do_group_exit(SIGKILL);
78208 +}
78209 +#endif
78210 +
78211 +int commit_creds(struct cred *new)
78212 +{
78213 +#ifdef CONFIG_GRKERNSEC_SETXID
78214 + int ret;
78215 + int schedule_it = 0;
78216 + struct task_struct *t;
78217 +
78218 + /* we won't get called with tasklist_lock held for writing
78219 + and interrupts disabled as the cred struct in that case is
78220 + init_cred
78221 + */
78222 + if (grsec_enable_setxid && !current_is_single_threaded() &&
78223 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
78224 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
78225 + schedule_it = 1;
78226 + }
78227 + ret = __commit_creds(new);
78228 + if (schedule_it) {
78229 + rcu_read_lock();
78230 + read_lock(&tasklist_lock);
78231 + for (t = next_thread(current); t != current;
78232 + t = next_thread(t)) {
78233 + if (t->delayed_cred == NULL) {
78234 + t->delayed_cred = get_cred(new);
78235 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
78236 + set_tsk_need_resched(t);
78237 + }
78238 + }
78239 + read_unlock(&tasklist_lock);
78240 + rcu_read_unlock();
78241 + }
78242 + return ret;
78243 +#else
78244 + return __commit_creds(new);
78245 +#endif
78246 +}
78247 +
78248 EXPORT_SYMBOL(commit_creds);
78249
78250 /**
78251 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
78252 index 0506d44..2c20034 100644
78253 --- a/kernel/debug/debug_core.c
78254 +++ b/kernel/debug/debug_core.c
78255 @@ -123,7 +123,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
78256 */
78257 static atomic_t masters_in_kgdb;
78258 static atomic_t slaves_in_kgdb;
78259 -static atomic_t kgdb_break_tasklet_var;
78260 +static atomic_unchecked_t kgdb_break_tasklet_var;
78261 atomic_t kgdb_setting_breakpoint;
78262
78263 struct task_struct *kgdb_usethread;
78264 @@ -133,7 +133,7 @@ int kgdb_single_step;
78265 static pid_t kgdb_sstep_pid;
78266
78267 /* to keep track of the CPU which is doing the single stepping*/
78268 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
78269 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
78270
78271 /*
78272 * If you are debugging a problem where roundup (the collection of
78273 @@ -541,7 +541,7 @@ return_normal:
78274 * kernel will only try for the value of sstep_tries before
78275 * giving up and continuing on.
78276 */
78277 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
78278 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
78279 (kgdb_info[cpu].task &&
78280 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
78281 atomic_set(&kgdb_active, -1);
78282 @@ -635,8 +635,8 @@ cpu_master_loop:
78283 }
78284
78285 kgdb_restore:
78286 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
78287 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
78288 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
78289 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
78290 if (kgdb_info[sstep_cpu].task)
78291 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
78292 else
78293 @@ -888,18 +888,18 @@ static void kgdb_unregister_callbacks(void)
78294 static void kgdb_tasklet_bpt(unsigned long ing)
78295 {
78296 kgdb_breakpoint();
78297 - atomic_set(&kgdb_break_tasklet_var, 0);
78298 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
78299 }
78300
78301 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
78302
78303 void kgdb_schedule_breakpoint(void)
78304 {
78305 - if (atomic_read(&kgdb_break_tasklet_var) ||
78306 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
78307 atomic_read(&kgdb_active) != -1 ||
78308 atomic_read(&kgdb_setting_breakpoint))
78309 return;
78310 - atomic_inc(&kgdb_break_tasklet_var);
78311 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
78312 tasklet_schedule(&kgdb_tasklet_breakpoint);
78313 }
78314 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
78315 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
78316 index 00eb8f7..d7e3244 100644
78317 --- a/kernel/debug/kdb/kdb_main.c
78318 +++ b/kernel/debug/kdb/kdb_main.c
78319 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
78320 continue;
78321
78322 kdb_printf("%-20s%8u 0x%p ", mod->name,
78323 - mod->core_size, (void *)mod);
78324 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
78325 #ifdef CONFIG_MODULE_UNLOAD
78326 kdb_printf("%4ld ", module_refcount(mod));
78327 #endif
78328 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
78329 kdb_printf(" (Loading)");
78330 else
78331 kdb_printf(" (Live)");
78332 - kdb_printf(" 0x%p", mod->module_core);
78333 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
78334
78335 #ifdef CONFIG_MODULE_UNLOAD
78336 {
78337 diff --git a/kernel/events/core.c b/kernel/events/core.c
78338 index e76e495..cbfe63a 100644
78339 --- a/kernel/events/core.c
78340 +++ b/kernel/events/core.c
78341 @@ -156,8 +156,15 @@ static struct srcu_struct pmus_srcu;
78342 * 0 - disallow raw tracepoint access for unpriv
78343 * 1 - disallow cpu events for unpriv
78344 * 2 - disallow kernel profiling for unpriv
78345 + * 3 - disallow all unpriv perf event use
78346 */
78347 -int sysctl_perf_event_paranoid __read_mostly = 1;
78348 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
78349 +int sysctl_perf_event_legitimately_concerned __read_mostly = 3;
78350 +#elif defined(CONFIG_GRKERNSEC_HIDESYM)
78351 +int sysctl_perf_event_legitimately_concerned __read_mostly = 2;
78352 +#else
78353 +int sysctl_perf_event_legitimately_concerned __read_mostly = 1;
78354 +#endif
78355
78356 /* Minimum for 512 kiB + 1 user control page */
78357 int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
78358 @@ -184,7 +191,7 @@ int perf_proc_update_handler(struct ctl_table *table, int write,
78359 return 0;
78360 }
78361
78362 -static atomic64_t perf_event_id;
78363 +static atomic64_unchecked_t perf_event_id;
78364
78365 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
78366 enum event_type_t event_type);
78367 @@ -2747,7 +2754,7 @@ static void __perf_event_read(void *info)
78368
78369 static inline u64 perf_event_count(struct perf_event *event)
78370 {
78371 - return local64_read(&event->count) + atomic64_read(&event->child_count);
78372 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
78373 }
78374
78375 static u64 perf_event_read(struct perf_event *event)
78376 @@ -3093,9 +3100,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
78377 mutex_lock(&event->child_mutex);
78378 total += perf_event_read(event);
78379 *enabled += event->total_time_enabled +
78380 - atomic64_read(&event->child_total_time_enabled);
78381 + atomic64_read_unchecked(&event->child_total_time_enabled);
78382 *running += event->total_time_running +
78383 - atomic64_read(&event->child_total_time_running);
78384 + atomic64_read_unchecked(&event->child_total_time_running);
78385
78386 list_for_each_entry(child, &event->child_list, child_list) {
78387 total += perf_event_read(child);
78388 @@ -3481,10 +3488,10 @@ void perf_event_update_userpage(struct perf_event *event)
78389 userpg->offset -= local64_read(&event->hw.prev_count);
78390
78391 userpg->time_enabled = enabled +
78392 - atomic64_read(&event->child_total_time_enabled);
78393 + atomic64_read_unchecked(&event->child_total_time_enabled);
78394
78395 userpg->time_running = running +
78396 - atomic64_read(&event->child_total_time_running);
78397 + atomic64_read_unchecked(&event->child_total_time_running);
78398
78399 arch_perf_update_userpage(userpg, now);
78400
78401 @@ -4034,7 +4041,7 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size,
78402
78403 /* Data. */
78404 sp = perf_user_stack_pointer(regs);
78405 - rem = __output_copy_user(handle, (void *) sp, dump_size);
78406 + rem = __output_copy_user(handle, (void __user *) sp, dump_size);
78407 dyn_size = dump_size - rem;
78408
78409 perf_output_skip(handle, rem);
78410 @@ -4122,11 +4129,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
78411 values[n++] = perf_event_count(event);
78412 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
78413 values[n++] = enabled +
78414 - atomic64_read(&event->child_total_time_enabled);
78415 + atomic64_read_unchecked(&event->child_total_time_enabled);
78416 }
78417 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
78418 values[n++] = running +
78419 - atomic64_read(&event->child_total_time_running);
78420 + atomic64_read_unchecked(&event->child_total_time_running);
78421 }
78422 if (read_format & PERF_FORMAT_ID)
78423 values[n++] = primary_event_id(event);
78424 @@ -4835,12 +4842,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
78425 * need to add enough zero bytes after the string to handle
78426 * the 64bit alignment we do later.
78427 */
78428 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
78429 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
78430 if (!buf) {
78431 name = strncpy(tmp, "//enomem", sizeof(tmp));
78432 goto got_name;
78433 }
78434 - name = d_path(&file->f_path, buf, PATH_MAX);
78435 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
78436 if (IS_ERR(name)) {
78437 name = strncpy(tmp, "//toolong", sizeof(tmp));
78438 goto got_name;
78439 @@ -6262,7 +6269,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
78440 event->parent = parent_event;
78441
78442 event->ns = get_pid_ns(task_active_pid_ns(current));
78443 - event->id = atomic64_inc_return(&perf_event_id);
78444 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
78445
78446 event->state = PERF_EVENT_STATE_INACTIVE;
78447
78448 @@ -6572,6 +6579,11 @@ SYSCALL_DEFINE5(perf_event_open,
78449 if (flags & ~PERF_FLAG_ALL)
78450 return -EINVAL;
78451
78452 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
78453 + if (perf_paranoid_any() && !capable(CAP_SYS_ADMIN))
78454 + return -EACCES;
78455 +#endif
78456 +
78457 err = perf_copy_attr(attr_uptr, &attr);
78458 if (err)
78459 return err;
78460 @@ -6904,10 +6916,10 @@ static void sync_child_event(struct perf_event *child_event,
78461 /*
78462 * Add back the child's count to the parent's count:
78463 */
78464 - atomic64_add(child_val, &parent_event->child_count);
78465 - atomic64_add(child_event->total_time_enabled,
78466 + atomic64_add_unchecked(child_val, &parent_event->child_count);
78467 + atomic64_add_unchecked(child_event->total_time_enabled,
78468 &parent_event->child_total_time_enabled);
78469 - atomic64_add(child_event->total_time_running,
78470 + atomic64_add_unchecked(child_event->total_time_running,
78471 &parent_event->child_total_time_running);
78472
78473 /*
78474 diff --git a/kernel/events/internal.h b/kernel/events/internal.h
78475 index ca65997..cc8cee4 100644
78476 --- a/kernel/events/internal.h
78477 +++ b/kernel/events/internal.h
78478 @@ -81,10 +81,10 @@ static inline unsigned long perf_data_size(struct ring_buffer *rb)
78479 return rb->nr_pages << (PAGE_SHIFT + page_order(rb));
78480 }
78481
78482 -#define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \
78483 +#define DEFINE_OUTPUT_COPY(func_name, memcpy_func, user) \
78484 static inline unsigned int \
78485 func_name(struct perf_output_handle *handle, \
78486 - const void *buf, unsigned int len) \
78487 + const void user *buf, unsigned int len) \
78488 { \
78489 unsigned long size, written; \
78490 \
78491 @@ -116,17 +116,17 @@ static inline int memcpy_common(void *dst, const void *src, size_t n)
78492 return n;
78493 }
78494
78495 -DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
78496 +DEFINE_OUTPUT_COPY(__output_copy, memcpy_common, )
78497
78498 #define MEMCPY_SKIP(dst, src, n) (n)
78499
78500 -DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP)
78501 +DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP, )
78502
78503 #ifndef arch_perf_out_copy_user
78504 #define arch_perf_out_copy_user __copy_from_user_inatomic
78505 #endif
78506
78507 -DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
78508 +DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user, __user)
78509
78510 /* Callchain handling */
78511 extern struct perf_callchain_entry *
78512 diff --git a/kernel/exit.c b/kernel/exit.c
78513 index 7bb73f9..d7978ed 100644
78514 --- a/kernel/exit.c
78515 +++ b/kernel/exit.c
78516 @@ -172,6 +172,10 @@ void release_task(struct task_struct * p)
78517 struct task_struct *leader;
78518 int zap_leader;
78519 repeat:
78520 +#ifdef CONFIG_NET
78521 + gr_del_task_from_ip_table(p);
78522 +#endif
78523 +
78524 /* don't need to get the RCU readlock here - the process is dead and
78525 * can't be modifying its own credentials. But shut RCU-lockdep up */
78526 rcu_read_lock();
78527 @@ -340,7 +344,7 @@ int allow_signal(int sig)
78528 * know it'll be handled, so that they don't get converted to
78529 * SIGKILL or just silently dropped.
78530 */
78531 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
78532 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
78533 recalc_sigpending();
78534 spin_unlock_irq(&current->sighand->siglock);
78535 return 0;
78536 @@ -709,6 +713,8 @@ void do_exit(long code)
78537 struct task_struct *tsk = current;
78538 int group_dead;
78539
78540 + set_fs(USER_DS);
78541 +
78542 profile_task_exit(tsk);
78543
78544 WARN_ON(blk_needs_flush_plug(tsk));
78545 @@ -725,7 +731,6 @@ void do_exit(long code)
78546 * mm_release()->clear_child_tid() from writing to a user-controlled
78547 * kernel address.
78548 */
78549 - set_fs(USER_DS);
78550
78551 ptrace_event(PTRACE_EVENT_EXIT, code);
78552
78553 @@ -784,6 +789,9 @@ void do_exit(long code)
78554 tsk->exit_code = code;
78555 taskstats_exit(tsk, group_dead);
78556
78557 + gr_acl_handle_psacct(tsk, code);
78558 + gr_acl_handle_exit();
78559 +
78560 exit_mm(tsk);
78561
78562 if (group_dead)
78563 @@ -905,7 +913,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
78564 * Take down every thread in the group. This is called by fatal signals
78565 * as well as by sys_exit_group (below).
78566 */
78567 -void
78568 +__noreturn void
78569 do_group_exit(int exit_code)
78570 {
78571 struct signal_struct *sig = current->signal;
78572 diff --git a/kernel/fork.c b/kernel/fork.c
78573 index ffbc090..08ceeee 100644
78574 --- a/kernel/fork.c
78575 +++ b/kernel/fork.c
78576 @@ -319,7 +319,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
78577 *stackend = STACK_END_MAGIC; /* for overflow detection */
78578
78579 #ifdef CONFIG_CC_STACKPROTECTOR
78580 - tsk->stack_canary = get_random_int();
78581 + tsk->stack_canary = pax_get_random_long();
78582 #endif
78583
78584 /*
78585 @@ -345,13 +345,81 @@ free_tsk:
78586 }
78587
78588 #ifdef CONFIG_MMU
78589 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
78590 +{
78591 + struct vm_area_struct *tmp;
78592 + unsigned long charge;
78593 + struct mempolicy *pol;
78594 + struct file *file;
78595 +
78596 + charge = 0;
78597 + if (mpnt->vm_flags & VM_ACCOUNT) {
78598 + unsigned long len = vma_pages(mpnt);
78599 +
78600 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
78601 + goto fail_nomem;
78602 + charge = len;
78603 + }
78604 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
78605 + if (!tmp)
78606 + goto fail_nomem;
78607 + *tmp = *mpnt;
78608 + tmp->vm_mm = mm;
78609 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
78610 + pol = mpol_dup(vma_policy(mpnt));
78611 + if (IS_ERR(pol))
78612 + goto fail_nomem_policy;
78613 + vma_set_policy(tmp, pol);
78614 + if (anon_vma_fork(tmp, mpnt))
78615 + goto fail_nomem_anon_vma_fork;
78616 + tmp->vm_flags &= ~VM_LOCKED;
78617 + tmp->vm_next = tmp->vm_prev = NULL;
78618 + tmp->vm_mirror = NULL;
78619 + file = tmp->vm_file;
78620 + if (file) {
78621 + struct inode *inode = file_inode(file);
78622 + struct address_space *mapping = file->f_mapping;
78623 +
78624 + get_file(file);
78625 + if (tmp->vm_flags & VM_DENYWRITE)
78626 + atomic_dec(&inode->i_writecount);
78627 + mutex_lock(&mapping->i_mmap_mutex);
78628 + if (tmp->vm_flags & VM_SHARED)
78629 + mapping->i_mmap_writable++;
78630 + flush_dcache_mmap_lock(mapping);
78631 + /* insert tmp into the share list, just after mpnt */
78632 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
78633 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
78634 + else
78635 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
78636 + flush_dcache_mmap_unlock(mapping);
78637 + mutex_unlock(&mapping->i_mmap_mutex);
78638 + }
78639 +
78640 + /*
78641 + * Clear hugetlb-related page reserves for children. This only
78642 + * affects MAP_PRIVATE mappings. Faults generated by the child
78643 + * are not guaranteed to succeed, even if read-only
78644 + */
78645 + if (is_vm_hugetlb_page(tmp))
78646 + reset_vma_resv_huge_pages(tmp);
78647 +
78648 + return tmp;
78649 +
78650 +fail_nomem_anon_vma_fork:
78651 + mpol_put(pol);
78652 +fail_nomem_policy:
78653 + kmem_cache_free(vm_area_cachep, tmp);
78654 +fail_nomem:
78655 + vm_unacct_memory(charge);
78656 + return NULL;
78657 +}
78658 +
78659 static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
78660 {
78661 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
78662 struct rb_node **rb_link, *rb_parent;
78663 int retval;
78664 - unsigned long charge;
78665 - struct mempolicy *pol;
78666
78667 uprobe_start_dup_mmap();
78668 down_write(&oldmm->mmap_sem);
78669 @@ -365,8 +433,8 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
78670 mm->locked_vm = 0;
78671 mm->mmap = NULL;
78672 mm->mmap_cache = NULL;
78673 - mm->free_area_cache = oldmm->mmap_base;
78674 - mm->cached_hole_size = ~0UL;
78675 + mm->free_area_cache = oldmm->free_area_cache;
78676 + mm->cached_hole_size = oldmm->cached_hole_size;
78677 mm->map_count = 0;
78678 cpumask_clear(mm_cpumask(mm));
78679 mm->mm_rb = RB_ROOT;
78680 @@ -382,57 +450,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
78681
78682 prev = NULL;
78683 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
78684 - struct file *file;
78685 -
78686 if (mpnt->vm_flags & VM_DONTCOPY) {
78687 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
78688 -vma_pages(mpnt));
78689 continue;
78690 }
78691 - charge = 0;
78692 - if (mpnt->vm_flags & VM_ACCOUNT) {
78693 - unsigned long len = vma_pages(mpnt);
78694 -
78695 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
78696 - goto fail_nomem;
78697 - charge = len;
78698 - }
78699 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
78700 - if (!tmp)
78701 - goto fail_nomem;
78702 - *tmp = *mpnt;
78703 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
78704 - pol = mpol_dup(vma_policy(mpnt));
78705 - retval = PTR_ERR(pol);
78706 - if (IS_ERR(pol))
78707 - goto fail_nomem_policy;
78708 - vma_set_policy(tmp, pol);
78709 - tmp->vm_mm = mm;
78710 - if (anon_vma_fork(tmp, mpnt))
78711 - goto fail_nomem_anon_vma_fork;
78712 - tmp->vm_flags &= ~VM_LOCKED;
78713 - tmp->vm_next = tmp->vm_prev = NULL;
78714 - file = tmp->vm_file;
78715 - if (file) {
78716 - struct inode *inode = file_inode(file);
78717 - struct address_space *mapping = file->f_mapping;
78718 -
78719 - get_file(file);
78720 - if (tmp->vm_flags & VM_DENYWRITE)
78721 - atomic_dec(&inode->i_writecount);
78722 - mutex_lock(&mapping->i_mmap_mutex);
78723 - if (tmp->vm_flags & VM_SHARED)
78724 - mapping->i_mmap_writable++;
78725 - flush_dcache_mmap_lock(mapping);
78726 - /* insert tmp into the share list, just after mpnt */
78727 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
78728 - vma_nonlinear_insert(tmp,
78729 - &mapping->i_mmap_nonlinear);
78730 - else
78731 - vma_interval_tree_insert_after(tmp, mpnt,
78732 - &mapping->i_mmap);
78733 - flush_dcache_mmap_unlock(mapping);
78734 - mutex_unlock(&mapping->i_mmap_mutex);
78735 + tmp = dup_vma(mm, oldmm, mpnt);
78736 + if (!tmp) {
78737 + retval = -ENOMEM;
78738 + goto out;
78739 }
78740
78741 /*
78742 @@ -464,6 +490,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
78743 if (retval)
78744 goto out;
78745 }
78746 +
78747 +#ifdef CONFIG_PAX_SEGMEXEC
78748 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
78749 + struct vm_area_struct *mpnt_m;
78750 +
78751 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
78752 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
78753 +
78754 + if (!mpnt->vm_mirror)
78755 + continue;
78756 +
78757 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
78758 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
78759 + mpnt->vm_mirror = mpnt_m;
78760 + } else {
78761 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
78762 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
78763 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
78764 + mpnt->vm_mirror->vm_mirror = mpnt;
78765 + }
78766 + }
78767 + BUG_ON(mpnt_m);
78768 + }
78769 +#endif
78770 +
78771 /* a new mm has just been created */
78772 arch_dup_mmap(oldmm, mm);
78773 retval = 0;
78774 @@ -473,14 +524,6 @@ out:
78775 up_write(&oldmm->mmap_sem);
78776 uprobe_end_dup_mmap();
78777 return retval;
78778 -fail_nomem_anon_vma_fork:
78779 - mpol_put(pol);
78780 -fail_nomem_policy:
78781 - kmem_cache_free(vm_area_cachep, tmp);
78782 -fail_nomem:
78783 - retval = -ENOMEM;
78784 - vm_unacct_memory(charge);
78785 - goto out;
78786 }
78787
78788 static inline int mm_alloc_pgd(struct mm_struct *mm)
78789 @@ -695,8 +738,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
78790 return ERR_PTR(err);
78791
78792 mm = get_task_mm(task);
78793 - if (mm && mm != current->mm &&
78794 - !ptrace_may_access(task, mode)) {
78795 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
78796 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
78797 mmput(mm);
78798 mm = ERR_PTR(-EACCES);
78799 }
78800 @@ -918,13 +961,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
78801 spin_unlock(&fs->lock);
78802 return -EAGAIN;
78803 }
78804 - fs->users++;
78805 + atomic_inc(&fs->users);
78806 spin_unlock(&fs->lock);
78807 return 0;
78808 }
78809 tsk->fs = copy_fs_struct(fs);
78810 if (!tsk->fs)
78811 return -ENOMEM;
78812 + /* Carry through gr_chroot_dentry and is_chrooted instead
78813 + of recomputing it here. Already copied when the task struct
78814 + is duplicated. This allows pivot_root to not be treated as
78815 + a chroot
78816 + */
78817 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
78818 +
78819 return 0;
78820 }
78821
78822 @@ -1197,10 +1247,13 @@ static struct task_struct *copy_process(unsigned long clone_flags,
78823 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
78824 #endif
78825 retval = -EAGAIN;
78826 +
78827 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
78828 +
78829 if (atomic_read(&p->real_cred->user->processes) >=
78830 task_rlimit(p, RLIMIT_NPROC)) {
78831 - if (!capable(CAP_SYS_ADMIN) && !capable(CAP_SYS_RESOURCE) &&
78832 - p->real_cred->user != INIT_USER)
78833 + if (p->real_cred->user != INIT_USER &&
78834 + !capable(CAP_SYS_RESOURCE) && !capable(CAP_SYS_ADMIN))
78835 goto bad_fork_free;
78836 }
78837 current->flags &= ~PF_NPROC_EXCEEDED;
78838 @@ -1446,6 +1499,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
78839 goto bad_fork_free_pid;
78840 }
78841
78842 + /* synchronizes with gr_set_acls()
78843 + we need to call this past the point of no return for fork()
78844 + */
78845 + gr_copy_label(p);
78846 +
78847 if (clone_flags & CLONE_THREAD) {
78848 current->signal->nr_threads++;
78849 atomic_inc(&current->signal->live);
78850 @@ -1529,6 +1587,8 @@ bad_fork_cleanup_count:
78851 bad_fork_free:
78852 free_task(p);
78853 fork_out:
78854 + gr_log_forkfail(retval);
78855 +
78856 return ERR_PTR(retval);
78857 }
78858
78859 @@ -1613,6 +1673,8 @@ long do_fork(unsigned long clone_flags,
78860 if (clone_flags & CLONE_PARENT_SETTID)
78861 put_user(nr, parent_tidptr);
78862
78863 + gr_handle_brute_check();
78864 +
78865 if (clone_flags & CLONE_VFORK) {
78866 p->vfork_done = &vfork;
78867 init_completion(&vfork);
78868 @@ -1729,7 +1791,7 @@ void __init proc_caches_init(void)
78869 mm_cachep = kmem_cache_create("mm_struct",
78870 sizeof(struct mm_struct), ARCH_MIN_MMSTRUCT_ALIGN,
78871 SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_NOTRACK, NULL);
78872 - vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC);
78873 + vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC | SLAB_NO_SANITIZE);
78874 mmap_init();
78875 nsproxy_cache_init();
78876 }
78877 @@ -1769,7 +1831,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
78878 return 0;
78879
78880 /* don't need lock here; in the worst case we'll do useless copy */
78881 - if (fs->users == 1)
78882 + if (atomic_read(&fs->users) == 1)
78883 return 0;
78884
78885 *new_fsp = copy_fs_struct(fs);
78886 @@ -1881,7 +1943,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
78887 fs = current->fs;
78888 spin_lock(&fs->lock);
78889 current->fs = new_fs;
78890 - if (--fs->users)
78891 + gr_set_chroot_entries(current, &current->fs->root);
78892 + if (atomic_dec_return(&fs->users))
78893 new_fs = NULL;
78894 else
78895 new_fs = fs;
78896 diff --git a/kernel/futex.c b/kernel/futex.c
78897 index 49dacfb..5c6b450 100644
78898 --- a/kernel/futex.c
78899 +++ b/kernel/futex.c
78900 @@ -54,6 +54,7 @@
78901 #include <linux/mount.h>
78902 #include <linux/pagemap.h>
78903 #include <linux/syscalls.h>
78904 +#include <linux/ptrace.h>
78905 #include <linux/signal.h>
78906 #include <linux/export.h>
78907 #include <linux/magic.h>
78908 @@ -242,6 +243,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
78909 struct page *page, *page_head;
78910 int err, ro = 0;
78911
78912 +#ifdef CONFIG_PAX_SEGMEXEC
78913 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
78914 + return -EFAULT;
78915 +#endif
78916 +
78917 /*
78918 * The futex address must be "naturally" aligned.
78919 */
78920 @@ -2733,6 +2739,7 @@ static int __init futex_init(void)
78921 {
78922 u32 curval;
78923 int i;
78924 + mm_segment_t oldfs;
78925
78926 /*
78927 * This will fail and we want it. Some arch implementations do
78928 @@ -2744,8 +2751,11 @@ static int __init futex_init(void)
78929 * implementation, the non-functional ones will return
78930 * -ENOSYS.
78931 */
78932 + oldfs = get_fs();
78933 + set_fs(USER_DS);
78934 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
78935 futex_cmpxchg_enabled = 1;
78936 + set_fs(oldfs);
78937
78938 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
78939 plist_head_init(&futex_queues[i].chain);
78940 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
78941 index f9f44fd..29885e4 100644
78942 --- a/kernel/futex_compat.c
78943 +++ b/kernel/futex_compat.c
78944 @@ -32,7 +32,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
78945 return 0;
78946 }
78947
78948 -static void __user *futex_uaddr(struct robust_list __user *entry,
78949 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
78950 compat_long_t futex_offset)
78951 {
78952 compat_uptr_t base = ptr_to_compat(entry);
78953 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
78954 index 9b22d03..6295b62 100644
78955 --- a/kernel/gcov/base.c
78956 +++ b/kernel/gcov/base.c
78957 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
78958 }
78959
78960 #ifdef CONFIG_MODULES
78961 -static inline int within(void *addr, void *start, unsigned long size)
78962 -{
78963 - return ((addr >= start) && (addr < start + size));
78964 -}
78965 -
78966 /* Update list and generate events when modules are unloaded. */
78967 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
78968 void *data)
78969 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
78970 prev = NULL;
78971 /* Remove entries located in module from linked list. */
78972 for (info = gcov_info_head; info; info = info->next) {
78973 - if (within(info, mod->module_core, mod->core_size)) {
78974 + if (within_module_core_rw((unsigned long)info, mod)) {
78975 if (prev)
78976 prev->next = info->next;
78977 else
78978 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
78979 index 2288fbd..0f3941f 100644
78980 --- a/kernel/hrtimer.c
78981 +++ b/kernel/hrtimer.c
78982 @@ -1435,7 +1435,7 @@ void hrtimer_peek_ahead_timers(void)
78983 local_irq_restore(flags);
78984 }
78985
78986 -static void run_hrtimer_softirq(struct softirq_action *h)
78987 +static void run_hrtimer_softirq(void)
78988 {
78989 hrtimer_peek_ahead_timers();
78990 }
78991 @@ -1770,7 +1770,7 @@ static int __cpuinit hrtimer_cpu_notify(struct notifier_block *self,
78992 return NOTIFY_OK;
78993 }
78994
78995 -static struct notifier_block __cpuinitdata hrtimers_nb = {
78996 +static struct notifier_block hrtimers_nb = {
78997 .notifier_call = hrtimer_cpu_notify,
78998 };
78999
79000 diff --git a/kernel/irq_work.c b/kernel/irq_work.c
79001 index 55fcce6..0e4cf34 100644
79002 --- a/kernel/irq_work.c
79003 +++ b/kernel/irq_work.c
79004 @@ -189,12 +189,13 @@ static int irq_work_cpu_notify(struct notifier_block *self,
79005 return NOTIFY_OK;
79006 }
79007
79008 -static struct notifier_block cpu_notify;
79009 +static struct notifier_block cpu_notify = {
79010 + .notifier_call = irq_work_cpu_notify,
79011 + .priority = 0,
79012 +};
79013
79014 static __init int irq_work_init_cpu_notifier(void)
79015 {
79016 - cpu_notify.notifier_call = irq_work_cpu_notify;
79017 - cpu_notify.priority = 0;
79018 register_cpu_notifier(&cpu_notify);
79019 return 0;
79020 }
79021 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
79022 index 60f48fa..7f3a770 100644
79023 --- a/kernel/jump_label.c
79024 +++ b/kernel/jump_label.c
79025 @@ -13,6 +13,7 @@
79026 #include <linux/sort.h>
79027 #include <linux/err.h>
79028 #include <linux/static_key.h>
79029 +#include <linux/mm.h>
79030
79031 #ifdef HAVE_JUMP_LABEL
79032
79033 @@ -50,7 +51,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
79034
79035 size = (((unsigned long)stop - (unsigned long)start)
79036 / sizeof(struct jump_entry));
79037 + pax_open_kernel();
79038 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
79039 + pax_close_kernel();
79040 }
79041
79042 static void jump_label_update(struct static_key *key, int enable);
79043 @@ -357,10 +360,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
79044 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
79045 struct jump_entry *iter;
79046
79047 + pax_open_kernel();
79048 for (iter = iter_start; iter < iter_stop; iter++) {
79049 if (within_module_init(iter->code, mod))
79050 iter->code = 0;
79051 }
79052 + pax_close_kernel();
79053 }
79054
79055 static int
79056 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
79057 index 3127ad5..159d880 100644
79058 --- a/kernel/kallsyms.c
79059 +++ b/kernel/kallsyms.c
79060 @@ -11,6 +11,9 @@
79061 * Changed the compression method from stem compression to "table lookup"
79062 * compression (see scripts/kallsyms.c for a more complete description)
79063 */
79064 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79065 +#define __INCLUDED_BY_HIDESYM 1
79066 +#endif
79067 #include <linux/kallsyms.h>
79068 #include <linux/module.h>
79069 #include <linux/init.h>
79070 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
79071
79072 static inline int is_kernel_inittext(unsigned long addr)
79073 {
79074 + if (system_state != SYSTEM_BOOTING)
79075 + return 0;
79076 +
79077 if (addr >= (unsigned long)_sinittext
79078 && addr <= (unsigned long)_einittext)
79079 return 1;
79080 return 0;
79081 }
79082
79083 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
79084 +#ifdef CONFIG_MODULES
79085 +static inline int is_module_text(unsigned long addr)
79086 +{
79087 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
79088 + return 1;
79089 +
79090 + addr = ktla_ktva(addr);
79091 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
79092 +}
79093 +#else
79094 +static inline int is_module_text(unsigned long addr)
79095 +{
79096 + return 0;
79097 +}
79098 +#endif
79099 +#endif
79100 +
79101 static inline int is_kernel_text(unsigned long addr)
79102 {
79103 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
79104 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
79105
79106 static inline int is_kernel(unsigned long addr)
79107 {
79108 +
79109 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
79110 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
79111 + return 1;
79112 +
79113 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
79114 +#else
79115 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
79116 +#endif
79117 +
79118 return 1;
79119 return in_gate_area_no_mm(addr);
79120 }
79121
79122 static int is_ksym_addr(unsigned long addr)
79123 {
79124 +
79125 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
79126 + if (is_module_text(addr))
79127 + return 0;
79128 +#endif
79129 +
79130 if (all_var)
79131 return is_kernel(addr);
79132
79133 @@ -480,7 +519,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
79134
79135 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
79136 {
79137 - iter->name[0] = '\0';
79138 iter->nameoff = get_symbol_offset(new_pos);
79139 iter->pos = new_pos;
79140 }
79141 @@ -528,6 +566,11 @@ static int s_show(struct seq_file *m, void *p)
79142 {
79143 struct kallsym_iter *iter = m->private;
79144
79145 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79146 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
79147 + return 0;
79148 +#endif
79149 +
79150 /* Some debugging symbols have no name. Ignore them. */
79151 if (!iter->name[0])
79152 return 0;
79153 @@ -541,6 +584,7 @@ static int s_show(struct seq_file *m, void *p)
79154 */
79155 type = iter->exported ? toupper(iter->type) :
79156 tolower(iter->type);
79157 +
79158 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
79159 type, iter->name, iter->module_name);
79160 } else
79161 @@ -566,7 +610,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
79162 struct kallsym_iter *iter;
79163 int ret;
79164
79165 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
79166 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
79167 if (!iter)
79168 return -ENOMEM;
79169 reset_iter(iter, 0);
79170 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
79171 index e30ac0f..3528cac 100644
79172 --- a/kernel/kcmp.c
79173 +++ b/kernel/kcmp.c
79174 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
79175 struct task_struct *task1, *task2;
79176 int ret;
79177
79178 +#ifdef CONFIG_GRKERNSEC
79179 + return -ENOSYS;
79180 +#endif
79181 +
79182 rcu_read_lock();
79183
79184 /*
79185 diff --git a/kernel/kexec.c b/kernel/kexec.c
79186 index 59f7b55..4022f65 100644
79187 --- a/kernel/kexec.c
79188 +++ b/kernel/kexec.c
79189 @@ -1041,7 +1041,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
79190 unsigned long flags)
79191 {
79192 struct compat_kexec_segment in;
79193 - struct kexec_segment out, __user *ksegments;
79194 + struct kexec_segment out;
79195 + struct kexec_segment __user *ksegments;
79196 unsigned long i, result;
79197
79198 /* Don't allow clients that don't understand the native
79199 diff --git a/kernel/kmod.c b/kernel/kmod.c
79200 index 8241906..d625f2c 100644
79201 --- a/kernel/kmod.c
79202 +++ b/kernel/kmod.c
79203 @@ -75,7 +75,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
79204 kfree(info->argv);
79205 }
79206
79207 -static int call_modprobe(char *module_name, int wait)
79208 +static int call_modprobe(char *module_name, char *module_param, int wait)
79209 {
79210 struct subprocess_info *info;
79211 static char *envp[] = {
79212 @@ -85,7 +85,7 @@ static int call_modprobe(char *module_name, int wait)
79213 NULL
79214 };
79215
79216 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
79217 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
79218 if (!argv)
79219 goto out;
79220
79221 @@ -97,7 +97,8 @@ static int call_modprobe(char *module_name, int wait)
79222 argv[1] = "-q";
79223 argv[2] = "--";
79224 argv[3] = module_name; /* check free_modprobe_argv() */
79225 - argv[4] = NULL;
79226 + argv[4] = module_param;
79227 + argv[5] = NULL;
79228
79229 info = call_usermodehelper_setup(modprobe_path, argv, envp, GFP_KERNEL,
79230 NULL, free_modprobe_argv, NULL);
79231 @@ -129,9 +130,8 @@ out:
79232 * If module auto-loading support is disabled then this function
79233 * becomes a no-operation.
79234 */
79235 -int __request_module(bool wait, const char *fmt, ...)
79236 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
79237 {
79238 - va_list args;
79239 char module_name[MODULE_NAME_LEN];
79240 unsigned int max_modprobes;
79241 int ret;
79242 @@ -147,9 +147,7 @@ int __request_module(bool wait, const char *fmt, ...)
79243 */
79244 WARN_ON_ONCE(wait && current_is_async());
79245
79246 - va_start(args, fmt);
79247 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
79248 - va_end(args);
79249 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
79250 if (ret >= MODULE_NAME_LEN)
79251 return -ENAMETOOLONG;
79252
79253 @@ -157,6 +155,20 @@ int __request_module(bool wait, const char *fmt, ...)
79254 if (ret)
79255 return ret;
79256
79257 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
79258 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
79259 + /* hack to workaround consolekit/udisks stupidity */
79260 + read_lock(&tasklist_lock);
79261 + if (!strcmp(current->comm, "mount") &&
79262 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
79263 + read_unlock(&tasklist_lock);
79264 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
79265 + return -EPERM;
79266 + }
79267 + read_unlock(&tasklist_lock);
79268 + }
79269 +#endif
79270 +
79271 /* If modprobe needs a service that is in a module, we get a recursive
79272 * loop. Limit the number of running kmod threads to max_threads/2 or
79273 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
79274 @@ -185,11 +197,52 @@ int __request_module(bool wait, const char *fmt, ...)
79275
79276 trace_module_request(module_name, wait, _RET_IP_);
79277
79278 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
79279 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
79280
79281 atomic_dec(&kmod_concurrent);
79282 return ret;
79283 }
79284 +
79285 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
79286 +{
79287 + va_list args;
79288 + int ret;
79289 +
79290 + va_start(args, fmt);
79291 + ret = ____request_module(wait, module_param, fmt, args);
79292 + va_end(args);
79293 +
79294 + return ret;
79295 +}
79296 +
79297 +int __request_module(bool wait, const char *fmt, ...)
79298 +{
79299 + va_list args;
79300 + int ret;
79301 +
79302 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
79303 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
79304 + char module_param[MODULE_NAME_LEN];
79305 +
79306 + memset(module_param, 0, sizeof(module_param));
79307 +
79308 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
79309 +
79310 + va_start(args, fmt);
79311 + ret = ____request_module(wait, module_param, fmt, args);
79312 + va_end(args);
79313 +
79314 + return ret;
79315 + }
79316 +#endif
79317 +
79318 + va_start(args, fmt);
79319 + ret = ____request_module(wait, NULL, fmt, args);
79320 + va_end(args);
79321 +
79322 + return ret;
79323 +}
79324 +
79325 EXPORT_SYMBOL(__request_module);
79326 #endif /* CONFIG_MODULES */
79327
79328 @@ -300,7 +353,7 @@ static int wait_for_helper(void *data)
79329 *
79330 * Thus the __user pointer cast is valid here.
79331 */
79332 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
79333 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
79334
79335 /*
79336 * If ret is 0, either ____call_usermodehelper failed and the
79337 @@ -651,7 +704,7 @@ EXPORT_SYMBOL(call_usermodehelper);
79338 static int proc_cap_handler(struct ctl_table *table, int write,
79339 void __user *buffer, size_t *lenp, loff_t *ppos)
79340 {
79341 - struct ctl_table t;
79342 + ctl_table_no_const t;
79343 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
79344 kernel_cap_t new_cap;
79345 int err, i;
79346 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
79347 index bddf3b2..233bf40 100644
79348 --- a/kernel/kprobes.c
79349 +++ b/kernel/kprobes.c
79350 @@ -31,6 +31,9 @@
79351 * <jkenisto@us.ibm.com> and Prasanna S Panchamukhi
79352 * <prasanna@in.ibm.com> added function-return probes.
79353 */
79354 +#ifdef CONFIG_GRKERNSEC_HIDESYM
79355 +#define __INCLUDED_BY_HIDESYM 1
79356 +#endif
79357 #include <linux/kprobes.h>
79358 #include <linux/hash.h>
79359 #include <linux/init.h>
79360 @@ -185,7 +188,7 @@ static kprobe_opcode_t __kprobes *__get_insn_slot(struct kprobe_insn_cache *c)
79361 * kernel image and loaded module images reside. This is required
79362 * so x86_64 can correctly handle the %rip-relative fixups.
79363 */
79364 - kip->insns = module_alloc(PAGE_SIZE);
79365 + kip->insns = module_alloc_exec(PAGE_SIZE);
79366 if (!kip->insns) {
79367 kfree(kip);
79368 return NULL;
79369 @@ -225,7 +228,7 @@ static int __kprobes collect_one_slot(struct kprobe_insn_page *kip, int idx)
79370 */
79371 if (!list_is_singular(&kip->list)) {
79372 list_del(&kip->list);
79373 - module_free(NULL, kip->insns);
79374 + module_free_exec(NULL, kip->insns);
79375 kfree(kip);
79376 }
79377 return 1;
79378 @@ -2083,7 +2086,7 @@ static int __init init_kprobes(void)
79379 {
79380 int i, err = 0;
79381 unsigned long offset = 0, size = 0;
79382 - char *modname, namebuf[128];
79383 + char *modname, namebuf[KSYM_NAME_LEN];
79384 const char *symbol_name;
79385 void *addr;
79386 struct kprobe_blackpoint *kb;
79387 @@ -2168,11 +2171,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
79388 kprobe_type = "k";
79389
79390 if (sym)
79391 - seq_printf(pi, "%p %s %s+0x%x %s ",
79392 + seq_printf(pi, "%pK %s %s+0x%x %s ",
79393 p->addr, kprobe_type, sym, offset,
79394 (modname ? modname : " "));
79395 else
79396 - seq_printf(pi, "%p %s %p ",
79397 + seq_printf(pi, "%pK %s %pK ",
79398 p->addr, kprobe_type, p->addr);
79399
79400 if (!pp)
79401 @@ -2209,7 +2212,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
79402 const char *sym = NULL;
79403 unsigned int i = *(loff_t *) v;
79404 unsigned long offset = 0;
79405 - char *modname, namebuf[128];
79406 + char *modname, namebuf[KSYM_NAME_LEN];
79407
79408 head = &kprobe_table[i];
79409 preempt_disable();
79410 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
79411 index 6ada93c..dce7d5d 100644
79412 --- a/kernel/ksysfs.c
79413 +++ b/kernel/ksysfs.c
79414 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
79415 {
79416 if (count+1 > UEVENT_HELPER_PATH_LEN)
79417 return -ENOENT;
79418 + if (!capable(CAP_SYS_ADMIN))
79419 + return -EPERM;
79420 memcpy(uevent_helper, buf, count);
79421 uevent_helper[count] = '\0';
79422 if (count && uevent_helper[count-1] == '\n')
79423 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
79424 return count;
79425 }
79426
79427 -static struct bin_attribute notes_attr = {
79428 +static bin_attribute_no_const notes_attr __read_only = {
79429 .attr = {
79430 .name = "notes",
79431 .mode = S_IRUGO,
79432 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
79433 index 1f3186b..bb7dbc6 100644
79434 --- a/kernel/lockdep.c
79435 +++ b/kernel/lockdep.c
79436 @@ -596,6 +596,10 @@ static int static_obj(void *obj)
79437 end = (unsigned long) &_end,
79438 addr = (unsigned long) obj;
79439
79440 +#ifdef CONFIG_PAX_KERNEXEC
79441 + start = ktla_ktva(start);
79442 +#endif
79443 +
79444 /*
79445 * static variable?
79446 */
79447 @@ -736,6 +740,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
79448 if (!static_obj(lock->key)) {
79449 debug_locks_off();
79450 printk("INFO: trying to register non-static key.\n");
79451 + printk("lock:%pS key:%pS.\n", lock, lock->key);
79452 printk("the code is fine but needs lockdep annotation.\n");
79453 printk("turning off the locking correctness validator.\n");
79454 dump_stack();
79455 @@ -3080,7 +3085,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
79456 if (!class)
79457 return 0;
79458 }
79459 - atomic_inc((atomic_t *)&class->ops);
79460 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
79461 if (very_verbose(class)) {
79462 printk("\nacquire class [%p] %s", class->key, class->name);
79463 if (class->name_version > 1)
79464 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
79465 index b2c71c5..7b88d63 100644
79466 --- a/kernel/lockdep_proc.c
79467 +++ b/kernel/lockdep_proc.c
79468 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
79469 return 0;
79470 }
79471
79472 - seq_printf(m, "%p", class->key);
79473 + seq_printf(m, "%pK", class->key);
79474 #ifdef CONFIG_DEBUG_LOCKDEP
79475 seq_printf(m, " OPS:%8ld", class->ops);
79476 #endif
79477 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
79478
79479 list_for_each_entry(entry, &class->locks_after, entry) {
79480 if (entry->distance == 1) {
79481 - seq_printf(m, " -> [%p] ", entry->class->key);
79482 + seq_printf(m, " -> [%pK] ", entry->class->key);
79483 print_name(m, entry->class);
79484 seq_puts(m, "\n");
79485 }
79486 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
79487 if (!class->key)
79488 continue;
79489
79490 - seq_printf(m, "[%p] ", class->key);
79491 + seq_printf(m, "[%pK] ", class->key);
79492 print_name(m, class);
79493 seq_puts(m, "\n");
79494 }
79495 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
79496 if (!i)
79497 seq_line(m, '-', 40-namelen, namelen);
79498
79499 - snprintf(ip, sizeof(ip), "[<%p>]",
79500 + snprintf(ip, sizeof(ip), "[<%pK>]",
79501 (void *)class->contention_point[i]);
79502 seq_printf(m, "%40s %14lu %29s %pS\n",
79503 name, stats->contention_point[i],
79504 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
79505 if (!i)
79506 seq_line(m, '-', 40-namelen, namelen);
79507
79508 - snprintf(ip, sizeof(ip), "[<%p>]",
79509 + snprintf(ip, sizeof(ip), "[<%pK>]",
79510 (void *)class->contending_point[i]);
79511 seq_printf(m, "%40s %14lu %29s %pS\n",
79512 name, stats->contending_point[i],
79513 diff --git a/kernel/module.c b/kernel/module.c
79514 index fa53db8..6f17200 100644
79515 --- a/kernel/module.c
79516 +++ b/kernel/module.c
79517 @@ -61,6 +61,7 @@
79518 #include <linux/pfn.h>
79519 #include <linux/bsearch.h>
79520 #include <linux/fips.h>
79521 +#include <linux/grsecurity.h>
79522 #include <uapi/linux/module.h>
79523 #include "module-internal.h"
79524
79525 @@ -156,7 +157,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
79526
79527 /* Bounds of module allocation, for speeding __module_address.
79528 * Protected by module_mutex. */
79529 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
79530 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
79531 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
79532
79533 int register_module_notifier(struct notifier_block * nb)
79534 {
79535 @@ -323,7 +325,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
79536 return true;
79537
79538 list_for_each_entry_rcu(mod, &modules, list) {
79539 - struct symsearch arr[] = {
79540 + struct symsearch modarr[] = {
79541 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
79542 NOT_GPL_ONLY, false },
79543 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
79544 @@ -348,7 +350,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
79545 if (mod->state == MODULE_STATE_UNFORMED)
79546 continue;
79547
79548 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
79549 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
79550 return true;
79551 }
79552 return false;
79553 @@ -485,7 +487,7 @@ static inline void __percpu *mod_percpu(struct module *mod)
79554 static int percpu_modalloc(struct module *mod,
79555 unsigned long size, unsigned long align)
79556 {
79557 - if (align > PAGE_SIZE) {
79558 + if (align-1 >= PAGE_SIZE) {
79559 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
79560 mod->name, align, PAGE_SIZE);
79561 align = PAGE_SIZE;
79562 @@ -1089,7 +1091,7 @@ struct module_attribute module_uevent =
79563 static ssize_t show_coresize(struct module_attribute *mattr,
79564 struct module_kobject *mk, char *buffer)
79565 {
79566 - return sprintf(buffer, "%u\n", mk->mod->core_size);
79567 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
79568 }
79569
79570 static struct module_attribute modinfo_coresize =
79571 @@ -1098,7 +1100,7 @@ static struct module_attribute modinfo_coresize =
79572 static ssize_t show_initsize(struct module_attribute *mattr,
79573 struct module_kobject *mk, char *buffer)
79574 {
79575 - return sprintf(buffer, "%u\n", mk->mod->init_size);
79576 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
79577 }
79578
79579 static struct module_attribute modinfo_initsize =
79580 @@ -1313,7 +1315,7 @@ resolve_symbol_wait(struct module *mod,
79581 */
79582 #ifdef CONFIG_SYSFS
79583
79584 -#ifdef CONFIG_KALLSYMS
79585 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
79586 static inline bool sect_empty(const Elf_Shdr *sect)
79587 {
79588 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
79589 @@ -1453,7 +1455,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
79590 {
79591 unsigned int notes, loaded, i;
79592 struct module_notes_attrs *notes_attrs;
79593 - struct bin_attribute *nattr;
79594 + bin_attribute_no_const *nattr;
79595
79596 /* failed to create section attributes, so can't create notes */
79597 if (!mod->sect_attrs)
79598 @@ -1565,7 +1567,7 @@ static void del_usage_links(struct module *mod)
79599 static int module_add_modinfo_attrs(struct module *mod)
79600 {
79601 struct module_attribute *attr;
79602 - struct module_attribute *temp_attr;
79603 + module_attribute_no_const *temp_attr;
79604 int error = 0;
79605 int i;
79606
79607 @@ -1779,21 +1781,21 @@ static void set_section_ro_nx(void *base,
79608
79609 static void unset_module_core_ro_nx(struct module *mod)
79610 {
79611 - set_page_attributes(mod->module_core + mod->core_text_size,
79612 - mod->module_core + mod->core_size,
79613 + set_page_attributes(mod->module_core_rw,
79614 + mod->module_core_rw + mod->core_size_rw,
79615 set_memory_x);
79616 - set_page_attributes(mod->module_core,
79617 - mod->module_core + mod->core_ro_size,
79618 + set_page_attributes(mod->module_core_rx,
79619 + mod->module_core_rx + mod->core_size_rx,
79620 set_memory_rw);
79621 }
79622
79623 static void unset_module_init_ro_nx(struct module *mod)
79624 {
79625 - set_page_attributes(mod->module_init + mod->init_text_size,
79626 - mod->module_init + mod->init_size,
79627 + set_page_attributes(mod->module_init_rw,
79628 + mod->module_init_rw + mod->init_size_rw,
79629 set_memory_x);
79630 - set_page_attributes(mod->module_init,
79631 - mod->module_init + mod->init_ro_size,
79632 + set_page_attributes(mod->module_init_rx,
79633 + mod->module_init_rx + mod->init_size_rx,
79634 set_memory_rw);
79635 }
79636
79637 @@ -1806,14 +1808,14 @@ void set_all_modules_text_rw(void)
79638 list_for_each_entry_rcu(mod, &modules, list) {
79639 if (mod->state == MODULE_STATE_UNFORMED)
79640 continue;
79641 - if ((mod->module_core) && (mod->core_text_size)) {
79642 - set_page_attributes(mod->module_core,
79643 - mod->module_core + mod->core_text_size,
79644 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
79645 + set_page_attributes(mod->module_core_rx,
79646 + mod->module_core_rx + mod->core_size_rx,
79647 set_memory_rw);
79648 }
79649 - if ((mod->module_init) && (mod->init_text_size)) {
79650 - set_page_attributes(mod->module_init,
79651 - mod->module_init + mod->init_text_size,
79652 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
79653 + set_page_attributes(mod->module_init_rx,
79654 + mod->module_init_rx + mod->init_size_rx,
79655 set_memory_rw);
79656 }
79657 }
79658 @@ -1829,14 +1831,14 @@ void set_all_modules_text_ro(void)
79659 list_for_each_entry_rcu(mod, &modules, list) {
79660 if (mod->state == MODULE_STATE_UNFORMED)
79661 continue;
79662 - if ((mod->module_core) && (mod->core_text_size)) {
79663 - set_page_attributes(mod->module_core,
79664 - mod->module_core + mod->core_text_size,
79665 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
79666 + set_page_attributes(mod->module_core_rx,
79667 + mod->module_core_rx + mod->core_size_rx,
79668 set_memory_ro);
79669 }
79670 - if ((mod->module_init) && (mod->init_text_size)) {
79671 - set_page_attributes(mod->module_init,
79672 - mod->module_init + mod->init_text_size,
79673 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
79674 + set_page_attributes(mod->module_init_rx,
79675 + mod->module_init_rx + mod->init_size_rx,
79676 set_memory_ro);
79677 }
79678 }
79679 @@ -1887,16 +1889,19 @@ static void free_module(struct module *mod)
79680
79681 /* This may be NULL, but that's OK */
79682 unset_module_init_ro_nx(mod);
79683 - module_free(mod, mod->module_init);
79684 + module_free(mod, mod->module_init_rw);
79685 + module_free_exec(mod, mod->module_init_rx);
79686 kfree(mod->args);
79687 percpu_modfree(mod);
79688
79689 /* Free lock-classes: */
79690 - lockdep_free_key_range(mod->module_core, mod->core_size);
79691 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
79692 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
79693
79694 /* Finally, free the core (containing the module structure) */
79695 unset_module_core_ro_nx(mod);
79696 - module_free(mod, mod->module_core);
79697 + module_free_exec(mod, mod->module_core_rx);
79698 + module_free(mod, mod->module_core_rw);
79699
79700 #ifdef CONFIG_MPU
79701 update_protections(current->mm);
79702 @@ -1966,9 +1971,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
79703 int ret = 0;
79704 const struct kernel_symbol *ksym;
79705
79706 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
79707 + int is_fs_load = 0;
79708 + int register_filesystem_found = 0;
79709 + char *p;
79710 +
79711 + p = strstr(mod->args, "grsec_modharden_fs");
79712 + if (p) {
79713 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
79714 + /* copy \0 as well */
79715 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
79716 + is_fs_load = 1;
79717 + }
79718 +#endif
79719 +
79720 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
79721 const char *name = info->strtab + sym[i].st_name;
79722
79723 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
79724 + /* it's a real shame this will never get ripped and copied
79725 + upstream! ;(
79726 + */
79727 + if (is_fs_load && !strcmp(name, "register_filesystem"))
79728 + register_filesystem_found = 1;
79729 +#endif
79730 +
79731 switch (sym[i].st_shndx) {
79732 case SHN_COMMON:
79733 /* We compiled with -fno-common. These are not
79734 @@ -1989,7 +2016,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
79735 ksym = resolve_symbol_wait(mod, info, name);
79736 /* Ok if resolved. */
79737 if (ksym && !IS_ERR(ksym)) {
79738 + pax_open_kernel();
79739 sym[i].st_value = ksym->value;
79740 + pax_close_kernel();
79741 break;
79742 }
79743
79744 @@ -2008,11 +2037,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
79745 secbase = (unsigned long)mod_percpu(mod);
79746 else
79747 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
79748 + pax_open_kernel();
79749 sym[i].st_value += secbase;
79750 + pax_close_kernel();
79751 break;
79752 }
79753 }
79754
79755 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
79756 + if (is_fs_load && !register_filesystem_found) {
79757 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
79758 + ret = -EPERM;
79759 + }
79760 +#endif
79761 +
79762 return ret;
79763 }
79764
79765 @@ -2096,22 +2134,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
79766 || s->sh_entsize != ~0UL
79767 || strstarts(sname, ".init"))
79768 continue;
79769 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
79770 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
79771 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
79772 + else
79773 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
79774 pr_debug("\t%s\n", sname);
79775 }
79776 - switch (m) {
79777 - case 0: /* executable */
79778 - mod->core_size = debug_align(mod->core_size);
79779 - mod->core_text_size = mod->core_size;
79780 - break;
79781 - case 1: /* RO: text and ro-data */
79782 - mod->core_size = debug_align(mod->core_size);
79783 - mod->core_ro_size = mod->core_size;
79784 - break;
79785 - case 3: /* whole core */
79786 - mod->core_size = debug_align(mod->core_size);
79787 - break;
79788 - }
79789 }
79790
79791 pr_debug("Init section allocation order:\n");
79792 @@ -2125,23 +2153,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
79793 || s->sh_entsize != ~0UL
79794 || !strstarts(sname, ".init"))
79795 continue;
79796 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
79797 - | INIT_OFFSET_MASK);
79798 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
79799 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
79800 + else
79801 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
79802 + s->sh_entsize |= INIT_OFFSET_MASK;
79803 pr_debug("\t%s\n", sname);
79804 }
79805 - switch (m) {
79806 - case 0: /* executable */
79807 - mod->init_size = debug_align(mod->init_size);
79808 - mod->init_text_size = mod->init_size;
79809 - break;
79810 - case 1: /* RO: text and ro-data */
79811 - mod->init_size = debug_align(mod->init_size);
79812 - mod->init_ro_size = mod->init_size;
79813 - break;
79814 - case 3: /* whole init */
79815 - mod->init_size = debug_align(mod->init_size);
79816 - break;
79817 - }
79818 }
79819 }
79820
79821 @@ -2314,7 +2332,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
79822
79823 /* Put symbol section at end of init part of module. */
79824 symsect->sh_flags |= SHF_ALLOC;
79825 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
79826 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
79827 info->index.sym) | INIT_OFFSET_MASK;
79828 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
79829
79830 @@ -2331,13 +2349,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
79831 }
79832
79833 /* Append room for core symbols at end of core part. */
79834 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
79835 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
79836 - mod->core_size += strtab_size;
79837 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
79838 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
79839 + mod->core_size_rx += strtab_size;
79840
79841 /* Put string table section at end of init part of module. */
79842 strsect->sh_flags |= SHF_ALLOC;
79843 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
79844 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
79845 info->index.str) | INIT_OFFSET_MASK;
79846 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
79847 }
79848 @@ -2355,12 +2373,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
79849 /* Make sure we get permanent strtab: don't use info->strtab. */
79850 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
79851
79852 + pax_open_kernel();
79853 +
79854 /* Set types up while we still have access to sections. */
79855 for (i = 0; i < mod->num_symtab; i++)
79856 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
79857
79858 - mod->core_symtab = dst = mod->module_core + info->symoffs;
79859 - mod->core_strtab = s = mod->module_core + info->stroffs;
79860 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
79861 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
79862 src = mod->symtab;
79863 for (ndst = i = 0; i < mod->num_symtab; i++) {
79864 if (i == 0 ||
79865 @@ -2372,6 +2392,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
79866 }
79867 }
79868 mod->core_num_syms = ndst;
79869 +
79870 + pax_close_kernel();
79871 }
79872 #else
79873 static inline void layout_symtab(struct module *mod, struct load_info *info)
79874 @@ -2405,17 +2427,33 @@ void * __weak module_alloc(unsigned long size)
79875 return vmalloc_exec(size);
79876 }
79877
79878 -static void *module_alloc_update_bounds(unsigned long size)
79879 +static void *module_alloc_update_bounds_rw(unsigned long size)
79880 {
79881 void *ret = module_alloc(size);
79882
79883 if (ret) {
79884 mutex_lock(&module_mutex);
79885 /* Update module bounds. */
79886 - if ((unsigned long)ret < module_addr_min)
79887 - module_addr_min = (unsigned long)ret;
79888 - if ((unsigned long)ret + size > module_addr_max)
79889 - module_addr_max = (unsigned long)ret + size;
79890 + if ((unsigned long)ret < module_addr_min_rw)
79891 + module_addr_min_rw = (unsigned long)ret;
79892 + if ((unsigned long)ret + size > module_addr_max_rw)
79893 + module_addr_max_rw = (unsigned long)ret + size;
79894 + mutex_unlock(&module_mutex);
79895 + }
79896 + return ret;
79897 +}
79898 +
79899 +static void *module_alloc_update_bounds_rx(unsigned long size)
79900 +{
79901 + void *ret = module_alloc_exec(size);
79902 +
79903 + if (ret) {
79904 + mutex_lock(&module_mutex);
79905 + /* Update module bounds. */
79906 + if ((unsigned long)ret < module_addr_min_rx)
79907 + module_addr_min_rx = (unsigned long)ret;
79908 + if ((unsigned long)ret + size > module_addr_max_rx)
79909 + module_addr_max_rx = (unsigned long)ret + size;
79910 mutex_unlock(&module_mutex);
79911 }
79912 return ret;
79913 @@ -2691,8 +2729,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
79914 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
79915 {
79916 const char *modmagic = get_modinfo(info, "vermagic");
79917 + const char *license = get_modinfo(info, "license");
79918 int err;
79919
79920 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
79921 + if (!license || !license_is_gpl_compatible(license))
79922 + return -ENOEXEC;
79923 +#endif
79924 +
79925 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
79926 modmagic = NULL;
79927
79928 @@ -2718,7 +2762,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
79929 }
79930
79931 /* Set up license info based on the info section */
79932 - set_license(mod, get_modinfo(info, "license"));
79933 + set_license(mod, license);
79934
79935 return 0;
79936 }
79937 @@ -2799,7 +2843,7 @@ static int move_module(struct module *mod, struct load_info *info)
79938 void *ptr;
79939
79940 /* Do the allocs. */
79941 - ptr = module_alloc_update_bounds(mod->core_size);
79942 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
79943 /*
79944 * The pointer to this block is stored in the module structure
79945 * which is inside the block. Just mark it as not being a
79946 @@ -2809,11 +2853,11 @@ static int move_module(struct module *mod, struct load_info *info)
79947 if (!ptr)
79948 return -ENOMEM;
79949
79950 - memset(ptr, 0, mod->core_size);
79951 - mod->module_core = ptr;
79952 + memset(ptr, 0, mod->core_size_rw);
79953 + mod->module_core_rw = ptr;
79954
79955 - if (mod->init_size) {
79956 - ptr = module_alloc_update_bounds(mod->init_size);
79957 + if (mod->init_size_rw) {
79958 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
79959 /*
79960 * The pointer to this block is stored in the module structure
79961 * which is inside the block. This block doesn't need to be
79962 @@ -2822,13 +2866,45 @@ static int move_module(struct module *mod, struct load_info *info)
79963 */
79964 kmemleak_ignore(ptr);
79965 if (!ptr) {
79966 - module_free(mod, mod->module_core);
79967 + module_free(mod, mod->module_core_rw);
79968 return -ENOMEM;
79969 }
79970 - memset(ptr, 0, mod->init_size);
79971 - mod->module_init = ptr;
79972 + memset(ptr, 0, mod->init_size_rw);
79973 + mod->module_init_rw = ptr;
79974 } else
79975 - mod->module_init = NULL;
79976 + mod->module_init_rw = NULL;
79977 +
79978 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
79979 + kmemleak_not_leak(ptr);
79980 + if (!ptr) {
79981 + if (mod->module_init_rw)
79982 + module_free(mod, mod->module_init_rw);
79983 + module_free(mod, mod->module_core_rw);
79984 + return -ENOMEM;
79985 + }
79986 +
79987 + pax_open_kernel();
79988 + memset(ptr, 0, mod->core_size_rx);
79989 + pax_close_kernel();
79990 + mod->module_core_rx = ptr;
79991 +
79992 + if (mod->init_size_rx) {
79993 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
79994 + kmemleak_ignore(ptr);
79995 + if (!ptr && mod->init_size_rx) {
79996 + module_free_exec(mod, mod->module_core_rx);
79997 + if (mod->module_init_rw)
79998 + module_free(mod, mod->module_init_rw);
79999 + module_free(mod, mod->module_core_rw);
80000 + return -ENOMEM;
80001 + }
80002 +
80003 + pax_open_kernel();
80004 + memset(ptr, 0, mod->init_size_rx);
80005 + pax_close_kernel();
80006 + mod->module_init_rx = ptr;
80007 + } else
80008 + mod->module_init_rx = NULL;
80009
80010 /* Transfer each section which specifies SHF_ALLOC */
80011 pr_debug("final section addresses:\n");
80012 @@ -2839,16 +2915,45 @@ static int move_module(struct module *mod, struct load_info *info)
80013 if (!(shdr->sh_flags & SHF_ALLOC))
80014 continue;
80015
80016 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
80017 - dest = mod->module_init
80018 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
80019 - else
80020 - dest = mod->module_core + shdr->sh_entsize;
80021 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
80022 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
80023 + dest = mod->module_init_rw
80024 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
80025 + else
80026 + dest = mod->module_init_rx
80027 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
80028 + } else {
80029 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
80030 + dest = mod->module_core_rw + shdr->sh_entsize;
80031 + else
80032 + dest = mod->module_core_rx + shdr->sh_entsize;
80033 + }
80034 +
80035 + if (shdr->sh_type != SHT_NOBITS) {
80036 +
80037 +#ifdef CONFIG_PAX_KERNEXEC
80038 +#ifdef CONFIG_X86_64
80039 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
80040 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
80041 +#endif
80042 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
80043 + pax_open_kernel();
80044 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
80045 + pax_close_kernel();
80046 + } else
80047 +#endif
80048
80049 - if (shdr->sh_type != SHT_NOBITS)
80050 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
80051 + }
80052 /* Update sh_addr to point to copy in image. */
80053 - shdr->sh_addr = (unsigned long)dest;
80054 +
80055 +#ifdef CONFIG_PAX_KERNEXEC
80056 + if (shdr->sh_flags & SHF_EXECINSTR)
80057 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
80058 + else
80059 +#endif
80060 +
80061 + shdr->sh_addr = (unsigned long)dest;
80062 pr_debug("\t0x%lx %s\n",
80063 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
80064 }
80065 @@ -2905,12 +3010,12 @@ static void flush_module_icache(const struct module *mod)
80066 * Do it before processing of module parameters, so the module
80067 * can provide parameter accessor functions of its own.
80068 */
80069 - if (mod->module_init)
80070 - flush_icache_range((unsigned long)mod->module_init,
80071 - (unsigned long)mod->module_init
80072 - + mod->init_size);
80073 - flush_icache_range((unsigned long)mod->module_core,
80074 - (unsigned long)mod->module_core + mod->core_size);
80075 + if (mod->module_init_rx)
80076 + flush_icache_range((unsigned long)mod->module_init_rx,
80077 + (unsigned long)mod->module_init_rx
80078 + + mod->init_size_rx);
80079 + flush_icache_range((unsigned long)mod->module_core_rx,
80080 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
80081
80082 set_fs(old_fs);
80083 }
80084 @@ -2977,8 +3082,10 @@ static int alloc_module_percpu(struct module *mod, struct load_info *info)
80085 static void module_deallocate(struct module *mod, struct load_info *info)
80086 {
80087 percpu_modfree(mod);
80088 - module_free(mod, mod->module_init);
80089 - module_free(mod, mod->module_core);
80090 + module_free_exec(mod, mod->module_init_rx);
80091 + module_free_exec(mod, mod->module_core_rx);
80092 + module_free(mod, mod->module_init_rw);
80093 + module_free(mod, mod->module_core_rw);
80094 }
80095
80096 int __weak module_finalize(const Elf_Ehdr *hdr,
80097 @@ -2991,7 +3098,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
80098 static int post_relocation(struct module *mod, const struct load_info *info)
80099 {
80100 /* Sort exception table now relocations are done. */
80101 + pax_open_kernel();
80102 sort_extable(mod->extable, mod->extable + mod->num_exentries);
80103 + pax_close_kernel();
80104
80105 /* Copy relocated percpu area over. */
80106 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
80107 @@ -3045,16 +3154,16 @@ static int do_init_module(struct module *mod)
80108 MODULE_STATE_COMING, mod);
80109
80110 /* Set RO and NX regions for core */
80111 - set_section_ro_nx(mod->module_core,
80112 - mod->core_text_size,
80113 - mod->core_ro_size,
80114 - mod->core_size);
80115 + set_section_ro_nx(mod->module_core_rx,
80116 + mod->core_size_rx,
80117 + mod->core_size_rx,
80118 + mod->core_size_rx);
80119
80120 /* Set RO and NX regions for init */
80121 - set_section_ro_nx(mod->module_init,
80122 - mod->init_text_size,
80123 - mod->init_ro_size,
80124 - mod->init_size);
80125 + set_section_ro_nx(mod->module_init_rx,
80126 + mod->init_size_rx,
80127 + mod->init_size_rx,
80128 + mod->init_size_rx);
80129
80130 do_mod_ctors(mod);
80131 /* Start the module */
80132 @@ -3116,11 +3225,12 @@ static int do_init_module(struct module *mod)
80133 mod->strtab = mod->core_strtab;
80134 #endif
80135 unset_module_init_ro_nx(mod);
80136 - module_free(mod, mod->module_init);
80137 - mod->module_init = NULL;
80138 - mod->init_size = 0;
80139 - mod->init_ro_size = 0;
80140 - mod->init_text_size = 0;
80141 + module_free(mod, mod->module_init_rw);
80142 + module_free_exec(mod, mod->module_init_rx);
80143 + mod->module_init_rw = NULL;
80144 + mod->module_init_rx = NULL;
80145 + mod->init_size_rw = 0;
80146 + mod->init_size_rx = 0;
80147 mutex_unlock(&module_mutex);
80148 wake_up_all(&module_wq);
80149
80150 @@ -3252,9 +3362,38 @@ static int load_module(struct load_info *info, const char __user *uargs,
80151 if (err)
80152 goto free_unload;
80153
80154 + /* Now copy in args */
80155 + mod->args = strndup_user(uargs, ~0UL >> 1);
80156 + if (IS_ERR(mod->args)) {
80157 + err = PTR_ERR(mod->args);
80158 + goto free_unload;
80159 + }
80160 +
80161 /* Set up MODINFO_ATTR fields */
80162 setup_modinfo(mod, info);
80163
80164 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
80165 + {
80166 + char *p, *p2;
80167 +
80168 + if (strstr(mod->args, "grsec_modharden_netdev")) {
80169 + 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);
80170 + err = -EPERM;
80171 + goto free_modinfo;
80172 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
80173 + p += sizeof("grsec_modharden_normal") - 1;
80174 + p2 = strstr(p, "_");
80175 + if (p2) {
80176 + *p2 = '\0';
80177 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
80178 + *p2 = '_';
80179 + }
80180 + err = -EPERM;
80181 + goto free_modinfo;
80182 + }
80183 + }
80184 +#endif
80185 +
80186 /* Fix up syms, so that st_value is a pointer to location. */
80187 err = simplify_symbols(mod, info);
80188 if (err < 0)
80189 @@ -3270,13 +3409,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
80190
80191 flush_module_icache(mod);
80192
80193 - /* Now copy in args */
80194 - mod->args = strndup_user(uargs, ~0UL >> 1);
80195 - if (IS_ERR(mod->args)) {
80196 - err = PTR_ERR(mod->args);
80197 - goto free_arch_cleanup;
80198 - }
80199 -
80200 dynamic_debug_setup(info->debug, info->num_debug);
80201
80202 /* Finally it's fully formed, ready to start executing. */
80203 @@ -3311,11 +3443,10 @@ static int load_module(struct load_info *info, const char __user *uargs,
80204 ddebug_cleanup:
80205 dynamic_debug_remove(info->debug);
80206 synchronize_sched();
80207 - kfree(mod->args);
80208 - free_arch_cleanup:
80209 module_arch_cleanup(mod);
80210 free_modinfo:
80211 free_modinfo(mod);
80212 + kfree(mod->args);
80213 free_unload:
80214 module_unload_free(mod);
80215 unlink_mod:
80216 @@ -3398,10 +3529,16 @@ static const char *get_ksymbol(struct module *mod,
80217 unsigned long nextval;
80218
80219 /* At worse, next value is at end of module */
80220 - if (within_module_init(addr, mod))
80221 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
80222 + if (within_module_init_rx(addr, mod))
80223 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
80224 + else if (within_module_init_rw(addr, mod))
80225 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
80226 + else if (within_module_core_rx(addr, mod))
80227 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
80228 + else if (within_module_core_rw(addr, mod))
80229 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
80230 else
80231 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
80232 + return NULL;
80233
80234 /* Scan for closest preceding symbol, and next symbol. (ELF
80235 starts real symbols at 1). */
80236 @@ -3654,7 +3791,7 @@ static int m_show(struct seq_file *m, void *p)
80237 return 0;
80238
80239 seq_printf(m, "%s %u",
80240 - mod->name, mod->init_size + mod->core_size);
80241 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
80242 print_unload_info(m, mod);
80243
80244 /* Informative for users. */
80245 @@ -3663,7 +3800,7 @@ static int m_show(struct seq_file *m, void *p)
80246 mod->state == MODULE_STATE_COMING ? "Loading":
80247 "Live");
80248 /* Used by oprofile and other similar tools. */
80249 - seq_printf(m, " 0x%pK", mod->module_core);
80250 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
80251
80252 /* Taints info */
80253 if (mod->taints)
80254 @@ -3699,7 +3836,17 @@ static const struct file_operations proc_modules_operations = {
80255
80256 static int __init proc_modules_init(void)
80257 {
80258 +#ifndef CONFIG_GRKERNSEC_HIDESYM
80259 +#ifdef CONFIG_GRKERNSEC_PROC_USER
80260 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
80261 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
80262 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
80263 +#else
80264 proc_create("modules", 0, NULL, &proc_modules_operations);
80265 +#endif
80266 +#else
80267 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
80268 +#endif
80269 return 0;
80270 }
80271 module_init(proc_modules_init);
80272 @@ -3760,14 +3907,14 @@ struct module *__module_address(unsigned long addr)
80273 {
80274 struct module *mod;
80275
80276 - if (addr < module_addr_min || addr > module_addr_max)
80277 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
80278 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
80279 return NULL;
80280
80281 list_for_each_entry_rcu(mod, &modules, list) {
80282 if (mod->state == MODULE_STATE_UNFORMED)
80283 continue;
80284 - if (within_module_core(addr, mod)
80285 - || within_module_init(addr, mod))
80286 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
80287 return mod;
80288 }
80289 return NULL;
80290 @@ -3802,11 +3949,20 @@ bool is_module_text_address(unsigned long addr)
80291 */
80292 struct module *__module_text_address(unsigned long addr)
80293 {
80294 - struct module *mod = __module_address(addr);
80295 + struct module *mod;
80296 +
80297 +#ifdef CONFIG_X86_32
80298 + addr = ktla_ktva(addr);
80299 +#endif
80300 +
80301 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
80302 + return NULL;
80303 +
80304 + mod = __module_address(addr);
80305 +
80306 if (mod) {
80307 /* Make sure it's within the text section. */
80308 - if (!within(addr, mod->module_init, mod->init_text_size)
80309 - && !within(addr, mod->module_core, mod->core_text_size))
80310 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
80311 mod = NULL;
80312 }
80313 return mod;
80314 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
80315 index 7e3443f..b2a1e6b 100644
80316 --- a/kernel/mutex-debug.c
80317 +++ b/kernel/mutex-debug.c
80318 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
80319 }
80320
80321 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
80322 - struct thread_info *ti)
80323 + struct task_struct *task)
80324 {
80325 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
80326
80327 /* Mark the current thread as blocked on the lock: */
80328 - ti->task->blocked_on = waiter;
80329 + task->blocked_on = waiter;
80330 }
80331
80332 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
80333 - struct thread_info *ti)
80334 + struct task_struct *task)
80335 {
80336 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
80337 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
80338 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
80339 - ti->task->blocked_on = NULL;
80340 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
80341 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
80342 + task->blocked_on = NULL;
80343
80344 list_del_init(&waiter->list);
80345 waiter->task = NULL;
80346 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
80347 index 0799fd3..d06ae3b 100644
80348 --- a/kernel/mutex-debug.h
80349 +++ b/kernel/mutex-debug.h
80350 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
80351 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
80352 extern void debug_mutex_add_waiter(struct mutex *lock,
80353 struct mutex_waiter *waiter,
80354 - struct thread_info *ti);
80355 + struct task_struct *task);
80356 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
80357 - struct thread_info *ti);
80358 + struct task_struct *task);
80359 extern void debug_mutex_unlock(struct mutex *lock);
80360 extern void debug_mutex_init(struct mutex *lock, const char *name,
80361 struct lock_class_key *key);
80362 diff --git a/kernel/mutex.c b/kernel/mutex.c
80363 index ad53a66..f1bf8bc 100644
80364 --- a/kernel/mutex.c
80365 +++ b/kernel/mutex.c
80366 @@ -134,7 +134,7 @@ void mspin_lock(struct mspin_node **lock, struct mspin_node *node)
80367 node->locked = 1;
80368 return;
80369 }
80370 - ACCESS_ONCE(prev->next) = node;
80371 + ACCESS_ONCE_RW(prev->next) = node;
80372 smp_wmb();
80373 /* Wait until the lock holder passes the lock down */
80374 while (!ACCESS_ONCE(node->locked))
80375 @@ -155,7 +155,7 @@ static void mspin_unlock(struct mspin_node **lock, struct mspin_node *node)
80376 while (!(next = ACCESS_ONCE(node->next)))
80377 arch_mutex_cpu_relax();
80378 }
80379 - ACCESS_ONCE(next->locked) = 1;
80380 + ACCESS_ONCE_RW(next->locked) = 1;
80381 smp_wmb();
80382 }
80383
80384 @@ -341,7 +341,7 @@ slowpath:
80385 spin_lock_mutex(&lock->wait_lock, flags);
80386
80387 debug_mutex_lock_common(lock, &waiter);
80388 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
80389 + debug_mutex_add_waiter(lock, &waiter, task);
80390
80391 /* add waiting tasks to the end of the waitqueue (FIFO): */
80392 list_add_tail(&waiter.list, &lock->wait_list);
80393 @@ -371,8 +371,7 @@ slowpath:
80394 * TASK_UNINTERRUPTIBLE case.)
80395 */
80396 if (unlikely(signal_pending_state(state, task))) {
80397 - mutex_remove_waiter(lock, &waiter,
80398 - task_thread_info(task));
80399 + mutex_remove_waiter(lock, &waiter, task);
80400 mutex_release(&lock->dep_map, 1, ip);
80401 spin_unlock_mutex(&lock->wait_lock, flags);
80402
80403 @@ -391,7 +390,7 @@ slowpath:
80404 done:
80405 lock_acquired(&lock->dep_map, ip);
80406 /* got the lock - rejoice! */
80407 - mutex_remove_waiter(lock, &waiter, current_thread_info());
80408 + mutex_remove_waiter(lock, &waiter, task);
80409 mutex_set_owner(lock);
80410
80411 /* set it to 0 if there are no waiters left: */
80412 diff --git a/kernel/notifier.c b/kernel/notifier.c
80413 index 2d5cc4c..d9ea600 100644
80414 --- a/kernel/notifier.c
80415 +++ b/kernel/notifier.c
80416 @@ -5,6 +5,7 @@
80417 #include <linux/rcupdate.h>
80418 #include <linux/vmalloc.h>
80419 #include <linux/reboot.h>
80420 +#include <linux/mm.h>
80421
80422 /*
80423 * Notifier list for kernel code which wants to be called
80424 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
80425 while ((*nl) != NULL) {
80426 if (n->priority > (*nl)->priority)
80427 break;
80428 - nl = &((*nl)->next);
80429 + nl = (struct notifier_block **)&((*nl)->next);
80430 }
80431 - n->next = *nl;
80432 + pax_open_kernel();
80433 + *(const void **)&n->next = *nl;
80434 rcu_assign_pointer(*nl, n);
80435 + pax_close_kernel();
80436 return 0;
80437 }
80438
80439 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
80440 return 0;
80441 if (n->priority > (*nl)->priority)
80442 break;
80443 - nl = &((*nl)->next);
80444 + nl = (struct notifier_block **)&((*nl)->next);
80445 }
80446 - n->next = *nl;
80447 + pax_open_kernel();
80448 + *(const void **)&n->next = *nl;
80449 rcu_assign_pointer(*nl, n);
80450 + pax_close_kernel();
80451 return 0;
80452 }
80453
80454 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
80455 {
80456 while ((*nl) != NULL) {
80457 if ((*nl) == n) {
80458 + pax_open_kernel();
80459 rcu_assign_pointer(*nl, n->next);
80460 + pax_close_kernel();
80461 return 0;
80462 }
80463 - nl = &((*nl)->next);
80464 + nl = (struct notifier_block **)&((*nl)->next);
80465 }
80466 return -ENOENT;
80467 }
80468 diff --git a/kernel/panic.c b/kernel/panic.c
80469 index 167ec09..0dda5f9 100644
80470 --- a/kernel/panic.c
80471 +++ b/kernel/panic.c
80472 @@ -400,7 +400,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
80473 unsigned taint, struct slowpath_args *args)
80474 {
80475 printk(KERN_WARNING "------------[ cut here ]------------\n");
80476 - printk(KERN_WARNING "WARNING: at %s:%d %pS()\n", file, line, caller);
80477 + printk(KERN_WARNING "WARNING: at %s:%d %pA()\n", file, line, caller);
80478
80479 if (args)
80480 vprintk(args->fmt, args->args);
80481 @@ -453,7 +453,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
80482 */
80483 void __stack_chk_fail(void)
80484 {
80485 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
80486 + dump_stack();
80487 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
80488 __builtin_return_address(0));
80489 }
80490 EXPORT_SYMBOL(__stack_chk_fail);
80491 diff --git a/kernel/pid.c b/kernel/pid.c
80492 index 0db3e79..95b9dc2 100644
80493 --- a/kernel/pid.c
80494 +++ b/kernel/pid.c
80495 @@ -33,6 +33,7 @@
80496 #include <linux/rculist.h>
80497 #include <linux/bootmem.h>
80498 #include <linux/hash.h>
80499 +#include <linux/security.h>
80500 #include <linux/pid_namespace.h>
80501 #include <linux/init_task.h>
80502 #include <linux/syscalls.h>
80503 @@ -47,7 +48,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
80504
80505 int pid_max = PID_MAX_DEFAULT;
80506
80507 -#define RESERVED_PIDS 300
80508 +#define RESERVED_PIDS 500
80509
80510 int pid_max_min = RESERVED_PIDS + 1;
80511 int pid_max_max = PID_MAX_LIMIT;
80512 @@ -442,10 +443,18 @@ EXPORT_SYMBOL(pid_task);
80513 */
80514 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
80515 {
80516 + struct task_struct *task;
80517 +
80518 rcu_lockdep_assert(rcu_read_lock_held(),
80519 "find_task_by_pid_ns() needs rcu_read_lock()"
80520 " protection");
80521 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
80522 +
80523 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
80524 +
80525 + if (gr_pid_is_chrooted(task))
80526 + return NULL;
80527 +
80528 + return task;
80529 }
80530
80531 struct task_struct *find_task_by_vpid(pid_t vnr)
80532 @@ -453,6 +462,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
80533 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
80534 }
80535
80536 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
80537 +{
80538 + rcu_lockdep_assert(rcu_read_lock_held(),
80539 + "find_task_by_pid_ns() needs rcu_read_lock()"
80540 + " protection");
80541 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
80542 +}
80543 +
80544 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
80545 {
80546 struct pid *pid;
80547 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
80548 index 6917e8e..9909aeb 100644
80549 --- a/kernel/pid_namespace.c
80550 +++ b/kernel/pid_namespace.c
80551 @@ -247,7 +247,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
80552 void __user *buffer, size_t *lenp, loff_t *ppos)
80553 {
80554 struct pid_namespace *pid_ns = task_active_pid_ns(current);
80555 - struct ctl_table tmp = *table;
80556 + ctl_table_no_const tmp = *table;
80557
80558 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
80559 return -EPERM;
80560 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
80561 index 42670e9..8719c2f 100644
80562 --- a/kernel/posix-cpu-timers.c
80563 +++ b/kernel/posix-cpu-timers.c
80564 @@ -1636,14 +1636,14 @@ struct k_clock clock_posix_cpu = {
80565
80566 static __init int init_posix_cpu_timers(void)
80567 {
80568 - struct k_clock process = {
80569 + static struct k_clock process = {
80570 .clock_getres = process_cpu_clock_getres,
80571 .clock_get = process_cpu_clock_get,
80572 .timer_create = process_cpu_timer_create,
80573 .nsleep = process_cpu_nsleep,
80574 .nsleep_restart = process_cpu_nsleep_restart,
80575 };
80576 - struct k_clock thread = {
80577 + static struct k_clock thread = {
80578 .clock_getres = thread_cpu_clock_getres,
80579 .clock_get = thread_cpu_clock_get,
80580 .timer_create = thread_cpu_timer_create,
80581 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
80582 index 424c2d4..679242f 100644
80583 --- a/kernel/posix-timers.c
80584 +++ b/kernel/posix-timers.c
80585 @@ -43,6 +43,7 @@
80586 #include <linux/hash.h>
80587 #include <linux/posix-clock.h>
80588 #include <linux/posix-timers.h>
80589 +#include <linux/grsecurity.h>
80590 #include <linux/syscalls.h>
80591 #include <linux/wait.h>
80592 #include <linux/workqueue.h>
80593 @@ -122,7 +123,7 @@ static DEFINE_SPINLOCK(hash_lock);
80594 * which we beg off on and pass to do_sys_settimeofday().
80595 */
80596
80597 -static struct k_clock posix_clocks[MAX_CLOCKS];
80598 +static struct k_clock *posix_clocks[MAX_CLOCKS];
80599
80600 /*
80601 * These ones are defined below.
80602 @@ -275,7 +276,7 @@ static int posix_get_tai(clockid_t which_clock, struct timespec *tp)
80603 */
80604 static __init int init_posix_timers(void)
80605 {
80606 - struct k_clock clock_realtime = {
80607 + static struct k_clock clock_realtime = {
80608 .clock_getres = hrtimer_get_res,
80609 .clock_get = posix_clock_realtime_get,
80610 .clock_set = posix_clock_realtime_set,
80611 @@ -287,7 +288,7 @@ static __init int init_posix_timers(void)
80612 .timer_get = common_timer_get,
80613 .timer_del = common_timer_del,
80614 };
80615 - struct k_clock clock_monotonic = {
80616 + static struct k_clock clock_monotonic = {
80617 .clock_getres = hrtimer_get_res,
80618 .clock_get = posix_ktime_get_ts,
80619 .nsleep = common_nsleep,
80620 @@ -297,19 +298,19 @@ static __init int init_posix_timers(void)
80621 .timer_get = common_timer_get,
80622 .timer_del = common_timer_del,
80623 };
80624 - struct k_clock clock_monotonic_raw = {
80625 + static struct k_clock clock_monotonic_raw = {
80626 .clock_getres = hrtimer_get_res,
80627 .clock_get = posix_get_monotonic_raw,
80628 };
80629 - struct k_clock clock_realtime_coarse = {
80630 + static struct k_clock clock_realtime_coarse = {
80631 .clock_getres = posix_get_coarse_res,
80632 .clock_get = posix_get_realtime_coarse,
80633 };
80634 - struct k_clock clock_monotonic_coarse = {
80635 + static struct k_clock clock_monotonic_coarse = {
80636 .clock_getres = posix_get_coarse_res,
80637 .clock_get = posix_get_monotonic_coarse,
80638 };
80639 - struct k_clock clock_tai = {
80640 + static struct k_clock clock_tai = {
80641 .clock_getres = hrtimer_get_res,
80642 .clock_get = posix_get_tai,
80643 .nsleep = common_nsleep,
80644 @@ -319,7 +320,7 @@ static __init int init_posix_timers(void)
80645 .timer_get = common_timer_get,
80646 .timer_del = common_timer_del,
80647 };
80648 - struct k_clock clock_boottime = {
80649 + static struct k_clock clock_boottime = {
80650 .clock_getres = hrtimer_get_res,
80651 .clock_get = posix_get_boottime,
80652 .nsleep = common_nsleep,
80653 @@ -531,7 +532,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
80654 return;
80655 }
80656
80657 - posix_clocks[clock_id] = *new_clock;
80658 + posix_clocks[clock_id] = new_clock;
80659 }
80660 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
80661
80662 @@ -577,9 +578,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
80663 return (id & CLOCKFD_MASK) == CLOCKFD ?
80664 &clock_posix_dynamic : &clock_posix_cpu;
80665
80666 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
80667 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
80668 return NULL;
80669 - return &posix_clocks[id];
80670 + return posix_clocks[id];
80671 }
80672
80673 static int common_timer_create(struct k_itimer *new_timer)
80674 @@ -597,7 +598,7 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
80675 struct k_clock *kc = clockid_to_kclock(which_clock);
80676 struct k_itimer *new_timer;
80677 int error, new_timer_id;
80678 - sigevent_t event;
80679 + sigevent_t event = { };
80680 int it_id_set = IT_ID_NOT_SET;
80681
80682 if (!kc)
80683 @@ -1011,6 +1012,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
80684 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
80685 return -EFAULT;
80686
80687 + /* only the CLOCK_REALTIME clock can be set, all other clocks
80688 + have their clock_set fptr set to a nosettime dummy function
80689 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
80690 + call common_clock_set, which calls do_sys_settimeofday, which
80691 + we hook
80692 + */
80693 +
80694 return kc->clock_set(which_clock, &new_tp);
80695 }
80696
80697 diff --git a/kernel/power/process.c b/kernel/power/process.c
80698 index 98088e0..aaf95c0 100644
80699 --- a/kernel/power/process.c
80700 +++ b/kernel/power/process.c
80701 @@ -33,6 +33,7 @@ static int try_to_freeze_tasks(bool user_only)
80702 u64 elapsed_csecs64;
80703 unsigned int elapsed_csecs;
80704 bool wakeup = false;
80705 + bool timedout = false;
80706
80707 do_gettimeofday(&start);
80708
80709 @@ -43,13 +44,20 @@ static int try_to_freeze_tasks(bool user_only)
80710
80711 while (true) {
80712 todo = 0;
80713 + if (time_after(jiffies, end_time))
80714 + timedout = true;
80715 read_lock(&tasklist_lock);
80716 do_each_thread(g, p) {
80717 if (p == current || !freeze_task(p))
80718 continue;
80719
80720 - if (!freezer_should_skip(p))
80721 + if (!freezer_should_skip(p)) {
80722 todo++;
80723 + if (timedout) {
80724 + printk(KERN_ERR "Task refusing to freeze:\n");
80725 + sched_show_task(p);
80726 + }
80727 + }
80728 } while_each_thread(g, p);
80729 read_unlock(&tasklist_lock);
80730
80731 @@ -58,7 +66,7 @@ static int try_to_freeze_tasks(bool user_only)
80732 todo += wq_busy;
80733 }
80734
80735 - if (!todo || time_after(jiffies, end_time))
80736 + if (!todo || timedout)
80737 break;
80738
80739 if (pm_wakeup_pending()) {
80740 diff --git a/kernel/printk.c b/kernel/printk.c
80741 index d37d45c..ab918b3 100644
80742 --- a/kernel/printk.c
80743 +++ b/kernel/printk.c
80744 @@ -390,6 +390,11 @@ static int check_syslog_permissions(int type, bool from_file)
80745 if (from_file && type != SYSLOG_ACTION_OPEN)
80746 return 0;
80747
80748 +#ifdef CONFIG_GRKERNSEC_DMESG
80749 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
80750 + return -EPERM;
80751 +#endif
80752 +
80753 if (syslog_action_restricted(type)) {
80754 if (capable(CAP_SYSLOG))
80755 return 0;
80756 diff --git a/kernel/profile.c b/kernel/profile.c
80757 index 0bf4007..6234708 100644
80758 --- a/kernel/profile.c
80759 +++ b/kernel/profile.c
80760 @@ -37,7 +37,7 @@ struct profile_hit {
80761 #define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
80762 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
80763
80764 -static atomic_t *prof_buffer;
80765 +static atomic_unchecked_t *prof_buffer;
80766 static unsigned long prof_len, prof_shift;
80767
80768 int prof_on __read_mostly;
80769 @@ -260,7 +260,7 @@ static void profile_flip_buffers(void)
80770 hits[i].pc = 0;
80771 continue;
80772 }
80773 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
80774 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
80775 hits[i].hits = hits[i].pc = 0;
80776 }
80777 }
80778 @@ -321,9 +321,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
80779 * Add the current hit(s) and flush the write-queue out
80780 * to the global buffer:
80781 */
80782 - atomic_add(nr_hits, &prof_buffer[pc]);
80783 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
80784 for (i = 0; i < NR_PROFILE_HIT; ++i) {
80785 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
80786 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
80787 hits[i].pc = hits[i].hits = 0;
80788 }
80789 out:
80790 @@ -398,7 +398,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
80791 {
80792 unsigned long pc;
80793 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
80794 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
80795 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
80796 }
80797 #endif /* !CONFIG_SMP */
80798
80799 @@ -494,7 +494,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
80800 return -EFAULT;
80801 buf++; p++; count--; read++;
80802 }
80803 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
80804 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
80805 if (copy_to_user(buf, (void *)pnt, count))
80806 return -EFAULT;
80807 read += count;
80808 @@ -525,7 +525,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
80809 }
80810 #endif
80811 profile_discard_flip_buffers();
80812 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
80813 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
80814 return count;
80815 }
80816
80817 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
80818 index 335a7ae..3bbbceb 100644
80819 --- a/kernel/ptrace.c
80820 +++ b/kernel/ptrace.c
80821 @@ -326,7 +326,7 @@ static int ptrace_attach(struct task_struct *task, long request,
80822 if (seize)
80823 flags |= PT_SEIZED;
80824 rcu_read_lock();
80825 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
80826 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
80827 flags |= PT_PTRACE_CAP;
80828 rcu_read_unlock();
80829 task->ptrace = flags;
80830 @@ -537,7 +537,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
80831 break;
80832 return -EIO;
80833 }
80834 - if (copy_to_user(dst, buf, retval))
80835 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
80836 return -EFAULT;
80837 copied += retval;
80838 src += retval;
80839 @@ -805,7 +805,7 @@ int ptrace_request(struct task_struct *child, long request,
80840 bool seized = child->ptrace & PT_SEIZED;
80841 int ret = -EIO;
80842 siginfo_t siginfo, *si;
80843 - void __user *datavp = (void __user *) data;
80844 + void __user *datavp = (__force void __user *) data;
80845 unsigned long __user *datalp = datavp;
80846 unsigned long flags;
80847
80848 @@ -1011,14 +1011,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
80849 goto out;
80850 }
80851
80852 + if (gr_handle_ptrace(child, request)) {
80853 + ret = -EPERM;
80854 + goto out_put_task_struct;
80855 + }
80856 +
80857 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
80858 ret = ptrace_attach(child, request, addr, data);
80859 /*
80860 * Some architectures need to do book-keeping after
80861 * a ptrace attach.
80862 */
80863 - if (!ret)
80864 + if (!ret) {
80865 arch_ptrace_attach(child);
80866 + gr_audit_ptrace(child);
80867 + }
80868 goto out_put_task_struct;
80869 }
80870
80871 @@ -1046,7 +1053,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
80872 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
80873 if (copied != sizeof(tmp))
80874 return -EIO;
80875 - return put_user(tmp, (unsigned long __user *)data);
80876 + return put_user(tmp, (__force unsigned long __user *)data);
80877 }
80878
80879 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
80880 @@ -1140,7 +1147,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
80881 }
80882
80883 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
80884 - compat_long_t addr, compat_long_t data)
80885 + compat_ulong_t addr, compat_ulong_t data)
80886 {
80887 struct task_struct *child;
80888 long ret;
80889 @@ -1156,14 +1163,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
80890 goto out;
80891 }
80892
80893 + if (gr_handle_ptrace(child, request)) {
80894 + ret = -EPERM;
80895 + goto out_put_task_struct;
80896 + }
80897 +
80898 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
80899 ret = ptrace_attach(child, request, addr, data);
80900 /*
80901 * Some architectures need to do book-keeping after
80902 * a ptrace attach.
80903 */
80904 - if (!ret)
80905 + if (!ret) {
80906 arch_ptrace_attach(child);
80907 + gr_audit_ptrace(child);
80908 + }
80909 goto out_put_task_struct;
80910 }
80911
80912 diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
80913 index 48ab703..07561d4 100644
80914 --- a/kernel/rcupdate.c
80915 +++ b/kernel/rcupdate.c
80916 @@ -439,10 +439,10 @@ int rcu_jiffies_till_stall_check(void)
80917 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
80918 */
80919 if (till_stall_check < 3) {
80920 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
80921 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
80922 till_stall_check = 3;
80923 } else if (till_stall_check > 300) {
80924 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
80925 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
80926 till_stall_check = 300;
80927 }
80928 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
80929 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
80930 index a0714a5..2ab5e34 100644
80931 --- a/kernel/rcutiny.c
80932 +++ b/kernel/rcutiny.c
80933 @@ -46,7 +46,7 @@
80934 struct rcu_ctrlblk;
80935 static void invoke_rcu_callbacks(void);
80936 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
80937 -static void rcu_process_callbacks(struct softirq_action *unused);
80938 +static void rcu_process_callbacks(void);
80939 static void __call_rcu(struct rcu_head *head,
80940 void (*func)(struct rcu_head *rcu),
80941 struct rcu_ctrlblk *rcp);
80942 @@ -312,7 +312,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
80943 rcu_is_callbacks_kthread()));
80944 }
80945
80946 -static void rcu_process_callbacks(struct softirq_action *unused)
80947 +static void rcu_process_callbacks(void)
80948 {
80949 __rcu_process_callbacks(&rcu_sched_ctrlblk);
80950 __rcu_process_callbacks(&rcu_bh_ctrlblk);
80951 diff --git a/kernel/rcutiny_plugin.h b/kernel/rcutiny_plugin.h
80952 index 8a23300..4255818 100644
80953 --- a/kernel/rcutiny_plugin.h
80954 +++ b/kernel/rcutiny_plugin.h
80955 @@ -945,7 +945,7 @@ static int rcu_kthread(void *arg)
80956 have_rcu_kthread_work = morework;
80957 local_irq_restore(flags);
80958 if (work)
80959 - rcu_process_callbacks(NULL);
80960 + rcu_process_callbacks();
80961 schedule_timeout_interruptible(1); /* Leave CPU for others. */
80962 }
80963
80964 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
80965 index e1f3a8c..42c94a2 100644
80966 --- a/kernel/rcutorture.c
80967 +++ b/kernel/rcutorture.c
80968 @@ -164,12 +164,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
80969 { 0 };
80970 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
80971 { 0 };
80972 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
80973 -static atomic_t n_rcu_torture_alloc;
80974 -static atomic_t n_rcu_torture_alloc_fail;
80975 -static atomic_t n_rcu_torture_free;
80976 -static atomic_t n_rcu_torture_mberror;
80977 -static atomic_t n_rcu_torture_error;
80978 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
80979 +static atomic_unchecked_t n_rcu_torture_alloc;
80980 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
80981 +static atomic_unchecked_t n_rcu_torture_free;
80982 +static atomic_unchecked_t n_rcu_torture_mberror;
80983 +static atomic_unchecked_t n_rcu_torture_error;
80984 static long n_rcu_torture_barrier_error;
80985 static long n_rcu_torture_boost_ktrerror;
80986 static long n_rcu_torture_boost_rterror;
80987 @@ -287,11 +287,11 @@ rcu_torture_alloc(void)
80988
80989 spin_lock_bh(&rcu_torture_lock);
80990 if (list_empty(&rcu_torture_freelist)) {
80991 - atomic_inc(&n_rcu_torture_alloc_fail);
80992 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
80993 spin_unlock_bh(&rcu_torture_lock);
80994 return NULL;
80995 }
80996 - atomic_inc(&n_rcu_torture_alloc);
80997 + atomic_inc_unchecked(&n_rcu_torture_alloc);
80998 p = rcu_torture_freelist.next;
80999 list_del_init(p);
81000 spin_unlock_bh(&rcu_torture_lock);
81001 @@ -304,7 +304,7 @@ rcu_torture_alloc(void)
81002 static void
81003 rcu_torture_free(struct rcu_torture *p)
81004 {
81005 - atomic_inc(&n_rcu_torture_free);
81006 + atomic_inc_unchecked(&n_rcu_torture_free);
81007 spin_lock_bh(&rcu_torture_lock);
81008 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
81009 spin_unlock_bh(&rcu_torture_lock);
81010 @@ -424,7 +424,7 @@ rcu_torture_cb(struct rcu_head *p)
81011 i = rp->rtort_pipe_count;
81012 if (i > RCU_TORTURE_PIPE_LEN)
81013 i = RCU_TORTURE_PIPE_LEN;
81014 - atomic_inc(&rcu_torture_wcount[i]);
81015 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
81016 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
81017 rp->rtort_mbtest = 0;
81018 rcu_torture_free(rp);
81019 @@ -472,7 +472,7 @@ static void rcu_sync_torture_deferred_free(struct rcu_torture *p)
81020 i = rp->rtort_pipe_count;
81021 if (i > RCU_TORTURE_PIPE_LEN)
81022 i = RCU_TORTURE_PIPE_LEN;
81023 - atomic_inc(&rcu_torture_wcount[i]);
81024 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
81025 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
81026 rp->rtort_mbtest = 0;
81027 list_del(&rp->rtort_free);
81028 @@ -990,7 +990,7 @@ rcu_torture_writer(void *arg)
81029 i = old_rp->rtort_pipe_count;
81030 if (i > RCU_TORTURE_PIPE_LEN)
81031 i = RCU_TORTURE_PIPE_LEN;
81032 - atomic_inc(&rcu_torture_wcount[i]);
81033 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
81034 old_rp->rtort_pipe_count++;
81035 cur_ops->deferred_free(old_rp);
81036 }
81037 @@ -1076,7 +1076,7 @@ static void rcu_torture_timer(unsigned long unused)
81038 return;
81039 }
81040 if (p->rtort_mbtest == 0)
81041 - atomic_inc(&n_rcu_torture_mberror);
81042 + atomic_inc_unchecked(&n_rcu_torture_mberror);
81043 spin_lock(&rand_lock);
81044 cur_ops->read_delay(&rand);
81045 n_rcu_torture_timers++;
81046 @@ -1146,7 +1146,7 @@ rcu_torture_reader(void *arg)
81047 continue;
81048 }
81049 if (p->rtort_mbtest == 0)
81050 - atomic_inc(&n_rcu_torture_mberror);
81051 + atomic_inc_unchecked(&n_rcu_torture_mberror);
81052 cur_ops->read_delay(&rand);
81053 preempt_disable();
81054 pipe_count = p->rtort_pipe_count;
81055 @@ -1209,11 +1209,11 @@ rcu_torture_printk(char *page)
81056 rcu_torture_current,
81057 rcu_torture_current_version,
81058 list_empty(&rcu_torture_freelist),
81059 - atomic_read(&n_rcu_torture_alloc),
81060 - atomic_read(&n_rcu_torture_alloc_fail),
81061 - atomic_read(&n_rcu_torture_free));
81062 + atomic_read_unchecked(&n_rcu_torture_alloc),
81063 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
81064 + atomic_read_unchecked(&n_rcu_torture_free));
81065 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
81066 - atomic_read(&n_rcu_torture_mberror),
81067 + atomic_read_unchecked(&n_rcu_torture_mberror),
81068 n_rcu_torture_boost_ktrerror,
81069 n_rcu_torture_boost_rterror);
81070 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
81071 @@ -1232,14 +1232,14 @@ rcu_torture_printk(char *page)
81072 n_barrier_attempts,
81073 n_rcu_torture_barrier_error);
81074 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
81075 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
81076 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
81077 n_rcu_torture_barrier_error != 0 ||
81078 n_rcu_torture_boost_ktrerror != 0 ||
81079 n_rcu_torture_boost_rterror != 0 ||
81080 n_rcu_torture_boost_failure != 0 ||
81081 i > 1) {
81082 cnt += sprintf(&page[cnt], "!!! ");
81083 - atomic_inc(&n_rcu_torture_error);
81084 + atomic_inc_unchecked(&n_rcu_torture_error);
81085 WARN_ON_ONCE(1);
81086 }
81087 cnt += sprintf(&page[cnt], "Reader Pipe: ");
81088 @@ -1253,7 +1253,7 @@ rcu_torture_printk(char *page)
81089 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
81090 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
81091 cnt += sprintf(&page[cnt], " %d",
81092 - atomic_read(&rcu_torture_wcount[i]));
81093 + atomic_read_unchecked(&rcu_torture_wcount[i]));
81094 }
81095 cnt += sprintf(&page[cnt], "\n");
81096 if (cur_ops->stats)
81097 @@ -1962,7 +1962,7 @@ rcu_torture_cleanup(void)
81098
81099 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
81100
81101 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
81102 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
81103 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
81104 else if (n_online_successes != n_online_attempts ||
81105 n_offline_successes != n_offline_attempts)
81106 @@ -2031,18 +2031,18 @@ rcu_torture_init(void)
81107
81108 rcu_torture_current = NULL;
81109 rcu_torture_current_version = 0;
81110 - atomic_set(&n_rcu_torture_alloc, 0);
81111 - atomic_set(&n_rcu_torture_alloc_fail, 0);
81112 - atomic_set(&n_rcu_torture_free, 0);
81113 - atomic_set(&n_rcu_torture_mberror, 0);
81114 - atomic_set(&n_rcu_torture_error, 0);
81115 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
81116 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
81117 + atomic_set_unchecked(&n_rcu_torture_free, 0);
81118 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
81119 + atomic_set_unchecked(&n_rcu_torture_error, 0);
81120 n_rcu_torture_barrier_error = 0;
81121 n_rcu_torture_boost_ktrerror = 0;
81122 n_rcu_torture_boost_rterror = 0;
81123 n_rcu_torture_boost_failure = 0;
81124 n_rcu_torture_boosts = 0;
81125 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
81126 - atomic_set(&rcu_torture_wcount[i], 0);
81127 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
81128 for_each_possible_cpu(cpu) {
81129 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
81130 per_cpu(rcu_torture_count, cpu)[i] = 0;
81131 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
81132 index 3538001..e379e0b 100644
81133 --- a/kernel/rcutree.c
81134 +++ b/kernel/rcutree.c
81135 @@ -358,9 +358,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
81136 rcu_prepare_for_idle(smp_processor_id());
81137 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
81138 smp_mb__before_atomic_inc(); /* See above. */
81139 - atomic_inc(&rdtp->dynticks);
81140 + atomic_inc_unchecked(&rdtp->dynticks);
81141 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
81142 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
81143 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
81144
81145 /*
81146 * It is illegal to enter an extended quiescent state while
81147 @@ -496,10 +496,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
81148 int user)
81149 {
81150 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
81151 - atomic_inc(&rdtp->dynticks);
81152 + atomic_inc_unchecked(&rdtp->dynticks);
81153 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
81154 smp_mb__after_atomic_inc(); /* See above. */
81155 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
81156 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
81157 rcu_cleanup_after_idle(smp_processor_id());
81158 trace_rcu_dyntick("End", oldval, rdtp->dynticks_nesting);
81159 if (!user && !is_idle_task(current)) {
81160 @@ -638,14 +638,14 @@ void rcu_nmi_enter(void)
81161 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
81162
81163 if (rdtp->dynticks_nmi_nesting == 0 &&
81164 - (atomic_read(&rdtp->dynticks) & 0x1))
81165 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
81166 return;
81167 rdtp->dynticks_nmi_nesting++;
81168 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
81169 - atomic_inc(&rdtp->dynticks);
81170 + atomic_inc_unchecked(&rdtp->dynticks);
81171 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
81172 smp_mb__after_atomic_inc(); /* See above. */
81173 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
81174 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
81175 }
81176
81177 /**
81178 @@ -664,9 +664,9 @@ void rcu_nmi_exit(void)
81179 return;
81180 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
81181 smp_mb__before_atomic_inc(); /* See above. */
81182 - atomic_inc(&rdtp->dynticks);
81183 + atomic_inc_unchecked(&rdtp->dynticks);
81184 smp_mb__after_atomic_inc(); /* Force delay to next write. */
81185 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
81186 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
81187 }
81188
81189 /**
81190 @@ -680,7 +680,7 @@ int rcu_is_cpu_idle(void)
81191 int ret;
81192
81193 preempt_disable();
81194 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
81195 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
81196 preempt_enable();
81197 return ret;
81198 }
81199 @@ -748,7 +748,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
81200 */
81201 static int dyntick_save_progress_counter(struct rcu_data *rdp)
81202 {
81203 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
81204 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
81205 return (rdp->dynticks_snap & 0x1) == 0;
81206 }
81207
81208 @@ -763,7 +763,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp)
81209 unsigned int curr;
81210 unsigned int snap;
81211
81212 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
81213 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
81214 snap = (unsigned int)rdp->dynticks_snap;
81215
81216 /*
81217 @@ -1440,9 +1440,9 @@ static int rcu_gp_init(struct rcu_state *rsp)
81218 rdp = this_cpu_ptr(rsp->rda);
81219 rcu_preempt_check_blocked_tasks(rnp);
81220 rnp->qsmask = rnp->qsmaskinit;
81221 - ACCESS_ONCE(rnp->gpnum) = rsp->gpnum;
81222 + ACCESS_ONCE_RW(rnp->gpnum) = rsp->gpnum;
81223 WARN_ON_ONCE(rnp->completed != rsp->completed);
81224 - ACCESS_ONCE(rnp->completed) = rsp->completed;
81225 + ACCESS_ONCE_RW(rnp->completed) = rsp->completed;
81226 if (rnp == rdp->mynode)
81227 rcu_start_gp_per_cpu(rsp, rnp, rdp);
81228 rcu_preempt_boost_start_gp(rnp);
81229 @@ -1524,7 +1524,7 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
81230 */
81231 rcu_for_each_node_breadth_first(rsp, rnp) {
81232 raw_spin_lock_irq(&rnp->lock);
81233 - ACCESS_ONCE(rnp->completed) = rsp->gpnum;
81234 + ACCESS_ONCE_RW(rnp->completed) = rsp->gpnum;
81235 rdp = this_cpu_ptr(rsp->rda);
81236 if (rnp == rdp->mynode)
81237 __rcu_process_gp_end(rsp, rnp, rdp);
81238 @@ -1855,7 +1855,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
81239 rsp->qlen += rdp->qlen;
81240 rdp->n_cbs_orphaned += rdp->qlen;
81241 rdp->qlen_lazy = 0;
81242 - ACCESS_ONCE(rdp->qlen) = 0;
81243 + ACCESS_ONCE_RW(rdp->qlen) = 0;
81244 }
81245
81246 /*
81247 @@ -2101,7 +2101,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
81248 }
81249 smp_mb(); /* List handling before counting for rcu_barrier(). */
81250 rdp->qlen_lazy -= count_lazy;
81251 - ACCESS_ONCE(rdp->qlen) -= count;
81252 + ACCESS_ONCE_RW(rdp->qlen) -= count;
81253 rdp->n_cbs_invoked += count;
81254
81255 /* Reinstate batch limit if we have worked down the excess. */
81256 @@ -2295,7 +2295,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
81257 /*
81258 * Do RCU core processing for the current CPU.
81259 */
81260 -static void rcu_process_callbacks(struct softirq_action *unused)
81261 +static void rcu_process_callbacks(void)
81262 {
81263 struct rcu_state *rsp;
81264
81265 @@ -2419,7 +2419,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
81266 local_irq_restore(flags);
81267 return;
81268 }
81269 - ACCESS_ONCE(rdp->qlen)++;
81270 + ACCESS_ONCE_RW(rdp->qlen)++;
81271 if (lazy)
81272 rdp->qlen_lazy++;
81273 else
81274 @@ -2628,11 +2628,11 @@ void synchronize_sched_expedited(void)
81275 * counter wrap on a 32-bit system. Quite a few more CPUs would of
81276 * course be required on a 64-bit system.
81277 */
81278 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
81279 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
81280 (ulong)atomic_long_read(&rsp->expedited_done) +
81281 ULONG_MAX / 8)) {
81282 synchronize_sched();
81283 - atomic_long_inc(&rsp->expedited_wrap);
81284 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
81285 return;
81286 }
81287
81288 @@ -2640,7 +2640,7 @@ void synchronize_sched_expedited(void)
81289 * Take a ticket. Note that atomic_inc_return() implies a
81290 * full memory barrier.
81291 */
81292 - snap = atomic_long_inc_return(&rsp->expedited_start);
81293 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
81294 firstsnap = snap;
81295 get_online_cpus();
81296 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
81297 @@ -2653,14 +2653,14 @@ void synchronize_sched_expedited(void)
81298 synchronize_sched_expedited_cpu_stop,
81299 NULL) == -EAGAIN) {
81300 put_online_cpus();
81301 - atomic_long_inc(&rsp->expedited_tryfail);
81302 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
81303
81304 /* Check to see if someone else did our work for us. */
81305 s = atomic_long_read(&rsp->expedited_done);
81306 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
81307 /* ensure test happens before caller kfree */
81308 smp_mb__before_atomic_inc(); /* ^^^ */
81309 - atomic_long_inc(&rsp->expedited_workdone1);
81310 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
81311 return;
81312 }
81313
81314 @@ -2669,7 +2669,7 @@ void synchronize_sched_expedited(void)
81315 udelay(trycount * num_online_cpus());
81316 } else {
81317 wait_rcu_gp(call_rcu_sched);
81318 - atomic_long_inc(&rsp->expedited_normal);
81319 + atomic_long_inc_unchecked(&rsp->expedited_normal);
81320 return;
81321 }
81322
81323 @@ -2678,7 +2678,7 @@ void synchronize_sched_expedited(void)
81324 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
81325 /* ensure test happens before caller kfree */
81326 smp_mb__before_atomic_inc(); /* ^^^ */
81327 - atomic_long_inc(&rsp->expedited_workdone2);
81328 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
81329 return;
81330 }
81331
81332 @@ -2690,10 +2690,10 @@ void synchronize_sched_expedited(void)
81333 * period works for us.
81334 */
81335 get_online_cpus();
81336 - snap = atomic_long_read(&rsp->expedited_start);
81337 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
81338 smp_mb(); /* ensure read is before try_stop_cpus(). */
81339 }
81340 - atomic_long_inc(&rsp->expedited_stoppedcpus);
81341 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
81342
81343 /*
81344 * Everyone up to our most recent fetch is covered by our grace
81345 @@ -2702,16 +2702,16 @@ void synchronize_sched_expedited(void)
81346 * than we did already did their update.
81347 */
81348 do {
81349 - atomic_long_inc(&rsp->expedited_done_tries);
81350 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
81351 s = atomic_long_read(&rsp->expedited_done);
81352 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
81353 /* ensure test happens before caller kfree */
81354 smp_mb__before_atomic_inc(); /* ^^^ */
81355 - atomic_long_inc(&rsp->expedited_done_lost);
81356 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
81357 break;
81358 }
81359 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
81360 - atomic_long_inc(&rsp->expedited_done_exit);
81361 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
81362
81363 put_online_cpus();
81364 }
81365 @@ -2893,7 +2893,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
81366 * ACCESS_ONCE() to prevent the compiler from speculating
81367 * the increment to precede the early-exit check.
81368 */
81369 - ACCESS_ONCE(rsp->n_barrier_done)++;
81370 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
81371 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
81372 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
81373 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
81374 @@ -2943,7 +2943,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
81375
81376 /* Increment ->n_barrier_done to prevent duplicate work. */
81377 smp_mb(); /* Keep increment after above mechanism. */
81378 - ACCESS_ONCE(rsp->n_barrier_done)++;
81379 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
81380 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
81381 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
81382 smp_mb(); /* Keep increment before caller's subsequent code. */
81383 @@ -2988,10 +2988,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
81384 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
81385 init_callback_list(rdp);
81386 rdp->qlen_lazy = 0;
81387 - ACCESS_ONCE(rdp->qlen) = 0;
81388 + ACCESS_ONCE_RW(rdp->qlen) = 0;
81389 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
81390 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
81391 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
81392 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
81393 rdp->cpu = cpu;
81394 rdp->rsp = rsp;
81395 rcu_boot_init_nocb_percpu_data(rdp);
81396 @@ -3024,8 +3024,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
81397 rdp->blimit = blimit;
81398 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
81399 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
81400 - atomic_set(&rdp->dynticks->dynticks,
81401 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
81402 + atomic_set_unchecked(&rdp->dynticks->dynticks,
81403 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
81404 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
81405
81406 /* Add CPU to rcu_node bitmasks. */
81407 @@ -3120,7 +3120,7 @@ static int __init rcu_spawn_gp_kthread(void)
81408 struct task_struct *t;
81409
81410 for_each_rcu_flavor(rsp) {
81411 - t = kthread_run(rcu_gp_kthread, rsp, rsp->name);
81412 + t = kthread_run(rcu_gp_kthread, rsp, "%s", rsp->name);
81413 BUG_ON(IS_ERR(t));
81414 rnp = rcu_get_root(rsp);
81415 raw_spin_lock_irqsave(&rnp->lock, flags);
81416 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
81417 index 4df5034..5ee93f2 100644
81418 --- a/kernel/rcutree.h
81419 +++ b/kernel/rcutree.h
81420 @@ -87,7 +87,7 @@ struct rcu_dynticks {
81421 long long dynticks_nesting; /* Track irq/process nesting level. */
81422 /* Process level is worth LLONG_MAX/2. */
81423 int dynticks_nmi_nesting; /* Track NMI nesting level. */
81424 - atomic_t dynticks; /* Even value for idle, else odd. */
81425 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
81426 #ifdef CONFIG_RCU_FAST_NO_HZ
81427 bool all_lazy; /* Are all CPU's CBs lazy? */
81428 unsigned long nonlazy_posted;
81429 @@ -414,17 +414,17 @@ struct rcu_state {
81430 /* _rcu_barrier(). */
81431 /* End of fields guarded by barrier_mutex. */
81432
81433 - atomic_long_t expedited_start; /* Starting ticket. */
81434 - atomic_long_t expedited_done; /* Done ticket. */
81435 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
81436 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
81437 - atomic_long_t expedited_workdone1; /* # done by others #1. */
81438 - atomic_long_t expedited_workdone2; /* # done by others #2. */
81439 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
81440 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
81441 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
81442 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
81443 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
81444 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
81445 + atomic_long_t expedited_done; /* Done ticket. */
81446 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
81447 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
81448 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
81449 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
81450 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
81451 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
81452 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
81453 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
81454 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
81455
81456 unsigned long jiffies_force_qs; /* Time at which to invoke */
81457 /* force_quiescent_state(). */
81458 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
81459 index 3db5a37..b395fb35 100644
81460 --- a/kernel/rcutree_plugin.h
81461 +++ b/kernel/rcutree_plugin.h
81462 @@ -903,7 +903,7 @@ void synchronize_rcu_expedited(void)
81463
81464 /* Clean up and exit. */
81465 smp_mb(); /* ensure expedited GP seen before counter increment. */
81466 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
81467 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
81468 unlock_mb_ret:
81469 mutex_unlock(&sync_rcu_preempt_exp_mutex);
81470 mb_ret:
81471 @@ -1451,7 +1451,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
81472 free_cpumask_var(cm);
81473 }
81474
81475 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
81476 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
81477 .store = &rcu_cpu_kthread_task,
81478 .thread_should_run = rcu_cpu_kthread_should_run,
81479 .thread_fn = rcu_cpu_kthread,
81480 @@ -1916,7 +1916,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
81481 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
81482 printk(KERN_ERR "\t%d: (%lu %s) idle=%03x/%llx/%d softirq=%u/%u %s\n",
81483 cpu, ticks_value, ticks_title,
81484 - atomic_read(&rdtp->dynticks) & 0xfff,
81485 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
81486 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
81487 rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu),
81488 fast_no_hz);
81489 @@ -2079,7 +2079,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
81490
81491 /* Enqueue the callback on the nocb list and update counts. */
81492 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
81493 - ACCESS_ONCE(*old_rhpp) = rhp;
81494 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
81495 atomic_long_add(rhcount, &rdp->nocb_q_count);
81496 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
81497
81498 @@ -2219,12 +2219,12 @@ static int rcu_nocb_kthread(void *arg)
81499 * Extract queued callbacks, update counts, and wait
81500 * for a grace period to elapse.
81501 */
81502 - ACCESS_ONCE(rdp->nocb_head) = NULL;
81503 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
81504 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
81505 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
81506 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
81507 - ACCESS_ONCE(rdp->nocb_p_count) += c;
81508 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
81509 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
81510 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
81511 rcu_nocb_wait_gp(rdp);
81512
81513 /* Each pass through the following loop invokes a callback. */
81514 @@ -2246,8 +2246,8 @@ static int rcu_nocb_kthread(void *arg)
81515 list = next;
81516 }
81517 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
81518 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
81519 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
81520 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
81521 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
81522 rdp->n_nocbs_invoked += c;
81523 }
81524 return 0;
81525 @@ -2274,7 +2274,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
81526 t = kthread_run(rcu_nocb_kthread, rdp,
81527 "rcuo%c/%d", rsp->abbr, cpu);
81528 BUG_ON(IS_ERR(t));
81529 - ACCESS_ONCE(rdp->nocb_kthread) = t;
81530 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
81531 }
81532 }
81533
81534 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
81535 index cf6c174..a8f4b50 100644
81536 --- a/kernel/rcutree_trace.c
81537 +++ b/kernel/rcutree_trace.c
81538 @@ -121,7 +121,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
81539 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
81540 rdp->passed_quiesce, rdp->qs_pending);
81541 seq_printf(m, " dt=%d/%llx/%d df=%lu",
81542 - atomic_read(&rdp->dynticks->dynticks),
81543 + atomic_read_unchecked(&rdp->dynticks->dynticks),
81544 rdp->dynticks->dynticks_nesting,
81545 rdp->dynticks->dynticks_nmi_nesting,
81546 rdp->dynticks_fqs);
81547 @@ -182,17 +182,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
81548 struct rcu_state *rsp = (struct rcu_state *)m->private;
81549
81550 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",
81551 - atomic_long_read(&rsp->expedited_start),
81552 + atomic_long_read_unchecked(&rsp->expedited_start),
81553 atomic_long_read(&rsp->expedited_done),
81554 - atomic_long_read(&rsp->expedited_wrap),
81555 - atomic_long_read(&rsp->expedited_tryfail),
81556 - atomic_long_read(&rsp->expedited_workdone1),
81557 - atomic_long_read(&rsp->expedited_workdone2),
81558 - atomic_long_read(&rsp->expedited_normal),
81559 - atomic_long_read(&rsp->expedited_stoppedcpus),
81560 - atomic_long_read(&rsp->expedited_done_tries),
81561 - atomic_long_read(&rsp->expedited_done_lost),
81562 - atomic_long_read(&rsp->expedited_done_exit));
81563 + atomic_long_read_unchecked(&rsp->expedited_wrap),
81564 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
81565 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
81566 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
81567 + atomic_long_read_unchecked(&rsp->expedited_normal),
81568 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
81569 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
81570 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
81571 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
81572 return 0;
81573 }
81574
81575 diff --git a/kernel/resource.c b/kernel/resource.c
81576 index d738698..5f8e60a 100644
81577 --- a/kernel/resource.c
81578 +++ b/kernel/resource.c
81579 @@ -152,8 +152,18 @@ static const struct file_operations proc_iomem_operations = {
81580
81581 static int __init ioresources_init(void)
81582 {
81583 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
81584 +#ifdef CONFIG_GRKERNSEC_PROC_USER
81585 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
81586 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
81587 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
81588 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
81589 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
81590 +#endif
81591 +#else
81592 proc_create("ioports", 0, NULL, &proc_ioports_operations);
81593 proc_create("iomem", 0, NULL, &proc_iomem_operations);
81594 +#endif
81595 return 0;
81596 }
81597 __initcall(ioresources_init);
81598 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
81599 index 1d96dd0..994ff19 100644
81600 --- a/kernel/rtmutex-tester.c
81601 +++ b/kernel/rtmutex-tester.c
81602 @@ -22,7 +22,7 @@
81603 #define MAX_RT_TEST_MUTEXES 8
81604
81605 static spinlock_t rttest_lock;
81606 -static atomic_t rttest_event;
81607 +static atomic_unchecked_t rttest_event;
81608
81609 struct test_thread_data {
81610 int opcode;
81611 @@ -63,7 +63,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
81612
81613 case RTTEST_LOCKCONT:
81614 td->mutexes[td->opdata] = 1;
81615 - td->event = atomic_add_return(1, &rttest_event);
81616 + td->event = atomic_add_return_unchecked(1, &rttest_event);
81617 return 0;
81618
81619 case RTTEST_RESET:
81620 @@ -76,7 +76,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
81621 return 0;
81622
81623 case RTTEST_RESETEVENT:
81624 - atomic_set(&rttest_event, 0);
81625 + atomic_set_unchecked(&rttest_event, 0);
81626 return 0;
81627
81628 default:
81629 @@ -93,9 +93,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
81630 return ret;
81631
81632 td->mutexes[id] = 1;
81633 - td->event = atomic_add_return(1, &rttest_event);
81634 + td->event = atomic_add_return_unchecked(1, &rttest_event);
81635 rt_mutex_lock(&mutexes[id]);
81636 - td->event = atomic_add_return(1, &rttest_event);
81637 + td->event = atomic_add_return_unchecked(1, &rttest_event);
81638 td->mutexes[id] = 4;
81639 return 0;
81640
81641 @@ -106,9 +106,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
81642 return ret;
81643
81644 td->mutexes[id] = 1;
81645 - td->event = atomic_add_return(1, &rttest_event);
81646 + td->event = atomic_add_return_unchecked(1, &rttest_event);
81647 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
81648 - td->event = atomic_add_return(1, &rttest_event);
81649 + td->event = atomic_add_return_unchecked(1, &rttest_event);
81650 td->mutexes[id] = ret ? 0 : 4;
81651 return ret ? -EINTR : 0;
81652
81653 @@ -117,9 +117,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
81654 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
81655 return ret;
81656
81657 - td->event = atomic_add_return(1, &rttest_event);
81658 + td->event = atomic_add_return_unchecked(1, &rttest_event);
81659 rt_mutex_unlock(&mutexes[id]);
81660 - td->event = atomic_add_return(1, &rttest_event);
81661 + td->event = atomic_add_return_unchecked(1, &rttest_event);
81662 td->mutexes[id] = 0;
81663 return 0;
81664
81665 @@ -166,7 +166,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
81666 break;
81667
81668 td->mutexes[dat] = 2;
81669 - td->event = atomic_add_return(1, &rttest_event);
81670 + td->event = atomic_add_return_unchecked(1, &rttest_event);
81671 break;
81672
81673 default:
81674 @@ -186,7 +186,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
81675 return;
81676
81677 td->mutexes[dat] = 3;
81678 - td->event = atomic_add_return(1, &rttest_event);
81679 + td->event = atomic_add_return_unchecked(1, &rttest_event);
81680 break;
81681
81682 case RTTEST_LOCKNOWAIT:
81683 @@ -198,7 +198,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
81684 return;
81685
81686 td->mutexes[dat] = 1;
81687 - td->event = atomic_add_return(1, &rttest_event);
81688 + td->event = atomic_add_return_unchecked(1, &rttest_event);
81689 return;
81690
81691 default:
81692 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
81693 index 64de5f8..7735e12 100644
81694 --- a/kernel/sched/auto_group.c
81695 +++ b/kernel/sched/auto_group.c
81696 @@ -11,7 +11,7 @@
81697
81698 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
81699 static struct autogroup autogroup_default;
81700 -static atomic_t autogroup_seq_nr;
81701 +static atomic_unchecked_t autogroup_seq_nr;
81702
81703 void __init autogroup_init(struct task_struct *init_task)
81704 {
81705 @@ -81,7 +81,7 @@ static inline struct autogroup *autogroup_create(void)
81706
81707 kref_init(&ag->kref);
81708 init_rwsem(&ag->lock);
81709 - ag->id = atomic_inc_return(&autogroup_seq_nr);
81710 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
81711 ag->tg = tg;
81712 #ifdef CONFIG_RT_GROUP_SCHED
81713 /*
81714 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
81715 index e8b3350..d83d44e 100644
81716 --- a/kernel/sched/core.c
81717 +++ b/kernel/sched/core.c
81718 @@ -3440,7 +3440,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
81719 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
81720 * positive (at least 1, or number of jiffies left till timeout) if completed.
81721 */
81722 -long __sched
81723 +long __sched __intentional_overflow(-1)
81724 wait_for_completion_interruptible_timeout(struct completion *x,
81725 unsigned long timeout)
81726 {
81727 @@ -3457,7 +3457,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
81728 *
81729 * The return value is -ERESTARTSYS if interrupted, 0 if completed.
81730 */
81731 -int __sched wait_for_completion_killable(struct completion *x)
81732 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
81733 {
81734 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
81735 if (t == -ERESTARTSYS)
81736 @@ -3478,7 +3478,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
81737 * The return value is -ERESTARTSYS if interrupted, 0 if timed out,
81738 * positive (at least 1, or number of jiffies left till timeout) if completed.
81739 */
81740 -long __sched
81741 +long __sched __intentional_overflow(-1)
81742 wait_for_completion_killable_timeout(struct completion *x,
81743 unsigned long timeout)
81744 {
81745 @@ -3704,6 +3704,8 @@ int can_nice(const struct task_struct *p, const int nice)
81746 /* convert nice value [19,-20] to rlimit style value [1,40] */
81747 int nice_rlim = 20 - nice;
81748
81749 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
81750 +
81751 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
81752 capable(CAP_SYS_NICE));
81753 }
81754 @@ -3737,7 +3739,8 @@ SYSCALL_DEFINE1(nice, int, increment)
81755 if (nice > 19)
81756 nice = 19;
81757
81758 - if (increment < 0 && !can_nice(current, nice))
81759 + if (increment < 0 && (!can_nice(current, nice) ||
81760 + gr_handle_chroot_nice()))
81761 return -EPERM;
81762
81763 retval = security_task_setnice(current, nice);
81764 @@ -3891,6 +3894,7 @@ recheck:
81765 unsigned long rlim_rtprio =
81766 task_rlimit(p, RLIMIT_RTPRIO);
81767
81768 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
81769 /* can't set/change the rt policy */
81770 if (policy != p->policy && !rlim_rtprio)
81771 return -EPERM;
81772 @@ -4988,7 +4992,7 @@ static void migrate_tasks(unsigned int dead_cpu)
81773
81774 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
81775
81776 -static struct ctl_table sd_ctl_dir[] = {
81777 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
81778 {
81779 .procname = "sched_domain",
81780 .mode = 0555,
81781 @@ -5005,17 +5009,17 @@ static struct ctl_table sd_ctl_root[] = {
81782 {}
81783 };
81784
81785 -static struct ctl_table *sd_alloc_ctl_entry(int n)
81786 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
81787 {
81788 - struct ctl_table *entry =
81789 + ctl_table_no_const *entry =
81790 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
81791
81792 return entry;
81793 }
81794
81795 -static void sd_free_ctl_entry(struct ctl_table **tablep)
81796 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
81797 {
81798 - struct ctl_table *entry;
81799 + ctl_table_no_const *entry;
81800
81801 /*
81802 * In the intermediate directories, both the child directory and
81803 @@ -5023,22 +5027,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
81804 * will always be set. In the lowest directory the names are
81805 * static strings and all have proc handlers.
81806 */
81807 - for (entry = *tablep; entry->mode; entry++) {
81808 - if (entry->child)
81809 - sd_free_ctl_entry(&entry->child);
81810 + for (entry = tablep; entry->mode; entry++) {
81811 + if (entry->child) {
81812 + sd_free_ctl_entry(entry->child);
81813 + pax_open_kernel();
81814 + entry->child = NULL;
81815 + pax_close_kernel();
81816 + }
81817 if (entry->proc_handler == NULL)
81818 kfree(entry->procname);
81819 }
81820
81821 - kfree(*tablep);
81822 - *tablep = NULL;
81823 + kfree(tablep);
81824 }
81825
81826 static int min_load_idx = 0;
81827 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
81828
81829 static void
81830 -set_table_entry(struct ctl_table *entry,
81831 +set_table_entry(ctl_table_no_const *entry,
81832 const char *procname, void *data, int maxlen,
81833 umode_t mode, proc_handler *proc_handler,
81834 bool load_idx)
81835 @@ -5058,7 +5065,7 @@ set_table_entry(struct ctl_table *entry,
81836 static struct ctl_table *
81837 sd_alloc_ctl_domain_table(struct sched_domain *sd)
81838 {
81839 - struct ctl_table *table = sd_alloc_ctl_entry(13);
81840 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
81841
81842 if (table == NULL)
81843 return NULL;
81844 @@ -5093,9 +5100,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
81845 return table;
81846 }
81847
81848 -static ctl_table *sd_alloc_ctl_cpu_table(int cpu)
81849 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
81850 {
81851 - struct ctl_table *entry, *table;
81852 + ctl_table_no_const *entry, *table;
81853 struct sched_domain *sd;
81854 int domain_num = 0, i;
81855 char buf[32];
81856 @@ -5122,11 +5129,13 @@ static struct ctl_table_header *sd_sysctl_header;
81857 static void register_sched_domain_sysctl(void)
81858 {
81859 int i, cpu_num = num_possible_cpus();
81860 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
81861 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
81862 char buf[32];
81863
81864 WARN_ON(sd_ctl_dir[0].child);
81865 + pax_open_kernel();
81866 sd_ctl_dir[0].child = entry;
81867 + pax_close_kernel();
81868
81869 if (entry == NULL)
81870 return;
81871 @@ -5149,8 +5158,12 @@ static void unregister_sched_domain_sysctl(void)
81872 if (sd_sysctl_header)
81873 unregister_sysctl_table(sd_sysctl_header);
81874 sd_sysctl_header = NULL;
81875 - if (sd_ctl_dir[0].child)
81876 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
81877 + if (sd_ctl_dir[0].child) {
81878 + sd_free_ctl_entry(sd_ctl_dir[0].child);
81879 + pax_open_kernel();
81880 + sd_ctl_dir[0].child = NULL;
81881 + pax_close_kernel();
81882 + }
81883 }
81884 #else
81885 static void register_sched_domain_sysctl(void)
81886 @@ -5249,7 +5262,7 @@ migration_call(struct notifier_block *nfb, unsigned long action, void *hcpu)
81887 * happens before everything else. This has to be lower priority than
81888 * the notifier in the perf_event subsystem, though.
81889 */
81890 -static struct notifier_block __cpuinitdata migration_notifier = {
81891 +static struct notifier_block migration_notifier = {
81892 .notifier_call = migration_call,
81893 .priority = CPU_PRI_MIGRATION,
81894 };
81895 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
81896 index 03b73be..9422b9f 100644
81897 --- a/kernel/sched/fair.c
81898 +++ b/kernel/sched/fair.c
81899 @@ -831,7 +831,7 @@ void task_numa_fault(int node, int pages, bool migrated)
81900
81901 static void reset_ptenuma_scan(struct task_struct *p)
81902 {
81903 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
81904 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
81905 p->mm->numa_scan_offset = 0;
81906 }
81907
81908 @@ -5687,7 +5687,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
81909 * run_rebalance_domains is triggered when needed from the scheduler tick.
81910 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
81911 */
81912 -static void run_rebalance_domains(struct softirq_action *h)
81913 +static void run_rebalance_domains(void)
81914 {
81915 int this_cpu = smp_processor_id();
81916 struct rq *this_rq = cpu_rq(this_cpu);
81917 diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
81918 index ce39224d..0e09343 100644
81919 --- a/kernel/sched/sched.h
81920 +++ b/kernel/sched/sched.h
81921 @@ -1009,7 +1009,7 @@ struct sched_class {
81922 #ifdef CONFIG_FAIR_GROUP_SCHED
81923 void (*task_move_group) (struct task_struct *p, int on_rq);
81924 #endif
81925 -};
81926 +} __do_const;
81927
81928 #define sched_class_highest (&stop_sched_class)
81929 #define for_each_class(class) \
81930 diff --git a/kernel/signal.c b/kernel/signal.c
81931 index 113411b..20d0a99 100644
81932 --- a/kernel/signal.c
81933 +++ b/kernel/signal.c
81934 @@ -51,12 +51,12 @@ static struct kmem_cache *sigqueue_cachep;
81935
81936 int print_fatal_signals __read_mostly;
81937
81938 -static void __user *sig_handler(struct task_struct *t, int sig)
81939 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
81940 {
81941 return t->sighand->action[sig - 1].sa.sa_handler;
81942 }
81943
81944 -static int sig_handler_ignored(void __user *handler, int sig)
81945 +static int sig_handler_ignored(__sighandler_t handler, int sig)
81946 {
81947 /* Is it explicitly or implicitly ignored? */
81948 return handler == SIG_IGN ||
81949 @@ -65,7 +65,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
81950
81951 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
81952 {
81953 - void __user *handler;
81954 + __sighandler_t handler;
81955
81956 handler = sig_handler(t, sig);
81957
81958 @@ -369,6 +369,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
81959 atomic_inc(&user->sigpending);
81960 rcu_read_unlock();
81961
81962 + if (!override_rlimit)
81963 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
81964 +
81965 if (override_rlimit ||
81966 atomic_read(&user->sigpending) <=
81967 task_rlimit(t, RLIMIT_SIGPENDING)) {
81968 @@ -496,7 +499,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
81969
81970 int unhandled_signal(struct task_struct *tsk, int sig)
81971 {
81972 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
81973 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
81974 if (is_global_init(tsk))
81975 return 1;
81976 if (handler != SIG_IGN && handler != SIG_DFL)
81977 @@ -816,6 +819,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
81978 }
81979 }
81980
81981 + /* allow glibc communication via tgkill to other threads in our
81982 + thread group */
81983 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
81984 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
81985 + && gr_handle_signal(t, sig))
81986 + return -EPERM;
81987 +
81988 return security_task_kill(t, info, sig, 0);
81989 }
81990
81991 @@ -1199,7 +1209,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
81992 return send_signal(sig, info, p, 1);
81993 }
81994
81995 -static int
81996 +int
81997 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
81998 {
81999 return send_signal(sig, info, t, 0);
82000 @@ -1236,6 +1246,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
82001 unsigned long int flags;
82002 int ret, blocked, ignored;
82003 struct k_sigaction *action;
82004 + int is_unhandled = 0;
82005
82006 spin_lock_irqsave(&t->sighand->siglock, flags);
82007 action = &t->sighand->action[sig-1];
82008 @@ -1250,9 +1261,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
82009 }
82010 if (action->sa.sa_handler == SIG_DFL)
82011 t->signal->flags &= ~SIGNAL_UNKILLABLE;
82012 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
82013 + is_unhandled = 1;
82014 ret = specific_send_sig_info(sig, info, t);
82015 spin_unlock_irqrestore(&t->sighand->siglock, flags);
82016
82017 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
82018 + normal operation */
82019 + if (is_unhandled) {
82020 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
82021 + gr_handle_crash(t, sig);
82022 + }
82023 +
82024 return ret;
82025 }
82026
82027 @@ -1319,8 +1339,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
82028 ret = check_kill_permission(sig, info, p);
82029 rcu_read_unlock();
82030
82031 - if (!ret && sig)
82032 + if (!ret && sig) {
82033 ret = do_send_sig_info(sig, info, p, true);
82034 + if (!ret)
82035 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
82036 + }
82037
82038 return ret;
82039 }
82040 @@ -2926,7 +2949,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
82041 int error = -ESRCH;
82042
82043 rcu_read_lock();
82044 - p = find_task_by_vpid(pid);
82045 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
82046 + /* allow glibc communication via tgkill to other threads in our
82047 + thread group */
82048 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
82049 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
82050 + p = find_task_by_vpid_unrestricted(pid);
82051 + else
82052 +#endif
82053 + p = find_task_by_vpid(pid);
82054 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
82055 error = check_kill_permission(sig, info, p);
82056 /*
82057 @@ -3219,6 +3250,16 @@ int __save_altstack(stack_t __user *uss, unsigned long sp)
82058 __put_user(t->sas_ss_size, &uss->ss_size);
82059 }
82060
82061 +#ifdef CONFIG_X86
82062 +void __save_altstack_ex(stack_t __user *uss, unsigned long sp)
82063 +{
82064 + struct task_struct *t = current;
82065 + put_user_ex((void __user *)t->sas_ss_sp, &uss->ss_sp);
82066 + put_user_ex(sas_ss_flags(sp), &uss->ss_flags);
82067 + put_user_ex(t->sas_ss_size, &uss->ss_size);
82068 +}
82069 +#endif
82070 +
82071 #ifdef CONFIG_COMPAT
82072 COMPAT_SYSCALL_DEFINE2(sigaltstack,
82073 const compat_stack_t __user *, uss_ptr,
82074 @@ -3240,8 +3281,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
82075 }
82076 seg = get_fs();
82077 set_fs(KERNEL_DS);
82078 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
82079 - (stack_t __force __user *) &uoss,
82080 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
82081 + (stack_t __force_user *) &uoss,
82082 compat_user_stack_pointer());
82083 set_fs(seg);
82084 if (ret >= 0 && uoss_ptr) {
82085 @@ -3268,6 +3309,16 @@ int __compat_save_altstack(compat_stack_t __user *uss, unsigned long sp)
82086 __put_user(sas_ss_flags(sp), &uss->ss_flags) |
82087 __put_user(t->sas_ss_size, &uss->ss_size);
82088 }
82089 +
82090 +#ifdef CONFIG_X86
82091 +void __compat_save_altstack_ex(compat_stack_t __user *uss, unsigned long sp)
82092 +{
82093 + struct task_struct *t = current;
82094 + put_user_ex(ptr_to_compat((void __user *)t->sas_ss_sp), &uss->ss_sp);
82095 + put_user_ex(sas_ss_flags(sp), &uss->ss_flags);
82096 + put_user_ex(t->sas_ss_size, &uss->ss_size);
82097 +}
82098 +#endif
82099 #endif
82100
82101 #ifdef __ARCH_WANT_SYS_SIGPENDING
82102 diff --git a/kernel/smp.c b/kernel/smp.c
82103 index 4dba0f7..fe9f773 100644
82104 --- a/kernel/smp.c
82105 +++ b/kernel/smp.c
82106 @@ -73,7 +73,7 @@ hotplug_cfd(struct notifier_block *nfb, unsigned long action, void *hcpu)
82107 return NOTIFY_OK;
82108 }
82109
82110 -static struct notifier_block __cpuinitdata hotplug_cfd_notifier = {
82111 +static struct notifier_block hotplug_cfd_notifier = {
82112 .notifier_call = hotplug_cfd,
82113 };
82114
82115 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
82116 index 02fc5c9..e54c335 100644
82117 --- a/kernel/smpboot.c
82118 +++ b/kernel/smpboot.c
82119 @@ -288,7 +288,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
82120 }
82121 smpboot_unpark_thread(plug_thread, cpu);
82122 }
82123 - list_add(&plug_thread->list, &hotplug_threads);
82124 + pax_list_add(&plug_thread->list, &hotplug_threads);
82125 out:
82126 mutex_unlock(&smpboot_threads_lock);
82127 return ret;
82128 @@ -305,7 +305,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
82129 {
82130 get_online_cpus();
82131 mutex_lock(&smpboot_threads_lock);
82132 - list_del(&plug_thread->list);
82133 + pax_list_del(&plug_thread->list);
82134 smpboot_destroy_threads(plug_thread);
82135 mutex_unlock(&smpboot_threads_lock);
82136 put_online_cpus();
82137 diff --git a/kernel/softirq.c b/kernel/softirq.c
82138 index 3d6833f..da6d93d 100644
82139 --- a/kernel/softirq.c
82140 +++ b/kernel/softirq.c
82141 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
82142 EXPORT_SYMBOL(irq_stat);
82143 #endif
82144
82145 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
82146 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
82147
82148 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
82149
82150 -char *softirq_to_name[NR_SOFTIRQS] = {
82151 +const char * const softirq_to_name[NR_SOFTIRQS] = {
82152 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
82153 "TASKLET", "SCHED", "HRTIMER", "RCU"
82154 };
82155 @@ -250,7 +250,7 @@ restart:
82156 kstat_incr_softirqs_this_cpu(vec_nr);
82157
82158 trace_softirq_entry(vec_nr);
82159 - h->action(h);
82160 + h->action();
82161 trace_softirq_exit(vec_nr);
82162 if (unlikely(prev_count != preempt_count())) {
82163 printk(KERN_ERR "huh, entered softirq %u %s %p"
82164 @@ -405,7 +405,7 @@ void __raise_softirq_irqoff(unsigned int nr)
82165 or_softirq_pending(1UL << nr);
82166 }
82167
82168 -void open_softirq(int nr, void (*action)(struct softirq_action *))
82169 +void __init open_softirq(int nr, void (*action)(void))
82170 {
82171 softirq_vec[nr].action = action;
82172 }
82173 @@ -461,7 +461,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
82174
82175 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
82176
82177 -static void tasklet_action(struct softirq_action *a)
82178 +static void tasklet_action(void)
82179 {
82180 struct tasklet_struct *list;
82181
82182 @@ -496,7 +496,7 @@ static void tasklet_action(struct softirq_action *a)
82183 }
82184 }
82185
82186 -static void tasklet_hi_action(struct softirq_action *a)
82187 +static void tasklet_hi_action(void)
82188 {
82189 struct tasklet_struct *list;
82190
82191 @@ -730,7 +730,7 @@ static int __cpuinit remote_softirq_cpu_notify(struct notifier_block *self,
82192 return NOTIFY_OK;
82193 }
82194
82195 -static struct notifier_block __cpuinitdata remote_softirq_cpu_notifier = {
82196 +static struct notifier_block remote_softirq_cpu_notifier = {
82197 .notifier_call = remote_softirq_cpu_notify,
82198 };
82199
82200 @@ -847,11 +847,11 @@ static int __cpuinit cpu_callback(struct notifier_block *nfb,
82201 return NOTIFY_OK;
82202 }
82203
82204 -static struct notifier_block __cpuinitdata cpu_nfb = {
82205 +static struct notifier_block cpu_nfb = {
82206 .notifier_call = cpu_callback
82207 };
82208
82209 -static struct smp_hotplug_thread softirq_threads = {
82210 +static struct smp_hotplug_thread softirq_threads __read_only = {
82211 .store = &ksoftirqd,
82212 .thread_should_run = ksoftirqd_should_run,
82213 .thread_fn = run_ksoftirqd,
82214 diff --git a/kernel/srcu.c b/kernel/srcu.c
82215 index 01d5ccb..cdcbee6 100644
82216 --- a/kernel/srcu.c
82217 +++ b/kernel/srcu.c
82218 @@ -300,9 +300,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
82219
82220 idx = ACCESS_ONCE(sp->completed) & 0x1;
82221 preempt_disable();
82222 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
82223 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
82224 smp_mb(); /* B */ /* Avoid leaking the critical section. */
82225 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
82226 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
82227 preempt_enable();
82228 return idx;
82229 }
82230 diff --git a/kernel/sys.c b/kernel/sys.c
82231 index 2bbd9a7..0875671 100644
82232 --- a/kernel/sys.c
82233 +++ b/kernel/sys.c
82234 @@ -163,6 +163,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
82235 error = -EACCES;
82236 goto out;
82237 }
82238 +
82239 + if (gr_handle_chroot_setpriority(p, niceval)) {
82240 + error = -EACCES;
82241 + goto out;
82242 + }
82243 +
82244 no_nice = security_task_setnice(p, niceval);
82245 if (no_nice) {
82246 error = no_nice;
82247 @@ -626,6 +632,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
82248 goto error;
82249 }
82250
82251 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
82252 + goto error;
82253 +
82254 if (rgid != (gid_t) -1 ||
82255 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
82256 new->sgid = new->egid;
82257 @@ -661,6 +670,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
82258 old = current_cred();
82259
82260 retval = -EPERM;
82261 +
82262 + if (gr_check_group_change(kgid, kgid, kgid))
82263 + goto error;
82264 +
82265 if (nsown_capable(CAP_SETGID))
82266 new->gid = new->egid = new->sgid = new->fsgid = kgid;
82267 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
82268 @@ -678,7 +691,7 @@ error:
82269 /*
82270 * change the user struct in a credentials set to match the new UID
82271 */
82272 -static int set_user(struct cred *new)
82273 +int set_user(struct cred *new)
82274 {
82275 struct user_struct *new_user;
82276
82277 @@ -758,6 +771,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
82278 goto error;
82279 }
82280
82281 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
82282 + goto error;
82283 +
82284 if (!uid_eq(new->uid, old->uid)) {
82285 retval = set_user(new);
82286 if (retval < 0)
82287 @@ -808,6 +824,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
82288 old = current_cred();
82289
82290 retval = -EPERM;
82291 +
82292 + if (gr_check_crash_uid(kuid))
82293 + goto error;
82294 + if (gr_check_user_change(kuid, kuid, kuid))
82295 + goto error;
82296 +
82297 if (nsown_capable(CAP_SETUID)) {
82298 new->suid = new->uid = kuid;
82299 if (!uid_eq(kuid, old->uid)) {
82300 @@ -877,6 +899,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
82301 goto error;
82302 }
82303
82304 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
82305 + goto error;
82306 +
82307 if (ruid != (uid_t) -1) {
82308 new->uid = kruid;
82309 if (!uid_eq(kruid, old->uid)) {
82310 @@ -959,6 +984,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
82311 goto error;
82312 }
82313
82314 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
82315 + goto error;
82316 +
82317 if (rgid != (gid_t) -1)
82318 new->gid = krgid;
82319 if (egid != (gid_t) -1)
82320 @@ -1020,12 +1048,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
82321 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
82322 nsown_capable(CAP_SETUID)) {
82323 if (!uid_eq(kuid, old->fsuid)) {
82324 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
82325 + goto error;
82326 +
82327 new->fsuid = kuid;
82328 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
82329 goto change_okay;
82330 }
82331 }
82332
82333 +error:
82334 abort_creds(new);
82335 return old_fsuid;
82336
82337 @@ -1058,12 +1090,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
82338 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
82339 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
82340 nsown_capable(CAP_SETGID)) {
82341 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
82342 + goto error;
82343 +
82344 if (!gid_eq(kgid, old->fsgid)) {
82345 new->fsgid = kgid;
82346 goto change_okay;
82347 }
82348 }
82349
82350 +error:
82351 abort_creds(new);
82352 return old_fsgid;
82353
82354 @@ -1432,19 +1468,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
82355 return -EFAULT;
82356
82357 down_read(&uts_sem);
82358 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
82359 + error = __copy_to_user(name->sysname, &utsname()->sysname,
82360 __OLD_UTS_LEN);
82361 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
82362 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
82363 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
82364 __OLD_UTS_LEN);
82365 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
82366 - error |= __copy_to_user(&name->release, &utsname()->release,
82367 + error |= __copy_to_user(name->release, &utsname()->release,
82368 __OLD_UTS_LEN);
82369 error |= __put_user(0, name->release + __OLD_UTS_LEN);
82370 - error |= __copy_to_user(&name->version, &utsname()->version,
82371 + error |= __copy_to_user(name->version, &utsname()->version,
82372 __OLD_UTS_LEN);
82373 error |= __put_user(0, name->version + __OLD_UTS_LEN);
82374 - error |= __copy_to_user(&name->machine, &utsname()->machine,
82375 + error |= __copy_to_user(name->machine, &utsname()->machine,
82376 __OLD_UTS_LEN);
82377 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
82378 up_read(&uts_sem);
82379 @@ -1646,6 +1682,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
82380 */
82381 new_rlim->rlim_cur = 1;
82382 }
82383 + /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
82384 + is changed to a lower value. Since tasks can be created by the same
82385 + user in between this limit change and an execve by this task, force
82386 + a recheck only for this task by setting PF_NPROC_EXCEEDED
82387 + */
82388 + if (resource == RLIMIT_NPROC && tsk->real_cred->user != INIT_USER)
82389 + tsk->flags |= PF_NPROC_EXCEEDED;
82390 }
82391 if (!retval) {
82392 if (old_rlim)
82393 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
82394 index 9edcf45..713c960 100644
82395 --- a/kernel/sysctl.c
82396 +++ b/kernel/sysctl.c
82397 @@ -93,7 +93,6 @@
82398
82399
82400 #if defined(CONFIG_SYSCTL)
82401 -
82402 /* External variables not in a header file. */
82403 extern int sysctl_overcommit_memory;
82404 extern int sysctl_overcommit_ratio;
82405 @@ -119,18 +118,18 @@ extern int blk_iopoll_enabled;
82406
82407 /* Constants used for minimum and maximum */
82408 #ifdef CONFIG_LOCKUP_DETECTOR
82409 -static int sixty = 60;
82410 -static int neg_one = -1;
82411 +static int sixty __read_only = 60;
82412 #endif
82413
82414 -static int zero;
82415 -static int __maybe_unused one = 1;
82416 -static int __maybe_unused two = 2;
82417 -static int __maybe_unused three = 3;
82418 -static unsigned long one_ul = 1;
82419 -static int one_hundred = 100;
82420 +static int neg_one __read_only = -1;
82421 +static int zero __read_only = 0;
82422 +static int __maybe_unused one __read_only = 1;
82423 +static int __maybe_unused two __read_only = 2;
82424 +static int __maybe_unused three __read_only = 3;
82425 +static unsigned long one_ul __read_only = 1;
82426 +static int one_hundred __read_only = 100;
82427 #ifdef CONFIG_PRINTK
82428 -static int ten_thousand = 10000;
82429 +static int ten_thousand __read_only = 10000;
82430 #endif
82431
82432 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
82433 @@ -177,10 +176,8 @@ static int proc_taint(struct ctl_table *table, int write,
82434 void __user *buffer, size_t *lenp, loff_t *ppos);
82435 #endif
82436
82437 -#ifdef CONFIG_PRINTK
82438 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
82439 void __user *buffer, size_t *lenp, loff_t *ppos);
82440 -#endif
82441
82442 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
82443 void __user *buffer, size_t *lenp, loff_t *ppos);
82444 @@ -211,6 +208,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
82445
82446 #endif
82447
82448 +extern struct ctl_table grsecurity_table[];
82449 +
82450 static struct ctl_table kern_table[];
82451 static struct ctl_table vm_table[];
82452 static struct ctl_table fs_table[];
82453 @@ -225,6 +224,20 @@ extern struct ctl_table epoll_table[];
82454 int sysctl_legacy_va_layout;
82455 #endif
82456
82457 +#ifdef CONFIG_PAX_SOFTMODE
82458 +static ctl_table pax_table[] = {
82459 + {
82460 + .procname = "softmode",
82461 + .data = &pax_softmode,
82462 + .maxlen = sizeof(unsigned int),
82463 + .mode = 0600,
82464 + .proc_handler = &proc_dointvec,
82465 + },
82466 +
82467 + { }
82468 +};
82469 +#endif
82470 +
82471 /* The default sysctl tables: */
82472
82473 static struct ctl_table sysctl_base_table[] = {
82474 @@ -273,6 +286,22 @@ static int max_extfrag_threshold = 1000;
82475 #endif
82476
82477 static struct ctl_table kern_table[] = {
82478 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
82479 + {
82480 + .procname = "grsecurity",
82481 + .mode = 0500,
82482 + .child = grsecurity_table,
82483 + },
82484 +#endif
82485 +
82486 +#ifdef CONFIG_PAX_SOFTMODE
82487 + {
82488 + .procname = "pax",
82489 + .mode = 0500,
82490 + .child = pax_table,
82491 + },
82492 +#endif
82493 +
82494 {
82495 .procname = "sched_child_runs_first",
82496 .data = &sysctl_sched_child_runs_first,
82497 @@ -607,7 +636,7 @@ static struct ctl_table kern_table[] = {
82498 .data = &modprobe_path,
82499 .maxlen = KMOD_PATH_LEN,
82500 .mode = 0644,
82501 - .proc_handler = proc_dostring,
82502 + .proc_handler = proc_dostring_modpriv,
82503 },
82504 {
82505 .procname = "modules_disabled",
82506 @@ -774,16 +803,20 @@ static struct ctl_table kern_table[] = {
82507 .extra1 = &zero,
82508 .extra2 = &one,
82509 },
82510 +#endif
82511 {
82512 .procname = "kptr_restrict",
82513 .data = &kptr_restrict,
82514 .maxlen = sizeof(int),
82515 .mode = 0644,
82516 .proc_handler = proc_dointvec_minmax_sysadmin,
82517 +#ifdef CONFIG_GRKERNSEC_HIDESYM
82518 + .extra1 = &two,
82519 +#else
82520 .extra1 = &zero,
82521 +#endif
82522 .extra2 = &two,
82523 },
82524 -#endif
82525 {
82526 .procname = "ngroups_max",
82527 .data = &ngroups_max,
82528 @@ -1025,10 +1058,17 @@ static struct ctl_table kern_table[] = {
82529 */
82530 {
82531 .procname = "perf_event_paranoid",
82532 - .data = &sysctl_perf_event_paranoid,
82533 - .maxlen = sizeof(sysctl_perf_event_paranoid),
82534 + .data = &sysctl_perf_event_legitimately_concerned,
82535 + .maxlen = sizeof(sysctl_perf_event_legitimately_concerned),
82536 .mode = 0644,
82537 - .proc_handler = proc_dointvec,
82538 + /* go ahead, be a hero */
82539 + .proc_handler = proc_dointvec_minmax_sysadmin,
82540 + .extra1 = &neg_one,
82541 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
82542 + .extra2 = &three,
82543 +#else
82544 + .extra2 = &two,
82545 +#endif
82546 },
82547 {
82548 .procname = "perf_event_mlock_kb",
82549 @@ -1282,6 +1322,13 @@ static struct ctl_table vm_table[] = {
82550 .proc_handler = proc_dointvec_minmax,
82551 .extra1 = &zero,
82552 },
82553 + {
82554 + .procname = "heap_stack_gap",
82555 + .data = &sysctl_heap_stack_gap,
82556 + .maxlen = sizeof(sysctl_heap_stack_gap),
82557 + .mode = 0644,
82558 + .proc_handler = proc_doulongvec_minmax,
82559 + },
82560 #else
82561 {
82562 .procname = "nr_trim_pages",
82563 @@ -1746,6 +1793,16 @@ int proc_dostring(struct ctl_table *table, int write,
82564 buffer, lenp, ppos);
82565 }
82566
82567 +int proc_dostring_modpriv(struct ctl_table *table, int write,
82568 + void __user *buffer, size_t *lenp, loff_t *ppos)
82569 +{
82570 + if (write && !capable(CAP_SYS_MODULE))
82571 + return -EPERM;
82572 +
82573 + return _proc_do_string(table->data, table->maxlen, write,
82574 + buffer, lenp, ppos);
82575 +}
82576 +
82577 static size_t proc_skip_spaces(char **buf)
82578 {
82579 size_t ret;
82580 @@ -1851,6 +1908,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
82581 len = strlen(tmp);
82582 if (len > *size)
82583 len = *size;
82584 + if (len > sizeof(tmp))
82585 + len = sizeof(tmp);
82586 if (copy_to_user(*buf, tmp, len))
82587 return -EFAULT;
82588 *size -= len;
82589 @@ -2015,7 +2074,7 @@ int proc_dointvec(struct ctl_table *table, int write,
82590 static int proc_taint(struct ctl_table *table, int write,
82591 void __user *buffer, size_t *lenp, loff_t *ppos)
82592 {
82593 - struct ctl_table t;
82594 + ctl_table_no_const t;
82595 unsigned long tmptaint = get_taint();
82596 int err;
82597
82598 @@ -2043,7 +2102,6 @@ static int proc_taint(struct ctl_table *table, int write,
82599 return err;
82600 }
82601
82602 -#ifdef CONFIG_PRINTK
82603 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
82604 void __user *buffer, size_t *lenp, loff_t *ppos)
82605 {
82606 @@ -2052,7 +2110,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
82607
82608 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
82609 }
82610 -#endif
82611
82612 struct do_proc_dointvec_minmax_conv_param {
82613 int *min;
82614 @@ -2199,8 +2256,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
82615 *i = val;
82616 } else {
82617 val = convdiv * (*i) / convmul;
82618 - if (!first)
82619 + if (!first) {
82620 err = proc_put_char(&buffer, &left, '\t');
82621 + if (err)
82622 + break;
82623 + }
82624 err = proc_put_long(&buffer, &left, val, false);
82625 if (err)
82626 break;
82627 @@ -2592,6 +2652,12 @@ int proc_dostring(struct ctl_table *table, int write,
82628 return -ENOSYS;
82629 }
82630
82631 +int proc_dostring_modpriv(struct ctl_table *table, int write,
82632 + void __user *buffer, size_t *lenp, loff_t *ppos)
82633 +{
82634 + return -ENOSYS;
82635 +}
82636 +
82637 int proc_dointvec(struct ctl_table *table, int write,
82638 void __user *buffer, size_t *lenp, loff_t *ppos)
82639 {
82640 @@ -2648,5 +2714,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
82641 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
82642 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
82643 EXPORT_SYMBOL(proc_dostring);
82644 +EXPORT_SYMBOL(proc_dostring_modpriv);
82645 EXPORT_SYMBOL(proc_doulongvec_minmax);
82646 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
82647 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
82648 index 145bb4d..b2aa969 100644
82649 --- a/kernel/taskstats.c
82650 +++ b/kernel/taskstats.c
82651 @@ -28,9 +28,12 @@
82652 #include <linux/fs.h>
82653 #include <linux/file.h>
82654 #include <linux/pid_namespace.h>
82655 +#include <linux/grsecurity.h>
82656 #include <net/genetlink.h>
82657 #include <linux/atomic.h>
82658
82659 +extern int gr_is_taskstats_denied(int pid);
82660 +
82661 /*
82662 * Maximum length of a cpumask that can be specified in
82663 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
82664 @@ -570,6 +573,9 @@ err:
82665
82666 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
82667 {
82668 + if (gr_is_taskstats_denied(current->pid))
82669 + return -EACCES;
82670 +
82671 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
82672 return cmd_attr_register_cpumask(info);
82673 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
82674 diff --git a/kernel/time.c b/kernel/time.c
82675 index d3617db..c98bbe9 100644
82676 --- a/kernel/time.c
82677 +++ b/kernel/time.c
82678 @@ -172,6 +172,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
82679 return error;
82680
82681 if (tz) {
82682 + /* we log in do_settimeofday called below, so don't log twice
82683 + */
82684 + if (!tv)
82685 + gr_log_timechange();
82686 +
82687 sys_tz = *tz;
82688 update_vsyscall_tz();
82689 if (firsttime) {
82690 @@ -502,7 +507,7 @@ EXPORT_SYMBOL(usecs_to_jiffies);
82691 * The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
82692 * value to a scaled second value.
82693 */
82694 -unsigned long
82695 +unsigned long __intentional_overflow(-1)
82696 timespec_to_jiffies(const struct timespec *value)
82697 {
82698 unsigned long sec = value->tv_sec;
82699 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
82700 index f11d83b..d016d91 100644
82701 --- a/kernel/time/alarmtimer.c
82702 +++ b/kernel/time/alarmtimer.c
82703 @@ -750,7 +750,7 @@ static int __init alarmtimer_init(void)
82704 struct platform_device *pdev;
82705 int error = 0;
82706 int i;
82707 - struct k_clock alarm_clock = {
82708 + static struct k_clock alarm_clock = {
82709 .clock_getres = alarm_clock_getres,
82710 .clock_get = alarm_clock_get,
82711 .timer_create = alarm_timer_create,
82712 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
82713 index baeeb5c..c22704a 100644
82714 --- a/kernel/time/timekeeping.c
82715 +++ b/kernel/time/timekeeping.c
82716 @@ -15,6 +15,7 @@
82717 #include <linux/init.h>
82718 #include <linux/mm.h>
82719 #include <linux/sched.h>
82720 +#include <linux/grsecurity.h>
82721 #include <linux/syscore_ops.h>
82722 #include <linux/clocksource.h>
82723 #include <linux/jiffies.h>
82724 @@ -495,6 +496,8 @@ int do_settimeofday(const struct timespec *tv)
82725 if (!timespec_valid_strict(tv))
82726 return -EINVAL;
82727
82728 + gr_log_timechange();
82729 +
82730 raw_spin_lock_irqsave(&timekeeper_lock, flags);
82731 write_seqcount_begin(&timekeeper_seq);
82732
82733 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
82734 index 3bdf283..cc68d83 100644
82735 --- a/kernel/time/timer_list.c
82736 +++ b/kernel/time/timer_list.c
82737 @@ -45,12 +45,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
82738
82739 static void print_name_offset(struct seq_file *m, void *sym)
82740 {
82741 +#ifdef CONFIG_GRKERNSEC_HIDESYM
82742 + SEQ_printf(m, "<%p>", NULL);
82743 +#else
82744 char symname[KSYM_NAME_LEN];
82745
82746 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
82747 SEQ_printf(m, "<%pK>", sym);
82748 else
82749 SEQ_printf(m, "%s", symname);
82750 +#endif
82751 }
82752
82753 static void
82754 @@ -119,7 +123,11 @@ next_one:
82755 static void
82756 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
82757 {
82758 +#ifdef CONFIG_GRKERNSEC_HIDESYM
82759 + SEQ_printf(m, " .base: %p\n", NULL);
82760 +#else
82761 SEQ_printf(m, " .base: %pK\n", base);
82762 +#endif
82763 SEQ_printf(m, " .index: %d\n",
82764 base->index);
82765 SEQ_printf(m, " .resolution: %Lu nsecs\n",
82766 @@ -355,7 +363,11 @@ static int __init init_timer_list_procfs(void)
82767 {
82768 struct proc_dir_entry *pe;
82769
82770 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
82771 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
82772 +#else
82773 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
82774 +#endif
82775 if (!pe)
82776 return -ENOMEM;
82777 return 0;
82778 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
82779 index 0b537f2..40d6c20 100644
82780 --- a/kernel/time/timer_stats.c
82781 +++ b/kernel/time/timer_stats.c
82782 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
82783 static unsigned long nr_entries;
82784 static struct entry entries[MAX_ENTRIES];
82785
82786 -static atomic_t overflow_count;
82787 +static atomic_unchecked_t overflow_count;
82788
82789 /*
82790 * The entries are in a hash-table, for fast lookup:
82791 @@ -140,7 +140,7 @@ static void reset_entries(void)
82792 nr_entries = 0;
82793 memset(entries, 0, sizeof(entries));
82794 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
82795 - atomic_set(&overflow_count, 0);
82796 + atomic_set_unchecked(&overflow_count, 0);
82797 }
82798
82799 static struct entry *alloc_entry(void)
82800 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
82801 if (likely(entry))
82802 entry->count++;
82803 else
82804 - atomic_inc(&overflow_count);
82805 + atomic_inc_unchecked(&overflow_count);
82806
82807 out_unlock:
82808 raw_spin_unlock_irqrestore(lock, flags);
82809 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
82810
82811 static void print_name_offset(struct seq_file *m, unsigned long addr)
82812 {
82813 +#ifdef CONFIG_GRKERNSEC_HIDESYM
82814 + seq_printf(m, "<%p>", NULL);
82815 +#else
82816 char symname[KSYM_NAME_LEN];
82817
82818 if (lookup_symbol_name(addr, symname) < 0)
82819 - seq_printf(m, "<%p>", (void *)addr);
82820 + seq_printf(m, "<%pK>", (void *)addr);
82821 else
82822 seq_printf(m, "%s", symname);
82823 +#endif
82824 }
82825
82826 static int tstats_show(struct seq_file *m, void *v)
82827 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
82828
82829 seq_puts(m, "Timer Stats Version: v0.2\n");
82830 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
82831 - if (atomic_read(&overflow_count))
82832 + if (atomic_read_unchecked(&overflow_count))
82833 seq_printf(m, "Overflow: %d entries\n",
82834 - atomic_read(&overflow_count));
82835 + atomic_read_unchecked(&overflow_count));
82836
82837 for (i = 0; i < nr_entries; i++) {
82838 entry = entries + i;
82839 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
82840 {
82841 struct proc_dir_entry *pe;
82842
82843 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
82844 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
82845 +#else
82846 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
82847 +#endif
82848 if (!pe)
82849 return -ENOMEM;
82850 return 0;
82851 diff --git a/kernel/timer.c b/kernel/timer.c
82852 index 15bc1b4..32da49c 100644
82853 --- a/kernel/timer.c
82854 +++ b/kernel/timer.c
82855 @@ -1366,7 +1366,7 @@ void update_process_times(int user_tick)
82856 /*
82857 * This function runs timers and the timer-tq in bottom half context.
82858 */
82859 -static void run_timer_softirq(struct softirq_action *h)
82860 +static void run_timer_softirq(void)
82861 {
82862 struct tvec_base *base = __this_cpu_read(tvec_bases);
82863
82864 @@ -1429,7 +1429,7 @@ static void process_timeout(unsigned long __data)
82865 *
82866 * In all cases the return value is guaranteed to be non-negative.
82867 */
82868 -signed long __sched schedule_timeout(signed long timeout)
82869 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
82870 {
82871 struct timer_list timer;
82872 unsigned long expire;
82873 @@ -1635,7 +1635,7 @@ static int __cpuinit timer_cpu_notify(struct notifier_block *self,
82874 return NOTIFY_OK;
82875 }
82876
82877 -static struct notifier_block __cpuinitdata timers_nb = {
82878 +static struct notifier_block timers_nb = {
82879 .notifier_call = timer_cpu_notify,
82880 };
82881
82882 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
82883 index b8b8560..75b1a09 100644
82884 --- a/kernel/trace/blktrace.c
82885 +++ b/kernel/trace/blktrace.c
82886 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
82887 struct blk_trace *bt = filp->private_data;
82888 char buf[16];
82889
82890 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
82891 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
82892
82893 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
82894 }
82895 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
82896 return 1;
82897
82898 bt = buf->chan->private_data;
82899 - atomic_inc(&bt->dropped);
82900 + atomic_inc_unchecked(&bt->dropped);
82901 return 0;
82902 }
82903
82904 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
82905
82906 bt->dir = dir;
82907 bt->dev = dev;
82908 - atomic_set(&bt->dropped, 0);
82909 + atomic_set_unchecked(&bt->dropped, 0);
82910
82911 ret = -EIO;
82912 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
82913 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
82914 index 6c508ff..ee55a13 100644
82915 --- a/kernel/trace/ftrace.c
82916 +++ b/kernel/trace/ftrace.c
82917 @@ -1915,12 +1915,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
82918 if (unlikely(ftrace_disabled))
82919 return 0;
82920
82921 + ret = ftrace_arch_code_modify_prepare();
82922 + FTRACE_WARN_ON(ret);
82923 + if (ret)
82924 + return 0;
82925 +
82926 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
82927 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
82928 if (ret) {
82929 ftrace_bug(ret, ip);
82930 - return 0;
82931 }
82932 - return 1;
82933 + return ret ? 0 : 1;
82934 }
82935
82936 /*
82937 @@ -3931,8 +3936,10 @@ static int ftrace_process_locs(struct module *mod,
82938 if (!count)
82939 return 0;
82940
82941 + pax_open_kernel();
82942 sort(start, count, sizeof(*start),
82943 ftrace_cmp_ips, ftrace_swap_ips);
82944 + pax_close_kernel();
82945
82946 start_pg = ftrace_allocate_pages(count);
82947 if (!start_pg)
82948 @@ -4655,8 +4662,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
82949 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
82950
82951 static int ftrace_graph_active;
82952 -static struct notifier_block ftrace_suspend_notifier;
82953 -
82954 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
82955 {
82956 return 0;
82957 @@ -4800,6 +4805,10 @@ ftrace_suspend_notifier_call(struct notifier_block *bl, unsigned long state,
82958 return NOTIFY_DONE;
82959 }
82960
82961 +static struct notifier_block ftrace_suspend_notifier = {
82962 + .notifier_call = ftrace_suspend_notifier_call
82963 +};
82964 +
82965 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
82966 trace_func_graph_ent_t entryfunc)
82967 {
82968 @@ -4813,7 +4822,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
82969 goto out;
82970 }
82971
82972 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
82973 register_pm_notifier(&ftrace_suspend_notifier);
82974
82975 ftrace_graph_active++;
82976 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
82977 index e444ff8..438b8f4 100644
82978 --- a/kernel/trace/ring_buffer.c
82979 +++ b/kernel/trace/ring_buffer.c
82980 @@ -352,9 +352,9 @@ struct buffer_data_page {
82981 */
82982 struct buffer_page {
82983 struct list_head list; /* list of buffer pages */
82984 - local_t write; /* index for next write */
82985 + local_unchecked_t write; /* index for next write */
82986 unsigned read; /* index for next read */
82987 - local_t entries; /* entries on this page */
82988 + local_unchecked_t entries; /* entries on this page */
82989 unsigned long real_end; /* real end of data */
82990 struct buffer_data_page *page; /* Actual data page */
82991 };
82992 @@ -473,8 +473,8 @@ struct ring_buffer_per_cpu {
82993 unsigned long last_overrun;
82994 local_t entries_bytes;
82995 local_t entries;
82996 - local_t overrun;
82997 - local_t commit_overrun;
82998 + local_unchecked_t overrun;
82999 + local_unchecked_t commit_overrun;
83000 local_t dropped_events;
83001 local_t committing;
83002 local_t commits;
83003 @@ -992,8 +992,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
83004 *
83005 * We add a counter to the write field to denote this.
83006 */
83007 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
83008 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
83009 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
83010 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
83011
83012 /*
83013 * Just make sure we have seen our old_write and synchronize
83014 @@ -1021,8 +1021,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
83015 * cmpxchg to only update if an interrupt did not already
83016 * do it for us. If the cmpxchg fails, we don't care.
83017 */
83018 - (void)local_cmpxchg(&next_page->write, old_write, val);
83019 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
83020 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
83021 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
83022
83023 /*
83024 * No need to worry about races with clearing out the commit.
83025 @@ -1386,12 +1386,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
83026
83027 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
83028 {
83029 - return local_read(&bpage->entries) & RB_WRITE_MASK;
83030 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
83031 }
83032
83033 static inline unsigned long rb_page_write(struct buffer_page *bpage)
83034 {
83035 - return local_read(&bpage->write) & RB_WRITE_MASK;
83036 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
83037 }
83038
83039 static int
83040 @@ -1486,7 +1486,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
83041 * bytes consumed in ring buffer from here.
83042 * Increment overrun to account for the lost events.
83043 */
83044 - local_add(page_entries, &cpu_buffer->overrun);
83045 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
83046 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
83047 }
83048
83049 @@ -2063,7 +2063,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
83050 * it is our responsibility to update
83051 * the counters.
83052 */
83053 - local_add(entries, &cpu_buffer->overrun);
83054 + local_add_unchecked(entries, &cpu_buffer->overrun);
83055 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
83056
83057 /*
83058 @@ -2213,7 +2213,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
83059 if (tail == BUF_PAGE_SIZE)
83060 tail_page->real_end = 0;
83061
83062 - local_sub(length, &tail_page->write);
83063 + local_sub_unchecked(length, &tail_page->write);
83064 return;
83065 }
83066
83067 @@ -2248,7 +2248,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
83068 rb_event_set_padding(event);
83069
83070 /* Set the write back to the previous setting */
83071 - local_sub(length, &tail_page->write);
83072 + local_sub_unchecked(length, &tail_page->write);
83073 return;
83074 }
83075
83076 @@ -2260,7 +2260,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
83077
83078 /* Set write to end of buffer */
83079 length = (tail + length) - BUF_PAGE_SIZE;
83080 - local_sub(length, &tail_page->write);
83081 + local_sub_unchecked(length, &tail_page->write);
83082 }
83083
83084 /*
83085 @@ -2286,7 +2286,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
83086 * about it.
83087 */
83088 if (unlikely(next_page == commit_page)) {
83089 - local_inc(&cpu_buffer->commit_overrun);
83090 + local_inc_unchecked(&cpu_buffer->commit_overrun);
83091 goto out_reset;
83092 }
83093
83094 @@ -2342,7 +2342,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
83095 cpu_buffer->tail_page) &&
83096 (cpu_buffer->commit_page ==
83097 cpu_buffer->reader_page))) {
83098 - local_inc(&cpu_buffer->commit_overrun);
83099 + local_inc_unchecked(&cpu_buffer->commit_overrun);
83100 goto out_reset;
83101 }
83102 }
83103 @@ -2390,7 +2390,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
83104 length += RB_LEN_TIME_EXTEND;
83105
83106 tail_page = cpu_buffer->tail_page;
83107 - write = local_add_return(length, &tail_page->write);
83108 + write = local_add_return_unchecked(length, &tail_page->write);
83109
83110 /* set write to only the index of the write */
83111 write &= RB_WRITE_MASK;
83112 @@ -2407,7 +2407,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
83113 kmemcheck_annotate_bitfield(event, bitfield);
83114 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
83115
83116 - local_inc(&tail_page->entries);
83117 + local_inc_unchecked(&tail_page->entries);
83118
83119 /*
83120 * If this is the first commit on the page, then update
83121 @@ -2440,7 +2440,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
83122
83123 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
83124 unsigned long write_mask =
83125 - local_read(&bpage->write) & ~RB_WRITE_MASK;
83126 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
83127 unsigned long event_length = rb_event_length(event);
83128 /*
83129 * This is on the tail page. It is possible that
83130 @@ -2450,7 +2450,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
83131 */
83132 old_index += write_mask;
83133 new_index += write_mask;
83134 - index = local_cmpxchg(&bpage->write, old_index, new_index);
83135 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
83136 if (index == old_index) {
83137 /* update counters */
83138 local_sub(event_length, &cpu_buffer->entries_bytes);
83139 @@ -2842,7 +2842,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
83140
83141 /* Do the likely case first */
83142 if (likely(bpage->page == (void *)addr)) {
83143 - local_dec(&bpage->entries);
83144 + local_dec_unchecked(&bpage->entries);
83145 return;
83146 }
83147
83148 @@ -2854,7 +2854,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
83149 start = bpage;
83150 do {
83151 if (bpage->page == (void *)addr) {
83152 - local_dec(&bpage->entries);
83153 + local_dec_unchecked(&bpage->entries);
83154 return;
83155 }
83156 rb_inc_page(cpu_buffer, &bpage);
83157 @@ -3138,7 +3138,7 @@ static inline unsigned long
83158 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
83159 {
83160 return local_read(&cpu_buffer->entries) -
83161 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
83162 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
83163 }
83164
83165 /**
83166 @@ -3227,7 +3227,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
83167 return 0;
83168
83169 cpu_buffer = buffer->buffers[cpu];
83170 - ret = local_read(&cpu_buffer->overrun);
83171 + ret = local_read_unchecked(&cpu_buffer->overrun);
83172
83173 return ret;
83174 }
83175 @@ -3250,7 +3250,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
83176 return 0;
83177
83178 cpu_buffer = buffer->buffers[cpu];
83179 - ret = local_read(&cpu_buffer->commit_overrun);
83180 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
83181
83182 return ret;
83183 }
83184 @@ -3335,7 +3335,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
83185 /* if you care about this being correct, lock the buffer */
83186 for_each_buffer_cpu(buffer, cpu) {
83187 cpu_buffer = buffer->buffers[cpu];
83188 - overruns += local_read(&cpu_buffer->overrun);
83189 + overruns += local_read_unchecked(&cpu_buffer->overrun);
83190 }
83191
83192 return overruns;
83193 @@ -3511,8 +3511,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
83194 /*
83195 * Reset the reader page to size zero.
83196 */
83197 - local_set(&cpu_buffer->reader_page->write, 0);
83198 - local_set(&cpu_buffer->reader_page->entries, 0);
83199 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
83200 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
83201 local_set(&cpu_buffer->reader_page->page->commit, 0);
83202 cpu_buffer->reader_page->real_end = 0;
83203
83204 @@ -3546,7 +3546,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
83205 * want to compare with the last_overrun.
83206 */
83207 smp_mb();
83208 - overwrite = local_read(&(cpu_buffer->overrun));
83209 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
83210
83211 /*
83212 * Here's the tricky part.
83213 @@ -4116,8 +4116,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
83214
83215 cpu_buffer->head_page
83216 = list_entry(cpu_buffer->pages, struct buffer_page, list);
83217 - local_set(&cpu_buffer->head_page->write, 0);
83218 - local_set(&cpu_buffer->head_page->entries, 0);
83219 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
83220 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
83221 local_set(&cpu_buffer->head_page->page->commit, 0);
83222
83223 cpu_buffer->head_page->read = 0;
83224 @@ -4127,14 +4127,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
83225
83226 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
83227 INIT_LIST_HEAD(&cpu_buffer->new_pages);
83228 - local_set(&cpu_buffer->reader_page->write, 0);
83229 - local_set(&cpu_buffer->reader_page->entries, 0);
83230 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
83231 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
83232 local_set(&cpu_buffer->reader_page->page->commit, 0);
83233 cpu_buffer->reader_page->read = 0;
83234
83235 local_set(&cpu_buffer->entries_bytes, 0);
83236 - local_set(&cpu_buffer->overrun, 0);
83237 - local_set(&cpu_buffer->commit_overrun, 0);
83238 + local_set_unchecked(&cpu_buffer->overrun, 0);
83239 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
83240 local_set(&cpu_buffer->dropped_events, 0);
83241 local_set(&cpu_buffer->entries, 0);
83242 local_set(&cpu_buffer->committing, 0);
83243 @@ -4538,8 +4538,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
83244 rb_init_page(bpage);
83245 bpage = reader->page;
83246 reader->page = *data_page;
83247 - local_set(&reader->write, 0);
83248 - local_set(&reader->entries, 0);
83249 + local_set_unchecked(&reader->write, 0);
83250 + local_set_unchecked(&reader->entries, 0);
83251 reader->read = 0;
83252 *data_page = bpage;
83253
83254 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
83255 index 06a5bce..53ad6e7 100644
83256 --- a/kernel/trace/trace.c
83257 +++ b/kernel/trace/trace.c
83258 @@ -3347,7 +3347,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
83259 return 0;
83260 }
83261
83262 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)
83263 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled)
83264 {
83265 /* do nothing if flag is already set */
83266 if (!!(trace_flags & mask) == !!enabled)
83267 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
83268 index 51b4448..7be601f 100644
83269 --- a/kernel/trace/trace.h
83270 +++ b/kernel/trace/trace.h
83271 @@ -1035,7 +1035,7 @@ extern const char *__stop___trace_bprintk_fmt[];
83272 void trace_printk_init_buffers(void);
83273 void trace_printk_start_comm(void);
83274 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
83275 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled);
83276 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled);
83277
83278 /*
83279 * Normal trace_printk() and friends allocates special buffers
83280 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
83281 index 6953263..2004e16 100644
83282 --- a/kernel/trace/trace_events.c
83283 +++ b/kernel/trace/trace_events.c
83284 @@ -1748,10 +1748,6 @@ static LIST_HEAD(ftrace_module_file_list);
83285 struct ftrace_module_file_ops {
83286 struct list_head list;
83287 struct module *mod;
83288 - struct file_operations id;
83289 - struct file_operations enable;
83290 - struct file_operations format;
83291 - struct file_operations filter;
83292 };
83293
83294 static struct ftrace_module_file_ops *
83295 @@ -1792,17 +1788,12 @@ trace_create_file_ops(struct module *mod)
83296
83297 file_ops->mod = mod;
83298
83299 - file_ops->id = ftrace_event_id_fops;
83300 - file_ops->id.owner = mod;
83301 -
83302 - file_ops->enable = ftrace_enable_fops;
83303 - file_ops->enable.owner = mod;
83304 -
83305 - file_ops->filter = ftrace_event_filter_fops;
83306 - file_ops->filter.owner = mod;
83307 -
83308 - file_ops->format = ftrace_event_format_fops;
83309 - file_ops->format.owner = mod;
83310 + pax_open_kernel();
83311 + mod->trace_id.owner = mod;
83312 + mod->trace_enable.owner = mod;
83313 + mod->trace_filter.owner = mod;
83314 + mod->trace_format.owner = mod;
83315 + pax_close_kernel();
83316
83317 list_add(&file_ops->list, &ftrace_module_file_list);
83318
83319 @@ -1895,8 +1886,8 @@ __trace_add_new_mod_event(struct ftrace_event_call *call,
83320 struct ftrace_module_file_ops *file_ops)
83321 {
83322 return __trace_add_new_event(call, tr,
83323 - &file_ops->id, &file_ops->enable,
83324 - &file_ops->filter, &file_ops->format);
83325 + &file_ops->mod->trace_id, &file_ops->mod->trace_enable,
83326 + &file_ops->mod->trace_filter, &file_ops->mod->trace_format);
83327 }
83328
83329 #else
83330 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
83331 index a5e8f48..a9690d2 100644
83332 --- a/kernel/trace/trace_mmiotrace.c
83333 +++ b/kernel/trace/trace_mmiotrace.c
83334 @@ -24,7 +24,7 @@ struct header_iter {
83335 static struct trace_array *mmio_trace_array;
83336 static bool overrun_detected;
83337 static unsigned long prev_overruns;
83338 -static atomic_t dropped_count;
83339 +static atomic_unchecked_t dropped_count;
83340
83341 static void mmio_reset_data(struct trace_array *tr)
83342 {
83343 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
83344
83345 static unsigned long count_overruns(struct trace_iterator *iter)
83346 {
83347 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
83348 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
83349 unsigned long over = ring_buffer_overruns(iter->trace_buffer->buffer);
83350
83351 if (over > prev_overruns)
83352 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
83353 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
83354 sizeof(*entry), 0, pc);
83355 if (!event) {
83356 - atomic_inc(&dropped_count);
83357 + atomic_inc_unchecked(&dropped_count);
83358 return;
83359 }
83360 entry = ring_buffer_event_data(event);
83361 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
83362 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
83363 sizeof(*entry), 0, pc);
83364 if (!event) {
83365 - atomic_inc(&dropped_count);
83366 + atomic_inc_unchecked(&dropped_count);
83367 return;
83368 }
83369 entry = ring_buffer_event_data(event);
83370 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
83371 index bb922d9..2a54a257 100644
83372 --- a/kernel/trace/trace_output.c
83373 +++ b/kernel/trace/trace_output.c
83374 @@ -294,7 +294,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
83375
83376 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
83377 if (!IS_ERR(p)) {
83378 - p = mangle_path(s->buffer + s->len, p, "\n");
83379 + p = mangle_path(s->buffer + s->len, p, "\n\\");
83380 if (p) {
83381 s->len = p - s->buffer;
83382 return 1;
83383 @@ -893,14 +893,16 @@ int register_ftrace_event(struct trace_event *event)
83384 goto out;
83385 }
83386
83387 + pax_open_kernel();
83388 if (event->funcs->trace == NULL)
83389 - event->funcs->trace = trace_nop_print;
83390 + *(void **)&event->funcs->trace = trace_nop_print;
83391 if (event->funcs->raw == NULL)
83392 - event->funcs->raw = trace_nop_print;
83393 + *(void **)&event->funcs->raw = trace_nop_print;
83394 if (event->funcs->hex == NULL)
83395 - event->funcs->hex = trace_nop_print;
83396 + *(void **)&event->funcs->hex = trace_nop_print;
83397 if (event->funcs->binary == NULL)
83398 - event->funcs->binary = trace_nop_print;
83399 + *(void **)&event->funcs->binary = trace_nop_print;
83400 + pax_close_kernel();
83401
83402 key = event->type & (EVENT_HASHSIZE - 1);
83403
83404 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
83405 index b20428c..4845a10 100644
83406 --- a/kernel/trace/trace_stack.c
83407 +++ b/kernel/trace/trace_stack.c
83408 @@ -68,7 +68,7 @@ check_stack(unsigned long ip, unsigned long *stack)
83409 return;
83410
83411 /* we do not handle interrupt stacks yet */
83412 - if (!object_is_on_stack(stack))
83413 + if (!object_starts_on_stack(stack))
83414 return;
83415
83416 local_irq_save(flags);
83417 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
83418 index 9064b91..1f5d2f8 100644
83419 --- a/kernel/user_namespace.c
83420 +++ b/kernel/user_namespace.c
83421 @@ -82,6 +82,21 @@ int create_user_ns(struct cred *new)
83422 !kgid_has_mapping(parent_ns, group))
83423 return -EPERM;
83424
83425 +#ifdef CONFIG_GRKERNSEC
83426 + /*
83427 + * This doesn't really inspire confidence:
83428 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
83429 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
83430 + * Increases kernel attack surface in areas developers
83431 + * previously cared little about ("low importance due
83432 + * to requiring "root" capability")
83433 + * To be removed when this code receives *proper* review
83434 + */
83435 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
83436 + !capable(CAP_SETGID))
83437 + return -EPERM;
83438 +#endif
83439 +
83440 ns = kmem_cache_zalloc(user_ns_cachep, GFP_KERNEL);
83441 if (!ns)
83442 return -ENOMEM;
83443 @@ -862,7 +877,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
83444 if (atomic_read(&current->mm->mm_users) > 1)
83445 return -EINVAL;
83446
83447 - if (current->fs->users != 1)
83448 + if (atomic_read(&current->fs->users) != 1)
83449 return -EINVAL;
83450
83451 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
83452 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
83453 index 4f69f9a..7c6f8f8 100644
83454 --- a/kernel/utsname_sysctl.c
83455 +++ b/kernel/utsname_sysctl.c
83456 @@ -47,7 +47,7 @@ static void put_uts(ctl_table *table, int write, void *which)
83457 static int proc_do_uts_string(ctl_table *table, int write,
83458 void __user *buffer, size_t *lenp, loff_t *ppos)
83459 {
83460 - struct ctl_table uts_table;
83461 + ctl_table_no_const uts_table;
83462 int r;
83463 memcpy(&uts_table, table, sizeof(uts_table));
83464 uts_table.data = get_uts(table, write);
83465 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
83466 index 05039e3..17490c7 100644
83467 --- a/kernel/watchdog.c
83468 +++ b/kernel/watchdog.c
83469 @@ -531,7 +531,7 @@ int proc_dowatchdog(struct ctl_table *table, int write,
83470 }
83471 #endif /* CONFIG_SYSCTL */
83472
83473 -static struct smp_hotplug_thread watchdog_threads = {
83474 +static struct smp_hotplug_thread watchdog_threads __read_only = {
83475 .store = &softlockup_watchdog,
83476 .thread_should_run = watchdog_should_run,
83477 .thread_fn = watchdog,
83478 diff --git a/kernel/workqueue.c b/kernel/workqueue.c
83479 index 6f01921..139869b 100644
83480 --- a/kernel/workqueue.c
83481 +++ b/kernel/workqueue.c
83482 @@ -4596,7 +4596,7 @@ static void rebind_workers(struct worker_pool *pool)
83483 WARN_ON_ONCE(!(worker_flags & WORKER_UNBOUND));
83484 worker_flags |= WORKER_REBOUND;
83485 worker_flags &= ~WORKER_UNBOUND;
83486 - ACCESS_ONCE(worker->flags) = worker_flags;
83487 + ACCESS_ONCE_RW(worker->flags) = worker_flags;
83488 }
83489
83490 spin_unlock_irq(&pool->lock);
83491 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
83492 index 74fdc5c..3310593 100644
83493 --- a/lib/Kconfig.debug
83494 +++ b/lib/Kconfig.debug
83495 @@ -549,7 +549,7 @@ config DEBUG_MUTEXES
83496
83497 config DEBUG_LOCK_ALLOC
83498 bool "Lock debugging: detect incorrect freeing of live locks"
83499 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
83500 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
83501 select DEBUG_SPINLOCK
83502 select DEBUG_MUTEXES
83503 select LOCKDEP
83504 @@ -563,7 +563,7 @@ config DEBUG_LOCK_ALLOC
83505
83506 config PROVE_LOCKING
83507 bool "Lock debugging: prove locking correctness"
83508 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
83509 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
83510 select LOCKDEP
83511 select DEBUG_SPINLOCK
83512 select DEBUG_MUTEXES
83513 @@ -614,7 +614,7 @@ config LOCKDEP
83514
83515 config LOCK_STAT
83516 bool "Lock usage statistics"
83517 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
83518 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
83519 select LOCKDEP
83520 select DEBUG_SPINLOCK
83521 select DEBUG_MUTEXES
83522 @@ -1282,6 +1282,7 @@ config LATENCYTOP
83523 depends on DEBUG_KERNEL
83524 depends on STACKTRACE_SUPPORT
83525 depends on PROC_FS
83526 + depends on !GRKERNSEC_HIDESYM
83527 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND
83528 select KALLSYMS
83529 select KALLSYMS_ALL
83530 @@ -1298,7 +1299,7 @@ config ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
83531 config DEBUG_STRICT_USER_COPY_CHECKS
83532 bool "Strict user copy size checks"
83533 depends on ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
83534 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
83535 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
83536 help
83537 Enabling this option turns a certain set of sanity checks for user
83538 copy operations into compile time failures.
83539 @@ -1328,7 +1329,7 @@ config INTERVAL_TREE_TEST
83540
83541 config PROVIDE_OHCI1394_DMA_INIT
83542 bool "Remote debugging over FireWire early on boot"
83543 - depends on PCI && X86
83544 + depends on PCI && X86 && !GRKERNSEC
83545 help
83546 If you want to debug problems which hang or crash the kernel early
83547 on boot and the crashing machine has a FireWire port, you can use
83548 @@ -1357,7 +1358,7 @@ config PROVIDE_OHCI1394_DMA_INIT
83549
83550 config FIREWIRE_OHCI_REMOTE_DMA
83551 bool "Remote debugging over FireWire with firewire-ohci"
83552 - depends on FIREWIRE_OHCI
83553 + depends on FIREWIRE_OHCI && !GRKERNSEC
83554 help
83555 This option lets you use the FireWire bus for remote debugging
83556 with help of the firewire-ohci driver. It enables unfiltered
83557 diff --git a/lib/Makefile b/lib/Makefile
83558 index c55a037..fb46e3b 100644
83559 --- a/lib/Makefile
83560 +++ b/lib/Makefile
83561 @@ -50,7 +50,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
83562
83563 obj-$(CONFIG_BTREE) += btree.o
83564 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
83565 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
83566 +obj-y += list_debug.o
83567 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
83568
83569 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
83570 diff --git a/lib/bitmap.c b/lib/bitmap.c
83571 index 06f7e4f..f3cf2b0 100644
83572 --- a/lib/bitmap.c
83573 +++ b/lib/bitmap.c
83574 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
83575 {
83576 int c, old_c, totaldigits, ndigits, nchunks, nbits;
83577 u32 chunk;
83578 - const char __user __force *ubuf = (const char __user __force *)buf;
83579 + const char __user *ubuf = (const char __force_user *)buf;
83580
83581 bitmap_zero(maskp, nmaskbits);
83582
83583 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
83584 {
83585 if (!access_ok(VERIFY_READ, ubuf, ulen))
83586 return -EFAULT;
83587 - return __bitmap_parse((const char __force *)ubuf,
83588 + return __bitmap_parse((const char __force_kernel *)ubuf,
83589 ulen, 1, maskp, nmaskbits);
83590
83591 }
83592 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
83593 {
83594 unsigned a, b;
83595 int c, old_c, totaldigits;
83596 - const char __user __force *ubuf = (const char __user __force *)buf;
83597 + const char __user *ubuf = (const char __force_user *)buf;
83598 int exp_digit, in_range;
83599
83600 totaldigits = c = 0;
83601 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
83602 {
83603 if (!access_ok(VERIFY_READ, ubuf, ulen))
83604 return -EFAULT;
83605 - return __bitmap_parselist((const char __force *)ubuf,
83606 + return __bitmap_parselist((const char __force_kernel *)ubuf,
83607 ulen, 1, maskp, nmaskbits);
83608 }
83609 EXPORT_SYMBOL(bitmap_parselist_user);
83610 diff --git a/lib/bug.c b/lib/bug.c
83611 index 1686034..a9c00c8 100644
83612 --- a/lib/bug.c
83613 +++ b/lib/bug.c
83614 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
83615 return BUG_TRAP_TYPE_NONE;
83616
83617 bug = find_bug(bugaddr);
83618 + if (!bug)
83619 + return BUG_TRAP_TYPE_NONE;
83620
83621 file = NULL;
83622 line = 0;
83623 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
83624 index 37061ed..da83f48 100644
83625 --- a/lib/debugobjects.c
83626 +++ b/lib/debugobjects.c
83627 @@ -286,7 +286,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
83628 if (limit > 4)
83629 return;
83630
83631 - is_on_stack = object_is_on_stack(addr);
83632 + is_on_stack = object_starts_on_stack(addr);
83633 if (is_on_stack == onstack)
83634 return;
83635
83636 diff --git a/lib/devres.c b/lib/devres.c
83637 index 8235331..5881053 100644
83638 --- a/lib/devres.c
83639 +++ b/lib/devres.c
83640 @@ -81,7 +81,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
83641 void devm_iounmap(struct device *dev, void __iomem *addr)
83642 {
83643 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
83644 - (void *)addr));
83645 + (void __force *)addr));
83646 iounmap(addr);
83647 }
83648 EXPORT_SYMBOL(devm_iounmap);
83649 @@ -224,7 +224,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
83650 {
83651 ioport_unmap(addr);
83652 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
83653 - devm_ioport_map_match, (void *)addr));
83654 + devm_ioport_map_match, (void __force *)addr));
83655 }
83656 EXPORT_SYMBOL(devm_ioport_unmap);
83657 #endif /* CONFIG_HAS_IOPORT */
83658 diff --git a/lib/div64.c b/lib/div64.c
83659 index a163b6c..9618fa5 100644
83660 --- a/lib/div64.c
83661 +++ b/lib/div64.c
83662 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
83663 EXPORT_SYMBOL(__div64_32);
83664
83665 #ifndef div_s64_rem
83666 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
83667 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
83668 {
83669 u64 quotient;
83670
83671 @@ -90,7 +90,7 @@ EXPORT_SYMBOL(div_s64_rem);
83672 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
83673 */
83674 #ifndef div64_u64
83675 -u64 div64_u64(u64 dividend, u64 divisor)
83676 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
83677 {
83678 u32 high = divisor >> 32;
83679 u64 quot;
83680 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
83681 index d87a17a..ac0d79a 100644
83682 --- a/lib/dma-debug.c
83683 +++ b/lib/dma-debug.c
83684 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
83685
83686 void dma_debug_add_bus(struct bus_type *bus)
83687 {
83688 - struct notifier_block *nb;
83689 + notifier_block_no_const *nb;
83690
83691 if (global_disable)
83692 return;
83693 @@ -945,7 +945,7 @@ static void check_unmap(struct dma_debug_entry *ref)
83694
83695 static void check_for_stack(struct device *dev, void *addr)
83696 {
83697 - if (object_is_on_stack(addr))
83698 + if (object_starts_on_stack(addr))
83699 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
83700 "stack [addr=%p]\n", addr);
83701 }
83702 diff --git a/lib/inflate.c b/lib/inflate.c
83703 index 013a761..c28f3fc 100644
83704 --- a/lib/inflate.c
83705 +++ b/lib/inflate.c
83706 @@ -269,7 +269,7 @@ static void free(void *where)
83707 malloc_ptr = free_mem_ptr;
83708 }
83709 #else
83710 -#define malloc(a) kmalloc(a, GFP_KERNEL)
83711 +#define malloc(a) kmalloc((a), GFP_KERNEL)
83712 #define free(a) kfree(a)
83713 #endif
83714
83715 diff --git a/lib/ioremap.c b/lib/ioremap.c
83716 index 0c9216c..863bd89 100644
83717 --- a/lib/ioremap.c
83718 +++ b/lib/ioremap.c
83719 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
83720 unsigned long next;
83721
83722 phys_addr -= addr;
83723 - pmd = pmd_alloc(&init_mm, pud, addr);
83724 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
83725 if (!pmd)
83726 return -ENOMEM;
83727 do {
83728 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
83729 unsigned long next;
83730
83731 phys_addr -= addr;
83732 - pud = pud_alloc(&init_mm, pgd, addr);
83733 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
83734 if (!pud)
83735 return -ENOMEM;
83736 do {
83737 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
83738 index bd2bea9..6b3c95e 100644
83739 --- a/lib/is_single_threaded.c
83740 +++ b/lib/is_single_threaded.c
83741 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
83742 struct task_struct *p, *t;
83743 bool ret;
83744
83745 + if (!mm)
83746 + return true;
83747 +
83748 if (atomic_read(&task->signal->live) != 1)
83749 return false;
83750
83751 diff --git a/lib/kobject.c b/lib/kobject.c
83752 index b7e29a6..2f3ca75 100644
83753 --- a/lib/kobject.c
83754 +++ b/lib/kobject.c
83755 @@ -805,7 +805,7 @@ static struct kset *kset_create(const char *name,
83756 kset = kzalloc(sizeof(*kset), GFP_KERNEL);
83757 if (!kset)
83758 return NULL;
83759 - retval = kobject_set_name(&kset->kobj, name);
83760 + retval = kobject_set_name(&kset->kobj, "%s", name);
83761 if (retval) {
83762 kfree(kset);
83763 return NULL;
83764 @@ -859,9 +859,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
83765
83766
83767 static DEFINE_SPINLOCK(kobj_ns_type_lock);
83768 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
83769 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
83770
83771 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
83772 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
83773 {
83774 enum kobj_ns_type type = ops->type;
83775 int error;
83776 diff --git a/lib/list_debug.c b/lib/list_debug.c
83777 index c24c2f7..06e070b 100644
83778 --- a/lib/list_debug.c
83779 +++ b/lib/list_debug.c
83780 @@ -11,7 +11,9 @@
83781 #include <linux/bug.h>
83782 #include <linux/kernel.h>
83783 #include <linux/rculist.h>
83784 +#include <linux/mm.h>
83785
83786 +#ifdef CONFIG_DEBUG_LIST
83787 /*
83788 * Insert a new entry between two known consecutive entries.
83789 *
83790 @@ -19,21 +21,32 @@
83791 * the prev/next entries already!
83792 */
83793
83794 -void __list_add(struct list_head *new,
83795 - struct list_head *prev,
83796 - struct list_head *next)
83797 +static bool __list_add_debug(struct list_head *new,
83798 + struct list_head *prev,
83799 + struct list_head *next)
83800 {
83801 - WARN(next->prev != prev,
83802 + if (WARN(next->prev != prev,
83803 "list_add corruption. next->prev should be "
83804 "prev (%p), but was %p. (next=%p).\n",
83805 - prev, next->prev, next);
83806 - WARN(prev->next != next,
83807 + prev, next->prev, next) ||
83808 + WARN(prev->next != next,
83809 "list_add corruption. prev->next should be "
83810 "next (%p), but was %p. (prev=%p).\n",
83811 - next, prev->next, prev);
83812 - WARN(new == prev || new == next,
83813 - "list_add double add: new=%p, prev=%p, next=%p.\n",
83814 - new, prev, next);
83815 + next, prev->next, prev) ||
83816 + WARN(new == prev || new == next,
83817 + "list_add double add: new=%p, prev=%p, next=%p.\n",
83818 + new, prev, next))
83819 + return false;
83820 + return true;
83821 +}
83822 +
83823 +void __list_add(struct list_head *new,
83824 + struct list_head *prev,
83825 + struct list_head *next)
83826 +{
83827 + if (!__list_add_debug(new, prev, next))
83828 + return;
83829 +
83830 next->prev = new;
83831 new->next = next;
83832 new->prev = prev;
83833 @@ -41,7 +54,7 @@ void __list_add(struct list_head *new,
83834 }
83835 EXPORT_SYMBOL(__list_add);
83836
83837 -void __list_del_entry(struct list_head *entry)
83838 +static bool __list_del_entry_debug(struct list_head *entry)
83839 {
83840 struct list_head *prev, *next;
83841
83842 @@ -60,9 +73,16 @@ void __list_del_entry(struct list_head *entry)
83843 WARN(next->prev != entry,
83844 "list_del corruption. next->prev should be %p, "
83845 "but was %p\n", entry, next->prev))
83846 + return false;
83847 + return true;
83848 +}
83849 +
83850 +void __list_del_entry(struct list_head *entry)
83851 +{
83852 + if (!__list_del_entry_debug(entry))
83853 return;
83854
83855 - __list_del(prev, next);
83856 + __list_del(entry->prev, entry->next);
83857 }
83858 EXPORT_SYMBOL(__list_del_entry);
83859
83860 @@ -86,15 +106,85 @@ EXPORT_SYMBOL(list_del);
83861 void __list_add_rcu(struct list_head *new,
83862 struct list_head *prev, struct list_head *next)
83863 {
83864 - WARN(next->prev != prev,
83865 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
83866 - prev, next->prev, next);
83867 - WARN(prev->next != next,
83868 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
83869 - next, prev->next, prev);
83870 + if (!__list_add_debug(new, prev, next))
83871 + return;
83872 +
83873 new->next = next;
83874 new->prev = prev;
83875 rcu_assign_pointer(list_next_rcu(prev), new);
83876 next->prev = new;
83877 }
83878 EXPORT_SYMBOL(__list_add_rcu);
83879 +#endif
83880 +
83881 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
83882 +{
83883 +#ifdef CONFIG_DEBUG_LIST
83884 + if (!__list_add_debug(new, prev, next))
83885 + return;
83886 +#endif
83887 +
83888 + pax_open_kernel();
83889 + next->prev = new;
83890 + new->next = next;
83891 + new->prev = prev;
83892 + prev->next = new;
83893 + pax_close_kernel();
83894 +}
83895 +EXPORT_SYMBOL(__pax_list_add);
83896 +
83897 +void pax_list_del(struct list_head *entry)
83898 +{
83899 +#ifdef CONFIG_DEBUG_LIST
83900 + if (!__list_del_entry_debug(entry))
83901 + return;
83902 +#endif
83903 +
83904 + pax_open_kernel();
83905 + __list_del(entry->prev, entry->next);
83906 + entry->next = LIST_POISON1;
83907 + entry->prev = LIST_POISON2;
83908 + pax_close_kernel();
83909 +}
83910 +EXPORT_SYMBOL(pax_list_del);
83911 +
83912 +void pax_list_del_init(struct list_head *entry)
83913 +{
83914 + pax_open_kernel();
83915 + __list_del(entry->prev, entry->next);
83916 + INIT_LIST_HEAD(entry);
83917 + pax_close_kernel();
83918 +}
83919 +EXPORT_SYMBOL(pax_list_del_init);
83920 +
83921 +void __pax_list_add_rcu(struct list_head *new,
83922 + struct list_head *prev, struct list_head *next)
83923 +{
83924 +#ifdef CONFIG_DEBUG_LIST
83925 + if (!__list_add_debug(new, prev, next))
83926 + return;
83927 +#endif
83928 +
83929 + pax_open_kernel();
83930 + new->next = next;
83931 + new->prev = prev;
83932 + rcu_assign_pointer(list_next_rcu(prev), new);
83933 + next->prev = new;
83934 + pax_close_kernel();
83935 +}
83936 +EXPORT_SYMBOL(__pax_list_add_rcu);
83937 +
83938 +void pax_list_del_rcu(struct list_head *entry)
83939 +{
83940 +#ifdef CONFIG_DEBUG_LIST
83941 + if (!__list_del_entry_debug(entry))
83942 + return;
83943 +#endif
83944 +
83945 + pax_open_kernel();
83946 + __list_del(entry->prev, entry->next);
83947 + entry->next = LIST_POISON1;
83948 + entry->prev = LIST_POISON2;
83949 + pax_close_kernel();
83950 +}
83951 +EXPORT_SYMBOL(pax_list_del_rcu);
83952 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
83953 index e796429..6e38f9f 100644
83954 --- a/lib/radix-tree.c
83955 +++ b/lib/radix-tree.c
83956 @@ -92,7 +92,7 @@ struct radix_tree_preload {
83957 int nr;
83958 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
83959 };
83960 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
83961 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
83962
83963 static inline void *ptr_to_indirect(void *ptr)
83964 {
83965 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
83966 index bb2b201..46abaf9 100644
83967 --- a/lib/strncpy_from_user.c
83968 +++ b/lib/strncpy_from_user.c
83969 @@ -21,7 +21,7 @@
83970 */
83971 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
83972 {
83973 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
83974 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
83975 long res = 0;
83976
83977 /*
83978 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
83979 index a28df52..3d55877 100644
83980 --- a/lib/strnlen_user.c
83981 +++ b/lib/strnlen_user.c
83982 @@ -26,7 +26,7 @@
83983 */
83984 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
83985 {
83986 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
83987 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
83988 long align, res = 0;
83989 unsigned long c;
83990
83991 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
83992 index d23762e..e21eab2 100644
83993 --- a/lib/swiotlb.c
83994 +++ b/lib/swiotlb.c
83995 @@ -664,7 +664,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
83996
83997 void
83998 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
83999 - dma_addr_t dev_addr)
84000 + dma_addr_t dev_addr, struct dma_attrs *attrs)
84001 {
84002 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
84003
84004 diff --git a/lib/usercopy.c b/lib/usercopy.c
84005 index 4f5b1dd..7cab418 100644
84006 --- a/lib/usercopy.c
84007 +++ b/lib/usercopy.c
84008 @@ -7,3 +7,9 @@ void copy_from_user_overflow(void)
84009 WARN(1, "Buffer overflow detected!\n");
84010 }
84011 EXPORT_SYMBOL(copy_from_user_overflow);
84012 +
84013 +void copy_to_user_overflow(void)
84014 +{
84015 + WARN(1, "Buffer overflow detected!\n");
84016 +}
84017 +EXPORT_SYMBOL(copy_to_user_overflow);
84018 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
84019 index e149c64..24aa71a 100644
84020 --- a/lib/vsprintf.c
84021 +++ b/lib/vsprintf.c
84022 @@ -16,6 +16,9 @@
84023 * - scnprintf and vscnprintf
84024 */
84025
84026 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84027 +#define __INCLUDED_BY_HIDESYM 1
84028 +#endif
84029 #include <stdarg.h>
84030 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
84031 #include <linux/types.h>
84032 @@ -981,7 +984,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
84033 return number(buf, end, *(const netdev_features_t *)addr, spec);
84034 }
84035
84036 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84037 +int kptr_restrict __read_mostly = 2;
84038 +#else
84039 int kptr_restrict __read_mostly;
84040 +#endif
84041
84042 /*
84043 * Show a '%p' thing. A kernel extension is that the '%p' is followed
84044 @@ -994,6 +1001,7 @@ int kptr_restrict __read_mostly;
84045 * - 'f' For simple symbolic function names without offset
84046 * - 'S' For symbolic direct pointers with offset
84047 * - 's' For symbolic direct pointers without offset
84048 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
84049 * - '[FfSs]R' as above with __builtin_extract_return_addr() translation
84050 * - 'B' For backtraced symbolic direct pointers with offset
84051 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
84052 @@ -1052,12 +1060,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
84053
84054 if (!ptr && *fmt != 'K') {
84055 /*
84056 - * Print (null) with the same width as a pointer so it makes
84057 + * Print (nil) with the same width as a pointer so it makes
84058 * tabular output look nice.
84059 */
84060 if (spec.field_width == -1)
84061 spec.field_width = default_width;
84062 - return string(buf, end, "(null)", spec);
84063 + return string(buf, end, "(nil)", spec);
84064 }
84065
84066 switch (*fmt) {
84067 @@ -1067,6 +1075,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
84068 /* Fallthrough */
84069 case 'S':
84070 case 's':
84071 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84072 + break;
84073 +#else
84074 + return symbol_string(buf, end, ptr, spec, fmt);
84075 +#endif
84076 + case 'A':
84077 case 'B':
84078 return symbol_string(buf, end, ptr, spec, fmt);
84079 case 'R':
84080 @@ -1107,6 +1121,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
84081 va_end(va);
84082 return buf;
84083 }
84084 + case 'P':
84085 + break;
84086 case 'K':
84087 /*
84088 * %pK cannot be used in IRQ context because its test
84089 @@ -1136,6 +1152,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
84090 return number(buf, end,
84091 (unsigned long long) *((phys_addr_t *)ptr), spec);
84092 }
84093 +
84094 +#ifdef CONFIG_GRKERNSEC_HIDESYM
84095 + /* 'P' = approved pointers to copy to userland,
84096 + as in the /proc/kallsyms case, as we make it display nothing
84097 + for non-root users, and the real contents for root users
84098 + Also ignore 'K' pointers, since we force their NULLing for non-root users
84099 + above
84100 + */
84101 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
84102 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
84103 + dump_stack();
84104 + ptr = NULL;
84105 + }
84106 +#endif
84107 +
84108 spec.flags |= SMALL;
84109 if (spec.field_width == -1) {
84110 spec.field_width = default_width;
84111 @@ -1857,11 +1888,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
84112 typeof(type) value; \
84113 if (sizeof(type) == 8) { \
84114 args = PTR_ALIGN(args, sizeof(u32)); \
84115 - *(u32 *)&value = *(u32 *)args; \
84116 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
84117 + *(u32 *)&value = *(const u32 *)args; \
84118 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
84119 } else { \
84120 args = PTR_ALIGN(args, sizeof(type)); \
84121 - value = *(typeof(type) *)args; \
84122 + value = *(const typeof(type) *)args; \
84123 } \
84124 args += sizeof(type); \
84125 value; \
84126 @@ -1924,7 +1955,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
84127 case FORMAT_TYPE_STR: {
84128 const char *str_arg = args;
84129 args += strlen(str_arg) + 1;
84130 - str = string(str, end, (char *)str_arg, spec);
84131 + str = string(str, end, str_arg, spec);
84132 break;
84133 }
84134
84135 diff --git a/localversion-grsec b/localversion-grsec
84136 new file mode 100644
84137 index 0000000..7cd6065
84138 --- /dev/null
84139 +++ b/localversion-grsec
84140 @@ -0,0 +1 @@
84141 +-grsec
84142 diff --git a/mm/Kconfig b/mm/Kconfig
84143 index e742d06..c56fdd8 100644
84144 --- a/mm/Kconfig
84145 +++ b/mm/Kconfig
84146 @@ -317,10 +317,10 @@ config KSM
84147 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
84148
84149 config DEFAULT_MMAP_MIN_ADDR
84150 - int "Low address space to protect from user allocation"
84151 + int "Low address space to protect from user allocation"
84152 depends on MMU
84153 - default 4096
84154 - help
84155 + default 65536
84156 + help
84157 This is the portion of low virtual memory which should be protected
84158 from userspace allocation. Keeping a user from writing to low pages
84159 can help reduce the impact of kernel NULL pointer bugs.
84160 @@ -351,7 +351,7 @@ config MEMORY_FAILURE
84161
84162 config HWPOISON_INJECT
84163 tristate "HWPoison pages injector"
84164 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
84165 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
84166 select PROC_PAGE_MONITOR
84167
84168 config NOMMU_INITIAL_TRIM_EXCESS
84169 diff --git a/mm/backing-dev.c b/mm/backing-dev.c
84170 index 5025174..9d67dcd 100644
84171 --- a/mm/backing-dev.c
84172 +++ b/mm/backing-dev.c
84173 @@ -12,7 +12,7 @@
84174 #include <linux/device.h>
84175 #include <trace/events/writeback.h>
84176
84177 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
84178 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
84179
84180 struct backing_dev_info default_backing_dev_info = {
84181 .name = "default",
84182 @@ -515,7 +515,6 @@ EXPORT_SYMBOL(bdi_destroy);
84183 int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
84184 unsigned int cap)
84185 {
84186 - char tmp[32];
84187 int err;
84188
84189 bdi->name = name;
84190 @@ -524,8 +523,7 @@ int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
84191 if (err)
84192 return err;
84193
84194 - sprintf(tmp, "%.28s%s", name, "-%d");
84195 - err = bdi_register(bdi, NULL, tmp, atomic_long_inc_return(&bdi_seq));
84196 + err = bdi_register(bdi, NULL, "%.28s-%ld", name, atomic_long_inc_return_unchecked(&bdi_seq));
84197 if (err) {
84198 bdi_destroy(bdi);
84199 return err;
84200 diff --git a/mm/filemap.c b/mm/filemap.c
84201 index 7905fe7..e60faa8 100644
84202 --- a/mm/filemap.c
84203 +++ b/mm/filemap.c
84204 @@ -1766,7 +1766,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
84205 struct address_space *mapping = file->f_mapping;
84206
84207 if (!mapping->a_ops->readpage)
84208 - return -ENOEXEC;
84209 + return -ENODEV;
84210 file_accessed(file);
84211 vma->vm_ops = &generic_file_vm_ops;
84212 return 0;
84213 @@ -2106,6 +2106,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
84214 *pos = i_size_read(inode);
84215
84216 if (limit != RLIM_INFINITY) {
84217 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
84218 if (*pos >= limit) {
84219 send_sig(SIGXFSZ, current, 0);
84220 return -EFBIG;
84221 diff --git a/mm/fremap.c b/mm/fremap.c
84222 index 87da359..3f41cb1 100644
84223 --- a/mm/fremap.c
84224 +++ b/mm/fremap.c
84225 @@ -158,6 +158,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
84226 retry:
84227 vma = find_vma(mm, start);
84228
84229 +#ifdef CONFIG_PAX_SEGMEXEC
84230 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
84231 + goto out;
84232 +#endif
84233 +
84234 /*
84235 * Make sure the vma is shared, that it supports prefaulting,
84236 * and that the remapped range is valid and fully within
84237 diff --git a/mm/highmem.c b/mm/highmem.c
84238 index b32b70c..e512eb0 100644
84239 --- a/mm/highmem.c
84240 +++ b/mm/highmem.c
84241 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
84242 * So no dangers, even with speculative execution.
84243 */
84244 page = pte_page(pkmap_page_table[i]);
84245 + pax_open_kernel();
84246 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
84247 -
84248 + pax_close_kernel();
84249 set_page_address(page, NULL);
84250 need_flush = 1;
84251 }
84252 @@ -198,9 +199,11 @@ start:
84253 }
84254 }
84255 vaddr = PKMAP_ADDR(last_pkmap_nr);
84256 +
84257 + pax_open_kernel();
84258 set_pte_at(&init_mm, vaddr,
84259 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
84260 -
84261 + pax_close_kernel();
84262 pkmap_count[last_pkmap_nr] = 1;
84263 set_page_address(page, (void *)vaddr);
84264
84265 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
84266 index 7c5eb85..5c01c2f 100644
84267 --- a/mm/hugetlb.c
84268 +++ b/mm/hugetlb.c
84269 @@ -2022,15 +2022,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
84270 struct hstate *h = &default_hstate;
84271 unsigned long tmp;
84272 int ret;
84273 + ctl_table_no_const hugetlb_table;
84274
84275 tmp = h->max_huge_pages;
84276
84277 if (write && h->order >= MAX_ORDER)
84278 return -EINVAL;
84279
84280 - table->data = &tmp;
84281 - table->maxlen = sizeof(unsigned long);
84282 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
84283 + hugetlb_table = *table;
84284 + hugetlb_table.data = &tmp;
84285 + hugetlb_table.maxlen = sizeof(unsigned long);
84286 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
84287 if (ret)
84288 goto out;
84289
84290 @@ -2087,15 +2089,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
84291 struct hstate *h = &default_hstate;
84292 unsigned long tmp;
84293 int ret;
84294 + ctl_table_no_const hugetlb_table;
84295
84296 tmp = h->nr_overcommit_huge_pages;
84297
84298 if (write && h->order >= MAX_ORDER)
84299 return -EINVAL;
84300
84301 - table->data = &tmp;
84302 - table->maxlen = sizeof(unsigned long);
84303 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
84304 + hugetlb_table = *table;
84305 + hugetlb_table.data = &tmp;
84306 + hugetlb_table.maxlen = sizeof(unsigned long);
84307 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
84308 if (ret)
84309 goto out;
84310
84311 @@ -2545,6 +2549,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
84312 return 1;
84313 }
84314
84315 +#ifdef CONFIG_PAX_SEGMEXEC
84316 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
84317 +{
84318 + struct mm_struct *mm = vma->vm_mm;
84319 + struct vm_area_struct *vma_m;
84320 + unsigned long address_m;
84321 + pte_t *ptep_m;
84322 +
84323 + vma_m = pax_find_mirror_vma(vma);
84324 + if (!vma_m)
84325 + return;
84326 +
84327 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
84328 + address_m = address + SEGMEXEC_TASK_SIZE;
84329 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
84330 + get_page(page_m);
84331 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
84332 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
84333 +}
84334 +#endif
84335 +
84336 /*
84337 * Hugetlb_cow() should be called with page lock of the original hugepage held.
84338 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
84339 @@ -2663,6 +2688,11 @@ retry_avoidcopy:
84340 make_huge_pte(vma, new_page, 1));
84341 page_remove_rmap(old_page);
84342 hugepage_add_new_anon_rmap(new_page, vma, address);
84343 +
84344 +#ifdef CONFIG_PAX_SEGMEXEC
84345 + pax_mirror_huge_pte(vma, address, new_page);
84346 +#endif
84347 +
84348 /* Make the old page be freed below */
84349 new_page = old_page;
84350 }
84351 @@ -2821,6 +2851,10 @@ retry:
84352 && (vma->vm_flags & VM_SHARED)));
84353 set_huge_pte_at(mm, address, ptep, new_pte);
84354
84355 +#ifdef CONFIG_PAX_SEGMEXEC
84356 + pax_mirror_huge_pte(vma, address, page);
84357 +#endif
84358 +
84359 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
84360 /* Optimization, do the COW without a second fault */
84361 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
84362 @@ -2850,6 +2884,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
84363 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
84364 struct hstate *h = hstate_vma(vma);
84365
84366 +#ifdef CONFIG_PAX_SEGMEXEC
84367 + struct vm_area_struct *vma_m;
84368 +#endif
84369 +
84370 address &= huge_page_mask(h);
84371
84372 ptep = huge_pte_offset(mm, address);
84373 @@ -2863,6 +2901,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
84374 VM_FAULT_SET_HINDEX(hstate_index(h));
84375 }
84376
84377 +#ifdef CONFIG_PAX_SEGMEXEC
84378 + vma_m = pax_find_mirror_vma(vma);
84379 + if (vma_m) {
84380 + unsigned long address_m;
84381 +
84382 + if (vma->vm_start > vma_m->vm_start) {
84383 + address_m = address;
84384 + address -= SEGMEXEC_TASK_SIZE;
84385 + vma = vma_m;
84386 + h = hstate_vma(vma);
84387 + } else
84388 + address_m = address + SEGMEXEC_TASK_SIZE;
84389 +
84390 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
84391 + return VM_FAULT_OOM;
84392 + address_m &= HPAGE_MASK;
84393 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
84394 + }
84395 +#endif
84396 +
84397 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
84398 if (!ptep)
84399 return VM_FAULT_OOM;
84400 diff --git a/mm/internal.h b/mm/internal.h
84401 index 8562de0..92b2073 100644
84402 --- a/mm/internal.h
84403 +++ b/mm/internal.h
84404 @@ -100,6 +100,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
84405 * in mm/page_alloc.c
84406 */
84407 extern void __free_pages_bootmem(struct page *page, unsigned int order);
84408 +extern void free_compound_page(struct page *page);
84409 extern void prep_compound_page(struct page *page, unsigned long order);
84410 #ifdef CONFIG_MEMORY_FAILURE
84411 extern bool is_free_buddy_page(struct page *page);
84412 @@ -355,7 +356,7 @@ extern u32 hwpoison_filter_enable;
84413
84414 extern unsigned long vm_mmap_pgoff(struct file *, unsigned long,
84415 unsigned long, unsigned long,
84416 - unsigned long, unsigned long);
84417 + unsigned long, unsigned long) __intentional_overflow(-1);
84418
84419 extern void set_pageblock_order(void);
84420 unsigned long reclaim_clean_pages_from_list(struct zone *zone,
84421 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
84422 index c8d7f31..2dbeffd 100644
84423 --- a/mm/kmemleak.c
84424 +++ b/mm/kmemleak.c
84425 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
84426
84427 for (i = 0; i < object->trace_len; i++) {
84428 void *ptr = (void *)object->trace[i];
84429 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
84430 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
84431 }
84432 }
84433
84434 @@ -1851,7 +1851,7 @@ static int __init kmemleak_late_init(void)
84435 return -ENOMEM;
84436 }
84437
84438 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
84439 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
84440 &kmemleak_fops);
84441 if (!dentry)
84442 pr_warning("Failed to create the debugfs kmemleak file\n");
84443 diff --git a/mm/maccess.c b/mm/maccess.c
84444 index d53adf9..03a24bf 100644
84445 --- a/mm/maccess.c
84446 +++ b/mm/maccess.c
84447 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
84448 set_fs(KERNEL_DS);
84449 pagefault_disable();
84450 ret = __copy_from_user_inatomic(dst,
84451 - (__force const void __user *)src, size);
84452 + (const void __force_user *)src, size);
84453 pagefault_enable();
84454 set_fs(old_fs);
84455
84456 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
84457
84458 set_fs(KERNEL_DS);
84459 pagefault_disable();
84460 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
84461 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
84462 pagefault_enable();
84463 set_fs(old_fs);
84464
84465 diff --git a/mm/madvise.c b/mm/madvise.c
84466 index 7055883..aafb1ed 100644
84467 --- a/mm/madvise.c
84468 +++ b/mm/madvise.c
84469 @@ -51,6 +51,10 @@ static long madvise_behavior(struct vm_area_struct * vma,
84470 pgoff_t pgoff;
84471 unsigned long new_flags = vma->vm_flags;
84472
84473 +#ifdef CONFIG_PAX_SEGMEXEC
84474 + struct vm_area_struct *vma_m;
84475 +#endif
84476 +
84477 switch (behavior) {
84478 case MADV_NORMAL:
84479 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
84480 @@ -126,6 +130,13 @@ success:
84481 /*
84482 * vm_flags is protected by the mmap_sem held in write mode.
84483 */
84484 +
84485 +#ifdef CONFIG_PAX_SEGMEXEC
84486 + vma_m = pax_find_mirror_vma(vma);
84487 + if (vma_m)
84488 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
84489 +#endif
84490 +
84491 vma->vm_flags = new_flags;
84492
84493 out:
84494 @@ -274,6 +285,11 @@ static long madvise_dontneed(struct vm_area_struct * vma,
84495 struct vm_area_struct ** prev,
84496 unsigned long start, unsigned long end)
84497 {
84498 +
84499 +#ifdef CONFIG_PAX_SEGMEXEC
84500 + struct vm_area_struct *vma_m;
84501 +#endif
84502 +
84503 *prev = vma;
84504 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
84505 return -EINVAL;
84506 @@ -286,6 +302,21 @@ static long madvise_dontneed(struct vm_area_struct * vma,
84507 zap_page_range(vma, start, end - start, &details);
84508 } else
84509 zap_page_range(vma, start, end - start, NULL);
84510 +
84511 +#ifdef CONFIG_PAX_SEGMEXEC
84512 + vma_m = pax_find_mirror_vma(vma);
84513 + if (vma_m) {
84514 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
84515 + struct zap_details details = {
84516 + .nonlinear_vma = vma_m,
84517 + .last_index = ULONG_MAX,
84518 + };
84519 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
84520 + } else
84521 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
84522 + }
84523 +#endif
84524 +
84525 return 0;
84526 }
84527
84528 @@ -485,6 +516,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
84529 if (end < start)
84530 return error;
84531
84532 +#ifdef CONFIG_PAX_SEGMEXEC
84533 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
84534 + if (end > SEGMEXEC_TASK_SIZE)
84535 + return error;
84536 + } else
84537 +#endif
84538 +
84539 + if (end > TASK_SIZE)
84540 + return error;
84541 +
84542 error = 0;
84543 if (end == start)
84544 return error;
84545 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
84546 index ceb0c7f..b2b8e94 100644
84547 --- a/mm/memory-failure.c
84548 +++ b/mm/memory-failure.c
84549 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
84550
84551 int sysctl_memory_failure_recovery __read_mostly = 1;
84552
84553 -atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
84554 +atomic_long_unchecked_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
84555
84556 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
84557
84558 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
84559 pfn, t->comm, t->pid);
84560 si.si_signo = SIGBUS;
84561 si.si_errno = 0;
84562 - si.si_addr = (void *)addr;
84563 + si.si_addr = (void __user *)addr;
84564 #ifdef __ARCH_SI_TRAPNO
84565 si.si_trapno = trapno;
84566 #endif
84567 @@ -760,7 +760,7 @@ static struct page_state {
84568 unsigned long res;
84569 char *msg;
84570 int (*action)(struct page *p, unsigned long pfn);
84571 -} error_states[] = {
84572 +} __do_const error_states[] = {
84573 { reserved, reserved, "reserved kernel", me_kernel },
84574 /*
84575 * free pages are specially detected outside this table:
84576 @@ -1051,7 +1051,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
84577 nr_pages = 1 << compound_order(hpage);
84578 else /* normal page or thp */
84579 nr_pages = 1;
84580 - atomic_long_add(nr_pages, &num_poisoned_pages);
84581 + atomic_long_add_unchecked(nr_pages, &num_poisoned_pages);
84582
84583 /*
84584 * We need/can do nothing about count=0 pages.
84585 @@ -1081,7 +1081,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
84586 if (!PageHWPoison(hpage)
84587 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
84588 || (p != hpage && TestSetPageHWPoison(hpage))) {
84589 - atomic_long_sub(nr_pages, &num_poisoned_pages);
84590 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
84591 return 0;
84592 }
84593 set_page_hwpoison_huge_page(hpage);
84594 @@ -1148,7 +1148,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
84595 }
84596 if (hwpoison_filter(p)) {
84597 if (TestClearPageHWPoison(p))
84598 - atomic_long_sub(nr_pages, &num_poisoned_pages);
84599 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
84600 unlock_page(hpage);
84601 put_page(hpage);
84602 return 0;
84603 @@ -1350,7 +1350,7 @@ int unpoison_memory(unsigned long pfn)
84604 return 0;
84605 }
84606 if (TestClearPageHWPoison(p))
84607 - atomic_long_sub(nr_pages, &num_poisoned_pages);
84608 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
84609 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
84610 return 0;
84611 }
84612 @@ -1364,7 +1364,7 @@ int unpoison_memory(unsigned long pfn)
84613 */
84614 if (TestClearPageHWPoison(page)) {
84615 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
84616 - atomic_long_sub(nr_pages, &num_poisoned_pages);
84617 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
84618 freeit = 1;
84619 if (PageHuge(page))
84620 clear_page_hwpoison_huge_page(page);
84621 @@ -1491,7 +1491,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
84622 } else {
84623 set_page_hwpoison_huge_page(hpage);
84624 dequeue_hwpoisoned_huge_page(hpage);
84625 - atomic_long_add(1 << compound_trans_order(hpage),
84626 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
84627 &num_poisoned_pages);
84628 }
84629 /* keep elevated page count for bad page */
84630 @@ -1552,11 +1552,11 @@ int soft_offline_page(struct page *page, int flags)
84631 if (PageHuge(page)) {
84632 set_page_hwpoison_huge_page(hpage);
84633 dequeue_hwpoisoned_huge_page(hpage);
84634 - atomic_long_add(1 << compound_trans_order(hpage),
84635 + atomic_long_add_unchecked(1 << compound_trans_order(hpage),
84636 &num_poisoned_pages);
84637 } else {
84638 SetPageHWPoison(page);
84639 - atomic_long_inc(&num_poisoned_pages);
84640 + atomic_long_inc_unchecked(&num_poisoned_pages);
84641 }
84642 }
84643 /* keep elevated page count for bad page */
84644 @@ -1596,7 +1596,7 @@ static int __soft_offline_page(struct page *page, int flags)
84645 put_page(page);
84646 pr_info("soft_offline: %#lx: invalidated\n", pfn);
84647 SetPageHWPoison(page);
84648 - atomic_long_inc(&num_poisoned_pages);
84649 + atomic_long_inc_unchecked(&num_poisoned_pages);
84650 return 0;
84651 }
84652
84653 @@ -1626,7 +1626,7 @@ static int __soft_offline_page(struct page *page, int flags)
84654 ret = -EIO;
84655 } else {
84656 SetPageHWPoison(page);
84657 - atomic_long_inc(&num_poisoned_pages);
84658 + atomic_long_inc_unchecked(&num_poisoned_pages);
84659 }
84660 } else {
84661 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
84662 diff --git a/mm/memory.c b/mm/memory.c
84663 index 5a35443..7c0340f 100644
84664 --- a/mm/memory.c
84665 +++ b/mm/memory.c
84666 @@ -428,6 +428,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
84667 free_pte_range(tlb, pmd, addr);
84668 } while (pmd++, addr = next, addr != end);
84669
84670 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
84671 start &= PUD_MASK;
84672 if (start < floor)
84673 return;
84674 @@ -442,6 +443,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
84675 pmd = pmd_offset(pud, start);
84676 pud_clear(pud);
84677 pmd_free_tlb(tlb, pmd, start);
84678 +#endif
84679 +
84680 }
84681
84682 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
84683 @@ -461,6 +464,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
84684 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
84685 } while (pud++, addr = next, addr != end);
84686
84687 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
84688 start &= PGDIR_MASK;
84689 if (start < floor)
84690 return;
84691 @@ -475,6 +479,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
84692 pud = pud_offset(pgd, start);
84693 pgd_clear(pgd);
84694 pud_free_tlb(tlb, pud, start);
84695 +#endif
84696 +
84697 }
84698
84699 /*
84700 @@ -1644,12 +1650,6 @@ no_page_table:
84701 return page;
84702 }
84703
84704 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
84705 -{
84706 - return stack_guard_page_start(vma, addr) ||
84707 - stack_guard_page_end(vma, addr+PAGE_SIZE);
84708 -}
84709 -
84710 /**
84711 * __get_user_pages() - pin user pages in memory
84712 * @tsk: task_struct of target task
84713 @@ -1736,10 +1736,10 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
84714
84715 i = 0;
84716
84717 - do {
84718 + while (nr_pages) {
84719 struct vm_area_struct *vma;
84720
84721 - vma = find_extend_vma(mm, start);
84722 + vma = find_vma(mm, start);
84723 if (!vma && in_gate_area(mm, start)) {
84724 unsigned long pg = start & PAGE_MASK;
84725 pgd_t *pgd;
84726 @@ -1788,7 +1788,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
84727 goto next_page;
84728 }
84729
84730 - if (!vma ||
84731 + if (!vma || start < vma->vm_start ||
84732 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
84733 !(vm_flags & vma->vm_flags))
84734 return i ? : -EFAULT;
84735 @@ -1817,11 +1817,6 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
84736 int ret;
84737 unsigned int fault_flags = 0;
84738
84739 - /* For mlock, just skip the stack guard page. */
84740 - if (foll_flags & FOLL_MLOCK) {
84741 - if (stack_guard_page(vma, start))
84742 - goto next_page;
84743 - }
84744 if (foll_flags & FOLL_WRITE)
84745 fault_flags |= FAULT_FLAG_WRITE;
84746 if (nonblocking)
84747 @@ -1901,7 +1896,7 @@ next_page:
84748 start += page_increm * PAGE_SIZE;
84749 nr_pages -= page_increm;
84750 } while (nr_pages && start < vma->vm_end);
84751 - } while (nr_pages);
84752 + }
84753 return i;
84754 }
84755 EXPORT_SYMBOL(__get_user_pages);
84756 @@ -2108,6 +2103,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
84757 page_add_file_rmap(page);
84758 set_pte_at(mm, addr, pte, mk_pte(page, prot));
84759
84760 +#ifdef CONFIG_PAX_SEGMEXEC
84761 + pax_mirror_file_pte(vma, addr, page, ptl);
84762 +#endif
84763 +
84764 retval = 0;
84765 pte_unmap_unlock(pte, ptl);
84766 return retval;
84767 @@ -2152,9 +2151,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
84768 if (!page_count(page))
84769 return -EINVAL;
84770 if (!(vma->vm_flags & VM_MIXEDMAP)) {
84771 +
84772 +#ifdef CONFIG_PAX_SEGMEXEC
84773 + struct vm_area_struct *vma_m;
84774 +#endif
84775 +
84776 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
84777 BUG_ON(vma->vm_flags & VM_PFNMAP);
84778 vma->vm_flags |= VM_MIXEDMAP;
84779 +
84780 +#ifdef CONFIG_PAX_SEGMEXEC
84781 + vma_m = pax_find_mirror_vma(vma);
84782 + if (vma_m)
84783 + vma_m->vm_flags |= VM_MIXEDMAP;
84784 +#endif
84785 +
84786 }
84787 return insert_page(vma, addr, page, vma->vm_page_prot);
84788 }
84789 @@ -2237,6 +2248,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
84790 unsigned long pfn)
84791 {
84792 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
84793 + BUG_ON(vma->vm_mirror);
84794
84795 if (addr < vma->vm_start || addr >= vma->vm_end)
84796 return -EFAULT;
84797 @@ -2484,7 +2496,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
84798
84799 BUG_ON(pud_huge(*pud));
84800
84801 - pmd = pmd_alloc(mm, pud, addr);
84802 + pmd = (mm == &init_mm) ?
84803 + pmd_alloc_kernel(mm, pud, addr) :
84804 + pmd_alloc(mm, pud, addr);
84805 if (!pmd)
84806 return -ENOMEM;
84807 do {
84808 @@ -2504,7 +2518,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
84809 unsigned long next;
84810 int err;
84811
84812 - pud = pud_alloc(mm, pgd, addr);
84813 + pud = (mm == &init_mm) ?
84814 + pud_alloc_kernel(mm, pgd, addr) :
84815 + pud_alloc(mm, pgd, addr);
84816 if (!pud)
84817 return -ENOMEM;
84818 do {
84819 @@ -2592,6 +2608,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
84820 copy_user_highpage(dst, src, va, vma);
84821 }
84822
84823 +#ifdef CONFIG_PAX_SEGMEXEC
84824 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
84825 +{
84826 + struct mm_struct *mm = vma->vm_mm;
84827 + spinlock_t *ptl;
84828 + pte_t *pte, entry;
84829 +
84830 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
84831 + entry = *pte;
84832 + if (!pte_present(entry)) {
84833 + if (!pte_none(entry)) {
84834 + BUG_ON(pte_file(entry));
84835 + free_swap_and_cache(pte_to_swp_entry(entry));
84836 + pte_clear_not_present_full(mm, address, pte, 0);
84837 + }
84838 + } else {
84839 + struct page *page;
84840 +
84841 + flush_cache_page(vma, address, pte_pfn(entry));
84842 + entry = ptep_clear_flush(vma, address, pte);
84843 + BUG_ON(pte_dirty(entry));
84844 + page = vm_normal_page(vma, address, entry);
84845 + if (page) {
84846 + update_hiwater_rss(mm);
84847 + if (PageAnon(page))
84848 + dec_mm_counter_fast(mm, MM_ANONPAGES);
84849 + else
84850 + dec_mm_counter_fast(mm, MM_FILEPAGES);
84851 + page_remove_rmap(page);
84852 + page_cache_release(page);
84853 + }
84854 + }
84855 + pte_unmap_unlock(pte, ptl);
84856 +}
84857 +
84858 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
84859 + *
84860 + * the ptl of the lower mapped page is held on entry and is not released on exit
84861 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
84862 + */
84863 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
84864 +{
84865 + struct mm_struct *mm = vma->vm_mm;
84866 + unsigned long address_m;
84867 + spinlock_t *ptl_m;
84868 + struct vm_area_struct *vma_m;
84869 + pmd_t *pmd_m;
84870 + pte_t *pte_m, entry_m;
84871 +
84872 + BUG_ON(!page_m || !PageAnon(page_m));
84873 +
84874 + vma_m = pax_find_mirror_vma(vma);
84875 + if (!vma_m)
84876 + return;
84877 +
84878 + BUG_ON(!PageLocked(page_m));
84879 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
84880 + address_m = address + SEGMEXEC_TASK_SIZE;
84881 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
84882 + pte_m = pte_offset_map(pmd_m, address_m);
84883 + ptl_m = pte_lockptr(mm, pmd_m);
84884 + if (ptl != ptl_m) {
84885 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
84886 + if (!pte_none(*pte_m))
84887 + goto out;
84888 + }
84889 +
84890 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
84891 + page_cache_get(page_m);
84892 + page_add_anon_rmap(page_m, vma_m, address_m);
84893 + inc_mm_counter_fast(mm, MM_ANONPAGES);
84894 + set_pte_at(mm, address_m, pte_m, entry_m);
84895 + update_mmu_cache(vma_m, address_m, pte_m);
84896 +out:
84897 + if (ptl != ptl_m)
84898 + spin_unlock(ptl_m);
84899 + pte_unmap(pte_m);
84900 + unlock_page(page_m);
84901 +}
84902 +
84903 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
84904 +{
84905 + struct mm_struct *mm = vma->vm_mm;
84906 + unsigned long address_m;
84907 + spinlock_t *ptl_m;
84908 + struct vm_area_struct *vma_m;
84909 + pmd_t *pmd_m;
84910 + pte_t *pte_m, entry_m;
84911 +
84912 + BUG_ON(!page_m || PageAnon(page_m));
84913 +
84914 + vma_m = pax_find_mirror_vma(vma);
84915 + if (!vma_m)
84916 + return;
84917 +
84918 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
84919 + address_m = address + SEGMEXEC_TASK_SIZE;
84920 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
84921 + pte_m = pte_offset_map(pmd_m, address_m);
84922 + ptl_m = pte_lockptr(mm, pmd_m);
84923 + if (ptl != ptl_m) {
84924 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
84925 + if (!pte_none(*pte_m))
84926 + goto out;
84927 + }
84928 +
84929 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
84930 + page_cache_get(page_m);
84931 + page_add_file_rmap(page_m);
84932 + inc_mm_counter_fast(mm, MM_FILEPAGES);
84933 + set_pte_at(mm, address_m, pte_m, entry_m);
84934 + update_mmu_cache(vma_m, address_m, pte_m);
84935 +out:
84936 + if (ptl != ptl_m)
84937 + spin_unlock(ptl_m);
84938 + pte_unmap(pte_m);
84939 +}
84940 +
84941 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
84942 +{
84943 + struct mm_struct *mm = vma->vm_mm;
84944 + unsigned long address_m;
84945 + spinlock_t *ptl_m;
84946 + struct vm_area_struct *vma_m;
84947 + pmd_t *pmd_m;
84948 + pte_t *pte_m, entry_m;
84949 +
84950 + vma_m = pax_find_mirror_vma(vma);
84951 + if (!vma_m)
84952 + return;
84953 +
84954 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
84955 + address_m = address + SEGMEXEC_TASK_SIZE;
84956 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
84957 + pte_m = pte_offset_map(pmd_m, address_m);
84958 + ptl_m = pte_lockptr(mm, pmd_m);
84959 + if (ptl != ptl_m) {
84960 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
84961 + if (!pte_none(*pte_m))
84962 + goto out;
84963 + }
84964 +
84965 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
84966 + set_pte_at(mm, address_m, pte_m, entry_m);
84967 +out:
84968 + if (ptl != ptl_m)
84969 + spin_unlock(ptl_m);
84970 + pte_unmap(pte_m);
84971 +}
84972 +
84973 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
84974 +{
84975 + struct page *page_m;
84976 + pte_t entry;
84977 +
84978 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
84979 + goto out;
84980 +
84981 + entry = *pte;
84982 + page_m = vm_normal_page(vma, address, entry);
84983 + if (!page_m)
84984 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
84985 + else if (PageAnon(page_m)) {
84986 + if (pax_find_mirror_vma(vma)) {
84987 + pte_unmap_unlock(pte, ptl);
84988 + lock_page(page_m);
84989 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
84990 + if (pte_same(entry, *pte))
84991 + pax_mirror_anon_pte(vma, address, page_m, ptl);
84992 + else
84993 + unlock_page(page_m);
84994 + }
84995 + } else
84996 + pax_mirror_file_pte(vma, address, page_m, ptl);
84997 +
84998 +out:
84999 + pte_unmap_unlock(pte, ptl);
85000 +}
85001 +#endif
85002 +
85003 /*
85004 * This routine handles present pages, when users try to write
85005 * to a shared page. It is done by copying the page to a new address
85006 @@ -2808,6 +3004,12 @@ gotten:
85007 */
85008 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
85009 if (likely(pte_same(*page_table, orig_pte))) {
85010 +
85011 +#ifdef CONFIG_PAX_SEGMEXEC
85012 + if (pax_find_mirror_vma(vma))
85013 + BUG_ON(!trylock_page(new_page));
85014 +#endif
85015 +
85016 if (old_page) {
85017 if (!PageAnon(old_page)) {
85018 dec_mm_counter_fast(mm, MM_FILEPAGES);
85019 @@ -2859,6 +3061,10 @@ gotten:
85020 page_remove_rmap(old_page);
85021 }
85022
85023 +#ifdef CONFIG_PAX_SEGMEXEC
85024 + pax_mirror_anon_pte(vma, address, new_page, ptl);
85025 +#endif
85026 +
85027 /* Free the old page.. */
85028 new_page = old_page;
85029 ret |= VM_FAULT_WRITE;
85030 @@ -3134,6 +3340,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
85031 swap_free(entry);
85032 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
85033 try_to_free_swap(page);
85034 +
85035 +#ifdef CONFIG_PAX_SEGMEXEC
85036 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
85037 +#endif
85038 +
85039 unlock_page(page);
85040 if (page != swapcache) {
85041 /*
85042 @@ -3157,6 +3368,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
85043
85044 /* No need to invalidate - it was non-present before */
85045 update_mmu_cache(vma, address, page_table);
85046 +
85047 +#ifdef CONFIG_PAX_SEGMEXEC
85048 + pax_mirror_anon_pte(vma, address, page, ptl);
85049 +#endif
85050 +
85051 unlock:
85052 pte_unmap_unlock(page_table, ptl);
85053 out:
85054 @@ -3176,40 +3392,6 @@ out_release:
85055 }
85056
85057 /*
85058 - * This is like a special single-page "expand_{down|up}wards()",
85059 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
85060 - * doesn't hit another vma.
85061 - */
85062 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
85063 -{
85064 - address &= PAGE_MASK;
85065 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
85066 - struct vm_area_struct *prev = vma->vm_prev;
85067 -
85068 - /*
85069 - * Is there a mapping abutting this one below?
85070 - *
85071 - * That's only ok if it's the same stack mapping
85072 - * that has gotten split..
85073 - */
85074 - if (prev && prev->vm_end == address)
85075 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
85076 -
85077 - expand_downwards(vma, address - PAGE_SIZE);
85078 - }
85079 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
85080 - struct vm_area_struct *next = vma->vm_next;
85081 -
85082 - /* As VM_GROWSDOWN but s/below/above/ */
85083 - if (next && next->vm_start == address + PAGE_SIZE)
85084 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
85085 -
85086 - expand_upwards(vma, address + PAGE_SIZE);
85087 - }
85088 - return 0;
85089 -}
85090 -
85091 -/*
85092 * We enter with non-exclusive mmap_sem (to exclude vma changes,
85093 * but allow concurrent faults), and pte mapped but not yet locked.
85094 * We return with mmap_sem still held, but pte unmapped and unlocked.
85095 @@ -3218,27 +3400,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
85096 unsigned long address, pte_t *page_table, pmd_t *pmd,
85097 unsigned int flags)
85098 {
85099 - struct page *page;
85100 + struct page *page = NULL;
85101 spinlock_t *ptl;
85102 pte_t entry;
85103
85104 - pte_unmap(page_table);
85105 -
85106 - /* Check if we need to add a guard page to the stack */
85107 - if (check_stack_guard_page(vma, address) < 0)
85108 - return VM_FAULT_SIGBUS;
85109 -
85110 - /* Use the zero-page for reads */
85111 if (!(flags & FAULT_FLAG_WRITE)) {
85112 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
85113 vma->vm_page_prot));
85114 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
85115 + ptl = pte_lockptr(mm, pmd);
85116 + spin_lock(ptl);
85117 if (!pte_none(*page_table))
85118 goto unlock;
85119 goto setpte;
85120 }
85121
85122 /* Allocate our own private page. */
85123 + pte_unmap(page_table);
85124 +
85125 if (unlikely(anon_vma_prepare(vma)))
85126 goto oom;
85127 page = alloc_zeroed_user_highpage_movable(vma, address);
85128 @@ -3262,6 +3440,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
85129 if (!pte_none(*page_table))
85130 goto release;
85131
85132 +#ifdef CONFIG_PAX_SEGMEXEC
85133 + if (pax_find_mirror_vma(vma))
85134 + BUG_ON(!trylock_page(page));
85135 +#endif
85136 +
85137 inc_mm_counter_fast(mm, MM_ANONPAGES);
85138 page_add_new_anon_rmap(page, vma, address);
85139 setpte:
85140 @@ -3269,6 +3452,12 @@ setpte:
85141
85142 /* No need to invalidate - it was non-present before */
85143 update_mmu_cache(vma, address, page_table);
85144 +
85145 +#ifdef CONFIG_PAX_SEGMEXEC
85146 + if (page)
85147 + pax_mirror_anon_pte(vma, address, page, ptl);
85148 +#endif
85149 +
85150 unlock:
85151 pte_unmap_unlock(page_table, ptl);
85152 return 0;
85153 @@ -3412,6 +3601,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
85154 */
85155 /* Only go through if we didn't race with anybody else... */
85156 if (likely(pte_same(*page_table, orig_pte))) {
85157 +
85158 +#ifdef CONFIG_PAX_SEGMEXEC
85159 + if (anon && pax_find_mirror_vma(vma))
85160 + BUG_ON(!trylock_page(page));
85161 +#endif
85162 +
85163 flush_icache_page(vma, page);
85164 entry = mk_pte(page, vma->vm_page_prot);
85165 if (flags & FAULT_FLAG_WRITE)
85166 @@ -3431,6 +3626,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
85167
85168 /* no need to invalidate: a not-present page won't be cached */
85169 update_mmu_cache(vma, address, page_table);
85170 +
85171 +#ifdef CONFIG_PAX_SEGMEXEC
85172 + if (anon)
85173 + pax_mirror_anon_pte(vma, address, page, ptl);
85174 + else
85175 + pax_mirror_file_pte(vma, address, page, ptl);
85176 +#endif
85177 +
85178 } else {
85179 if (cow_page)
85180 mem_cgroup_uncharge_page(cow_page);
85181 @@ -3752,6 +3955,12 @@ int handle_pte_fault(struct mm_struct *mm,
85182 if (flags & FAULT_FLAG_WRITE)
85183 flush_tlb_fix_spurious_fault(vma, address);
85184 }
85185 +
85186 +#ifdef CONFIG_PAX_SEGMEXEC
85187 + pax_mirror_pte(vma, address, pte, pmd, ptl);
85188 + return 0;
85189 +#endif
85190 +
85191 unlock:
85192 pte_unmap_unlock(pte, ptl);
85193 return 0;
85194 @@ -3768,6 +3977,10 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
85195 pmd_t *pmd;
85196 pte_t *pte;
85197
85198 +#ifdef CONFIG_PAX_SEGMEXEC
85199 + struct vm_area_struct *vma_m;
85200 +#endif
85201 +
85202 __set_current_state(TASK_RUNNING);
85203
85204 count_vm_event(PGFAULT);
85205 @@ -3779,6 +3992,34 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
85206 if (unlikely(is_vm_hugetlb_page(vma)))
85207 return hugetlb_fault(mm, vma, address, flags);
85208
85209 +#ifdef CONFIG_PAX_SEGMEXEC
85210 + vma_m = pax_find_mirror_vma(vma);
85211 + if (vma_m) {
85212 + unsigned long address_m;
85213 + pgd_t *pgd_m;
85214 + pud_t *pud_m;
85215 + pmd_t *pmd_m;
85216 +
85217 + if (vma->vm_start > vma_m->vm_start) {
85218 + address_m = address;
85219 + address -= SEGMEXEC_TASK_SIZE;
85220 + vma = vma_m;
85221 + } else
85222 + address_m = address + SEGMEXEC_TASK_SIZE;
85223 +
85224 + pgd_m = pgd_offset(mm, address_m);
85225 + pud_m = pud_alloc(mm, pgd_m, address_m);
85226 + if (!pud_m)
85227 + return VM_FAULT_OOM;
85228 + pmd_m = pmd_alloc(mm, pud_m, address_m);
85229 + if (!pmd_m)
85230 + return VM_FAULT_OOM;
85231 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
85232 + return VM_FAULT_OOM;
85233 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
85234 + }
85235 +#endif
85236 +
85237 retry:
85238 pgd = pgd_offset(mm, address);
85239 pud = pud_alloc(mm, pgd, address);
85240 @@ -3877,6 +4118,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
85241 spin_unlock(&mm->page_table_lock);
85242 return 0;
85243 }
85244 +
85245 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
85246 +{
85247 + pud_t *new = pud_alloc_one(mm, address);
85248 + if (!new)
85249 + return -ENOMEM;
85250 +
85251 + smp_wmb(); /* See comment in __pte_alloc */
85252 +
85253 + spin_lock(&mm->page_table_lock);
85254 + if (pgd_present(*pgd)) /* Another has populated it */
85255 + pud_free(mm, new);
85256 + else
85257 + pgd_populate_kernel(mm, pgd, new);
85258 + spin_unlock(&mm->page_table_lock);
85259 + return 0;
85260 +}
85261 #endif /* __PAGETABLE_PUD_FOLDED */
85262
85263 #ifndef __PAGETABLE_PMD_FOLDED
85264 @@ -3907,6 +4165,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
85265 spin_unlock(&mm->page_table_lock);
85266 return 0;
85267 }
85268 +
85269 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
85270 +{
85271 + pmd_t *new = pmd_alloc_one(mm, address);
85272 + if (!new)
85273 + return -ENOMEM;
85274 +
85275 + smp_wmb(); /* See comment in __pte_alloc */
85276 +
85277 + spin_lock(&mm->page_table_lock);
85278 +#ifndef __ARCH_HAS_4LEVEL_HACK
85279 + if (pud_present(*pud)) /* Another has populated it */
85280 + pmd_free(mm, new);
85281 + else
85282 + pud_populate_kernel(mm, pud, new);
85283 +#else
85284 + if (pgd_present(*pud)) /* Another has populated it */
85285 + pmd_free(mm, new);
85286 + else
85287 + pgd_populate_kernel(mm, pud, new);
85288 +#endif /* __ARCH_HAS_4LEVEL_HACK */
85289 + spin_unlock(&mm->page_table_lock);
85290 + return 0;
85291 +}
85292 #endif /* __PAGETABLE_PMD_FOLDED */
85293
85294 #if !defined(__HAVE_ARCH_GATE_AREA)
85295 @@ -3920,7 +4202,7 @@ static int __init gate_vma_init(void)
85296 gate_vma.vm_start = FIXADDR_USER_START;
85297 gate_vma.vm_end = FIXADDR_USER_END;
85298 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
85299 - gate_vma.vm_page_prot = __P101;
85300 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
85301
85302 return 0;
85303 }
85304 @@ -4054,8 +4336,8 @@ out:
85305 return ret;
85306 }
85307
85308 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
85309 - void *buf, int len, int write)
85310 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
85311 + void *buf, size_t len, int write)
85312 {
85313 resource_size_t phys_addr;
85314 unsigned long prot = 0;
85315 @@ -4080,8 +4362,8 @@ int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
85316 * Access another process' address space as given in mm. If non-NULL, use the
85317 * given task for page fault accounting.
85318 */
85319 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
85320 - unsigned long addr, void *buf, int len, int write)
85321 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
85322 + unsigned long addr, void *buf, size_t len, int write)
85323 {
85324 struct vm_area_struct *vma;
85325 void *old_buf = buf;
85326 @@ -4089,7 +4371,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
85327 down_read(&mm->mmap_sem);
85328 /* ignore errors, just check how much was successfully transferred */
85329 while (len) {
85330 - int bytes, ret, offset;
85331 + ssize_t bytes, ret, offset;
85332 void *maddr;
85333 struct page *page = NULL;
85334
85335 @@ -4148,8 +4430,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
85336 *
85337 * The caller must hold a reference on @mm.
85338 */
85339 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
85340 - void *buf, int len, int write)
85341 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
85342 + void *buf, size_t len, int write)
85343 {
85344 return __access_remote_vm(NULL, mm, addr, buf, len, write);
85345 }
85346 @@ -4159,11 +4441,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
85347 * Source/target buffer must be kernel space,
85348 * Do not walk the page table directly, use get_user_pages
85349 */
85350 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
85351 - void *buf, int len, int write)
85352 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
85353 + void *buf, size_t len, int write)
85354 {
85355 struct mm_struct *mm;
85356 - int ret;
85357 + ssize_t ret;
85358
85359 mm = get_task_mm(tsk);
85360 if (!mm)
85361 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
85362 index 4baf12e..5497066 100644
85363 --- a/mm/mempolicy.c
85364 +++ b/mm/mempolicy.c
85365 @@ -708,6 +708,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
85366 unsigned long vmstart;
85367 unsigned long vmend;
85368
85369 +#ifdef CONFIG_PAX_SEGMEXEC
85370 + struct vm_area_struct *vma_m;
85371 +#endif
85372 +
85373 vma = find_vma(mm, start);
85374 if (!vma || vma->vm_start > start)
85375 return -EFAULT;
85376 @@ -751,6 +755,16 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
85377 err = vma_replace_policy(vma, new_pol);
85378 if (err)
85379 goto out;
85380 +
85381 +#ifdef CONFIG_PAX_SEGMEXEC
85382 + vma_m = pax_find_mirror_vma(vma);
85383 + if (vma_m) {
85384 + err = vma_replace_policy(vma_m, new_pol);
85385 + if (err)
85386 + goto out;
85387 + }
85388 +#endif
85389 +
85390 }
85391
85392 out:
85393 @@ -1206,6 +1220,17 @@ static long do_mbind(unsigned long start, unsigned long len,
85394
85395 if (end < start)
85396 return -EINVAL;
85397 +
85398 +#ifdef CONFIG_PAX_SEGMEXEC
85399 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
85400 + if (end > SEGMEXEC_TASK_SIZE)
85401 + return -EINVAL;
85402 + } else
85403 +#endif
85404 +
85405 + if (end > TASK_SIZE)
85406 + return -EINVAL;
85407 +
85408 if (end == start)
85409 return 0;
85410
85411 @@ -1434,8 +1459,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
85412 */
85413 tcred = __task_cred(task);
85414 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
85415 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
85416 - !capable(CAP_SYS_NICE)) {
85417 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
85418 rcu_read_unlock();
85419 err = -EPERM;
85420 goto out_put;
85421 @@ -1466,6 +1490,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
85422 goto out;
85423 }
85424
85425 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
85426 + if (mm != current->mm &&
85427 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
85428 + mmput(mm);
85429 + err = -EPERM;
85430 + goto out;
85431 + }
85432 +#endif
85433 +
85434 err = do_migrate_pages(mm, old, new,
85435 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
85436
85437 diff --git a/mm/migrate.c b/mm/migrate.c
85438 index 6f0c244..6d1ae32 100644
85439 --- a/mm/migrate.c
85440 +++ b/mm/migrate.c
85441 @@ -1399,8 +1399,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
85442 */
85443 tcred = __task_cred(task);
85444 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
85445 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
85446 - !capable(CAP_SYS_NICE)) {
85447 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
85448 rcu_read_unlock();
85449 err = -EPERM;
85450 goto out;
85451 diff --git a/mm/mlock.c b/mm/mlock.c
85452 index 79b7cf7..9944291 100644
85453 --- a/mm/mlock.c
85454 +++ b/mm/mlock.c
85455 @@ -13,6 +13,7 @@
85456 #include <linux/pagemap.h>
85457 #include <linux/mempolicy.h>
85458 #include <linux/syscalls.h>
85459 +#include <linux/security.h>
85460 #include <linux/sched.h>
85461 #include <linux/export.h>
85462 #include <linux/rmap.h>
85463 @@ -334,7 +335,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
85464 {
85465 unsigned long nstart, end, tmp;
85466 struct vm_area_struct * vma, * prev;
85467 - int error;
85468 + int error = 0;
85469
85470 VM_BUG_ON(start & ~PAGE_MASK);
85471 VM_BUG_ON(len != PAGE_ALIGN(len));
85472 @@ -343,6 +344,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
85473 return -EINVAL;
85474 if (end == start)
85475 return 0;
85476 + if (end > TASK_SIZE)
85477 + return -EINVAL;
85478 +
85479 vma = find_vma(current->mm, start);
85480 if (!vma || vma->vm_start > start)
85481 return -ENOMEM;
85482 @@ -354,6 +358,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
85483 for (nstart = start ; ; ) {
85484 vm_flags_t newflags;
85485
85486 +#ifdef CONFIG_PAX_SEGMEXEC
85487 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
85488 + break;
85489 +#endif
85490 +
85491 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
85492
85493 newflags = vma->vm_flags & ~VM_LOCKED;
85494 @@ -466,6 +475,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
85495 lock_limit >>= PAGE_SHIFT;
85496
85497 /* check against resource limits */
85498 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
85499 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
85500 error = do_mlock(start, len, 1);
85501 up_write(&current->mm->mmap_sem);
85502 @@ -500,6 +510,11 @@ static int do_mlockall(int flags)
85503 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
85504 vm_flags_t newflags;
85505
85506 +#ifdef CONFIG_PAX_SEGMEXEC
85507 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
85508 + break;
85509 +#endif
85510 +
85511 newflags = vma->vm_flags & ~VM_LOCKED;
85512 if (flags & MCL_CURRENT)
85513 newflags |= VM_LOCKED;
85514 @@ -532,6 +547,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
85515 lock_limit >>= PAGE_SHIFT;
85516
85517 ret = -ENOMEM;
85518 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
85519 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
85520 capable(CAP_IPC_LOCK))
85521 ret = do_mlockall(flags);
85522 diff --git a/mm/mmap.c b/mm/mmap.c
85523 index 8d25fdc..bfb7626 100644
85524 --- a/mm/mmap.c
85525 +++ b/mm/mmap.c
85526 @@ -36,6 +36,7 @@
85527 #include <linux/sched/sysctl.h>
85528 #include <linux/notifier.h>
85529 #include <linux/memory.h>
85530 +#include <linux/random.h>
85531
85532 #include <asm/uaccess.h>
85533 #include <asm/cacheflush.h>
85534 @@ -52,6 +53,16 @@
85535 #define arch_rebalance_pgtables(addr, len) (addr)
85536 #endif
85537
85538 +static inline void verify_mm_writelocked(struct mm_struct *mm)
85539 +{
85540 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
85541 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
85542 + up_read(&mm->mmap_sem);
85543 + BUG();
85544 + }
85545 +#endif
85546 +}
85547 +
85548 static void unmap_region(struct mm_struct *mm,
85549 struct vm_area_struct *vma, struct vm_area_struct *prev,
85550 unsigned long start, unsigned long end);
85551 @@ -71,16 +82,25 @@ static void unmap_region(struct mm_struct *mm,
85552 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
85553 *
85554 */
85555 -pgprot_t protection_map[16] = {
85556 +pgprot_t protection_map[16] __read_only = {
85557 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
85558 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
85559 };
85560
85561 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
85562 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
85563 {
85564 - return __pgprot(pgprot_val(protection_map[vm_flags &
85565 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
85566 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
85567 pgprot_val(arch_vm_get_page_prot(vm_flags)));
85568 +
85569 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
85570 + if (!(__supported_pte_mask & _PAGE_NX) &&
85571 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
85572 + (vm_flags & (VM_READ | VM_WRITE)))
85573 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
85574 +#endif
85575 +
85576 + return prot;
85577 }
85578 EXPORT_SYMBOL(vm_get_page_prot);
85579
85580 @@ -89,6 +109,7 @@ int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
85581 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
85582 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
85583 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
85584 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
85585 /*
85586 * Make sure vm_committed_as in one cacheline and not cacheline shared with
85587 * other variables. It can be updated by several CPUs frequently.
85588 @@ -247,6 +268,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
85589 struct vm_area_struct *next = vma->vm_next;
85590
85591 might_sleep();
85592 + BUG_ON(vma->vm_mirror);
85593 if (vma->vm_ops && vma->vm_ops->close)
85594 vma->vm_ops->close(vma);
85595 if (vma->vm_file)
85596 @@ -291,6 +313,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
85597 * not page aligned -Ram Gupta
85598 */
85599 rlim = rlimit(RLIMIT_DATA);
85600 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
85601 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
85602 (mm->end_data - mm->start_data) > rlim)
85603 goto out;
85604 @@ -933,6 +956,12 @@ static int
85605 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
85606 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
85607 {
85608 +
85609 +#ifdef CONFIG_PAX_SEGMEXEC
85610 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
85611 + return 0;
85612 +#endif
85613 +
85614 if (is_mergeable_vma(vma, file, vm_flags) &&
85615 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
85616 if (vma->vm_pgoff == vm_pgoff)
85617 @@ -952,6 +981,12 @@ static int
85618 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
85619 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
85620 {
85621 +
85622 +#ifdef CONFIG_PAX_SEGMEXEC
85623 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
85624 + return 0;
85625 +#endif
85626 +
85627 if (is_mergeable_vma(vma, file, vm_flags) &&
85628 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
85629 pgoff_t vm_pglen;
85630 @@ -994,13 +1029,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
85631 struct vm_area_struct *vma_merge(struct mm_struct *mm,
85632 struct vm_area_struct *prev, unsigned long addr,
85633 unsigned long end, unsigned long vm_flags,
85634 - struct anon_vma *anon_vma, struct file *file,
85635 + struct anon_vma *anon_vma, struct file *file,
85636 pgoff_t pgoff, struct mempolicy *policy)
85637 {
85638 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
85639 struct vm_area_struct *area, *next;
85640 int err;
85641
85642 +#ifdef CONFIG_PAX_SEGMEXEC
85643 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
85644 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
85645 +
85646 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
85647 +#endif
85648 +
85649 /*
85650 * We later require that vma->vm_flags == vm_flags,
85651 * so this tests vma->vm_flags & VM_SPECIAL, too.
85652 @@ -1016,6 +1058,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
85653 if (next && next->vm_end == end) /* cases 6, 7, 8 */
85654 next = next->vm_next;
85655
85656 +#ifdef CONFIG_PAX_SEGMEXEC
85657 + if (prev)
85658 + prev_m = pax_find_mirror_vma(prev);
85659 + if (area)
85660 + area_m = pax_find_mirror_vma(area);
85661 + if (next)
85662 + next_m = pax_find_mirror_vma(next);
85663 +#endif
85664 +
85665 /*
85666 * Can it merge with the predecessor?
85667 */
85668 @@ -1035,9 +1086,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
85669 /* cases 1, 6 */
85670 err = vma_adjust(prev, prev->vm_start,
85671 next->vm_end, prev->vm_pgoff, NULL);
85672 - } else /* cases 2, 5, 7 */
85673 +
85674 +#ifdef CONFIG_PAX_SEGMEXEC
85675 + if (!err && prev_m)
85676 + err = vma_adjust(prev_m, prev_m->vm_start,
85677 + next_m->vm_end, prev_m->vm_pgoff, NULL);
85678 +#endif
85679 +
85680 + } else { /* cases 2, 5, 7 */
85681 err = vma_adjust(prev, prev->vm_start,
85682 end, prev->vm_pgoff, NULL);
85683 +
85684 +#ifdef CONFIG_PAX_SEGMEXEC
85685 + if (!err && prev_m)
85686 + err = vma_adjust(prev_m, prev_m->vm_start,
85687 + end_m, prev_m->vm_pgoff, NULL);
85688 +#endif
85689 +
85690 + }
85691 if (err)
85692 return NULL;
85693 khugepaged_enter_vma_merge(prev);
85694 @@ -1051,12 +1117,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
85695 mpol_equal(policy, vma_policy(next)) &&
85696 can_vma_merge_before(next, vm_flags,
85697 anon_vma, file, pgoff+pglen)) {
85698 - if (prev && addr < prev->vm_end) /* case 4 */
85699 + if (prev && addr < prev->vm_end) { /* case 4 */
85700 err = vma_adjust(prev, prev->vm_start,
85701 addr, prev->vm_pgoff, NULL);
85702 - else /* cases 3, 8 */
85703 +
85704 +#ifdef CONFIG_PAX_SEGMEXEC
85705 + if (!err && prev_m)
85706 + err = vma_adjust(prev_m, prev_m->vm_start,
85707 + addr_m, prev_m->vm_pgoff, NULL);
85708 +#endif
85709 +
85710 + } else { /* cases 3, 8 */
85711 err = vma_adjust(area, addr, next->vm_end,
85712 next->vm_pgoff - pglen, NULL);
85713 +
85714 +#ifdef CONFIG_PAX_SEGMEXEC
85715 + if (!err && area_m)
85716 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
85717 + next_m->vm_pgoff - pglen, NULL);
85718 +#endif
85719 +
85720 + }
85721 if (err)
85722 return NULL;
85723 khugepaged_enter_vma_merge(area);
85724 @@ -1165,8 +1246,10 @@ none:
85725 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
85726 struct file *file, long pages)
85727 {
85728 - const unsigned long stack_flags
85729 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
85730 +
85731 +#ifdef CONFIG_PAX_RANDMMAP
85732 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
85733 +#endif
85734
85735 mm->total_vm += pages;
85736
85737 @@ -1174,7 +1257,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
85738 mm->shared_vm += pages;
85739 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
85740 mm->exec_vm += pages;
85741 - } else if (flags & stack_flags)
85742 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
85743 mm->stack_vm += pages;
85744 }
85745 #endif /* CONFIG_PROC_FS */
85746 @@ -1213,7 +1296,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
85747 * (the exception is when the underlying filesystem is noexec
85748 * mounted, in which case we dont add PROT_EXEC.)
85749 */
85750 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
85751 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
85752 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
85753 prot |= PROT_EXEC;
85754
85755 @@ -1239,7 +1322,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
85756 /* Obtain the address to map to. we verify (or select) it and ensure
85757 * that it represents a valid section of the address space.
85758 */
85759 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
85760 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
85761 if (addr & ~PAGE_MASK)
85762 return addr;
85763
85764 @@ -1250,6 +1333,43 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
85765 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
85766 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
85767
85768 +#ifdef CONFIG_PAX_MPROTECT
85769 + if (mm->pax_flags & MF_PAX_MPROTECT) {
85770 +
85771 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
85772 + if (file && !pgoff && (vm_flags & VM_EXEC) && mm->binfmt &&
85773 + mm->binfmt->handle_mmap)
85774 + mm->binfmt->handle_mmap(file);
85775 +#endif
85776 +
85777 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
85778 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
85779 + gr_log_rwxmmap(file);
85780 +
85781 +#ifdef CONFIG_PAX_EMUPLT
85782 + vm_flags &= ~VM_EXEC;
85783 +#else
85784 + return -EPERM;
85785 +#endif
85786 +
85787 + }
85788 +
85789 + if (!(vm_flags & VM_EXEC))
85790 + vm_flags &= ~VM_MAYEXEC;
85791 +#else
85792 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
85793 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
85794 +#endif
85795 + else
85796 + vm_flags &= ~VM_MAYWRITE;
85797 + }
85798 +#endif
85799 +
85800 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
85801 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
85802 + vm_flags &= ~VM_PAGEEXEC;
85803 +#endif
85804 +
85805 if (flags & MAP_LOCKED)
85806 if (!can_do_mlock())
85807 return -EPERM;
85808 @@ -1261,6 +1381,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
85809 locked += mm->locked_vm;
85810 lock_limit = rlimit(RLIMIT_MEMLOCK);
85811 lock_limit >>= PAGE_SHIFT;
85812 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
85813 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
85814 return -EAGAIN;
85815 }
85816 @@ -1341,6 +1462,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
85817 vm_flags |= VM_NORESERVE;
85818 }
85819
85820 + if (!gr_acl_handle_mmap(file, prot))
85821 + return -EACCES;
85822 +
85823 addr = mmap_region(file, addr, len, vm_flags, pgoff);
85824 if (!IS_ERR_VALUE(addr) &&
85825 ((vm_flags & VM_LOCKED) ||
85826 @@ -1432,7 +1556,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
85827 vm_flags_t vm_flags = vma->vm_flags;
85828
85829 /* If it was private or non-writable, the write bit is already clear */
85830 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
85831 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
85832 return 0;
85833
85834 /* The backer wishes to know when pages are first written to? */
85835 @@ -1480,7 +1604,22 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
85836 unsigned long charged = 0;
85837 struct inode *inode = file ? file_inode(file) : NULL;
85838
85839 +#ifdef CONFIG_PAX_SEGMEXEC
85840 + struct vm_area_struct *vma_m = NULL;
85841 +#endif
85842 +
85843 + /*
85844 + * mm->mmap_sem is required to protect against another thread
85845 + * changing the mappings in case we sleep.
85846 + */
85847 + verify_mm_writelocked(mm);
85848 +
85849 /* Check against address space limit. */
85850 +
85851 +#ifdef CONFIG_PAX_RANDMMAP
85852 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
85853 +#endif
85854 +
85855 if (!may_expand_vm(mm, len >> PAGE_SHIFT)) {
85856 unsigned long nr_pages;
85857
85858 @@ -1499,11 +1638,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
85859
85860 /* Clear old maps */
85861 error = -ENOMEM;
85862 -munmap_back:
85863 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
85864 if (do_munmap(mm, addr, len))
85865 return -ENOMEM;
85866 - goto munmap_back;
85867 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
85868 }
85869
85870 /*
85871 @@ -1534,6 +1672,16 @@ munmap_back:
85872 goto unacct_error;
85873 }
85874
85875 +#ifdef CONFIG_PAX_SEGMEXEC
85876 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
85877 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
85878 + if (!vma_m) {
85879 + error = -ENOMEM;
85880 + goto free_vma;
85881 + }
85882 + }
85883 +#endif
85884 +
85885 vma->vm_mm = mm;
85886 vma->vm_start = addr;
85887 vma->vm_end = addr + len;
85888 @@ -1558,6 +1706,13 @@ munmap_back:
85889 if (error)
85890 goto unmap_and_free_vma;
85891
85892 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
85893 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
85894 + vma->vm_flags |= VM_PAGEEXEC;
85895 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
85896 + }
85897 +#endif
85898 +
85899 /* Can addr have changed??
85900 *
85901 * Answer: Yes, several device drivers can do it in their
85902 @@ -1596,6 +1751,11 @@ munmap_back:
85903 vma_link(mm, vma, prev, rb_link, rb_parent);
85904 file = vma->vm_file;
85905
85906 +#ifdef CONFIG_PAX_SEGMEXEC
85907 + if (vma_m)
85908 + BUG_ON(pax_mirror_vma(vma_m, vma));
85909 +#endif
85910 +
85911 /* Once vma denies write, undo our temporary denial count */
85912 if (correct_wcount)
85913 atomic_inc(&inode->i_writecount);
85914 @@ -1603,6 +1763,7 @@ out:
85915 perf_event_mmap(vma);
85916
85917 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
85918 + track_exec_limit(mm, addr, addr + len, vm_flags);
85919 if (vm_flags & VM_LOCKED) {
85920 if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) ||
85921 vma == get_gate_vma(current->mm)))
85922 @@ -1626,6 +1787,12 @@ unmap_and_free_vma:
85923 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
85924 charged = 0;
85925 free_vma:
85926 +
85927 +#ifdef CONFIG_PAX_SEGMEXEC
85928 + if (vma_m)
85929 + kmem_cache_free(vm_area_cachep, vma_m);
85930 +#endif
85931 +
85932 kmem_cache_free(vm_area_cachep, vma);
85933 unacct_error:
85934 if (charged)
85935 @@ -1633,7 +1800,63 @@ unacct_error:
85936 return error;
85937 }
85938
85939 -unsigned long unmapped_area(struct vm_unmapped_area_info *info)
85940 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
85941 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
85942 +{
85943 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
85944 + return ((prandom_u32() & 0xFF) + 1) << PAGE_SHIFT;
85945 +
85946 + return 0;
85947 +}
85948 +#endif
85949 +
85950 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
85951 +{
85952 + if (!vma) {
85953 +#ifdef CONFIG_STACK_GROWSUP
85954 + if (addr > sysctl_heap_stack_gap)
85955 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
85956 + else
85957 + vma = find_vma(current->mm, 0);
85958 + if (vma && (vma->vm_flags & VM_GROWSUP))
85959 + return false;
85960 +#endif
85961 + return true;
85962 + }
85963 +
85964 + if (addr + len > vma->vm_start)
85965 + return false;
85966 +
85967 + if (vma->vm_flags & VM_GROWSDOWN)
85968 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
85969 +#ifdef CONFIG_STACK_GROWSUP
85970 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
85971 + return addr - vma->vm_prev->vm_end >= sysctl_heap_stack_gap;
85972 +#endif
85973 + else if (offset)
85974 + return offset <= vma->vm_start - addr - len;
85975 +
85976 + return true;
85977 +}
85978 +
85979 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
85980 +{
85981 + if (vma->vm_start < len)
85982 + return -ENOMEM;
85983 +
85984 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
85985 + if (offset <= vma->vm_start - len)
85986 + return vma->vm_start - len - offset;
85987 + else
85988 + return -ENOMEM;
85989 + }
85990 +
85991 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
85992 + return vma->vm_start - len - sysctl_heap_stack_gap;
85993 + return -ENOMEM;
85994 +}
85995 +
85996 +unsigned long unmapped_area(const struct vm_unmapped_area_info *info)
85997 {
85998 /*
85999 * We implement the search by looking for an rbtree node that
86000 @@ -1681,11 +1904,29 @@ unsigned long unmapped_area(struct vm_unmapped_area_info *info)
86001 }
86002 }
86003
86004 - gap_start = vma->vm_prev ? vma->vm_prev->vm_end : 0;
86005 + gap_start = vma->vm_prev ? vma->vm_prev->vm_end: 0;
86006 check_current:
86007 /* Check if current node has a suitable gap */
86008 if (gap_start > high_limit)
86009 return -ENOMEM;
86010 +
86011 + if (gap_end - gap_start > info->threadstack_offset)
86012 + gap_start += info->threadstack_offset;
86013 + else
86014 + gap_start = gap_end;
86015 +
86016 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
86017 + if (gap_end - gap_start > sysctl_heap_stack_gap)
86018 + gap_start += sysctl_heap_stack_gap;
86019 + else
86020 + gap_start = gap_end;
86021 + }
86022 + if (vma->vm_flags & VM_GROWSDOWN) {
86023 + if (gap_end - gap_start > sysctl_heap_stack_gap)
86024 + gap_end -= sysctl_heap_stack_gap;
86025 + else
86026 + gap_end = gap_start;
86027 + }
86028 if (gap_end >= low_limit && gap_end - gap_start >= length)
86029 goto found;
86030
86031 @@ -1735,7 +1976,7 @@ found:
86032 return gap_start;
86033 }
86034
86035 -unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
86036 +unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info)
86037 {
86038 struct mm_struct *mm = current->mm;
86039 struct vm_area_struct *vma;
86040 @@ -1789,6 +2030,24 @@ check_current:
86041 gap_end = vma->vm_start;
86042 if (gap_end < low_limit)
86043 return -ENOMEM;
86044 +
86045 + if (gap_end - gap_start > info->threadstack_offset)
86046 + gap_end -= info->threadstack_offset;
86047 + else
86048 + gap_end = gap_start;
86049 +
86050 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
86051 + if (gap_end - gap_start > sysctl_heap_stack_gap)
86052 + gap_start += sysctl_heap_stack_gap;
86053 + else
86054 + gap_start = gap_end;
86055 + }
86056 + if (vma->vm_flags & VM_GROWSDOWN) {
86057 + if (gap_end - gap_start > sysctl_heap_stack_gap)
86058 + gap_end -= sysctl_heap_stack_gap;
86059 + else
86060 + gap_end = gap_start;
86061 + }
86062 if (gap_start <= high_limit && gap_end - gap_start >= length)
86063 goto found;
86064
86065 @@ -1852,6 +2111,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
86066 struct mm_struct *mm = current->mm;
86067 struct vm_area_struct *vma;
86068 struct vm_unmapped_area_info info;
86069 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
86070
86071 if (len > TASK_SIZE)
86072 return -ENOMEM;
86073 @@ -1859,29 +2119,45 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
86074 if (flags & MAP_FIXED)
86075 return addr;
86076
86077 +#ifdef CONFIG_PAX_RANDMMAP
86078 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
86079 +#endif
86080 +
86081 if (addr) {
86082 addr = PAGE_ALIGN(addr);
86083 vma = find_vma(mm, addr);
86084 - if (TASK_SIZE - len >= addr &&
86085 - (!vma || addr + len <= vma->vm_start))
86086 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
86087 return addr;
86088 }
86089
86090 info.flags = 0;
86091 info.length = len;
86092 info.low_limit = TASK_UNMAPPED_BASE;
86093 +
86094 +#ifdef CONFIG_PAX_RANDMMAP
86095 + if (mm->pax_flags & MF_PAX_RANDMMAP)
86096 + info.low_limit += mm->delta_mmap;
86097 +#endif
86098 +
86099 info.high_limit = TASK_SIZE;
86100 info.align_mask = 0;
86101 + info.threadstack_offset = offset;
86102 return vm_unmapped_area(&info);
86103 }
86104 #endif
86105
86106 void arch_unmap_area(struct mm_struct *mm, unsigned long addr)
86107 {
86108 +
86109 +#ifdef CONFIG_PAX_SEGMEXEC
86110 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
86111 + return;
86112 +#endif
86113 +
86114 /*
86115 * Is this a new hole at the lowest possible address?
86116 */
86117 - if (addr >= TASK_UNMAPPED_BASE && addr < mm->free_area_cache)
86118 + if (addr >= mm->mmap_base && addr < mm->free_area_cache)
86119 mm->free_area_cache = addr;
86120 }
86121
86122 @@ -1899,6 +2175,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
86123 struct mm_struct *mm = current->mm;
86124 unsigned long addr = addr0;
86125 struct vm_unmapped_area_info info;
86126 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
86127
86128 /* requested length too big for entire address space */
86129 if (len > TASK_SIZE)
86130 @@ -1907,12 +2184,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
86131 if (flags & MAP_FIXED)
86132 return addr;
86133
86134 +#ifdef CONFIG_PAX_RANDMMAP
86135 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
86136 +#endif
86137 +
86138 /* requesting a specific address */
86139 if (addr) {
86140 addr = PAGE_ALIGN(addr);
86141 vma = find_vma(mm, addr);
86142 - if (TASK_SIZE - len >= addr &&
86143 - (!vma || addr + len <= vma->vm_start))
86144 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
86145 return addr;
86146 }
86147
86148 @@ -1921,6 +2201,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
86149 info.low_limit = PAGE_SIZE;
86150 info.high_limit = mm->mmap_base;
86151 info.align_mask = 0;
86152 + info.threadstack_offset = offset;
86153 addr = vm_unmapped_area(&info);
86154
86155 /*
86156 @@ -1933,6 +2214,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
86157 VM_BUG_ON(addr != -ENOMEM);
86158 info.flags = 0;
86159 info.low_limit = TASK_UNMAPPED_BASE;
86160 +
86161 +#ifdef CONFIG_PAX_RANDMMAP
86162 + if (mm->pax_flags & MF_PAX_RANDMMAP)
86163 + info.low_limit += mm->delta_mmap;
86164 +#endif
86165 +
86166 info.high_limit = TASK_SIZE;
86167 addr = vm_unmapped_area(&info);
86168 }
86169 @@ -1943,6 +2230,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
86170
86171 void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
86172 {
86173 +
86174 +#ifdef CONFIG_PAX_SEGMEXEC
86175 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE <= addr)
86176 + return;
86177 +#endif
86178 +
86179 /*
86180 * Is this a new hole at the highest possible address?
86181 */
86182 @@ -1950,8 +2243,10 @@ void arch_unmap_area_topdown(struct mm_struct *mm, unsigned long addr)
86183 mm->free_area_cache = addr;
86184
86185 /* dont allow allocations above current base */
86186 - if (mm->free_area_cache > mm->mmap_base)
86187 + if (mm->free_area_cache > mm->mmap_base) {
86188 mm->free_area_cache = mm->mmap_base;
86189 + mm->cached_hole_size = ~0UL;
86190 + }
86191 }
86192
86193 unsigned long
86194 @@ -2047,6 +2342,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
86195 return vma;
86196 }
86197
86198 +#ifdef CONFIG_PAX_SEGMEXEC
86199 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
86200 +{
86201 + struct vm_area_struct *vma_m;
86202 +
86203 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
86204 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
86205 + BUG_ON(vma->vm_mirror);
86206 + return NULL;
86207 + }
86208 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
86209 + vma_m = vma->vm_mirror;
86210 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
86211 + BUG_ON(vma->vm_file != vma_m->vm_file);
86212 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
86213 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
86214 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
86215 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
86216 + return vma_m;
86217 +}
86218 +#endif
86219 +
86220 /*
86221 * Verify that the stack growth is acceptable and
86222 * update accounting. This is shared with both the
86223 @@ -2063,6 +2380,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
86224 return -ENOMEM;
86225
86226 /* Stack limit test */
86227 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
86228 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
86229 return -ENOMEM;
86230
86231 @@ -2073,6 +2391,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
86232 locked = mm->locked_vm + grow;
86233 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
86234 limit >>= PAGE_SHIFT;
86235 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
86236 if (locked > limit && !capable(CAP_IPC_LOCK))
86237 return -ENOMEM;
86238 }
86239 @@ -2102,37 +2421,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
86240 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
86241 * vma is the last one with address > vma->vm_end. Have to extend vma.
86242 */
86243 +#ifndef CONFIG_IA64
86244 +static
86245 +#endif
86246 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
86247 {
86248 int error;
86249 + bool locknext;
86250
86251 if (!(vma->vm_flags & VM_GROWSUP))
86252 return -EFAULT;
86253
86254 + /* Also guard against wrapping around to address 0. */
86255 + if (address < PAGE_ALIGN(address+1))
86256 + address = PAGE_ALIGN(address+1);
86257 + else
86258 + return -ENOMEM;
86259 +
86260 /*
86261 * We must make sure the anon_vma is allocated
86262 * so that the anon_vma locking is not a noop.
86263 */
86264 if (unlikely(anon_vma_prepare(vma)))
86265 return -ENOMEM;
86266 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
86267 + if (locknext && anon_vma_prepare(vma->vm_next))
86268 + return -ENOMEM;
86269 vma_lock_anon_vma(vma);
86270 + if (locknext)
86271 + vma_lock_anon_vma(vma->vm_next);
86272
86273 /*
86274 * vma->vm_start/vm_end cannot change under us because the caller
86275 * is required to hold the mmap_sem in read mode. We need the
86276 - * anon_vma lock to serialize against concurrent expand_stacks.
86277 - * Also guard against wrapping around to address 0.
86278 + * anon_vma locks to serialize against concurrent expand_stacks
86279 + * and expand_upwards.
86280 */
86281 - if (address < PAGE_ALIGN(address+4))
86282 - address = PAGE_ALIGN(address+4);
86283 - else {
86284 - vma_unlock_anon_vma(vma);
86285 - return -ENOMEM;
86286 - }
86287 error = 0;
86288
86289 /* Somebody else might have raced and expanded it already */
86290 - if (address > vma->vm_end) {
86291 + 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)
86292 + error = -ENOMEM;
86293 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
86294 unsigned long size, grow;
86295
86296 size = address - vma->vm_start;
86297 @@ -2167,6 +2497,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
86298 }
86299 }
86300 }
86301 + if (locknext)
86302 + vma_unlock_anon_vma(vma->vm_next);
86303 vma_unlock_anon_vma(vma);
86304 khugepaged_enter_vma_merge(vma);
86305 validate_mm(vma->vm_mm);
86306 @@ -2181,6 +2513,8 @@ int expand_downwards(struct vm_area_struct *vma,
86307 unsigned long address)
86308 {
86309 int error;
86310 + bool lockprev = false;
86311 + struct vm_area_struct *prev;
86312
86313 /*
86314 * We must make sure the anon_vma is allocated
86315 @@ -2194,6 +2528,15 @@ int expand_downwards(struct vm_area_struct *vma,
86316 if (error)
86317 return error;
86318
86319 + prev = vma->vm_prev;
86320 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
86321 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
86322 +#endif
86323 + if (lockprev && anon_vma_prepare(prev))
86324 + return -ENOMEM;
86325 + if (lockprev)
86326 + vma_lock_anon_vma(prev);
86327 +
86328 vma_lock_anon_vma(vma);
86329
86330 /*
86331 @@ -2203,9 +2546,17 @@ int expand_downwards(struct vm_area_struct *vma,
86332 */
86333
86334 /* Somebody else might have raced and expanded it already */
86335 - if (address < vma->vm_start) {
86336 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
86337 + error = -ENOMEM;
86338 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
86339 unsigned long size, grow;
86340
86341 +#ifdef CONFIG_PAX_SEGMEXEC
86342 + struct vm_area_struct *vma_m;
86343 +
86344 + vma_m = pax_find_mirror_vma(vma);
86345 +#endif
86346 +
86347 size = vma->vm_end - address;
86348 grow = (vma->vm_start - address) >> PAGE_SHIFT;
86349
86350 @@ -2230,13 +2581,27 @@ int expand_downwards(struct vm_area_struct *vma,
86351 vma->vm_pgoff -= grow;
86352 anon_vma_interval_tree_post_update_vma(vma);
86353 vma_gap_update(vma);
86354 +
86355 +#ifdef CONFIG_PAX_SEGMEXEC
86356 + if (vma_m) {
86357 + anon_vma_interval_tree_pre_update_vma(vma_m);
86358 + vma_m->vm_start -= grow << PAGE_SHIFT;
86359 + vma_m->vm_pgoff -= grow;
86360 + anon_vma_interval_tree_post_update_vma(vma_m);
86361 + vma_gap_update(vma_m);
86362 + }
86363 +#endif
86364 +
86365 spin_unlock(&vma->vm_mm->page_table_lock);
86366
86367 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
86368 perf_event_mmap(vma);
86369 }
86370 }
86371 }
86372 vma_unlock_anon_vma(vma);
86373 + if (lockprev)
86374 + vma_unlock_anon_vma(prev);
86375 khugepaged_enter_vma_merge(vma);
86376 validate_mm(vma->vm_mm);
86377 return error;
86378 @@ -2334,6 +2699,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
86379 do {
86380 long nrpages = vma_pages(vma);
86381
86382 +#ifdef CONFIG_PAX_SEGMEXEC
86383 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
86384 + vma = remove_vma(vma);
86385 + continue;
86386 + }
86387 +#endif
86388 +
86389 if (vma->vm_flags & VM_ACCOUNT)
86390 nr_accounted += nrpages;
86391 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
86392 @@ -2379,6 +2751,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
86393 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
86394 vma->vm_prev = NULL;
86395 do {
86396 +
86397 +#ifdef CONFIG_PAX_SEGMEXEC
86398 + if (vma->vm_mirror) {
86399 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
86400 + vma->vm_mirror->vm_mirror = NULL;
86401 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
86402 + vma->vm_mirror = NULL;
86403 + }
86404 +#endif
86405 +
86406 vma_rb_erase(vma, &mm->mm_rb);
86407 mm->map_count--;
86408 tail_vma = vma;
86409 @@ -2410,14 +2792,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
86410 struct vm_area_struct *new;
86411 int err = -ENOMEM;
86412
86413 +#ifdef CONFIG_PAX_SEGMEXEC
86414 + struct vm_area_struct *vma_m, *new_m = NULL;
86415 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
86416 +#endif
86417 +
86418 if (is_vm_hugetlb_page(vma) && (addr &
86419 ~(huge_page_mask(hstate_vma(vma)))))
86420 return -EINVAL;
86421
86422 +#ifdef CONFIG_PAX_SEGMEXEC
86423 + vma_m = pax_find_mirror_vma(vma);
86424 +#endif
86425 +
86426 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
86427 if (!new)
86428 goto out_err;
86429
86430 +#ifdef CONFIG_PAX_SEGMEXEC
86431 + if (vma_m) {
86432 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
86433 + if (!new_m) {
86434 + kmem_cache_free(vm_area_cachep, new);
86435 + goto out_err;
86436 + }
86437 + }
86438 +#endif
86439 +
86440 /* most fields are the same, copy all, and then fixup */
86441 *new = *vma;
86442
86443 @@ -2430,6 +2831,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
86444 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
86445 }
86446
86447 +#ifdef CONFIG_PAX_SEGMEXEC
86448 + if (vma_m) {
86449 + *new_m = *vma_m;
86450 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
86451 + new_m->vm_mirror = new;
86452 + new->vm_mirror = new_m;
86453 +
86454 + if (new_below)
86455 + new_m->vm_end = addr_m;
86456 + else {
86457 + new_m->vm_start = addr_m;
86458 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
86459 + }
86460 + }
86461 +#endif
86462 +
86463 pol = mpol_dup(vma_policy(vma));
86464 if (IS_ERR(pol)) {
86465 err = PTR_ERR(pol);
86466 @@ -2452,6 +2869,36 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
86467 else
86468 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
86469
86470 +#ifdef CONFIG_PAX_SEGMEXEC
86471 + if (!err && vma_m) {
86472 + if (anon_vma_clone(new_m, vma_m))
86473 + goto out_free_mpol;
86474 +
86475 + mpol_get(pol);
86476 + vma_set_policy(new_m, pol);
86477 +
86478 + if (new_m->vm_file)
86479 + get_file(new_m->vm_file);
86480 +
86481 + if (new_m->vm_ops && new_m->vm_ops->open)
86482 + new_m->vm_ops->open(new_m);
86483 +
86484 + if (new_below)
86485 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
86486 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
86487 + else
86488 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
86489 +
86490 + if (err) {
86491 + if (new_m->vm_ops && new_m->vm_ops->close)
86492 + new_m->vm_ops->close(new_m);
86493 + if (new_m->vm_file)
86494 + fput(new_m->vm_file);
86495 + mpol_put(pol);
86496 + }
86497 + }
86498 +#endif
86499 +
86500 /* Success. */
86501 if (!err)
86502 return 0;
86503 @@ -2461,10 +2908,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
86504 new->vm_ops->close(new);
86505 if (new->vm_file)
86506 fput(new->vm_file);
86507 - unlink_anon_vmas(new);
86508 out_free_mpol:
86509 mpol_put(pol);
86510 out_free_vma:
86511 +
86512 +#ifdef CONFIG_PAX_SEGMEXEC
86513 + if (new_m) {
86514 + unlink_anon_vmas(new_m);
86515 + kmem_cache_free(vm_area_cachep, new_m);
86516 + }
86517 +#endif
86518 +
86519 + unlink_anon_vmas(new);
86520 kmem_cache_free(vm_area_cachep, new);
86521 out_err:
86522 return err;
86523 @@ -2477,6 +2932,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
86524 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
86525 unsigned long addr, int new_below)
86526 {
86527 +
86528 +#ifdef CONFIG_PAX_SEGMEXEC
86529 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
86530 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
86531 + if (mm->map_count >= sysctl_max_map_count-1)
86532 + return -ENOMEM;
86533 + } else
86534 +#endif
86535 +
86536 if (mm->map_count >= sysctl_max_map_count)
86537 return -ENOMEM;
86538
86539 @@ -2488,11 +2952,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
86540 * work. This now handles partial unmappings.
86541 * Jeremy Fitzhardinge <jeremy@goop.org>
86542 */
86543 +#ifdef CONFIG_PAX_SEGMEXEC
86544 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
86545 {
86546 + int ret = __do_munmap(mm, start, len);
86547 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
86548 + return ret;
86549 +
86550 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
86551 +}
86552 +
86553 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
86554 +#else
86555 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
86556 +#endif
86557 +{
86558 unsigned long end;
86559 struct vm_area_struct *vma, *prev, *last;
86560
86561 + /*
86562 + * mm->mmap_sem is required to protect against another thread
86563 + * changing the mappings in case we sleep.
86564 + */
86565 + verify_mm_writelocked(mm);
86566 +
86567 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
86568 return -EINVAL;
86569
86570 @@ -2567,6 +3050,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
86571 /* Fix up all other VM information */
86572 remove_vma_list(mm, vma);
86573
86574 + track_exec_limit(mm, start, end, 0UL);
86575 +
86576 return 0;
86577 }
86578
86579 @@ -2575,6 +3060,13 @@ int vm_munmap(unsigned long start, size_t len)
86580 int ret;
86581 struct mm_struct *mm = current->mm;
86582
86583 +
86584 +#ifdef CONFIG_PAX_SEGMEXEC
86585 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
86586 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
86587 + return -EINVAL;
86588 +#endif
86589 +
86590 down_write(&mm->mmap_sem);
86591 ret = do_munmap(mm, start, len);
86592 up_write(&mm->mmap_sem);
86593 @@ -2588,16 +3080,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
86594 return vm_munmap(addr, len);
86595 }
86596
86597 -static inline void verify_mm_writelocked(struct mm_struct *mm)
86598 -{
86599 -#ifdef CONFIG_DEBUG_VM
86600 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
86601 - WARN_ON(1);
86602 - up_read(&mm->mmap_sem);
86603 - }
86604 -#endif
86605 -}
86606 -
86607 /*
86608 * this is really a simplified "do_mmap". it only handles
86609 * anonymous maps. eventually we may be able to do some
86610 @@ -2611,6 +3093,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
86611 struct rb_node ** rb_link, * rb_parent;
86612 pgoff_t pgoff = addr >> PAGE_SHIFT;
86613 int error;
86614 + unsigned long charged;
86615
86616 len = PAGE_ALIGN(len);
86617 if (!len)
86618 @@ -2618,16 +3101,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
86619
86620 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
86621
86622 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
86623 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
86624 + flags &= ~VM_EXEC;
86625 +
86626 +#ifdef CONFIG_PAX_MPROTECT
86627 + if (mm->pax_flags & MF_PAX_MPROTECT)
86628 + flags &= ~VM_MAYEXEC;
86629 +#endif
86630 +
86631 + }
86632 +#endif
86633 +
86634 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
86635 if (error & ~PAGE_MASK)
86636 return error;
86637
86638 + charged = len >> PAGE_SHIFT;
86639 +
86640 /*
86641 * mlock MCL_FUTURE?
86642 */
86643 if (mm->def_flags & VM_LOCKED) {
86644 unsigned long locked, lock_limit;
86645 - locked = len >> PAGE_SHIFT;
86646 + locked = charged;
86647 locked += mm->locked_vm;
86648 lock_limit = rlimit(RLIMIT_MEMLOCK);
86649 lock_limit >>= PAGE_SHIFT;
86650 @@ -2644,21 +3141,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
86651 /*
86652 * Clear old maps. this also does some error checking for us
86653 */
86654 - munmap_back:
86655 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
86656 if (do_munmap(mm, addr, len))
86657 return -ENOMEM;
86658 - goto munmap_back;
86659 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
86660 }
86661
86662 /* Check against address space limits *after* clearing old maps... */
86663 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
86664 + if (!may_expand_vm(mm, charged))
86665 return -ENOMEM;
86666
86667 if (mm->map_count > sysctl_max_map_count)
86668 return -ENOMEM;
86669
86670 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
86671 + if (security_vm_enough_memory_mm(mm, charged))
86672 return -ENOMEM;
86673
86674 /* Can we just expand an old private anonymous mapping? */
86675 @@ -2672,7 +3168,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
86676 */
86677 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
86678 if (!vma) {
86679 - vm_unacct_memory(len >> PAGE_SHIFT);
86680 + vm_unacct_memory(charged);
86681 return -ENOMEM;
86682 }
86683
86684 @@ -2686,9 +3182,10 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
86685 vma_link(mm, vma, prev, rb_link, rb_parent);
86686 out:
86687 perf_event_mmap(vma);
86688 - mm->total_vm += len >> PAGE_SHIFT;
86689 + mm->total_vm += charged;
86690 if (flags & VM_LOCKED)
86691 - mm->locked_vm += (len >> PAGE_SHIFT);
86692 + mm->locked_vm += charged;
86693 + track_exec_limit(mm, addr, addr + len, flags);
86694 return addr;
86695 }
86696
86697 @@ -2750,6 +3247,7 @@ void exit_mmap(struct mm_struct *mm)
86698 while (vma) {
86699 if (vma->vm_flags & VM_ACCOUNT)
86700 nr_accounted += vma_pages(vma);
86701 + vma->vm_mirror = NULL;
86702 vma = remove_vma(vma);
86703 }
86704 vm_unacct_memory(nr_accounted);
86705 @@ -2766,6 +3264,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
86706 struct vm_area_struct *prev;
86707 struct rb_node **rb_link, *rb_parent;
86708
86709 +#ifdef CONFIG_PAX_SEGMEXEC
86710 + struct vm_area_struct *vma_m = NULL;
86711 +#endif
86712 +
86713 + if (security_mmap_addr(vma->vm_start))
86714 + return -EPERM;
86715 +
86716 /*
86717 * The vm_pgoff of a purely anonymous vma should be irrelevant
86718 * until its first write fault, when page's anon_vma and index
86719 @@ -2789,7 +3294,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
86720 security_vm_enough_memory_mm(mm, vma_pages(vma)))
86721 return -ENOMEM;
86722
86723 +#ifdef CONFIG_PAX_SEGMEXEC
86724 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
86725 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
86726 + if (!vma_m)
86727 + return -ENOMEM;
86728 + }
86729 +#endif
86730 +
86731 vma_link(mm, vma, prev, rb_link, rb_parent);
86732 +
86733 +#ifdef CONFIG_PAX_SEGMEXEC
86734 + if (vma_m)
86735 + BUG_ON(pax_mirror_vma(vma_m, vma));
86736 +#endif
86737 +
86738 return 0;
86739 }
86740
86741 @@ -2809,6 +3328,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
86742 struct mempolicy *pol;
86743 bool faulted_in_anon_vma = true;
86744
86745 + BUG_ON(vma->vm_mirror);
86746 +
86747 /*
86748 * If anonymous vma has not yet been faulted, update new pgoff
86749 * to match new location, to increase its chance of merging.
86750 @@ -2875,6 +3396,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
86751 return NULL;
86752 }
86753
86754 +#ifdef CONFIG_PAX_SEGMEXEC
86755 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
86756 +{
86757 + struct vm_area_struct *prev_m;
86758 + struct rb_node **rb_link_m, *rb_parent_m;
86759 + struct mempolicy *pol_m;
86760 +
86761 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
86762 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
86763 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
86764 + *vma_m = *vma;
86765 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
86766 + if (anon_vma_clone(vma_m, vma))
86767 + return -ENOMEM;
86768 + pol_m = vma_policy(vma_m);
86769 + mpol_get(pol_m);
86770 + vma_set_policy(vma_m, pol_m);
86771 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
86772 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
86773 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
86774 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
86775 + if (vma_m->vm_file)
86776 + get_file(vma_m->vm_file);
86777 + if (vma_m->vm_ops && vma_m->vm_ops->open)
86778 + vma_m->vm_ops->open(vma_m);
86779 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
86780 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
86781 + vma_m->vm_mirror = vma;
86782 + vma->vm_mirror = vma_m;
86783 + return 0;
86784 +}
86785 +#endif
86786 +
86787 /*
86788 * Return true if the calling process may expand its vm space by the passed
86789 * number of pages
86790 @@ -2886,6 +3440,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
86791
86792 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
86793
86794 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
86795 if (cur + npages > lim)
86796 return 0;
86797 return 1;
86798 @@ -2956,6 +3511,22 @@ int install_special_mapping(struct mm_struct *mm,
86799 vma->vm_start = addr;
86800 vma->vm_end = addr + len;
86801
86802 +#ifdef CONFIG_PAX_MPROTECT
86803 + if (mm->pax_flags & MF_PAX_MPROTECT) {
86804 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
86805 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
86806 + return -EPERM;
86807 + if (!(vm_flags & VM_EXEC))
86808 + vm_flags &= ~VM_MAYEXEC;
86809 +#else
86810 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
86811 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
86812 +#endif
86813 + else
86814 + vm_flags &= ~VM_MAYWRITE;
86815 + }
86816 +#endif
86817 +
86818 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND;
86819 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
86820
86821 diff --git a/mm/mprotect.c b/mm/mprotect.c
86822 index 94722a4..e661e29 100644
86823 --- a/mm/mprotect.c
86824 +++ b/mm/mprotect.c
86825 @@ -23,10 +23,18 @@
86826 #include <linux/mmu_notifier.h>
86827 #include <linux/migrate.h>
86828 #include <linux/perf_event.h>
86829 +#include <linux/sched/sysctl.h>
86830 +
86831 +#ifdef CONFIG_PAX_MPROTECT
86832 +#include <linux/elf.h>
86833 +#include <linux/binfmts.h>
86834 +#endif
86835 +
86836 #include <asm/uaccess.h>
86837 #include <asm/pgtable.h>
86838 #include <asm/cacheflush.h>
86839 #include <asm/tlbflush.h>
86840 +#include <asm/mmu_context.h>
86841
86842 #ifndef pgprot_modify
86843 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
86844 @@ -233,6 +241,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
86845 return pages;
86846 }
86847
86848 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
86849 +/* called while holding the mmap semaphor for writing except stack expansion */
86850 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
86851 +{
86852 + unsigned long oldlimit, newlimit = 0UL;
86853 +
86854 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
86855 + return;
86856 +
86857 + spin_lock(&mm->page_table_lock);
86858 + oldlimit = mm->context.user_cs_limit;
86859 + if ((prot & VM_EXEC) && oldlimit < end)
86860 + /* USER_CS limit moved up */
86861 + newlimit = end;
86862 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
86863 + /* USER_CS limit moved down */
86864 + newlimit = start;
86865 +
86866 + if (newlimit) {
86867 + mm->context.user_cs_limit = newlimit;
86868 +
86869 +#ifdef CONFIG_SMP
86870 + wmb();
86871 + cpus_clear(mm->context.cpu_user_cs_mask);
86872 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
86873 +#endif
86874 +
86875 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
86876 + }
86877 + spin_unlock(&mm->page_table_lock);
86878 + if (newlimit == end) {
86879 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
86880 +
86881 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
86882 + if (is_vm_hugetlb_page(vma))
86883 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
86884 + else
86885 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
86886 + }
86887 +}
86888 +#endif
86889 +
86890 int
86891 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
86892 unsigned long start, unsigned long end, unsigned long newflags)
86893 @@ -245,11 +295,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
86894 int error;
86895 int dirty_accountable = 0;
86896
86897 +#ifdef CONFIG_PAX_SEGMEXEC
86898 + struct vm_area_struct *vma_m = NULL;
86899 + unsigned long start_m, end_m;
86900 +
86901 + start_m = start + SEGMEXEC_TASK_SIZE;
86902 + end_m = end + SEGMEXEC_TASK_SIZE;
86903 +#endif
86904 +
86905 if (newflags == oldflags) {
86906 *pprev = vma;
86907 return 0;
86908 }
86909
86910 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
86911 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
86912 +
86913 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
86914 + return -ENOMEM;
86915 +
86916 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
86917 + return -ENOMEM;
86918 + }
86919 +
86920 /*
86921 * If we make a private mapping writable we increase our commit;
86922 * but (without finer accounting) cannot reduce our commit if we
86923 @@ -266,6 +334,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
86924 }
86925 }
86926
86927 +#ifdef CONFIG_PAX_SEGMEXEC
86928 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
86929 + if (start != vma->vm_start) {
86930 + error = split_vma(mm, vma, start, 1);
86931 + if (error)
86932 + goto fail;
86933 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
86934 + *pprev = (*pprev)->vm_next;
86935 + }
86936 +
86937 + if (end != vma->vm_end) {
86938 + error = split_vma(mm, vma, end, 0);
86939 + if (error)
86940 + goto fail;
86941 + }
86942 +
86943 + if (pax_find_mirror_vma(vma)) {
86944 + error = __do_munmap(mm, start_m, end_m - start_m);
86945 + if (error)
86946 + goto fail;
86947 + } else {
86948 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
86949 + if (!vma_m) {
86950 + error = -ENOMEM;
86951 + goto fail;
86952 + }
86953 + vma->vm_flags = newflags;
86954 + error = pax_mirror_vma(vma_m, vma);
86955 + if (error) {
86956 + vma->vm_flags = oldflags;
86957 + goto fail;
86958 + }
86959 + }
86960 + }
86961 +#endif
86962 +
86963 /*
86964 * First try to merge with previous and/or next vma.
86965 */
86966 @@ -296,9 +400,21 @@ success:
86967 * vm_flags and vm_page_prot are protected by the mmap_sem
86968 * held in write mode.
86969 */
86970 +
86971 +#ifdef CONFIG_PAX_SEGMEXEC
86972 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
86973 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
86974 +#endif
86975 +
86976 vma->vm_flags = newflags;
86977 +
86978 +#ifdef CONFIG_PAX_MPROTECT
86979 + if (mm->binfmt && mm->binfmt->handle_mprotect)
86980 + mm->binfmt->handle_mprotect(vma, newflags);
86981 +#endif
86982 +
86983 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
86984 - vm_get_page_prot(newflags));
86985 + vm_get_page_prot(vma->vm_flags));
86986
86987 if (vma_wants_writenotify(vma)) {
86988 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
86989 @@ -337,6 +453,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
86990 end = start + len;
86991 if (end <= start)
86992 return -ENOMEM;
86993 +
86994 +#ifdef CONFIG_PAX_SEGMEXEC
86995 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
86996 + if (end > SEGMEXEC_TASK_SIZE)
86997 + return -EINVAL;
86998 + } else
86999 +#endif
87000 +
87001 + if (end > TASK_SIZE)
87002 + return -EINVAL;
87003 +
87004 if (!arch_validate_prot(prot))
87005 return -EINVAL;
87006
87007 @@ -344,7 +471,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
87008 /*
87009 * Does the application expect PROT_READ to imply PROT_EXEC:
87010 */
87011 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
87012 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
87013 prot |= PROT_EXEC;
87014
87015 vm_flags = calc_vm_prot_bits(prot);
87016 @@ -376,6 +503,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
87017 if (start > vma->vm_start)
87018 prev = vma;
87019
87020 +#ifdef CONFIG_PAX_MPROTECT
87021 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
87022 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
87023 +#endif
87024 +
87025 for (nstart = start ; ; ) {
87026 unsigned long newflags;
87027
87028 @@ -386,6 +518,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
87029
87030 /* newflags >> 4 shift VM_MAY% in place of VM_% */
87031 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
87032 + if (prot & (PROT_WRITE | PROT_EXEC))
87033 + gr_log_rwxmprotect(vma);
87034 +
87035 + error = -EACCES;
87036 + goto out;
87037 + }
87038 +
87039 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
87040 error = -EACCES;
87041 goto out;
87042 }
87043 @@ -400,6 +540,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
87044 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
87045 if (error)
87046 goto out;
87047 +
87048 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
87049 +
87050 nstart = tmp;
87051
87052 if (nstart < prev->vm_end)
87053 diff --git a/mm/mremap.c b/mm/mremap.c
87054 index 463a257..c0c7a92 100644
87055 --- a/mm/mremap.c
87056 +++ b/mm/mremap.c
87057 @@ -126,6 +126,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
87058 continue;
87059 pte = ptep_get_and_clear(mm, old_addr, old_pte);
87060 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
87061 +
87062 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
87063 + if (!(__supported_pte_mask & _PAGE_NX) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
87064 + pte = pte_exprotect(pte);
87065 +#endif
87066 +
87067 set_pte_at(mm, new_addr, new_pte, pte);
87068 }
87069
87070 @@ -318,6 +324,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
87071 if (is_vm_hugetlb_page(vma))
87072 goto Einval;
87073
87074 +#ifdef CONFIG_PAX_SEGMEXEC
87075 + if (pax_find_mirror_vma(vma))
87076 + goto Einval;
87077 +#endif
87078 +
87079 /* We can't remap across vm area boundaries */
87080 if (old_len > vma->vm_end - addr)
87081 goto Efault;
87082 @@ -373,20 +384,25 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
87083 unsigned long ret = -EINVAL;
87084 unsigned long charged = 0;
87085 unsigned long map_flags;
87086 + unsigned long pax_task_size = TASK_SIZE;
87087
87088 if (new_addr & ~PAGE_MASK)
87089 goto out;
87090
87091 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
87092 +#ifdef CONFIG_PAX_SEGMEXEC
87093 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
87094 + pax_task_size = SEGMEXEC_TASK_SIZE;
87095 +#endif
87096 +
87097 + pax_task_size -= PAGE_SIZE;
87098 +
87099 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
87100 goto out;
87101
87102 /* Check if the location we're moving into overlaps the
87103 * old location at all, and fail if it does.
87104 */
87105 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
87106 - goto out;
87107 -
87108 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
87109 + if (addr + old_len > new_addr && new_addr + new_len > addr)
87110 goto out;
87111
87112 ret = do_munmap(mm, new_addr, new_len);
87113 @@ -455,6 +471,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
87114 unsigned long ret = -EINVAL;
87115 unsigned long charged = 0;
87116 bool locked = false;
87117 + unsigned long pax_task_size = TASK_SIZE;
87118
87119 down_write(&current->mm->mmap_sem);
87120
87121 @@ -475,6 +492,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
87122 if (!new_len)
87123 goto out;
87124
87125 +#ifdef CONFIG_PAX_SEGMEXEC
87126 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
87127 + pax_task_size = SEGMEXEC_TASK_SIZE;
87128 +#endif
87129 +
87130 + pax_task_size -= PAGE_SIZE;
87131 +
87132 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
87133 + old_len > pax_task_size || addr > pax_task_size-old_len)
87134 + goto out;
87135 +
87136 if (flags & MREMAP_FIXED) {
87137 if (flags & MREMAP_MAYMOVE)
87138 ret = mremap_to(addr, old_len, new_addr, new_len,
87139 @@ -524,6 +552,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
87140 new_addr = addr;
87141 }
87142 ret = addr;
87143 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
87144 goto out;
87145 }
87146 }
87147 @@ -547,7 +576,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
87148 goto out;
87149 }
87150
87151 + map_flags = vma->vm_flags;
87152 ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
87153 + if (!(ret & ~PAGE_MASK)) {
87154 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
87155 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
87156 + }
87157 }
87158 out:
87159 if (ret & ~PAGE_MASK)
87160 diff --git a/mm/nommu.c b/mm/nommu.c
87161 index 298884d..5f74980 100644
87162 --- a/mm/nommu.c
87163 +++ b/mm/nommu.c
87164 @@ -65,7 +65,6 @@ int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
87165 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
87166 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
87167 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
87168 -int heap_stack_gap = 0;
87169
87170 atomic_long_t mmap_pages_allocated;
87171
87172 @@ -842,15 +841,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
87173 EXPORT_SYMBOL(find_vma);
87174
87175 /*
87176 - * find a VMA
87177 - * - we don't extend stack VMAs under NOMMU conditions
87178 - */
87179 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
87180 -{
87181 - return find_vma(mm, addr);
87182 -}
87183 -
87184 -/*
87185 * expand a stack to a given address
87186 * - not supported under NOMMU conditions
87187 */
87188 @@ -1561,6 +1551,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
87189
87190 /* most fields are the same, copy all, and then fixup */
87191 *new = *vma;
87192 + INIT_LIST_HEAD(&new->anon_vma_chain);
87193 *region = *vma->vm_region;
87194 new->vm_region = region;
87195
87196 @@ -1995,8 +1986,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
87197 }
87198 EXPORT_SYMBOL(generic_file_remap_pages);
87199
87200 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
87201 - unsigned long addr, void *buf, int len, int write)
87202 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
87203 + unsigned long addr, void *buf, size_t len, int write)
87204 {
87205 struct vm_area_struct *vma;
87206
87207 @@ -2037,8 +2028,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
87208 *
87209 * The caller must hold a reference on @mm.
87210 */
87211 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
87212 - void *buf, int len, int write)
87213 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
87214 + void *buf, size_t len, int write)
87215 {
87216 return __access_remote_vm(NULL, mm, addr, buf, len, write);
87217 }
87218 @@ -2047,7 +2038,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
87219 * Access another process' address space.
87220 * - source/target buffer must be kernel space
87221 */
87222 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
87223 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
87224 {
87225 struct mm_struct *mm;
87226
87227 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
87228 index 4514ad7..92eaa1c 100644
87229 --- a/mm/page-writeback.c
87230 +++ b/mm/page-writeback.c
87231 @@ -659,7 +659,7 @@ unsigned long bdi_dirty_limit(struct backing_dev_info *bdi, unsigned long dirty)
87232 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
87233 * - the bdi dirty thresh drops quickly due to change of JBOD workload
87234 */
87235 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
87236 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
87237 unsigned long thresh,
87238 unsigned long bg_thresh,
87239 unsigned long dirty,
87240 @@ -1634,7 +1634,7 @@ ratelimit_handler(struct notifier_block *self, unsigned long action,
87241 }
87242 }
87243
87244 -static struct notifier_block __cpuinitdata ratelimit_nb = {
87245 +static struct notifier_block ratelimit_nb = {
87246 .notifier_call = ratelimit_handler,
87247 .next = NULL,
87248 };
87249 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
87250 index 2ee0fd3..6e2edfb 100644
87251 --- a/mm/page_alloc.c
87252 +++ b/mm/page_alloc.c
87253 @@ -60,6 +60,7 @@
87254 #include <linux/page-debug-flags.h>
87255 #include <linux/hugetlb.h>
87256 #include <linux/sched/rt.h>
87257 +#include <linux/random.h>
87258
87259 #include <asm/tlbflush.h>
87260 #include <asm/div64.h>
87261 @@ -345,7 +346,7 @@ out:
87262 * This usage means that zero-order pages may not be compound.
87263 */
87264
87265 -static void free_compound_page(struct page *page)
87266 +void free_compound_page(struct page *page)
87267 {
87268 __free_pages_ok(page, compound_order(page));
87269 }
87270 @@ -702,6 +703,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
87271 int i;
87272 int bad = 0;
87273
87274 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
87275 + unsigned long index = 1UL << order;
87276 +#endif
87277 +
87278 trace_mm_page_free(page, order);
87279 kmemcheck_free_shadow(page, order);
87280
87281 @@ -717,6 +722,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
87282 debug_check_no_obj_freed(page_address(page),
87283 PAGE_SIZE << order);
87284 }
87285 +
87286 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
87287 + for (; index; --index)
87288 + sanitize_highpage(page + index - 1);
87289 +#endif
87290 +
87291 arch_free_page(page, order);
87292 kernel_map_pages(page, 1 << order, 0);
87293
87294 @@ -739,6 +750,19 @@ static void __free_pages_ok(struct page *page, unsigned int order)
87295 local_irq_restore(flags);
87296 }
87297
87298 +#ifdef CONFIG_PAX_LATENT_ENTROPY
87299 +bool __meminitdata extra_latent_entropy;
87300 +
87301 +static int __init setup_pax_extra_latent_entropy(char *str)
87302 +{
87303 + extra_latent_entropy = true;
87304 + return 0;
87305 +}
87306 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
87307 +
87308 +volatile u64 latent_entropy;
87309 +#endif
87310 +
87311 /*
87312 * Read access to zone->managed_pages is safe because it's unsigned long,
87313 * but we still need to serialize writers. Currently all callers of
87314 @@ -761,6 +785,19 @@ void __meminit __free_pages_bootmem(struct page *page, unsigned int order)
87315 set_page_count(p, 0);
87316 }
87317
87318 +#ifdef CONFIG_PAX_LATENT_ENTROPY
87319 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
87320 + u64 hash = 0;
87321 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
87322 + const u64 *data = lowmem_page_address(page);
87323 +
87324 + for (index = 0; index < end; index++)
87325 + hash ^= hash + data[index];
87326 + latent_entropy ^= hash;
87327 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
87328 + }
87329 +#endif
87330 +
87331 page_zone(page)->managed_pages += 1 << order;
87332 set_page_refcounted(page);
87333 __free_pages(page, order);
87334 @@ -870,8 +907,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
87335 arch_alloc_page(page, order);
87336 kernel_map_pages(page, 1 << order, 1);
87337
87338 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
87339 if (gfp_flags & __GFP_ZERO)
87340 prep_zero_page(page, order, gfp_flags);
87341 +#endif
87342
87343 if (order && (gfp_flags & __GFP_COMP))
87344 prep_compound_page(page, order);
87345 diff --git a/mm/page_io.c b/mm/page_io.c
87346 index a8a3ef4..7260a60 100644
87347 --- a/mm/page_io.c
87348 +++ b/mm/page_io.c
87349 @@ -214,7 +214,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
87350 struct file *swap_file = sis->swap_file;
87351 struct address_space *mapping = swap_file->f_mapping;
87352 struct iovec iov = {
87353 - .iov_base = kmap(page),
87354 + .iov_base = (void __force_user *)kmap(page),
87355 .iov_len = PAGE_SIZE,
87356 };
87357
87358 diff --git a/mm/percpu.c b/mm/percpu.c
87359 index 8c8e08f..73a5cda 100644
87360 --- a/mm/percpu.c
87361 +++ b/mm/percpu.c
87362 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
87363 static unsigned int pcpu_high_unit_cpu __read_mostly;
87364
87365 /* the address of the first chunk which starts with the kernel static area */
87366 -void *pcpu_base_addr __read_mostly;
87367 +void *pcpu_base_addr __read_only;
87368 EXPORT_SYMBOL_GPL(pcpu_base_addr);
87369
87370 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
87371 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
87372 index fd26d04..0cea1b0 100644
87373 --- a/mm/process_vm_access.c
87374 +++ b/mm/process_vm_access.c
87375 @@ -13,6 +13,7 @@
87376 #include <linux/uio.h>
87377 #include <linux/sched.h>
87378 #include <linux/highmem.h>
87379 +#include <linux/security.h>
87380 #include <linux/ptrace.h>
87381 #include <linux/slab.h>
87382 #include <linux/syscalls.h>
87383 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
87384 size_t iov_l_curr_offset = 0;
87385 ssize_t iov_len;
87386
87387 + return -ENOSYS; // PaX: until properly audited
87388 +
87389 /*
87390 * Work out how many pages of struct pages we're going to need
87391 * when eventually calling get_user_pages
87392 */
87393 for (i = 0; i < riovcnt; i++) {
87394 iov_len = rvec[i].iov_len;
87395 - if (iov_len > 0) {
87396 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
87397 - + iov_len)
87398 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
87399 - / PAGE_SIZE + 1;
87400 - nr_pages = max(nr_pages, nr_pages_iov);
87401 - }
87402 + if (iov_len <= 0)
87403 + continue;
87404 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
87405 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
87406 + nr_pages = max(nr_pages, nr_pages_iov);
87407 }
87408
87409 if (nr_pages == 0)
87410 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
87411 goto free_proc_pages;
87412 }
87413
87414 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
87415 + rc = -EPERM;
87416 + goto put_task_struct;
87417 + }
87418 +
87419 mm = mm_access(task, PTRACE_MODE_ATTACH);
87420 if (!mm || IS_ERR(mm)) {
87421 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
87422 diff --git a/mm/rmap.c b/mm/rmap.c
87423 index 6280da8..b5c090e 100644
87424 --- a/mm/rmap.c
87425 +++ b/mm/rmap.c
87426 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
87427 struct anon_vma *anon_vma = vma->anon_vma;
87428 struct anon_vma_chain *avc;
87429
87430 +#ifdef CONFIG_PAX_SEGMEXEC
87431 + struct anon_vma_chain *avc_m = NULL;
87432 +#endif
87433 +
87434 might_sleep();
87435 if (unlikely(!anon_vma)) {
87436 struct mm_struct *mm = vma->vm_mm;
87437 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
87438 if (!avc)
87439 goto out_enomem;
87440
87441 +#ifdef CONFIG_PAX_SEGMEXEC
87442 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
87443 + if (!avc_m)
87444 + goto out_enomem_free_avc;
87445 +#endif
87446 +
87447 anon_vma = find_mergeable_anon_vma(vma);
87448 allocated = NULL;
87449 if (!anon_vma) {
87450 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
87451 /* page_table_lock to protect against threads */
87452 spin_lock(&mm->page_table_lock);
87453 if (likely(!vma->anon_vma)) {
87454 +
87455 +#ifdef CONFIG_PAX_SEGMEXEC
87456 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
87457 +
87458 + if (vma_m) {
87459 + BUG_ON(vma_m->anon_vma);
87460 + vma_m->anon_vma = anon_vma;
87461 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
87462 + avc_m = NULL;
87463 + }
87464 +#endif
87465 +
87466 vma->anon_vma = anon_vma;
87467 anon_vma_chain_link(vma, avc, anon_vma);
87468 allocated = NULL;
87469 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
87470
87471 if (unlikely(allocated))
87472 put_anon_vma(allocated);
87473 +
87474 +#ifdef CONFIG_PAX_SEGMEXEC
87475 + if (unlikely(avc_m))
87476 + anon_vma_chain_free(avc_m);
87477 +#endif
87478 +
87479 if (unlikely(avc))
87480 anon_vma_chain_free(avc);
87481 }
87482 return 0;
87483
87484 out_enomem_free_avc:
87485 +
87486 +#ifdef CONFIG_PAX_SEGMEXEC
87487 + if (avc_m)
87488 + anon_vma_chain_free(avc_m);
87489 +#endif
87490 +
87491 anon_vma_chain_free(avc);
87492 out_enomem:
87493 return -ENOMEM;
87494 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
87495 * Attach the anon_vmas from src to dst.
87496 * Returns 0 on success, -ENOMEM on failure.
87497 */
87498 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
87499 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
87500 {
87501 struct anon_vma_chain *avc, *pavc;
87502 struct anon_vma *root = NULL;
87503 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
87504 * the corresponding VMA in the parent process is attached to.
87505 * Returns 0 on success, non-zero on failure.
87506 */
87507 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
87508 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
87509 {
87510 struct anon_vma_chain *avc;
87511 struct anon_vma *anon_vma;
87512 @@ -373,8 +407,10 @@ static void anon_vma_ctor(void *data)
87513 void __init anon_vma_init(void)
87514 {
87515 anon_vma_cachep = kmem_cache_create("anon_vma", sizeof(struct anon_vma),
87516 - 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC, anon_vma_ctor);
87517 - anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain, SLAB_PANIC);
87518 + 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC|SLAB_NO_SANITIZE,
87519 + anon_vma_ctor);
87520 + anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain,
87521 + SLAB_PANIC|SLAB_NO_SANITIZE);
87522 }
87523
87524 /*
87525 diff --git a/mm/shmem.c b/mm/shmem.c
87526 index 5e6a842..b41916e 100644
87527 --- a/mm/shmem.c
87528 +++ b/mm/shmem.c
87529 @@ -33,7 +33,7 @@
87530 #include <linux/swap.h>
87531 #include <linux/aio.h>
87532
87533 -static struct vfsmount *shm_mnt;
87534 +struct vfsmount *shm_mnt;
87535
87536 #ifdef CONFIG_SHMEM
87537 /*
87538 @@ -77,7 +77,7 @@ static struct vfsmount *shm_mnt;
87539 #define BOGO_DIRENT_SIZE 20
87540
87541 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
87542 -#define SHORT_SYMLINK_LEN 128
87543 +#define SHORT_SYMLINK_LEN 64
87544
87545 /*
87546 * shmem_fallocate and shmem_writepage communicate via inode->i_private
87547 @@ -2203,6 +2203,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
87548 static int shmem_xattr_validate(const char *name)
87549 {
87550 struct { const char *prefix; size_t len; } arr[] = {
87551 +
87552 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
87553 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
87554 +#endif
87555 +
87556 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
87557 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
87558 };
87559 @@ -2258,6 +2263,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
87560 if (err)
87561 return err;
87562
87563 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
87564 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
87565 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
87566 + return -EOPNOTSUPP;
87567 + if (size > 8)
87568 + return -EINVAL;
87569 + }
87570 +#endif
87571 +
87572 return simple_xattr_set(&info->xattrs, name, value, size, flags);
87573 }
87574
87575 @@ -2570,8 +2584,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
87576 int err = -ENOMEM;
87577
87578 /* Round up to L1_CACHE_BYTES to resist false sharing */
87579 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
87580 - L1_CACHE_BYTES), GFP_KERNEL);
87581 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
87582 if (!sbinfo)
87583 return -ENOMEM;
87584
87585 diff --git a/mm/slab.c b/mm/slab.c
87586 index bd88411..2d46fd6 100644
87587 --- a/mm/slab.c
87588 +++ b/mm/slab.c
87589 @@ -366,10 +366,12 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
87590 if ((x)->max_freeable < i) \
87591 (x)->max_freeable = i; \
87592 } while (0)
87593 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
87594 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
87595 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
87596 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
87597 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
87598 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
87599 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
87600 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
87601 +#define STATS_INC_SANITIZED(x) atomic_inc_unchecked(&(x)->sanitized)
87602 +#define STATS_INC_NOT_SANITIZED(x) atomic_inc_unchecked(&(x)->not_sanitized)
87603 #else
87604 #define STATS_INC_ACTIVE(x) do { } while (0)
87605 #define STATS_DEC_ACTIVE(x) do { } while (0)
87606 @@ -386,6 +388,8 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
87607 #define STATS_INC_ALLOCMISS(x) do { } while (0)
87608 #define STATS_INC_FREEHIT(x) do { } while (0)
87609 #define STATS_INC_FREEMISS(x) do { } while (0)
87610 +#define STATS_INC_SANITIZED(x) do { } while (0)
87611 +#define STATS_INC_NOT_SANITIZED(x) do { } while (0)
87612 #endif
87613
87614 #if DEBUG
87615 @@ -477,7 +481,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
87616 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
87617 */
87618 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
87619 - const struct slab *slab, void *obj)
87620 + const struct slab *slab, const void *obj)
87621 {
87622 u32 offset = (obj - slab->s_mem);
87623 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
87624 @@ -1384,7 +1388,7 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
87625 return notifier_from_errno(err);
87626 }
87627
87628 -static struct notifier_block __cpuinitdata cpucache_notifier = {
87629 +static struct notifier_block cpucache_notifier = {
87630 &cpuup_callback, NULL, 0
87631 };
87632
87633 @@ -1565,12 +1569,12 @@ void __init kmem_cache_init(void)
87634 */
87635
87636 kmalloc_caches[INDEX_AC] = create_kmalloc_cache("kmalloc-ac",
87637 - kmalloc_size(INDEX_AC), ARCH_KMALLOC_FLAGS);
87638 + kmalloc_size(INDEX_AC), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
87639
87640 if (INDEX_AC != INDEX_NODE)
87641 kmalloc_caches[INDEX_NODE] =
87642 create_kmalloc_cache("kmalloc-node",
87643 - kmalloc_size(INDEX_NODE), ARCH_KMALLOC_FLAGS);
87644 + kmalloc_size(INDEX_NODE), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
87645
87646 slab_early_init = 0;
87647
87648 @@ -3583,6 +3587,21 @@ static inline void __cache_free(struct kmem_cache *cachep, void *objp,
87649 struct array_cache *ac = cpu_cache_get(cachep);
87650
87651 check_irq_off();
87652 +
87653 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
87654 + if (pax_sanitize_slab) {
87655 + if (!(cachep->flags & (SLAB_POISON | SLAB_NO_SANITIZE))) {
87656 + memset(objp, PAX_MEMORY_SANITIZE_VALUE, cachep->object_size);
87657 +
87658 + if (cachep->ctor)
87659 + cachep->ctor(objp);
87660 +
87661 + STATS_INC_SANITIZED(cachep);
87662 + } else
87663 + STATS_INC_NOT_SANITIZED(cachep);
87664 + }
87665 +#endif
87666 +
87667 kmemleak_free_recursive(objp, cachep->flags);
87668 objp = cache_free_debugcheck(cachep, objp, caller);
87669
87670 @@ -3800,6 +3819,7 @@ void kfree(const void *objp)
87671
87672 if (unlikely(ZERO_OR_NULL_PTR(objp)))
87673 return;
87674 + VM_BUG_ON(!virt_addr_valid(objp));
87675 local_irq_save(flags);
87676 kfree_debugcheck(objp);
87677 c = virt_to_cache(objp);
87678 @@ -4241,14 +4261,22 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
87679 }
87680 /* cpu stats */
87681 {
87682 - unsigned long allochit = atomic_read(&cachep->allochit);
87683 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
87684 - unsigned long freehit = atomic_read(&cachep->freehit);
87685 - unsigned long freemiss = atomic_read(&cachep->freemiss);
87686 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
87687 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
87688 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
87689 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
87690
87691 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
87692 allochit, allocmiss, freehit, freemiss);
87693 }
87694 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
87695 + {
87696 + unsigned long sanitized = atomic_read_unchecked(&cachep->sanitized);
87697 + unsigned long not_sanitized = atomic_read_unchecked(&cachep->not_sanitized);
87698 +
87699 + seq_printf(m, " : pax %6lu %6lu", sanitized, not_sanitized);
87700 + }
87701 +#endif
87702 #endif
87703 }
87704
87705 @@ -4476,13 +4504,71 @@ static const struct file_operations proc_slabstats_operations = {
87706 static int __init slab_proc_init(void)
87707 {
87708 #ifdef CONFIG_DEBUG_SLAB_LEAK
87709 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
87710 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
87711 #endif
87712 return 0;
87713 }
87714 module_init(slab_proc_init);
87715 #endif
87716
87717 +bool is_usercopy_object(const void *ptr)
87718 +{
87719 + struct page *page;
87720 + struct kmem_cache *cachep;
87721 +
87722 + if (ZERO_OR_NULL_PTR(ptr))
87723 + return false;
87724 +
87725 + if (!slab_is_available())
87726 + return false;
87727 +
87728 + if (!virt_addr_valid(ptr))
87729 + return false;
87730 +
87731 + page = virt_to_head_page(ptr);
87732 +
87733 + if (!PageSlab(page))
87734 + return false;
87735 +
87736 + cachep = page->slab_cache;
87737 + return cachep->flags & SLAB_USERCOPY;
87738 +}
87739 +
87740 +#ifdef CONFIG_PAX_USERCOPY
87741 +const char *check_heap_object(const void *ptr, unsigned long n)
87742 +{
87743 + struct page *page;
87744 + struct kmem_cache *cachep;
87745 + struct slab *slabp;
87746 + unsigned int objnr;
87747 + unsigned long offset;
87748 +
87749 + if (ZERO_OR_NULL_PTR(ptr))
87750 + return "<null>";
87751 +
87752 + if (!virt_addr_valid(ptr))
87753 + return NULL;
87754 +
87755 + page = virt_to_head_page(ptr);
87756 +
87757 + if (!PageSlab(page))
87758 + return NULL;
87759 +
87760 + cachep = page->slab_cache;
87761 + if (!(cachep->flags & SLAB_USERCOPY))
87762 + return cachep->name;
87763 +
87764 + slabp = page->slab_page;
87765 + objnr = obj_to_index(cachep, slabp, ptr);
87766 + BUG_ON(objnr >= cachep->num);
87767 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
87768 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
87769 + return NULL;
87770 +
87771 + return cachep->name;
87772 +}
87773 +#endif
87774 +
87775 /**
87776 * ksize - get the actual amount of memory allocated for a given object
87777 * @objp: Pointer to the object
87778 diff --git a/mm/slab.h b/mm/slab.h
87779 index f96b49e..db1d204 100644
87780 --- a/mm/slab.h
87781 +++ b/mm/slab.h
87782 @@ -32,6 +32,15 @@ extern struct list_head slab_caches;
87783 /* The slab cache that manages slab cache information */
87784 extern struct kmem_cache *kmem_cache;
87785
87786 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
87787 +#ifdef CONFIG_X86_64
87788 +#define PAX_MEMORY_SANITIZE_VALUE '\xfe'
87789 +#else
87790 +#define PAX_MEMORY_SANITIZE_VALUE '\xff'
87791 +#endif
87792 +extern bool pax_sanitize_slab;
87793 +#endif
87794 +
87795 unsigned long calculate_alignment(unsigned long flags,
87796 unsigned long align, unsigned long size);
87797
87798 @@ -67,7 +76,8 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
87799
87800 /* Legal flag mask for kmem_cache_create(), for various configurations */
87801 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
87802 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
87803 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | \
87804 + SLAB_USERCOPY | SLAB_NO_SANITIZE)
87805
87806 #if defined(CONFIG_DEBUG_SLAB)
87807 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
87808 @@ -229,6 +239,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
87809 return s;
87810
87811 page = virt_to_head_page(x);
87812 +
87813 + BUG_ON(!PageSlab(page));
87814 +
87815 cachep = page->slab_cache;
87816 if (slab_equal_or_root(cachep, s))
87817 return cachep;
87818 diff --git a/mm/slab_common.c b/mm/slab_common.c
87819 index 2d41450..4efe6ee 100644
87820 --- a/mm/slab_common.c
87821 +++ b/mm/slab_common.c
87822 @@ -22,11 +22,22 @@
87823
87824 #include "slab.h"
87825
87826 -enum slab_state slab_state;
87827 +enum slab_state slab_state __read_only;
87828 LIST_HEAD(slab_caches);
87829 DEFINE_MUTEX(slab_mutex);
87830 struct kmem_cache *kmem_cache;
87831
87832 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
87833 +bool pax_sanitize_slab __read_only = true;
87834 +static int __init pax_sanitize_slab_setup(char *str)
87835 +{
87836 + pax_sanitize_slab = !!simple_strtol(str, NULL, 0);
87837 + printk("%sabled PaX slab sanitization\n", pax_sanitize_slab ? "En" : "Dis");
87838 + return 1;
87839 +}
87840 +__setup("pax_sanitize_slab=", pax_sanitize_slab_setup);
87841 +#endif
87842 +
87843 #ifdef CONFIG_DEBUG_VM
87844 static int kmem_cache_sanity_check(struct mem_cgroup *memcg, const char *name,
87845 size_t size)
87846 @@ -209,7 +220,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
87847
87848 err = __kmem_cache_create(s, flags);
87849 if (!err) {
87850 - s->refcount = 1;
87851 + atomic_set(&s->refcount, 1);
87852 list_add(&s->list, &slab_caches);
87853 memcg_cache_list_add(memcg, s);
87854 } else {
87855 @@ -255,8 +266,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
87856
87857 get_online_cpus();
87858 mutex_lock(&slab_mutex);
87859 - s->refcount--;
87860 - if (!s->refcount) {
87861 + if (atomic_dec_and_test(&s->refcount)) {
87862 list_del(&s->list);
87863
87864 if (!__kmem_cache_shutdown(s)) {
87865 @@ -302,7 +312,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
87866 panic("Creation of kmalloc slab %s size=%zu failed. Reason %d\n",
87867 name, size, err);
87868
87869 - s->refcount = -1; /* Exempt from merging for now */
87870 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
87871 }
87872
87873 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
87874 @@ -315,7 +325,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
87875
87876 create_boot_cache(s, name, size, flags);
87877 list_add(&s->list, &slab_caches);
87878 - s->refcount = 1;
87879 + atomic_set(&s->refcount, 1);
87880 return s;
87881 }
87882
87883 @@ -327,6 +337,11 @@ struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
87884 EXPORT_SYMBOL(kmalloc_dma_caches);
87885 #endif
87886
87887 +#ifdef CONFIG_PAX_USERCOPY_SLABS
87888 +struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
87889 +EXPORT_SYMBOL(kmalloc_usercopy_caches);
87890 +#endif
87891 +
87892 /*
87893 * Conversion table for small slabs sizes / 8 to the index in the
87894 * kmalloc array. This is necessary for slabs < 192 since we have non power
87895 @@ -391,6 +406,13 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags)
87896 return kmalloc_dma_caches[index];
87897
87898 #endif
87899 +
87900 +#ifdef CONFIG_PAX_USERCOPY_SLABS
87901 + if (unlikely((flags & GFP_USERCOPY)))
87902 + return kmalloc_usercopy_caches[index];
87903 +
87904 +#endif
87905 +
87906 return kmalloc_caches[index];
87907 }
87908
87909 @@ -447,7 +469,7 @@ void __init create_kmalloc_caches(unsigned long flags)
87910 for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
87911 if (!kmalloc_caches[i]) {
87912 kmalloc_caches[i] = create_kmalloc_cache(NULL,
87913 - 1 << i, flags);
87914 + 1 << i, SLAB_USERCOPY | flags);
87915 }
87916
87917 /*
87918 @@ -456,10 +478,10 @@ void __init create_kmalloc_caches(unsigned long flags)
87919 * earlier power of two caches
87920 */
87921 if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[1] && i == 6)
87922 - kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, flags);
87923 + kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, SLAB_USERCOPY | flags);
87924
87925 if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[2] && i == 7)
87926 - kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, flags);
87927 + kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, SLAB_USERCOPY | flags);
87928 }
87929
87930 /* Kmalloc array is now usable */
87931 @@ -492,6 +514,23 @@ void __init create_kmalloc_caches(unsigned long flags)
87932 }
87933 }
87934 #endif
87935 +
87936 +#ifdef CONFIG_PAX_USERCOPY_SLABS
87937 + for (i = 0; i <= KMALLOC_SHIFT_HIGH; i++) {
87938 + struct kmem_cache *s = kmalloc_caches[i];
87939 +
87940 + if (s) {
87941 + int size = kmalloc_size(i);
87942 + char *n = kasprintf(GFP_NOWAIT,
87943 + "usercopy-kmalloc-%d", size);
87944 +
87945 + BUG_ON(!n);
87946 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(n,
87947 + size, SLAB_USERCOPY | flags);
87948 + }
87949 + }
87950 +#endif
87951 +
87952 }
87953 #endif /* !CONFIG_SLOB */
87954
87955 @@ -516,6 +555,9 @@ void print_slabinfo_header(struct seq_file *m)
87956 seq_puts(m, " : globalstat <listallocs> <maxobjs> <grown> <reaped> "
87957 "<error> <maxfreeable> <nodeallocs> <remotefrees> <alienoverflow>");
87958 seq_puts(m, " : cpustat <allochit> <allocmiss> <freehit> <freemiss>");
87959 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
87960 + seq_puts(m, " : pax <sanitized> <not_sanitized>");
87961 +#endif
87962 #endif
87963 seq_putc(m, '\n');
87964 }
87965 diff --git a/mm/slob.c b/mm/slob.c
87966 index eeed4a0..bb0e9ab 100644
87967 --- a/mm/slob.c
87968 +++ b/mm/slob.c
87969 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
87970 /*
87971 * Return the size of a slob block.
87972 */
87973 -static slobidx_t slob_units(slob_t *s)
87974 +static slobidx_t slob_units(const slob_t *s)
87975 {
87976 if (s->units > 0)
87977 return s->units;
87978 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
87979 /*
87980 * Return the next free slob block pointer after this one.
87981 */
87982 -static slob_t *slob_next(slob_t *s)
87983 +static slob_t *slob_next(const slob_t *s)
87984 {
87985 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
87986 slobidx_t next;
87987 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
87988 /*
87989 * Returns true if s is the last free block in its page.
87990 */
87991 -static int slob_last(slob_t *s)
87992 +static int slob_last(const slob_t *s)
87993 {
87994 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
87995 }
87996
87997 -static void *slob_new_pages(gfp_t gfp, int order, int node)
87998 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
87999 {
88000 - void *page;
88001 + struct page *page;
88002
88003 #ifdef CONFIG_NUMA
88004 if (node != NUMA_NO_NODE)
88005 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
88006 if (!page)
88007 return NULL;
88008
88009 - return page_address(page);
88010 + __SetPageSlab(page);
88011 + return page;
88012 }
88013
88014 -static void slob_free_pages(void *b, int order)
88015 +static void slob_free_pages(struct page *sp, int order)
88016 {
88017 if (current->reclaim_state)
88018 current->reclaim_state->reclaimed_slab += 1 << order;
88019 - free_pages((unsigned long)b, order);
88020 + __ClearPageSlab(sp);
88021 + page_mapcount_reset(sp);
88022 + sp->private = 0;
88023 + __free_pages(sp, order);
88024 }
88025
88026 /*
88027 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
88028
88029 /* Not enough space: must allocate a new page */
88030 if (!b) {
88031 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
88032 - if (!b)
88033 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
88034 + if (!sp)
88035 return NULL;
88036 - sp = virt_to_page(b);
88037 - __SetPageSlab(sp);
88038 + b = page_address(sp);
88039
88040 spin_lock_irqsave(&slob_lock, flags);
88041 sp->units = SLOB_UNITS(PAGE_SIZE);
88042 sp->freelist = b;
88043 + sp->private = 0;
88044 INIT_LIST_HEAD(&sp->list);
88045 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
88046 set_slob_page_free(sp, slob_list);
88047 @@ -359,12 +363,15 @@ static void slob_free(void *block, int size)
88048 if (slob_page_free(sp))
88049 clear_slob_page_free(sp);
88050 spin_unlock_irqrestore(&slob_lock, flags);
88051 - __ClearPageSlab(sp);
88052 - page_mapcount_reset(sp);
88053 - slob_free_pages(b, 0);
88054 + slob_free_pages(sp, 0);
88055 return;
88056 }
88057
88058 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
88059 + if (pax_sanitize_slab)
88060 + memset(block, PAX_MEMORY_SANITIZE_VALUE, size);
88061 +#endif
88062 +
88063 if (!slob_page_free(sp)) {
88064 /* This slob page is about to become partially free. Easy! */
88065 sp->units = units;
88066 @@ -424,11 +431,10 @@ out:
88067 */
88068
88069 static __always_inline void *
88070 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
88071 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
88072 {
88073 - unsigned int *m;
88074 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
88075 - void *ret;
88076 + slob_t *m;
88077 + void *ret = NULL;
88078
88079 gfp &= gfp_allowed_mask;
88080
88081 @@ -442,23 +448,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
88082
88083 if (!m)
88084 return NULL;
88085 - *m = size;
88086 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
88087 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
88088 + m[0].units = size;
88089 + m[1].units = align;
88090 ret = (void *)m + align;
88091
88092 trace_kmalloc_node(caller, ret,
88093 size, size + align, gfp, node);
88094 } else {
88095 unsigned int order = get_order(size);
88096 + struct page *page;
88097
88098 if (likely(order))
88099 gfp |= __GFP_COMP;
88100 - ret = slob_new_pages(gfp, order, node);
88101 + page = slob_new_pages(gfp, order, node);
88102 + if (page) {
88103 + ret = page_address(page);
88104 + page->private = size;
88105 + }
88106
88107 trace_kmalloc_node(caller, ret,
88108 size, PAGE_SIZE << order, gfp, node);
88109 }
88110
88111 - kmemleak_alloc(ret, size, 1, gfp);
88112 + return ret;
88113 +}
88114 +
88115 +static __always_inline void *
88116 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
88117 +{
88118 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
88119 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
88120 +
88121 + if (!ZERO_OR_NULL_PTR(ret))
88122 + kmemleak_alloc(ret, size, 1, gfp);
88123 return ret;
88124 }
88125
88126 @@ -493,34 +517,112 @@ void kfree(const void *block)
88127 return;
88128 kmemleak_free(block);
88129
88130 + VM_BUG_ON(!virt_addr_valid(block));
88131 sp = virt_to_page(block);
88132 - if (PageSlab(sp)) {
88133 + VM_BUG_ON(!PageSlab(sp));
88134 + if (!sp->private) {
88135 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
88136 - unsigned int *m = (unsigned int *)(block - align);
88137 - slob_free(m, *m + align);
88138 - } else
88139 + slob_t *m = (slob_t *)(block - align);
88140 + slob_free(m, m[0].units + align);
88141 + } else {
88142 + __ClearPageSlab(sp);
88143 + page_mapcount_reset(sp);
88144 + sp->private = 0;
88145 __free_pages(sp, compound_order(sp));
88146 + }
88147 }
88148 EXPORT_SYMBOL(kfree);
88149
88150 +bool is_usercopy_object(const void *ptr)
88151 +{
88152 + if (!slab_is_available())
88153 + return false;
88154 +
88155 + // PAX: TODO
88156 +
88157 + return false;
88158 +}
88159 +
88160 +#ifdef CONFIG_PAX_USERCOPY
88161 +const char *check_heap_object(const void *ptr, unsigned long n)
88162 +{
88163 + struct page *page;
88164 + const slob_t *free;
88165 + const void *base;
88166 + unsigned long flags;
88167 +
88168 + if (ZERO_OR_NULL_PTR(ptr))
88169 + return "<null>";
88170 +
88171 + if (!virt_addr_valid(ptr))
88172 + return NULL;
88173 +
88174 + page = virt_to_head_page(ptr);
88175 + if (!PageSlab(page))
88176 + return NULL;
88177 +
88178 + if (page->private) {
88179 + base = page;
88180 + if (base <= ptr && n <= page->private - (ptr - base))
88181 + return NULL;
88182 + return "<slob>";
88183 + }
88184 +
88185 + /* some tricky double walking to find the chunk */
88186 + spin_lock_irqsave(&slob_lock, flags);
88187 + base = (void *)((unsigned long)ptr & PAGE_MASK);
88188 + free = page->freelist;
88189 +
88190 + while (!slob_last(free) && (void *)free <= ptr) {
88191 + base = free + slob_units(free);
88192 + free = slob_next(free);
88193 + }
88194 +
88195 + while (base < (void *)free) {
88196 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
88197 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
88198 + int offset;
88199 +
88200 + if (ptr < base + align)
88201 + break;
88202 +
88203 + offset = ptr - base - align;
88204 + if (offset >= m) {
88205 + base += size;
88206 + continue;
88207 + }
88208 +
88209 + if (n > m - offset)
88210 + break;
88211 +
88212 + spin_unlock_irqrestore(&slob_lock, flags);
88213 + return NULL;
88214 + }
88215 +
88216 + spin_unlock_irqrestore(&slob_lock, flags);
88217 + return "<slob>";
88218 +}
88219 +#endif
88220 +
88221 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
88222 size_t ksize(const void *block)
88223 {
88224 struct page *sp;
88225 int align;
88226 - unsigned int *m;
88227 + slob_t *m;
88228
88229 BUG_ON(!block);
88230 if (unlikely(block == ZERO_SIZE_PTR))
88231 return 0;
88232
88233 sp = virt_to_page(block);
88234 - if (unlikely(!PageSlab(sp)))
88235 - return PAGE_SIZE << compound_order(sp);
88236 + VM_BUG_ON(!PageSlab(sp));
88237 + if (sp->private)
88238 + return sp->private;
88239
88240 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
88241 - m = (unsigned int *)(block - align);
88242 - return SLOB_UNITS(*m) * SLOB_UNIT;
88243 + m = (slob_t *)(block - align);
88244 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
88245 }
88246 EXPORT_SYMBOL(ksize);
88247
88248 @@ -536,23 +638,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
88249
88250 void *kmem_cache_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
88251 {
88252 - void *b;
88253 + void *b = NULL;
88254
88255 flags &= gfp_allowed_mask;
88256
88257 lockdep_trace_alloc(flags);
88258
88259 +#ifdef CONFIG_PAX_USERCOPY_SLABS
88260 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
88261 +#else
88262 if (c->size < PAGE_SIZE) {
88263 b = slob_alloc(c->size, flags, c->align, node);
88264 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
88265 SLOB_UNITS(c->size) * SLOB_UNIT,
88266 flags, node);
88267 } else {
88268 - b = slob_new_pages(flags, get_order(c->size), node);
88269 + struct page *sp;
88270 +
88271 + sp = slob_new_pages(flags, get_order(c->size), node);
88272 + if (sp) {
88273 + b = page_address(sp);
88274 + sp->private = c->size;
88275 + }
88276 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
88277 PAGE_SIZE << get_order(c->size),
88278 flags, node);
88279 }
88280 +#endif
88281
88282 if (c->ctor)
88283 c->ctor(b);
88284 @@ -564,10 +676,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
88285
88286 static void __kmem_cache_free(void *b, int size)
88287 {
88288 - if (size < PAGE_SIZE)
88289 + struct page *sp;
88290 +
88291 + sp = virt_to_page(b);
88292 + BUG_ON(!PageSlab(sp));
88293 + if (!sp->private)
88294 slob_free(b, size);
88295 else
88296 - slob_free_pages(b, get_order(size));
88297 + slob_free_pages(sp, get_order(size));
88298 }
88299
88300 static void kmem_rcu_free(struct rcu_head *head)
88301 @@ -580,17 +696,31 @@ static void kmem_rcu_free(struct rcu_head *head)
88302
88303 void kmem_cache_free(struct kmem_cache *c, void *b)
88304 {
88305 + int size = c->size;
88306 +
88307 +#ifdef CONFIG_PAX_USERCOPY_SLABS
88308 + if (size + c->align < PAGE_SIZE) {
88309 + size += c->align;
88310 + b -= c->align;
88311 + }
88312 +#endif
88313 +
88314 kmemleak_free_recursive(b, c->flags);
88315 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
88316 struct slob_rcu *slob_rcu;
88317 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
88318 - slob_rcu->size = c->size;
88319 + slob_rcu = b + (size - sizeof(struct slob_rcu));
88320 + slob_rcu->size = size;
88321 call_rcu(&slob_rcu->head, kmem_rcu_free);
88322 } else {
88323 - __kmem_cache_free(b, c->size);
88324 + __kmem_cache_free(b, size);
88325 }
88326
88327 +#ifdef CONFIG_PAX_USERCOPY_SLABS
88328 + trace_kfree(_RET_IP_, b);
88329 +#else
88330 trace_kmem_cache_free(_RET_IP_, b);
88331 +#endif
88332 +
88333 }
88334 EXPORT_SYMBOL(kmem_cache_free);
88335
88336 diff --git a/mm/slub.c b/mm/slub.c
88337 index 57707f0..7857bd3 100644
88338 --- a/mm/slub.c
88339 +++ b/mm/slub.c
88340 @@ -198,7 +198,7 @@ struct track {
88341
88342 enum track_item { TRACK_ALLOC, TRACK_FREE };
88343
88344 -#ifdef CONFIG_SYSFS
88345 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
88346 static int sysfs_slab_add(struct kmem_cache *);
88347 static int sysfs_slab_alias(struct kmem_cache *, const char *);
88348 static void sysfs_slab_remove(struct kmem_cache *);
88349 @@ -519,7 +519,7 @@ static void print_track(const char *s, struct track *t)
88350 if (!t->addr)
88351 return;
88352
88353 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
88354 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
88355 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
88356 #ifdef CONFIG_STACKTRACE
88357 {
88358 @@ -2594,6 +2594,14 @@ static __always_inline void slab_free(struct kmem_cache *s,
88359
88360 slab_free_hook(s, x);
88361
88362 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
88363 + if (pax_sanitize_slab && !(s->flags & SLAB_NO_SANITIZE)) {
88364 + memset(x, PAX_MEMORY_SANITIZE_VALUE, s->object_size);
88365 + if (s->ctor)
88366 + s->ctor(x);
88367 + }
88368 +#endif
88369 +
88370 redo:
88371 /*
88372 * Determine the currently cpus per cpu slab.
88373 @@ -2661,7 +2669,7 @@ static int slub_min_objects;
88374 * Merge control. If this is set then no merging of slab caches will occur.
88375 * (Could be removed. This was introduced to pacify the merge skeptics.)
88376 */
88377 -static int slub_nomerge;
88378 +static int slub_nomerge = 1;
88379
88380 /*
88381 * Calculate the order of allocation given an slab object size.
88382 @@ -2938,6 +2946,9 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order)
88383 s->inuse = size;
88384
88385 if (((flags & (SLAB_DESTROY_BY_RCU | SLAB_POISON)) ||
88386 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
88387 + (pax_sanitize_slab && !(flags & SLAB_NO_SANITIZE)) ||
88388 +#endif
88389 s->ctor)) {
88390 /*
88391 * Relocate free pointer after the object if it is not
88392 @@ -3283,6 +3294,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
88393 EXPORT_SYMBOL(__kmalloc_node);
88394 #endif
88395
88396 +bool is_usercopy_object(const void *ptr)
88397 +{
88398 + struct page *page;
88399 + struct kmem_cache *s;
88400 +
88401 + if (ZERO_OR_NULL_PTR(ptr))
88402 + return false;
88403 +
88404 + if (!slab_is_available())
88405 + return false;
88406 +
88407 + if (!virt_addr_valid(ptr))
88408 + return false;
88409 +
88410 + page = virt_to_head_page(ptr);
88411 +
88412 + if (!PageSlab(page))
88413 + return false;
88414 +
88415 + s = page->slab_cache;
88416 + return s->flags & SLAB_USERCOPY;
88417 +}
88418 +
88419 +#ifdef CONFIG_PAX_USERCOPY
88420 +const char *check_heap_object(const void *ptr, unsigned long n)
88421 +{
88422 + struct page *page;
88423 + struct kmem_cache *s;
88424 + unsigned long offset;
88425 +
88426 + if (ZERO_OR_NULL_PTR(ptr))
88427 + return "<null>";
88428 +
88429 + if (!virt_addr_valid(ptr))
88430 + return NULL;
88431 +
88432 + page = virt_to_head_page(ptr);
88433 +
88434 + if (!PageSlab(page))
88435 + return NULL;
88436 +
88437 + s = page->slab_cache;
88438 + if (!(s->flags & SLAB_USERCOPY))
88439 + return s->name;
88440 +
88441 + offset = (ptr - page_address(page)) % s->size;
88442 + if (offset <= s->object_size && n <= s->object_size - offset)
88443 + return NULL;
88444 +
88445 + return s->name;
88446 +}
88447 +#endif
88448 +
88449 size_t ksize(const void *object)
88450 {
88451 struct page *page;
88452 @@ -3347,6 +3411,7 @@ void kfree(const void *x)
88453 if (unlikely(ZERO_OR_NULL_PTR(x)))
88454 return;
88455
88456 + VM_BUG_ON(!virt_addr_valid(x));
88457 page = virt_to_head_page(x);
88458 if (unlikely(!PageSlab(page))) {
88459 BUG_ON(!PageCompound(page));
88460 @@ -3652,7 +3717,7 @@ static int slab_unmergeable(struct kmem_cache *s)
88461 /*
88462 * We may have set a slab to be unmergeable during bootstrap.
88463 */
88464 - if (s->refcount < 0)
88465 + if (atomic_read(&s->refcount) < 0)
88466 return 1;
88467
88468 return 0;
88469 @@ -3710,7 +3775,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
88470
88471 s = find_mergeable(memcg, size, align, flags, name, ctor);
88472 if (s) {
88473 - s->refcount++;
88474 + atomic_inc(&s->refcount);
88475 /*
88476 * Adjust the object sizes so that we clear
88477 * the complete object on kzalloc.
88478 @@ -3719,7 +3784,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
88479 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
88480
88481 if (sysfs_slab_alias(s, name)) {
88482 - s->refcount--;
88483 + atomic_dec(&s->refcount);
88484 s = NULL;
88485 }
88486 }
88487 @@ -3781,7 +3846,7 @@ static int __cpuinit slab_cpuup_callback(struct notifier_block *nfb,
88488 return NOTIFY_OK;
88489 }
88490
88491 -static struct notifier_block __cpuinitdata slab_notifier = {
88492 +static struct notifier_block slab_notifier = {
88493 .notifier_call = slab_cpuup_callback
88494 };
88495
88496 @@ -3839,7 +3904,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
88497 }
88498 #endif
88499
88500 -#ifdef CONFIG_SYSFS
88501 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
88502 static int count_inuse(struct page *page)
88503 {
88504 return page->inuse;
88505 @@ -4226,12 +4291,12 @@ static void resiliency_test(void)
88506 validate_slab_cache(kmalloc_caches[9]);
88507 }
88508 #else
88509 -#ifdef CONFIG_SYSFS
88510 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
88511 static void resiliency_test(void) {};
88512 #endif
88513 #endif
88514
88515 -#ifdef CONFIG_SYSFS
88516 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
88517 enum slab_stat_type {
88518 SL_ALL, /* All slabs */
88519 SL_PARTIAL, /* Only partially allocated slabs */
88520 @@ -4475,7 +4540,7 @@ SLAB_ATTR_RO(ctor);
88521
88522 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
88523 {
88524 - return sprintf(buf, "%d\n", s->refcount - 1);
88525 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
88526 }
88527 SLAB_ATTR_RO(aliases);
88528
88529 @@ -4563,6 +4628,14 @@ static ssize_t cache_dma_show(struct kmem_cache *s, char *buf)
88530 SLAB_ATTR_RO(cache_dma);
88531 #endif
88532
88533 +#ifdef CONFIG_PAX_USERCOPY_SLABS
88534 +static ssize_t usercopy_show(struct kmem_cache *s, char *buf)
88535 +{
88536 + return sprintf(buf, "%d\n", !!(s->flags & SLAB_USERCOPY));
88537 +}
88538 +SLAB_ATTR_RO(usercopy);
88539 +#endif
88540 +
88541 static ssize_t destroy_by_rcu_show(struct kmem_cache *s, char *buf)
88542 {
88543 return sprintf(buf, "%d\n", !!(s->flags & SLAB_DESTROY_BY_RCU));
88544 @@ -4897,6 +4970,9 @@ static struct attribute *slab_attrs[] = {
88545 #ifdef CONFIG_ZONE_DMA
88546 &cache_dma_attr.attr,
88547 #endif
88548 +#ifdef CONFIG_PAX_USERCOPY_SLABS
88549 + &usercopy_attr.attr,
88550 +#endif
88551 #ifdef CONFIG_NUMA
88552 &remote_node_defrag_ratio_attr.attr,
88553 #endif
88554 @@ -5128,6 +5204,7 @@ static char *create_unique_id(struct kmem_cache *s)
88555 return name;
88556 }
88557
88558 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
88559 static int sysfs_slab_add(struct kmem_cache *s)
88560 {
88561 int err;
88562 @@ -5151,7 +5228,7 @@ static int sysfs_slab_add(struct kmem_cache *s)
88563 }
88564
88565 s->kobj.kset = slab_kset;
88566 - err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, name);
88567 + err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, "%s", name);
88568 if (err) {
88569 kobject_put(&s->kobj);
88570 return err;
88571 @@ -5185,6 +5262,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
88572 kobject_del(&s->kobj);
88573 kobject_put(&s->kobj);
88574 }
88575 +#endif
88576
88577 /*
88578 * Need to buffer aliases during bootup until sysfs becomes
88579 @@ -5198,6 +5276,7 @@ struct saved_alias {
88580
88581 static struct saved_alias *alias_list;
88582
88583 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
88584 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
88585 {
88586 struct saved_alias *al;
88587 @@ -5220,6 +5299,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
88588 alias_list = al;
88589 return 0;
88590 }
88591 +#endif
88592
88593 static int __init slab_sysfs_init(void)
88594 {
88595 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
88596 index 27eeab3..7c3f7f2 100644
88597 --- a/mm/sparse-vmemmap.c
88598 +++ b/mm/sparse-vmemmap.c
88599 @@ -130,7 +130,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
88600 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
88601 if (!p)
88602 return NULL;
88603 - pud_populate(&init_mm, pud, p);
88604 + pud_populate_kernel(&init_mm, pud, p);
88605 }
88606 return pud;
88607 }
88608 @@ -142,7 +142,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
88609 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
88610 if (!p)
88611 return NULL;
88612 - pgd_populate(&init_mm, pgd, p);
88613 + pgd_populate_kernel(&init_mm, pgd, p);
88614 }
88615 return pgd;
88616 }
88617 diff --git a/mm/sparse.c b/mm/sparse.c
88618 index 1c91f0d3..485470a 100644
88619 --- a/mm/sparse.c
88620 +++ b/mm/sparse.c
88621 @@ -761,7 +761,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
88622
88623 for (i = 0; i < PAGES_PER_SECTION; i++) {
88624 if (PageHWPoison(&memmap[i])) {
88625 - atomic_long_sub(1, &num_poisoned_pages);
88626 + atomic_long_sub_unchecked(1, &num_poisoned_pages);
88627 ClearPageHWPoison(&memmap[i]);
88628 }
88629 }
88630 diff --git a/mm/swap.c b/mm/swap.c
88631 index dfd7d71..ccdf688 100644
88632 --- a/mm/swap.c
88633 +++ b/mm/swap.c
88634 @@ -31,6 +31,7 @@
88635 #include <linux/memcontrol.h>
88636 #include <linux/gfp.h>
88637 #include <linux/uio.h>
88638 +#include <linux/hugetlb.h>
88639
88640 #include "internal.h"
88641
88642 @@ -73,6 +74,8 @@ static void __put_compound_page(struct page *page)
88643
88644 __page_cache_release(page);
88645 dtor = get_compound_page_dtor(page);
88646 + if (!PageHuge(page))
88647 + BUG_ON(dtor != free_compound_page);
88648 (*dtor)(page);
88649 }
88650
88651 diff --git a/mm/swapfile.c b/mm/swapfile.c
88652 index 746af55b..7ac94ae 100644
88653 --- a/mm/swapfile.c
88654 +++ b/mm/swapfile.c
88655 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(swapon_mutex);
88656
88657 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
88658 /* Activity counter to indicate that a swapon or swapoff has occurred */
88659 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
88660 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
88661
88662 static inline unsigned char swap_count(unsigned char ent)
88663 {
88664 @@ -1684,7 +1684,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
88665 }
88666 filp_close(swap_file, NULL);
88667 err = 0;
88668 - atomic_inc(&proc_poll_event);
88669 + atomic_inc_unchecked(&proc_poll_event);
88670 wake_up_interruptible(&proc_poll_wait);
88671
88672 out_dput:
88673 @@ -1701,8 +1701,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
88674
88675 poll_wait(file, &proc_poll_wait, wait);
88676
88677 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
88678 - seq->poll_event = atomic_read(&proc_poll_event);
88679 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
88680 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
88681 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
88682 }
88683
88684 @@ -1800,7 +1800,7 @@ static int swaps_open(struct inode *inode, struct file *file)
88685 return ret;
88686
88687 seq = file->private_data;
88688 - seq->poll_event = atomic_read(&proc_poll_event);
88689 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
88690 return 0;
88691 }
88692
88693 @@ -2143,7 +2143,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
88694 (frontswap_map) ? "FS" : "");
88695
88696 mutex_unlock(&swapon_mutex);
88697 - atomic_inc(&proc_poll_event);
88698 + atomic_inc_unchecked(&proc_poll_event);
88699 wake_up_interruptible(&proc_poll_wait);
88700
88701 if (S_ISREG(inode->i_mode))
88702 diff --git a/mm/util.c b/mm/util.c
88703 index ab1424d..7c5bd5a 100644
88704 --- a/mm/util.c
88705 +++ b/mm/util.c
88706 @@ -294,6 +294,12 @@ done:
88707 void arch_pick_mmap_layout(struct mm_struct *mm)
88708 {
88709 mm->mmap_base = TASK_UNMAPPED_BASE;
88710 +
88711 +#ifdef CONFIG_PAX_RANDMMAP
88712 + if (mm->pax_flags & MF_PAX_RANDMMAP)
88713 + mm->mmap_base += mm->delta_mmap;
88714 +#endif
88715 +
88716 mm->get_unmapped_area = arch_get_unmapped_area;
88717 mm->unmap_area = arch_unmap_area;
88718 }
88719 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
88720 index d365724..6cae7c2 100644
88721 --- a/mm/vmalloc.c
88722 +++ b/mm/vmalloc.c
88723 @@ -59,8 +59,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
88724
88725 pte = pte_offset_kernel(pmd, addr);
88726 do {
88727 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
88728 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
88729 +
88730 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
88731 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
88732 + BUG_ON(!pte_exec(*pte));
88733 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
88734 + continue;
88735 + }
88736 +#endif
88737 +
88738 + {
88739 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
88740 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
88741 + }
88742 } while (pte++, addr += PAGE_SIZE, addr != end);
88743 }
88744
88745 @@ -120,16 +131,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
88746 pte = pte_alloc_kernel(pmd, addr);
88747 if (!pte)
88748 return -ENOMEM;
88749 +
88750 + pax_open_kernel();
88751 do {
88752 struct page *page = pages[*nr];
88753
88754 - if (WARN_ON(!pte_none(*pte)))
88755 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
88756 + if (pgprot_val(prot) & _PAGE_NX)
88757 +#endif
88758 +
88759 + if (!pte_none(*pte)) {
88760 + pax_close_kernel();
88761 + WARN_ON(1);
88762 return -EBUSY;
88763 - if (WARN_ON(!page))
88764 + }
88765 + if (!page) {
88766 + pax_close_kernel();
88767 + WARN_ON(1);
88768 return -ENOMEM;
88769 + }
88770 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
88771 (*nr)++;
88772 } while (pte++, addr += PAGE_SIZE, addr != end);
88773 + pax_close_kernel();
88774 return 0;
88775 }
88776
88777 @@ -139,7 +163,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
88778 pmd_t *pmd;
88779 unsigned long next;
88780
88781 - pmd = pmd_alloc(&init_mm, pud, addr);
88782 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
88783 if (!pmd)
88784 return -ENOMEM;
88785 do {
88786 @@ -156,7 +180,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
88787 pud_t *pud;
88788 unsigned long next;
88789
88790 - pud = pud_alloc(&init_mm, pgd, addr);
88791 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
88792 if (!pud)
88793 return -ENOMEM;
88794 do {
88795 @@ -216,6 +240,12 @@ int is_vmalloc_or_module_addr(const void *x)
88796 if (addr >= MODULES_VADDR && addr < MODULES_END)
88797 return 1;
88798 #endif
88799 +
88800 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
88801 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
88802 + return 1;
88803 +#endif
88804 +
88805 return is_vmalloc_addr(x);
88806 }
88807
88808 @@ -236,8 +266,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
88809
88810 if (!pgd_none(*pgd)) {
88811 pud_t *pud = pud_offset(pgd, addr);
88812 +#ifdef CONFIG_X86
88813 + if (!pud_large(*pud))
88814 +#endif
88815 if (!pud_none(*pud)) {
88816 pmd_t *pmd = pmd_offset(pud, addr);
88817 +#ifdef CONFIG_X86
88818 + if (!pmd_large(*pmd))
88819 +#endif
88820 if (!pmd_none(*pmd)) {
88821 pte_t *ptep, pte;
88822
88823 @@ -339,7 +375,7 @@ static void purge_vmap_area_lazy(void);
88824 * Allocate a region of KVA of the specified size and alignment, within the
88825 * vstart and vend.
88826 */
88827 -static struct vmap_area *alloc_vmap_area(unsigned long size,
88828 +static __size_overflow(1) struct vmap_area *alloc_vmap_area(unsigned long size,
88829 unsigned long align,
88830 unsigned long vstart, unsigned long vend,
88831 int node, gfp_t gfp_mask)
88832 @@ -1337,6 +1373,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
88833 struct vm_struct *area;
88834
88835 BUG_ON(in_interrupt());
88836 +
88837 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
88838 + if (flags & VM_KERNEXEC) {
88839 + if (start != VMALLOC_START || end != VMALLOC_END)
88840 + return NULL;
88841 + start = (unsigned long)MODULES_EXEC_VADDR;
88842 + end = (unsigned long)MODULES_EXEC_END;
88843 + }
88844 +#endif
88845 +
88846 if (flags & VM_IOREMAP) {
88847 int bit = fls(size);
88848
88849 @@ -1581,6 +1627,11 @@ void *vmap(struct page **pages, unsigned int count,
88850 if (count > totalram_pages)
88851 return NULL;
88852
88853 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
88854 + if (!(pgprot_val(prot) & _PAGE_NX))
88855 + flags |= VM_KERNEXEC;
88856 +#endif
88857 +
88858 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
88859 __builtin_return_address(0));
88860 if (!area)
88861 @@ -1682,6 +1733,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
88862 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
88863 goto fail;
88864
88865 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
88866 + if (!(pgprot_val(prot) & _PAGE_NX))
88867 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST | VM_KERNEXEC,
88868 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
88869 + else
88870 +#endif
88871 +
88872 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNLIST,
88873 start, end, node, gfp_mask, caller);
88874 if (!area)
88875 @@ -1858,10 +1916,9 @@ EXPORT_SYMBOL(vzalloc_node);
88876 * For tight control over page level allocator and protection flags
88877 * use __vmalloc() instead.
88878 */
88879 -
88880 void *vmalloc_exec(unsigned long size)
88881 {
88882 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
88883 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
88884 NUMA_NO_NODE, __builtin_return_address(0));
88885 }
88886
88887 @@ -2168,6 +2225,8 @@ int remap_vmalloc_range(struct vm_area_struct *vma, void *addr,
88888 unsigned long uaddr = vma->vm_start;
88889 unsigned long usize = vma->vm_end - vma->vm_start;
88890
88891 + BUG_ON(vma->vm_mirror);
88892 +
88893 if ((PAGE_SIZE-1) & (unsigned long)addr)
88894 return -EINVAL;
88895
88896 @@ -2629,7 +2688,11 @@ static int s_show(struct seq_file *m, void *p)
88897 v->addr, v->addr + v->size, v->size);
88898
88899 if (v->caller)
88900 +#ifdef CONFIG_GRKERNSEC_HIDESYM
88901 + seq_printf(m, " %pK", v->caller);
88902 +#else
88903 seq_printf(m, " %pS", v->caller);
88904 +#endif
88905
88906 if (v->nr_pages)
88907 seq_printf(m, " pages=%d", v->nr_pages);
88908 diff --git a/mm/vmstat.c b/mm/vmstat.c
88909 index f42745e..62f8346 100644
88910 --- a/mm/vmstat.c
88911 +++ b/mm/vmstat.c
88912 @@ -76,7 +76,7 @@ void vm_events_fold_cpu(int cpu)
88913 *
88914 * vm_stat contains the global counters
88915 */
88916 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
88917 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
88918 EXPORT_SYMBOL(vm_stat);
88919
88920 #ifdef CONFIG_SMP
88921 @@ -452,7 +452,7 @@ void refresh_cpu_vm_stats(int cpu)
88922 v = p->vm_stat_diff[i];
88923 p->vm_stat_diff[i] = 0;
88924 local_irq_restore(flags);
88925 - atomic_long_add(v, &zone->vm_stat[i]);
88926 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
88927 global_diff[i] += v;
88928 #ifdef CONFIG_NUMA
88929 /* 3 seconds idle till flush */
88930 @@ -490,7 +490,7 @@ void refresh_cpu_vm_stats(int cpu)
88931
88932 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
88933 if (global_diff[i])
88934 - atomic_long_add(global_diff[i], &vm_stat[i]);
88935 + atomic_long_add_unchecked(global_diff[i], &vm_stat[i]);
88936 }
88937
88938 /*
88939 @@ -505,8 +505,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
88940 if (pset->vm_stat_diff[i]) {
88941 int v = pset->vm_stat_diff[i];
88942 pset->vm_stat_diff[i] = 0;
88943 - atomic_long_add(v, &zone->vm_stat[i]);
88944 - atomic_long_add(v, &vm_stat[i]);
88945 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
88946 + atomic_long_add_unchecked(v, &vm_stat[i]);
88947 }
88948 }
88949 #endif
88950 @@ -1226,7 +1226,7 @@ static int __cpuinit vmstat_cpuup_callback(struct notifier_block *nfb,
88951 return NOTIFY_OK;
88952 }
88953
88954 -static struct notifier_block __cpuinitdata vmstat_notifier =
88955 +static struct notifier_block vmstat_notifier =
88956 { &vmstat_cpuup_callback, NULL, 0 };
88957 #endif
88958
88959 @@ -1241,10 +1241,20 @@ static int __init setup_vmstat(void)
88960 start_cpu_timer(cpu);
88961 #endif
88962 #ifdef CONFIG_PROC_FS
88963 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
88964 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
88965 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
88966 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
88967 + {
88968 + mode_t gr_mode = S_IRUGO;
88969 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
88970 + gr_mode = S_IRUSR;
88971 +#endif
88972 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
88973 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
88974 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
88975 + proc_create("vmstat", gr_mode | S_IRGRP, NULL, &proc_vmstat_file_operations);
88976 +#else
88977 + proc_create("vmstat", gr_mode, NULL, &proc_vmstat_file_operations);
88978 +#endif
88979 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
88980 + }
88981 #endif
88982 return 0;
88983 }
88984 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
88985 index 9424f37..6aabf19 100644
88986 --- a/net/8021q/vlan.c
88987 +++ b/net/8021q/vlan.c
88988 @@ -469,7 +469,7 @@ out:
88989 return NOTIFY_DONE;
88990 }
88991
88992 -static struct notifier_block vlan_notifier_block __read_mostly = {
88993 +static struct notifier_block vlan_notifier_block = {
88994 .notifier_call = vlan_device_event,
88995 };
88996
88997 @@ -544,8 +544,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
88998 err = -EPERM;
88999 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
89000 break;
89001 - if ((args.u.name_type >= 0) &&
89002 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
89003 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
89004 struct vlan_net *vn;
89005
89006 vn = net_generic(net, vlan_net_id);
89007 diff --git a/net/9p/mod.c b/net/9p/mod.c
89008 index 6ab36ae..6f1841b 100644
89009 --- a/net/9p/mod.c
89010 +++ b/net/9p/mod.c
89011 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
89012 void v9fs_register_trans(struct p9_trans_module *m)
89013 {
89014 spin_lock(&v9fs_trans_lock);
89015 - list_add_tail(&m->list, &v9fs_trans_list);
89016 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
89017 spin_unlock(&v9fs_trans_lock);
89018 }
89019 EXPORT_SYMBOL(v9fs_register_trans);
89020 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
89021 void v9fs_unregister_trans(struct p9_trans_module *m)
89022 {
89023 spin_lock(&v9fs_trans_lock);
89024 - list_del_init(&m->list);
89025 + pax_list_del_init((struct list_head *)&m->list);
89026 spin_unlock(&v9fs_trans_lock);
89027 }
89028 EXPORT_SYMBOL(v9fs_unregister_trans);
89029 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
89030 index 02efb25..41541a9 100644
89031 --- a/net/9p/trans_fd.c
89032 +++ b/net/9p/trans_fd.c
89033 @@ -425,7 +425,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
89034 oldfs = get_fs();
89035 set_fs(get_ds());
89036 /* The cast to a user pointer is valid due to the set_fs() */
89037 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
89038 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
89039 set_fs(oldfs);
89040
89041 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
89042 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
89043 index 876fbe8..8bbea9f 100644
89044 --- a/net/atm/atm_misc.c
89045 +++ b/net/atm/atm_misc.c
89046 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
89047 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
89048 return 1;
89049 atm_return(vcc, truesize);
89050 - atomic_inc(&vcc->stats->rx_drop);
89051 + atomic_inc_unchecked(&vcc->stats->rx_drop);
89052 return 0;
89053 }
89054 EXPORT_SYMBOL(atm_charge);
89055 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
89056 }
89057 }
89058 atm_return(vcc, guess);
89059 - atomic_inc(&vcc->stats->rx_drop);
89060 + atomic_inc_unchecked(&vcc->stats->rx_drop);
89061 return NULL;
89062 }
89063 EXPORT_SYMBOL(atm_alloc_charge);
89064 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
89065
89066 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
89067 {
89068 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
89069 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
89070 __SONET_ITEMS
89071 #undef __HANDLE_ITEM
89072 }
89073 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
89074
89075 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
89076 {
89077 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
89078 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
89079 __SONET_ITEMS
89080 #undef __HANDLE_ITEM
89081 }
89082 diff --git a/net/atm/lec.h b/net/atm/lec.h
89083 index 4149db1..f2ab682 100644
89084 --- a/net/atm/lec.h
89085 +++ b/net/atm/lec.h
89086 @@ -48,7 +48,7 @@ struct lane2_ops {
89087 const u8 *tlvs, u32 sizeoftlvs);
89088 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
89089 const u8 *tlvs, u32 sizeoftlvs);
89090 -};
89091 +} __no_const;
89092
89093 /*
89094 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
89095 diff --git a/net/atm/proc.c b/net/atm/proc.c
89096 index bbb6461..cf04016 100644
89097 --- a/net/atm/proc.c
89098 +++ b/net/atm/proc.c
89099 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
89100 const struct k_atm_aal_stats *stats)
89101 {
89102 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
89103 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
89104 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
89105 - atomic_read(&stats->rx_drop));
89106 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
89107 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
89108 + atomic_read_unchecked(&stats->rx_drop));
89109 }
89110
89111 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
89112 diff --git a/net/atm/resources.c b/net/atm/resources.c
89113 index 0447d5d..3cf4728 100644
89114 --- a/net/atm/resources.c
89115 +++ b/net/atm/resources.c
89116 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
89117 static void copy_aal_stats(struct k_atm_aal_stats *from,
89118 struct atm_aal_stats *to)
89119 {
89120 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
89121 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
89122 __AAL_STAT_ITEMS
89123 #undef __HANDLE_ITEM
89124 }
89125 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
89126 static void subtract_aal_stats(struct k_atm_aal_stats *from,
89127 struct atm_aal_stats *to)
89128 {
89129 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
89130 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
89131 __AAL_STAT_ITEMS
89132 #undef __HANDLE_ITEM
89133 }
89134 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
89135 index d5744b7..506bae3 100644
89136 --- a/net/ax25/sysctl_net_ax25.c
89137 +++ b/net/ax25/sysctl_net_ax25.c
89138 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
89139 {
89140 char path[sizeof("net/ax25/") + IFNAMSIZ];
89141 int k;
89142 - struct ctl_table *table;
89143 + ctl_table_no_const *table;
89144
89145 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
89146 if (!table)
89147 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
89148 index f680ee1..97e3542 100644
89149 --- a/net/batman-adv/bat_iv_ogm.c
89150 +++ b/net/batman-adv/bat_iv_ogm.c
89151 @@ -79,7 +79,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
89152
89153 /* randomize initial seqno to avoid collision */
89154 get_random_bytes(&random_seqno, sizeof(random_seqno));
89155 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
89156 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
89157
89158 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
89159 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
89160 @@ -627,9 +627,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
89161 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
89162
89163 /* change sequence number to network order */
89164 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
89165 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
89166 batadv_ogm_packet->seqno = htonl(seqno);
89167 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
89168 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
89169
89170 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
89171 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
89172 @@ -1037,7 +1037,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
89173 return;
89174
89175 /* could be changed by schedule_own_packet() */
89176 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
89177 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
89178
89179 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
89180 has_directlink_flag = 1;
89181 diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c
89182 index de27b31..7058bfe 100644
89183 --- a/net/batman-adv/bridge_loop_avoidance.c
89184 +++ b/net/batman-adv/bridge_loop_avoidance.c
89185 @@ -1522,6 +1522,8 @@ out:
89186 * in these cases, the skb is further handled by this function and
89187 * returns 1, otherwise it returns 0 and the caller shall further
89188 * process the skb.
89189 + *
89190 + * This call might reallocate skb data.
89191 */
89192 int batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb, short vid)
89193 {
89194 diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c
89195 index f105219..7614af3 100644
89196 --- a/net/batman-adv/gateway_client.c
89197 +++ b/net/batman-adv/gateway_client.c
89198 @@ -508,6 +508,7 @@ out:
89199 return 0;
89200 }
89201
89202 +/* this call might reallocate skb data */
89203 static bool batadv_is_type_dhcprequest(struct sk_buff *skb, int header_len)
89204 {
89205 int ret = false;
89206 @@ -568,6 +569,7 @@ out:
89207 return ret;
89208 }
89209
89210 +/* this call might reallocate skb data */
89211 bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len)
89212 {
89213 struct ethhdr *ethhdr;
89214 @@ -619,6 +621,12 @@ bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len)
89215
89216 if (!pskb_may_pull(skb, *header_len + sizeof(*udphdr)))
89217 return false;
89218 +
89219 + /* skb->data might have been reallocated by pskb_may_pull() */
89220 + ethhdr = (struct ethhdr *)skb->data;
89221 + if (ntohs(ethhdr->h_proto) == ETH_P_8021Q)
89222 + ethhdr = (struct ethhdr *)(skb->data + VLAN_HLEN);
89223 +
89224 udphdr = (struct udphdr *)(skb->data + *header_len);
89225 *header_len += sizeof(*udphdr);
89226
89227 @@ -634,12 +642,14 @@ bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len)
89228 return true;
89229 }
89230
89231 +/* this call might reallocate skb data */
89232 bool batadv_gw_out_of_range(struct batadv_priv *bat_priv,
89233 - struct sk_buff *skb, struct ethhdr *ethhdr)
89234 + struct sk_buff *skb)
89235 {
89236 struct batadv_neigh_node *neigh_curr = NULL, *neigh_old = NULL;
89237 struct batadv_orig_node *orig_dst_node = NULL;
89238 struct batadv_gw_node *curr_gw = NULL;
89239 + struct ethhdr *ethhdr;
89240 bool ret, out_of_range = false;
89241 unsigned int header_len = 0;
89242 uint8_t curr_tq_avg;
89243 @@ -648,6 +658,7 @@ bool batadv_gw_out_of_range(struct batadv_priv *bat_priv,
89244 if (!ret)
89245 goto out;
89246
89247 + ethhdr = (struct ethhdr *)skb->data;
89248 orig_dst_node = batadv_transtable_search(bat_priv, ethhdr->h_source,
89249 ethhdr->h_dest);
89250 if (!orig_dst_node)
89251 diff --git a/net/batman-adv/gateway_client.h b/net/batman-adv/gateway_client.h
89252 index 039902d..1037d75 100644
89253 --- a/net/batman-adv/gateway_client.h
89254 +++ b/net/batman-adv/gateway_client.h
89255 @@ -34,7 +34,6 @@ void batadv_gw_node_delete(struct batadv_priv *bat_priv,
89256 void batadv_gw_node_purge(struct batadv_priv *bat_priv);
89257 int batadv_gw_client_seq_print_text(struct seq_file *seq, void *offset);
89258 bool batadv_gw_is_dhcp_target(struct sk_buff *skb, unsigned int *header_len);
89259 -bool batadv_gw_out_of_range(struct batadv_priv *bat_priv,
89260 - struct sk_buff *skb, struct ethhdr *ethhdr);
89261 +bool batadv_gw_out_of_range(struct batadv_priv *bat_priv, struct sk_buff *skb);
89262
89263 #endif /* _NET_BATMAN_ADV_GATEWAY_CLIENT_H_ */
89264 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
89265 index 522243a..b48c0ef 100644
89266 --- a/net/batman-adv/hard-interface.c
89267 +++ b/net/batman-adv/hard-interface.c
89268 @@ -401,7 +401,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
89269 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
89270 dev_add_pack(&hard_iface->batman_adv_ptype);
89271
89272 - atomic_set(&hard_iface->frag_seqno, 1);
89273 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
89274 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
89275 hard_iface->net_dev->name);
89276
89277 @@ -550,7 +550,7 @@ batadv_hardif_add_interface(struct net_device *net_dev)
89278 /* This can't be called via a bat_priv callback because
89279 * we have no bat_priv yet.
89280 */
89281 - atomic_set(&hard_iface->bat_iv.ogm_seqno, 1);
89282 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, 1);
89283 hard_iface->bat_iv.ogm_buff = NULL;
89284
89285 return hard_iface;
89286 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
89287 index 819dfb0..226bacd 100644
89288 --- a/net/batman-adv/soft-interface.c
89289 +++ b/net/batman-adv/soft-interface.c
89290 @@ -180,6 +180,9 @@ static int batadv_interface_tx(struct sk_buff *skb,
89291 if (batadv_bla_tx(bat_priv, skb, vid))
89292 goto dropped;
89293
89294 + /* skb->data might have been reallocated by batadv_bla_tx() */
89295 + ethhdr = (struct ethhdr *)skb->data;
89296 +
89297 /* Register the client MAC in the transtable */
89298 if (!is_multicast_ether_addr(ethhdr->h_source))
89299 batadv_tt_local_add(soft_iface, ethhdr->h_source, skb->skb_iif);
89300 @@ -220,6 +223,10 @@ static int batadv_interface_tx(struct sk_buff *skb,
89301 default:
89302 break;
89303 }
89304 +
89305 + /* reminder: ethhdr might have become unusable from here on
89306 + * (batadv_gw_is_dhcp_target() might have reallocated skb data)
89307 + */
89308 }
89309
89310 /* ethernet packet should be broadcasted */
89311 @@ -253,7 +260,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
89312 primary_if->net_dev->dev_addr, ETH_ALEN);
89313
89314 /* set broadcast sequence number */
89315 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
89316 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
89317 bcast_packet->seqno = htonl(seqno);
89318
89319 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
89320 @@ -266,7 +273,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
89321 /* unicast packet */
89322 } else {
89323 if (atomic_read(&bat_priv->gw_mode) != BATADV_GW_MODE_OFF) {
89324 - ret = batadv_gw_out_of_range(bat_priv, skb, ethhdr);
89325 + ret = batadv_gw_out_of_range(bat_priv, skb);
89326 if (ret)
89327 goto dropped;
89328 }
89329 @@ -472,7 +479,7 @@ static int batadv_softif_init_late(struct net_device *dev)
89330 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
89331
89332 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
89333 - atomic_set(&bat_priv->bcast_seqno, 1);
89334 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
89335 atomic_set(&bat_priv->tt.vn, 0);
89336 atomic_set(&bat_priv->tt.local_changes, 0);
89337 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
89338 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
89339 index aba8364..50fcbb8 100644
89340 --- a/net/batman-adv/types.h
89341 +++ b/net/batman-adv/types.h
89342 @@ -51,7 +51,7 @@
89343 struct batadv_hard_iface_bat_iv {
89344 unsigned char *ogm_buff;
89345 int ogm_buff_len;
89346 - atomic_t ogm_seqno;
89347 + atomic_unchecked_t ogm_seqno;
89348 };
89349
89350 /**
89351 @@ -75,7 +75,7 @@ struct batadv_hard_iface {
89352 int16_t if_num;
89353 char if_status;
89354 struct net_device *net_dev;
89355 - atomic_t frag_seqno;
89356 + atomic_unchecked_t frag_seqno;
89357 struct kobject *hardif_obj;
89358 atomic_t refcount;
89359 struct packet_type batman_adv_ptype;
89360 @@ -558,7 +558,7 @@ struct batadv_priv {
89361 #ifdef CONFIG_BATMAN_ADV_DEBUG
89362 atomic_t log_level;
89363 #endif
89364 - atomic_t bcast_seqno;
89365 + atomic_unchecked_t bcast_seqno;
89366 atomic_t bcast_queue_left;
89367 atomic_t batman_queue_left;
89368 char num_ifaces;
89369 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
89370 index 0bb3b59..0e3052e 100644
89371 --- a/net/batman-adv/unicast.c
89372 +++ b/net/batman-adv/unicast.c
89373 @@ -270,7 +270,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
89374 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
89375 frag2->flags = large_tail;
89376
89377 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
89378 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
89379 frag1->seqno = htons(seqno - 1);
89380 frag2->seqno = htons(seqno);
89381
89382 @@ -326,7 +326,9 @@ static bool batadv_unicast_push_and_fill_skb(struct sk_buff *skb, int hdr_size,
89383 * @skb: the skb containing the payload to encapsulate
89384 * @orig_node: the destination node
89385 *
89386 - * Returns false if the payload could not be encapsulated or true otherwise
89387 + * Returns false if the payload could not be encapsulated or true otherwise.
89388 + *
89389 + * This call might reallocate skb data.
89390 */
89391 static bool batadv_unicast_prepare_skb(struct sk_buff *skb,
89392 struct batadv_orig_node *orig_node)
89393 @@ -343,7 +345,9 @@ static bool batadv_unicast_prepare_skb(struct sk_buff *skb,
89394 * @orig_node: the destination node
89395 * @packet_subtype: the batman 4addr packet subtype to use
89396 *
89397 - * Returns false if the payload could not be encapsulated or true otherwise
89398 + * Returns false if the payload could not be encapsulated or true otherwise.
89399 + *
89400 + * This call might reallocate skb data.
89401 */
89402 bool batadv_unicast_4addr_prepare_skb(struct batadv_priv *bat_priv,
89403 struct sk_buff *skb,
89404 @@ -401,7 +405,7 @@ int batadv_unicast_generic_send_skb(struct batadv_priv *bat_priv,
89405 struct batadv_neigh_node *neigh_node;
89406 int data_len = skb->len;
89407 int ret = NET_RX_DROP;
89408 - unsigned int dev_mtu;
89409 + unsigned int dev_mtu, header_len;
89410
89411 /* get routing information */
89412 if (is_multicast_ether_addr(ethhdr->h_dest)) {
89413 @@ -429,10 +433,12 @@ find_router:
89414 switch (packet_type) {
89415 case BATADV_UNICAST:
89416 batadv_unicast_prepare_skb(skb, orig_node);
89417 + header_len = sizeof(struct batadv_unicast_packet);
89418 break;
89419 case BATADV_UNICAST_4ADDR:
89420 batadv_unicast_4addr_prepare_skb(bat_priv, skb, orig_node,
89421 packet_subtype);
89422 + header_len = sizeof(struct batadv_unicast_4addr_packet);
89423 break;
89424 default:
89425 /* this function supports UNICAST and UNICAST_4ADDR only. It
89426 @@ -441,6 +447,7 @@ find_router:
89427 goto out;
89428 }
89429
89430 + ethhdr = (struct ethhdr *)(skb->data + header_len);
89431 unicast_packet = (struct batadv_unicast_packet *)skb->data;
89432
89433 /* inform the destination node that we are still missing a correct route
89434 diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
89435 index ace5e55..a65a1c0 100644
89436 --- a/net/bluetooth/hci_core.c
89437 +++ b/net/bluetooth/hci_core.c
89438 @@ -2211,16 +2211,16 @@ int hci_register_dev(struct hci_dev *hdev)
89439 list_add(&hdev->list, &hci_dev_list);
89440 write_unlock(&hci_dev_list_lock);
89441
89442 - hdev->workqueue = alloc_workqueue(hdev->name, WQ_HIGHPRI | WQ_UNBOUND |
89443 - WQ_MEM_RECLAIM, 1);
89444 + hdev->workqueue = alloc_workqueue("%s", WQ_HIGHPRI | WQ_UNBOUND |
89445 + WQ_MEM_RECLAIM, 1, hdev->name);
89446 if (!hdev->workqueue) {
89447 error = -ENOMEM;
89448 goto err;
89449 }
89450
89451 - hdev->req_workqueue = alloc_workqueue(hdev->name,
89452 + hdev->req_workqueue = alloc_workqueue("%s",
89453 WQ_HIGHPRI | WQ_UNBOUND |
89454 - WQ_MEM_RECLAIM, 1);
89455 + WQ_MEM_RECLAIM, 1, hdev->name);
89456 if (!hdev->req_workqueue) {
89457 destroy_workqueue(hdev->workqueue);
89458 error = -ENOMEM;
89459 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
89460 index 9bd7d95..6c4884f 100644
89461 --- a/net/bluetooth/hci_sock.c
89462 +++ b/net/bluetooth/hci_sock.c
89463 @@ -934,7 +934,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
89464 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
89465 }
89466
89467 - len = min_t(unsigned int, len, sizeof(uf));
89468 + len = min((size_t)len, sizeof(uf));
89469 if (copy_from_user(&uf, optval, len)) {
89470 err = -EFAULT;
89471 break;
89472 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
89473 index 68843a2..30e9342 100644
89474 --- a/net/bluetooth/l2cap_core.c
89475 +++ b/net/bluetooth/l2cap_core.c
89476 @@ -3507,8 +3507,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
89477 break;
89478
89479 case L2CAP_CONF_RFC:
89480 - if (olen == sizeof(rfc))
89481 - memcpy(&rfc, (void *)val, olen);
89482 + if (olen != sizeof(rfc))
89483 + break;
89484 +
89485 + memcpy(&rfc, (void *)val, olen);
89486
89487 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
89488 rfc.mode != chan->mode)
89489 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
89490 index 36fed40..be2eeb2 100644
89491 --- a/net/bluetooth/l2cap_sock.c
89492 +++ b/net/bluetooth/l2cap_sock.c
89493 @@ -485,7 +485,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
89494 struct sock *sk = sock->sk;
89495 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
89496 struct l2cap_options opts;
89497 - int len, err = 0;
89498 + int err = 0;
89499 + size_t len = optlen;
89500 u32 opt;
89501
89502 BT_DBG("sk %p", sk);
89503 @@ -507,7 +508,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
89504 opts.max_tx = chan->max_tx;
89505 opts.txwin_size = chan->tx_win;
89506
89507 - len = min_t(unsigned int, sizeof(opts), optlen);
89508 + len = min(sizeof(opts), len);
89509 if (copy_from_user((char *) &opts, optval, len)) {
89510 err = -EFAULT;
89511 break;
89512 @@ -587,7 +588,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
89513 struct bt_security sec;
89514 struct bt_power pwr;
89515 struct l2cap_conn *conn;
89516 - int len, err = 0;
89517 + int err = 0;
89518 + size_t len = optlen;
89519 u32 opt;
89520
89521 BT_DBG("sk %p", sk);
89522 @@ -610,7 +612,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
89523
89524 sec.level = BT_SECURITY_LOW;
89525
89526 - len = min_t(unsigned int, sizeof(sec), optlen);
89527 + len = min(sizeof(sec), len);
89528 if (copy_from_user((char *) &sec, optval, len)) {
89529 err = -EFAULT;
89530 break;
89531 @@ -707,7 +709,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
89532
89533 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
89534
89535 - len = min_t(unsigned int, sizeof(pwr), optlen);
89536 + len = min(sizeof(pwr), len);
89537 if (copy_from_user((char *) &pwr, optval, len)) {
89538 err = -EFAULT;
89539 break;
89540 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
89541 index 30b3721..c1bd0a0 100644
89542 --- a/net/bluetooth/rfcomm/sock.c
89543 +++ b/net/bluetooth/rfcomm/sock.c
89544 @@ -666,7 +666,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
89545 struct sock *sk = sock->sk;
89546 struct bt_security sec;
89547 int err = 0;
89548 - size_t len;
89549 + size_t len = optlen;
89550 u32 opt;
89551
89552 BT_DBG("sk %p", sk);
89553 @@ -688,7 +688,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
89554
89555 sec.level = BT_SECURITY_LOW;
89556
89557 - len = min_t(unsigned int, sizeof(sec), optlen);
89558 + len = min(sizeof(sec), len);
89559 if (copy_from_user((char *) &sec, optval, len)) {
89560 err = -EFAULT;
89561 break;
89562 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
89563 index b6e44ad..5b0d514 100644
89564 --- a/net/bluetooth/rfcomm/tty.c
89565 +++ b/net/bluetooth/rfcomm/tty.c
89566 @@ -309,7 +309,7 @@ static void rfcomm_dev_del(struct rfcomm_dev *dev)
89567 BUG_ON(test_and_set_bit(RFCOMM_TTY_RELEASED, &dev->flags));
89568
89569 spin_lock_irqsave(&dev->port.lock, flags);
89570 - if (dev->port.count > 0) {
89571 + if (atomic_read(&dev->port.count) > 0) {
89572 spin_unlock_irqrestore(&dev->port.lock, flags);
89573 return;
89574 }
89575 @@ -659,10 +659,10 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
89576 return -ENODEV;
89577
89578 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
89579 - dev->channel, dev->port.count);
89580 + dev->channel, atomic_read(&dev->port.count));
89581
89582 spin_lock_irqsave(&dev->port.lock, flags);
89583 - if (++dev->port.count > 1) {
89584 + if (atomic_inc_return(&dev->port.count) > 1) {
89585 spin_unlock_irqrestore(&dev->port.lock, flags);
89586 return 0;
89587 }
89588 @@ -727,10 +727,10 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
89589 return;
89590
89591 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
89592 - dev->port.count);
89593 + atomic_read(&dev->port.count));
89594
89595 spin_lock_irqsave(&dev->port.lock, flags);
89596 - if (!--dev->port.count) {
89597 + if (!atomic_dec_return(&dev->port.count)) {
89598 spin_unlock_irqrestore(&dev->port.lock, flags);
89599 if (dev->tty_dev->parent)
89600 device_move(dev->tty_dev, NULL, DPM_ORDER_DEV_LAST);
89601 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
89602 index 3d110c4..4e1b2eb 100644
89603 --- a/net/bridge/netfilter/ebtables.c
89604 +++ b/net/bridge/netfilter/ebtables.c
89605 @@ -1525,7 +1525,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
89606 tmp.valid_hooks = t->table->valid_hooks;
89607 }
89608 mutex_unlock(&ebt_mutex);
89609 - if (copy_to_user(user, &tmp, *len) != 0){
89610 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
89611 BUGPRINT("c2u Didn't work\n");
89612 ret = -EFAULT;
89613 break;
89614 @@ -2331,7 +2331,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
89615 goto out;
89616 tmp.valid_hooks = t->valid_hooks;
89617
89618 - if (copy_to_user(user, &tmp, *len) != 0) {
89619 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
89620 ret = -EFAULT;
89621 break;
89622 }
89623 @@ -2342,7 +2342,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
89624 tmp.entries_size = t->table->entries_size;
89625 tmp.valid_hooks = t->table->valid_hooks;
89626
89627 - if (copy_to_user(user, &tmp, *len) != 0) {
89628 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
89629 ret = -EFAULT;
89630 break;
89631 }
89632 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
89633 index 2bd4b58..0dc30a1 100644
89634 --- a/net/caif/cfctrl.c
89635 +++ b/net/caif/cfctrl.c
89636 @@ -10,6 +10,7 @@
89637 #include <linux/spinlock.h>
89638 #include <linux/slab.h>
89639 #include <linux/pkt_sched.h>
89640 +#include <linux/sched.h>
89641 #include <net/caif/caif_layer.h>
89642 #include <net/caif/cfpkt.h>
89643 #include <net/caif/cfctrl.h>
89644 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
89645 memset(&dev_info, 0, sizeof(dev_info));
89646 dev_info.id = 0xff;
89647 cfsrvl_init(&this->serv, 0, &dev_info, false);
89648 - atomic_set(&this->req_seq_no, 1);
89649 - atomic_set(&this->rsp_seq_no, 1);
89650 + atomic_set_unchecked(&this->req_seq_no, 1);
89651 + atomic_set_unchecked(&this->rsp_seq_no, 1);
89652 this->serv.layer.receive = cfctrl_recv;
89653 sprintf(this->serv.layer.name, "ctrl");
89654 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
89655 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
89656 struct cfctrl_request_info *req)
89657 {
89658 spin_lock_bh(&ctrl->info_list_lock);
89659 - atomic_inc(&ctrl->req_seq_no);
89660 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
89661 + atomic_inc_unchecked(&ctrl->req_seq_no);
89662 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
89663 list_add_tail(&req->list, &ctrl->list);
89664 spin_unlock_bh(&ctrl->info_list_lock);
89665 }
89666 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
89667 if (p != first)
89668 pr_warn("Requests are not received in order\n");
89669
89670 - atomic_set(&ctrl->rsp_seq_no,
89671 + atomic_set_unchecked(&ctrl->rsp_seq_no,
89672 p->sequence_no);
89673 list_del(&p->list);
89674 goto out;
89675 diff --git a/net/can/af_can.c b/net/can/af_can.c
89676 index c4e5085..aa9efdf 100644
89677 --- a/net/can/af_can.c
89678 +++ b/net/can/af_can.c
89679 @@ -862,7 +862,7 @@ static const struct net_proto_family can_family_ops = {
89680 };
89681
89682 /* notifier block for netdevice event */
89683 -static struct notifier_block can_netdev_notifier __read_mostly = {
89684 +static struct notifier_block can_netdev_notifier = {
89685 .notifier_call = can_notifier,
89686 };
89687
89688 diff --git a/net/can/gw.c b/net/can/gw.c
89689 index 3ee690e..00d581b 100644
89690 --- a/net/can/gw.c
89691 +++ b/net/can/gw.c
89692 @@ -80,7 +80,6 @@ MODULE_PARM_DESC(max_hops,
89693 "default: " __stringify(CGW_DEFAULT_HOPS) ")");
89694
89695 static HLIST_HEAD(cgw_list);
89696 -static struct notifier_block notifier;
89697
89698 static struct kmem_cache *cgw_cache __read_mostly;
89699
89700 @@ -927,6 +926,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh)
89701 return err;
89702 }
89703
89704 +static struct notifier_block notifier = {
89705 + .notifier_call = cgw_notifier
89706 +};
89707 +
89708 static __init int cgw_module_init(void)
89709 {
89710 /* sanitize given module parameter */
89711 @@ -942,7 +945,6 @@ static __init int cgw_module_init(void)
89712 return -ENOMEM;
89713
89714 /* set notifier */
89715 - notifier.notifier_call = cgw_notifier;
89716 register_netdevice_notifier(&notifier);
89717
89718 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
89719 diff --git a/net/compat.c b/net/compat.c
89720 index f0a1ba6..0541331 100644
89721 --- a/net/compat.c
89722 +++ b/net/compat.c
89723 @@ -71,9 +71,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
89724 __get_user(kmsg->msg_controllen, &umsg->msg_controllen) ||
89725 __get_user(kmsg->msg_flags, &umsg->msg_flags))
89726 return -EFAULT;
89727 - kmsg->msg_name = compat_ptr(tmp1);
89728 - kmsg->msg_iov = compat_ptr(tmp2);
89729 - kmsg->msg_control = compat_ptr(tmp3);
89730 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
89731 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
89732 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
89733 return 0;
89734 }
89735
89736 @@ -85,7 +85,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
89737
89738 if (kern_msg->msg_namelen) {
89739 if (mode == VERIFY_READ) {
89740 - int err = move_addr_to_kernel(kern_msg->msg_name,
89741 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
89742 kern_msg->msg_namelen,
89743 kern_address);
89744 if (err < 0)
89745 @@ -96,7 +96,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
89746 kern_msg->msg_name = NULL;
89747
89748 tot_len = iov_from_user_compat_to_kern(kern_iov,
89749 - (struct compat_iovec __user *)kern_msg->msg_iov,
89750 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
89751 kern_msg->msg_iovlen);
89752 if (tot_len >= 0)
89753 kern_msg->msg_iov = kern_iov;
89754 @@ -116,20 +116,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
89755
89756 #define CMSG_COMPAT_FIRSTHDR(msg) \
89757 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
89758 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
89759 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
89760 (struct compat_cmsghdr __user *)NULL)
89761
89762 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
89763 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
89764 (ucmlen) <= (unsigned long) \
89765 ((mhdr)->msg_controllen - \
89766 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
89767 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
89768
89769 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
89770 struct compat_cmsghdr __user *cmsg, int cmsg_len)
89771 {
89772 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
89773 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
89774 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
89775 msg->msg_controllen)
89776 return NULL;
89777 return (struct compat_cmsghdr __user *)ptr;
89778 @@ -219,7 +219,7 @@ Efault:
89779
89780 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
89781 {
89782 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
89783 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
89784 struct compat_cmsghdr cmhdr;
89785 struct compat_timeval ctv;
89786 struct compat_timespec cts[3];
89787 @@ -275,7 +275,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
89788
89789 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
89790 {
89791 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
89792 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
89793 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
89794 int fdnum = scm->fp->count;
89795 struct file **fp = scm->fp->fp;
89796 @@ -363,7 +363,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
89797 return -EFAULT;
89798 old_fs = get_fs();
89799 set_fs(KERNEL_DS);
89800 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
89801 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
89802 set_fs(old_fs);
89803
89804 return err;
89805 @@ -424,7 +424,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
89806 len = sizeof(ktime);
89807 old_fs = get_fs();
89808 set_fs(KERNEL_DS);
89809 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
89810 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
89811 set_fs(old_fs);
89812
89813 if (!err) {
89814 @@ -567,7 +567,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
89815 case MCAST_JOIN_GROUP:
89816 case MCAST_LEAVE_GROUP:
89817 {
89818 - struct compat_group_req __user *gr32 = (void *)optval;
89819 + struct compat_group_req __user *gr32 = (void __user *)optval;
89820 struct group_req __user *kgr =
89821 compat_alloc_user_space(sizeof(struct group_req));
89822 u32 interface;
89823 @@ -588,7 +588,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
89824 case MCAST_BLOCK_SOURCE:
89825 case MCAST_UNBLOCK_SOURCE:
89826 {
89827 - struct compat_group_source_req __user *gsr32 = (void *)optval;
89828 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
89829 struct group_source_req __user *kgsr = compat_alloc_user_space(
89830 sizeof(struct group_source_req));
89831 u32 interface;
89832 @@ -609,7 +609,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
89833 }
89834 case MCAST_MSFILTER:
89835 {
89836 - struct compat_group_filter __user *gf32 = (void *)optval;
89837 + struct compat_group_filter __user *gf32 = (void __user *)optval;
89838 struct group_filter __user *kgf;
89839 u32 interface, fmode, numsrc;
89840
89841 @@ -647,7 +647,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
89842 char __user *optval, int __user *optlen,
89843 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
89844 {
89845 - struct compat_group_filter __user *gf32 = (void *)optval;
89846 + struct compat_group_filter __user *gf32 = (void __user *)optval;
89847 struct group_filter __user *kgf;
89848 int __user *koptlen;
89849 u32 interface, fmode, numsrc;
89850 @@ -805,7 +805,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
89851
89852 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
89853 return -EINVAL;
89854 - if (copy_from_user(a, args, nas[call]))
89855 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
89856 return -EFAULT;
89857 a0 = a[0];
89858 a1 = a[1];
89859 diff --git a/net/core/datagram.c b/net/core/datagram.c
89860 index b71423d..0360434 100644
89861 --- a/net/core/datagram.c
89862 +++ b/net/core/datagram.c
89863 @@ -295,7 +295,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
89864 }
89865
89866 kfree_skb(skb);
89867 - atomic_inc(&sk->sk_drops);
89868 + atomic_inc_unchecked(&sk->sk_drops);
89869 sk_mem_reclaim_partial(sk);
89870
89871 return err;
89872 diff --git a/net/core/dev.c b/net/core/dev.c
89873 index 7ddbb31..3902452 100644
89874 --- a/net/core/dev.c
89875 +++ b/net/core/dev.c
89876 @@ -1649,7 +1649,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
89877 {
89878 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
89879 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
89880 - atomic_long_inc(&dev->rx_dropped);
89881 + atomic_long_inc_unchecked(&dev->rx_dropped);
89882 kfree_skb(skb);
89883 return NET_RX_DROP;
89884 }
89885 @@ -1658,7 +1658,7 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
89886 skb_orphan(skb);
89887
89888 if (unlikely(!is_skb_forwardable(dev, skb))) {
89889 - atomic_long_inc(&dev->rx_dropped);
89890 + atomic_long_inc_unchecked(&dev->rx_dropped);
89891 kfree_skb(skb);
89892 return NET_RX_DROP;
89893 }
89894 @@ -2404,7 +2404,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
89895
89896 struct dev_gso_cb {
89897 void (*destructor)(struct sk_buff *skb);
89898 -};
89899 +} __no_const;
89900
89901 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
89902
89903 @@ -3139,7 +3139,7 @@ enqueue:
89904
89905 local_irq_restore(flags);
89906
89907 - atomic_long_inc(&skb->dev->rx_dropped);
89908 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
89909 kfree_skb(skb);
89910 return NET_RX_DROP;
89911 }
89912 @@ -3211,7 +3211,7 @@ int netif_rx_ni(struct sk_buff *skb)
89913 }
89914 EXPORT_SYMBOL(netif_rx_ni);
89915
89916 -static void net_tx_action(struct softirq_action *h)
89917 +static void net_tx_action(void)
89918 {
89919 struct softnet_data *sd = &__get_cpu_var(softnet_data);
89920
89921 @@ -3545,7 +3545,7 @@ ncls:
89922 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
89923 } else {
89924 drop:
89925 - atomic_long_inc(&skb->dev->rx_dropped);
89926 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
89927 kfree_skb(skb);
89928 /* Jamal, now you will not able to escape explaining
89929 * me how you were going to use this. :-)
89930 @@ -4153,7 +4153,7 @@ void netif_napi_del(struct napi_struct *napi)
89931 }
89932 EXPORT_SYMBOL(netif_napi_del);
89933
89934 -static void net_rx_action(struct softirq_action *h)
89935 +static void net_rx_action(void)
89936 {
89937 struct softnet_data *sd = &__get_cpu_var(softnet_data);
89938 unsigned long time_limit = jiffies + 2;
89939 @@ -5590,7 +5590,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
89940 } else {
89941 netdev_stats_to_stats64(storage, &dev->stats);
89942 }
89943 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
89944 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
89945 return storage;
89946 }
89947 EXPORT_SYMBOL(dev_get_stats);
89948 diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
89949 index 5b7d0e1..cb960fc 100644
89950 --- a/net/core/dev_ioctl.c
89951 +++ b/net/core/dev_ioctl.c
89952 @@ -365,9 +365,13 @@ void dev_load(struct net *net, const char *name)
89953 if (no_module && capable(CAP_NET_ADMIN))
89954 no_module = request_module("netdev-%s", name);
89955 if (no_module && capable(CAP_SYS_MODULE)) {
89956 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
89957 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
89958 +#else
89959 if (!request_module("%s", name))
89960 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
89961 name);
89962 +#endif
89963 }
89964 }
89965 EXPORT_SYMBOL(dev_load);
89966 diff --git a/net/core/ethtool.c b/net/core/ethtool.c
89967 index ce91766..3b71cdb 100644
89968 --- a/net/core/ethtool.c
89969 +++ b/net/core/ethtool.c
89970 @@ -1319,10 +1319,19 @@ static int ethtool_get_dump_data(struct net_device *dev,
89971 if (ret)
89972 return ret;
89973
89974 - len = (tmp.len > dump.len) ? dump.len : tmp.len;
89975 + len = min(tmp.len, dump.len);
89976 if (!len)
89977 return -EFAULT;
89978
89979 + /* Don't ever let the driver think there's more space available
89980 + * than it requested with .get_dump_flag().
89981 + */
89982 + dump.len = len;
89983 +
89984 + /* Always allocate enough space to hold the whole thing so that the
89985 + * driver does not need to check the length and bother with partial
89986 + * dumping.
89987 + */
89988 data = vzalloc(tmp.len);
89989 if (!data)
89990 return -ENOMEM;
89991 @@ -1330,6 +1339,16 @@ static int ethtool_get_dump_data(struct net_device *dev,
89992 if (ret)
89993 goto out;
89994
89995 + /* There are two sane possibilities:
89996 + * 1. The driver's .get_dump_data() does not touch dump.len.
89997 + * 2. Or it may set dump.len to how much it really writes, which
89998 + * should be tmp.len (or len if it can do a partial dump).
89999 + * In any case respond to userspace with the actual length of data
90000 + * it's receiving.
90001 + */
90002 + WARN_ON(dump.len != len && dump.len != tmp.len);
90003 + dump.len = len;
90004 +
90005 if (copy_to_user(useraddr, &dump, sizeof(dump))) {
90006 ret = -EFAULT;
90007 goto out;
90008 diff --git a/net/core/flow.c b/net/core/flow.c
90009 index 7102f16..146b4bd 100644
90010 --- a/net/core/flow.c
90011 +++ b/net/core/flow.c
90012 @@ -61,7 +61,7 @@ struct flow_cache {
90013 struct timer_list rnd_timer;
90014 };
90015
90016 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
90017 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
90018 EXPORT_SYMBOL(flow_cache_genid);
90019 static struct flow_cache flow_cache_global;
90020 static struct kmem_cache *flow_cachep __read_mostly;
90021 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
90022
90023 static int flow_entry_valid(struct flow_cache_entry *fle)
90024 {
90025 - if (atomic_read(&flow_cache_genid) != fle->genid)
90026 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
90027 return 0;
90028 if (fle->object && !fle->object->ops->check(fle->object))
90029 return 0;
90030 @@ -258,7 +258,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
90031 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
90032 fcp->hash_count++;
90033 }
90034 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
90035 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
90036 flo = fle->object;
90037 if (!flo)
90038 goto ret_object;
90039 @@ -279,7 +279,7 @@ nocache:
90040 }
90041 flo = resolver(net, key, family, dir, flo, ctx);
90042 if (fle) {
90043 - fle->genid = atomic_read(&flow_cache_genid);
90044 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
90045 if (!IS_ERR(flo))
90046 fle->object = flo;
90047 else
90048 diff --git a/net/core/iovec.c b/net/core/iovec.c
90049 index de178e4..1dabd8b 100644
90050 --- a/net/core/iovec.c
90051 +++ b/net/core/iovec.c
90052 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
90053 if (m->msg_namelen) {
90054 if (mode == VERIFY_READ) {
90055 void __user *namep;
90056 - namep = (void __user __force *) m->msg_name;
90057 + namep = (void __force_user *) m->msg_name;
90058 err = move_addr_to_kernel(namep, m->msg_namelen,
90059 address);
90060 if (err < 0)
90061 @@ -54,7 +54,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
90062 }
90063
90064 size = m->msg_iovlen * sizeof(struct iovec);
90065 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
90066 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
90067 return -EFAULT;
90068
90069 m->msg_iov = iov;
90070 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
90071 index ce90b02..8752627 100644
90072 --- a/net/core/neighbour.c
90073 +++ b/net/core/neighbour.c
90074 @@ -2771,7 +2771,7 @@ static int proc_unres_qlen(ctl_table *ctl, int write, void __user *buffer,
90075 size_t *lenp, loff_t *ppos)
90076 {
90077 int size, ret;
90078 - ctl_table tmp = *ctl;
90079 + ctl_table_no_const tmp = *ctl;
90080
90081 tmp.extra1 = &zero;
90082 tmp.extra2 = &unres_qlen_max;
90083 diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
90084 index 569d355..79cf2d0 100644
90085 --- a/net/core/net-procfs.c
90086 +++ b/net/core/net-procfs.c
90087 @@ -271,8 +271,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
90088 else
90089 seq_printf(seq, "%04x", ntohs(pt->type));
90090
90091 +#ifdef CONFIG_GRKERNSEC_HIDESYM
90092 + seq_printf(seq, " %-8s %pf\n",
90093 + pt->dev ? pt->dev->name : "", NULL);
90094 +#else
90095 seq_printf(seq, " %-8s %pf\n",
90096 pt->dev ? pt->dev->name : "", pt->func);
90097 +#endif
90098 }
90099
90100 return 0;
90101 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
90102 index 981fed3..536af34 100644
90103 --- a/net/core/net-sysfs.c
90104 +++ b/net/core/net-sysfs.c
90105 @@ -1311,7 +1311,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
90106 }
90107 EXPORT_SYMBOL(netdev_class_remove_file);
90108
90109 -int netdev_kobject_init(void)
90110 +int __init netdev_kobject_init(void)
90111 {
90112 kobj_ns_type_register(&net_ns_type_operations);
90113 return class_register(&net_class);
90114 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
90115 index f9765203..9feaef8 100644
90116 --- a/net/core/net_namespace.c
90117 +++ b/net/core/net_namespace.c
90118 @@ -443,7 +443,7 @@ static int __register_pernet_operations(struct list_head *list,
90119 int error;
90120 LIST_HEAD(net_exit_list);
90121
90122 - list_add_tail(&ops->list, list);
90123 + pax_list_add_tail((struct list_head *)&ops->list, list);
90124 if (ops->init || (ops->id && ops->size)) {
90125 for_each_net(net) {
90126 error = ops_init(ops, net);
90127 @@ -456,7 +456,7 @@ static int __register_pernet_operations(struct list_head *list,
90128
90129 out_undo:
90130 /* If I have an error cleanup all namespaces I initialized */
90131 - list_del(&ops->list);
90132 + pax_list_del((struct list_head *)&ops->list);
90133 ops_exit_list(ops, &net_exit_list);
90134 ops_free_list(ops, &net_exit_list);
90135 return error;
90136 @@ -467,7 +467,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
90137 struct net *net;
90138 LIST_HEAD(net_exit_list);
90139
90140 - list_del(&ops->list);
90141 + pax_list_del((struct list_head *)&ops->list);
90142 for_each_net(net)
90143 list_add_tail(&net->exit_list, &net_exit_list);
90144 ops_exit_list(ops, &net_exit_list);
90145 @@ -601,7 +601,7 @@ int register_pernet_device(struct pernet_operations *ops)
90146 mutex_lock(&net_mutex);
90147 error = register_pernet_operations(&pernet_list, ops);
90148 if (!error && (first_device == &pernet_list))
90149 - first_device = &ops->list;
90150 + first_device = (struct list_head *)&ops->list;
90151 mutex_unlock(&net_mutex);
90152 return error;
90153 }
90154 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
90155 index a08bd2b..c59bd7c 100644
90156 --- a/net/core/rtnetlink.c
90157 +++ b/net/core/rtnetlink.c
90158 @@ -58,7 +58,7 @@ struct rtnl_link {
90159 rtnl_doit_func doit;
90160 rtnl_dumpit_func dumpit;
90161 rtnl_calcit_func calcit;
90162 -};
90163 +} __no_const;
90164
90165 static DEFINE_MUTEX(rtnl_mutex);
90166
90167 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
90168 if (rtnl_link_ops_get(ops->kind))
90169 return -EEXIST;
90170
90171 - if (!ops->dellink)
90172 - ops->dellink = unregister_netdevice_queue;
90173 + if (!ops->dellink) {
90174 + pax_open_kernel();
90175 + *(void **)&ops->dellink = unregister_netdevice_queue;
90176 + pax_close_kernel();
90177 + }
90178
90179 - list_add_tail(&ops->list, &link_ops);
90180 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
90181 return 0;
90182 }
90183 EXPORT_SYMBOL_GPL(__rtnl_link_register);
90184 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
90185 for_each_net(net) {
90186 __rtnl_kill_links(net, ops);
90187 }
90188 - list_del(&ops->list);
90189 + pax_list_del((struct list_head *)&ops->list);
90190 }
90191 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
90192
90193 @@ -2374,7 +2377,7 @@ static int rtnl_bridge_getlink(struct sk_buff *skb, struct netlink_callback *cb)
90194 struct nlattr *extfilt;
90195 u32 filter_mask = 0;
90196
90197 - extfilt = nlmsg_find_attr(cb->nlh, sizeof(struct rtgenmsg),
90198 + extfilt = nlmsg_find_attr(cb->nlh, sizeof(struct ifinfomsg),
90199 IFLA_EXT_MASK);
90200 if (extfilt)
90201 filter_mask = nla_get_u32(extfilt);
90202 diff --git a/net/core/scm.c b/net/core/scm.c
90203 index 03795d0..eaf7368 100644
90204 --- a/net/core/scm.c
90205 +++ b/net/core/scm.c
90206 @@ -210,7 +210,7 @@ EXPORT_SYMBOL(__scm_send);
90207 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
90208 {
90209 struct cmsghdr __user *cm
90210 - = (__force struct cmsghdr __user *)msg->msg_control;
90211 + = (struct cmsghdr __force_user *)msg->msg_control;
90212 struct cmsghdr cmhdr;
90213 int cmlen = CMSG_LEN(len);
90214 int err;
90215 @@ -233,7 +233,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
90216 err = -EFAULT;
90217 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
90218 goto out;
90219 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
90220 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
90221 goto out;
90222 cmlen = CMSG_SPACE(len);
90223 if (msg->msg_controllen < cmlen)
90224 @@ -249,7 +249,7 @@ EXPORT_SYMBOL(put_cmsg);
90225 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
90226 {
90227 struct cmsghdr __user *cm
90228 - = (__force struct cmsghdr __user*)msg->msg_control;
90229 + = (struct cmsghdr __force_user *)msg->msg_control;
90230
90231 int fdmax = 0;
90232 int fdnum = scm->fp->count;
90233 @@ -269,7 +269,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
90234 if (fdnum < fdmax)
90235 fdmax = fdnum;
90236
90237 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
90238 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
90239 i++, cmfptr++)
90240 {
90241 struct socket *sock;
90242 diff --git a/net/core/skbuff.c b/net/core/skbuff.c
90243 index 1c1738c..4cab7f0 100644
90244 --- a/net/core/skbuff.c
90245 +++ b/net/core/skbuff.c
90246 @@ -3087,13 +3087,15 @@ void __init skb_init(void)
90247 skbuff_head_cache = kmem_cache_create("skbuff_head_cache",
90248 sizeof(struct sk_buff),
90249 0,
90250 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
90251 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
90252 + SLAB_NO_SANITIZE,
90253 NULL);
90254 skbuff_fclone_cache = kmem_cache_create("skbuff_fclone_cache",
90255 (2*sizeof(struct sk_buff)) +
90256 sizeof(atomic_t),
90257 0,
90258 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
90259 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
90260 + SLAB_NO_SANITIZE,
90261 NULL);
90262 }
90263
90264 diff --git a/net/core/sock.c b/net/core/sock.c
90265 index d6d024c..6ea7ab4 100644
90266 --- a/net/core/sock.c
90267 +++ b/net/core/sock.c
90268 @@ -390,7 +390,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
90269 struct sk_buff_head *list = &sk->sk_receive_queue;
90270
90271 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
90272 - atomic_inc(&sk->sk_drops);
90273 + atomic_inc_unchecked(&sk->sk_drops);
90274 trace_sock_rcvqueue_full(sk, skb);
90275 return -ENOMEM;
90276 }
90277 @@ -400,7 +400,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
90278 return err;
90279
90280 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
90281 - atomic_inc(&sk->sk_drops);
90282 + atomic_inc_unchecked(&sk->sk_drops);
90283 return -ENOBUFS;
90284 }
90285
90286 @@ -420,7 +420,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
90287 skb_dst_force(skb);
90288
90289 spin_lock_irqsave(&list->lock, flags);
90290 - skb->dropcount = atomic_read(&sk->sk_drops);
90291 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
90292 __skb_queue_tail(list, skb);
90293 spin_unlock_irqrestore(&list->lock, flags);
90294
90295 @@ -440,7 +440,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
90296 skb->dev = NULL;
90297
90298 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
90299 - atomic_inc(&sk->sk_drops);
90300 + atomic_inc_unchecked(&sk->sk_drops);
90301 goto discard_and_relse;
90302 }
90303 if (nested)
90304 @@ -458,7 +458,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
90305 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
90306 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
90307 bh_unlock_sock(sk);
90308 - atomic_inc(&sk->sk_drops);
90309 + atomic_inc_unchecked(&sk->sk_drops);
90310 goto discard_and_relse;
90311 }
90312
90313 @@ -933,12 +933,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
90314 struct timeval tm;
90315 } v;
90316
90317 - int lv = sizeof(int);
90318 - int len;
90319 + unsigned int lv = sizeof(int);
90320 + unsigned int len;
90321
90322 if (get_user(len, optlen))
90323 return -EFAULT;
90324 - if (len < 0)
90325 + if (len > INT_MAX)
90326 return -EINVAL;
90327
90328 memset(&v, 0, sizeof(v));
90329 @@ -1090,11 +1090,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
90330
90331 case SO_PEERNAME:
90332 {
90333 - char address[128];
90334 + char address[_K_SS_MAXSIZE];
90335
90336 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
90337 return -ENOTCONN;
90338 - if (lv < len)
90339 + if (lv < len || sizeof address < len)
90340 return -EINVAL;
90341 if (copy_to_user(optval, address, len))
90342 return -EFAULT;
90343 @@ -1161,7 +1161,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
90344
90345 if (len > lv)
90346 len = lv;
90347 - if (copy_to_user(optval, &v, len))
90348 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
90349 return -EFAULT;
90350 lenout:
90351 if (put_user(len, optlen))
90352 @@ -2277,7 +2277,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
90353 */
90354 smp_wmb();
90355 atomic_set(&sk->sk_refcnt, 1);
90356 - atomic_set(&sk->sk_drops, 0);
90357 + atomic_set_unchecked(&sk->sk_drops, 0);
90358 }
90359 EXPORT_SYMBOL(sock_init_data);
90360
90361 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
90362 index a0e9cf6..ef7f9ed 100644
90363 --- a/net/core/sock_diag.c
90364 +++ b/net/core/sock_diag.c
90365 @@ -9,26 +9,33 @@
90366 #include <linux/inet_diag.h>
90367 #include <linux/sock_diag.h>
90368
90369 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
90370 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
90371 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
90372 static DEFINE_MUTEX(sock_diag_table_mutex);
90373
90374 int sock_diag_check_cookie(void *sk, __u32 *cookie)
90375 {
90376 +#ifndef CONFIG_GRKERNSEC_HIDESYM
90377 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
90378 cookie[1] != INET_DIAG_NOCOOKIE) &&
90379 ((u32)(unsigned long)sk != cookie[0] ||
90380 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
90381 return -ESTALE;
90382 else
90383 +#endif
90384 return 0;
90385 }
90386 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
90387
90388 void sock_diag_save_cookie(void *sk, __u32 *cookie)
90389 {
90390 +#ifdef CONFIG_GRKERNSEC_HIDESYM
90391 + cookie[0] = 0;
90392 + cookie[1] = 0;
90393 +#else
90394 cookie[0] = (u32)(unsigned long)sk;
90395 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
90396 +#endif
90397 }
90398 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
90399
90400 @@ -113,8 +120,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
90401 mutex_lock(&sock_diag_table_mutex);
90402 if (sock_diag_handlers[hndl->family])
90403 err = -EBUSY;
90404 - else
90405 + else {
90406 + pax_open_kernel();
90407 sock_diag_handlers[hndl->family] = hndl;
90408 + pax_close_kernel();
90409 + }
90410 mutex_unlock(&sock_diag_table_mutex);
90411
90412 return err;
90413 @@ -130,7 +140,9 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
90414
90415 mutex_lock(&sock_diag_table_mutex);
90416 BUG_ON(sock_diag_handlers[family] != hnld);
90417 + pax_open_kernel();
90418 sock_diag_handlers[family] = NULL;
90419 + pax_close_kernel();
90420 mutex_unlock(&sock_diag_table_mutex);
90421 }
90422 EXPORT_SYMBOL_GPL(sock_diag_unregister);
90423 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
90424 index cfdb46a..cef55e1 100644
90425 --- a/net/core/sysctl_net_core.c
90426 +++ b/net/core/sysctl_net_core.c
90427 @@ -28,7 +28,7 @@ static int rps_sock_flow_sysctl(ctl_table *table, int write,
90428 {
90429 unsigned int orig_size, size;
90430 int ret, i;
90431 - ctl_table tmp = {
90432 + ctl_table_no_const tmp = {
90433 .data = &size,
90434 .maxlen = sizeof(size),
90435 .mode = table->mode
90436 @@ -211,13 +211,12 @@ static struct ctl_table netns_core_table[] = {
90437
90438 static __net_init int sysctl_core_net_init(struct net *net)
90439 {
90440 - struct ctl_table *tbl;
90441 + ctl_table_no_const *tbl = NULL;
90442
90443 net->core.sysctl_somaxconn = SOMAXCONN;
90444
90445 - tbl = netns_core_table;
90446 if (!net_eq(net, &init_net)) {
90447 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
90448 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
90449 if (tbl == NULL)
90450 goto err_dup;
90451
90452 @@ -227,17 +226,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
90453 if (net->user_ns != &init_user_ns) {
90454 tbl[0].procname = NULL;
90455 }
90456 - }
90457 -
90458 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
90459 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
90460 + } else
90461 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
90462 if (net->core.sysctl_hdr == NULL)
90463 goto err_reg;
90464
90465 return 0;
90466
90467 err_reg:
90468 - if (tbl != netns_core_table)
90469 - kfree(tbl);
90470 + kfree(tbl);
90471 err_dup:
90472 return -ENOMEM;
90473 }
90474 @@ -252,7 +250,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
90475 kfree(tbl);
90476 }
90477
90478 -static __net_initdata struct pernet_operations sysctl_core_ops = {
90479 +static __net_initconst struct pernet_operations sysctl_core_ops = {
90480 .init = sysctl_core_net_init,
90481 .exit = sysctl_core_net_exit,
90482 };
90483 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
90484 index c21f200..bc4565b 100644
90485 --- a/net/decnet/af_decnet.c
90486 +++ b/net/decnet/af_decnet.c
90487 @@ -465,6 +465,7 @@ static struct proto dn_proto = {
90488 .sysctl_rmem = sysctl_decnet_rmem,
90489 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
90490 .obj_size = sizeof(struct dn_sock),
90491 + .slab_flags = SLAB_USERCOPY,
90492 };
90493
90494 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
90495 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
90496 index a55eecc..dd8428c 100644
90497 --- a/net/decnet/sysctl_net_decnet.c
90498 +++ b/net/decnet/sysctl_net_decnet.c
90499 @@ -174,7 +174,7 @@ static int dn_node_address_handler(ctl_table *table, int write,
90500
90501 if (len > *lenp) len = *lenp;
90502
90503 - if (copy_to_user(buffer, addr, len))
90504 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
90505 return -EFAULT;
90506
90507 *lenp = len;
90508 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(ctl_table *table, int write,
90509
90510 if (len > *lenp) len = *lenp;
90511
90512 - if (copy_to_user(buffer, devname, len))
90513 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
90514 return -EFAULT;
90515
90516 *lenp = len;
90517 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
90518 index d01be2a..8976537 100644
90519 --- a/net/ipv4/af_inet.c
90520 +++ b/net/ipv4/af_inet.c
90521 @@ -1703,13 +1703,9 @@ static int __init inet_init(void)
90522
90523 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > FIELD_SIZEOF(struct sk_buff, cb));
90524
90525 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
90526 - if (!sysctl_local_reserved_ports)
90527 - goto out;
90528 -
90529 rc = proto_register(&tcp_prot, 1);
90530 if (rc)
90531 - goto out_free_reserved_ports;
90532 + goto out;
90533
90534 rc = proto_register(&udp_prot, 1);
90535 if (rc)
90536 @@ -1818,8 +1814,6 @@ out_unregister_udp_proto:
90537 proto_unregister(&udp_prot);
90538 out_unregister_tcp_proto:
90539 proto_unregister(&tcp_prot);
90540 -out_free_reserved_ports:
90541 - kfree(sysctl_local_reserved_ports);
90542 goto out;
90543 }
90544
90545 diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
90546 index 2e7f194..0fa4d6d 100644
90547 --- a/net/ipv4/ah4.c
90548 +++ b/net/ipv4/ah4.c
90549 @@ -420,7 +420,7 @@ static void ah4_err(struct sk_buff *skb, u32 info)
90550 return;
90551
90552 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
90553 - atomic_inc(&flow_cache_genid);
90554 + atomic_inc_unchecked(&flow_cache_genid);
90555 rt_genid_bump(net);
90556
90557 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_AH, 0);
90558 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
90559 index dfc39d4..0d4fa52 100644
90560 --- a/net/ipv4/devinet.c
90561 +++ b/net/ipv4/devinet.c
90562 @@ -771,7 +771,7 @@ static struct in_ifaddr *rtm_to_ifaddr(struct net *net, struct nlmsghdr *nlh,
90563 ci = nla_data(tb[IFA_CACHEINFO]);
90564 if (!ci->ifa_valid || ci->ifa_prefered > ci->ifa_valid) {
90565 err = -EINVAL;
90566 - goto errout;
90567 + goto errout_free;
90568 }
90569 *pvalid_lft = ci->ifa_valid;
90570 *pprefered_lft = ci->ifa_prefered;
90571 @@ -779,6 +779,8 @@ static struct in_ifaddr *rtm_to_ifaddr(struct net *net, struct nlmsghdr *nlh,
90572
90573 return ifa;
90574
90575 +errout_free:
90576 + inet_free_ifa(ifa);
90577 errout:
90578 return ERR_PTR(err);
90579 }
90580 @@ -1529,7 +1531,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
90581 idx = 0;
90582 head = &net->dev_index_head[h];
90583 rcu_read_lock();
90584 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
90585 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
90586 net->dev_base_seq;
90587 hlist_for_each_entry_rcu(dev, head, index_hlist) {
90588 if (idx < s_idx)
90589 @@ -1840,7 +1842,7 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb,
90590 idx = 0;
90591 head = &net->dev_index_head[h];
90592 rcu_read_lock();
90593 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
90594 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
90595 net->dev_base_seq;
90596 hlist_for_each_entry_rcu(dev, head, index_hlist) {
90597 if (idx < s_idx)
90598 @@ -2065,7 +2067,7 @@ static int ipv4_doint_and_flush(ctl_table *ctl, int write,
90599 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
90600 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
90601
90602 -static struct devinet_sysctl_table {
90603 +static const struct devinet_sysctl_table {
90604 struct ctl_table_header *sysctl_header;
90605 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
90606 } devinet_sysctl = {
90607 @@ -2183,7 +2185,7 @@ static __net_init int devinet_init_net(struct net *net)
90608 int err;
90609 struct ipv4_devconf *all, *dflt;
90610 #ifdef CONFIG_SYSCTL
90611 - struct ctl_table *tbl = ctl_forward_entry;
90612 + ctl_table_no_const *tbl = NULL;
90613 struct ctl_table_header *forw_hdr;
90614 #endif
90615
90616 @@ -2201,7 +2203,7 @@ static __net_init int devinet_init_net(struct net *net)
90617 goto err_alloc_dflt;
90618
90619 #ifdef CONFIG_SYSCTL
90620 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
90621 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
90622 if (tbl == NULL)
90623 goto err_alloc_ctl;
90624
90625 @@ -2221,7 +2223,10 @@ static __net_init int devinet_init_net(struct net *net)
90626 goto err_reg_dflt;
90627
90628 err = -ENOMEM;
90629 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
90630 + if (!net_eq(net, &init_net))
90631 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
90632 + else
90633 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
90634 if (forw_hdr == NULL)
90635 goto err_reg_ctl;
90636 net->ipv4.forw_hdr = forw_hdr;
90637 @@ -2237,8 +2242,7 @@ err_reg_ctl:
90638 err_reg_dflt:
90639 __devinet_sysctl_unregister(all);
90640 err_reg_all:
90641 - if (tbl != ctl_forward_entry)
90642 - kfree(tbl);
90643 + kfree(tbl);
90644 err_alloc_ctl:
90645 #endif
90646 if (dflt != &ipv4_devconf_dflt)
90647 diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
90648 index 4cfe34d..d2fac8a 100644
90649 --- a/net/ipv4/esp4.c
90650 +++ b/net/ipv4/esp4.c
90651 @@ -477,7 +477,7 @@ static u32 esp4_get_mtu(struct xfrm_state *x, int mtu)
90652 }
90653
90654 return ((mtu - x->props.header_len - crypto_aead_authsize(esp->aead) -
90655 - net_adj) & ~(align - 1)) + (net_adj - 2);
90656 + net_adj) & ~(align - 1)) + net_adj - 2;
90657 }
90658
90659 static void esp4_err(struct sk_buff *skb, u32 info)
90660 @@ -503,7 +503,7 @@ static void esp4_err(struct sk_buff *skb, u32 info)
90661 return;
90662
90663 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
90664 - atomic_inc(&flow_cache_genid);
90665 + atomic_inc_unchecked(&flow_cache_genid);
90666 rt_genid_bump(net);
90667
90668 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_ESP, 0);
90669 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
90670 index c7629a2..b62d139 100644
90671 --- a/net/ipv4/fib_frontend.c
90672 +++ b/net/ipv4/fib_frontend.c
90673 @@ -1017,12 +1017,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
90674 #ifdef CONFIG_IP_ROUTE_MULTIPATH
90675 fib_sync_up(dev);
90676 #endif
90677 - atomic_inc(&net->ipv4.dev_addr_genid);
90678 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
90679 rt_cache_flush(dev_net(dev));
90680 break;
90681 case NETDEV_DOWN:
90682 fib_del_ifaddr(ifa, NULL);
90683 - atomic_inc(&net->ipv4.dev_addr_genid);
90684 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
90685 if (ifa->ifa_dev->ifa_list == NULL) {
90686 /* Last address was deleted from this interface.
90687 * Disable IP.
90688 @@ -1058,7 +1058,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
90689 #ifdef CONFIG_IP_ROUTE_MULTIPATH
90690 fib_sync_up(dev);
90691 #endif
90692 - atomic_inc(&net->ipv4.dev_addr_genid);
90693 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
90694 rt_cache_flush(net);
90695 break;
90696 case NETDEV_DOWN:
90697 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
90698 index 8f6cb7a..34507f9 100644
90699 --- a/net/ipv4/fib_semantics.c
90700 +++ b/net/ipv4/fib_semantics.c
90701 @@ -765,7 +765,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
90702 nh->nh_saddr = inet_select_addr(nh->nh_dev,
90703 nh->nh_gw,
90704 nh->nh_parent->fib_scope);
90705 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
90706 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
90707
90708 return nh->nh_saddr;
90709 }
90710 diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
90711 index 49616fe..6e8a13d 100644
90712 --- a/net/ipv4/fib_trie.c
90713 +++ b/net/ipv4/fib_trie.c
90714 @@ -71,7 +71,6 @@
90715 #include <linux/init.h>
90716 #include <linux/list.h>
90717 #include <linux/slab.h>
90718 -#include <linux/prefetch.h>
90719 #include <linux/export.h>
90720 #include <net/net_namespace.h>
90721 #include <net/ip.h>
90722 @@ -1761,10 +1760,8 @@ static struct leaf *leaf_walk_rcu(struct tnode *p, struct rt_trie_node *c)
90723 if (!c)
90724 continue;
90725
90726 - if (IS_LEAF(c)) {
90727 - prefetch(rcu_dereference_rtnl(p->child[idx]));
90728 + if (IS_LEAF(c))
90729 return (struct leaf *) c;
90730 - }
90731
90732 /* Rescan start scanning in new node */
90733 p = (struct tnode *) c;
90734 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
90735 index 6acb541..9ea617d 100644
90736 --- a/net/ipv4/inet_connection_sock.c
90737 +++ b/net/ipv4/inet_connection_sock.c
90738 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
90739 .range = { 32768, 61000 },
90740 };
90741
90742 -unsigned long *sysctl_local_reserved_ports;
90743 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
90744 EXPORT_SYMBOL(sysctl_local_reserved_ports);
90745
90746 void inet_get_local_port_range(int *low, int *high)
90747 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
90748 index 6af375a..c493c74 100644
90749 --- a/net/ipv4/inet_hashtables.c
90750 +++ b/net/ipv4/inet_hashtables.c
90751 @@ -18,12 +18,15 @@
90752 #include <linux/sched.h>
90753 #include <linux/slab.h>
90754 #include <linux/wait.h>
90755 +#include <linux/security.h>
90756
90757 #include <net/inet_connection_sock.h>
90758 #include <net/inet_hashtables.h>
90759 #include <net/secure_seq.h>
90760 #include <net/ip.h>
90761
90762 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
90763 +
90764 /*
90765 * Allocate and initialize a new local port bind bucket.
90766 * The bindhash mutex for snum's hash chain must be held here.
90767 @@ -554,6 +557,8 @@ ok:
90768 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
90769 spin_unlock(&head->lock);
90770
90771 + gr_update_task_in_ip_table(current, inet_sk(sk));
90772 +
90773 if (tw) {
90774 inet_twsk_deschedule(tw, death_row);
90775 while (twrefcnt) {
90776 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
90777 index 000e3d2..5472da3 100644
90778 --- a/net/ipv4/inetpeer.c
90779 +++ b/net/ipv4/inetpeer.c
90780 @@ -503,8 +503,8 @@ relookup:
90781 if (p) {
90782 p->daddr = *daddr;
90783 atomic_set(&p->refcnt, 1);
90784 - atomic_set(&p->rid, 0);
90785 - atomic_set(&p->ip_id_count,
90786 + atomic_set_unchecked(&p->rid, 0);
90787 + atomic_set_unchecked(&p->ip_id_count,
90788 (daddr->family == AF_INET) ?
90789 secure_ip_id(daddr->addr.a4) :
90790 secure_ipv6_id(daddr->addr.a6));
90791 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
90792 index b66910a..cfe416e 100644
90793 --- a/net/ipv4/ip_fragment.c
90794 +++ b/net/ipv4/ip_fragment.c
90795 @@ -282,7 +282,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
90796 return 0;
90797
90798 start = qp->rid;
90799 - end = atomic_inc_return(&peer->rid);
90800 + end = atomic_inc_return_unchecked(&peer->rid);
90801 qp->rid = end;
90802
90803 rc = qp->q.fragments && (end - start) > max;
90804 @@ -759,12 +759,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
90805
90806 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
90807 {
90808 - struct ctl_table *table;
90809 + ctl_table_no_const *table = NULL;
90810 struct ctl_table_header *hdr;
90811
90812 - table = ip4_frags_ns_ctl_table;
90813 if (!net_eq(net, &init_net)) {
90814 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
90815 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
90816 if (table == NULL)
90817 goto err_alloc;
90818
90819 @@ -775,9 +774,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
90820 /* Don't export sysctls to unprivileged users */
90821 if (net->user_ns != &init_user_ns)
90822 table[0].procname = NULL;
90823 - }
90824 + hdr = register_net_sysctl(net, "net/ipv4", table);
90825 + } else
90826 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
90827
90828 - hdr = register_net_sysctl(net, "net/ipv4", table);
90829 if (hdr == NULL)
90830 goto err_reg;
90831
90832 @@ -785,8 +785,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
90833 return 0;
90834
90835 err_reg:
90836 - if (!net_eq(net, &init_net))
90837 - kfree(table);
90838 + kfree(table);
90839 err_alloc:
90840 return -ENOMEM;
90841 }
90842 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
90843 index 855004f..9644112 100644
90844 --- a/net/ipv4/ip_gre.c
90845 +++ b/net/ipv4/ip_gre.c
90846 @@ -115,7 +115,7 @@ static bool log_ecn_error = true;
90847 module_param(log_ecn_error, bool, 0644);
90848 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
90849
90850 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
90851 +static struct rtnl_link_ops ipgre_link_ops;
90852 static int ipgre_tunnel_init(struct net_device *dev);
90853
90854 static int ipgre_net_id __read_mostly;
90855 @@ -572,7 +572,7 @@ static int ipgre_header(struct sk_buff *skb, struct net_device *dev,
90856 if (daddr)
90857 memcpy(&iph->daddr, daddr, 4);
90858 if (iph->daddr)
90859 - return t->hlen;
90860 + return t->hlen + sizeof(*iph);
90861
90862 return -(t->hlen + sizeof(*iph));
90863 }
90864 @@ -919,7 +919,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
90865 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
90866 };
90867
90868 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
90869 +static struct rtnl_link_ops ipgre_link_ops = {
90870 .kind = "gre",
90871 .maxtype = IFLA_GRE_MAX,
90872 .policy = ipgre_policy,
90873 @@ -933,7 +933,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
90874 .fill_info = ipgre_fill_info,
90875 };
90876
90877 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
90878 +static struct rtnl_link_ops ipgre_tap_ops = {
90879 .kind = "gretap",
90880 .maxtype = IFLA_GRE_MAX,
90881 .policy = ipgre_policy,
90882 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
90883 index d9c4f11..02b82dbc 100644
90884 --- a/net/ipv4/ip_sockglue.c
90885 +++ b/net/ipv4/ip_sockglue.c
90886 @@ -1152,7 +1152,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
90887 len = min_t(unsigned int, len, opt->optlen);
90888 if (put_user(len, optlen))
90889 return -EFAULT;
90890 - if (copy_to_user(optval, opt->__data, len))
90891 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
90892 + copy_to_user(optval, opt->__data, len))
90893 return -EFAULT;
90894 return 0;
90895 }
90896 @@ -1283,7 +1284,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
90897 if (sk->sk_type != SOCK_STREAM)
90898 return -ENOPROTOOPT;
90899
90900 - msg.msg_control = optval;
90901 + msg.msg_control = (void __force_kernel *)optval;
90902 msg.msg_controllen = len;
90903 msg.msg_flags = flags;
90904
90905 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
90906 index 17cc0ff..63856c4 100644
90907 --- a/net/ipv4/ip_vti.c
90908 +++ b/net/ipv4/ip_vti.c
90909 @@ -47,7 +47,7 @@
90910 #define HASH_SIZE 16
90911 #define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&(HASH_SIZE-1))
90912
90913 -static struct rtnl_link_ops vti_link_ops __read_mostly;
90914 +static struct rtnl_link_ops vti_link_ops;
90915
90916 static int vti_net_id __read_mostly;
90917 struct vti_net {
90918 @@ -840,7 +840,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
90919 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
90920 };
90921
90922 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
90923 +static struct rtnl_link_ops vti_link_ops = {
90924 .kind = "vti",
90925 .maxtype = IFLA_VTI_MAX,
90926 .policy = vti_policy,
90927 diff --git a/net/ipv4/ipcomp.c b/net/ipv4/ipcomp.c
90928 index 59cb8c7..a72160c 100644
90929 --- a/net/ipv4/ipcomp.c
90930 +++ b/net/ipv4/ipcomp.c
90931 @@ -48,7 +48,7 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info)
90932 return;
90933
90934 if (icmp_hdr(skb)->type == ICMP_DEST_UNREACH) {
90935 - atomic_inc(&flow_cache_genid);
90936 + atomic_inc_unchecked(&flow_cache_genid);
90937 rt_genid_bump(net);
90938
90939 ipv4_update_pmtu(skb, net, info, 0, 0, IPPROTO_COMP, 0);
90940 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
90941 index efa1138..20dbba0 100644
90942 --- a/net/ipv4/ipconfig.c
90943 +++ b/net/ipv4/ipconfig.c
90944 @@ -334,7 +334,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
90945
90946 mm_segment_t oldfs = get_fs();
90947 set_fs(get_ds());
90948 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
90949 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
90950 set_fs(oldfs);
90951 return res;
90952 }
90953 @@ -345,7 +345,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
90954
90955 mm_segment_t oldfs = get_fs();
90956 set_fs(get_ds());
90957 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
90958 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
90959 set_fs(oldfs);
90960 return res;
90961 }
90962 @@ -356,7 +356,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
90963
90964 mm_segment_t oldfs = get_fs();
90965 set_fs(get_ds());
90966 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
90967 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
90968 set_fs(oldfs);
90969 return res;
90970 }
90971 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
90972 index 7cfc456..e726868 100644
90973 --- a/net/ipv4/ipip.c
90974 +++ b/net/ipv4/ipip.c
90975 @@ -124,7 +124,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
90976 static int ipip_net_id __read_mostly;
90977
90978 static int ipip_tunnel_init(struct net_device *dev);
90979 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
90980 +static struct rtnl_link_ops ipip_link_ops;
90981
90982 static int ipip_err(struct sk_buff *skb, u32 info)
90983 {
90984 @@ -406,7 +406,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
90985 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
90986 };
90987
90988 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
90989 +static struct rtnl_link_ops ipip_link_ops = {
90990 .kind = "ipip",
90991 .maxtype = IFLA_IPTUN_MAX,
90992 .policy = ipip_policy,
90993 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
90994 index 85a4f21..1beb1f5 100644
90995 --- a/net/ipv4/netfilter/arp_tables.c
90996 +++ b/net/ipv4/netfilter/arp_tables.c
90997 @@ -880,14 +880,14 @@ static int compat_table_info(const struct xt_table_info *info,
90998 #endif
90999
91000 static int get_info(struct net *net, void __user *user,
91001 - const int *len, int compat)
91002 + int len, int compat)
91003 {
91004 char name[XT_TABLE_MAXNAMELEN];
91005 struct xt_table *t;
91006 int ret;
91007
91008 - if (*len != sizeof(struct arpt_getinfo)) {
91009 - duprintf("length %u != %Zu\n", *len,
91010 + if (len != sizeof(struct arpt_getinfo)) {
91011 + duprintf("length %u != %Zu\n", len,
91012 sizeof(struct arpt_getinfo));
91013 return -EINVAL;
91014 }
91015 @@ -924,7 +924,7 @@ static int get_info(struct net *net, void __user *user,
91016 info.size = private->size;
91017 strcpy(info.name, name);
91018
91019 - if (copy_to_user(user, &info, *len) != 0)
91020 + if (copy_to_user(user, &info, len) != 0)
91021 ret = -EFAULT;
91022 else
91023 ret = 0;
91024 @@ -1683,7 +1683,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
91025
91026 switch (cmd) {
91027 case ARPT_SO_GET_INFO:
91028 - ret = get_info(sock_net(sk), user, len, 1);
91029 + ret = get_info(sock_net(sk), user, *len, 1);
91030 break;
91031 case ARPT_SO_GET_ENTRIES:
91032 ret = compat_get_entries(sock_net(sk), user, len);
91033 @@ -1728,7 +1728,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
91034
91035 switch (cmd) {
91036 case ARPT_SO_GET_INFO:
91037 - ret = get_info(sock_net(sk), user, len, 0);
91038 + ret = get_info(sock_net(sk), user, *len, 0);
91039 break;
91040
91041 case ARPT_SO_GET_ENTRIES:
91042 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
91043 index d23118d..6ad7277 100644
91044 --- a/net/ipv4/netfilter/ip_tables.c
91045 +++ b/net/ipv4/netfilter/ip_tables.c
91046 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
91047 #endif
91048
91049 static int get_info(struct net *net, void __user *user,
91050 - const int *len, int compat)
91051 + int len, int compat)
91052 {
91053 char name[XT_TABLE_MAXNAMELEN];
91054 struct xt_table *t;
91055 int ret;
91056
91057 - if (*len != sizeof(struct ipt_getinfo)) {
91058 - duprintf("length %u != %zu\n", *len,
91059 + if (len != sizeof(struct ipt_getinfo)) {
91060 + duprintf("length %u != %zu\n", len,
91061 sizeof(struct ipt_getinfo));
91062 return -EINVAL;
91063 }
91064 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
91065 info.size = private->size;
91066 strcpy(info.name, name);
91067
91068 - if (copy_to_user(user, &info, *len) != 0)
91069 + if (copy_to_user(user, &info, len) != 0)
91070 ret = -EFAULT;
91071 else
91072 ret = 0;
91073 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
91074
91075 switch (cmd) {
91076 case IPT_SO_GET_INFO:
91077 - ret = get_info(sock_net(sk), user, len, 1);
91078 + ret = get_info(sock_net(sk), user, *len, 1);
91079 break;
91080 case IPT_SO_GET_ENTRIES:
91081 ret = compat_get_entries(sock_net(sk), user, len);
91082 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
91083
91084 switch (cmd) {
91085 case IPT_SO_GET_INFO:
91086 - ret = get_info(sock_net(sk), user, len, 0);
91087 + ret = get_info(sock_net(sk), user, *len, 0);
91088 break;
91089
91090 case IPT_SO_GET_ENTRIES:
91091 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
91092 index 7d93d62..cbbf2a3 100644
91093 --- a/net/ipv4/ping.c
91094 +++ b/net/ipv4/ping.c
91095 @@ -843,7 +843,7 @@ static void ping_format_sock(struct sock *sp, struct seq_file *f,
91096 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
91097 0, sock_i_ino(sp),
91098 atomic_read(&sp->sk_refcnt), sp,
91099 - atomic_read(&sp->sk_drops), len);
91100 + atomic_read_unchecked(&sp->sk_drops), len);
91101 }
91102
91103 static int ping_seq_show(struct seq_file *seq, void *v)
91104 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
91105 index dd44e0a..06dcca4 100644
91106 --- a/net/ipv4/raw.c
91107 +++ b/net/ipv4/raw.c
91108 @@ -309,7 +309,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
91109 int raw_rcv(struct sock *sk, struct sk_buff *skb)
91110 {
91111 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
91112 - atomic_inc(&sk->sk_drops);
91113 + atomic_inc_unchecked(&sk->sk_drops);
91114 kfree_skb(skb);
91115 return NET_RX_DROP;
91116 }
91117 @@ -745,16 +745,20 @@ static int raw_init(struct sock *sk)
91118
91119 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
91120 {
91121 + struct icmp_filter filter;
91122 +
91123 if (optlen > sizeof(struct icmp_filter))
91124 optlen = sizeof(struct icmp_filter);
91125 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
91126 + if (copy_from_user(&filter, optval, optlen))
91127 return -EFAULT;
91128 + raw_sk(sk)->filter = filter;
91129 return 0;
91130 }
91131
91132 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
91133 {
91134 int len, ret = -EFAULT;
91135 + struct icmp_filter filter;
91136
91137 if (get_user(len, optlen))
91138 goto out;
91139 @@ -764,8 +768,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
91140 if (len > sizeof(struct icmp_filter))
91141 len = sizeof(struct icmp_filter);
91142 ret = -EFAULT;
91143 - if (put_user(len, optlen) ||
91144 - copy_to_user(optval, &raw_sk(sk)->filter, len))
91145 + filter = raw_sk(sk)->filter;
91146 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
91147 goto out;
91148 ret = 0;
91149 out: return ret;
91150 @@ -994,7 +998,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
91151 0, 0L, 0,
91152 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
91153 0, sock_i_ino(sp),
91154 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
91155 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
91156 }
91157
91158 static int raw_seq_show(struct seq_file *seq, void *v)
91159 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
91160 index d35bbf0..faa3ab8 100644
91161 --- a/net/ipv4/route.c
91162 +++ b/net/ipv4/route.c
91163 @@ -2558,34 +2558,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
91164 .maxlen = sizeof(int),
91165 .mode = 0200,
91166 .proc_handler = ipv4_sysctl_rtcache_flush,
91167 + .extra1 = &init_net,
91168 },
91169 { },
91170 };
91171
91172 static __net_init int sysctl_route_net_init(struct net *net)
91173 {
91174 - struct ctl_table *tbl;
91175 + ctl_table_no_const *tbl = NULL;
91176
91177 - tbl = ipv4_route_flush_table;
91178 if (!net_eq(net, &init_net)) {
91179 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
91180 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
91181 if (tbl == NULL)
91182 goto err_dup;
91183
91184 /* Don't export sysctls to unprivileged users */
91185 if (net->user_ns != &init_user_ns)
91186 tbl[0].procname = NULL;
91187 - }
91188 - tbl[0].extra1 = net;
91189 + tbl[0].extra1 = net;
91190 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
91191 + } else
91192 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
91193
91194 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
91195 if (net->ipv4.route_hdr == NULL)
91196 goto err_reg;
91197 return 0;
91198
91199 err_reg:
91200 - if (tbl != ipv4_route_flush_table)
91201 - kfree(tbl);
91202 + kfree(tbl);
91203 err_dup:
91204 return -ENOMEM;
91205 }
91206 @@ -2608,7 +2608,7 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
91207
91208 static __net_init int rt_genid_init(struct net *net)
91209 {
91210 - atomic_set(&net->rt_genid, 0);
91211 + atomic_set_unchecked(&net->rt_genid, 0);
91212 get_random_bytes(&net->ipv4.dev_addr_genid,
91213 sizeof(net->ipv4.dev_addr_genid));
91214 return 0;
91215 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
91216 index 3f25e75..3ae0f4d 100644
91217 --- a/net/ipv4/sysctl_net_ipv4.c
91218 +++ b/net/ipv4/sysctl_net_ipv4.c
91219 @@ -57,7 +57,7 @@ static int ipv4_local_port_range(ctl_table *table, int write,
91220 {
91221 int ret;
91222 int range[2];
91223 - ctl_table tmp = {
91224 + ctl_table_no_const tmp = {
91225 .data = &range,
91226 .maxlen = sizeof(range),
91227 .mode = table->mode,
91228 @@ -110,7 +110,7 @@ static int ipv4_ping_group_range(ctl_table *table, int write,
91229 int ret;
91230 gid_t urange[2];
91231 kgid_t low, high;
91232 - ctl_table tmp = {
91233 + ctl_table_no_const tmp = {
91234 .data = &urange,
91235 .maxlen = sizeof(urange),
91236 .mode = table->mode,
91237 @@ -141,7 +141,7 @@ static int proc_tcp_congestion_control(ctl_table *ctl, int write,
91238 void __user *buffer, size_t *lenp, loff_t *ppos)
91239 {
91240 char val[TCP_CA_NAME_MAX];
91241 - ctl_table tbl = {
91242 + ctl_table_no_const tbl = {
91243 .data = val,
91244 .maxlen = TCP_CA_NAME_MAX,
91245 };
91246 @@ -160,7 +160,7 @@ static int proc_tcp_available_congestion_control(ctl_table *ctl,
91247 void __user *buffer, size_t *lenp,
91248 loff_t *ppos)
91249 {
91250 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
91251 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
91252 int ret;
91253
91254 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
91255 @@ -177,7 +177,7 @@ static int proc_allowed_congestion_control(ctl_table *ctl,
91256 void __user *buffer, size_t *lenp,
91257 loff_t *ppos)
91258 {
91259 - ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
91260 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
91261 int ret;
91262
91263 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
91264 @@ -203,15 +203,17 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
91265 struct mem_cgroup *memcg;
91266 #endif
91267
91268 - ctl_table tmp = {
91269 + ctl_table_no_const tmp = {
91270 .data = &vec,
91271 .maxlen = sizeof(vec),
91272 .mode = ctl->mode,
91273 };
91274
91275 if (!write) {
91276 - ctl->data = &net->ipv4.sysctl_tcp_mem;
91277 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
91278 + ctl_table_no_const tcp_mem = *ctl;
91279 +
91280 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
91281 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
91282 }
91283
91284 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
91285 @@ -238,7 +240,7 @@ static int ipv4_tcp_mem(ctl_table *ctl, int write,
91286 static int proc_tcp_fastopen_key(ctl_table *ctl, int write, void __user *buffer,
91287 size_t *lenp, loff_t *ppos)
91288 {
91289 - ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
91290 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
91291 struct tcp_fastopen_context *ctxt;
91292 int ret;
91293 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
91294 @@ -481,7 +483,7 @@ static struct ctl_table ipv4_table[] = {
91295 },
91296 {
91297 .procname = "ip_local_reserved_ports",
91298 - .data = NULL, /* initialized in sysctl_ipv4_init */
91299 + .data = sysctl_local_reserved_ports,
91300 .maxlen = 65536,
91301 .mode = 0644,
91302 .proc_handler = proc_do_large_bitmap,
91303 @@ -846,11 +848,10 @@ static struct ctl_table ipv4_net_table[] = {
91304
91305 static __net_init int ipv4_sysctl_init_net(struct net *net)
91306 {
91307 - struct ctl_table *table;
91308 + ctl_table_no_const *table = NULL;
91309
91310 - table = ipv4_net_table;
91311 if (!net_eq(net, &init_net)) {
91312 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
91313 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
91314 if (table == NULL)
91315 goto err_alloc;
91316
91317 @@ -885,15 +886,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
91318
91319 tcp_init_mem(net);
91320
91321 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
91322 + if (!net_eq(net, &init_net))
91323 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
91324 + else
91325 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
91326 if (net->ipv4.ipv4_hdr == NULL)
91327 goto err_reg;
91328
91329 return 0;
91330
91331 err_reg:
91332 - if (!net_eq(net, &init_net))
91333 - kfree(table);
91334 + kfree(table);
91335 err_alloc:
91336 return -ENOMEM;
91337 }
91338 @@ -915,16 +918,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
91339 static __init int sysctl_ipv4_init(void)
91340 {
91341 struct ctl_table_header *hdr;
91342 - struct ctl_table *i;
91343 -
91344 - for (i = ipv4_table; i->procname; i++) {
91345 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
91346 - i->data = sysctl_local_reserved_ports;
91347 - break;
91348 - }
91349 - }
91350 - if (!i->procname)
91351 - return -EINVAL;
91352
91353 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
91354 if (hdr == NULL)
91355 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
91356 index 9c62257..651cc27 100644
91357 --- a/net/ipv4/tcp_input.c
91358 +++ b/net/ipv4/tcp_input.c
91359 @@ -4436,7 +4436,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
91360 * simplifies code)
91361 */
91362 static void
91363 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
91364 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
91365 struct sk_buff *head, struct sk_buff *tail,
91366 u32 start, u32 end)
91367 {
91368 @@ -5522,6 +5522,7 @@ discard:
91369 tcp_paws_reject(&tp->rx_opt, 0))
91370 goto discard_and_undo;
91371
91372 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
91373 if (th->syn) {
91374 /* We see SYN without ACK. It is attempt of
91375 * simultaneous connect with crossed SYNs.
91376 @@ -5572,6 +5573,7 @@ discard:
91377 goto discard;
91378 #endif
91379 }
91380 +#endif
91381 /* "fifth, if neither of the SYN or RST bits is set then
91382 * drop the segment and return."
91383 */
91384 @@ -5616,7 +5618,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
91385 goto discard;
91386
91387 if (th->syn) {
91388 - if (th->fin)
91389 + if (th->fin || th->urg || th->psh)
91390 goto discard;
91391 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
91392 return 1;
91393 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
91394 index 7999fc5..c812f42 100644
91395 --- a/net/ipv4/tcp_ipv4.c
91396 +++ b/net/ipv4/tcp_ipv4.c
91397 @@ -90,6 +90,10 @@ int sysctl_tcp_low_latency __read_mostly;
91398 EXPORT_SYMBOL(sysctl_tcp_low_latency);
91399
91400
91401 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
91402 +extern int grsec_enable_blackhole;
91403 +#endif
91404 +
91405 #ifdef CONFIG_TCP_MD5SIG
91406 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
91407 __be32 daddr, __be32 saddr, const struct tcphdr *th);
91408 @@ -1855,6 +1859,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
91409 return 0;
91410
91411 reset:
91412 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
91413 + if (!grsec_enable_blackhole)
91414 +#endif
91415 tcp_v4_send_reset(rsk, skb);
91416 discard:
91417 kfree_skb(skb);
91418 @@ -2000,12 +2007,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
91419 TCP_SKB_CB(skb)->sacked = 0;
91420
91421 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
91422 - if (!sk)
91423 + if (!sk) {
91424 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
91425 + ret = 1;
91426 +#endif
91427 goto no_tcp_socket;
91428 -
91429 + }
91430 process:
91431 - if (sk->sk_state == TCP_TIME_WAIT)
91432 + if (sk->sk_state == TCP_TIME_WAIT) {
91433 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
91434 + ret = 2;
91435 +#endif
91436 goto do_time_wait;
91437 + }
91438
91439 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
91440 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
91441 @@ -2058,6 +2072,10 @@ csum_error:
91442 bad_packet:
91443 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
91444 } else {
91445 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
91446 + if (!grsec_enable_blackhole || (ret == 1 &&
91447 + (skb->dev->flags & IFF_LOOPBACK)))
91448 +#endif
91449 tcp_v4_send_reset(NULL, skb);
91450 }
91451
91452 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
91453 index 0f01788..d52a859 100644
91454 --- a/net/ipv4/tcp_minisocks.c
91455 +++ b/net/ipv4/tcp_minisocks.c
91456 @@ -27,6 +27,10 @@
91457 #include <net/inet_common.h>
91458 #include <net/xfrm.h>
91459
91460 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
91461 +extern int grsec_enable_blackhole;
91462 +#endif
91463 +
91464 int sysctl_tcp_syncookies __read_mostly = 1;
91465 EXPORT_SYMBOL(sysctl_tcp_syncookies);
91466
91467 @@ -717,7 +721,10 @@ embryonic_reset:
91468 * avoid becoming vulnerable to outside attack aiming at
91469 * resetting legit local connections.
91470 */
91471 - req->rsk_ops->send_reset(sk, skb);
91472 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
91473 + if (!grsec_enable_blackhole)
91474 +#endif
91475 + req->rsk_ops->send_reset(sk, skb);
91476 } else if (fastopen) { /* received a valid RST pkt */
91477 reqsk_fastopen_remove(sk, req, true);
91478 tcp_reset(sk);
91479 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
91480 index d4943f6..e7a74a5 100644
91481 --- a/net/ipv4/tcp_probe.c
91482 +++ b/net/ipv4/tcp_probe.c
91483 @@ -204,7 +204,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
91484 if (cnt + width >= len)
91485 break;
91486
91487 - if (copy_to_user(buf + cnt, tbuf, width))
91488 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
91489 return -EFAULT;
91490 cnt += width;
91491 }
91492 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
91493 index 4b85e6f..22f9ac9 100644
91494 --- a/net/ipv4/tcp_timer.c
91495 +++ b/net/ipv4/tcp_timer.c
91496 @@ -22,6 +22,10 @@
91497 #include <linux/gfp.h>
91498 #include <net/tcp.h>
91499
91500 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
91501 +extern int grsec_lastack_retries;
91502 +#endif
91503 +
91504 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
91505 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
91506 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
91507 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
91508 }
91509 }
91510
91511 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
91512 + if ((sk->sk_state == TCP_LAST_ACK) &&
91513 + (grsec_lastack_retries > 0) &&
91514 + (grsec_lastack_retries < retry_until))
91515 + retry_until = grsec_lastack_retries;
91516 +#endif
91517 +
91518 if (retransmits_timed_out(sk, retry_until,
91519 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
91520 /* Has it gone just too far? */
91521 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
91522 index 93b731d..5a2dd92 100644
91523 --- a/net/ipv4/udp.c
91524 +++ b/net/ipv4/udp.c
91525 @@ -87,6 +87,7 @@
91526 #include <linux/types.h>
91527 #include <linux/fcntl.h>
91528 #include <linux/module.h>
91529 +#include <linux/security.h>
91530 #include <linux/socket.h>
91531 #include <linux/sockios.h>
91532 #include <linux/igmp.h>
91533 @@ -111,6 +112,10 @@
91534 #include <trace/events/skb.h>
91535 #include "udp_impl.h"
91536
91537 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
91538 +extern int grsec_enable_blackhole;
91539 +#endif
91540 +
91541 struct udp_table udp_table __read_mostly;
91542 EXPORT_SYMBOL(udp_table);
91543
91544 @@ -594,6 +599,9 @@ found:
91545 return s;
91546 }
91547
91548 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
91549 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
91550 +
91551 /*
91552 * This routine is called by the ICMP module when it gets some
91553 * sort of error condition. If err < 0 then the socket should
91554 @@ -890,9 +898,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
91555 dport = usin->sin_port;
91556 if (dport == 0)
91557 return -EINVAL;
91558 +
91559 + err = gr_search_udp_sendmsg(sk, usin);
91560 + if (err)
91561 + return err;
91562 } else {
91563 if (sk->sk_state != TCP_ESTABLISHED)
91564 return -EDESTADDRREQ;
91565 +
91566 + err = gr_search_udp_sendmsg(sk, NULL);
91567 + if (err)
91568 + return err;
91569 +
91570 daddr = inet->inet_daddr;
91571 dport = inet->inet_dport;
91572 /* Open fast path for connected socket.
91573 @@ -1136,7 +1153,7 @@ static unsigned int first_packet_length(struct sock *sk)
91574 IS_UDPLITE(sk));
91575 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
91576 IS_UDPLITE(sk));
91577 - atomic_inc(&sk->sk_drops);
91578 + atomic_inc_unchecked(&sk->sk_drops);
91579 __skb_unlink(skb, rcvq);
91580 __skb_queue_tail(&list_kill, skb);
91581 }
91582 @@ -1222,6 +1239,10 @@ try_again:
91583 if (!skb)
91584 goto out;
91585
91586 + err = gr_search_udp_recvmsg(sk, skb);
91587 + if (err)
91588 + goto out_free;
91589 +
91590 ulen = skb->len - sizeof(struct udphdr);
91591 copied = len;
91592 if (copied > ulen)
91593 @@ -1255,7 +1276,7 @@ try_again:
91594 if (unlikely(err)) {
91595 trace_kfree_skb(skb, udp_recvmsg);
91596 if (!peeked) {
91597 - atomic_inc(&sk->sk_drops);
91598 + atomic_inc_unchecked(&sk->sk_drops);
91599 UDP_INC_STATS_USER(sock_net(sk),
91600 UDP_MIB_INERRORS, is_udplite);
91601 }
91602 @@ -1542,7 +1563,7 @@ csum_error:
91603 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
91604 drop:
91605 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
91606 - atomic_inc(&sk->sk_drops);
91607 + atomic_inc_unchecked(&sk->sk_drops);
91608 kfree_skb(skb);
91609 return -1;
91610 }
91611 @@ -1561,7 +1582,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
91612 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
91613
91614 if (!skb1) {
91615 - atomic_inc(&sk->sk_drops);
91616 + atomic_inc_unchecked(&sk->sk_drops);
91617 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
91618 IS_UDPLITE(sk));
91619 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
91620 @@ -1730,6 +1751,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
91621 goto csum_error;
91622
91623 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
91624 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
91625 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
91626 +#endif
91627 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
91628
91629 /*
91630 @@ -2160,7 +2184,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
91631 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
91632 0, sock_i_ino(sp),
91633 atomic_read(&sp->sk_refcnt), sp,
91634 - atomic_read(&sp->sk_drops), len);
91635 + atomic_read_unchecked(&sp->sk_drops), len);
91636 }
91637
91638 int udp4_seq_show(struct seq_file *seq, void *v)
91639 diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
91640 index 9a459be..086b866 100644
91641 --- a/net/ipv4/xfrm4_policy.c
91642 +++ b/net/ipv4/xfrm4_policy.c
91643 @@ -264,19 +264,18 @@ static struct ctl_table xfrm4_policy_table[] = {
91644
91645 static int __net_init xfrm4_net_init(struct net *net)
91646 {
91647 - struct ctl_table *table;
91648 + ctl_table_no_const *table = NULL;
91649 struct ctl_table_header *hdr;
91650
91651 - table = xfrm4_policy_table;
91652 if (!net_eq(net, &init_net)) {
91653 - table = kmemdup(table, sizeof(xfrm4_policy_table), GFP_KERNEL);
91654 + table = kmemdup(xfrm4_policy_table, sizeof(xfrm4_policy_table), GFP_KERNEL);
91655 if (!table)
91656 goto err_alloc;
91657
91658 table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh;
91659 - }
91660 -
91661 - hdr = register_net_sysctl(net, "net/ipv4", table);
91662 + hdr = register_net_sysctl(net, "net/ipv4", table);
91663 + } else
91664 + hdr = register_net_sysctl(net, "net/ipv4", xfrm4_policy_table);
91665 if (!hdr)
91666 goto err_reg;
91667
91668 @@ -284,8 +283,7 @@ static int __net_init xfrm4_net_init(struct net *net)
91669 return 0;
91670
91671 err_reg:
91672 - if (!net_eq(net, &init_net))
91673 - kfree(table);
91674 + kfree(table);
91675 err_alloc:
91676 return -ENOMEM;
91677 }
91678 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
91679 index fb8c94c..fb18024 100644
91680 --- a/net/ipv6/addrconf.c
91681 +++ b/net/ipv6/addrconf.c
91682 @@ -621,7 +621,7 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb,
91683 idx = 0;
91684 head = &net->dev_index_head[h];
91685 rcu_read_lock();
91686 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^
91687 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^
91688 net->dev_base_seq;
91689 hlist_for_each_entry_rcu(dev, head, index_hlist) {
91690 if (idx < s_idx)
91691 @@ -2380,7 +2380,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
91692 p.iph.ihl = 5;
91693 p.iph.protocol = IPPROTO_IPV6;
91694 p.iph.ttl = 64;
91695 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
91696 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
91697
91698 if (ops->ndo_do_ioctl) {
91699 mm_segment_t oldfs = get_fs();
91700 @@ -4002,7 +4002,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
91701 s_ip_idx = ip_idx = cb->args[2];
91702
91703 rcu_read_lock();
91704 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
91705 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
91706 for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
91707 idx = 0;
91708 head = &net->dev_index_head[h];
91709 @@ -4587,7 +4587,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
91710 dst_free(&ifp->rt->dst);
91711 break;
91712 }
91713 - atomic_inc(&net->ipv6.dev_addr_genid);
91714 + atomic_inc_unchecked(&net->ipv6.dev_addr_genid);
91715 }
91716
91717 static void ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
91718 @@ -4607,7 +4607,7 @@ int addrconf_sysctl_forward(ctl_table *ctl, int write,
91719 int *valp = ctl->data;
91720 int val = *valp;
91721 loff_t pos = *ppos;
91722 - ctl_table lctl;
91723 + ctl_table_no_const lctl;
91724 int ret;
91725
91726 /*
91727 @@ -4689,7 +4689,7 @@ int addrconf_sysctl_disable(ctl_table *ctl, int write,
91728 int *valp = ctl->data;
91729 int val = *valp;
91730 loff_t pos = *ppos;
91731 - ctl_table lctl;
91732 + ctl_table_no_const lctl;
91733 int ret;
91734
91735 /*
91736 diff --git a/net/ipv6/esp6.c b/net/ipv6/esp6.c
91737 index 40ffd72..aeac0dc 100644
91738 --- a/net/ipv6/esp6.c
91739 +++ b/net/ipv6/esp6.c
91740 @@ -425,7 +425,7 @@ static u32 esp6_get_mtu(struct xfrm_state *x, int mtu)
91741 net_adj = 0;
91742
91743 return ((mtu - x->props.header_len - crypto_aead_authsize(esp->aead) -
91744 - net_adj) & ~(align - 1)) + (net_adj - 2);
91745 + net_adj) & ~(align - 1)) + net_adj - 2;
91746 }
91747
91748 static void esp6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
91749 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
91750 index b4ff0a4..db9b764 100644
91751 --- a/net/ipv6/icmp.c
91752 +++ b/net/ipv6/icmp.c
91753 @@ -980,7 +980,7 @@ ctl_table ipv6_icmp_table_template[] = {
91754
91755 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
91756 {
91757 - struct ctl_table *table;
91758 + ctl_table_no_const *table;
91759
91760 table = kmemdup(ipv6_icmp_table_template,
91761 sizeof(ipv6_icmp_table_template),
91762 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
91763 index ecd6073..58162ae 100644
91764 --- a/net/ipv6/ip6_gre.c
91765 +++ b/net/ipv6/ip6_gre.c
91766 @@ -74,7 +74,7 @@ struct ip6gre_net {
91767 struct net_device *fb_tunnel_dev;
91768 };
91769
91770 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
91771 +static struct rtnl_link_ops ip6gre_link_ops;
91772 static int ip6gre_tunnel_init(struct net_device *dev);
91773 static void ip6gre_tunnel_setup(struct net_device *dev);
91774 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
91775 @@ -1283,7 +1283,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
91776 }
91777
91778
91779 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
91780 +static struct inet6_protocol ip6gre_protocol = {
91781 .handler = ip6gre_rcv,
91782 .err_handler = ip6gre_err,
91783 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
91784 @@ -1617,7 +1617,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
91785 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
91786 };
91787
91788 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
91789 +static struct rtnl_link_ops ip6gre_link_ops = {
91790 .kind = "ip6gre",
91791 .maxtype = IFLA_GRE_MAX,
91792 .policy = ip6gre_policy,
91793 @@ -1630,7 +1630,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
91794 .fill_info = ip6gre_fill_info,
91795 };
91796
91797 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
91798 +static struct rtnl_link_ops ip6gre_tap_ops = {
91799 .kind = "ip6gretap",
91800 .maxtype = IFLA_GRE_MAX,
91801 .policy = ip6gre_policy,
91802 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
91803 index 1e55866..b398dab 100644
91804 --- a/net/ipv6/ip6_tunnel.c
91805 +++ b/net/ipv6/ip6_tunnel.c
91806 @@ -88,7 +88,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
91807
91808 static int ip6_tnl_dev_init(struct net_device *dev);
91809 static void ip6_tnl_dev_setup(struct net_device *dev);
91810 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
91811 +static struct rtnl_link_ops ip6_link_ops;
91812
91813 static int ip6_tnl_net_id __read_mostly;
91814 struct ip6_tnl_net {
91815 @@ -1672,7 +1672,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
91816 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
91817 };
91818
91819 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
91820 +static struct rtnl_link_ops ip6_link_ops = {
91821 .kind = "ip6tnl",
91822 .maxtype = IFLA_IPTUN_MAX,
91823 .policy = ip6_tnl_policy,
91824 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
91825 index d1e2e8e..51c19ae 100644
91826 --- a/net/ipv6/ipv6_sockglue.c
91827 +++ b/net/ipv6/ipv6_sockglue.c
91828 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
91829 if (sk->sk_type != SOCK_STREAM)
91830 return -ENOPROTOOPT;
91831
91832 - msg.msg_control = optval;
91833 + msg.msg_control = (void __force_kernel *)optval;
91834 msg.msg_controllen = len;
91835 msg.msg_flags = flags;
91836
91837 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
91838 index 44400c2..8e11f52 100644
91839 --- a/net/ipv6/netfilter/ip6_tables.c
91840 +++ b/net/ipv6/netfilter/ip6_tables.c
91841 @@ -1078,14 +1078,14 @@ static int compat_table_info(const struct xt_table_info *info,
91842 #endif
91843
91844 static int get_info(struct net *net, void __user *user,
91845 - const int *len, int compat)
91846 + int len, int compat)
91847 {
91848 char name[XT_TABLE_MAXNAMELEN];
91849 struct xt_table *t;
91850 int ret;
91851
91852 - if (*len != sizeof(struct ip6t_getinfo)) {
91853 - duprintf("length %u != %zu\n", *len,
91854 + if (len != sizeof(struct ip6t_getinfo)) {
91855 + duprintf("length %u != %zu\n", len,
91856 sizeof(struct ip6t_getinfo));
91857 return -EINVAL;
91858 }
91859 @@ -1122,7 +1122,7 @@ static int get_info(struct net *net, void __user *user,
91860 info.size = private->size;
91861 strcpy(info.name, name);
91862
91863 - if (copy_to_user(user, &info, *len) != 0)
91864 + if (copy_to_user(user, &info, len) != 0)
91865 ret = -EFAULT;
91866 else
91867 ret = 0;
91868 @@ -1976,7 +1976,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
91869
91870 switch (cmd) {
91871 case IP6T_SO_GET_INFO:
91872 - ret = get_info(sock_net(sk), user, len, 1);
91873 + ret = get_info(sock_net(sk), user, *len, 1);
91874 break;
91875 case IP6T_SO_GET_ENTRIES:
91876 ret = compat_get_entries(sock_net(sk), user, len);
91877 @@ -2023,7 +2023,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
91878
91879 switch (cmd) {
91880 case IP6T_SO_GET_INFO:
91881 - ret = get_info(sock_net(sk), user, len, 0);
91882 + ret = get_info(sock_net(sk), user, *len, 0);
91883 break;
91884
91885 case IP6T_SO_GET_ENTRIES:
91886 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
91887 index dffdc1a..ccc6678 100644
91888 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
91889 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
91890 @@ -90,12 +90,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
91891
91892 static int nf_ct_frag6_sysctl_register(struct net *net)
91893 {
91894 - struct ctl_table *table;
91895 + ctl_table_no_const *table = NULL;
91896 struct ctl_table_header *hdr;
91897
91898 - table = nf_ct_frag6_sysctl_table;
91899 if (!net_eq(net, &init_net)) {
91900 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
91901 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
91902 GFP_KERNEL);
91903 if (table == NULL)
91904 goto err_alloc;
91905 @@ -103,9 +102,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
91906 table[0].data = &net->nf_frag.frags.timeout;
91907 table[1].data = &net->nf_frag.frags.low_thresh;
91908 table[2].data = &net->nf_frag.frags.high_thresh;
91909 - }
91910 -
91911 - hdr = register_net_sysctl(net, "net/netfilter", table);
91912 + hdr = register_net_sysctl(net, "net/netfilter", table);
91913 + } else
91914 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
91915 if (hdr == NULL)
91916 goto err_reg;
91917
91918 @@ -113,8 +112,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
91919 return 0;
91920
91921 err_reg:
91922 - if (!net_eq(net, &init_net))
91923 - kfree(table);
91924 + kfree(table);
91925 err_alloc:
91926 return -ENOMEM;
91927 }
91928 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
91929 index eedff8c..6e13a47 100644
91930 --- a/net/ipv6/raw.c
91931 +++ b/net/ipv6/raw.c
91932 @@ -378,7 +378,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
91933 {
91934 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
91935 skb_checksum_complete(skb)) {
91936 - atomic_inc(&sk->sk_drops);
91937 + atomic_inc_unchecked(&sk->sk_drops);
91938 kfree_skb(skb);
91939 return NET_RX_DROP;
91940 }
91941 @@ -406,7 +406,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
91942 struct raw6_sock *rp = raw6_sk(sk);
91943
91944 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
91945 - atomic_inc(&sk->sk_drops);
91946 + atomic_inc_unchecked(&sk->sk_drops);
91947 kfree_skb(skb);
91948 return NET_RX_DROP;
91949 }
91950 @@ -430,7 +430,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
91951
91952 if (inet->hdrincl) {
91953 if (skb_checksum_complete(skb)) {
91954 - atomic_inc(&sk->sk_drops);
91955 + atomic_inc_unchecked(&sk->sk_drops);
91956 kfree_skb(skb);
91957 return NET_RX_DROP;
91958 }
91959 @@ -602,7 +602,7 @@ out:
91960 return err;
91961 }
91962
91963 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
91964 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
91965 struct flowi6 *fl6, struct dst_entry **dstp,
91966 unsigned int flags)
91967 {
91968 @@ -914,12 +914,15 @@ do_confirm:
91969 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
91970 char __user *optval, int optlen)
91971 {
91972 + struct icmp6_filter filter;
91973 +
91974 switch (optname) {
91975 case ICMPV6_FILTER:
91976 if (optlen > sizeof(struct icmp6_filter))
91977 optlen = sizeof(struct icmp6_filter);
91978 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
91979 + if (copy_from_user(&filter, optval, optlen))
91980 return -EFAULT;
91981 + raw6_sk(sk)->filter = filter;
91982 return 0;
91983 default:
91984 return -ENOPROTOOPT;
91985 @@ -932,6 +935,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
91986 char __user *optval, int __user *optlen)
91987 {
91988 int len;
91989 + struct icmp6_filter filter;
91990
91991 switch (optname) {
91992 case ICMPV6_FILTER:
91993 @@ -943,7 +947,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
91994 len = sizeof(struct icmp6_filter);
91995 if (put_user(len, optlen))
91996 return -EFAULT;
91997 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
91998 + filter = raw6_sk(sk)->filter;
91999 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
92000 return -EFAULT;
92001 return 0;
92002 default:
92003 @@ -1251,7 +1256,7 @@ static void raw6_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
92004 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
92005 0,
92006 sock_i_ino(sp),
92007 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
92008 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
92009 }
92010
92011 static int raw6_seq_show(struct seq_file *seq, void *v)
92012 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
92013 index 790d9f4..68ae078 100644
92014 --- a/net/ipv6/reassembly.c
92015 +++ b/net/ipv6/reassembly.c
92016 @@ -621,12 +621,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
92017
92018 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
92019 {
92020 - struct ctl_table *table;
92021 + ctl_table_no_const *table = NULL;
92022 struct ctl_table_header *hdr;
92023
92024 - table = ip6_frags_ns_ctl_table;
92025 if (!net_eq(net, &init_net)) {
92026 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
92027 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
92028 if (table == NULL)
92029 goto err_alloc;
92030
92031 @@ -637,9 +636,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
92032 /* Don't export sysctls to unprivileged users */
92033 if (net->user_ns != &init_user_ns)
92034 table[0].procname = NULL;
92035 - }
92036 + hdr = register_net_sysctl(net, "net/ipv6", table);
92037 + } else
92038 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
92039
92040 - hdr = register_net_sysctl(net, "net/ipv6", table);
92041 if (hdr == NULL)
92042 goto err_reg;
92043
92044 @@ -647,8 +647,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
92045 return 0;
92046
92047 err_reg:
92048 - if (!net_eq(net, &init_net))
92049 - kfree(table);
92050 + kfree(table);
92051 err_alloc:
92052 return -ENOMEM;
92053 }
92054 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
92055 index bacce6c..9d1741a 100644
92056 --- a/net/ipv6/route.c
92057 +++ b/net/ipv6/route.c
92058 @@ -2903,7 +2903,7 @@ ctl_table ipv6_route_table_template[] = {
92059
92060 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
92061 {
92062 - struct ctl_table *table;
92063 + ctl_table_no_const *table;
92064
92065 table = kmemdup(ipv6_route_table_template,
92066 sizeof(ipv6_route_table_template),
92067 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
92068 index 60df36d..f3ab7c8 100644
92069 --- a/net/ipv6/sit.c
92070 +++ b/net/ipv6/sit.c
92071 @@ -74,7 +74,7 @@ static void ipip6_tunnel_setup(struct net_device *dev);
92072 static void ipip6_dev_free(struct net_device *dev);
92073 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
92074 __be32 *v4dst);
92075 -static struct rtnl_link_ops sit_link_ops __read_mostly;
92076 +static struct rtnl_link_ops sit_link_ops;
92077
92078 static int sit_net_id __read_mostly;
92079 struct sit_net {
92080 @@ -1453,7 +1453,7 @@ static const struct nla_policy ipip6_policy[IFLA_IPTUN_MAX + 1] = {
92081 #endif
92082 };
92083
92084 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
92085 +static struct rtnl_link_ops sit_link_ops = {
92086 .kind = "sit",
92087 .maxtype = IFLA_IPTUN_MAX,
92088 .policy = ipip6_policy,
92089 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
92090 index e85c48b..b8268d3 100644
92091 --- a/net/ipv6/sysctl_net_ipv6.c
92092 +++ b/net/ipv6/sysctl_net_ipv6.c
92093 @@ -40,7 +40,7 @@ static ctl_table ipv6_rotable[] = {
92094
92095 static int __net_init ipv6_sysctl_net_init(struct net *net)
92096 {
92097 - struct ctl_table *ipv6_table;
92098 + ctl_table_no_const *ipv6_table;
92099 struct ctl_table *ipv6_route_table;
92100 struct ctl_table *ipv6_icmp_table;
92101 int err;
92102 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
92103 index 0a17ed9..2526cc3 100644
92104 --- a/net/ipv6/tcp_ipv6.c
92105 +++ b/net/ipv6/tcp_ipv6.c
92106 @@ -103,6 +103,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
92107 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
92108 }
92109
92110 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92111 +extern int grsec_enable_blackhole;
92112 +#endif
92113 +
92114 static void tcp_v6_hash(struct sock *sk)
92115 {
92116 if (sk->sk_state != TCP_CLOSE) {
92117 @@ -1398,6 +1402,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
92118 return 0;
92119
92120 reset:
92121 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92122 + if (!grsec_enable_blackhole)
92123 +#endif
92124 tcp_v6_send_reset(sk, skb);
92125 discard:
92126 if (opt_skb)
92127 @@ -1480,12 +1487,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
92128 TCP_SKB_CB(skb)->sacked = 0;
92129
92130 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
92131 - if (!sk)
92132 + if (!sk) {
92133 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92134 + ret = 1;
92135 +#endif
92136 goto no_tcp_socket;
92137 + }
92138
92139 process:
92140 - if (sk->sk_state == TCP_TIME_WAIT)
92141 + if (sk->sk_state == TCP_TIME_WAIT) {
92142 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92143 + ret = 2;
92144 +#endif
92145 goto do_time_wait;
92146 + }
92147
92148 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
92149 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
92150 @@ -1536,6 +1551,10 @@ csum_error:
92151 bad_packet:
92152 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
92153 } else {
92154 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92155 + if (!grsec_enable_blackhole || (ret == 1 &&
92156 + (skb->dev->flags & IFF_LOOPBACK)))
92157 +#endif
92158 tcp_v6_send_reset(NULL, skb);
92159 }
92160
92161 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
92162 index e7b28f9..d09c290 100644
92163 --- a/net/ipv6/udp.c
92164 +++ b/net/ipv6/udp.c
92165 @@ -52,6 +52,10 @@
92166 #include <trace/events/skb.h>
92167 #include "udp_impl.h"
92168
92169 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92170 +extern int grsec_enable_blackhole;
92171 +#endif
92172 +
92173 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
92174 {
92175 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
92176 @@ -419,7 +423,7 @@ try_again:
92177 if (unlikely(err)) {
92178 trace_kfree_skb(skb, udpv6_recvmsg);
92179 if (!peeked) {
92180 - atomic_inc(&sk->sk_drops);
92181 + atomic_inc_unchecked(&sk->sk_drops);
92182 if (is_udp4)
92183 UDP_INC_STATS_USER(sock_net(sk),
92184 UDP_MIB_INERRORS,
92185 @@ -665,7 +669,7 @@ csum_error:
92186 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
92187 drop:
92188 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
92189 - atomic_inc(&sk->sk_drops);
92190 + atomic_inc_unchecked(&sk->sk_drops);
92191 kfree_skb(skb);
92192 return -1;
92193 }
92194 @@ -723,7 +727,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
92195 if (likely(skb1 == NULL))
92196 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
92197 if (!skb1) {
92198 - atomic_inc(&sk->sk_drops);
92199 + atomic_inc_unchecked(&sk->sk_drops);
92200 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
92201 IS_UDPLITE(sk));
92202 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
92203 @@ -860,6 +864,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
92204 goto csum_error;
92205
92206 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
92207 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
92208 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
92209 +#endif
92210 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
92211
92212 kfree_skb(skb);
92213 @@ -1392,7 +1399,7 @@ static void udp6_sock_seq_show(struct seq_file *seq, struct sock *sp, int bucket
92214 0,
92215 sock_i_ino(sp),
92216 atomic_read(&sp->sk_refcnt), sp,
92217 - atomic_read(&sp->sk_drops));
92218 + atomic_read_unchecked(&sp->sk_drops));
92219 }
92220
92221 int udp6_seq_show(struct seq_file *seq, void *v)
92222 diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
92223 index 23ed03d..465a71d 100644
92224 --- a/net/ipv6/xfrm6_policy.c
92225 +++ b/net/ipv6/xfrm6_policy.c
92226 @@ -324,19 +324,19 @@ static struct ctl_table xfrm6_policy_table[] = {
92227
92228 static int __net_init xfrm6_net_init(struct net *net)
92229 {
92230 - struct ctl_table *table;
92231 + ctl_table_no_const *table = NULL;
92232 struct ctl_table_header *hdr;
92233
92234 - table = xfrm6_policy_table;
92235 if (!net_eq(net, &init_net)) {
92236 - table = kmemdup(table, sizeof(xfrm6_policy_table), GFP_KERNEL);
92237 + table = kmemdup(xfrm6_policy_table, sizeof(xfrm6_policy_table), GFP_KERNEL);
92238 if (!table)
92239 goto err_alloc;
92240
92241 table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh;
92242 - }
92243 + hdr = register_net_sysctl(net, "net/ipv6", table);
92244 + } else
92245 + hdr = register_net_sysctl(net, "net/ipv6", xfrm6_policy_table);
92246
92247 - hdr = register_net_sysctl(net, "net/ipv6", table);
92248 if (!hdr)
92249 goto err_reg;
92250
92251 @@ -344,8 +344,7 @@ static int __net_init xfrm6_net_init(struct net *net)
92252 return 0;
92253
92254 err_reg:
92255 - if (!net_eq(net, &init_net))
92256 - kfree(table);
92257 + kfree(table);
92258 err_alloc:
92259 return -ENOMEM;
92260 }
92261 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
92262 index 41ac7938..75e3bb1 100644
92263 --- a/net/irda/ircomm/ircomm_tty.c
92264 +++ b/net/irda/ircomm/ircomm_tty.c
92265 @@ -319,11 +319,11 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
92266 add_wait_queue(&port->open_wait, &wait);
92267
92268 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
92269 - __FILE__, __LINE__, tty->driver->name, port->count);
92270 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
92271
92272 spin_lock_irqsave(&port->lock, flags);
92273 if (!tty_hung_up_p(filp))
92274 - port->count--;
92275 + atomic_dec(&port->count);
92276 port->blocked_open++;
92277 spin_unlock_irqrestore(&port->lock, flags);
92278
92279 @@ -358,7 +358,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
92280 }
92281
92282 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
92283 - __FILE__, __LINE__, tty->driver->name, port->count);
92284 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
92285
92286 schedule();
92287 }
92288 @@ -368,12 +368,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
92289
92290 spin_lock_irqsave(&port->lock, flags);
92291 if (!tty_hung_up_p(filp))
92292 - port->count++;
92293 + atomic_inc(&port->count);
92294 port->blocked_open--;
92295 spin_unlock_irqrestore(&port->lock, flags);
92296
92297 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
92298 - __FILE__, __LINE__, tty->driver->name, port->count);
92299 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
92300
92301 if (!retval)
92302 port->flags |= ASYNC_NORMAL_ACTIVE;
92303 @@ -447,12 +447,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
92304
92305 /* ++ is not atomic, so this should be protected - Jean II */
92306 spin_lock_irqsave(&self->port.lock, flags);
92307 - self->port.count++;
92308 + atomic_inc(&self->port.count);
92309 spin_unlock_irqrestore(&self->port.lock, flags);
92310 tty_port_tty_set(&self->port, tty);
92311
92312 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
92313 - self->line, self->port.count);
92314 + self->line, atomic_read(&self->port.count));
92315
92316 /* Not really used by us, but lets do it anyway */
92317 self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
92318 @@ -989,7 +989,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
92319 tty_kref_put(port->tty);
92320 }
92321 port->tty = NULL;
92322 - port->count = 0;
92323 + atomic_set(&port->count, 0);
92324 spin_unlock_irqrestore(&port->lock, flags);
92325
92326 wake_up_interruptible(&port->open_wait);
92327 @@ -1346,7 +1346,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
92328 seq_putc(m, '\n');
92329
92330 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
92331 - seq_printf(m, "Open count: %d\n", self->port.count);
92332 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
92333 seq_printf(m, "Max data size: %d\n", self->max_data_size);
92334 seq_printf(m, "Max header size: %d\n", self->max_header_size);
92335
92336 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
92337 index ae69165..c8b82d8 100644
92338 --- a/net/iucv/af_iucv.c
92339 +++ b/net/iucv/af_iucv.c
92340 @@ -773,10 +773,10 @@ static int iucv_sock_autobind(struct sock *sk)
92341
92342 write_lock_bh(&iucv_sk_list.lock);
92343
92344 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
92345 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
92346 while (__iucv_get_sock_by_name(name)) {
92347 sprintf(name, "%08x",
92348 - atomic_inc_return(&iucv_sk_list.autobind_name));
92349 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
92350 }
92351
92352 write_unlock_bh(&iucv_sk_list.lock);
92353 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
92354 index 4fe76ff..426a904 100644
92355 --- a/net/iucv/iucv.c
92356 +++ b/net/iucv/iucv.c
92357 @@ -690,7 +690,7 @@ static int __cpuinit iucv_cpu_notify(struct notifier_block *self,
92358 return NOTIFY_OK;
92359 }
92360
92361 -static struct notifier_block __refdata iucv_cpu_notifier = {
92362 +static struct notifier_block iucv_cpu_notifier = {
92363 .notifier_call = iucv_cpu_notify,
92364 };
92365
92366 diff --git a/net/key/af_key.c b/net/key/af_key.c
92367 index ab8bd2c..cd2d641 100644
92368 --- a/net/key/af_key.c
92369 +++ b/net/key/af_key.c
92370 @@ -3048,10 +3048,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
92371 static u32 get_acqseq(void)
92372 {
92373 u32 res;
92374 - static atomic_t acqseq;
92375 + static atomic_unchecked_t acqseq;
92376
92377 do {
92378 - res = atomic_inc_return(&acqseq);
92379 + res = atomic_inc_return_unchecked(&acqseq);
92380 } while (!res);
92381 return res;
92382 }
92383 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
92384 index ae36f8e..09d42ac 100644
92385 --- a/net/mac80211/cfg.c
92386 +++ b/net/mac80211/cfg.c
92387 @@ -806,7 +806,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
92388 ret = ieee80211_vif_use_channel(sdata, chandef,
92389 IEEE80211_CHANCTX_EXCLUSIVE);
92390 }
92391 - } else if (local->open_count == local->monitors) {
92392 + } else if (local_read(&local->open_count) == local->monitors) {
92393 local->_oper_chandef = *chandef;
92394 ieee80211_hw_config(local, 0);
92395 }
92396 @@ -2922,7 +2922,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
92397 else
92398 local->probe_req_reg--;
92399
92400 - if (!local->open_count)
92401 + if (!local_read(&local->open_count))
92402 break;
92403
92404 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
92405 @@ -3385,8 +3385,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
92406 if (chanctx_conf) {
92407 *chandef = chanctx_conf->def;
92408 ret = 0;
92409 - } else if (local->open_count > 0 &&
92410 - local->open_count == local->monitors &&
92411 + } else if (local_read(&local->open_count) > 0 &&
92412 + local_read(&local->open_count) == local->monitors &&
92413 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
92414 if (local->use_chanctx)
92415 *chandef = local->monitor_chandef;
92416 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
92417 index 9ca8e32..48e4a9b 100644
92418 --- a/net/mac80211/ieee80211_i.h
92419 +++ b/net/mac80211/ieee80211_i.h
92420 @@ -28,6 +28,7 @@
92421 #include <net/ieee80211_radiotap.h>
92422 #include <net/cfg80211.h>
92423 #include <net/mac80211.h>
92424 +#include <asm/local.h>
92425 #include "key.h"
92426 #include "sta_info.h"
92427 #include "debug.h"
92428 @@ -891,7 +892,7 @@ struct ieee80211_local {
92429 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
92430 spinlock_t queue_stop_reason_lock;
92431
92432 - int open_count;
92433 + local_t open_count;
92434 int monitors, cooked_mntrs;
92435 /* number of interfaces with corresponding FIF_ flags */
92436 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
92437 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
92438 index 514e90f..56f22bf 100644
92439 --- a/net/mac80211/iface.c
92440 +++ b/net/mac80211/iface.c
92441 @@ -502,7 +502,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
92442 break;
92443 }
92444
92445 - if (local->open_count == 0) {
92446 + if (local_read(&local->open_count) == 0) {
92447 res = drv_start(local);
92448 if (res)
92449 goto err_del_bss;
92450 @@ -545,7 +545,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
92451 break;
92452 }
92453
92454 - if (local->monitors == 0 && local->open_count == 0) {
92455 + if (local->monitors == 0 && local_read(&local->open_count) == 0) {
92456 res = ieee80211_add_virtual_monitor(local);
92457 if (res)
92458 goto err_stop;
92459 @@ -653,7 +653,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
92460 atomic_inc(&local->iff_promiscs);
92461
92462 if (coming_up)
92463 - local->open_count++;
92464 + local_inc(&local->open_count);
92465
92466 if (hw_reconf_flags)
92467 ieee80211_hw_config(local, hw_reconf_flags);
92468 @@ -691,7 +691,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
92469 err_del_interface:
92470 drv_remove_interface(local, sdata);
92471 err_stop:
92472 - if (!local->open_count)
92473 + if (!local_read(&local->open_count))
92474 drv_stop(local);
92475 err_del_bss:
92476 sdata->bss = NULL;
92477 @@ -828,7 +828,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
92478 }
92479
92480 if (going_down)
92481 - local->open_count--;
92482 + local_dec(&local->open_count);
92483
92484 switch (sdata->vif.type) {
92485 case NL80211_IFTYPE_AP_VLAN:
92486 @@ -895,7 +895,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
92487 }
92488 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
92489
92490 - if (local->open_count == 0)
92491 + if (local_read(&local->open_count) == 0)
92492 ieee80211_clear_tx_pending(local);
92493
92494 /*
92495 @@ -931,7 +931,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
92496
92497 ieee80211_recalc_ps(local, -1);
92498
92499 - if (local->open_count == 0) {
92500 + if (local_read(&local->open_count) == 0) {
92501 ieee80211_stop_device(local);
92502
92503 /* no reconfiguring after stop! */
92504 @@ -942,7 +942,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
92505 ieee80211_configure_filter(local);
92506 ieee80211_hw_config(local, hw_reconf_flags);
92507
92508 - if (local->monitors == local->open_count)
92509 + if (local->monitors == local_read(&local->open_count))
92510 ieee80211_add_virtual_monitor(local);
92511 }
92512
92513 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
92514 index 8a7bfc4..4407cd0 100644
92515 --- a/net/mac80211/main.c
92516 +++ b/net/mac80211/main.c
92517 @@ -181,7 +181,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
92518 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
92519 IEEE80211_CONF_CHANGE_POWER);
92520
92521 - if (changed && local->open_count) {
92522 + if (changed && local_read(&local->open_count)) {
92523 ret = drv_config(local, changed);
92524 /*
92525 * Goal:
92526 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
92527 index 3401262..d5cd68d 100644
92528 --- a/net/mac80211/pm.c
92529 +++ b/net/mac80211/pm.c
92530 @@ -12,7 +12,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
92531 struct ieee80211_sub_if_data *sdata;
92532 struct sta_info *sta;
92533
92534 - if (!local->open_count)
92535 + if (!local_read(&local->open_count))
92536 goto suspend;
92537
92538 ieee80211_scan_cancel(local);
92539 @@ -59,7 +59,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
92540 cancel_work_sync(&local->dynamic_ps_enable_work);
92541 del_timer_sync(&local->dynamic_ps_timer);
92542
92543 - local->wowlan = wowlan && local->open_count;
92544 + local->wowlan = wowlan && local_read(&local->open_count);
92545 if (local->wowlan) {
92546 int err = drv_suspend(local, wowlan);
92547 if (err < 0) {
92548 @@ -116,7 +116,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
92549 WARN_ON(!list_empty(&local->chanctx_list));
92550
92551 /* stop hardware - this must stop RX */
92552 - if (local->open_count)
92553 + if (local_read(&local->open_count))
92554 ieee80211_stop_device(local);
92555
92556 suspend:
92557 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
92558 index a02bef3..f2f38dd 100644
92559 --- a/net/mac80211/rate.c
92560 +++ b/net/mac80211/rate.c
92561 @@ -712,7 +712,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
92562
92563 ASSERT_RTNL();
92564
92565 - if (local->open_count)
92566 + if (local_read(&local->open_count))
92567 return -EBUSY;
92568
92569 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
92570 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
92571 index c97a065..ff61928 100644
92572 --- a/net/mac80211/rc80211_pid_debugfs.c
92573 +++ b/net/mac80211/rc80211_pid_debugfs.c
92574 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
92575
92576 spin_unlock_irqrestore(&events->lock, status);
92577
92578 - if (copy_to_user(buf, pb, p))
92579 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
92580 return -EFAULT;
92581
92582 return p;
92583 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
92584 index 72e6292..e6319eb 100644
92585 --- a/net/mac80211/util.c
92586 +++ b/net/mac80211/util.c
92587 @@ -1472,7 +1472,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
92588 }
92589 #endif
92590 /* everything else happens only if HW was up & running */
92591 - if (!local->open_count)
92592 + if (!local_read(&local->open_count))
92593 goto wake_up;
92594
92595 /*
92596 @@ -1696,7 +1696,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
92597 local->in_reconfig = false;
92598 barrier();
92599
92600 - if (local->monitors == local->open_count && local->monitors > 0)
92601 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
92602 ieee80211_add_virtual_monitor(local);
92603
92604 /*
92605 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
92606 index 56d22ca..87c778f 100644
92607 --- a/net/netfilter/Kconfig
92608 +++ b/net/netfilter/Kconfig
92609 @@ -958,6 +958,16 @@ config NETFILTER_XT_MATCH_ESP
92610
92611 To compile it as a module, choose M here. If unsure, say N.
92612
92613 +config NETFILTER_XT_MATCH_GRADM
92614 + tristate '"gradm" match support'
92615 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
92616 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
92617 + ---help---
92618 + The gradm match allows to match on grsecurity RBAC being enabled.
92619 + It is useful when iptables rules are applied early on bootup to
92620 + prevent connections to the machine (except from a trusted host)
92621 + while the RBAC system is disabled.
92622 +
92623 config NETFILTER_XT_MATCH_HASHLIMIT
92624 tristate '"hashlimit" match support'
92625 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
92626 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
92627 index a1abf87..dbcb7ee 100644
92628 --- a/net/netfilter/Makefile
92629 +++ b/net/netfilter/Makefile
92630 @@ -112,6 +112,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
92631 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
92632 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
92633 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
92634 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
92635 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
92636 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
92637 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
92638 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
92639 index f771390..145b765 100644
92640 --- a/net/netfilter/ipset/ip_set_core.c
92641 +++ b/net/netfilter/ipset/ip_set_core.c
92642 @@ -1820,7 +1820,7 @@ done:
92643 return ret;
92644 }
92645
92646 -static struct nf_sockopt_ops so_set __read_mostly = {
92647 +static struct nf_sockopt_ops so_set = {
92648 .pf = PF_INET,
92649 .get_optmin = SO_IP_SET,
92650 .get_optmax = SO_IP_SET + 1,
92651 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
92652 index a083bda..da661c3 100644
92653 --- a/net/netfilter/ipvs/ip_vs_conn.c
92654 +++ b/net/netfilter/ipvs/ip_vs_conn.c
92655 @@ -556,7 +556,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
92656 /* Increase the refcnt counter of the dest */
92657 ip_vs_dest_hold(dest);
92658
92659 - conn_flags = atomic_read(&dest->conn_flags);
92660 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
92661 if (cp->protocol != IPPROTO_UDP)
92662 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
92663 flags = cp->flags;
92664 @@ -900,7 +900,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
92665
92666 cp->control = NULL;
92667 atomic_set(&cp->n_control, 0);
92668 - atomic_set(&cp->in_pkts, 0);
92669 + atomic_set_unchecked(&cp->in_pkts, 0);
92670
92671 cp->packet_xmit = NULL;
92672 cp->app = NULL;
92673 @@ -1190,7 +1190,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
92674
92675 /* Don't drop the entry if its number of incoming packets is not
92676 located in [0, 8] */
92677 - i = atomic_read(&cp->in_pkts);
92678 + i = atomic_read_unchecked(&cp->in_pkts);
92679 if (i > 8 || i < 0) return 0;
92680
92681 if (!todrop_rate[i]) return 0;
92682 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
92683 index 23b8eb5..48a8959 100644
92684 --- a/net/netfilter/ipvs/ip_vs_core.c
92685 +++ b/net/netfilter/ipvs/ip_vs_core.c
92686 @@ -559,7 +559,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
92687 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
92688 /* do not touch skb anymore */
92689
92690 - atomic_inc(&cp->in_pkts);
92691 + atomic_inc_unchecked(&cp->in_pkts);
92692 ip_vs_conn_put(cp);
92693 return ret;
92694 }
92695 @@ -1711,7 +1711,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
92696 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
92697 pkts = sysctl_sync_threshold(ipvs);
92698 else
92699 - pkts = atomic_add_return(1, &cp->in_pkts);
92700 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
92701
92702 if (ipvs->sync_state & IP_VS_STATE_MASTER)
92703 ip_vs_sync_conn(net, cp, pkts);
92704 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
92705 index 9e6c2a0..28552e2 100644
92706 --- a/net/netfilter/ipvs/ip_vs_ctl.c
92707 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
92708 @@ -789,7 +789,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
92709 */
92710 ip_vs_rs_hash(ipvs, dest);
92711 }
92712 - atomic_set(&dest->conn_flags, conn_flags);
92713 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
92714
92715 /* bind the service */
92716 if (!dest->svc) {
92717 @@ -1657,7 +1657,7 @@ proc_do_sync_ports(ctl_table *table, int write,
92718 * align with netns init in ip_vs_control_net_init()
92719 */
92720
92721 -static struct ctl_table vs_vars[] = {
92722 +static ctl_table_no_const vs_vars[] __read_only = {
92723 {
92724 .procname = "amemthresh",
92725 .maxlen = sizeof(int),
92726 @@ -2060,7 +2060,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
92727 " %-7s %-6d %-10d %-10d\n",
92728 &dest->addr.in6,
92729 ntohs(dest->port),
92730 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
92731 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
92732 atomic_read(&dest->weight),
92733 atomic_read(&dest->activeconns),
92734 atomic_read(&dest->inactconns));
92735 @@ -2071,7 +2071,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
92736 "%-7s %-6d %-10d %-10d\n",
92737 ntohl(dest->addr.ip),
92738 ntohs(dest->port),
92739 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
92740 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
92741 atomic_read(&dest->weight),
92742 atomic_read(&dest->activeconns),
92743 atomic_read(&dest->inactconns));
92744 @@ -2549,7 +2549,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
92745
92746 entry.addr = dest->addr.ip;
92747 entry.port = dest->port;
92748 - entry.conn_flags = atomic_read(&dest->conn_flags);
92749 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
92750 entry.weight = atomic_read(&dest->weight);
92751 entry.u_threshold = dest->u_threshold;
92752 entry.l_threshold = dest->l_threshold;
92753 @@ -3092,7 +3092,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
92754 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
92755 nla_put_be16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
92756 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
92757 - (atomic_read(&dest->conn_flags) &
92758 + (atomic_read_unchecked(&dest->conn_flags) &
92759 IP_VS_CONN_F_FWD_MASK)) ||
92760 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
92761 atomic_read(&dest->weight)) ||
92762 @@ -3682,7 +3682,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
92763 {
92764 int idx;
92765 struct netns_ipvs *ipvs = net_ipvs(net);
92766 - struct ctl_table *tbl;
92767 + ctl_table_no_const *tbl;
92768
92769 atomic_set(&ipvs->dropentry, 0);
92770 spin_lock_init(&ipvs->dropentry_lock);
92771 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
92772 index 5ea26bd..c9bc65f 100644
92773 --- a/net/netfilter/ipvs/ip_vs_lblc.c
92774 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
92775 @@ -118,7 +118,7 @@ struct ip_vs_lblc_table {
92776 * IPVS LBLC sysctl table
92777 */
92778 #ifdef CONFIG_SYSCTL
92779 -static ctl_table vs_vars_table[] = {
92780 +static ctl_table_no_const vs_vars_table[] __read_only = {
92781 {
92782 .procname = "lblc_expiration",
92783 .data = NULL,
92784 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
92785 index 50123c2..067c773 100644
92786 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
92787 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
92788 @@ -299,7 +299,7 @@ struct ip_vs_lblcr_table {
92789 * IPVS LBLCR sysctl table
92790 */
92791
92792 -static ctl_table vs_vars_table[] = {
92793 +static ctl_table_no_const vs_vars_table[] __read_only = {
92794 {
92795 .procname = "lblcr_expiration",
92796 .data = NULL,
92797 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
92798 index f6046d9..4f10cfd 100644
92799 --- a/net/netfilter/ipvs/ip_vs_sync.c
92800 +++ b/net/netfilter/ipvs/ip_vs_sync.c
92801 @@ -596,7 +596,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
92802 cp = cp->control;
92803 if (cp) {
92804 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
92805 - pkts = atomic_add_return(1, &cp->in_pkts);
92806 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
92807 else
92808 pkts = sysctl_sync_threshold(ipvs);
92809 ip_vs_sync_conn(net, cp->control, pkts);
92810 @@ -758,7 +758,7 @@ control:
92811 if (!cp)
92812 return;
92813 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
92814 - pkts = atomic_add_return(1, &cp->in_pkts);
92815 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
92816 else
92817 pkts = sysctl_sync_threshold(ipvs);
92818 goto sloop;
92819 @@ -882,7 +882,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
92820
92821 if (opt)
92822 memcpy(&cp->in_seq, opt, sizeof(*opt));
92823 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
92824 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
92825 cp->state = state;
92826 cp->old_state = cp->state;
92827 /*
92828 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
92829 index b75ff64..0c51bbe 100644
92830 --- a/net/netfilter/ipvs/ip_vs_xmit.c
92831 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
92832 @@ -1102,7 +1102,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
92833 else
92834 rc = NF_ACCEPT;
92835 /* do not touch skb anymore */
92836 - atomic_inc(&cp->in_pkts);
92837 + atomic_inc_unchecked(&cp->in_pkts);
92838 goto out;
92839 }
92840
92841 @@ -1194,7 +1194,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
92842 else
92843 rc = NF_ACCEPT;
92844 /* do not touch skb anymore */
92845 - atomic_inc(&cp->in_pkts);
92846 + atomic_inc_unchecked(&cp->in_pkts);
92847 goto out;
92848 }
92849
92850 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
92851 index 2d3030a..7ba1c0a 100644
92852 --- a/net/netfilter/nf_conntrack_acct.c
92853 +++ b/net/netfilter/nf_conntrack_acct.c
92854 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
92855 #ifdef CONFIG_SYSCTL
92856 static int nf_conntrack_acct_init_sysctl(struct net *net)
92857 {
92858 - struct ctl_table *table;
92859 + ctl_table_no_const *table;
92860
92861 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
92862 GFP_KERNEL);
92863 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
92864 index 0283bae..5febcb0 100644
92865 --- a/net/netfilter/nf_conntrack_core.c
92866 +++ b/net/netfilter/nf_conntrack_core.c
92867 @@ -1614,6 +1614,10 @@ void nf_conntrack_init_end(void)
92868 #define DYING_NULLS_VAL ((1<<30)+1)
92869 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
92870
92871 +#ifdef CONFIG_GRKERNSEC_HIDESYM
92872 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
92873 +#endif
92874 +
92875 int nf_conntrack_init_net(struct net *net)
92876 {
92877 int ret;
92878 @@ -1628,7 +1632,11 @@ int nf_conntrack_init_net(struct net *net)
92879 goto err_stat;
92880 }
92881
92882 +#ifdef CONFIG_GRKERNSEC_HIDESYM
92883 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
92884 +#else
92885 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
92886 +#endif
92887 if (!net->ct.slabname) {
92888 ret = -ENOMEM;
92889 goto err_slabname;
92890 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
92891 index 1df1761..ce8b88a 100644
92892 --- a/net/netfilter/nf_conntrack_ecache.c
92893 +++ b/net/netfilter/nf_conntrack_ecache.c
92894 @@ -188,7 +188,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
92895 #ifdef CONFIG_SYSCTL
92896 static int nf_conntrack_event_init_sysctl(struct net *net)
92897 {
92898 - struct ctl_table *table;
92899 + ctl_table_no_const *table;
92900
92901 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
92902 GFP_KERNEL);
92903 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
92904 index 974a2a4..52cc6ff 100644
92905 --- a/net/netfilter/nf_conntrack_helper.c
92906 +++ b/net/netfilter/nf_conntrack_helper.c
92907 @@ -57,7 +57,7 @@ static struct ctl_table helper_sysctl_table[] = {
92908
92909 static int nf_conntrack_helper_init_sysctl(struct net *net)
92910 {
92911 - struct ctl_table *table;
92912 + ctl_table_no_const *table;
92913
92914 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
92915 GFP_KERNEL);
92916 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
92917 index 0ab9636..cea3c6a 100644
92918 --- a/net/netfilter/nf_conntrack_proto.c
92919 +++ b/net/netfilter/nf_conntrack_proto.c
92920 @@ -52,7 +52,7 @@ nf_ct_register_sysctl(struct net *net,
92921
92922 static void
92923 nf_ct_unregister_sysctl(struct ctl_table_header **header,
92924 - struct ctl_table **table,
92925 + ctl_table_no_const **table,
92926 unsigned int users)
92927 {
92928 if (users > 0)
92929 diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
92930 index a99b6c3..3841268 100644
92931 --- a/net/netfilter/nf_conntrack_proto_dccp.c
92932 +++ b/net/netfilter/nf_conntrack_proto_dccp.c
92933 @@ -457,7 +457,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
92934 out_invalid:
92935 if (LOG_INVALID(net, IPPROTO_DCCP))
92936 nf_log_packet(net, nf_ct_l3num(ct), 0, skb, NULL, NULL,
92937 - NULL, msg);
92938 + NULL, "%s", msg);
92939 return false;
92940 }
92941
92942 @@ -614,7 +614,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
92943
92944 out_invalid:
92945 if (LOG_INVALID(net, IPPROTO_DCCP))
92946 - nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, msg);
92947 + nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, "%s", msg);
92948 return -NF_ACCEPT;
92949 }
92950
92951 diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
92952 index 4d4d8f1..e0f9a32 100644
92953 --- a/net/netfilter/nf_conntrack_proto_tcp.c
92954 +++ b/net/netfilter/nf_conntrack_proto_tcp.c
92955 @@ -526,7 +526,7 @@ static bool tcp_in_window(const struct nf_conn *ct,
92956 const struct nf_conntrack_tuple *tuple = &ct->tuplehash[dir].tuple;
92957 __u32 seq, ack, sack, end, win, swin;
92958 s16 receiver_offset;
92959 - bool res;
92960 + bool res, in_recv_win;
92961
92962 /*
92963 * Get the required data from the packet.
92964 @@ -649,14 +649,18 @@ static bool tcp_in_window(const struct nf_conn *ct,
92965 receiver->td_end, receiver->td_maxend, receiver->td_maxwin,
92966 receiver->td_scale);
92967
92968 + /* Is the ending sequence in the receive window (if available)? */
92969 + in_recv_win = !receiver->td_maxwin ||
92970 + after(end, sender->td_end - receiver->td_maxwin - 1);
92971 +
92972 pr_debug("tcp_in_window: I=%i II=%i III=%i IV=%i\n",
92973 before(seq, sender->td_maxend + 1),
92974 - after(end, sender->td_end - receiver->td_maxwin - 1),
92975 + (in_recv_win ? 1 : 0),
92976 before(sack, receiver->td_end + 1),
92977 after(sack, receiver->td_end - MAXACKWINDOW(sender) - 1));
92978
92979 if (before(seq, sender->td_maxend + 1) &&
92980 - after(end, sender->td_end - receiver->td_maxwin - 1) &&
92981 + in_recv_win &&
92982 before(sack, receiver->td_end + 1) &&
92983 after(sack, receiver->td_end - MAXACKWINDOW(sender) - 1)) {
92984 /*
92985 @@ -725,7 +729,7 @@ static bool tcp_in_window(const struct nf_conn *ct,
92986 nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL,
92987 "nf_ct_tcp: %s ",
92988 before(seq, sender->td_maxend + 1) ?
92989 - after(end, sender->td_end - receiver->td_maxwin - 1) ?
92990 + in_recv_win ?
92991 before(sack, receiver->td_end + 1) ?
92992 after(sack, receiver->td_end - MAXACKWINDOW(sender) - 1) ? "BUG"
92993 : "ACK is under the lower bound (possible overly delayed ACK)"
92994 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
92995 index bd700b4..4a3dc61 100644
92996 --- a/net/netfilter/nf_conntrack_standalone.c
92997 +++ b/net/netfilter/nf_conntrack_standalone.c
92998 @@ -471,7 +471,7 @@ static ctl_table nf_ct_netfilter_table[] = {
92999
93000 static int nf_conntrack_standalone_init_sysctl(struct net *net)
93001 {
93002 - struct ctl_table *table;
93003 + ctl_table_no_const *table;
93004
93005 table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),
93006 GFP_KERNEL);
93007 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
93008 index 902fb0a..87f7fdb 100644
93009 --- a/net/netfilter/nf_conntrack_timestamp.c
93010 +++ b/net/netfilter/nf_conntrack_timestamp.c
93011 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
93012 #ifdef CONFIG_SYSCTL
93013 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
93014 {
93015 - struct ctl_table *table;
93016 + ctl_table_no_const *table;
93017
93018 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
93019 GFP_KERNEL);
93020 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
93021 index 3b18dd1..f79e0ca 100644
93022 --- a/net/netfilter/nf_log.c
93023 +++ b/net/netfilter/nf_log.c
93024 @@ -243,7 +243,7 @@ static const struct file_operations nflog_file_ops = {
93025
93026 #ifdef CONFIG_SYSCTL
93027 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
93028 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
93029 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
93030
93031 static int nf_log_proc_dostring(ctl_table *table, int write,
93032 void __user *buffer, size_t *lenp, loff_t *ppos)
93033 @@ -274,14 +274,16 @@ static int nf_log_proc_dostring(ctl_table *table, int write,
93034 rcu_assign_pointer(net->nf.nf_loggers[tindex], logger);
93035 mutex_unlock(&nf_log_mutex);
93036 } else {
93037 + ctl_table_no_const nf_log_table = *table;
93038 +
93039 mutex_lock(&nf_log_mutex);
93040 logger = rcu_dereference_protected(net->nf.nf_loggers[tindex],
93041 lockdep_is_held(&nf_log_mutex));
93042 if (!logger)
93043 - table->data = "NONE";
93044 + nf_log_table.data = "NONE";
93045 else
93046 - table->data = logger->name;
93047 - r = proc_dostring(table, write, buffer, lenp, ppos);
93048 + nf_log_table.data = logger->name;
93049 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
93050 mutex_unlock(&nf_log_mutex);
93051 }
93052
93053 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
93054 index f042ae5..30ea486 100644
93055 --- a/net/netfilter/nf_sockopt.c
93056 +++ b/net/netfilter/nf_sockopt.c
93057 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
93058 }
93059 }
93060
93061 - list_add(&reg->list, &nf_sockopts);
93062 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
93063 out:
93064 mutex_unlock(&nf_sockopt_mutex);
93065 return ret;
93066 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
93067 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
93068 {
93069 mutex_lock(&nf_sockopt_mutex);
93070 - list_del(&reg->list);
93071 + pax_list_del((struct list_head *)&reg->list);
93072 mutex_unlock(&nf_sockopt_mutex);
93073 }
93074 EXPORT_SYMBOL(nf_unregister_sockopt);
93075 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
93076 index 962e979..e46f350 100644
93077 --- a/net/netfilter/nfnetlink_log.c
93078 +++ b/net/netfilter/nfnetlink_log.c
93079 @@ -82,7 +82,7 @@ static int nfnl_log_net_id __read_mostly;
93080 struct nfnl_log_net {
93081 spinlock_t instances_lock;
93082 struct hlist_head instance_table[INSTANCE_BUCKETS];
93083 - atomic_t global_seq;
93084 + atomic_unchecked_t global_seq;
93085 };
93086
93087 static struct nfnl_log_net *nfnl_log_pernet(struct net *net)
93088 @@ -419,6 +419,7 @@ __build_packet_message(struct nfnl_log_net *log,
93089 nfmsg->version = NFNETLINK_V0;
93090 nfmsg->res_id = htons(inst->group_num);
93091
93092 + memset(&pmsg, 0, sizeof(pmsg));
93093 pmsg.hw_protocol = skb->protocol;
93094 pmsg.hook = hooknum;
93095
93096 @@ -498,7 +499,10 @@ __build_packet_message(struct nfnl_log_net *log,
93097 if (indev && skb->dev &&
93098 skb->mac_header != skb->network_header) {
93099 struct nfulnl_msg_packet_hw phw;
93100 - int len = dev_parse_header(skb, phw.hw_addr);
93101 + int len;
93102 +
93103 + memset(&phw, 0, sizeof(phw));
93104 + len = dev_parse_header(skb, phw.hw_addr);
93105 if (len > 0) {
93106 phw.hw_addrlen = htons(len);
93107 if (nla_put(inst->skb, NFULA_HWADDR, sizeof(phw), &phw))
93108 @@ -559,7 +563,7 @@ __build_packet_message(struct nfnl_log_net *log,
93109 /* global sequence number */
93110 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
93111 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
93112 - htonl(atomic_inc_return(&log->global_seq))))
93113 + htonl(atomic_inc_return_unchecked(&log->global_seq))))
93114 goto nla_put_failure;
93115
93116 if (data_len) {
93117 diff --git a/net/netfilter/nfnetlink_queue_core.c b/net/netfilter/nfnetlink_queue_core.c
93118 index 5352b2d..e0083ce 100644
93119 --- a/net/netfilter/nfnetlink_queue_core.c
93120 +++ b/net/netfilter/nfnetlink_queue_core.c
93121 @@ -444,7 +444,10 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue,
93122 if (indev && entskb->dev &&
93123 entskb->mac_header != entskb->network_header) {
93124 struct nfqnl_msg_packet_hw phw;
93125 - int len = dev_parse_header(entskb, phw.hw_addr);
93126 + int len;
93127 +
93128 + memset(&phw, 0, sizeof(phw));
93129 + len = dev_parse_header(entskb, phw.hw_addr);
93130 if (len) {
93131 phw.hw_addrlen = htons(len);
93132 if (nla_put(skb, NFQA_HWADDR, sizeof(phw), &phw))
93133 diff --git a/net/netfilter/xt_TCPMSS.c b/net/netfilter/xt_TCPMSS.c
93134 index 7011c71..6113cc7 100644
93135 --- a/net/netfilter/xt_TCPMSS.c
93136 +++ b/net/netfilter/xt_TCPMSS.c
93137 @@ -52,7 +52,8 @@ tcpmss_mangle_packet(struct sk_buff *skb,
93138 {
93139 const struct xt_tcpmss_info *info = par->targinfo;
93140 struct tcphdr *tcph;
93141 - unsigned int tcplen, i;
93142 + int len, tcp_hdrlen;
93143 + unsigned int i;
93144 __be16 oldval;
93145 u16 newmss;
93146 u8 *opt;
93147 @@ -64,11 +65,14 @@ tcpmss_mangle_packet(struct sk_buff *skb,
93148 if (!skb_make_writable(skb, skb->len))
93149 return -1;
93150
93151 - tcplen = skb->len - tcphoff;
93152 + len = skb->len - tcphoff;
93153 + if (len < (int)sizeof(struct tcphdr))
93154 + return -1;
93155 +
93156 tcph = (struct tcphdr *)(skb_network_header(skb) + tcphoff);
93157 + tcp_hdrlen = tcph->doff * 4;
93158
93159 - /* Header cannot be larger than the packet */
93160 - if (tcplen < tcph->doff*4)
93161 + if (len < tcp_hdrlen)
93162 return -1;
93163
93164 if (info->mss == XT_TCPMSS_CLAMP_PMTU) {
93165 @@ -87,9 +91,8 @@ tcpmss_mangle_packet(struct sk_buff *skb,
93166 newmss = info->mss;
93167
93168 opt = (u_int8_t *)tcph;
93169 - for (i = sizeof(struct tcphdr); i < tcph->doff*4; i += optlen(opt, i)) {
93170 - if (opt[i] == TCPOPT_MSS && tcph->doff*4 - i >= TCPOLEN_MSS &&
93171 - opt[i+1] == TCPOLEN_MSS) {
93172 + for (i = sizeof(struct tcphdr); i <= tcp_hdrlen - TCPOLEN_MSS; i += optlen(opt, i)) {
93173 + if (opt[i] == TCPOPT_MSS && opt[i+1] == TCPOLEN_MSS) {
93174 u_int16_t oldmss;
93175
93176 oldmss = (opt[i+2] << 8) | opt[i+3];
93177 @@ -112,9 +115,10 @@ tcpmss_mangle_packet(struct sk_buff *skb,
93178 }
93179
93180 /* There is data after the header so the option can't be added
93181 - without moving it, and doing so may make the SYN packet
93182 - itself too large. Accept the packet unmodified instead. */
93183 - if (tcplen > tcph->doff*4)
93184 + * without moving it, and doing so may make the SYN packet
93185 + * itself too large. Accept the packet unmodified instead.
93186 + */
93187 + if (len > tcp_hdrlen)
93188 return 0;
93189
93190 /*
93191 @@ -143,10 +147,10 @@ tcpmss_mangle_packet(struct sk_buff *skb,
93192 newmss = min(newmss, (u16)1220);
93193
93194 opt = (u_int8_t *)tcph + sizeof(struct tcphdr);
93195 - memmove(opt + TCPOLEN_MSS, opt, tcplen - sizeof(struct tcphdr));
93196 + memmove(opt + TCPOLEN_MSS, opt, len - sizeof(struct tcphdr));
93197
93198 inet_proto_csum_replace2(&tcph->check, skb,
93199 - htons(tcplen), htons(tcplen + TCPOLEN_MSS), 1);
93200 + htons(len), htons(len + TCPOLEN_MSS), 1);
93201 opt[0] = TCPOPT_MSS;
93202 opt[1] = TCPOLEN_MSS;
93203 opt[2] = (newmss & 0xff00) >> 8;
93204 diff --git a/net/netfilter/xt_TCPOPTSTRIP.c b/net/netfilter/xt_TCPOPTSTRIP.c
93205 index b68fa19..625fa1d 100644
93206 --- a/net/netfilter/xt_TCPOPTSTRIP.c
93207 +++ b/net/netfilter/xt_TCPOPTSTRIP.c
93208 @@ -38,7 +38,7 @@ tcpoptstrip_mangle_packet(struct sk_buff *skb,
93209 struct tcphdr *tcph;
93210 u_int16_t n, o;
93211 u_int8_t *opt;
93212 - int len;
93213 + int len, tcp_hdrlen;
93214
93215 /* This is a fragment, no TCP header is available */
93216 if (par->fragoff != 0)
93217 @@ -52,7 +52,9 @@ tcpoptstrip_mangle_packet(struct sk_buff *skb,
93218 return NF_DROP;
93219
93220 tcph = (struct tcphdr *)(skb_network_header(skb) + tcphoff);
93221 - if (tcph->doff * 4 > len)
93222 + tcp_hdrlen = tcph->doff * 4;
93223 +
93224 + if (len < tcp_hdrlen)
93225 return NF_DROP;
93226
93227 opt = (u_int8_t *)tcph;
93228 @@ -61,10 +63,10 @@ tcpoptstrip_mangle_packet(struct sk_buff *skb,
93229 * Walk through all TCP options - if we find some option to remove,
93230 * set all octets to %TCPOPT_NOP and adjust checksum.
93231 */
93232 - for (i = sizeof(struct tcphdr); i < tcp_hdrlen(skb); i += optl) {
93233 + for (i = sizeof(struct tcphdr); i < tcp_hdrlen - 1; i += optl) {
93234 optl = optlen(opt, i);
93235
93236 - if (i + optl > tcp_hdrlen(skb))
93237 + if (i + optl > tcp_hdrlen)
93238 break;
93239
93240 if (!tcpoptstrip_test_bit(info->strip_bmap, opt[i]))
93241 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
93242 new file mode 100644
93243 index 0000000..c566332
93244 --- /dev/null
93245 +++ b/net/netfilter/xt_gradm.c
93246 @@ -0,0 +1,51 @@
93247 +/*
93248 + * gradm match for netfilter
93249 + * Copyright © Zbigniew Krzystolik, 2010
93250 + *
93251 + * This program is free software; you can redistribute it and/or modify
93252 + * it under the terms of the GNU General Public License; either version
93253 + * 2 or 3 as published by the Free Software Foundation.
93254 + */
93255 +#include <linux/module.h>
93256 +#include <linux/moduleparam.h>
93257 +#include <linux/skbuff.h>
93258 +#include <linux/netfilter/x_tables.h>
93259 +#include <linux/grsecurity.h>
93260 +#include <linux/netfilter/xt_gradm.h>
93261 +
93262 +static bool
93263 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
93264 +{
93265 + const struct xt_gradm_mtinfo *info = par->matchinfo;
93266 + bool retval = false;
93267 + if (gr_acl_is_enabled())
93268 + retval = true;
93269 + return retval ^ info->invflags;
93270 +}
93271 +
93272 +static struct xt_match gradm_mt_reg __read_mostly = {
93273 + .name = "gradm",
93274 + .revision = 0,
93275 + .family = NFPROTO_UNSPEC,
93276 + .match = gradm_mt,
93277 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
93278 + .me = THIS_MODULE,
93279 +};
93280 +
93281 +static int __init gradm_mt_init(void)
93282 +{
93283 + return xt_register_match(&gradm_mt_reg);
93284 +}
93285 +
93286 +static void __exit gradm_mt_exit(void)
93287 +{
93288 + xt_unregister_match(&gradm_mt_reg);
93289 +}
93290 +
93291 +module_init(gradm_mt_init);
93292 +module_exit(gradm_mt_exit);
93293 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
93294 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
93295 +MODULE_LICENSE("GPL");
93296 +MODULE_ALIAS("ipt_gradm");
93297 +MODULE_ALIAS("ip6t_gradm");
93298 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
93299 index 4fe4fb4..87a89e5 100644
93300 --- a/net/netfilter/xt_statistic.c
93301 +++ b/net/netfilter/xt_statistic.c
93302 @@ -19,7 +19,7 @@
93303 #include <linux/module.h>
93304
93305 struct xt_statistic_priv {
93306 - atomic_t count;
93307 + atomic_unchecked_t count;
93308 } ____cacheline_aligned_in_smp;
93309
93310 MODULE_LICENSE("GPL");
93311 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
93312 break;
93313 case XT_STATISTIC_MODE_NTH:
93314 do {
93315 - oval = atomic_read(&info->master->count);
93316 + oval = atomic_read_unchecked(&info->master->count);
93317 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
93318 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
93319 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
93320 if (nval == 0)
93321 ret = !ret;
93322 break;
93323 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
93324 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
93325 if (info->master == NULL)
93326 return -ENOMEM;
93327 - atomic_set(&info->master->count, info->u.nth.count);
93328 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
93329
93330 return 0;
93331 }
93332 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
93333 index 57ee84d..8b99cf5 100644
93334 --- a/net/netlink/af_netlink.c
93335 +++ b/net/netlink/af_netlink.c
93336 @@ -121,7 +121,7 @@ static void netlink_overrun(struct sock *sk)
93337 sk->sk_error_report(sk);
93338 }
93339 }
93340 - atomic_inc(&sk->sk_drops);
93341 + atomic_inc_unchecked(&sk->sk_drops);
93342 }
93343
93344 static void netlink_rcv_wake(struct sock *sk)
93345 @@ -2771,7 +2771,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
93346 sk_wmem_alloc_get(s),
93347 nlk->cb,
93348 atomic_read(&s->sk_refcnt),
93349 - atomic_read(&s->sk_drops),
93350 + atomic_read_unchecked(&s->sk_drops),
93351 sock_i_ino(s)
93352 );
93353
93354 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
93355 index ba6e55d..8285fd7 100644
93356 --- a/net/netlink/genetlink.c
93357 +++ b/net/netlink/genetlink.c
93358 @@ -310,18 +310,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
93359 goto errout;
93360 }
93361
93362 + pax_open_kernel();
93363 if (ops->dumpit)
93364 - ops->flags |= GENL_CMD_CAP_DUMP;
93365 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
93366 if (ops->doit)
93367 - ops->flags |= GENL_CMD_CAP_DO;
93368 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
93369 if (ops->policy)
93370 - ops->flags |= GENL_CMD_CAP_HASPOL;
93371 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
93372 + pax_close_kernel();
93373
93374 genl_lock_all();
93375 - list_add_tail(&ops->ops_list, &family->ops_list);
93376 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
93377 genl_unlock_all();
93378
93379 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
93380 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
93381 err = 0;
93382 errout:
93383 return err;
93384 @@ -351,9 +353,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
93385 genl_lock_all();
93386 list_for_each_entry(rc, &family->ops_list, ops_list) {
93387 if (rc == ops) {
93388 - list_del(&ops->ops_list);
93389 + pax_list_del((struct list_head *)&ops->ops_list);
93390 genl_unlock_all();
93391 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
93392 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
93393 return 0;
93394 }
93395 }
93396 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
93397 index ec0c80f..41e1830 100644
93398 --- a/net/netrom/af_netrom.c
93399 +++ b/net/netrom/af_netrom.c
93400 @@ -850,7 +850,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
93401 *uaddr_len = sizeof(struct full_sockaddr_ax25);
93402 } else {
93403 sax->fsa_ax25.sax25_family = AF_NETROM;
93404 - sax->fsa_ax25.sax25_ndigis = 0;
93405 sax->fsa_ax25.sax25_call = nr->source_addr;
93406 *uaddr_len = sizeof(struct sockaddr_ax25);
93407 }
93408 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
93409 index 20a1bd0..bb8f1c1 100644
93410 --- a/net/packet/af_packet.c
93411 +++ b/net/packet/af_packet.c
93412 @@ -1681,7 +1681,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
93413
93414 spin_lock(&sk->sk_receive_queue.lock);
93415 po->stats.stats1.tp_packets++;
93416 - skb->dropcount = atomic_read(&sk->sk_drops);
93417 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
93418 __skb_queue_tail(&sk->sk_receive_queue, skb);
93419 spin_unlock(&sk->sk_receive_queue.lock);
93420 sk->sk_data_ready(sk, skb->len);
93421 @@ -1690,7 +1690,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
93422 drop_n_acct:
93423 spin_lock(&sk->sk_receive_queue.lock);
93424 po->stats.stats1.tp_drops++;
93425 - atomic_inc(&sk->sk_drops);
93426 + atomic_inc_unchecked(&sk->sk_drops);
93427 spin_unlock(&sk->sk_receive_queue.lock);
93428
93429 drop_n_restore:
93430 @@ -2640,6 +2640,7 @@ out:
93431
93432 static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
93433 {
93434 + struct sock_extended_err ee;
93435 struct sock_exterr_skb *serr;
93436 struct sk_buff *skb, *skb2;
93437 int copied, err;
93438 @@ -2661,8 +2662,9 @@ static int packet_recv_error(struct sock *sk, struct msghdr *msg, int len)
93439 sock_recv_timestamp(msg, sk, skb);
93440
93441 serr = SKB_EXT_ERR(skb);
93442 + ee = serr->ee;
93443 put_cmsg(msg, SOL_PACKET, PACKET_TX_TIMESTAMP,
93444 - sizeof(serr->ee), &serr->ee);
93445 + sizeof ee, &ee);
93446
93447 msg->msg_flags |= MSG_ERRQUEUE;
93448 err = copied;
93449 @@ -3281,7 +3283,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
93450 case PACKET_HDRLEN:
93451 if (len > sizeof(int))
93452 len = sizeof(int);
93453 - if (copy_from_user(&val, optval, len))
93454 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
93455 return -EFAULT;
93456 switch (val) {
93457 case TPACKET_V1:
93458 @@ -3324,7 +3326,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
93459 len = lv;
93460 if (put_user(len, optlen))
93461 return -EFAULT;
93462 - if (copy_to_user(optval, data, len))
93463 + if (len > sizeof(st) || copy_to_user(optval, data, len))
93464 return -EFAULT;
93465 return 0;
93466 }
93467 diff --git a/net/phonet/af_phonet.c b/net/phonet/af_phonet.c
93468 index 5a940db..d6a502d 100644
93469 --- a/net/phonet/af_phonet.c
93470 +++ b/net/phonet/af_phonet.c
93471 @@ -469,7 +469,7 @@ int __init_or_module phonet_proto_register(unsigned int protocol,
93472 {
93473 int err = 0;
93474
93475 - if (protocol >= PHONET_NPROTO)
93476 + if (protocol < 0 || protocol >= PHONET_NPROTO)
93477 return -EINVAL;
93478
93479 err = proto_register(pp->prot, 1);
93480 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
93481 index e774117..900b8b7 100644
93482 --- a/net/phonet/pep.c
93483 +++ b/net/phonet/pep.c
93484 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
93485
93486 case PNS_PEP_CTRL_REQ:
93487 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
93488 - atomic_inc(&sk->sk_drops);
93489 + atomic_inc_unchecked(&sk->sk_drops);
93490 break;
93491 }
93492 __skb_pull(skb, 4);
93493 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
93494 }
93495
93496 if (pn->rx_credits == 0) {
93497 - atomic_inc(&sk->sk_drops);
93498 + atomic_inc_unchecked(&sk->sk_drops);
93499 err = -ENOBUFS;
93500 break;
93501 }
93502 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
93503 }
93504
93505 if (pn->rx_credits == 0) {
93506 - atomic_inc(&sk->sk_drops);
93507 + atomic_inc_unchecked(&sk->sk_drops);
93508 err = NET_RX_DROP;
93509 break;
93510 }
93511 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
93512 index 1afd138..0b42453 100644
93513 --- a/net/phonet/socket.c
93514 +++ b/net/phonet/socket.c
93515 @@ -612,7 +612,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
93516 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
93517 sock_i_ino(sk),
93518 atomic_read(&sk->sk_refcnt), sk,
93519 - atomic_read(&sk->sk_drops), &len);
93520 + atomic_read_unchecked(&sk->sk_drops), &len);
93521 }
93522 seq_printf(seq, "%*s\n", 127 - len, "");
93523 return 0;
93524 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
93525 index d6bbbbd..61561e4 100644
93526 --- a/net/phonet/sysctl.c
93527 +++ b/net/phonet/sysctl.c
93528 @@ -67,7 +67,7 @@ static int proc_local_port_range(ctl_table *table, int write,
93529 {
93530 int ret;
93531 int range[2] = {local_port_range[0], local_port_range[1]};
93532 - ctl_table tmp = {
93533 + ctl_table_no_const tmp = {
93534 .data = &range,
93535 .maxlen = sizeof(range),
93536 .mode = table->mode,
93537 diff --git a/net/rds/cong.c b/net/rds/cong.c
93538 index e5b65ac..f3b6fb7 100644
93539 --- a/net/rds/cong.c
93540 +++ b/net/rds/cong.c
93541 @@ -78,7 +78,7 @@
93542 * finds that the saved generation number is smaller than the global generation
93543 * number, it wakes up the process.
93544 */
93545 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
93546 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
93547
93548 /*
93549 * Congestion monitoring
93550 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
93551 rdsdebug("waking map %p for %pI4\n",
93552 map, &map->m_addr);
93553 rds_stats_inc(s_cong_update_received);
93554 - atomic_inc(&rds_cong_generation);
93555 + atomic_inc_unchecked(&rds_cong_generation);
93556 if (waitqueue_active(&map->m_waitq))
93557 wake_up(&map->m_waitq);
93558 if (waitqueue_active(&rds_poll_waitq))
93559 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
93560
93561 int rds_cong_updated_since(unsigned long *recent)
93562 {
93563 - unsigned long gen = atomic_read(&rds_cong_generation);
93564 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
93565
93566 if (likely(*recent == gen))
93567 return 0;
93568 diff --git a/net/rds/ib.h b/net/rds/ib.h
93569 index 7280ab8..e04f4ea 100644
93570 --- a/net/rds/ib.h
93571 +++ b/net/rds/ib.h
93572 @@ -128,7 +128,7 @@ struct rds_ib_connection {
93573 /* sending acks */
93574 unsigned long i_ack_flags;
93575 #ifdef KERNEL_HAS_ATOMIC64
93576 - atomic64_t i_ack_next; /* next ACK to send */
93577 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
93578 #else
93579 spinlock_t i_ack_lock; /* protect i_ack_next */
93580 u64 i_ack_next; /* next ACK to send */
93581 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
93582 index 31b74f5..dc1fbfa 100644
93583 --- a/net/rds/ib_cm.c
93584 +++ b/net/rds/ib_cm.c
93585 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
93586 /* Clear the ACK state */
93587 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
93588 #ifdef KERNEL_HAS_ATOMIC64
93589 - atomic64_set(&ic->i_ack_next, 0);
93590 + atomic64_set_unchecked(&ic->i_ack_next, 0);
93591 #else
93592 ic->i_ack_next = 0;
93593 #endif
93594 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
93595 index 8eb9501..0c386ff 100644
93596 --- a/net/rds/ib_recv.c
93597 +++ b/net/rds/ib_recv.c
93598 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
93599 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
93600 int ack_required)
93601 {
93602 - atomic64_set(&ic->i_ack_next, seq);
93603 + atomic64_set_unchecked(&ic->i_ack_next, seq);
93604 if (ack_required) {
93605 smp_mb__before_clear_bit();
93606 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
93607 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
93608 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
93609 smp_mb__after_clear_bit();
93610
93611 - return atomic64_read(&ic->i_ack_next);
93612 + return atomic64_read_unchecked(&ic->i_ack_next);
93613 }
93614 #endif
93615
93616 diff --git a/net/rds/iw.h b/net/rds/iw.h
93617 index 04ce3b1..48119a6 100644
93618 --- a/net/rds/iw.h
93619 +++ b/net/rds/iw.h
93620 @@ -134,7 +134,7 @@ struct rds_iw_connection {
93621 /* sending acks */
93622 unsigned long i_ack_flags;
93623 #ifdef KERNEL_HAS_ATOMIC64
93624 - atomic64_t i_ack_next; /* next ACK to send */
93625 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
93626 #else
93627 spinlock_t i_ack_lock; /* protect i_ack_next */
93628 u64 i_ack_next; /* next ACK to send */
93629 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
93630 index a91e1db..cf3053f 100644
93631 --- a/net/rds/iw_cm.c
93632 +++ b/net/rds/iw_cm.c
93633 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
93634 /* Clear the ACK state */
93635 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
93636 #ifdef KERNEL_HAS_ATOMIC64
93637 - atomic64_set(&ic->i_ack_next, 0);
93638 + atomic64_set_unchecked(&ic->i_ack_next, 0);
93639 #else
93640 ic->i_ack_next = 0;
93641 #endif
93642 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
93643 index 4503335..db566b4 100644
93644 --- a/net/rds/iw_recv.c
93645 +++ b/net/rds/iw_recv.c
93646 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
93647 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
93648 int ack_required)
93649 {
93650 - atomic64_set(&ic->i_ack_next, seq);
93651 + atomic64_set_unchecked(&ic->i_ack_next, seq);
93652 if (ack_required) {
93653 smp_mb__before_clear_bit();
93654 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
93655 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
93656 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
93657 smp_mb__after_clear_bit();
93658
93659 - return atomic64_read(&ic->i_ack_next);
93660 + return atomic64_read_unchecked(&ic->i_ack_next);
93661 }
93662 #endif
93663
93664 diff --git a/net/rds/rds.h b/net/rds/rds.h
93665 index ec1d731..90a3a8d 100644
93666 --- a/net/rds/rds.h
93667 +++ b/net/rds/rds.h
93668 @@ -449,7 +449,7 @@ struct rds_transport {
93669 void (*sync_mr)(void *trans_private, int direction);
93670 void (*free_mr)(void *trans_private, int invalidate);
93671 void (*flush_mrs)(void);
93672 -};
93673 +} __do_const;
93674
93675 struct rds_sock {
93676 struct sock rs_sk;
93677 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
93678 index edac9ef..16bcb98 100644
93679 --- a/net/rds/tcp.c
93680 +++ b/net/rds/tcp.c
93681 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
93682 int val = 1;
93683
93684 set_fs(KERNEL_DS);
93685 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
93686 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
93687 sizeof(val));
93688 set_fs(oldfs);
93689 }
93690 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
93691 index 81cf5a4..b5826ff 100644
93692 --- a/net/rds/tcp_send.c
93693 +++ b/net/rds/tcp_send.c
93694 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
93695
93696 oldfs = get_fs();
93697 set_fs(KERNEL_DS);
93698 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
93699 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
93700 sizeof(val));
93701 set_fs(oldfs);
93702 }
93703 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
93704 index e61aa60..f07cc89 100644
93705 --- a/net/rxrpc/af_rxrpc.c
93706 +++ b/net/rxrpc/af_rxrpc.c
93707 @@ -40,7 +40,7 @@ static const struct proto_ops rxrpc_rpc_ops;
93708 __be32 rxrpc_epoch;
93709
93710 /* current debugging ID */
93711 -atomic_t rxrpc_debug_id;
93712 +atomic_unchecked_t rxrpc_debug_id;
93713
93714 /* count of skbs currently in use */
93715 atomic_t rxrpc_n_skbs;
93716 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
93717 index e4d9cbc..b229649 100644
93718 --- a/net/rxrpc/ar-ack.c
93719 +++ b/net/rxrpc/ar-ack.c
93720 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
93721
93722 _enter("{%d,%d,%d,%d},",
93723 call->acks_hard, call->acks_unacked,
93724 - atomic_read(&call->sequence),
93725 + atomic_read_unchecked(&call->sequence),
93726 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
93727
93728 stop = 0;
93729 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
93730
93731 /* each Tx packet has a new serial number */
93732 sp->hdr.serial =
93733 - htonl(atomic_inc_return(&call->conn->serial));
93734 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
93735
93736 hdr = (struct rxrpc_header *) txb->head;
93737 hdr->serial = sp->hdr.serial;
93738 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
93739 */
93740 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
93741 {
93742 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
93743 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
93744 }
93745
93746 /*
93747 @@ -629,7 +629,7 @@ process_further:
93748
93749 latest = ntohl(sp->hdr.serial);
93750 hard = ntohl(ack.firstPacket);
93751 - tx = atomic_read(&call->sequence);
93752 + tx = atomic_read_unchecked(&call->sequence);
93753
93754 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
93755 latest,
93756 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
93757 goto maybe_reschedule;
93758
93759 send_ACK_with_skew:
93760 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
93761 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
93762 ntohl(ack.serial));
93763 send_ACK:
93764 mtu = call->conn->trans->peer->if_mtu;
93765 @@ -1173,7 +1173,7 @@ send_ACK:
93766 ackinfo.rxMTU = htonl(5692);
93767 ackinfo.jumbo_max = htonl(4);
93768
93769 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
93770 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
93771 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
93772 ntohl(hdr.serial),
93773 ntohs(ack.maxSkew),
93774 @@ -1191,7 +1191,7 @@ send_ACK:
93775 send_message:
93776 _debug("send message");
93777
93778 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
93779 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
93780 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
93781 send_message_2:
93782
93783 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
93784 index a3bbb36..3341fb9 100644
93785 --- a/net/rxrpc/ar-call.c
93786 +++ b/net/rxrpc/ar-call.c
93787 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
93788 spin_lock_init(&call->lock);
93789 rwlock_init(&call->state_lock);
93790 atomic_set(&call->usage, 1);
93791 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
93792 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
93793 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
93794
93795 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
93796 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
93797 index 4106ca9..a338d7a 100644
93798 --- a/net/rxrpc/ar-connection.c
93799 +++ b/net/rxrpc/ar-connection.c
93800 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
93801 rwlock_init(&conn->lock);
93802 spin_lock_init(&conn->state_lock);
93803 atomic_set(&conn->usage, 1);
93804 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
93805 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
93806 conn->avail_calls = RXRPC_MAXCALLS;
93807 conn->size_align = 4;
93808 conn->header_size = sizeof(struct rxrpc_header);
93809 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
93810 index e7ed43a..6afa140 100644
93811 --- a/net/rxrpc/ar-connevent.c
93812 +++ b/net/rxrpc/ar-connevent.c
93813 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
93814
93815 len = iov[0].iov_len + iov[1].iov_len;
93816
93817 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
93818 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
93819 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
93820
93821 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
93822 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
93823 index 529572f..c758ca7 100644
93824 --- a/net/rxrpc/ar-input.c
93825 +++ b/net/rxrpc/ar-input.c
93826 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
93827 /* track the latest serial number on this connection for ACK packet
93828 * information */
93829 serial = ntohl(sp->hdr.serial);
93830 - hi_serial = atomic_read(&call->conn->hi_serial);
93831 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
93832 while (serial > hi_serial)
93833 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
93834 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
93835 serial);
93836
93837 /* request ACK generation for any ACK or DATA packet that requests
93838 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
93839 index a693aca..81e7293 100644
93840 --- a/net/rxrpc/ar-internal.h
93841 +++ b/net/rxrpc/ar-internal.h
93842 @@ -272,8 +272,8 @@ struct rxrpc_connection {
93843 int error; /* error code for local abort */
93844 int debug_id; /* debug ID for printks */
93845 unsigned int call_counter; /* call ID counter */
93846 - atomic_t serial; /* packet serial number counter */
93847 - atomic_t hi_serial; /* highest serial number received */
93848 + atomic_unchecked_t serial; /* packet serial number counter */
93849 + atomic_unchecked_t hi_serial; /* highest serial number received */
93850 u8 avail_calls; /* number of calls available */
93851 u8 size_align; /* data size alignment (for security) */
93852 u8 header_size; /* rxrpc + security header size */
93853 @@ -346,7 +346,7 @@ struct rxrpc_call {
93854 spinlock_t lock;
93855 rwlock_t state_lock; /* lock for state transition */
93856 atomic_t usage;
93857 - atomic_t sequence; /* Tx data packet sequence counter */
93858 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
93859 u32 abort_code; /* local/remote abort code */
93860 enum { /* current state of call */
93861 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
93862 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
93863 */
93864 extern atomic_t rxrpc_n_skbs;
93865 extern __be32 rxrpc_epoch;
93866 -extern atomic_t rxrpc_debug_id;
93867 +extern atomic_unchecked_t rxrpc_debug_id;
93868 extern struct workqueue_struct *rxrpc_workqueue;
93869
93870 /*
93871 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
93872 index 87f7135..74d3703 100644
93873 --- a/net/rxrpc/ar-local.c
93874 +++ b/net/rxrpc/ar-local.c
93875 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
93876 spin_lock_init(&local->lock);
93877 rwlock_init(&local->services_lock);
93878 atomic_set(&local->usage, 1);
93879 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
93880 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
93881 memcpy(&local->srx, srx, sizeof(*srx));
93882 }
93883
93884 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
93885 index e1ac183..b43e10e 100644
93886 --- a/net/rxrpc/ar-output.c
93887 +++ b/net/rxrpc/ar-output.c
93888 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
93889 sp->hdr.cid = call->cid;
93890 sp->hdr.callNumber = call->call_id;
93891 sp->hdr.seq =
93892 - htonl(atomic_inc_return(&call->sequence));
93893 + htonl(atomic_inc_return_unchecked(&call->sequence));
93894 sp->hdr.serial =
93895 - htonl(atomic_inc_return(&conn->serial));
93896 + htonl(atomic_inc_return_unchecked(&conn->serial));
93897 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
93898 sp->hdr.userStatus = 0;
93899 sp->hdr.securityIndex = conn->security_ix;
93900 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
93901 index bebaa43..2644591 100644
93902 --- a/net/rxrpc/ar-peer.c
93903 +++ b/net/rxrpc/ar-peer.c
93904 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
93905 INIT_LIST_HEAD(&peer->error_targets);
93906 spin_lock_init(&peer->lock);
93907 atomic_set(&peer->usage, 1);
93908 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
93909 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
93910 memcpy(&peer->srx, srx, sizeof(*srx));
93911
93912 rxrpc_assess_MTU_size(peer);
93913 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
93914 index 38047f7..9f48511 100644
93915 --- a/net/rxrpc/ar-proc.c
93916 +++ b/net/rxrpc/ar-proc.c
93917 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
93918 atomic_read(&conn->usage),
93919 rxrpc_conn_states[conn->state],
93920 key_serial(conn->key),
93921 - atomic_read(&conn->serial),
93922 - atomic_read(&conn->hi_serial));
93923 + atomic_read_unchecked(&conn->serial),
93924 + atomic_read_unchecked(&conn->hi_serial));
93925
93926 return 0;
93927 }
93928 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
93929 index 92df566..87ec1bf 100644
93930 --- a/net/rxrpc/ar-transport.c
93931 +++ b/net/rxrpc/ar-transport.c
93932 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
93933 spin_lock_init(&trans->client_lock);
93934 rwlock_init(&trans->conn_lock);
93935 atomic_set(&trans->usage, 1);
93936 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
93937 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
93938
93939 if (peer->srx.transport.family == AF_INET) {
93940 switch (peer->srx.transport_type) {
93941 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
93942 index f226709..0e735a8 100644
93943 --- a/net/rxrpc/rxkad.c
93944 +++ b/net/rxrpc/rxkad.c
93945 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
93946
93947 len = iov[0].iov_len + iov[1].iov_len;
93948
93949 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
93950 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
93951 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
93952
93953 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
93954 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
93955
93956 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
93957
93958 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
93959 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
93960 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
93961
93962 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
93963 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
93964 index 391a245..296b3d7 100644
93965 --- a/net/sctp/ipv6.c
93966 +++ b/net/sctp/ipv6.c
93967 @@ -981,7 +981,7 @@ static const struct inet6_protocol sctpv6_protocol = {
93968 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
93969 };
93970
93971 -static struct sctp_af sctp_af_inet6 = {
93972 +static struct sctp_af sctp_af_inet6 __read_only = {
93973 .sa_family = AF_INET6,
93974 .sctp_xmit = sctp_v6_xmit,
93975 .setsockopt = ipv6_setsockopt,
93976 @@ -1013,7 +1013,7 @@ static struct sctp_af sctp_af_inet6 = {
93977 #endif
93978 };
93979
93980 -static struct sctp_pf sctp_pf_inet6 = {
93981 +static struct sctp_pf sctp_pf_inet6 __read_only = {
93982 .event_msgname = sctp_inet6_event_msgname,
93983 .skb_msgname = sctp_inet6_skb_msgname,
93984 .af_supported = sctp_inet6_af_supported,
93985 @@ -1038,7 +1038,7 @@ void sctp_v6_pf_init(void)
93986
93987 void sctp_v6_pf_exit(void)
93988 {
93989 - list_del(&sctp_af_inet6.list);
93990 + pax_list_del(&sctp_af_inet6.list);
93991 }
93992
93993 /* Initialize IPv6 support and register with socket layer. */
93994 diff --git a/net/sctp/proc.c b/net/sctp/proc.c
93995 index 4e45ee3..e66a031 100644
93996 --- a/net/sctp/proc.c
93997 +++ b/net/sctp/proc.c
93998 @@ -337,7 +337,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
93999 seq_printf(seq,
94000 "%8pK %8pK %-3d %-3d %-2d %-4d "
94001 "%4d %8d %8d %7d %5lu %-5d %5d ",
94002 - assoc, sk, sctp_sk(sk)->type, sk->sk_state,
94003 + assoc, sk,
94004 + sctp_sk(sk)->type, sk->sk_state,
94005 assoc->state, hash,
94006 assoc->assoc_id,
94007 assoc->sndbuf_used,
94008 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
94009 index eaee00c..97c0afd 100644
94010 --- a/net/sctp/protocol.c
94011 +++ b/net/sctp/protocol.c
94012 @@ -834,8 +834,10 @@ int sctp_register_af(struct sctp_af *af)
94013 return 0;
94014 }
94015
94016 + pax_open_kernel();
94017 INIT_LIST_HEAD(&af->list);
94018 - list_add_tail(&af->list, &sctp_address_families);
94019 + pax_close_kernel();
94020 + pax_list_add_tail(&af->list, &sctp_address_families);
94021 return 1;
94022 }
94023
94024 @@ -966,7 +968,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
94025
94026 static struct sctp_af sctp_af_inet;
94027
94028 -static struct sctp_pf sctp_pf_inet = {
94029 +static struct sctp_pf sctp_pf_inet __read_only = {
94030 .event_msgname = sctp_inet_event_msgname,
94031 .skb_msgname = sctp_inet_skb_msgname,
94032 .af_supported = sctp_inet_af_supported,
94033 @@ -1037,7 +1039,7 @@ static const struct net_protocol sctp_protocol = {
94034 };
94035
94036 /* IPv4 address related functions. */
94037 -static struct sctp_af sctp_af_inet = {
94038 +static struct sctp_af sctp_af_inet __read_only = {
94039 .sa_family = AF_INET,
94040 .sctp_xmit = sctp_v4_xmit,
94041 .setsockopt = ip_setsockopt,
94042 @@ -1122,7 +1124,7 @@ static void sctp_v4_pf_init(void)
94043
94044 static void sctp_v4_pf_exit(void)
94045 {
94046 - list_del(&sctp_af_inet.list);
94047 + pax_list_del(&sctp_af_inet.list);
94048 }
94049
94050 static int sctp_v4_protosw_init(void)
94051 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
94052 index 8aab894..f6b7e7d 100644
94053 --- a/net/sctp/sm_sideeffect.c
94054 +++ b/net/sctp/sm_sideeffect.c
94055 @@ -447,7 +447,7 @@ static void sctp_generate_sack_event(unsigned long data)
94056 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
94057 }
94058
94059 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
94060 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
94061 NULL,
94062 sctp_generate_t1_cookie_event,
94063 sctp_generate_t1_init_event,
94064 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
94065 index 6abb1ca..1678f8b 100644
94066 --- a/net/sctp/socket.c
94067 +++ b/net/sctp/socket.c
94068 @@ -2167,11 +2167,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
94069 {
94070 struct sctp_association *asoc;
94071 struct sctp_ulpevent *event;
94072 + struct sctp_event_subscribe subscribe;
94073
94074 if (optlen > sizeof(struct sctp_event_subscribe))
94075 return -EINVAL;
94076 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
94077 + if (copy_from_user(&subscribe, optval, optlen))
94078 return -EFAULT;
94079 + sctp_sk(sk)->subscribe = subscribe;
94080
94081 /*
94082 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
94083 @@ -4222,13 +4224,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
94084 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
94085 int __user *optlen)
94086 {
94087 + struct sctp_event_subscribe subscribe;
94088 +
94089 if (len <= 0)
94090 return -EINVAL;
94091 if (len > sizeof(struct sctp_event_subscribe))
94092 len = sizeof(struct sctp_event_subscribe);
94093 if (put_user(len, optlen))
94094 return -EFAULT;
94095 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
94096 + subscribe = sctp_sk(sk)->subscribe;
94097 + if (copy_to_user(optval, &subscribe, len))
94098 return -EFAULT;
94099 return 0;
94100 }
94101 @@ -4246,6 +4251,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
94102 */
94103 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
94104 {
94105 + __u32 autoclose;
94106 +
94107 /* Applicable to UDP-style socket only */
94108 if (sctp_style(sk, TCP))
94109 return -EOPNOTSUPP;
94110 @@ -4254,7 +4261,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
94111 len = sizeof(int);
94112 if (put_user(len, optlen))
94113 return -EFAULT;
94114 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
94115 + autoclose = sctp_sk(sk)->autoclose;
94116 + if (copy_to_user(optval, &autoclose, sizeof(int)))
94117 return -EFAULT;
94118 return 0;
94119 }
94120 @@ -4626,12 +4634,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
94121 */
94122 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
94123 {
94124 + struct sctp_initmsg initmsg;
94125 +
94126 if (len < sizeof(struct sctp_initmsg))
94127 return -EINVAL;
94128 len = sizeof(struct sctp_initmsg);
94129 if (put_user(len, optlen))
94130 return -EFAULT;
94131 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
94132 + initmsg = sctp_sk(sk)->initmsg;
94133 + if (copy_to_user(optval, &initmsg, len))
94134 return -EFAULT;
94135 return 0;
94136 }
94137 @@ -4672,6 +4683,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
94138 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
94139 if (space_left < addrlen)
94140 return -ENOMEM;
94141 + if (addrlen > sizeof(temp) || addrlen < 0)
94142 + return -EFAULT;
94143 if (copy_to_user(to, &temp, addrlen))
94144 return -EFAULT;
94145 to += addrlen;
94146 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
94147 index bf3c6e8..376d8d0 100644
94148 --- a/net/sctp/sysctl.c
94149 +++ b/net/sctp/sysctl.c
94150 @@ -307,7 +307,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
94151 {
94152 struct net *net = current->nsproxy->net_ns;
94153 char tmp[8];
94154 - ctl_table tbl;
94155 + ctl_table_no_const tbl;
94156 int ret;
94157 int changed = 0;
94158 char *none = "none";
94159 @@ -350,7 +350,7 @@ static int proc_sctp_do_hmac_alg(ctl_table *ctl,
94160
94161 int sctp_sysctl_net_register(struct net *net)
94162 {
94163 - struct ctl_table *table;
94164 + ctl_table_no_const *table;
94165 int i;
94166
94167 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
94168 diff --git a/net/sctp/transport.c b/net/sctp/transport.c
94169 index 098f1d5f..60da2f7 100644
94170 --- a/net/sctp/transport.c
94171 +++ b/net/sctp/transport.c
94172 @@ -178,12 +178,12 @@ static void sctp_transport_destroy(struct sctp_transport *transport)
94173 {
94174 SCTP_ASSERT(transport->dead, "Transport is not dead", return);
94175
94176 - call_rcu(&transport->rcu, sctp_transport_destroy_rcu);
94177 -
94178 sctp_packet_free(&transport->packet);
94179
94180 if (transport->asoc)
94181 sctp_association_put(transport->asoc);
94182 +
94183 + call_rcu(&transport->rcu, sctp_transport_destroy_rcu);
94184 }
94185
94186 /* Start T3_rtx timer if it is not already running and update the heartbeat
94187 diff --git a/net/socket.c b/net/socket.c
94188 index 4ca1526..df83e47 100644
94189 --- a/net/socket.c
94190 +++ b/net/socket.c
94191 @@ -88,6 +88,7 @@
94192 #include <linux/magic.h>
94193 #include <linux/slab.h>
94194 #include <linux/xattr.h>
94195 +#include <linux/in.h>
94196
94197 #include <asm/uaccess.h>
94198 #include <asm/unistd.h>
94199 @@ -105,6 +106,8 @@
94200 #include <linux/sockios.h>
94201 #include <linux/atalk.h>
94202
94203 +#include <linux/grsock.h>
94204 +
94205 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
94206 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
94207 unsigned long nr_segs, loff_t pos);
94208 @@ -321,7 +324,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
94209 &sockfs_dentry_operations, SOCKFS_MAGIC);
94210 }
94211
94212 -static struct vfsmount *sock_mnt __read_mostly;
94213 +struct vfsmount *sock_mnt __read_mostly;
94214
94215 static struct file_system_type sock_fs_type = {
94216 .name = "sockfs",
94217 @@ -1246,6 +1249,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
94218 return -EAFNOSUPPORT;
94219 if (type < 0 || type >= SOCK_MAX)
94220 return -EINVAL;
94221 + if (protocol < 0)
94222 + return -EINVAL;
94223
94224 /* Compatibility.
94225
94226 @@ -1377,6 +1382,16 @@ SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)
94227 if (SOCK_NONBLOCK != O_NONBLOCK && (flags & SOCK_NONBLOCK))
94228 flags = (flags & ~SOCK_NONBLOCK) | O_NONBLOCK;
94229
94230 + if(!gr_search_socket(family, type, protocol)) {
94231 + retval = -EACCES;
94232 + goto out;
94233 + }
94234 +
94235 + if (gr_handle_sock_all(family, type, protocol)) {
94236 + retval = -EACCES;
94237 + goto out;
94238 + }
94239 +
94240 retval = sock_create(family, type, protocol, &sock);
94241 if (retval < 0)
94242 goto out;
94243 @@ -1504,6 +1519,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
94244 if (sock) {
94245 err = move_addr_to_kernel(umyaddr, addrlen, &address);
94246 if (err >= 0) {
94247 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
94248 + err = -EACCES;
94249 + goto error;
94250 + }
94251 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
94252 + if (err)
94253 + goto error;
94254 +
94255 err = security_socket_bind(sock,
94256 (struct sockaddr *)&address,
94257 addrlen);
94258 @@ -1512,6 +1535,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
94259 (struct sockaddr *)
94260 &address, addrlen);
94261 }
94262 +error:
94263 fput_light(sock->file, fput_needed);
94264 }
94265 return err;
94266 @@ -1535,10 +1559,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
94267 if ((unsigned int)backlog > somaxconn)
94268 backlog = somaxconn;
94269
94270 + if (gr_handle_sock_server_other(sock->sk)) {
94271 + err = -EPERM;
94272 + goto error;
94273 + }
94274 +
94275 + err = gr_search_listen(sock);
94276 + if (err)
94277 + goto error;
94278 +
94279 err = security_socket_listen(sock, backlog);
94280 if (!err)
94281 err = sock->ops->listen(sock, backlog);
94282
94283 +error:
94284 fput_light(sock->file, fput_needed);
94285 }
94286 return err;
94287 @@ -1582,6 +1616,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
94288 newsock->type = sock->type;
94289 newsock->ops = sock->ops;
94290
94291 + if (gr_handle_sock_server_other(sock->sk)) {
94292 + err = -EPERM;
94293 + sock_release(newsock);
94294 + goto out_put;
94295 + }
94296 +
94297 + err = gr_search_accept(sock);
94298 + if (err) {
94299 + sock_release(newsock);
94300 + goto out_put;
94301 + }
94302 +
94303 /*
94304 * We don't need try_module_get here, as the listening socket (sock)
94305 * has the protocol module (sock->ops->owner) held.
94306 @@ -1627,6 +1673,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
94307 fd_install(newfd, newfile);
94308 err = newfd;
94309
94310 + gr_attach_curr_ip(newsock->sk);
94311 +
94312 out_put:
94313 fput_light(sock->file, fput_needed);
94314 out:
94315 @@ -1659,6 +1707,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
94316 int, addrlen)
94317 {
94318 struct socket *sock;
94319 + struct sockaddr *sck;
94320 struct sockaddr_storage address;
94321 int err, fput_needed;
94322
94323 @@ -1669,6 +1718,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
94324 if (err < 0)
94325 goto out_put;
94326
94327 + sck = (struct sockaddr *)&address;
94328 +
94329 + if (gr_handle_sock_client(sck)) {
94330 + err = -EACCES;
94331 + goto out_put;
94332 + }
94333 +
94334 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
94335 + if (err)
94336 + goto out_put;
94337 +
94338 err =
94339 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
94340 if (err)
94341 @@ -1750,6 +1810,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
94342 * the protocol.
94343 */
94344
94345 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
94346 +
94347 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
94348 unsigned int, flags, struct sockaddr __user *, addr,
94349 int, addr_len)
94350 @@ -1816,7 +1878,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
94351 struct socket *sock;
94352 struct iovec iov;
94353 struct msghdr msg;
94354 - struct sockaddr_storage address;
94355 + struct sockaddr_storage address = { };
94356 int err, err2;
94357 int fput_needed;
94358
94359 @@ -2023,7 +2085,7 @@ static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
94360 * checking falls down on this.
94361 */
94362 if (copy_from_user(ctl_buf,
94363 - (void __user __force *)msg_sys->msg_control,
94364 + (void __force_user *)msg_sys->msg_control,
94365 ctl_len))
94366 goto out_freectl;
94367 msg_sys->msg_control = ctl_buf;
94368 @@ -2174,7 +2236,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
94369 int err, total_len, len;
94370
94371 /* kernel mode address */
94372 - struct sockaddr_storage addr;
94373 + struct sockaddr_storage addr = { };
94374
94375 /* user mode address pointers */
94376 struct sockaddr __user *uaddr;
94377 @@ -2202,7 +2264,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
94378 * kernel msghdr to use the kernel address space)
94379 */
94380
94381 - uaddr = (__force void __user *)msg_sys->msg_name;
94382 + uaddr = (void __force_user *)msg_sys->msg_name;
94383 uaddr_len = COMPAT_NAMELEN(msg);
94384 if (MSG_CMSG_COMPAT & flags) {
94385 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
94386 @@ -2955,7 +3017,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
94387 old_fs = get_fs();
94388 set_fs(KERNEL_DS);
94389 err = dev_ioctl(net, cmd,
94390 - (struct ifreq __user __force *) &kifr);
94391 + (struct ifreq __force_user *) &kifr);
94392 set_fs(old_fs);
94393
94394 return err;
94395 @@ -3064,7 +3126,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
94396
94397 old_fs = get_fs();
94398 set_fs(KERNEL_DS);
94399 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
94400 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
94401 set_fs(old_fs);
94402
94403 if (cmd == SIOCGIFMAP && !err) {
94404 @@ -3169,7 +3231,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
94405 ret |= __get_user(rtdev, &(ur4->rt_dev));
94406 if (rtdev) {
94407 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
94408 - r4.rt_dev = (char __user __force *)devname;
94409 + r4.rt_dev = (char __force_user *)devname;
94410 devname[15] = 0;
94411 } else
94412 r4.rt_dev = NULL;
94413 @@ -3395,8 +3457,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
94414 int __user *uoptlen;
94415 int err;
94416
94417 - uoptval = (char __user __force *) optval;
94418 - uoptlen = (int __user __force *) optlen;
94419 + uoptval = (char __force_user *) optval;
94420 + uoptlen = (int __force_user *) optlen;
94421
94422 set_fs(KERNEL_DS);
94423 if (level == SOL_SOCKET)
94424 @@ -3416,7 +3478,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
94425 char __user *uoptval;
94426 int err;
94427
94428 - uoptval = (char __user __force *) optval;
94429 + uoptval = (char __force_user *) optval;
94430
94431 set_fs(KERNEL_DS);
94432 if (level == SOL_SOCKET)
94433 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
94434 index 426f8fc..1ef9c32 100644
94435 --- a/net/sunrpc/clnt.c
94436 +++ b/net/sunrpc/clnt.c
94437 @@ -1288,7 +1288,9 @@ call_start(struct rpc_task *task)
94438 (RPC_IS_ASYNC(task) ? "async" : "sync"));
94439
94440 /* Increment call count */
94441 - task->tk_msg.rpc_proc->p_count++;
94442 + pax_open_kernel();
94443 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
94444 + pax_close_kernel();
94445 clnt->cl_stats->rpccnt++;
94446 task->tk_action = call_reserve;
94447 }
94448 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
94449 index 5356b12..c0f4c29 100644
94450 --- a/net/sunrpc/sched.c
94451 +++ b/net/sunrpc/sched.c
94452 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
94453 #ifdef RPC_DEBUG
94454 static void rpc_task_set_debuginfo(struct rpc_task *task)
94455 {
94456 - static atomic_t rpc_pid;
94457 + static atomic_unchecked_t rpc_pid;
94458
94459 - task->tk_pid = atomic_inc_return(&rpc_pid);
94460 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
94461 }
94462 #else
94463 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
94464 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
94465 index 89a588b..678ed90 100644
94466 --- a/net/sunrpc/svc.c
94467 +++ b/net/sunrpc/svc.c
94468 @@ -740,7 +740,7 @@ svc_set_num_threads(struct svc_serv *serv, struct svc_pool *pool, int nrservs)
94469
94470 __module_get(serv->sv_module);
94471 task = kthread_create_on_node(serv->sv_function, rqstp,
94472 - node, serv->sv_name);
94473 + node, "%s", serv->sv_name);
94474 if (IS_ERR(task)) {
94475 error = PTR_ERR(task);
94476 module_put(serv->sv_module);
94477 @@ -1160,7 +1160,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
94478 svc_putnl(resv, RPC_SUCCESS);
94479
94480 /* Bump per-procedure stats counter */
94481 - procp->pc_count++;
94482 + pax_open_kernel();
94483 + (*(unsigned int *)&procp->pc_count)++;
94484 + pax_close_kernel();
94485
94486 /* Initialize storage for argp and resp */
94487 memset(rqstp->rq_argp, 0, procp->pc_argsize);
94488 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
94489 index 8343737..677025e 100644
94490 --- a/net/sunrpc/xprtrdma/svc_rdma.c
94491 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
94492 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
94493 static unsigned int min_max_inline = 4096;
94494 static unsigned int max_max_inline = 65536;
94495
94496 -atomic_t rdma_stat_recv;
94497 -atomic_t rdma_stat_read;
94498 -atomic_t rdma_stat_write;
94499 -atomic_t rdma_stat_sq_starve;
94500 -atomic_t rdma_stat_rq_starve;
94501 -atomic_t rdma_stat_rq_poll;
94502 -atomic_t rdma_stat_rq_prod;
94503 -atomic_t rdma_stat_sq_poll;
94504 -atomic_t rdma_stat_sq_prod;
94505 +atomic_unchecked_t rdma_stat_recv;
94506 +atomic_unchecked_t rdma_stat_read;
94507 +atomic_unchecked_t rdma_stat_write;
94508 +atomic_unchecked_t rdma_stat_sq_starve;
94509 +atomic_unchecked_t rdma_stat_rq_starve;
94510 +atomic_unchecked_t rdma_stat_rq_poll;
94511 +atomic_unchecked_t rdma_stat_rq_prod;
94512 +atomic_unchecked_t rdma_stat_sq_poll;
94513 +atomic_unchecked_t rdma_stat_sq_prod;
94514
94515 /* Temporary NFS request map and context caches */
94516 struct kmem_cache *svc_rdma_map_cachep;
94517 @@ -110,7 +110,7 @@ static int read_reset_stat(ctl_table *table, int write,
94518 len -= *ppos;
94519 if (len > *lenp)
94520 len = *lenp;
94521 - if (len && copy_to_user(buffer, str_buf, len))
94522 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
94523 return -EFAULT;
94524 *lenp = len;
94525 *ppos += len;
94526 @@ -151,63 +151,63 @@ static ctl_table svcrdma_parm_table[] = {
94527 {
94528 .procname = "rdma_stat_read",
94529 .data = &rdma_stat_read,
94530 - .maxlen = sizeof(atomic_t),
94531 + .maxlen = sizeof(atomic_unchecked_t),
94532 .mode = 0644,
94533 .proc_handler = read_reset_stat,
94534 },
94535 {
94536 .procname = "rdma_stat_recv",
94537 .data = &rdma_stat_recv,
94538 - .maxlen = sizeof(atomic_t),
94539 + .maxlen = sizeof(atomic_unchecked_t),
94540 .mode = 0644,
94541 .proc_handler = read_reset_stat,
94542 },
94543 {
94544 .procname = "rdma_stat_write",
94545 .data = &rdma_stat_write,
94546 - .maxlen = sizeof(atomic_t),
94547 + .maxlen = sizeof(atomic_unchecked_t),
94548 .mode = 0644,
94549 .proc_handler = read_reset_stat,
94550 },
94551 {
94552 .procname = "rdma_stat_sq_starve",
94553 .data = &rdma_stat_sq_starve,
94554 - .maxlen = sizeof(atomic_t),
94555 + .maxlen = sizeof(atomic_unchecked_t),
94556 .mode = 0644,
94557 .proc_handler = read_reset_stat,
94558 },
94559 {
94560 .procname = "rdma_stat_rq_starve",
94561 .data = &rdma_stat_rq_starve,
94562 - .maxlen = sizeof(atomic_t),
94563 + .maxlen = sizeof(atomic_unchecked_t),
94564 .mode = 0644,
94565 .proc_handler = read_reset_stat,
94566 },
94567 {
94568 .procname = "rdma_stat_rq_poll",
94569 .data = &rdma_stat_rq_poll,
94570 - .maxlen = sizeof(atomic_t),
94571 + .maxlen = sizeof(atomic_unchecked_t),
94572 .mode = 0644,
94573 .proc_handler = read_reset_stat,
94574 },
94575 {
94576 .procname = "rdma_stat_rq_prod",
94577 .data = &rdma_stat_rq_prod,
94578 - .maxlen = sizeof(atomic_t),
94579 + .maxlen = sizeof(atomic_unchecked_t),
94580 .mode = 0644,
94581 .proc_handler = read_reset_stat,
94582 },
94583 {
94584 .procname = "rdma_stat_sq_poll",
94585 .data = &rdma_stat_sq_poll,
94586 - .maxlen = sizeof(atomic_t),
94587 + .maxlen = sizeof(atomic_unchecked_t),
94588 .mode = 0644,
94589 .proc_handler = read_reset_stat,
94590 },
94591 {
94592 .procname = "rdma_stat_sq_prod",
94593 .data = &rdma_stat_sq_prod,
94594 - .maxlen = sizeof(atomic_t),
94595 + .maxlen = sizeof(atomic_unchecked_t),
94596 .mode = 0644,
94597 .proc_handler = read_reset_stat,
94598 },
94599 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
94600 index 0ce7552..d074459 100644
94601 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
94602 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
94603 @@ -501,7 +501,7 @@ next_sge:
94604 svc_rdma_put_context(ctxt, 0);
94605 goto out;
94606 }
94607 - atomic_inc(&rdma_stat_read);
94608 + atomic_inc_unchecked(&rdma_stat_read);
94609
94610 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
94611 chl_map->ch[ch_no].count -= read_wr.num_sge;
94612 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
94613 dto_q);
94614 list_del_init(&ctxt->dto_q);
94615 } else {
94616 - atomic_inc(&rdma_stat_rq_starve);
94617 + atomic_inc_unchecked(&rdma_stat_rq_starve);
94618 clear_bit(XPT_DATA, &xprt->xpt_flags);
94619 ctxt = NULL;
94620 }
94621 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
94622 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
94623 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
94624 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
94625 - atomic_inc(&rdma_stat_recv);
94626 + atomic_inc_unchecked(&rdma_stat_recv);
94627
94628 /* Build up the XDR from the receive buffers. */
94629 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
94630 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
94631 index c1d124d..acfc59e 100644
94632 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
94633 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
94634 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
94635 write_wr.wr.rdma.remote_addr = to;
94636
94637 /* Post It */
94638 - atomic_inc(&rdma_stat_write);
94639 + atomic_inc_unchecked(&rdma_stat_write);
94640 if (svc_rdma_send(xprt, &write_wr))
94641 goto err;
94642 return 0;
94643 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
94644 index 62e4f9b..dd3f2d7 100644
94645 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
94646 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
94647 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
94648 return;
94649
94650 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
94651 - atomic_inc(&rdma_stat_rq_poll);
94652 + atomic_inc_unchecked(&rdma_stat_rq_poll);
94653
94654 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
94655 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
94656 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
94657 }
94658
94659 if (ctxt)
94660 - atomic_inc(&rdma_stat_rq_prod);
94661 + atomic_inc_unchecked(&rdma_stat_rq_prod);
94662
94663 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
94664 /*
94665 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
94666 return;
94667
94668 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
94669 - atomic_inc(&rdma_stat_sq_poll);
94670 + atomic_inc_unchecked(&rdma_stat_sq_poll);
94671 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
94672 if (wc.status != IB_WC_SUCCESS)
94673 /* Close the transport */
94674 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
94675 }
94676
94677 if (ctxt)
94678 - atomic_inc(&rdma_stat_sq_prod);
94679 + atomic_inc_unchecked(&rdma_stat_sq_prod);
94680 }
94681
94682 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
94683 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
94684 spin_lock_bh(&xprt->sc_lock);
94685 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
94686 spin_unlock_bh(&xprt->sc_lock);
94687 - atomic_inc(&rdma_stat_sq_starve);
94688 + atomic_inc_unchecked(&rdma_stat_sq_starve);
94689
94690 /* See if we can opportunistically reap SQ WR to make room */
94691 sq_cq_reap(xprt);
94692 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
94693 index 9bc6db0..47ac8c0 100644
94694 --- a/net/sysctl_net.c
94695 +++ b/net/sysctl_net.c
94696 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
94697 kgid_t root_gid = make_kgid(net->user_ns, 0);
94698
94699 /* Allow network administrator to have same access as root. */
94700 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
94701 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
94702 uid_eq(root_uid, current_uid())) {
94703 int mode = (table->mode >> 6) & 7;
94704 return (mode << 6) | (mode << 3) | mode;
94705 diff --git a/net/tipc/link.c b/net/tipc/link.c
94706 index a80feee..2bbbe70 100644
94707 --- a/net/tipc/link.c
94708 +++ b/net/tipc/link.c
94709 @@ -1201,7 +1201,7 @@ static int link_send_sections_long(struct tipc_port *sender,
94710 struct tipc_msg fragm_hdr;
94711 struct sk_buff *buf, *buf_chain, *prev;
94712 u32 fragm_crs, fragm_rest, hsz, sect_rest;
94713 - const unchar *sect_crs;
94714 + const unchar __user *sect_crs;
94715 int curr_sect;
94716 u32 fragm_no;
94717
94718 @@ -1242,7 +1242,7 @@ again:
94719
94720 if (!sect_rest) {
94721 sect_rest = msg_sect[++curr_sect].iov_len;
94722 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
94723 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
94724 }
94725
94726 if (sect_rest < fragm_rest)
94727 @@ -1261,7 +1261,7 @@ error:
94728 }
94729 } else
94730 skb_copy_to_linear_data_offset(buf, fragm_crs,
94731 - sect_crs, sz);
94732 + (const void __force_kernel *)sect_crs, sz);
94733 sect_crs += sz;
94734 sect_rest -= sz;
94735 fragm_crs += sz;
94736 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
94737 index f2db8a8..9245aa4 100644
94738 --- a/net/tipc/msg.c
94739 +++ b/net/tipc/msg.c
94740 @@ -98,7 +98,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
94741 msg_sect[cnt].iov_len);
94742 else
94743 skb_copy_to_linear_data_offset(*buf, pos,
94744 - msg_sect[cnt].iov_base,
94745 + (const void __force_kernel *)msg_sect[cnt].iov_base,
94746 msg_sect[cnt].iov_len);
94747 pos += msg_sect[cnt].iov_len;
94748 }
94749 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
94750 index 6b42d47..2ac24d5 100644
94751 --- a/net/tipc/subscr.c
94752 +++ b/net/tipc/subscr.c
94753 @@ -96,7 +96,7 @@ static void subscr_send_event(struct tipc_subscription *sub,
94754 {
94755 struct iovec msg_sect;
94756
94757 - msg_sect.iov_base = (void *)&sub->evt;
94758 + msg_sect.iov_base = (void __force_user *)&sub->evt;
94759 msg_sect.iov_len = sizeof(struct tipc_event);
94760
94761 sub->evt.event = htohl(event, sub->swap);
94762 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
94763 index 826e099..4fa8c93 100644
94764 --- a/net/unix/af_unix.c
94765 +++ b/net/unix/af_unix.c
94766 @@ -783,6 +783,12 @@ static struct sock *unix_find_other(struct net *net,
94767 err = -ECONNREFUSED;
94768 if (!S_ISSOCK(inode->i_mode))
94769 goto put_fail;
94770 +
94771 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
94772 + err = -EACCES;
94773 + goto put_fail;
94774 + }
94775 +
94776 u = unix_find_socket_byinode(inode);
94777 if (!u)
94778 goto put_fail;
94779 @@ -803,6 +809,13 @@ static struct sock *unix_find_other(struct net *net,
94780 if (u) {
94781 struct dentry *dentry;
94782 dentry = unix_sk(u)->path.dentry;
94783 +
94784 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
94785 + err = -EPERM;
94786 + sock_put(u);
94787 + goto fail;
94788 + }
94789 +
94790 if (dentry)
94791 touch_atime(&unix_sk(u)->path);
94792 } else
94793 @@ -836,12 +849,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
94794 */
94795 err = security_path_mknod(&path, dentry, mode, 0);
94796 if (!err) {
94797 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
94798 + err = -EACCES;
94799 + goto out;
94800 + }
94801 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
94802 if (!err) {
94803 res->mnt = mntget(path.mnt);
94804 res->dentry = dget(dentry);
94805 + gr_handle_create(dentry, path.mnt);
94806 }
94807 }
94808 +out:
94809 done_path_create(&path, dentry);
94810 return err;
94811 }
94812 @@ -2324,9 +2343,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
94813 seq_puts(seq, "Num RefCount Protocol Flags Type St "
94814 "Inode Path\n");
94815 else {
94816 - struct sock *s = v;
94817 + struct sock *s = v, *peer;
94818 struct unix_sock *u = unix_sk(s);
94819 unix_state_lock(s);
94820 + peer = unix_peer(s);
94821 + unix_state_unlock(s);
94822 +
94823 + unix_state_double_lock(s, peer);
94824
94825 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
94826 s,
94827 @@ -2353,8 +2376,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
94828 }
94829 for ( ; i < len; i++)
94830 seq_putc(seq, u->addr->name->sun_path[i]);
94831 - }
94832 - unix_state_unlock(s);
94833 + } else if (peer)
94834 + seq_printf(seq, " P%lu", sock_i_ino(peer));
94835 +
94836 + unix_state_double_unlock(s, peer);
94837 seq_putc(seq, '\n');
94838 }
94839
94840 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
94841 index 8800604..0526440 100644
94842 --- a/net/unix/sysctl_net_unix.c
94843 +++ b/net/unix/sysctl_net_unix.c
94844 @@ -28,7 +28,7 @@ static ctl_table unix_table[] = {
94845
94846 int __net_init unix_sysctl_register(struct net *net)
94847 {
94848 - struct ctl_table *table;
94849 + ctl_table_no_const *table;
94850
94851 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
94852 if (table == NULL)
94853 diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c
94854 index 3f77f42..662d89b 100644
94855 --- a/net/vmw_vsock/af_vsock.c
94856 +++ b/net/vmw_vsock/af_vsock.c
94857 @@ -335,7 +335,7 @@ void vsock_for_each_connected_socket(void (*fn)(struct sock *sk))
94858 for (i = 0; i < ARRAY_SIZE(vsock_connected_table); i++) {
94859 struct vsock_sock *vsk;
94860 list_for_each_entry(vsk, &vsock_connected_table[i],
94861 - connected_table);
94862 + connected_table)
94863 fn(sk_vsock(vsk));
94864 }
94865
94866 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
94867 index c8717c1..08539f5 100644
94868 --- a/net/wireless/wext-core.c
94869 +++ b/net/wireless/wext-core.c
94870 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
94871 */
94872
94873 /* Support for very large requests */
94874 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
94875 - (user_length > descr->max_tokens)) {
94876 + if (user_length > descr->max_tokens) {
94877 /* Allow userspace to GET more than max so
94878 * we can support any size GET requests.
94879 * There is still a limit : -ENOMEM.
94880 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
94881 }
94882 }
94883
94884 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
94885 - /*
94886 - * If this is a GET, but not NOMAX, it means that the extra
94887 - * data is not bounded by userspace, but by max_tokens. Thus
94888 - * set the length to max_tokens. This matches the extra data
94889 - * allocation.
94890 - * The driver should fill it with the number of tokens it
94891 - * provided, and it may check iwp->length rather than having
94892 - * knowledge of max_tokens. If the driver doesn't change the
94893 - * iwp->length, this ioctl just copies back max_token tokens
94894 - * filled with zeroes. Hopefully the driver isn't claiming
94895 - * them to be valid data.
94896 - */
94897 - iwp->length = descr->max_tokens;
94898 - }
94899 -
94900 err = handler(dev, info, (union iwreq_data *) iwp, extra);
94901
94902 iwp->length += essid_compat;
94903 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
94904 index ea970b8..c68edb9f 100644
94905 --- a/net/xfrm/xfrm_policy.c
94906 +++ b/net/xfrm/xfrm_policy.c
94907 @@ -334,7 +334,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
94908 {
94909 policy->walk.dead = 1;
94910
94911 - atomic_inc(&policy->genid);
94912 + atomic_inc_unchecked(&policy->genid);
94913
94914 del_timer(&policy->polq.hold_timer);
94915 xfrm_queue_purge(&policy->polq.hold_queue);
94916 @@ -659,7 +659,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
94917 hlist_add_head(&policy->bydst, chain);
94918 xfrm_pol_hold(policy);
94919 net->xfrm.policy_count[dir]++;
94920 - atomic_inc(&flow_cache_genid);
94921 + atomic_inc_unchecked(&flow_cache_genid);
94922 rt_genid_bump(net);
94923 if (delpol) {
94924 xfrm_policy_requeue(delpol, policy);
94925 @@ -1629,7 +1629,7 @@ free_dst:
94926 goto out;
94927 }
94928
94929 -static int inline
94930 +static inline int
94931 xfrm_dst_alloc_copy(void **target, const void *src, int size)
94932 {
94933 if (!*target) {
94934 @@ -1641,7 +1641,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
94935 return 0;
94936 }
94937
94938 -static int inline
94939 +static inline int
94940 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
94941 {
94942 #ifdef CONFIG_XFRM_SUB_POLICY
94943 @@ -1653,7 +1653,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
94944 #endif
94945 }
94946
94947 -static int inline
94948 +static inline int
94949 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
94950 {
94951 #ifdef CONFIG_XFRM_SUB_POLICY
94952 @@ -1747,7 +1747,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
94953
94954 xdst->num_pols = num_pols;
94955 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
94956 - xdst->policy_genid = atomic_read(&pols[0]->genid);
94957 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
94958
94959 return xdst;
94960 }
94961 @@ -2618,7 +2618,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
94962 if (xdst->xfrm_genid != dst->xfrm->genid)
94963 return 0;
94964 if (xdst->num_pols > 0 &&
94965 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
94966 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
94967 return 0;
94968
94969 mtu = dst_mtu(dst->child);
94970 @@ -2706,8 +2706,11 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
94971 dst_ops->link_failure = xfrm_link_failure;
94972 if (likely(dst_ops->neigh_lookup == NULL))
94973 dst_ops->neigh_lookup = xfrm_neigh_lookup;
94974 - if (likely(afinfo->garbage_collect == NULL))
94975 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
94976 + if (likely(afinfo->garbage_collect == NULL)) {
94977 + pax_open_kernel();
94978 + *(void **)&afinfo->garbage_collect = xfrm_garbage_collect_deferred;
94979 + pax_close_kernel();
94980 + }
94981 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
94982 }
94983 spin_unlock(&xfrm_policy_afinfo_lock);
94984 @@ -2761,7 +2764,9 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
94985 dst_ops->check = NULL;
94986 dst_ops->negative_advice = NULL;
94987 dst_ops->link_failure = NULL;
94988 - afinfo->garbage_collect = NULL;
94989 + pax_open_kernel();
94990 + *(void **)&afinfo->garbage_collect = NULL;
94991 + pax_close_kernel();
94992 }
94993 return err;
94994 }
94995 @@ -3144,7 +3149,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
94996 sizeof(pol->xfrm_vec[i].saddr));
94997 pol->xfrm_vec[i].encap_family = mp->new_family;
94998 /* flush bundles */
94999 - atomic_inc(&pol->genid);
95000 + atomic_inc_unchecked(&pol->genid);
95001 }
95002 }
95003
95004 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
95005 index 78f66fa..9286768 100644
95006 --- a/net/xfrm/xfrm_state.c
95007 +++ b/net/xfrm/xfrm_state.c
95008 @@ -177,12 +177,14 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
95009
95010 if (unlikely(afinfo == NULL))
95011 return -EAFNOSUPPORT;
95012 - typemap = afinfo->type_map;
95013 + typemap = (const struct xfrm_type **)afinfo->type_map;
95014 spin_lock_bh(&xfrm_type_lock);
95015
95016 - if (likely(typemap[type->proto] == NULL))
95017 + if (likely(typemap[type->proto] == NULL)) {
95018 + pax_open_kernel();
95019 typemap[type->proto] = type;
95020 - else
95021 + pax_close_kernel();
95022 + } else
95023 err = -EEXIST;
95024 spin_unlock_bh(&xfrm_type_lock);
95025 xfrm_state_put_afinfo(afinfo);
95026 @@ -198,13 +200,16 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
95027
95028 if (unlikely(afinfo == NULL))
95029 return -EAFNOSUPPORT;
95030 - typemap = afinfo->type_map;
95031 + typemap = (const struct xfrm_type **)afinfo->type_map;
95032 spin_lock_bh(&xfrm_type_lock);
95033
95034 if (unlikely(typemap[type->proto] != type))
95035 err = -ENOENT;
95036 - else
95037 + else {
95038 + pax_open_kernel();
95039 typemap[type->proto] = NULL;
95040 + pax_close_kernel();
95041 + }
95042 spin_unlock_bh(&xfrm_type_lock);
95043 xfrm_state_put_afinfo(afinfo);
95044 return err;
95045 @@ -214,7 +219,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
95046 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
95047 {
95048 struct xfrm_state_afinfo *afinfo;
95049 - const struct xfrm_type **typemap;
95050 const struct xfrm_type *type;
95051 int modload_attempted = 0;
95052
95053 @@ -222,9 +226,8 @@ retry:
95054 afinfo = xfrm_state_get_afinfo(family);
95055 if (unlikely(afinfo == NULL))
95056 return NULL;
95057 - typemap = afinfo->type_map;
95058
95059 - type = typemap[proto];
95060 + type = afinfo->type_map[proto];
95061 if (unlikely(type && !try_module_get(type->owner)))
95062 type = NULL;
95063 if (!type && !modload_attempted) {
95064 @@ -258,7 +261,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
95065 return -EAFNOSUPPORT;
95066
95067 err = -EEXIST;
95068 - modemap = afinfo->mode_map;
95069 + modemap = (struct xfrm_mode **)afinfo->mode_map;
95070 spin_lock_bh(&xfrm_mode_lock);
95071 if (modemap[mode->encap])
95072 goto out;
95073 @@ -267,8 +270,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
95074 if (!try_module_get(afinfo->owner))
95075 goto out;
95076
95077 - mode->afinfo = afinfo;
95078 + pax_open_kernel();
95079 + *(const void **)&mode->afinfo = afinfo;
95080 modemap[mode->encap] = mode;
95081 + pax_close_kernel();
95082 err = 0;
95083
95084 out:
95085 @@ -292,10 +297,12 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
95086 return -EAFNOSUPPORT;
95087
95088 err = -ENOENT;
95089 - modemap = afinfo->mode_map;
95090 + modemap = (struct xfrm_mode **)afinfo->mode_map;
95091 spin_lock_bh(&xfrm_mode_lock);
95092 if (likely(modemap[mode->encap] == mode)) {
95093 + pax_open_kernel();
95094 modemap[mode->encap] = NULL;
95095 + pax_close_kernel();
95096 module_put(mode->afinfo->owner);
95097 err = 0;
95098 }
95099 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
95100 index 05a6e3d..6716ec9 100644
95101 --- a/net/xfrm/xfrm_sysctl.c
95102 +++ b/net/xfrm/xfrm_sysctl.c
95103 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
95104
95105 int __net_init xfrm_sysctl_init(struct net *net)
95106 {
95107 - struct ctl_table *table;
95108 + ctl_table_no_const *table;
95109
95110 __xfrm_sysctl_init(net);
95111
95112 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
95113 index d5d859c..781cbcb 100644
95114 --- a/scripts/Makefile.build
95115 +++ b/scripts/Makefile.build
95116 @@ -111,7 +111,7 @@ endif
95117 endif
95118
95119 # Do not include host rules unless needed
95120 -ifneq ($(hostprogs-y)$(hostprogs-m),)
95121 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
95122 include scripts/Makefile.host
95123 endif
95124
95125 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
95126 index 686cb0d..9d653bf 100644
95127 --- a/scripts/Makefile.clean
95128 +++ b/scripts/Makefile.clean
95129 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
95130 __clean-files := $(extra-y) $(always) \
95131 $(targets) $(clean-files) \
95132 $(host-progs) \
95133 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
95134 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
95135 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
95136
95137 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
95138
95139 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
95140 index 1ac414f..38575f7 100644
95141 --- a/scripts/Makefile.host
95142 +++ b/scripts/Makefile.host
95143 @@ -31,6 +31,8 @@
95144 # Note: Shared libraries consisting of C++ files are not supported
95145
95146 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
95147 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
95148 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
95149
95150 # C code
95151 # Executables compiled from a single .c file
95152 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
95153 # Shared libaries (only .c supported)
95154 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
95155 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
95156 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
95157 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
95158 # Remove .so files from "xxx-objs"
95159 host-cobjs := $(filter-out %.so,$(host-cobjs))
95160 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
95161
95162 -#Object (.o) files used by the shared libaries
95163 +# Object (.o) files used by the shared libaries
95164 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
95165 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
95166
95167 # output directory for programs/.o files
95168 # hostprogs-y := tools/build may have been specified. Retrieve directory
95169 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
95170 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
95171 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
95172 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
95173 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
95174 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
95175 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
95176 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
95177
95178 obj-dirs += $(host-objdirs)
95179 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
95180 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
95181 $(call if_changed_dep,host-cshobjs)
95182
95183 +# Compile .c file, create position independent .o file
95184 +# host-cxxshobjs -> .o
95185 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
95186 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
95187 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
95188 + $(call if_changed_dep,host-cxxshobjs)
95189 +
95190 # Link a shared library, based on position independent .o files
95191 # *.o -> .so shared library (host-cshlib)
95192 quiet_cmd_host-cshlib = HOSTLLD -shared $@
95193 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
95194 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
95195 $(call if_changed,host-cshlib)
95196
95197 +# Link a shared library, based on position independent .o files
95198 +# *.o -> .so shared library (host-cxxshlib)
95199 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
95200 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
95201 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
95202 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
95203 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
95204 + $(call if_changed,host-cxxshlib)
95205 +
95206 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
95207 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
95208 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
95209
95210 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
95211 index 078fe1d..fbdb363 100644
95212 --- a/scripts/basic/fixdep.c
95213 +++ b/scripts/basic/fixdep.c
95214 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
95215 /*
95216 * Lookup a value in the configuration string.
95217 */
95218 -static int is_defined_config(const char *name, int len, unsigned int hash)
95219 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
95220 {
95221 struct item *aux;
95222
95223 @@ -211,10 +211,10 @@ static void clear_config(void)
95224 /*
95225 * Record the use of a CONFIG_* word.
95226 */
95227 -static void use_config(const char *m, int slen)
95228 +static void use_config(const char *m, unsigned int slen)
95229 {
95230 unsigned int hash = strhash(m, slen);
95231 - int c, i;
95232 + unsigned int c, i;
95233
95234 if (is_defined_config(m, slen, hash))
95235 return;
95236 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
95237
95238 static void parse_config_file(const char *map, size_t len)
95239 {
95240 - const int *end = (const int *) (map + len);
95241 + const unsigned int *end = (const unsigned int *) (map + len);
95242 /* start at +1, so that p can never be < map */
95243 - const int *m = (const int *) map + 1;
95244 + const unsigned int *m = (const unsigned int *) map + 1;
95245 const char *p, *q;
95246
95247 for (; m < end; m++) {
95248 @@ -435,7 +435,7 @@ static void print_deps(void)
95249 static void traps(void)
95250 {
95251 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
95252 - int *p = (int *)test;
95253 + unsigned int *p = (unsigned int *)test;
95254
95255 if (*p != INT_CONF) {
95256 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianness? %#x\n",
95257 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
95258 new file mode 100644
95259 index 0000000..5e0222d
95260 --- /dev/null
95261 +++ b/scripts/gcc-plugin.sh
95262 @@ -0,0 +1,17 @@
95263 +#!/bin/bash
95264 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
95265 +#include "gcc-plugin.h"
95266 +#include "tree.h"
95267 +#include "tm.h"
95268 +#include "rtl.h"
95269 +#ifdef ENABLE_BUILD_WITH_CXX
95270 +#warning $2
95271 +#else
95272 +#warning $1
95273 +#endif
95274 +EOF`
95275 +if [ $? -eq 0 ]
95276 +then
95277 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
95278 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
95279 +fi
95280 diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
95281 index 643764f..6cc0137 100644
95282 --- a/scripts/headers_install.sh
95283 +++ b/scripts/headers_install.sh
95284 @@ -29,6 +29,7 @@ do
95285 FILE="$(basename "$i")"
95286 sed -r \
95287 -e 's/([ \t(])(__user|__force|__iomem)[ \t]/\1/g' \
95288 + -e 's/__intentional_overflow\([- \t,0-9]*\)//g' \
95289 -e 's/__attribute_const__([ \t]|$)/\1/g' \
95290 -e 's@^#include <linux/compiler.h>@@' \
95291 -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
95292 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
95293 index 0149949..d482a0d 100644
95294 --- a/scripts/link-vmlinux.sh
95295 +++ b/scripts/link-vmlinux.sh
95296 @@ -158,7 +158,7 @@ else
95297 fi;
95298
95299 # final build of init/
95300 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
95301 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
95302
95303 kallsymso=""
95304 kallsyms_vmlinux=""
95305 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
95306 index 45f9a33..e4194b3 100644
95307 --- a/scripts/mod/file2alias.c
95308 +++ b/scripts/mod/file2alias.c
95309 @@ -140,7 +140,7 @@ static void device_id_check(const char *modname, const char *device_id,
95310 unsigned long size, unsigned long id_size,
95311 void *symval)
95312 {
95313 - int i;
95314 + unsigned int i;
95315
95316 if (size % id_size || size < id_size) {
95317 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
95318 @@ -168,7 +168,7 @@ static void device_id_check(const char *modname, const char *device_id,
95319 /* USB is special because the bcdDevice can be matched against a numeric range */
95320 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
95321 static void do_usb_entry(void *symval,
95322 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
95323 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
95324 unsigned char range_lo, unsigned char range_hi,
95325 unsigned char max, struct module *mod)
95326 {
95327 @@ -278,7 +278,7 @@ static void do_usb_entry_multi(void *symval, struct module *mod)
95328 {
95329 unsigned int devlo, devhi;
95330 unsigned char chi, clo, max;
95331 - int ndigits;
95332 + unsigned int ndigits;
95333
95334 DEF_FIELD(symval, usb_device_id, match_flags);
95335 DEF_FIELD(symval, usb_device_id, idVendor);
95336 @@ -531,7 +531,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
95337 for (i = 0; i < count; i++) {
95338 DEF_FIELD_ADDR(symval + i*id_size, pnp_device_id, id);
95339 char acpi_id[sizeof(*id)];
95340 - int j;
95341 + unsigned int j;
95342
95343 buf_printf(&mod->dev_table_buf,
95344 "MODULE_ALIAS(\"pnp:d%s*\");\n", *id);
95345 @@ -560,7 +560,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
95346
95347 for (j = 0; j < PNP_MAX_DEVICES; j++) {
95348 const char *id = (char *)(*devs)[j].id;
95349 - int i2, j2;
95350 + unsigned int i2, j2;
95351 int dup = 0;
95352
95353 if (!id[0])
95354 @@ -586,7 +586,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
95355 /* add an individual alias for every device entry */
95356 if (!dup) {
95357 char acpi_id[PNP_ID_LEN];
95358 - int k;
95359 + unsigned int k;
95360
95361 buf_printf(&mod->dev_table_buf,
95362 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
95363 @@ -938,7 +938,7 @@ static void dmi_ascii_filter(char *d, const char *s)
95364 static int do_dmi_entry(const char *filename, void *symval,
95365 char *alias)
95366 {
95367 - int i, j;
95368 + unsigned int i, j;
95369 DEF_FIELD_ADDR(symval, dmi_system_id, matches);
95370 sprintf(alias, "dmi*");
95371
95372 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
95373 index a4be8e1..6e8a5fb 100644
95374 --- a/scripts/mod/modpost.c
95375 +++ b/scripts/mod/modpost.c
95376 @@ -933,6 +933,7 @@ enum mismatch {
95377 ANY_INIT_TO_ANY_EXIT,
95378 ANY_EXIT_TO_ANY_INIT,
95379 EXPORT_TO_INIT_EXIT,
95380 + DATA_TO_TEXT
95381 };
95382
95383 struct sectioncheck {
95384 @@ -1047,6 +1048,12 @@ const struct sectioncheck sectioncheck[] = {
95385 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
95386 .mismatch = EXPORT_TO_INIT_EXIT,
95387 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
95388 +},
95389 +/* Do not reference code from writable data */
95390 +{
95391 + .fromsec = { DATA_SECTIONS, NULL },
95392 + .tosec = { TEXT_SECTIONS, NULL },
95393 + .mismatch = DATA_TO_TEXT
95394 }
95395 };
95396
95397 @@ -1169,10 +1176,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
95398 continue;
95399 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
95400 continue;
95401 - if (sym->st_value == addr)
95402 - return sym;
95403 /* Find a symbol nearby - addr are maybe negative */
95404 d = sym->st_value - addr;
95405 + if (d == 0)
95406 + return sym;
95407 if (d < 0)
95408 d = addr - sym->st_value;
95409 if (d < distance) {
95410 @@ -1451,6 +1458,14 @@ static void report_sec_mismatch(const char *modname,
95411 tosym, prl_to, prl_to, tosym);
95412 free(prl_to);
95413 break;
95414 + case DATA_TO_TEXT:
95415 +#if 0
95416 + fprintf(stderr,
95417 + "The %s %s:%s references\n"
95418 + "the %s %s:%s%s\n",
95419 + from, fromsec, fromsym, to, tosec, tosym, to_p);
95420 +#endif
95421 + break;
95422 }
95423 fprintf(stderr, "\n");
95424 }
95425 @@ -1685,7 +1700,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
95426 static void check_sec_ref(struct module *mod, const char *modname,
95427 struct elf_info *elf)
95428 {
95429 - int i;
95430 + unsigned int i;
95431 Elf_Shdr *sechdrs = elf->sechdrs;
95432
95433 /* Walk through all sections */
95434 @@ -1804,7 +1819,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
95435 va_end(ap);
95436 }
95437
95438 -void buf_write(struct buffer *buf, const char *s, int len)
95439 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
95440 {
95441 if (buf->size - buf->pos < len) {
95442 buf->size += len + SZ;
95443 @@ -2023,7 +2038,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
95444 if (fstat(fileno(file), &st) < 0)
95445 goto close_write;
95446
95447 - if (st.st_size != b->pos)
95448 + if (st.st_size != (off_t)b->pos)
95449 goto close_write;
95450
95451 tmp = NOFAIL(malloc(b->pos));
95452 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
95453 index 51207e4..f7d603d 100644
95454 --- a/scripts/mod/modpost.h
95455 +++ b/scripts/mod/modpost.h
95456 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
95457
95458 struct buffer {
95459 char *p;
95460 - int pos;
95461 - int size;
95462 + unsigned int pos;
95463 + unsigned int size;
95464 };
95465
95466 void __attribute__((format(printf, 2, 3)))
95467 buf_printf(struct buffer *buf, const char *fmt, ...);
95468
95469 void
95470 -buf_write(struct buffer *buf, const char *s, int len);
95471 +buf_write(struct buffer *buf, const char *s, unsigned int len);
95472
95473 struct module {
95474 struct module *next;
95475 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
95476 index 9dfcd6d..099068e 100644
95477 --- a/scripts/mod/sumversion.c
95478 +++ b/scripts/mod/sumversion.c
95479 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
95480 goto out;
95481 }
95482
95483 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
95484 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
95485 warn("writing sum in %s failed: %s\n",
95486 filename, strerror(errno));
95487 goto out;
95488 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
95489 index acb8650..b8c5f02 100644
95490 --- a/scripts/package/builddeb
95491 +++ b/scripts/package/builddeb
95492 @@ -246,6 +246,7 @@ fi
95493 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
95494 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
95495 (cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
95496 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
95497 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
95498 mkdir -p "$destdir"
95499 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
95500 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
95501 index 68bb4ef..2f419e1 100644
95502 --- a/scripts/pnmtologo.c
95503 +++ b/scripts/pnmtologo.c
95504 @@ -244,14 +244,14 @@ static void write_header(void)
95505 fprintf(out, " * Linux logo %s\n", logoname);
95506 fputs(" */\n\n", out);
95507 fputs("#include <linux/linux_logo.h>\n\n", out);
95508 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
95509 + fprintf(out, "static unsigned char %s_data[] = {\n",
95510 logoname);
95511 }
95512
95513 static void write_footer(void)
95514 {
95515 fputs("\n};\n\n", out);
95516 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
95517 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
95518 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
95519 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
95520 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
95521 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
95522 fputs("\n};\n\n", out);
95523
95524 /* write logo clut */
95525 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
95526 + fprintf(out, "static unsigned char %s_clut[] = {\n",
95527 logoname);
95528 write_hex_cnt = 0;
95529 for (i = 0; i < logo_clutsize; i++) {
95530 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
95531 index f5eb43d..1814de8 100644
95532 --- a/scripts/sortextable.h
95533 +++ b/scripts/sortextable.h
95534 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
95535 const char *secstrtab;
95536 const char *strtab;
95537 char *extab_image;
95538 - int extab_index = 0;
95539 - int i;
95540 - int idx;
95541 + unsigned int extab_index = 0;
95542 + unsigned int i;
95543 + unsigned int idx;
95544
95545 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
95546 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
95547 diff --git a/security/Kconfig b/security/Kconfig
95548 index e9c6ac7..3e3f362 100644
95549 --- a/security/Kconfig
95550 +++ b/security/Kconfig
95551 @@ -4,6 +4,959 @@
95552
95553 menu "Security options"
95554
95555 +menu "Grsecurity"
95556 +
95557 + config ARCH_TRACK_EXEC_LIMIT
95558 + bool
95559 +
95560 + config PAX_KERNEXEC_PLUGIN
95561 + bool
95562 +
95563 + config PAX_PER_CPU_PGD
95564 + bool
95565 +
95566 + config TASK_SIZE_MAX_SHIFT
95567 + int
95568 + depends on X86_64
95569 + default 47 if !PAX_PER_CPU_PGD
95570 + default 42 if PAX_PER_CPU_PGD
95571 +
95572 + config PAX_ENABLE_PAE
95573 + bool
95574 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
95575 +
95576 + config PAX_USERCOPY_SLABS
95577 + bool
95578 +
95579 +config GRKERNSEC
95580 + bool "Grsecurity"
95581 + select CRYPTO
95582 + select CRYPTO_SHA256
95583 + select PROC_FS
95584 + select STOP_MACHINE
95585 + select TTY
95586 + help
95587 + If you say Y here, you will be able to configure many features
95588 + that will enhance the security of your system. It is highly
95589 + recommended that you say Y here and read through the help
95590 + for each option so that you fully understand the features and
95591 + can evaluate their usefulness for your machine.
95592 +
95593 +choice
95594 + prompt "Configuration Method"
95595 + depends on GRKERNSEC
95596 + default GRKERNSEC_CONFIG_CUSTOM
95597 + help
95598 +
95599 +config GRKERNSEC_CONFIG_AUTO
95600 + bool "Automatic"
95601 + help
95602 + If you choose this configuration method, you'll be able to answer a small
95603 + number of simple questions about how you plan to use this kernel.
95604 + The settings of grsecurity and PaX will be automatically configured for
95605 + the highest commonly-used settings within the provided constraints.
95606 +
95607 + If you require additional configuration, custom changes can still be made
95608 + from the "custom configuration" menu.
95609 +
95610 +config GRKERNSEC_CONFIG_CUSTOM
95611 + bool "Custom"
95612 + help
95613 + If you choose this configuration method, you'll be able to configure all
95614 + grsecurity and PaX settings manually. Via this method, no options are
95615 + automatically enabled.
95616 +
95617 +endchoice
95618 +
95619 +choice
95620 + prompt "Usage Type"
95621 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
95622 + default GRKERNSEC_CONFIG_SERVER
95623 + help
95624 +
95625 +config GRKERNSEC_CONFIG_SERVER
95626 + bool "Server"
95627 + help
95628 + Choose this option if you plan to use this kernel on a server.
95629 +
95630 +config GRKERNSEC_CONFIG_DESKTOP
95631 + bool "Desktop"
95632 + help
95633 + Choose this option if you plan to use this kernel on a desktop.
95634 +
95635 +endchoice
95636 +
95637 +choice
95638 + prompt "Virtualization Type"
95639 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
95640 + default GRKERNSEC_CONFIG_VIRT_NONE
95641 + help
95642 +
95643 +config GRKERNSEC_CONFIG_VIRT_NONE
95644 + bool "None"
95645 + help
95646 + Choose this option if this kernel will be run on bare metal.
95647 +
95648 +config GRKERNSEC_CONFIG_VIRT_GUEST
95649 + bool "Guest"
95650 + help
95651 + Choose this option if this kernel will be run as a VM guest.
95652 +
95653 +config GRKERNSEC_CONFIG_VIRT_HOST
95654 + bool "Host"
95655 + help
95656 + Choose this option if this kernel will be run as a VM host.
95657 +
95658 +endchoice
95659 +
95660 +choice
95661 + prompt "Virtualization Hardware"
95662 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
95663 + help
95664 +
95665 +config GRKERNSEC_CONFIG_VIRT_EPT
95666 + bool "EPT/RVI Processor Support"
95667 + depends on X86
95668 + help
95669 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
95670 + hardware virtualization. This allows for additional kernel hardening protections
95671 + to operate without additional performance impact.
95672 +
95673 + To see if your Intel processor supports EPT, see:
95674 + http://ark.intel.com/Products/VirtualizationTechnology
95675 + (Most Core i3/5/7 support EPT)
95676 +
95677 + To see if your AMD processor supports RVI, see:
95678 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
95679 +
95680 +config GRKERNSEC_CONFIG_VIRT_SOFT
95681 + bool "First-gen/No Hardware Virtualization"
95682 + help
95683 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
95684 + support hardware virtualization or doesn't support the EPT/RVI extensions.
95685 +
95686 +endchoice
95687 +
95688 +choice
95689 + prompt "Virtualization Software"
95690 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
95691 + help
95692 +
95693 +config GRKERNSEC_CONFIG_VIRT_XEN
95694 + bool "Xen"
95695 + help
95696 + Choose this option if this kernel is running as a Xen guest or host.
95697 +
95698 +config GRKERNSEC_CONFIG_VIRT_VMWARE
95699 + bool "VMWare"
95700 + help
95701 + Choose this option if this kernel is running as a VMWare guest or host.
95702 +
95703 +config GRKERNSEC_CONFIG_VIRT_KVM
95704 + bool "KVM"
95705 + help
95706 + Choose this option if this kernel is running as a KVM guest or host.
95707 +
95708 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
95709 + bool "VirtualBox"
95710 + help
95711 + Choose this option if this kernel is running as a VirtualBox guest or host.
95712 +
95713 +endchoice
95714 +
95715 +choice
95716 + prompt "Required Priorities"
95717 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
95718 + default GRKERNSEC_CONFIG_PRIORITY_PERF
95719 + help
95720 +
95721 +config GRKERNSEC_CONFIG_PRIORITY_PERF
95722 + bool "Performance"
95723 + help
95724 + Choose this option if performance is of highest priority for this deployment
95725 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
95726 + clearing of structures intended for userland, and freed memory sanitizing will
95727 + be disabled.
95728 +
95729 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
95730 + bool "Security"
95731 + help
95732 + Choose this option if security is of highest priority for this deployment of
95733 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
95734 + for userland, and freed memory sanitizing will be enabled for this kernel.
95735 + In a worst-case scenario, these features can introduce a 20% performance hit
95736 + (UDEREF on x64 contributing half of this hit).
95737 +
95738 +endchoice
95739 +
95740 +menu "Default Special Groups"
95741 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
95742 +
95743 +config GRKERNSEC_PROC_GID
95744 + int "GID exempted from /proc restrictions"
95745 + default 1001
95746 + help
95747 + Setting this GID determines which group will be exempted from
95748 + grsecurity's /proc restrictions, allowing users of the specified
95749 + group to view network statistics and the existence of other users'
95750 + processes on the system. This GID may also be chosen at boot time
95751 + via "grsec_proc_gid=" on the kernel commandline.
95752 +
95753 +config GRKERNSEC_TPE_UNTRUSTED_GID
95754 + int "GID for TPE-untrusted users"
95755 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
95756 + default 1005
95757 + help
95758 + Setting this GID determines which group untrusted users should
95759 + be added to. These users will be placed under grsecurity's Trusted Path
95760 + Execution mechanism, preventing them from executing their own binaries.
95761 + The users will only be able to execute binaries in directories owned and
95762 + writable only by the root user. If the sysctl option is enabled, a sysctl
95763 + option with name "tpe_gid" is created.
95764 +
95765 +config GRKERNSEC_TPE_TRUSTED_GID
95766 + int "GID for TPE-trusted users"
95767 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
95768 + default 1005
95769 + help
95770 + Setting this GID determines what group TPE restrictions will be
95771 + *disabled* for. If the sysctl option is enabled, a sysctl option
95772 + with name "tpe_gid" is created.
95773 +
95774 +config GRKERNSEC_SYMLINKOWN_GID
95775 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
95776 + depends on GRKERNSEC_CONFIG_SERVER
95777 + default 1006
95778 + help
95779 + Setting this GID determines what group kernel-enforced
95780 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
95781 + is enabled, a sysctl option with name "symlinkown_gid" is created.
95782 +
95783 +
95784 +endmenu
95785 +
95786 +menu "Customize Configuration"
95787 +depends on GRKERNSEC
95788 +
95789 +menu "PaX"
95790 +
95791 +config PAX
95792 + bool "Enable various PaX features"
95793 + default y if GRKERNSEC_CONFIG_AUTO
95794 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
95795 + help
95796 + This allows you to enable various PaX features. PaX adds
95797 + intrusion prevention mechanisms to the kernel that reduce
95798 + the risks posed by exploitable memory corruption bugs.
95799 +
95800 +menu "PaX Control"
95801 + depends on PAX
95802 +
95803 +config PAX_SOFTMODE
95804 + bool 'Support soft mode'
95805 + help
95806 + Enabling this option will allow you to run PaX in soft mode, that
95807 + is, PaX features will not be enforced by default, only on executables
95808 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
95809 + support as they are the only way to mark executables for soft mode use.
95810 +
95811 + Soft mode can be activated by using the "pax_softmode=1" kernel command
95812 + line option on boot. Furthermore you can control various PaX features
95813 + at runtime via the entries in /proc/sys/kernel/pax.
95814 +
95815 +config PAX_EI_PAX
95816 + bool 'Use legacy ELF header marking'
95817 + default y if GRKERNSEC_CONFIG_AUTO
95818 + help
95819 + Enabling this option will allow you to control PaX features on
95820 + a per executable basis via the 'chpax' utility available at
95821 + http://pax.grsecurity.net/. The control flags will be read from
95822 + an otherwise reserved part of the ELF header. This marking has
95823 + numerous drawbacks (no support for soft-mode, toolchain does not
95824 + know about the non-standard use of the ELF header) therefore it
95825 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
95826 + support.
95827 +
95828 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
95829 + support as well, they will override the legacy EI_PAX marks.
95830 +
95831 + If you enable none of the marking options then all applications
95832 + will run with PaX enabled on them by default.
95833 +
95834 +config PAX_PT_PAX_FLAGS
95835 + bool 'Use ELF program header marking'
95836 + default y if GRKERNSEC_CONFIG_AUTO
95837 + help
95838 + Enabling this option will allow you to control PaX features on
95839 + a per executable basis via the 'paxctl' utility available at
95840 + http://pax.grsecurity.net/. The control flags will be read from
95841 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
95842 + has the benefits of supporting both soft mode and being fully
95843 + integrated into the toolchain (the binutils patch is available
95844 + from http://pax.grsecurity.net).
95845 +
95846 + Note that if you enable the legacy EI_PAX marking support as well,
95847 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
95848 +
95849 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
95850 + must make sure that the marks are the same if a binary has both marks.
95851 +
95852 + If you enable none of the marking options then all applications
95853 + will run with PaX enabled on them by default.
95854 +
95855 +config PAX_XATTR_PAX_FLAGS
95856 + bool 'Use filesystem extended attributes marking'
95857 + default y if GRKERNSEC_CONFIG_AUTO
95858 + select CIFS_XATTR if CIFS
95859 + select EXT2_FS_XATTR if EXT2_FS
95860 + select EXT3_FS_XATTR if EXT3_FS
95861 + select EXT4_FS_XATTR if EXT4_FS
95862 + select JFFS2_FS_XATTR if JFFS2_FS
95863 + select REISERFS_FS_XATTR if REISERFS_FS
95864 + select SQUASHFS_XATTR if SQUASHFS
95865 + select TMPFS_XATTR if TMPFS
95866 + select UBIFS_FS_XATTR if UBIFS_FS
95867 + help
95868 + Enabling this option will allow you to control PaX features on
95869 + a per executable basis via the 'setfattr' utility. The control
95870 + flags will be read from the user.pax.flags extended attribute of
95871 + the file. This marking has the benefit of supporting binary-only
95872 + applications that self-check themselves (e.g., skype) and would
95873 + not tolerate chpax/paxctl changes. The main drawback is that
95874 + extended attributes are not supported by some filesystems (e.g.,
95875 + isofs, udf, vfat) so copying files through such filesystems will
95876 + lose the extended attributes and these PaX markings.
95877 +
95878 + Note that if you enable the legacy EI_PAX marking support as well,
95879 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
95880 +
95881 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
95882 + must make sure that the marks are the same if a binary has both marks.
95883 +
95884 + If you enable none of the marking options then all applications
95885 + will run with PaX enabled on them by default.
95886 +
95887 +choice
95888 + prompt 'MAC system integration'
95889 + default PAX_HAVE_ACL_FLAGS
95890 + help
95891 + Mandatory Access Control systems have the option of controlling
95892 + PaX flags on a per executable basis, choose the method supported
95893 + by your particular system.
95894 +
95895 + - "none": if your MAC system does not interact with PaX,
95896 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
95897 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
95898 +
95899 + NOTE: this option is for developers/integrators only.
95900 +
95901 + config PAX_NO_ACL_FLAGS
95902 + bool 'none'
95903 +
95904 + config PAX_HAVE_ACL_FLAGS
95905 + bool 'direct'
95906 +
95907 + config PAX_HOOK_ACL_FLAGS
95908 + bool 'hook'
95909 +endchoice
95910 +
95911 +endmenu
95912 +
95913 +menu "Non-executable pages"
95914 + depends on PAX
95915 +
95916 +config PAX_NOEXEC
95917 + bool "Enforce non-executable pages"
95918 + default y if GRKERNSEC_CONFIG_AUTO
95919 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
95920 + help
95921 + By design some architectures do not allow for protecting memory
95922 + pages against execution or even if they do, Linux does not make
95923 + use of this feature. In practice this means that if a page is
95924 + readable (such as the stack or heap) it is also executable.
95925 +
95926 + There is a well known exploit technique that makes use of this
95927 + fact and a common programming mistake where an attacker can
95928 + introduce code of his choice somewhere in the attacked program's
95929 + memory (typically the stack or the heap) and then execute it.
95930 +
95931 + If the attacked program was running with different (typically
95932 + higher) privileges than that of the attacker, then he can elevate
95933 + his own privilege level (e.g. get a root shell, write to files for
95934 + which he does not have write access to, etc).
95935 +
95936 + Enabling this option will let you choose from various features
95937 + that prevent the injection and execution of 'foreign' code in
95938 + a program.
95939 +
95940 + This will also break programs that rely on the old behaviour and
95941 + expect that dynamically allocated memory via the malloc() family
95942 + of functions is executable (which it is not). Notable examples
95943 + are the XFree86 4.x server, the java runtime and wine.
95944 +
95945 +config PAX_PAGEEXEC
95946 + bool "Paging based non-executable pages"
95947 + default y if GRKERNSEC_CONFIG_AUTO
95948 + 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)
95949 + select ARCH_TRACK_EXEC_LIMIT if X86_32
95950 + help
95951 + This implementation is based on the paging feature of the CPU.
95952 + On i386 without hardware non-executable bit support there is a
95953 + variable but usually low performance impact, however on Intel's
95954 + P4 core based CPUs it is very high so you should not enable this
95955 + for kernels meant to be used on such CPUs.
95956 +
95957 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
95958 + with hardware non-executable bit support there is no performance
95959 + impact, on ppc the impact is negligible.
95960 +
95961 + Note that several architectures require various emulations due to
95962 + badly designed userland ABIs, this will cause a performance impact
95963 + but will disappear as soon as userland is fixed. For example, ppc
95964 + userland MUST have been built with secure-plt by a recent toolchain.
95965 +
95966 +config PAX_SEGMEXEC
95967 + bool "Segmentation based non-executable pages"
95968 + default y if GRKERNSEC_CONFIG_AUTO
95969 + depends on PAX_NOEXEC && X86_32
95970 + help
95971 + This implementation is based on the segmentation feature of the
95972 + CPU and has a very small performance impact, however applications
95973 + will be limited to a 1.5 GB address space instead of the normal
95974 + 3 GB.
95975 +
95976 +config PAX_EMUTRAMP
95977 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
95978 + default y if PARISC
95979 + help
95980 + There are some programs and libraries that for one reason or
95981 + another attempt to execute special small code snippets from
95982 + non-executable memory pages. Most notable examples are the
95983 + signal handler return code generated by the kernel itself and
95984 + the GCC trampolines.
95985 +
95986 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
95987 + such programs will no longer work under your kernel.
95988 +
95989 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
95990 + utilities to enable trampoline emulation for the affected programs
95991 + yet still have the protection provided by the non-executable pages.
95992 +
95993 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
95994 + your system will not even boot.
95995 +
95996 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
95997 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
95998 + for the affected files.
95999 +
96000 + NOTE: enabling this feature *may* open up a loophole in the
96001 + protection provided by non-executable pages that an attacker
96002 + could abuse. Therefore the best solution is to not have any
96003 + files on your system that would require this option. This can
96004 + be achieved by not using libc5 (which relies on the kernel
96005 + signal handler return code) and not using or rewriting programs
96006 + that make use of the nested function implementation of GCC.
96007 + Skilled users can just fix GCC itself so that it implements
96008 + nested function calls in a way that does not interfere with PaX.
96009 +
96010 +config PAX_EMUSIGRT
96011 + bool "Automatically emulate sigreturn trampolines"
96012 + depends on PAX_EMUTRAMP && PARISC
96013 + default y
96014 + help
96015 + Enabling this option will have the kernel automatically detect
96016 + and emulate signal return trampolines executing on the stack
96017 + that would otherwise lead to task termination.
96018 +
96019 + This solution is intended as a temporary one for users with
96020 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
96021 + Modula-3 runtime, etc) or executables linked to such, basically
96022 + everything that does not specify its own SA_RESTORER function in
96023 + normal executable memory like glibc 2.1+ does.
96024 +
96025 + On parisc you MUST enable this option, otherwise your system will
96026 + not even boot.
96027 +
96028 + NOTE: this feature cannot be disabled on a per executable basis
96029 + and since it *does* open up a loophole in the protection provided
96030 + by non-executable pages, the best solution is to not have any
96031 + files on your system that would require this option.
96032 +
96033 +config PAX_MPROTECT
96034 + bool "Restrict mprotect()"
96035 + default y if GRKERNSEC_CONFIG_AUTO
96036 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
96037 + help
96038 + Enabling this option will prevent programs from
96039 + - changing the executable status of memory pages that were
96040 + not originally created as executable,
96041 + - making read-only executable pages writable again,
96042 + - creating executable pages from anonymous memory,
96043 + - making read-only-after-relocations (RELRO) data pages writable again.
96044 +
96045 + You should say Y here to complete the protection provided by
96046 + the enforcement of non-executable pages.
96047 +
96048 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
96049 + this feature on a per file basis.
96050 +
96051 +config PAX_MPROTECT_COMPAT
96052 + bool "Use legacy/compat protection demoting (read help)"
96053 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
96054 + depends on PAX_MPROTECT
96055 + help
96056 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
96057 + by sending the proper error code to the application. For some broken
96058 + userland, this can cause problems with Python or other applications. The
96059 + current implementation however allows for applications like clamav to
96060 + detect if JIT compilation/execution is allowed and to fall back gracefully
96061 + to an interpreter-based mode if it does not. While we encourage everyone
96062 + to use the current implementation as-is and push upstream to fix broken
96063 + userland (note that the RWX logging option can assist with this), in some
96064 + environments this may not be possible. Having to disable MPROTECT
96065 + completely on certain binaries reduces the security benefit of PaX,
96066 + so this option is provided for those environments to revert to the old
96067 + behavior.
96068 +
96069 +config PAX_ELFRELOCS
96070 + bool "Allow ELF text relocations (read help)"
96071 + depends on PAX_MPROTECT
96072 + default n
96073 + help
96074 + Non-executable pages and mprotect() restrictions are effective
96075 + in preventing the introduction of new executable code into an
96076 + attacked task's address space. There remain only two venues
96077 + for this kind of attack: if the attacker can execute already
96078 + existing code in the attacked task then he can either have it
96079 + create and mmap() a file containing his code or have it mmap()
96080 + an already existing ELF library that does not have position
96081 + independent code in it and use mprotect() on it to make it
96082 + writable and copy his code there. While protecting against
96083 + the former approach is beyond PaX, the latter can be prevented
96084 + by having only PIC ELF libraries on one's system (which do not
96085 + need to relocate their code). If you are sure this is your case,
96086 + as is the case with all modern Linux distributions, then leave
96087 + this option disabled. You should say 'n' here.
96088 +
96089 +config PAX_ETEXECRELOCS
96090 + bool "Allow ELF ET_EXEC text relocations"
96091 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
96092 + select PAX_ELFRELOCS
96093 + default y
96094 + help
96095 + On some architectures there are incorrectly created applications
96096 + that require text relocations and would not work without enabling
96097 + this option. If you are an alpha, ia64 or parisc user, you should
96098 + enable this option and disable it once you have made sure that
96099 + none of your applications need it.
96100 +
96101 +config PAX_EMUPLT
96102 + bool "Automatically emulate ELF PLT"
96103 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
96104 + default y
96105 + help
96106 + Enabling this option will have the kernel automatically detect
96107 + and emulate the Procedure Linkage Table entries in ELF files.
96108 + On some architectures such entries are in writable memory, and
96109 + become non-executable leading to task termination. Therefore
96110 + it is mandatory that you enable this option on alpha, parisc,
96111 + sparc and sparc64, otherwise your system would not even boot.
96112 +
96113 + NOTE: this feature *does* open up a loophole in the protection
96114 + provided by the non-executable pages, therefore the proper
96115 + solution is to modify the toolchain to produce a PLT that does
96116 + not need to be writable.
96117 +
96118 +config PAX_DLRESOLVE
96119 + bool 'Emulate old glibc resolver stub'
96120 + depends on PAX_EMUPLT && SPARC
96121 + default n
96122 + help
96123 + This option is needed if userland has an old glibc (before 2.4)
96124 + that puts a 'save' instruction into the runtime generated resolver
96125 + stub that needs special emulation.
96126 +
96127 +config PAX_KERNEXEC
96128 + bool "Enforce non-executable kernel pages"
96129 + 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))
96130 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
96131 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
96132 + select PAX_KERNEXEC_PLUGIN if X86_64
96133 + help
96134 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
96135 + that is, enabling this option will make it harder to inject
96136 + and execute 'foreign' code in kernel memory itself.
96137 +
96138 +choice
96139 + prompt "Return Address Instrumentation Method"
96140 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
96141 + depends on PAX_KERNEXEC_PLUGIN
96142 + help
96143 + Select the method used to instrument function pointer dereferences.
96144 + Note that binary modules cannot be instrumented by this approach.
96145 +
96146 + Note that the implementation requires a gcc with plugin support,
96147 + i.e., gcc 4.5 or newer. You may need to install the supporting
96148 + headers explicitly in addition to the normal gcc package.
96149 +
96150 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
96151 + bool "bts"
96152 + help
96153 + This method is compatible with binary only modules but has
96154 + a higher runtime overhead.
96155 +
96156 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
96157 + bool "or"
96158 + depends on !PARAVIRT
96159 + help
96160 + This method is incompatible with binary only modules but has
96161 + a lower runtime overhead.
96162 +endchoice
96163 +
96164 +config PAX_KERNEXEC_PLUGIN_METHOD
96165 + string
96166 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
96167 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
96168 + default ""
96169 +
96170 +config PAX_KERNEXEC_MODULE_TEXT
96171 + int "Minimum amount of memory reserved for module code"
96172 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
96173 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
96174 + depends on PAX_KERNEXEC && X86_32
96175 + help
96176 + Due to implementation details the kernel must reserve a fixed
96177 + amount of memory for runtime allocated code (such as modules)
96178 + at compile time that cannot be changed at runtime. Here you
96179 + can specify the minimum amount in MB that will be reserved.
96180 + Due to the same implementation details this size will always
96181 + be rounded up to the next 2/4 MB boundary (depends on PAE) so
96182 + the actually available memory for runtime allocated code will
96183 + usually be more than this minimum.
96184 +
96185 + The default 4 MB should be enough for most users but if you have
96186 + an excessive number of modules (e.g., most distribution configs
96187 + compile many drivers as modules) or use huge modules such as
96188 + nvidia's kernel driver, you will need to adjust this amount.
96189 + A good rule of thumb is to look at your currently loaded kernel
96190 + modules and add up their sizes.
96191 +
96192 +endmenu
96193 +
96194 +menu "Address Space Layout Randomization"
96195 + depends on PAX
96196 +
96197 +config PAX_ASLR
96198 + bool "Address Space Layout Randomization"
96199 + default y if GRKERNSEC_CONFIG_AUTO
96200 + help
96201 + Many if not most exploit techniques rely on the knowledge of
96202 + certain addresses in the attacked program. The following options
96203 + will allow the kernel to apply a certain amount of randomization
96204 + to specific parts of the program thereby forcing an attacker to
96205 + guess them in most cases. Any failed guess will most likely crash
96206 + the attacked program which allows the kernel to detect such attempts
96207 + and react on them. PaX itself provides no reaction mechanisms,
96208 + instead it is strongly encouraged that you make use of Nergal's
96209 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
96210 + (http://www.grsecurity.net/) built-in crash detection features or
96211 + develop one yourself.
96212 +
96213 + By saying Y here you can choose to randomize the following areas:
96214 + - top of the task's kernel stack
96215 + - top of the task's userland stack
96216 + - base address for mmap() requests that do not specify one
96217 + (this includes all libraries)
96218 + - base address of the main executable
96219 +
96220 + It is strongly recommended to say Y here as address space layout
96221 + randomization has negligible impact on performance yet it provides
96222 + a very effective protection.
96223 +
96224 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
96225 + this feature on a per file basis.
96226 +
96227 +config PAX_RANDKSTACK
96228 + bool "Randomize kernel stack base"
96229 + default y if GRKERNSEC_CONFIG_AUTO && !(GRKERNSEC_CONFIG_VIRT_HOST && GRKERNSEC_CONFIG_VIRT_VIRTUALBOX)
96230 + depends on X86_TSC && X86
96231 + help
96232 + By saying Y here the kernel will randomize every task's kernel
96233 + stack on every system call. This will not only force an attacker
96234 + to guess it but also prevent him from making use of possible
96235 + leaked information about it.
96236 +
96237 + Since the kernel stack is a rather scarce resource, randomization
96238 + may cause unexpected stack overflows, therefore you should very
96239 + carefully test your system. Note that once enabled in the kernel
96240 + configuration, this feature cannot be disabled on a per file basis.
96241 +
96242 +config PAX_RANDUSTACK
96243 + bool "Randomize user stack base"
96244 + default y if GRKERNSEC_CONFIG_AUTO
96245 + depends on PAX_ASLR
96246 + help
96247 + By saying Y here the kernel will randomize every task's userland
96248 + stack. The randomization is done in two steps where the second
96249 + one may apply a big amount of shift to the top of the stack and
96250 + cause problems for programs that want to use lots of memory (more
96251 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
96252 + For this reason the second step can be controlled by 'chpax' or
96253 + 'paxctl' on a per file basis.
96254 +
96255 +config PAX_RANDMMAP
96256 + bool "Randomize mmap() base"
96257 + default y if GRKERNSEC_CONFIG_AUTO
96258 + depends on PAX_ASLR
96259 + help
96260 + By saying Y here the kernel will use a randomized base address for
96261 + mmap() requests that do not specify one themselves. As a result
96262 + all dynamically loaded libraries will appear at random addresses
96263 + and therefore be harder to exploit by a technique where an attacker
96264 + attempts to execute library code for his purposes (e.g. spawn a
96265 + shell from an exploited program that is running at an elevated
96266 + privilege level).
96267 +
96268 + Furthermore, if a program is relinked as a dynamic ELF file, its
96269 + base address will be randomized as well, completing the full
96270 + randomization of the address space layout. Attacking such programs
96271 + becomes a guess game. You can find an example of doing this at
96272 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
96273 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
96274 +
96275 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
96276 + feature on a per file basis.
96277 +
96278 +endmenu
96279 +
96280 +menu "Miscellaneous hardening features"
96281 +
96282 +config PAX_MEMORY_SANITIZE
96283 + bool "Sanitize all freed memory"
96284 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
96285 + depends on !HIBERNATION
96286 + help
96287 + By saying Y here the kernel will erase memory pages and slab objects
96288 + as soon as they are freed. This in turn reduces the lifetime of data
96289 + stored in them, making it less likely that sensitive information such
96290 + as passwords, cryptographic secrets, etc stay in memory for too long.
96291 +
96292 + This is especially useful for programs whose runtime is short, long
96293 + lived processes and the kernel itself benefit from this as long as
96294 + they ensure timely freeing of memory that may hold sensitive
96295 + information.
96296 +
96297 + A nice side effect of the sanitization of slab objects is the
96298 + reduction of possible info leaks caused by padding bytes within the
96299 + leaky structures. Use-after-free bugs for structures containing
96300 + pointers can also be detected as dereferencing the sanitized pointer
96301 + will generate an access violation.
96302 +
96303 + The tradeoff is performance impact, on a single CPU system kernel
96304 + compilation sees a 3% slowdown, other systems and workloads may vary
96305 + and you are advised to test this feature on your expected workload
96306 + before deploying it.
96307 +
96308 + To reduce the performance penalty by sanitizing pages only, albeit
96309 + limiting the effectiveness of this feature at the same time, slab
96310 + sanitization can be disabled with the kernel commandline parameter
96311 + "pax_sanitize_slab=0".
96312 +
96313 + Note that this feature does not protect data stored in live pages,
96314 + e.g., process memory swapped to disk may stay there for a long time.
96315 +
96316 +config PAX_MEMORY_STACKLEAK
96317 + bool "Sanitize kernel stack"
96318 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
96319 + depends on X86
96320 + help
96321 + By saying Y here the kernel will erase the kernel stack before it
96322 + returns from a system call. This in turn reduces the information
96323 + that a kernel stack leak bug can reveal.
96324 +
96325 + Note that such a bug can still leak information that was put on
96326 + the stack by the current system call (the one eventually triggering
96327 + the bug) but traces of earlier system calls on the kernel stack
96328 + cannot leak anymore.
96329 +
96330 + The tradeoff is performance impact: on a single CPU system kernel
96331 + compilation sees a 1% slowdown, other systems and workloads may vary
96332 + and you are advised to test this feature on your expected workload
96333 + before deploying it.
96334 +
96335 + Note that the full feature requires a gcc with plugin support,
96336 + i.e., gcc 4.5 or newer. You may need to install the supporting
96337 + headers explicitly in addition to the normal gcc package. Using
96338 + older gcc versions means that functions with large enough stack
96339 + frames may leave uninitialized memory behind that may be exposed
96340 + to a later syscall leaking the stack.
96341 +
96342 +config PAX_MEMORY_STRUCTLEAK
96343 + bool "Forcibly initialize local variables copied to userland"
96344 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
96345 + help
96346 + By saying Y here the kernel will zero initialize some local
96347 + variables that are going to be copied to userland. This in
96348 + turn prevents unintended information leakage from the kernel
96349 + stack should later code forget to explicitly set all parts of
96350 + the copied variable.
96351 +
96352 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
96353 + at a much smaller coverage.
96354 +
96355 + Note that the implementation requires a gcc with plugin support,
96356 + i.e., gcc 4.5 or newer. You may need to install the supporting
96357 + headers explicitly in addition to the normal gcc package.
96358 +
96359 +config PAX_MEMORY_UDEREF
96360 + bool "Prevent invalid userland pointer dereference"
96361 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
96362 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
96363 + select PAX_PER_CPU_PGD if X86_64
96364 + help
96365 + By saying Y here the kernel will be prevented from dereferencing
96366 + userland pointers in contexts where the kernel expects only kernel
96367 + pointers. This is both a useful runtime debugging feature and a
96368 + security measure that prevents exploiting a class of kernel bugs.
96369 +
96370 + The tradeoff is that some virtualization solutions may experience
96371 + a huge slowdown and therefore you should not enable this feature
96372 + for kernels meant to run in such environments. Whether a given VM
96373 + solution is affected or not is best determined by simply trying it
96374 + out, the performance impact will be obvious right on boot as this
96375 + mechanism engages from very early on. A good rule of thumb is that
96376 + VMs running on CPUs without hardware virtualization support (i.e.,
96377 + the majority of IA-32 CPUs) will likely experience the slowdown.
96378 +
96379 + On X86_64 the kernel will make use of PCID support when available
96380 + (Intel's Westmere, Sandy Bridge, etc) for better security (default)
96381 + or performance impact. Pass pax_weakuderef on the kernel command
96382 + line to choose the latter.
96383 +
96384 +config PAX_REFCOUNT
96385 + bool "Prevent various kernel object reference counter overflows"
96386 + default y if GRKERNSEC_CONFIG_AUTO
96387 + depends on GRKERNSEC && ((ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || SPARC64 || X86)
96388 + help
96389 + By saying Y here the kernel will detect and prevent overflowing
96390 + various (but not all) kinds of object reference counters. Such
96391 + overflows can normally occur due to bugs only and are often, if
96392 + not always, exploitable.
96393 +
96394 + The tradeoff is that data structures protected by an overflowed
96395 + refcount will never be freed and therefore will leak memory. Note
96396 + that this leak also happens even without this protection but in
96397 + that case the overflow can eventually trigger the freeing of the
96398 + data structure while it is still being used elsewhere, resulting
96399 + in the exploitable situation that this feature prevents.
96400 +
96401 + Since this has a negligible performance impact, you should enable
96402 + this feature.
96403 +
96404 +config PAX_CONSTIFY_PLUGIN
96405 + bool "Automatically constify eligible structures"
96406 + default y
96407 + depends on !UML && PAX_KERNEXEC
96408 + help
96409 + By saying Y here the compiler will automatically constify a class
96410 + of types that contain only function pointers. This reduces the
96411 + kernel's attack surface and also produces a better memory layout.
96412 +
96413 + Note that the implementation requires a gcc with plugin support,
96414 + i.e., gcc 4.5 or newer. You may need to install the supporting
96415 + headers explicitly in addition to the normal gcc package.
96416 +
96417 + Note that if some code really has to modify constified variables
96418 + then the source code will have to be patched to allow it. Examples
96419 + can be found in PaX itself (the no_const attribute) and for some
96420 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
96421 +
96422 +config PAX_USERCOPY
96423 + bool "Harden heap object copies between kernel and userland"
96424 + default y if GRKERNSEC_CONFIG_AUTO
96425 + depends on ARM || IA64 || PPC || SPARC || X86
96426 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
96427 + select PAX_USERCOPY_SLABS
96428 + help
96429 + By saying Y here the kernel will enforce the size of heap objects
96430 + when they are copied in either direction between the kernel and
96431 + userland, even if only a part of the heap object is copied.
96432 +
96433 + Specifically, this checking prevents information leaking from the
96434 + kernel heap during kernel to userland copies (if the kernel heap
96435 + object is otherwise fully initialized) and prevents kernel heap
96436 + overflows during userland to kernel copies.
96437 +
96438 + Note that the current implementation provides the strictest bounds
96439 + checks for the SLUB allocator.
96440 +
96441 + Enabling this option also enables per-slab cache protection against
96442 + data in a given cache being copied into/out of via userland
96443 + accessors. Though the whitelist of regions will be reduced over
96444 + time, it notably protects important data structures like task structs.
96445 +
96446 + If frame pointers are enabled on x86, this option will also restrict
96447 + copies into and out of the kernel stack to local variables within a
96448 + single frame.
96449 +
96450 + Since this has a negligible performance impact, you should enable
96451 + this feature.
96452 +
96453 +config PAX_USERCOPY_DEBUG
96454 + bool
96455 + depends on X86 && PAX_USERCOPY
96456 + default n
96457 +
96458 +config PAX_SIZE_OVERFLOW
96459 + bool "Prevent various integer overflows in function size parameters"
96460 + default y if GRKERNSEC_CONFIG_AUTO
96461 + depends on X86
96462 + help
96463 + By saying Y here the kernel recomputes expressions of function
96464 + arguments marked by a size_overflow attribute with double integer
96465 + precision (DImode/TImode for 32/64 bit integer types).
96466 +
96467 + The recomputed argument is checked against TYPE_MAX and an event
96468 + is logged on overflow and the triggering process is killed.
96469 +
96470 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
96471 +
96472 + Note that the implementation requires a gcc with plugin support,
96473 + i.e., gcc 4.5 or newer. You may need to install the supporting
96474 + headers explicitly in addition to the normal gcc package.
96475 +
96476 +config PAX_LATENT_ENTROPY
96477 + bool "Generate some entropy during boot"
96478 + default y if GRKERNSEC_CONFIG_AUTO
96479 + help
96480 + By saying Y here the kernel will instrument early boot code to
96481 + extract some entropy from both original and artificially created
96482 + program state. This will help especially embedded systems where
96483 + there is little 'natural' source of entropy normally. The cost
96484 + is some slowdown of the boot process.
96485 +
96486 + When pax_extra_latent_entropy is passed on the kernel command line,
96487 + entropy will be extracted from up to the first 4GB of RAM while the
96488 + runtime memory allocator is being initialized. This costs even more
96489 + slowdown of the boot process.
96490 +
96491 + Note that the implementation requires a gcc with plugin support,
96492 + i.e., gcc 4.5 or newer. You may need to install the supporting
96493 + headers explicitly in addition to the normal gcc package.
96494 +
96495 + Note that entropy extracted this way is not cryptographically
96496 + secure!
96497 +
96498 +endmenu
96499 +
96500 +endmenu
96501 +
96502 +source grsecurity/Kconfig
96503 +
96504 +endmenu
96505 +
96506 +endmenu
96507 +
96508 source security/keys/Kconfig
96509
96510 config SECURITY_DMESG_RESTRICT
96511 @@ -103,7 +1056,7 @@ config INTEL_TXT
96512 config LSM_MMAP_MIN_ADDR
96513 int "Low address space for LSM to protect from user allocation"
96514 depends on SECURITY && SECURITY_SELINUX
96515 - default 32768 if ARM
96516 + default 32768 if ALPHA || ARM || PARISC || SPARC32
96517 default 65536
96518 help
96519 This is the portion of low virtual memory which should be protected
96520 diff --git a/security/apparmor/Kconfig b/security/apparmor/Kconfig
96521 index 9b9013b..51ebf96 100644
96522 --- a/security/apparmor/Kconfig
96523 +++ b/security/apparmor/Kconfig
96524 @@ -29,3 +29,12 @@ config SECURITY_APPARMOR_BOOTPARAM_VALUE
96525 boot.
96526
96527 If you are unsure how to answer this question, answer 1.
96528 +
96529 +config SECURITY_APPARMOR_COMPAT_24
96530 + bool "Enable AppArmor 2.4 compatability"
96531 + depends on SECURITY_APPARMOR
96532 + default y
96533 + help
96534 + This option enables compatability with AppArmor 2.4. It is
96535 + recommended if compatability with older versions of AppArmor
96536 + is desired.
96537 diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
96538 index 16c15ec..42b7c9f 100644
96539 --- a/security/apparmor/apparmorfs.c
96540 +++ b/security/apparmor/apparmorfs.c
96541 @@ -182,6 +182,234 @@ const struct file_operations aa_fs_seq_file_ops = {
96542 .release = single_release,
96543 };
96544
96545 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
96546 +/**
96547 + * __next_namespace - find the next namespace to list
96548 + * @root: root namespace to stop search at (NOT NULL)
96549 + * @ns: current ns position (NOT NULL)
96550 + *
96551 + * Find the next namespace from @ns under @root and handle all locking needed
96552 + * while switching current namespace.
96553 + *
96554 + * Returns: next namespace or NULL if at last namespace under @root
96555 + * NOTE: will not unlock root->lock
96556 + */
96557 +static struct aa_namespace *__next_namespace(struct aa_namespace *root,
96558 + struct aa_namespace *ns)
96559 +{
96560 + struct aa_namespace *parent;
96561 +
96562 + /* is next namespace a child */
96563 + if (!list_empty(&ns->sub_ns)) {
96564 + struct aa_namespace *next;
96565 + next = list_first_entry(&ns->sub_ns, typeof(*ns), base.list);
96566 + read_lock(&next->lock);
96567 + return next;
96568 + }
96569 +
96570 + /* check if the next ns is a sibling, parent, gp, .. */
96571 + parent = ns->parent;
96572 + while (parent) {
96573 + read_unlock(&ns->lock);
96574 + list_for_each_entry_continue(ns, &parent->sub_ns, base.list) {
96575 + read_lock(&ns->lock);
96576 + return ns;
96577 + }
96578 + if (parent == root)
96579 + return NULL;
96580 + ns = parent;
96581 + parent = parent->parent;
96582 + }
96583 +
96584 + return NULL;
96585 +}
96586 +
96587 +/**
96588 + * __first_profile - find the first profile in a namespace
96589 + * @root: namespace that is root of profiles being displayed (NOT NULL)
96590 + * @ns: namespace to start in (NOT NULL)
96591 + *
96592 + * Returns: unrefcounted profile or NULL if no profile
96593 + */
96594 +static struct aa_profile *__first_profile(struct aa_namespace *root,
96595 + struct aa_namespace *ns)
96596 +{
96597 + for ( ; ns; ns = __next_namespace(root, ns)) {
96598 + if (!list_empty(&ns->base.profiles))
96599 + return list_first_entry(&ns->base.profiles,
96600 + struct aa_profile, base.list);
96601 + }
96602 + return NULL;
96603 +}
96604 +
96605 +/**
96606 + * __next_profile - step to the next profile in a profile tree
96607 + * @profile: current profile in tree (NOT NULL)
96608 + *
96609 + * Perform a depth first taversal on the profile tree in a namespace
96610 + *
96611 + * Returns: next profile or NULL if done
96612 + * Requires: profile->ns.lock to be held
96613 + */
96614 +static struct aa_profile *__next_profile(struct aa_profile *p)
96615 +{
96616 + struct aa_profile *parent;
96617 + struct aa_namespace *ns = p->ns;
96618 +
96619 + /* is next profile a child */
96620 + if (!list_empty(&p->base.profiles))
96621 + return list_first_entry(&p->base.profiles, typeof(*p),
96622 + base.list);
96623 +
96624 + /* is next profile a sibling, parent sibling, gp, subling, .. */
96625 + parent = p->parent;
96626 + while (parent) {
96627 + list_for_each_entry_continue(p, &parent->base.profiles,
96628 + base.list)
96629 + return p;
96630 + p = parent;
96631 + parent = parent->parent;
96632 + }
96633 +
96634 + /* is next another profile in the namespace */
96635 + list_for_each_entry_continue(p, &ns->base.profiles, base.list)
96636 + return p;
96637 +
96638 + return NULL;
96639 +}
96640 +
96641 +/**
96642 + * next_profile - step to the next profile in where ever it may be
96643 + * @root: root namespace (NOT NULL)
96644 + * @profile: current profile (NOT NULL)
96645 + *
96646 + * Returns: next profile or NULL if there isn't one
96647 + */
96648 +static struct aa_profile *next_profile(struct aa_namespace *root,
96649 + struct aa_profile *profile)
96650 +{
96651 + struct aa_profile *next = __next_profile(profile);
96652 + if (next)
96653 + return next;
96654 +
96655 + /* finished all profiles in namespace move to next namespace */
96656 + return __first_profile(root, __next_namespace(root, profile->ns));
96657 +}
96658 +
96659 +/**
96660 + * p_start - start a depth first traversal of profile tree
96661 + * @f: seq_file to fill
96662 + * @pos: current position
96663 + *
96664 + * Returns: first profile under current namespace or NULL if none found
96665 + *
96666 + * acquires first ns->lock
96667 + */
96668 +static void *p_start(struct seq_file *f, loff_t *pos)
96669 + __acquires(root->lock)
96670 +{
96671 + struct aa_profile *profile = NULL;
96672 + struct aa_namespace *root = aa_current_profile()->ns;
96673 + loff_t l = *pos;
96674 + f->private = aa_get_namespace(root);
96675 +
96676 +
96677 + /* find the first profile */
96678 + read_lock(&root->lock);
96679 + profile = __first_profile(root, root);
96680 +
96681 + /* skip to position */
96682 + for (; profile && l > 0; l--)
96683 + profile = next_profile(root, profile);
96684 +
96685 + return profile;
96686 +}
96687 +
96688 +/**
96689 + * p_next - read the next profile entry
96690 + * @f: seq_file to fill
96691 + * @p: profile previously returned
96692 + * @pos: current position
96693 + *
96694 + * Returns: next profile after @p or NULL if none
96695 + *
96696 + * may acquire/release locks in namespace tree as necessary
96697 + */
96698 +static void *p_next(struct seq_file *f, void *p, loff_t *pos)
96699 +{
96700 + struct aa_profile *profile = p;
96701 + struct aa_namespace *root = f->private;
96702 + (*pos)++;
96703 +
96704 + return next_profile(root, profile);
96705 +}
96706 +
96707 +/**
96708 + * p_stop - stop depth first traversal
96709 + * @f: seq_file we are filling
96710 + * @p: the last profile writen
96711 + *
96712 + * Release all locking done by p_start/p_next on namespace tree
96713 + */
96714 +static void p_stop(struct seq_file *f, void *p)
96715 + __releases(root->lock)
96716 +{
96717 + struct aa_profile *profile = p;
96718 + struct aa_namespace *root = f->private, *ns;
96719 +
96720 + if (profile) {
96721 + for (ns = profile->ns; ns && ns != root; ns = ns->parent)
96722 + read_unlock(&ns->lock);
96723 + }
96724 + read_unlock(&root->lock);
96725 + aa_put_namespace(root);
96726 +}
96727 +
96728 +/**
96729 + * seq_show_profile - show a profile entry
96730 + * @f: seq_file to file
96731 + * @p: current position (profile) (NOT NULL)
96732 + *
96733 + * Returns: error on failure
96734 + */
96735 +static int seq_show_profile(struct seq_file *f, void *p)
96736 +{
96737 + struct aa_profile *profile = (struct aa_profile *)p;
96738 + struct aa_namespace *root = f->private;
96739 +
96740 + if (profile->ns != root)
96741 + seq_printf(f, ":%s://", aa_ns_name(root, profile->ns));
96742 + seq_printf(f, "%s (%s)\n", profile->base.hname,
96743 + COMPLAIN_MODE(profile) ? "complain" : "enforce");
96744 +
96745 + return 0;
96746 +}
96747 +
96748 +static const struct seq_operations aa_fs_profiles_op = {
96749 + .start = p_start,
96750 + .next = p_next,
96751 + .stop = p_stop,
96752 + .show = seq_show_profile,
96753 +};
96754 +
96755 +static int profiles_open(struct inode *inode, struct file *file)
96756 +{
96757 + return seq_open(file, &aa_fs_profiles_op);
96758 +}
96759 +
96760 +static int profiles_release(struct inode *inode, struct file *file)
96761 +{
96762 + return seq_release(inode, file);
96763 +}
96764 +
96765 +const struct file_operations aa_fs_profiles_fops = {
96766 + .open = profiles_open,
96767 + .read = seq_read,
96768 + .llseek = seq_lseek,
96769 + .release = profiles_release,
96770 +};
96771 +#endif /* CONFIG_SECURITY_APPARMOR_COMPAT_24 */
96772 +
96773 /** Base file system setup **/
96774
96775 static struct aa_fs_entry aa_fs_entry_file[] = {
96776 @@ -210,6 +438,9 @@ static struct aa_fs_entry aa_fs_entry_apparmor[] = {
96777 AA_FS_FILE_FOPS(".load", 0640, &aa_fs_profile_load),
96778 AA_FS_FILE_FOPS(".replace", 0640, &aa_fs_profile_replace),
96779 AA_FS_FILE_FOPS(".remove", 0640, &aa_fs_profile_remove),
96780 +#ifdef CONFIG_SECURITY_APPARMOR_COMPAT_24
96781 + AA_FS_FILE_FOPS("profiles", 0640, &aa_fs_profiles_fops),
96782 +#endif
96783 AA_FS_DIR("features", aa_fs_entry_features),
96784 { }
96785 };
96786 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
96787 index b21830e..a7d1a17 100644
96788 --- a/security/apparmor/lsm.c
96789 +++ b/security/apparmor/lsm.c
96790 @@ -614,7 +614,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
96791 return error;
96792 }
96793
96794 -static struct security_operations apparmor_ops = {
96795 +static struct security_operations apparmor_ops __read_only = {
96796 .name = "apparmor",
96797
96798 .ptrace_access_check = apparmor_ptrace_access_check,
96799 diff --git a/security/commoncap.c b/security/commoncap.c
96800 index c44b6fe..932df30 100644
96801 --- a/security/commoncap.c
96802 +++ b/security/commoncap.c
96803 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
96804 return 0;
96805 }
96806
96807 +/* returns:
96808 + 1 for suid privilege
96809 + 2 for sgid privilege
96810 + 3 for fscap privilege
96811 +*/
96812 +int is_privileged_binary(const struct dentry *dentry)
96813 +{
96814 + struct cpu_vfs_cap_data capdata;
96815 + struct inode *inode = dentry->d_inode;
96816 +
96817 + if (!inode || S_ISDIR(inode->i_mode))
96818 + return 0;
96819 +
96820 + if (inode->i_mode & S_ISUID)
96821 + return 1;
96822 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
96823 + return 2;
96824 +
96825 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
96826 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
96827 + return 3;
96828 + }
96829 +
96830 + return 0;
96831 +}
96832 +
96833 /*
96834 * Attempt to get the on-exec apply capability sets for an executable file from
96835 * its xattrs and, if present, apply them to the proposed credentials being
96836 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
96837 const struct cred *cred = current_cred();
96838 kuid_t root_uid = make_kuid(cred->user_ns, 0);
96839
96840 + if (gr_acl_enable_at_secure())
96841 + return 1;
96842 +
96843 if (!uid_eq(cred->uid, root_uid)) {
96844 if (bprm->cap_effective)
96845 return 1;
96846 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
96847 index a41c9c1..83da6dd 100644
96848 --- a/security/integrity/ima/ima.h
96849 +++ b/security/integrity/ima/ima.h
96850 @@ -97,8 +97,8 @@ int ima_init_crypto(void);
96851 extern spinlock_t ima_queue_lock;
96852
96853 struct ima_h_table {
96854 - atomic_long_t len; /* number of stored measurements in the list */
96855 - atomic_long_t violations;
96856 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
96857 + atomic_long_unchecked_t violations;
96858 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
96859 };
96860 extern struct ima_h_table ima_htable;
96861 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
96862 index 1c03e8f1..398a941 100644
96863 --- a/security/integrity/ima/ima_api.c
96864 +++ b/security/integrity/ima/ima_api.c
96865 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
96866 int result;
96867
96868 /* can overflow, only indicator */
96869 - atomic_long_inc(&ima_htable.violations);
96870 + atomic_long_inc_unchecked(&ima_htable.violations);
96871
96872 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
96873 if (!entry) {
96874 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
96875 index 38477c9..87a60c7 100644
96876 --- a/security/integrity/ima/ima_fs.c
96877 +++ b/security/integrity/ima/ima_fs.c
96878 @@ -28,12 +28,12 @@
96879 static int valid_policy = 1;
96880 #define TMPBUFLEN 12
96881 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
96882 - loff_t *ppos, atomic_long_t *val)
96883 + loff_t *ppos, atomic_long_unchecked_t *val)
96884 {
96885 char tmpbuf[TMPBUFLEN];
96886 ssize_t len;
96887
96888 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
96889 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
96890 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
96891 }
96892
96893 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
96894 index ff63fe0..809cd96 100644
96895 --- a/security/integrity/ima/ima_queue.c
96896 +++ b/security/integrity/ima/ima_queue.c
96897 @@ -80,7 +80,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
96898 INIT_LIST_HEAD(&qe->later);
96899 list_add_tail_rcu(&qe->later, &ima_measurements);
96900
96901 - atomic_long_inc(&ima_htable.len);
96902 + atomic_long_inc_unchecked(&ima_htable.len);
96903 key = ima_hash_key(entry->digest);
96904 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
96905 return 0;
96906 diff --git a/security/keys/compat.c b/security/keys/compat.c
96907 index d65fa7f..cbfe366 100644
96908 --- a/security/keys/compat.c
96909 +++ b/security/keys/compat.c
96910 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
96911 if (ret == 0)
96912 goto no_payload_free;
96913
96914 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
96915 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
96916 err:
96917 if (iov != iovstack)
96918 kfree(iov);
96919 diff --git a/security/keys/internal.h b/security/keys/internal.h
96920 index d4f1468..cc52f92 100644
96921 --- a/security/keys/internal.h
96922 +++ b/security/keys/internal.h
96923 @@ -242,7 +242,7 @@ extern long keyctl_instantiate_key_iov(key_serial_t,
96924 extern long keyctl_invalidate_key(key_serial_t);
96925
96926 extern long keyctl_instantiate_key_common(key_serial_t,
96927 - const struct iovec *,
96928 + const struct iovec __user *,
96929 unsigned, size_t, key_serial_t);
96930
96931 /*
96932 diff --git a/security/keys/key.c b/security/keys/key.c
96933 index 8fb7c7b..ba3610d 100644
96934 --- a/security/keys/key.c
96935 +++ b/security/keys/key.c
96936 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
96937
96938 atomic_set(&key->usage, 1);
96939 init_rwsem(&key->sem);
96940 - lockdep_set_class(&key->sem, &type->lock_class);
96941 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
96942 key->type = type;
96943 key->user = user;
96944 key->quotalen = quotalen;
96945 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
96946 struct key_type *p;
96947 int ret;
96948
96949 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
96950 + pax_open_kernel();
96951 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
96952 + pax_close_kernel();
96953
96954 ret = -EEXIST;
96955 down_write(&key_types_sem);
96956 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
96957 }
96958
96959 /* store the type */
96960 - list_add(&ktype->link, &key_types_list);
96961 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
96962
96963 pr_notice("Key type %s registered\n", ktype->name);
96964 ret = 0;
96965 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
96966 void unregister_key_type(struct key_type *ktype)
96967 {
96968 down_write(&key_types_sem);
96969 - list_del_init(&ktype->link);
96970 + pax_list_del_init((struct list_head *)&ktype->link);
96971 downgrade_write(&key_types_sem);
96972 key_gc_keytype(ktype);
96973 pr_notice("Key type %s unregistered\n", ktype->name);
96974 @@ -1084,10 +1086,10 @@ void __init key_init(void)
96975 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
96976
96977 /* add the special key types */
96978 - list_add_tail(&key_type_keyring.link, &key_types_list);
96979 - list_add_tail(&key_type_dead.link, &key_types_list);
96980 - list_add_tail(&key_type_user.link, &key_types_list);
96981 - list_add_tail(&key_type_logon.link, &key_types_list);
96982 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
96983 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
96984 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
96985 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
96986
96987 /* record the root user tracking */
96988 rb_link_node(&root_key_user.node,
96989 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
96990 index 33cfd27..842fc5a 100644
96991 --- a/security/keys/keyctl.c
96992 +++ b/security/keys/keyctl.c
96993 @@ -987,7 +987,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
96994 /*
96995 * Copy the iovec data from userspace
96996 */
96997 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
96998 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
96999 unsigned ioc)
97000 {
97001 for (; ioc > 0; ioc--) {
97002 @@ -1009,7 +1009,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
97003 * If successful, 0 will be returned.
97004 */
97005 long keyctl_instantiate_key_common(key_serial_t id,
97006 - const struct iovec *payload_iov,
97007 + const struct iovec __user *payload_iov,
97008 unsigned ioc,
97009 size_t plen,
97010 key_serial_t ringid)
97011 @@ -1104,7 +1104,7 @@ long keyctl_instantiate_key(key_serial_t id,
97012 [0].iov_len = plen
97013 };
97014
97015 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
97016 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
97017 }
97018
97019 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
97020 @@ -1137,7 +1137,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
97021 if (ret == 0)
97022 goto no_payload_free;
97023
97024 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
97025 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
97026 err:
97027 if (iov != iovstack)
97028 kfree(iov);
97029 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
97030 index 6ece7f2..ecdb55c 100644
97031 --- a/security/keys/keyring.c
97032 +++ b/security/keys/keyring.c
97033 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
97034 ret = -EFAULT;
97035
97036 for (loop = 0; loop < klist->nkeys; loop++) {
97037 + key_serial_t serial;
97038 key = rcu_deref_link_locked(klist, loop,
97039 keyring);
97040 + serial = key->serial;
97041
97042 tmp = sizeof(key_serial_t);
97043 if (tmp > buflen)
97044 tmp = buflen;
97045
97046 - if (copy_to_user(buffer,
97047 - &key->serial,
97048 - tmp) != 0)
97049 + if (copy_to_user(buffer, &serial, tmp))
97050 goto error;
97051
97052 buflen -= tmp;
97053 diff --git a/security/min_addr.c b/security/min_addr.c
97054 index f728728..6457a0c 100644
97055 --- a/security/min_addr.c
97056 +++ b/security/min_addr.c
97057 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
97058 */
97059 static void update_mmap_min_addr(void)
97060 {
97061 +#ifndef SPARC
97062 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
97063 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
97064 mmap_min_addr = dac_mmap_min_addr;
97065 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
97066 #else
97067 mmap_min_addr = dac_mmap_min_addr;
97068 #endif
97069 +#endif
97070 }
97071
97072 /*
97073 diff --git a/security/security.c b/security/security.c
97074 index a3dce87..9ca1435 100644
97075 --- a/security/security.c
97076 +++ b/security/security.c
97077 @@ -20,6 +20,7 @@
97078 #include <linux/ima.h>
97079 #include <linux/evm.h>
97080 #include <linux/fsnotify.h>
97081 +#include <linux/mm.h>
97082 #include <linux/mman.h>
97083 #include <linux/mount.h>
97084 #include <linux/personality.h>
97085 @@ -32,8 +33,8 @@
97086 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
97087 CONFIG_DEFAULT_SECURITY;
97088
97089 -static struct security_operations *security_ops;
97090 -static struct security_operations default_security_ops = {
97091 +static struct security_operations *security_ops __read_only;
97092 +static struct security_operations default_security_ops __read_only = {
97093 .name = "default",
97094 };
97095
97096 @@ -74,7 +75,9 @@ int __init security_init(void)
97097
97098 void reset_security_ops(void)
97099 {
97100 + pax_open_kernel();
97101 security_ops = &default_security_ops;
97102 + pax_close_kernel();
97103 }
97104
97105 /* Save user chosen LSM */
97106 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
97107 index 5c6f2cd..b4f945c 100644
97108 --- a/security/selinux/hooks.c
97109 +++ b/security/selinux/hooks.c
97110 @@ -96,8 +96,6 @@
97111
97112 #define NUM_SEL_MNT_OPTS 5
97113
97114 -extern struct security_operations *security_ops;
97115 -
97116 /* SECMARK reference count */
97117 static atomic_t selinux_secmark_refcount = ATOMIC_INIT(0);
97118
97119 @@ -5529,7 +5527,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
97120
97121 #endif
97122
97123 -static struct security_operations selinux_ops = {
97124 +static struct security_operations selinux_ops __read_only = {
97125 .name = "selinux",
97126
97127 .ptrace_access_check = selinux_ptrace_access_check,
97128 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
97129 index 65f67cb..3f141ef 100644
97130 --- a/security/selinux/include/xfrm.h
97131 +++ b/security/selinux/include/xfrm.h
97132 @@ -50,7 +50,7 @@ int selinux_xfrm_decode_session(struct sk_buff *skb, u32 *sid, int ckall);
97133
97134 static inline void selinux_xfrm_notify_policyload(void)
97135 {
97136 - atomic_inc(&flow_cache_genid);
97137 + atomic_inc_unchecked(&flow_cache_genid);
97138 rt_genid_bump(&init_net);
97139 }
97140 #else
97141 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
97142 index d52c780..6431349 100644
97143 --- a/security/smack/smack_lsm.c
97144 +++ b/security/smack/smack_lsm.c
97145 @@ -3392,7 +3392,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
97146 return 0;
97147 }
97148
97149 -struct security_operations smack_ops = {
97150 +struct security_operations smack_ops __read_only = {
97151 .name = "smack",
97152
97153 .ptrace_access_check = smack_ptrace_access_check,
97154 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
97155 index 390c646..f2f8db3 100644
97156 --- a/security/tomoyo/mount.c
97157 +++ b/security/tomoyo/mount.c
97158 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
97159 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
97160 need_dev = -1; /* dev_name is a directory */
97161 } else {
97162 + if (!capable(CAP_SYS_ADMIN)) {
97163 + error = -EPERM;
97164 + goto out;
97165 + }
97166 fstype = get_fs_type(type);
97167 if (!fstype) {
97168 error = -ENODEV;
97169 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
97170 index f0b756e..b129202 100644
97171 --- a/security/tomoyo/tomoyo.c
97172 +++ b/security/tomoyo/tomoyo.c
97173 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
97174 * tomoyo_security_ops is a "struct security_operations" which is used for
97175 * registering TOMOYO.
97176 */
97177 -static struct security_operations tomoyo_security_ops = {
97178 +static struct security_operations tomoyo_security_ops __read_only = {
97179 .name = "tomoyo",
97180 .cred_alloc_blank = tomoyo_cred_alloc_blank,
97181 .cred_prepare = tomoyo_cred_prepare,
97182 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
97183 index 20ef514..4182bed 100644
97184 --- a/security/yama/Kconfig
97185 +++ b/security/yama/Kconfig
97186 @@ -1,6 +1,6 @@
97187 config SECURITY_YAMA
97188 bool "Yama support"
97189 - depends on SECURITY
97190 + depends on SECURITY && !GRKERNSEC
97191 select SECURITYFS
97192 select SECURITY_PATH
97193 default n
97194 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
97195 index 13c88fbc..f8c115e 100644
97196 --- a/security/yama/yama_lsm.c
97197 +++ b/security/yama/yama_lsm.c
97198 @@ -365,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
97199 }
97200
97201 #ifndef CONFIG_SECURITY_YAMA_STACKED
97202 -static struct security_operations yama_ops = {
97203 +static struct security_operations yama_ops __read_only = {
97204 .name = "yama",
97205
97206 .ptrace_access_check = yama_ptrace_access_check,
97207 @@ -376,28 +376,24 @@ static struct security_operations yama_ops = {
97208 #endif
97209
97210 #ifdef CONFIG_SYSCTL
97211 +static int zero __read_only;
97212 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
97213 +
97214 static int yama_dointvec_minmax(struct ctl_table *table, int write,
97215 void __user *buffer, size_t *lenp, loff_t *ppos)
97216 {
97217 - int rc;
97218 + ctl_table_no_const yama_table;
97219
97220 if (write && !capable(CAP_SYS_PTRACE))
97221 return -EPERM;
97222
97223 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
97224 - if (rc)
97225 - return rc;
97226 -
97227 + yama_table = *table;
97228 /* Lock the max value if it ever gets set. */
97229 - if (write && *(int *)table->data == *(int *)table->extra2)
97230 - table->extra1 = table->extra2;
97231 -
97232 - return rc;
97233 + if (ptrace_scope == max_scope)
97234 + yama_table.extra1 = &max_scope;
97235 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
97236 }
97237
97238 -static int zero;
97239 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
97240 -
97241 struct ctl_path yama_sysctl_path[] = {
97242 { .procname = "kernel", },
97243 { .procname = "yama", },
97244 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
97245 index 4cedc69..e59d8a3 100644
97246 --- a/sound/aoa/codecs/onyx.c
97247 +++ b/sound/aoa/codecs/onyx.c
97248 @@ -54,7 +54,7 @@ struct onyx {
97249 spdif_locked:1,
97250 analog_locked:1,
97251 original_mute:2;
97252 - int open_count;
97253 + local_t open_count;
97254 struct codec_info *codec_info;
97255
97256 /* mutex serializes concurrent access to the device
97257 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
97258 struct onyx *onyx = cii->codec_data;
97259
97260 mutex_lock(&onyx->mutex);
97261 - onyx->open_count++;
97262 + local_inc(&onyx->open_count);
97263 mutex_unlock(&onyx->mutex);
97264
97265 return 0;
97266 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
97267 struct onyx *onyx = cii->codec_data;
97268
97269 mutex_lock(&onyx->mutex);
97270 - onyx->open_count--;
97271 - if (!onyx->open_count)
97272 + if (local_dec_and_test(&onyx->open_count))
97273 onyx->spdif_locked = onyx->analog_locked = 0;
97274 mutex_unlock(&onyx->mutex);
97275
97276 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
97277 index ffd2025..df062c9 100644
97278 --- a/sound/aoa/codecs/onyx.h
97279 +++ b/sound/aoa/codecs/onyx.h
97280 @@ -11,6 +11,7 @@
97281 #include <linux/i2c.h>
97282 #include <asm/pmac_low_i2c.h>
97283 #include <asm/prom.h>
97284 +#include <asm/local.h>
97285
97286 /* PCM3052 register definitions */
97287
97288 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
97289 index 4c1cc51..16040040 100644
97290 --- a/sound/core/oss/pcm_oss.c
97291 +++ b/sound/core/oss/pcm_oss.c
97292 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
97293 if (in_kernel) {
97294 mm_segment_t fs;
97295 fs = snd_enter_user();
97296 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
97297 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
97298 snd_leave_user(fs);
97299 } else {
97300 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
97301 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
97302 }
97303 if (ret != -EPIPE && ret != -ESTRPIPE)
97304 break;
97305 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
97306 if (in_kernel) {
97307 mm_segment_t fs;
97308 fs = snd_enter_user();
97309 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
97310 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
97311 snd_leave_user(fs);
97312 } else {
97313 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
97314 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
97315 }
97316 if (ret == -EPIPE) {
97317 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
97318 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
97319 struct snd_pcm_plugin_channel *channels;
97320 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
97321 if (!in_kernel) {
97322 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
97323 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
97324 return -EFAULT;
97325 buf = runtime->oss.buffer;
97326 }
97327 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
97328 }
97329 } else {
97330 tmp = snd_pcm_oss_write2(substream,
97331 - (const char __force *)buf,
97332 + (const char __force_kernel *)buf,
97333 runtime->oss.period_bytes, 0);
97334 if (tmp <= 0)
97335 goto err;
97336 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
97337 struct snd_pcm_runtime *runtime = substream->runtime;
97338 snd_pcm_sframes_t frames, frames1;
97339 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
97340 - char __user *final_dst = (char __force __user *)buf;
97341 + char __user *final_dst = (char __force_user *)buf;
97342 if (runtime->oss.plugin_first) {
97343 struct snd_pcm_plugin_channel *channels;
97344 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
97345 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
97346 xfer += tmp;
97347 runtime->oss.buffer_used -= tmp;
97348 } else {
97349 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
97350 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
97351 runtime->oss.period_bytes, 0);
97352 if (tmp <= 0)
97353 goto err;
97354 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
97355 size1);
97356 size1 /= runtime->channels; /* frames */
97357 fs = snd_enter_user();
97358 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
97359 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
97360 snd_leave_user(fs);
97361 }
97362 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
97363 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
97364 index af49721..e85058e 100644
97365 --- a/sound/core/pcm_compat.c
97366 +++ b/sound/core/pcm_compat.c
97367 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
97368 int err;
97369
97370 fs = snd_enter_user();
97371 - err = snd_pcm_delay(substream, &delay);
97372 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
97373 snd_leave_user(fs);
97374 if (err < 0)
97375 return err;
97376 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
97377 index f928181..33fb83d 100644
97378 --- a/sound/core/pcm_native.c
97379 +++ b/sound/core/pcm_native.c
97380 @@ -2819,11 +2819,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
97381 switch (substream->stream) {
97382 case SNDRV_PCM_STREAM_PLAYBACK:
97383 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
97384 - (void __user *)arg);
97385 + (void __force_user *)arg);
97386 break;
97387 case SNDRV_PCM_STREAM_CAPTURE:
97388 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
97389 - (void __user *)arg);
97390 + (void __force_user *)arg);
97391 break;
97392 default:
97393 result = -EINVAL;
97394 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
97395 index 040c60e..989a19a 100644
97396 --- a/sound/core/seq/seq_device.c
97397 +++ b/sound/core/seq/seq_device.c
97398 @@ -64,7 +64,7 @@ struct ops_list {
97399 int argsize; /* argument size */
97400
97401 /* operators */
97402 - struct snd_seq_dev_ops ops;
97403 + struct snd_seq_dev_ops *ops;
97404
97405 /* registered devices */
97406 struct list_head dev_list; /* list of devices */
97407 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
97408
97409 mutex_lock(&ops->reg_mutex);
97410 /* copy driver operators */
97411 - ops->ops = *entry;
97412 + ops->ops = entry;
97413 ops->driver |= DRIVER_LOADED;
97414 ops->argsize = argsize;
97415
97416 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
97417 dev->name, ops->id, ops->argsize, dev->argsize);
97418 return -EINVAL;
97419 }
97420 - if (ops->ops.init_device(dev) >= 0) {
97421 + if (ops->ops->init_device(dev) >= 0) {
97422 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
97423 ops->num_init_devices++;
97424 } else {
97425 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
97426 dev->name, ops->id, ops->argsize, dev->argsize);
97427 return -EINVAL;
97428 }
97429 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
97430 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
97431 dev->status = SNDRV_SEQ_DEVICE_FREE;
97432 dev->driver_data = NULL;
97433 ops->num_init_devices--;
97434 diff --git a/sound/core/sound.c b/sound/core/sound.c
97435 index f002bd9..c462985 100644
97436 --- a/sound/core/sound.c
97437 +++ b/sound/core/sound.c
97438 @@ -86,7 +86,7 @@ static void snd_request_other(int minor)
97439 case SNDRV_MINOR_TIMER: str = "snd-timer"; break;
97440 default: return;
97441 }
97442 - request_module(str);
97443 + request_module("%s", str);
97444 }
97445
97446 #endif /* modular kernel */
97447 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
97448 index 4e0dd22..7a1f32c 100644
97449 --- a/sound/drivers/mts64.c
97450 +++ b/sound/drivers/mts64.c
97451 @@ -29,6 +29,7 @@
97452 #include <sound/initval.h>
97453 #include <sound/rawmidi.h>
97454 #include <sound/control.h>
97455 +#include <asm/local.h>
97456
97457 #define CARD_NAME "Miditerminal 4140"
97458 #define DRIVER_NAME "MTS64"
97459 @@ -67,7 +68,7 @@ struct mts64 {
97460 struct pardevice *pardev;
97461 int pardev_claimed;
97462
97463 - int open_count;
97464 + local_t open_count;
97465 int current_midi_output_port;
97466 int current_midi_input_port;
97467 u8 mode[MTS64_NUM_INPUT_PORTS];
97468 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
97469 {
97470 struct mts64 *mts = substream->rmidi->private_data;
97471
97472 - if (mts->open_count == 0) {
97473 + if (local_read(&mts->open_count) == 0) {
97474 /* We don't need a spinlock here, because this is just called
97475 if the device has not been opened before.
97476 So there aren't any IRQs from the device */
97477 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
97478
97479 msleep(50);
97480 }
97481 - ++(mts->open_count);
97482 + local_inc(&mts->open_count);
97483
97484 return 0;
97485 }
97486 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
97487 struct mts64 *mts = substream->rmidi->private_data;
97488 unsigned long flags;
97489
97490 - --(mts->open_count);
97491 - if (mts->open_count == 0) {
97492 + if (local_dec_return(&mts->open_count) == 0) {
97493 /* We need the spinlock_irqsave here because we can still
97494 have IRQs at this point */
97495 spin_lock_irqsave(&mts->lock, flags);
97496 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
97497
97498 msleep(500);
97499
97500 - } else if (mts->open_count < 0)
97501 - mts->open_count = 0;
97502 + } else if (local_read(&mts->open_count) < 0)
97503 + local_set(&mts->open_count, 0);
97504
97505 return 0;
97506 }
97507 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
97508 index b953fb4..1999c01 100644
97509 --- a/sound/drivers/opl4/opl4_lib.c
97510 +++ b/sound/drivers/opl4/opl4_lib.c
97511 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
97512 MODULE_DESCRIPTION("OPL4 driver");
97513 MODULE_LICENSE("GPL");
97514
97515 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
97516 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
97517 {
97518 int timeout = 10;
97519 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
97520 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
97521 index 991018d..8984740 100644
97522 --- a/sound/drivers/portman2x4.c
97523 +++ b/sound/drivers/portman2x4.c
97524 @@ -48,6 +48,7 @@
97525 #include <sound/initval.h>
97526 #include <sound/rawmidi.h>
97527 #include <sound/control.h>
97528 +#include <asm/local.h>
97529
97530 #define CARD_NAME "Portman 2x4"
97531 #define DRIVER_NAME "portman"
97532 @@ -85,7 +86,7 @@ struct portman {
97533 struct pardevice *pardev;
97534 int pardev_claimed;
97535
97536 - int open_count;
97537 + local_t open_count;
97538 int mode[PORTMAN_NUM_INPUT_PORTS];
97539 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
97540 };
97541 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
97542 index ea995af..f1bfa37 100644
97543 --- a/sound/firewire/amdtp.c
97544 +++ b/sound/firewire/amdtp.c
97545 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
97546 ptr = s->pcm_buffer_pointer + data_blocks;
97547 if (ptr >= pcm->runtime->buffer_size)
97548 ptr -= pcm->runtime->buffer_size;
97549 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
97550 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
97551
97552 s->pcm_period_pointer += data_blocks;
97553 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
97554 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
97555 */
97556 void amdtp_out_stream_update(struct amdtp_out_stream *s)
97557 {
97558 - ACCESS_ONCE(s->source_node_id_field) =
97559 + ACCESS_ONCE_RW(s->source_node_id_field) =
97560 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
97561 }
97562 EXPORT_SYMBOL(amdtp_out_stream_update);
97563 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
97564 index b680c5e..061b7a0 100644
97565 --- a/sound/firewire/amdtp.h
97566 +++ b/sound/firewire/amdtp.h
97567 @@ -139,7 +139,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
97568 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
97569 struct snd_pcm_substream *pcm)
97570 {
97571 - ACCESS_ONCE(s->pcm) = pcm;
97572 + ACCESS_ONCE_RW(s->pcm) = pcm;
97573 }
97574
97575 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
97576 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
97577 index d428ffe..751ef78 100644
97578 --- a/sound/firewire/isight.c
97579 +++ b/sound/firewire/isight.c
97580 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
97581 ptr += count;
97582 if (ptr >= runtime->buffer_size)
97583 ptr -= runtime->buffer_size;
97584 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
97585 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
97586
97587 isight->period_counter += count;
97588 if (isight->period_counter >= runtime->period_size) {
97589 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
97590 if (err < 0)
97591 return err;
97592
97593 - ACCESS_ONCE(isight->pcm_active) = true;
97594 + ACCESS_ONCE_RW(isight->pcm_active) = true;
97595
97596 return 0;
97597 }
97598 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
97599 {
97600 struct isight *isight = substream->private_data;
97601
97602 - ACCESS_ONCE(isight->pcm_active) = false;
97603 + ACCESS_ONCE_RW(isight->pcm_active) = false;
97604
97605 mutex_lock(&isight->mutex);
97606 isight_stop_streaming(isight);
97607 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
97608
97609 switch (cmd) {
97610 case SNDRV_PCM_TRIGGER_START:
97611 - ACCESS_ONCE(isight->pcm_running) = true;
97612 + ACCESS_ONCE_RW(isight->pcm_running) = true;
97613 break;
97614 case SNDRV_PCM_TRIGGER_STOP:
97615 - ACCESS_ONCE(isight->pcm_running) = false;
97616 + ACCESS_ONCE_RW(isight->pcm_running) = false;
97617 break;
97618 default:
97619 return -EINVAL;
97620 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
97621 index 844a555..985ab83 100644
97622 --- a/sound/firewire/scs1x.c
97623 +++ b/sound/firewire/scs1x.c
97624 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
97625 {
97626 struct scs *scs = stream->rmidi->private_data;
97627
97628 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
97629 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
97630 if (up) {
97631 scs->output_idle = false;
97632 tasklet_schedule(&scs->tasklet);
97633 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
97634 {
97635 struct scs *scs = stream->rmidi->private_data;
97636
97637 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
97638 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
97639 }
97640
97641 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
97642 @@ -457,8 +457,8 @@ static int scs_remove(struct device *dev)
97643
97644 snd_card_disconnect(scs->card);
97645
97646 - ACCESS_ONCE(scs->output) = NULL;
97647 - ACCESS_ONCE(scs->input) = NULL;
97648 + ACCESS_ONCE_RW(scs->output) = NULL;
97649 + ACCESS_ONCE_RW(scs->input) = NULL;
97650
97651 wait_event(scs->idle_wait, scs->output_idle);
97652
97653 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
97654 index 048439a..3be9f6f 100644
97655 --- a/sound/oss/sb_audio.c
97656 +++ b/sound/oss/sb_audio.c
97657 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
97658 buf16 = (signed short *)(localbuf + localoffs);
97659 while (c)
97660 {
97661 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
97662 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
97663 if (copy_from_user(lbuf8,
97664 userbuf+useroffs + p,
97665 locallen))
97666 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
97667 index 7d8803a..559f8d0 100644
97668 --- a/sound/oss/swarm_cs4297a.c
97669 +++ b/sound/oss/swarm_cs4297a.c
97670 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
97671 {
97672 struct cs4297a_state *s;
97673 u32 pwr, id;
97674 - mm_segment_t fs;
97675 int rval;
97676 #ifndef CONFIG_BCM_CS4297A_CSWARM
97677 u64 cfg;
97678 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
97679 if (!rval) {
97680 char *sb1250_duart_present;
97681
97682 +#if 0
97683 + mm_segment_t fs;
97684 fs = get_fs();
97685 set_fs(KERNEL_DS);
97686 -#if 0
97687 val = SOUND_MASK_LINE;
97688 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
97689 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
97690 val = initvol[i].vol;
97691 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
97692 }
97693 + set_fs(fs);
97694 // cs4297a_write_ac97(s, 0x18, 0x0808);
97695 #else
97696 // cs4297a_write_ac97(s, 0x5e, 0x180);
97697 cs4297a_write_ac97(s, 0x02, 0x0808);
97698 cs4297a_write_ac97(s, 0x18, 0x0808);
97699 #endif
97700 - set_fs(fs);
97701
97702 list_add(&s->list, &cs4297a_devs);
97703
97704 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
97705 index 4631a23..001ae57 100644
97706 --- a/sound/pci/ymfpci/ymfpci.h
97707 +++ b/sound/pci/ymfpci/ymfpci.h
97708 @@ -358,7 +358,7 @@ struct snd_ymfpci {
97709 spinlock_t reg_lock;
97710 spinlock_t voice_lock;
97711 wait_queue_head_t interrupt_sleep;
97712 - atomic_t interrupt_sleep_count;
97713 + atomic_unchecked_t interrupt_sleep_count;
97714 struct snd_info_entry *proc_entry;
97715 const struct firmware *dsp_microcode;
97716 const struct firmware *controller_microcode;
97717 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
97718 index 22056c5..25d3244 100644
97719 --- a/sound/pci/ymfpci/ymfpci_main.c
97720 +++ b/sound/pci/ymfpci/ymfpci_main.c
97721 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
97722 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
97723 break;
97724 }
97725 - if (atomic_read(&chip->interrupt_sleep_count)) {
97726 - atomic_set(&chip->interrupt_sleep_count, 0);
97727 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
97728 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
97729 wake_up(&chip->interrupt_sleep);
97730 }
97731 __end:
97732 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
97733 continue;
97734 init_waitqueue_entry(&wait, current);
97735 add_wait_queue(&chip->interrupt_sleep, &wait);
97736 - atomic_inc(&chip->interrupt_sleep_count);
97737 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
97738 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
97739 remove_wait_queue(&chip->interrupt_sleep, &wait);
97740 }
97741 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
97742 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
97743 spin_unlock(&chip->reg_lock);
97744
97745 - if (atomic_read(&chip->interrupt_sleep_count)) {
97746 - atomic_set(&chip->interrupt_sleep_count, 0);
97747 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
97748 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
97749 wake_up(&chip->interrupt_sleep);
97750 }
97751 }
97752 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
97753 spin_lock_init(&chip->reg_lock);
97754 spin_lock_init(&chip->voice_lock);
97755 init_waitqueue_head(&chip->interrupt_sleep);
97756 - atomic_set(&chip->interrupt_sleep_count, 0);
97757 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
97758 chip->card = card;
97759 chip->pci = pci;
97760 chip->irq = -1;
97761 diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
97762 index 0f0bed6..c161e28 100644
97763 --- a/sound/soc/fsl/fsl_ssi.c
97764 +++ b/sound/soc/fsl/fsl_ssi.c
97765 @@ -657,7 +657,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
97766 {
97767 struct fsl_ssi_private *ssi_private;
97768 int ret = 0;
97769 - struct device_attribute *dev_attr = NULL;
97770 + device_attribute_no_const *dev_attr = NULL;
97771 struct device_node *np = pdev->dev.of_node;
97772 const char *p, *sprop;
97773 const uint32_t *iprop;
97774 diff --git a/sound/sound_core.c b/sound/sound_core.c
97775 index 359753f..45759f4 100644
97776 --- a/sound/sound_core.c
97777 +++ b/sound/sound_core.c
97778 @@ -292,7 +292,7 @@ retry:
97779 }
97780
97781 device_create(sound_class, dev, MKDEV(SOUND_MAJOR, s->unit_minor),
97782 - NULL, s->name+6);
97783 + NULL, "%s", s->name+6);
97784 return s->unit_minor;
97785
97786 fail:
97787 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
97788 new file mode 100644
97789 index 0000000..50f2f2f
97790 --- /dev/null
97791 +++ b/tools/gcc/.gitignore
97792 @@ -0,0 +1 @@
97793 +size_overflow_hash.h
97794 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
97795 new file mode 100644
97796 index 0000000..144dbee
97797 --- /dev/null
97798 +++ b/tools/gcc/Makefile
97799 @@ -0,0 +1,45 @@
97800 +#CC := gcc
97801 +#PLUGIN_SOURCE_FILES := pax_plugin.c
97802 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
97803 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
97804 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
97805 +
97806 +ifeq ($(PLUGINCC),$(HOSTCC))
97807 +HOSTLIBS := hostlibs
97808 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
97809 +else
97810 +HOSTLIBS := hostcxxlibs
97811 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
97812 +endif
97813 +
97814 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
97815 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
97816 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
97817 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
97818 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
97819 +$(HOSTLIBS)-y += colorize_plugin.so
97820 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
97821 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
97822 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
97823 +
97824 +always := $($(HOSTLIBS)-y)
97825 +
97826 +constify_plugin-objs := constify_plugin.o
97827 +stackleak_plugin-objs := stackleak_plugin.o
97828 +kallocstat_plugin-objs := kallocstat_plugin.o
97829 +kernexec_plugin-objs := kernexec_plugin.o
97830 +checker_plugin-objs := checker_plugin.o
97831 +colorize_plugin-objs := colorize_plugin.o
97832 +size_overflow_plugin-objs := size_overflow_plugin.o
97833 +latent_entropy_plugin-objs := latent_entropy_plugin.o
97834 +structleak_plugin-objs := structleak_plugin.o
97835 +
97836 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
97837 +
97838 +quiet_cmd_build_size_overflow_hash = GENHASH $@
97839 + cmd_build_size_overflow_hash = \
97840 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
97841 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
97842 + $(call if_changed,build_size_overflow_hash)
97843 +
97844 +targets += size_overflow_hash.h
97845 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
97846 new file mode 100644
97847 index 0000000..22f03c0
97848 --- /dev/null
97849 +++ b/tools/gcc/checker_plugin.c
97850 @@ -0,0 +1,172 @@
97851 +/*
97852 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
97853 + * Licensed under the GPL v2
97854 + *
97855 + * Note: the choice of the license means that the compilation process is
97856 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
97857 + * but for the kernel it doesn't matter since it doesn't link against
97858 + * any of the gcc libraries
97859 + *
97860 + * gcc plugin to implement various sparse (source code checker) features
97861 + *
97862 + * TODO:
97863 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
97864 + *
97865 + * BUGS:
97866 + * - none known
97867 + */
97868 +#include "gcc-plugin.h"
97869 +#include "config.h"
97870 +#include "system.h"
97871 +#include "coretypes.h"
97872 +#include "tree.h"
97873 +#include "tree-pass.h"
97874 +#include "flags.h"
97875 +#include "intl.h"
97876 +#include "toplev.h"
97877 +#include "plugin.h"
97878 +//#include "expr.h" where are you...
97879 +#include "diagnostic.h"
97880 +#include "plugin-version.h"
97881 +#include "tm.h"
97882 +#include "function.h"
97883 +#include "basic-block.h"
97884 +#include "gimple.h"
97885 +#include "rtl.h"
97886 +#include "emit-rtl.h"
97887 +#include "tree-flow.h"
97888 +#include "target.h"
97889 +
97890 +extern void c_register_addr_space (const char *str, addr_space_t as);
97891 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
97892 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
97893 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
97894 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
97895 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
97896 +
97897 +extern void print_gimple_stmt(FILE *, gimple, int, int);
97898 +extern rtx emit_move_insn(rtx x, rtx y);
97899 +
97900 +int plugin_is_GPL_compatible;
97901 +
97902 +static struct plugin_info checker_plugin_info = {
97903 + .version = "201111150100",
97904 + .help = NULL,
97905 +};
97906 +
97907 +#define ADDR_SPACE_KERNEL 0
97908 +#define ADDR_SPACE_FORCE_KERNEL 1
97909 +#define ADDR_SPACE_USER 2
97910 +#define ADDR_SPACE_FORCE_USER 3
97911 +#define ADDR_SPACE_IOMEM 0
97912 +#define ADDR_SPACE_FORCE_IOMEM 0
97913 +#define ADDR_SPACE_PERCPU 0
97914 +#define ADDR_SPACE_FORCE_PERCPU 0
97915 +#define ADDR_SPACE_RCU 0
97916 +#define ADDR_SPACE_FORCE_RCU 0
97917 +
97918 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
97919 +{
97920 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
97921 +}
97922 +
97923 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
97924 +{
97925 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
97926 +}
97927 +
97928 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
97929 +{
97930 + return default_addr_space_valid_pointer_mode(mode, as);
97931 +}
97932 +
97933 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
97934 +{
97935 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
97936 +}
97937 +
97938 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
97939 +{
97940 + return default_addr_space_legitimize_address(x, oldx, mode, as);
97941 +}
97942 +
97943 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
97944 +{
97945 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
97946 + return true;
97947 +
97948 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
97949 + return true;
97950 +
97951 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
97952 + return true;
97953 +
97954 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
97955 + return true;
97956 +
97957 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
97958 + return true;
97959 +
97960 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
97961 + return true;
97962 +
97963 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
97964 + return true;
97965 +
97966 + return subset == superset;
97967 +}
97968 +
97969 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
97970 +{
97971 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
97972 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
97973 +
97974 + return op;
97975 +}
97976 +
97977 +static void register_checker_address_spaces(void *event_data, void *data)
97978 +{
97979 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
97980 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
97981 + c_register_addr_space("__user", ADDR_SPACE_USER);
97982 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
97983 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
97984 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
97985 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
97986 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
97987 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
97988 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
97989 +
97990 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
97991 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
97992 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
97993 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
97994 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
97995 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
97996 + targetm.addr_space.convert = checker_addr_space_convert;
97997 +}
97998 +
97999 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
98000 +{
98001 + const char * const plugin_name = plugin_info->base_name;
98002 + const int argc = plugin_info->argc;
98003 + const struct plugin_argument * const argv = plugin_info->argv;
98004 + int i;
98005 +
98006 + if (!plugin_default_version_check(version, &gcc_version)) {
98007 + error(G_("incompatible gcc/plugin versions"));
98008 + return 1;
98009 + }
98010 +
98011 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
98012 +
98013 + for (i = 0; i < argc; ++i)
98014 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
98015 +
98016 + if (TARGET_64BIT == 0)
98017 + return 0;
98018 +
98019 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
98020 +
98021 + return 0;
98022 +}
98023 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
98024 new file mode 100644
98025 index 0000000..414fe5e
98026 --- /dev/null
98027 +++ b/tools/gcc/colorize_plugin.c
98028 @@ -0,0 +1,151 @@
98029 +/*
98030 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
98031 + * Licensed under the GPL v2
98032 + *
98033 + * Note: the choice of the license means that the compilation process is
98034 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
98035 + * but for the kernel it doesn't matter since it doesn't link against
98036 + * any of the gcc libraries
98037 + *
98038 + * gcc plugin to colorize diagnostic output
98039 + *
98040 + */
98041 +
98042 +#include "gcc-plugin.h"
98043 +#include "config.h"
98044 +#include "system.h"
98045 +#include "coretypes.h"
98046 +#include "tree.h"
98047 +#include "tree-pass.h"
98048 +#include "flags.h"
98049 +#include "intl.h"
98050 +#include "toplev.h"
98051 +#include "plugin.h"
98052 +#include "diagnostic.h"
98053 +#include "plugin-version.h"
98054 +#include "tm.h"
98055 +
98056 +int plugin_is_GPL_compatible;
98057 +
98058 +static struct plugin_info colorize_plugin_info = {
98059 + .version = "201302112000",
98060 + .help = NULL,
98061 +};
98062 +
98063 +#define GREEN "\033[32m\033[2m"
98064 +#define LIGHTGREEN "\033[32m\033[1m"
98065 +#define YELLOW "\033[33m\033[2m"
98066 +#define LIGHTYELLOW "\033[33m\033[1m"
98067 +#define RED "\033[31m\033[2m"
98068 +#define LIGHTRED "\033[31m\033[1m"
98069 +#define BLUE "\033[34m\033[2m"
98070 +#define LIGHTBLUE "\033[34m\033[1m"
98071 +#define BRIGHT "\033[m\033[1m"
98072 +#define NORMAL "\033[m"
98073 +
98074 +static diagnostic_starter_fn old_starter;
98075 +static diagnostic_finalizer_fn old_finalizer;
98076 +
98077 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
98078 +{
98079 + const char *color;
98080 + char *newprefix;
98081 +
98082 + switch (diagnostic->kind) {
98083 + case DK_NOTE:
98084 + color = LIGHTBLUE;
98085 + break;
98086 +
98087 + case DK_PEDWARN:
98088 + case DK_WARNING:
98089 + color = LIGHTYELLOW;
98090 + break;
98091 +
98092 + case DK_ERROR:
98093 + case DK_FATAL:
98094 + case DK_ICE:
98095 + case DK_PERMERROR:
98096 + case DK_SORRY:
98097 + color = LIGHTRED;
98098 + break;
98099 +
98100 + default:
98101 + color = NORMAL;
98102 + }
98103 +
98104 + old_starter(context, diagnostic);
98105 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
98106 + return;
98107 + pp_destroy_prefix(context->printer);
98108 + pp_set_prefix(context->printer, newprefix);
98109 +}
98110 +
98111 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
98112 +{
98113 + old_finalizer(context, diagnostic);
98114 +}
98115 +
98116 +static void colorize_arm(void)
98117 +{
98118 + old_starter = diagnostic_starter(global_dc);
98119 + old_finalizer = diagnostic_finalizer(global_dc);
98120 +
98121 + diagnostic_starter(global_dc) = start_colorize;
98122 + diagnostic_finalizer(global_dc) = finalize_colorize;
98123 +}
98124 +
98125 +static unsigned int execute_colorize_rearm(void)
98126 +{
98127 + if (diagnostic_starter(global_dc) == start_colorize)
98128 + return 0;
98129 +
98130 + colorize_arm();
98131 + return 0;
98132 +}
98133 +
98134 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
98135 + .pass = {
98136 + .type = SIMPLE_IPA_PASS,
98137 + .name = "colorize_rearm",
98138 +#if BUILDING_GCC_VERSION >= 4008
98139 + .optinfo_flags = OPTGROUP_NONE,
98140 +#endif
98141 + .gate = NULL,
98142 + .execute = execute_colorize_rearm,
98143 + .sub = NULL,
98144 + .next = NULL,
98145 + .static_pass_number = 0,
98146 + .tv_id = TV_NONE,
98147 + .properties_required = 0,
98148 + .properties_provided = 0,
98149 + .properties_destroyed = 0,
98150 + .todo_flags_start = 0,
98151 + .todo_flags_finish = 0
98152 + }
98153 +};
98154 +
98155 +static void colorize_start_unit(void *gcc_data, void *user_data)
98156 +{
98157 + colorize_arm();
98158 +}
98159 +
98160 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
98161 +{
98162 + const char * const plugin_name = plugin_info->base_name;
98163 + struct register_pass_info colorize_rearm_pass_info = {
98164 + .pass = &pass_ipa_colorize_rearm.pass,
98165 + .reference_pass_name = "*free_lang_data",
98166 + .ref_pass_instance_number = 1,
98167 + .pos_op = PASS_POS_INSERT_AFTER
98168 + };
98169 +
98170 + if (!plugin_default_version_check(version, &gcc_version)) {
98171 + error(G_("incompatible gcc/plugin versions"));
98172 + return 1;
98173 + }
98174 +
98175 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
98176 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
98177 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
98178 + return 0;
98179 +}
98180 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
98181 new file mode 100644
98182 index 0000000..c17312d
98183 --- /dev/null
98184 +++ b/tools/gcc/constify_plugin.c
98185 @@ -0,0 +1,560 @@
98186 +/*
98187 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
98188 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
98189 + * Licensed under the GPL v2, or (at your option) v3
98190 + *
98191 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
98192 + *
98193 + * Homepage:
98194 + * http://www.grsecurity.net/~ephox/const_plugin/
98195 + *
98196 + * Usage:
98197 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
98198 + * $ gcc -fplugin=constify_plugin.so test.c -O2
98199 + */
98200 +
98201 +#include "gcc-plugin.h"
98202 +#include "config.h"
98203 +#include "system.h"
98204 +#include "coretypes.h"
98205 +#include "tree.h"
98206 +#include "tree-pass.h"
98207 +#include "flags.h"
98208 +#include "intl.h"
98209 +#include "toplev.h"
98210 +#include "plugin.h"
98211 +#include "diagnostic.h"
98212 +#include "plugin-version.h"
98213 +#include "tm.h"
98214 +#include "function.h"
98215 +#include "basic-block.h"
98216 +#include "gimple.h"
98217 +#include "rtl.h"
98218 +#include "emit-rtl.h"
98219 +#include "tree-flow.h"
98220 +#include "target.h"
98221 +#include "langhooks.h"
98222 +
98223 +// should come from c-tree.h if only it were installed for gcc 4.5...
98224 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
98225 +
98226 +// unused type flag in all versions 4.5-4.8
98227 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
98228 +
98229 +int plugin_is_GPL_compatible;
98230 +
98231 +static struct plugin_info const_plugin_info = {
98232 + .version = "201305231310",
98233 + .help = "no-constify\tturn off constification\n",
98234 +};
98235 +
98236 +typedef struct {
98237 + bool has_fptr_field;
98238 + bool has_writable_field;
98239 + bool has_do_const_field;
98240 + bool has_no_const_field;
98241 +} constify_info;
98242 +
98243 +static const_tree get_field_type(const_tree field)
98244 +{
98245 + return strip_array_types(TREE_TYPE(field));
98246 +}
98247 +
98248 +static bool is_fptr(const_tree field)
98249 +{
98250 + const_tree ptr = get_field_type(field);
98251 +
98252 + if (TREE_CODE(ptr) != POINTER_TYPE)
98253 + return false;
98254 +
98255 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
98256 +}
98257 +
98258 +/*
98259 + * determine whether the given structure type meets the requirements for automatic constification,
98260 + * including the constification attributes on nested structure types
98261 + */
98262 +static void constifiable(const_tree node, constify_info *cinfo)
98263 +{
98264 + const_tree field;
98265 +
98266 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
98267 +
98268 + // e.g., pointer to structure fields while still constructing the structure type
98269 + if (TYPE_FIELDS(node) == NULL_TREE)
98270 + return;
98271 +
98272 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
98273 + const_tree type = get_field_type(field);
98274 + enum tree_code code = TREE_CODE(type);
98275 +
98276 + if (node == type)
98277 + continue;
98278 +
98279 + if (is_fptr(field))
98280 + cinfo->has_fptr_field = true;
98281 + else if (!TREE_READONLY(field))
98282 + cinfo->has_writable_field = true;
98283 +
98284 + if (code == RECORD_TYPE || code == UNION_TYPE) {
98285 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
98286 + cinfo->has_do_const_field = true;
98287 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
98288 + cinfo->has_no_const_field = true;
98289 + else
98290 + constifiable(type, cinfo);
98291 + }
98292 + }
98293 +}
98294 +
98295 +static bool constified(const_tree node)
98296 +{
98297 + constify_info cinfo = {
98298 + .has_fptr_field = false,
98299 + .has_writable_field = false,
98300 + .has_do_const_field = false,
98301 + .has_no_const_field = false
98302 + };
98303 +
98304 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
98305 +
98306 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
98307 + gcc_assert(!TYPE_READONLY(node));
98308 + return false;
98309 + }
98310 +
98311 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
98312 + gcc_assert(TYPE_READONLY(node));
98313 + return true;
98314 + }
98315 +
98316 + constifiable(node, &cinfo);
98317 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
98318 + return false;
98319 +
98320 + return TYPE_READONLY(node);
98321 +}
98322 +
98323 +static void deconstify_tree(tree node);
98324 +
98325 +static void deconstify_type(tree type)
98326 +{
98327 + tree field;
98328 +
98329 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
98330 +
98331 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
98332 + const_tree fieldtype = get_field_type(field);
98333 +
98334 + // special case handling of simple ptr-to-same-array-type members
98335 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
98336 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
98337 +
98338 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
98339 + continue;
98340 + if (TREE_TYPE(TREE_TYPE(field)) == type)
98341 + continue;
98342 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
98343 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
98344 + TREE_TYPE(TREE_TYPE(field)) = type;
98345 + }
98346 + continue;
98347 + }
98348 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
98349 + continue;
98350 + if (!constified(fieldtype))
98351 + continue;
98352 +
98353 + deconstify_tree(field);
98354 + TREE_READONLY(field) = 0;
98355 + }
98356 + TYPE_READONLY(type) = 0;
98357 + C_TYPE_FIELDS_READONLY(type) = 0;
98358 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
98359 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
98360 +}
98361 +
98362 +static void deconstify_tree(tree node)
98363 +{
98364 + tree old_type, new_type, field;
98365 +
98366 + old_type = TREE_TYPE(node);
98367 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
98368 + node = TREE_TYPE(node) = copy_node(old_type);
98369 + old_type = TREE_TYPE(old_type);
98370 + }
98371 +
98372 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
98373 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
98374 +
98375 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
98376 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
98377 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
98378 + DECL_FIELD_CONTEXT(field) = new_type;
98379 +
98380 + deconstify_type(new_type);
98381 +
98382 + TREE_TYPE(node) = new_type;
98383 +}
98384 +
98385 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
98386 +{
98387 + tree type;
98388 + constify_info cinfo = {
98389 + .has_fptr_field = false,
98390 + .has_writable_field = false,
98391 + .has_do_const_field = false,
98392 + .has_no_const_field = false
98393 + };
98394 +
98395 + *no_add_attrs = true;
98396 + if (TREE_CODE(*node) == FUNCTION_DECL) {
98397 + error("%qE attribute does not apply to functions", name);
98398 + return NULL_TREE;
98399 + }
98400 +
98401 + if (TREE_CODE(*node) == PARM_DECL) {
98402 + error("%qE attribute does not apply to function parameters", name);
98403 + return NULL_TREE;
98404 + }
98405 +
98406 + if (TREE_CODE(*node) == VAR_DECL) {
98407 + error("%qE attribute does not apply to variables", name);
98408 + return NULL_TREE;
98409 + }
98410 +
98411 + if (TYPE_P(*node)) {
98412 + *no_add_attrs = false;
98413 + type = *node;
98414 + } else {
98415 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
98416 + type = TREE_TYPE(*node);
98417 + }
98418 +
98419 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
98420 + error("%qE attribute applies to struct and union types only", name);
98421 + return NULL_TREE;
98422 + }
98423 +
98424 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
98425 + error("%qE attribute is already applied to the type", name);
98426 + return NULL_TREE;
98427 + }
98428 +
98429 + if (TYPE_P(*node)) {
98430 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
98431 + error("%qE attribute is incompatible with 'do_const'", name);
98432 + return NULL_TREE;
98433 + }
98434 +
98435 + constifiable(type, &cinfo);
98436 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
98437 + deconstify_tree(*node);
98438 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
98439 + return NULL_TREE;
98440 + }
98441 +
98442 + error("%qE attribute used on type that is not constified", name);
98443 + return NULL_TREE;
98444 +}
98445 +
98446 +static void constify_type(tree type)
98447 +{
98448 + TYPE_READONLY(type) = 1;
98449 + C_TYPE_FIELDS_READONLY(type) = 1;
98450 + TYPE_CONSTIFY_VISITED(type) = 1;
98451 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
98452 +}
98453 +
98454 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
98455 +{
98456 + *no_add_attrs = true;
98457 + if (!TYPE_P(*node)) {
98458 + error("%qE attribute applies to types only", name);
98459 + return NULL_TREE;
98460 + }
98461 +
98462 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
98463 + error("%qE attribute applies to struct and union types only", name);
98464 + return NULL_TREE;
98465 + }
98466 +
98467 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
98468 + error("%qE attribute is already applied to the type", name);
98469 + return NULL_TREE;
98470 + }
98471 +
98472 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
98473 + error("%qE attribute is incompatible with 'no_const'", name);
98474 + return NULL_TREE;
98475 + }
98476 +
98477 + *no_add_attrs = false;
98478 + return NULL_TREE;
98479 +}
98480 +
98481 +static struct attribute_spec no_const_attr = {
98482 + .name = "no_const",
98483 + .min_length = 0,
98484 + .max_length = 0,
98485 + .decl_required = false,
98486 + .type_required = false,
98487 + .function_type_required = false,
98488 + .handler = handle_no_const_attribute,
98489 +#if BUILDING_GCC_VERSION >= 4007
98490 + .affects_type_identity = true
98491 +#endif
98492 +};
98493 +
98494 +static struct attribute_spec do_const_attr = {
98495 + .name = "do_const",
98496 + .min_length = 0,
98497 + .max_length = 0,
98498 + .decl_required = false,
98499 + .type_required = false,
98500 + .function_type_required = false,
98501 + .handler = handle_do_const_attribute,
98502 +#if BUILDING_GCC_VERSION >= 4007
98503 + .affects_type_identity = true
98504 +#endif
98505 +};
98506 +
98507 +static void register_attributes(void *event_data, void *data)
98508 +{
98509 + register_attribute(&no_const_attr);
98510 + register_attribute(&do_const_attr);
98511 +}
98512 +
98513 +static void finish_type(void *event_data, void *data)
98514 +{
98515 + tree type = (tree)event_data;
98516 + constify_info cinfo = {
98517 + .has_fptr_field = false,
98518 + .has_writable_field = false,
98519 + .has_do_const_field = false,
98520 + .has_no_const_field = false
98521 + };
98522 +
98523 + if (type == NULL_TREE || type == error_mark_node)
98524 + return;
98525 +
98526 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
98527 + return;
98528 +
98529 + constifiable(type, &cinfo);
98530 +
98531 + if (TYPE_READONLY(type) && C_TYPE_FIELDS_READONLY(type)) {
98532 + if (!lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
98533 + return;
98534 + if (cinfo.has_writable_field)
98535 + return;
98536 + error("'do_const' attribute used on type that is%sconstified", cinfo.has_fptr_field ? " " : " not ");
98537 + return;
98538 + }
98539 +
98540 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
98541 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
98542 + deconstify_type(type);
98543 + TYPE_CONSTIFY_VISITED(type) = 1;
98544 + } else
98545 + error("'no_const' attribute used on type that is not constified");
98546 + return;
98547 + }
98548 +
98549 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
98550 + constify_type(type);
98551 + return;
98552 + }
98553 +
98554 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
98555 + constify_type(type);
98556 + return;
98557 + }
98558 +
98559 + deconstify_type(type);
98560 + TYPE_CONSTIFY_VISITED(type) = 1;
98561 +}
98562 +
98563 +static void check_global_variables(void)
98564 +{
98565 + struct varpool_node *node;
98566 +
98567 +#if BUILDING_GCC_VERSION <= 4007
98568 + for (node = varpool_nodes; node; node = node->next) {
98569 + tree var = node->decl;
98570 +#else
98571 + FOR_EACH_VARIABLE(node) {
98572 + tree var = node->symbol.decl;
98573 +#endif
98574 + tree type = TREE_TYPE(var);
98575 +
98576 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
98577 + continue;
98578 +
98579 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
98580 + continue;
98581 +
98582 + if (!TYPE_CONSTIFY_VISITED(type))
98583 + continue;
98584 +
98585 + if (DECL_EXTERNAL(var))
98586 + continue;
98587 +
98588 + if (DECL_INITIAL(var))
98589 + continue;
98590 +
98591 + // this works around a gcc bug/feature where uninitialized globals
98592 + // are moved into the .bss section regardless of any constification
98593 + DECL_INITIAL(var) = build_constructor(type, NULL);
98594 +// inform(DECL_SOURCE_LOCATION(var), "constified variable %qE moved into .rodata", var);
98595 + }
98596 +}
98597 +
98598 +static unsigned int check_local_variables(void)
98599 +{
98600 + unsigned int ret = 0;
98601 + tree var;
98602 +
98603 +#if BUILDING_GCC_VERSION == 4005
98604 + tree vars;
98605 +#else
98606 + unsigned int i;
98607 +#endif
98608 +
98609 +#if BUILDING_GCC_VERSION == 4005
98610 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
98611 + var = TREE_VALUE(vars);
98612 +#else
98613 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
98614 +#endif
98615 + tree type = TREE_TYPE(var);
98616 +
98617 + gcc_assert(DECL_P(var));
98618 + if (is_global_var(var))
98619 + continue;
98620 +
98621 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
98622 + continue;
98623 +
98624 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
98625 + continue;
98626 +
98627 + if (!TYPE_CONSTIFY_VISITED(type))
98628 + continue;
98629 +
98630 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
98631 + ret = 1;
98632 + }
98633 + return ret;
98634 +}
98635 +
98636 +static unsigned int check_variables(void)
98637 +{
98638 + check_global_variables();
98639 + return check_local_variables();
98640 +}
98641 +
98642 + unsigned int ret = 0;
98643 +static struct gimple_opt_pass pass_local_variable = {
98644 + {
98645 + .type = GIMPLE_PASS,
98646 + .name = "check_variables",
98647 +#if BUILDING_GCC_VERSION >= 4008
98648 + .optinfo_flags = OPTGROUP_NONE,
98649 +#endif
98650 + .gate = NULL,
98651 + .execute = check_variables,
98652 + .sub = NULL,
98653 + .next = NULL,
98654 + .static_pass_number = 0,
98655 + .tv_id = TV_NONE,
98656 + .properties_required = 0,
98657 + .properties_provided = 0,
98658 + .properties_destroyed = 0,
98659 + .todo_flags_start = 0,
98660 + .todo_flags_finish = 0
98661 + }
98662 +};
98663 +
98664 +static struct {
98665 + const char *name;
98666 + const char *asm_op;
98667 +} sections[] = {
98668 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
98669 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
98670 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
98671 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
98672 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
98673 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
98674 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
98675 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
98676 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
98677 +};
98678 +
98679 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
98680 +
98681 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
98682 +{
98683 + size_t i;
98684 +
98685 + for (i = 0; i < ARRAY_SIZE(sections); i++)
98686 + if (!strcmp(sections[i].name, name))
98687 + return 0;
98688 + return old_section_type_flags(decl, name, reloc);
98689 +}
98690 +
98691 +static void constify_start_unit(void *gcc_data, void *user_data)
98692 +{
98693 +// size_t i;
98694 +
98695 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
98696 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
98697 +// sections[i].section = get_section(sections[i].name, 0, NULL);
98698 +
98699 + old_section_type_flags = targetm.section_type_flags;
98700 + targetm.section_type_flags = constify_section_type_flags;
98701 +}
98702 +
98703 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
98704 +{
98705 + const char * const plugin_name = plugin_info->base_name;
98706 + const int argc = plugin_info->argc;
98707 + const struct plugin_argument * const argv = plugin_info->argv;
98708 + int i;
98709 + bool constify = true;
98710 +
98711 + struct register_pass_info local_variable_pass_info = {
98712 + .pass = &pass_local_variable.pass,
98713 + .reference_pass_name = "ssa",
98714 + .ref_pass_instance_number = 1,
98715 + .pos_op = PASS_POS_INSERT_BEFORE
98716 + };
98717 +
98718 + if (!plugin_default_version_check(version, &gcc_version)) {
98719 + error(G_("incompatible gcc/plugin versions"));
98720 + return 1;
98721 + }
98722 +
98723 + for (i = 0; i < argc; ++i) {
98724 + if (!(strcmp(argv[i].key, "no-constify"))) {
98725 + constify = false;
98726 + continue;
98727 + }
98728 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
98729 + }
98730 +
98731 + if (strcmp(lang_hooks.name, "GNU C")) {
98732 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
98733 + constify = false;
98734 + }
98735 +
98736 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
98737 + if (constify) {
98738 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
98739 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
98740 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
98741 + }
98742 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
98743 +
98744 + return 0;
98745 +}
98746 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
98747 new file mode 100644
98748 index 0000000..e518932
98749 --- /dev/null
98750 +++ b/tools/gcc/generate_size_overflow_hash.sh
98751 @@ -0,0 +1,94 @@
98752 +#!/bin/bash
98753 +
98754 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
98755 +
98756 +header1="size_overflow_hash.h"
98757 +database="size_overflow_hash.data"
98758 +n=65536
98759 +
98760 +usage() {
98761 +cat <<EOF
98762 +usage: $0 options
98763 +OPTIONS:
98764 + -h|--help help
98765 + -o header file
98766 + -d database file
98767 + -n hash array size
98768 +EOF
98769 + return 0
98770 +}
98771 +
98772 +while true
98773 +do
98774 + case "$1" in
98775 + -h|--help) usage && exit 0;;
98776 + -n) n=$2; shift 2;;
98777 + -o) header1="$2"; shift 2;;
98778 + -d) database="$2"; shift 2;;
98779 + --) shift 1; break ;;
98780 + *) break ;;
98781 + esac
98782 +done
98783 +
98784 +create_defines() {
98785 + for i in `seq 0 31`
98786 + do
98787 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
98788 + done
98789 + echo >> "$header1"
98790 +}
98791 +
98792 +create_structs() {
98793 + rm -f "$header1"
98794 +
98795 + create_defines
98796 +
98797 + cat "$database" | while read data
98798 + do
98799 + data_array=($data)
98800 + struct_hash_name="${data_array[0]}"
98801 + funcn="${data_array[1]}"
98802 + params="${data_array[2]}"
98803 + next="${data_array[4]}"
98804 +
98805 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
98806 +
98807 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
98808 + echo -en "\t.param\t= " >> "$header1"
98809 + line=
98810 + for param_num in ${params//-/ };
98811 + do
98812 + line="${line}PARAM"$param_num"|"
98813 + done
98814 +
98815 + echo -e "${line%?},\n};\n" >> "$header1"
98816 + done
98817 +}
98818 +
98819 +create_headers() {
98820 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
98821 +}
98822 +
98823 +create_array_elements() {
98824 + index=0
98825 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
98826 + do
98827 + data_array=($data)
98828 + i="${data_array[3]}"
98829 + hash="${data_array[0]}"
98830 + while [[ $index -lt $i ]]
98831 + do
98832 + echo -e "\t["$index"]\t= NULL," >> "$header1"
98833 + index=$(($index + 1))
98834 + done
98835 + index=$(($index + 1))
98836 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
98837 + done
98838 + echo '};' >> $header1
98839 +}
98840 +
98841 +create_structs
98842 +create_headers
98843 +create_array_elements
98844 +
98845 +exit 0
98846 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
98847 new file mode 100644
98848 index 0000000..568b360
98849 --- /dev/null
98850 +++ b/tools/gcc/kallocstat_plugin.c
98851 @@ -0,0 +1,170 @@
98852 +/*
98853 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
98854 + * Licensed under the GPL v2
98855 + *
98856 + * Note: the choice of the license means that the compilation process is
98857 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
98858 + * but for the kernel it doesn't matter since it doesn't link against
98859 + * any of the gcc libraries
98860 + *
98861 + * gcc plugin to find the distribution of k*alloc sizes
98862 + *
98863 + * TODO:
98864 + *
98865 + * BUGS:
98866 + * - none known
98867 + */
98868 +#include "gcc-plugin.h"
98869 +#include "config.h"
98870 +#include "system.h"
98871 +#include "coretypes.h"
98872 +#include "tree.h"
98873 +#include "tree-pass.h"
98874 +#include "flags.h"
98875 +#include "intl.h"
98876 +#include "toplev.h"
98877 +#include "plugin.h"
98878 +//#include "expr.h" where are you...
98879 +#include "diagnostic.h"
98880 +#include "plugin-version.h"
98881 +#include "tm.h"
98882 +#include "function.h"
98883 +#include "basic-block.h"
98884 +#include "gimple.h"
98885 +#include "rtl.h"
98886 +#include "emit-rtl.h"
98887 +
98888 +extern void print_gimple_stmt(FILE *, gimple, int, int);
98889 +
98890 +int plugin_is_GPL_compatible;
98891 +
98892 +static const char * const kalloc_functions[] = {
98893 + "__kmalloc",
98894 + "kmalloc",
98895 + "kmalloc_large",
98896 + "kmalloc_node",
98897 + "kmalloc_order",
98898 + "kmalloc_order_trace",
98899 + "kmalloc_slab",
98900 + "kzalloc",
98901 + "kzalloc_node",
98902 +};
98903 +
98904 +static struct plugin_info kallocstat_plugin_info = {
98905 + .version = "201302112000",
98906 +};
98907 +
98908 +static unsigned int execute_kallocstat(void);
98909 +
98910 +static struct gimple_opt_pass kallocstat_pass = {
98911 + .pass = {
98912 + .type = GIMPLE_PASS,
98913 + .name = "kallocstat",
98914 +#if BUILDING_GCC_VERSION >= 4008
98915 + .optinfo_flags = OPTGROUP_NONE,
98916 +#endif
98917 + .gate = NULL,
98918 + .execute = execute_kallocstat,
98919 + .sub = NULL,
98920 + .next = NULL,
98921 + .static_pass_number = 0,
98922 + .tv_id = TV_NONE,
98923 + .properties_required = 0,
98924 + .properties_provided = 0,
98925 + .properties_destroyed = 0,
98926 + .todo_flags_start = 0,
98927 + .todo_flags_finish = 0
98928 + }
98929 +};
98930 +
98931 +static bool is_kalloc(const char *fnname)
98932 +{
98933 + size_t i;
98934 +
98935 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
98936 + if (!strcmp(fnname, kalloc_functions[i]))
98937 + return true;
98938 + return false;
98939 +}
98940 +
98941 +static unsigned int execute_kallocstat(void)
98942 +{
98943 + basic_block bb;
98944 +
98945 + // 1. loop through BBs and GIMPLE statements
98946 + FOR_EACH_BB(bb) {
98947 + gimple_stmt_iterator gsi;
98948 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
98949 + // gimple match:
98950 + tree fndecl, size;
98951 + gimple call_stmt;
98952 + const char *fnname;
98953 +
98954 + // is it a call
98955 + call_stmt = gsi_stmt(gsi);
98956 + if (!is_gimple_call(call_stmt))
98957 + continue;
98958 + fndecl = gimple_call_fndecl(call_stmt);
98959 + if (fndecl == NULL_TREE)
98960 + continue;
98961 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
98962 + continue;
98963 +
98964 + // is it a call to k*alloc
98965 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
98966 + if (!is_kalloc(fnname))
98967 + continue;
98968 +
98969 + // is the size arg the result of a simple const assignment
98970 + size = gimple_call_arg(call_stmt, 0);
98971 + while (true) {
98972 + gimple def_stmt;
98973 + expanded_location xloc;
98974 + size_t size_val;
98975 +
98976 + if (TREE_CODE(size) != SSA_NAME)
98977 + break;
98978 + def_stmt = SSA_NAME_DEF_STMT(size);
98979 + if (!def_stmt || !is_gimple_assign(def_stmt))
98980 + break;
98981 + if (gimple_num_ops(def_stmt) != 2)
98982 + break;
98983 + size = gimple_assign_rhs1(def_stmt);
98984 + if (!TREE_CONSTANT(size))
98985 + continue;
98986 + xloc = expand_location(gimple_location(def_stmt));
98987 + if (!xloc.file)
98988 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
98989 + size_val = TREE_INT_CST_LOW(size);
98990 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
98991 + break;
98992 + }
98993 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
98994 +//debug_tree(gimple_call_fn(call_stmt));
98995 +//print_node(stderr, "pax", fndecl, 4);
98996 + }
98997 + }
98998 +
98999 + return 0;
99000 +}
99001 +
99002 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
99003 +{
99004 + const char * const plugin_name = plugin_info->base_name;
99005 + struct register_pass_info kallocstat_pass_info = {
99006 + .pass = &kallocstat_pass.pass,
99007 + .reference_pass_name = "ssa",
99008 + .ref_pass_instance_number = 1,
99009 + .pos_op = PASS_POS_INSERT_AFTER
99010 + };
99011 +
99012 + if (!plugin_default_version_check(version, &gcc_version)) {
99013 + error(G_("incompatible gcc/plugin versions"));
99014 + return 1;
99015 + }
99016 +
99017 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
99018 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
99019 +
99020 + return 0;
99021 +}
99022 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
99023 new file mode 100644
99024 index 0000000..0408e06
99025 --- /dev/null
99026 +++ b/tools/gcc/kernexec_plugin.c
99027 @@ -0,0 +1,465 @@
99028 +/*
99029 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
99030 + * Licensed under the GPL v2
99031 + *
99032 + * Note: the choice of the license means that the compilation process is
99033 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
99034 + * but for the kernel it doesn't matter since it doesn't link against
99035 + * any of the gcc libraries
99036 + *
99037 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
99038 + *
99039 + * TODO:
99040 + *
99041 + * BUGS:
99042 + * - none known
99043 + */
99044 +#include "gcc-plugin.h"
99045 +#include "config.h"
99046 +#include "system.h"
99047 +#include "coretypes.h"
99048 +#include "tree.h"
99049 +#include "tree-pass.h"
99050 +#include "flags.h"
99051 +#include "intl.h"
99052 +#include "toplev.h"
99053 +#include "plugin.h"
99054 +//#include "expr.h" where are you...
99055 +#include "diagnostic.h"
99056 +#include "plugin-version.h"
99057 +#include "tm.h"
99058 +#include "function.h"
99059 +#include "basic-block.h"
99060 +#include "gimple.h"
99061 +#include "rtl.h"
99062 +#include "emit-rtl.h"
99063 +#include "tree-flow.h"
99064 +
99065 +extern void print_gimple_stmt(FILE *, gimple, int, int);
99066 +extern rtx emit_move_insn(rtx x, rtx y);
99067 +
99068 +#if BUILDING_GCC_VERSION <= 4006
99069 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
99070 +#endif
99071 +
99072 +#if BUILDING_GCC_VERSION >= 4008
99073 +#define TODO_dump_func 0
99074 +#endif
99075 +
99076 +int plugin_is_GPL_compatible;
99077 +
99078 +static struct plugin_info kernexec_plugin_info = {
99079 + .version = "201302112000",
99080 + .help = "method=[bts|or]\tinstrumentation method\n"
99081 +};
99082 +
99083 +static unsigned int execute_kernexec_reload(void);
99084 +static unsigned int execute_kernexec_fptr(void);
99085 +static unsigned int execute_kernexec_retaddr(void);
99086 +static bool kernexec_cmodel_check(void);
99087 +
99088 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
99089 +static void (*kernexec_instrument_retaddr)(rtx);
99090 +
99091 +static struct gimple_opt_pass kernexec_reload_pass = {
99092 + .pass = {
99093 + .type = GIMPLE_PASS,
99094 + .name = "kernexec_reload",
99095 +#if BUILDING_GCC_VERSION >= 4008
99096 + .optinfo_flags = OPTGROUP_NONE,
99097 +#endif
99098 + .gate = kernexec_cmodel_check,
99099 + .execute = execute_kernexec_reload,
99100 + .sub = NULL,
99101 + .next = NULL,
99102 + .static_pass_number = 0,
99103 + .tv_id = TV_NONE,
99104 + .properties_required = 0,
99105 + .properties_provided = 0,
99106 + .properties_destroyed = 0,
99107 + .todo_flags_start = 0,
99108 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
99109 + }
99110 +};
99111 +
99112 +static struct gimple_opt_pass kernexec_fptr_pass = {
99113 + .pass = {
99114 + .type = GIMPLE_PASS,
99115 + .name = "kernexec_fptr",
99116 +#if BUILDING_GCC_VERSION >= 4008
99117 + .optinfo_flags = OPTGROUP_NONE,
99118 +#endif
99119 + .gate = kernexec_cmodel_check,
99120 + .execute = execute_kernexec_fptr,
99121 + .sub = NULL,
99122 + .next = NULL,
99123 + .static_pass_number = 0,
99124 + .tv_id = TV_NONE,
99125 + .properties_required = 0,
99126 + .properties_provided = 0,
99127 + .properties_destroyed = 0,
99128 + .todo_flags_start = 0,
99129 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
99130 + }
99131 +};
99132 +
99133 +static struct rtl_opt_pass kernexec_retaddr_pass = {
99134 + .pass = {
99135 + .type = RTL_PASS,
99136 + .name = "kernexec_retaddr",
99137 +#if BUILDING_GCC_VERSION >= 4008
99138 + .optinfo_flags = OPTGROUP_NONE,
99139 +#endif
99140 + .gate = kernexec_cmodel_check,
99141 + .execute = execute_kernexec_retaddr,
99142 + .sub = NULL,
99143 + .next = NULL,
99144 + .static_pass_number = 0,
99145 + .tv_id = TV_NONE,
99146 + .properties_required = 0,
99147 + .properties_provided = 0,
99148 + .properties_destroyed = 0,
99149 + .todo_flags_start = 0,
99150 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
99151 + }
99152 +};
99153 +
99154 +static bool kernexec_cmodel_check(void)
99155 +{
99156 + tree section;
99157 +
99158 + if (ix86_cmodel != CM_KERNEL)
99159 + return false;
99160 +
99161 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
99162 + if (!section || !TREE_VALUE(section))
99163 + return true;
99164 +
99165 + section = TREE_VALUE(TREE_VALUE(section));
99166 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
99167 + return true;
99168 +
99169 + return false;
99170 +}
99171 +
99172 +/*
99173 + * add special KERNEXEC instrumentation: reload %r10 after it has been clobbered
99174 + */
99175 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
99176 +{
99177 + gimple asm_movabs_stmt;
99178 +
99179 + // build asm volatile("movabs $0x8000000000000000, %%r10\n\t" : : : );
99180 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r10\n\t", NULL, NULL, NULL, NULL);
99181 + gimple_asm_set_volatile(asm_movabs_stmt, true);
99182 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
99183 + update_stmt(asm_movabs_stmt);
99184 +}
99185 +
99186 +/*
99187 + * find all asm() stmts that clobber r10 and add a reload of r10
99188 + */
99189 +static unsigned int execute_kernexec_reload(void)
99190 +{
99191 + basic_block bb;
99192 +
99193 + // 1. loop through BBs and GIMPLE statements
99194 + FOR_EACH_BB(bb) {
99195 + gimple_stmt_iterator gsi;
99196 +
99197 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
99198 + // gimple match: __asm__ ("" : : : "r10");
99199 + gimple asm_stmt;
99200 + size_t nclobbers;
99201 +
99202 + // is it an asm ...
99203 + asm_stmt = gsi_stmt(gsi);
99204 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
99205 + continue;
99206 +
99207 + // ... clobbering r10
99208 + nclobbers = gimple_asm_nclobbers(asm_stmt);
99209 + while (nclobbers--) {
99210 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
99211 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r10"))
99212 + continue;
99213 + kernexec_reload_fptr_mask(&gsi);
99214 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
99215 + break;
99216 + }
99217 + }
99218 + }
99219 +
99220 + return 0;
99221 +}
99222 +
99223 +/*
99224 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
99225 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
99226 + */
99227 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
99228 +{
99229 + gimple assign_intptr, assign_new_fptr, call_stmt;
99230 + tree intptr, old_fptr, new_fptr, kernexec_mask;
99231 +
99232 + call_stmt = gsi_stmt(*gsi);
99233 + old_fptr = gimple_call_fn(call_stmt);
99234 +
99235 + // create temporary unsigned long variable used for bitops and cast fptr to it
99236 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
99237 +#if BUILDING_GCC_VERSION <= 4007
99238 + add_referenced_var(intptr);
99239 + mark_sym_for_renaming(intptr);
99240 +#endif
99241 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
99242 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
99243 + update_stmt(assign_intptr);
99244 +
99245 + // apply logical or to temporary unsigned long and bitmask
99246 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
99247 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
99248 + assign_intptr = gimple_build_assign(intptr, fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask));
99249 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
99250 + update_stmt(assign_intptr);
99251 +
99252 + // cast temporary unsigned long back to a temporary fptr variable
99253 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
99254 +#if BUILDING_GCC_VERSION <= 4007
99255 + add_referenced_var(new_fptr);
99256 + mark_sym_for_renaming(new_fptr);
99257 +#endif
99258 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
99259 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
99260 + update_stmt(assign_new_fptr);
99261 +
99262 + // replace call stmt fn with the new fptr
99263 + gimple_call_set_fn(call_stmt, new_fptr);
99264 + update_stmt(call_stmt);
99265 +}
99266 +
99267 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
99268 +{
99269 + gimple asm_or_stmt, call_stmt;
99270 + tree old_fptr, new_fptr, input, output;
99271 +#if BUILDING_GCC_VERSION <= 4007
99272 + VEC(tree, gc) *inputs = NULL;
99273 + VEC(tree, gc) *outputs = NULL;
99274 +#else
99275 + vec<tree, va_gc> *inputs = NULL;
99276 + vec<tree, va_gc> *outputs = NULL;
99277 +#endif
99278 +
99279 + call_stmt = gsi_stmt(*gsi);
99280 + old_fptr = gimple_call_fn(call_stmt);
99281 +
99282 + // create temporary fptr variable
99283 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
99284 +#if BUILDING_GCC_VERSION <= 4007
99285 + add_referenced_var(new_fptr);
99286 + mark_sym_for_renaming(new_fptr);
99287 +#endif
99288 +
99289 + // build asm volatile("orq %%r10, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
99290 + input = build_tree_list(NULL_TREE, build_string(2, "0"));
99291 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
99292 + output = build_tree_list(NULL_TREE, build_string(3, "=r"));
99293 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
99294 +#if BUILDING_GCC_VERSION <= 4007
99295 + VEC_safe_push(tree, gc, inputs, input);
99296 + VEC_safe_push(tree, gc, outputs, output);
99297 +#else
99298 + vec_safe_push(inputs, input);
99299 + vec_safe_push(outputs, output);
99300 +#endif
99301 + asm_or_stmt = gimple_build_asm_vec("orq %%r10, %0\n\t", inputs, outputs, NULL, NULL);
99302 + gimple_asm_set_volatile(asm_or_stmt, true);
99303 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
99304 + update_stmt(asm_or_stmt);
99305 +
99306 + // replace call stmt fn with the new fptr
99307 + gimple_call_set_fn(call_stmt, new_fptr);
99308 + update_stmt(call_stmt);
99309 +}
99310 +
99311 +/*
99312 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
99313 + */
99314 +static unsigned int execute_kernexec_fptr(void)
99315 +{
99316 + basic_block bb;
99317 +
99318 + // 1. loop through BBs and GIMPLE statements
99319 + FOR_EACH_BB(bb) {
99320 + gimple_stmt_iterator gsi;
99321 +
99322 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
99323 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
99324 + tree fn;
99325 + gimple call_stmt;
99326 +
99327 + // is it a call ...
99328 + call_stmt = gsi_stmt(gsi);
99329 + if (!is_gimple_call(call_stmt))
99330 + continue;
99331 + fn = gimple_call_fn(call_stmt);
99332 + if (TREE_CODE(fn) == ADDR_EXPR)
99333 + continue;
99334 + if (TREE_CODE(fn) != SSA_NAME)
99335 + gcc_unreachable();
99336 +
99337 + // ... through a function pointer
99338 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
99339 + fn = SSA_NAME_VAR(fn);
99340 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
99341 + debug_tree(fn);
99342 + gcc_unreachable();
99343 + }
99344 + }
99345 + fn = TREE_TYPE(fn);
99346 + if (TREE_CODE(fn) != POINTER_TYPE)
99347 + continue;
99348 + fn = TREE_TYPE(fn);
99349 + if (TREE_CODE(fn) != FUNCTION_TYPE)
99350 + continue;
99351 +
99352 + kernexec_instrument_fptr(&gsi);
99353 +
99354 +//debug_tree(gimple_call_fn(call_stmt));
99355 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
99356 + }
99357 + }
99358 +
99359 + return 0;
99360 +}
99361 +
99362 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
99363 +static void kernexec_instrument_retaddr_bts(rtx insn)
99364 +{
99365 + rtx btsq;
99366 + rtvec argvec, constraintvec, labelvec;
99367 + int line;
99368 +
99369 + // create asm volatile("btsq $63,(%%rsp)":::)
99370 + argvec = rtvec_alloc(0);
99371 + constraintvec = rtvec_alloc(0);
99372 + labelvec = rtvec_alloc(0);
99373 + line = expand_location(RTL_LOCATION(insn)).line;
99374 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
99375 + MEM_VOLATILE_P(btsq) = 1;
99376 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
99377 + emit_insn_before(btsq, insn);
99378 +}
99379 +
99380 +// add special KERNEXEC instrumentation: orq %r10,(%rsp) just before retn
99381 +static void kernexec_instrument_retaddr_or(rtx insn)
99382 +{
99383 + rtx orq;
99384 + rtvec argvec, constraintvec, labelvec;
99385 + int line;
99386 +
99387 + // create asm volatile("orq %%r10,(%%rsp)":::)
99388 + argvec = rtvec_alloc(0);
99389 + constraintvec = rtvec_alloc(0);
99390 + labelvec = rtvec_alloc(0);
99391 + line = expand_location(RTL_LOCATION(insn)).line;
99392 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r10,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
99393 + MEM_VOLATILE_P(orq) = 1;
99394 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
99395 + emit_insn_before(orq, insn);
99396 +}
99397 +
99398 +/*
99399 + * find all asm level function returns and forcibly set the highest bit of the return address
99400 + */
99401 +static unsigned int execute_kernexec_retaddr(void)
99402 +{
99403 + rtx insn;
99404 +
99405 + // 1. find function returns
99406 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
99407 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
99408 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
99409 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
99410 + rtx body;
99411 +
99412 + // is it a retn
99413 + if (!JUMP_P(insn))
99414 + continue;
99415 + body = PATTERN(insn);
99416 + if (GET_CODE(body) == PARALLEL)
99417 + body = XVECEXP(body, 0, 0);
99418 + if (!ANY_RETURN_P(body))
99419 + continue;
99420 + kernexec_instrument_retaddr(insn);
99421 + }
99422 +
99423 +// print_simple_rtl(stderr, get_insns());
99424 +// print_rtl(stderr, get_insns());
99425 +
99426 + return 0;
99427 +}
99428 +
99429 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
99430 +{
99431 + const char * const plugin_name = plugin_info->base_name;
99432 + const int argc = plugin_info->argc;
99433 + const struct plugin_argument * const argv = plugin_info->argv;
99434 + int i;
99435 + struct register_pass_info kernexec_reload_pass_info = {
99436 + .pass = &kernexec_reload_pass.pass,
99437 + .reference_pass_name = "ssa",
99438 + .ref_pass_instance_number = 1,
99439 + .pos_op = PASS_POS_INSERT_AFTER
99440 + };
99441 + struct register_pass_info kernexec_fptr_pass_info = {
99442 + .pass = &kernexec_fptr_pass.pass,
99443 + .reference_pass_name = "ssa",
99444 + .ref_pass_instance_number = 1,
99445 + .pos_op = PASS_POS_INSERT_AFTER
99446 + };
99447 + struct register_pass_info kernexec_retaddr_pass_info = {
99448 + .pass = &kernexec_retaddr_pass.pass,
99449 + .reference_pass_name = "pro_and_epilogue",
99450 + .ref_pass_instance_number = 1,
99451 + .pos_op = PASS_POS_INSERT_AFTER
99452 + };
99453 +
99454 + if (!plugin_default_version_check(version, &gcc_version)) {
99455 + error(G_("incompatible gcc/plugin versions"));
99456 + return 1;
99457 + }
99458 +
99459 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
99460 +
99461 + if (TARGET_64BIT == 0)
99462 + return 0;
99463 +
99464 + for (i = 0; i < argc; ++i) {
99465 + if (!strcmp(argv[i].key, "method")) {
99466 + if (!argv[i].value) {
99467 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
99468 + continue;
99469 + }
99470 + if (!strcmp(argv[i].value, "bts")) {
99471 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
99472 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
99473 + } else if (!strcmp(argv[i].value, "or")) {
99474 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
99475 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
99476 + fix_register("r10", 1, 1);
99477 + } else
99478 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
99479 + continue;
99480 + }
99481 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
99482 + }
99483 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
99484 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
99485 +
99486 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
99487 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
99488 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
99489 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
99490 +
99491 + return 0;
99492 +}
99493 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
99494 new file mode 100644
99495 index 0000000..b5395ba
99496 --- /dev/null
99497 +++ b/tools/gcc/latent_entropy_plugin.c
99498 @@ -0,0 +1,327 @@
99499 +/*
99500 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
99501 + * Licensed under the GPL v2
99502 + *
99503 + * Note: the choice of the license means that the compilation process is
99504 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
99505 + * but for the kernel it doesn't matter since it doesn't link against
99506 + * any of the gcc libraries
99507 + *
99508 + * gcc plugin to help generate a little bit of entropy from program state,
99509 + * used during boot in the kernel
99510 + *
99511 + * TODO:
99512 + * - add ipa pass to identify not explicitly marked candidate functions
99513 + * - mix in more program state (function arguments/return values, loop variables, etc)
99514 + * - more instrumentation control via attribute parameters
99515 + *
99516 + * BUGS:
99517 + * - LTO needs -flto-partition=none for now
99518 + */
99519 +#include "gcc-plugin.h"
99520 +#include "config.h"
99521 +#include "system.h"
99522 +#include "coretypes.h"
99523 +#include "tree.h"
99524 +#include "tree-pass.h"
99525 +#include "flags.h"
99526 +#include "intl.h"
99527 +#include "toplev.h"
99528 +#include "plugin.h"
99529 +//#include "expr.h" where are you...
99530 +#include "diagnostic.h"
99531 +#include "plugin-version.h"
99532 +#include "tm.h"
99533 +#include "function.h"
99534 +#include "basic-block.h"
99535 +#include "gimple.h"
99536 +#include "rtl.h"
99537 +#include "emit-rtl.h"
99538 +#include "tree-flow.h"
99539 +#include "langhooks.h"
99540 +
99541 +#if BUILDING_GCC_VERSION >= 4008
99542 +#define TODO_dump_func 0
99543 +#endif
99544 +
99545 +int plugin_is_GPL_compatible;
99546 +
99547 +static tree latent_entropy_decl;
99548 +
99549 +static struct plugin_info latent_entropy_plugin_info = {
99550 + .version = "201303102320",
99551 + .help = NULL
99552 +};
99553 +
99554 +static unsigned int execute_latent_entropy(void);
99555 +static bool gate_latent_entropy(void);
99556 +
99557 +static struct gimple_opt_pass latent_entropy_pass = {
99558 + .pass = {
99559 + .type = GIMPLE_PASS,
99560 + .name = "latent_entropy",
99561 +#if BUILDING_GCC_VERSION >= 4008
99562 + .optinfo_flags = OPTGROUP_NONE,
99563 +#endif
99564 + .gate = gate_latent_entropy,
99565 + .execute = execute_latent_entropy,
99566 + .sub = NULL,
99567 + .next = NULL,
99568 + .static_pass_number = 0,
99569 + .tv_id = TV_NONE,
99570 + .properties_required = PROP_gimple_leh | PROP_cfg,
99571 + .properties_provided = 0,
99572 + .properties_destroyed = 0,
99573 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
99574 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
99575 + }
99576 +};
99577 +
99578 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
99579 +{
99580 + if (TREE_CODE(*node) != FUNCTION_DECL) {
99581 + *no_add_attrs = true;
99582 + error("%qE attribute only applies to functions", name);
99583 + }
99584 + return NULL_TREE;
99585 +}
99586 +
99587 +static struct attribute_spec latent_entropy_attr = {
99588 + .name = "latent_entropy",
99589 + .min_length = 0,
99590 + .max_length = 0,
99591 + .decl_required = true,
99592 + .type_required = false,
99593 + .function_type_required = false,
99594 + .handler = handle_latent_entropy_attribute,
99595 +#if BUILDING_GCC_VERSION >= 4007
99596 + .affects_type_identity = false
99597 +#endif
99598 +};
99599 +
99600 +static void register_attributes(void *event_data, void *data)
99601 +{
99602 + register_attribute(&latent_entropy_attr);
99603 +}
99604 +
99605 +static bool gate_latent_entropy(void)
99606 +{
99607 + tree latent_entropy_attr;
99608 +
99609 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
99610 + return latent_entropy_attr != NULL_TREE;
99611 +}
99612 +
99613 +static unsigned HOST_WIDE_INT seed;
99614 +static unsigned HOST_WIDE_INT get_random_const(void)
99615 +{
99616 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
99617 + return seed;
99618 +}
99619 +
99620 +static enum tree_code get_op(tree *rhs)
99621 +{
99622 + static enum tree_code op;
99623 + unsigned HOST_WIDE_INT random_const;
99624 +
99625 + random_const = get_random_const();
99626 +
99627 + switch (op) {
99628 + case BIT_XOR_EXPR:
99629 + op = PLUS_EXPR;
99630 + break;
99631 +
99632 + case PLUS_EXPR:
99633 + if (rhs) {
99634 + op = LROTATE_EXPR;
99635 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
99636 + break;
99637 + }
99638 +
99639 + case LROTATE_EXPR:
99640 + default:
99641 + op = BIT_XOR_EXPR;
99642 + break;
99643 + }
99644 + if (rhs)
99645 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
99646 + return op;
99647 +}
99648 +
99649 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
99650 +{
99651 + gimple_stmt_iterator gsi;
99652 + gimple assign;
99653 + tree addxorrol, rhs;
99654 + enum tree_code op;
99655 +
99656 + op = get_op(&rhs);
99657 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
99658 + assign = gimple_build_assign(local_entropy, addxorrol);
99659 +#if BUILDING_GCC_VERSION <= 4007
99660 + find_referenced_vars_in(assign);
99661 +#endif
99662 +//debug_bb(bb);
99663 + gsi = gsi_after_labels(bb);
99664 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
99665 + update_stmt(assign);
99666 +}
99667 +
99668 +static void perturb_latent_entropy(basic_block bb, tree rhs)
99669 +{
99670 + gimple_stmt_iterator gsi;
99671 + gimple assign;
99672 + tree addxorrol, temp;
99673 +
99674 + // 1. create temporary copy of latent_entropy
99675 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
99676 +#if BUILDING_GCC_VERSION <= 4007
99677 + add_referenced_var(temp);
99678 + mark_sym_for_renaming(temp);
99679 +#endif
99680 +
99681 + // 2. read...
99682 + assign = gimple_build_assign(temp, latent_entropy_decl);
99683 +#if BUILDING_GCC_VERSION <= 4007
99684 + find_referenced_vars_in(assign);
99685 +#endif
99686 + gsi = gsi_after_labels(bb);
99687 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
99688 + update_stmt(assign);
99689 +
99690 + // 3. ...modify...
99691 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
99692 + assign = gimple_build_assign(temp, addxorrol);
99693 +#if BUILDING_GCC_VERSION <= 4007
99694 + find_referenced_vars_in(assign);
99695 +#endif
99696 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
99697 + update_stmt(assign);
99698 +
99699 + // 4. ...write latent_entropy
99700 + assign = gimple_build_assign(latent_entropy_decl, temp);
99701 +#if BUILDING_GCC_VERSION <= 4007
99702 + find_referenced_vars_in(assign);
99703 +#endif
99704 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
99705 + update_stmt(assign);
99706 +}
99707 +
99708 +static unsigned int execute_latent_entropy(void)
99709 +{
99710 + basic_block bb;
99711 + gimple assign;
99712 + gimple_stmt_iterator gsi;
99713 + tree local_entropy;
99714 +
99715 + if (!latent_entropy_decl) {
99716 + struct varpool_node *node;
99717 +
99718 +#if BUILDING_GCC_VERSION <= 4007
99719 + for (node = varpool_nodes; node; node = node->next) {
99720 + tree var = node->decl;
99721 +#else
99722 + FOR_EACH_VARIABLE(node) {
99723 + tree var = node->symbol.decl;
99724 +#endif
99725 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
99726 + continue;
99727 + latent_entropy_decl = var;
99728 +// debug_tree(var);
99729 + break;
99730 + }
99731 + if (!latent_entropy_decl) {
99732 +// debug_tree(current_function_decl);
99733 + return 0;
99734 + }
99735 + }
99736 +
99737 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
99738 +
99739 + // 1. create local entropy variable
99740 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
99741 +#if BUILDING_GCC_VERSION <= 4007
99742 + add_referenced_var(local_entropy);
99743 + mark_sym_for_renaming(local_entropy);
99744 +#endif
99745 +
99746 + // 2. initialize local entropy variable
99747 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
99748 + if (dom_info_available_p(CDI_DOMINATORS))
99749 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
99750 + gsi = gsi_start_bb(bb);
99751 +
99752 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
99753 +// gimple_set_location(assign, loc);
99754 +#if BUILDING_GCC_VERSION <= 4007
99755 + find_referenced_vars_in(assign);
99756 +#endif
99757 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
99758 + update_stmt(assign);
99759 + bb = bb->next_bb;
99760 +
99761 + // 3. instrument each BB with an operation on the local entropy variable
99762 + while (bb != EXIT_BLOCK_PTR) {
99763 + perturb_local_entropy(bb, local_entropy);
99764 + bb = bb->next_bb;
99765 + };
99766 +
99767 + // 4. mix local entropy into the global entropy variable
99768 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
99769 + return 0;
99770 +}
99771 +
99772 +static void start_unit_callback(void *gcc_data, void *user_data)
99773 +{
99774 + tree latent_entropy_type;
99775 +
99776 +#if BUILDING_GCC_VERSION >= 4007
99777 + seed = get_random_seed(false);
99778 +#else
99779 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
99780 + seed *= seed;
99781 +#endif
99782 +
99783 + if (in_lto_p)
99784 + return;
99785 +
99786 + // extern volatile u64 latent_entropy
99787 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
99788 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
99789 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
99790 +
99791 + TREE_STATIC(latent_entropy_decl) = 1;
99792 + TREE_PUBLIC(latent_entropy_decl) = 1;
99793 + TREE_USED(latent_entropy_decl) = 1;
99794 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
99795 + DECL_EXTERNAL(latent_entropy_decl) = 1;
99796 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
99797 + DECL_INITIAL(latent_entropy_decl) = NULL;
99798 + lang_hooks.decls.pushdecl(latent_entropy_decl);
99799 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
99800 +// varpool_finalize_decl(latent_entropy_decl);
99801 +// varpool_mark_needed_node(latent_entropy_decl);
99802 +}
99803 +
99804 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
99805 +{
99806 + const char * const plugin_name = plugin_info->base_name;
99807 + struct register_pass_info latent_entropy_pass_info = {
99808 + .pass = &latent_entropy_pass.pass,
99809 + .reference_pass_name = "optimized",
99810 + .ref_pass_instance_number = 1,
99811 + .pos_op = PASS_POS_INSERT_BEFORE
99812 + };
99813 +
99814 + if (!plugin_default_version_check(version, &gcc_version)) {
99815 + error(G_("incompatible gcc/plugin versions"));
99816 + return 1;
99817 + }
99818 +
99819 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
99820 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
99821 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
99822 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
99823 +
99824 + return 0;
99825 +}
99826 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
99827 new file mode 100644
99828 index 0000000..b04803b
99829 --- /dev/null
99830 +++ b/tools/gcc/size_overflow_hash.data
99831 @@ -0,0 +1,6350 @@
99832 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
99833 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
99834 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
99835 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
99836 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
99837 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
99838 +padzero_55 padzero 1 55 &sel_read_policyvers_55
99839 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
99840 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
99841 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 NULL
99842 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
99843 +load_msg_95 load_msg 2 95 NULL
99844 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
99845 +init_q_132 init_q 4 132 NULL
99846 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
99847 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
99848 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 NULL
99849 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
99850 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
99851 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
99852 +virtblk_add_req_197 virtblk_add_req 2-3 197 NULL
99853 +proc_scsi_write_proc_267 proc_scsi_write_proc 3 267 NULL
99854 +br_port_info_size_268 br_port_info_size 0 268 NULL
99855 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
99856 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
99857 +SYSC_connect_304 SYSC_connect 3 304 NULL
99858 +syslog_print_307 syslog_print 2 307 NULL
99859 +platform_device_add_data_310 platform_device_add_data 3 310 NULL
99860 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
99861 +next_node_allowed_318 next_node_allowed 1 318 NULL
99862 +compat_sys_ioctl_333 compat_sys_ioctl 3 333 NULL
99863 +btmrvl_txdnldready_read_413 btmrvl_txdnldready_read 3 413 NULL
99864 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
99865 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
99866 +_alloc_get_attr_desc_470 _alloc_get_attr_desc 2 470 NULL
99867 +dccp_manip_pkt_476 dccp_manip_pkt 4 476 NULL
99868 +nvme_trans_modesel_data_488 nvme_trans_modesel_data 4 488 NULL
99869 +pidlist_resize_496 pidlist_resize 2 496 NULL
99870 +read_vbt_r0_503 read_vbt_r0 1 503 NULL
99871 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
99872 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
99873 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0 537 NULL
99874 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
99875 +dle_count_543 dle_count 0 543 NULL
99876 +devres_alloc_551 devres_alloc 2 551 NULL
99877 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
99878 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
99879 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
99880 +compat_sys_preadv_583 compat_sys_preadv 3 583 NULL
99881 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
99882 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
99883 +fuse_request_alloc_nofs_617 fuse_request_alloc_nofs 1 617 NULL
99884 +compat_sys_shmat_620 compat_sys_shmat 3 620 NULL
99885 +isp1760_register_628 isp1760_register 1-2 628 NULL
99886 +clone_split_bio_633 clone_split_bio 6 633 NULL
99887 +ceph_osdc_new_request_635 ceph_osdc_new_request 6 635 NULL
99888 +remap_to_cache_640 remap_to_cache 3 640 NULL
99889 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 NULL
99890 +unlink_queued_645 unlink_queued 3-4 645 NULL
99891 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
99892 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
99893 +rtl8169_try_rx_copy_705 rtl8169_try_rx_copy 3 705 NULL
99894 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
99895 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
99896 +disk_max_parts_719 disk_max_parts 0 719 NULL
99897 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
99898 +dvb_video_write_754 dvb_video_write 3 754 NULL
99899 +if_writecmd_815 if_writecmd 2 815 NULL
99900 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
99901 +read_fifo_826 read_fifo 3 826 NULL
99902 +um_idi_read_850 um_idi_read 3 850 NULL
99903 +ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz_856 ieee80211_if_fmt_rc_rateidx_mcs_mask_5ghz 3 856 NULL
99904 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
99905 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
99906 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
99907 +btmrvl_hsstate_read_920 btmrvl_hsstate_read 3 920 NULL
99908 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
99909 +get_ramdisk_size_954 get_ramdisk_size 0 954 NULL
99910 +__nodes_weight_956 __nodes_weight 2-0 956 NULL
99911 +sys_msgrcv_959 sys_msgrcv 3 959 NULL
99912 +pte_prefetch_gfn_to_pfn_997 pte_prefetch_gfn_to_pfn 2 997 NULL nohasharray
99913 +hdlcdev_rx_997 hdlcdev_rx 3 997 &pte_prefetch_gfn_to_pfn_997
99914 +dm_cache_set_dirty_1016 dm_cache_set_dirty 2 1016 NULL
99915 +_do_truncate_1019 _do_truncate 2 1019 NULL
99916 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
99917 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
99918 +Read_hfc16_1070 Read_hfc16 0 1070 NULL
99919 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
99920 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
99921 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
99922 +nfs_pgarray_set_1085 nfs_pgarray_set 2 1085 NULL
99923 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
99924 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
99925 +sys_mremap_1107 sys_mremap 5-1-2 1107 NULL
99926 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
99927 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
99928 +dec_zcache_eph_zpages_1138 dec_zcache_eph_zpages 1 1138 NULL
99929 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
99930 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
99931 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
99932 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
99933 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
99934 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
99935 +ipw_packet_received_skb_1230 ipw_packet_received_skb 2 1230 NULL
99936 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
99937 +nested_get_page_1252 nested_get_page 2 1252 NULL
99938 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
99939 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
99940 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
99941 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
99942 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
99943 +wm_adsp_buf_alloc_1317 wm_adsp_buf_alloc 2 1317 NULL
99944 +compat_put_u64_1319 compat_put_u64 1 1319 NULL
99945 +ffs_1322 ffs 0 1322 NULL
99946 +qlcnic_pci_sriov_configure_1327 qlcnic_pci_sriov_configure 2 1327 NULL
99947 +carl9170_rx_stream_1334 carl9170_rx_stream 3 1334 NULL
99948 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
99949 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
99950 +io_mapping_create_wc_1354 io_mapping_create_wc 1-2 1354 NULL
99951 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
99952 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
99953 +iov_num_pages_1364 iov_num_pages 0 1364 NULL
99954 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
99955 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
99956 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
99957 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
99958 +zone_page_state_1393 zone_page_state 0 1393 NULL
99959 +file_read_actor_1401 file_read_actor 4 1401 NULL
99960 +vb2_dc_get_user_pages_1442 vb2_dc_get_user_pages 1-3 1442 NULL
99961 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
99962 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
99963 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
99964 +SYSC_syslog_1477 SYSC_syslog 3 1477 NULL
99965 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
99966 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
99967 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
99968 +__vfio_dma_map_1523 __vfio_dma_map 3 1523 NULL
99969 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
99970 +ath6kl_init_get_fwcaps_1557 ath6kl_init_get_fwcaps 3 1557 NULL
99971 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
99972 +fc_frame_alloc_1596 fc_frame_alloc 2 1596 NULL
99973 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
99974 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
99975 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
99976 +btmrvl_hsmode_read_1647 btmrvl_hsmode_read 3 1647 NULL
99977 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
99978 +mei_cl_recv_1665 mei_cl_recv 3 1665 NULL
99979 +netdev_feature_string_1667 netdev_feature_string 0 1667 NULL
99980 +compat_x25_ioctl_1674 compat_x25_ioctl 3 1674 NULL
99981 +rmap_add_1677 rmap_add 3 1677 NULL
99982 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
99983 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL
99984 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
99985 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
99986 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
99987 +compat_cdrom_generic_command_1756 compat_cdrom_generic_command 4 1756 NULL
99988 +ieee80211_new_mesh_header_1761 ieee80211_new_mesh_header 0 1761 NULL
99989 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
99990 +cosa_write_1774 cosa_write 3 1774 NULL
99991 +update_macheader_1775 update_macheader 7 1775 NULL
99992 +dec_zcache_pers_zbytes_1779 dec_zcache_pers_zbytes 1 1779 NULL
99993 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
99994 +__nodelist_scnprintf_1815 __nodelist_scnprintf 0-2-4 1815 NULL
99995 +alloc_pages_exact_1892 alloc_pages_exact 1 1892 NULL
99996 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
99997 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
99998 +SyS_add_key_1900 SyS_add_key 4 1900 NULL
99999 +isku_sysfs_write_keys_media_1910 isku_sysfs_write_keys_media 6 1910 NULL
100000 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
100001 +memblock_alloc_base_1938 memblock_alloc_base 1-2 1938 NULL
100002 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
100003 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
100004 +read_swap_header_1957 read_swap_header 0 1957 NULL
100005 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
100006 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
100007 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2-3 1992 NULL
100008 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
100009 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
100010 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
100011 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
100012 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
100013 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
100014 +BcmCopySection_2035 BcmCopySection 5 2035 NULL
100015 +devm_ioremap_nocache_2036 devm_ioremap_nocache 2-3 2036 NULL
100016 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
100017 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
100018 +subbuf_read_actor_2071 subbuf_read_actor 3 2071 NULL
100019 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
100020 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
100021 +audit_expand_2098 audit_expand 2 2098 NULL
100022 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
100023 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
100024 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
100025 +__find_xattr_2117 __find_xattr 6 2117 NULL nohasharray
100026 +enable_read_2117 enable_read 3 2117 &__find_xattr_2117
100027 +pcf50633_write_block_2124 pcf50633_write_block 2-3 2124 NULL
100028 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
100029 +lp_gpio_irq_map_2149 lp_gpio_irq_map 2 2149 NULL
100030 +mlx4_init_icm_table_2151 mlx4_init_icm_table 5-4 2151 NULL
100031 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
100032 +_ore_get_io_state_2166 _ore_get_io_state 3-4-5 2166 NULL
100033 +bio_integrity_alloc_2194 bio_integrity_alloc 3 2194 NULL
100034 +ssb_bus_ssbbus_register_2217 ssb_bus_ssbbus_register 2 2217 NULL
100035 +mei_dbgfs_read_meclients_2219 mei_dbgfs_read_meclients 3 2219 NULL nohasharray
100036 +u32_array_read_2219 u32_array_read 3 2219 &mei_dbgfs_read_meclients_2219
100037 +vhci_write_2224 vhci_write 3 2224 NULL
100038 +efx_tsoh_page_count_2225 efx_tsoh_page_count 0 2225 NULL
100039 +lowpan_get_mac_header_length_2231 lowpan_get_mac_header_length 0 2231 NULL
100040 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
100041 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
100042 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
100043 +do_update_counters_2259 do_update_counters 4 2259 NULL
100044 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
100045 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
100046 +kvm_clear_guest_page_2308 kvm_clear_guest_page 4-2 2308 NULL
100047 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
100048 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL
100049 +gart_map_page_2325 gart_map_page 3-4 2325 NULL
100050 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
100051 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
100052 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
100053 +SyS_mremap_2367 SyS_mremap 1-2-5 2367 NULL
100054 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL
100055 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
100056 +rtl_port_map_2385 rtl_port_map 1-2 2385 NULL
100057 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
100058 +SYSC_mlock_2415 SYSC_mlock 1 2415 NULL
100059 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
100060 +raid1_size_2419 raid1_size 0-2 2419 NULL
100061 +roccat_common2_send_2422 roccat_common2_send 4 2422 NULL
100062 +hfcpci_empty_fifo_2427 hfcpci_empty_fifo 4 2427 NULL
100063 +ioremap_nocache_2439 ioremap_nocache 1-2 2439 NULL
100064 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
100065 +ath6kl_usb_bmi_write_2454 ath6kl_usb_bmi_write 3 2454 NULL
100066 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
100067 +update_pmkid_2481 update_pmkid 4 2481 NULL
100068 +wiphy_new_2482 wiphy_new 2 2482 NULL
100069 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
100070 +lookup_cache_entry_2494 lookup_cache_entry 2 2494 NULL
100071 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
100072 +dm_write_2513 dm_write 3 2513 NULL
100073 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
100074 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
100075 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
100076 +i915_next_seqno_write_2572 i915_next_seqno_write 3 2572 NULL
100077 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
100078 +slot_bytes_2609 slot_bytes 0 2609 NULL
100079 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
100080 +kvm_gfn_to_hva_cache_init_2636 kvm_gfn_to_hva_cache_init 3 2636 NULL
100081 +lro_gen_skb_2644 lro_gen_skb 6 2644 NULL
100082 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
100083 +memcpy_fromiovecend_2707 memcpy_fromiovecend 3-4 2707 NULL
100084 +__xip_file_write_2733 __xip_file_write 4-3 2733 NULL
100085 +hid_report_raw_event_2762 hid_report_raw_event 4 2762 NULL
100086 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL nohasharray
100087 +bictcp_update_2771 bictcp_update 2 2771 &mon_bin_ioctl_2771
100088 +__next_cpu_2782 __next_cpu 1 2782 NULL
100089 +set_msr_hyperv_pw_2785 set_msr_hyperv_pw 3 2785 NULL
100090 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
100091 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL
100092 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
100093 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
100094 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
100095 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
100096 +mq_map_2871 mq_map 2 2871 NULL
100097 +nla_padlen_2883 nla_padlen 1 2883 NULL
100098 +cmm_write_2896 cmm_write 3 2896 NULL
100099 +alloc_page_cgroup_2919 alloc_page_cgroup 1 2919 NULL
100100 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
100101 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
100102 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
100103 +set_fast_connectable_2952 set_fast_connectable 4 2952 NULL
100104 +ppp_cp_event_2965 ppp_cp_event 6 2965 NULL
100105 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
100106 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
100107 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
100108 +depth_write_3021 depth_write 3 3021 NULL
100109 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
100110 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
100111 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 NULL
100112 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
100113 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
100114 +qp_alloc_ppn_set_3068 qp_alloc_ppn_set 2-4 3068 NULL
100115 +__blk_end_bidi_request_3070 __blk_end_bidi_request 3-4 3070 NULL
100116 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
100117 +free_coherent_3082 free_coherent 4-2 3082 NULL
100118 +clone_bio_3100 clone_bio 6 3100 NULL nohasharray
100119 +ttusb2_msg_3100 ttusb2_msg 4 3100 &clone_bio_3100
100120 +rb_alloc_3102 rb_alloc 1 3102 NULL
100121 +simple_write_to_buffer_3122 simple_write_to_buffer 5-2 3122 NULL
100122 +print_time_3132 print_time 0 3132 NULL
100123 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
100124 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
100125 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
100126 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
100127 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
100128 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
100129 +mempool_create_node_3191 mempool_create_node 1 3191 NULL
100130 +alloc_context_3194 alloc_context 1 3194 NULL
100131 +shmem_pread_slow_3198 shmem_pread_slow 3 3198 NULL
100132 +SyS_sendto_3219 SyS_sendto 6 3219 NULL
100133 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
100134 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
100135 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
100136 +key_key_read_3241 key_key_read 3 3241 NULL
100137 +number_3243 number 0 3243 NULL
100138 +check_vendor_extension_3254 check_vendor_extension 1 3254 NULL
100139 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
100140 +arvo_sysfs_write_3311 arvo_sysfs_write 6 3311 NULL
100141 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
100142 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
100143 +aac_rkt_ioremap_3333 aac_rkt_ioremap 2 3333 NULL
100144 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
100145 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
100146 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
100147 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
100148 +scnprintf_3360 scnprintf 0-2 3360 NULL
100149 +x86_emulate_instruction_3389 x86_emulate_instruction 2 3389 NULL
100150 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
100151 +send_stream_3397 send_stream 4 3397 NULL
100152 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
100153 +msix_map_region_3411 msix_map_region 3 3411 NULL
100154 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
100155 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
100156 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
100157 +SyS_msgsnd_3436 SyS_msgsnd 3 3436 NULL
100158 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
100159 +percpu_modalloc_3448 percpu_modalloc 2-3 3448 NULL
100160 +map_single_3449 map_single 0-2 3449 NULL
100161 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
100162 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 4-2-5 3464 &jffs2_acl_setxattr_3464
100163 +alloc_skb_fclone_3467 alloc_skb_fclone 1 3467 NULL
100164 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
100165 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
100166 +kvm_handle_bad_page_3503 kvm_handle_bad_page 2 3503 NULL
100167 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL nohasharray
100168 +ieee80211_wx_set_gen_ie_rsl_3521 ieee80211_wx_set_gen_ie_rsl 3 3521 &mem_tx_free_mem_blks_read_3521
100169 +SyS_readv_3539 SyS_readv 3 3539 NULL
100170 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
100171 +b43legacy_read16_3561 b43legacy_read16 0 3561 NULL
100172 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
100173 +evtchn_read_3569 evtchn_read 3 3569 NULL
100174 +vc_resize_3585 vc_resize 2-3 3585 NULL
100175 +compat_sys_semtimedop_3606 compat_sys_semtimedop 3 3606 NULL
100176 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
100177 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
100178 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
100179 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
100180 +x86_swiotlb_alloc_coherent_3649 x86_swiotlb_alloc_coherent 2 3649 NULL nohasharray
100181 +cm_copy_private_data_3649 cm_copy_private_data 2 3649 &x86_swiotlb_alloc_coherent_3649
100182 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
100183 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
100184 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 NULL nohasharray
100185 +create_irq_3703 create_irq 0 3703 &snd_m3_assp_read_3703 nohasharray
100186 +btmrvl_psmode_write_3703 btmrvl_psmode_write 3 3703 &create_irq_3703
100187 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
100188 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
100189 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
100190 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
100191 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
100192 +read_file_tx_chainmask_3829 read_file_tx_chainmask 3 3829 NULL
100193 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
100194 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
100195 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
100196 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
100197 +get_fd_set_3866 get_fd_set 1 3866 NULL
100198 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
100199 +uea_send_modem_cmd_3888 uea_send_modem_cmd 3 3888 NULL
100200 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
100201 +nvram_write_3894 nvram_write 3 3894 NULL
100202 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
100203 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
100204 +vcs_write_3910 vcs_write 3 3910 NULL
100205 +brcmf_debugfs_fws_stats_read_3947 brcmf_debugfs_fws_stats_read 3 3947 NULL
100206 +atalk_compat_ioctl_3991 atalk_compat_ioctl 3 3991 NULL
100207 +do_add_counters_3992 do_add_counters 3 3992 NULL
100208 +userspace_status_4004 userspace_status 4 4004 NULL
100209 +mei_write_4005 mei_write 3 4005 NULL nohasharray
100210 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
100211 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
100212 +mm_populate_4016 mm_populate 1 4016 NULL
100213 +blk_end_request_4024 blk_end_request 3 4024 NULL
100214 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
100215 +usbnet_write_cmd_async_4035 usbnet_write_cmd_async 7 4035 NULL
100216 +read_file_queues_4078 read_file_queues 3 4078 NULL
100217 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
100218 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
100219 +C_SYSC_rt_sigpending_4114 C_SYSC_rt_sigpending 2 4114 NULL
100220 +ntb_netdev_change_mtu_4147 ntb_netdev_change_mtu 2 4147 NULL
100221 +tm6000_read_4151 tm6000_read 3 4151 NULL
100222 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
100223 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
100224 +get_alua_req_4166 get_alua_req 3 4166 NULL
100225 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
100226 +read_file_bool_4180 read_file_bool 3 4180 NULL
100227 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
100228 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
100229 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
100230 +goldfish_audio_write_4284 goldfish_audio_write 3 4284 NULL
100231 +paging32_page_fault_4288 paging32_page_fault 2 4288 NULL
100232 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
100233 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
100234 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 3-2-5 4303 NULL
100235 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
100236 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
100237 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 3 4365 NULL
100238 +sys_setdomainname_4373 sys_setdomainname 2 4373 NULL
100239 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
100240 +access_process_vm_4412 access_process_vm 0-2-4 4412 NULL nohasharray
100241 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
100242 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
100243 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
100244 +memparse_4444 memparse 0 4444 NULL
100245 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
100246 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 0-5 4481 NULL
100247 +sys_semtimedop_4486 sys_semtimedop 3 4486 NULL
100248 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
100249 +set_link_security_4502 set_link_security 4 4502 NULL
100250 +dm_cache_remove_mapping_4513 dm_cache_remove_mapping 2 4513 NULL
100251 +__gfn_to_pfn_memslot_4530 __gfn_to_pfn_memslot 2 4530 NULL
100252 +sys_llistxattr_4532 sys_llistxattr 3 4532 NULL
100253 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
100254 +tty_register_device_4544 tty_register_device 2 4544 NULL
100255 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
100256 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
100257 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
100258 +bch_alloc_4593 bch_alloc 1 4593 NULL
100259 +__wb_force_remove_mapping_4622 __wb_force_remove_mapping 2 4622 NULL
100260 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
100261 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
100262 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
100263 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
100264 +kone_receive_4690 kone_receive 4 4690 NULL
100265 +round_pipe_size_4701 round_pipe_size 0 4701 NULL
100266 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
100267 +konepure_sysfs_read_4709 konepure_sysfs_read 6 4709 NULL
100268 +btmrvl_gpiogap_read_4718 btmrvl_gpiogap_read 3 4718 NULL
100269 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
100270 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
100271 +__find_free_cblock_4741 __find_free_cblock 2 4741 NULL
100272 +memblock_find_in_range_4759 memblock_find_in_range 3-4 4759 NULL
100273 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 NULL
100274 +create_subvol_4791 create_subvol 4 4791 NULL
100275 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
100276 +repair_io_failure_4815 repair_io_failure 4 4815 NULL
100277 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
100278 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
100279 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3 4873 NULL
100280 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
100281 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
100282 +sys_ipc_4889 sys_ipc 3 4889 NULL
100283 +sys_process_vm_writev_4928 sys_process_vm_writev 3-5 4928 NULL
100284 +ntfs_rl_insert_4931 ntfs_rl_insert 2-4 4931 NULL
100285 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
100286 +devm_kzalloc_4966 devm_kzalloc 2 4966 NULL
100287 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
100288 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
100289 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
100290 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
100291 +compat_SyS_ipc_5000 compat_SyS_ipc 3-4-5-6 5000 NULL
100292 +qla82xx_pci_mem_write_direct_5008 qla82xx_pci_mem_write_direct 2 5008 NULL
100293 +do_mincore_5018 do_mincore 0-1 5018 NULL
100294 +mtd_device_parse_register_5024 mtd_device_parse_register 5 5024 NULL
100295 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 2-3 5066 NULL
100296 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
100297 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
100298 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
100299 +kfifo_copy_from_user_5091 kfifo_copy_from_user 3 5091 &get_random_bytes_5091 nohasharray
100300 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
100301 +mpol_to_str_5093 mpol_to_str 2 5093 NULL
100302 +sound_write_5102 sound_write 3 5102 NULL
100303 +clear_dirty_5105 clear_dirty 3 5105 NULL
100304 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
100305 +compat_ptr_5159 compat_ptr 0-1 5159 NULL
100306 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
100307 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
100308 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
100309 +sfi_map_memory_5183 sfi_map_memory 1-2 5183 NULL
100310 +skb_network_header_5203 skb_network_header 0 5203 NULL
100311 +pipe_set_size_5204 pipe_set_size 2 5204 NULL
100312 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL
100313 +dwc2_hcd_urb_alloc_5217 dwc2_hcd_urb_alloc 2 5217 NULL
100314 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
100315 +ssb_ioremap_5228 ssb_ioremap 2 5228 NULL nohasharray
100316 +konepure_sysfs_write_5228 konepure_sysfs_write 6 5228 &ssb_ioremap_5228
100317 +isdn_ppp_skb_push_5236 isdn_ppp_skb_push 2 5236 NULL
100318 +do_atmif_sioc_5247 do_atmif_sioc 3 5247 NULL
100319 +gfn_to_hva_memslot_5265 gfn_to_hva_memslot 2 5265 NULL
100320 +alloc_cache_blocks_with_hash_5285 alloc_cache_blocks_with_hash 2 5285 NULL
100321 +__gfn_to_hva_memslot_5304 __gfn_to_hva_memslot 0-2 5304 NULL
100322 +sbc_get_write_same_sectors_5317 sbc_get_write_same_sectors 0 5317 NULL
100323 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
100324 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
100325 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
100326 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 3-2 5368 NULL
100327 +kvm_pin_pages_5369 kvm_pin_pages 2 5369 NULL
100328 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
100329 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
100330 +sfi_map_table_5462 sfi_map_table 1 5462 NULL
100331 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
100332 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
100333 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
100334 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
100335 +tty_write_5494 tty_write 3 5494 NULL
100336 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
100337 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
100338 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
100339 +spidev_message_5518 spidev_message 3 5518 NULL
100340 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
100341 +get_entry_msg_len_5552 get_entry_msg_len 0 5552 NULL
100342 +brcmu_pkt_buf_get_skb_5556 brcmu_pkt_buf_get_skb 1 5556 NULL
100343 +le_readq_5557 le_readq 0 5557 NULL
100344 +inw_5558 inw 0 5558 NULL
100345 +fir16_create_5574 fir16_create 3 5574 NULL
100346 +bioset_create_5580 bioset_create 1 5580 NULL
100347 +oz_ep_alloc_5587 oz_ep_alloc 2 5587 NULL
100348 +usb_dump_device_descriptor_5599 usb_dump_device_descriptor 0 5599 NULL
100349 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
100350 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
100351 +SYSC_fsetxattr_5639 SYSC_fsetxattr 4 5639 NULL
100352 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
100353 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
100354 +mthca_map_reg_5664 mthca_map_reg 2-3 5664 NULL
100355 +__videobuf_alloc_vb_5665 __videobuf_alloc_vb 1 5665 NULL
100356 +wb_clear_dirty_5684 wb_clear_dirty 2 5684 NULL
100357 +get_arg_5694 get_arg 3 5694 NULL
100358 +subbuf_read_actor_5708 subbuf_read_actor 3 5708 NULL
100359 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
100360 +reexecute_instruction_5733 reexecute_instruction 2 5733 NULL
100361 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
100362 +ubi_cdev_compat_ioctl_5746 ubi_cdev_compat_ioctl 3 5746 NULL
100363 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL nohasharray
100364 +qlcnic_83xx_sysfs_flash_read_handler_5775 qlcnic_83xx_sysfs_flash_read_handler 6 5775 &sctp_setsockopt_autoclose_5775
100365 +compat_sys_writev_5784 compat_sys_writev 3 5784 NULL
100366 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
100367 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
100368 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
100369 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
100370 +autofs4_root_compat_ioctl_5838 autofs4_root_compat_ioctl 3 5838 NULL
100371 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
100372 +ixgb_check_copybreak_5847 ixgb_check_copybreak 3 5847 NULL
100373 +setup_req_5848 setup_req 3 5848 NULL
100374 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
100375 +compat_sys_move_pages_5861 compat_sys_move_pages 2 5861 NULL nohasharray
100376 +uinput_compat_ioctl_5861 uinput_compat_ioctl 3 5861 &compat_sys_move_pages_5861
100377 +paging64_walk_addr_5887 paging64_walk_addr 3 5887 NULL
100378 +port_show_regs_5904 port_show_regs 3 5904 NULL
100379 +rbd_segment_length_5907 rbd_segment_length 0-3-2 5907 NULL
100380 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
100381 +qla82xx_pci_mem_read_2M_5912 qla82xx_pci_mem_read_2M 2 5912 NULL
100382 +ttm_bo_kmap_ttm_5922 ttm_bo_kmap_ttm 3 5922 NULL
100383 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
100384 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
100385 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
100386 +tipc_subseq_alloc_5957 tipc_subseq_alloc 1 5957 NULL
100387 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
100388 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
100389 +native_pte_val_5978 native_pte_val 0 5978 NULL
100390 +SyS_semop_5980 SyS_semop 3 5980 NULL
100391 +ntfs_rl_append_6037 ntfs_rl_append 2-4 6037 NULL
100392 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL
100393 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
100394 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
100395 +md_trim_bio_6078 md_trim_bio 2 6078 NULL
100396 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
100397 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
100398 +matrix_keypad_build_keymap_6129 matrix_keypad_build_keymap 3 6129 NULL
100399 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
100400 +ieee80211_if_fmt_beacon_timeout_6153 ieee80211_if_fmt_beacon_timeout 3 6153 NULL
100401 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
100402 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
100403 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
100404 +paging64_walk_addr_generic_6180 paging64_walk_addr_generic 4 6180 NULL
100405 +qp_host_get_user_memory_6189 qp_host_get_user_memory 1-2 6189 NULL
100406 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
100407 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
100408 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
100409 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
100410 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
100411 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
100412 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
100413 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 3 6282 NULL nohasharray
100414 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
100415 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
100416 +paging64_gva_to_gpa_nested_6287 paging64_gva_to_gpa_nested 2 6287 NULL
100417 +nf_nat_ipv6_manip_pkt_6289 nf_nat_ipv6_manip_pkt 2 6289 NULL
100418 +nf_nat_sack_adjust_6297 nf_nat_sack_adjust 2 6297 NULL
100419 +mid_get_vbt_data_r10_6308 mid_get_vbt_data_r10 2 6308 NULL
100420 +qlcnic_sriov_alloc_bc_msg_6309 qlcnic_sriov_alloc_bc_msg 2 6309 NULL
100421 +SyS_mincore_6329 SyS_mincore 1 6329 NULL
100422 +fuse_get_req_for_background_6337 fuse_get_req_for_background 2 6337 NULL
100423 +ucs2_strnlen_6342 ucs2_strnlen 0 6342 NULL
100424 +mei_dbgfs_read_devstate_6352 mei_dbgfs_read_devstate 3 6352 NULL
100425 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
100426 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
100427 +isku_sysfs_write_light_6406 isku_sysfs_write_light 6 6406 NULL
100428 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
100429 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
100430 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2-3 6432 NULL
100431 +paging32_gva_to_gpa_nested_6442 paging32_gva_to_gpa_nested 2 6442 NULL
100432 +mlx4_ib_reg_user_mr_6471 mlx4_ib_reg_user_mr 2-3 6471 NULL nohasharray
100433 +ext4_compat_ioctl_6471 ext4_compat_ioctl 3 6471 &mlx4_ib_reg_user_mr_6471
100434 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
100435 +qp_memcpy_from_queue_6479 qp_memcpy_from_queue 4-5 6479 NULL
100436 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
100437 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
100438 +mei_read_6507 mei_read 3 6507 NULL
100439 +read_file_disable_ani_6536 read_file_disable_ani 3 6536 NULL
100440 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
100441 +wdm_read_6549 wdm_read 3 6549 NULL
100442 +isku_sysfs_write_keys_easyzone_6553 isku_sysfs_write_keys_easyzone 6 6553 NULL
100443 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
100444 +SyS_semtimedop_6563 SyS_semtimedop 3 6563 NULL
100445 +SyS_fcntl64_6582 SyS_fcntl64 3 6582 NULL
100446 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
100447 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
100448 +compat_SyS_shmat_6642 compat_SyS_shmat 2 6642 NULL
100449 +virtscsi_alloc_tgt_6643 virtscsi_alloc_tgt 2 6643 NULL
100450 +aac_srcv_ioremap_6659 aac_srcv_ioremap 2 6659 NULL
100451 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
100452 +ql_process_mac_rx_skb_6689 ql_process_mac_rx_skb 4 6689 NULL
100453 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2 6696 NULL
100454 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
100455 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
100456 +mpeg_read_6708 mpeg_read 3 6708 NULL
100457 +set_orig_insn_6712 set_orig_insn 3 6712 NULL
100458 +video_proc_write_6724 video_proc_write 3 6724 NULL
100459 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
100460 +rds_rdma_pages_6735 rds_rdma_pages 0 6735 NULL
100461 +sfi_check_table_6772 sfi_check_table 1 6772 NULL
100462 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
100463 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
100464 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
100465 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
100466 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
100467 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
100468 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
100469 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
100470 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
100471 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
100472 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
100473 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
100474 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
100475 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
100476 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
100477 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
100478 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
100479 +qsfp_cks_6945 qsfp_cks 0-2 6945 NULL
100480 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
100481 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
100482 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 NULL
100483 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
100484 +request_key_async_6990 request_key_async 4 6990 NULL
100485 +tpl_write_6998 tpl_write 3 6998 NULL
100486 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
100487 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
100488 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
100489 +wimax_msg_7030 wimax_msg 4 7030 NULL
100490 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
100491 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
100492 +event_enable_read_7074 event_enable_read 3 7074 NULL
100493 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
100494 +lp_compat_ioctl_7098 lp_compat_ioctl 3 7098 NULL
100495 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
100496 +check_header_7108 check_header 0 7108 NULL
100497 +qlcnic_enable_msix_7144 qlcnic_enable_msix 2 7144 NULL
100498 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 NULL
100499 +batadv_check_unicast_ttvn_7206 batadv_check_unicast_ttvn 3 7206 NULL
100500 +sys32_ipc_7238 sys32_ipc 3-5-6 7238 NULL
100501 +get_param_h_7247 get_param_h 0 7247 NULL
100502 +af_alg_make_sg_7254 af_alg_make_sg 3 7254 NULL
100503 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
100504 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5 7272 NULL
100505 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
100506 +isku_sysfs_write_macro_7293 isku_sysfs_write_macro 6 7293 NULL
100507 +wb_remove_mapping_7307 wb_remove_mapping 2 7307 NULL
100508 +mgmt_control_7349 mgmt_control 3 7349 NULL
100509 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 NULL
100510 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
100511 +hweight_long_7388 hweight_long 0-1 7388 NULL
100512 +vhost_scsi_compat_ioctl_7393 vhost_scsi_compat_ioctl 3 7393 NULL
100513 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
100514 +readb_7401 readb 0 7401 NULL
100515 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
100516 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
100517 +SYSC_setgroups_7454 SYSC_setgroups 1 7454 NULL
100518 +numa_emulation_7466 numa_emulation 2 7466 NULL
100519 +__mutex_lock_common_7469 __mutex_lock_common 0 7469 NULL
100520 +garp_request_join_7471 garp_request_join 4 7471 NULL
100521 +compat_sys_msgrcv_7482 compat_sys_msgrcv 2 7482 NULL
100522 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
100523 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
100524 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
100525 +array_zalloc_7519 array_zalloc 1-2 7519 NULL
100526 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
100527 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
100528 +btrfs_block_rsv_add_7579 btrfs_block_rsv_add 3 7579 NULL
100529 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3 7590 NULL
100530 +groups_alloc_7614 groups_alloc 1 7614 NULL
100531 +sg_virt_7616 sg_virt 0 7616 NULL
100532 +skb_copy_expand_7685 skb_copy_expand 2-3 7685 NULL nohasharray
100533 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 2-1 7685 &skb_copy_expand_7685
100534 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
100535 +dev_write_7708 dev_write 3 7708 NULL
100536 +unmap_region_7709 unmap_region 1 7709 NULL
100537 +brcmf_sdcard_send_buf_7713 brcmf_sdcard_send_buf 6 7713 NULL
100538 +set_bypass_pwup_pfs_7742 set_bypass_pwup_pfs 3 7742 NULL
100539 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
100540 +osdv2_attr_list_elem_size_7763 osdv2_attr_list_elem_size 0-1 7763 NULL
100541 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
100542 +ioread32be_7773 ioread32be 0 7773 NULL
100543 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
100544 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
100545 +bnx2_nvram_write_7790 bnx2_nvram_write 4-2 7790 NULL
100546 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL
100547 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
100548 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
100549 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
100550 +gfs2_tune_get_i_7903 gfs2_tune_get_i 0 7903 NULL
100551 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
100552 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
100553 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
100554 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1 7934 NULL
100555 +hash_netiface6_expire_7944 hash_netiface6_expire 3 7944 NULL
100556 +integrity_digsig_verify_7956 integrity_digsig_verify 3 7956 NULL
100557 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
100558 +sys_mbind_7990 sys_mbind 5 7990 NULL
100559 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
100560 +vcs_read_8017 vcs_read 3 8017 NULL
100561 +normalize_up_8037 normalize_up 0-1-2 8037 NULL
100562 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
100563 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
100564 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
100565 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
100566 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
100567 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
100568 +venus_lookup_8121 venus_lookup 4 8121 NULL
100569 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
100570 +dma_map_area_8178 dma_map_area 5-2-3 8178 NULL
100571 +ore_truncate_8181 ore_truncate 3 8181 NULL
100572 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
100573 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
100574 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
100575 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
100576 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
100577 +play_iframe_8219 play_iframe 3 8219 NULL
100578 +create_log_8225 create_log 2 8225 NULL nohasharray
100579 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
100580 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
100581 +ceph_sync_write_8233 ceph_sync_write 4 8233 NULL
100582 +bnx2x_iov_get_max_queue_count_8235 bnx2x_iov_get_max_queue_count 0 8235 NULL
100583 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
100584 +add_rx_skb_8257 add_rx_skb 3 8257 NULL
100585 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
100586 +init_cdev_8274 init_cdev 1 8274 NULL
100587 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
100588 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
100589 +construct_key_and_link_8321 construct_key_and_link 4 8321 NULL
100590 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
100591 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
100592 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
100593 +isku_sysfs_write_talk_8360 isku_sysfs_write_talk 6 8360 NULL nohasharray
100594 +ping_getfrag_8360 ping_getfrag 4-3 8360 &isku_sysfs_write_talk_8360
100595 +uvc_v4l2_compat_ioctl32_8375 uvc_v4l2_compat_ioctl32 3 8375 NULL
100596 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
100597 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
100598 +smk_write_change_rule_8411 smk_write_change_rule 3 8411 NULL nohasharray
100599 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 &smk_write_change_rule_8411
100600 +pca953x_gpio_to_irq_8424 pca953x_gpio_to_irq 2 8424 NULL
100601 +snd_usb_ctl_msg_8436 snd_usb_ctl_msg 8 8436 NULL
100602 +irq_create_mapping_8437 irq_create_mapping 2 8437 NULL
100603 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
100604 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
100605 +dev_config_8506 dev_config 3 8506 NULL
100606 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
100607 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
100608 +pnp_resource_len_8532 pnp_resource_len 0 8532 NULL
100609 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
100610 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
100611 +user_on_off_8552 user_on_off 2 8552 NULL
100612 +profile_remove_8556 profile_remove 3 8556 NULL
100613 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
100614 +mga_ioremap_8571 mga_ioremap 1-2 8571 NULL
100615 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
100616 +tower_write_8580 tower_write 3 8580 NULL
100617 +rtllib_MFIE_rate_len_8606 rtllib_MFIE_rate_len 0 8606 NULL
100618 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
100619 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
100620 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
100621 +fuse_send_write_pages_8636 fuse_send_write_pages 0-5 8636 NULL
100622 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
100623 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
100624 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
100625 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
100626 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
100627 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
100628 +arcfb_write_8702 arcfb_write 3 8702 NULL
100629 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
100630 +init_header_8703 init_header 0 8703 &i_size_read_8703
100631 +ctrl_out_8712 ctrl_out 3-5 8712 NULL
100632 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL
100633 +f_dupfd_8730 f_dupfd 1 8730 NULL
100634 +__create_irqs_8733 __create_irqs 2-1 8733 NULL
100635 +pca953x_gpio_irq_map_8737 pca953x_gpio_irq_map 2 8737 NULL
100636 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
100637 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
100638 +sys_prctl_8766 sys_prctl 4 8766 NULL
100639 +x32_arch_ptrace_8767 x32_arch_ptrace 3-4 8767 NULL
100640 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
100641 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
100642 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
100643 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
100644 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
100645 +icmpv6_manip_pkt_8833 icmpv6_manip_pkt 4 8833 NULL nohasharray
100646 +get_queue_depth_8833 get_queue_depth 0 8833 &icmpv6_manip_pkt_8833
100647 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
100648 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
100649 +clear_bitset_8840 clear_bitset 2 8840 NULL
100650 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
100651 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
100652 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
100653 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 NULL
100654 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
100655 +layout_commit_8926 layout_commit 3 8926 NULL
100656 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
100657 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
100658 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
100659 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
100660 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
100661 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
100662 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
100663 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
100664 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
100665 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
100666 +btrfs_alloc_free_block_8986 btrfs_alloc_free_block 3 8986 NULL
100667 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
100668 +__pskb_copy_9038 __pskb_copy 2 9038 NULL
100669 +nla_put_9042 nla_put 3 9042 NULL
100670 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 3-5 9061 NULL
100671 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
100672 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
100673 +string_9080 string 0 9080 NULL
100674 +create_queues_9088 create_queues 2-3 9088 NULL
100675 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
100676 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
100677 +gfn_to_rmap_9110 gfn_to_rmap 2-3 9110 &caif_stream_sendmsg_9110
100678 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
100679 +isku_sysfs_write_keys_macro_9120 isku_sysfs_write_keys_macro 6 9120 NULL
100680 +mq_remove_mapping_9124 mq_remove_mapping 2 9124 NULL
100681 +mlx4_alloc_resize_umem_9132 mlx4_alloc_resize_umem 3 9132 NULL
100682 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
100683 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
100684 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
100685 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
100686 +alloc_group_attrs_9194 alloc_group_attrs 2 9194 NULL nohasharray
100687 +altera_swap_ir_9194 altera_swap_ir 2 9194 &alloc_group_attrs_9194
100688 +gx1_gx_base_9198 gx1_gx_base 0 9198 NULL
100689 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
100690 +get_pfn_9207 get_pfn 1 9207 NULL
100691 +virtqueue_add_9217 virtqueue_add 5-4 9217 NULL
100692 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
100693 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
100694 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4 9256 NULL
100695 +tcf_csum_ipv4_icmp_9258 tcf_csum_ipv4_icmp 3 9258 NULL
100696 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
100697 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
100698 +flakey_status_9274 flakey_status 5 9274 NULL
100699 +qla82xx_pci_set_window_9303 qla82xx_pci_set_window 0-2 9303 NULL
100700 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
100701 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
100702 +memblock_find_in_range_node_9328 memblock_find_in_range_node 0-3-4 9328 NULL
100703 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
100704 +nvme_trans_fmt_get_parm_header_9340 nvme_trans_fmt_get_parm_header 2 9340 NULL
100705 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
100706 +sta_beacon_loss_count_read_9370 sta_beacon_loss_count_read 3 9370 NULL
100707 +virtqueue_add_outbuf_9395 virtqueue_add_outbuf 3 9395 NULL
100708 +read_9397 read 3 9397 NULL
100709 +nf_nat_sip_expect_9418 nf_nat_sip_expect 8 9418 NULL
100710 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
100711 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
100712 +kmalloc_array_9444 kmalloc_array 1-2 9444 NULL
100713 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
100714 +mcs_unwrap_mir_9455 mcs_unwrap_mir 3 9455 NULL
100715 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
100716 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL
100717 +__alloc_preds_9492 __alloc_preds 2 9492 NULL nohasharray
100718 +crypt_status_9492 crypt_status 5 9492 &__alloc_preds_9492
100719 +lp_write_9511 lp_write 3 9511 NULL
100720 +xen_remap_exchanged_ptes_9513 xen_remap_exchanged_ptes 1 9513 NULL
100721 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
100722 +read_file_dma_9530 read_file_dma 3 9530 NULL
100723 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
100724 +audit_log_n_untrustedstring_9548 audit_log_n_untrustedstring 3 9548 NULL
100725 +fw_node_create_9559 fw_node_create 2 9559 NULL
100726 +ipath_get_user_pages_9561 ipath_get_user_pages 1-2 9561 NULL
100727 +kobj_map_9566 kobj_map 2-3 9566 NULL
100728 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
100729 +biovec_create_pools_9575 biovec_create_pools 2 9575 NULL
100730 +ieee80211_tdls_mgmt_9581 ieee80211_tdls_mgmt 8 9581 NULL
100731 +use_block_rsv_9597 use_block_rsv 3 9597 NULL
100732 +do_sync_9604 do_sync 1 9604 NULL
100733 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
100734 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
100735 +ceph_copy_user_to_page_vector_9635 ceph_copy_user_to_page_vector 4-3 9635 NULL
100736 +compat_sys_keyctl_9639 compat_sys_keyctl 4-2-3 9639 NULL
100737 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
100738 +uvc_alloc_buffers_9656 uvc_alloc_buffers 2-3 9656 NULL
100739 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
100740 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
100741 +ks8842_read16_9676 ks8842_read16 0 9676 NULL nohasharray
100742 +dns_query_9676 dns_query 3 9676 &ks8842_read16_9676
100743 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
100744 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
100745 +is_hole_9694 is_hole 2 9694 NULL nohasharray
100746 +x25_asy_compat_ioctl_9694 x25_asy_compat_ioctl 4 9694 &is_hole_9694
100747 +fnb_9703 fnb 2-3 9703 NULL
100748 +fuse_iter_npages_9705 fuse_iter_npages 0 9705 NULL nohasharray
100749 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 &fuse_iter_npages_9705
100750 +nla_get_u8_9736 nla_get_u8 0 9736 NULL
100751 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
100752 +ddb_input_read_9743 ddb_input_read 3 9743 NULL
100753 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
100754 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
100755 +__alloc_percpu_9764 __alloc_percpu 1-2 9764 NULL
100756 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
100757 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
100758 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
100759 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 NULL
100760 +pnp_mem_start_9817 pnp_mem_start 0 9817 NULL
100761 +kernel_physical_mapping_init_9818 kernel_physical_mapping_init 0-2-1 9818 NULL
100762 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
100763 +cfg80211_send_deauth_9862 cfg80211_send_deauth 3 9862 NULL
100764 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
100765 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
100766 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
100767 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
100768 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
100769 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
100770 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
100771 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 3-5 9895 NULL
100772 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
100773 +gen6_get_total_gtt_size_9913 gen6_get_total_gtt_size 0-1 9913 NULL
100774 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
100775 +read_file_misc_9948 read_file_misc 3 9948 NULL
100776 +set_rxd_buffer_pointer_9950 set_rxd_buffer_pointer 8 9950 NULL
100777 +ext2_new_blocks_9954 ext2_new_blocks 2 9954 NULL
100778 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 3-4 9957 NULL
100779 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
100780 +btrfs_add_link_9973 btrfs_add_link 5 9973 NULL
100781 +ath6kl_usb_submit_ctrl_out_9978 ath6kl_usb_submit_ctrl_out 6 9978 NULL
100782 +SYSC_move_pages_9986 SYSC_move_pages 2 9986 NULL
100783 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
100784 +handle_request_10024 handle_request 9 10024 NULL
100785 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
100786 +ieee80211_probereq_get_10040 ieee80211_probereq_get 4-5 10040 NULL
100787 +xen_destroy_contiguous_region_10054 xen_destroy_contiguous_region 1 10054 NULL
100788 +vfio_pci_write_10063 vfio_pci_write 3 10063 NULL
100789 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
100790 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
100791 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
100792 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
100793 +jbd_alloc_10112 jbd_alloc 0 10112 NULL nohasharray
100794 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 &jbd_alloc_10112
100795 +offset_to_bit_10134 offset_to_bit 0 10134 NULL
100796 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
100797 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
100798 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
100799 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
100800 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
100801 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
100802 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
100803 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
100804 +do_ioctl_trans_10194 do_ioctl_trans 3 10194 NULL
100805 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
100806 +__qlcnic_pci_sriov_enable_10281 __qlcnic_pci_sriov_enable 2 10281 NULL
100807 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
100808 +ubi_leb_change_10289 ubi_leb_change 4 10289 NULL
100809 +read_emulate_10310 read_emulate 2-4 10310 NULL
100810 +read_file_spectral_count_10320 read_file_spectral_count 3 10320 NULL
100811 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
100812 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
100813 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
100814 +get_dump_page_10338 get_dump_page 1 10338 NULL
100815 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
100816 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
100817 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
100818 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
100819 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
100820 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
100821 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
100822 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
100823 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
100824 +ca91cx42_alloc_resource_10502 ca91cx42_alloc_resource 2 10502 NULL
100825 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
100826 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
100827 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
100828 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
100829 +qlcnic_pci_sriov_enable_10519 qlcnic_pci_sriov_enable 2 10519 NULL nohasharray
100830 +hash_netiface4_expire_10519 hash_netiface4_expire 3 10519 &qlcnic_pci_sriov_enable_10519
100831 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
100832 +get_vm_area_caller_10527 get_vm_area_caller 1 10527 NULL
100833 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL
100834 +ieee80211_send_probe_req_10539 ieee80211_send_probe_req 4-6 10539 NULL
100835 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
100836 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
100837 +otp_read_10594 otp_read 2-4-5 10594 NULL
100838 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
100839 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
100840 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
100841 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 NULL
100842 +dtf_read_device_10663 dtf_read_device 3 10663 NULL
100843 +parport_write_10669 parport_write 0 10669 NULL
100844 +inl_10708 inl 0 10708 NULL nohasharray
100845 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
100846 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
100847 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
100848 +spi_sync_10731 spi_sync 0 10731 NULL
100849 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
100850 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
100851 +compat_sys_msgsnd_10738 compat_sys_msgsnd 2 10738 NULL
100852 +sys_syslog_10746 sys_syslog 3 10746 NULL
100853 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
100854 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
100855 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 4-2 10765 NULL
100856 +wb_set_dirty_10778 wb_set_dirty 2 10778 NULL
100857 +__qp_memcpy_to_queue_10779 __qp_memcpy_to_queue 2-4 10779 NULL
100858 +sys_bind_10799 sys_bind 3 10799 NULL
100859 +compat_put_int_10828 compat_put_int 1 10828 NULL
100860 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
100861 +ida_get_new_above_10853 ida_get_new_above 2 10853 NULL
100862 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
100863 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
100864 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
100865 +mid_get_vbt_data_r0_10876 mid_get_vbt_data_r0 2 10876 NULL
100866 +bl_mark_for_commit_10879 bl_mark_for_commit 2-3 10879 NULL
100867 +get_scq_10897 get_scq 2 10897 NULL
100868 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
100869 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
100870 +__copy_from_user_10918 __copy_from_user 3 10918 NULL
100871 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
100872 +ci_port_test_write_10962 ci_port_test_write 3 10962 NULL
100873 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
100874 +i915_min_freq_write_10981 i915_min_freq_write 3 10981 NULL
100875 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
100876 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
100877 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
100878 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
100879 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
100880 +mb_find_next_bit_11037 mb_find_next_bit 2-3-0 11037 NULL
100881 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
100882 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
100883 +count_argc_11083 count_argc 0 11083 NULL
100884 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
100885 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
100886 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
100887 +page_offset_11120 page_offset 0 11120 NULL
100888 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL nohasharray
100889 +cea_db_payload_len_11124 cea_db_payload_len 0 11124 &tracing_buffers_read_11124
100890 +alloc_alien_cache_11127 alloc_alien_cache 2 11127 NULL
100891 +acpi_os_map_memory_11161 acpi_os_map_memory 1-2 11161 NULL
100892 +ioat2_alloc_ring_11172 ioat2_alloc_ring 2 11172 NULL nohasharray
100893 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 3-4 11172 &ioat2_alloc_ring_11172
100894 +__swab16p_11220 __swab16p 0 11220 NULL
100895 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
100896 +mmap_region_11247 mmap_region 0-2 11247 NULL
100897 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
100898 +dm_cache_discard_bitset_resize_11262 dm_cache_discard_bitset_resize 3 11262 NULL
100899 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
100900 +cru_detect_11272 cru_detect 1 11272 NULL
100901 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
100902 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 NULL
100903 +construct_key_11329 construct_key 3 11329 NULL nohasharray
100904 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
100905 +next_segment_11330 next_segment 0-2-1 11330 NULL
100906 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 1-2 11332 NULL
100907 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
100908 +i915_max_freq_write_11350 i915_max_freq_write 3 11350 NULL
100909 +sel_write_create_11353 sel_write_create 3 11353 NULL
100910 +handle_unit_11355 handle_unit 0-1 11355 NULL
100911 +batadv_skb_head_push_11360 batadv_skb_head_push 2 11360 NULL
100912 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
100913 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
100914 +isku_sysfs_read_keys_capslock_11392 isku_sysfs_read_keys_capslock 6 11392 NULL
100915 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
100916 +___alloc_bootmem_11410 ___alloc_bootmem 1-2 11410 NULL
100917 +str_to_user_11411 str_to_user 2 11411 NULL
100918 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
100919 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
100920 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
100921 +trace_options_read_11419 trace_options_read 3 11419 NULL
100922 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 NULL
100923 +prepare_image_11424 prepare_image 0 11424 NULL
100924 +vring_size_11426 vring_size 0-1-2 11426 NULL
100925 +bttv_read_11432 bttv_read 3 11432 NULL
100926 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
100927 +swp_offset_11475 swp_offset 0 11475 NULL
100928 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 NULL
100929 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
100930 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
100931 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
100932 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
100933 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
100934 +skb_cow_data_11565 skb_cow_data 0-2 11565 NULL
100935 +mlx4_init_cmpt_table_11569 mlx4_init_cmpt_table 3 11569 NULL
100936 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
100937 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
100938 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
100939 +SYSC_mq_timedsend_11607 SYSC_mq_timedsend 3 11607 NULL
100940 +add_new_bitmap_11644 add_new_bitmap 3 11644 NULL
100941 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
100942 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
100943 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
100944 +compat_SyS_msgsnd_11675 compat_SyS_msgsnd 2-3 11675 NULL
100945 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
100946 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
100947 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
100948 +split_11691 split 2 11691 NULL
100949 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
100950 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
100951 +tcf_csum_ipv6_icmp_11738 tcf_csum_ipv6_icmp 4 11738 NULL
100952 +nfsd4_get_drc_mem_11748 nfsd4_get_drc_mem 0-1-2 11748 NULL
100953 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
100954 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
100955 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
100956 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
100957 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
100958 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2-3 11818 NULL
100959 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
100960 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
100961 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
100962 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
100963 +nf_nat_sdp_media_11863 nf_nat_sdp_media 9 11863 NULL
100964 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
100965 +ieee80211_rx_bss_info_11887 ieee80211_rx_bss_info 3 11887 NULL
100966 +kmalloc_slab_11917 kmalloc_slab 1 11917 NULL
100967 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
100968 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
100969 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
100970 +dccp_feat_clone_sp_val_11942 dccp_feat_clone_sp_val 3 11942 NULL
100971 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
100972 +atmel_read16_11981 atmel_read16 0 11981 NULL
100973 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
100974 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
100975 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
100976 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
100977 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
100978 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
100979 +pse36_gfn_delta_12087 pse36_gfn_delta 0-1 12087 NULL
100980 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
100981 +set_powered_12129 set_powered 4 12129 NULL
100982 +nfs_writedata_alloc_12133 nfs_writedata_alloc 2 12133 NULL
100983 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
100984 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
100985 +batadv_add_packet_12136 batadv_add_packet 3 12136 NULL
100986 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
100987 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
100988 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
100989 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
100990 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
100991 +wil_rxdesc_phy_length_12165 wil_rxdesc_phy_length 0 12165 NULL
100992 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
100993 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
100994 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
100995 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
100996 +bl_is_sector_init_12199 bl_is_sector_init 2 12199 NULL
100997 +scaled_div_12201 scaled_div 1-2 12201 NULL
100998 +free_initrd_mem_12203 free_initrd_mem 1 12203 NULL
100999 +receive_copy_12216 receive_copy 3 12216 NULL
101000 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
101001 +fuse_get_req_12221 fuse_get_req 2 12221 NULL nohasharray
101002 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 &fuse_get_req_12221
101003 +__alloc_bootmem_low_nopanic_12235 __alloc_bootmem_low_nopanic 1-2 12235 NULL
101004 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
101005 +ath_descdma_setup_12257 ath_descdma_setup 5 12257 NULL
101006 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
101007 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
101008 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
101009 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
101010 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
101011 +vxge_get_num_vfs_12302 vxge_get_num_vfs 0 12302 NULL
101012 +wrap_min_12303 wrap_min 0-1-2 12303 NULL
101013 +tipc_msg_build_12326 tipc_msg_build 4 12326 NULL
101014 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
101015 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
101016 +paging32_walk_addr_12359 paging32_walk_addr 3 12359 NULL
101017 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
101018 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
101019 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL
101020 +hbucket_elem_add_12416 hbucket_elem_add 3 12416 NULL
101021 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
101022 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
101023 +qla4_82xx_pci_mem_write_direct_12479 qla4_82xx_pci_mem_write_direct 2 12479 NULL
101024 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
101025 +rtllib_auth_challenge_12493 rtllib_auth_challenge 3 12493 NULL
101026 +fnic_trace_ctrl_read_12497 fnic_trace_ctrl_read 3 12497 NULL
101027 +nfs_readdir_make_qstr_12509 nfs_readdir_make_qstr 3 12509 NULL
101028 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
101029 +kvm_setup_async_pf_12555 kvm_setup_async_pf 3 12555 NULL
101030 +ib_umem_get_12557 ib_umem_get 2-3 12557 NULL
101031 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
101032 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
101033 +macvtap_compat_ioctl_12587 macvtap_compat_ioctl 3 12587 NULL
101034 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
101035 +ipv6_get_l4proto_12600 ipv6_get_l4proto 2 12600 NULL
101036 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
101037 +fc_fcp_frame_alloc_12624 fc_fcp_frame_alloc 2 12624 NULL
101038 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
101039 +ctrl_cdev_compat_ioctl_12634 ctrl_cdev_compat_ioctl 3 12634 NULL
101040 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
101041 +dwc3_link_state_write_12641 dwc3_link_state_write 3 12641 NULL
101042 +wb_create_12651 wb_create 1 12651 NULL
101043 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
101044 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
101045 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4 12669 &sel_read_class_12669
101046 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
101047 +ivtv_write_12721 ivtv_write 3 12721 NULL
101048 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
101049 +__mei_cl_async_send_12737 __mei_cl_async_send 3 12737 NULL
101050 +__videobuf_alloc_cached_12740 __videobuf_alloc_cached 1 12740 NULL
101051 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
101052 +listxattr_12769 listxattr 3 12769 NULL
101053 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
101054 +ieee80211_rx_mgmt_beacon_12780 ieee80211_rx_mgmt_beacon 3 12780 NULL
101055 +platform_create_bundle_12785 platform_create_bundle 4-6 12785 NULL
101056 +btrfs_remove_free_space_12793 btrfs_remove_free_space 2 12793 NULL
101057 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
101058 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
101059 +readq_12825 readq 0 12825 NULL
101060 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
101061 +spidev_sync_12842 spidev_sync 0 12842 NULL nohasharray
101062 +ath6kl_wmi_add_wow_pattern_cmd_12842 ath6kl_wmi_add_wow_pattern_cmd 4 12842 &spidev_sync_12842
101063 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
101064 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
101065 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
101066 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
101067 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
101068 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
101069 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
101070 +bm_status_write_12964 bm_status_write 3 12964 NULL
101071 +_drbd_md_first_sector_12984 _drbd_md_first_sector 0 12984 NULL
101072 +raid56_parity_recover_12987 raid56_parity_recover 5 12987 NULL
101073 +acpi_tb_install_table_12988 acpi_tb_install_table 1 12988 NULL
101074 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
101075 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
101076 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
101077 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
101078 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
101079 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 NULL
101080 +biovec_create_pool_13079 biovec_create_pool 2 13079 NULL
101081 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
101082 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
101083 +blk_rq_map_sg_13092 blk_rq_map_sg 0 13092 NULL
101084 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3 13100 NULL
101085 +ubifs_compat_ioctl_13108 ubifs_compat_ioctl 3 13108 NULL
101086 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
101087 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
101088 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
101089 +blk_update_request_13146 blk_update_request 3 13146 NULL
101090 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
101091 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
101092 +ucs2_strlen_13178 ucs2_strlen 0 13178 NULL
101093 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
101094 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
101095 +compat_put_ulong_13186 compat_put_ulong 1 13186 NULL
101096 +__cmpxchg64_13187 __cmpxchg64 0 13187 NULL
101097 +comedi_read_13199 comedi_read 3 13199 NULL
101098 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
101099 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
101100 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
101101 +fnic_trace_ctrl_write_13229 fnic_trace_ctrl_write 3 13229 NULL
101102 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
101103 +fw_download_code_13249 fw_download_code 3 13249 NULL nohasharray
101104 +kvm_lapic_enable_pv_eoi_13249 kvm_lapic_enable_pv_eoi 2 13249 &fw_download_code_13249
101105 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
101106 +hostap_80211_get_hdrlen_13255 hostap_80211_get_hdrlen 0 13255 NULL
101107 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
101108 +c4iw_reg_user_mr_13269 c4iw_reg_user_mr 2-3 13269 NULL
101109 +carl9170_rx_13272 carl9170_rx 3 13272 NULL
101110 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
101111 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
101112 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
101113 +platform_device_add_resources_13289 platform_device_add_resources 3 13289 NULL
101114 +i915_drop_caches_write_13308 i915_drop_caches_write 3 13308 NULL
101115 +reexecute_instruction_13321 reexecute_instruction 2 13321 NULL
101116 +us122l_ctl_msg_13330 us122l_ctl_msg 8 13330 NULL
101117 +__clone_and_map_data_bio_13334 __clone_and_map_data_bio 4-8 13334 NULL
101118 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5-2 13337 NULL
101119 +cache_ctr_13364 cache_ctr 2 13364 NULL
101120 +mthca_alloc_mtt_range_13371 mthca_alloc_mtt_range 2 13371 NULL
101121 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
101122 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
101123 +dis_bypass_write_13388 dis_bypass_write 3 13388 NULL
101124 +carl9170_rx_untie_data_13405 carl9170_rx_untie_data 3 13405 NULL
101125 +sky2_receive_13407 sky2_receive 2 13407 NULL
101126 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
101127 +keyring_read_13438 keyring_read 3 13438 NULL
101128 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL nohasharray
101129 +set_tap_pwup_pfs_13440 set_tap_pwup_pfs 3 13440 &sctp_setsockopt_peer_primary_addr_13440
101130 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 8-9-7 13443 NULL
101131 +mthca_buddy_alloc_13454 mthca_buddy_alloc 2 13454 NULL
101132 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2 13512 NULL
101133 +core_status_13515 core_status 4 13515 NULL
101134 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
101135 +bm_init_13529 bm_init 2 13529 NULL
101136 +non_atomic_pte_lookup_13540 non_atomic_pte_lookup 2 13540 NULL nohasharray
101137 +SYSC_remap_file_pages_13540 SYSC_remap_file_pages 1 13540 &non_atomic_pte_lookup_13540
101138 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
101139 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
101140 +sys_madvise_13569 sys_madvise 1 13569 NULL
101141 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
101142 +cache_write_13589 cache_write 3 13589 NULL
101143 +mpt_lan_receive_post_turbo_13592 mpt_lan_receive_post_turbo 2 13592 NULL
101144 +aac_sa_ioremap_13596 aac_sa_ioremap 2 13596 NULL nohasharray
101145 +irias_new_octseq_value_13596 irias_new_octseq_value 2 13596 &aac_sa_ioremap_13596
101146 +usb_dump_interface_descriptor_13603 usb_dump_interface_descriptor 0 13603 NULL
101147 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
101148 +wm8994_bulk_write_13615 wm8994_bulk_write 2-3 13615 NULL
101149 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
101150 +iio_device_add_event_sysfs_13627 iio_device_add_event_sysfs 0 13627 NULL
101151 +packet_snd_13634 packet_snd 3 13634 NULL
101152 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
101153 +cache_downcall_13666 cache_downcall 3 13666 NULL
101154 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
101155 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
101156 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
101157 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
101158 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
101159 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
101160 +random_read_13815 random_read 3 13815 NULL
101161 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
101162 +___mei_cl_send_13821 ___mei_cl_send 3 13821 NULL
101163 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2-3 13851 NULL
101164 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL nohasharray
101165 +alloc_trace_uprobe_13870 alloc_trace_uprobe 3 13870 &compat_ip_setsockopt_13870
101166 +qp_memcpy_to_queue_13886 qp_memcpy_to_queue 2-5 13886 NULL
101167 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
101168 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
101169 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
101170 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
101171 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
101172 +compat_chaninfo_13945 compat_chaninfo 2 13945 NULL
101173 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
101174 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
101175 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
101176 +com90xx_found_13974 com90xx_found 3 13974 NULL
101177 +qcam_read_13977 qcam_read 3 13977 NULL
101178 +dsp_read_13980 dsp_read 2 13980 NULL
101179 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
101180 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
101181 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
101182 +dmi_format_ids_14018 dmi_format_ids 2 14018 NULL
101183 +_rtl92s_firmware_downloadcode_14021 _rtl92s_firmware_downloadcode 3 14021 NULL
101184 +iscsi_create_flashnode_conn_14022 iscsi_create_flashnode_conn 4 14022 NULL
101185 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
101186 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
101187 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
101188 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
101189 +i915_drop_caches_read_14060 i915_drop_caches_read 3 14060 NULL
101190 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
101191 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
101192 +nlmsg_len_14115 nlmsg_len 0 14115 NULL
101193 +vfio_fops_compat_ioctl_14130 vfio_fops_compat_ioctl 3 14130 NULL
101194 +ntfs_rl_replace_14136 ntfs_rl_replace 2-4 14136 NULL
101195 +isku_sysfs_read_light_14140 isku_sysfs_read_light 6 14140 NULL
101196 +em_canid_change_14150 em_canid_change 3 14150 NULL
101197 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
101198 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
101199 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
101200 +alloc_async_14208 alloc_async 1 14208 NULL
101201 +sys_kexec_load_14222 sys_kexec_load 2 14222 NULL
101202 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
101203 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4-2 14244 NULL
101204 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 2-4 14245 NULL
101205 +reiserfs_compat_ioctl_14265 reiserfs_compat_ioctl 3 14265 NULL
101206 +ath6kl_connect_event_14267 ath6kl_connect_event 8-9-7 14267 NULL
101207 +add_numbered_child_14273 add_numbered_child 5 14273 NULL
101208 +OS_mem_token_alloc_14276 OS_mem_token_alloc 1 14276 NULL
101209 +snd_seq_oss_readq_new_14283 snd_seq_oss_readq_new 2 14283 NULL
101210 +rr_status_14293 rr_status 5 14293 NULL
101211 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
101212 +oo_objects_14319 oo_objects 0 14319 NULL
101213 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
101214 +scsi2int_14358 scsi2int 0 14358 NULL
101215 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
101216 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
101217 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
101218 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
101219 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
101220 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
101221 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
101222 +block_size_14443 block_size 0 14443 NULL
101223 +ci13xxx_add_device_14456 ci13xxx_add_device 3 14456 NULL
101224 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
101225 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
101226 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 NULL
101227 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
101228 +dataflash_read_user_otp_14536 dataflash_read_user_otp 2-3 14536 NULL nohasharray
101229 +ep0_write_14536 ep0_write 3 14536 &dataflash_read_user_otp_14536
101230 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
101231 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
101232 +usb_dump_desc_14553 usb_dump_desc 0 14553 NULL
101233 +qp_host_alloc_queue_14566 qp_host_alloc_queue 1 14566 NULL
101234 +SyS_setdomainname_14569 SyS_setdomainname 2 14569 NULL
101235 +remap_to_origin_then_cache_14583 remap_to_origin_then_cache 3 14583 NULL
101236 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
101237 +ceph_osdc_alloc_request_14597 ceph_osdc_alloc_request 3 14597 NULL
101238 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
101239 +dbJoin_14644 dbJoin 0 14644 NULL
101240 +profile_replace_14652 profile_replace 3 14652 NULL
101241 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
101242 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
101243 +tsi148_master_set_14685 tsi148_master_set 4 14685 NULL
101244 +SyS_fsetxattr_14702 SyS_fsetxattr 4 14702 NULL
101245 +persistent_ram_ecc_string_14704 persistent_ram_ecc_string 0 14704 NULL
101246 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
101247 +get_bio_block_14714 get_bio_block 0 14714 NULL
101248 +vfd_write_14717 vfd_write 3 14717 NULL
101249 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
101250 +raid1_resize_14740 raid1_resize 2 14740 NULL
101251 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
101252 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
101253 +qla82xx_pci_mem_write_2M_14765 qla82xx_pci_mem_write_2M 2 14765 NULL
101254 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
101255 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
101256 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
101257 +hpet_readl_14801 hpet_readl 0 14801 NULL nohasharray
101258 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 &hpet_readl_14801
101259 +bcma_scan_read32_14802 bcma_scan_read32 0 14802 NULL
101260 +do_tune_cpucache_14828 do_tune_cpucache 2 14828 NULL
101261 +__mutex_fastpath_lock_retval_14844 __mutex_fastpath_lock_retval 0 14844 NULL
101262 +mrp_attr_create_14853 mrp_attr_create 3 14853 NULL
101263 +lcd_write_14857 lcd_write 3 14857 NULL nohasharray
101264 +__krealloc_14857 __krealloc 2 14857 &lcd_write_14857
101265 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
101266 +sriov_enable_migration_14889 sriov_enable_migration 2 14889 NULL
101267 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
101268 +unifi_read_14899 unifi_read 3 14899 NULL
101269 +SYSC_readv_14901 SYSC_readv 3 14901 NULL
101270 +krealloc_14908 krealloc 2 14908 NULL
101271 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2 14910 NULL
101272 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL nohasharray
101273 +qp_memcpy_to_queue_iov_14923 qp_memcpy_to_queue_iov 2-5 14923 &__arch_hweight64_14923
101274 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
101275 +queue_cnt_14951 queue_cnt 0 14951 NULL
101276 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
101277 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
101278 +setkey_14987 setkey 3 14987 NULL nohasharray
101279 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
101280 +xfs_dinode_size_14996 xfs_dinode_size 0 14996 NULL
101281 +vmap_15025 vmap 2 15025 NULL
101282 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
101283 +irq_get_next_irq_15053 irq_get_next_irq 1 15053 NULL
101284 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
101285 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
101286 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
101287 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5 15072 NULL
101288 +compat_SyS_preadv_15105 compat_SyS_preadv 3 15105 NULL
101289 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
101290 +start_port_15124 start_port 0 15124 NULL
101291 +memchr_15126 memchr 0 15126 NULL
101292 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
101293 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
101294 +SYSC_setdomainname_15180 SYSC_setdomainname 2 15180 NULL
101295 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
101296 +reserve_resources_15194 reserve_resources 3 15194 NULL
101297 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
101298 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
101299 +div64_u64_15263 div64_u64 0-1-2 15263 NULL
101300 +compat_raw_ioctl_15290 compat_raw_ioctl 3 15290 NULL
101301 +sys_connect_15291 sys_connect 3 15291 NULL nohasharray
101302 +xlate_dev_mem_ptr_15291 xlate_dev_mem_ptr 1 15291 &sys_connect_15291
101303 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
101304 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
101305 +tpm_tis_init_15304 tpm_tis_init 2-3 15304 NULL
101306 +fcoe_ctlr_send_keep_alive_15308 fcoe_ctlr_send_keep_alive 3 15308 NULL
101307 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-5-3 15330 NULL
101308 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
101309 +ioread16_15342 ioread16 0 15342 NULL
101310 +alloc_ring_15345 alloc_ring 2-4 15345 NULL
101311 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
101312 +graph_depth_read_15371 graph_depth_read 3 15371 NULL
101313 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
101314 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
101315 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
101316 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
101317 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
101318 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
101319 +get_modalias_15406 get_modalias 2 15406 NULL
101320 +dm_cache_resize_15422 dm_cache_resize 2 15422 NULL
101321 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4 15423 NULL
101322 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 2 15438 NULL
101323 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
101324 +memweight_15450 memweight 2 15450 NULL
101325 +vmalloc_15464 vmalloc 1 15464 NULL
101326 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
101327 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
101328 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
101329 +ql_process_mac_rx_page_15543 ql_process_mac_rx_page 4 15543 NULL
101330 +ieee80211_amsdu_to_8023s_15561 ieee80211_amsdu_to_8023s 5 15561 NULL
101331 +persistent_status_15574 persistent_status 4 15574 NULL
101332 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
101333 +vme_user_write_15587 vme_user_write 3 15587 NULL
101334 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7 15595 NULL
101335 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
101336 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
101337 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
101338 +set_dis_tap_pfs_15621 set_dis_tap_pfs 3 15621 NULL
101339 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
101340 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 2-4 15642 NULL nohasharray
101341 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
101342 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
101343 +fs_path_add_15648 fs_path_add 3 15648 NULL
101344 +xsd_read_15653 xsd_read 3 15653 NULL
101345 +compat_sys_fcntl_15654 compat_sys_fcntl 3 15654 NULL
101346 +unix_bind_15668 unix_bind 3 15668 NULL
101347 +dm_read_15674 dm_read 3 15674 NULL
101348 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
101349 +uf_sme_queue_message_15697 uf_sme_queue_message 3 15697 NULL
101350 +ocfs2_split_tree_15716 ocfs2_split_tree 5 15716 NULL
101351 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
101352 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1 15762 NULL
101353 +do_test_15766 do_test 1 15766 NULL
101354 +set_std_nic_pfs_15792 set_std_nic_pfs 3 15792 NULL
101355 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
101356 +snd_pcm_ioctl_compat_15804 snd_pcm_ioctl_compat 3 15804 NULL
101357 +gx1_read_conf_reg_15817 gx1_read_conf_reg 0 15817 NULL nohasharray
101358 +nameseq_list_15817 nameseq_list 3 15817 &gx1_read_conf_reg_15817 nohasharray
101359 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
101360 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL nohasharray
101361 +firmware_upload_15822 firmware_upload 3 15822 &afs_proc_rootcell_write_15822
101362 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
101363 +table_size_15851 table_size 0-1-2 15851 NULL
101364 +ubi_io_write_15870 ubi_io_write 5-4 15870 NULL nohasharray
101365 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
101366 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
101367 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
101368 +native_read_msr_15905 native_read_msr 0 15905 NULL
101369 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
101370 +power_read_15939 power_read 3 15939 NULL
101371 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
101372 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 4-2-5 15952 NULL
101373 +remap_pci_mem_15966 remap_pci_mem 1-2 15966 NULL
101374 +tfrc_calc_x_15975 tfrc_calc_x 1-2 15975 NULL
101375 +frame_alloc_15981 frame_alloc 4 15981 NULL
101376 +alloc_vm_area_15989 alloc_vm_area 1 15989 NULL
101377 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
101378 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
101379 +got_frame_16028 got_frame 2 16028 NULL
101380 +read_file_spectral_period_16057 read_file_spectral_period 3 16057 NULL
101381 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
101382 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
101383 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
101384 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
101385 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
101386 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
101387 +fsm_init_16134 fsm_init 2 16134 NULL
101388 +hysdn_rx_netpkt_16136 hysdn_rx_netpkt 3 16136 NULL
101389 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
101390 +bnx2i_get_cid_num_16166 bnx2i_get_cid_num 0 16166 NULL
101391 +mapping_level_16188 mapping_level 2 16188 NULL
101392 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
101393 +SyS_pselect6_16210 SyS_pselect6 1 16210 NULL
101394 +create_table_16213 create_table 2 16213 NULL
101395 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
101396 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
101397 +swiotlb_sync_single_for_device_16247 swiotlb_sync_single_for_device 2 16247 NULL nohasharray
101398 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 &swiotlb_sync_single_for_device_16247
101399 +mark_written_sectors_16262 mark_written_sectors 2 16262 NULL
101400 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
101401 +set_disc_pfs_16270 set_disc_pfs 3 16270 NULL
101402 +mq_force_mapping_16277 mq_force_mapping 2 16277 NULL
101403 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
101404 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
101405 +nand_bch_init_16280 nand_bch_init 3-2 16280 &drbd_setsockopt_16280
101406 +account_16283 account 0-2-4 16283 NULL nohasharray
101407 +mirror_status_16283 mirror_status 5 16283 &account_16283
101408 +retry_instruction_16285 retry_instruction 2 16285 NULL
101409 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
101410 +rbd_segment_offset_16293 rbd_segment_offset 0-2 16293 NULL
101411 +tfrc_invert_loss_event_rate_16295 tfrc_invert_loss_event_rate 1 16295 NULL
101412 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
101413 +wb_map_16301 wb_map 2 16301 NULL
101414 +ext4_blocks_count_16320 ext4_blocks_count 0 16320 NULL
101415 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
101416 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
101417 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
101418 +nl80211_send_unprot_deauth_16378 nl80211_send_unprot_deauth 4 16378 NULL
101419 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
101420 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
101421 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
101422 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
101423 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
101424 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
101425 +raid10_resize_16537 raid10_resize 2 16537 NULL
101426 +tcp_manip_pkt_16563 tcp_manip_pkt 4 16563 NULL
101427 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
101428 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
101429 +virt_to_scatterlist_16582 virt_to_scatterlist 2 16582 NULL
101430 +palmas_irq_get_virq_16613 palmas_irq_get_virq 2 16613 NULL
101431 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
101432 +mfd_add_devices_16668 mfd_add_devices 4 16668 NULL
101433 +ax88179_write_cmd_async_16671 ax88179_write_cmd_async 5 16671 NULL
101434 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
101435 +compat_blkdev_driver_ioctl_16769 compat_blkdev_driver_ioctl 4 16769 NULL
101436 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
101437 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
101438 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
101439 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
101440 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
101441 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
101442 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
101443 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
101444 +vfio_pci_rw_16861 vfio_pci_rw 3 16861 NULL
101445 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
101446 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
101447 +st_write_16874 st_write 3 16874 NULL
101448 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
101449 +idx_to_pfn_16919 idx_to_pfn 0 16919 NULL
101450 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
101451 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
101452 +_sp2d_alloc_16944 _sp2d_alloc 1-2-3 16944 NULL
101453 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
101454 +cfg80211_send_unprot_disassoc_16951 cfg80211_send_unprot_disassoc 3 16951 NULL
101455 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
101456 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
101457 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
101458 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
101459 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
101460 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
101461 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
101462 +__kmalloc_reserve_17080 __kmalloc_reserve 1 17080 NULL
101463 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
101464 +mac_address_string_17091 mac_address_string 0 17091 NULL
101465 +entry_length_17093 entry_length 0 17093 NULL
101466 +sys_preadv_17100 sys_preadv 3 17100 NULL
101467 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
101468 +mwifiex_get_common_rates_17131 mwifiex_get_common_rates 3 17131 NULL
101469 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
101470 +sep_read_17161 sep_read 3 17161 NULL
101471 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
101472 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
101473 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
101474 +access_remote_vm_17189 access_remote_vm 0-2-4 17189 NULL
101475 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
101476 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
101477 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
101478 +to_oblock_17254 to_oblock 0-1 17254 NULL
101479 +unpack_value_17259 unpack_value 1 17259 NULL
101480 +__be16_to_cpup_17261 __be16_to_cpup 0 17261 NULL
101481 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
101482 +alloc_ep_17269 alloc_ep 1 17269 NULL
101483 +pg_read_17276 pg_read 3 17276 NULL
101484 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
101485 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
101486 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
101487 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
101488 +install_breakpoint_17292 install_breakpoint 4 17292 NULL
101489 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
101490 +skb_pad_17302 skb_pad 2 17302 NULL
101491 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
101492 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
101493 +ata_host_alloc_pinfo_17325 ata_host_alloc_pinfo 3 17325 NULL
101494 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
101495 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
101496 +_fd_dma_mem_free_17406 _fd_dma_mem_free 1 17406 NULL
101497 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
101498 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
101499 +SYSC_fcntl_17441 SYSC_fcntl 3 17441 NULL
101500 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
101501 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
101502 +compat_cmd_17465 compat_cmd 2 17465 NULL
101503 +probe_bios_17467 probe_bios 1 17467 NULL
101504 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
101505 +__alloc_session_17485 __alloc_session 2-1 17485 NULL
101506 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
101507 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
101508 +__copy_to_user_17551 __copy_to_user 0-3 17551 NULL
101509 +copy_from_user_17559 copy_from_user 3 17559 NULL
101510 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
101511 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
101512 +rts51x_write_mem_17598 rts51x_write_mem 4 17598 NULL
101513 +iwl_dump_nic_event_log_17601 iwl_dump_nic_event_log 0 17601 NULL
101514 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
101515 +osst_execute_17607 osst_execute 7-6 17607 NULL
101516 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
101517 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
101518 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
101519 +SYSC_migrate_pages_17657 SYSC_migrate_pages 2 17657 NULL
101520 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
101521 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
101522 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
101523 +gfn_to_pfn_memslot_17693 gfn_to_pfn_memslot 2 17693 NULL
101524 +__einj_error_trigger_17707 __einj_error_trigger 1 17707 NULL nohasharray
101525 +venus_rename_17707 venus_rename 5-4 17707 &__einj_error_trigger_17707
101526 +isku_sysfs_write_keys_function_17726 isku_sysfs_write_keys_function 6 17726 NULL
101527 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
101528 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
101529 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
101530 +brcmf_usb_attach_17766 brcmf_usb_attach 2-3 17766 NULL
101531 +dtf_read_run_17768 dtf_read_run 3 17768 NULL
101532 +brcmf_sdio_chip_verifynvram_17776 brcmf_sdio_chip_verifynvram 4 17776 NULL
101533 +hash_ipport6_expire_17784 hash_ipport6_expire 3 17784 NULL
101534 +perf_clock_17787 perf_clock 0 17787 NULL
101535 +ubifs_leb_change_17789 ubifs_leb_change 4 17789 NULL
101536 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
101537 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
101538 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
101539 +count_leafs_17842 count_leafs 0 17842 NULL
101540 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
101541 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
101542 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
101543 +orinoco_set_key_17878 orinoco_set_key 5-7 17878 NULL
101544 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
101545 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
101546 +compat_sys_pwritev_17886 compat_sys_pwritev 3 17886 NULL
101547 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
101548 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
101549 +recover_head_17904 recover_head 3 17904 NULL
101550 +dccp_feat_register_sp_17914 dccp_feat_register_sp 5 17914 NULL
101551 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
101552 +srp_iu_pool_alloc_17920 srp_iu_pool_alloc 2 17920 NULL
101553 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
101554 +ufs_free_blocks_17963 ufs_free_blocks 2-3 17963 NULL
101555 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
101556 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
101557 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
101558 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
101559 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
101560 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
101561 +fill_read_18019 fill_read 0 18019 NULL
101562 +o2hb_highest_node_18034 o2hb_highest_node 2 18034 NULL
101563 +cryptd_alloc_instance_18048 cryptd_alloc_instance 2-3 18048 NULL
101564 +find_next_inuse_18051 find_next_inuse 2-3 18051 NULL
101565 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
101566 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
101567 +hex_byte_pack_18064 hex_byte_pack 0 18064 NULL
101568 +packet_came_18072 packet_came 3 18072 NULL
101569 +kvm_read_guest_page_18074 kvm_read_guest_page 5-2 18074 NULL
101570 +SYSC_pselect6_18076 SYSC_pselect6 1 18076 NULL
101571 +get_vm_area_18080 get_vm_area 1 18080 NULL
101572 +SYSC_semtimedop_18091 SYSC_semtimedop 3 18091 NULL
101573 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
101574 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
101575 +svc_getnl_18120 svc_getnl 0 18120 NULL
101576 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-1-2 18131 NULL
101577 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
101578 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
101579 +_has_tag_18169 _has_tag 2 18169 NULL
101580 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
101581 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
101582 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
101583 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
101584 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
101585 +alloc_trace_uprobe_18247 alloc_trace_uprobe 3 18247 NULL
101586 +snd_ctl_ioctl_compat_18250 snd_ctl_ioctl_compat 3 18250 NULL
101587 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
101588 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
101589 +alloc_ring_18278 alloc_ring 2-4 18278 NULL
101590 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
101591 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
101592 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
101593 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
101594 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
101595 +um_idi_write_18293 um_idi_write 3 18293 NULL
101596 +nouveau_disp_create__18305 nouveau_disp_create_ 4-7 18305 NULL
101597 +ip6ip6_err_18308 ip6ip6_err 5 18308 NULL
101598 +vga_r_18310 vga_r 0 18310 NULL
101599 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
101600 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
101601 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
101602 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
101603 +SyS_process_vm_readv_18366 SyS_process_vm_readv 3-5 18366 NULL
101604 +ep_io_18367 ep_io 0 18367 NULL
101605 +qib_user_sdma_num_pages_18371 qib_user_sdma_num_pages 0 18371 NULL
101606 +ci_role_write_18388 ci_role_write 3 18388 NULL
101607 +__video_register_device_18399 __video_register_device 3 18399 NULL
101608 +hash_ip4_expire_18402 hash_ip4_expire 3 18402 NULL nohasharray
101609 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 &hash_ip4_expire_18402
101610 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
101611 +usbnet_write_cmd_nopm_18426 usbnet_write_cmd_nopm 7 18426 NULL
101612 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL nohasharray
101613 +iscsi_create_flashnode_sess_18433 iscsi_create_flashnode_sess 4 18433 &batadv_orig_node_add_if_18433
101614 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
101615 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
101616 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
101617 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
101618 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL
101619 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 NULL
101620 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
101621 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 5-6-9 18530 NULL
101622 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
101623 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
101624 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
101625 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
101626 +debug_output_18575 debug_output 3 18575 NULL
101627 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
101628 +__netdev_alloc_skb_18595 __netdev_alloc_skb 2 18595 NULL
101629 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL nohasharray
101630 +slabinfo_write_18600 slabinfo_write 3 18600 &filemap_fdatawait_range_18600
101631 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
101632 +batadv_arp_get_type_18609 batadv_arp_get_type 3 18609 NULL
101633 +from_buffer_18625 from_buffer 3 18625 NULL
101634 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
101635 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
101636 +unmap_page_18665 unmap_page 2-3 18665 NULL
101637 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 NULL
101638 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
101639 +unlocked_compat_ipmi_ioctl_18708 unlocked_compat_ipmi_ioctl 3 18708 NULL nohasharray
101640 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 &unlocked_compat_ipmi_ioctl_18708
101641 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
101642 +ocfs2_trim_extent_18711 ocfs2_trim_extent 4-3 18711 NULL
101643 +compat_SyS_writev_18712 compat_SyS_writev 3 18712 NULL
101644 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
101645 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
101646 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
101647 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
101648 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
101649 +md_compat_ioctl_18764 md_compat_ioctl 4 18764 NULL
101650 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
101651 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
101652 +SyS_lsetxattr_18776 SyS_lsetxattr 4 18776 NULL
101653 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
101654 +fat_compat_dir_ioctl_18800 fat_compat_dir_ioctl 3 18800 NULL
101655 +ieee80211_auth_challenge_18810 ieee80211_auth_challenge 3 18810 NULL
101656 +madvise_hwpoison_18812 madvise_hwpoison 2 18812 NULL
101657 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
101658 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
101659 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
101660 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
101661 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
101662 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL
101663 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
101664 +___alloc_bootmem_node_18882 ___alloc_bootmem_node 2-3 18882 NULL
101665 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
101666 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
101667 +mangle_packet_18920 mangle_packet 7-9 18920 NULL
101668 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
101669 +regcache_sync_block_18963 regcache_sync_block 3-4 18963 NULL
101670 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
101671 +gfn_to_pfn_atomic_18981 gfn_to_pfn_atomic 2 18981 NULL
101672 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL
101673 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
101674 +huge_page_size_19008 huge_page_size 0 19008 NULL
101675 +usbdev_compat_ioctl_19026 usbdev_compat_ioctl 3 19026 NULL
101676 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
101677 +revalidate_19043 revalidate 2 19043 NULL
101678 +drm_fb_helper_init_19044 drm_fb_helper_init 3-4 19044 NULL
101679 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
101680 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
101681 +msix_map_region_19072 msix_map_region 2 19072 NULL
101682 +ceph_create_snap_context_19082 ceph_create_snap_context 1 19082 NULL
101683 +sys_process_vm_readv_19090 sys_process_vm_readv 3-5 19090 NULL nohasharray
101684 +brcmf_usbdev_qinit_19090 brcmf_usbdev_qinit 2 19090 &sys_process_vm_readv_19090
101685 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
101686 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
101687 +skb_gro_offset_19123 skb_gro_offset 0 19123 NULL
101688 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
101689 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
101690 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
101691 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
101692 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
101693 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
101694 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
101695 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3 19214 NULL
101696 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
101697 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
101698 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
101699 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
101700 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
101701 +sys_fcntl_19267 sys_fcntl 3 19267 NULL
101702 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
101703 +io_mapping_map_wc_19284 io_mapping_map_wc 2 19284 NULL
101704 +qc_capture_19298 qc_capture 3 19298 NULL
101705 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 3-4 19303 NULL
101706 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
101707 +gfn_to_gpa_19320 gfn_to_gpa 0-1 19320 NULL
101708 +debug_read_19322 debug_read 3 19322 NULL
101709 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL
101710 +closure_sub_19359 closure_sub 2 19359 NULL
101711 +read_zero_19366 read_zero 3 19366 NULL
101712 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
101713 +sync_fill_pt_info_19397 sync_fill_pt_info 0 19397 NULL
101714 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
101715 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
101716 +__phys_addr_19434 __phys_addr 0 19434 NULL
101717 +SyS_sched_getaffinity_19444 SyS_sched_getaffinity 2 19444 NULL
101718 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
101719 +hpet_compat_ioctl_19455 hpet_compat_ioctl 3 19455 NULL
101720 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
101721 +sky2_read16_19475 sky2_read16 0 19475 NULL
101722 +efivar_create_sysfs_entry_19485 efivar_create_sysfs_entry 2 19485 NULL
101723 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
101724 +skb_realloc_headroom_19516 skb_realloc_headroom 2 19516 NULL
101725 +dev_alloc_skb_19517 dev_alloc_skb 1 19517 NULL
101726 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
101727 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
101728 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
101729 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL nohasharray
101730 +wlcore_hw_get_rx_packet_len_19565 wlcore_hw_get_rx_packet_len 0 19565 &ieee80211_if_read_tkip_mic_test_19565
101731 +nfsd_read_19568 nfsd_read 5 19568 NULL
101732 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
101733 +bm_status_read_19583 bm_status_read 3 19583 NULL
101734 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
101735 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
101736 +__mei_cl_recv_19636 __mei_cl_recv 3 19636 NULL
101737 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
101738 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
101739 +usbnet_write_cmd_19679 usbnet_write_cmd 7 19679 NULL
101740 +bio_detain_19690 bio_detain 2 19690 NULL
101741 +mem_cgroup_swappiness_19718 mem_cgroup_swappiness 0 19718 NULL
101742 +read_reg_19723 read_reg 0 19723 NULL
101743 +wm8350_block_write_19727 wm8350_block_write 3-2 19727 NULL
101744 +memcpy_toiovecend_19736 memcpy_toiovecend 4-3 19736 NULL
101745 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
101746 +p9_client_read_19750 p9_client_read 5 19750 NULL
101747 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
101748 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
101749 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
101750 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
101751 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
101752 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
101753 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
101754 +vfs_getxattr_19832 vfs_getxattr 0 19832 NULL
101755 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
101756 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
101757 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
101758 +__nla_put_19857 __nla_put 3 19857 NULL
101759 +ip6gre_err_19869 ip6gre_err 5 19869 NULL
101760 +mrp_request_join_19882 mrp_request_join 4 19882 NULL
101761 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
101762 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
101763 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
101764 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
101765 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
101766 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
101767 +SYSC_fgetxattr_20027 SYSC_fgetxattr 4 20027 NULL
101768 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
101769 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
101770 +btrfs_pin_extent_for_log_replay_20069 btrfs_pin_extent_for_log_replay 2 20069 NULL
101771 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
101772 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
101773 +team_options_register_20091 team_options_register 3 20091 NULL
101774 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
101775 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
101776 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
101777 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
101778 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
101779 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
101780 +crystalhd_map_dio_20181 crystalhd_map_dio 3 20181 NULL
101781 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
101782 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
101783 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
101784 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
101785 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
101786 +_rtl92s_get_h2c_cmdlen_20312 _rtl92s_get_h2c_cmdlen 0 20312 NULL
101787 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
101788 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
101789 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
101790 +handle_arr_calc_size_20355 handle_arr_calc_size 0-1 20355 NULL
101791 +qla82xx_pci_mem_read_direct_20368 qla82xx_pci_mem_read_direct 2 20368 NULL
101792 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
101793 +u64_to_uptr_20384 u64_to_uptr 1 20384 NULL
101794 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL
101795 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL
101796 +xen_create_contiguous_region_20457 xen_create_contiguous_region 1 20457 NULL
101797 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
101798 +dec_zcache_pers_zpages_20465 dec_zcache_pers_zpages 1 20465 NULL
101799 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
101800 +read_buf_20469 read_buf 2 20469 NULL
101801 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
101802 +fast_user_write_20494 fast_user_write 5 20494 NULL
101803 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL nohasharray
101804 +hidraw_report_event_20503 hidraw_report_event 3 20503 &ocfs2_db_frozen_trigger_20503
101805 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
101806 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 2-3 20517 NULL
101807 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
101808 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
101809 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
101810 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
101811 +venus_create_20555 venus_create 4 20555 NULL
101812 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
101813 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
101814 +i915_max_freq_read_20581 i915_max_freq_read 3 20581 NULL
101815 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL
101816 +sync_timeline_create_20601 sync_timeline_create 2 20601 NULL
101817 +lirc_write_20604 lirc_write 3 20604 NULL
101818 +qib_qsfp_write_20614 qib_qsfp_write 0-4-2 20614 NULL
101819 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
101820 +kfifo_copy_to_user_20646 kfifo_copy_to_user 3 20646 NULL
101821 +cpulist_scnprintf_20648 cpulist_scnprintf 0-2 20648 NULL
101822 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
101823 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
101824 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 NULL
101825 +get_user_page_nowait_20682 get_user_page_nowait 3 20682 NULL nohasharray
101826 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 &get_user_page_nowait_20682
101827 +cpumask_size_20683 cpumask_size 0 20683 NULL
101828 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
101829 +gru_vtop_20689 gru_vtop 2 20689 NULL
101830 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
101831 +__maestro_read_20700 __maestro_read 0 20700 NULL
101832 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
101833 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
101834 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
101835 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
101836 +vring_add_indirect_20737 vring_add_indirect 3-4 20737 NULL
101837 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
101838 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
101839 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
101840 +brcmf_p2p_escan_20763 brcmf_p2p_escan 2 20763 NULL
101841 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
101842 +ext4_r_blocks_count_20768 ext4_r_blocks_count 0 20768 NULL
101843 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
101844 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
101845 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
101846 +sys_sendto_20809 sys_sendto 6 20809 NULL
101847 +cfv_alloc_and_copy_skb_20812 cfv_alloc_and_copy_skb 4 20812 NULL
101848 +strndup_user_20819 strndup_user 2 20819 NULL
101849 +calc_layout_20829 calc_layout 3 20829 NULL
101850 +dtf_read_channel_20831 dtf_read_channel 3 20831 NULL
101851 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
101852 +uvc_alloc_entity_20836 uvc_alloc_entity 3-4 20836 NULL
101853 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
101854 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
101855 +skb_tail_pointer_20878 skb_tail_pointer 0 20878 NULL
101856 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
101857 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
101858 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
101859 +compat_sys_readv_20911 compat_sys_readv 3 20911 NULL
101860 +htable_bits_20933 htable_bits 0 20933 NULL
101861 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
101862 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
101863 +nfs_map_name_to_uid_20962 nfs_map_name_to_uid 3 20962 NULL
101864 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
101865 +brcmf_tx_frame_20978 brcmf_tx_frame 3 20978 NULL
101866 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
101867 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4 21001 NULL
101868 +ceph_osdc_new_request_21017 ceph_osdc_new_request 14-4 21017 NULL
101869 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
101870 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
101871 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
101872 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
101873 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
101874 +compat_sock_ioctl_trans_21092 compat_sock_ioctl_trans 4 21092 NULL
101875 +multipath_status_21094 multipath_status 5 21094 NULL
101876 +__cfg80211_send_disassoc_21096 __cfg80211_send_disassoc 3 21096 NULL
101877 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
101878 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
101879 +bitset_size_in_bytes_21124 bitset_size_in_bytes 0-1 21124 NULL
101880 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
101881 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
101882 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
101883 +alloc_pg_vec_21159 alloc_pg_vec 3 21159 NULL
101884 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
101885 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
101886 +scsi_execute_req_flags_21215 scsi_execute_req_flags 5 21215 NULL
101887 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4 21220 NULL
101888 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
101889 +SyS_mlock_21238 SyS_mlock 1 21238 NULL
101890 +input_ff_create_21240 input_ff_create 2 21240 NULL
101891 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
101892 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
101893 +ip_vs_icmp_xmit_21269 ip_vs_icmp_xmit 4 21269 NULL
101894 +make_alloc_exact_21279 make_alloc_exact 1-3 21279 NULL
101895 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
101896 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
101897 +add_res_range_21310 add_res_range 4 21310 NULL
101898 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
101899 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
101900 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
101901 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
101902 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
101903 +SYSC_rt_sigpending_21379 SYSC_rt_sigpending 2 21379 NULL
101904 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
101905 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
101906 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
101907 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
101908 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
101909 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
101910 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
101911 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
101912 +concat_writev_21451 concat_writev 3 21451 NULL
101913 +mei_nfc_send_21477 mei_nfc_send 3 21477 NULL
101914 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
101915 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
101916 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
101917 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
101918 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
101919 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
101920 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
101921 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
101922 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
101923 +compat_SyS_pwritev64_21606 compat_SyS_pwritev64 3 21606 NULL
101924 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
101925 +validate_nnode_21638 validate_nnode 0 21638 NULL
101926 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-3 21639 NULL
101927 +carl9170_rx_copy_data_21656 carl9170_rx_copy_data 2 21656 NULL
101928 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
101929 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
101930 +regmap_register_patch_21681 regmap_register_patch 3 21681 NULL
101931 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1-2 21687 NULL
101932 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
101933 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL
101934 +vm_brk_21739 vm_brk 1 21739 NULL
101935 +__nf_nat_mangle_tcp_packet_21744 __nf_nat_mangle_tcp_packet 8-6 21744 NULL
101936 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
101937 +gen_pool_add_21776 gen_pool_add 3 21776 NULL
101938 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
101939 +__ioremap_caller_21800 __ioremap_caller 1-2 21800 NULL
101940 +min_odd_21802 min_odd 0 21802 NULL
101941 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
101942 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
101943 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
101944 +acpi_tb_check_xsdt_21862 acpi_tb_check_xsdt 1 21862 NULL
101945 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
101946 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
101947 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL nohasharray
101948 +tcp_cookie_size_check_21873 tcp_cookie_size_check 0-1 21873 &sisusbcon_bmove_21873
101949 +xen_swiotlb_map_page_21886 xen_swiotlb_map_page 3 21886 NULL
101950 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 1-2 21895 NULL
101951 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
101952 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
101953 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
101954 +security_mmap_addr_21970 security_mmap_addr 0 21970 NULL
101955 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
101956 +SYSC_prctl_21980 SYSC_prctl 4 21980 NULL
101957 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
101958 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 0-3 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
101959 +regcache_sync_block_raw_flush_22021 regcache_sync_block_raw_flush 3-4 22021 NULL
101960 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
101961 +_sp2d_min_pg_22032 _sp2d_min_pg 0 22032 NULL
101962 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
101963 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
101964 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2 22077 NULL
101965 +write_opcode_22082 write_opcode 2 22082 NULL
101966 +mem_rw_22085 mem_rw 3 22085 NULL
101967 +is_swbp_at_addr_22089 is_swbp_at_addr 2 22089 NULL
101968 +lowpan_fragment_xmit_22095 lowpan_fragment_xmit 3-4 22095 NULL
101969 +sched_clock_cpu_22098 sched_clock_cpu 0 22098 NULL
101970 +qlcnic_sriov_pf_enable_22103 qlcnic_sriov_pf_enable 2 22103 NULL
101971 +sys_remap_file_pages_22124 sys_remap_file_pages 1 22124 NULL
101972 +__bitmap_size_22138 __bitmap_size 0 22138 NULL
101973 +compat_insn_22142 compat_insn 2 22142 NULL
101974 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
101975 +__kfifo_alloc_22173 __kfifo_alloc 3 22173 NULL
101976 +fls_22210 fls 0 22210 NULL
101977 +mem_write_22232 mem_write 3 22232 NULL
101978 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
101979 +atomic64_xchg_22246 atomic64_xchg 0 22246 NULL
101980 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
101981 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
101982 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
101983 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
101984 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
101985 +extend_brk_22301 extend_brk 0 22301 NULL
101986 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
101987 +C_SYSC_msgrcv_22320 C_SYSC_msgrcv 2-3 22320 NULL
101988 +get_segment_base_22324 get_segment_base 0 22324 NULL
101989 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 2-3 22334 NULL
101990 +atomic_read_22342 atomic_read 0 22342 NULL
101991 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
101992 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL nohasharray
101993 +memcg_size_22360 memcg_size 0 22360 &irq_reserve_irq_22360
101994 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
101995 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 NULL
101996 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
101997 +alloc_large_system_hash_22391 alloc_large_system_hash 2 22391 NULL
101998 +btmrvl_psmode_read_22395 btmrvl_psmode_read 3 22395 NULL
101999 +crash_shrink_memory_22401 crash_shrink_memory 1 22401 NULL
102000 +zoran_write_22404 zoran_write 3 22404 NULL
102001 +queue_reply_22416 queue_reply 3 22416 NULL
102002 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
102003 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
102004 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
102005 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
102006 +batadv_check_unicast_packet_22468 batadv_check_unicast_packet 3 22468 NULL
102007 +dtf_write_device_22471 dtf_write_device 3 22471 NULL
102008 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
102009 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
102010 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
102011 +ip4_addr_string_22511 ip4_addr_string 0 22511 NULL
102012 +swiotlb_tbl_unmap_single_22522 swiotlb_tbl_unmap_single 2 22522 NULL nohasharray
102013 +usb_dump_config_descriptor_22522 usb_dump_config_descriptor 0 22522 &swiotlb_tbl_unmap_single_22522
102014 +pskb_may_pull_22546 pskb_may_pull 2 22546 NULL
102015 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
102016 +atomic_long_read_unchecked_22551 atomic_long_read_unchecked 0 22551 NULL
102017 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
102018 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
102019 +snapshot_read_22601 snapshot_read 3 22601 NULL
102020 +remove_breakpoint_22628 remove_breakpoint 3 22628 NULL
102021 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
102022 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
102023 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
102024 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
102025 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
102026 +compat_SyS_msgrcv_22661 compat_SyS_msgrcv 2-3 22661 NULL
102027 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL
102028 +qlcnic_83xx_sysfs_flash_write_handler_22680 qlcnic_83xx_sysfs_flash_write_handler 6 22680 NULL
102029 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
102030 +compat_fd_ioctl_22694 compat_fd_ioctl 4 22694 NULL
102031 +map_22700 map 2 22700 NULL
102032 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
102033 +brcmf_sdbrcm_read_control_22721 brcmf_sdbrcm_read_control 3 22721 NULL
102034 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4 22735 NULL
102035 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL nohasharray
102036 +__mei_cl_send_22738 __mei_cl_send 3 22738 &ceph_decode_32_22738
102037 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
102038 +qlcnic_sriov_init_22762 qlcnic_sriov_init 2 22762 NULL
102039 +print_frame_22769 print_frame 0 22769 NULL
102040 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
102041 +compat_blkdev_ioctl_22841 compat_blkdev_ioctl 3 22841 NULL
102042 +clone_bio_integrity_22842 clone_bio_integrity 4 22842 NULL
102043 +read_file_rcstat_22854 read_file_rcstat 3 22854 NULL
102044 +do_atm_iobuf_22857 do_atm_iobuf 3 22857 NULL
102045 +create_attr_set_22861 create_attr_set 1 22861 NULL
102046 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
102047 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
102048 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
102049 +policy_emit_config_values_22900 policy_emit_config_values 3 22900 NULL
102050 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
102051 +alloc_sglist_22960 alloc_sglist 1-2-3 22960 NULL
102052 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
102053 +vme_get_size_22964 vme_get_size 0 22964 NULL
102054 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
102055 +page_table_range_init_count_22977 page_table_range_init_count 0 22977 NULL
102056 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
102057 +set_msr_hyperv_22985 set_msr_hyperv 3 22985 NULL
102058 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
102059 +brcmf_sdio_chip_exit_download_23001 brcmf_sdio_chip_exit_download 4 23001 NULL
102060 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
102061 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
102062 +st_status_23032 st_status 5 23032 NULL
102063 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
102064 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL
102065 +mei_cl_send_23068 mei_cl_send 3 23068 NULL
102066 +kvm_mmu_gva_to_gpa_write_23075 kvm_mmu_gva_to_gpa_write 0 23075 NULL
102067 +vm_map_ram_23078 vm_map_ram 2 23078 NULL nohasharray
102068 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
102069 +get_user_hdr_len_23079 get_user_hdr_len 0 23079 NULL
102070 +qla4_82xx_pci_mem_read_2M_23081 qla4_82xx_pci_mem_read_2M 2 23081 NULL
102071 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
102072 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
102073 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
102074 +fls_long_23096 fls_long 0 23096 NULL
102075 +ntfs_ucstonls_23097 ntfs_ucstonls 3-5 23097 NULL
102076 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
102077 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
102078 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
102079 +__clear_user_23118 __clear_user 0 23118 NULL
102080 +dm_write_async_23120 dm_write_async 3 23120 NULL
102081 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
102082 +ca91cx42_master_set_23146 ca91cx42_master_set 4 23146 NULL
102083 +read_file_ani_23161 read_file_ani 3 23161 NULL
102084 +ioremap_23172 ioremap 1-2 23172 NULL
102085 +tg_get_cfs_quota_23176 tg_get_cfs_quota 0 23176 NULL
102086 +usblp_write_23178 usblp_write 3 23178 NULL
102087 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
102088 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
102089 +ieee80211_get_mesh_hdrlen_23183 ieee80211_get_mesh_hdrlen 0 23183 NULL
102090 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
102091 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
102092 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
102093 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL nohasharray
102094 +compat_rawv6_ioctl_23210 compat_rawv6_ioctl 3 23210 &pm80x_free_irq_23210
102095 +tty_buffer_request_room_23228 tty_buffer_request_room 2 23228 NULL
102096 +xlog_get_bp_23229 xlog_get_bp 2 23229 NULL
102097 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
102098 +__gfn_to_rmap_23240 __gfn_to_rmap 1-2 23240 NULL
102099 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
102100 +ipv6_skip_exthdr_23283 ipv6_skip_exthdr 0-2 23283 NULL
102101 +doc_probe_23285 doc_probe 1 23285 NULL
102102 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
102103 +perf_mmap_free_page_23302 perf_mmap_free_page 1 23302 NULL
102104 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
102105 +mc13xxx_get_num_regulators_dt_23344 mc13xxx_get_num_regulators_dt 0 23344 NULL
102106 +page_readlink_23346 page_readlink 3 23346 NULL
102107 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
102108 +fd_setup_write_same_buf_23369 fd_setup_write_same_buf 3 23369 NULL
102109 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
102110 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
102111 +vzalloc_node_23424 vzalloc_node 1 23424 NULL
102112 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 NULL
102113 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
102114 +linear_conf_23485 linear_conf 2 23485 NULL nohasharray
102115 +divasa_remap_pci_bar_23485 divasa_remap_pci_bar 3-4 23485 &linear_conf_23485
102116 +event_filter_read_23494 event_filter_read 3 23494 NULL
102117 +__gfn_to_hva_many_23508 __gfn_to_hva_many 0-2 23508 NULL
102118 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
102119 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
102120 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
102121 +dbg_leb_change_23555 dbg_leb_change 4 23555 NULL
102122 +venus_symlink_23570 venus_symlink 4-6 23570 NULL
102123 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
102124 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
102125 +do_mmap_pgoff_23600 do_mmap_pgoff 0 23600 NULL
102126 +_alloc_cdb_cont_23609 _alloc_cdb_cont 2 23609 NULL
102127 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
102128 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
102129 +ext3_compat_ioctl_23659 ext3_compat_ioctl 3 23659 NULL
102130 +sInW_23663 sInW 0 23663 NULL
102131 +SyS_connect_23669 SyS_connect 3 23669 NULL
102132 +proc_ioctl_compat_23682 proc_ioctl_compat 2 23682 NULL
102133 +nftl_partscan_23688 nftl_partscan 0 23688 NULL
102134 +cx18_read_23699 cx18_read 3 23699 NULL
102135 +isku_sysfs_write_control_23718 isku_sysfs_write_control 6 23718 NULL
102136 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
102137 +pack_sg_list_p_23739 pack_sg_list_p 0-2 23739 NULL
102138 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
102139 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
102140 +__build_packet_message_23778 __build_packet_message 10-4 23778 NULL
102141 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
102142 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
102143 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
102144 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2-3 23824 NULL
102145 +ceph_copy_page_vector_to_user_23829 ceph_copy_page_vector_to_user 3-4 23829 NULL
102146 +tfrc_binsearch_23833 tfrc_binsearch 0 23833 NULL
102147 +xfs_dir2_leaf_getdents_23841 xfs_dir2_leaf_getdents 3 23841 NULL
102148 +pgdat_end_pfn_23842 pgdat_end_pfn 0 23842 NULL
102149 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
102150 +p54_init_common_23850 p54_init_common 1 23850 NULL
102151 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
102152 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
102153 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
102154 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
102155 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
102156 +tipc_snprintf_23893 tipc_snprintf 2 23893 NULL
102157 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
102158 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
102159 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
102160 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
102161 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
102162 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL
102163 +__alloc_skb_23940 __alloc_skb 1 23940 NULL
102164 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
102165 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
102166 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
102167 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
102168 +dgrp_send_24028 dgrp_send 0-2 24028 NULL
102169 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
102170 +adis16400_show_serial_number_24037 adis16400_show_serial_number 3 24037 NULL
102171 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
102172 +brcmf_sdio_ramrw_24074 brcmf_sdio_ramrw 5 24074 NULL
102173 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
102174 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
102175 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
102176 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
102177 +mpu401_read_24126 mpu401_read 3 24126 NULL
102178 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
102179 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
102180 +set_discard_24162 set_discard 2 24162 NULL
102181 +adu_read_24177 adu_read 3 24177 NULL
102182 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
102183 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
102184 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
102185 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
102186 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 1-2-3 24224 NULL nohasharray
102187 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
102188 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
102189 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
102190 +dm_cache_save_hint_24257 dm_cache_save_hint 2 24257 NULL
102191 +em28xx_alloc_urbs_24260 em28xx_alloc_urbs 4-6 24260 NULL
102192 +thin_status_24278 thin_status 5 24278 NULL
102193 +compat_sys_preadv64_24283 compat_sys_preadv64 3 24283 NULL
102194 +msg_size_24288 msg_size 0 24288 NULL
102195 +ext2_free_blocks_24292 ext2_free_blocks 2-3 24292 NULL
102196 +map_page_24298 map_page 3-4 24298 NULL
102197 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
102198 +reserve_metadata_bytes_24313 reserve_metadata_bytes 3 24313 NULL
102199 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
102200 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
102201 +si476x_radio_read_acf_blob_24336 si476x_radio_read_acf_blob 3 24336 NULL
102202 +C_SYSC_pwritev_24345 C_SYSC_pwritev 3 24345 NULL
102203 +kzalloc_node_24352 kzalloc_node 1 24352 NULL
102204 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
102205 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
102206 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
102207 +igetword_24373 igetword 0 24373 NULL
102208 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
102209 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398
102210 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
102211 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
102212 +iwl_nvm_read_section_24438 iwl_nvm_read_section 0 24438 NULL
102213 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 4-6 24439 NULL
102214 +smk_user_access_24440 smk_user_access 3 24440 NULL
102215 +page_address_24444 page_address 0 24444 NULL
102216 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
102217 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 5-6 24466 NULL
102218 +read_file_spec_scan_ctl_24491 read_file_spec_scan_ctl 3 24491 NULL
102219 +pd_video_read_24510 pd_video_read 3 24510 NULL
102220 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
102221 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
102222 +named_prepare_buf_24532 named_prepare_buf 2 24532 NULL
102223 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
102224 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
102225 +tsi148_alloc_resource_24563 tsi148_alloc_resource 2 24563 NULL
102226 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
102227 +count_preds_24600 count_preds 0 24600 NULL
102228 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL
102229 +kvm_pv_enable_async_pf_24637 kvm_pv_enable_async_pf 2 24637 NULL
102230 +context_alloc_24645 context_alloc 3 24645 NULL
102231 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
102232 +unifi_net_data_malloc_24716 unifi_net_data_malloc 3 24716 NULL
102233 +read_fs_24717 read_fs 0 24717 NULL
102234 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
102235 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
102236 +ath_rxbuf_alloc_24745 ath_rxbuf_alloc 2 24745 NULL
102237 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
102238 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
102239 +nfsd4_sanitize_slot_size_24756 nfsd4_sanitize_slot_size 0-1 24756 NULL
102240 +i915_cache_sharing_read_24775 i915_cache_sharing_read 3 24775 NULL
102241 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
102242 +skb_make_writable_24783 skb_make_writable 2 24783 NULL
102243 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
102244 +cache_read_24790 cache_read 3 24790 NULL
102245 +unpack_str_24798 unpack_str 0 24798 NULL
102246 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
102247 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
102248 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
102249 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
102250 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
102251 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
102252 +setup_buffering_24872 setup_buffering 3 24872 NULL
102253 +bnx2fc_cmd_mgr_alloc_24873 bnx2fc_cmd_mgr_alloc 3-2 24873 NULL
102254 +queues_read_24877 queues_read 3 24877 NULL nohasharray
102255 +symbol_string_24877 symbol_string 0 24877 &queues_read_24877
102256 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
102257 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 NULL
102258 +next_token_24929 next_token 0 24929 NULL
102259 +uf_create_device_nodes_24948 uf_create_device_nodes 2 24948 NULL
102260 +ocfs2_fiemap_24949 ocfs2_fiemap 3-4 24949 NULL
102261 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
102262 +sys_rt_sigpending_24961 sys_rt_sigpending 2 24961 NULL
102263 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
102264 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
102265 +nf_nat_sdp_port_24977 nf_nat_sdp_port 7 24977 NULL
102266 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
102267 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
102268 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
102269 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
102270 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
102271 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
102272 +SYSC_listxattr_25072 SYSC_listxattr 3 25072 NULL
102273 +ceph_osdc_writepages_25085 ceph_osdc_writepages 5 25085 NULL
102274 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
102275 +sys_fgetxattr_25166 sys_fgetxattr 4 25166 NULL
102276 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL
102277 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
102278 +ks8851_rdreg32_25187 ks8851_rdreg32 0 25187 NULL
102279 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
102280 +free_memcg_kmem_pages_25228 free_memcg_kmem_pages 1 25228 NULL
102281 +dtf_write_string_25232 dtf_write_string 5 25232 NULL
102282 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
102283 +tcf_csum_ipv6_udp_25241 tcf_csum_ipv6_udp 4 25241 NULL
102284 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 3-5 25245 NULL
102285 +stripe_status_25259 stripe_status 5 25259 NULL
102286 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
102287 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
102288 +vfs_writev_25278 vfs_writev 3 25278 NULL
102289 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
102290 +snd_seq_ioctl_compat_25307 snd_seq_ioctl_compat 3 25307 NULL
102291 +help_25316 help 5 25316 NULL nohasharray
102292 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 &help_25316
102293 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
102294 +SYSC_kexec_load_25361 SYSC_kexec_load 2 25361 NULL
102295 +rio_destid_next_25368 rio_destid_next 2 25368 NULL nohasharray
102296 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
102297 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
102298 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
102299 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
102300 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
102301 +ath6kl_wmi_beginscan_cmd_25462 ath6kl_wmi_beginscan_cmd 8 25462 NULL
102302 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
102303 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
102304 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
102305 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4 25502 NULL
102306 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
102307 +sb_permission_25523 sb_permission 0 25523 NULL
102308 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
102309 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
102310 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
102311 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
102312 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
102313 +find_extend_vma_25597 find_extend_vma 2 25597 NULL
102314 +__devres_alloc_25598 __devres_alloc 2 25598 NULL
102315 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
102316 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
102317 +__get_user_pages_25628 __get_user_pages 0-3-4 25628 NULL nohasharray
102318 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
102319 +__direct_map_25647 __direct_map 5-6 25647 NULL
102320 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2 25667 NULL
102321 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
102322 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
102323 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
102324 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 NULL
102325 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
102326 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
102327 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2-3 25726 &sel_write_context_25726
102328 +mcs_unwrap_fir_25733 mcs_unwrap_fir 3 25733 NULL
102329 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
102330 +__set_clear_dirty_25744 __set_clear_dirty 2 25744 NULL
102331 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
102332 +dtf_write_channel_25748 dtf_write_channel 3 25748 NULL
102333 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
102334 +sg_read_25799 sg_read 3 25799 NULL
102335 +system_enable_read_25815 system_enable_read 3 25815 NULL
102336 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
102337 +mthca_map_user_db_25823 mthca_map_user_db 5 25823 NULL
102338 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
102339 +parport_read_25855 parport_read 0 25855 NULL
102340 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
102341 +uf_ap_process_data_pdu_25860 uf_ap_process_data_pdu 7 25860 NULL
102342 +key_attr_size_25865 key_attr_size 0 25865 NULL
102343 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
102344 +run_delalloc_nocow_25896 run_delalloc_nocow 3 25896 NULL
102345 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
102346 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
102347 +nvme_trans_mode_page_create_25908 nvme_trans_mode_page_create 7 25908 NULL
102348 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
102349 +rcname_read_25919 rcname_read 3 25919 NULL
102350 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
102351 +key_flags_read_25931 key_flags_read 3 25931 NULL
102352 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
102353 +flush_25957 flush 2 25957 NULL
102354 +video_register_device_25971 video_register_device 3 25971 NULL
102355 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
102356 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
102357 +lpfc_sli_probe_sriov_nr_virtfn_26004 lpfc_sli_probe_sriov_nr_virtfn 2 26004 NULL
102358 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
102359 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
102360 +skb_mac_header_26034 skb_mac_header 0 26034 NULL
102361 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
102362 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
102363 +tun_do_read_26047 tun_do_read 5 26047 NULL
102364 +__alloc_memory_core_early_26053 __alloc_memory_core_early 2-3 26053 NULL
102365 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
102366 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
102367 +skb_cow_26138 skb_cow 2 26138 NULL
102368 +usb_dump_device_strings_26146 usb_dump_device_strings 0 26146 NULL
102369 +copy_oldmem_page_26164 copy_oldmem_page 3-1 26164 NULL
102370 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 NULL nohasharray
102371 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 &gfs2_xattr_acl_get_26166
102372 +perf_adjust_period_26168 perf_adjust_period 2-3 26168 NULL
102373 +mid_get_vbt_data_r1_26170 mid_get_vbt_data_r1 2 26170 NULL
102374 +disk_devt_26180 disk_devt 0 26180 NULL
102375 +get_registers_26187 get_registers 3 26187 NULL
102376 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
102377 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
102378 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
102379 +mce_write_26201 mce_write 3 26201 NULL
102380 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
102381 +bio_split_26235 bio_split 2 26235 NULL
102382 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
102383 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
102384 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
102385 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
102386 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
102387 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
102388 +efx_rx_mk_skb_26342 efx_rx_mk_skb 5 26342 NULL
102389 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5 26357 NULL
102390 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
102391 +dup_to_netobj_26363 dup_to_netobj 3 26363 NULL
102392 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
102393 +dma_declare_contiguous_26455 dma_declare_contiguous 2 26455 NULL
102394 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
102395 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
102396 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
102397 +read_vmcore_26501 read_vmcore 3 26501 NULL
102398 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 3-4 26507 NULL
102399 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
102400 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
102401 +ip6_addr_string_26568 ip6_addr_string 0 26568 NULL
102402 +kvm_iommu_put_pages_26571 kvm_iommu_put_pages 2 26571 NULL
102403 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL nohasharray
102404 +batadv_receive_server_sync_packet_26577 batadv_receive_server_sync_packet 3 26577 &rts51x_read_mem_26577
102405 +cirrusfb_get_memsize_26597 cirrusfb_get_memsize 0 26597 NULL
102406 +regcache_set_reg_present_26598 regcache_set_reg_present 2 26598 NULL
102407 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
102408 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
102409 +pack_value_26625 pack_value 1 26625 NULL
102410 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
102411 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
102412 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
102413 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
102414 +__alloc_pred_stack_26687 __alloc_pred_stack 2 26687 NULL
102415 +rtllib_authentication_req_26713 rtllib_authentication_req 3 26713 NULL
102416 +aty_ld_le32_26720 aty_ld_le32 0 26720 NULL
102417 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
102418 +SyS_fcntl_26737 SyS_fcntl 3 26737 NULL
102419 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
102420 +srp_ring_alloc_26760 srp_ring_alloc 2 26760 NULL
102421 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
102422 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
102423 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
102424 +iwl_trans_read_mem32_26825 iwl_trans_read_mem32 0 26825 NULL
102425 +smk_write_load_26829 smk_write_load 3 26829 NULL
102426 +sizeof_pwm_leds_priv_26830 sizeof_pwm_leds_priv 0-1 26830 NULL
102427 +slgt_compat_ioctl_26834 slgt_compat_ioctl 3 26834 NULL
102428 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
102429 +scnprint_id_26842 scnprint_id 3 26842 NULL
102430 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
102431 +netxen_nic_hw_read_wx_128M_26858 netxen_nic_hw_read_wx_128M 2 26858 NULL
102432 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
102433 +ext2_compat_ioctl_26883 ext2_compat_ioctl 3 26883 NULL
102434 +slhc_uncompress_26905 slhc_uncompress 0-3 26905 NULL
102435 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
102436 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
102437 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
102438 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
102439 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
102440 +carl9170_handle_mpdu_26940 carl9170_handle_mpdu 3 26940 NULL nohasharray
102441 +create_bm_block_list_26940 create_bm_block_list 0 26940 &carl9170_handle_mpdu_26940
102442 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
102443 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
102444 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
102445 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
102446 +swiotlb_bounce_27046 swiotlb_bounce 2-1 27046 NULL
102447 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
102448 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
102449 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
102450 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
102451 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
102452 +compat_SyS_rt_sigpending_27084 compat_SyS_rt_sigpending 2 27084 NULL
102453 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
102454 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
102455 +nes_reg_user_mr_27106 nes_reg_user_mr 2-3 27106 NULL
102456 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
102457 +SYSC_ipc_27123 SYSC_ipc 3 27123 NULL
102458 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
102459 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
102460 +pms_capture_27142 pms_capture 4 27142 NULL
102461 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
102462 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
102463 +i2400m_net_rx_27170 i2400m_net_rx 5 27170 NULL
102464 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
102465 +mmc_blk_compat_ioctl_27194 mmc_blk_compat_ioctl 4 27194 NULL
102466 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
102467 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
102468 +cfpkt_add_trail_27260 cfpkt_add_trail 3 27260 NULL
102469 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
102470 +hpi_read_reg_27302 hpi_read_reg 0 27302 NULL
102471 +copy_from_buf_27308 copy_from_buf 4-2 27308 NULL
102472 +virtqueue_add_inbuf_27312 virtqueue_add_inbuf 3 27312 NULL nohasharray
102473 +ath6kl_wmi_test_cmd_27312 ath6kl_wmi_test_cmd 3 27312 &virtqueue_add_inbuf_27312
102474 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
102475 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
102476 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
102477 +compat_SyS_semctl_27349 compat_SyS_semctl 4 27349 NULL
102478 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
102479 +init_memory_mapping_27395 init_memory_mapping 0 27395 NULL
102480 +phys_pte_init_27411 phys_pte_init 0-3-2 27411 NULL
102481 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL
102482 +acpi_os_get_root_pointer_27416 acpi_os_get_root_pointer 0 27416 NULL nohasharray
102483 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 &acpi_os_get_root_pointer_27416
102484 +pack_sg_list_27425 pack_sg_list 0-2 27425 NULL
102485 +ktime_to_us_27455 ktime_to_us 0 27455 NULL
102486 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
102487 +set_tpl_pfs_27490 set_tpl_pfs 3 27490 NULL
102488 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
102489 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
102490 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
102491 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
102492 +__usbnet_write_cmd_27500 __usbnet_write_cmd 7 27500 NULL
102493 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
102494 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
102495 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
102496 +SyS_fgetxattr_27571 SyS_fgetxattr 4 27571 NULL
102497 +libipw_alloc_txb_27579 libipw_alloc_txb 1-2-3 27579 NULL
102498 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
102499 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
102500 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &nl80211_send_connect_result_27642
102501 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
102502 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
102503 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
102504 +set_bypass_pwoff_pfs_27669 set_bypass_pwoff_pfs 3 27669 NULL
102505 +qword_get_27670 qword_get 0 27670 NULL
102506 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
102507 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4 27702 NULL
102508 +inc_zcache_eph_zbytes_27704 inc_zcache_eph_zbytes 1 27704 NULL
102509 +evm_write_key_27715 evm_write_key 3 27715 NULL
102510 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
102511 +reg_w_buf_27724 reg_w_buf 3 27724 NULL
102512 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
102513 +a4t_cs_init_27734 a4t_cs_init 3 27734 NULL
102514 +SyS_setsockopt_27759 SyS_setsockopt 5 27759 NULL
102515 +kcalloc_27770 kcalloc 1-2 27770 NULL
102516 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
102517 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
102518 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL
102519 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
102520 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
102521 +init_header_complete_27833 init_header_complete 0 27833 NULL nohasharray
102522 +sys_listxattr_27833 sys_listxattr 3 27833 &init_header_complete_27833
102523 +read_profile_27859 read_profile 3 27859 NULL
102524 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
102525 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
102526 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
102527 +gluebi_write_27905 gluebi_write 3 27905 NULL
102528 +SyS_ptrace_27924 SyS_ptrace 3-4 27924 NULL
102529 +bm_find_next_27929 bm_find_next 2 27929 NULL
102530 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
102531 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
102532 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 NULL
102533 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
102534 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
102535 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
102536 +serial8250_port_size_28019 serial8250_port_size 0 28019 NULL
102537 +alloc_one_pg_vec_page_28031 alloc_one_pg_vec_page 1 28031 NULL
102538 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
102539 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
102540 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2 28053 NULL
102541 +pool_status_28055 pool_status 5 28055 NULL
102542 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
102543 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
102544 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
102545 +GetRecvByte_28082 GetRecvByte 0 28082 NULL
102546 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
102547 +gdth_init_isa_28091 gdth_init_isa 1 28091 NULL
102548 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 3-2 28102 NULL
102549 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
102550 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
102551 +video_read_28148 video_read 3 28148 NULL
102552 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
102553 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
102554 +vread_28173 vread 0 28173 NULL
102555 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
102556 +d_path_28198 d_path 0 28198 NULL
102557 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
102558 +__qp_memcpy_from_queue_28220 __qp_memcpy_from_queue 3-4 28220 NULL
102559 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL nohasharray
102560 +set_dis_disc_pfs_28225 set_dis_disc_pfs 3 28225 &line6_alloc_sysex_buffer_28225
102561 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
102562 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
102563 +usemap_size_28281 usemap_size 0 28281 NULL
102564 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
102565 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
102566 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
102567 +__mlock_vma_pages_range_28315 __mlock_vma_pages_range 2-3 28315 NULL
102568 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
102569 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
102570 +snapshot_write_28351 snapshot_write 3 28351 NULL
102571 +sys_writev_28384 sys_writev 3 28384 NULL
102572 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
102573 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
102574 +set_bypass_pfs_28395 set_bypass_pfs 3 28395 NULL
102575 +bypass_pwup_write_28416 bypass_pwup_write 3 28416 NULL
102576 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
102577 +__split_large_page_28429 __split_large_page 2 28429 NULL
102578 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
102579 +set_memory_uc_28439 set_memory_uc 1 28439 NULL
102580 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
102581 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
102582 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
102583 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
102584 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
102585 +max_response_pages_28492 max_response_pages 0 28492 NULL
102586 +clear_discard_28494 clear_discard 2 28494 NULL
102587 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
102588 +__next_node_28521 __next_node 1 28521 NULL
102589 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
102590 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
102591 +run_delalloc_range_28545 run_delalloc_range 3 28545 NULL nohasharray
102592 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545
102593 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
102594 +asymmetric_verify_28567 asymmetric_verify 3 28567 NULL
102595 +phys_pud_init_28574 phys_pud_init 0-3-2 28574 NULL
102596 +cfg80211_send_rx_auth_28580 cfg80211_send_rx_auth 3 28580 NULL
102597 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
102598 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
102599 +extract_entropy_28604 extract_entropy 3-5 28604 NULL
102600 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
102601 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
102602 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
102603 +_set_range_28627 _set_range 3 28627 NULL
102604 +v4l2_compat_ioctl32_28630 v4l2_compat_ioctl32 3 28630 NULL
102605 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
102606 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
102607 +__dev_alloc_skb_28681 __dev_alloc_skb 1 28681 NULL
102608 +nl80211_send_new_peer_candidate_28692 nl80211_send_new_peer_candidate 5 28692 NULL nohasharray
102609 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 &nl80211_send_new_peer_candidate_28692
102610 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
102611 +spi_execute_28736 spi_execute 5 28736 NULL
102612 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL nohasharray
102613 +phantom_compat_ioctl_28738 phantom_compat_ioctl 3 28738 &snd_pcm_aio_write_28738
102614 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
102615 +max_hw_blocks_28748 max_hw_blocks 0 28748 NULL
102616 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
102617 +dvb_net_sec_callback_28786 dvb_net_sec_callback 2 28786 NULL
102618 +btrfs_block_rsv_refill_28800 btrfs_block_rsv_refill 3 28800 NULL nohasharray
102619 +sel_write_member_28800 sel_write_member 3 28800 &btrfs_block_rsv_refill_28800
102620 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
102621 +btrfs_ref_to_path_28809 btrfs_ref_to_path 0 28809 NULL
102622 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
102623 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
102624 +C_SYSC_shmat_28843 C_SYSC_shmat 2 28843 NULL
102625 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
102626 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
102627 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
102628 +to_cblock_28899 to_cblock 0-1 28899 NULL
102629 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
102630 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
102631 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
102632 +push_rx_28939 push_rx 3 28939 NULL
102633 +btrfs_trim_block_group_28963 btrfs_trim_block_group 3 28963 NULL
102634 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
102635 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
102636 +bin_uuid_28999 bin_uuid 3 28999 NULL
102637 +offset_to_bitmap_29004 offset_to_bitmap 2 29004 NULL
102638 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
102639 +sys_fcntl64_29031 sys_fcntl64 3 29031 NULL
102640 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
102641 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL
102642 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
102643 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
102644 +memblock_alloc_base_nid_29072 memblock_alloc_base_nid 1-2 29072 NULL
102645 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
102646 +mark_extents_written_29082 mark_extents_written 2 29082 NULL
102647 +i915_error_object_create_sized_29091 i915_error_object_create_sized 3 29091 NULL
102648 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
102649 +snprintf_29125 snprintf 0 29125 NULL
102650 +iov_shorten_29130 iov_shorten 0 29130 NULL
102651 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
102652 +reshape_ring_29147 reshape_ring 2 29147 NULL
102653 +alloc_irqs_from_29152 alloc_irqs_from 1-2 29152 NULL
102654 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
102655 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL nohasharray
102656 +alloc_group_attrs_29203 alloc_group_attrs 3 29203 &wusb_prf_256_29203
102657 +__mm_populate_29204 __mm_populate 1 29204 NULL
102658 +comedi_alloc_subdevices_29207 comedi_alloc_subdevices 2 29207 NULL
102659 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
102660 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
102661 +nvme_trans_copy_from_user_29227 nvme_trans_copy_from_user 3 29227 NULL
102662 +devm_ioremap_29235 devm_ioremap 2-3 29235 NULL
102663 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
102664 +recover_peb_29238 recover_peb 6-7 29238 NULL
102665 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
102666 +block_div_29268 block_div 0-1-2 29268 NULL
102667 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
102668 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
102669 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
102670 +__fuse_get_req_29315 __fuse_get_req 2 29315 NULL
102671 +lo_compat_ioctl_29336 lo_compat_ioctl 4 29336 NULL
102672 +tun_put_user_29337 tun_put_user 5 29337 NULL
102673 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
102674 +alloc_and_copy_ftrace_hash_29368 alloc_and_copy_ftrace_hash 1 29368 NULL
102675 +ktime_us_delta_29375 ktime_us_delta 0 29375 NULL
102676 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
102677 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
102678 +mempool_create_29437 mempool_create 1 29437 NULL
102679 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
102680 +apei_exec_ctx_get_output_29457 apei_exec_ctx_get_output 0 29457 NULL
102681 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
102682 +SyS_flistxattr_29474 SyS_flistxattr 3 29474 NULL
102683 +do_register_entry_29478 do_register_entry 4 29478 NULL
102684 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
102685 +sched_clock_local_29498 sched_clock_local 0 29498 NULL
102686 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
102687 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
102688 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
102689 +_regmap_raw_write_29541 _regmap_raw_write 4-2 29541 NULL
102690 +set_brk_29551 set_brk 1 29551 NULL nohasharray
102691 +ftrace_write_29551 ftrace_write 3 29551 &set_brk_29551
102692 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
102693 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL nohasharray
102694 +alloc_empty_pages_29566 alloc_empty_pages 2 29566 &leaf_dealloc_29566
102695 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
102696 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4 29589 NULL
102697 +slots_per_page_29601 slots_per_page 0 29601 NULL
102698 +qla4_82xx_pci_set_window_29605 qla4_82xx_pci_set_window 0-2 29605 NULL
102699 +alloc_low_pages_29623 alloc_low_pages 1 29623 NULL
102700 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
102701 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
102702 +lowmem_page_address_29649 lowmem_page_address 0 29649 NULL
102703 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
102704 +br_send_bpdu_29669 br_send_bpdu 3 29669 NULL
102705 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
102706 +sd_alloc_ctl_entry_29708 sd_alloc_ctl_entry 1 29708 NULL nohasharray
102707 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 &sd_alloc_ctl_entry_29708
102708 +probes_write_29711 probes_write 3 29711 NULL
102709 +emi62_writememory_29731 emi62_writememory 4 29731 NULL
102710 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
102711 +std_nic_write_29752 std_nic_write 3 29752 NULL
102712 +ip_vs_conn_fill_param_sync_29771 ip_vs_conn_fill_param_sync 6 29771 NULL
102713 +tcf_csum_ipv6_icmp_29777 tcf_csum_ipv6_icmp 3 29777 NULL
102714 +dbAlloc_29794 dbAlloc 0 29794 NULL
102715 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
102716 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
102717 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
102718 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
102719 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
102720 +solo_enc_alloc_29860 solo_enc_alloc 3 29860 NULL
102721 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
102722 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
102723 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
102724 +nfc_targets_found_29886 nfc_targets_found 3 29886 NULL
102725 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
102726 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL
102727 +irias_add_octseq_attrib_29983 irias_add_octseq_attrib 4 29983 NULL nohasharray
102728 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 &irias_add_octseq_attrib_29983
102729 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
102730 +vmci_host_setup_notify_30002 vmci_host_setup_notify 2 30002 NULL
102731 +utf32_to_utf8_30028 utf32_to_utf8 0 30028 NULL
102732 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
102733 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
102734 +drp_wmove_30043 drp_wmove 4 30043 NULL
102735 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
102736 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
102737 +tg3_run_loopback_30093 tg3_run_loopback 2 30093 NULL
102738 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL nohasharray
102739 +dma_to_phys_30098 dma_to_phys 0-2 30098 &rx_filter_data_filter_read_30098
102740 +skb_pagelen_30113 skb_pagelen 0 30113 NULL
102741 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
102742 +calgary_unmap_page_30130 calgary_unmap_page 2-3 30130 NULL
102743 +_osd_req_sizeof_alist_header_30134 _osd_req_sizeof_alist_header 0 30134 NULL
102744 +u_memcpya_30139 u_memcpya 2-3 30139 NULL
102745 +btrfs_start_transaction_lflush_30178 btrfs_start_transaction_lflush 2 30178 NULL
102746 +cx25821_video_ioctl_30188 cx25821_video_ioctl 2 30188 NULL
102747 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
102748 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
102749 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
102750 +nfs_idmap_request_key_30208 nfs_idmap_request_key 3 30208 NULL
102751 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
102752 +snd_ac97_pcm_assign_30218 snd_ac97_pcm_assign 2 30218 NULL
102753 +f2fs_compat_ioctl_30261 f2fs_compat_ioctl 3 30261 NULL
102754 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
102755 +compat_readv_30273 compat_readv 3 30273 NULL
102756 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
102757 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
102758 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
102759 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
102760 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
102761 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
102762 +resource_from_user_30341 resource_from_user 3 30341 NULL
102763 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1 30352 NULL
102764 +C_SYSC_readv_30369 C_SYSC_readv 3 30369 NULL
102765 +sys_get_mempolicy_30379 sys_get_mempolicy 3-4 30379 NULL
102766 +mangle_sdp_packet_30381 mangle_sdp_packet 10 30381 NULL
102767 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
102768 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
102769 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
102770 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
102771 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
102772 +mq_create_30425 mq_create 1 30425 NULL
102773 +enable_write_30456 enable_write 3 30456 NULL
102774 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
102775 +urandom_read_30462 urandom_read 3 30462 NULL
102776 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
102777 +ocrdma_reg_user_mr_30474 ocrdma_reg_user_mr 2-3 30474 NULL
102778 +write_head_30481 write_head 4 30481 NULL
102779 +adu_write_30487 adu_write 3 30487 NULL
102780 +dwc3_testmode_write_30516 dwc3_testmode_write 3 30516 NULL
102781 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL
102782 +batadv_dat_snoop_incoming_arp_request_30548 batadv_dat_snoop_incoming_arp_request 3 30548 NULL
102783 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
102784 +set_le_30581 set_le 4 30581 NULL
102785 +from_cblock_30582 from_cblock 0-1 30582 NULL
102786 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
102787 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
102788 +sgl_map_user_pages_30610 sgl_map_user_pages 2-3-4 30610 NULL
102789 +SyS_msgrcv_30611 SyS_msgrcv 3 30611 NULL
102790 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
102791 +ieee80211_if_read_dot11MeshAwakeWindowDuration_30631 ieee80211_if_read_dot11MeshAwakeWindowDuration 3 30631 NULL
102792 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
102793 +agp_remap_30665 agp_remap 2 30665 NULL
102794 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
102795 +il_free_pages_30692 il_free_pages 2 30692 NULL
102796 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
102797 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
102798 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
102799 +snapshot_status_30744 snapshot_status 5 30744 NULL
102800 +tcf_csum_ipv4_udp_30777 tcf_csum_ipv4_udp 4 30777 NULL
102801 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
102802 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
102803 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
102804 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL
102805 +hda_hwdep_ioctl_compat_30847 hda_hwdep_ioctl_compat 4 30847 NULL
102806 +trace_probe_nr_files_30882 trace_probe_nr_files 0 30882 NULL
102807 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
102808 +iommu_map_mmio_space_30919 iommu_map_mmio_space 1 30919 NULL
102809 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
102810 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
102811 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
102812 +i2400mu_rx_size_grow_30989 i2400mu_rx_size_grow 0 30989 NULL
102813 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
102814 +phys_pmd_init_31024 phys_pmd_init 0-3-2 31024 NULL
102815 +compat_sys_mq_timedsend_31060 compat_sys_mq_timedsend 3 31060 NULL
102816 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
102817 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
102818 +sys_mincore_31079 sys_mincore 1 31079 NULL
102819 +ttm_bo_ioremap_31082 ttm_bo_ioremap 2-3 31082 NULL
102820 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
102821 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3-4 31109 NULL
102822 +depth_read_31112 depth_read 3 31112 NULL
102823 +ssb_read16_31139 ssb_read16 0 31139 NULL
102824 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
102825 +size_inside_page_31141 size_inside_page 0 31141 NULL
102826 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
102827 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
102828 +acpi_ex_system_memory_space_handler_31192 acpi_ex_system_memory_space_handler 2 31192 NULL
102829 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
102830 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
102831 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
102832 +kvm_mmu_page_fault_31213 kvm_mmu_page_fault 2 31213 NULL
102833 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
102834 +__read_reg_31216 __read_reg 0 31216 NULL
102835 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
102836 +cyy_readb_31240 cyy_readb 0 31240 NULL
102837 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
102838 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
102839 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
102840 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
102841 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
102842 +command_file_write_31318 command_file_write 3 31318 NULL
102843 +em28xx_init_usb_xfer_31337 em28xx_init_usb_xfer 4-6 31337 NULL
102844 +__cpu_to_node_31345 __cpu_to_node 0 31345 NULL
102845 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
102846 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 3-2 31374 NULL
102847 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
102848 +inb_31388 inb 0 31388 NULL
102849 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
102850 +mcs7830_set_reg_31413 mcs7830_set_reg 3 31413 NULL
102851 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
102852 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
102853 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
102854 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
102855 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
102856 +do_fcntl_31468 do_fcntl 3 31468 NULL
102857 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
102858 +alg_setkey_31485 alg_setkey 3 31485 NULL
102859 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
102860 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
102861 +__alloc_bootmem_31498 __alloc_bootmem 1-2 31498 NULL
102862 +rmode_tss_base_31510 rmode_tss_base 0 31510 NULL
102863 +hidraw_write_31536 hidraw_write 3 31536 NULL
102864 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
102865 +usbvision_read_31555 usbvision_read 3 31555 NULL
102866 +normalize_31566 normalize 0-1-2 31566 NULL
102867 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
102868 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
102869 +osst_write_31581 osst_write 3 31581 NULL
102870 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
102871 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
102872 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
102873 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
102874 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
102875 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
102876 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
102877 +emulator_set_cr_31665 emulator_set_cr 3 31665 NULL
102878 +__lgread_31668 __lgread 4 31668 NULL
102879 +symbol_string_31670 symbol_string 0 31670 NULL
102880 +_usb_writeN_sync_31682 _usb_writeN_sync 4 31682 NULL
102881 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
102882 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
102883 +audit_log_n_string_31705 audit_log_n_string 3 31705 NULL
102884 +ath6kl_wmi_send_probe_response_cmd_31728 ath6kl_wmi_send_probe_response_cmd 6 31728 NULL nohasharray
102885 +gfn_to_hva_read_31728 gfn_to_hva_read 2 31728 &ath6kl_wmi_send_probe_response_cmd_31728
102886 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL
102887 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3 31741 NULL
102888 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
102889 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
102890 +muldiv64_31743 muldiv64 2-3 31743 NULL
102891 +bcm_char_read_31750 bcm_char_read 3 31750 NULL
102892 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
102893 +set_memory_wb_31761 set_memory_wb 1 31761 NULL
102894 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
102895 +get_count_order_31800 get_count_order 0 31800 NULL
102896 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
102897 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
102898 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
102899 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
102900 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
102901 +ddb_output_write_31902 ddb_output_write 3 31902 NULL
102902 +xattr_permission_31907 xattr_permission 0 31907 NULL
102903 +new_dir_31919 new_dir 3 31919 NULL
102904 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
102905 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
102906 +SYSC_sethostname_31940 SYSC_sethostname 2 31940 NULL
102907 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4 31942 NULL
102908 +vb2_write_31948 vb2_write 3 31948 NULL
102909 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
102910 +regcache_rbtree_sync_31964 regcache_rbtree_sync 2 31964 NULL
102911 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
102912 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
102913 +find_next_zero_bit_31990 find_next_zero_bit 0-2-3 31990 NULL
102914 +default_setup_hpet_msi_31991 default_setup_hpet_msi 1 31991 NULL
102915 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
102916 +calc_hmac_32010 calc_hmac 3 32010 NULL
102917 +vmcs_read64_32012 vmcs_read64 0 32012 NULL
102918 +aead_len_32021 aead_len 0 32021 NULL
102919 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3 32032 NULL
102920 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
102921 +stk_read_32038 stk_read 3 32038 NULL
102922 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
102923 +sys_sched_setaffinity_32046 sys_sched_setaffinity 2 32046 NULL
102924 +SYSC_llistxattr_32061 SYSC_llistxattr 3 32061 NULL
102925 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
102926 +cfg80211_send_unprot_deauth_32080 cfg80211_send_unprot_deauth 3 32080 NULL
102927 +bio_alloc_32095 bio_alloc 2 32095 NULL
102928 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
102929 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
102930 +disk_status_32120 disk_status 4 32120 NULL
102931 +venus_link_32165 venus_link 5 32165 NULL
102932 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
102933 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
102934 +load_header_32183 load_header 0 32183 NULL
102935 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
102936 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
102937 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
102938 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
102939 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
102940 +fb_compat_ioctl_32265 fb_compat_ioctl 3 32265 NULL
102941 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
102942 +hex_string_32310 hex_string 0 32310 NULL
102943 +SyS_select_32319 SyS_select 1 32319 NULL
102944 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
102945 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
102946 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
102947 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL
102948 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL
102949 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
102950 +usbtmc_read_32377 usbtmc_read 3 32377 NULL
102951 +local_clock_32385 local_clock 0 32385 NULL
102952 +qla4_82xx_pci_mem_write_2M_32398 qla4_82xx_pci_mem_write_2M 2 32398 NULL
102953 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
102954 +vmci_qp_alloc_32405 vmci_qp_alloc 3-5 32405 NULL
102955 +log_text_32428 log_text 0 32428 NULL
102956 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
102957 +hid_input_report_32458 hid_input_report 4 32458 NULL
102958 +cache_status_32462 cache_status 5 32462 NULL
102959 +ieee80211_fill_mesh_addresses_32465 ieee80211_fill_mesh_addresses 0 32465 NULL
102960 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
102961 +bypass_pwoff_write_32499 bypass_pwoff_write 3 32499 NULL
102962 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
102963 +disconnect_32521 disconnect 4 32521 NULL
102964 +qsfp_read_32522 qsfp_read 0-4-2 32522 NULL
102965 +ilo_read_32531 ilo_read 3 32531 NULL
102966 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL
102967 +gnttab_set_unmap_op_32534 gnttab_set_unmap_op 2 32534 NULL
102968 +ieee80211_send_auth_32543 ieee80211_send_auth 6 32543 NULL
102969 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
102970 +__first_node_32558 __first_node 0 32558 NULL
102971 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
102972 +pnp_mem_len_32584 pnp_mem_len 0 32584 NULL
102973 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
102974 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
102975 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
102976 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
102977 +sys_set_mempolicy_32608 sys_set_mempolicy 3 32608 NULL
102978 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
102979 +ieee80211_hdrlen_32637 ieee80211_hdrlen 0 32637 NULL
102980 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
102981 +kvmalloc_32646 kvmalloc 1 32646 NULL
102982 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
102983 +generic_readlink_32654 generic_readlink 3 32654 NULL
102984 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
102985 +compat_SyS_pwritev_32680 compat_SyS_pwritev 3 32680 NULL
102986 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
102987 +snd_hwdep_ioctl_compat_32736 snd_hwdep_ioctl_compat 3 32736 NULL
102988 +get_arg_page_32746 get_arg_page 2 32746 NULL
102989 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
102990 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
102991 +tty_compat_ioctl_32761 tty_compat_ioctl 3 32761 NULL
102992 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
102993 +firmwareUpload_32794 firmwareUpload 3 32794 NULL
102994 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
102995 +vga_rseq_32848 vga_rseq 0 32848 NULL
102996 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
102997 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1 32868 NULL
102998 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
102999 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
103000 +ath6kl_usb_post_recv_transfers_32892 ath6kl_usb_post_recv_transfers 2 32892 NULL
103001 +ext4_get_group_number_32899 ext4_get_group_number 0 32899 NULL
103002 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
103003 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
103004 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
103005 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
103006 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
103007 +arch_ptrace_32981 arch_ptrace 3-4 32981 NULL
103008 +compat_filldir_32999 compat_filldir 3 32999 NULL
103009 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3 33007 NULL nohasharray
103010 +SyS_syslog_33007 SyS_syslog 3 33007 &ext3_alloc_blocks_33007
103011 +SYSC_lgetxattr_33049 SYSC_lgetxattr 4 33049 NULL
103012 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
103013 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
103014 +bitmap_resize_33054 bitmap_resize 2 33054 NULL
103015 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
103016 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
103017 +alloc_tio_33077 alloc_tio 3 33077 NULL
103018 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
103019 +ieee80211_fragment_33112 ieee80211_fragment 4 33112 NULL
103020 +write_node_33121 write_node 4 33121 NULL
103021 +calc_patch_size_33124 calc_patch_size 0 33124 NULL
103022 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
103023 +__len_within_target_33132 __len_within_target 0 33132 NULL
103024 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
103025 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 2-3 33204 NULL
103026 +pp_read_33210 pp_read 3 33210 NULL
103027 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL
103028 +build_completion_wait_33242 build_completion_wait 2 33242 NULL
103029 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
103030 +sched_find_first_bit_33270 sched_find_first_bit 0 33270 NULL
103031 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
103032 +mei_compat_ioctl_33275 mei_compat_ioctl 3 33275 NULL
103033 +sync_pt_create_33282 sync_pt_create 2 33282 NULL
103034 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
103035 +isku_sysfs_read_keys_easyzone_33318 isku_sysfs_read_keys_easyzone 6 33318 NULL
103036 +ath6kl_usb_ctrl_msg_exchange_33327 ath6kl_usb_ctrl_msg_exchange 4 33327 NULL
103037 +gsm_mux_rx_netchar_33336 gsm_mux_rx_netchar 3 33336 NULL
103038 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
103039 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
103040 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
103041 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
103042 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
103043 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
103044 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
103045 +tg_get_cfs_period_33390 tg_get_cfs_period 0 33390 NULL
103046 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 2-3 33394 NULL
103047 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
103048 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
103049 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
103050 +dis_tap_write_33426 dis_tap_write 3 33426 NULL
103051 +ubh_scanc_33436 ubh_scanc 0-4-3 33436 NULL
103052 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
103053 +create_entry_33479 create_entry 2 33479 NULL
103054 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
103055 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
103056 +netxen_nic_hw_write_wx_128M_33488 netxen_nic_hw_write_wx_128M 2 33488 NULL
103057 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
103058 +res_counter_read_33499 res_counter_read 4 33499 NULL
103059 +fb_read_33506 fb_read 3 33506 NULL
103060 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
103061 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
103062 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
103063 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
103064 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
103065 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 NULL
103066 +dup_array_33551 dup_array 3 33551 NULL
103067 +solo_enc_read_33553 solo_enc_read 3 33553 NULL
103068 +count_subheaders_33591 count_subheaders 0 33591 NULL
103069 +scsi_execute_33596 scsi_execute 5 33596 NULL
103070 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
103071 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL nohasharray
103072 +ip6_find_1stfragopt_33608 ip6_find_1stfragopt 0 33608 &xt_compat_target_offset_33608
103073 +usb_gstrings_attach_33615 usb_gstrings_attach 3 33615 NULL nohasharray
103074 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 &usb_gstrings_attach_33615
103075 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
103076 +inw_p_33668 inw_p 0 33668 NULL
103077 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
103078 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
103079 +ath6kl_wmi_startscan_cmd_33674 ath6kl_wmi_startscan_cmd 8 33674 NULL
103080 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
103081 +compat_insnlist_33706 compat_insnlist 2 33706 NULL
103082 +sys_keyctl_33708 sys_keyctl 4 33708 NULL nohasharray
103083 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 &sys_keyctl_33708
103084 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
103085 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
103086 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
103087 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
103088 +Read_hfc_33755 Read_hfc 0 33755 NULL
103089 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
103090 +hashtab_create_33769 hashtab_create 3 33769 NULL
103091 +midibuf_message_length_33770 midibuf_message_length 0 33770 NULL
103092 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
103093 +find_next_offset_33804 find_next_offset 3 33804 NULL
103094 +sky2_rx_pad_33819 sky2_rx_pad 0 33819 NULL
103095 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
103096 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
103097 +udplite_manip_pkt_33832 udplite_manip_pkt 4 33832 NULL
103098 +usb_dump_endpoint_descriptor_33849 usb_dump_endpoint_descriptor 0 33849 NULL
103099 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
103100 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
103101 +cap_mmap_addr_33853 cap_mmap_addr 0 33853 NULL
103102 +get_user_pages_33908 get_user_pages 0-3-4 33908 NULL
103103 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
103104 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
103105 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
103106 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL
103107 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
103108 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
103109 +ppp_write_34034 ppp_write 3 34034 NULL
103110 +tty_insert_flip_string_34042 tty_insert_flip_string 3 34042 NULL
103111 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
103112 +is_trap_at_addr_34047 is_trap_at_addr 2 34047 NULL
103113 +acpi_dev_get_irqresource_34064 acpi_dev_get_irqresource 2 34064 NULL
103114 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
103115 +read_file_ant_diversity_34071 read_file_ant_diversity 3 34071 NULL
103116 +compat_hdio_ioctl_34088 compat_hdio_ioctl 4 34088 NULL
103117 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
103118 +proc_scsi_host_write_34107 proc_scsi_host_write 3 34107 NULL
103119 +is_discarded_oblock_34120 is_discarded_oblock 2 34120 NULL
103120 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
103121 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2 34135 NULL
103122 +cdc_mbim_process_dgram_34136 cdc_mbim_process_dgram 3 34136 NULL
103123 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
103124 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
103125 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
103126 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
103127 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
103128 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
103129 +zone_spanned_pages_in_node_34299 zone_spanned_pages_in_node 0 34299 NULL
103130 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
103131 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
103132 +__insert_34349 __insert 2-3 34349 NULL
103133 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 NULL
103134 +rngapi_reset_34366 rngapi_reset 3 34366 NULL nohasharray
103135 +p54_alloc_skb_34366 p54_alloc_skb 3 34366 &rngapi_reset_34366
103136 +i2c_hid_get_raw_report_34376 i2c_hid_get_raw_report 0 34376 NULL
103137 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
103138 +ea_read_34378 ea_read 0 34378 NULL
103139 +fuse_send_read_34379 fuse_send_read 4 34379 NULL
103140 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
103141 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
103142 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
103143 +iwl_calib_set_34400 iwl_calib_set 3 34400 NULL nohasharray
103144 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 &iwl_calib_set_34400
103145 +wd_exp_mode_write_34407 wd_exp_mode_write 3 34407 NULL
103146 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
103147 +usbtest_alloc_urb_34446 usbtest_alloc_urb 3-5 34446 NULL
103148 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
103149 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
103150 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
103151 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
103152 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL
103153 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 0-2-5-4 34547 NULL
103154 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
103155 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL
103156 +velocity_rx_copy_34583 velocity_rx_copy 2 34583 NULL
103157 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
103158 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
103159 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL
103160 +brcmf_cfg80211_mgmt_tx_34608 brcmf_cfg80211_mgmt_tx 7 34608 NULL
103161 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 NULL
103162 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
103163 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
103164 +tomoyo_dump_page_34649 tomoyo_dump_page 2 34649 NULL
103165 +nf_nat_mangle_udp_packet_34661 nf_nat_mangle_udp_packet 8-6 34661 NULL
103166 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
103167 +port_print_34704 port_print 3 34704 NULL
103168 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1 34706 NULL
103169 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
103170 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
103171 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
103172 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
103173 +__copy_in_user_34790 __copy_in_user 3 34790 NULL
103174 +SYSC_keyctl_34800 SYSC_keyctl 4 34800 NULL
103175 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
103176 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
103177 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
103178 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
103179 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
103180 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
103181 +msg_print_text_34889 msg_print_text 0 34889 NULL
103182 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
103183 +compat_put_uint_34905 compat_put_uint 1 34905 NULL
103184 +si476x_radio_read_rsq_primary_blob_34916 si476x_radio_read_rsq_primary_blob 3 34916 NULL
103185 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
103186 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
103187 +ceph_aio_write_34930 ceph_aio_write 4 34930 NULL
103188 +skb_gro_header_slow_34958 skb_gro_header_slow 2 34958 NULL nohasharray
103189 +i2c_transfer_34958 i2c_transfer 0 34958 &skb_gro_header_slow_34958
103190 +Realloc_34961 Realloc 2 34961 NULL
103191 +mq_lookup_34990 mq_lookup 2 34990 NULL
103192 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
103193 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
103194 +dm_cache_insert_mapping_35005 dm_cache_insert_mapping 2-3 35005 NULL
103195 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
103196 +alloc_p2m_page_35025 alloc_p2m_page 0 35025 NULL
103197 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
103198 +brcmf_sdio_chip_writenvram_35042 brcmf_sdio_chip_writenvram 4 35042 NULL
103199 +btmrvl_gpiogap_write_35053 btmrvl_gpiogap_write 3 35053 NULL
103200 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
103201 +store_ifalias_35088 store_ifalias 4 35088 NULL
103202 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
103203 +capi_write_35104 capi_write 3 35104 NULL nohasharray
103204 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
103205 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
103206 +pointer_35138 pointer 0 35138 NULL
103207 +gntdev_alloc_map_35145 gntdev_alloc_map 2 35145 NULL
103208 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
103209 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
103210 +solo_v4l2_init_35179 solo_v4l2_init 2 35179 NULL
103211 +mlx4_ib_get_cq_umem_35184 mlx4_ib_get_cq_umem 5-6 35184 NULL
103212 +iwl_nvm_read_chunk_35198 iwl_nvm_read_chunk 0 35198 NULL
103213 +uprobe_get_swbp_addr_35201 uprobe_get_swbp_addr 0 35201 NULL
103214 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
103215 +_osd_req_alist_elem_size_35216 _osd_req_alist_elem_size 0-2 35216 NULL
103216 +striped_read_35218 striped_read 0-2-8-3 35218 NULL nohasharray
103217 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
103218 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 NULL nohasharray
103219 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 &rx_rx_cmplt_task_read_35226
103220 +gfn_to_page_many_atomic_35234 gfn_to_page_many_atomic 2 35234 NULL
103221 +SYSC_madvise_35241 SYSC_madvise 1 35241 NULL
103222 +set_fd_set_35249 set_fd_set 1 35249 NULL
103223 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
103224 +dis_disc_write_35265 dis_disc_write 3 35265 NULL
103225 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
103226 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
103227 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
103228 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
103229 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
103230 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
103231 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
103232 +sys_setsockopt_35320 sys_setsockopt 5 35320 NULL
103233 +irq_domain_disassociate_many_35325 irq_domain_disassociate_many 2-3 35325 NULL
103234 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
103235 +pskb_network_may_pull_35336 pskb_network_may_pull 2 35336 NULL
103236 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
103237 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
103238 +hpi_alloc_control_cache_35351 hpi_alloc_control_cache 1 35351 NULL
103239 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
103240 +SyS_getxattr_35408 SyS_getxattr 4 35408 NULL
103241 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
103242 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
103243 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
103244 +i915_wedged_read_35474 i915_wedged_read 3 35474 NULL
103245 +ecryptfs_get_zeroed_pages_35483 ecryptfs_get_zeroed_pages 0 35483 NULL
103246 +do_atm_ioctl_35519 do_atm_ioctl 3 35519 NULL
103247 +async_setkey_35521 async_setkey 3 35521 NULL
103248 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
103249 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
103250 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
103251 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
103252 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
103253 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
103254 +spk_msg_set_35586 spk_msg_set 3 35586 NULL
103255 +ReadZReg_35604 ReadZReg 0 35604 NULL
103256 +kernel_readv_35617 kernel_readv 3 35617 NULL
103257 +ixgbe_pci_sriov_configure_35624 ixgbe_pci_sriov_configure 2 35624 NULL
103258 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
103259 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
103260 +store_debug_level_35652 store_debug_level 3 35652 NULL
103261 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
103262 +compat_sys_kexec_load_35674 compat_sys_kexec_load 2 35674 NULL
103263 +dm_table_create_35687 dm_table_create 3 35687 NULL
103264 +SYSC_pwritev_35690 SYSC_pwritev 3 35690 NULL
103265 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
103266 +pci_enable_sriov_35745 pci_enable_sriov 2 35745 NULL
103267 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
103268 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
103269 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
103270 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
103271 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
103272 +fls64_35862 fls64 0 35862 NULL
103273 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
103274 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
103275 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
103276 +SyS_set_mempolicy_35909 SyS_set_mempolicy 3 35909 NULL
103277 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
103278 +rbio_nr_pages_35916 rbio_nr_pages 0-1-2 35916 NULL
103279 +vol_cdev_compat_ioctl_35923 vol_cdev_compat_ioctl 3 35923 NULL
103280 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
103281 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
103282 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
103283 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
103284 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL
103285 +acl_alloc_35979 acl_alloc 1 35979 NULL
103286 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
103287 +koneplus_sysfs_write_35993 koneplus_sysfs_write 6 35993 NULL
103288 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
103289 +ubi_eba_write_leb_36029 ubi_eba_write_leb 5-6 36029 NULL
103290 +__videobuf_alloc_36031 __videobuf_alloc 1 36031 NULL
103291 +account_shadowed_36048 account_shadowed 2 36048 NULL
103292 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
103293 +write_emulate_36065 write_emulate 2-4 36065 NULL
103294 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
103295 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
103296 +ext3_new_blocks_36073 ext3_new_blocks 3 36073 NULL
103297 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
103298 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 NULL
103299 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
103300 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
103301 +compat_ptrace_request_36131 compat_ptrace_request 3-4 36131 NULL
103302 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
103303 +max8925_irq_domain_map_36133 max8925_irq_domain_map 2 36133 NULL
103304 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
103305 +alloc_vm_area_36149 alloc_vm_area 1 36149 NULL
103306 +twl_set_36154 twl_set 2 36154 NULL
103307 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
103308 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
103309 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
103310 +SyS_kexec_load_36176 SyS_kexec_load 2 36176 NULL
103311 +SYSC_sched_getaffinity_36208 SYSC_sched_getaffinity 2 36208 NULL
103312 +SYSC_process_vm_readv_36216 SYSC_process_vm_readv 3-5 36216 NULL
103313 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
103314 +is_dirty_36223 is_dirty 2 36223 NULL
103315 +dma_alloc_attrs_36225 dma_alloc_attrs 0 36225 NULL
103316 +nfqnl_mangle_36226 nfqnl_mangle 4-2 36226 NULL
103317 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
103318 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
103319 +SYSC_getxattr_36242 SYSC_getxattr 4 36242 NULL
103320 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
103321 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
103322 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
103323 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL
103324 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
103325 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
103326 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
103327 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
103328 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
103329 +fuse_get_user_addr_36312 fuse_get_user_addr 0 36312 NULL
103330 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
103331 +lc_create_36332 lc_create 4 36332 NULL
103332 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
103333 +isku_sysfs_read_key_mask_36343 isku_sysfs_read_key_mask 6 36343 NULL
103334 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
103335 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
103336 +to_sector_36361 to_sector 0-1 36361 NULL
103337 +tunables_read_36385 tunables_read 3 36385 NULL
103338 +afs_alloc_flat_call_36399 afs_alloc_flat_call 2-3 36399 NULL
103339 +SyS_sethostname_36417 SyS_sethostname 2 36417 NULL
103340 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
103341 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
103342 +tcf_csum_ipv6_udp_36457 tcf_csum_ipv6_udp 3 36457 NULL
103343 +SyS_process_vm_writev_36476 SyS_process_vm_writev 3-5 36476 NULL
103344 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
103345 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 NULL
103346 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
103347 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
103348 +get_param_l_36518 get_param_l 0 36518 NULL
103349 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
103350 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
103351 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
103352 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
103353 +get_entry_len_36549 get_entry_len 0 36549 NULL
103354 +__kfifo_to_user_36555 __kfifo_to_user 3 36555 NULL nohasharray
103355 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
103356 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
103357 +ssb_bus_scan_36578 ssb_bus_scan 2 36578 NULL
103358 +__erst_read_36579 __erst_read 0 36579 NULL
103359 +put_cmsg_36589 put_cmsg 4 36589 NULL
103360 +pcnet32_realloc_rx_ring_36598 pcnet32_realloc_rx_ring 3 36598 NULL
103361 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
103362 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
103363 +format_decode_36638 format_decode 0 36638 NULL
103364 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
103365 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
103366 +perf_calculate_period_36662 perf_calculate_period 3-2 36662 NULL
103367 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
103368 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
103369 +ptr_to_compat_36680 ptr_to_compat 0 36680 NULL
103370 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 NULL
103371 +sched_clock_36717 sched_clock 0 36717 NULL
103372 +extract_icmp6_fields_36732 extract_icmp6_fields 2 36732 NULL
103373 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4 36740 NULL
103374 +cxgbi_device_register_36746 cxgbi_device_register 1-2 36746 NULL
103375 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
103376 +ip4ip6_err_36772 ip4ip6_err 5 36772 NULL
103377 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
103378 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
103379 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
103380 +tcf_csum_ipv6_tcp_36822 tcf_csum_ipv6_tcp 3 36822 NULL
103381 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
103382 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 NULL
103383 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
103384 +cm_write_36858 cm_write 3 36858 NULL
103385 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
103386 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
103387 +raid56_parity_write_36877 raid56_parity_write 5 36877 NULL
103388 +__btrfs_map_block_36883 __btrfs_map_block 3 36883 NULL
103389 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
103390 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
103391 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
103392 +build_key_36931 build_key 1 36931 NULL
103393 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
103394 +write_leb_36957 write_leb 5 36957 NULL
103395 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
103396 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
103397 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
103398 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
103399 +setxattr_37006 setxattr 4 37006 NULL
103400 +qp_broker_create_37053 qp_broker_create 6-5 37053 NULL nohasharray
103401 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 &qp_broker_create_37053
103402 +SYSC_setxattr_37078 SYSC_setxattr 4 37078 NULL
103403 +parse_command_37079 parse_command 2 37079 NULL
103404 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
103405 +tun_get_user_37094 tun_get_user 5 37094 NULL
103406 +has_wrprotected_page_37123 has_wrprotected_page 2-3 37123 NULL
103407 +snd_hda_get_conn_list_37132 snd_hda_get_conn_list 0 37132 NULL
103408 +msg_word_37164 msg_word 0 37164 NULL
103409 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
103410 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL
103411 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
103412 +__do_replace_37227 __do_replace 5 37227 NULL
103413 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
103414 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
103415 +ath6kl_wmi_set_ie_cmd_37260 ath6kl_wmi_set_ie_cmd 6 37260 NULL
103416 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
103417 +nested_svm_map_37268 nested_svm_map 2 37268 NULL
103418 +c101_run_37279 c101_run 2 37279 NULL
103419 +srp_target_alloc_37288 srp_target_alloc 3 37288 NULL
103420 +isku_sysfs_write_talkfx_37298 isku_sysfs_write_talkfx 6 37298 NULL
103421 +ieee80211_if_read_power_mode_37305 ieee80211_if_read_power_mode 3 37305 NULL
103422 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
103423 +send_msg_37323 send_msg 4 37323 NULL
103424 +brcmf_sdbrcm_membytes_37324 brcmf_sdbrcm_membytes 3-5 37324 NULL
103425 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL
103426 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
103427 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
103428 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
103429 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
103430 +sys_getxattr_37418 sys_getxattr 4 37418 NULL
103431 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
103432 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
103433 +find_next_bit_37422 find_next_bit 0-2-3 37422 &acpi_os_allocate_zeroed_37422
103434 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4 37428 NULL
103435 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
103436 +tty_audit_log_37440 tty_audit_log 5 37440 NULL
103437 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
103438 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
103439 +__remove_37457 __remove 2 37457 NULL
103440 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
103441 +get_est_timing_37484 get_est_timing 0 37484 NULL
103442 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
103443 +kvm_vcpu_compat_ioctl_37500 kvm_vcpu_compat_ioctl 3 37500 NULL
103444 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 NULL
103445 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
103446 +hdr_size_37536 hdr_size 0 37536 NULL
103447 +a2p_37544 a2p 0-1 37544 NULL
103448 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL nohasharray
103449 +nf_nat_mangle_tcp_packet_37551 nf_nat_mangle_tcp_packet 6-8 37551 &sep_create_dcb_dmatables_context_37551
103450 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
103451 +mlx4_get_mgm_entry_size_37607 mlx4_get_mgm_entry_size 0 37607 NULL
103452 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6-3 37611 NULL
103453 +SYSC_mbind_37622 SYSC_mbind 5 37622 NULL
103454 +btrfs_calc_trans_metadata_size_37629 btrfs_calc_trans_metadata_size 0-2 37629 NULL nohasharray
103455 +policy_residency_37629 policy_residency 0 37629 &btrfs_calc_trans_metadata_size_37629
103456 +check_pt_base_37635 check_pt_base 3 37635 NULL
103457 +alloc_fd_37637 alloc_fd 1 37637 NULL
103458 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
103459 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
103460 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
103461 +SYSC_get_mempolicy_37664 SYSC_get_mempolicy 4-3 37664 NULL
103462 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
103463 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
103464 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
103465 +nametbl_header_37698 nametbl_header 2 37698 NULL
103466 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
103467 +dm_thin_remove_block_37724 dm_thin_remove_block 2 37724 NULL
103468 +find_active_uprobe_37733 find_active_uprobe 1 37733 NULL
103469 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
103470 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 6-4-5 37749 NULL
103471 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
103472 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
103473 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
103474 +dma_pte_addr_37784 dma_pte_addr 0 37784 NULL
103475 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
103476 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
103477 +deny_write_access_37813 deny_write_access 0 37813 NULL
103478 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
103479 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-5-4 37827 NULL
103480 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
103481 +isku_sysfs_write_last_set_37868 isku_sysfs_write_last_set 6 37868 NULL nohasharray
103482 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 &isku_sysfs_write_last_set_37868
103483 +sys_setxattr_37880 sys_setxattr 4 37880 NULL
103484 +dvb_net_sec_37884 dvb_net_sec 3 37884 NULL
103485 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
103486 +compat_sys_rt_sigpending_37899 compat_sys_rt_sigpending 2 37899 NULL
103487 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
103488 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 NULL
103489 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
103490 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
103491 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 3-4 37967 NULL
103492 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
103493 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
103494 +vfs_readv_38011 vfs_readv 3 38011 NULL
103495 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
103496 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
103497 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
103498 +SyS_llistxattr_38048 SyS_llistxattr 3 38048 NULL
103499 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL nohasharray
103500 +is_discarded_38058 is_discarded 2 38058 &_xfs_buf_alloc_38058
103501 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
103502 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
103503 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
103504 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
103505 +tcf_csum_ipv4_udp_38089 tcf_csum_ipv4_udp 3 38089 NULL
103506 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
103507 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
103508 +ep0_read_38095 ep0_read 3 38095 NULL
103509 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL
103510 +rbd_obj_read_sync_38098 rbd_obj_read_sync 3-4 38098 NULL
103511 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
103512 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
103513 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 3-4 38153 NULL
103514 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
103515 +cdev_add_38176 cdev_add 2-3 38176 NULL
103516 +brcmf_sdcard_recv_buf_38179 brcmf_sdcard_recv_buf 6 38179 NULL
103517 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
103518 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
103519 +ext3_new_block_38208 ext3_new_block 3 38208 NULL
103520 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
103521 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
103522 +palmas_gpio_to_irq_38235 palmas_gpio_to_irq 2 38235 NULL
103523 +vhost_net_compat_ioctl_38237 vhost_net_compat_ioctl 3 38237 NULL
103524 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
103525 +from_dblock_38256 from_dblock 0-1 38256 NULL
103526 +vmci_qp_broker_set_page_store_38260 vmci_qp_broker_set_page_store 2-3 38260 NULL
103527 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
103528 +SYSC_msgrcv_38268 SYSC_msgrcv 3 38268 &ieee80211_if_read_auto_open_plinks_38268 nohasharray
103529 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &SYSC_msgrcv_38268
103530 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 NULL nohasharray
103531 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 &xfs_bmbt_to_bmdr_38275
103532 +ftdi_process_packet_38281 ftdi_process_packet 4 38281 NULL nohasharray
103533 +swiotlb_sync_single_for_cpu_38281 swiotlb_sync_single_for_cpu 2 38281 &ftdi_process_packet_38281
103534 +gpa_to_gfn_38291 gpa_to_gfn 0-1 38291 NULL
103535 +zd_mac_rx_38296 zd_mac_rx 3 38296 NULL
103536 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
103537 +ida_simple_get_38326 ida_simple_get 2 38326 NULL
103538 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
103539 +pyra_sysfs_write_38370 pyra_sysfs_write 6 38370 NULL
103540 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
103541 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
103542 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 2 38413 NULL
103543 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
103544 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
103545 +asix_write_cmd_async_38420 asix_write_cmd_async 5 38420 NULL
103546 +pcnet32_realloc_tx_ring_38428 pcnet32_realloc_tx_ring 3 38428 NULL
103547 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
103548 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
103549 +i915_min_freq_read_38470 i915_min_freq_read 3 38470 NULL
103550 +kvm_arch_setup_async_pf_38481 kvm_arch_setup_async_pf 3 38481 NULL
103551 +blk_end_bidi_request_38482 blk_end_bidi_request 3-4 38482 NULL
103552 +cpu_to_mem_38501 cpu_to_mem 0 38501 NULL
103553 +dev_names_read_38509 dev_names_read 3 38509 NULL
103554 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
103555 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
103556 +set_queue_count_38519 set_queue_count 0 38519 NULL
103557 +mlx4_ib_db_map_user_38529 mlx4_ib_db_map_user 2 38529 NULL
103558 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
103559 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
103560 +cpu_to_node_38561 cpu_to_node 0 38561 NULL
103561 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
103562 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
103563 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
103564 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
103565 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
103566 +cosa_net_setup_rx_38594 cosa_net_setup_rx 2 38594 NULL
103567 +compat_sys_ptrace_38595 compat_sys_ptrace 3-4 38595 NULL
103568 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
103569 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
103570 +cma_create_area_38642 cma_create_area 2 38642 NULL
103571 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
103572 +qp_broker_alloc_38646 qp_broker_alloc 5-6 38646 NULL
103573 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
103574 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
103575 +skb_tnl_header_len_38669 skb_tnl_header_len 0 38669 NULL
103576 +cfg80211_send_disassoc_38678 cfg80211_send_disassoc 3 38678 NULL
103577 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
103578 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
103579 +rbio_add_io_page_38700 rbio_add_io_page 6 38700 NULL
103580 +find_next_usable_block_38716 find_next_usable_block 1-3 38716 NULL
103581 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
103582 +phys_to_virt_38757 phys_to_virt 0-1 38757 NULL
103583 +udf_readpages_38761 udf_readpages 4 38761 NULL
103584 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
103585 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
103586 +err_decode_38804 err_decode 2 38804 NULL
103587 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
103588 +sys_select_38827 sys_select 1 38827 NULL
103589 +b43_txhdr_size_38832 b43_txhdr_size 0 38832 NULL
103590 +direct_entry_38836 direct_entry 3 38836 NULL
103591 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
103592 +interfaces_38859 interfaces 2 38859 NULL
103593 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
103594 +sizeof_gpio_leds_priv_38882 sizeof_gpio_leds_priv 0-1 38882 NULL
103595 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
103596 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
103597 +process_bulk_data_command_38906 process_bulk_data_command 4 38906 NULL
103598 +ext3_trim_all_free_38929 ext3_trim_all_free 3-4-2 38929 NULL
103599 +sbp_count_se_tpg_luns_38943 sbp_count_se_tpg_luns 0 38943 NULL
103600 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
103601 +C_SYSC_preadv64_38977 C_SYSC_preadv64 3 38977 NULL nohasharray
103602 +usb_maxpacket_38977 usb_maxpacket 0 38977 &C_SYSC_preadv64_38977
103603 +OSDSetBlock_38986 OSDSetBlock 4-2 38986 NULL
103604 +udf_new_block_38999 udf_new_block 4 38999 NULL
103605 +get_nodes_39012 get_nodes 3 39012 NULL
103606 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
103607 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
103608 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
103609 +line6_midibuf_read_39067 line6_midibuf_read 0-3 39067 NULL
103610 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
103611 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
103612 +__kfifo_to_user_r_39123 __kfifo_to_user_r 3 39123 NULL
103613 +ea_foreach_39133 ea_foreach 0 39133 NULL
103614 +generic_permission_39150 generic_permission 0 39150 NULL
103615 +alloc_ring_39151 alloc_ring 2-4 39151 NULL
103616 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
103617 +create_bounce_buffer_39155 create_bounce_buffer 3 39155 NULL
103618 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
103619 +init_list_set_39188 init_list_set 2-3 39188 NULL
103620 +ubi_more_update_data_39189 ubi_more_update_data 4 39189 NULL
103621 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
103622 +qla4_82xx_pci_mem_read_direct_39208 qla4_82xx_pci_mem_read_direct 2 39208 NULL
103623 +vfio_group_fops_compat_ioctl_39219 vfio_group_fops_compat_ioctl 3 39219 NULL
103624 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
103625 +batadv_tt_response_fill_table_39236 batadv_tt_response_fill_table 1 39236 NULL
103626 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
103627 +drm_order_39244 drm_order 0 39244 NULL
103628 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
103629 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
103630 +__skb_cow_39254 __skb_cow 2 39254 NULL
103631 +ath6kl_wmi_set_appie_cmd_39266 ath6kl_wmi_set_appie_cmd 5 39266 NULL
103632 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
103633 +__vmalloc_node_39308 __vmalloc_node 1 39308 NULL
103634 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
103635 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
103636 +__cfg80211_send_deauth_39344 __cfg80211_send_deauth 3 39344 NULL
103637 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3 39351 NULL
103638 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
103639 +do_write_log_from_user_39362 do_write_log_from_user 3 39362 NULL
103640 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
103641 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
103642 +fnic_trace_debugfs_read_39380 fnic_trace_debugfs_read 3 39380 NULL
103643 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
103644 +__send_to_port_39386 __send_to_port 3 39386 NULL
103645 +user_power_read_39414 user_power_read 3 39414 NULL
103646 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
103647 +sys_semop_39457 sys_semop 3 39457 NULL
103648 +ptrace_peek_siginfo_39458 ptrace_peek_siginfo 3 39458 NULL
103649 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
103650 +do_get_mempolicy_39485 do_get_mempolicy 3 39485 NULL
103651 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
103652 +atomic64_read_unchecked_39505 atomic64_read_unchecked 0 39505 NULL
103653 +int_proc_write_39542 int_proc_write 3 39542 NULL
103654 +pp_write_39554 pp_write 3 39554 NULL
103655 +ol_dqblk_block_39558 ol_dqblk_block 0-3-2 39558 NULL
103656 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
103657 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
103658 +handle_response_icmp_39574 handle_response_icmp 7 39574 NULL
103659 +mtdchar_compat_ioctl_39602 mtdchar_compat_ioctl 3 39602 NULL
103660 +n_tty_compat_ioctl_helper_39605 n_tty_compat_ioctl_helper 4 39605 NULL
103661 +ext_depth_39607 ext_depth 0 39607 NULL
103662 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
103663 +sdio_readb_39618 sdio_readb 0 39618 NULL
103664 +set_dev_class_39645 set_dev_class 4 39645 NULL nohasharray
103665 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 &set_dev_class_39645
103666 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
103667 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL nohasharray
103668 +prism2_info_hostscanresults_39657 prism2_info_hostscanresults 3 39657 &tcp_try_rmem_schedule_39657
103669 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
103670 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
103671 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
103672 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
103673 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
103674 +tcf_csum_ipv4_tcp_39713 tcf_csum_ipv4_tcp 4 39713 NULL
103675 +remap_to_origin_clear_discard_39767 remap_to_origin_clear_discard 3 39767 NULL
103676 +ocfs2_pages_per_cluster_39790 ocfs2_pages_per_cluster 0 39790 NULL
103677 +crypto_ablkcipher_blocksize_39811 crypto_ablkcipher_blocksize 0 39811 NULL
103678 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
103679 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
103680 +sys_migrate_pages_39825 sys_migrate_pages 2 39825 NULL
103681 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
103682 +pkt_add_39897 pkt_add 3 39897 NULL
103683 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
103684 +gen_pool_add_virt_39913 gen_pool_add_virt 4 39913 NULL
103685 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
103686 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
103687 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
103688 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
103689 +__spi_async_39932 __spi_async 0 39932 NULL
103690 +__get_order_39935 __get_order 0 39935 NULL
103691 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL nohasharray
103692 +fwnet_pd_new_39947 fwnet_pd_new 4 39947 &error_error_frame_read_39947
103693 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3 39955 NULL
103694 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
103695 +vfio_pci_read_39975 vfio_pci_read 3 39975 NULL
103696 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
103697 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
103698 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
103699 +nf_nat_icmpv6_reply_translation_40023 nf_nat_icmpv6_reply_translation 5 40023 NULL nohasharray
103700 +ivtvfb_write_40023 ivtvfb_write 3 40023 &nf_nat_icmpv6_reply_translation_40023
103701 +disc_pwup_write_40027 disc_pwup_write 3 40027 NULL
103702 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
103703 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
103704 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
103705 +add_tty_40055 add_tty 1 40055 NULL nohasharray
103706 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
103707 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
103708 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
103709 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
103710 +dwc2_max_desc_num_40132 dwc2_max_desc_num 0 40132 NULL
103711 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
103712 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
103713 +pt_write_40159 pt_write 3 40159 NULL
103714 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
103715 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
103716 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
103717 +allocate_probes_40204 allocate_probes 1 40204 NULL
103718 +compat_put_long_40214 compat_put_long 1 40214 NULL
103719 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
103720 +osst_read_40237 osst_read 3 40237 NULL
103721 +lpage_info_slot_40243 lpage_info_slot 1-3 40243 NULL
103722 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4 40248 NULL
103723 +of_get_child_count_40254 of_get_child_count 0 40254 NULL
103724 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
103725 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
103726 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
103727 +_calc_trunk_info_40291 _calc_trunk_info 2 40291 NULL
103728 +crash_free_reserved_phys_range_40292 crash_free_reserved_phys_range 1 40292 NULL
103729 +ubi_io_write_data_40305 ubi_io_write_data 4-5 40305 NULL
103730 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
103731 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
103732 +mmio_read_40348 mmio_read 4 40348 NULL
103733 +usb_dump_interface_40353 usb_dump_interface 0 40353 NULL
103734 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4 40355 NULL
103735 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
103736 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 2-3 40365 NULL
103737 +fwnet_incoming_packet_40380 fwnet_incoming_packet 3 40380 NULL
103738 +brcmf_sdbrcm_get_image_40397 brcmf_sdbrcm_get_image 0-2 40397 NULL
103739 +atmel_rmem16_40450 atmel_rmem16 0 40450 NULL
103740 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
103741 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
103742 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
103743 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
103744 +tty_write_room_40495 tty_write_room 0 40495 NULL
103745 +persistent_ram_new_40501 persistent_ram_new 1-2 40501 NULL
103746 +sg_phys_40507 sg_phys 0 40507 NULL
103747 +TSS_checkhmac2_40520 TSS_checkhmac2 5-7 40520 NULL
103748 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
103749 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
103750 +esp_alloc_tmp_40558 esp_alloc_tmp 3-2 40558 NULL
103751 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
103752 +bdev_sectors_40564 bdev_sectors 0 40564 NULL
103753 +lba_to_map_index_40580 lba_to_map_index 0-1 40580 NULL
103754 +skge_rx_get_40598 skge_rx_get 3 40598 NULL
103755 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
103756 +bl_mark_sectors_init_40613 bl_mark_sectors_init 2-3 40613 NULL
103757 +cpuset_sprintf_cpulist_40627 cpuset_sprintf_cpulist 0 40627 NULL
103758 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
103759 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
103760 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
103761 +fops_read_40672 fops_read 3 40672 NULL
103762 +alloc_rbio_40676 alloc_rbio 4 40676 NULL
103763 +videobuf_dma_init_user_locked_40678 videobuf_dma_init_user_locked 3 40678 NULL
103764 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
103765 +vfio_pci_config_rw_40698 vfio_pci_config_rw 3 40698 NULL
103766 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
103767 +fuse_readpages_40737 fuse_readpages 4 40737 NULL
103768 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
103769 +find_next_zero_bit_le_40744 find_next_zero_bit_le 0-2-3 40744 &xfs_iext_remove_direct_40744
103770 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
103771 +fat_generic_compat_ioctl_40755 fat_generic_compat_ioctl 3 40755 NULL
103772 +card_send_command_40757 card_send_command 3 40757 NULL
103773 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
103774 +pg_write_40766 pg_write 3 40766 NULL
103775 +show_list_40775 show_list 3 40775 NULL
103776 +calcu_metadata_size_40782 calcu_metadata_size 0 40782 NULL
103777 +kfifo_out_copy_r_40784 kfifo_out_copy_r 0-3 40784 NULL
103778 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
103779 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
103780 +netdev_alloc_skb_ip_align_40811 netdev_alloc_skb_ip_align 2 40811 NULL
103781 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
103782 +SyS_mbind_40828 SyS_mbind 5 40828 NULL
103783 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
103784 +isku_sysfs_write_keys_thumbster_40851 isku_sysfs_write_keys_thumbster 6 40851 NULL
103785 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
103786 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
103787 +read_file_queue_40895 read_file_queue 3 40895 NULL
103788 +waiters_read_40902 waiters_read 3 40902 NULL
103789 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
103790 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
103791 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
103792 +snd_vx_create_40948 snd_vx_create 4 40948 NULL
103793 +skb_end_offset_40949 skb_end_offset 0 40949 NULL
103794 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
103795 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
103796 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
103797 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
103798 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
103799 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
103800 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
103801 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
103802 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL
103803 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
103804 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
103805 +nvme_map_user_pages_41093 nvme_map_user_pages 3-4 41093 &roccat_read_41093
103806 +dma_attach_41094 dma_attach 5-6 41094 NULL
103807 +provide_user_output_41105 provide_user_output 3 41105 NULL
103808 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
103809 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
103810 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
103811 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
103812 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
103813 +netif_get_num_default_rss_queues_41187 netif_get_num_default_rss_queues 0 41187 NULL
103814 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
103815 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
103816 +xfs_readdir_41200 xfs_readdir 3 41200 NULL
103817 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
103818 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
103819 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2-3 41255 NULL
103820 +erst_read_41260 erst_read 0 41260 NULL
103821 +__fprog_create_41263 __fprog_create 2 41263 NULL
103822 +setup_cluster_bitmap_41270 setup_cluster_bitmap 4 41270 NULL
103823 +alloc_context_41283 alloc_context 1 41283 NULL
103824 +arch_gnttab_map_shared_41306 arch_gnttab_map_shared 3 41306 NULL
103825 +objio_alloc_io_state_41316 objio_alloc_io_state 6 41316 NULL
103826 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
103827 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
103828 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
103829 +kmp_init_41373 kmp_init 2 41373 NULL
103830 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
103831 +is_writethrough_io_41406 is_writethrough_io 3 41406 NULL
103832 +sys_flistxattr_41407 sys_flistxattr 3 41407 NULL
103833 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
103834 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
103835 +vsock_dev_compat_ioctl_41427 vsock_dev_compat_ioctl 3 41427 NULL
103836 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
103837 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
103838 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
103839 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 4-6 41442 NULL
103840 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
103841 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
103842 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
103843 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
103844 +SyS_get_mempolicy_41495 SyS_get_mempolicy 3-4 41495 NULL
103845 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
103846 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
103847 +ldisc_receive_41516 ldisc_receive 4 41516 NULL
103848 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
103849 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
103850 +nr_status_frames_41559 nr_status_frames 0-1 41559 NULL
103851 +batadv_receive_client_update_packet_41578 batadv_receive_client_update_packet 3 41578 NULL
103852 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
103853 +read_file_rx_chainmask_41605 read_file_rx_chainmask 3 41605 NULL
103854 +vga_io_r_41609 vga_io_r 0 41609 NULL
103855 +tcp_hdrlen_41610 tcp_hdrlen 0 41610 NULL
103856 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 NULL
103857 +a2mp_send_41615 a2mp_send 4 41615 NULL
103858 +btrfs_calc_trunc_metadata_size_41626 btrfs_calc_trunc_metadata_size 0-2 41626 NULL
103859 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
103860 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
103861 +get_std_timing_41654 get_std_timing 0 41654 NULL
103862 +squashfs_cache_init_41656 squashfs_cache_init 2 41656 NULL
103863 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
103864 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
103865 +aac_src_ioremap_41688 aac_src_ioremap 2 41688 NULL
103866 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
103867 +sys_pwritev_41722 sys_pwritev 3 41722 NULL
103868 +get_bios_ebda_41730 get_bios_ebda 0 41730 NULL
103869 +fillonedir_41746 fillonedir 3 41746 NULL
103870 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
103871 +iwl_dbgfs_bt_notif_read_41794 iwl_dbgfs_bt_notif_read 3 41794 NULL
103872 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
103873 +regcache_sync_block_raw_41803 regcache_sync_block_raw 3-4 41803 NULL
103874 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
103875 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
103876 +lp_gpio_to_irq_41822 lp_gpio_to_irq 2 41822 NULL
103877 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
103878 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
103879 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
103880 +ieee80211_rx_radiotap_space_41870 ieee80211_rx_radiotap_space 0 41870 NULL
103881 +get_packet_41914 get_packet 3 41914 NULL
103882 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
103883 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
103884 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
103885 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
103886 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
103887 +read_gssp_41947 read_gssp 3 41947 NULL
103888 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
103889 +portnames_read_41958 portnames_read 3 41958 NULL
103890 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 4 41959 NULL
103891 +dst_mtu_41969 dst_mtu 0 41969 NULL
103892 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
103893 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
103894 +lguest_map_42008 lguest_map 1-2 42008 NULL
103895 +pool_allocate_42012 pool_allocate 3 42012 NULL
103896 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
103897 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
103898 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
103899 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
103900 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
103901 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
103902 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
103903 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
103904 +alloc_bitset_42085 alloc_bitset 1 42085 NULL
103905 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
103906 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
103907 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
103908 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL nohasharray
103909 +dw_dma_cyclic_prep_42113 dw_dma_cyclic_prep 3-4 42113 &sysfs_read_file_42113
103910 +Read_hfc16_stable_42131 Read_hfc16_stable 0 42131 NULL
103911 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
103912 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
103913 +iwl_mvm_send_cmd_42173 iwl_mvm_send_cmd 0 42173 NULL
103914 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
103915 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
103916 +btmrvl_hsmode_write_42252 btmrvl_hsmode_write 3 42252 NULL
103917 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
103918 +netxen_nic_map_indirect_address_128M_42257 netxen_nic_map_indirect_address_128M 2 42257 NULL
103919 +savu_sysfs_write_42273 savu_sysfs_write 6 42273 NULL
103920 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
103921 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
103922 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
103923 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
103924 +gfn_to_hva_42305 gfn_to_hva 0-2 42305 NULL
103925 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 NULL
103926 +free_cblock_42318 free_cblock 2 42318 NULL
103927 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
103928 +tcp_sync_mss_42330 tcp_sync_mss 0-2 42330 NULL
103929 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
103930 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
103931 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
103932 +hash_ipportnet4_expire_42391 hash_ipportnet4_expire 3 42391 NULL
103933 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
103934 +krng_get_random_42420 krng_get_random 3 42420 NULL
103935 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
103936 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
103937 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
103938 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
103939 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
103940 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
103941 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
103942 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
103943 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
103944 +brcmf_sdbrcm_bus_txctl_42492 brcmf_sdbrcm_bus_txctl 3 42492 NULL
103945 +bypass_write_42498 bypass_write 3 42498 NULL
103946 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
103947 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
103948 +snd_emux_create_port_42533 snd_emux_create_port 3 42533 NULL
103949 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
103950 +i915_ring_stop_read_42549 i915_ring_stop_read 3 42549 NULL nohasharray
103951 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 &i915_ring_stop_read_42549
103952 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
103953 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
103954 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
103955 +map_state_42602 map_state 1 42602 NULL nohasharray
103956 +__pskb_pull_42602 __pskb_pull 2 42602 &map_state_42602
103957 +nd_get_link_42603 nd_get_link 0 42603 NULL
103958 +sys_move_pages_42626 sys_move_pages 2 42626 NULL
103959 +resp_write_42628 resp_write 2 42628 NULL
103960 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
103961 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
103962 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
103963 +l2tp_xmit_skb_42672 l2tp_xmit_skb 3 42672 NULL
103964 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
103965 +acpi_dev_get_irqresource_42694 acpi_dev_get_irqresource 2 42694 NULL
103966 +vb2_read_42703 vb2_read 3 42703 NULL
103967 +sierra_net_send_cmd_42708 sierra_net_send_cmd 3 42708 NULL
103968 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 4 42717 NULL
103969 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
103970 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
103971 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
103972 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
103973 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
103974 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL nohasharray
103975 +isku_sysfs_read_info_42781 isku_sysfs_read_info 6 42781 &cryptd_hash_setkey_42781
103976 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
103977 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2 42796 NULL
103978 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2-3 42804 NULL
103979 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
103980 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
103981 +set_arg_42824 set_arg 3 42824 NULL
103982 +si476x_radio_read_rsq_blob_42827 si476x_radio_read_rsq_blob 3 42827 NULL
103983 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
103984 +prandom_u32_42853 prandom_u32 0 42853 NULL
103985 +of_property_count_strings_42863 of_property_count_strings 0 42863 NULL
103986 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
103987 +pskb_expand_head_42881 pskb_expand_head 2-3 42881 NULL
103988 +vt_compat_ioctl_42887 vt_compat_ioctl 3 42887 NULL
103989 +tipc_port_recv_sections_42890 tipc_port_recv_sections 4 42890 NULL
103990 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
103991 +SendTxCommandPacket_42901 SendTxCommandPacket 3 42901 NULL
103992 +hd_end_request_42904 hd_end_request 2 42904 NULL
103993 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
103994 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
103995 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
103996 +sys_sethostname_42962 sys_sethostname 2 42962 NULL
103997 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
103998 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
103999 +snd_timer_user_ioctl_compat_42985 snd_timer_user_ioctl_compat 3 42985 NULL
104000 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 4-2 42990 NULL
104001 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
104002 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
104003 +add_bytes_to_bitmap_43026 add_bytes_to_bitmap 0 43026 NULL
104004 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
104005 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
104006 +nfs_map_group_to_gid_43082 nfs_map_group_to_gid 3 43082 NULL
104007 +cpuset_sprintf_memlist_43088 cpuset_sprintf_memlist 0 43088 NULL
104008 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
104009 +read_file_dfs_43145 read_file_dfs 3 43145 NULL nohasharray
104010 +i2c_hid_get_report_43145 i2c_hid_get_report 0 43145 &read_file_dfs_43145
104011 +uuid_string_43154 uuid_string 0 43154 NULL
104012 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
104013 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
104014 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
104015 +process_measurement_43190 process_measurement 0 43190 NULL
104016 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
104017 +uio_write_43202 uio_write 3 43202 NULL
104018 +iso_callback_43208 iso_callback 3 43208 NULL
104019 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
104020 +atomic_long_add_return_43217 atomic_long_add_return 1 43217 NULL
104021 +comedi_compat_ioctl_43218 comedi_compat_ioctl 3 43218 NULL
104022 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1 43245 NULL
104023 +fixup_leb_43256 fixup_leb 3 43256 NULL
104024 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
104025 +evtchn_write_43278 evtchn_write 3 43278 NULL
104026 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
104027 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
104028 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
104029 +mmu_set_spte_43327 mmu_set_spte 6-7 43327 NULL
104030 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
104031 +kvm_host_page_size_43348 kvm_host_page_size 2 43348 NULL
104032 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
104033 +hash_net4_expire_43378 hash_net4_expire 3 43378 NULL
104034 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1-2 43423 NULL nohasharray
104035 +gdm_wimax_netif_rx_43423 gdm_wimax_netif_rx 3 43423 &__alloc_bootmem_low_43423
104036 +isku_sysfs_write_keys_capslock_43432 isku_sysfs_write_keys_capslock 6 43432 NULL
104037 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
104038 +ucs2_strsize_43438 ucs2_strsize 0 43438 NULL
104039 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
104040 +usemap_size_43443 usemap_size 0-2-1 43443 NULL nohasharray
104041 +usb_string_43443 usb_string 0 43443 &usemap_size_43443
104042 +alloc_new_reservation_43480 alloc_new_reservation 4 43480 NULL
104043 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
104044 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
104045 +do_readlink_43518 do_readlink 2 43518 NULL
104046 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
104047 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
104048 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
104049 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
104050 +ath_rx_init_43564 ath_rx_init 2 43564 NULL
104051 +_fc_frame_alloc_43568 _fc_frame_alloc 1 43568 NULL
104052 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
104053 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
104054 +proc_read_43614 proc_read 3 43614 NULL
104055 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
104056 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 NULL
104057 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4-2 43679 NULL
104058 +calgary_map_page_43686 calgary_map_page 3-4 43686 NULL
104059 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
104060 +drbd_md_first_sector_43729 drbd_md_first_sector 0 43729 NULL
104061 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
104062 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5 43733 NULL
104063 +osdv1_attr_list_elem_size_43747 osdv1_attr_list_elem_size 0-1 43747 NULL
104064 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
104065 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
104066 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
104067 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
104068 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
104069 +btrfs_copy_from_user_43806 btrfs_copy_from_user 3-1 43806 NULL
104070 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
104071 +div64_u64_safe_43815 div64_u64_safe 1-2 43815 NULL
104072 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
104073 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
104074 +p54_download_eeprom_43842 p54_download_eeprom 4 43842 NULL
104075 +read_flush_43851 read_flush 3 43851 NULL
104076 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
104077 +pm860x_bulk_write_43875 pm860x_bulk_write 2-3 43875 NULL
104078 +prism2_sta_send_mgmt_43916 prism2_sta_send_mgmt 5 43916 NULL
104079 +SendString_43928 SendString 3 43928 NULL
104080 +xen_register_gsi_43946 xen_register_gsi 1-2 43946 NULL
104081 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
104082 +__get_required_blob_size_43980 __get_required_blob_size 0-2-3 43980 NULL
104083 +nla_reserve_43984 nla_reserve 3 43984 NULL
104084 +__clkdev_alloc_43990 __clkdev_alloc 1 43990 NULL
104085 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
104086 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &scsi_command_size_43992
104087 +emit_flags_44006 emit_flags 4-3 44006 NULL
104088 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
104089 +swiotlb_unmap_page_44063 swiotlb_unmap_page 2 44063 NULL
104090 +SYSC_add_key_44079 SYSC_add_key 4 44079 NULL
104091 +load_discard_44083 load_discard 3 44083 NULL
104092 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
104093 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
104094 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
104095 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
104096 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
104097 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
104098 +SYSC_set_mempolicy_44176 SYSC_set_mempolicy 3 44176 NULL
104099 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
104100 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
104101 +__set_free_44211 __set_free 2 44211 NULL
104102 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
104103 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
104104 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
104105 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
104106 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
104107 +enlarge_skb_44248 enlarge_skb 2 44248 NULL
104108 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
104109 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
104110 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
104111 +bitmap_scnprintf_44318 bitmap_scnprintf 2 44318 NULL
104112 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
104113 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 5 44343 NULL
104114 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
104115 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
104116 +__is_discarded_44359 __is_discarded 2 44359 NULL
104117 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
104118 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
104119 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
104120 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
104121 +check_user_page_hwpoison_44412 check_user_page_hwpoison 1 44412 NULL
104122 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
104123 +prandom_u32_state_44445 prandom_u32_state 0 44445 NULL
104124 +___alloc_bootmem_node_nopanic_44461 ___alloc_bootmem_node_nopanic 2-3 44461 NULL
104125 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
104126 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
104127 +bio_advance_44496 bio_advance 2 44496 NULL
104128 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
104129 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
104130 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
104131 +spidev_write_44510 spidev_write 3 44510 NULL
104132 +sys_msgsnd_44537 sys_msgsnd 3 44537 NULL nohasharray
104133 +comm_write_44537 comm_write 3 44537 &sys_msgsnd_44537
104134 +hash_ipport4_expire_44564 hash_ipport4_expire 3 44564 NULL
104135 +dgrp_config_proc_write_44571 dgrp_config_proc_write 3 44571 NULL
104136 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
104137 +slip_compat_ioctl_44599 slip_compat_ioctl 4 44599 NULL
104138 +brcmf_sdbrcm_glom_len_44618 brcmf_sdbrcm_glom_len 0 44618 NULL
104139 +cfpkt_add_body_44630 cfpkt_add_body 3 44630 NULL
104140 +ext2_new_block_44645 ext2_new_block 2 44645 NULL
104141 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
104142 +mpi_resize_44674 mpi_resize 2 44674 NULL
104143 +ts_read_44687 ts_read 3 44687 NULL
104144 +qib_get_user_pages_44689 qib_get_user_pages 1-2 44689 NULL
104145 +xfer_to_user_44713 xfer_to_user 3 44713 NULL
104146 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
104147 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
104148 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
104149 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
104150 +WIL_GET_BITS_44747 WIL_GET_BITS 0-1-2-3 44747 NULL
104151 +set_brk_44749 set_brk 1 44749 NULL
104152 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
104153 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
104154 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4 44769 NULL
104155 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
104156 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
104157 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
104158 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
104159 +mei_cl_read_start_44824 mei_cl_read_start 2 44824 NULL
104160 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
104161 +sisusb_write_44834 sisusb_write 3 44834 NULL
104162 +nl80211_send_unprot_disassoc_44846 nl80211_send_unprot_disassoc 4 44846 NULL
104163 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
104164 +cubic_root_44848 cubic_root 1 44848 NULL
104165 +copydesc_user_44855 copydesc_user 3 44855 NULL
104166 +skb_availroom_44883 skb_availroom 0 44883 NULL
104167 +nf_bridge_encap_header_len_44890 nf_bridge_encap_header_len 0 44890 NULL
104168 +do_tty_write_44896 do_tty_write 5 44896 NULL
104169 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
104170 +nf_nat_seq_adjust_44989 nf_nat_seq_adjust 4 44989 NULL
104171 +map_index_to_lba_44993 map_index_to_lba 0-1 44993 NULL
104172 +bytepos_delta_45017 bytepos_delta 0 45017 NULL
104173 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
104174 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
104175 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
104176 +sel_write_user_45060 sel_write_user 3 45060 NULL
104177 +vmscan_swappiness_45062 vmscan_swappiness 0 45062 NULL
104178 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL nohasharray
104179 +do_video_ioctl_45069 do_video_ioctl 3 45069 &snd_mixart_BA0_read_45069
104180 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
104181 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
104182 +usbdev_read_45114 usbdev_read 3 45114 NULL
104183 +isku_sysfs_write_reset_45133 isku_sysfs_write_reset 6 45133 NULL
104184 +send_to_tty_45141 send_to_tty 3 45141 NULL
104185 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
104186 +crypto_aead_blocksize_45148 crypto_aead_blocksize 0 45148 NULL
104187 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
104188 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
104189 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
104190 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
104191 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
104192 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
104193 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 NULL
104194 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
104195 +add_child_45201 add_child 4 45201 NULL
104196 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
104197 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
104198 +__dirty_45228 __dirty 2 45228 NULL
104199 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
104200 +prism2_pda_proc_read_45246 prism2_pda_proc_read 3 45246 NULL
104201 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
104202 +vcc_compat_ioctl_45291 vcc_compat_ioctl 3 45291 NULL
104203 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
104204 +pte_val_45313 pte_val 0 45313 NULL
104205 +__i2c_hid_command_45321 __i2c_hid_command 0 45321 NULL
104206 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
104207 +lane2_associate_req_45398 lane2_associate_req 4 45398 NULL
104208 +keymap_store_45406 keymap_store 4 45406 NULL
104209 +paging64_gva_to_gpa_45421 paging64_gva_to_gpa 2 45421 NULL nohasharray
104210 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 &paging64_gva_to_gpa_45421
104211 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
104212 +intel_render_ring_init_dri_45446 intel_render_ring_init_dri 2-3 45446 NULL nohasharray
104213 +SYSC_mremap_45446 SYSC_mremap 5-1-2 45446 &intel_render_ring_init_dri_45446
104214 +__node_remap_45458 __node_remap 4 45458 NULL
104215 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
104216 +udp_manip_pkt_45467 udp_manip_pkt 4 45467 NULL
104217 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
104218 +arizona_init_fll_45503 arizona_init_fll 5 45503 NULL
104219 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
104220 +sys_lgetxattr_45531 sys_lgetxattr 4 45531 NULL
104221 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
104222 +copy_macs_45534 copy_macs 4 45534 NULL
104223 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
104224 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
104225 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
104226 +atomic_long_sub_return_45551 atomic_long_sub_return 1 45551 NULL
104227 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
104228 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
104229 +_regmap_bus_raw_write_45559 _regmap_bus_raw_write 2 45559 NULL
104230 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
104231 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
104232 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
104233 +rdma_set_ib_paths_45592 rdma_set_ib_paths 3 45592 NULL
104234 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
104235 +audit_log_n_hex_45617 audit_log_n_hex 3 45617 NULL
104236 +ebitmap_next_positive_45651 ebitmap_next_positive 3 45651 NULL
104237 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
104238 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
104239 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
104240 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
104241 +dm_compat_ctl_ioctl_45692 dm_compat_ctl_ioctl 3 45692 NULL
104242 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
104243 +bscnl_emit_45699 bscnl_emit 2-5-0 45699 &unix_dgram_sendmsg_45699
104244 +dvb_ca_en50221_init_45718 dvb_ca_en50221_init 4 45718 NULL
104245 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL
104246 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3 45748 NULL nohasharray
104247 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
104248 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
104249 +nilfs_compat_ioctl_45769 nilfs_compat_ioctl 3 45769 NULL
104250 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
104251 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
104252 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
104253 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
104254 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
104255 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
104256 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
104257 +isdn_write_45863 isdn_write 3 45863 NULL
104258 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
104259 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
104260 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
104261 +wm_adsp_region_to_reg_45915 wm_adsp_region_to_reg 0-2 45915 NULL
104262 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
104263 +nf_nat_ftp_fmt_cmd_45926 nf_nat_ftp_fmt_cmd 0 45926 NULL
104264 +smp_scan_config_45934 smp_scan_config 1 45934 NULL
104265 +alloc_mr_45935 alloc_mr 1 45935 NULL
104266 +split_large_page_45941 split_large_page 2 45941 NULL
104267 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
104268 +ezusb_writememory_45976 ezusb_writememory 4 45976 NULL
104269 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
104270 +ore_calc_stripe_info_46023 ore_calc_stripe_info 2 46023 NULL
104271 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
104272 +get_free_entries_46030 get_free_entries 1 46030 NULL
104273 +__access_remote_vm_46031 __access_remote_vm 0-5-3 46031 NULL
104274 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
104275 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
104276 +line6_midibuf_bytes_used_46059 line6_midibuf_bytes_used 0 46059 NULL
104277 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6 46060 NULL nohasharray
104278 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
104279 +slhc_toss_46066 slhc_toss 0 46066 NULL
104280 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
104281 +vfio_config_do_rw_46091 vfio_config_do_rw 3 46091 NULL
104282 +ata_host_alloc_46094 ata_host_alloc 2 46094 NULL
104283 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
104284 +pkt_ctl_compat_ioctl_46110 pkt_ctl_compat_ioctl 3 46110 NULL
104285 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 NULL nohasharray
104286 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 &memcg_update_array_size_46111
104287 +C_SYSC_writev_46113 C_SYSC_writev 3 46113 NULL
104288 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
104289 +paging32_walk_addr_nested_46121 paging32_walk_addr_nested 3 46121 NULL
104290 +vb2_dma_sg_get_userptr_46146 vb2_dma_sg_get_userptr 2 46146 NULL
104291 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
104292 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
104293 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
104294 +add_conn_list_46197 add_conn_list 3 46197 NULL
104295 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
104296 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
104297 +dsp_write_46218 dsp_write 2 46218 NULL
104298 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
104299 +nf_nat_ftp_46265 nf_nat_ftp 6 46265 NULL
104300 +ReadReg_46277 ReadReg 0 46277 NULL
104301 +batadv_iv_ogm_queue_add_46319 batadv_iv_ogm_queue_add 3 46319 NULL
104302 +qlcnic_83xx_sysfs_flash_bulk_write_46320 qlcnic_83xx_sysfs_flash_bulk_write 4 46320 NULL
104303 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 NULL
104304 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
104305 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
104306 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
104307 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
104308 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
104309 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
104310 +hash_ipportip6_expire_46443 hash_ipportip6_expire 3 46443 NULL
104311 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
104312 +filldir64_46469 filldir64 3 46469 NULL
104313 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
104314 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
104315 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
104316 +kmsg_read_46514 kmsg_read 3 46514 NULL
104317 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
104318 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
104319 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
104320 +mv_get_hc_count_46554 mv_get_hc_count 0 46554 NULL
104321 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
104322 +irq_domain_associate_46564 irq_domain_associate 2 46564 NULL
104323 +dn_current_mss_46574 dn_current_mss 0 46574 NULL
104324 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
104325 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
104326 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
104327 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
104328 +__kfifo_out_r_46623 __kfifo_out_r 0-3 46623 NULL
104329 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
104330 +vfs_getxattr_alloc_46649 vfs_getxattr_alloc 0 46649 NULL
104331 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
104332 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
104333 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
104334 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
104335 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
104336 +prepare_copy_46725 prepare_copy 2 46725 NULL
104337 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
104338 +set_memory_wc_46747 set_memory_wc 1 46747 NULL
104339 +ext4_count_free_46754 ext4_count_free 2 46754 NULL nohasharray
104340 +pte_pfn_46754 pte_pfn 0 46754 &ext4_count_free_46754
104341 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
104342 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
104343 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
104344 +_sys_packet_req_46793 _sys_packet_req 4 46793 NULL
104345 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
104346 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
104347 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
104348 +spi_async_46857 spi_async 0 46857 NULL
104349 +vsnprintf_46863 vsnprintf 0 46863 NULL nohasharray
104350 +SyS_move_pages_46863 SyS_move_pages 2 46863 &vsnprintf_46863
104351 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
104352 +sip_sprintf_addr_46872 sip_sprintf_addr 0 46872 NULL
104353 +rvmalloc_46873 rvmalloc 1 46873 NULL
104354 +qp_memcpy_from_queue_iov_46874 qp_memcpy_from_queue_iov 4-5 46874 NULL
104355 +hpi_read_word_nolock_46881 hpi_read_word_nolock 0 46881 NULL
104356 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
104357 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
104358 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
104359 +ol_dqblk_off_46904 ol_dqblk_off 3-2 46904 NULL
104360 +ieee80211_if_fmt_power_mode_46906 ieee80211_if_fmt_power_mode 3 46906 NULL
104361 +wlcore_alloc_hw_46917 wlcore_alloc_hw 1 46917 NULL
104362 +fb_write_46924 fb_write 3 46924 NULL
104363 +btmrvl_curpsmode_read_46939 btmrvl_curpsmode_read 3 46939 NULL
104364 +kvm_register_read_46948 kvm_register_read 0 46948 NULL
104365 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
104366 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
104367 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
104368 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
104369 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
104370 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
104371 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
104372 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
104373 +add_free_space_entry_47005 add_free_space_entry 2 47005 NULL
104374 +__map_single_47020 __map_single 3-4-7 47020 NULL
104375 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2 47024 NULL
104376 +swiotlb_sync_single_47031 swiotlb_sync_single 2 47031 NULL
104377 +set_dis_bypass_pfs_47038 set_dis_bypass_pfs 3 47038 NULL
104378 +fs_path_len_47060 fs_path_len 0 47060 NULL
104379 +ufs_new_fragments_47070 ufs_new_fragments 3-5-4 47070 NULL
104380 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
104381 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
104382 +iwl_dump_nic_event_log_47089 iwl_dump_nic_event_log 0 47089 NULL
104383 +mousedev_read_47123 mousedev_read 3 47123 NULL
104384 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
104385 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
104386 +persistent_ram_iomap_47156 persistent_ram_iomap 1-2 47156 NULL
104387 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
104388 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
104389 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
104390 +svc_pool_map_alloc_arrays_47181 svc_pool_map_alloc_arrays 2 47181 NULL
104391 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
104392 +ioremap_cache_47189 ioremap_cache 1-2 47189 NULL
104393 +gnttab_set_map_op_47206 gnttab_set_map_op 2 47206 NULL
104394 +l2headersize_47238 l2headersize 0 47238 NULL
104395 +options_write_47243 options_write 3 47243 NULL
104396 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
104397 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
104398 +ablkcipher_next_slow_47274 ablkcipher_next_slow 4-3 47274 NULL
104399 +tty_audit_log_47280 tty_audit_log 8 47280 NULL
104400 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
104401 +vsnprintf_47291 vsnprintf 0 47291 NULL
104402 +SYSC_semop_47292 SYSC_semop 3 47292 NULL
104403 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
104404 +SyS_madvise_47354 SyS_madvise 1 47354 NULL
104405 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
104406 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
104407 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
104408 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
104409 +nv_rd32_47390 nv_rd32 0 47390 NULL nohasharray
104410 +trace_options_core_read_47390 trace_options_core_read 3 47390 &nv_rd32_47390
104411 +nametbl_list_47391 nametbl_list 2 47391 NULL
104412 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
104413 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
104414 +gfn_to_pfn_prot_47398 gfn_to_pfn_prot 2 47398 NULL
104415 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
104416 +sta_vht_capa_read_47409 sta_vht_capa_read 3 47409 NULL
104417 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
104418 +vzalloc_47421 vzalloc 1 47421 NULL
104419 +hash_ipportip4_expire_47426 hash_ipportip4_expire 3 47426 NULL
104420 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
104421 +__load_mapping_47460 __load_mapping 2 47460 NULL
104422 +nvme_trans_send_fw_cmd_47479 nvme_trans_send_fw_cmd 4 47479 NULL
104423 +wb_force_mapping_47485 wb_force_mapping 2 47485 NULL nohasharray
104424 +newpart_47485 newpart 6 47485 &wb_force_mapping_47485
104425 +core_sys_select_47494 core_sys_select 1 47494 NULL
104426 +alloc_arraycache_47505 alloc_arraycache 2 47505 NULL
104427 +unlink_simple_47506 unlink_simple 3 47506 NULL
104428 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
104429 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
104430 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
104431 +oz_events_read_47535 oz_events_read 3 47535 NULL
104432 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
104433 +read_ldt_47570 read_ldt 2 47570 NULL
104434 +_rtl_rx_get_padding_47572 _rtl_rx_get_padding 0 47572 NULL nohasharray
104435 +isku_sysfs_read_last_set_47572 isku_sysfs_read_last_set 6 47572 &_rtl_rx_get_padding_47572
104436 +pci_iomap_47575 pci_iomap 3 47575 NULL
104437 +rpipe_get_idx_47579 rpipe_get_idx 2 47579 NULL
104438 +SYSC_fcntl64_47581 SYSC_fcntl64 3 47581 NULL
104439 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
104440 +sctp_ssnmap_new_47608 sctp_ssnmap_new 1-2 47608 NULL
104441 +uea_request_47613 uea_request 4 47613 NULL
104442 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
104443 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
104444 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
104445 +__build_packet_message_47643 __build_packet_message 3-9 47643 NULL
104446 +global_rt_runtime_47712 global_rt_runtime 0 47712 NULL
104447 +save_microcode_47717 save_microcode 3 47717 NULL
104448 +bits_to_user_47733 bits_to_user 2-3 47733 NULL
104449 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
104450 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
104451 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
104452 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
104453 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
104454 +i915_wedged_write_47771 i915_wedged_write 3 47771 NULL
104455 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
104456 +SyS_setgroups16_47780 SyS_setgroups16 1 47780 NULL
104457 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
104458 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
104459 +stmmac_set_bfsize_47834 stmmac_set_bfsize 0 47834 NULL
104460 +KEY_SIZE_47855 KEY_SIZE 0 47855 NULL
104461 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
104462 +vhci_read_47878 vhci_read 3 47878 NULL
104463 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
104464 +load_mapping_47904 load_mapping 3 47904 NULL
104465 +osd_req_read_sg_47905 osd_req_read_sg 5 47905 NULL
104466 +comedi_write_47926 comedi_write 3 47926 NULL
104467 +nvme_trans_get_blk_desc_len_47946 nvme_trans_get_blk_desc_len 0-2 47946 NULL
104468 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
104469 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
104470 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
104471 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
104472 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
104473 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
104474 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
104475 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
104476 +SYSC_writev_48040 SYSC_writev 3 48040 NULL
104477 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
104478 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
104479 +palmas_bulk_write_48068 palmas_bulk_write 2-3-5 48068 NULL
104480 +disc_write_48070 disc_write 3 48070 NULL
104481 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
104482 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5 48102 NULL
104483 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
104484 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
104485 +set_discoverable_48141 set_discoverable 4 48141 NULL
104486 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
104487 +bitmap_onto_48152 bitmap_onto 4 48152 NULL
104488 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
104489 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
104490 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL nohasharray
104491 +rbd_obj_method_sync_48170 rbd_obj_method_sync 8 48170 &ocfs2_find_next_zero_bit_unaligned_48170
104492 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
104493 +init_ipath_48187 init_ipath 1 48187 NULL
104494 +brcmf_sdio_chip_cm3_exitdl_48192 brcmf_sdio_chip_cm3_exitdl 4 48192 NULL
104495 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
104496 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
104497 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
104498 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
104499 +read_file_recv_48232 read_file_recv 3 48232 NULL
104500 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL
104501 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
104502 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
104503 +send_set_info_48288 send_set_info 7 48288 NULL
104504 +set_disc_pwup_pfs_48300 set_disc_pwup_pfs 3 48300 NULL
104505 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
104506 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
104507 +hash_setkey_48310 hash_setkey 3 48310 NULL
104508 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
104509 +skb_add_data_48363 skb_add_data 3 48363 NULL
104510 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
104511 +ixgbe_pci_sriov_enable_48410 ixgbe_pci_sriov_enable 2 48410 NULL
104512 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
104513 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
104514 +nfs4_alloc_pages_48426 nfs4_alloc_pages 1 48426 NULL
104515 +print_filtered_48442 print_filtered 2-0 48442 NULL
104516 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
104517 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 NULL
104518 +send_control_msg_48498 send_control_msg 6 48498 NULL
104519 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
104520 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
104521 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
104522 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
104523 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
104524 +wiimote_hid_send_48528 wiimote_hid_send 3 48528 NULL
104525 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
104526 +named_distribute_48544 named_distribute 4 48544 NULL
104527 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
104528 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
104529 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
104530 +mtd_read_48655 mtd_read 0 48655 NULL
104531 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
104532 +ore_get_rw_state_48667 ore_get_rw_state 4 48667 NULL
104533 +sm501_create_subdev_48668 sm501_create_subdev 3-4 48668 NULL nohasharray
104534 +sys_setgroups_48668 sys_setgroups 1 48668 &sm501_create_subdev_48668
104535 +altera_drscan_48698 altera_drscan 2 48698 NULL
104536 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
104537 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
104538 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
104539 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 NULL
104540 +lua_sysfs_write_48797 lua_sysfs_write 6 48797 NULL
104541 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
104542 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
104543 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
104544 +efi_memory_uc_48828 efi_memory_uc 1 48828 NULL
104545 +azx_get_position_48841 azx_get_position 0 48841 NULL
104546 +vc_do_resize_48842 vc_do_resize 3-4 48842 NULL
104547 +C_SYSC_pwritev64_48864 C_SYSC_pwritev64 3 48864 NULL nohasharray
104548 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 &C_SYSC_pwritev64_48864
104549 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
104550 +sys_setgroups16_48882 sys_setgroups16 1 48882 NULL
104551 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
104552 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
104553 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
104554 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
104555 +gdth_isa_probe_one_48925 gdth_isa_probe_one 1 48925 NULL
104556 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
104557 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
104558 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
104559 +vmci_handle_arr_create_48971 vmci_handle_arr_create 1 48971 NULL
104560 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
104561 +_alloc_set_attr_list_48991 _alloc_set_attr_list 4 48991 NULL
104562 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
104563 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
104564 +filemap_check_errors_49022 filemap_check_errors 0 49022 NULL
104565 +transient_status_49027 transient_status 4 49027 NULL
104566 +ipath_reg_user_mr_49038 ipath_reg_user_mr 2-3 49038 NULL
104567 +setup_msi_irq_49052 setup_msi_irq 3-4 49052 NULL
104568 +ubi_read_49061 ubi_read 0 49061 NULL
104569 +scsi_register_49094 scsi_register 2 49094 NULL
104570 +paging64_walk_addr_nested_49100 paging64_walk_addr_nested 3 49100 NULL
104571 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
104572 +check_exists_49119 check_exists 2 49119 NULL nohasharray
104573 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 &check_exists_49119
104574 +pt_read_49136 pt_read 3 49136 NULL
104575 +tipc_multicast_49144 tipc_multicast 5 49144 NULL
104576 +atyfb_setup_generic_49151 atyfb_setup_generic 3 49151 NULL
104577 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
104578 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
104579 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
104580 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
104581 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
104582 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
104583 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
104584 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
104585 +resp_write_same_49217 resp_write_same 2 49217 NULL
104586 +nouveau_therm_create__49228 nouveau_therm_create_ 4 49228 NULL
104587 +nouveau_i2c_port_create__49237 nouveau_i2c_port_create_ 6 49237 NULL
104588 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
104589 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
104590 +isku_sysfs_read_keys_media_49268 isku_sysfs_read_keys_media 6 49268 NULL
104591 +osd_req_add_get_attr_list_49278 osd_req_add_get_attr_list 3 49278 NULL
104592 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
104593 +uio_read_49300 uio_read 3 49300 NULL
104594 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
104595 +isku_sysfs_read_keys_macro_49312 isku_sysfs_read_keys_macro 6 49312 NULL
104596 +SYSC_mincore_49319 SYSC_mincore 1 49319 NULL
104597 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
104598 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-3-4 49330 NULL
104599 +cfpkt_setlen_49343 cfpkt_setlen 2 49343 NULL
104600 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
104601 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-5-3 49370 NULL
104602 +px_raw_event_49371 px_raw_event 4 49371 NULL
104603 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
104604 +applesmc_create_nodes_49392 applesmc_create_nodes 2 49392 NULL
104605 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
104606 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
104607 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
104608 +md_domain_init_49432 md_domain_init 2 49432 NULL
104609 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
104610 +get_lru_size_49441 get_lru_size 0 49441 NULL
104611 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
104612 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
104613 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
104614 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
104615 +SyS_listxattr_49519 SyS_listxattr 3 49519 NULL
104616 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
104617 +acpi_os_ioremap_49523 acpi_os_ioremap 1-2 49523 NULL
104618 +smk_write_access_49561 smk_write_access 3 49561 NULL
104619 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
104620 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
104621 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
104622 +tap_write_49595 tap_write 3 49595 NULL
104623 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
104624 +btrfs_mksubvol_49616 btrfs_mksubvol 3 49616 NULL
104625 +heap_init_49617 heap_init 2 49617 NULL
104626 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
104627 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
104628 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
104629 +SyS_pwritev_49688 SyS_pwritev 3 49688 NULL
104630 +sys_gethostname_49698 sys_gethostname 2 49698 NULL
104631 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
104632 +dm_thin_insert_block_49720 dm_thin_insert_block 2-3 49720 NULL
104633 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
104634 +sys_fsetxattr_49736 sys_fsetxattr 4 49736 NULL
104635 +check_frame_49741 check_frame 0 49741 NULL
104636 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
104637 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
104638 +fuse_wr_pages_49753 fuse_wr_pages 0-1-2 49753 NULL
104639 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
104640 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
104641 +isku_sysfs_write_49767 isku_sysfs_write 6-5 49767 NULL
104642 +ceph_osdc_readpages_49789 ceph_osdc_readpages 10-4 49789 NULL
104643 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
104644 +arch_gnttab_map_status_49812 arch_gnttab_map_status 3 49812 NULL
104645 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
104646 +add_uuid_49831 add_uuid 4 49831 NULL
104647 +tcf_csum_ipv4_tcp_49834 tcf_csum_ipv4_tcp 3 49834 NULL
104648 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
104649 +twl4030_write_49846 twl4030_write 2 49846 NULL
104650 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
104651 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
104652 +btrfs_subvolume_reserve_metadata_49859 btrfs_subvolume_reserve_metadata 3 49859 NULL
104653 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
104654 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
104655 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
104656 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
104657 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
104658 +b43legacy_pio_read_49978 b43legacy_pio_read 0 49978 NULL
104659 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
104660 +sta2x11_swiotlb_alloc_coherent_49994 sta2x11_swiotlb_alloc_coherent 2 49994 NULL
104661 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
104662 +__module_alloc_50004 __module_alloc 1 50004 NULL
104663 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
104664 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
104665 +isdn_read_50021 isdn_read 3 50021 NULL
104666 +qp_alloc_queue_50028 qp_alloc_queue 1 50028 NULL
104667 +alloc_ebda_hpc_50046 alloc_ebda_hpc 1-2 50046 NULL
104668 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
104669 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
104670 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
104671 +pcpu_get_vm_areas_50085 pcpu_get_vm_areas 3 50085 NULL
104672 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
104673 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
104674 +read_file_slot_50111 read_file_slot 3 50111 NULL
104675 +SYSC_preadv_50134 SYSC_preadv 3 50134 NULL
104676 +copy_items_50140 copy_items 6 50140 NULL
104677 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
104678 +set_cmd_header_50155 set_cmd_header 0 50155 NULL
104679 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
104680 +aac_nark_ioremap_50163 aac_nark_ioremap 2 50163 NULL nohasharray
104681 +kmalloc_node_50163 kmalloc_node 1 50163 &aac_nark_ioremap_50163
104682 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
104683 +odev_update_50169 odev_update 2 50169 NULL
104684 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
104685 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172
104686 +ib_send_cm_drep_50186 ib_send_cm_drep 3 50186 NULL
104687 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 4-6 50198 NULL
104688 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
104689 +ieee80211_skb_resize_50211 ieee80211_skb_resize 3 50211 NULL
104690 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
104691 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
104692 +afs_extract_data_50261 afs_extract_data 5 50261 NULL
104693 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
104694 +soc_codec_reg_show_50302 soc_codec_reg_show 0 50302 NULL
104695 +SYSC_flistxattr_50307 SYSC_flistxattr 3 50307 NULL
104696 +SYSC_sched_setaffinity_50310 SYSC_sched_setaffinity 2 50310 NULL
104697 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
104698 +do_launder_page_50329 do_launder_page 0 50329 NULL
104699 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
104700 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
104701 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
104702 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
104703 +roccat_common2_send_with_status_50343 roccat_common2_send_with_status 4 50343 NULL
104704 +tpm_read_50344 tpm_read 3 50344 NULL
104705 +sched_clock_remote_50347 sched_clock_remote 0 50347 NULL
104706 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
104707 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
104708 +unpack_u16_chunk_50357 unpack_u16_chunk 0 50357 NULL
104709 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
104710 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
104711 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
104712 +hash_ip6_expire_50390 hash_ip6_expire 3 50390 NULL
104713 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
104714 +ceph_writepages_osd_request_50423 ceph_writepages_osd_request 5 50423 NULL
104715 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
104716 +validate_acl_mac_addrs_50429 validate_acl_mac_addrs 0 50429 NULL
104717 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL
104718 +calc_csum_metadata_size_50448 calc_csum_metadata_size 0 50448 NULL
104719 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
104720 +force_mapping_50464 force_mapping 2 50464 NULL
104721 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
104722 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
104723 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
104724 +fwnet_receive_packet_50537 fwnet_receive_packet 9 50537 NULL
104725 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
104726 +hme_read_desc32_50574 hme_read_desc32 0 50574 NULL
104727 +fat_readpages_50582 fat_readpages 4 50582 NULL
104728 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
104729 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
104730 +sge_rx_50594 sge_rx 3 50594 NULL
104731 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
104732 +__ffs_50625 __ffs 0 50625 NULL
104733 +regcache_rbtree_write_50629 regcache_rbtree_write 2 50629 NULL
104734 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
104735 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL nohasharray
104736 +sys_readv_50664 sys_readv 3 50664 &ath6kl_tm_rx_event_50664
104737 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
104738 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2 50669 NULL
104739 +btmrvl_psstate_read_50683 btmrvl_psstate_read 3 50683 NULL
104740 +swiotlb_free_coherent_50690 swiotlb_free_coherent 4 50690 NULL
104741 +paging32_gva_to_gpa_50696 paging32_gva_to_gpa 2 50696 NULL
104742 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
104743 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
104744 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
104745 +skb_padto_50759 skb_padto 2 50759 NULL
104746 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
104747 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
104748 +bio_alloc_map_data_50782 bio_alloc_map_data 1-2 50782 NULL
104749 +tpm_write_50798 tpm_write 3 50798 NULL
104750 +write_flush_50803 write_flush 3 50803 NULL
104751 +dvb_play_50814 dvb_play 3 50814 NULL
104752 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
104753 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
104754 +SetArea_50835 SetArea 4 50835 NULL nohasharray
104755 +create_mem_extents_50835 create_mem_extents 0 50835 &SetArea_50835
104756 +videobuf_dma_init_user_50839 videobuf_dma_init_user 3 50839 NULL
104757 +self_check_write_50856 self_check_write 5 50856 NULL
104758 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
104759 +SyS_lgetxattr_50889 SyS_lgetxattr 4 50889 NULL
104760 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
104761 +osd_req_write_sg_50908 osd_req_write_sg 5 50908 NULL
104762 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
104763 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
104764 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
104765 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
104766 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
104767 +SyS_setxattr_50957 SyS_setxattr 4 50957 NULL
104768 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
104769 +timeout_write_50991 timeout_write 3 50991 NULL
104770 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL
104771 +proc_write_51003 proc_write 3 51003 NULL
104772 +snd_pcm_default_page_ops_51021 snd_pcm_default_page_ops 2 51021 NULL
104773 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
104774 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
104775 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
104776 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
104777 +dump_midi_51040 dump_midi 3 51040 NULL
104778 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
104779 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
104780 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
104781 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
104782 +solo_enc_v4l2_init_51094 solo_enc_v4l2_init 2 51094 NULL
104783 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
104784 +ti_recv_51110 ti_recv 3 51110 NULL
104785 +dgrp_net_read_51113 dgrp_net_read 3 51113 NULL
104786 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
104787 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
104788 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
104789 +set_dirty_51144 set_dirty 3 51144 NULL
104790 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
104791 +compat_sys_pwritev64_51151 compat_sys_pwritev64 3 51151 NULL
104792 +blk_bio_map_sg_51213 blk_bio_map_sg 0 51213 NULL
104793 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
104794 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
104795 +tipc_send_51238 tipc_send 4 51238 NULL
104796 +drm_property_create_51239 drm_property_create 4 51239 NULL
104797 +st_read_51251 st_read 3 51251 NULL
104798 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
104799 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
104800 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
104801 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL
104802 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
104803 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
104804 +get_cell_51316 get_cell 2 51316 NULL
104805 +init_map_ipmac_51317 init_map_ipmac 4-3-5 51317 NULL
104806 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
104807 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
104808 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
104809 +compat_arch_ptrace_51337 compat_arch_ptrace 3-4 51337 &alloc_smp_req_51337
104810 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
104811 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
104812 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
104813 +ieee80211_wx_set_gen_ie_51399 ieee80211_wx_set_gen_ie 3 51399 NULL
104814 +ceph_sync_read_51410 ceph_sync_read 3 51410 NULL
104815 +x86_swiotlb_free_coherent_51421 x86_swiotlb_free_coherent 4 51421 NULL
104816 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
104817 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
104818 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
104819 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
104820 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
104821 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
104822 +vaddr_51480 vaddr 0 51480 NULL
104823 +skb_inner_mac_header_51482 skb_inner_mac_header 0 51482 NULL nohasharray
104824 +btrfs_find_space_cluster_51482 btrfs_find_space_cluster 5 51482 &skb_inner_mac_header_51482
104825 +__cpa_process_fault_51502 __cpa_process_fault 2 51502 NULL
104826 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
104827 +load_pdptrs_51541 load_pdptrs 3 51541 NULL
104828 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
104829 +icmp_manip_pkt_51560 icmp_manip_pkt 4 51560 NULL
104830 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
104831 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
104832 +raw_ioctl_51607 raw_ioctl 3 51607 NULL
104833 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
104834 +gnttab_end_foreign_access_51617 gnttab_end_foreign_access 3 51617 NULL
104835 +dns_resolve_server_name_to_ip_51632 dns_resolve_server_name_to_ip 0 51632 NULL
104836 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
104837 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
104838 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
104839 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
104840 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
104841 +sfi_sysfs_install_table_51688 sfi_sysfs_install_table 1 51688 NULL
104842 +host_mapping_level_51696 host_mapping_level 2 51696 NULL
104843 +sel_write_access_51704 sel_write_access 3 51704 NULL
104844 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
104845 +v9fs_alloc_rdir_buf_51716 v9fs_alloc_rdir_buf 2 51716 NULL
104846 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
104847 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
104848 +hid_parse_report_51737 hid_parse_report 3 51737 NULL
104849 +get_user_pages_fast_51751 get_user_pages_fast 0-1-2 51751 NULL
104850 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
104851 +if_write_51756 if_write 3 51756 NULL
104852 +ioremap_prot_51764 ioremap_prot 1-2 51764 NULL
104853 +iio_buffer_add_channel_sysfs_51766 iio_buffer_add_channel_sysfs 0 51766 NULL
104854 +to_ratio_51809 to_ratio 2-1 51809 NULL
104855 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
104856 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
104857 +ioread32_51847 ioread32 0 51847 NULL nohasharray
104858 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
104859 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
104860 +SYSC_sendto_51852 SYSC_sendto 6 51852 NULL
104861 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
104862 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
104863 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
104864 +user_read_51881 user_read 3 51881 NULL
104865 +memblock_alloc_51884 memblock_alloc 1-2 51884 NULL
104866 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
104867 +virt_to_phys_51896 virt_to_phys 0 51896 NULL
104868 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
104869 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
104870 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
104871 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
104872 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
104873 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
104874 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
104875 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
104876 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
104877 +dwc3_mode_write_51997 dwc3_mode_write 3 51997 NULL
104878 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
104879 +rdmalt_52022 rdmalt 0 52022 NULL
104880 +vxge_rx_alloc_52024 vxge_rx_alloc 3 52024 NULL
104881 +override_release_52032 override_release 2 52032 NULL
104882 +end_port_52042 end_port 0 52042 NULL
104883 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
104884 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
104885 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
104886 +__fuse_request_alloc_52060 __fuse_request_alloc 1 52060 NULL
104887 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
104888 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
104889 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
104890 +smsdvb_stats_read_52114 smsdvb_stats_read 3 52114 NULL
104891 +retry_count_read_52129 retry_count_read 3 52129 NULL
104892 +zram_meta_alloc_52140 zram_meta_alloc 1 52140 NULL
104893 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
104894 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2 52145 &hysdn_conf_write_52145
104895 +htable_size_52148 htable_size 0-1 52148 NULL
104896 +__le16_to_cpup_52155 __le16_to_cpup 0 52155 NULL nohasharray
104897 +smk_write_load2_52155 smk_write_load2 3 52155 &__le16_to_cpup_52155
104898 +alix_present_52165 alix_present 1 52165 NULL
104899 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
104900 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
104901 +print_prefix_52176 print_prefix 0 52176 NULL
104902 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
104903 +vmci_qp_broker_alloc_52216 vmci_qp_broker_alloc 5-6 52216 NULL
104904 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
104905 +fuse_request_alloc_52243 fuse_request_alloc 1 52243 NULL
104906 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
104907 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
104908 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
104909 +hva_to_pfn_slow_52262 hva_to_pfn_slow 1 52262 NULL
104910 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
104911 +atomic64_read_52300 atomic64_read 0 52300 NULL
104912 +ath6kl_wmi_get_new_buf_52304 ath6kl_wmi_get_new_buf 1 52304 NULL
104913 +read_file_reset_52310 read_file_reset 3 52310 NULL
104914 +request_asymmetric_key_52317 request_asymmetric_key 2-4 52317 NULL
104915 +hwflags_read_52318 hwflags_read 3 52318 NULL
104916 +ntfs_rl_split_52328 ntfs_rl_split 2-4 52328 NULL
104917 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
104918 +compat_SyS_preadv64_52351 compat_SyS_preadv64 3 52351 NULL
104919 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
104920 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
104921 +mq_emit_config_values_52378 mq_emit_config_values 3 52378 NULL
104922 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
104923 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
104924 +aer_inject_write_52399 aer_inject_write 3 52399 NULL
104925 +aac_rx_ioremap_52410 aac_rx_ioremap 2 52410 NULL
104926 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
104927 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
104928 +delay_status_52431 delay_status 5 52431 NULL
104929 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
104930 +nl80211_send_mgmt_tx_status_52445 nl80211_send_mgmt_tx_status 5 52445 NULL
104931 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1-2 52477 NULL
104932 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
104933 +fd_do_rw_52495 fd_do_rw 3 52495 NULL nohasharray
104934 +skb_cow_head_52495 skb_cow_head 2 52495 &fd_do_rw_52495
104935 +qib_user_sdma_pin_pages_52498 qib_user_sdma_pin_pages 3-5 52498 NULL
104936 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
104937 +qlcnic_83xx_sysfs_flash_write_52507 qlcnic_83xx_sysfs_flash_write 4 52507 NULL
104938 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
104939 +dup_variable_bug_52525 dup_variable_bug 3 52525 NULL
104940 +from_oblock_52546 from_oblock 0-1 52546 NULL
104941 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
104942 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
104943 +emit_code_52583 emit_code 0-3 52583 NULL
104944 +isku_sysfs_read_macro_52587 isku_sysfs_read_macro 6 52587 NULL
104945 +tps80031_writes_52638 tps80031_writes 3-4 52638 NULL
104946 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
104947 +SYSC_gethostname_52677 SYSC_gethostname 2 52677 NULL
104948 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
104949 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
104950 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
104951 +blkcipher_next_slow_52733 blkcipher_next_slow 3-4 52733 NULL
104952 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
104953 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
104954 +ieee80211_if_read_beacon_timeout_52756 ieee80211_if_read_beacon_timeout 3 52756 NULL
104955 +copy_ctr_args_52761 copy_ctr_args 2 52761 NULL
104956 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
104957 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
104958 +mon_bin_get_event_52863 mon_bin_get_event 4 52863 NULL
104959 +twlreg_write_52880 twlreg_write 3 52880 NULL
104960 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
104961 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
104962 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
104963 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
104964 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
104965 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL nohasharray
104966 +__iio_device_attr_init_52936 __iio_device_attr_init 0 52936 &iblock_get_bio_52936
104967 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
104968 +send_packet_52960 send_packet 4 52960 NULL
104969 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
104970 +hx8357_spi_write_then_read_52964 hx8357_spi_write_then_read 3 52964 NULL nohasharray
104971 +compat_sock_ioctl_52964 compat_sock_ioctl 3 52964 &hx8357_spi_write_then_read_52964
104972 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
104973 +num_node_state_52989 num_node_state 0 52989 NULL
104974 +batadv_check_management_packet_52993 batadv_check_management_packet 3 52993 NULL
104975 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
104976 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
104977 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
104978 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
104979 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
104980 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
104981 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
104982 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
104983 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
104984 +verity_status_53120 verity_status 5 53120 NULL
104985 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
104986 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
104987 +ieee80211_bss_info_update_53170 ieee80211_bss_info_update 4 53170 NULL
104988 +btrfs_io_bio_alloc_53179 btrfs_io_bio_alloc 2 53179 NULL
104989 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
104990 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
104991 +fixup_user_fault_53210 fixup_user_fault 3 53210 NULL
104992 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
104993 +rbd_obj_method_sync_53252 rbd_obj_method_sync 8 53252 NULL
104994 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
104995 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
104996 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
104997 +isku_sysfs_write_key_mask_53305 isku_sysfs_write_key_mask 6 53305 NULL
104998 +batadv_interface_rx_53325 batadv_interface_rx 4 53325 NULL
104999 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
105000 +vm_mmap_53339 vm_mmap 0 53339 NULL
105001 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
105002 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
105003 +iwl_pcie_txq_alloc_53413 iwl_pcie_txq_alloc 3 53413 NULL
105004 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
105005 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
105006 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
105007 +acpi_tb_parse_root_table_53455 acpi_tb_parse_root_table 1 53455 NULL
105008 +n2_run_53459 n2_run 3 53459 NULL
105009 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
105010 +rds_tcp_data_recv_53476 rds_tcp_data_recv 3 53476 NULL
105011 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
105012 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
105013 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
105014 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
105015 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
105016 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
105017 +check_acl_53512 check_acl 0 53512 NULL
105018 +alloc_pages_exact_nid_53515 alloc_pages_exact_nid 2 53515 NULL
105019 +SYSC_bind_53582 SYSC_bind 3 53582 NULL nohasharray
105020 +set_registers_53582 set_registers 3 53582 &SYSC_bind_53582
105021 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
105022 +gfn_to_pfn_async_53597 gfn_to_pfn_async 2 53597 NULL
105023 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1-2 53626 NULL
105024 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
105025 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 NULL
105026 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
105027 +_preload_range_53676 _preload_range 2-3 53676 NULL
105028 +lowpan_fragment_xmit_53680 lowpan_fragment_xmit 3-4 53680 NULL
105029 +fuse_fill_write_pages_53682 fuse_fill_write_pages 4 53682 NULL
105030 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
105031 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 NULL nohasharray
105032 +igb_alloc_q_vector_53690 igb_alloc_q_vector 4-6 53690 &bdev_logical_block_size_53690
105033 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
105034 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
105035 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
105036 +wdm_write_53735 wdm_write 3 53735 NULL
105037 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3 53737 NULL
105038 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
105039 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
105040 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
105041 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
105042 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
105043 +qp_alloc_host_work_53798 qp_alloc_host_work 3-5 53798 NULL
105044 +__tty_alloc_driver_53799 __tty_alloc_driver 1 53799 NULL
105045 +regmap_raw_write_53803 regmap_raw_write 2-4 53803 NULL
105046 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
105047 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
105048 +pms_read_53873 pms_read 3 53873 NULL
105049 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
105050 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 5-4-3 53900 NULL nohasharray
105051 +SyS_setgroups_53900 SyS_setgroups 1 53900 &ocfs2_rm_xattr_cluster_53900
105052 +proc_file_read_53905 proc_file_read 3 53905 NULL
105053 +early_reserve_e820_53915 early_reserve_e820 1-2 53915 NULL
105054 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 4 53938 NULL
105055 +mthca_setup_cmd_doorbells_53954 mthca_setup_cmd_doorbells 2 53954 NULL
105056 +mlx4_num_eq_uar_53965 mlx4_num_eq_uar 0 53965 NULL
105057 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
105058 +mthca_reg_user_mr_53980 mthca_reg_user_mr 2-3 53980 NULL
105059 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
105060 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
105061 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 4-2-5 54018 NULL
105062 +cmpk_message_handle_tx_54024 cmpk_message_handle_tx 4 54024 NULL
105063 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
105064 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
105065 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
105066 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
105067 +btrfs_start_transaction_54066 btrfs_start_transaction 2 54066 NULL
105068 +_malloc_54077 _malloc 1 54077 NULL
105069 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
105070 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL
105071 +create_xattr_54106 create_xattr 5 54106 NULL
105072 +inc_zcache_pers_zbytes_54107 inc_zcache_pers_zbytes 1 54107 NULL
105073 +strn_len_54122 strn_len 0 54122 NULL
105074 +isku_receive_54130 isku_receive 4 54130 NULL
105075 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
105076 +i2400m_zrealloc_2x_54166 i2400m_zrealloc_2x 3 54166 NULL nohasharray
105077 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 &i2400m_zrealloc_2x_54166
105078 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
105079 +acpi_os_read_memory_54186 acpi_os_read_memory 1-3 54186 NULL
105080 +SyS_ipc_54206 SyS_ipc 3 54206 NULL
105081 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
105082 +_format_mac_addr_54229 _format_mac_addr 2-0 54229 NULL
105083 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
105084 +reada_add_block_54247 reada_add_block 2 54247 NULL
105085 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 NULL
105086 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
105087 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
105088 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
105089 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
105090 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
105091 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
105092 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
105093 +get_iovec_page_array_54298 get_iovec_page_array 6 54298 NULL
105094 +sprintf_54306 sprintf 0 54306 NULL
105095 +irq_domain_associate_many_54307 irq_domain_associate_many 2 54307 NULL
105096 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
105097 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
105098 +__get_free_pages_54352 __get_free_pages 0 54352 NULL nohasharray
105099 +_osd_realloc_seg_54352 _osd_realloc_seg 3 54352 &__get_free_pages_54352
105100 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
105101 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
105102 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
105103 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
105104 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
105105 +ah_alloc_tmp_54378 ah_alloc_tmp 3-2 54378 NULL
105106 +gart_unmap_page_54379 gart_unmap_page 2-3 54379 NULL
105107 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 0-3 54387 NULL
105108 +i386_mmap_check_54388 i386_mmap_check 0 54388 NULL
105109 +__do_krealloc_54389 __do_krealloc 2 54389 NULL
105110 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
105111 +copy_gadget_strings_54417 copy_gadget_strings 2-3 54417 NULL
105112 +swiotlb_tbl_sync_single_54486 swiotlb_tbl_sync_single 2 54486 NULL
105113 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
105114 +swiotlb_tbl_map_single_54495 swiotlb_tbl_map_single 3-0 54495 NULL
105115 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
105116 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL nohasharray
105117 +xen_bus_to_phys_54514 xen_bus_to_phys 0 54514 &cgroup_write_X64_54514
105118 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
105119 +vmci_transport_dgram_enqueue_54525 vmci_transport_dgram_enqueue 4 54525 NULL
105120 +viacam_read_54526 viacam_read 3 54526 NULL
105121 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
105122 +setsockopt_54539 setsockopt 5 54539 NULL
105123 +mwifiex_usb_submit_rx_urb_54558 mwifiex_usb_submit_rx_urb 2 54558 NULL
105124 +SYSC_setsockopt_54561 SYSC_setsockopt 5 54561 NULL
105125 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
105126 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
105127 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
105128 +fwSendNullPacket_54618 fwSendNullPacket 2 54618 NULL
105129 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
105130 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
105131 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
105132 +kvm_read_cr3_54662 kvm_read_cr3 0 54662 NULL
105133 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
105134 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
105135 +evm_read_key_54674 evm_read_key 3 54674 NULL
105136 +resource_string_54699 resource_string 0 54699 NULL
105137 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
105138 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL nohasharray
105139 +compat_SyS_readv_54711 compat_SyS_readv 3 54711 &rfkill_fop_read_54711
105140 +_add_sg_continuation_descriptor_54721 _add_sg_continuation_descriptor 3 54721 NULL
105141 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
105142 +kzalloc_54740 kzalloc 1 54740 NULL
105143 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
105144 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
105145 +batadv_iv_ogm_aggregate_new_54761 batadv_iv_ogm_aggregate_new 2 54761 NULL
105146 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
105147 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
105148 +domain_init_54797 domain_init 2 54797 NULL
105149 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
105150 +get_dev_size_54807 get_dev_size 0 54807 NULL
105151 +nfsd_write_54809 nfsd_write 6 54809 NULL
105152 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
105153 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &aes_decrypt_fail_read_54815
105154 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
105155 +write_rio_54837 write_rio 3 54837 NULL
105156 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
105157 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
105158 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
105159 +printer_read_54851 printer_read 3 54851 NULL
105160 +qib_reg_user_mr_54858 qib_reg_user_mr 2-3 54858 NULL
105161 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
105162 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
105163 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
105164 +tcf_csum_ipv6_tcp_54877 tcf_csum_ipv6_tcp 4 54877 NULL
105165 +iscsi_pool_init_54913 iscsi_pool_init 2-4 54913 NULL
105166 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
105167 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
105168 +add_port_54941 add_port 2 54941 NULL
105169 +virtblk_add_buf_wait_54943 virtblk_add_buf_wait 3-4 54943 NULL
105170 +wl12xx_cmd_build_probe_req_54946 wl12xx_cmd_build_probe_req 6-8 54946 NULL
105171 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
105172 +c4_add_card_54968 c4_add_card 3 54968 NULL
105173 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
105174 +__proc_file_read_54978 __proc_file_read 3 54978 NULL
105175 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
105176 +Bus_to_Virtual_54991 Bus_to_Virtual 1 54991 NULL
105177 +mem_cgroup_get_lru_size_55008 mem_cgroup_get_lru_size 0 55008 NULL
105178 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
105179 +paging32_get_level1_sp_gpa_55022 paging32_get_level1_sp_gpa 0 55022 NULL
105180 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
105181 +__netdev_alloc_skb_ip_align_55067 __netdev_alloc_skb_ip_align 2 55067 NULL
105182 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
105183 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
105184 +hx8357_spi_write_array_55095 hx8357_spi_write_array 3 55095 NULL
105185 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
105186 +corrupt_data_55120 corrupt_data 0 55120 NULL
105187 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
105188 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3 55137 NULL nohasharray
105189 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
105190 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
105191 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
105192 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
105193 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
105194 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
105195 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL
105196 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 NULL
105197 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
105198 +qxl_alloc_client_monitors_config_55216 qxl_alloc_client_monitors_config 2 55216 NULL
105199 +nouveau_mc_create__55217 nouveau_mc_create_ 4 55217 NULL
105200 +dump_command_55220 dump_command 1 55220 NULL
105201 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
105202 +tipc_port_reject_sections_55229 tipc_port_reject_sections 5 55229 NULL
105203 +hash_netport6_expire_55232 hash_netport6_expire 3 55232 NULL
105204 +register_unifi_sdio_55239 register_unifi_sdio 2 55239 NULL
105205 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
105206 +persistent_ram_new_55286 persistent_ram_new 1-2 55286 NULL
105207 +ptrace_request_55288 ptrace_request 3-4 55288 NULL
105208 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
105209 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
105210 +qp_alloc_guest_work_55305 qp_alloc_guest_work 3-5 55305 NULL nohasharray
105211 +__get_vm_area_node_55305 __get_vm_area_node 1 55305 &qp_alloc_guest_work_55305
105212 +do_shmat_55336 do_shmat 5 55336 NULL
105213 +vme_user_read_55338 vme_user_read 3 55338 NULL
105214 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
105215 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
105216 +__memblock_alloc_base_55359 __memblock_alloc_base 1-2 55359 NULL
105217 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 NULL
105218 +nf_nat_ipv4_manip_pkt_55387 nf_nat_ipv4_manip_pkt 2 55387 NULL
105219 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
105220 +si476x_radio_read_rds_blckcnt_blob_55427 si476x_radio_read_rds_blckcnt_blob 3 55427 NULL
105221 +alloc_skb_55439 alloc_skb 1 55439 NULL
105222 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
105223 +isdnhdlc_decode_55466 isdnhdlc_decode 0 55466 NULL
105224 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
105225 +batadv_unicast_push_and_fill_skb_55474 batadv_unicast_push_and_fill_skb 2 55474 NULL
105226 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
105227 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
105228 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL
105229 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
105230 +cfpkt_pad_trail_55511 cfpkt_pad_trail 2 55511 NULL nohasharray
105231 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 &cfpkt_pad_trail_55511
105232 +ea_get_55522 ea_get 0 55522 NULL
105233 +buffer_size_55534 buffer_size 0 55534 NULL
105234 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
105235 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
105236 +hash_netport4_expire_55584 hash_netport4_expire 3 55584 NULL
105237 +add_partition_55588 add_partition 2 55588 NULL
105238 +SyS_keyctl_55602 SyS_keyctl 4 55602 NULL
105239 +free_pages_55603 free_pages 1 55603 NULL
105240 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
105241 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
105242 +edge_tty_recv_55622 edge_tty_recv 3 55622 NULL
105243 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
105244 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
105245 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
105246 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
105247 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
105248 +ib_umad_compat_ioctl_55650 ib_umad_compat_ioctl 3 55650 NULL
105249 +cfg80211_send_rx_assoc_55651 cfg80211_send_rx_assoc 4 55651 NULL
105250 +read_oldmem_55658 read_oldmem 3 55658 NULL
105251 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
105252 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
105253 +get_info_55681 get_info 3 55681 NULL
105254 +wil_vring_alloc_skb_55703 wil_vring_alloc_skb 4 55703 NULL
105255 +__videobuf_alloc_uncached_55711 __videobuf_alloc_uncached 1 55711 NULL
105256 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
105257 +mtdswap_init_55719 mtdswap_init 2 55719 NULL
105258 +tap_pwup_write_55723 tap_pwup_write 3 55723 NULL
105259 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 2 55738 NULL
105260 +set_local_name_55757 set_local_name 4 55757 NULL
105261 +strlen_55778 strlen 0 55778 NULL
105262 +set_spte_55783 set_spte 5-4 55783 NULL
105263 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
105264 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
105265 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
105266 +sb16_copy_from_user_55836 sb16_copy_from_user 10-6-7 55836 NULL
105267 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
105268 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
105269 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
105270 +hsc_write_55875 hsc_write 3 55875 NULL
105271 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
105272 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
105273 +paging64_page_fault_55942 paging64_page_fault 2 55942 NULL
105274 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
105275 +ceph_get_direct_page_vector_55956 ceph_get_direct_page_vector 2 55956 NULL
105276 +simple_read_from_buffer_55957 simple_read_from_buffer 2-5 55957 NULL
105277 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
105278 +ssb_bus_pcmciabus_register_56020 ssb_bus_pcmciabus_register 3 56020 NULL
105279 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
105280 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
105281 +__set_discard_56081 __set_discard 2 56081 NULL
105282 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
105283 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
105284 +kmem_zalloc_large_56128 kmem_zalloc_large 1 56128 NULL
105285 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
105286 +map_addr_56144 map_addr 7 56144 NULL
105287 +__i2c_transfer_56162 __i2c_transfer 0 56162 NULL
105288 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
105289 +create_irq_nr_56180 create_irq_nr 1 56180 NULL
105290 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
105291 +skb_headroom_56200 skb_headroom 0 56200 NULL
105292 +usb_dump_iad_descriptor_56204 usb_dump_iad_descriptor 0 56204 NULL
105293 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
105294 +vring_add_indirect_56222 vring_add_indirect 4 56222 NULL
105295 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
105296 +cp210x_get_config_56229 cp210x_get_config 4 56229 NULL
105297 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
105298 +fd_copyin_56247 fd_copyin 3 56247 NULL
105299 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
105300 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
105301 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
105302 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
105303 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
105304 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
105305 +compat_cdrom_read_audio_56304 compat_cdrom_read_audio 4 56304 NULL
105306 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
105307 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
105308 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
105309 +sixpack_compat_ioctl_56346 sixpack_compat_ioctl 4 56346 NULL
105310 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
105311 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 4 56368 NULL
105312 +dev_read_56369 dev_read 3 56369 NULL
105313 +write_gssp_56404 write_gssp 3 56404 NULL
105314 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
105315 +__get_vm_area_caller_56416 __get_vm_area_caller 1 56416 NULL nohasharray
105316 +acpi_os_write_memory_56416 acpi_os_write_memory 1-3 56416 &__get_vm_area_caller_56416
105317 +store_msg_56417 store_msg 3 56417 NULL
105318 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
105319 +fl_create_56435 fl_create 5 56435 NULL
105320 +gnttab_map_56439 gnttab_map 2 56439 NULL
105321 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2 56453 NULL
105322 +set_connectable_56458 set_connectable 4 56458 NULL
105323 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
105324 +putused_user_56467 putused_user 3 56467 NULL
105325 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
105326 +global_rt_period_56476 global_rt_period 0 56476 NULL
105327 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
105328 +ieee80211_rx_mgmt_probe_beacon_56491 ieee80211_rx_mgmt_probe_beacon 3 56491 NULL
105329 +init_map_ip_56508 init_map_ip 5 56508 NULL
105330 +cfg80211_connect_result_56515 cfg80211_connect_result 4-6 56515 NULL
105331 +ip_options_get_56538 ip_options_get 4 56538 NULL
105332 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
105333 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
105334 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
105335 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
105336 +event_filter_write_56609 event_filter_write 3 56609 NULL
105337 +gather_array_56641 gather_array 3 56641 NULL
105338 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
105339 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
105340 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
105341 +build_map_info_56696 build_map_info 2 56696 NULL
105342 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3 56702 NULL
105343 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
105344 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
105345 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
105346 +pcpu_populate_chunk_56741 pcpu_populate_chunk 2-3 56741 NULL
105347 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
105348 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
105349 +alloc_iommu_56778 alloc_iommu 2-3 56778 NULL
105350 +__carl9170_rx_56784 __carl9170_rx 3 56784 NULL
105351 +hash_lookup_56792 hash_lookup 2 56792 NULL
105352 +do_syslog_56807 do_syslog 3 56807 NULL
105353 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
105354 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
105355 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4 56847 NULL
105356 +si476x_radio_read_agc_blob_56849 si476x_radio_read_agc_blob 3 56849 NULL
105357 +wb_lookup_56858 wb_lookup 2 56858 NULL
105358 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
105359 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
105360 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
105361 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
105362 +strcspn_56913 strcspn 0 56913 NULL
105363 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
105364 +check_header_56930 check_header 2 56930 NULL
105365 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL
105366 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
105367 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
105368 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
105369 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
105370 +aircable_process_packet_57027 aircable_process_packet 4 57027 NULL
105371 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
105372 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
105373 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
105374 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
105375 +autofs_dev_ioctl_compat_57059 autofs_dev_ioctl_compat 3 57059 NULL
105376 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
105377 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
105378 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
105379 +sis190_try_rx_copy_57069 sis190_try_rx_copy 3 57069 NULL
105380 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
105381 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
105382 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
105383 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
105384 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
105385 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
105386 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
105387 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
105388 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
105389 +__ipath_get_user_pages_57166 __ipath_get_user_pages 1-2 57166 NULL
105390 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
105391 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
105392 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
105393 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
105394 +flush_space_57241 flush_space 3 57241 NULL
105395 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
105396 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
105397 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
105398 +security_mmap_file_57268 security_mmap_file 0 57268 NULL
105399 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
105400 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
105401 +ath6kl_buf_alloc_57304 ath6kl_buf_alloc 1 57304 NULL
105402 +fw_file_size_57307 fw_file_size 0 57307 NULL
105403 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
105404 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
105405 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
105406 +check_mirror_57342 check_mirror 1-2 57342 NULL nohasharray
105407 +usblp_read_57342 usblp_read 3 57342 &check_mirror_57342
105408 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
105409 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
105410 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
105411 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
105412 +read_file_blob_57406 read_file_blob 3 57406 NULL
105413 +enclosure_register_57412 enclosure_register 3 57412 NULL
105414 +gre_manip_pkt_57416 gre_manip_pkt 4 57416 NULL
105415 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL nohasharray
105416 +alloc_ftrace_hash_57431 alloc_ftrace_hash 1 57431 &compat_keyctl_instantiate_key_iov_57431
105417 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
105418 +sys_pselect6_57449 sys_pselect6 1 57449 NULL
105419 +ReadReg_57453 ReadReg 0 57453 NULL
105420 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
105421 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL nohasharray
105422 +send_midi_async_57463 send_midi_async 3 57463 &crypto_tfm_alg_blocksize_57463
105423 +sisusb_clear_vram_57466 sisusb_clear_vram 3-2 57466 NULL
105424 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
105425 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
105426 +ocfs2_write_cluster_57483 ocfs2_write_cluster 8-2-9 57483 NULL
105427 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
105428 +skb_headlen_57501 skb_headlen 0 57501 NULL
105429 +copy_in_user_57502 copy_in_user 3 57502 NULL
105430 +ks8842_read32_57505 ks8842_read32 0 57505 NULL nohasharray
105431 +ckhdid_printf_57505 ckhdid_printf 2 57505 &ks8842_read32_57505
105432 +init_tag_map_57515 init_tag_map 3 57515 NULL
105433 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
105434 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517
105435 +inode_permission_57531 inode_permission 0 57531 NULL
105436 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL nohasharray
105437 +DoC_Probe_57534 DoC_Probe 1 57534 &acpi_dev_get_resources_57534
105438 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 NULL
105439 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
105440 +uio_find_mem_index_57584 uio_find_mem_index 0 57584 NULL
105441 +read_file_spectral_fft_period_57593 read_file_spectral_fft_period 3 57593 NULL
105442 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
105443 +sk_stream_alloc_skb_57622 sk_stream_alloc_skb 2 57622 NULL
105444 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 NULL
105445 +osdmap_set_max_osd_57630 osdmap_set_max_osd 2 57630 NULL nohasharray
105446 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 &osdmap_set_max_osd_57630
105447 +mem_read_57631 mem_read 3 57631 NULL
105448 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
105449 +sys_mq_timedsend_57661 sys_mq_timedsend 3 57661 NULL
105450 +r3964_write_57662 r3964_write 4 57662 NULL
105451 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
105452 +__lgwrite_57669 __lgwrite 4 57669 NULL
105453 +ieee80211_MFIE_rate_len_57692 ieee80211_MFIE_rate_len 0 57692 NULL
105454 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
105455 +check_prefree_segments_57702 check_prefree_segments 2 57702 NULL
105456 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
105457 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
105458 +nouveau_gpio_create__57735 nouveau_gpio_create_ 4-5 57735 NULL
105459 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL
105460 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
105461 +SYSC_process_vm_writev_57776 SYSC_process_vm_writev 3-5 57776 NULL
105462 +ld2_57794 ld2 0 57794 NULL
105463 +ivtv_read_57796 ivtv_read 3 57796 NULL
105464 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
105465 +ipath_user_sdma_num_pages_57813 ipath_user_sdma_num_pages 0 57813 NULL
105466 +usb_dump_config_57817 usb_dump_config 0 57817 NULL
105467 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
105468 +copy_to_user_57835 copy_to_user 3 57835 NULL
105469 +flash_read_57843 flash_read 3 57843 NULL
105470 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
105471 +emi26_writememory_57908 emi26_writememory 4 57908 NULL
105472 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 NULL
105473 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
105474 +twl_i2c_write_57923 twl_i2c_write 4-3 57923 NULL
105475 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
105476 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
105477 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
105478 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
105479 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
105480 +i915_cache_sharing_write_57961 i915_cache_sharing_write 3 57961 NULL
105481 +hfc_empty_fifo_57972 hfc_empty_fifo 2 57972 NULL
105482 +c2_reg_user_mr_57982 c2_reg_user_mr 2-3 57982 NULL
105483 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
105484 +regcache_rbtree_insert_to_block_58009 regcache_rbtree_insert_to_block 5 58009 NULL
105485 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
105486 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
105487 +mce_async_out_58056 mce_async_out 3 58056 NULL
105488 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
105489 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
105490 +cm4040_write_58079 cm4040_write 3 58079 NULL
105491 +udi_log_event_58105 udi_log_event 3 58105 NULL
105492 +savemem_58129 savemem 3 58129 NULL
105493 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
105494 +slhc_init_58135 slhc_init 1-2 58135 &ipv6_flowlabel_opt_58135
105495 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
105496 +asix_write_cmd_58192 asix_write_cmd 5 58192 NULL
105497 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
105498 +hva_to_pfn_58241 hva_to_pfn 1 58241 NULL
105499 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
105500 +read_file_debug_58256 read_file_debug 3 58256 NULL
105501 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
105502 +profile_load_58267 profile_load 3 58267 NULL
105503 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
105504 +r100_mm_rreg_58276 r100_mm_rreg 0 58276 NULL
105505 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
105506 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
105507 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
105508 +pcim_iomap_58334 pcim_iomap 3 58334 NULL
105509 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
105510 +next_pidmap_58347 next_pidmap 2 58347 NULL
105511 +SyS_migrate_pages_58348 SyS_migrate_pages 2 58348 NULL
105512 +vmalloc_to_sg_58354 vmalloc_to_sg 2 58354 NULL
105513 +save_hint_58359 save_hint 2 58359 NULL
105514 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 NULL
105515 +hash_ipportnet6_expire_58379 hash_ipportnet6_expire 3 58379 NULL
105516 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
105517 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3 58406 NULL
105518 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
105519 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
105520 +__iio_add_chan_devattr_58451 __iio_add_chan_devattr 0 58451 NULL
105521 +capabilities_read_58457 capabilities_read 3 58457 NULL
105522 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
105523 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
105524 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
105525 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
105526 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
105527 +batadv_bla_is_backbone_gw_58488 batadv_bla_is_backbone_gw 3 58488 NULL
105528 +memblock_alloc_try_nid_58493 memblock_alloc_try_nid 1-2 58493 NULL
105529 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
105530 +__clear_discard_58546 __clear_discard 2 58546 NULL
105531 +wrap_max_58548 wrap_max 0-1-2 58548 NULL
105532 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
105533 +sip_sprintf_addr_port_58574 sip_sprintf_addr_port 0 58574 NULL
105534 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
105535 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
105536 +isku_sysfs_read_keys_thumbster_58590 isku_sysfs_read_keys_thumbster 6 58590 NULL
105537 +xip_file_read_58592 xip_file_read 3 58592 NULL
105538 +gdth_search_isa_58595 gdth_search_isa 1 58595 NULL
105539 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
105540 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
105541 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL nohasharray
105542 +efi_ioremap_58634 efi_ioremap 1-2 58634 &module_alloc_update_bounds_rx_58634
105543 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
105544 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
105545 +__gfn_to_pfn_58671 __gfn_to_pfn 2 58671 NULL
105546 +iwl_trans_send_cmd_58681 iwl_trans_send_cmd 0 58681 NULL
105547 +find_zero_58685 find_zero 0-1 58685 NULL nohasharray
105548 +mcs7830_set_reg_async_58685 mcs7830_set_reg_async 3 58685 &find_zero_58685
105549 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
105550 +pci_alloc_consistent_58688 pci_alloc_consistent 0 58688 NULL
105551 +tps6586x_writes_58689 tps6586x_writes 3-2 58689 NULL
105552 +vmalloc_node_58700 vmalloc_node 1 58700 NULL
105553 +acpi_map_58725 acpi_map 1-2 58725 NULL
105554 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
105555 +csum_exist_in_range_58730 csum_exist_in_range 2 58730 NULL
105556 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
105557 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
105558 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
105559 +oblock_to_dblock_58762 oblock_to_dblock 0-2 58762 NULL
105560 +__do_config_autodelink_58763 __do_config_autodelink 3 58763 NULL
105561 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
105562 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
105563 +isku_sysfs_read_58806 isku_sysfs_read 6-5 58806 NULL
105564 +ep_read_58813 ep_read 3 58813 NULL
105565 +command_write_58841 command_write 3 58841 NULL
105566 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3 58850 NULL
105567 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
105568 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
105569 +cs553x_init_one_58886 cs553x_init_one 3 58886 NULL
105570 +raw_ctl_compat_ioctl_58905 raw_ctl_compat_ioctl 3 58905 NULL
105571 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
105572 +tun_chr_compat_ioctl_58921 tun_chr_compat_ioctl 3 58921 NULL
105573 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
105574 +st5481_isoc_flatten_58952 st5481_isoc_flatten 0 58952 NULL
105575 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
105576 +idx_to_kaddr_58968 idx_to_kaddr 0 58968 NULL
105577 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
105578 +remap_to_cache_dirty_58991 remap_to_cache_dirty 4-3 58991 NULL
105579 +handle_rx_packet_58993 handle_rx_packet 3 58993 NULL
105580 +edac_align_ptr_59003 edac_align_ptr 0 59003 NULL
105581 +ep_write_59008 ep_write 3 59008 NULL
105582 +i915_ring_stop_write_59010 i915_ring_stop_write 3 59010 NULL
105583 +SyS_preadv_59029 SyS_preadv 3 59029 NULL
105584 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
105585 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
105586 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
105587 +regmap_bulk_write_59049 regmap_bulk_write 4-2 59049 NULL
105588 +vfio_device_fops_compat_ioctl_59111 vfio_device_fops_compat_ioctl 3 59111 NULL
105589 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
105590 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
105591 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
105592 +__iio_add_event_config_attrs_59136 __iio_add_event_config_attrs 0 59136 NULL
105593 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
105594 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
105595 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
105596 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
105597 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
105598 +ocfs2_move_extent_59187 ocfs2_move_extent 3 59187 NULL
105599 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
105600 +fast_rx_path_59214 fast_rx_path 3 59214 NULL
105601 +inftl_partscan_59216 inftl_partscan 0 59216 NULL
105602 +skb_transport_header_59223 skb_transport_header 0 59223 NULL
105603 +dt3155_read_59226 dt3155_read 3 59226 NULL
105604 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
105605 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
105606 +solo_v4l2_read_59247 solo_v4l2_read 3 59247 NULL
105607 +nla_len_59258 nla_len 0 59258 NULL
105608 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4 59304 NULL
105609 +fd_copyout_59323 fd_copyout 3 59323 NULL
105610 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
105611 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
105612 +paging64_get_level1_sp_gpa_59346 paging64_get_level1_sp_gpa 0 59346 NULL nohasharray
105613 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 &paging64_get_level1_sp_gpa_59346
105614 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
105615 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
105616 +fc_frame_alloc_fill_59394 fc_frame_alloc_fill 2 59394 NULL
105617 +isku_sysfs_read_keys_function_59412 isku_sysfs_read_keys_function 6 59412 NULL
105618 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
105619 +squashfs_read_data_59440 squashfs_read_data 6 59440 NULL
105620 +SyS_sched_setaffinity_59442 SyS_sched_setaffinity 2 59442 NULL
105621 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2 59445 NULL
105622 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
105623 +do_compat_semctl_59449 do_compat_semctl 4 59449 NULL
105624 +virtqueue_add_buf_59470 virtqueue_add_buf 3-4 59470 NULL
105625 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
105626 +nfsd_nrpools_59503 nfsd_nrpools 0 59503 NULL
105627 +rds_pin_pages_59507 rds_pin_pages 0-1-2 59507 NULL
105628 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
105629 +tunables_write_59563 tunables_write 3 59563 NULL
105630 +memdup_user_59590 memdup_user 2 59590 NULL
105631 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
105632 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL
105633 +mtrr_write_59622 mtrr_write 3 59622 NULL
105634 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
105635 +ubifs_setxattr_59650 ubifs_setxattr 4 59650 NULL nohasharray
105636 +hidraw_read_59650 hidraw_read 3 59650 &ubifs_setxattr_59650
105637 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
105638 +paravirt_sched_clock_59660 paravirt_sched_clock 0 59660 NULL
105639 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
105640 +iwl_dbgfs_mac_params_read_59666 iwl_dbgfs_mac_params_read 3 59666 NULL
105641 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
105642 +can_nocow_odirect_59681 can_nocow_odirect 3 59681 NULL
105643 +sriov_enable_59689 sriov_enable 2 59689 NULL
105644 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
105645 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
105646 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
105647 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
105648 +strnlen_59746 strnlen 0 59746 NULL
105649 +sctp_manip_pkt_59749 sctp_manip_pkt 4 59749 NULL
105650 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 NULL
105651 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
105652 +venus_remove_59781 venus_remove 4 59781 NULL
105653 +mei_nfc_recv_59784 mei_nfc_recv 3 59784 NULL
105654 +C_SYSC_preadv_59801 C_SYSC_preadv 3 59801 NULL
105655 +ipw_write_59807 ipw_write 3 59807 NULL
105656 +rtllib_wx_set_gen_ie_59808 rtllib_wx_set_gen_ie 3 59808 NULL
105657 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
105658 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
105659 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
105660 +regmap_raw_write_async_59849 regmap_raw_write_async 2-4 59849 NULL
105661 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
105662 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL nohasharray
105663 +start_transaction_59885 start_transaction 2 59885 &shmem_zero_setup_59885
105664 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
105665 +swiotlb_map_page_59909 swiotlb_map_page 3 59909 NULL
105666 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
105667 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
105668 +lookup_node_59953 lookup_node 2 59953 NULL
105669 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 NULL nohasharray
105670 +compat_ipmi_ioctl_59956 compat_ipmi_ioctl 3 59956 &il_dbgfs_missed_beacon_read_59956
105671 +kvm_set_cr3_59965 kvm_set_cr3 2 59965 NULL
105672 +fb_getput_cmap_59971 fb_getput_cmap 3 59971 NULL
105673 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
105674 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
105675 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
105676 +ieee80211_if_fmt_dot11MeshAwakeWindowDuration_60006 ieee80211_if_fmt_dot11MeshAwakeWindowDuration 3 60006 NULL
105677 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
105678 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
105679 +register_device_60015 register_device 2-3 60015 NULL
105680 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
105681 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
105682 +sys_sched_getaffinity_60033 sys_sched_getaffinity 2 60033 NULL
105683 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
105684 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
105685 +pin_2_irq_60050 pin_2_irq 0-3 60050 NULL nohasharray
105686 +vcs_size_60050 vcs_size 0 60050 &pin_2_irq_60050
105687 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 NULL
105688 +compat_writev_60063 compat_writev 3 60063 NULL
105689 +ieee80211_build_probe_req_60064 ieee80211_build_probe_req 6-8 60064 NULL
105690 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
105691 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
105692 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
105693 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
105694 +SYSC_msgsnd_60113 SYSC_msgsnd 3 60113 NULL
105695 +ttm_bo_kmap_60118 ttm_bo_kmap 3-2 60118 NULL
105696 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
105697 +init_state_60165 init_state 2 60165 NULL
105698 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
105699 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
105700 +fuse_async_req_send_60183 fuse_async_req_send 0-3 60183 NULL
105701 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
105702 +svc_compat_ioctl_60194 svc_compat_ioctl 3 60194 NULL
105703 +ib_send_cm_mra_60202 ib_send_cm_mra 4 60202 NULL nohasharray
105704 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 &ib_send_cm_mra_60202
105705 +set_tap_pfs_60203 set_tap_pfs 3 60203 NULL
105706 +ieee80211_mgmt_tx_60209 ieee80211_mgmt_tx 7 60209 NULL
105707 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
105708 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL nohasharray
105709 +__phys_addr_nodebug_60230 __phys_addr_nodebug 0-1 60230 &arizona_map_irq_60230
105710 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
105711 +compat_sys_fcntl64_60256 compat_sys_fcntl64 3 60256 NULL
105712 +printer_write_60276 printer_write 3 60276 NULL
105713 +__pskb_pull_tail_60287 __pskb_pull_tail 2 60287 NULL
105714 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
105715 +getDataLength_60301 getDataLength 0 60301 NULL
105716 +ceph_parse_server_name_60318 ceph_parse_server_name 2 60318 NULL
105717 +__kfifo_from_user_r_60345 __kfifo_from_user_r 3-5 60345 NULL
105718 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
105719 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 5 60379 NULL
105720 +instruction_pointer_60384 instruction_pointer 0 60384 NULL
105721 +drop_outstanding_extent_60390 drop_outstanding_extent 0 60390 NULL
105722 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
105723 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
105724 +driver_names_read_60399 driver_names_read 3 60399 NULL
105725 +paging32_walk_addr_generic_60415 paging32_walk_addr_generic 4 60415 NULL
105726 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
105727 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
105728 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
105729 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
105730 +tipc_buf_acquire_60437 tipc_buf_acquire 1 60437 NULL
105731 +rx_data_60442 rx_data 4 60442 NULL nohasharray
105732 +scaled_div32_60442 scaled_div32 1-2 60442 &rx_data_60442
105733 +tcf_csum_ipv4_igmp_60446 tcf_csum_ipv4_igmp 3 60446 NULL
105734 +snd_hda_get_num_raw_conns_60462 snd_hda_get_num_raw_conns 0 60462 NULL
105735 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
105736 +ath_tx_init_60515 ath_tx_init 2 60515 NULL
105737 +hysdn_sched_rx_60533 hysdn_sched_rx 3 60533 NULL
105738 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
105739 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
105740 +nfsd_hashsize_60562 nfsd_hashsize 0 60562 NULL
105741 +hash_net6_expire_60598 hash_net6_expire 3 60598 NULL
105742 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
105743 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
105744 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
105745 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
105746 +fb_get_fscreeninfo_60640 fb_get_fscreeninfo 3 60640 NULL
105747 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
105748 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
105749 +read_vbt_r10_60679 read_vbt_r10 1 60679 NULL
105750 +init_data_container_60709 init_data_container 1 60709 NULL
105751 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
105752 +raid_status_60755 raid_status 5 60755 NULL
105753 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
105754 +opticon_write_60775 opticon_write 4 60775 NULL
105755 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
105756 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
105757 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
105758 +alloc_buf_60864 alloc_buf 3-2 60864 NULL
105759 +generic_writepages_60871 generic_writepages 0 60871 NULL
105760 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
105761 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
105762 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
105763 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
105764 +sys_mlock_60932 sys_mlock 1 60932 NULL
105765 +pti_char_write_60960 pti_char_write 3 60960 NULL
105766 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 2-3 60961 NULL
105767 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
105768 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
105769 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
105770 +symtab_init_61050 symtab_init 2 61050 NULL
105771 +fuse_send_write_61053 fuse_send_write 0-4 61053 NULL
105772 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
105773 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
105774 +get_derived_key_61100 get_derived_key 4 61100 NULL
105775 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
105776 +p80211_headerlen_61119 p80211_headerlen 0 61119 NULL nohasharray
105777 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 &p80211_headerlen_61119
105778 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1 61126 NULL
105779 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
105780 +brcmf_sdio_chip_cr4_exitdl_61143 brcmf_sdio_chip_cr4_exitdl 4 61143 NULL
105781 +__vmalloc_61168 __vmalloc 1 61168 NULL
105782 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
105783 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
105784 +sys_lsetxattr_61177 sys_lsetxattr 4 61177 NULL
105785 +SyS_prctl_61202 SyS_prctl 4 61202 NULL
105786 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
105787 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
105788 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 NULL
105789 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 NULL
105790 +sys_add_key_61288 sys_add_key 4 61288 NULL nohasharray
105791 +nvme_trans_copy_to_user_61288 nvme_trans_copy_to_user 3 61288 &sys_add_key_61288
105792 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
105793 +xfer_from_user_61307 xfer_from_user 3 61307 NULL
105794 +timespec_to_ns_61317 timespec_to_ns 0 61317 NULL
105795 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
105796 +C_SYSC_msgsnd_61330 C_SYSC_msgsnd 2-3 61330 NULL
105797 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 NULL
105798 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 NULL
105799 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
105800 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
105801 +sys_ptrace_61369 sys_ptrace 3 61369 NULL
105802 +change_xattr_61390 change_xattr 5 61390 NULL
105803 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
105804 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5 61440 NULL
105805 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
105806 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
105807 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 4-2-5 61483 NULL
105808 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
105809 +erst_errno_61526 erst_errno 0 61526 NULL
105810 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
105811 +get_ohm_of_thermistor_61545 get_ohm_of_thermistor 2 61545 NULL
105812 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
105813 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
105814 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
105815 +seq_open_private_61589 seq_open_private 3 61589 NULL
105816 +__get_vm_area_61599 __get_vm_area 1 61599 NULL
105817 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
105818 +ncp_compat_ioctl_61608 ncp_compat_ioctl 3 61608 NULL
105819 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
105820 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
105821 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
105822 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
105823 +resize_stripes_61650 resize_stripes 2 61650 NULL
105824 +ttm_page_pool_free_61661 ttm_page_pool_free 2 61661 NULL
105825 +insert_one_name_61668 insert_one_name 7 61668 NULL
105826 +lock_loop_61681 lock_loop 1 61681 NULL
105827 +__do_tune_cpucache_61684 __do_tune_cpucache 2 61684 NULL
105828 +filter_read_61692 filter_read 3 61692 NULL
105829 +iov_length_61716 iov_length 0 61716 NULL
105830 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
105831 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
105832 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
105833 +batadv_dat_snoop_incoming_arp_reply_61801 batadv_dat_snoop_incoming_arp_reply 3 61801 NULL
105834 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
105835 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
105836 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2 61854 NULL
105837 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
105838 +SYSC_lsetxattr_61869 SYSC_lsetxattr 4 61869 NULL
105839 +get_fw_name_61874 get_fw_name 3 61874 NULL
105840 +free_init_pages_61875 free_init_pages 2 61875 NULL
105841 +twl4030_sih_setup_61878 twl4030_sih_setup 3 61878 NULL
105842 +ieee80211_rtl_auth_challenge_61897 ieee80211_rtl_auth_challenge 3 61897 NULL
105843 +ax25_addr_size_61899 ax25_addr_size 0 61899 NULL nohasharray
105844 +cxgb4_pktgl_to_skb_61899 cxgb4_pktgl_to_skb 2 61899 &ax25_addr_size_61899
105845 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
105846 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
105847 +au0828_init_isoc_61917 au0828_init_isoc 3-2 61917 NULL
105848 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
105849 +send_bulk_static_data_61932 send_bulk_static_data 3 61932 NULL
105850 +gfn_to_pfn_memslot_atomic_61947 gfn_to_pfn_memslot_atomic 2 61947 NULL
105851 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
105852 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
105853 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
105854 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
105855 +cow_file_range_61979 cow_file_range 3 61979 NULL
105856 +module_alloc_exec_61991 module_alloc_exec 1 61991 NULL
105857 +virtnet_send_command_61993 virtnet_send_command 5-6 61993 NULL
105858 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
105859 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
105860 +SYSC_select_62024 SYSC_select 1 62024 NULL
105861 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
105862 +ppp_tx_cp_62044 ppp_tx_cp 5 62044 NULL
105863 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
105864 +do_pselect_62061 do_pselect 1 62061 NULL
105865 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2-3 62074 NULL
105866 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
105867 +ipath_user_sdma_pin_pages_62100 ipath_user_sdma_pin_pages 3-5 62100 NULL
105868 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
105869 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
105870 +qib_diag_write_62133 qib_diag_write 3 62133 NULL
105871 +ql_status_62135 ql_status 5 62135 NULL
105872 +video_usercopy_62151 video_usercopy 2 62151 NULL
105873 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
105874 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
105875 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
105876 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
105877 +SYSC_setgroups16_62232 SYSC_setgroups16 1 62232 NULL
105878 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
105879 +allocate_partition_62245 allocate_partition 4 62245 NULL
105880 +__qib_get_user_pages_62287 __qib_get_user_pages 1-2 62287 NULL
105881 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
105882 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
105883 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
105884 +udf_sb_alloc_partition_maps_62313 udf_sb_alloc_partition_maps 2 62313 NULL
105885 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
105886 +subseq_list_62332 subseq_list 3-0 62332 NULL
105887 +flash_write_62354 flash_write 3 62354 NULL
105888 +set_wd_exp_mode_pfs_62372 set_wd_exp_mode_pfs 3 62372 NULL
105889 +twl_get_num_slaves_62386 twl_get_num_slaves 0 62386 NULL
105890 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
105891 +altera_irscan_62396 altera_irscan 2 62396 NULL
105892 +set_ssp_62411 set_ssp 4 62411 NULL
105893 +unmap_single_62423 unmap_single 2 62423 NULL
105894 +netdev_alloc_skb_62437 netdev_alloc_skb 2 62437 NULL
105895 +e1000_check_copybreak_62448 e1000_check_copybreak 3 62448 NULL
105896 +ip_vs_icmp_xmit_v6_62477 ip_vs_icmp_xmit_v6 4 62477 NULL
105897 +ceph_dns_resolve_name_62488 ceph_dns_resolve_name 2 62488 NULL
105898 +remove_mapping_62491 remove_mapping 2 62491 NULL
105899 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
105900 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
105901 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL nohasharray
105902 +i915_next_seqno_read_62524 i915_next_seqno_read 3 62524 &pep_sendmsg_62524
105903 +test_iso_queue_62534 test_iso_queue 5 62534 NULL
105904 +debugfs_read_62535 debugfs_read 3 62535 NULL
105905 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
105906 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
105907 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
105908 +get_subdir_62581 get_subdir 3 62581 NULL
105909 +prism2_send_mgmt_62605 prism2_send_mgmt 4 62605 NULL nohasharray
105910 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 &prism2_send_mgmt_62605
105911 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7 62619 NULL
105912 +ems_pcmcia_add_card_62627 ems_pcmcia_add_card 2 62627 NULL
105913 +compat_rangeinfo_62630 compat_rangeinfo 2 62630 NULL
105914 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
105915 +memblock_alloc_nid_62652 memblock_alloc_nid 1-2 62652 NULL
105916 +ima_file_mmap_62663 ima_file_mmap 0 62663 NULL
105917 +write_62671 write 3 62671 NULL
105918 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
105919 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
105920 +ioremap_wc_62695 ioremap_wc 1-2 62695 NULL
105921 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
105922 +rdm_62719 rdm 0 62719 NULL
105923 +key_replays_read_62746 key_replays_read 3 62746 NULL
105924 +init_chip_wc_pat_62768 init_chip_wc_pat 2 62768 NULL
105925 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
105926 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
105927 +C_SYSC_ipc_62776 C_SYSC_ipc 5-3-6-4 62776 NULL
105928 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
105929 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
105930 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
105931 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
105932 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
105933 +set_swbp_62853 set_swbp 3 62853 NULL
105934 +hpi_read_word_62862 hpi_read_word 0 62862 NULL
105935 +aoechr_write_62883 aoechr_write 3 62883 NULL
105936 +resize_info_buffer_62889 resize_info_buffer 2 62889 NULL
105937 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
105938 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
105939 +getdqbuf_62908 getdqbuf 1 62908 NULL
105940 +try_async_pf_62914 try_async_pf 3 62914 NULL nohasharray
105941 +SyS_remap_file_pages_62914 SyS_remap_file_pages 1 62914 &try_async_pf_62914
105942 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
105943 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 NULL
105944 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
105945 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
105946 +gso_pskb_expand_head_63052 gso_pskb_expand_head 2 63052 NULL
105947 +unlink1_63059 unlink1 3 63059 NULL
105948 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
105949 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 3 63078 NULL
105950 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-2-3 63087 NULL
105951 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
105952 +alloc_cblock_63133 alloc_cblock 2 63133 NULL
105953 +ib_send_cm_rtu_63138 ib_send_cm_rtu 3 63138 NULL
105954 +xen_zap_pfn_range_63149 xen_zap_pfn_range 1 63149 NULL
105955 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
105956 +vme_master_read_63221 vme_master_read 0 63221 NULL
105957 +SyS_gethostname_63227 SyS_gethostname 2 63227 NULL
105958 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
105959 +ptp_read_63251 ptp_read 4 63251 NULL
105960 +raid5_resize_63306 raid5_resize 2 63306 NULL
105961 +proc_info_read_63344 proc_info_read 3 63344 NULL
105962 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
105963 +idmouse_read_63374 idmouse_read 3 63374 NULL
105964 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
105965 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
105966 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
105967 +nouveau_event_create_63411 nouveau_event_create 1 63411 NULL
105968 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
105969 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 2-4-3 63429 NULL
105970 +kone_send_63435 kone_send 4 63435 NULL
105971 +gfn_to_hva_many_63437 gfn_to_hva_many 0-2 63437 NULL
105972 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
105973 +ipv6_is_mld_63461 ipv6_is_mld 3 63461 NULL
105974 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
105975 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
105976 +read_kcore_63488 read_kcore 3 63488 NULL
105977 +save_hint_63497 save_hint 2 63497 NULL
105978 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
105979 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4 63534 NULL
105980 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
105981 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
105982 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
105983 +kvm_write_guest_page_63555 kvm_write_guest_page 5-2 63555 &dbg_leb_write_63555
105984 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
105985 +iwch_reg_user_mr_63575 iwch_reg_user_mr 2-3 63575 NULL
105986 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
105987 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
105988 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
105989 +module_alloc_63630 module_alloc 1 63630 NULL
105990 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
105991 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
105992 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 4-5-3 63640 NULL
105993 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
105994 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
105995 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
105996 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
105997 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
105998 +alloc_tty_driver_63681 alloc_tty_driver 1 63681 NULL
105999 +mkiss_compat_ioctl_63686 mkiss_compat_ioctl 4 63686 NULL
106000 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
106001 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
106002 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4 63720 NULL
106003 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
106004 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
106005 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
106006 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2-3 63778 NULL
106007 +snapshot_compat_ioctl_63792 snapshot_compat_ioctl 3 63792 NULL
106008 +kovaplus_sysfs_write_63795 kovaplus_sysfs_write 6 63795 NULL
106009 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
106010 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
106011 +dec_zcache_eph_zbytes_63817 dec_zcache_eph_zbytes 1 63817 NULL
106012 +prepare_copy_63826 prepare_copy 2 63826 NULL
106013 +sel_write_load_63830 sel_write_load 3 63830 NULL
106014 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
106015 +init_map_ipmac_63896 init_map_ipmac 4-3 63896 NULL
106016 +divas_write_63901 divas_write 3 63901 NULL
106017 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 NULL
106018 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-3-2 63922 NULL
106019 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
106020 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
106021 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
106022 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
106023 +__team_options_register_63941 __team_options_register 3 63941 NULL
106024 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
106025 +ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz_63968 ieee80211_if_fmt_rc_rateidx_mcs_mask_2ghz 3 63968 NULL
106026 +ieee80211_authentication_req_63973 ieee80211_authentication_req 3 63973 NULL
106027 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
106028 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
106029 +kmemdup_64015 kmemdup 2 64015 NULL
106030 +SyS_rt_sigpending_64018 SyS_rt_sigpending 2 64018 NULL
106031 +offset_to_vaddr_64025 offset_to_vaddr 0-2 64025 NULL nohasharray
106032 +tcf_csum_skb_nextlayer_64025 tcf_csum_skb_nextlayer 3 64025 &offset_to_vaddr_64025
106033 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
106034 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
106035 +sep_lli_table_secure_dma_64042 sep_lli_table_secure_dma 2-3 64042 NULL
106036 +tfrc_calc_x_reverse_lookup_64057 tfrc_calc_x_reverse_lookup 0 64057 NULL
106037 +get_u8_64076 get_u8 0 64076 NULL
106038 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
106039 +vmci_handle_arr_get_size_64088 vmci_handle_arr_get_size 0 64088 NULL
106040 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
106041 +SyS_mq_timedsend_64107 SyS_mq_timedsend 3 64107 NULL
106042 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
106043 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
106044 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
106045 +init_bch_64130 init_bch 1-2 64130 NULL
106046 +SYSC_ptrace_64136 SYSC_ptrace 3-4 64136 NULL
106047 +uea_idma_write_64139 uea_idma_write 3 64139 NULL
106048 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
106049 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
106050 +__comedi_buf_alloc_64155 __comedi_buf_alloc 3 64155 NULL
106051 +cpumask_scnprintf_64170 cpumask_scnprintf 2 64170 NULL
106052 +read_pulse_64227 read_pulse 0-3 64227 NULL
106053 +header_len_64232 header_len 0 64232 NULL
106054 +redrat3_transmit_ir_64244 redrat3_transmit_ir 3 64244 NULL
106055 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
106056 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
106057 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
106058 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
106059 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
106060 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
106061 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
106062 +ffz_64324 ffz 0 64324 NULL
106063 +map_region_64328 map_region 1 64328 NULL
106064 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
106065 +ts_write_64336 ts_write 3 64336 NULL
106066 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
106067 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
106068 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
106069 +bnx2x_vfop_mcast_cmd_64354 bnx2x_vfop_mcast_cmd 5 64354 NULL
106070 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
106071 +ilo_write_64378 ilo_write 3 64378 NULL
106072 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
106073 +vmcs_readl_64381 vmcs_readl 0 64381 NULL
106074 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
106075 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
106076 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
106077 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
106078 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
106079 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
106080 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
106081 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
106082 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL nohasharray
106083 +read_file_spectral_short_repeat_64431 read_file_spectral_short_repeat 3 64431 &ext4_trim_extent_64431
106084 +cap_capable_64462 cap_capable 0 64462 NULL
106085 +ip_vs_create_timeout_table_64478 ip_vs_create_timeout_table 2 64478 NULL
106086 +single_open_size_64483 single_open_size 4 64483 NULL
106087 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
106088 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
106089 +remove_uuid_64505 remove_uuid 4 64505 NULL nohasharray
106090 +handle_abnormal_pfn_64505 handle_abnormal_pfn 3 64505 &remove_uuid_64505
106091 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
106092 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
106093 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
106094 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
106095 +SyS_bind_64544 SyS_bind 3 64544 NULL
106096 +rbd_obj_read_sync_64554 rbd_obj_read_sync 3-4 64554 NULL
106097 +__spi_sync_64561 __spi_sync 0 64561 NULL
106098 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
106099 +fanotify_write_64623 fanotify_write 3 64623 NULL
106100 +to_dblock_64655 to_dblock 0-1 64655 NULL
106101 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
106102 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
106103 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661
106104 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
106105 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
106106 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
106107 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL
106108 +__feat_register_sp_64712 __feat_register_sp 6 64712 NULL
106109 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
106110 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
106111 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
106112 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
106113 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
106114 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
106115 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
106116 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
106117 +regmap_reg_ranges_read_file_64798 regmap_reg_ranges_read_file 3 64798 NULL
106118 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
106119 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
106120 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
106121 +vaddr_get_pfn_64818 vaddr_get_pfn 1 64818 NULL
106122 +gfn_to_page_64826 gfn_to_page 2 64826 NULL
106123 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
106124 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
106125 +gfn_to_pfn_64870 gfn_to_pfn 2 64870 NULL
106126 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
106127 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
106128 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
106129 +snd_rawmidi_ioctl_compat_64954 snd_rawmidi_ioctl_compat 3 64954 NULL
106130 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
106131 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
106132 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
106133 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
106134 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
106135 +pskb_pull_65005 pskb_pull 2 65005 NULL
106136 +unifi_write_65012 unifi_write 3 65012 NULL
106137 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
106138 +nfs_readdata_alloc_65015 nfs_readdata_alloc 2 65015 NULL
106139 +insert_dent_65034 insert_dent 7 65034 NULL
106140 +compat_put_ushort_65040 compat_put_ushort 1 65040 NULL
106141 +brcmf_sdcard_rwdata_65041 brcmf_sdcard_rwdata 5 65041 NULL
106142 +tty_audit_log_65043 tty_audit_log 8 65043 NULL
106143 +compat_cmdtest_65064 compat_cmdtest 2 65064 NULL
106144 +count_run_65072 count_run 0-2-4 65072 NULL nohasharray
106145 +bnx2fc_process_l2_frame_compl_65072 bnx2fc_process_l2_frame_compl 3 65072 &count_run_65072
106146 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2-3 65076 NULL
106147 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
106148 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 NULL
106149 +C_SYSC_semctl_65091 C_SYSC_semctl 4 65091 NULL
106150 +ssb_bus_register_65183 ssb_bus_register 3 65183 NULL
106151 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
106152 +print_endpoint_stat_65232 print_endpoint_stat 3-4-0 65232 NULL
106153 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
106154 +atomic_long_read_65263 atomic_long_read 0 65263 NULL
106155 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
106156 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
106157 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
106158 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
106159 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
106160 +get_var_len_65304 get_var_len 0 65304 NULL
106161 +unpack_array_65318 unpack_array 0 65318 NULL
106162 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
106163 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
106164 +init_list_set_65351 init_list_set 2-3 65351 NULL
106165 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
106166 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
106167 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
106168 +__ext4_new_inode_65370 __ext4_new_inode 5 65370 NULL
106169 +strchr_65372 strchr 0 65372 NULL nohasharray
106170 +SyS_writev_65372 SyS_writev 3 65372 &strchr_65372
106171 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1-2 65397 NULL
106172 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
106173 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
106174 +iio_device_add_channel_sysfs_65406 iio_device_add_channel_sysfs 0 65406 NULL
106175 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 3-4 65410 NULL
106176 +drm_calloc_large_65421 drm_calloc_large 1-2 65421 NULL
106177 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
106178 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
106179 +ath_rx_edma_init_65483 ath_rx_edma_init 2 65483 NULL
106180 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 NULL
106181 +alloc_dr_65495 alloc_dr 2 65495 NULL
106182 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
106183 new file mode 100644
106184 index 0000000..9db0d0e
106185 --- /dev/null
106186 +++ b/tools/gcc/size_overflow_plugin.c
106187 @@ -0,0 +1,2114 @@
106188 +/*
106189 + * Copyright 2011, 2012, 2013 by Emese Revfy <re.emese@gmail.com>
106190 + * Licensed under the GPL v2, or (at your option) v3
106191 + *
106192 + * Homepage:
106193 + * http://www.grsecurity.net/~ephox/overflow_plugin/
106194 + *
106195 + * Documentation:
106196 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
106197 + *
106198 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
106199 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
106200 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
106201 + *
106202 + * Usage:
106203 + * $ 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
106204 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
106205 + */
106206 +
106207 +#include "gcc-plugin.h"
106208 +#include "config.h"
106209 +#include "system.h"
106210 +#include "coretypes.h"
106211 +#include "tree.h"
106212 +#include "tree-pass.h"
106213 +#include "intl.h"
106214 +#include "plugin-version.h"
106215 +#include "tm.h"
106216 +#include "toplev.h"
106217 +#include "function.h"
106218 +#include "tree-flow.h"
106219 +#include "plugin.h"
106220 +#include "gimple.h"
106221 +#include "diagnostic.h"
106222 +#include "cfgloop.h"
106223 +
106224 +#if BUILDING_GCC_VERSION >= 4008
106225 +#define TODO_dump_func 0
106226 +#endif
106227 +
106228 +struct size_overflow_hash {
106229 + const struct size_overflow_hash * const next;
106230 + const char * const name;
106231 + const unsigned int param;
106232 +};
106233 +
106234 +#include "size_overflow_hash.h"
106235 +
106236 +enum mark {
106237 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
106238 +};
106239 +
106240 +enum err_code_conditions {
106241 + CAST_ONLY, FROM_CONST
106242 +};
106243 +
106244 +static unsigned int call_count = 0;
106245 +
106246 +#define __unused __attribute__((__unused__))
106247 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
106248 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
106249 +#define BEFORE_STMT true
106250 +#define AFTER_STMT false
106251 +#define CREATE_NEW_VAR NULL_TREE
106252 +#define CODES_LIMIT 32
106253 +#define MAX_PARAM 31
106254 +#define MY_STMT GF_PLF_1
106255 +#define NO_CAST_CHECK GF_PLF_2
106256 +#define FROM_ARG true
106257 +#define FROM_RET false
106258 +
106259 +#if BUILDING_GCC_VERSION == 4005
106260 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
106261 +#endif
106262 +
106263 +int plugin_is_GPL_compatible;
106264 +void debug_gimple_stmt(gimple gs);
106265 +
106266 +static tree expand(struct pointer_set_t *visited, tree lhs);
106267 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs);
106268 +static tree report_size_overflow_decl;
106269 +static const_tree const_char_ptr_type_node;
106270 +static unsigned int handle_function(void);
106271 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
106272 +static tree get_size_overflow_type(gimple stmt, const_tree node);
106273 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
106274 +static void print_missing_msg(tree func, unsigned int argnum);
106275 +
106276 +static struct plugin_info size_overflow_plugin_info = {
106277 + .version = "20130410beta",
106278 + .help = "no-size-overflow\tturn off size overflow checking\n",
106279 +};
106280 +
106281 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
106282 +{
106283 + unsigned int arg_count;
106284 + enum tree_code code = TREE_CODE(*node);
106285 +
106286 + switch (code) {
106287 + case FUNCTION_DECL:
106288 + arg_count = type_num_arguments(TREE_TYPE(*node));
106289 + break;
106290 + case FUNCTION_TYPE:
106291 + case METHOD_TYPE:
106292 + arg_count = type_num_arguments(*node);
106293 + break;
106294 + default:
106295 + *no_add_attrs = true;
106296 + error("%s: %qE attribute only applies to functions", __func__, name);
106297 + return NULL_TREE;
106298 + }
106299 +
106300 + for (; args; args = TREE_CHAIN(args)) {
106301 + tree position = TREE_VALUE(args);
106302 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
106303 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
106304 + *no_add_attrs = true;
106305 + }
106306 + }
106307 + return NULL_TREE;
106308 +}
106309 +
106310 +static const char* get_asm_name(tree node)
106311 +{
106312 + return IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node));
106313 +}
106314 +
106315 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
106316 +{
106317 + unsigned int arg_count, arg_num;
106318 + enum tree_code code = TREE_CODE(*node);
106319 +
106320 + switch (code) {
106321 + case FUNCTION_DECL:
106322 + arg_count = type_num_arguments(TREE_TYPE(*node));
106323 + break;
106324 + case FUNCTION_TYPE:
106325 + case METHOD_TYPE:
106326 + arg_count = type_num_arguments(*node);
106327 + break;
106328 + case FIELD_DECL:
106329 + arg_num = TREE_INT_CST_LOW(TREE_VALUE(args));
106330 + if (arg_num != 0) {
106331 + *no_add_attrs = true;
106332 + error("%s: %qE attribute parameter can only be 0 in structure fields", __func__, name);
106333 + }
106334 + return NULL_TREE;
106335 + default:
106336 + *no_add_attrs = true;
106337 + error("%qE attribute only applies to functions", name);
106338 + return NULL_TREE;
106339 + }
106340 +
106341 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
106342 + return NULL_TREE;
106343 +
106344 + for (; args; args = TREE_CHAIN(args)) {
106345 + tree position = TREE_VALUE(args);
106346 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
106347 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
106348 + *no_add_attrs = true;
106349 + }
106350 + }
106351 + return NULL_TREE;
106352 +}
106353 +
106354 +static struct attribute_spec size_overflow_attr = {
106355 + .name = "size_overflow",
106356 + .min_length = 1,
106357 + .max_length = -1,
106358 + .decl_required = true,
106359 + .type_required = false,
106360 + .function_type_required = false,
106361 + .handler = handle_size_overflow_attribute,
106362 +#if BUILDING_GCC_VERSION >= 4007
106363 + .affects_type_identity = false
106364 +#endif
106365 +};
106366 +
106367 +static struct attribute_spec intentional_overflow_attr = {
106368 + .name = "intentional_overflow",
106369 + .min_length = 1,
106370 + .max_length = -1,
106371 + .decl_required = true,
106372 + .type_required = false,
106373 + .function_type_required = false,
106374 + .handler = handle_intentional_overflow_attribute,
106375 +#if BUILDING_GCC_VERSION >= 4007
106376 + .affects_type_identity = false
106377 +#endif
106378 +};
106379 +
106380 +static void register_attributes(void __unused *event_data, void __unused *data)
106381 +{
106382 + register_attribute(&size_overflow_attr);
106383 + register_attribute(&intentional_overflow_attr);
106384 +}
106385 +
106386 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
106387 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
106388 +{
106389 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
106390 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
106391 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
106392 +
106393 + unsigned int m = 0x57559429;
106394 + unsigned int n = 0x5052acdb;
106395 + const unsigned int *key4 = (const unsigned int *)key;
106396 + unsigned int h = len;
106397 + unsigned int k = len + seed + n;
106398 + unsigned long long p;
106399 +
106400 + while (len >= 8) {
106401 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
106402 + len -= 8;
106403 + }
106404 + if (len >= 4) {
106405 + cwmixb(key4[0]) key4 += 1;
106406 + len -= 4;
106407 + }
106408 + if (len)
106409 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
106410 + cwmixb(h ^ (k + n));
106411 + return k ^ h;
106412 +
106413 +#undef cwfold
106414 +#undef cwmixa
106415 +#undef cwmixb
106416 +}
106417 +
106418 +static inline unsigned int get_hash_num(const char *fndecl, const char *tree_codes, unsigned int len, unsigned int seed)
106419 +{
106420 + unsigned int fn = CrapWow(fndecl, strlen(fndecl), seed) & 0xffff;
106421 + unsigned int codes = CrapWow(tree_codes, len, seed) & 0xffff;
106422 + return fn ^ codes;
106423 +}
106424 +
106425 +static inline tree get_original_function_decl(tree fndecl)
106426 +{
106427 + if (DECL_ABSTRACT_ORIGIN(fndecl))
106428 + return DECL_ABSTRACT_ORIGIN(fndecl);
106429 + return fndecl;
106430 +}
106431 +
106432 +static inline gimple get_def_stmt(const_tree node)
106433 +{
106434 + gcc_assert(node != NULL_TREE);
106435 + if (TREE_CODE(node) != SSA_NAME)
106436 + return NULL;
106437 + return SSA_NAME_DEF_STMT(node);
106438 +}
106439 +
106440 +static unsigned char get_tree_code(const_tree type)
106441 +{
106442 + switch (TREE_CODE(type)) {
106443 + case ARRAY_TYPE:
106444 + return 0;
106445 + case BOOLEAN_TYPE:
106446 + return 1;
106447 + case ENUMERAL_TYPE:
106448 + return 2;
106449 + case FUNCTION_TYPE:
106450 + return 3;
106451 + case INTEGER_TYPE:
106452 + return 4;
106453 + case POINTER_TYPE:
106454 + return 5;
106455 + case RECORD_TYPE:
106456 + return 6;
106457 + case UNION_TYPE:
106458 + return 7;
106459 + case VOID_TYPE:
106460 + return 8;
106461 + case REAL_TYPE:
106462 + return 9;
106463 + case VECTOR_TYPE:
106464 + return 10;
106465 + case REFERENCE_TYPE:
106466 + return 11;
106467 + case OFFSET_TYPE:
106468 + return 12;
106469 + case COMPLEX_TYPE:
106470 + return 13;
106471 + default:
106472 + debug_tree((tree)type);
106473 + gcc_unreachable();
106474 + }
106475 +}
106476 +
106477 +static size_t add_type_codes(const_tree type, unsigned char *tree_codes, size_t len)
106478 +{
106479 + gcc_assert(type != NULL_TREE);
106480 +
106481 + while (type && len < CODES_LIMIT) {
106482 + tree_codes[len] = get_tree_code(type);
106483 + len++;
106484 + type = TREE_TYPE(type);
106485 + }
106486 + return len;
106487 +}
106488 +
106489 +static unsigned int get_function_decl(const_tree fndecl, unsigned char *tree_codes)
106490 +{
106491 + const_tree arg, result, arg_field, type = TREE_TYPE(fndecl);
106492 + enum tree_code code = TREE_CODE(type);
106493 + size_t len = 0;
106494 +
106495 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
106496 +
106497 + arg = TYPE_ARG_TYPES(type);
106498 + // skip builtins __builtin_constant_p
106499 + if (!arg && DECL_BUILT_IN(fndecl))
106500 + return 0;
106501 +
106502 + if (TREE_CODE_CLASS(code) == tcc_type)
106503 + result = type;
106504 + else
106505 + result = DECL_RESULT(fndecl);
106506 +
106507 + gcc_assert(result != NULL_TREE);
106508 + len = add_type_codes(TREE_TYPE(result), tree_codes, len);
106509 +
106510 + if (arg == NULL_TREE) {
106511 + gcc_assert(CODE_CONTAINS_STRUCT(TREE_CODE(fndecl), TS_DECL_NON_COMMON));
106512 + arg_field = DECL_ARGUMENT_FLD(fndecl);
106513 + if (arg_field == NULL_TREE)
106514 + return 0;
106515 + arg = TREE_TYPE(arg_field);
106516 + len = add_type_codes(arg, tree_codes, len);
106517 + gcc_assert(len != 0);
106518 + return len;
106519 + }
106520 +
106521 + gcc_assert(arg != NULL_TREE && TREE_CODE(arg) == TREE_LIST);
106522 + while (arg && len < CODES_LIMIT) {
106523 + len = add_type_codes(TREE_VALUE(arg), tree_codes, len);
106524 + arg = TREE_CHAIN(arg);
106525 + }
106526 +
106527 + gcc_assert(len != 0);
106528 + return len;
106529 +}
106530 +
106531 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
106532 +{
106533 + unsigned int hash;
106534 + const struct size_overflow_hash *entry;
106535 + unsigned char tree_codes[CODES_LIMIT];
106536 + size_t len;
106537 + const char *func_name;
106538 +
106539 + fndecl = get_original_function_decl(fndecl);
106540 + len = get_function_decl(fndecl, tree_codes);
106541 + if (len == 0)
106542 + return NULL;
106543 +
106544 + func_name = get_asm_name(fndecl);
106545 + hash = get_hash_num(func_name, (const char*) tree_codes, len, 0);
106546 +
106547 + entry = size_overflow_hash[hash];
106548 + while (entry) {
106549 + if (!strcmp(entry->name, func_name))
106550 + return entry;
106551 + entry = entry->next;
106552 + }
106553 +
106554 + return NULL;
106555 +}
106556 +
106557 +static bool is_bool(const_tree node)
106558 +{
106559 + const_tree type;
106560 +
106561 + if (node == NULL_TREE)
106562 + return false;
106563 +
106564 + type = TREE_TYPE(node);
106565 + if (!INTEGRAL_TYPE_P(type))
106566 + return false;
106567 + if (TREE_CODE(type) == BOOLEAN_TYPE)
106568 + return true;
106569 + if (TYPE_PRECISION(type) == 1)
106570 + return true;
106571 + return false;
106572 +}
106573 +
106574 +static bool skip_types(const_tree var)
106575 +{
106576 + tree type;
106577 +
106578 + if (is_gimple_constant(var))
106579 + return true;
106580 +
106581 + switch (TREE_CODE(var)) {
106582 + case ADDR_EXPR:
106583 +#if BUILDING_GCC_VERSION >= 4006
106584 + case MEM_REF:
106585 +#endif
106586 + case ARRAY_REF:
106587 + case BIT_FIELD_REF:
106588 + case INDIRECT_REF:
106589 + case TARGET_MEM_REF:
106590 + return true;
106591 + case PARM_DECL:
106592 + case VAR_DECL:
106593 + case COMPONENT_REF:
106594 + return false;
106595 + default:
106596 + break;
106597 + }
106598 +
106599 + gcc_assert(TREE_CODE(var) == SSA_NAME);
106600 +
106601 + type = TREE_TYPE(var);
106602 + switch (TREE_CODE(type)) {
106603 + case INTEGER_TYPE:
106604 + case ENUMERAL_TYPE:
106605 + return false;
106606 + case BOOLEAN_TYPE:
106607 + return is_bool(var);
106608 + default:
106609 + break;
106610 + }
106611 +
106612 + gcc_assert(TREE_CODE(type) == POINTER_TYPE);
106613 +
106614 + type = TREE_TYPE(type);
106615 + gcc_assert(type != NULL_TREE);
106616 + switch (TREE_CODE(type)) {
106617 + case RECORD_TYPE:
106618 + case POINTER_TYPE:
106619 + case ARRAY_TYPE:
106620 + return true;
106621 + case VOID_TYPE:
106622 + case INTEGER_TYPE:
106623 + case UNION_TYPE:
106624 + return false;
106625 + default:
106626 + break;
106627 + }
106628 +
106629 + debug_tree((tree)var);
106630 + gcc_unreachable();
106631 +}
106632 +
106633 +static unsigned int find_arg_number(const_tree arg, tree func)
106634 +{
106635 + tree var;
106636 + unsigned int argnum = 1;
106637 +
106638 + if (TREE_CODE(arg) == SSA_NAME)
106639 + arg = SSA_NAME_VAR(arg);
106640 +
106641 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
106642 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
106643 + continue;
106644 + if (!skip_types(var))
106645 + return argnum;
106646 + }
106647 +
106648 + return 0;
106649 +}
106650 +
106651 +static tree create_new_var(tree type)
106652 +{
106653 + tree new_var = create_tmp_var(type, "cicus");
106654 +
106655 +#if BUILDING_GCC_VERSION <= 4007
106656 + add_referenced_var(new_var);
106657 + mark_sym_for_renaming(new_var);
106658 +#endif
106659 + return new_var;
106660 +}
106661 +
106662 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
106663 +{
106664 + gimple assign;
106665 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
106666 + tree type = TREE_TYPE(rhs1);
106667 + tree lhs = create_new_var(type);
106668 +
106669 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
106670 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
106671 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
106672 +
106673 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
106674 + update_stmt(assign);
106675 + gimple_set_plf(assign, MY_STMT, true);
106676 + return assign;
106677 +}
106678 +
106679 +static tree cast_a_tree(tree type, tree var)
106680 +{
106681 + gcc_assert(type != NULL_TREE);
106682 + gcc_assert(var != NULL_TREE);
106683 + gcc_assert(fold_convertible_p(type, var));
106684 +
106685 + return fold_convert(type, var);
106686 +}
106687 +
106688 +static tree get_lhs(const_gimple stmt)
106689 +{
106690 + switch (gimple_code(stmt)) {
106691 + case GIMPLE_ASSIGN:
106692 + return gimple_get_lhs(stmt);
106693 + case GIMPLE_PHI:
106694 + return gimple_phi_result(stmt);
106695 + case GIMPLE_CALL:
106696 + return gimple_call_lhs(stmt);
106697 + default:
106698 + return NULL_TREE;
106699 + }
106700 +}
106701 +
106702 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
106703 +{
106704 + const_gimple def_stmt = get_def_stmt(rhs);
106705 +
106706 + if (force)
106707 + return false;
106708 +
106709 + if (is_gimple_constant(rhs))
106710 + return false;
106711 +
106712 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
106713 + return false;
106714 +
106715 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
106716 + return false;
106717 +
106718 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
106719 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
106720 + return false;
106721 +
106722 + return true;
106723 +}
106724 +
106725 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
106726 +{
106727 + gimple assign, def_stmt;
106728 +
106729 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
106730 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
106731 + gcc_unreachable();
106732 +
106733 + def_stmt = get_def_stmt(rhs);
106734 + if (skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
106735 + return def_stmt;
106736 +
106737 + if (lhs == CREATE_NEW_VAR)
106738 + lhs = create_new_var(dst_type);
106739 +
106740 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
106741 +
106742 + if (!gsi_end_p(*gsi)) {
106743 + location_t loc = gimple_location(gsi_stmt(*gsi));
106744 + gimple_set_location(assign, loc);
106745 + }
106746 +
106747 + gimple_set_lhs(assign, make_ssa_name(lhs, assign));
106748 +
106749 + if (before)
106750 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
106751 + else
106752 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
106753 + update_stmt(assign);
106754 + gimple_set_plf(assign, MY_STMT, true);
106755 +
106756 + return assign;
106757 +}
106758 +
106759 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
106760 +{
106761 + gimple_stmt_iterator gsi;
106762 + tree lhs;
106763 + const_gimple new_stmt;
106764 +
106765 + if (rhs == NULL_TREE)
106766 + return NULL_TREE;
106767 +
106768 + gsi = gsi_for_stmt(stmt);
106769 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
106770 +
106771 + lhs = get_lhs(new_stmt);
106772 + gcc_assert(lhs != NULL_TREE);
106773 + return lhs;
106774 +}
106775 +
106776 +static tree cast_to_TI_type(gimple stmt, tree node)
106777 +{
106778 + gimple_stmt_iterator gsi;
106779 + gimple cast_stmt;
106780 + tree type = TREE_TYPE(node);
106781 +
106782 + if (types_compatible_p(type, intTI_type_node))
106783 + return node;
106784 +
106785 + gsi = gsi_for_stmt(stmt);
106786 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
106787 + return gimple_get_lhs(cast_stmt);
106788 +}
106789 +
106790 +static void check_function_hash(const_gimple stmt)
106791 +{
106792 + tree func;
106793 + const struct size_overflow_hash *hash;
106794 +
106795 + if (gimple_code(stmt) != GIMPLE_CALL)
106796 + return;
106797 +
106798 + func = gimple_call_fndecl(stmt);
106799 + //fs/xattr.c D.34222_15 = D.34219_14 (dentry_3(D), name_7(D), 0B, 0);
106800 + if (func == NULL_TREE)
106801 + return;
106802 +
106803 + hash = get_function_hash(func);
106804 + if (!hash)
106805 + print_missing_msg(func, 0);
106806 +}
106807 +
106808 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
106809 +{
106810 + tree lhs, new_lhs;
106811 + gimple_stmt_iterator gsi;
106812 +
106813 + if (rhs1 == NULL_TREE) {
106814 + debug_gimple_stmt(oldstmt);
106815 + error("%s: rhs1 is NULL_TREE", __func__);
106816 + gcc_unreachable();
106817 + }
106818 +
106819 + switch (gimple_code(oldstmt)) {
106820 + case GIMPLE_ASM:
106821 + lhs = rhs1;
106822 + break;
106823 + case GIMPLE_CALL:
106824 + lhs = gimple_call_lhs(oldstmt);
106825 + break;
106826 + case GIMPLE_ASSIGN:
106827 + lhs = gimple_get_lhs(oldstmt);
106828 + break;
106829 + default:
106830 + debug_gimple_stmt(oldstmt);
106831 + gcc_unreachable();
106832 + }
106833 +
106834 + gsi = gsi_for_stmt(oldstmt);
106835 + pointer_set_insert(visited, oldstmt);
106836 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
106837 + basic_block next_bb, cur_bb;
106838 + const_edge e;
106839 +
106840 + gcc_assert(before == false);
106841 + gcc_assert(stmt_can_throw_internal(oldstmt));
106842 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
106843 + gcc_assert(!gsi_end_p(gsi));
106844 +
106845 + cur_bb = gimple_bb(oldstmt);
106846 + next_bb = cur_bb->next_bb;
106847 + e = find_edge(cur_bb, next_bb);
106848 + gcc_assert(e != NULL);
106849 + gcc_assert(e->flags & EDGE_FALLTHRU);
106850 +
106851 + gsi = gsi_after_labels(next_bb);
106852 + gcc_assert(!gsi_end_p(gsi));
106853 +
106854 + before = true;
106855 + oldstmt = gsi_stmt(gsi);
106856 + }
106857 +
106858 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
106859 + return new_lhs;
106860 +}
106861 +
106862 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
106863 +{
106864 + gimple stmt;
106865 + gimple_stmt_iterator gsi;
106866 + tree size_overflow_type, new_var, lhs = gimple_get_lhs(oldstmt);
106867 +
106868 + if (gimple_plf(oldstmt, MY_STMT))
106869 + return lhs;
106870 +
106871 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
106872 + rhs1 = gimple_assign_rhs1(oldstmt);
106873 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
106874 + }
106875 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
106876 + rhs2 = gimple_assign_rhs2(oldstmt);
106877 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
106878 + }
106879 +
106880 + stmt = gimple_copy(oldstmt);
106881 + gimple_set_location(stmt, gimple_location(oldstmt));
106882 + gimple_set_plf(stmt, MY_STMT, true);
106883 +
106884 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
106885 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
106886 +
106887 + size_overflow_type = get_size_overflow_type(oldstmt, node);
106888 +
106889 + new_var = create_new_var(size_overflow_type);
106890 + new_var = make_ssa_name(new_var, stmt);
106891 + gimple_set_lhs(stmt, new_var);
106892 +
106893 + if (rhs1 != NULL_TREE)
106894 + gimple_assign_set_rhs1(stmt, rhs1);
106895 +
106896 + if (rhs2 != NULL_TREE)
106897 + gimple_assign_set_rhs2(stmt, rhs2);
106898 +#if BUILDING_GCC_VERSION >= 4007
106899 + if (rhs3 != NULL_TREE)
106900 + gimple_assign_set_rhs3(stmt, rhs3);
106901 +#endif
106902 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
106903 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
106904 +
106905 + gsi = gsi_for_stmt(oldstmt);
106906 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
106907 + update_stmt(stmt);
106908 + pointer_set_insert(visited, oldstmt);
106909 + return gimple_get_lhs(stmt);
106910 +}
106911 +
106912 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type)
106913 +{
106914 + basic_block first_bb;
106915 + gimple assign;
106916 + gimple_stmt_iterator gsi;
106917 +
106918 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
106919 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
106920 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
106921 +
106922 + gsi = gsi_start_bb(first_bb);
106923 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
106924 + return gimple_get_lhs(assign);
106925 +}
106926 +
106927 +static tree use_phi_ssa_name(tree phi_ssa_name, tree new_arg)
106928 +{
106929 + gimple_stmt_iterator gsi;
106930 + const_gimple assign;
106931 + gimple def_stmt = get_def_stmt(new_arg);
106932 +
106933 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
106934 + gsi = gsi_after_labels(gimple_bb(def_stmt));
106935 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, BEFORE_STMT, true);
106936 + } else {
106937 + gsi = gsi_for_stmt(def_stmt);
106938 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, phi_ssa_name, &gsi, AFTER_STMT, true);
106939 + }
106940 +
106941 + return gimple_get_lhs(assign);
106942 +}
106943 +
106944 +static tree cast_visited_phi_arg(tree phi_ssa_name, tree arg, tree size_overflow_type)
106945 +{
106946 + basic_block bb;
106947 + gimple_stmt_iterator gsi;
106948 + const_gimple assign, def_stmt;
106949 +
106950 + def_stmt = get_def_stmt(arg);
106951 + bb = gimple_bb(def_stmt);
106952 + gcc_assert(bb->index != 0);
106953 + gsi = gsi_after_labels(bb);
106954 +
106955 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
106956 + return gimple_get_lhs(assign);
106957 +}
106958 +
106959 +static tree create_new_phi_arg(tree phi_ssa_name, tree new_arg, tree arg, gimple oldstmt)
106960 +{
106961 + tree size_overflow_type;
106962 + const_gimple def_stmt = get_def_stmt(arg);
106963 +
106964 + if (phi_ssa_name != NULL_TREE)
106965 + phi_ssa_name = SSA_NAME_VAR(phi_ssa_name);
106966 +
106967 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
106968 +
106969 + if (new_arg != NULL_TREE) {
106970 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
106971 + return use_phi_ssa_name(phi_ssa_name, new_arg);
106972 + }
106973 +
106974 + switch(gimple_code(def_stmt)) {
106975 + case GIMPLE_PHI:
106976 + return cast_visited_phi_arg(phi_ssa_name, arg, size_overflow_type);
106977 + case GIMPLE_NOP:
106978 + return cast_parm_decl(phi_ssa_name, arg, size_overflow_type);
106979 + default:
106980 + debug_gimple_stmt((gimple)def_stmt);
106981 + gcc_unreachable();
106982 + }
106983 +}
106984 +
106985 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
106986 +{
106987 + basic_block bb;
106988 + gimple phi;
106989 + gimple_seq seq;
106990 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
106991 +
106992 + bb = gsi_bb(gsi);
106993 +
106994 + phi = create_phi_node(result, bb);
106995 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
106996 + seq = phi_nodes(bb);
106997 + gsi = gsi_last(seq);
106998 + gsi_remove(&gsi, false);
106999 +
107000 + gsi = gsi_for_stmt(oldstmt);
107001 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
107002 + gimple_set_bb(phi, bb);
107003 + gimple_set_plf(phi, MY_STMT, true);
107004 + return phi;
107005 +}
107006 +
107007 +static tree handle_phi(struct pointer_set_t *visited, tree orig_result)
107008 +{
107009 + gimple new_phi = NULL;
107010 + gimple oldstmt = get_def_stmt(orig_result);
107011 + tree phi_ssa_name = NULL_TREE;
107012 + unsigned int i;
107013 +
107014 + pointer_set_insert(visited, oldstmt);
107015 + for (i = 0; i < gimple_phi_num_args(oldstmt); i++) {
107016 + tree arg, new_arg;
107017 +
107018 + arg = gimple_phi_arg_def(oldstmt, i);
107019 +
107020 + new_arg = expand(visited, arg);
107021 + new_arg = create_new_phi_arg(phi_ssa_name, new_arg, arg, oldstmt);
107022 + if (i == 0) {
107023 + phi_ssa_name = new_arg;
107024 + new_phi = overflow_create_phi_node(oldstmt, SSA_NAME_VAR(phi_ssa_name));
107025 + }
107026 +
107027 + gcc_assert(new_phi != NULL);
107028 + add_phi_arg(new_phi, new_arg, gimple_phi_arg_edge(oldstmt, i), gimple_location(oldstmt));
107029 + }
107030 +
107031 + gcc_assert(new_phi != NULL);
107032 + update_stmt(new_phi);
107033 + return gimple_phi_result(new_phi);
107034 +}
107035 +
107036 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
107037 +{
107038 + const_gimple assign;
107039 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
107040 + tree origtype = TREE_TYPE(orig_rhs);
107041 +
107042 + gcc_assert(gimple_code(stmt) == GIMPLE_ASSIGN);
107043 +
107044 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
107045 + return gimple_get_lhs(assign);
107046 +}
107047 +
107048 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
107049 +{
107050 + const_tree rhs1, lhs, rhs1_type, lhs_type;
107051 + enum machine_mode lhs_mode, rhs_mode;
107052 + gimple def_stmt = get_def_stmt(no_const_rhs);
107053 +
107054 + if (!gimple_assign_cast_p(def_stmt))
107055 + return false;
107056 +
107057 + rhs1 = gimple_assign_rhs1(def_stmt);
107058 + lhs = gimple_get_lhs(def_stmt);
107059 + rhs1_type = TREE_TYPE(rhs1);
107060 + lhs_type = TREE_TYPE(lhs);
107061 + rhs_mode = TYPE_MODE(rhs1_type);
107062 + lhs_mode = TYPE_MODE(lhs_type);
107063 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
107064 + return false;
107065 +
107066 + return true;
107067 +}
107068 +
107069 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
107070 +{
107071 + tree rhs1 = gimple_assign_rhs1(stmt);
107072 + tree lhs = gimple_get_lhs(stmt);
107073 + const_tree rhs1_type = TREE_TYPE(rhs1);
107074 + const_tree lhs_type = TREE_TYPE(lhs);
107075 +
107076 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
107077 + return create_assign(visited, stmt, lhs, AFTER_STMT);
107078 +
107079 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
107080 +}
107081 +
107082 +static bool no_uses(tree node)
107083 +{
107084 + imm_use_iterator imm_iter;
107085 + use_operand_p use_p;
107086 +
107087 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
107088 + const_gimple use_stmt = USE_STMT(use_p);
107089 + if (use_stmt == NULL)
107090 + return true;
107091 + if (is_gimple_debug(use_stmt))
107092 + continue;
107093 + if (!(gimple_bb(use_stmt)->flags & BB_REACHABLE))
107094 + continue;
107095 + return false;
107096 + }
107097 + return true;
107098 +}
107099 +
107100 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
107101 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
107102 +{
107103 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
107104 + gimple def_stmt = get_def_stmt(lhs);
107105 +
107106 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
107107 + return false;
107108 +
107109 + rhs1 = gimple_assign_rhs1(def_stmt);
107110 + rhs_type = TREE_TYPE(rhs1);
107111 + lhs_type = TREE_TYPE(lhs);
107112 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
107113 + return false;
107114 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
107115 + return false;
107116 +
107117 + def_stmt = get_def_stmt(rhs1);
107118 + if (!def_stmt || gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_num_ops(def_stmt) != 3)
107119 + return false;
107120 +
107121 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
107122 + return false;
107123 +
107124 + rhs1 = gimple_assign_rhs1(def_stmt);
107125 + rhs2 = gimple_assign_rhs2(def_stmt);
107126 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
107127 + return false;
107128 +
107129 + if (is_gimple_constant(rhs2))
107130 + not_const_rhs = rhs1;
107131 + else
107132 + not_const_rhs = rhs2;
107133 +
107134 + return no_uses(not_const_rhs);
107135 +}
107136 +
107137 +static bool skip_lhs_cast_check(const_gimple stmt)
107138 +{
107139 + const_tree rhs = gimple_assign_rhs1(stmt);
107140 + const_gimple def_stmt = get_def_stmt(rhs);
107141 +
107142 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
107143 + if (gimple_code(def_stmt) == GIMPLE_ASM)
107144 + return true;
107145 +
107146 + if (is_const_plus_unsigned_signed_truncation(rhs))
107147 + return true;
107148 +
107149 + return false;
107150 +}
107151 +
107152 +static tree create_cast_overflow_check(struct pointer_set_t *visited, tree new_rhs1, gimple stmt)
107153 +{
107154 + bool cast_lhs, cast_rhs;
107155 + tree lhs = gimple_get_lhs(stmt);
107156 + tree rhs = gimple_assign_rhs1(stmt);
107157 + const_tree lhs_type = TREE_TYPE(lhs);
107158 + const_tree rhs_type = TREE_TYPE(rhs);
107159 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
107160 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
107161 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
107162 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
107163 +
107164 + static bool check_lhs[3][4] = {
107165 + // ss su us uu
107166 + { false, true, true, false }, // lhs > rhs
107167 + { false, false, false, false }, // lhs = rhs
107168 + { true, true, true, true }, // lhs < rhs
107169 + };
107170 +
107171 + static bool check_rhs[3][4] = {
107172 + // ss su us uu
107173 + { true, false, true, true }, // lhs > rhs
107174 + { true, false, true, true }, // lhs = rhs
107175 + { true, false, true, true }, // lhs < rhs
107176 + };
107177 +
107178 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
107179 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
107180 + return create_assign(visited, stmt, lhs, AFTER_STMT);
107181 +
107182 + if (lhs_size > rhs_size) {
107183 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
107184 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
107185 + } else if (lhs_size == rhs_size) {
107186 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
107187 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
107188 + } else {
107189 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
107190 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
107191 + }
107192 +
107193 + if (!cast_lhs && !cast_rhs)
107194 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
107195 +
107196 + if (cast_lhs && !skip_lhs_cast_check(stmt))
107197 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
107198 +
107199 + if (cast_rhs)
107200 + check_size_overflow(stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
107201 +
107202 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
107203 +}
107204 +
107205 +static tree handle_unary_rhs(struct pointer_set_t *visited, gimple stmt)
107206 +{
107207 + tree rhs1, new_rhs1, lhs = gimple_get_lhs(stmt);
107208 +
107209 + if (gimple_plf(stmt, MY_STMT))
107210 + return lhs;
107211 +
107212 + rhs1 = gimple_assign_rhs1(stmt);
107213 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
107214 + return create_assign(visited, stmt, lhs, AFTER_STMT);
107215 +
107216 + new_rhs1 = expand(visited, rhs1);
107217 +
107218 + if (new_rhs1 == NULL_TREE)
107219 + return create_cast_assign(visited, stmt);
107220 +
107221 + if (gimple_plf(stmt, NO_CAST_CHECK))
107222 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
107223 +
107224 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
107225 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
107226 +
107227 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
107228 + check_size_overflow(stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
107229 + return create_assign(visited, stmt, lhs, AFTER_STMT);
107230 + }
107231 +
107232 + if (!gimple_assign_cast_p(stmt))
107233 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
107234 +
107235 + return create_cast_overflow_check(visited, new_rhs1, stmt);
107236 +}
107237 +
107238 +static tree handle_unary_ops(struct pointer_set_t *visited, gimple stmt)
107239 +{
107240 + tree rhs1, lhs = gimple_get_lhs(stmt);
107241 + gimple def_stmt = get_def_stmt(lhs);
107242 +
107243 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
107244 + rhs1 = gimple_assign_rhs1(def_stmt);
107245 +
107246 + if (is_gimple_constant(rhs1))
107247 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
107248 +
107249 + switch (TREE_CODE(rhs1)) {
107250 + case SSA_NAME:
107251 + return handle_unary_rhs(visited, def_stmt);
107252 + case ARRAY_REF:
107253 + case BIT_FIELD_REF:
107254 + case ADDR_EXPR:
107255 + case COMPONENT_REF:
107256 + case INDIRECT_REF:
107257 +#if BUILDING_GCC_VERSION >= 4006
107258 + case MEM_REF:
107259 +#endif
107260 + case TARGET_MEM_REF:
107261 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
107262 + case PARM_DECL:
107263 + case VAR_DECL:
107264 + return create_assign(visited, stmt, lhs, AFTER_STMT);
107265 +
107266 + default:
107267 + debug_gimple_stmt(def_stmt);
107268 + debug_tree(rhs1);
107269 + gcc_unreachable();
107270 + }
107271 +}
107272 +
107273 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
107274 +{
107275 + gimple cond_stmt;
107276 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
107277 +
107278 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
107279 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
107280 + update_stmt(cond_stmt);
107281 +}
107282 +
107283 +static tree create_string_param(tree string)
107284 +{
107285 + tree i_type, a_type;
107286 + const int length = TREE_STRING_LENGTH(string);
107287 +
107288 + gcc_assert(length > 0);
107289 +
107290 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
107291 + a_type = build_array_type(char_type_node, i_type);
107292 +
107293 + TREE_TYPE(string) = a_type;
107294 + TREE_CONSTANT(string) = 1;
107295 + TREE_READONLY(string) = 1;
107296 +
107297 + return build1(ADDR_EXPR, ptr_type_node, string);
107298 +}
107299 +
107300 +static void insert_cond_result(basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
107301 +{
107302 + gimple func_stmt;
107303 + const_gimple def_stmt;
107304 + const_tree loc_line;
107305 + tree loc_file, ssa_name, current_func;
107306 + expanded_location xloc;
107307 + char *ssa_name_buf;
107308 + int len;
107309 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
107310 +
107311 + def_stmt = get_def_stmt(arg);
107312 + xloc = expand_location(gimple_location(def_stmt));
107313 +
107314 + if (!gimple_has_location(def_stmt)) {
107315 + xloc = expand_location(gimple_location(stmt));
107316 + if (!gimple_has_location(stmt))
107317 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
107318 + }
107319 +
107320 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
107321 +
107322 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
107323 + loc_file = create_string_param(loc_file);
107324 +
107325 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
107326 + current_func = create_string_param(current_func);
107327 +
107328 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
107329 + call_count++;
107330 + 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);
107331 + gcc_assert(len > 0);
107332 + ssa_name = build_string(len + 1, ssa_name_buf);
107333 + free(ssa_name_buf);
107334 + ssa_name = create_string_param(ssa_name);
107335 +
107336 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
107337 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
107338 +
107339 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
107340 +}
107341 +
107342 +static void __unused print_the_code_insertions(const_gimple stmt)
107343 +{
107344 + location_t loc = gimple_location(stmt);
107345 +
107346 + inform(loc, "Integer size_overflow check applied here.");
107347 +}
107348 +
107349 +static void insert_check_size_overflow(gimple stmt, enum tree_code cond_code, tree arg, tree type_value, bool before, bool min)
107350 +{
107351 + basic_block cond_bb, join_bb, bb_true;
107352 + edge e;
107353 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
107354 +
107355 + cond_bb = gimple_bb(stmt);
107356 + if (before)
107357 + gsi_prev(&gsi);
107358 + if (gsi_end_p(gsi))
107359 + e = split_block_after_labels(cond_bb);
107360 + else
107361 + e = split_block(cond_bb, gsi_stmt(gsi));
107362 + cond_bb = e->src;
107363 + join_bb = e->dest;
107364 + e->flags = EDGE_FALSE_VALUE;
107365 + e->probability = REG_BR_PROB_BASE;
107366 +
107367 + bb_true = create_empty_bb(cond_bb);
107368 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
107369 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
107370 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
107371 +
107372 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
107373 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
107374 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
107375 +
107376 + if (current_loops != NULL) {
107377 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
107378 + add_bb_to_loop(bb_true, cond_bb->loop_father);
107379 + }
107380 +
107381 + insert_cond(cond_bb, arg, cond_code, type_value);
107382 + insert_cond_result(bb_true, stmt, arg, min);
107383 +
107384 +// print_the_code_insertions(stmt);
107385 +}
107386 +
107387 +static void check_size_overflow(gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
107388 +{
107389 + const_tree rhs_type = TREE_TYPE(rhs);
107390 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
107391 +
107392 + gcc_assert(rhs_type != NULL_TREE);
107393 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
107394 + return;
107395 +
107396 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
107397 +
107398 + if (is_const_plus_unsigned_signed_truncation(rhs))
107399 + return;
107400 +
107401 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
107402 + // typemax (-1) < typemin (0)
107403 + if (TREE_OVERFLOW(type_max))
107404 + return;
107405 +
107406 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
107407 +
107408 + cast_rhs_type = TREE_TYPE(cast_rhs);
107409 + type_max_type = TREE_TYPE(type_max);
107410 + type_min_type = TREE_TYPE(type_min);
107411 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
107412 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
107413 +
107414 + insert_check_size_overflow(stmt, GT_EXPR, cast_rhs, type_max, before, false);
107415 + insert_check_size_overflow(stmt, LT_EXPR, cast_rhs, type_min, before, true);
107416 +}
107417 +
107418 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
107419 +{
107420 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
107421 + return false;
107422 + if (!is_gimple_constant(rhs))
107423 + return false;
107424 + return true;
107425 +}
107426 +
107427 +static tree get_def_stmt_rhs(const_tree var)
107428 +{
107429 + tree rhs1, def_stmt_rhs1;
107430 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
107431 +
107432 + def_stmt = get_def_stmt(var);
107433 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
107434 +
107435 + rhs1 = gimple_assign_rhs1(def_stmt);
107436 + rhs1_def_stmt = get_def_stmt(rhs1);
107437 + if (!gimple_assign_cast_p(rhs1_def_stmt))
107438 + return rhs1;
107439 +
107440 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
107441 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
107442 +
107443 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
107444 + case GIMPLE_CALL:
107445 + case GIMPLE_NOP:
107446 + case GIMPLE_ASM:
107447 + case GIMPLE_PHI:
107448 + return def_stmt_rhs1;
107449 + case GIMPLE_ASSIGN:
107450 + return rhs1;
107451 + default:
107452 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
107453 + gcc_unreachable();
107454 + }
107455 +}
107456 +
107457 +static tree handle_intentional_overflow(struct pointer_set_t *visited, bool check_overflow, gimple stmt, tree change_rhs, tree new_rhs2)
107458 +{
107459 + tree new_rhs, orig_rhs;
107460 + void (*gimple_assign_set_rhs)(gimple, tree);
107461 + tree rhs1 = gimple_assign_rhs1(stmt);
107462 + tree rhs2 = gimple_assign_rhs2(stmt);
107463 + tree lhs = gimple_get_lhs(stmt);
107464 +
107465 + if (!check_overflow)
107466 + return create_assign(visited, stmt, lhs, AFTER_STMT);
107467 +
107468 + if (change_rhs == NULL_TREE)
107469 + return create_assign(visited, stmt, lhs, AFTER_STMT);
107470 +
107471 + if (new_rhs2 == NULL_TREE) {
107472 + orig_rhs = rhs1;
107473 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
107474 + } else {
107475 + orig_rhs = rhs2;
107476 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
107477 + }
107478 +
107479 + check_size_overflow(stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
107480 +
107481 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
107482 + gimple_assign_set_rhs(stmt, new_rhs);
107483 + update_stmt(stmt);
107484 +
107485 + return create_assign(visited, stmt, lhs, AFTER_STMT);
107486 +}
107487 +
107488 +static bool is_subtraction_special(const_gimple stmt)
107489 +{
107490 + gimple rhs1_def_stmt, rhs2_def_stmt;
107491 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
107492 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
107493 + const_tree rhs1 = gimple_assign_rhs1(stmt);
107494 + const_tree rhs2 = gimple_assign_rhs2(stmt);
107495 +
107496 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
107497 + return false;
107498 +
107499 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
107500 +
107501 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
107502 + return false;
107503 +
107504 + rhs1_def_stmt = get_def_stmt(rhs1);
107505 + rhs2_def_stmt = get_def_stmt(rhs2);
107506 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
107507 + return false;
107508 +
107509 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
107510 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
107511 + rhs1_def_stmt_lhs = gimple_get_lhs(rhs1_def_stmt);
107512 + rhs2_def_stmt_lhs = gimple_get_lhs(rhs2_def_stmt);
107513 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
107514 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
107515 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
107516 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
107517 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
107518 + return false;
107519 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
107520 + return false;
107521 +
107522 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
107523 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
107524 + return true;
107525 +}
107526 +
107527 +static tree handle_integer_truncation(struct pointer_set_t *visited, const_tree lhs)
107528 +{
107529 + tree new_rhs1, new_rhs2;
107530 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
107531 + gimple assign, stmt = get_def_stmt(lhs);
107532 + tree rhs1 = gimple_assign_rhs1(stmt);
107533 + tree rhs2 = gimple_assign_rhs2(stmt);
107534 +
107535 + if (!is_subtraction_special(stmt))
107536 + return NULL_TREE;
107537 +
107538 + new_rhs1 = expand(visited, rhs1);
107539 + new_rhs2 = expand(visited, rhs2);
107540 +
107541 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
107542 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
107543 +
107544 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
107545 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
107546 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
107547 + }
107548 +
107549 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
107550 + new_lhs = gimple_get_lhs(assign);
107551 + check_size_overflow(assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
107552 +
107553 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
107554 +}
107555 +
107556 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
107557 +{
107558 + const_gimple def_stmt;
107559 +
107560 + if (TREE_CODE(rhs) != SSA_NAME)
107561 + return false;
107562 +
107563 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
107564 + return false;
107565 +
107566 + def_stmt = get_def_stmt(rhs);
107567 + if (gimple_code(def_stmt) != GIMPLE_ASSIGN || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
107568 + return false;
107569 +
107570 + return true;
107571 +}
107572 +
107573 +static tree handle_binary_ops(struct pointer_set_t *visited, tree lhs)
107574 +{
107575 + tree rhs1, rhs2, new_lhs;
107576 + gimple def_stmt = get_def_stmt(lhs);
107577 + tree new_rhs1 = NULL_TREE;
107578 + tree new_rhs2 = NULL_TREE;
107579 +
107580 + rhs1 = gimple_assign_rhs1(def_stmt);
107581 + rhs2 = gimple_assign_rhs2(def_stmt);
107582 +
107583 + /* no DImode/TImode division in the 32/64 bit kernel */
107584 + switch (gimple_assign_rhs_code(def_stmt)) {
107585 + case RDIV_EXPR:
107586 + case TRUNC_DIV_EXPR:
107587 + case CEIL_DIV_EXPR:
107588 + case FLOOR_DIV_EXPR:
107589 + case ROUND_DIV_EXPR:
107590 + case TRUNC_MOD_EXPR:
107591 + case CEIL_MOD_EXPR:
107592 + case FLOOR_MOD_EXPR:
107593 + case ROUND_MOD_EXPR:
107594 + case EXACT_DIV_EXPR:
107595 + case POINTER_PLUS_EXPR:
107596 + case BIT_AND_EXPR:
107597 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
107598 + default:
107599 + break;
107600 + }
107601 +
107602 + new_lhs = handle_integer_truncation(visited, lhs);
107603 + if (new_lhs != NULL_TREE)
107604 + return new_lhs;
107605 +
107606 + if (TREE_CODE(rhs1) == SSA_NAME)
107607 + new_rhs1 = expand(visited, rhs1);
107608 + if (TREE_CODE(rhs2) == SSA_NAME)
107609 + new_rhs2 = expand(visited, rhs2);
107610 +
107611 + if (is_a_neg_overflow(def_stmt, rhs2))
107612 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs1, NULL_TREE);
107613 + if (is_a_neg_overflow(def_stmt, rhs1))
107614 + return handle_intentional_overflow(visited, true, def_stmt, new_rhs2, new_rhs2);
107615 +
107616 +
107617 + if (is_a_constant_overflow(def_stmt, rhs2))
107618 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
107619 + if (is_a_constant_overflow(def_stmt, rhs1))
107620 + return handle_intentional_overflow(visited, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
107621 +
107622 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
107623 +}
107624 +
107625 +#if BUILDING_GCC_VERSION >= 4007
107626 +static tree get_new_rhs(struct pointer_set_t *visited, tree size_overflow_type, tree rhs)
107627 +{
107628 + if (is_gimple_constant(rhs))
107629 + return cast_a_tree(size_overflow_type, rhs);
107630 + if (TREE_CODE(rhs) != SSA_NAME)
107631 + return NULL_TREE;
107632 + return expand(visited, rhs);
107633 +}
107634 +
107635 +static tree handle_ternary_ops(struct pointer_set_t *visited, tree lhs)
107636 +{
107637 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
107638 + gimple def_stmt = get_def_stmt(lhs);
107639 +
107640 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
107641 +
107642 + rhs1 = gimple_assign_rhs1(def_stmt);
107643 + rhs2 = gimple_assign_rhs2(def_stmt);
107644 + rhs3 = gimple_assign_rhs3(def_stmt);
107645 + new_rhs1 = get_new_rhs(visited, size_overflow_type, rhs1);
107646 + new_rhs2 = get_new_rhs(visited, size_overflow_type, rhs2);
107647 + new_rhs3 = get_new_rhs(visited, size_overflow_type, rhs3);
107648 +
107649 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
107650 +}
107651 +#endif
107652 +
107653 +static tree get_size_overflow_type(gimple stmt, const_tree node)
107654 +{
107655 + const_tree type;
107656 + tree new_type;
107657 +
107658 + gcc_assert(node != NULL_TREE);
107659 +
107660 + type = TREE_TYPE(node);
107661 +
107662 + if (gimple_plf(stmt, MY_STMT))
107663 + return TREE_TYPE(node);
107664 +
107665 + switch (TYPE_MODE(type)) {
107666 + case QImode:
107667 + new_type = intHI_type_node;
107668 + break;
107669 + case HImode:
107670 + new_type = intSI_type_node;
107671 + break;
107672 + case SImode:
107673 + new_type = intDI_type_node;
107674 + break;
107675 + case DImode:
107676 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
107677 + new_type = intDI_type_node;
107678 + else
107679 + new_type = intTI_type_node;
107680 + break;
107681 + default:
107682 + debug_tree((tree)node);
107683 + error("%s: unsupported gcc configuration.", __func__);
107684 + gcc_unreachable();
107685 + }
107686 +
107687 + if (TYPE_QUALS(type) != 0)
107688 + return build_qualified_type(new_type, TYPE_QUALS(type));
107689 + return new_type;
107690 +}
107691 +
107692 +static tree expand_visited(gimple def_stmt)
107693 +{
107694 + const_gimple next_stmt;
107695 + gimple_stmt_iterator gsi;
107696 + enum gimple_code code = gimple_code(def_stmt);
107697 +
107698 + if (code == GIMPLE_ASM)
107699 + return NULL_TREE;
107700 +
107701 + gsi = gsi_for_stmt(def_stmt);
107702 + gsi_next(&gsi);
107703 +
107704 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
107705 + return NULL_TREE;
107706 + gcc_assert(!gsi_end_p(gsi));
107707 + next_stmt = gsi_stmt(gsi);
107708 +
107709 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
107710 + return NULL_TREE;
107711 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
107712 +
107713 + return get_lhs(next_stmt);
107714 +}
107715 +
107716 +static tree expand(struct pointer_set_t *visited, tree lhs)
107717 +{
107718 + gimple def_stmt;
107719 +
107720 + if (skip_types(lhs))
107721 + return NULL_TREE;
107722 +
107723 + def_stmt = get_def_stmt(lhs);
107724 +
107725 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
107726 + return NULL_TREE;
107727 +
107728 + if (gimple_plf(def_stmt, MY_STMT))
107729 + return lhs;
107730 +
107731 + if (pointer_set_contains(visited, def_stmt))
107732 + return expand_visited(def_stmt);
107733 +
107734 + switch (gimple_code(def_stmt)) {
107735 + case GIMPLE_PHI:
107736 + return handle_phi(visited, lhs);
107737 + case GIMPLE_CALL:
107738 + case GIMPLE_ASM:
107739 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
107740 + case GIMPLE_ASSIGN:
107741 + switch (gimple_num_ops(def_stmt)) {
107742 + case 2:
107743 + return handle_unary_ops(visited, def_stmt);
107744 + case 3:
107745 + return handle_binary_ops(visited, lhs);
107746 +#if BUILDING_GCC_VERSION >= 4007
107747 + case 4:
107748 + return handle_ternary_ops(visited, lhs);
107749 +#endif
107750 + }
107751 + default:
107752 + debug_gimple_stmt(def_stmt);
107753 + error("%s: unknown gimple code", __func__);
107754 + gcc_unreachable();
107755 + }
107756 +}
107757 +
107758 +static tree get_new_tree(gimple stmt, const_tree orig_node, tree new_node)
107759 +{
107760 + const_gimple assign;
107761 + tree orig_type = TREE_TYPE(orig_node);
107762 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
107763 +
107764 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
107765 + return gimple_get_lhs(assign);
107766 +}
107767 +
107768 +static void change_function_arg(gimple stmt, const_tree orig_arg, unsigned int argnum, tree new_arg)
107769 +{
107770 + gimple_call_set_arg(stmt, argnum, get_new_tree(stmt, orig_arg, new_arg));
107771 + update_stmt(stmt);
107772 +}
107773 +
107774 +static void change_function_return(gimple stmt, const_tree orig_ret, tree new_ret)
107775 +{
107776 + gimple_return_set_retval(stmt, get_new_tree(stmt, orig_ret, new_ret));
107777 + update_stmt(stmt);
107778 +}
107779 +
107780 +static bool get_function_arg(unsigned int* argnum, const_tree fndecl)
107781 +{
107782 + tree arg;
107783 + const_tree origarg;
107784 +
107785 + if (!DECL_ABSTRACT_ORIGIN(fndecl))
107786 + return true;
107787 +
107788 + origarg = DECL_ARGUMENTS(DECL_ABSTRACT_ORIGIN(fndecl));
107789 + while (origarg && *argnum) {
107790 + (*argnum)--;
107791 + origarg = TREE_CHAIN(origarg);
107792 + }
107793 +
107794 + gcc_assert(*argnum == 0);
107795 +
107796 + gcc_assert(origarg != NULL_TREE);
107797 + *argnum = 0;
107798 + for (arg = DECL_ARGUMENTS(fndecl); arg; arg = TREE_CHAIN(arg), (*argnum)++)
107799 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
107800 + return true;
107801 + return false;
107802 +}
107803 +
107804 +static enum mark walk_phi(struct pointer_set_t *visited, bool *search_err_code, const_tree result)
107805 +{
107806 + gimple phi = get_def_stmt(result);
107807 + unsigned int i, n = gimple_phi_num_args(phi);
107808 +
107809 + if (!phi)
107810 + return MARK_NO;
107811 +
107812 + pointer_set_insert(visited, phi);
107813 + for (i = 0; i < n; i++) {
107814 + enum mark marked;
107815 + const_tree arg = gimple_phi_arg_def(phi, i);
107816 + marked = pre_expand(visited, search_err_code, arg);
107817 + if (marked != MARK_NO)
107818 + return marked;
107819 + }
107820 + return MARK_NO;
107821 +}
107822 +
107823 +static enum mark walk_unary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
107824 +{
107825 + gimple def_stmt = get_def_stmt(lhs);
107826 + const_tree rhs;
107827 +
107828 + if (!def_stmt)
107829 + return MARK_NO;
107830 +
107831 + rhs = gimple_assign_rhs1(def_stmt);
107832 +
107833 + def_stmt = get_def_stmt(rhs);
107834 + if (is_gimple_constant(rhs))
107835 + search_err_code[FROM_CONST] = true;
107836 +
107837 + return pre_expand(visited, search_err_code, rhs);
107838 +}
107839 +
107840 +static enum mark walk_binary_ops(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
107841 +{
107842 + gimple def_stmt = get_def_stmt(lhs);
107843 + const_tree rhs1, rhs2;
107844 + enum mark marked;
107845 +
107846 + if (!def_stmt)
107847 + return MARK_NO;
107848 +
107849 + search_err_code[CAST_ONLY] = false;
107850 +
107851 + rhs1 = gimple_assign_rhs1(def_stmt);
107852 + rhs2 = gimple_assign_rhs2(def_stmt);
107853 + marked = pre_expand(visited, search_err_code, rhs1);
107854 + if (marked != MARK_NO)
107855 + return marked;
107856 + return pre_expand(visited, search_err_code, rhs2);
107857 +}
107858 +
107859 +static const_tree search_field_decl(const_tree comp_ref)
107860 +{
107861 + const_tree field = NULL_TREE;
107862 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
107863 +
107864 + for (i = 0; i < len; i++) {
107865 + field = TREE_OPERAND(comp_ref, i);
107866 + if (TREE_CODE(field) == FIELD_DECL)
107867 + break;
107868 + }
107869 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
107870 + return field;
107871 +}
107872 +
107873 +static enum mark mark_status(const_tree fndecl, unsigned int argnum)
107874 +{
107875 + const_tree attr, p;
107876 +
107877 + // 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);
107878 + if (fndecl == NULL_TREE)
107879 + return MARK_NO;
107880 +
107881 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(fndecl));
107882 + if (!attr || !TREE_VALUE(attr))
107883 + return MARK_NO;
107884 +
107885 + p = TREE_VALUE(attr);
107886 + if (TREE_INT_CST_HIGH(TREE_VALUE(p)) == -1)
107887 + return MARK_TURN_OFF;
107888 + if (!TREE_INT_CST_LOW(TREE_VALUE(p)))
107889 + return MARK_NOT_INTENTIONAL;
107890 + if (argnum == 0) {
107891 + gcc_assert(current_function_decl == fndecl);
107892 + return MARK_NO;
107893 + }
107894 +
107895 + do {
107896 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(p)))
107897 + return MARK_YES;
107898 + p = TREE_CHAIN(p);
107899 + } while (p);
107900 +
107901 + return MARK_NO;
107902 +}
107903 +
107904 +static void print_missing_msg(tree func, unsigned int argnum)
107905 +{
107906 + unsigned int new_hash;
107907 + size_t len;
107908 + unsigned char tree_codes[CODES_LIMIT];
107909 + location_t loc;
107910 + const char *curfunc;
107911 +
107912 + func = get_original_function_decl(func);
107913 + loc = DECL_SOURCE_LOCATION(func);
107914 + curfunc = get_asm_name(func);
107915 +
107916 + len = get_function_decl(func, tree_codes);
107917 + new_hash = get_hash_num(curfunc, (const char *) tree_codes, len, 0);
107918 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, new_hash);
107919 +}
107920 +
107921 +static unsigned int search_missing_attribute(const_tree arg)
107922 +{
107923 + unsigned int argnum;
107924 + const struct size_overflow_hash *hash;
107925 + const_tree type = TREE_TYPE(arg);
107926 + tree func = get_original_function_decl(current_function_decl);
107927 +
107928 + gcc_assert(TREE_CODE(arg) != COMPONENT_REF);
107929 +
107930 + if (TREE_CODE(type) == POINTER_TYPE)
107931 + return 0;
107932 +
107933 + argnum = find_arg_number(arg, func);
107934 + if (argnum == 0)
107935 + return 0;
107936 +
107937 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(func)))
107938 + return argnum;
107939 +
107940 + hash = get_function_hash(func);
107941 + if (!hash || !(hash->param & (1U << argnum))) {
107942 + print_missing_msg(func, argnum);
107943 + return 0;
107944 + }
107945 + return argnum;
107946 +}
107947 +
107948 +static enum mark is_already_marked(const_tree lhs)
107949 +{
107950 + unsigned int argnum;
107951 + const_tree fndecl;
107952 +
107953 + argnum = search_missing_attribute(lhs);
107954 + fndecl = get_original_function_decl(current_function_decl);
107955 + if (argnum && mark_status(fndecl, argnum) == MARK_YES)
107956 + return MARK_YES;
107957 + return MARK_NO;
107958 +}
107959 +
107960 +static enum mark pre_expand(struct pointer_set_t *visited, bool *search_err_code, const_tree lhs)
107961 +{
107962 + const_gimple def_stmt;
107963 +
107964 + if (skip_types(lhs))
107965 + return MARK_NO;
107966 +
107967 + if (TREE_CODE(lhs) == PARM_DECL)
107968 + return is_already_marked(lhs);
107969 +
107970 + if (TREE_CODE(lhs) == COMPONENT_REF) {
107971 + const_tree field, attr;
107972 +
107973 + field = search_field_decl(lhs);
107974 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(field));
107975 + if (!attr || !TREE_VALUE(attr))
107976 + return MARK_NO;
107977 + return MARK_YES;
107978 + }
107979 +
107980 + def_stmt = get_def_stmt(lhs);
107981 +
107982 + if (!def_stmt)
107983 + return MARK_NO;
107984 +
107985 + if (pointer_set_contains(visited, def_stmt))
107986 + return MARK_NO;
107987 +
107988 + switch (gimple_code(def_stmt)) {
107989 + case GIMPLE_NOP:
107990 + if (TREE_CODE(SSA_NAME_VAR(lhs)) == PARM_DECL)
107991 + return is_already_marked(lhs);
107992 + return MARK_NO;
107993 + case GIMPLE_PHI:
107994 + return walk_phi(visited, search_err_code, lhs);
107995 + case GIMPLE_CALL:
107996 + if (mark_status((gimple_call_fndecl(def_stmt)), 0) == MARK_TURN_OFF)
107997 + return MARK_TURN_OFF;
107998 + check_function_hash(def_stmt);
107999 + return MARK_NO;
108000 + case GIMPLE_ASM:
108001 + search_err_code[CAST_ONLY] = false;
108002 + return MARK_NO;
108003 + case GIMPLE_ASSIGN:
108004 + switch (gimple_num_ops(def_stmt)) {
108005 + case 2:
108006 + return walk_unary_ops(visited, search_err_code, lhs);
108007 + case 3:
108008 + return walk_binary_ops(visited, search_err_code, lhs);
108009 + }
108010 + default:
108011 + debug_gimple_stmt((gimple)def_stmt);
108012 + error("%s: unknown gimple code", __func__);
108013 + gcc_unreachable();
108014 + }
108015 +}
108016 +
108017 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
108018 +static bool skip_asm(const_tree arg)
108019 +{
108020 + gimple def_stmt = get_def_stmt(arg);
108021 +
108022 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
108023 + return false;
108024 +
108025 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
108026 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
108027 +}
108028 +
108029 +/*
108030 +0</MARK_YES: no dup, search attributes (so, int)
108031 +0/MARK_NOT_INTENTIONAL: no dup, search attribute (int)
108032 +-1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
108033 +*/
108034 +
108035 +static bool search_attributes(tree fndecl, const_tree arg, unsigned int argnum, bool where)
108036 +{
108037 + struct pointer_set_t *visited;
108038 + enum mark is_marked, is_found;
108039 + location_t loc;
108040 + bool search_err_code[2] = {true, false};
108041 +
108042 + is_marked = mark_status(current_function_decl, 0);
108043 + if (is_marked == MARK_TURN_OFF)
108044 + return true;
108045 +
108046 + is_marked = mark_status(fndecl, argnum + 1);
108047 + if (is_marked == MARK_TURN_OFF || is_marked == MARK_NOT_INTENTIONAL)
108048 + return true;
108049 +
108050 + visited = pointer_set_create();
108051 + is_found = pre_expand(visited, search_err_code, arg);
108052 + pointer_set_destroy(visited);
108053 +
108054 + if (where == FROM_RET && search_err_code[CAST_ONLY] && search_err_code[FROM_CONST])
108055 + return true;
108056 +
108057 + if (where == FROM_ARG && skip_asm(arg))
108058 + return true;
108059 +
108060 + if (is_found == MARK_TURN_OFF)
108061 + return true;
108062 +
108063 + if ((is_found == MARK_YES && is_marked == MARK_YES))
108064 + return true;
108065 +
108066 + if (is_found == MARK_YES) {
108067 + loc = DECL_SOURCE_LOCATION(fndecl);
108068 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", get_asm_name(fndecl), argnum + 1);
108069 + return true;
108070 + }
108071 + return false;
108072 +}
108073 +
108074 +static void handle_function_arg(gimple stmt, tree fndecl, unsigned int argnum)
108075 +{
108076 + struct pointer_set_t *visited;
108077 + tree arg, new_arg;
108078 + bool match;
108079 +
108080 + if (argnum == 0)
108081 + return;
108082 +
108083 + argnum--;
108084 +
108085 + match = get_function_arg(&argnum, fndecl);
108086 + if (!match)
108087 + return;
108088 + gcc_assert(gimple_call_num_args(stmt) > argnum);
108089 + arg = gimple_call_arg(stmt, argnum);
108090 + if (arg == NULL_TREE)
108091 + return;
108092 +
108093 + if (skip_types(arg))
108094 + return;
108095 +
108096 + if (search_attributes(fndecl, arg, argnum, FROM_ARG))
108097 + return;
108098 +
108099 + visited = pointer_set_create();
108100 + new_arg = expand(visited, arg);
108101 + pointer_set_destroy(visited);
108102 +
108103 + if (new_arg == NULL_TREE)
108104 + return;
108105 +
108106 + change_function_arg(stmt, arg, argnum, new_arg);
108107 + check_size_overflow(stmt, TREE_TYPE(new_arg), new_arg, arg, BEFORE_STMT);
108108 +}
108109 +
108110 +static void handle_function_by_attribute(gimple stmt, const_tree attr, tree fndecl)
108111 +{
108112 + tree p = TREE_VALUE(attr);
108113 + do {
108114 + handle_function_arg(stmt, fndecl, TREE_INT_CST_LOW(TREE_VALUE(p)));
108115 + p = TREE_CHAIN(p);
108116 + } while (p);
108117 +}
108118 +
108119 +static void handle_function_by_hash(gimple stmt, tree fndecl)
108120 +{
108121 + unsigned int num;
108122 + const struct size_overflow_hash *hash;
108123 +
108124 + hash = get_function_hash(fndecl);
108125 + if (!hash)
108126 + return;
108127 +
108128 + for (num = 0; num <= MAX_PARAM; num++)
108129 + if (hash->param & (1U << num))
108130 + handle_function_arg(stmt, fndecl, num);
108131 +}
108132 +
108133 +static bool check_return_value(void)
108134 +{
108135 + const struct size_overflow_hash *hash;
108136 +
108137 + hash = get_function_hash(current_function_decl);
108138 + if (!hash || !(hash->param & 1U << 0))
108139 + return false;
108140 +
108141 + return true;
108142 +}
108143 +
108144 +static void handle_return_value(gimple ret_stmt)
108145 +{
108146 + struct pointer_set_t *visited;
108147 + tree ret, new_ret;
108148 +
108149 + if (gimple_code(ret_stmt) != GIMPLE_RETURN)
108150 + return;
108151 +
108152 + ret = gimple_return_retval(ret_stmt);
108153 +
108154 + if (skip_types(ret))
108155 + return;
108156 +
108157 + if (search_attributes(current_function_decl, ret, 0, FROM_RET))
108158 + return;
108159 +
108160 + visited = pointer_set_create();
108161 + new_ret = expand(visited, ret);
108162 + pointer_set_destroy(visited);
108163 +
108164 + change_function_return(ret_stmt, ret, new_ret);
108165 + check_size_overflow(ret_stmt, TREE_TYPE(new_ret), new_ret, ret, BEFORE_STMT);
108166 +}
108167 +
108168 +static void set_plf_false(void)
108169 +{
108170 + basic_block bb;
108171 +
108172 + FOR_ALL_BB(bb) {
108173 + gimple_stmt_iterator si;
108174 +
108175 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
108176 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
108177 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
108178 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
108179 + }
108180 +}
108181 +
108182 +static unsigned int handle_function(void)
108183 +{
108184 + basic_block next, bb = ENTRY_BLOCK_PTR->next_bb;
108185 + bool check_ret;
108186 +
108187 + set_plf_false();
108188 +
108189 + check_ret = check_return_value();
108190 +
108191 + do {
108192 + gimple_stmt_iterator gsi;
108193 + next = bb->next_bb;
108194 +
108195 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
108196 + tree fndecl, attr;
108197 + gimple stmt = gsi_stmt(gsi);
108198 +
108199 + if (check_ret)
108200 + handle_return_value(stmt);
108201 +
108202 + if (!(is_gimple_call(stmt)))
108203 + continue;
108204 + fndecl = gimple_call_fndecl(stmt);
108205 + if (fndecl == NULL_TREE)
108206 + continue;
108207 + if (gimple_call_num_args(stmt) == 0)
108208 + continue;
108209 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
108210 + if (!attr || !TREE_VALUE(attr))
108211 + handle_function_by_hash(stmt, fndecl);
108212 + else
108213 + handle_function_by_attribute(stmt, attr, fndecl);
108214 + gsi = gsi_for_stmt(stmt);
108215 + next = gimple_bb(stmt)->next_bb;
108216 + }
108217 + bb = next;
108218 + } while (bb);
108219 + return 0;
108220 +}
108221 +
108222 +static struct gimple_opt_pass size_overflow_pass = {
108223 + .pass = {
108224 + .type = GIMPLE_PASS,
108225 + .name = "size_overflow",
108226 +#if BUILDING_GCC_VERSION >= 4008
108227 + .optinfo_flags = OPTGROUP_NONE,
108228 +#endif
108229 + .gate = NULL,
108230 + .execute = handle_function,
108231 + .sub = NULL,
108232 + .next = NULL,
108233 + .static_pass_number = 0,
108234 + .tv_id = TV_NONE,
108235 + .properties_required = PROP_cfg,
108236 + .properties_provided = 0,
108237 + .properties_destroyed = 0,
108238 + .todo_flags_start = 0,
108239 + .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
108240 + }
108241 +};
108242 +
108243 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
108244 +{
108245 + tree fntype;
108246 +
108247 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
108248 +
108249 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
108250 + fntype = build_function_type_list(void_type_node,
108251 + const_char_ptr_type_node,
108252 + unsigned_type_node,
108253 + const_char_ptr_type_node,
108254 + const_char_ptr_type_node,
108255 + NULL_TREE);
108256 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
108257 +
108258 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
108259 + TREE_PUBLIC(report_size_overflow_decl) = 1;
108260 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
108261 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
108262 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
108263 +}
108264 +
108265 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
108266 +{
108267 + int i;
108268 + const char * const plugin_name = plugin_info->base_name;
108269 + const int argc = plugin_info->argc;
108270 + const struct plugin_argument * const argv = plugin_info->argv;
108271 + bool enable = true;
108272 +
108273 + struct register_pass_info size_overflow_pass_info = {
108274 + .pass = &size_overflow_pass.pass,
108275 + .reference_pass_name = "ssa",
108276 + .ref_pass_instance_number = 1,
108277 + .pos_op = PASS_POS_INSERT_AFTER
108278 + };
108279 +
108280 + if (!plugin_default_version_check(version, &gcc_version)) {
108281 + error(G_("incompatible gcc/plugin versions"));
108282 + return 1;
108283 + }
108284 +
108285 + for (i = 0; i < argc; ++i) {
108286 + if (!strcmp(argv[i].key, "no-size-overflow")) {
108287 + enable = false;
108288 + continue;
108289 + }
108290 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
108291 + }
108292 +
108293 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
108294 + if (enable) {
108295 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
108296 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &size_overflow_pass_info);
108297 + }
108298 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
108299 +
108300 + return 0;
108301 +}
108302 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
108303 new file mode 100644
108304 index 0000000..ac2901e
108305 --- /dev/null
108306 +++ b/tools/gcc/stackleak_plugin.c
108307 @@ -0,0 +1,327 @@
108308 +/*
108309 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
108310 + * Licensed under the GPL v2
108311 + *
108312 + * Note: the choice of the license means that the compilation process is
108313 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
108314 + * but for the kernel it doesn't matter since it doesn't link against
108315 + * any of the gcc libraries
108316 + *
108317 + * gcc plugin to help implement various PaX features
108318 + *
108319 + * - track lowest stack pointer
108320 + *
108321 + * TODO:
108322 + * - initialize all local variables
108323 + *
108324 + * BUGS:
108325 + * - none known
108326 + */
108327 +#include "gcc-plugin.h"
108328 +#include "config.h"
108329 +#include "system.h"
108330 +#include "coretypes.h"
108331 +#include "tree.h"
108332 +#include "tree-pass.h"
108333 +#include "flags.h"
108334 +#include "intl.h"
108335 +#include "toplev.h"
108336 +#include "plugin.h"
108337 +//#include "expr.h" where are you...
108338 +#include "diagnostic.h"
108339 +#include "plugin-version.h"
108340 +#include "tm.h"
108341 +#include "function.h"
108342 +#include "basic-block.h"
108343 +#include "gimple.h"
108344 +#include "rtl.h"
108345 +#include "emit-rtl.h"
108346 +
108347 +#if BUILDING_GCC_VERSION >= 4008
108348 +#define TODO_dump_func 0
108349 +#endif
108350 +
108351 +extern void print_gimple_stmt(FILE *, gimple, int, int);
108352 +
108353 +int plugin_is_GPL_compatible;
108354 +
108355 +static int track_frame_size = -1;
108356 +static const char track_function[] = "pax_track_stack";
108357 +static const char check_function[] = "pax_check_alloca";
108358 +static bool init_locals;
108359 +
108360 +static struct plugin_info stackleak_plugin_info = {
108361 + .version = "201302112000",
108362 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
108363 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
108364 +};
108365 +
108366 +static bool gate_stackleak_track_stack(void);
108367 +static unsigned int execute_stackleak_tree_instrument(void);
108368 +static unsigned int execute_stackleak_final(void);
108369 +
108370 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
108371 + .pass = {
108372 + .type = GIMPLE_PASS,
108373 + .name = "stackleak_tree_instrument",
108374 +#if BUILDING_GCC_VERSION >= 4008
108375 + .optinfo_flags = OPTGROUP_NONE,
108376 +#endif
108377 + .gate = gate_stackleak_track_stack,
108378 + .execute = execute_stackleak_tree_instrument,
108379 + .sub = NULL,
108380 + .next = NULL,
108381 + .static_pass_number = 0,
108382 + .tv_id = TV_NONE,
108383 + .properties_required = PROP_gimple_leh | PROP_cfg,
108384 + .properties_provided = 0,
108385 + .properties_destroyed = 0,
108386 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
108387 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
108388 + }
108389 +};
108390 +
108391 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
108392 + .pass = {
108393 + .type = RTL_PASS,
108394 + .name = "stackleak_final",
108395 +#if BUILDING_GCC_VERSION >= 4008
108396 + .optinfo_flags = OPTGROUP_NONE,
108397 +#endif
108398 + .gate = gate_stackleak_track_stack,
108399 + .execute = execute_stackleak_final,
108400 + .sub = NULL,
108401 + .next = NULL,
108402 + .static_pass_number = 0,
108403 + .tv_id = TV_NONE,
108404 + .properties_required = 0,
108405 + .properties_provided = 0,
108406 + .properties_destroyed = 0,
108407 + .todo_flags_start = 0,
108408 + .todo_flags_finish = TODO_dump_func
108409 + }
108410 +};
108411 +
108412 +static bool gate_stackleak_track_stack(void)
108413 +{
108414 + return track_frame_size >= 0;
108415 +}
108416 +
108417 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
108418 +{
108419 + gimple check_alloca;
108420 + tree fntype, fndecl, alloca_size;
108421 +
108422 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
108423 + fndecl = build_fn_decl(check_function, fntype);
108424 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
108425 +
108426 + // insert call to void pax_check_alloca(unsigned long size)
108427 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
108428 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
108429 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
108430 +}
108431 +
108432 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
108433 +{
108434 + gimple track_stack;
108435 + tree fntype, fndecl;
108436 +
108437 + fntype = build_function_type_list(void_type_node, NULL_TREE);
108438 + fndecl = build_fn_decl(track_function, fntype);
108439 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
108440 +
108441 + // insert call to void pax_track_stack(void)
108442 + track_stack = gimple_build_call(fndecl, 0);
108443 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
108444 +}
108445 +
108446 +#if BUILDING_GCC_VERSION == 4005
108447 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
108448 +{
108449 + tree fndecl;
108450 +
108451 + if (!is_gimple_call(stmt))
108452 + return false;
108453 + fndecl = gimple_call_fndecl(stmt);
108454 + if (!fndecl)
108455 + return false;
108456 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
108457 + return false;
108458 +// print_node(stderr, "pax", fndecl, 4);
108459 + return DECL_FUNCTION_CODE(fndecl) == code;
108460 +}
108461 +#endif
108462 +
108463 +static bool is_alloca(gimple stmt)
108464 +{
108465 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
108466 + return true;
108467 +
108468 +#if BUILDING_GCC_VERSION >= 4007
108469 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
108470 + return true;
108471 +#endif
108472 +
108473 + return false;
108474 +}
108475 +
108476 +static unsigned int execute_stackleak_tree_instrument(void)
108477 +{
108478 + basic_block bb, entry_bb;
108479 + bool prologue_instrumented = false, is_leaf = true;
108480 +
108481 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
108482 +
108483 + // 1. loop through BBs and GIMPLE statements
108484 + FOR_EACH_BB(bb) {
108485 + gimple_stmt_iterator gsi;
108486 +
108487 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
108488 + gimple stmt;
108489 +
108490 + stmt = gsi_stmt(gsi);
108491 +
108492 + if (is_gimple_call(stmt))
108493 + is_leaf = false;
108494 +
108495 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
108496 + if (!is_alloca(stmt))
108497 + continue;
108498 +
108499 + // 2. insert stack overflow check before each __builtin_alloca call
108500 + stackleak_check_alloca(&gsi);
108501 +
108502 + // 3. insert track call after each __builtin_alloca call
108503 + stackleak_add_instrumentation(&gsi);
108504 + if (bb == entry_bb)
108505 + prologue_instrumented = true;
108506 + }
108507 + }
108508 +
108509 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
108510 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
108511 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
108512 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
108513 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
108514 + return 0;
108515 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
108516 + return 0;
108517 +
108518 + // 4. insert track call at the beginning
108519 + if (!prologue_instrumented) {
108520 + gimple_stmt_iterator gsi;
108521 +
108522 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
108523 + if (dom_info_available_p(CDI_DOMINATORS))
108524 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
108525 + gsi = gsi_start_bb(bb);
108526 + stackleak_add_instrumentation(&gsi);
108527 + }
108528 +
108529 + return 0;
108530 +}
108531 +
108532 +static unsigned int execute_stackleak_final(void)
108533 +{
108534 + rtx insn, next;
108535 +
108536 + if (cfun->calls_alloca)
108537 + return 0;
108538 +
108539 + // keep calls only if function frame is big enough
108540 + if (get_frame_size() >= track_frame_size)
108541 + return 0;
108542 +
108543 + // 1. find pax_track_stack calls
108544 + for (insn = get_insns(); insn; insn = next) {
108545 + // 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))
108546 + rtx body;
108547 +
108548 + next = NEXT_INSN(insn);
108549 + if (!CALL_P(insn))
108550 + continue;
108551 + body = PATTERN(insn);
108552 + if (GET_CODE(body) != CALL)
108553 + continue;
108554 + body = XEXP(body, 0);
108555 + if (GET_CODE(body) != MEM)
108556 + continue;
108557 + body = XEXP(body, 0);
108558 + if (GET_CODE(body) != SYMBOL_REF)
108559 + continue;
108560 + if (strcmp(XSTR(body, 0), track_function))
108561 + continue;
108562 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
108563 + // 2. delete call
108564 + delete_insn_and_edges(insn);
108565 +#if BUILDING_GCC_VERSION >= 4007
108566 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
108567 + insn = next;
108568 + next = NEXT_INSN(insn);
108569 + delete_insn_and_edges(insn);
108570 + }
108571 +#endif
108572 + }
108573 +
108574 +// print_simple_rtl(stderr, get_insns());
108575 +// print_rtl(stderr, get_insns());
108576 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
108577 +
108578 + return 0;
108579 +}
108580 +
108581 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
108582 +{
108583 + const char * const plugin_name = plugin_info->base_name;
108584 + const int argc = plugin_info->argc;
108585 + const struct plugin_argument * const argv = plugin_info->argv;
108586 + int i;
108587 + struct register_pass_info stackleak_tree_instrument_pass_info = {
108588 + .pass = &stackleak_tree_instrument_pass.pass,
108589 +// .reference_pass_name = "tree_profile",
108590 + .reference_pass_name = "optimized",
108591 + .ref_pass_instance_number = 1,
108592 + .pos_op = PASS_POS_INSERT_BEFORE
108593 + };
108594 + struct register_pass_info stackleak_final_pass_info = {
108595 + .pass = &stackleak_final_rtl_opt_pass.pass,
108596 + .reference_pass_name = "final",
108597 + .ref_pass_instance_number = 1,
108598 + .pos_op = PASS_POS_INSERT_BEFORE
108599 + };
108600 +
108601 + if (!plugin_default_version_check(version, &gcc_version)) {
108602 + error(G_("incompatible gcc/plugin versions"));
108603 + return 1;
108604 + }
108605 +
108606 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
108607 +
108608 + for (i = 0; i < argc; ++i) {
108609 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
108610 + if (!argv[i].value) {
108611 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
108612 + continue;
108613 + }
108614 + track_frame_size = atoi(argv[i].value);
108615 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
108616 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
108617 + continue;
108618 + }
108619 + if (!strcmp(argv[i].key, "initialize-locals")) {
108620 + if (argv[i].value) {
108621 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
108622 + continue;
108623 + }
108624 + init_locals = true;
108625 + continue;
108626 + }
108627 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
108628 + }
108629 +
108630 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
108631 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
108632 +
108633 + return 0;
108634 +}
108635 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
108636 new file mode 100644
108637 index 0000000..4fae911
108638 --- /dev/null
108639 +++ b/tools/gcc/structleak_plugin.c
108640 @@ -0,0 +1,277 @@
108641 +/*
108642 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
108643 + * Licensed under the GPL v2
108644 + *
108645 + * Note: the choice of the license means that the compilation process is
108646 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
108647 + * but for the kernel it doesn't matter since it doesn't link against
108648 + * any of the gcc libraries
108649 + *
108650 + * gcc plugin to forcibly initialize certain local variables that could
108651 + * otherwise leak kernel stack to userland if they aren't properly initialized
108652 + * by later code
108653 + *
108654 + * Homepage: http://pax.grsecurity.net/
108655 + *
108656 + * Usage:
108657 + * $ # for 4.5/4.6/C based 4.7
108658 + * $ 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
108659 + * $ # for C++ based 4.7/4.8+
108660 + * $ 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
108661 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
108662 + *
108663 + * TODO: eliminate redundant initializers
108664 + * increase type coverage
108665 + */
108666 +
108667 +#include "gcc-plugin.h"
108668 +#include "config.h"
108669 +#include "system.h"
108670 +#include "coretypes.h"
108671 +#include "tree.h"
108672 +#include "tree-pass.h"
108673 +#include "intl.h"
108674 +#include "plugin-version.h"
108675 +#include "tm.h"
108676 +#include "toplev.h"
108677 +#include "function.h"
108678 +#include "tree-flow.h"
108679 +#include "plugin.h"
108680 +#include "gimple.h"
108681 +#include "diagnostic.h"
108682 +#include "cfgloop.h"
108683 +#include "langhooks.h"
108684 +
108685 +#if BUILDING_GCC_VERSION >= 4008
108686 +#define TODO_dump_func 0
108687 +#endif
108688 +
108689 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
108690 +
108691 +// unused type flag in all versions 4.5-4.8
108692 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
108693 +
108694 +int plugin_is_GPL_compatible;
108695 +void debug_gimple_stmt(gimple gs);
108696 +
108697 +static struct plugin_info structleak_plugin_info = {
108698 + .version = "201304082245",
108699 + .help = "disable\tdo not activate plugin\n",
108700 +};
108701 +
108702 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
108703 +{
108704 + *no_add_attrs = true;
108705 +
108706 + // check for types? for now accept everything linux has to offer
108707 + if (TREE_CODE(*node) != FIELD_DECL)
108708 + return NULL_TREE;
108709 +
108710 + *no_add_attrs = false;
108711 + return NULL_TREE;
108712 +}
108713 +
108714 +static struct attribute_spec user_attr = {
108715 + .name = "user",
108716 + .min_length = 0,
108717 + .max_length = 0,
108718 + .decl_required = false,
108719 + .type_required = false,
108720 + .function_type_required = false,
108721 + .handler = handle_user_attribute,
108722 +#if BUILDING_GCC_VERSION >= 4007
108723 + .affects_type_identity = true
108724 +#endif
108725 +};
108726 +
108727 +static void register_attributes(void *event_data, void *data)
108728 +{
108729 + register_attribute(&user_attr);
108730 +// register_attribute(&force_attr);
108731 +}
108732 +
108733 +static tree get_field_type(tree field)
108734 +{
108735 + return strip_array_types(TREE_TYPE(field));
108736 +}
108737 +
108738 +static bool is_userspace_type(tree type)
108739 +{
108740 + tree field;
108741 +
108742 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
108743 + tree fieldtype = get_field_type(field);
108744 + enum tree_code code = TREE_CODE(fieldtype);
108745 +
108746 + if (code == RECORD_TYPE || code == UNION_TYPE)
108747 + if (is_userspace_type(fieldtype))
108748 + return true;
108749 +
108750 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
108751 + return true;
108752 + }
108753 + return false;
108754 +}
108755 +
108756 +static void finish_type(void *event_data, void *data)
108757 +{
108758 + tree type = (tree)event_data;
108759 +
108760 + if (TYPE_USERSPACE(type))
108761 + return;
108762 +
108763 + if (is_userspace_type(type))
108764 + TYPE_USERSPACE(type) = 1;
108765 +}
108766 +
108767 +static void initialize(tree var)
108768 +{
108769 + basic_block bb;
108770 + gimple_stmt_iterator gsi;
108771 + tree initializer;
108772 + gimple init_stmt;
108773 +
108774 + // this is the original entry bb before the forced split
108775 + // TODO: check further BBs in case more splits occured before us
108776 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
108777 +
108778 + // first check if the variable is already initialized, warn otherwise
108779 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
108780 + gimple stmt = gsi_stmt(gsi);
108781 + tree rhs1;
108782 +
108783 + // we're looking for an assignment of a single rhs...
108784 + if (!gimple_assign_single_p(stmt))
108785 + continue;
108786 + rhs1 = gimple_assign_rhs1(stmt);
108787 +#if BUILDING_GCC_VERSION >= 4007
108788 + // ... of a non-clobbering expression...
108789 + if (TREE_CLOBBER_P(rhs1))
108790 + continue;
108791 +#endif
108792 + // ... to our variable...
108793 + if (gimple_get_lhs(stmt) != var)
108794 + continue;
108795 + // if it's an initializer then we're good
108796 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
108797 + return;
108798 + }
108799 +
108800 + // these aren't the 0days you're looking for
108801 +// inform(DECL_SOURCE_LOCATION(var), "userspace variable will be forcibly initialized");
108802 +
108803 + // build the initializer expression
108804 + initializer = build_constructor(TREE_TYPE(var), NULL);
108805 +
108806 + // build the initializer stmt
108807 + init_stmt = gimple_build_assign(var, initializer);
108808 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
108809 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
108810 + update_stmt(init_stmt);
108811 +}
108812 +
108813 +static unsigned int handle_function(void)
108814 +{
108815 + basic_block bb;
108816 + unsigned int ret = 0;
108817 + tree var;
108818 +
108819 +#if BUILDING_GCC_VERSION == 4005
108820 + tree vars;
108821 +#else
108822 + unsigned int i;
108823 +#endif
108824 +
108825 + // split the first bb where we can put the forced initializers
108826 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
108827 + if (dom_info_available_p(CDI_DOMINATORS))
108828 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
108829 +
108830 + // enumarate all local variables and forcibly initialize our targets
108831 +#if BUILDING_GCC_VERSION == 4005
108832 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
108833 + var = TREE_VALUE(vars);
108834 +#else
108835 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
108836 +#endif
108837 + tree type = TREE_TYPE(var);
108838 +
108839 + gcc_assert(DECL_P(var));
108840 + if (!auto_var_in_fn_p(var, current_function_decl))
108841 + continue;
108842 +
108843 + // only care about structure types
108844 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
108845 + continue;
108846 +
108847 + // if the type is of interest, examine the variable
108848 + if (TYPE_USERSPACE(type))
108849 + initialize(var);
108850 + }
108851 +
108852 + return ret;
108853 +}
108854 +
108855 +static struct gimple_opt_pass structleak_pass = {
108856 + .pass = {
108857 + .type = GIMPLE_PASS,
108858 + .name = "structleak",
108859 +#if BUILDING_GCC_VERSION >= 4008
108860 + .optinfo_flags = OPTGROUP_NONE,
108861 +#endif
108862 + .gate = NULL,
108863 + .execute = handle_function,
108864 + .sub = NULL,
108865 + .next = NULL,
108866 + .static_pass_number = 0,
108867 + .tv_id = TV_NONE,
108868 + .properties_required = PROP_cfg,
108869 + .properties_provided = 0,
108870 + .properties_destroyed = 0,
108871 + .todo_flags_start = 0,
108872 + .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
108873 + }
108874 +};
108875 +
108876 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
108877 +{
108878 + int i;
108879 + const char * const plugin_name = plugin_info->base_name;
108880 + const int argc = plugin_info->argc;
108881 + const struct plugin_argument * const argv = plugin_info->argv;
108882 + bool enable = true;
108883 +
108884 + struct register_pass_info structleak_pass_info = {
108885 + .pass = &structleak_pass.pass,
108886 + .reference_pass_name = "ssa",
108887 + .ref_pass_instance_number = 1,
108888 + .pos_op = PASS_POS_INSERT_AFTER
108889 + };
108890 +
108891 + if (!plugin_default_version_check(version, &gcc_version)) {
108892 + error(G_("incompatible gcc/plugin versions"));
108893 + return 1;
108894 + }
108895 +
108896 + if (strcmp(lang_hooks.name, "GNU C")) {
108897 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
108898 + enable = false;
108899 + }
108900 +
108901 + for (i = 0; i < argc; ++i) {
108902 + if (!strcmp(argv[i].key, "disable")) {
108903 + enable = false;
108904 + continue;
108905 + }
108906 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
108907 + }
108908 +
108909 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
108910 + if (enable) {
108911 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
108912 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
108913 + }
108914 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
108915 +
108916 + return 0;
108917 +}
108918 diff --git a/tools/lib/lk/Makefile b/tools/lib/lk/Makefile
108919 index 926cbf3..b8403e0 100644
108920 --- a/tools/lib/lk/Makefile
108921 +++ b/tools/lib/lk/Makefile
108922 @@ -10,7 +10,7 @@ LIB_OBJS += $(OUTPUT)debugfs.o
108923
108924 LIBFILE = liblk.a
108925
108926 -CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
108927 +CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
108928 EXTLIBS = -lpthread -lrt -lelf -lm
108929 ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
108930 ALL_LDFLAGS = $(LDFLAGS)
108931 diff --git a/tools/perf/Makefile b/tools/perf/Makefile
108932 index b0f164b..63c9f7d 100644
108933 --- a/tools/perf/Makefile
108934 +++ b/tools/perf/Makefile
108935 @@ -188,7 +188,7 @@ endif
108936
108937 ifndef PERF_DEBUG
108938 ifeq ($(call try-cc,$(SOURCE_HELLO),$(CFLAGS) -D_FORTIFY_SOURCE=2,-D_FORTIFY_SOURCE=2),y)
108939 - CFLAGS := $(CFLAGS) -D_FORTIFY_SOURCE=2
108940 + CFLAGS := $(CFLAGS) -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
108941 endif
108942 endif
108943
108944 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
108945 index 6789d78..4afd019e 100644
108946 --- a/tools/perf/util/include/asm/alternative-asm.h
108947 +++ b/tools/perf/util/include/asm/alternative-asm.h
108948 @@ -5,4 +5,7 @@
108949
108950 #define altinstruction_entry #
108951
108952 + .macro pax_force_retaddr rip=0, reload=0
108953 + .endm
108954 +
108955 #endif
108956 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
108957 index 96b919d..c49bb74 100644
108958 --- a/tools/perf/util/include/linux/compiler.h
108959 +++ b/tools/perf/util/include/linux/compiler.h
108960 @@ -18,4 +18,12 @@
108961 #define __force
108962 #endif
108963
108964 +#ifndef __size_overflow
108965 +# define __size_overflow(...)
108966 +#endif
108967 +
108968 +#ifndef __intentional_overflow
108969 +# define __intentional_overflow(...)
108970 +#endif
108971 +
108972 #endif
108973 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
108974 index 302681c..3bde377 100644
108975 --- a/virt/kvm/kvm_main.c
108976 +++ b/virt/kvm/kvm_main.c
108977 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
108978
108979 static cpumask_var_t cpus_hardware_enabled;
108980 static int kvm_usage_count = 0;
108981 -static atomic_t hardware_enable_failed;
108982 +static atomic_unchecked_t hardware_enable_failed;
108983
108984 struct kmem_cache *kvm_vcpu_cache;
108985 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
108986
108987 -static __read_mostly struct preempt_ops kvm_preempt_ops;
108988 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
108989 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
108990 +static struct preempt_ops kvm_preempt_ops = {
108991 + .sched_in = kvm_sched_in,
108992 + .sched_out = kvm_sched_out,
108993 +};
108994
108995 struct dentry *kvm_debugfs_dir;
108996
108997 @@ -766,7 +771,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
108998 /* We can read the guest memory with __xxx_user() later on. */
108999 if ((mem->slot < KVM_USER_MEM_SLOTS) &&
109000 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
109001 - !access_ok(VERIFY_WRITE,
109002 + !__access_ok(VERIFY_WRITE,
109003 (void __user *)(unsigned long)mem->userspace_addr,
109004 mem->memory_size)))
109005 goto out;
109006 @@ -1878,7 +1883,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
109007 return 0;
109008 }
109009
109010 -static struct file_operations kvm_vcpu_fops = {
109011 +static file_operations_no_const kvm_vcpu_fops __read_only = {
109012 .release = kvm_vcpu_release,
109013 .unlocked_ioctl = kvm_vcpu_ioctl,
109014 #ifdef CONFIG_COMPAT
109015 @@ -2561,7 +2566,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
109016 return 0;
109017 }
109018
109019 -static struct file_operations kvm_vm_fops = {
109020 +static file_operations_no_const kvm_vm_fops __read_only = {
109021 .release = kvm_vm_release,
109022 .unlocked_ioctl = kvm_vm_ioctl,
109023 #ifdef CONFIG_COMPAT
109024 @@ -2662,7 +2667,7 @@ out:
109025 return r;
109026 }
109027
109028 -static struct file_operations kvm_chardev_ops = {
109029 +static file_operations_no_const kvm_chardev_ops __read_only = {
109030 .unlocked_ioctl = kvm_dev_ioctl,
109031 .compat_ioctl = kvm_dev_ioctl,
109032 .llseek = noop_llseek,
109033 @@ -2688,7 +2693,7 @@ static void hardware_enable_nolock(void *junk)
109034
109035 if (r) {
109036 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
109037 - atomic_inc(&hardware_enable_failed);
109038 + atomic_inc_unchecked(&hardware_enable_failed);
109039 printk(KERN_INFO "kvm: enabling virtualization on "
109040 "CPU%d failed\n", cpu);
109041 }
109042 @@ -2742,10 +2747,10 @@ static int hardware_enable_all(void)
109043
109044 kvm_usage_count++;
109045 if (kvm_usage_count == 1) {
109046 - atomic_set(&hardware_enable_failed, 0);
109047 + atomic_set_unchecked(&hardware_enable_failed, 0);
109048 on_each_cpu(hardware_enable_nolock, NULL, 1);
109049
109050 - if (atomic_read(&hardware_enable_failed)) {
109051 + if (atomic_read_unchecked(&hardware_enable_failed)) {
109052 hardware_disable_all_nolock();
109053 r = -EBUSY;
109054 }
109055 @@ -3099,7 +3104,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
109056 kvm_arch_vcpu_put(vcpu);
109057 }
109058
109059 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
109060 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
109061 struct module *module)
109062 {
109063 int r;
109064 @@ -3146,7 +3151,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
109065 if (!vcpu_align)
109066 vcpu_align = __alignof__(struct kvm_vcpu);
109067 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
109068 - 0, NULL);
109069 + SLAB_USERCOPY, NULL);
109070 if (!kvm_vcpu_cache) {
109071 r = -ENOMEM;
109072 goto out_free_3;
109073 @@ -3156,9 +3161,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
109074 if (r)
109075 goto out_free;
109076
109077 + pax_open_kernel();
109078 kvm_chardev_ops.owner = module;
109079 kvm_vm_fops.owner = module;
109080 kvm_vcpu_fops.owner = module;
109081 + pax_close_kernel();
109082
109083 r = misc_register(&kvm_dev);
109084 if (r) {
109085 @@ -3168,9 +3175,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
109086
109087 register_syscore_ops(&kvm_syscore_ops);
109088
109089 - kvm_preempt_ops.sched_in = kvm_sched_in;
109090 - kvm_preempt_ops.sched_out = kvm_sched_out;
109091 -
109092 r = kvm_init_debug();
109093 if (r) {
109094 printk(KERN_ERR "kvm: create debugfs files failed\n");